@mapvx/web-kit 1.2.0-develop.12 → 1.2.0-develop.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/cjs/chunks/{DRACOLoader-B7myelzS.cjs → DRACOLoader-B1Y7vbrj.cjs} +2 -2
  2. package/dist/cjs/chunks/{GLTFLoader-Bhlg-PN9.cjs → GLTFLoader-DrrfQ0_F.cjs} +2 -2
  3. package/dist/cjs/chunks/{KTX2Loader-8oVInPCY.cjs → KTX2Loader-BoLi8knA.cjs} +2 -2
  4. package/dist/cjs/chunks/{accessibility-DQMGPqEF.cjs → accessibility-Djzp33ox.cjs} +2 -2
  5. package/dist/cjs/chunks/{back_arrow-BT38PaNs.cjs → back_arrow-BPoJQerl.cjs} +2 -2
  6. package/dist/cjs/chunks/{debug-hooks-DDHLlDXD.cjs → debug-hooks-CMF1BR-2.cjs} +2 -2
  7. package/dist/cjs/chunks/{dist-Dqt88Zla.cjs → dist-B06OgE5W.cjs} +2 -2
  8. package/dist/cjs/chunks/{dist-BsZPOLf6.cjs → dist-DII2Jcfe.cjs} +2 -2
  9. package/dist/cjs/chunks/{dist-CdHuaZdF.cjs → dist-_3MDeFq6.cjs} +2 -2
  10. package/dist/cjs/chunks/{expression-DOSBosTT.cjs → expression-Dq2zVyIz.cjs} +2 -2
  11. package/dist/cjs/chunks/{globe-viewport-CTph-zTi.cjs → globe-viewport-s9VMxxMl.cjs} +2 -2
  12. package/dist/cjs/chunks/{icon-origin-point-BQq_v8fl.cjs → icon-origin-point-B07J_RrC.cjs} +2 -2
  13. package/dist/cjs/chunks/{meshopt_decoder.module-Xc0iTpWr.cjs → meshopt_decoder.module-CedN2Fs4.cjs} +2 -2
  14. package/dist/cjs/chunks/{repeat_icon-DgZwJHQn.cjs → repeat_icon-BwwtBUqw.cjs} +2 -2
  15. package/dist/cjs/chunks/{rolldown-runtime-DCHM1mdG.cjs → rolldown-runtime-S4XI6pHy.cjs} +2 -2
  16. package/dist/cjs/chunks/{shader-type-decoder-ClUxS2uC.cjs → shader-type-decoder-CplMa6Zn.cjs} +2 -2
  17. package/dist/cjs/chunks/{styles-ap7q_oUC.cjs → styles-eVk3as0O.cjs} +2 -2
  18. package/dist/cjs/chunks/{three.module-CZrl_ZUv.cjs → three.module-TyjyfRuV.cjs} +2 -2
  19. package/dist/cjs/chunks/{walking-zHHQi5LZ.cjs → walking-BXmnNjav.cjs} +2 -2
  20. package/dist/cjs/chunks/{webgl-CmboLkDs.cjs → webgl-C3A9O7UB.cjs} +2 -2
  21. package/dist/cjs/chunks/{webgl-device-BXkaCOiH.cjs → webgl-device-CR_IOS1K.cjs} +2 -2
  22. package/dist/cjs/web-kit.cjs +5 -5
  23. package/dist/es/chunks/{DRACOLoader-CNpxxqVh.js → DRACOLoader-D0vU8-Oo.js} +2 -2
  24. package/dist/es/chunks/{GLTFLoader-CbnWtZLU.js → GLTFLoader-DQ80Aq6X.js} +2 -2
  25. package/dist/es/chunks/{KTX2Loader-DA7PMnUh.js → KTX2Loader-Dh9k32r5.js} +2 -2
  26. package/dist/es/chunks/{accessibility-D1G0e3jm.js → accessibility-BG8JCwcH.js} +2 -2
  27. package/dist/es/chunks/{back_arrow-DOtCNdHS.js → back_arrow-CF2VEGV0.js} +2 -2
  28. package/dist/es/chunks/{debug-hooks-Cd_b4Bki.js → debug-hooks-D_XQuFlb.js} +2 -2
  29. package/dist/es/chunks/{dist-DXAjwVD1.js → dist-B7VX6I_c.js} +2 -2
  30. package/dist/es/chunks/{dist-DXRF-lm8.js → dist-CQzG76mh.js} +2 -2
  31. package/dist/es/chunks/{dist-CrKfguaO.js → dist-CcWEArpE.js} +2 -2
  32. package/dist/es/chunks/{expression-6f6kc1i6.js → expression-C7yC7-03.js} +2 -2
  33. package/dist/es/chunks/{globe-viewport-Brth2aT0.js → globe-viewport-D0Ev9_5m.js} +2 -2
  34. package/dist/es/chunks/{icon-origin-point-DWIRQVPT.js → icon-origin-point-C23InZ8B.js} +2 -2
  35. package/dist/es/chunks/{meshopt_decoder.module-Ch7mmZHA.js → meshopt_decoder.module-CrrPmGGq.js} +2 -2
  36. package/dist/es/chunks/{repeat_icon-D5mfHUaL.js → repeat_icon-BIa50JSA.js} +2 -2
  37. package/dist/es/chunks/{rolldown-runtime-BptZgroH.js → rolldown-runtime-CDBfnOLQ.js} +2 -2
  38. package/dist/es/chunks/{shader-type-decoder-CQKC8yW9.js → shader-type-decoder-CmsRL_mF.js} +2 -2
  39. package/dist/es/chunks/{styles-Be_VFWZ4.js → styles-CU6-Ggto.js} +2 -2
  40. package/dist/es/chunks/{three.module-CrfgWCl8.js → three.module-Df6wkceO.js} +2 -2
  41. package/dist/es/chunks/{walking-BRSMxmlG.js → walking-BY9QNI9o.js} +2 -2
  42. package/dist/es/chunks/{webgl-device-6J3R62SY.js → webgl-device-CjfmtXLr.js} +2 -2
  43. package/dist/es/chunks/{webgl-ClUuONJn.js → webgl-y_Wz0lFW.js} +2 -2
  44. package/dist/es/web-kit.mjs +5 -5
  45. package/dist/iife/web-kit.iife.js +3 -3
  46. package/dist/sw/mvx-tiles-sw.js +82 -49
  47. package/dist/types/index.d.ts +22 -22
  48. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- /*! Web-kit v1.2.0-develop.12 | (c) 2026 MapVX */
2
- !function(){try{var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="9e84890b-892c-4d7c-a71a-2e8a285c883f",e._sentryDebugIdIdentifier="sentry-dbid-9e84890b-892c-4d7c-a71a-2e8a285c883f")}catch(e){}}();const e=require("./rolldown-runtime-DCHM1mdG.cjs"),t=require("./dist-Dqt88Zla.cjs"),n=require("./debug-hooks-DDHLlDXD.cjs"),r=require("./globe-viewport-CTph-zTi.cjs"),i=require("./expression-DOSBosTT.cjs"),a=require("./shader-type-decoder-ClUxS2uC.cjs"),o=require("./webgl-device-BXkaCOiH.cjs");async function s(e,t,n,r){return r._parse(e,t,n,r)}globalThis.probe||(globalThis.probe=a.probe);var A=new a.ProbeLog({id:"@probe.gl/log"});var l={};function c(e={}){const t=e.useLocalLibraries??e.core?.useLocalLibraries,n=e.CDN??e.core?.CDN,r=e.modules;return{...void 0!==t?{useLocalLibraries:t}:{},...void 0!==n?{CDN:n}:{},...void 0!==r?{modules:r}:{}}}async function u(e,t=null,r={},i=null){if(t){const a=r.modules?.[i||e];if(void 0!==a&&"string"!=typeof a)return a;e=function(e,t,r={},i=null){if(r?.core)throw new Error("loadLibrary: options.core must be pre-normalized");i=i||e;const a=r.modules||{};if("string"==typeof a[i])return a[i];if(!r.useLocalLibraries&&e.startsWith("http"))return e;if(!n.isBrowser)return`modules/${t}/dist/libs/${i}`;if(r.CDN)return n.assert$2(r.CDN.startsWith("http")),`${r.CDN}/${t}@${n.VERSION}/dist/libs/${i}`;return n.isWorker?`../src/libs/${i}`:`modules/${t}/src/libs/${i}`}(e,t,r,i)}return l[e]=l[e]||async function(e){if(e.endsWith("wasm"))return await async function(e){const{readFileAsArrayBuffer:t}=globalThis.loaders||{};if(n.isBrowser||!t||e.startsWith("http"))return await(await fetch(e)).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(!n.isBrowser){const{requireFromFile:n}=globalThis.loaders||{};try{const t=await(n?.(e));return t||!e.includes("/dist/libs/")?t:await(n?.(e.replace("/dist/libs/","/src/libs/")))}catch(t){if(e.includes("/dist/libs/"))try{return await(n?.(e.replace("/dist/libs/","/src/libs/")))}catch{}return console.error(t),null}}return n.isWorker?importScripts(e):function(e,t){if(!n.isBrowser){const{requireFromString:n}=globalThis.loaders||{};return n?.(e,t)}if(n.isWorker)return eval.call(globalThis,e),null;const r=document.createElement("script");r.id=t;try{r.appendChild(document.createTextNode(e))}catch(Gt){r.text=e}return document.body.appendChild(r),null}(await async function(e){const{readFileAsText:t}=globalThis.loaders||{};if(n.isBrowser||!t||e.startsWith("http"))return await(await fetch(e)).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),e)}(e),await l[e]}function f(e,t,n){if(e.byteLength<=t+n)return"";const r=new DataView(e);let i="";for(let a=0;a<n;a++)i+=String.fromCharCode(r.getUint8(t+a));return i}function d(e){try{return JSON.parse(e)}catch(t){throw new Error(`Failed to parse JSON from data starting with "${function(e,t=5){return"string"==typeof e?e.slice(0,t):ArrayBuffer.isView(e)?f(e.buffer,e.byteOffset,t):e instanceof ArrayBuffer?f(e,0,t):""}(e)}"`)}}function h(e,t){return n.assert$3(e>=0),n.assert$3(t>0),e+(t-1)&~(t-1)}function p(e,t,n){let r;if(e instanceof ArrayBuffer)r=new Uint8Array(e);else{const t=e.byteOffset,n=e.byteLength;r=new Uint8Array(e.buffer||e.arrayBuffer,t,n)}return t.set(r,n),n+h(r.byteLength,4)}var m={id:"request-scheduler",throttleRequests:!0,maxRequests:6,debounceTime:0},g=class{props;stats;activeRequestCount=0;requestQueue=[];requestMap=new Map;updateTimer=null;constructor(e={}){this.props={...m,...e},this.stats=new n.Stats({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},r=new Promise(e=>(n.resolve=e,n));return this.requestQueue.push(n),this.requestMap.set(e,r),this._issueNewRequests(),r}_issueRequest(e){const{handle:t,resolve:n}=e;let r=!1;const i=()=>{r||(r=!0,this.requestMap.delete(t),this.activeRequestCount--,null===this.updateTimer&&(this.updateTimer=setTimeout(()=>this._issueNewRequestsAsync(),0)))};return this.activeRequestCount++,n?n({done:i}):Promise.resolve({done:i})}_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)}},b=class e{static defaultOptions={core:{type:"auto",attributions:[],loadOptions:{},loaders:[]}};optionsType;options;data;url;loadOptions;fetch;_needsRefresh=!0;constructor(t,r,i){this.options=i?n.mergeOptions({...i,core:e.defaultOptions},r):{...r},this.data=t,this.url="string"==typeof t?n.resolvePath(t):"",this.loadOptions=function(e){const t={...e};e?.core&&(t.core={...e.core});const n="string"==typeof t.baseUri?t.baseUri:void 0,r="string"==typeof t.baseUrl?t.baseUrl:void 0;void 0===n&&void 0===r||(t.core||={},void 0===t.core.baseUrl&&(t.core.baseUrl=r??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;return n&&"function"!=typeof n?e=>fetch(e,n):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}};var v=class{static type="template";static testURL=e=>!1};function y(e,t){return new Promise((n,r)=>{let i=!1;function a(e){i||(i=!0,r(e))}function o(e){if(!i){i=!0;try{n(t(e))}catch(a){r(a)}}}try{e(o,a)?.then(o,a)}catch(s){a(s)}})}function x(e,t,n){const r=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),i=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:r}]},nullable:!1,metadata:i}}var _=["image/png","image/jpeg","image/gif","image/webp","image/avif","image/tiff","image/svg","image/svg+xml","image/bmp","image/vnd.microsoft.icon"],w=null;async function T(){return w||(w=async function(){const e=new Set;for(const t of _)(n.isBrowser$1?await I(t):E(t))&&e.add(t);return e}()),await w}var S={};function M(e){if(void 0===S[e]){const t=n.isBrowser$1?function(e){switch(e){case"image/avif":case"image/webp":return function(e){try{return 0===document.createElement("canvas").toDataURL(e).indexOf(`data:${e}`)}catch{return!1}}(e);default:return!0}}(e):E(e);S[e]=t}return S[e]}function E(e){const t=globalThis.loaders?.imageFormatsNode||["image/png","image/jpeg","image/gif"],n=globalThis.loaders?.parseImageNode;return Boolean(n)&&t.includes(e)}var C={"image/avif":"data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A=","image/webp":"data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA"};async function I(e){const t=C[e];return!t||await async function(e){return new Promise(t=>{const n=new Image;n.src=e,n.onload=()=>t(n.height>0),n.onerror=()=>t(!1)})}(t)}var R,P=class extends n.Vector{constructor(e=0,t=0){super(2),n.isArray(e)&&1===arguments.length?this.copy(e):(n.config.debug&&(n.checkNumber(e),n.checkNumber(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 n.config.debug&&(n.checkNumber(e.x),n.checkNumber(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 n.transformMat4$2(this,this,e),this.check()}transformAsVector(e){return n.vec2_transformMat4AsVector(this,this,e),this.check()}transformByMatrix3(e){return n.transformMat3$1(this,this,e),this.check()}transformByMatrix2x3(e){return n.transformMat2d(this,this,e),this.check()}transformByMatrix2(e){return n.transformMat2(this,this,e),this.check()}};!function(e){e[e.COL0ROW0=0]="COL0ROW0",e[e.COL0ROW1=1]="COL0ROW1",e[e.COL0ROW2=2]="COL0ROW2",e[e.COL1ROW0=3]="COL1ROW0",e[e.COL1ROW1=4]="COL1ROW1",e[e.COL1ROW2=5]="COL1ROW2",e[e.COL2ROW0=6]="COL2ROW0",e[e.COL2ROW1=7]="COL2ROW1",e[e.COL2ROW2=8]="COL2ROW2"}(R||(R={}));var N,k=Object.freeze([1,0,0,0,1,0,0,0,1]),L=class extends n.Matrix{static get IDENTITY(){return function(){B||(B=new L,Object.freeze(B));return B}()}static get ZERO(){return function(){N||(N=new L([0,0,0,0,0,0,0,0,0]),Object.freeze(N));return N}()}get ELEMENTS(){return 9}get RANK(){return 3}get INDICES(){return R}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(k)}fromObject(e){return this.check()}fromQuaternion(e){return r.fromQuat(this,e),this.check()}set(e,t,n,r,i,a,o,s,A){return this[0]=e,this[1]=t,this[2]=n,this[3]=r,this[4]=i,this[5]=a,this[6]=o,this[7]=s,this[8]=A,this.check()}setRowMajor(e,t,n,r,i,a,o,s,A){return this[0]=e,this[1]=r,this[2]=o,this[3]=t,this[4]=i,this[5]=s,this[6]=n,this[7]=a,this[8]=A,this.check()}determinant(){return r.determinant(this)}transpose(){return r.transpose(this,this),this.check()}invert(){return r.invert(this,this),this.check()}multiplyLeft(e){return r.multiply(this,e,this),this.check()}multiplyRight(e){return r.multiply(this,this,e),this.check()}rotate(e){return r.rotate(this,this,e),this.check()}scale(e){return Array.isArray(e)?r.scale(this,this,e):r.scale(this,this,[e,e]),this.check()}translate(e){return r.translate(this,this,e),this.check()}transform(e,t){let r;switch(e.length){case 2:r=n.transformMat3$1(t||[-0,-0],e,this);break;case 3:r=n.transformMat3(t||[-0,-0,-0],e,this);break;case 4:r=n.vec4_transformMat3(t||[-0,-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return n.checkVector(r,e.length),r}transformVector(e,t){return this.transform(e,t)}transformVector2(e,t){return this.transform(e,t)}transformVector3(e,t){return this.transform(e,t)}},B=null;var O={props:{},uniforms:{},bindings:{},name:"skin",bindingLayout:[{name:"skin",group:0},{name:"skinJointMatrices",group:0,visibility:1}],dependencies:[],source:"\nstruct skinUniforms {\n jointMatrix: array<mat4x4<f32>, 64>,\n};\n\n@group(0) @binding(auto) var<uniform> skin: skinUniforms;\n\n#ifdef HAS_INSTANCED_SKIN\n@group(0) @binding(auto) var<storage, read> skinJointMatrices: array<mat4x4<f32>>;\n\nfn getInstancedSkinMatrix(\n weights: vec4f,\n joints: vec4u,\n instanceIndex: u32,\n jointsPerInstance: u32\n) -> mat4x4<f32> {\n let firstJoint = instanceIndex * jointsPerInstance;\n return (weights.x * skinJointMatrices[firstJoint + joints.x])\n + (weights.y * skinJointMatrices[firstJoint + joints.y])\n + (weights.z * skinJointMatrices[firstJoint + joints.z])\n + (weights.w * skinJointMatrices[firstJoint + joints.w]);\n}\n#endif\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\n#ifdef HAS_INSTANCED_SKIN\nuniform highp sampler2D skinJointMatrices;\n\nmat4 getInstancedJointMatrix(uint jointIndex, uint instanceIndex) {\n int firstColumn = int(jointIndex * 4u);\n int row = int(instanceIndex);\n return mat4(\n texelFetch(skinJointMatrices, ivec2(firstColumn, row), 0),\n texelFetch(skinJointMatrices, ivec2(firstColumn + 1, row), 0),\n texelFetch(skinJointMatrices, ivec2(firstColumn + 2, row), 0),\n texelFetch(skinJointMatrices, ivec2(firstColumn + 3, row), 0)\n );\n}\n\nmat4 getInstancedSkinMatrix(\n vec4 weights,\n uvec4 joints,\n uint instanceIndex,\n uint jointsPerInstance\n) {\n return (weights.x * getInstancedJointMatrix(joints.x, instanceIndex))\n + (weights.y * getInstancedJointMatrix(joints.y, instanceIndex))\n + (weights.z * getInstancedJointMatrix(joints.z, instanceIndex))\n + (weights.w * getInstancedJointMatrix(joints.w, instanceIndex));\n}\n#endif\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:64},getUniforms:(e={},t)=>{const{jointMatrices:r,skinJointMatrices:i,scenegraphsFromGLTF:a,skinIndex:o=0,meshWorldMatrix:s}=e,A=i?{skinJointMatrices:i}:{};if(r)return{jointMatrix:F(r),...A};const l=a?.gltf?.skins?.[o];if(!l)return{jointMatrix:[],...A};const{inverseBindMatrices:c,joints:u,skeleton:f}=l,d=a.gltfNodeIndexToNodeMap,h=new Map,p=void 0===f?void 0:d?.get(f),m=p?[p]:a.scenes||[];for(const n of m)n.preorderTraversal((e,{worldMatrix:t})=>{h.set(e.id,t)});const g=s?new n.Matrix4(s).invert():null,b=new Float32Array(1024),v=c?.value;for(let y=0;y<Math.min(u.length,64);y++){const e=d?.get(u[y]);if(!e)continue;const t=h.get(e.id)||e.matrix,r=g?new n.Matrix4(g).multiplyRight(t):new n.Matrix4(t);v&&v.length>=16*(y+1)&&r.multiplyRight(new n.Matrix4(Array.from(v.slice(16*y,16*(y+1))))),b.set(r,16*y)}return{jointMatrix:b,...A}},uniformTypes:{jointMatrix:["mat4x4<f32>",64]}};function F(e){const t=new Float32Array(1024);return t.set(e instanceof Float32Array?e.subarray(0,t.length):e.slice(0,t.length)),t}var D={name:"gpuAnimation",props:{},uniforms:{},bindings:{},source:"\n#ifdef HAS_GPU_CROWD_ANIMATION\n@group(0) @binding(auto) var<storage, read> gpuAnimationFrames: array<vec4f>;\n\nfn readGPUAnimationFrame(frame: u32, offset: u32, frameStride: u32) -> vec4f {\n return gpuAnimationFrames[frame * frameStride + offset];\n}\n\nfn sampleGPUAnimationFrame(\n frames: vec4f,\n blend: vec4f,\n offset: u32,\n frameStride: u32\n) -> vec4f {\n let first = mix(\n readGPUAnimationFrame(u32(frames.x), offset, frameStride),\n readGPUAnimationFrame(u32(frames.y), offset, frameStride),\n frames.z\n );\n if (blend.w <= 0.0) {\n return first;\n }\n let second = mix(\n readGPUAnimationFrame(u32(blend.x), offset, frameStride),\n readGPUAnimationFrame(u32(blend.y), offset, frameStride),\n blend.z\n );\n return mix(first, second, blend.w);\n}\n\nfn sampleGPUAnimationMatrix(\n frames: vec4f,\n blend: vec4f,\n firstColumn: u32,\n frameStride: u32\n) -> mat4x4f {\n return mat4x4f(\n sampleGPUAnimationFrame(frames, blend, firstColumn, frameStride),\n sampleGPUAnimationFrame(frames, blend, firstColumn + 1u, frameStride),\n sampleGPUAnimationFrame(frames, blend, firstColumn + 2u, frameStride),\n sampleGPUAnimationFrame(frames, blend, firstColumn + 3u, frameStride)\n );\n}\n\nfn getGPUAnimatedSkinMatrix(\n weights: vec4f,\n joints: vec4u,\n frames: vec4f,\n blend: vec4f,\n frameStride: u32\n) -> mat4x4f {\n return weights.x * sampleGPUAnimationMatrix(frames, blend, 4u + joints.x * 4u, frameStride)\n + weights.y * sampleGPUAnimationMatrix(frames, blend, 4u + joints.y * 4u, frameStride)\n + weights.z * sampleGPUAnimationMatrix(frames, blend, 4u + joints.z * 4u, frameStride)\n + weights.w * sampleGPUAnimationMatrix(frames, blend, 4u + joints.w * 4u, frameStride);\n}\n#endif\n\n#ifdef HAS_INSTANCED_MORPH\n@group(0) @binding(auto) var<storage, read> gpuMorphTargets: array<vec4f>;\n\n#ifndef HAS_GPU_CROWD_ANIMATION\n@group(0) @binding(auto) var<storage, read> gpuMorphWeights: array<vec4f>;\n#endif\n\nfn getGPUCrowdMorphWeight(\n instanceIndex: u32,\n targetIndex: u32,\n targetCount: u32,\n jointsPerInstance: u32,\n frames: vec4f,\n blend: vec4f,\n frameStride: u32\n) -> f32 {\n#ifdef HAS_GPU_CROWD_ANIMATION\n let offset = 4u + jointsPerInstance * 4u + targetIndex;\n return sampleGPUAnimationFrame(frames, blend, offset, frameStride).x;\n#else\n let packedCount = (targetCount + 3u) / 4u;\n let packedWeights = gpuMorphWeights[instanceIndex * packedCount + targetIndex / 4u];\n return packedWeights[targetIndex % 4u];\n#endif\n}\n\nfn getGPUCrowdMorphDelta(\n instanceIndex: u32,\n vertexIndex: u32,\n attributeIndex: u32,\n vertexCount: u32,\n targetCount: u32,\n jointsPerInstance: u32,\n frames: vec4f,\n blend: vec4f,\n frameStride: u32\n) -> vec3f {\n var result = vec3f(0.0);\n for (var targetIndex = 0u; targetIndex < targetCount; targetIndex++) {\n let weight = getGPUCrowdMorphWeight(\n instanceIndex,\n targetIndex,\n targetCount,\n jointsPerInstance,\n frames,\n blend,\n frameStride\n );\n let offset = (targetIndex * 3u + attributeIndex) * vertexCount + vertexIndex;\n result += gpuMorphTargets[offset].xyz * weight;\n }\n return result;\n}\n#endif\n",vs:"\n#ifdef HAS_GPU_CROWD_ANIMATION\nuniform highp sampler2D gpuAnimationFrames;\n\nvec4 sampleGPUAnimationFrame(vec4 frames, vec4 blend, int offset) {\n vec4 first = mix(\n texelFetch(gpuAnimationFrames, ivec2(offset, int(frames.x)), 0),\n texelFetch(gpuAnimationFrames, ivec2(offset, int(frames.y)), 0),\n frames.z\n );\n if (blend.w <= 0.0) {\n return first;\n }\n vec4 second = mix(\n texelFetch(gpuAnimationFrames, ivec2(offset, int(blend.x)), 0),\n texelFetch(gpuAnimationFrames, ivec2(offset, int(blend.y)), 0),\n blend.z\n );\n return mix(first, second, blend.w);\n}\n\nmat4 sampleGPUAnimationMatrix(vec4 frames, vec4 blend, int firstColumn) {\n return mat4(\n sampleGPUAnimationFrame(frames, blend, firstColumn),\n sampleGPUAnimationFrame(frames, blend, firstColumn + 1),\n sampleGPUAnimationFrame(frames, blend, firstColumn + 2),\n sampleGPUAnimationFrame(frames, blend, firstColumn + 3)\n );\n}\n\nmat4 getGPUAnimatedSkinMatrix(vec4 weights, uvec4 joints, vec4 frames, vec4 blend) {\n return weights.x * sampleGPUAnimationMatrix(frames, blend, 4 + int(joints.x) * 4)\n + weights.y * sampleGPUAnimationMatrix(frames, blend, 4 + int(joints.y) * 4)\n + weights.z * sampleGPUAnimationMatrix(frames, blend, 4 + int(joints.z) * 4)\n + weights.w * sampleGPUAnimationMatrix(frames, blend, 4 + int(joints.w) * 4);\n}\n#endif\n\n#ifdef HAS_INSTANCED_MORPH\nuniform highp sampler2D gpuMorphTargets;\n\n#ifndef HAS_GPU_CROWD_ANIMATION\nuniform highp sampler2D gpuMorphWeights;\n#endif\n\nfloat getGPUCrowdMorphWeight(\n uint instanceIndex,\n uint targetIndex,\n uint jointsPerInstance,\n vec4 frames,\n vec4 blend\n) {\n#ifdef HAS_GPU_CROWD_ANIMATION\n int offset = 4 + int(jointsPerInstance) * 4 + int(targetIndex);\n return sampleGPUAnimationFrame(frames, blend, offset).x;\n#else\n vec4 packedWeights = texelFetch(\n gpuMorphWeights,\n ivec2(int(targetIndex / 4u), int(instanceIndex)),\n 0\n );\n return packedWeights[int(targetIndex % 4u)];\n#endif\n}\n\nvec3 getGPUCrowdMorphDelta(\n uint instanceIndex,\n uint vertexIndex,\n uint attributeIndex,\n uint targetCount,\n uint jointsPerInstance,\n vec4 frames,\n vec4 blend\n) {\n vec3 result = vec3(0.0);\n for (uint targetIndex = 0u; targetIndex < targetCount; targetIndex++) {\n float weight = getGPUCrowdMorphWeight(\n instanceIndex,\n targetIndex,\n jointsPerInstance,\n frames,\n blend\n );\n result += texelFetch(\n gpuMorphTargets,\n ivec2(int(vertexIndex), int(targetIndex * 3u + attributeIndex)),\n 0\n ).xyz * weight;\n }\n return result;\n}\n#endif\n",fs:"",bindingLayout:[{name:"gpuAnimationFrames",group:0,visibility:1},{name:"gpuMorphTargets",group:0,visibility:1},{name:"gpuMorphWeights",group:0,visibility:1}],getUniforms:(e={})=>e},U="#ifdef USE_IBL\nuniform samplerCube pbr_diffuseEnvSampler;\nuniform samplerCube pbr_specularEnvSampler;\nuniform sampler2D pbr_brdfLUT;\n#endif\n",V={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:U,fs:U},j="layout(std140) uniform pbrProjectionUniforms {\n mat4 modelViewProjectionMatrix;\n mat4 modelMatrix;\n mat4 normalMatrix;\n vec3 camera;\n} pbrProjection;\n",z={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:j,fs:j,getUniforms:e=>e,uniformTypes:{modelViewProjectionMatrix:"mat4x4<f32>",modelMatrix:"mat4x4<f32>",normalMatrix:"mat4x4<f32>",camera:"vec3<f32>"}},G={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,dispersion:0,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],bumpFactor:1,bumpMapEnabled:!1,diffuseTransmissionFactor:0,diffuseTransmissionMapEnabled:!1,diffuseTransmissionColorFactor:[1,1,1],diffuseTransmissionColorMapEnabled:!1,multiscatterColorFactor:[0,0,0],multiscatterColorMapEnabled:!1,scatterAnisotropy:0,bumpUVSet:0,bumpUVTransform:[1,0,0,0,1,0,0,0,1],diffuseTransmissionUVSet:0,diffuseTransmissionUVTransform:[1,0,0,0,1,0,0,0,1],diffuseTransmissionColorUVSet:0,diffuseTransmissionColorUVTransform:[1,0,0,0,1,0,0,0,1],multiscatterColorUVSet:0,multiscatterColorUVTransform:[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},{name:"pbr_bumpSampler",group:3},{name:"pbr_diffuseTransmissionSampler",group:3},{name:"pbr_diffuseTransmissionColorSampler",group:3},{name:"pbr_multiscatterColorSampler",group:3}],dependencies:[t.lighting,V,z],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 dispersion: 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 bumpFactor: f32,\n bumpMapEnabled: i32,\n diffuseTransmissionFactor: f32,\n diffuseTransmissionMapEnabled: i32,\n diffuseTransmissionColorFactor: vec3f,\n diffuseTransmissionColorMapEnabled: i32,\n multiscatterColorFactor: vec3f,\n multiscatterColorMapEnabled: i32,\n scatterAnisotropy: f32,\n\n bumpUVSet: i32,\n bumpUVTransform: mat3x3f,\n diffuseTransmissionUVSet: i32,\n diffuseTransmissionUVTransform: mat3x3f,\n diffuseTransmissionColorUVSet: i32,\n diffuseTransmissionColorUVTransform: mat3x3f,\n multiscatterColorUVSet: i32,\n multiscatterColorUVTransform: 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#ifdef HAS_BUMPMAP\n@group(3) @binding(auto) var pbr_bumpSampler: texture_2d<f32>;\n@group(3) @binding(auto) var pbr_bumpSamplerSampler: sampler;\n#endif\n#ifdef HAS_DIFFUSETRANSMISSIONMAP\n@group(3) @binding(auto) var pbr_diffuseTransmissionSampler: texture_2d<f32>;\n@group(3) @binding(auto) var pbr_diffuseTransmissionSamplerSampler: sampler;\n#endif\n#ifdef HAS_DIFFUSETRANSMISSIONCOLORMAP\n@group(3) @binding(auto) var pbr_diffuseTransmissionColorSampler: texture_2d<f32>;\n@group(3) @binding(auto) var pbr_diffuseTransmissionColorSamplerSampler: sampler;\n#endif\n#ifdef HAS_MULTISCATTERCOLORMAP\n@group(3) @binding(auto) var pbr_multiscatterColorSampler: texture_2d<f32>;\n@group(3) @binding(auto) var pbr_multiscatterColorSamplerSampler: 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 l: vec3f, // direction from the surface toward the current light\n h: vec3f // half vector between the current light and camera\n};\n\nconst M_PI = 3.141592653589793;\nconst c_MinRoughness = 0.04;\n\n// Widen sub-pixel specular lobes using the screen-space normal footprint.\n// This is geometric specular antialiasing: the normal variance is converted\n// into an additional squared perceptual roughness before evaluating BRDFs.\nfn widenSpecularRoughness(perceptualRoughness: f32, normal: vec3f) -> f32 {\n let normalDerivativeX = dpdx(normal);\n let normalDerivativeY = dpdy(normal);\n let normalVariance =\n dot(normalDerivativeX, normalDerivativeX) +\n dot(normalDerivativeY, normalDerivativeY);\n let kernelRoughnessSquared = min(2.0 * normalVariance, 1.0);\n return clamp(\n sqrt(perceptualRoughness * perceptualRoughness + kernelRoughnessSquared),\n c_MinRoughness,\n 1.0\n );\n}\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_dy, pos_dx);\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#ifdef HAS_BUMPMAP\n let bumpUV = getMaterialUV(pbrMaterial.bumpUVSet, pbrMaterial.bumpUVTransform);\n let bumpTexelSize = 1.0 / vec2f(textureDimensions(pbr_bumpSampler, 0));\n let bumpHeight = textureSample(pbr_bumpSampler, pbr_bumpSamplerSampler, bumpUV).r;\n let bumpGradient = vec2f(\n textureSample(\n pbr_bumpSampler,\n pbr_bumpSamplerSampler,\n bumpUV + vec2f(bumpTexelSize.x, 0.0)\n ).r - bumpHeight,\n textureSample(\n pbr_bumpSampler,\n pbr_bumpSamplerSampler,\n bumpUV + vec2f(0.0, bumpTexelSize.y)\n ).r - bumpHeight\n );\n n = normalize(n - pbrMaterial.bumpFactor *\n (tbn[0] * bumpGradient.x + tbn[1] * bumpGradient.y));\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#ifdef USE_SCENE_ENVIRONMENT\n let maximumMipLevel = max(pbrScene.environmentMipCount - 1.0, 0.0);\n let rotationSine = sin(pbrScene.environmentRotation);\n let rotationCosine = cos(pbrScene.environmentRotation);\n let environmentRotation = mat2x2f(\n vec2f(rotationCosine, rotationSine),\n vec2f(-rotationSine, rotationCosine)\n );\n let rotatedNormal = environmentRotation * n.xz;\n let rotatedReflection = environmentRotation * reflection.xz;\n let environmentNormal = vec3f(rotatedNormal.x, n.y, rotatedNormal.y);\n let environmentReflection = vec3f(rotatedReflection.x, reflection.y, rotatedReflection.y);\n#else\n let maximumMipLevel = 9.0;\n let environmentNormal = n;\n let environmentReflection = reflection;\n#endif\n let lod = pbrInfo.perceptualRoughness * maximumMipLevel;\n // retrieve a scale and bias to F0. See [1], Figure 3\n let brdfSample = textureSampleLevel(\n pbr_brdfLUT,\n pbr_brdfLUTSampler,\n vec2f(pbrInfo.NdotV, 1.0 - pbrInfo.perceptualRoughness),\n 0.0\n );\n let diffuseSample = textureSampleLevel(\n pbr_diffuseEnvSampler,\n pbr_diffuseEnvSamplerSampler,\n environmentNormal,\n 0.0\n );\n var specularSample = textureSampleLevel(\n pbr_specularEnvSampler,\n pbr_specularEnvSamplerSampler,\n environmentReflection,\n 0.0\n );\n#ifdef USE_TEX_LOD\n specularSample = textureSampleLevel(\n pbr_specularEnvSampler,\n pbr_specularEnvSamplerSampler,\n environmentReflection,\n lod\n );\n#endif\n\n#ifdef USE_SCENE_ENVIRONMENT\n let brdf = brdfSample.rgb;\n let diffuseLight = diffuseSample.rgb;\n let specularLight = specularSample.rgb;\n#else\n let brdf = SRGBtoLINEAR(brdfSample).rgb;\n let diffuseLight = SRGBtoLINEAR(diffuseSample).rgb;\n let specularLight = SRGBtoLINEAR(specularSample).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#ifdef USE_SCENE_ENVIRONMENT\n return (diffuse + specular) * max(pbrScene.environmentIntensity, 0.0);\n#else\n return diffuse + specular;\n#endif\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 encodeLinearSRGB(linearColor: vec3f) -> vec3f {\n let positiveColor = max(linearColor, vec3f(0.0));\n return select(\n positiveColor * 12.92,\n 1.055 * pow(positiveColor, vec3f(1.0 / 2.4)) - 0.055,\n positiveColor > vec3f(0.0031308)\n );\n}\n\nfn toneMapKhronosPBRNeutral(inputColor: vec3f) -> vec3f {\n let startCompression = 0.76;\n let darkestChannel = min(inputColor.r, min(inputColor.g, inputColor.b));\n let offset = select(\n 0.04,\n darkestChannel - 6.25 * darkestChannel * darkestChannel,\n darkestChannel < 0.08\n );\n var color = inputColor - vec3f(offset);\n let peak = maxComponent(color);\n if (peak < startCompression) {\n return color;\n }\n\n let compressionRange = 1.0 - startCompression;\n let compressedPeak = 1.0 - compressionRange * compressionRange /\n (peak + compressionRange - startCompression);\n color *= compressedPeak / max(peak, 0.0001);\n let desaturation = 1.0 - 1.0 / (0.15 * (peak - compressedPeak) + 1.0);\n return mix(color, vec3f(compressedPeak), desaturation);\n}\n\nfn applySceneColorManagement(sceneColor: vec3f) -> vec3f {\n#ifdef USE_SCENE_COLOR_MANAGEMENT\n var color = max(sceneColor, vec3f(0.0)) * max(pbrScene.exposure, 0.0);\n if (pbrScene.toneMapMode == 1) {\n color /= vec3f(1.0) + color;\n } else if (pbrScene.toneMapMode == 2) {\n color = toneMapKhronosPBRNeutral(color);\n } else if (pbrScene.toneMapMode == 3) {\n color = clamp(\n (color * (2.51 * color + 0.03)) / (color * (2.43 * color + 0.59) + 0.14),\n vec3f(0.0),\n vec3f(1.0)\n );\n }\n if (pbrScene.outputEncoding == 0) {\n return color;\n }\n return encodeLinearSRGB(color);\n#else\n return pow(max(sceneColor, vec3f(0.0)), vec3f(1.0 / 2.2));\n#endif\n}\n\nfn dielectricSchlick(reflectance: f32, cosine: f32) -> f32 {\n return reflectance + (1.0 - reflectance) * pow(clamp(1.0 - cosine, 0.0, 1.0), 5.0);\n}\n\nfn evaluateIridescenceSensitivity(opticalPathDifference: f32, phaseShift: vec3f) -> vec3f {\n let phase = 2.0 * M_PI * opticalPathDifference * 1.0e-9;\n let sensitivity = vec3f(5.4856e-13, 4.4201e-13, 5.2481e-13);\n let position = vec3f(1.6810e6, 1.7953e6, 2.2084e6);\n let variance = vec3f(4.3278e9, 9.3046e9, 6.6121e9);\n var xyz = sensitivity * sqrt(2.0 * M_PI * variance) *\n cos(position * phase + phaseShift) * exp(-phase * phase * variance);\n xyz.x += 9.7470e-14 * sqrt(2.0 * M_PI * 4.5282e9) *\n cos(2.2399e6 * phase + phaseShift.x) * exp(-4.5282e9 * phase * phase);\n xyz /= 1.0685e-7;\n return mat3x3f(\n vec3f(3.2404542, -0.9692660, 0.0556434),\n vec3f(-1.5371385, 1.8760108, -0.2040259),\n vec3f(-0.4985314, 0.0415560, 1.0572252)\n ) * xyz;\n}\n\nfn getIridescenceTint(\n iridescence: f32,\n thickness: f32,\n NdotV: f32,\n baseReflectance: vec3f\n) -> vec3f {\n if (iridescence <= 0.0 || thickness <= 0.0) {\n return baseReflectance;\n }\n\n let filmIor = max(pbrMaterial.iridescenceIor, 1.0);\n let sineSquared = (1.0 - NdotV * NdotV) / (filmIor * filmIor);\n let cosineSquared = 1.0 - sineSquared;\n if (cosineSquared <= 0.0) {\n return mix(baseReflectance, vec3f(1.0), iridescence);\n }\n let filmCosine = sqrt(cosineSquared);\n let firstInterfaceReflectance = dielectricSchlick(getDielectricF0(filmIor), NdotV);\n let transmittedEnergy = 1.0 - firstInterfaceReflectance;\n let squareRootReflectance = sqrt(clamp(baseReflectance, vec3f(0.0), vec3f(0.9999)));\n let baseIor = (vec3f(1.0) + squareRootReflectance) /\n (vec3f(1.0) - squareRootReflectance);\n var secondInterfaceF0 = (baseIor - vec3f(filmIor)) / (baseIor + vec3f(filmIor));\n secondInterfaceF0 *= secondInterfaceF0;\n let secondInterfaceReflectance = secondInterfaceF0 +\n (vec3f(1.0) - secondInterfaceF0) * pow(1.0 - filmCosine, 5.0);\n let phaseShift = vec3f(M_PI) + select(\n vec3f(0.0),\n vec3f(M_PI),\n baseIor < vec3f(filmIor)\n );\n let opticalPathDifference = 2.0 * filmIor * thickness * filmCosine;\n let combinedReflectance = clamp(\n firstInterfaceReflectance * secondInterfaceReflectance,\n vec3f(0.00001),\n vec3f(0.9999)\n );\n let recurringAmplitude = sqrt(combinedReflectance);\n let interfaceResponse = transmittedEnergy * transmittedEnergy * secondInterfaceReflectance /\n (vec3f(1.0) - combinedReflectance);\n var reflectedSpectrum = vec3f(firstInterfaceReflectance) + interfaceResponse;\n var harmonicAmplitude = interfaceResponse - vec3f(transmittedEnergy);\n for (var harmonic = 1; harmonic <= 2; harmonic++) {\n harmonicAmplitude *= recurringAmplitude;\n reflectedSpectrum += harmonicAmplitude * 2.0 * evaluateIridescenceSensitivity(\n f32(harmonic) * opticalPathDifference,\n f32(harmonic) * phaseShift\n );\n }\n return mix(baseReflectance, clamp(reflectedSpectrum, vec3f(0.0), vec3f(1.0)), 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\n// KHR_materials_volume_scatter is an active draft. This evaluates a local,\n// thickness-aware single-scattering approximation rather than random walk.\nfn getDiffuseTransmissionAttenuation(\n pbrInfo: PBRInfo,\n multiscatterColor: vec3f,\n thickness: f32\n) -> vec3f {\n let volumeAttenuation = getVolumeAttenuation(thickness);\n let scatteringStrength = maxComponent(multiscatterColor);\n if (thickness <= 0.0 || scatteringStrength <= 0.0001) {\n return volumeAttenuation;\n }\n\n let anisotropy = clamp(pbrMaterial.scatterAnisotropy, -0.95, 0.95);\n let scatteringCosine = clamp(dot(-pbrInfo.v, pbrInfo.l), -1.0, 1.0);\n let phaseDenominator = max(\n 1.0 + anisotropy * anisotropy - 2.0 * anisotropy * scatteringCosine,\n 0.0001\n );\n let phaseWeight = clamp(\n (1.0 - anisotropy * anisotropy) / pow(phaseDenominator, 1.5),\n 0.0,\n 4.0\n );\n let scatteringDepth = thickness / max(pbrMaterial.attenuationDistance, 0.0001);\n let scatteringProbability = 1.0 - exp(-scatteringDepth);\n let scatteringColor = clamp(multiscatterColor, vec3f(0.0), vec3f(1.0));\n return mix(\n volumeAttenuation,\n volumeAttenuation * mix(vec3f(1.0), scatteringColor * phaseWeight, scatteringColor),\n scatteringProbability\n );\n}\n\nfn calculateDiffuseTransmissionLight(\n pbrInfo: PBRInfo,\n lightColor: vec3f,\n diffuseTransmissionColor: vec3f,\n diffuseTransmission: f32,\n multiscatterColor: vec3f,\n thickness: f32\n) -> vec3f {\n let oppositeHemisphere = max(dot(-pbrInfo.n, pbrInfo.l), 0.0);\n if (oppositeHemisphere <= 0.0 || diffuseTransmission <= 0.0) {\n return vec3f(0.0);\n }\n\n let nonReflectedEnergy = vec3f(1.0) - clamp(pbrInfo.reflectance0, vec3f(0.0), vec3f(1.0));\n let attenuatedColor = getDiffuseTransmissionAttenuation(\n pbrInfo,\n multiscatterColor,\n thickness\n );\n return lightColor * diffuseTransmissionColor * nonReflectedEnergy *\n attenuatedColor * (diffuseTransmission * oppositeHemisphere / M_PI);\n}\n\n#ifdef USE_IBL\nfn calculateDiffuseTransmissionIBL(\n pbrInfo: PBRInfo,\n diffuseTransmissionColor: vec3f,\n diffuseTransmission: f32,\n multiscatterColor: vec3f,\n thickness: f32\n) -> vec3f {\n if (diffuseTransmission <= 0.0) {\n return vec3f(0.0);\n }\n\n#ifdef USE_SCENE_ENVIRONMENT\n let rotationSine = sin(pbrScene.environmentRotation);\n let rotationCosine = cos(pbrScene.environmentRotation);\n let environmentRotation = mat2x2f(\n vec2f(rotationCosine, rotationSine),\n vec2f(-rotationSine, rotationCosine)\n );\n let rotatedNormal = environmentRotation * -pbrInfo.n.xz;\n let oppositeNormal = vec3f(rotatedNormal.x, -pbrInfo.n.y, rotatedNormal.y);\n let environmentColor = textureSampleLevel(\n pbr_diffuseEnvSampler,\n pbr_diffuseEnvSamplerSampler,\n oppositeNormal,\n 0.0\n ).rgb * max(pbrScene.environmentIntensity, 0.0);\n#else\n let environmentColor = SRGBtoLINEAR(\n textureSampleLevel(pbr_diffuseEnvSampler, pbr_diffuseEnvSamplerSampler, -pbrInfo.n, 0.0)\n ).rgb;\n#endif\n let nonReflectedEnergy = vec3f(1.0) - clamp(pbrInfo.reflectance0, vec3f(0.0), vec3f(1.0));\n return environmentColor * diffuseTransmissionColor * nonReflectedEnergy *\n getDiffuseTransmissionAttenuation(pbrInfo, multiscatterColor, thickness) *\n diffuseTransmission * pbrMaterial.scaleIBLAmbient.x;\n}\n#endif\n\n#ifdef USE_TRANSMISSION_FRAMEBUFFER\nfn sampleTransmittedSceneColor(\n position: vec3f,\n normal: vec3f,\n viewDirection: vec3f,\n thickness: f32,\n perceptualRoughness: f32,\n indexOfRefraction: f32\n) -> vec3f {\n let refractionDirection = refract(\n -viewDirection,\n normal,\n 1.0 / max(indexOfRefraction, 1.0)\n );\n let refractedPosition = position + refractionDirection * thickness;\n let clipPosition = pbrScene.projectionMatrix *\n pbrScene.viewMatrix * vec4f(refractedPosition, 1.0);\n var textureCoordinate = clipPosition.xy / max(clipPosition.w, 0.0001) * 0.5 + 0.5;\n textureCoordinate.y = 1.0 - textureCoordinate.y;\n textureCoordinate = clamp(textureCoordinate, vec2f(0.001), vec2f(0.999));\n\n let blurRadius = perceptualRoughness * perceptualRoughness * 8.0 /\n max(pbrScene.framebufferSize, vec2f(1.0));\n var sceneColor = textureSampleLevel(\n pbr_transmissionFramebufferSampler,\n pbr_transmissionFramebufferSamplerSampler,\n textureCoordinate,\n 0.0\n ).rgb * 0.4;\n sceneColor += textureSampleLevel(\n pbr_transmissionFramebufferSampler,\n pbr_transmissionFramebufferSamplerSampler,\n textureCoordinate + vec2f(blurRadius.x, 0.0),\n 0.0\n ).rgb * 0.15;\n sceneColor += textureSampleLevel(\n pbr_transmissionFramebufferSampler,\n pbr_transmissionFramebufferSamplerSampler,\n textureCoordinate - vec2f(blurRadius.x, 0.0),\n 0.0\n ).rgb * 0.15;\n sceneColor += textureSampleLevel(\n pbr_transmissionFramebufferSampler,\n pbr_transmissionFramebufferSamplerSampler,\n textureCoordinate + vec2f(0.0, blurRadius.y),\n 0.0\n ).rgb * 0.15;\n sceneColor += textureSampleLevel(\n pbr_transmissionFramebufferSampler,\n pbr_transmissionFramebufferSamplerSampler,\n textureCoordinate - vec2f(0.0, blurRadius.y),\n 0.0\n ).rgb * 0.15;\n return max(sceneColor, vec3f(0.0));\n}\n\nfn getTransmittedSceneColor(\n position: vec3f,\n normal: vec3f,\n viewDirection: vec3f,\n thickness: f32,\n perceptualRoughness: f32\n) -> vec3f {\n if (pbrMaterial.dispersion <= 0.0) {\n return sampleTransmittedSceneColor(\n position,\n normal,\n viewDirection,\n thickness,\n perceptualRoughness,\n pbrMaterial.ior\n );\n }\n\n let halfSpread = (max(pbrMaterial.ior, 1.0) - 1.0) * 0.025 * pbrMaterial.dispersion;\n let indicesOfRefraction = max(\n vec3f(pbrMaterial.ior - halfSpread, pbrMaterial.ior, pbrMaterial.ior + halfSpread),\n vec3f(1.0)\n );\n return vec3f(\n sampleTransmittedSceneColor(\n position, normal, viewDirection, thickness, perceptualRoughness, indicesOfRefraction.r\n ).r,\n sampleTransmittedSceneColor(\n position, normal, viewDirection, thickness, perceptualRoughness, indicesOfRefraction.g\n ).g,\n sampleTransmittedSceneColor(\n position, normal, viewDirection, thickness, perceptualRoughness, indicesOfRefraction.b\n ).b\n );\n}\n#endif\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 basePBRInfo.l,\n basePBRInfo.h\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 alpha = max(sheenRoughness * sheenRoughness, 0.0001);\n let inverseAlpha = 1.0 / alpha;\n let sineSquared = max(1.0 - pbrInfo.NdotH * pbrInfo.NdotH, 0.0);\n let distribution = (2.0 + inverseAlpha) * pow(sineSquared, inverseAlpha * 0.5) /\n (2.0 * M_PI);\n let visibility = 1.0 / max(\n 4.0 * (pbrInfo.NdotL + pbrInfo.NdotV - pbrInfo.NdotL * pbrInfo.NdotV),\n 0.0001\n );\n return pbrInfo.NdotL * lightColor * sheenColor * distribution * visibility *\n (1.0 - pbrInfo.metalness);\n}\n\nfn calculateAnisotropicLightColor(\n pbrInfo: PBRInfo,\n lightColor: vec3f,\n anisotropyTangent: vec3f,\n anisotropyStrength: f32\n) -> vec3f {\n if (anisotropyStrength <= 0.0) {\n return calculateFinalColor(pbrInfo, lightColor);\n }\n\n let anisotropyBitangent = normalize(cross(pbrInfo.n, anisotropyTangent));\n let tangentRoughness = mix(\n pbrInfo.alphaRoughness,\n 1.0,\n anisotropyStrength * anisotropyStrength\n );\n let bitangentRoughness = clamp(pbrInfo.alphaRoughness, 0.001, 1.0);\n let roughnessProduct = tangentRoughness * bitangentRoughness;\n let distributionVector = vec3f(\n bitangentRoughness * dot(anisotropyTangent, pbrInfo.h),\n tangentRoughness * dot(anisotropyBitangent, pbrInfo.h),\n roughnessProduct * pbrInfo.NdotH\n );\n let distributionFactor = roughnessProduct /\n max(dot(distributionVector, distributionVector), 0.000001);\n let distribution = roughnessProduct * distributionFactor * distributionFactor / M_PI;\n let viewMask = pbrInfo.NdotL * length(vec3f(\n tangentRoughness * dot(anisotropyTangent, pbrInfo.v),\n bitangentRoughness * dot(anisotropyBitangent, pbrInfo.v),\n pbrInfo.NdotV\n ));\n let lightMask = pbrInfo.NdotV * length(vec3f(\n tangentRoughness * dot(anisotropyTangent, pbrInfo.l),\n bitangentRoughness * dot(anisotropyBitangent, pbrInfo.l),\n pbrInfo.NdotL\n ));\n let visibility = clamp(0.5 / max(viewMask + lightMask, 0.000001), 0.0, 1.0);\n let fresnel = specularReflection(pbrInfo);\n let diffuseContribution = (vec3f(1.0) - fresnel) * diffuse(pbrInfo);\n return pbrInfo.NdotL * lightColor *\n (diffuseContribution + fresnel * distribution * visibility);\n}\n\nfn getAnisotropicReflection(\n pbrInfo: PBRInfo,\n anisotropyTangent: vec3f,\n anisotropyStrength: f32\n) -> vec3f {\n if (anisotropyStrength <= 0.0) {\n return -normalize(reflect(pbrInfo.v, pbrInfo.n));\n }\n let anisotropyBitangent = normalize(cross(pbrInfo.n, anisotropyTangent));\n var anisotropicNormal = normalize(cross(anisotropyBitangent, pbrInfo.v));\n anisotropicNormal = normalize(cross(anisotropicNormal, anisotropyBitangent));\n let bend = anisotropyStrength * (1.0 - pbrInfo.perceptualRoughness);\n return -normalize(reflect(pbrInfo.v, normalize(mix(pbrInfo.n, anisotropicNormal, bend))));\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 var color = calculateAnisotropicLightColor(\n pbrInfo,\n lightColor,\n anisotropyTangent,\n anisotropyStrength\n );\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 (*pbrInfo).l = (*pbrInfo).n;\n (*pbrInfo).h = (*pbrInfo).n;\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 (*pbrInfo).l = l;\n (*pbrInfo).h = h;\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(vertexColor: 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 let diffuseTransmissionUV = getMaterialUV(\n pbrMaterial.diffuseTransmissionUVSet,\n pbrMaterial.diffuseTransmissionUVTransform\n );\n let diffuseTransmissionColorUV = getMaterialUV(\n pbrMaterial.diffuseTransmissionColorUVSet,\n pbrMaterial.diffuseTransmissionColorUVTransform\n );\n let multiscatterColorUV = getMaterialUV(\n pbrMaterial.multiscatterColorUVSet,\n pbrMaterial.multiscatterColorUVTransform\n );\n\n // The albedo may be defined from a base texture or a flat color\n var baseColor: vec4<f32> = pbrMaterial.baseColorFactor * vertexColor;\n #ifdef HAS_BASECOLORMAP\n baseColor = SRGBtoLINEAR(\n textureSample(pbr_baseColorSampler, pbr_baseColorSamplerSampler, baseColorUV)\n ) * pbrMaterial.baseColorFactor * vertexColor;\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 perceptualRoughness = widenSpecularRoughness(perceptualRoughness, n);\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.dispersion > 0.0001 ||\n pbrMaterial.transmissionMapEnabled != 0 ||\n pbrMaterial.transmissionFactor > 0.0001 ||\n pbrMaterial.diffuseTransmissionMapEnabled != 0 ||\n pbrMaterial.diffuseTransmissionColorMapEnabled != 0 ||\n pbrMaterial.diffuseTransmissionFactor > 0.0001 ||\n pbrMaterial.multiscatterColorMapEnabled != 0 ||\n maxComponent(pbrMaterial.multiscatterColorFactor) > 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 n\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>(applySceneColorManagement(color), 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 diffuseTransmission = clamp(pbrMaterial.diffuseTransmissionFactor, 0.0, 1.0);\n #ifdef HAS_DIFFUSETRANSMISSIONMAP\n if (pbrMaterial.diffuseTransmissionMapEnabled != 0) {\n diffuseTransmission *= textureSample(\n pbr_diffuseTransmissionSampler,\n pbr_diffuseTransmissionSamplerSampler,\n diffuseTransmissionUV\n ).a;\n }\n #endif\n diffuseTransmission *= (1.0 - metallic) * (1.0 - transmission);\n var diffuseTransmissionColor = pbrMaterial.diffuseTransmissionColorFactor;\n #ifdef HAS_DIFFUSETRANSMISSIONCOLORMAP\n if (pbrMaterial.diffuseTransmissionColorMapEnabled != 0) {\n diffuseTransmissionColor *= SRGBtoLINEAR(\n textureSample(\n pbr_diffuseTransmissionColorSampler,\n pbr_diffuseTransmissionColorSamplerSampler,\n diffuseTransmissionColorUV\n )\n ).rgb;\n }\n #endif\n var multiscatterColor = pbrMaterial.multiscatterColorFactor;\n #ifdef HAS_MULTISCATTERCOLORMAP\n if (pbrMaterial.multiscatterColorMapEnabled != 0) {\n multiscatterColor *= SRGBtoLINEAR(\n textureSample(\n pbr_multiscatterColorSampler,\n pbr_multiscatterColorSamplerSampler,\n multiscatterColorUV\n )\n ).rgb;\n }\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 clearcoatRoughness = widenSpecularRoughness(clearcoatRoughness, clearcoatNormal);\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 // 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 dielectricSpecularF0 = getIridescenceTint(\n iridescence,\n iridescenceThickness,\n NdotV,\n dielectricSpecularF0\n );\n var diffuseColor = baseColor.rgb * (vec3f(1.0) - dielectricSpecularF0);\n diffuseColor *= (1.0 - metallic) * (1.0 - transmission) * (1.0 - diffuseTransmission);\n var specularColor = mix(dielectricSpecularF0, baseColor.rgb, metallic);\n\n let clearcoatViewFresnel = dielectricSchlick(\n 0.04,\n clamp(abs(dot(clearcoatNormal, v)), 0.0, 1.0)\n );\n let sheenDirectionalAlbedo = maxComponent(sheenColor) *\n (0.157 + 0.343 * (1.0 - NdotV)) * (1.0 - sheenRoughness * 0.5);\n let baseLayerEnergy = (1.0 - clearcoatFactor * clearcoatViewFresnel) *\n (1.0 - clamp(sheenDirectionalAlbedo, 0.0, 1.0));\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 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 (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 color += calculateDiffuseTransmissionLight(\n pbrInfo,\n lighting_getDirectionalLight(i).color,\n diffuseTransmissionColor,\n diffuseTransmission,\n multiscatterColor,\n thickness\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 color += calculateDiffuseTransmissionLight(\n pbrInfo,\n lighting_getPointLight(i).color / attenuation,\n diffuseTransmissionColor,\n diffuseTransmission,\n multiscatterColor,\n thickness\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 color += calculateDiffuseTransmissionLight(\n pbrInfo,\n lighting_getSpotLight(i).color / attenuation,\n diffuseTransmissionColor,\n diffuseTransmission,\n multiscatterColor,\n thickness\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(\n pbrInfo,\n n,\n getAnisotropicReflection(pbrInfo, anisotropyTangent, anisotropyStrength)\n );\n color += calculateClearcoatIBLContribution(\n pbrInfo,\n clearcoatNormal,\n -normalize(reflect(v, clearcoatNormal)),\n clearcoatFactor,\n clearcoatRoughness\n );\n color += calculateDiffuseTransmissionIBL(\n pbrInfo,\n diffuseTransmissionColor,\n diffuseTransmission,\n multiscatterColor,\n thickness\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 #ifdef USE_TRANSMISSION_FRAMEBUFFER\n let dielectricFresnel = getDielectricF0(pbrMaterial.ior);\n let transmissionFresnel = dielectricFresnel +\n (1.0 - dielectricFresnel) * pow(1.0 - NdotV, 5.0);\n let transmittedColor = getTransmittedSceneColor(\n fragmentInputs.pbr_vPosition,\n n,\n v,\n thickness,\n perceptualRoughness\n );\n color += transmittedColor * getVolumeAttenuation(thickness) *\n transmission * (1.0 - transmissionFresnel);\n #else\n color = mix(color, color * getVolumeAttenuation(thickness), transmission);\n #endif\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 #ifdef USE_TRANSMISSION_FRAMEBUFFER\n let alpha = clamp(baseColor.a, 0.0, 1.0);\n #else\n let alpha = clamp(baseColor.a * (1.0 - transmission), 0.0, 1.0);\n #endif\n return vec4<f32>(applySceneColorManagement(color), 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 float dispersion;\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\n float bumpFactor;\n bool bumpMapEnabled;\n float diffuseTransmissionFactor;\n bool diffuseTransmissionMapEnabled;\n vec3 diffuseTransmissionColorFactor;\n bool diffuseTransmissionColorMapEnabled;\n vec3 multiscatterColorFactor;\n bool multiscatterColorMapEnabled;\n float scatterAnisotropy;\n\n int bumpUVSet;\n mat3 bumpUVTransform;\n int diffuseTransmissionUVSet;\n mat3 diffuseTransmissionUVTransform;\n int diffuseTransmissionColorUVSet;\n mat3 diffuseTransmissionColorUVTransform;\n int multiscatterColorUVSet;\n mat3 multiscatterColorUVTransform;\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#ifdef HAS_BUMPMAP\nuniform sampler2D pbr_bumpSampler;\n#endif\n#ifdef HAS_DIFFUSETRANSMISSIONMAP\nuniform sampler2D pbr_diffuseTransmissionSampler;\n#endif\n#ifdef HAS_DIFFUSETRANSMISSIONCOLORMAP\nuniform sampler2D pbr_diffuseTransmissionColorSampler;\n#endif\n#ifdef HAS_MULTISCATTERCOLORMAP\nuniform sampler2D pbr_multiscatterColorSampler;\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 vec3 l; // direction from the surface toward the current light\n vec3 h; // half vector between the current light and camera\n};\n\nconst float M_PI = 3.141592653589793;\nconst float c_MinRoughness = 0.04;\n\n// Widen sub-pixel specular lobes using the screen-space normal footprint.\n// This is geometric specular antialiasing: the normal variance is converted\n// into an additional squared perceptual roughness before evaluating BRDFs.\nfloat widenSpecularRoughness(float perceptualRoughness, vec3 normal)\n{\n vec3 normalDerivativeX = dFdx(normal);\n vec3 normalDerivativeY = dFdy(normal);\n float normalVariance =\n dot(normalDerivativeX, normalDerivativeX) +\n dot(normalDerivativeY, normalDerivativeY);\n float kernelRoughnessSquared = min(2.0 * normalVariance, 1.0);\n return clamp(\n sqrt(perceptualRoughness * perceptualRoughness + kernelRoughnessSquared),\n c_MinRoughness,\n 1.0\n );\n}\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#ifdef HAS_BUMPMAP\n vec2 bumpUV = getMaterialUV(pbrMaterial.bumpUVSet, pbrMaterial.bumpUVTransform);\n vec2 bumpTexelSize = 1.0 / vec2(textureSize(pbr_bumpSampler, 0));\n float bumpHeight = texture(pbr_bumpSampler, bumpUV).r;\n vec2 bumpGradient = vec2(\n texture(pbr_bumpSampler, bumpUV + vec2(bumpTexelSize.x, 0.0)).r - bumpHeight,\n texture(pbr_bumpSampler, bumpUV + vec2(0.0, bumpTexelSize.y)).r - bumpHeight\n );\n n = normalize(n - pbrMaterial.bumpFactor *\n (tbn[0] * bumpGradient.x + tbn[1] * bumpGradient.y));\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#ifdef USE_SCENE_ENVIRONMENT\n float maximumMipLevel = max(pbrScene.environmentMipCount - 1.0, 0.0);\n float rotationSine = sin(pbrScene.environmentRotation);\n float rotationCosine = cos(pbrScene.environmentRotation);\n mat2 environmentRotation = mat2(rotationCosine, rotationSine, -rotationSine, rotationCosine);\n vec3 environmentNormal = vec3(environmentRotation * n.xz, n.y).xzy;\n vec3 environmentReflection = vec3(environmentRotation * reflection.xz, reflection.y).xzy;\n#else\n float maximumMipLevel = 9.0;\n vec3 environmentNormal = n;\n vec3 environmentReflection = reflection;\n#endif\n float lod = pbrInfo.perceptualRoughness * maximumMipLevel;\n // retrieve a scale and bias to F0. See [1], Figure 3\n vec4 brdfSample = texture(pbr_brdfLUT,\n vec2(pbrInfo.NdotV, 1.0 - pbrInfo.perceptualRoughness));\n vec4 diffuseSample = texture(pbr_diffuseEnvSampler, environmentNormal);\n\n#ifdef USE_TEX_LOD\n vec4 specularSample = textureLod(pbr_specularEnvSampler, environmentReflection, lod);\n#else\n vec4 specularSample = texture(pbr_specularEnvSampler, environmentReflection);\n#endif\n\n#ifdef USE_SCENE_ENVIRONMENT\n vec3 brdf = brdfSample.rgb;\n vec3 diffuseLight = diffuseSample.rgb;\n vec3 specularLight = specularSample.rgb;\n#else\n vec3 brdf = SRGBtoLINEAR(brdfSample).rgb;\n vec3 diffuseLight = SRGBtoLINEAR(diffuseSample).rgb;\n vec3 specularLight = SRGBtoLINEAR(specularSample).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#ifdef USE_SCENE_ENVIRONMENT\n return (diffuse + specular) * max(pbrScene.environmentIntensity, 0.0);\n#else\n return diffuse + specular;\n#endif\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 encodeLinearSRGB(vec3 linearColor)\n{\n vec3 positiveColor = max(linearColor, vec3(0.0));\n return mix(\n positiveColor * 12.92,\n 1.055 * pow(positiveColor, vec3(1.0 / 2.4)) - 0.055,\n greaterThan(positiveColor, vec3(0.0031308))\n );\n}\n\nvec3 toneMapKhronosPBRNeutral(vec3 color)\n{\n const float startCompression = 0.76;\n float darkestChannel = min(color.r, min(color.g, color.b));\n float offset = darkestChannel < 0.08\n ? darkestChannel - 6.25 * darkestChannel * darkestChannel\n : 0.04;\n color -= vec3(offset);\n\n float peak = maxComponent(color);\n if (peak < startCompression) {\n return color;\n }\n\n float compressionRange = 1.0 - startCompression;\n float compressedPeak = 1.0 - compressionRange * compressionRange /\n (peak + compressionRange - startCompression);\n color *= compressedPeak / max(peak, 0.0001);\n float desaturation = 1.0 - 1.0 / (0.15 * (peak - compressedPeak) + 1.0);\n return mix(color, vec3(compressedPeak), desaturation);\n}\n\nvec3 applySceneColorManagement(vec3 sceneColor)\n{\n#ifdef USE_SCENE_COLOR_MANAGEMENT\n vec3 color = max(sceneColor, vec3(0.0)) * max(pbrScene.exposure, 0.0);\n if (pbrScene.toneMapMode == 1) {\n color /= vec3(1.0) + color;\n } else if (pbrScene.toneMapMode == 2) {\n color = toneMapKhronosPBRNeutral(color);\n } else if (pbrScene.toneMapMode == 3) {\n color = clamp(\n (color * (2.51 * color + 0.03)) / (color * (2.43 * color + 0.59) + 0.14),\n vec3(0.0),\n vec3(1.0)\n );\n }\n return pbrScene.outputEncoding == 0 ? color : encodeLinearSRGB(color);\n#else\n return pow(max(sceneColor, vec3(0.0)), vec3(1.0 / 2.2));\n#endif\n}\n\nfloat dielectricSchlick(float reflectance, float cosine)\n{\n return reflectance + (1.0 - reflectance) * pow(clamp(1.0 - cosine, 0.0, 1.0), 5.0);\n}\n\nvec3 evaluateIridescenceSensitivity(float opticalPathDifference, vec3 phaseShift)\n{\n float phase = 2.0 * M_PI * opticalPathDifference * 1.0e-9;\n vec3 sensitivity = vec3(5.4856e-13, 4.4201e-13, 5.2481e-13);\n vec3 position = vec3(1.6810e6, 1.7953e6, 2.2084e6);\n vec3 variance = vec3(4.3278e9, 9.3046e9, 6.6121e9);\n vec3 xyz = sensitivity * sqrt(2.0 * M_PI * variance) *\n cos(position * phase + phaseShift) * exp(-phase * phase * variance);\n xyz.x += 9.7470e-14 * sqrt(2.0 * M_PI * 4.5282e9) *\n cos(2.2399e6 * phase + phaseShift.x) * exp(-4.5282e9 * phase * phase);\n xyz /= 1.0685e-7;\n return mat3(\n 3.2404542, -0.9692660, 0.0556434,\n -1.5371385, 1.8760108, -0.2040259,\n -0.4985314, 0.0415560, 1.0572252\n ) * xyz;\n}\n\nvec3 getIridescenceTint(float iridescence, float thickness, float NdotV, vec3 baseReflectance)\n{\n if (iridescence <= 0.0 || thickness <= 0.0) {\n return baseReflectance;\n }\n\n float filmIor = max(pbrMaterial.iridescenceIor, 1.0);\n float sineSquared = (1.0 - NdotV * NdotV) / (filmIor * filmIor);\n float cosineSquared = 1.0 - sineSquared;\n if (cosineSquared <= 0.0) {\n return mix(baseReflectance, vec3(1.0), iridescence);\n }\n float filmCosine = sqrt(cosineSquared);\n float firstInterfaceReflectance = dielectricSchlick(getDielectricF0(filmIor), NdotV);\n float transmittedEnergy = 1.0 - firstInterfaceReflectance;\n\n vec3 baseIor = (vec3(1.0) + sqrt(clamp(baseReflectance, vec3(0.0), vec3(0.9999)))) /\n (vec3(1.0) - sqrt(clamp(baseReflectance, vec3(0.0), vec3(0.9999))));\n vec3 secondInterfaceF0 = (baseIor - vec3(filmIor)) / (baseIor + vec3(filmIor));\n secondInterfaceF0 *= secondInterfaceF0;\n vec3 secondInterfaceReflectance = secondInterfaceF0 +\n (vec3(1.0) - secondInterfaceF0) * pow(1.0 - filmCosine, 5.0);\n vec3 phaseShift = vec3(M_PI);\n phaseShift += mix(vec3(0.0), vec3(M_PI), lessThan(baseIor, vec3(filmIor)));\n float opticalPathDifference = 2.0 * filmIor * thickness * filmCosine;\n vec3 combinedReflectance = clamp(\n firstInterfaceReflectance * secondInterfaceReflectance,\n vec3(0.00001),\n vec3(0.9999)\n );\n vec3 recurringAmplitude = sqrt(combinedReflectance);\n vec3 interfaceResponse = transmittedEnergy * transmittedEnergy * secondInterfaceReflectance /\n (vec3(1.0) - combinedReflectance);\n vec3 reflectedSpectrum = vec3(firstInterfaceReflectance) + interfaceResponse;\n vec3 harmonicAmplitude = interfaceResponse - vec3(transmittedEnergy);\n for (int harmonic = 1; harmonic <= 2; harmonic++) {\n harmonicAmplitude *= recurringAmplitude;\n reflectedSpectrum += harmonicAmplitude * 2.0 * evaluateIridescenceSensitivity(\n float(harmonic) * opticalPathDifference,\n float(harmonic) * phaseShift\n );\n }\n return mix(baseReflectance, clamp(reflectedSpectrum, vec3(0.0), vec3(1.0)), 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\n// KHR_materials_volume_scatter is an active draft. This evaluates a local,\n// thickness-aware single-scattering approximation rather than random walk.\nvec3 getDiffuseTransmissionAttenuation(\n PBRInfo pbrInfo,\n vec3 multiscatterColor,\n float thickness\n)\n{\n vec3 volumeAttenuation = getVolumeAttenuation(thickness);\n float scatteringStrength = maxComponent(multiscatterColor);\n if (thickness <= 0.0 || scatteringStrength <= 0.0001) {\n return volumeAttenuation;\n }\n\n float anisotropy = clamp(pbrMaterial.scatterAnisotropy, -0.95, 0.95);\n float scatteringCosine = clamp(dot(-pbrInfo.v, pbrInfo.l), -1.0, 1.0);\n float phaseDenominator = max(\n 1.0 + anisotropy * anisotropy - 2.0 * anisotropy * scatteringCosine,\n 0.0001\n );\n float phaseWeight = clamp(\n (1.0 - anisotropy * anisotropy) / pow(phaseDenominator, 1.5),\n 0.0,\n 4.0\n );\n float scatteringDepth = thickness / max(pbrMaterial.attenuationDistance, 0.0001);\n float scatteringProbability = 1.0 - exp(-scatteringDepth);\n vec3 scatteringColor = clamp(multiscatterColor, vec3(0.0), vec3(1.0));\n return mix(\n volumeAttenuation,\n volumeAttenuation * mix(vec3(1.0), scatteringColor * phaseWeight, scatteringColor),\n scatteringProbability\n );\n}\n\nvec3 calculateDiffuseTransmissionLight(\n PBRInfo pbrInfo,\n vec3 lightColor,\n vec3 diffuseTransmissionColor,\n float diffuseTransmission,\n vec3 multiscatterColor,\n float thickness\n)\n{\n float oppositeHemisphere = max(dot(-pbrInfo.n, pbrInfo.l), 0.0);\n if (oppositeHemisphere <= 0.0 || diffuseTransmission <= 0.0) {\n return vec3(0.0);\n }\n\n vec3 nonReflectedEnergy = vec3(1.0) - clamp(pbrInfo.reflectance0, vec3(0.0), vec3(1.0));\n vec3 attenuatedColor = getDiffuseTransmissionAttenuation(\n pbrInfo,\n multiscatterColor,\n thickness\n );\n return lightColor * diffuseTransmissionColor * nonReflectedEnergy *\n attenuatedColor * (diffuseTransmission * oppositeHemisphere / M_PI);\n}\n\n#ifdef USE_IBL\nvec3 calculateDiffuseTransmissionIBL(\n PBRInfo pbrInfo,\n vec3 diffuseTransmissionColor,\n float diffuseTransmission,\n vec3 multiscatterColor,\n float thickness\n)\n{\n if (diffuseTransmission <= 0.0) {\n return vec3(0.0);\n }\n\n#ifdef USE_SCENE_ENVIRONMENT\n float rotationSine = sin(pbrScene.environmentRotation);\n float rotationCosine = cos(pbrScene.environmentRotation);\n mat2 environmentRotation = mat2(rotationCosine, rotationSine, -rotationSine, rotationCosine);\n vec3 oppositeNormal = vec3(environmentRotation * -pbrInfo.n.xz, -pbrInfo.n.y).xzy;\n vec3 environmentColor = texture(pbr_diffuseEnvSampler, oppositeNormal).rgb *\n max(pbrScene.environmentIntensity, 0.0);\n#else\n vec3 environmentColor = SRGBtoLINEAR(texture(pbr_diffuseEnvSampler, -pbrInfo.n)).rgb;\n#endif\n vec3 nonReflectedEnergy = vec3(1.0) - clamp(pbrInfo.reflectance0, vec3(0.0), vec3(1.0));\n return environmentColor * diffuseTransmissionColor * nonReflectedEnergy *\n getDiffuseTransmissionAttenuation(pbrInfo, multiscatterColor, thickness) *\n diffuseTransmission * pbrMaterial.scaleIBLAmbient.x;\n}\n#endif\n\n#ifdef USE_TRANSMISSION_FRAMEBUFFER\nvec3 sampleTransmittedSceneColor(\n vec3 position,\n vec3 normal,\n vec3 viewDirection,\n float thickness,\n float perceptualRoughness,\n float indexOfRefraction\n)\n{\n vec3 refractionDirection = refract(\n -viewDirection,\n normal,\n 1.0 / max(indexOfRefraction, 1.0)\n );\n vec3 refractedPosition = position + refractionDirection * thickness;\n vec4 clipPosition = pbrScene.projectionMatrix *\n pbrScene.viewMatrix * vec4(refractedPosition, 1.0);\n vec2 textureCoordinate = clipPosition.xy / max(clipPosition.w, 0.0001) * 0.5 + 0.5;\n textureCoordinate = clamp(textureCoordinate, vec2(0.001), vec2(0.999));\n\n vec2 blurRadius = perceptualRoughness * perceptualRoughness * 8.0 /\n max(pbrScene.framebufferSize, vec2(1.0));\n vec3 sceneColor = texture(pbr_transmissionFramebufferSampler, textureCoordinate).rgb * 0.4;\n sceneColor += texture(\n pbr_transmissionFramebufferSampler,\n textureCoordinate + vec2(blurRadius.x, 0.0)\n ).rgb * 0.15;\n sceneColor += texture(\n pbr_transmissionFramebufferSampler,\n textureCoordinate - vec2(blurRadius.x, 0.0)\n ).rgb * 0.15;\n sceneColor += texture(\n pbr_transmissionFramebufferSampler,\n textureCoordinate + vec2(0.0, blurRadius.y)\n ).rgb * 0.15;\n sceneColor += texture(\n pbr_transmissionFramebufferSampler,\n textureCoordinate - vec2(0.0, blurRadius.y)\n ).rgb * 0.15;\n return max(sceneColor, vec3(0.0));\n}\n\nvec3 getTransmittedSceneColor(\n vec3 position,\n vec3 normal,\n vec3 viewDirection,\n float thickness,\n float perceptualRoughness\n)\n{\n if (pbrMaterial.dispersion <= 0.0) {\n return sampleTransmittedSceneColor(\n position,\n normal,\n viewDirection,\n thickness,\n perceptualRoughness,\n pbrMaterial.ior\n );\n }\n\n float halfSpread = (max(pbrMaterial.ior, 1.0) - 1.0) * 0.025 * pbrMaterial.dispersion;\n vec3 indicesOfRefraction = max(\n vec3(pbrMaterial.ior - halfSpread, pbrMaterial.ior, pbrMaterial.ior + halfSpread),\n vec3(1.0)\n );\n return vec3(\n sampleTransmittedSceneColor(\n position, normal, viewDirection, thickness, perceptualRoughness, indicesOfRefraction.r\n ).r,\n sampleTransmittedSceneColor(\n position, normal, viewDirection, thickness, perceptualRoughness, indicesOfRefraction.g\n ).g,\n sampleTransmittedSceneColor(\n position, normal, viewDirection, thickness, perceptualRoughness, indicesOfRefraction.b\n ).b\n );\n}\n#endif\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 basePBRInfo.l,\n basePBRInfo.h\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 alpha = max(sheenRoughness * sheenRoughness, 0.0001);\n float inverseAlpha = 1.0 / alpha;\n float sineSquared = max(1.0 - pbrInfo.NdotH * pbrInfo.NdotH, 0.0);\n float distribution = (2.0 + inverseAlpha) * pow(sineSquared, inverseAlpha * 0.5) /\n (2.0 * M_PI);\n float visibility = 1.0 / max(\n 4.0 * (pbrInfo.NdotL + pbrInfo.NdotV - pbrInfo.NdotL * pbrInfo.NdotV),\n 0.0001\n );\n return pbrInfo.NdotL * lightColor * sheenColor * distribution * visibility *\n (1.0 - pbrInfo.metalness);\n}\n\nvec3 calculateAnisotropicLightColor(\n PBRInfo pbrInfo,\n vec3 lightColor,\n vec3 anisotropyTangent,\n float anisotropyStrength\n) {\n if (anisotropyStrength <= 0.0) {\n return calculateFinalColor(pbrInfo, lightColor);\n }\n\n vec3 anisotropyBitangent = normalize(cross(pbrInfo.n, anisotropyTangent));\n float tangentRoughness = mix(\n pbrInfo.alphaRoughness,\n 1.0,\n anisotropyStrength * anisotropyStrength\n );\n float bitangentRoughness = clamp(pbrInfo.alphaRoughness, 0.001, 1.0);\n float roughnessProduct = tangentRoughness * bitangentRoughness;\n vec3 distributionVector = vec3(\n bitangentRoughness * dot(anisotropyTangent, pbrInfo.h),\n tangentRoughness * dot(anisotropyBitangent, pbrInfo.h),\n roughnessProduct * pbrInfo.NdotH\n );\n float distributionFactor = roughnessProduct /\n max(dot(distributionVector, distributionVector), 0.000001);\n float distribution = roughnessProduct * distributionFactor * distributionFactor / M_PI;\n float viewMask = pbrInfo.NdotL * length(vec3(\n tangentRoughness * dot(anisotropyTangent, pbrInfo.v),\n bitangentRoughness * dot(anisotropyBitangent, pbrInfo.v),\n pbrInfo.NdotV\n ));\n float lightMask = pbrInfo.NdotV * length(vec3(\n tangentRoughness * dot(anisotropyTangent, pbrInfo.l),\n bitangentRoughness * dot(anisotropyBitangent, pbrInfo.l),\n pbrInfo.NdotL\n ));\n float visibility = clamp(0.5 / max(viewMask + lightMask, 0.000001), 0.0, 1.0);\n vec3 fresnel = specularReflection(pbrInfo);\n vec3 diffuseContribution = (vec3(1.0) - fresnel) * diffuse(pbrInfo);\n return pbrInfo.NdotL * lightColor *\n (diffuseContribution + fresnel * distribution * visibility);\n}\n\nvec3 getAnisotropicReflection(PBRInfo pbrInfo, vec3 anisotropyTangent, float anisotropyStrength)\n{\n if (anisotropyStrength <= 0.0) {\n return -normalize(reflect(pbrInfo.v, pbrInfo.n));\n }\n vec3 anisotropyBitangent = normalize(cross(pbrInfo.n, anisotropyTangent));\n vec3 anisotropicNormal = normalize(cross(anisotropyBitangent, pbrInfo.v));\n anisotropicNormal = normalize(cross(anisotropicNormal, anisotropyBitangent));\n float bend = anisotropyStrength * (1.0 - pbrInfo.perceptualRoughness);\n return -normalize(reflect(pbrInfo.v, normalize(mix(pbrInfo.n, anisotropicNormal, bend))));\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 vec3 color = calculateAnisotropicLightColor(\n pbrInfo,\n lightColor,\n anisotropyTangent,\n anisotropyStrength\n );\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 pbrInfo.l = pbrInfo.n;\n pbrInfo.h = pbrInfo.n;\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 pbrInfo.l = l;\n pbrInfo.h = h;\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 vertexColor)\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 vec2 diffuseTransmissionUV = getMaterialUV(\n pbrMaterial.diffuseTransmissionUVSet,\n pbrMaterial.diffuseTransmissionUVTransform\n );\n vec2 diffuseTransmissionColorUV = getMaterialUV(\n pbrMaterial.diffuseTransmissionColorUVSet,\n pbrMaterial.diffuseTransmissionColorUVTransform\n );\n vec2 multiscatterColorUV = getMaterialUV(\n pbrMaterial.multiscatterColorUVSet,\n pbrMaterial.multiscatterColorUVTransform\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)) *\n pbrMaterial.baseColorFactor * vertexColor;\n#else\n vec4 baseColor = pbrMaterial.baseColorFactor * vertexColor;\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 perceptualRoughness = widenSpecularRoughness(perceptualRoughness, n);\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.dispersion > 0.0001 ||\n pbrMaterial.transmissionMapEnabled ||\n pbrMaterial.transmissionFactor > 0.0001 ||\n pbrMaterial.diffuseTransmissionMapEnabled ||\n pbrMaterial.diffuseTransmissionColorMapEnabled ||\n pbrMaterial.diffuseTransmissionFactor > 0.0001 ||\n pbrMaterial.multiscatterColorMapEnabled ||\n maxComponent(pbrMaterial.multiscatterColorFactor) > 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 n\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(applySceneColorManagement(color), 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 diffuseTransmission = clamp(pbrMaterial.diffuseTransmissionFactor, 0.0, 1.0);\n#ifdef HAS_DIFFUSETRANSMISSIONMAP\n if (pbrMaterial.diffuseTransmissionMapEnabled) {\n diffuseTransmission *= texture(pbr_diffuseTransmissionSampler, diffuseTransmissionUV).a;\n }\n#endif\n diffuseTransmission *= (1.0 - metallic) * (1.0 - transmission);\n vec3 diffuseTransmissionColor = pbrMaterial.diffuseTransmissionColorFactor;\n#ifdef HAS_DIFFUSETRANSMISSIONCOLORMAP\n if (pbrMaterial.diffuseTransmissionColorMapEnabled) {\n diffuseTransmissionColor *= SRGBtoLINEAR(\n texture(pbr_diffuseTransmissionColorSampler, diffuseTransmissionColorUV)\n ).rgb;\n }\n#endif\n vec3 multiscatterColor = pbrMaterial.multiscatterColorFactor;\n#ifdef HAS_MULTISCATTERCOLORMAP\n if (pbrMaterial.multiscatterColorMapEnabled) {\n multiscatterColor *= SRGBtoLINEAR(\n texture(pbr_multiscatterColorSampler, multiscatterColorUV)\n ).rgb;\n }\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 clearcoatRoughness = widenSpecularRoughness(clearcoatRoughness, clearcoatNormal);\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 // 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 dielectricSpecularF0 = getIridescenceTint(\n iridescence,\n iridescenceThickness,\n NdotV,\n dielectricSpecularF0\n );\n vec3 diffuseColor = baseColor.rgb * (vec3(1.0) - dielectricSpecularF0);\n diffuseColor *= (1.0 - metallic) * (1.0 - transmission) * (1.0 - diffuseTransmission);\n vec3 specularColor = mix(dielectricSpecularF0, baseColor.rgb, metallic);\n\n float clearcoatViewFresnel = dielectricSchlick(\n 0.04,\n clamp(abs(dot(clearcoatNormal, v)), 0.0, 1.0)\n );\n float sheenDirectionalAlbedo = maxComponent(sheenColor) *\n (0.157 + 0.343 * (1.0 - NdotV)) * (1.0 - sheenRoughness * 0.5);\n float baseLayerEnergy = (1.0 - clearcoatFactor * clearcoatViewFresnel) *\n (1.0 - clamp(sheenDirectionalAlbedo, 0.0, 1.0));\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\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 color += calculateDiffuseTransmissionLight(\n pbrInfo,\n lighting_getDirectionalLight(i).color,\n diffuseTransmissionColor,\n diffuseTransmission,\n multiscatterColor,\n thickness\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 color += calculateDiffuseTransmissionLight(\n pbrInfo,\n lighting_getPointLight(i).color / attenuation,\n diffuseTransmissionColor,\n diffuseTransmission,\n multiscatterColor,\n thickness\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 color += calculateDiffuseTransmissionLight(\n pbrInfo,\n lighting_getSpotLight(i).color / attenuation,\n diffuseTransmissionColor,\n diffuseTransmission,\n multiscatterColor,\n thickness\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(\n pbrInfo,\n n,\n getAnisotropicReflection(pbrInfo, anisotropyTangent, anisotropyStrength)\n );\n color += calculateClearcoatIBLContribution(\n pbrInfo,\n clearcoatNormal,\n -normalize(reflect(v, clearcoatNormal)),\n clearcoatFactor,\n clearcoatRoughness\n );\n color += calculateDiffuseTransmissionIBL(\n pbrInfo,\n diffuseTransmissionColor,\n diffuseTransmission,\n multiscatterColor,\n thickness\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#ifdef USE_TRANSMISSION_FRAMEBUFFER\n float dielectricFresnel = getDielectricF0(pbrMaterial.ior);\n float transmissionFresnel = dielectricFresnel +\n (1.0 - dielectricFresnel) * pow(1.0 - NdotV, 5.0);\n vec3 transmittedColor = getTransmittedSceneColor(\n pbr_vPosition,\n n,\n v,\n thickness,\n perceptualRoughness\n );\n color += transmittedColor * getVolumeAttenuation(thickness) *\n transmission * (1.0 - transmissionFresnel);\n#else\n color = mix(color, color * getVolumeAttenuation(thickness), transmission);\n#endif\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#ifdef USE_TRANSMISSION_FRAMEBUFFER\n float alpha = clamp(baseColor.a, 0.0, 1.0);\n#else\n float alpha = clamp(baseColor.a * (1.0 - transmission), 0.0, 1.0);\n#endif\n return vec4(applySceneColorManagement(color), 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,HAS_BUMPMAP:!1,HAS_DIFFUSETRANSMISSIONMAP:!1,HAS_DIFFUSETRANSMISSIONCOLORMAP:!1,HAS_MULTISCATTERCOLORMAP:!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",dispersion:"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>",bumpFactor:"f32",bumpMapEnabled:"i32",diffuseTransmissionFactor:"f32",diffuseTransmissionMapEnabled:"i32",diffuseTransmissionColorFactor:"vec3<f32>",diffuseTransmissionColorMapEnabled:"i32",multiscatterColorFactor:"vec3<f32>",multiscatterColorMapEnabled:"i32",scatterAnisotropy:"f32",bumpUVSet:"i32",bumpUVTransform:"mat3x3<f32>",diffuseTransmissionUVSet:"i32",diffuseTransmissionUVTransform:"mat3x3<f32>",diffuseTransmissionColorUVSet:"i32",diffuseTransmissionColorUVTransform:"mat3x3<f32>",multiscatterColorUVSet:"i32",multiscatterColorUVTransform:"mat3x3<f32>"}},H=class{name;playing=!0;speed=1;startTime=0;constructor(e={}){this.name=e.name||"unnamed",Object.assign(this,e)}setTime(e){if(!this.playing)return;const t=(e/1e3-this.startTime)*this.speed;this.applyTime(t)}},q=class{clips;animations;constructor(e){this.clips=e,this.animations=e}animate(e){a.log.warn(`${this.constructor.name}#animate is deprecated. Use ${this.constructor.name}#setTime instead`)(),this.setTime(e)}setTime(e){this.clips.forEach(t=>t.setTime(e))}getAnimations(){return this.clips}};function Q(e,t,n){const r=W(e),i=W(t);let a=r.reduce((e,t,n)=>e+t*i[n],0);const o=a<0?-1:1;if(a=Math.min(Math.abs(a),1),a>.9995)return W(r.map((e,t)=>e+n*(i[t]*o-e)));const s=Math.acos(a),A=Math.sin(s),l=Math.sin((1-n)*s)/A,c=Math.sin(n*s)/A*o;return W(r.map((e,t)=>e*l+i[t]*c))}function K(e,t,n,r){const i=e["CUBICSPLINE"===t?3*n+1:n];return i?"quaternion"===r?W(i):[...i]:null}function W(e){const t=Math.hypot(...e);return t>0?e.map(e=>e/t):[0,0,0,1]}var $=class{name;times;values;interpolation;valueType;binding;constructor(e){this.name=e.name||e.binding.id||"unnamed",this.times=e.times,this.values=e.values,this.interpolation=e.interpolation||"LINEAR",this.valueType=e.valueType||"vector",this.binding=e.binding}get duration(){return this.times[this.times.length-1]||0}get sampler(){return{input:this.times,output:this.values,interpolation:this.interpolation}}evaluate(e){return function(e,t,n="vector"){const{input:r,output:i,interpolation:a="LINEAR"}=t;if(!r.length||!i.length||!Number.isFinite(e))return null;const o=r.length-1;if(e<=r[0]||0===o)return K(i,a,0,n);if(e>=r[o])return K(i,a,o,n);let s=0,A=o;for(;A-s>1;){const t=Math.floor((s+A)/2);r[t]<=e?s=t:A=t}const l=r[s],c=r[A]-l;if(c<=0||"STEP"===a)return K(i,a,s,n);const u=(e-l)/c;switch(a){case"LINEAR":{const e=i[s],t=i[A];return e&&t?"quaternion"===n?Q(e,t,u):function(e,t,n){return e.map((e,r)=>(1-n)*e+n*t[r])}(e,t,u):null}case"CUBICSPLINE":{const e=i[3*s+1],t=i[3*s+2],r=i[3*A],a=i[3*A+1];if(!(e&&t&&r&&a))return null;const o=function(e,t,n,r,i,a){const o=a*a,s=o*a;return e.map((e,A)=>(2*s-3*o+1)*e+(s-2*o+a)*t[A]*i+(-2*s+3*o)*r[A]+(s-o)*n[A]*i)}(e,t,r,a,c,u);return"quaternion"===n?W(o):o}default:return null}}(e,this.sampler,this.valueType)}},J=class{name;tracks;duration;constructor(e){this.name=e.name||"unnamed",this.tracks=e.tracks,this.duration=e.duration??Math.max(0,...e.tracks.map(e=>e.duration))}},Y=class{clip;mixer;time=0;timeScale;weight;loop;repetitions;paused=!1;playing=!1;elapsedTime=0;fade=null;constructor(e,t,n={}){this.mixer=e,this.clip=t,this.loop=n.loop||"repeat",this.repetitions=n.repetitions??Number.POSITIVE_INFINITY,this.timeScale=n.timeScale??1,this.weight=n.weight??1}play(){return this.playing=!0,this.paused=!1,this}pause(){return this.paused=!0,this}resume(){return this.playing=!0,this.paused=!1,this}stop(){return this.playing=!1,this.paused=!1,this.fade=null,this.reset()}reset(){return this.elapsedTime=0,this.time=0,this}setTime(e){return this.elapsedTime=e,this.time=this.resolveLocalTime(e),this}setLoop(e,t=Number.POSITIVE_INFINITY){return this.loop=e,this.repetitions=t,this.time=this.resolveLocalTime(this.elapsedTime),this}setEffectiveWeight(e){return this.weight=Math.max(0,e),this.fade=null,this}setEffectiveTimeScale(e){return this.timeScale=e,this}fadeIn(e){return this.scheduleFade(1,e)}fadeOut(e){return this.scheduleFade(0,e)}crossFadeTo(e,t){return e.weight=0,e.play().fadeIn(t),this.fadeOut(t)}crossFadeFrom(e,t){return e.crossFadeTo(this,t),this}advance(e){this.playing&&!this.paused&&(this.advanceFade(Math.abs(e)),this.elapsedTime+=e*this.timeScale,this.time=this.resolveLocalTime(this.elapsedTime),this.hasFinished()&&(this.playing=!1))}get shouldApply(){return(this.playing||this.hasFinished())&&this.weight>0}scheduleFade(e,t){return t<=0?(this.weight=e,this.fade=null,this):(this.fade={duration:t,elapsedTime:0,startWeight:this.weight,endWeight:e},this)}advanceFade(e){if(!this.fade)return;this.fade.elapsedTime+=e;const t=Math.min(this.fade.elapsedTime/this.fade.duration,1);this.weight=this.fade.startWeight+(this.fade.endWeight-this.fade.startWeight)*t,1===t&&(this.fade=null)}hasFinished(){const e=this.clip.duration;return e<=0?"once"===this.loop:"once"===this.loop?this.elapsedTime>=e||this.elapsedTime<0:Number.isFinite(this.repetitions)&&Math.abs(this.elapsedTime)>=e*this.repetitions}resolveLocalTime(e){const t=this.clip.duration;if(t<=0)return 0;if("once"===this.loop)return Math.min(Math.max(e,0),t);if(Number.isFinite(this.repetitions)&&Math.abs(e)>=t*this.repetitions)return"ping-pong"===this.loop&&this.repetitions%2==0||e<0?0:t;const n=e>=0&&e<t?e:(e%t+t)%t;if("repeat"===this.loop)return n;const r=Math.floor(e/t);return 0===Math.abs(r%2)?n:t-n}},X=class{time=0;timeScale=1;clips=new Map;actions=new Map;initialValues=new Map;constructor(e=[]){e.forEach(e=>this.addClip(e))}addClip(e){return this.clips.set(e.name,e),this}clipAction(e,t){const n="string"==typeof e?this.clips.get(e):e;if(!n)throw new Error(`Unknown animation clip: ${e}`);this.addClip(n);let r=this.actions.get(n);return r||(r=new Y(this,n,t),this.actions.set(n,r)),r}getAction(e){const t=this.clips.get(e);return t?this.actions.get(t):void 0}update(e){return this.advance(e),this.applyValues(),this}advance(e){const t=e*this.timeScale;return this.time+=t,this.actions.forEach(e=>e.advance(t)),this}setTime(e){return this.time=e,this.actions.forEach(t=>{t.paused||t.setTime(e*t.timeScale)}),this.applyValues(),this}stopAllAction(){return this.actions.forEach(e=>e.stop()),this}applyValues(){const e=new Map;this.actions.forEach(t=>{(t.shouldApply||t.playing&&0===t.weight)&&t.clip.tracks.forEach(n=>{const r=n.evaluate(t.time);if(!r)return;const i=n.binding.id||n.binding;if(!this.initialValues.has(i)){const e=n.binding.getValue?.();e&&this.initialValues.set(i,[...e])}if(0===t.weight&&!this.initialValues.has(i))return;const a=e.get(i);if(!a)return void e.set(i,{binding:n.binding,value:[...r],valueType:n.valueType,weight:t.weight});if(0===t.weight)return;const o=a.weight+t.weight,s=t.weight/o;a.value="quaternion"===n.valueType?Q(a.value,r,s):a.value.map((e,t)=>e+(r[t]-e)*s),a.weight=o})}),e.forEach(({binding:e,value:t,valueType:n,weight:r},i)=>{const a=r<1?this.initialValues.get(i):void 0;a&&a.length===t.length&&(t="quaternion"===n?Q(a,t,r):t.map((e,t)=>a[t]+(e-a[t])*r)),e.setValue(t)})}};function Z(e){const t=e.value;if(t instanceof Float32Array)return t;const n=new Float32Array(t.length),r=ne(t),i=t instanceof Int8Array||t instanceof Int16Array||t instanceof Int32Array;for(let a=0;a<t.length;a++){const o=Number(t[a]);n[a]=e.normalized&&r?i?Math.max(o/r,-1):o/r:o}return n}function ee(e,n,r,i){const a={};for(const t of["POSITION","NORMAL","TANGENT"]){const e=n.attributes[t];e&&(a[t]=Z(e))}const o=function(e,t,n){const r={};for(const i of["POSITION","NORMAL","TANGENT"]){const a=e[i];if(!a)continue;const o=new Float32Array(a),s="TANGENT"===i?4:3,A=Math.floor(a.length/s);for(let e=0;e<Math.min(t.length,n.length);e++){const r=n[e],a=t[e][i];if(!r||!a)continue;const l="TANGENT"===i&&a.length===4*A?4:3;for(let e=0;e<A;e++){const t=e*s,n=e*l;for(let e=0;e<3;e++)o[t+e]+=(a[n+e]||0)*r}}"POSITION"!==i&&re(o,s),r[i]=o}return r}(a,r,i),s={};for(const[t,u]of Object.entries(n.attributes))u&&(s[t]=u);for(const t of["POSITION","NORMAL","TANGENT"]){const e=o[t],n=s[t];e&&n&&(s[t]={...n,value:te(n,e)})}const A=new t.Geometry({id:n.id,topology:n.topology||"triangle-list",vertexCount:n.vertexCount,indices:n.indices,attributes:s,bufferLayout:n.bufferLayout}),l=t.makeInterleavedGeometry(A).attributes.geometry?.value,c=e._gpuGeometry?.attributes.geometry||e.bufferAttributes.geometry;if(l&&c)c.write(l);else for(const t of["POSITION","NORMAL","TANGENT"]){const n=o[t];if(n){const r="POSITION"===t?"positions":"NORMAL"===t?"normals":"TANGENT";e.bufferAttributes[r]?.write(n)}}}function te(e,t){if(e.value instanceof Float32Array)return t;const n=e.value.slice(),r=ne(n),i=n instanceof Int8Array||n instanceof Int16Array||n instanceof Int32Array;for(let a=0;a<t.length;a++){const o=t[a];n[a]=e.normalized&&r?Math.round(Math.max(i?-1:0,Math.min(1,o))*r):o}return n}function ne(e){return e instanceof Int8Array?127:e instanceof Uint8Array||e instanceof Uint8ClampedArray?255:e instanceof Int16Array?32767:e instanceof Uint16Array?65535:e instanceof Int32Array?2147483647:e instanceof Uint32Array?4294967295:0}function re(e,t){for(let n=0;n<e.length;n+=t){const t=Math.hypot(e[n],e[n+1],e[n+2]);t>0&&(e[n]/=t,e[n+1]/=t,e[n+2]/=t)}}function ie(e){const{joints:t,meshNode:r,worldMatrices:i,inverseBindMatrices:a,target:o}=e,s=t.length,A=o&&o.length===16*s?o:new Float32Array(16*s),l=r?i.get(r)||r.matrix:void 0,c=l?new n.Matrix4(l).invert():null;for(let u=0;u<s;u++){const e=t[u],r=i.get(e)||e.matrix,o=c?new n.Matrix4(c).multiplyRight(r):new n.Matrix4(r),s=16*u;if(a&&a.length>=s+16){const e=new n.Matrix4;for(let t=0;t<16;t++)e[t]=a[s+t];o.multiplyRight(e)}A.set(o,s)}return A}var ae=class{device;modules;_materialBindingNames;_materialModuleNames;constructor(e,t={}){this.device=e,this.modules=t.modules||[];const n=new i.ShaderInputs(Object.fromEntries(this.modules.map(e=>[e.name,e])));this._materialBindingNames=function(e){const t=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=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 se(this.device,{...e,factory:this})}getBindingNames(){return Array.from(this._materialBindingNames)}ownsBinding(e){if(this._materialBindingNames.has(e))return!0;const t=oe(e);return!!t&&this._materialModuleNames.has(t)}ownsModule(e){return this._materialModuleNames.has(e)}getBindingsByGroup(e){return Object.keys(e).length>0?{3:e}:{}}};function oe(e){return e.endsWith("Uniforms")?e.slice(0,-8):null}var se=class{id;device;factory;shaderInputs;bindings={};_uniformStore;_bindGroupCacheToken={};_dynamicResourceGenerations={};constructor(e,t={}){this.id=t.id||i.uid("material"),this.device=e,this.factory=t.factory||new ae(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 i.ShaderInputs(n),this._uniformStore=new i.UniformStore(this.device,this.shaderInputs.modules);for(const[r,a]of Object.entries(this.shaderInputs.modules))if(this.ownsModule(r)&&i.shaderModuleHasUniforms(a)){const e=this._uniformStore.getManagedUniformBuffer(r);this.bindings[`${r}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.updateShaderInputs(),t}ownsBinding(e){return this.factory.ownsBinding(e)}ownsModule(e){return this.factory.ownsModule(e)}setProps(e){this.shaderInputs.setProps(e)}updateShaderInputs(e){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues(),e),this._setOwnedBindings(this.shaderInputs.getBindingValues())&&(this._bindGroupCacheToken={})}getResourceBindings(){const e={};for(const[t,n]of Object.entries(this.bindings))oe(t)||(e[t]=n);return e}getBindings(e={bindings:[]}){this._syncDynamicResourceGenerations();const n={},r=n;for(const[a,o]of Object.entries(this.bindings))if(t.isTextureBindingSource(o)){const n=t.getTextureBindingLayout(e,a,{fallbackGroup:3}),i=n?o.resolveTextureBinding(n):null;i&&(r[a]=i)}else o instanceof i.DynamicBuffer?r[a]=o.buffer:i.isBufferRangeBinding(o)?r[a]=i.resolveBufferRangeBinding(o):r[a]=o;return this._syncDynamicResourceGenerations(),n}getBindingsByGroup(e={bindings:[]}){return this.factory.getBindingsByGroup(this.getBindings(e))}getBindGroupCacheKey(e){return this._syncDynamicResourceGenerations(),3===e?this._bindGroupCacheToken:null}getBindingsUpdateTimestamp(){let e=0;for(const r of Object.values(this.bindings))r instanceof o.TextureView?e=Math.max(e,r.texture.updateTimestamp):r instanceof a.Buffer||r instanceof n.Texture||r instanceof t.ExternalTexture||r instanceof i.DynamicBuffer?e=Math.max(e,r.updateTimestamp):t.isTextureBindingSource(r)?e=r.isReady?Math.max(e,r.updateTimestamp):1/0:i.isBufferRangeBinding(r)&&(e=Math.max(e,(r.buffer,i.DynamicBuffer,r.buffer.updateTimestamp)));return e}_replaceOwnedBindings(e){this._setOwnedBindings(e)&&(this._bindGroupCacheToken={})}_setOwnedBindings(e){let t=!1;for(const[n,r]of Object.entries(e))void 0!==r&&this.ownsBinding(n)&&this.bindings[n]!==r&&(this.bindings[n]=r,t=!0);return t}_syncDynamicResourceGenerations(){const e={};let t=!1;for(const[n,r]of Object.entries(this.bindings)){const i=Ae(r);null!==i&&(e[n]=i,this._dynamicResourceGenerations[n]!==i&&(t=!0))}Object.keys(e).length!==Object.keys(this._dynamicResourceGenerations).length&&(t=!0),this._dynamicResourceGenerations=e,t&&(this._bindGroupCacheToken={})}};function Ae(e){return t.isTextureBindingSource(e)?e.generation:i.getDynamicBufferFromBinding(e)?.generation??null}var le={"+X":0,"-X":1,"+Y":2,"-Y":3,"+Z":4,"-Z":5};function ce(e){return e?Array.isArray(e)?e[0]??null:e:null}function ue(e){if(n.isExternalImage(e))return n.getExternalImageSize(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 fe(e){return"object"==typeof e&&null!==e&&"data"in e&&"width"in e&&"height"in e}function de(e){return ArrayBuffer.isView(e)}function he(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 pe(e){const t=le[e];if(void 0===t)throw new Error(`Invalid cube face: ${e}`);return t}function me(e,t){return 6*e+pe(t)}function ge(e){throw new Error("setTexture1DData not supported in WebGL.")}function be(e,t,r,i){const a=(o=t,Array.isArray(o)?o:[o]);var o;const s=e,A=[];for(let l=0;l<a.length;l++){const e=a[l];if(n.isExternalImage(e))A.push({type:"external-image",image:e,z:s,mipLevel:l});else if(fe(e))A.push({type:"texture-data",data:e,textureFormat:he(e),z:s,mipLevel:l});else{if(!de(e)||!r)throw new Error("Unsupported 2D mip-level payload");A.push({type:"texture-data",data:{data:e,width:Math.max(1,r.width>>l),height:Math.max(1,r.height>>l),...i?{format:i}:{}},textureFormat:i,z:s,mipLevel:l})}}return A}function ve(e){const t=[];for(let n=0;n<e.length;n++)t.push(...be(n,e[n]));return t}function ye(e){const t=[];for(let n=0;n<e.length;n++)t.push(...be(n,e[n]));return t}function xe(e){const t=[];for(const[n,r]of Object.entries(e)){const e=pe(n);t.push(...be(e,r))}return t}function _e(e){const t=[];return e.forEach((e,n)=>{for(const[r,i]of Object.entries(e)){const e=me(n,r);t.push(...be(e,i))}}),t}var we=class e{device;id;props;_texture=null;_sampler=null;_view=null;ready;isReady=!1;destroyed=!1;generation=0;updateTimestamp;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..."})`}resolveTextureBinding(e){return this.isReady?this.texture:null}constructor(t,n){this.device=t;const r=i.uid("dynamic-texture"),a=n;this.props={...e.defaultProps,id:r,...n,data:null},this.id=this.props.id,this.ready=new Promise((e,t)=>{this.resolveReady=e,this.rejectReady=t}),this.updateTimestamp=this.device.incrementTimestamp(),this.initAsync(a)}async initAsync(e){try{const t=await this._loadAllData(e);this._checkNotDestroyed();const r=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 ge(e.data);case"2d":return be(0,e.data,t,n);case"3d":return ve(e.data);case"2d-array":return ye(e.data);case"cube":return xe(e.data);case"cube-array":return _e(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,o="usage"in e&&void 0!==e.usage,s=()=>{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=ce(n);if(!e)return null;const{width:t}=ue(e);return{width:t,height:1}}case"2d":{if(ArrayBuffer.isView(n))return null;const e=ce(n);return e?ue(e):null}case"3d":case"2d-array":{if(!Array.isArray(n)||0===n.length)return null;const e=ce(n[0]);return e?ue(e):null}case"cube":{const e=Object.keys(n)[0]??null;if(!e)return null;const t=ce(n[e]);return t?ue(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 r=ce(e[t]);return r?ue(r):null}default:return null}}(t);return e||{width:this.props.width||1,height:this.props.height||1}},A=s();if(!A||A.width<=0||A.height<=0)throw new Error(`${this} size could not be determined or was zero`);const l=function(e,t,n,r){if(0===t.length)return{subresources:t,mipLevels:1,format:r.format,hasExplicitMipChain:!1};const i=new Map;for(const c of t){const e=i.get(c.z)??[];e.push(c),i.set(c.z,e)}const a=t.some(e=>e.mipLevel>0);let o=r.format,s=Number.POSITIVE_INFINITY;const A=[];for(const[c,u]of i){const t=[...u].sort((e,t)=>e.mipLevel-t.mipLevel),r=t[0];if(!r||0!==r.mipLevel)throw new Error(`DynamicTexture: slice ${c} is missing mip level 0`);const i=Se(e,r);if(i.width!==n.width||i.height!==n.height)throw new Error(`DynamicTexture: slice ${c} base level dimensions ${i.width}x${i.height} do not match expected ${n.width}x${n.height}`);const a=Te(r);if(a){if(o&&o!==a)throw new Error(`DynamicTexture: slice ${c} base level format "${a}" does not match texture format "${o}"`);o=a}const l=o&&e.isTextureFormatCompressed(o)?Me(e,i.width,i.height,o):e.getMipLevelCount(i.width,i.height);let f=0;for(let n=0;n<t.length;n++){const r=t[n];if(!r||r.mipLevel!==n)break;if(n>=l)break;const a=Se(e,r),s=Math.max(1,i.width>>n),c=Math.max(1,i.height>>n);if(a.width!==s||a.height!==c)break;const u=Te(r);if(u&&(o||(o=u),u!==o))break;f++,A.push(r)}s=Math.min(s,f)}const l=Number.isFinite(s)?Math.max(1,s):1;return{subresources:A.filter(e=>e.mipLevel<l),mipLevels:l,format:o,hasExplicitMipChain:a}}(this.device,r,A,{format:i?e.format:void 0}),c=l.format??this.props.format,u={...this.props,...A,format:c,mipLevels:1,data:void 0};this.device.isTextureFormatCompressed(c)&&!o&&(u.usage=n.Texture.SAMPLE|n.Texture.COPY_DST);const f=this.props.mipmaps&&!l.hasExplicitMipChain&&!this.device.isTextureFormatCompressed(c);if("webgpu"===this.device.type&&f){const e="3d"===this.props.dimension?n.Texture.SAMPLE|n.Texture.STORAGE|n.Texture.COPY_DST|n.Texture.COPY_SRC:n.Texture.SAMPLE|n.Texture.RENDER|n.Texture.COPY_DST|n.Texture.COPY_SRC;u.usage|=e}const d=this.device.getMipLevelCount(u.width,u.height),h=l.hasExplicitMipChain?l.mipLevels:"auto"===this.props.mipLevels?d:Math.max(1,Math.min(d,this.props.mipLevels??1)),p={...u,mipLevels:h};this._texture=this.device.createTexture(p),this._sampler=this.texture.sampler,this._view=this.texture.view,this._touchGeneration(),l.subresources.length&&this._setTextureSubresources(l.subresources),!this.props.mipmaps||l.hasExplicitMipChain||f||a.log.warn(`${this} skipping auto-generated mipmaps for compressed texture format`)(),f&&this.generateMipmaps(),this.isReady=!0,this.resolveReady(this.texture),a.log.info(1,`${this} created`)()}catch(Gt){const t=Gt instanceof Error?Gt:new Error(String(Gt));this.rejectReady(t)}}destroy(){this._texture&&(this._texture.destroy(),this._texture=null,this._sampler=null,this._view=null),this.isReady=!1,this.destroyed=!0}generateMipmaps(){"webgl"===this.device.type?(this.texture.generateMipmapsWebGL(),this._touch()):"webgpu"===this.device.type?(this.device.generateMipmapsWebGPU(this.texture),this._touch()):a.log.warn(`${this} mipmaps not supported on ${this.device.type}`)}setSampler(e={}){this._checkReady();const t=e instanceof n.Sampler?e:this.device.createSampler(e);this.texture.setSampler(t),this._sampler=t,this._touchGeneration()}async readBuffer(e={}){this.isReady||await this.ready;const t=e.width??this.texture.width,n=e.height??this.texture.height,r=e.depthOrArrayLayers??this.texture.depth,i=this.texture.computeMemoryLayout({width:t,height:n,depthOrArrayLayers:r}),o=this.device.createBuffer({byteLength:i.byteLength,usage:a.Buffer.COPY_DST|a.Buffer.MAP_READ});this.texture.readBuffer({...e,width:t,height:n,depthOrArrayLayers:r},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,r=e.depthOrArrayLayers??this.texture.depth,i=this.texture.computeMemoryLayout({width:t,height:n,depthOrArrayLayers:r}),a=await this.readBuffer(e),o=await a.readAsync(0,i.byteLength);return a.destroy(),o.buffer instanceof ArrayBuffer?o.buffer:o.slice().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(),this._touchGeneration(),a.log.info(`${this} resized`),!0}getCubeFaceIndex(e){const t=le[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=ge();this._setTextureSubresources(t)}setTexture2DData(e,t=0){if(this._checkReady(),"2d"!==this.texture.props.dimension)throw new Error(`${this} is not 2d`);const n=be(t,e);this._setTextureSubresources(n)}setTexture3DData(e){if("3d"!==this.texture.props.dimension)throw new Error(`${this} is not 3d`);const t=ve(e);this._setTextureSubresources(t)}setTextureArrayData(e){if("2d-array"!==this.texture.props.dimension)throw new Error(`${this} is not 2d-array`);const t=ye(e);this._setTextureSubresources(t)}setTextureCubeData(e){if("cube"!==this.texture.props.dimension)throw new Error(`${this} is not cube`);const t=xe(e);this._setTextureSubresources(t)}setTextureCubeArrayData(e){if("cube-array"!==this.texture.props.dimension)throw new Error(`${this} is not cube-array`);const t=_e(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:r,flipY:i}=t;this.texture.copyExternalImage({image:r,z:e,mipLevel:n,flipY:i});break;case"texture-data":const{data:a,textureFormat:o}=t;if(o&&o!==this.texture.format)throw new Error(`${this} mip level ${n} uses format "${o}" but texture format is "${this.texture.format}"`);this.texture.writeData(a.data,{x:0,y:0,z:e,width:a.width,height:a.height,depthOrArrayLayers:1,mipLevel:n});break;default:throw new Error("Unsupported 2D mip-level payload")}}e.length>0&&this._touch()}async _loadAllData(e){const t=await Ee(e.data);return{dimension:e.dimension??"2d",data:t??null}}_checkNotDestroyed(){this.destroyed&&a.log.warn(`${this} already destroyed`)}_checkReady(){this.isReady||a.log.warn(`${this} Cannot perform this operation before ready`)}_touch(){this.updateTimestamp=this.device.incrementTimestamp()}_touchGeneration(){this.generation++,this._touch()}static defaultProps={...n.Texture.defaultProps,dimension:"2d",data:null,mipmaps:!1}};function Te(e){if("texture-data"===e.type)return e.textureFormat??he(e.data)}function Se(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 Me(e,t,n,r){const{blockWidth:i=1,blockHeight:a=1}=e.getTextureFormatInfo(r);let o=1;for(let s=1;;s++){const e=Math.max(1,t>>s),r=Math.max(1,n>>s);if(e<i||r<a)break;o++}return o}async function Ee(e){if(e=await e,Array.isArray(e))return await Promise.all(e.map(Ee));if(e&&"object"==typeof e&&e.constructor===Object){const t=e,n=await Promise.all(Object.values(t).map(Ee)),r=Object.keys(t),i={};for(let e=0;e<r.length;e++)i[r[e]]=n[e];return i}return e}function Ce(e,t){if(!e)throw new Error(t)}var Ie=class{id;matrix=new n.Matrix4;display=!0;position=new n.Vector3;rotation=new n.Vector3;scale=new n.Vector3(1,1,1);userData={};props={};constructor(e={}){const{id:t}=e;this.id=t||i.uid(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 Ce(3===e.length,"setPosition requires vector argument"),this.position=e,this}setRotation(e){return Ce(3===e.length||4===e.length,"setRotation requires vector argument"),this.rotation=e,this}setScale(e){return Ce(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:r,update:i=!0}=e;return t&&this.setPosition(t),n&&this.setRotation(n),r&&this.setScale(r),i&&this.updateMatrix(),this}updateMatrix(){if(this.matrix.identity(),this.matrix.translate(this.position),4===this.rotation.length){const e=(new n.Matrix4).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 r=new n.Matrix4(e).multiplyRight(t),i=r.invert(),a=i.transpose();return{viewMatrix:e,modelMatrix:t,objectMatrix:t,worldMatrix:r,worldInverseMatrix:i,worldInverseTransposeMatrix:a}}_setScenegraphNodeProps(e){void 0!==e.display&&(this.display=e.display),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)}};function Re(e,t,r){const i=new n.Matrix4(r);for(let a=0;a<8;a++){const r=new n.Vector3(t[1&a?1:0][0],t[2&a?1:0][1],t[4&a?1:0][2]);i.transformAsPoint(r,r);for(let t=0;t<3;t++)e[0][t]=Math.min(e[0][t],r[t]),e[1][t]=Math.max(e[1][t],r[t])}}function Pe(e){return Number.isFinite(e[0][0])}var Ne=class e extends Ie{children;constructor(e={}){e=Array.isArray(e)?{children:e}:e;const{children:t=[]}=e;a.log.assert(t.every(e=>e instanceof Ie),"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:r})=>{const i=t.getBounds();if(!i)return;const a=new n.Matrix4(r).multiplyRight(t.matrix);Re(e,i,a)}),Pe(e)?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(t,{worldMatrix:r=new n.Matrix4}={}){if(!this.display)return;const i=new n.Matrix4(r).multiplyRight(this.matrix);for(const n of this.children)n.display&&(n instanceof e?n.traverse(t,{worldMatrix:i}):t(n,{worldMatrix:i}))}traverseDepthSorted(e,{viewMatrix:t,worldMatrix:r=new n.Matrix4,order:i="back-to-front"}){const a=new n.Matrix4(t),o=[];this.traverse((e,t)=>{const r=e.getBounds(),i=r?new n.Vector3(r[0]).add(r[1]).divide([2,2,2]):new n.Vector3,s=new n.Matrix4(t.worldMatrix).multiplyRight(e.matrix);s.transformAsPoint(i,i),a.transformAsPoint(i,i),o.push({node:e,context:{worldMatrix:s,bounds:r,depth:-i[2]},index:o.length})},{worldMatrix:new n.Matrix4(r)});const s="back-to-front"===i?-1:1;o.sort((e,t)=>s*(e.context.depth-t.context.depth)||e.index-t.index);for(const{node:n,context:A}of o)e(n,A)}preorderTraversal(t,{worldMatrix:r=new n.Matrix4}={}){const i=new n.Matrix4(r).multiplyRight(this.matrix);t(this,{worldMatrix:i});for(const n of this.children)n instanceof e?n.preorderTraversal(t,{worldMatrix:i}):t(n,{worldMatrix:i})}},ke=class extends Ie{model;instanceMatrices;bounds=null;managedResources;constructor(e){super(e),this.model=e.model,this.managedResources=e.managedResources||[],this.instanceMatrices=e.instanceMatrices||null,this.bounds=e.bounds?this.instanceMatrices?function(e,t){const n=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]];for(const r of t)Re(n,e,r);return Pe(n)?n:null}(e.bounds,this.instanceMatrices):e.bounds:null,this.setProps(e)}destroy(){this.model&&(this.model.destroy(),this.model=null),this.managedResources.forEach(e=>e.destroy()),this.managedResources=[]}getBounds(){return this.bounds}draw(e){return this.model.draw(e)}};var Le=class{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&&n.deepEqual(this.opts,e.opts,1)}getShaders(e){return null}getSubLayerProps(e){const{defaultProps:t}=e.constructor,n={updateTriggers:{}};for(const r in t)if(r in this.props){const e=t[r],i=this.props[r];n[r]=i,e&&"accessor"===e.type&&(n.updateTriggers[r]=this.props.updateTriggers[r],"function"==typeof i&&(n[r]=this.getSubLayerAccessor(i)))}return n}initializeState(e,t){}updateState(e,t){}onNeedsRedraw(e){}getNeedsPickingBuffer(e){return!1}draw(e,t){}finalizeState(e,t){}};function Be(e,t,n=2,r,i="xy"){const a=t&&t.length,o=a?t[0]*n:e.length;let s=Oe(e,0,o,n,!0,r&&r[0],i);const A=[];if(!s||s.next===s.prev)return A;let l,c,u,f,d,h,p;if(a&&(s=function(e,t,n,r,i,a){const o=[];let s,A,l,c,u;for(s=0,A=t.length;s<A;s++)l=t[s]*r,c=s<A-1?t[s+1]*r:e.length,u=Oe(e,l,c,r,!1,i&&i[s+1],a),u===u.next&&(u.steiner=!0),o.push(Ke(u));for(o.sort(Ge),s=0;s<o.length;s++)n=He(o[s],n);return n}(e,t,s,n,r,i)),e.length>80*n){f=c=e[0],d=u=e[1];for(let t=n;t<o;t+=n)h=e[t],p=e[t+1],h<f&&(f=h),p<d&&(d=p),h>c&&(c=h),p>u&&(u=p);l=Math.max(c-f,u-d),l=0!==l?32767/l:0}return De(s,A,n,f,d,l,0),A}function Oe(e,n,r,i,a,o,s){let A,l;void 0===o&&(o=t.getPolygonSignedArea(e,{start:n,end:r,size:i,plane:s}));let c=t.DimIndex[s[0]],u=t.DimIndex[s[1]];if(a===o<0)for(A=n;A<r;A+=i)l=rt(A,e[A+c],e[A+u],l);else for(A=r-i;A>=n;A-=i)l=rt(A,e[A+c],e[A+u],l);return l&&Ye(l,l.next)&&(it(l),l=l.next),l}function Fe(e,t){if(!e)return e;t||(t=e);let n,r=e;do{if(n=!1,r.steiner||!Ye(r,r.next)&&0!==Je(r.prev,r,r.next))r=r.next;else{if(it(r),r=t=r.prev,r===r.next)break;n=!0}}while(n||r!==t);return t}function De(e,t,n,r,i,a,o){if(!e)return;!o&&a&&function(e,t,n,r){let i=e;do{0===i.z&&(i.z=Qe(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){let t,n,r,i,a,o,s,A,l=1;do{for(i=e,e=null,A=null,r=0;i;){for(r++,o=i,a=0,n=0;n<l&&(a++,o=o.nextZ,o);n++);for(s=l;a>0||s>0&&o;)0!==a&&(0===s||!o||i.z<=o.z)?(t=i,i=i.nextZ,a--):(t=o,o=o.nextZ,s--),A?A.nextZ=t:e=t,t.prevZ=A,A=t;i=o}A.nextZ=null,l*=2}while(r>1)}(i)}(e,r,i,a);let s,A,l=e;for(;e.prev!==e.next;)if(s=e.prev,A=e.next,a?Ve(e,r,i,a):Ue(e))t.push(s.i/n|0),t.push(e.i/n|0),t.push(A.i/n|0),it(e),e=A.next,l=A.next;else if((e=A)===l){o?1===o?De(e=je(Fe(e),t,n),t,n,r,i,a,2):2===o&&ze(e,t,n,r,i,a):De(Fe(e),t,n,r,i,a,1);break}}function Ue(e){const t=e.prev,n=e,r=e.next;if(Je(t,n,r)>=0)return!1;const i=t.x,a=n.x,o=r.x,s=t.y,A=n.y,l=r.y,c=i<a?i<o?i:o:a<o?a:o,u=s<A?s<l?s:l:A<l?A:l,f=i>a?i>o?i:o:a>o?a:o,d=s>A?s>l?s:l:A>l?A:l;let h=r.next;for(;h!==t;){if(h.x>=c&&h.x<=f&&h.y>=u&&h.y<=d&&We(i,s,a,A,o,l,h.x,h.y)&&Je(h.prev,h,h.next)>=0)return!1;h=h.next}return!0}function Ve(e,t,n,r){const i=e.prev,a=e,o=e.next;if(Je(i,a,o)>=0)return!1;const s=i.x,A=a.x,l=o.x,c=i.y,u=a.y,f=o.y,d=s<A?s<l?s:l:A<l?A:l,h=c<u?c<f?c:f:u<f?u:f,p=s>A?s>l?s:l:A>l?A:l,m=c>u?c>f?c:f:u>f?u:f,g=Qe(d,h,t,n,r),b=Qe(p,m,t,n,r);let v=e.prevZ,y=e.nextZ;for(;v&&v.z>=g&&y&&y.z<=b;){if(v.x>=d&&v.x<=p&&v.y>=h&&v.y<=m&&v!==i&&v!==o&&We(s,c,A,u,l,f,v.x,v.y)&&Je(v.prev,v,v.next)>=0)return!1;if(v=v.prevZ,y.x>=d&&y.x<=p&&y.y>=h&&y.y<=m&&y!==i&&y!==o&&We(s,c,A,u,l,f,y.x,y.y)&&Je(y.prev,y,y.next)>=0)return!1;y=y.nextZ}for(;v&&v.z>=g;){if(v.x>=d&&v.x<=p&&v.y>=h&&v.y<=m&&v!==i&&v!==o&&We(s,c,A,u,l,f,v.x,v.y)&&Je(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;y&&y.z<=b;){if(y.x>=d&&y.x<=p&&y.y>=h&&y.y<=m&&y!==i&&y!==o&&We(s,c,A,u,l,f,y.x,y.y)&&Je(y.prev,y,y.next)>=0)return!1;y=y.nextZ}return!0}function je(e,t,n){let r=e;do{const i=r.prev,a=r.next.next;!Ye(i,a)&&Xe(i,r,r.next,a)&&tt(i,a)&&tt(a,i)&&(t.push(i.i/n|0),t.push(r.i/n|0),t.push(a.i/n|0),it(r),it(r.next),r=e=a),r=r.next}while(r!==e);return Fe(r)}function ze(e,t,n,r,i,a){let o=e;do{let e=o.next.next;for(;e!==o.prev;){if(o.i!==e.i&&$e(o,e)){let s=nt(o,e);return o=Fe(o,o.next),s=Fe(s,s.next),De(o,t,n,r,i,a,0),void De(s,t,n,r,i,a,0)}e=e.next}o=o.next}while(o!==e)}function Ge(e,t){return e.x-t.x}function He(e,t){const n=function(e,t){let n=t;const r=e.x,i=e.y;let a,o=-1/0;do{if(i<=n.y&&i>=n.next.y&&n.next.y!==n.y){const e=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=r&&e>o&&(o=e,a=n.x<n.next.x?n:n.next,e===r))return a}n=n.next}while(n!==t);if(!a)return null;const s=a,A=a.x,l=a.y;let c,u=1/0;n=a;do{r>=n.x&&n.x>=A&&r!==n.x&&We(i<l?r:o,i,A,l,i<l?o:r,i,n.x,n.y)&&(c=Math.abs(i-n.y)/(r-n.x),tt(n,e)&&(c<u||c===u&&(n.x>a.x||n.x===a.x&&qe(a,n)))&&(a=n,u=c)),n=n.next}while(n!==s);return a}(e,t);if(!n)return t;const r=nt(n,e);return Fe(r,r.next),Fe(n,n.next)}function qe(e,t){return Je(e.prev,e,t.prev)<0&&Je(t.next,e,e.next)<0}function Qe(e,t,n,r,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Ke(e){let 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 We(e,t,n,r,i,a,o,s){return(i-o)*(t-s)>=(e-o)*(a-s)&&(e-o)*(r-s)>=(n-o)*(t-s)&&(n-o)*(a-s)>=(i-o)*(r-s)}function $e(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&Xe(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(tt(e,t)&&tt(t,e)&&function(e,t){let n=e,r=!1;const i=(e.x+t.x)/2,a=(e.y+t.y)/2;do{n.y>a!=n.next.y>a&&n.next.y!==n.y&&i<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==e);return r}(e,t)&&(Je(e.prev,e,t.prev)||Je(e,t.prev,t))||Ye(e,t)&&Je(e.prev,e,e.next)>0&&Je(t.prev,t,t.next)>0)}function Je(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function Ye(e,t){return e.x===t.x&&e.y===t.y}function Xe(e,t,n,r){const i=et(Je(e,t,n)),a=et(Je(e,t,r)),o=et(Je(n,r,e)),s=et(Je(n,r,t));return i!==a&&o!==s||(!(0!==i||!Ze(e,n,t))||(!(0!==a||!Ze(e,r,t))||(!(0!==o||!Ze(n,e,r))||!(0!==s||!Ze(n,t,r)))))}function Ze(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 et(e){return e>0?1:e<0?-1:0}function tt(e,t){return Je(e.prev,e,e.next)<0?Je(e,t,e.next)>=0&&Je(e,e.prev,t)>=0:Je(e,t,e.prev)<0||Je(e,e.next,t)<0}function nt(e,t){const n=new at(e.i,e.x,e.y),r=new at(t.i,t.x,t.y),i=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function rt(e,t,n,r){const i=new at(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function it(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)}Le.defaultProps={},Le.extensionName="LayerExtension";var at=class{constructor(e,t,n){this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1,this.i=e,this.x=t,this.y=n}},ot={...t.PolygonLayer.defaultProps},st=class extends t.CompositeLayer{indexToBounds(){return null}renderLayers(){const{elevationScale:e,extruded:n,wireframe:r,filled:i,stroked:a,lineWidthUnits:o,lineWidthScale:s,lineWidthMinPixels:A,lineWidthMaxPixels:l,lineAntialiasing:c,lineJointRounded:u,lineMiterLimit:f,lineDashJustified:d,getElevation:h,getFillColor:p,getLineColor:m,getLineWidth:g}=this.props,{updateTriggers:b,material:v,transitions:y}=this.props,x=this.getSubLayerClass("cell",t.PolygonLayer),{updateTriggers:_,...w}=this.indexToBounds()||{};return new x({filled:i,wireframe:r,extruded:n,elevationScale:e,stroked:a,lineWidthUnits:o,lineWidthScale:s,lineWidthMinPixels:A,lineWidthMaxPixels:l,lineAntialiasing:c,lineJointRounded:u,lineMiterLimit:f,lineDashJustified:d,material:v,transitions:y,getElevation:h,getFillColor:p,getLineColor:m,getLineWidth:g},this.getSubLayerProps({id:"cell",updateTriggers:b&&{..._,getElevation:b.getElevation,getFillColor:b.getFillColor,getLineColor:b.getLineColor,getLineWidth:b.getLineWidth}}),w)}};function At(){const e=new Float64Array(4);return e[0]=1,e[3]=1,e}function lt(){return new Float64Array(2)}function ct(e){const t=new Float64Array(2);return t[0]=e[0],t[1]=e[1],t}function ut(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e}function ft(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e}function dt(e,t){return e[0]=-t[0],e[1]=-t[1],e}function ht(e){return Math.hypot(e[0],e[1])}function pt(e,t,n,r){const i=t[0],a=t[1];return e[0]=i+r*(n[0]-i),e[1]=a+r*(n[1]-a),e}function mt(e,t,n){const r=t[0],i=t[1];return e[0]=n[0]*r+n[2]*i,e[1]=n[1]*r+n[3]*i,e}function gt(e,t,n){const r=t[0],i=t[1];return e[0]=n[0]*r+n[2]*i+n[4],e[1]=n[1]*r+n[3]*i+n[5],e}function bt(){return new Float64Array(3)}function vt(e,t,n){const r=new Float64Array(3);return r[0]=e,r[1]=t,r[2]=n,r}function yt(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e}function xt(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e}function _t(e,t,n,r){return e[0]=t[0]+n[0]*r,e[1]=t[1]+n[1]*r,e[2]=t[2]+n[2]*r,e}function wt(e,t){return Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2])}function Tt(e,t){const n=t[0],r=t[1],i=t[2];let a=n*n+r*r+i*i;return a>0&&(a=1/Math.sqrt(a)),e[0]=t[0]*a,e[1]=t[1]*a,e[2]=t[2]*a,e}function St(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function Mt(e,t,n){const r=t[0],i=t[1],a=t[2],o=n[0],s=n[1],A=n[2];return e[0]=i*A-a*s,e[1]=a*o-r*A,e[2]=r*s-i*o,e}function Et(e,t,n){const r=n[0],i=n[1],a=n[2],o=n[3],s=t[0],A=t[1],l=t[2];let c=i*l-a*A,u=a*s-r*l,f=r*A-i*s,d=i*f-a*u,h=a*c-r*f,p=r*u-i*c;const m=2*o;return c*=m,u*=m,f*=m,d*=2,h*=2,p*=2,e[0]=s+c+d,e[1]=A+u+h,e[2]=l+f+p,e}st.layerName="GeoCellLayer",st.defaultProps=ot;var Ct=(1+Math.sqrt(5))/2,It=2*Math.PI/5,Rt=Math.PI/5,Pt=Math.PI/10,Nt=2*Math.atan(Ct),kt=Math.PI-Nt;Math.PI,Math.acos(-1/Math.sqrt(3-Ct));var Lt=(Math.sqrt(5)-1)/2,Bt=3-Math.sqrt(5);Math.sqrt(3-Ct);Math.sqrt(3);var Ot=6371007.2;Math.PI;function Ft(e,t,n,r){const i=t[0]-e[0],a=t[1]-e[1],o=r[0]-n[0],s=r[1]-n[1],A=i*s-a*o;if(Math.abs(A)<1e-12)return!1;const l=n[0]-e[0],c=n[1]-e[1],u=(l*s-c*o)/A,f=(l*a-c*i)/A;return u>=0&&u<=1&&f>=0&&f<=1}var Dt=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 r=(n+1)%t;e+=(this.vertices[r][0]-this.vertices[n][0])*(this.vertices[r][1]+this.vertices[n][1])}return e}isWindingCorrect(){return this.getArea()>=0}getVertices(){return this.vertices}scale(e){for(const t of this.vertices)ft(t,t,e);return this}rotate180(){for(const e of this.vertices)dt(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)ut(t,t,e);return this}transform(e){for(const t of this.vertices)mt(t,t,e);return this}transform2d(e){for(const t of this.vertices)gt(t,t,e);return this}clone(){return new e(this.vertices.map(e=>ct(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 r=0;r<t;r++){const i=this.vertices[r],a=this.vertices[(r+1)%t],o=i[0]-a[0],s=i[1]-a[1],A=e[0]-i[0],l=e[1]-i[1],c=o*l-s*A;if(c<0){const e=Math.sqrt(A*A+l*l);n=Math.min(n,c/e)}}return n}intersectsSegment(e,t){if(this.containsPoint(e)>0||this.containsPoint(t)>0)return!0;const n=this.vertices.length;for(let r=0;r<n;r++){if(Ft(e,t,this.vertices[r],this.vertices[(r+1)%n]))return!0}return!1}splitEdges(t){if(t<=1)return this;const n=[],r=this.vertices.length;for(let e=0;e<r;e++){const i=this.vertices[e],a=this.vertices[(e+1)%r];n.push(ct(i));for(let e=1;e<t;e++){const r=e/t,o=lt();pt(o,i,a,r),n.push(o)}}return new e(n)}},Ut=[0,0],Vt=[0,1],jt=[.7885966681787006,1.6149108024237764],zt=[1.6171013659387945,1.054928690397459],Gt=[Math.cos(Pt),Math.sin(Pt)],Ht=2*ht(jt)*Math.cos(Rt),qt=Rt-Math.atan2(jt[1],jt[0]),Qt=2*Lt/Ht;[Ut,Vt,jt,zt,Gt].forEach(e=>{ft(e,e,Qt),function(e,t,n,r){const i=t[0]-n[0],a=t[1]-n[1],o=Math.sin(r),s=Math.cos(r);e[0]=i*s-a*o+n[0],e[1]=i*o+a*s+n[1]}(e,e,[0,0],qt)});var Kt=new Dt([Ut,Vt,jt,zt,Gt]),Wt=Math.atan2(jt[1],jt[0])-Rt,$t=Lt/Math.cos(Rt),Jt=Wt+Rt,Yt=[$t*Math.cos(Jt),$t*Math.sin(Jt)],Xt=Wt-Rt,Zt=[$t*Math.cos(Xt),$t*Math.sin(Xt)],en=new Dt([[0,0],Yt,Zt]),tn=[Yt[0],Yt[1],Zt[0],Zt[1]],nn=new Float64Array([-.0022392098386786394,21308606513250217e-22,-2.559257686421274e-9,33701965267802837e-28,-4667545312611249e-30,667492870384816e-32]),rn=new Float64Array([.0022392089963541657,28831978048607556e-22,5.08622073997266e-9,102018123778161e-25,21912872306767718e-30,49284235482523806e-33]),an=new class{applyCoefficients(e,t){const n=Math.sin(e),r=Math.cos(e),i=2*(r-n)*(r+n);let a,o;return a=i*t[5]+t[4],o=i*a+t[3],a=i*o-a+t[2],o=i*a-o+t[1],a=i*o-a+t[0],e+2*n*r*a}forward(e){return this.applyCoefficients(e,nn)}inverse(e){return this.applyCoefficients(e,rn)}};function on(e){return e*(Math.PI/180)}function sn(e){return e*(180/Math.PI)}function An(e){return[ht(e),Math.atan2(e[1],e[0])]}function ln(e){const t=Math.atan2(e[1],e[0]),n=Math.sqrt(e[0]*e[0]+e[1]*e[1]);return[t,Math.atan2(n,e[2])]}function cn([e,t]){const n=Math.sin(t);return[n*Math.cos(e),n*Math.sin(e),Math.cos(t)]}function un([e,t]){const n=on(e+93),r=on(t),i=an.forward(r);return[n,Math.PI/2-i]}function fn(e){return((e+180)%360+360)%360-180}function dn([e,t]){const n=fn(sn(e)-93),r=Math.PI/2-t;return[n,sn(an.inverse(r))]}bt(),vt(1,0,0),vt(0,1,0);var hn=Math.sqrt(5),pn=Math.sqrt(.2),mn=Math.sqrt((1-pn)/2),gn=Math.sqrt((1+pn)/2),bn=.5,vn=Math.sqrt((2.5-hn)/10),yn=Math.sqrt((2.5+hn)/10),xn=Math.sqrt((1+pn)/8),_n=Math.sqrt((1-pn)/8),wn=Math.sqrt((3-hn)/8),Tn=Math.sqrt((3+hn)/8),Sn=[[0,0],[mn,0],[vn,bn],[-xn,wn],[-xn,-wn],[vn,-bn],[-gn,0],[-_n,-Tn],[yn,-bn],[yn,bn],[-_n,Tn],[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?gn:mn]),Mn=["vu","uw","vw","vw","vw"],En=["wu","uw","vw","vu","uw"],Cn=["wu","uv","wv","wu","uw"],In=["vu","uv","wv","wu","uw"],Rn=[Mn,In,Cn,En,Cn,In,Cn,En,En,En,In,In],Pn=[4,2,3,2,0,4,3,2,2,0,3,0],Nn=[0,1,2,4,3,5,7,8,6,11,10,9],kn=[];var Ln=0;function Bn(e,t,n){if(Ln>11)throw new Error(`Too many origins: ${Ln}`);const r=function(){const e=new Float64Array(4);return e[3]=1,e}();var i,a;a=n,(i=r)[0]=-a[0],i[1]=-a[1],i[2]=-a[2],i[3]=a[3];const o={id:Ln,axis:e,axisCartesian:cn(e),quat:n,inverseQuat:r,angle:t,orientation:Rn[Ln],firstQuintant:Pn[Ln]};kn.push(o),Ln++}!function(){Bn([0,0],0,Sn[0]);for(let e=0;e<5;e++){const t=e*It,n=t+Rt;Bn([t,kt],Rt,Sn[e+1]),Bn([n,Math.PI-kt],Rt,Sn[(e+3)%5+6])}Bn([0,Math.PI],0,Sn[11])}(),kn.sort((e,t)=>Nn.indexOf(e.id)-Nn.indexOf(t.id)),kn.forEach((e,t)=>e.id=t);var On=class{forward([e,t]){return[Math.tan(t),e]}inverse([e,t]){return[t,Math.atan(e)]}};bt();function Fn(e,t,n){const r=e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+1+(t[0]*n[0]+t[1]*n[1]+t[2]*n[2])+(n[0]*e[0]+n[1]*e[1]+n[2]*e[2]);return 2*Math.atan2((a=t,o=n,(i=e)[0]*(a[1]*o[2]-a[2]*o[1])+i[1]*(a[2]*o[0]-a[0]*o[2])+i[2]*(a[0]*o[1]-a[1]*o[0])),r);var i,a,o}var Dn=bt(),Un=bt(),Vn=lt(),jn=lt(),zn=class e{constructor(t){this.constants=e.computeConstants(t)}static computeConstants(e){const[t,n,r]=e,i=bt();Mt(i,n,r);const a=St(t,n),o=St(t,r),s=St(n,r),A=St(t,i),l=o+s,c=a+1,u=l*l-c*c,f=2*c*(a*s-o),d=function(e,t,n,r,i,a){const o=new Float64Array(6);return o[0]=e,o[1]=t,o[2]=n,o[3]=r,o[4]=i,o[5]=a,o}(A*A-u,-f,-2*A*l,2*A*c,A*A+u,f);return{volumeABC:A,areaABC:Fn(t,n,r),AdotB:a,AdotC:o,alphaTransform:d}}forward(e,t,n){const[r,i,a]=t,{areaABC:o,volumeABC:s}=this.constants;Mt(Dn,i,a);const A=St(e,Dn);xt(Un,e,s),_t(Un,Un,r,-A);const l=(c=Un,Math.hypot(c[0],c[1],c[2]));var c;xt(Un,Un,l>0?1/l:1);const u=Math.max(0,Fn(r,i,Un))/o,f=l/s*Math.sqrt((1+St(r,Un))/(1+St(r,e)));return function(e,[t,n,r]){return[e[0]*t[0]+e[1]*n[0]+e[2]*r[0],e[0]*t[1]+e[1]*n[1]+e[2]*r[1]]}([1-f,f*(1-u),f*u],n)}inverse(e,t,n){const[r,i,a]=n,o=function(e,[t,n,r]){const i=[t[0]-r[0],t[1]-r[1]],a=[r[0]-n[0],r[1]-n[1]],o=[e[0]-r[0],e[1]-r[1]],s=a[0]*i[1]-a[1]*i[0],A=(a[0]*o[1]-a[1]*o[0])/s,l=(i[0]*o[1]-i[1]*o[0])/s;return[A,l,1-(A+l)]}(e,t),s=1-1e-14;if(o[0]>s)return r;if(o[1]>s)return i;if(o[2]>s)return a;const{AdotB:A,AdotC:l,alphaTransform:c,areaABC:u}=this.constants,f=St(r,i),d=Math.abs(f-A)>Math.abs(f-l),h=d?a:i,p=d?i:a,m=d?o[1]:o[2],g=1-o[0],b=m/g*u;Vn[0]=Math.cos(b),Vn[1]=Math.sin(b),gt(jn,Vn,c),xt(Un,h,jn[0]),_t(Un,Un,p,jn[1]),Tt(Un,Un);const v=St(r,Un),y=1+g*g*(v-1),x=g*Math.sqrt((1+y)/(1+v)),_=y-v*x,w=bt();return xt(w,r,_),_t(w,w,Un,x),w}},Gn=[0,1,2,3,4].map(e=>{const t=At();return function(e,t){const n=Math.sin(t),r=Math.cos(t);e[0]=r,e[1]=n,e[2]=-n,e[3]=r}(t,It*e),t}),Hn=lt(),qn=lt();[0,1,2,3].map(e=>{const t=Kt.clone();return 1&e&&t.rotate180(),2&e&&t.reflectY(),t.getCenter()});function Qn(e){const t=en.clone();return t.transform(Gn[e]),t}var Kn=new class{constructor(){if(this.vertices=[],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)}getCanonicalTriangle(){return[this.vertices[0],this.vertices[32],this.vertices[12]]}getVertex(e){for(const t of this.vertices)if(wt(e,t)<1e-5)return t;throw new Error("Failed to find vertex in CRS")}addFaceCenters(){kn.forEach(e=>this.add(cn(e.axis)))}addVertices(){const e=Math.atan(Bt);for(const t of kn)for(let n=0;n<5;n++){const r=cn([(2*n+1)*Math.PI/5+t.angle,e]);Et(r,r,t.quat),this.add(r)}}addMidpoints(){const e=Math.atan(Lt);for(const t of kn)for(let n=0;n<5;n++){const r=cn([2*n*Math.PI/5+t.angle,e]);Et(r,r,t.quat),this.add(r)}}add(e){const t=Tt(bt(),e);return!this.vertices.find(e=>wt(t,e)<1e-5)&&(this.vertices.push(t),!0)}},Wn={A:"PQAB",B:"B+++PQ---A",C:"P---RMb+++",M:"qQ+++C---b",P:"PpB---B+++",Q:"PQ---Cb+++",R:"b+++a---qQ"},$n=Object.keys(Wn);$n.map(e=>e.toLowerCase());var Jn=e=>[...e].reverse().map(e=>"+"===e?"-":"-"===e?"+":(e=>e>="a"&&e<="z"?e.toUpperCase():e.toLowerCase())(e)).join("");function Yn(e,t){let n="";for(const r of e){const e=r.toUpperCase();void 0!==t[r]?n+=t[r]:r!==e&&void 0!==t[e]?n+=Jn(t[e]):n+=r}return n}var Xn=(e,t)=>({a:e.a+t.a,b:e.b+t.b}),Zn=e=>({a:-e.b,b:e.a+e.b}),er=(e,t)=>{let n=e;const r=(t%6+6)%6;for(let i=0;i<r;i++)n=Zn(n);return n},tr={E:{a:4,b:0},e:{a:4,b:0},S:{a:4,b:-2},s:{a:4,b:-2},U:{a:0,b:2},u:{a:0,b:2},D:{a:0,b:-2},d:{a:0,b:-2},T:{a:-4,b:0},t:{a:-4,b:0}},nr=new Set(Object.keys(tr)),rr={E:[{a:0,b:0},{a:4,b:0},{a:4,b:-4}],e:[{a:0,b:0},{a:4,b:0},{a:0,b:4}],S:[{a:0,b:0},{a:4,b:0},{a:4,b:-4}],s:[{a:4,b:-2},{a:0,b:2},{a:0,b:-2}],U:[{a:0,b:2},{a:0,b:-2},{a:4,b:-2}],u:[{a:0,b:0},{a:0,b:4},{a:-4,b:4}],D:[{a:0,b:2},{a:0,b:-2},{a:4,b:-2}],d:[{a:0,b:0},{a:0,b:-4},{a:-4,b:0}],T:[{a:0,b:-4},{a:-4,b:0},{a:-4,b:-4}],t:[{a:-4,b:4},{a:0,b:0},{a:0,b:4}]};function ir(e,t,n){return rr[e].map(e=>Xn(t,er(e,n)))}function ar(e,t,n){const[r,i,a]=ir(e,t,n);return{a:r.a+i.a+a.a,b:r.b+i.b+a.b}}function or(e,t,n,r){let i={...t},a=(n%6+6)%6;for(const o of e)"+"!==o?"-"!==o?nr.has(o)&&(r?.(o,i,a),i=Xn(i,er(tr[o],a))):a=(a+5)%6:a=(a+1)%6;return{pos:i,heading:a}}var sr=1e-6;function Ar(e,t,n){const r=n?-1:1,i=[];for(let a=0;a<4;a++){const o=4*t+a,s=e.childToken[o],A=e.childFlip[o],l=e.childOffA[o],c=e.childOffB[o],u=e.fpEdges[2*s+(n^A)],f=[];for(let e=0;e<u.length;e+=4)f.push([3*l*r+u[e],3*c*r+u[e+1]]);i.push([a,f])}return i}function lr(e){if(1===e.length)return{leaf:e[0][0]};for(const[,t]of e){const n=t.length;for(let r=0;r<n;r++){const[i,a]=t[r],[o,s]=t[(r+1)%n],A=s-a,l=-(o-i),c=-(A*i+l*a),u=[],f=[];let d=!0;for(const[t,n]of e){let e=1/0,r=-1/0;for(const[t,i]of n){const n=A*t+l*i+c;n<e&&(e=n),n>r&&(r=n)}if(e>=-sr)u.push([t,n]);else{if(!(r<=sr)){d=!1;break}f.push([t,n])}}if(d&&u.length&&f.length)return{nx:A,ny:l,c:c,pos:lr(u),neg:lr(f)}}}throw new Error("lsystem: no clean BSP split for child set")}function cr(e,t){if("leaf"in e)return;const n=[e.nx,e.ny,e.c];t.some(e=>e[0]===n[0]&&e[1]===n[1]&&e[2]===n[2])||t.push(n),cr(e.pos,t),cr(e.neg,t)}function ur(e,t,n){return"leaf"in e?e.leaf:ur(t>>n.findIndex(t=>t[0]===e.nx&&t[1]===e.ny&&t[2]===e.c)&1?e.pos:e.neg,t,n)}var fr={S:0,D:1,E:2,T:3};function dr(e,t){const n=Object.keys(e),r=[...n,...n.map(e=>e.toLowerCase())],i=r.length,a={};function o(n,r){let i=n;for(let t=0;t<r;t++)i=Yn(i,e);return Yn(i,t)}r.forEach((e,t)=>a[e]=t);const s=e=>function(e){const t=or(e,{a:0,b:0},0);return{disp:t.pos,dHeading:t.heading}}(o(e,1)).disp;function A(t){let n={a:0,b:0},r=0;const i=[];for(const a of t){if("+"===a){r=(r+1)%6;continue}if("-"===a){r=(r+5)%6;continue}if(void 0===e[a.toUpperCase()])continue;if(0!==r&&3!==r)throw new Error(`lsystem: non-180° turn (${60*r}°) before a child in rule "${t}"`);const o=3===r;i.push({token:a,offUnit:{...n},flip:o});const A=s(a);n=o?{a:n.a-A.a,b:n.b-A.b}:{a:n.a+A.a,b:n.b+A.b}}if(4!==i.length)throw new Error(`lsystem: rule "${t}" must have 4 children`);return i}const l={};for(const y of n)l[y]=A(e[y]);for(const y of n)l[y.toLowerCase()]=A(Jn(e[y]));const c=new Int32Array(4*i),u=new Uint8Array(4*i),f=new Float64Array(4*i),d=new Float64Array(4*i);for(const y of r){const e=l[y];for(let t=0;t<4;t++){const n=4*a[y]+t;c[n]=a[e[t].token],u[n]=e[t].flip?1:0,f[n]=e[t].offUnit.a,d[n]=e[t].offUnit.b}}function h(e){const t=[...new Map(e.map(e=>[`${e.a},${e.b}`,e])).values()].sort((e,t)=>e.a-t.a||e.b-t.b);if(t.length<3)return t;const n=(e,t,n)=>(t.a-e.a)*(n.b-e.b)-(t.b-e.b)*(n.a-e.a),r=[];for(const a of t){for(;r.length>=2&&n(r[r.length-2],r[r.length-1],a)<=0;)r.pop();r.push(a)}const i=[];for(let a=t.length-1;a>=0;a--){const e=t[a];for(;i.length>=2&&n(i[i.length-2],i[i.length-1],e)<=0;)i.pop();i.push(e)}return r.slice(0,-1).concat(i.slice(0,-1))}const p=new Array(2*i);for(const y of r){const e=[];or(o(y,1),{a:0,b:0},0,(t,n,r)=>e.push(...ir(t,n,r)));const t=h(e);for(let n=0;n<2;n++){const e=n?-1:1,r=new Float64Array(4*t.length);for(let n=0;n<t.length;n++){const i=t[n],a=t[(n+1)%t.length];r[4*n]=3*e*i.a,r[4*n+1]=3*e*i.b,r[4*n+2]=e*(a.a-i.a),r[4*n+3]=e*(a.b-i.b)}p[2*a[y]+n]=r}}const m=new Float64Array(2*i*8),g=new Float64Array(2*i*48),b=new Uint8Array(2*i*4);for(const y of r){const e=o(y,1);for(let t=0;t<2;t++){const n=2*a[y]+t;let r=0;or(e,{a:0,b:0},t?3:0,(e,t,i)=>{const a=ar(e,t,i);m[8*n+2*r]=a.a,m[8*n+2*r+1]=a.b;const o=e.toUpperCase();if(void 0===fr[o])throw new Error(`lsystem: no pentagon flavor for draw symbol ${e}`);b[4*n+r]=fr[o]^(e===o?0:1)^1&i;let s=ir(e,t,i);(s[1].a-s[0].a)*(s[2].b-s[0].b)-(s[1].b-s[0].b)*(s[2].a-s[0].a)<0&&(s=[s[0],s[2],s[1]]);for(let A=0;A<3;A++){const e=s[A],t=s[(A+1)%3],i=48*n+12*r+4*A;g[i]=3*e.a,g[i+1]=3*e.b,g[i+2]=t.a-e.a,g[i+3]=t.b-e.b}r++})}}const v={motifIdx:a,childToken:c,childFlip:u,childOffA:f,childOffB:d,fpEdges:p,leafSum:m,leafTri:g,leafFlavor:b,classSep:new Float64Array(2*i*9),classLut:new Uint8Array(2*i*8)};for(let y=0;y<i;y++)for(let e=0;e<2;e++){const t=2*y+e,n=lr(Ar(v,y,e)),r=[];cr(n,r);for(let e=0;e<r.length;e++)v.classSep[9*t+3*e]=r[e][0],v.classSep[9*t+3*e+1]=r[e][1],v.classSep[9*t+3*e+2]=r[e][2];for(let e=0;e<8;e++)v.classLut[8*t+e]=ur(n,e,r)}return v}var hr=new Float64Array(32);for(let ev=0;ev<32;ev++)hr[ev]=2**ev;var pr=new Float64Array(20);for(let ev=0;ev<20;ev++)pr[ev]=4**ev;var mr=dr(Wn,{A:"E",B:"+e-",C:"-e+",M:"T",P:"S",Q:"D",R:"+++D---"});mr.motifIdx.A,mr.motifIdx.A,mr.motifIdx.C,mr.motifIdx.C,mr.motifIdx.B,mr.motifIdx.B;var gr=dr({W:"W+++Z---WZ",Z:"Z+++W---ZW"},{W:"E",Z:"+e-"}),br=gr.motifIdx.W;function vr(e){return Array.from({length:e.length},(t,n)=>e.indexOf(n))}var yr=[0,1,3,4,5,6,7,2],xr=[0,1,2,7,3,4,5,6];vr(yr),vr(xr);function _r(e,t,n,r,i){if(t<=0)return;const a=e[t]||0,o=e[t-1];let s=!0,A=!0;if(r!==(0===n[0]+n[1])?(s=1===a||2===a,A=1===a):(s=a<2,A=0===a),!s)return;const l=A?o:o+4,c=i[l];e[t-1]=c%4,e[t]=(a+4+Math.floor(c/4)-Math.floor(l/4))%4}function wr(e,t){1===t?e[1]=-e[1]:3===t&&(e[0]=-e[0])}var Tr={uv:{reverse:!1,invertJ:!1,flipIJ:!1},vu:{reverse:!0,invertJ:!1,flipIJ:!1},uw:{reverse:!1,invertJ:!1,flipIJ:!0},wu:{reverse:!0,invertJ:!1,flipIJ:!0},vw:{reverse:!0,invertJ:!0,flipIJ:!1},wv:{reverse:!1,invertJ:!0,flipIJ:!1}};function Sr(e,t){return(-1===e[1]?1:0)|((e[0]+e[1]===0?0===t||3===t:2===t||3===t)?1:0)<<1}function Mr(e,t,n){const r=1n<<BigInt(2*t),i=function(e,t){const n=[];let r=e;for(;r>0n||n.length<t;)n.push(Number(3n&r)),r>>=2n;return n}(n.reverse?r-1n-e:e,t),a=function(e,t,n){const r=n?xr:yr,i=[1,1];for(let a=e.length-1;a>=0;a--)_r(e,a,i,t,r),wr(i,e[a]);return i}(i,n.invertJ,n.flipIJ),o=function(e,t,n,r){const{childToken:i,childFlip:a,childOffA:o,childOffB:s,leafSum:A,leafFlavor:l}=e,c=Number(67108863n&t),u=Number(t>>26n);let f=r,d=0,h=0,p=0;for(let b=n;b>=2;b--){const e=b-1,t=4*f+(e<13?c>>>(e<<1)&3:Math.floor(u/pr[e-13])%4),n=d?-hr[b-2]:hr[b-2];h+=o[t]*n,p+=s[t]*n,d^=a[t],f=i[t]}const m=n>=1?3&c:0,g=2*f+d;return{a:3*h+A[8*g+2*m],b:3*p+A[8*g+2*m+1],flavor:l[4*g+m]}}(gr,function(e){let t=0n;for(let n=e.length-1;n>=0;n--)t=t<<2n|BigInt(e[n]);return t}(i),t,br);let s=function(e,t){if((2*e+t)%12!=0||t%4!=0)throw new Error(`abToTriple: off-lattice corner sum (${e},${t})`);const n=(2*e+t-12)/12,r=(t+4)/4;for(const i of[0,1]){if((r+i)%3!=0)continue;const e=(r+i)/3,t=i-e;if((t+n)%2==0)return{x:e,y:(t+n)/2,z:(t-n)/2}}throw new Error(`abToTriple: no integer triple for (${e},${t})`)}(o.a,o.b);if(n.flipIJ&&(s={x:s.z,y:s.y,z:s.x}),n.invertJ){const e=hr[t]-1;s={x:s.y-e,y:s.x+e,z:s.z}}return{triple:s,flips:a,q:i.length>0?i[0]:0}}function Er(e){const t=function(e){if(0n===e)return-1;if(1n&e||4n==(7n&e)||16n==(31n&e))return 30;let t=29,n=e>>1n;if(0n===n)return-1;let r,i=Number(4294967295n&n);for(0===i?(n>>=32n,t-=16,r=Number(n)):r=i,65535&r||(r>>=16,t-=8),t>=6&&!(255&r)&&(r>>=8,t-=4),t>=4&&!(15&r)&&(r>>=4,t-=2);t>-1&&!(1&r);)t-=1,r>>=t<2?1:2;return t}(e);if(-1===t)return{origin:kn[0],segment:0,S:0n,resolution:t};let n=58n,r=0;if(30===t){const t=1n&e?1n:4n&e?3n:5n;n=58n+t,r=1n===t?0:3n===t?32:40}const i=Number(e>>n)+r;let a,o;if(0===t?(a=kn[i],o=0):(a=kn[Math.floor(i/5)],o=(i+a.firstQuintant)%5),!a)throw new Error(`Could not parse origin: ${i}`);if(t<2)return{origin:a,segment:o,S:0n,resolution:t};return{origin:a,segment:o,S:(e&(1n<<n)-1n)>>n-BigInt(2*(t-2+1)),resolution:t}}var Cr=(e,t,n)=>({x:e,y:t,z:n}),Ir=(Cr(0,0,1),Cr(0,1,-1),Cr(0,1,0),Cr(1,-1,0),Cr(1,0,0),Cr(1,-1,1),Cr(1,1,-1),Cr(0,0,1),Cr(0,1,-1),Cr(0,1,0),Cr(1,-1,0),Cr(1,0,0),Cr(1,-1,1),Cr(1,1,-1),Cr(0,0,-1),Cr(0,-1,1),Cr(0,-1,0),Cr(-1,1,0),Cr(-1,0,0),Cr(-1,1,-1),Cr(-1,-1,1),Cr(0,0,-1),Cr(0,-1,1),Cr(0,-1,0),Cr(-1,1,0),Cr(-1,0,0),Cr(-1,1,-1),Cr(-1,-1,1),Cr(-1,1,0),Cr(0,-1,1),Cr(0,0,1),Cr(0,1,0),Cr(1,0,0),Cr(-1,1,1),Cr(1,-1,1),Cr(-1,1,0),Cr(0,-1,1),Cr(0,0,1),Cr(0,1,0),Cr(1,0,0),Cr(-1,1,1),Cr(1,-1,1),Cr(1,-1,0),Cr(0,1,-1),Cr(0,0,-1),Cr(0,-1,0),Cr(-1,0,0),Cr(1,-1,-1),Cr(-1,1,-1),Cr(1,-1,0),Cr(0,1,-1),Cr(0,0,-1),Cr(0,-1,0),Cr(-1,0,0),Cr(1,-1,-1),Cr(-1,1,-1),vt(0,0,1),(()=>{const e=[];for(let t=0;t<24;t++){const n=1.4*(t+1);e.push(vt(Math.cos(n),Math.sin(n),0))}})(),At(),new class{constructor(){this.faceTriangles=[],this.sphericalTriangles=[],this.equalArea=new zn(Kn.getCanonicalTriangle()),this.gnomonic=new On}forward(e,t){return this.forwardCartesian(cn(e),t)}forwardCartesian(e,t){const n=kn[t],r=bt();Et(r,e,n.inverseQuat);const i=ln(r),a=this.gnomonic.forward(i);a[1]=a[1]-n.angle;const o=this.getFaceTriangleIndex(a),s=this.shouldReflect(a);let A=this.getFaceTriangle(o,s,!1),l=this.getSphericalTriangle(o,t,s);return this.equalArea.forward(e,l,A)}inverse(e,t){const n=An(e),r=this.getFaceTriangleIndex(n),i=this.shouldReflect(n),a=this.getFaceTriangle(r,i,!1),o=this.getSphericalTriangle(r,t,i);return ln(this.equalArea.inverse(e,a,o))}shouldReflect(e){const[t,n]=e;return function([e,t]){return[e*Math.cos(t),e*Math.sin(t)]}([t,this.normalizeGamma(n)])[0]>Lt}getFaceTriangleIndex([e,t]){return(Math.floor(t/Rt)+10)%10}getFaceTriangle(e,t=!1,n=!1){let r=e;return t&&(r+=n?20:10),this.faceTriangles[r]||(this.faceTriangles[r]=t?this._getReflectedFaceTriangle(e,n):this._getFaceTriangle(e),Object.freeze(this.faceTriangles[r])),this.faceTriangles[r]}_getFaceTriangle(e){const[t,n,r]=Qn(Math.floor((e+1)/2)%5).getVertices(),i=lt();return pt(i,n,r,.5),e%2==0?[t,i,n]:[t,r,i]}_getReflectedFaceTriangle(e,t=!1){let[n,r,i]=this._getFaceTriangle(e).map(e=>ct(e));const a=e%2==0;var o,s,A,l;return dt(n,n),o=n,s=n,A=a?r:i,l=t?1+1/Math.cos(kt):2,o[0]=s[0]+A[0]*l,o[1]=s[1]+A[1]*l,[n,i,r]}getSphericalTriangle(e,t,n=!1){let r=10*t+e;return n&&(r+=120),this.sphericalTriangles[r]||(this.sphericalTriangles[r]=this._getSphericalTriangle(e,t,n),Object.freeze(this.sphericalTriangles[r])),this.sphericalTriangles[r]}_getSphericalTriangle(e,t,n=!1){const r=kn[t];return this.getFaceTriangle(e,n,!0).map(e=>{const[t,n]=An(e),i=[t,n+r.angle],a=cn(this.gnomonic.inverse(i));return Et(a,a,r.quat),Kn.getVertex(a)})}normalizeGamma(e){const t=e/It;return(t-Math.round(t))*It}});bt();function Rr({S:e,segment:t,origin:n,resolution:r}){const{quintant:i,orientation:a}=function(e,t){const n=t.orientation,r=n===Mn||n===En?-1:1,i=(e-t.firstQuintant+5)%5,a=n[i];return{quintant:(t.firstQuintant+r*i+5)%5,orientation:a}}(t,n);if(1===r)return Qn(i);if(0===r)return function(){const e=[];for(const t of Gn)e.push(mt(lt(),Yt,t));return e.reverse(),new Dt(e)}();const o=r-2+1,{triple:s,flavor:A}=function(e,t,n="uv"){const r=Tr[n],{triple:i,flips:a,q:o}=Mr(e,t,r);return r.invertJ&&(a[0]=-a[0]),{triple:i,flavor:Sr(a,o)}}(e,o,a);return function(e,t,n,r,i=!1){const a=(i?en:Kt).clone();var o,s,A;return 1&r&&a.rotate180(),2&r&&a.reflectY(),o=qn,s=n.x+n.y,A=-n.x+(1&r),o[0]=s,o[1]=A,mt(Hn,qn,tn),a.translate(Hn),a.scale(1/2**e),a.transform(Gn[t]),a}(o,i,s,A)}function Pr(e,{closedRing:t=!0,segments:n="auto"}={closedRing:!0,segments:"auto"}){if(0n===e)return[];const{S:r,segment:i,origin:a,resolution:o}=Er(e);"auto"===n&&(n=Math.max(1,Math.pow(2,6-o)));const s=Rr({S:r,segment:i,origin:a,resolution:o}).splitEdges(n).getVertices(),A=new Array(s.length);for(let c=0;c<s.length;c++)A[c]=dn(Ir.inverse(s[c],a.id));const l=function(e){const t=bt();for(let a=0;a<e.length;a++)yt(t,t,cn(un(e[a])));Tt(t,t);let[n,r]=dn(ln(t));(r>89.99||r<-89.99)&&(n=e[0][0]),n=fn(n);const i=new Array(e.length);for(let a=0;a<e.length;a++){let t=e[a][0];const r=e[a][1];for(;t-n>180;)t-=360;for(;t-n<-180;)t+=360;i[a]=[t,r]}return i}(A);return t&&l.push(l[0]),l.reverse(),l}var Nr=12742014.4/Math.sqrt(15),kr=new Array(31);kr[0]=12742014.4/Math.sqrt(3);for(let ev=1;ev<=30;ev++)kr[ev]=Nr/(1<<ev-1);(()=>{const e=[];for(let t=-1;t<=1;t++)for(let n=-1;n<=1;n++)for(let r=-1;r<=1;r++)0===t&&0===n&&0===r||e.push([t,n,r])})(),vt(0,0,1),vt(1,0,0),bt();var Lr=function(e){var t,n=void 0!==(e=e||{})?e:{},r={};for(t in n)n.hasOwnProperty(t)&&(r[t]=n[t]);var i,a=[],o="";"undefined"!=typeof document&&document.currentScript&&(o=document.currentScript.src),o=0!==o.indexOf("blob:")?o.substr(0,o.lastIndexOf("/")+1):"",i=function(e,t,n){var r=new XMLHttpRequest;r.open("GET",e,!0),r.responseType="arraybuffer",r.onload=function(){if(200==r.status||0==r.status&&r.response)t(r.response);else{var i=J(e);i?t(i.buffer):n()}},r.onerror=n,r.send(null)};var s=n.print||console.log.bind(console),A=n.printErr||console.warn.bind(console);for(t in r)r.hasOwnProperty(t)&&(n[t]=r[t]);r=null,n.arguments&&(a=n.arguments);var l=0;var c=!1;function u(e){var t,r=n["_"+e];return t="Cannot call unknown function "+e+", make sure it is exported",r||le("Assertion failed: "+t),r}function f(e,t,n,r,i){var a={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,r){if(!(r>0))return 0;for(var i=n,a=n+r-1,o=0;o<e.length;++o){var s=e.charCodeAt(o);if(s>=55296&&s<=57343)s=65536+((1023&s)<<10)|1023&e.charCodeAt(++o);if(s<=127){if(n>=a)break;t[n++]=s}else if(s<=2047){if(n+1>=a)break;t[n++]=192|s>>6,t[n++]=128|63&s}else if(s<=65535){if(n+2>=a)break;t[n++]=224|s>>12,t[n++]=128|s>>6&63,t[n++]=128|63&s}else{if(n+3>=a)break;t[n++]=240|s>>18,t[n++]=128|s>>12&63,t[n++]=128|s>>6&63,t[n++]=128|63&s}}t[n]=0})(e,p,t,n)})(e,t=te(n),n)}return t},array:function(e){var t=te(e.length);return function(e,t){h.set(e,t)}(e,t),t}};var o=u(e),s=[],A=0;if(r)for(var l=0;l<r.length;l++){var c=a[n[l]];c?(0===A&&(A=re()),s[l]=c(r[l])):s[l]=r[l]}var f=o.apply(null,s);return f=function(e){return"string"===t?x(e):"boolean"===t?Boolean(e):e}(f),0!==A&&ne(A),f}var d,h,p,m,g,b,v,y="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function x(e,t){return e?function(e,t,n){for(var r=t+n,i=t;e[i]&&!(i>=r);)++i;if(i-t>16&&e.subarray&&y)return y.decode(e.subarray(t,i));for(var a="";t<i;){var o=e[t++];if(128&o){var s=63&e[t++];if(192!=(224&o)){var A=63&e[t++];if((o=224==(240&o)?(15&o)<<12|s<<6|A:(7&o)<<18|s<<12|A<<6|63&e[t++])<65536)a+=String.fromCharCode(o);else{var l=o-65536;a+=String.fromCharCode(55296|l>>10,56320|1023&l)}}else a+=String.fromCharCode((31&o)<<6|s)}else a+=String.fromCharCode(o)}return a}(p,e,t):""}function _(e,t){return e%t>0&&(e+=t-e%t),e}function w(e){d=e,n.HEAP8=h=new Int8Array(e),n.HEAP16=m=new Int16Array(e),n.HEAP32=g=new Int32Array(e),n.HEAPU8=p=new Uint8Array(e),n.HEAPU16=new Uint16Array(e),n.HEAPU32=new Uint32Array(e),n.HEAPF32=b=new Float32Array(e),n.HEAPF64=v=new Float64Array(e)}"undefined"!=typeof TextDecoder&&new TextDecoder("utf-16le");var T=n.TOTAL_MEMORY||33554432;function S(e){for(;e.length>0;){var t=e.shift();if("function"!=typeof t){var r=t.func;"number"==typeof r?void 0===t.arg?n.dynCall_v(r):n.dynCall_vi(r,t.arg):r(void 0===t.arg?null:t.arg)}else t()}}T=(d=n.buffer?n.buffer:new ArrayBuffer(T)).byteLength,w(d),g[7096]=5271296;var M=[],E=[],C=[],I=[];function R(e){M.unshift(e)}function P(e){I.unshift(e)}var N=Math.abs,k=Math.ceil,L=Math.floor,B=Math.min,O=0,F=null,D=null;n.preloadedImages={},n.preloadedAudios={};var U,V,j=null,z="data:application/octet-stream;base64,";function G(e){return String.prototype.startsWith?e.startsWith(z):0===e.indexOf(z)}j="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+AAAAAAAAACsAAAADAAAAYQAAAAAAAABZAAAAAwAAAEcAAAADAAAAYgAAAAMAAABUAAAAAAAAAEUAAAAAAAAAYAAAAAMAAABSAAAAAwAAAEAAAAAAAAAASwAAAAAAAABBAAAAAAAAADoAAAADAAAAPQAAAAAAAAA1AAAAAwAAACwAAAADAAAAMQAAAAMAAAApAAAAAwAAAB8AAAADAAAAXgAAAAAAAABWAAAAAAAAAEwAAAADAAAAUQAAAAMAAABLAAAAAAAAAEEAAAAAAAAAQgAAAAMAAAA9AAAAAAAAADUAAAADAAAAawAAAAAAAABoAAAAAwAAAGAAAAADAAAAZQAAAAMAAABeAAAAAAAAAFYAAAAAAAAAVQAAAAMAAABRAAAAAwAAAEsAAAAAAAAAOQAAAAAAAAA7AAAAAAAAAD8AAAADAAAASgAAAAAAAABOAAAAAwAAAE8AAAADAAAAUwAAAAMAAABcAAAAAwAAAF8AAAADAAAAJQAAAAAAAAAnAAAAAwAAAC0AAAADAAAANAAAAAAAAAA5AAAAAAAAADsAAAAAAAAARgAAAAMAAABKAAAAAAAAAE4AAAADAAAAGAAAAAAAAAAXAAAAAwAAABkAAAADAAAAIAAAAAMAAAAlAAAAAAAAACcAAAADAAAAMgAAAAMAAAA0AAAAAAAAADkAAAAAAAAALgAAAAAAAAA8AAAAAAAAAEgAAAADAAAAOAAAAAAAAABEAAAAAwAAAFAAAAADAAAAPwAAAAMAAABNAAAAAwAAAFoAAAADAAAAGwAAAAAAAAAoAAAAAwAAADcAAAADAAAAIwAAAAAAAAAuAAAAAAAAADwAAAAAAAAALQAAAAMAAAA4AAAAAAAAAEQAAAADAAAADgAAAAAAAAAUAAAAAwAAACQAAAADAAAAEQAAAAMAAAAbAAAAAAAAACgAAAADAAAAGQAAAAMAAAAjAAAAAAAAAC4AAAAAAAAARwAAAAAAAABZAAAAAAAAAGEAAAADAAAASQAAAAAAAABbAAAAAwAAAGcAAAADAAAASAAAAAMAAABYAAAAAwAAAGkAAAADAAAAMwAAAAAAAABFAAAAAwAAAFQAAAADAAAANgAAAAAAAABHAAAAAAAAAFkAAAAAAAAANwAAAAMAAABJAAAAAAAAAFsAAAADAAAAJgAAAAAAAAAvAAAAAwAAAEAAAAADAAAAIgAAAAMAAAAzAAAAAAAAAEUAAAADAAAAJAAAAAMAAAA2AAAAAAAAAEcAAAAAAAAAYAAAAAAAAABoAAAAAAAAAGsAAAADAAAAYgAAAAAAAABuAAAAAwAAAHMAAAADAAAAYQAAAAMAAABvAAAAAwAAAHcAAAADAAAATAAAAAAAAABWAAAAAwAAAF4AAAADAAAAUgAAAAAAAABgAAAAAAAAAGgAAAAAAAAAVAAAAAMAAABiAAAAAAAAAG4AAAADAAAAOgAAAAAAAABBAAAAAwAAAEsAAAADAAAAPgAAAAMAAABMAAAAAAAAAFYAAAADAAAAQAAAAAMAAABSAAAAAAAAAGAAAAAAAAAAVQAAAAAAAABXAAAAAAAAAFMAAAADAAAAZQAAAAAAAABmAAAAAwAAAGQAAAADAAAAawAAAAMAAABwAAAAAwAAAHIAAAADAAAAQgAAAAAAAABDAAAAAwAAAEYAAAADAAAAUQAAAAAAAABVAAAAAAAAAFcAAAAAAAAAXgAAAAMAAABlAAAAAAAAAGYAAAADAAAAMQAAAAAAAAAwAAAAAwAAADIAAAADAAAAPQAAAAMAAABCAAAAAAAAAEMAAAADAAAASwAAAAMAAABRAAAAAAAAAFUAAAAAAAAAXwAAAAAAAABcAAAAAAAAAFMAAAAAAAAATwAAAAAAAABOAAAAAAAAAEoAAAADAAAAPwAAAAEAAAA7AAAAAwAAADkAAAADAAAAbQAAAAAAAABsAAAAAAAAAGQAAAAFAAAAXQAAAAEAAABfAAAAAAAAAFwAAAAAAAAATQAAAAEAAABPAAAAAAAAAE4AAAAAAAAAdQAAAAQAAAB2AAAABQAAAHIAAAAFAAAAagAAAAEAAABtAAAAAAAAAGwAAAAAAAAAWgAAAAEAAABdAAAAAQAAAF8AAAAAAAAAWgAAAAAAAABNAAAAAAAAAD8AAAAAAAAAUAAAAAAAAABEAAAAAAAAADgAAAADAAAASAAAAAEAAAA8AAAAAwAAAC4AAAADAAAAagAAAAAAAABdAAAAAAAAAE8AAAAFAAAAYwAAAAEAAABaAAAAAAAAAE0AAAAAAAAAWAAAAAEAAABQAAAAAAAAAEQAAAAAAAAAdQAAAAMAAABtAAAABQAAAF8AAAAFAAAAcQAAAAEAAABqAAAAAAAAAF0AAAAAAAAAaQAAAAEAAABjAAAAAQAAAFoAAAAAAAAAaQAAAAAAAABYAAAAAAAAAEgAAAAAAAAAZwAAAAAAAABbAAAAAAAAAEkAAAADAAAAYQAAAAEAAABZAAAAAwAAAEcAAAADAAAAcQAAAAAAAABjAAAAAAAAAFAAAAAFAAAAdAAAAAEAAABpAAAAAAAAAFgAAAAAAAAAbwAAAAEAAABnAAAAAAAAAFsAAAAAAAAAdQAAAAIAAABqAAAABQAAAFoAAAAFAAAAeQAAAAEAAABxAAAAAAAAAGMAAAAAAAAAdwAAAAEAAAB0AAAAAQAAAGkAAAAAAAAAdwAAAAAAAABvAAAAAAAAAGEAAAAAAAAAcwAAAAAAAABuAAAAAAAAAGIAAAADAAAAawAAAAEAAABoAAAAAwAAAGAAAAADAAAAeQAAAAAAAAB0AAAAAAAAAGcAAAAFAAAAeAAAAAEAAAB3AAAAAAAAAG8AAAAAAAAAcAAAAAEAAABzAAAAAAAAAG4AAAAAAAAAdQAAAAEAAABxAAAABQAAAGkAAAAFAAAAdgAAAAEAAAB5AAAAAAAAAHQAAAAAAAAAcgAAAAEAAAB4AAAAAQAAAHcAAAAAAAAAcgAAAAAAAABwAAAAAAAAAGsAAAAAAAAAZAAAAAAAAABmAAAAAAAAAGUAAAADAAAAUwAAAAEAAABXAAAAAwAAAFUAAAADAAAAdgAAAAAAAAB4AAAAAAAAAHMAAAAFAAAAbAAAAAEAAAByAAAAAAAAAHAAAAAAAAAAXAAAAAEAAABkAAAAAAAAAGYAAAAAAAAAdQAAAAAAAAB5AAAABQAAAHcAAAAFAAAAbQAAAAEAAAB2AAAAAAAAAHgAAAAAAAAAXwAAAAEAAABsAAAAAQAAAHIAAAAAAAAAGC1EVPsh+T8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABgtRFT7Ifk/GC1EVPsh+T8AAAAAAAAAAAAAAAAAAAAAGC1EVPsh+T8AAAAAAAAAABgtRFT7IQlAGC1EVPsh+T8AAAAAAAAAAAAAAAAAAAAAGC1EVPshCUAAAAAAAAAAABgtRFT7Ifm/GC1EVPsh+T8AAAAAAAAAAAAAAAAAAAAAGC1EVPsh+b8AAAAAAAAAAAAAAAAAAAAAGC1EVPsh+b8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABgtRFT7Ifm/GC1EVPsh+b8AAAAAAAAAAAAAAAAAAAAAGC1EVPsh+b8AAAAAAAAAABgtRFT7IQnAGC1EVPsh+b8AAAAAAAAAAAAAAAAAAAAAGC1EVPshCcAAAAAAAAAAABgtRFT7Ifk/GC1EVPsh+b8AAAAAAAAAAAAAAAAAAAAAGC1EVPsh+T8AAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAGAAAAAgAAAAUAAAABAAAABAAAAAAAAAAAAAAABQAAAAMAAAABAAAABgAAAAQAAAACAAAAAAAAAMpi5RexJsw/BlIKPVwR5T95Wyu0/QjnP5PjoT7YYcu/mBhKZ6zrwj8wRYS7NebuP3qW6geh+Ls/SLrixebL3r+pcyymN9XrPwmkNHp7xec/GWNMZVAA17+82s+x2BLiPwn2ytbJ9ek/LgEH1sMS1j8yp/2LhTfeP+SnWwtQBbu/d38gkp5X7z8ytsuHaADGPzUYObdf1+m/7IauECWhwz+cjSACjzniP76Z+wUhN9K/1+GEKzup67+/GYr/04baPw6idWOvsuc/ZedTWsRa5b/EJQOuRzi0v/OncYhHPes/h49PixY53j+i8wWfC03Nvw2idWOvsue/ZedTWsRa5T/EJQOuRzi0P/KncYhHPeu/iY9PixY53r+i8wWfC03NP9anWwtQBbs/d38gkp5X778ytsuHaADGvzUYObdf1+k/74auECWhw7+cjSACjzniv8CZ+wUhN9I/1uGEKzup6z+/GYr/04bavwmkNHp7xee/F2NMZVAA1z+82s+x2BLivwr2ytbJ9em/KwEH1sMS1r8yp/2LhTfev81i5RexJsy/BlIKPVwR5b95Wyu0/Qjnv5DjoT7YYcs/nBhKZ6zrwr8wRYS7Nebuv3OW6geh+Lu/SLrixebL3j+pcyymN9Xrv8rHIFfWehZAMBwUdlo0DECTUc17EOb2PxpVB1SWChdAzjbhb9pTDUDQhmdvECX5P9FlMKCC9+g/IIAzjELgE0DajDngMv8GQFhWDmDPjNs/y1guLh96EkAxPi8k7DIEQJCc4URlhRhA3eLKKLwkEECqpNAyTBD/P6xpjXcDiwVAFtl//cQm4z+Ibt3XKiYTQM7mCLUb3QdAoM1t8yVv7D8aLZv2Nk8UQEAJPV5nQwxAtSsfTCoE9z9TPjXLXIIWQBVanC5W9AtAYM3d7Adm9j++5mQz1FoWQBUThyaVBghAwH5muQsV7T89Q1qv82MUQJoWGOfNuBdAzrkClkmwDkDQjKq77t37Py+g0dtitsE/ZwAMTwVPEUBojepluNwBQGYbtuW+t9w/HNWIJs6MEkDTNuQUSlgEQKxktPP5TcQ/ixbLB8JjEUCwuWjXMQYCQAS/R09FkRdAowpiZjhhDkB7LmlczD/7P01iQmhhsAVAnrtTwDy84z/Z6jfQ2TgTQChOCXMnWwpAhrW3daoz8z/HYJvVPI4VQLT3ik5FcA5Angi7LOZd+z+NNVzDy5gXQBXdvVTFUA1AYNMgOeYe+T8+qHXGCwkXQKQTOKwa5AJA8gFVoEMW0T+FwzJyttIRQAEAAAD/////BwAAAP////8xAAAA/////1cBAAD/////YQkAAP////+nQQAA/////5HLAQD/////95AMAP/////B9lcAAAAAAAAAAAAAAAAAAgAAAP////8OAAAA/////2IAAAD/////rgIAAP/////CEgAA/////06DAAD/////IpcDAP/////uIRkA/////4LtrwAAAAAAAAAAAAAAAAAAAAAAAgAAAP//////////AQAAAAMAAAD//////////////////////////////////////////////////////////////////////////wEAAAAAAAAAAgAAAP///////////////wMAAAD//////////////////////////////////////////////////////////////////////////wEAAAAAAAAAAgAAAP///////////////wMAAAD//////////////////////////////////////////////////////////////////////////wEAAAAAAAAAAgAAAP///////////////wMAAAD//////////////////////////////////////////////////////////wIAAAD//////////wEAAAAAAAAA/////////////////////wMAAAD/////////////////////////////////////////////////////AwAAAP////////////////////8AAAAA/////////////////////wEAAAD///////////////8CAAAA////////////////////////////////AwAAAP////////////////////8AAAAA////////////////AgAAAAEAAAD/////////////////////////////////////////////////////AwAAAP////////////////////8AAAAA////////////////AgAAAAEAAAD/////////////////////////////////////////////////////AwAAAP////////////////////8AAAAA////////////////AgAAAAEAAAD/////////////////////////////////////////////////////AwAAAP////////////////////8AAAAA////////////////AgAAAAEAAAD/////////////////////////////////////////////////////AQAAAAIAAAD///////////////8AAAAA/////////////////////wMAAAD/////////////////////////////////////////////////////AQAAAAIAAAD///////////////8AAAAA/////////////////////wMAAAD/////////////////////////////////////////////////////AQAAAAIAAAD///////////////8AAAAA/////////////////////wMAAAD/////////////////////////////////////////////////////AQAAAAIAAAD///////////////8AAAAA/////////////////////wMAAAD///////////////////////////////8CAAAA////////////////AQAAAP////////////////////8AAAAA/////////////////////wMAAAD/////////////////////////////////////////////////////AwAAAP////////////////////8AAAAAAQAAAP//////////AgAAAP//////////////////////////////////////////////////////////AwAAAP///////////////wIAAAAAAAAAAQAAAP//////////////////////////////////////////////////////////////////////////AwAAAP///////////////wIAAAAAAAAAAQAAAP//////////////////////////////////////////////////////////////////////////AwAAAP///////////////wIAAAAAAAAAAQAAAP//////////////////////////////////////////////////////////////////////////AwAAAAEAAAD//////////wIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAgAAAAAAAAACAAAAAQAAAAEAAAACAAAAAgAAAAAAAAAFAAAABQAAAAAAAAACAAAAAgAAAAMAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAIAAAABAAAAAgAAAAIAAAACAAAAAAAAAAUAAAAGAAAAAAAAAAIAAAACAAAAAwAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAIAAAAAAAAAAgAAAAEAAAADAAAAAgAAAAIAAAAAAAAABQAAAAcAAAAAAAAAAgAAAAIAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAgAAAAAAAAACAAAAAQAAAAQAAAACAAAAAgAAAAAAAAAFAAAACAAAAAAAAAACAAAAAgAAAAMAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAACAAAAAAAAAAIAAAABAAAAAAAAAAIAAAACAAAAAAAAAAUAAAAJAAAAAAAAAAIAAAACAAAAAwAAAAUAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAIAAAACAAAAAAAAAAMAAAAOAAAAAgAAAAAAAAACAAAAAwAAAAAAAAAAAAAAAgAAAAIAAAADAAAABgAAAAAAAAAAAAAAAAAAAAAAAAALAAAAAgAAAAIAAAAAAAAAAwAAAAoAAAACAAAAAAAAAAIAAAADAAAAAQAAAAAAAAACAAAAAgAAAAMAAAAHAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAACAAAAAgAAAAAAAAADAAAACwAAAAIAAAAAAAAAAgAAAAMAAAACAAAAAAAAAAIAAAACAAAAAwAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAIAAAACAAAAAAAAAAMAAAAMAAAAAgAAAAAAAAACAAAAAwAAAAMAAAAAAAAAAgAAAAIAAAADAAAACQAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAgAAAAIAAAAAAAAAAwAAAA0AAAACAAAAAAAAAAIAAAADAAAABAAAAAAAAAACAAAAAgAAAAMAAAAKAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAACAAAAAgAAAAAAAAADAAAABgAAAAIAAAAAAAAAAgAAAAMAAAAPAAAAAAAAAAIAAAACAAAAAwAAAAsAAAAAAAAAAAAAAAAAAAAAAAAABgAAAAIAAAACAAAAAAAAAAMAAAAHAAAAAgAAAAAAAAACAAAAAwAAABAAAAAAAAAAAgAAAAIAAAADAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAgAAAAIAAAAAAAAAAwAAAAgAAAACAAAAAAAAAAIAAAADAAAAEQAAAAAAAAACAAAAAgAAAAMAAAANAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAACAAAAAgAAAAAAAAADAAAACQAAAAIAAAAAAAAAAgAAAAMAAAASAAAAAAAAAAIAAAACAAAAAwAAAA4AAAAAAAAAAAAAAAAAAAAAAAAACQAAAAIAAAACAAAAAAAAAAMAAAAFAAAAAgAAAAAAAAACAAAAAwAAABMAAAAAAAAAAgAAAAIAAAADAAAADwAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAgAAAAAAAAACAAAAAQAAABMAAAACAAAAAgAAAAAAAAAFAAAACgAAAAAAAAACAAAAAgAAAAMAAAAQAAAAAAAAAAAAAAAAAAAAAAAAABEAAAACAAAAAAAAAAIAAAABAAAADwAAAAIAAAACAAAAAAAAAAUAAAALAAAAAAAAAAIAAAACAAAAAwAAABEAAAAAAAAAAAAAAAAAAAAAAAAAEgAAAAIAAAAAAAAAAgAAAAEAAAAQAAAAAgAAAAIAAAAAAAAABQAAAAwAAAAAAAAAAgAAAAIAAAADAAAAEgAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAgAAAAAAAAACAAAAAQAAABEAAAACAAAAAgAAAAAAAAAFAAAADQAAAAAAAAACAAAAAgAAAAMAAAATAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAACAAAAAAAAAAIAAAABAAAAEgAAAAIAAAACAAAAAAAAAAUAAAAOAAAAAAAAAAIAAAACAAAAAwAAAAIAAAABAAAAAAAAAAEAAAACAAAAAAAAAAAAAAACAAAAAQAAAAAAAAABAAAAAgAAAAEAAAAAAAAAAgAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAAAAAAAAAAABQAAAAQAAAAAAAAAAQAAAAUAAAAEAAAAAAAAAAUAAAAAAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAAAAAAAAAAAAAIAAAABAAAAAAAAAAEAAAACAAAAAQAAAAAAAAACAAAAAgAAAAAAAAABAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAAAAAAAAAAABQAAAAQAAAAAAAAAAQAAAAUAAAAEAAAAAAAAAAUAAAAFAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAQAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAABAAAAAAAAAAABAAAAAAEAAAAAAAAAAAEAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAQAAAAAAAAAAAAEAAAAAAAAAAAAAOgehWlKfUEEz1zLi+JsiQa2og3wcMfVAWCbHorc0yEDi+Yn/Y6mbQJ11/mfsnG9At6bnG4UQQkBvMCQWKqUUQJVmwwswmOc/3hVgVBL3uj//qqOEOdGOPw/WDN4gnGE/H3ANkCUgND+AA8btKgAHPwTXBqJVSdo+XfRQAqsKrj4fc+zLYbSPQklEmCZHv2FCUP+uDso1NEKYtPhwphUHQptxnyFXYdpB7CddZAMmrkGAt1AxSTqBQUibBVdTsFNBSuX3MV+AJkFocv82SLf5QAqmgj7AY81A23VDSEnLoEDGEJVSeDFzQDYrqvBk70VA8U157pcRGUBWfEF+ZKbsP6phvycGBZRAJbod0OgwfkCp+L8jatBmQCjl3pGrPlFAfMWm114SOkButwtqS7UjQHQwbcjXyw1A8jnLuuyA9j9KwjL0VwHhPyotk0lcs8k/Q5PvEs9rsz+SfsOQEVqdPzUAKDojLoY/WJz/kcjCcD8YFu070FRZPyoLC2BdJEM/YOXQAuiMM0HIBz1bw3sdQdV46aaHRwZByatzjDPX8EDb3Jie8HXZQCJxj6ULP8NAUaG6uRAZrUCWdmou5/mVQLb9huRPm4BAhvoCHygZaUCuX/I3SPdSQC9/bC/1qTxAfKxsYQ6pJUCuslH+N14QQMS/cv7SvPg/Ol8maYKx4j8AAAAA/////wAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////////////////////////////wAAAAD/////AAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAA/////wAAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAP////8AAAAABQAAAAAAAAAAAAAAAAAAAAAAAAD/////BQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAA/////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////////////////////////////8AAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////AAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAABQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////////////////////////////wAAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAQAAAAAAAAABAAAAAAAAAAUAAAABAAAAAQAAAAAAAAAAAAAAAQAAAAEAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQEAAAAAAAEAAQAAAQEAAAAAAAEAAAABAAAAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAKriWFiWZfg/Y2nmTbY/8z8MHSPSqmnjv6hnn18HR3c/quJYWJZl+D/jq5TzDdzyPwwdI9KqaeO/u0kC1eFSBECq4lhYlmX4P69pJmt7c/E/NnkJi6jSBsDESFlzKkr6P33ArMz7sfY/o2q2uqM08D+oZ59fB0d3PzEqCi3qrvK/kmm4ANp49D+4wS2wzhzvP9WJvyAnx+E/upcY75RVx7+95t+9y0T1P9L18g1caO0/k6CkRyVzAEBf99+e/GjxP6QMsuuLQ/U/PlP4Qr8q7j8Mb/GO2GMCwLl2K/DQIghAePiwytEp9D9UHrsuI/nqPzjMedJ+yuy/k6xgf58n/L+XoQtn22DzP2lzCnsYk+s/JhUSDI4P8z+8lFcBhgTcPxOqKRxEX/M/89MEdoPQ6j8OKQaXDob7vzWwNvblgAPAzGkxMcl88j9Nm4okPkbpP0vI89vxSgRAdac2Z6W2/T+6UFOMC3zyP/+2XEF3hug/QqhELwGKCMAwdlQerEoEQFcr/B+VnvE/hB1hfFzT5j8wdsE/Da64P0hIvnF/sOC/KH/hrXUg8T9bI5OQHaLlP+mYzla7td6/CtKG6iOm8b8FW3TV8oXwP8ORhtNuJ+c/q8JrTMz/AcC8PaUl+PUFwAXv9rkMT/A/m+sAswr15D+7hk/O3yvkP6c/yVsOHKI/qqAX9idJ8D/8hNz1KNPiP7xSXh3Ggvg/epbkiKr57T/23/LB1GLvP4GTTeNZi+M/W4TqlTheBcDupZgIdYUIQGwlcW3YZO8/tQvDXQ3H4j8Bt+sf9DkAQMdFie+nNvg/Z5Uh1wDX7j9h5X2d4KjhPxMJ1ZVT4Pa/evqB8xB//7+W183U9QLsPwzNxsC7AOA/af/LqCnK/r/lPceQ0FQDwHoY0nYIW+w/bHNSHrTg4D/DFcMAdabuv2sz5Ojhnve/FvLf01HN6z/tEDL2Hz/gP0bBv0KUhPA/pd7sEnMc4D8EGon4Lo7sP5NVbYtSON8/DAMC50odBkB+Z2J8MGYCQIhlM1gubOo/FssiPwWy4D8OIlGqRnkCQAd1vopp6f4/QS1keLLK6T9rfoBuT7LZP3KQbH5ugwjAjqVPXTmbBUBL/JxcqR3qP3oSeovuktg/Y6pRhJmqy7+0kwuU0Yjmv2wvsfFmQ+g/R98lJFqQ2T/IGb5gjLkCwK3mNff3kQbAqDznPFM86T+iiP0FfsvYP7fzKG6Mls0/h7+at2btzL8tsUTgk+LmP/YEIrTDINU/WmwKoVjA5L9aC02r6FHxvzzFCT/Qg+Y/nx0V97en0j8+1toJOm77P1kZ7h8KjfQ/GBbbqxgk5j9RGXM79G/SP+beHsWmweQ/9REi4eX0xD/V9s+kmMHkP+pb9yNs09A/c5ERjVDTAECqEr3OBCH7P14ILfMECOU/piRx4P8P0j+JYU//bfL0Pw62fw28B+w/l5YW2Ga45D9+CyKRbenOP5cH6fHy1/S/o/egk03++r91nTYRL/bjP3fHN6OJVdA/7xXQh1XLBcAB3g6tBdUIQKW2KnGYjeQ/SqIpagclyz8F9P3YgNL6v9H6NBsZ8QDAW2k5L5Qs4z/0axa1l6zLP1GE65Mu4wNAwfX+BYmWAEBBgJP90M3hP6/03qhPLdA/zqo5bJz2778/ESlPCTn1v7JkhGyvzuE/DM7sj5twwz/6xbXLavYGQH29RFRGkgNA7bOXVSJ54T9fEhTHO/TDP+8t+HMOiwDAxa0SbGTtA8Atii7y0mLgP4cecHFB3sM/uPUpyv+K7j8nktD1/WvhP2cWmi772d8/Fj7uU9kEvD8oKOESLzKmvwSdCqrHdNu/XCluGsvI3T929OW5md+uP9dP6rXcZNq/gXM+ggzL6b+eKjsPgJncP6i1e9aVu7E/2CnPNJyD1D/DnyGgSe+xvy8k7g9bp9s/nYmLvHn1sz9cFOwApH8IwGa6Mjy9cgZAJr95SiSW2z8rCkhOFvqdP3SIKmO/UwPAEy0zkN7bBsCds8Hg/13YP1zv413hVGi/FVtqixSn6L9XAPQGul3yv7SGu2BoCNk/n94bv7Maj79p13T6X9z3P45MPCW3WvI/rU/8/LRj1T9cgR6SXd+ZPymL2DstbPI/8s/pAkIz6z/fmoB+8efYPz2XyfWgYaa/6wys72AW/j8LZImhgrf3P729Zla/n9U/ySB8B3PBqL8O2nhevvbxv17+5A+n6fe/YrGIqEGB1T+wCEGbkhaxv989QHVE5wFAzd12PTu3/T9AHUPZY2DUP3SQDST0zq2/JCxAlIoj5T+Mhe1IJkrQP/cRpl8QhtU/amc4seFts79khiUSVaz3vxYfWtjPwf2/CHscxQqD0j/ctUBQ9my3v0POnFiyXv2/pjjn2Ju/AcDk45DwBhPRP/GjwlCrv7m/aT2ciwolBsAQOzHr/wUJQCzpq5UYvtI/gDCf3SlCwb+4i7S+mukEQBDA1f8mowFA2utnRN3KyT9T+9EYAVG6v9/IVZ0enrE/7NbRtdGfzr/8y8GpRz7LP3U0vTSk18e/JzHEcwiBB0AGm8Q7AJkEQNLciyt4Esk/gLou5zoQxr+RrOfM91oBwEzd36KybgTAgLou5zoQxj/S3IsreBLJv1gCch0OHO8/FD+RxSLN4j91NL00pNfHP/zLwalHPsu/nL7/By4Pyr8tSP5h7CPiv1P70RgBUbo/2utnRN3Kyb/KfllfCpUIwLkP5zj+NwdAgDCf3SlCwT8s6auVGL7Sv2aFPlaC4eC/XrS5UVH77b/xo8JQq7+5P+TjkPAGE9G/Q30/RYbn1z8FF/ISafuLv9y1QFD2bLc/CHscxQqD0r/fi+tPROX0P6vRc+19ie0/amc4seFtsz/3EaZfEIbVv77TYpahl/o/DDsu0CaC9D90kA0k9M6tP0AdQ9ljYNS/CCI0rxjZA8BgfCaLthgHwLAIQZuSFrE/YrGIqEGB1b8kvQ982+rsv4J8EWu7jPS/ySB8B3PBqD+9vWZWv5/VvwrAByWcJgBAxFujmE9a+j89l8n1oGGmP9+agH7x59i/N03cuJUt9L8X9v4GdIz6v1yBHpJd35m/rU/8/LRj1b8mz69sydf/vyu5idMqVQLAn94bv7Majz8AhrtgaAjZv+aCE66WZ/q/lA1Mgz/p/79c7+Nd4VRoP52zweD/Xdi/TJZpMTb4AkDLWZShPOb/PysKSE4W+p2/Jr95SiSW27/PkmbE7zjnP6UAiCDmMNI/nYmLvHn1s78vJO4PW6fbv5MWA2vqSrQ/V5WLwPB51b+otXvWlbuxv54qOw+Amdy/1keqzYeRBsApIEMHgZIIQHb05bmZ366/XCluGsvI3b8W44a9X9UFQEeQtDM4rwJAFj7uU9kEvL9nFpou+9nfv3Co+JcyyQhAcdkCX2KzBUCHHnBxQd7Dvy2KLvLSYuC/o6+5YTt/AcCHCNDW+8YEwF8SFMc79MO/7bOXVSJ54b9E/pfA2S3xPzD9xaBb0uQ/DM7sj5tww7+yZIRsr87hv7c4c0SEXNG/Tr79/9M+5r+v9N6oTy3Qv5uAk/3QzeG/XcI1OVQkAUAQSV9Z7Qr9P/RrFrWXrMu/W2k5L5Qs479Zo2IBM/vkv6FuipzkFvG/SqIpagcly7+ltipxmI3kv0pmis91cfc/gWQecsRh8D93xzejiVXQv3WdNhEv9uO/D7mgYy612j+PyVPNaT2jv34LIpFt6c6/l5YW2Ga45L+LUp+2A2z9P39i5xSpRfc/piRx4P8P0r9eCC3zBAjlv5n4OKmIUf2/jj/kUAwgAsDqW/cjbNPQv9X2z6SYweS/aTdljlWd8L94R8vZ8SL3v1EZczv0b9K/GBbbqxgk5r9XdfyikfEDwPILMvas0gfAnx0V97en0r88xQk/0IPmvxGErZ681fa/9kCaiOy2/b/2BCK0wyDVvy2xROCT4ua/+5EBLOXxA0B7p53+BnkAQKKI/QV+y9i/qDznPFM86b/snWGNkkgHwC+ByugkUwdAR98lJFqQ2b9sL7HxZkPovyJNGM67oek/HzNy6BqA1D96EnqL7pLYv0v8nFypHeq/axL/u1FnB0AkSEHvxn8DQGt+gG5Pstm/QS1keLLK6b/Sk/O6mtGzPxU8pLcPNty/FssiPwWy4L+IZTNYLmzqvw4szKfSouq/G+XJHY1a87+TVW2LUjjfvwQaifgujuy/3VARaoMl2L9NFodfK+/qv+0QMvYfP+C/FvLf01HN67+ETOQysd8AwH71iI/eGgXAbHNSHrTg4L96GNJ2CFvsv6BnExReeAFA5CakvxSl+j8MzcbAuwDgv5bXzdT1Auy/uVq8/8x58z+uvPMNqzTnP2HlfZ3gqOG/Z5Uh1wDX7r8PUbMSo2P7P9VfBrXlxPI/tQvDXQ3H4r9sJXFt2GTvvyDssGgO0PG/WxT/uE4N+r+Bk03jWYvjv/bf8sHUYu+/rUXN8hUe3j9m5HB1yZCzv/yE3PUo0+K/qqAX9idJ8L9mByqLMMH5v4kHC7KQowHAm+sAswr15L8F7/a5DE/wv2JLsGADFwTAKQjVGovZCMDDkYbTbifnvwVbdNXyhfC/malhH7yI7D+oevd0GWDZP1sjk5AdouW/KH/hrXUg8b8KWmrpQ0sFQAzEAF/pTgBAhB1hfFzT5r9XK/wflZ7xv18hRuqKXAjA/5rUd9v1BED/tlxBd4bov7pQU4wLfPK/4pnwn0T/sj/c277XPF3jv02biiQ+Rum/zGkxMcl88r8Yk0HhJVzjv62yUUFRjfS/89MEdoPQ6r8TqikcRF/zvxQxghHovfY/cfM1eFWE5j9pcwp7GJPrv5ehC2fbYPO/KUV2nGg0/795OhmUaqEFwFQeuy4j+eq/ePiwytEp9L8DuqWfW+8BQLytJylXHPY/PlP4Qr8q7r+kDLLri0P1vxT4ShWL+Oo/DMsWg0zlv7/S9fINXGjtv73m373LRPW/+xg/Gaxd8b94MdQEfW0AwLjBLbDOHO+/kmm4ANp49L+cShSMMbAEwKyjUgWirAdAo2q2uqM08L99wKzM+7H2v3RdlNBXFgnA8S9+ewyV/z+vaSZre3Pxv6riWFiWZfi/2J7VSZZ60j+LES81zPn3v+OrlPMN3PK/quJYWJZl+L/OZbufkEcEQLCNB/1lPOO/Y2nmTbY/87+q4lhYlmX4v7CNB/1lPOO/zmW7n5BHBEBwKD1Aa57LP/XsSsw7RbU/PMDPJGsfoD/TqningGKIPzFtCLYmb3I/qYfrJr7eWz9pQmleXRFFP0rWlJkA2i8/pCvcttgTGD9Dt8IWbjMCPyCG4GRlhOs+1JI2GhDN1D7ns8cGvXK/Pi8m8UTJxac+hNTfA2z4kT7GI8kjLyt7Pv//////HwAI//////8zEAj/////fzIgCP////9vMjAI/////2MyQAj///8/YjJQCP///zdiMmAI////M2IycAj//78zYjKACP//qzNiMpAI/3+rM2IyoAj/D6szYjKwCP8DqzNiMsAIvwOrM2Iy0AifA6szYjLgCJkDqzNiMvAI//////8/Dwj//////ysfCP////9/KS8I/////z8pPwj/////OSlPCP///z84KV8I////Dzgpbwj///8OOCl/CP//Hw44KY8I//8PDjgpnwj/fw0OOCmvCP8PDQ44Kb8I/w0NDjgpzwj/DA0OOCnfCMcMDQ44Ke8IxAwNDjgp/wgHAAAABwAAAAEAAAACAAAABAAAAAMAAAAAAAAAAAAAAAcAAAADAAAAAQAAAAIAAAAFAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAAAgAAAAEAAAADAAAADgAAAAYAAAALAAAAAgAAAAcAAAABAAAAGAAAAAUAAAAKAAAAAQAAAAYAAAAAAAAAJgAAAAcAAAAMAAAAAwAAAAgAAAACAAAAMQAAAAkAAAAOAAAAAAAAAAUAAAAEAAAAOgAAAAgAAAANAAAABAAAAAkAAAADAAAAPwAAAAsAAAAGAAAADwAAAAoAAAAQAAAASAAAAAwAAAAHAAAAEAAAAAsAAAARAAAAUwAAAAoAAAAFAAAAEwAAAA4AAAAPAAAAYQAAAA0AAAAIAAAAEQAAAAwAAAASAAAAawAAAA4AAAAJAAAAEgAAAA0AAAATAAAAdQAAAA8AAAATAAAAEQAAABIAAAAQAAAABgAAAAIAAAADAAAABQAAAAQAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAMAAAABAAAABQAAAAQAAAAAAAAAAAAAAAcAAAAFAAAAAwAAAAQAAAABAAAAAAAAAAIAAAAAAAAAAgAAAAMAAAABAAAABQAAAAQAAAAGAAAAAAAAAAAAAAAYLURU+yH5PxgtRFT7Ifm/GC1EVPshCUAYLURU+yEJwGFsZ29zLmMAaDNOZWlnaGJvclJvdGF0aW9ucwBjZWxsc1RvTXVsdGlQb2x5LmMAY2VsbFRvRWRnZUFyY3MAAAEDAgQABAMFAQJjYW5jZWxBcmNQYWlycwBjcmVhdGVTb3J0YWJsZUxvb3AAZGlyZWN0ZWRFZGdlLmMAZGlyZWN0ZWRFZGdlVG9Cb3VuZGFyeQBhZGphY2VudEZhY2VEaXJbdG1wRmlqay5mYWNlXVtmaWprLmZhY2VdID09IEtJAGZhY2VpamsuYwBfZmFjZUlqa1BlbnRUb0NlbGxCb3VuZGFyeQBhZGphY2VudEZhY2VEaXJbY2VudGVySUpLLmZhY2VdW2ZhY2UyXSA9PSBLSQBfZmFjZUlqa1RvQ2VsbEJvdW5kYXJ5AGgzSW5kZXguYwBjb21wYWN0Q2VsbHMAdmVjM1RvQ2VsbABjZWxsVG9DaGlsZFBvcwB2YWxpZGF0ZUNoaWxkUG9zAHJldkRpciAhPSBJTlZBTElEX0RJR0lUAGxvY2FsaWouYwBjZWxsVG9Mb2NhbElqawBiYXNlQ2VsbCAhPSBvcmlnaW5CYXNlQ2VsbAAhKG9yaWdpbk9uUGVudCAmJiBpbmRleE9uUGVudCkAYmFzZUNlbGwgPT0gb3JpZ2luQmFzZUNlbGwALi4vaW5jbHVkZS9jb29yZGlqay5oAF91cEFwN0NoZWNrZWQAX3VwQXA3ckNoZWNrZWQAYmFzZUNlbGwgIT0gSU5WQUxJRF9CQVNFX0NFTEwAbG9jYWxJamtUb0NlbGwAIV9pc0Jhc2VDZWxsUGVudGFnb24oYmFzZUNlbGwpAGJhc2VDZWxsUm90YXRpb25zID49IDAAZ3JpZFBhdGhDZWxsc0ludGVycG9sYXRlAHBvbHlmaWxsLmMAaXRlclN0ZXBQb2x5Z29uQ29tcGFjdAAwAHZlcnRleC5jAHZlcnRleFJvdGF0aW9ucwBjZWxsVG9WZXJ0ZXg=";function H(e){return e}function q(e){return e.replace(/\b__Z[\w\d_]+/g,function(e){return e===e?e:e+" ["+e+"]"})}function Q(){var e=new Error;if(!e.stack){try{throw new Error(0)}catch(Gt){e=Gt}if(!e.stack)return"(no stack trace available)"}return e.stack.toString()}function K(){return h.length}function W(e){try{var t=new ArrayBuffer(e);if(t.byteLength!=e)return;return new Int8Array(t).set(h),X(t),w(t),1}catch(Gt){}}var $="function"==typeof atob?atob:function(e){var t,n,r,i,a,o,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",A="",l=0;e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{t=s.indexOf(e.charAt(l++))<<2|(i=s.indexOf(e.charAt(l++)))>>4,n=(15&i)<<4|(a=s.indexOf(e.charAt(l++)))>>2,r=(3&a)<<6|(o=s.indexOf(e.charAt(l++))),A+=String.fromCharCode(t),64!==a&&(A+=String.fromCharCode(n)),64!==o&&(A+=String.fromCharCode(r))}while(l<e.length);return A};function J(e){if(G(e))return function(e){try{for(var t=$(e),n=new Uint8Array(t.length),r=0;r<t.length;++r)n[r]=t.charCodeAt(r);return n}catch(i){throw new Error("Converting base64 string to bytes failed.")}}(e.slice(z.length))}var Y=function(e,t,n){var r=new e.Int8Array(n),i=new e.Int32Array(n);new e.Uint8Array(n),new e.Float32Array(n);var a=new e.Float64Array(n),o=0|t.o,s=0|t.p,A=e.Math.floor,l=e.Math.abs,c=e.Math.sqrt,u=e.Math.cos,f=e.Math.sin,d=e.Math.tan,h=e.Math.acos,p=e.Math.asin,m=e.Math.atan,g=e.Math.atan2,b=e.Math.ceil,v=e.Math.imul,y=e.Math.min,x=e.Math.max,_=e.Math.clz32,w=t.a,T=t.b,S=t.c,M=t.d,E=t.e,C=t.f,I=t.g,R=t.h,P=t.i,N=28416;function k(e,t,n,r){return 0|L(e|=0,t|=0,n|=0,r|=0,0)}function L(e,t,n,r,a){var o,s=0,A=0,l=0,c=0;if(o=N,N=N+16|0,A=o,!(0|B(e|=0,t|=0,n|=0,r|=0,a|=0)))return N=o,0|(r=0);do{if((0|n)>=0){if((0|n)>13780509){if(0|(s=0|We(15,A)))break;A=0|i[(l=A)>>2],l=0|i[l+4>>2]}else c=0|Ot(0|n,0|(s=((0|n)<0)<<31>>31),3,0),l=0|S(),s=0|Pt(0|n,0|s,1,0),s=0|Pt(0|(s=0|Ot(0|c,0|l,0|s,0|S())),0|S(),1,0),l=0|S(),i[A>>2]=s,i[A+4>>2]=l,A=s;if(Wt(0|r,0,A<<3),0|a){Wt(0|a,0,A<<2),s=0|O(e,t,n,r,a,A,l,0);break}(s=0|Ct(A,4))?(c=0|O(e,t,n,r,s,A,l,0),Et(s),s=c):s=13}else s=2}while(0);return N=o,0|(c=s)}function B(e,t,n,r,a){e|=0,t|=0,n|=0,r|=0,a|=0;var o,s,A=0,l=0,c=0,u=0,f=0,d=0,h=0,p=0,m=0;if(s=N,N=N+16|0,m=s+8|0,i[(p=o=s)>>2]=e,i[p+4>>2]=t,(0|n)<0)return N=s,0|(m=2);if(i[(A=r)>>2]=e,i[A+4>>2]=t,(A=!!(0|a))&&(i[a>>2]=0),0|Se(e,t))return N=s,0|(m=9);i[m>>2]=0;e:do{if((0|n)>=1)if(A)for(d=1,f=0,h=0,p=1,A=e;;){if(!(f|h)){if(0|(A=0|F(A,t,4,m,o)))break e;if(0|Se(A=0|i[(t=o)>>2],t=0|i[t+4>>2])){A=9;break e}}if(0|(A=0|F(A,t,0|i[26864+(h<<2)>>2],m,o)))break e;if(A=0|i[(t=o)>>2],t=0|i[t+4>>2],i[(e=r+(d<<3)|0)>>2]=A,i[e+4>>2]=t,i[a+(d<<2)>>2]=p,l=(0|(e=f+1|0))==(0|p),u=6==(0|(c=h+1|0)),0|Se(A,t)){A=9;break e}if((0|(p=p+(u&l&1)|0))>(0|n)){A=0;break}d=d+1|0,f=l?0:e,h=l?u?0:c:h}else for(d=1,f=0,h=0,p=1,A=e;;){if(!(f|h)){if(0|(A=0|F(A,t,4,m,o)))break e;if(0|Se(A=0|i[(t=o)>>2],t=0|i[t+4>>2])){A=9;break e}}if(0|(A=0|F(A,t,0|i[26864+(h<<2)>>2],m,o)))break e;if(A=0|i[(t=o)>>2],t=0|i[t+4>>2],i[(e=r+(d<<3)|0)>>2]=A,i[e+4>>2]=t,l=(0|(e=f+1|0))==(0|p),u=6==(0|(c=h+1|0)),0|Se(A,t)){A=9;break e}if((0|(p=p+(u&l&1)|0))>(0|n)){A=0;break}d=d+1|0,f=l?0:e,h=l?u?0:c:h}else A=0}while(0);return N=s,0|(m=A)}function O(e,t,n,r,a,o,s,A){n|=0,r|=0,a|=0,A|=0;var l,c,u,f=0,d=0,h=0,p=0,m=0,g=0,b=0;if(u=N,N=N+16|0,l=u+8|0,c=u,f=0|Dt(0|(e|=0),0|(t|=0),0|(o|=0),0|(s|=0)),h=0|S(),!(!(0|(b=0|i[(g=p=r+(f<<3)|0)>>2]))&!(0|(g=0|i[g+4>>2]))|(d=(0|b)==(0|e)&(0|g)==(0|t))))do{f=0|Ft(0|(f=0|Pt(0|f,0|h,1,0)),0|S(),0|o,0|s),h=0|S(),d=(0|(g=0|i[(b=p=r+(f<<3)|0)>>2]))==(0|e)&(0|(b=0|i[b+4>>2]))==(0|t)}while(!(!(0|g)&!(0|b)|d));if(f=a+(f<<2)|0,d&&(0|i[f>>2])<=(0|A))return N=u,0|(b=0);if(i[(b=p)>>2]=e,i[b+4>>2]=t,i[f>>2]=A,(0|A)>=(0|n))return N=u,0|(b=0);switch(d=A+1|0,i[l>>2]=0,0|(f=0|F(e,t,2,l,c))){case 9:m=9;break;case 0:(f=0|O(0|i[(f=c)>>2],0|i[f+4>>2],n,r,a,o,s,d))||(m=9)}e:do{if(9==(0|m)){switch(i[l>>2]=0,0|(f=0|F(e,t,3,l,c))){case 9:break;case 0:if(0|(f=0|O(0|i[(f=c)>>2],0|i[f+4>>2],n,r,a,o,s,d)))break e;break;default:break e}switch(i[l>>2]=0,0|(f=0|F(e,t,1,l,c))){case 9:break;case 0:if(0|(f=0|O(0|i[(f=c)>>2],0|i[f+4>>2],n,r,a,o,s,d)))break e;break;default:break e}switch(i[l>>2]=0,0|(f=0|F(e,t,5,l,c))){case 9:break;case 0:if(0|(f=0|O(0|i[(f=c)>>2],0|i[f+4>>2],n,r,a,o,s,d)))break e;break;default:break e}switch(i[l>>2]=0,0|(f=0|F(e,t,4,l,c))){case 9:break;case 0:if(0|(f=0|O(0|i[(f=c)>>2],0|i[f+4>>2],n,r,a,o,s,d)))break e;break;default:break e}switch(i[l>>2]=0,0|(f=0|F(e,t,6,l,c))){case 9:break;case 0:if(0|(f=0|O(0|i[(f=c)>>2],0|i[f+4>>2],n,r,a,o,s,d)))break e;break;default:break e}return N=u,0|(b=0)}}while(0);return N=u,0|(b=f)}function F(e,t,n,r,a){e|=0,t|=0,a|=0;var o,s,A,l=0,c=0,u=0,f=0,d=0,h=0;if((n|=0)>>>0>6)return 0|(a=1);c=(0|i[(r|=0)>>2])%6|0,i[r>>2]=c;e:do{if((0|c)>0)for(l=0;;){switch(0|n){case 1:n=5;break;case 5:n=4;break;case 4:n=6;break;case 6:n=2;break;case 2:n=3;break;case 3:n=1}if((0|(l=l+1|0))==(0|c))break e}}while(0);if(A=0|Vt(0|e,0|t,45),S(),(s=127&A)>>>0>121)return 0|(a=5);o=0|Ce(e,t),l=0|Vt(0|e,0|t,52),S(),l&=15;e:do{if(l){for(;;){if(u=0|Vt(0|e,0|t,0|(c=3*(15-l|0)|0)),S(),7==(0|(u&=7))){t=5;break}if(h=!(0|Le(l)),l=l+-1|0,d=0|jt(7,0,0|c),t&=~S(),e=0|jt(0|i[(h?432:16)+(28*u|0)+(n<<2)>>2],0,0|c)|e&~d,t|=c=0|S(),!(n=0|i[(h?640:224)+(28*u|0)+(n<<2)>>2])){n=0;break e}if(!l){f=15;break e}}return 0|t}f=15}while(0);15==(0|f)&&(e|=0|jt(0|(h=0|i[848+(28*s|0)+(n<<2)>>2]),0,45),t=S()|-1040385&t,n=0|i[4272+(28*s|0)+(n<<2)>>2],127&~h||(h=0|jt(0|i[848+(28*s|0)+20>>2],0,45),t=S()|-1040385&t,n=0|i[4272+(28*s|0)+20>>2],e=0|Re(h|e,t),t=0|S(),i[r>>2]=1+(0|i[r>>2]))),u=0|Vt(0|e,0|t,45),S(),u&=127;e:do{if(0|G(u)){t:do{if(1==(0|Ce(e,t))){if((0|s)!=(0|u)){if(0|K(u,0|i[7696+(28*s|0)>>2])){e=0|Ne(e,t),c=1,t=0|S();break}M(27634,26928,533,26936)}switch(0|o){case 3:e=0|Re(e,t),t=0|S(),i[r>>2]=1+(0|i[r>>2]),c=0;break t;case 5:e=0|Ne(e,t),t=0|S(),i[r>>2]=5+(0|i[r>>2]),c=0;break t;case 0:return 0|(h=9);default:return 0|(h=1)}}else c=0}while(0);if((0|n)>0){l=0;do{e=0|Ie(e,t),t=0|S(),l=l+1|0}while((0|l)!=(0|n))}if((0|s)!=(0|u)){if(!(0|H(u))){if(!!(0|c)|5!=(0|Ce(e,t)))break;i[r>>2]=1+(0|i[r>>2]);break}switch(127&A){case 8:case 118:break e}3!=(0|Ce(e,t))&&(i[r>>2]=1+(0|i[r>>2]))}}else if((0|n)>0){l=0;do{e=0|Re(e,t),t=0|S(),l=l+1|0}while((0|l)!=(0|n))}}while(0);return i[r>>2]=((0|i[r>>2])+n|0)%6|0,i[(h=a)>>2]=e,i[h+4>>2]=t,0|(h=0)}function D(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a,o,s=0,A=0,l=0,c=0,u=0,f=0,d=0,h=0,p=0;if(o=N,N=N+16|0,p=o+8|0,i[(h=a=o)>>2]=e,i[h+4>>2]=t,(0|n)<0)return N=o,0|(p=2);if(!n)return i[(p=r)>>2]=e,i[p+4>>2]=t,N=o,0|(p=0);i[p>>2]=0;e:do{if(0|Se(e,t))e=9;else{s=0,h=e;do{if(0|(e=0|F(h,t,4,p,a)))break e;if(s=s+1|0,0|Se(h=0|i[(t=a)>>2],t=0|i[t+4>>2])){e=9;break e}}while((0|s)<(0|n));i[(d=r)>>2]=h,i[d+4>>2]=t,d=n+-1|0,f=0,e=1;do{if(s=26864+(f<<2)|0,5==(0|f))for(l=0|i[s>>2],A=0,s=e;;){if(0|(e=0|F(0|i[(e=a)>>2],0|i[e+4>>2],l,p,a)))break e;if((0|A)!=(0|d)){if(c=0|i[(u=a)>>2],u=0|i[u+4>>2],i[(e=r+(s<<3)|0)>>2]=c,i[e+4>>2]=u,0|Se(c,u)){e=9;break e}e=s+1|0}else e=s;if((0|(A=A+1|0))>=(0|n))break;s=e}else for(l=a,u=0|i[s>>2],c=0,s=e,A=0|i[l>>2],l=0|i[l+4>>2];;){if(0|(e=0|F(A,l,u,p,a)))break e;if(A=0|i[(l=a)>>2],l=0|i[l+4>>2],i[(e=r+(s<<3)|0)>>2]=A,i[e+4>>2]=l,e=s+1|0,0|Se(A,l)){e=9;break e}if((0|(c=c+1|0))>=(0|n))break;s=e}f=f+1|0}while(f>>>0<6);e=(0|h)==(0|i[(e=a)>>2])&&(0|t)==(0|i[e+4>>2])?0:9}}while(0);return N=o,0|(p=e)}function U(e,t,n,r){e|=0,t|=0,r|=0;var a,o=0,s=0,A=0,l=0,c=0,u=0,f=0,d=0;if(a=N,N=N+16|0,A=a,!(n|=0))return i[r>>2]=e,i[r+4>>2]=t,N=a,0|(r=0);do{if((0|n)>=0){if((0|n)>13780509){if(0|(o=0|We(15,A)))break;o=0|i[(s=A)>>2],s=0|i[s+4>>2]}else f=0|Ot(0|n,0|(o=((0|n)<0)<<31>>31),3,0),s=0|S(),o=0|Pt(0|n,0|o,1,0),o=0|Pt(0|(o=0|Ot(0|f,0|s,0|o,0|S())),0|S(),1,0),s=0|S(),i[(f=A)>>2]=o,i[f+4>>2]=s;if(u=0|Ct(o,8)){if(!(f=0|Ct(o,4))){Et(u),o=13;break}if(0|(o=0|O(e,t,n,u,f,o,s,0))){Et(u),Et(f);break}if(t=0|i[A>>2],(0|(A=0|i[A+4>>2]))>0|!(0|A)&t>>>0>0){o=0,l=0,c=0;do{!(0|(s=0|i[(e=u+(l<<3)|0)>>2]))&!(0|(e=0|i[e+4>>2]))||(0|i[f+(l<<2)>>2])!=(0|n)||(i[(d=r+(o<<3)|0)>>2]=s,i[d+4>>2]=e,o=o+1|0),l=0|Pt(0|l,0|c,1,0),c=0|S()}while((0|c)<(0|A)|(0|c)==(0|A)&l>>>0<t>>>0)}Et(u),Et(f),o=0}else o=13}else o=2}while(0);return N=a,0|(d=o)}function V(e,t,n,r){n|=0,r|=0;var a,o,s,A=0,l=0;for(s=N,N=N+16|0,a=s,o=s+8|0,A=(A=!(0|Se(e|=0,t|=0)))?1:2;;){if(i[o>>2]=0,!(0|F(e,t,A,o,a))&((0|i[(l=a)>>2])==(0|n)?(0|i[l+4>>2])==(0|r):0)){e=4;break}if((A=A+1|0)>>>0>=7){A=7,e=4;break}}return 4==(0|e)?(N=s,0|A):0}function j(e,t,n,r,o,s,A){t|=0,n|=0,r|=0,o|=0,s|=0,A|=0;var l,c,u,f,d,h,p,m,g,b,v=0,y=0,x=0,_=0,w=0,T=0,M=0,E=0,C=0,I=0,R=0,P=0,k=0,L=0,B=0,O=0,F=0,D=0,U=0;if(b=N,N=N+64|0,p=b+48|0,m=b+32|0,g=b+24|0,l=b+8|0,c=b,(0|(y=0|i[(e|=0)>>2]))<=0)return N=b,0|(B=0);for(u=e+4|0,f=p+8|0,d=m+8|0,h=l+8|0,v=0,k=0;;){P=(x=0|i[u>>2])+(k<<4)|0,i[p>>2]=i[P>>2],i[p+4>>2]=i[P+4>>2],i[p+8>>2]=i[P+8>>2],i[p+12>>2]=i[P+12>>2],(0|k)==(y+-1|0)?(i[m>>2]=i[x>>2],i[m+4>>2]=i[x+4>>2],i[m+8>>2]=i[x+8>>2],i[m+12>>2]=i[x+12>>2]):(P=x+(k+1<<4)|0,i[m>>2]=i[P>>2],i[m+4>>2]=i[P+4>>2],i[m+8>>2]=i[P+8>>2],i[m+12>>2]=i[P+12>>2]),y=0|re(p,m,r,g);e:do{if(y)x=0,v=y;else if(x=0|i[(y=g)>>2],(0|(y=0|i[y+4>>2]))>0|!(0|y)&x>>>0>0){R=0,P=0;t:for(;;){if(F=1/(+(x>>>0)+4294967296*+(0|y)),U=+a[p>>3],D=+((y=0|Nt(0|x,0|y,0|R,0|P))>>>0)+4294967296*+(0|S()),O=+(R>>>0)+4294967296*+(0|P),a[l>>3]=F*(U*D)+F*(+a[m>>3]*O),a[h>>3]=F*(+a[f>>3]*D)+F*(+a[d>>3]*O),0|(y=0|Be(l,r,c))){v=y;break}T=0|Dt(0|(C=0|i[(I=c)>>2]),0|(I=0|i[I+4>>2]),0|t,0|n),_=0|S(),x=0|i[(w=y=A+(T<<3)|0)>>2],w=0|i[w+4>>2];n:do{if(!(0|x)&!(0|w))L=y,B=16;else for(M=0,E=0;;){if((0|M)>(0|n)|(0|M)==(0|n)&E>>>0>t>>>0){v=1;break t}if((0|x)==(0|C)&(0|w)==(0|I))break n;if(T=0|Ft(0|(y=0|Pt(0|T,0|_,1,0)),0|S(),0|t,0|n),_=0|S(),E=0|Pt(0|E,0|M,1,0),M=0|S(),!(0|(x=0|i[(w=y=A+(T<<3)|0)>>2]))&!(0|(w=0|i[w+4>>2]))){L=y,B=16;break}}}while(0);if(16!=(0|B)||(B=0,!(0|C)&!(0|I))||(i[(E=L)>>2]=C,i[E+4>>2]=I,E=s+(i[o>>2]<<3)|0,i[E>>2]=C,i[E+4>>2]=I,E=0|Pt(0|i[(E=o)>>2],0|i[E+4>>2],1,0),C=0|S(),i[(I=o)>>2]=E,i[I+4>>2]=C),R=0|Pt(0|R,0|P,1,0),P=0|S(),x=0|i[(y=g)>>2],!((0|(y=0|i[y+4>>2]))>(0|P)|(0|y)==(0|P)&x>>>0>R>>>0)){x=1;break e}}x=0}else x=1}while(0);if(k=k+1|0,!x){B=21;break}if((0|k)>=(0|(y=0|i[e>>2]))){v=0,B=21;break}}return 21==(0|B)?(N=b,0|v):0}function z(e,t){t|=0;var n,r=0,o=0,s=0,A=0,l=0,c=0,d=0,h=0,p=0;if((0|(A=0|i[(e|=0)>>2]))<=0)return o=(s=0)+(o=12.566370614359172-(o=0)),s=(A=s<0)?o:s,a[t>>3]=s,0;if(n=0|i[e+4>>2],e=1!=(0|A)&1,l=.5*+a[n>>3]+.7853981633974483,s=.5*+a[n+(e<<4)>>3]+.7853981633974483,r=+f(+l)*+f(+s),o=+a[n+(e<<4)+8>>3]-+a[n+8>>3],r=(o=(r=-2*+g(+ +f(+o)*r,+(+u(+l)*+u(+s)+ +u(+o)*r)))+0)-r,1==(0|A))return s=(l=o)+(s=12.566370614359172-(s=r)),l=(A=l<0)?s:l,a[t>>3]=l,0;for(e=1,s=o;h=e,p=(0|(e=e+1|0))%(0|A)|0,d=.5*+a[n+(h<<4)>>3]+.7853981633974483,c=.5*+a[n+(p<<4)>>3]+.7853981633974483,o=+f(+d)*+f(+c),l=+a[n+(p<<4)+8>>3]-+a[n+(h<<4)+8>>3],r=(o=s+(r=-2*+g(+ +f(+l)*o,+(+u(+d)*+u(+c)+ +u(+l)*o))-r))-s-r,!((0|e)>=(0|A));)s=o;return d=o+(d=12.566370614359172-r),d=(p=o<0)?d:o,a[t>>3]=d,0}function G(e){return(e|=0)>>>0>121?0|(e=0):0|(e=0|i[7696+(28*e|0)+16>>2])}function H(e){return 4==(0|(e|=0))|117==(0|e)|0}function q(e){return 0|i[11120+(216*(0|i[(e|=0)>>2])|0)+(72*(0|i[e+4>>2])|0)+(24*(0|i[e+8>>2])|0)+(i[e+12>>2]<<3)>>2]}function Q(e){return 0|i[11120+(216*(0|i[(e|=0)>>2])|0)+(72*(0|i[e+4>>2])|0)+(24*(0|i[e+8>>2])|0)+(i[e+12>>2]<<3)+4>>2]}function K(e,t){return t|=0,(0|i[7696+(28*(e|=0)|0)+20>>2])==(0|t)?0|(t=1):0|(t=(0|i[7696+(28*e|0)+24>>2])==(0|t))}function W(e,t){return 0|i[848+(28*(e|=0)|0)+((t|=0)<<2)>>2]}function $(e,t){return t|=0,(0|i[848+(28*(e|=0)|0)>>2])==(0|t)?0|(t=0):(0|i[848+(28*e|0)+4>>2])==(0|t)?0|(t=1):(0|i[848+(28*e|0)+8>>2])==(0|t)?0|(t=2):(0|i[848+(28*e|0)+12>>2])==(0|t)?0|(t=3):(0|i[848+(28*e|0)+16>>2])==(0|t)?0|(t=4):(0|i[848+(28*e|0)+20>>2])==(0|t)?0|(t=5):0|((0|i[848+(28*e|0)+24>>2])==(0|t)?6:7)}function J(e){var t,n,r;return t=(r=+a[(e|=0)+16>>3])-(n=+a[e+24>>3]),+(r<n?t+6.283185307179586:t)}function Y(e){return+(+a[(e|=0)>>3]-+a[e+8>>3])}function X(e,t){e|=0;var n,r,i=0;return(i=+a[(t|=0)>>3])>=+a[e+8>>3]&&i<=+a[e>>3]?(n=+a[e+16>>3],i=+a[e+24>>3],t=(r=+a[t+8>>3])>=i,e=r<=n&1,n<i?t&&(e=1):t||(e=0),0|(t=!!(0|e))):0|(t=0)}function Z(e,t){t|=0;var n,r,i,o,s,A=0,l=0,c=0,u=0;return+a[(e|=0)>>3]<+a[t+8>>3]||+a[e+8>>3]>+a[t>>3]?0|(A=0):(i=(l=+a[e+16>>3])<(u=+a[(n=e+24|0)>>3]),c=(s=+a[(A=t+16|0)>>3])<(o=+a[(r=t+24|0)>>3]),t=u-s<o-l,e=i?c|t?1:2:0,t=c?i?1:t?2:1:0,(l=+qe(l,e))<+qe(+a[r>>3],t)||(u=+qe(+a[n>>3],e))>+qe(+a[A>>3],t)?0|(c=0):0|(c=1))}function ee(e,t){t|=0;var n,r,i,o,s,A=0,l=0,c=0,u=0;return+a[(e|=0)>>3]<+a[t>>3]||+a[e+8>>3]>+a[t+8>>3]?0|(A=0):(i=(o=+a[(A=e+16|0)>>3])<(l=+a[e+24>>3]),c=(u=+a[(n=t+16|0)>>3])<(s=+a[(r=t+24|0)>>3]),t=l-u<s-o,e=i?c|t?1:2:0,t=c?i?1:t?2:1:0,(l=+qe(l,e))<=+qe(+a[r>>3],t)?0|(c=(u=+qe(+a[A>>3],e))>=+qe(+a[n>>3],t)):0|(c=0))}function te(e,t){e|=0,t|=0;var n,r,o,s,A,l=0;o=N,N=N+176|0,i[(r=o)>>2]=4,l=+a[t>>3],a[r+8>>3]=l,s=+a[t+16>>3],a[r+16>>3]=s,a[r+24>>3]=l,l=+a[t+24>>3],a[r+32>>3]=l,A=+a[t+8>>3],a[r+40>>3]=A,a[r+48>>3]=l,a[r+56>>3]=A,a[r+64>>3]=s,n=(t=r+72|0)+96|0;do{i[t>>2]=0,t=t+4|0}while((0|t)<(0|n));Qt(0|e,0|r,168),N=o}function ne(e,t,n){e|=0,t|=0,n|=0;var r,s,c,u,f,d,h,p=0,m=0,g=0,v=0,x=0,_=0,w=0;d=N,N=N+288|0,f=d+264|0,v=d+96|0,m=(p=g=d)+96|0;do{i[p>>2]=0,p=p+4|0}while((0|p)<(0|m));return 0|(t=0|Ve(t,g))?(N=d,0|(_=t)):(De(g=0|i[(m=g)>>2],m=0|i[m+4>>2],f),Ue(g,m,v),u=+Qe(f,v+8|0),a[f>>3]=+a[e>>3],a[(m=f+8|0)>>3]=+a[e+16>>3],a[v>>3]=+a[e+8>>3],a[(g=v+8|0)>>3]=+a[e+24>>3],s=+Qe(f,v),w=+a[m>>3]-+a[g>>3],c=+l(+w),h=+a[f>>3]-+a[v>>3],r=+l(+h),!(0==w|0==h)&&(w=+Gt(+c,+r),w=+b(+s*s/+Ht(+w/+Ht(+c,+r),3)/(u*(2.59807621135*u)*.8)),a[o>>3]=w,x=~~w>>>0,_=+l(w)>=1?w>0?~~+y(+A(w/4294967296),4294967295)>>>0:~~+b((w-+(~~w>>>0))/4294967296)>>>0:0,2146435072&~i[o+4>>2])?(v=!(0|x)&!(0|_),i[(t=n)>>2]=v?1:x,i[t+4>>2]=v?0:_,t=0):t=1,N=d,0|(_=t))}function re(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var s,c,u,f,d=0,h=0,p=0;f=N,N=N+288|0,c=f+264|0,u=f+96|0,s=(d=h=f)+96|0;do{i[d>>2]=0,d=d+4|0}while((0|d)<(0|s));return 0|(n=0|Ve(n,h))?(N=f,0|(r=n)):(De(d=0|i[(n=h)>>2],n=0|i[n+4>>2],c),Ue(d,n,u),p=+Qe(c,u+8|0),p=+b(+ +Qe(e,t)/(2*p)),a[o>>3]=p,n=~~p>>>0,d=+l(p)>=1?p>0?~~+y(+A(p/4294967296),4294967295)>>>0:~~+b((p-+(~~p>>>0))/4294967296)>>>0:0,2146435072&~i[o+4>>2]?(h=!(0|n)&!(0|d),i[r>>2]=h?1:n,i[r+4>>2]=h?0:d,N=f,0|(r=0)):(N=f,0|(r=1)))}function ie(e,t,n,o){e|=0,o|=0;var s,A=0,l=0,c=0,u=0,f=0,d=0,h=0,p=0,m=0,g=0,b=0,v=0,y=0,x=0,_=0,w=0,T=0,E=0,C=0,I=0,R=0,P=0,k=0,L=0,B=0;if(s=N,N=N+224|0,P=s,E=s+48|0,(f=(0|(n|=0))>0|!(0|n)&(t|=0)>>>0>0)&(n>>>0>0|!(0|n)&t>>>0>17895697))return N=s,0|(B=14);if((0|n)<0)return N=s,0|(B=2);if(!(0|t)&!(0|n))return i[o>>2]=0,i[o+4>>2]=0,N=s,0|(B=0);for(A=0|ve(0|i[(A=e)>>2],0|i[A+4>>2]),c=0,u=0;;){if(!(0|xe(0|i[(B=l=e+(c<<3)|0)>>2],0|i[B+4>>2]))){A=5,k=159;break}if(B=(0|ve(0|i[(B=l)>>2],0|i[B+4>>2]))==(0|A),c=0|Pt(0|c,0|u,1,0),u=0|S(),!B){A=12,k=159;break}if(!((0|u)<(0|n)|(0|u)==(0|n)&c>>>0<t>>>0)){k=8;break}}if(8==(0|k)){do{if((0|n)>0|!(0|n)&t>>>0>1){if(!(c=0|Mt(A=t<<3)))return N=s,0|(B=13);for(Qt(0|c,0|e,0|A),gt(c,t,8,1),A=1,l=0;B=c+(A+-1<<3)|0,B=(0|i[(L=c+(A<<3)|0)>>2])==(0|i[B>>2])?(0|i[L+4>>2])==(0|i[B+4>>2]):0,A=0|Pt(0|A,0|l,1,0),l=0|S(),!B;)if(!((0|l)<(0|n)|(0|l)==(0|n)&A>>>0<t>>>0)){k=14;break}if(14==(0|k)){Et(c);break}return Et(c),N=s,0|(B=10)}}while(0);if(A=0|Ot(0|t,0|n,6,0),l=0|S(),f){c=0,u=0;do{A=0|Pt(0|A,0|l,0|(B=!!(0|Se(0|i[(B=e+(u<<3)|0)>>2],0|i[B+4>>2]))<<31>>31),((0|B)<0)<<31>>31),l=0|S(),u=0|Pt(0|u,0|c,1,0),c=0|S()}while((0|c)<(0|n)|(0|c)==(0|n)&u>>>0<t>>>0);T=A,w=l}else T=A,w=l;if(x=0|Ot(0|T,0|w,10,0),_=0|S(),!(L=0|Mt(T<<5)))return N=s,0|(B=13);if(!(B=0|Ct(x,4)))return Et(L),N=s,0|(B=13);e:do{if(f){for(se(0|i[(R=e)>>2],0|i[R+4>>2],P),g=L,b=0,v=0,A=0,y=0;;){l=(f=!(0|i[(f=P)>>2])&!(0|i[f+4>>2]))?26990:26995,c=f?5:6,f=P+((1&f)<<3)|0,d=0|Pt(0|c,0|(u=0),-1,-1),h=0|S(),p=0,m=0;do{C=0|i[(I=f+(p<<3)|0)+4>>2],i[(R=g+(p<<5)|0)>>2]=i[I>>2],i[R+4>>2]=C,r[g+(p<<5)+9|0]=0,r[g+(p<<5)+8|0]=0,i[g+(p<<5)+20>>2]=g,i[(R=g+(p<<5)+24|0)>>2]=1,i[R+4>>2]=0,R=0|r[l+p|0],C=0|Dt(0|(C=0|Pt(0|d,0|h,0|p,0|m)),0|S(),0|c,0|u),S(),C=0|r[l+C|0],p=0|Pt(0|p,0|m,1,0),m=0|S(),I=0|r[l+((0|p)==(0|c)&(0|m)==(0|u)?0:p)|0],i[g+((R&=255)<<5)+16>>2]=g+((255&C)<<5),i[g+(R<<5)+12>>2]=g+((255&I)<<5)}while(m>>>0<u>>>0|(0|m)==(0|u)&p>>>0<c>>>0);if(b=0|Pt(0|b,0|v,1,0),v=0|S(),A=0|Pt(0|c,0|u,0|A,0|y),y=0|S(),!((0|v)<(0|n)|(0|v)==(0|n)&b>>>0<t>>>0))break e;0|se(0|i[(R=e+(b<<3)|0)>>2],0|i[R+4>>2],P)||(g=L+(A<<5)|0)}M(27634,26956,108,26975)}}while(0);if((0|w)>0|!(0|w)&T>>>0>0){u=0,f=0;do{if(A=0|Vt(0|(c=0|i[(l=L+(u<<5)|0)>>2]),0|(l=0|i[l+4>>2]),30),A=0|Vt(0|(l=0|Ot(A^c|0,(0|S())^l,484763065,-1084733587)),0|(c=0|S()),27),l=0|Dt((A=0|Vt(0|(c=0|Ot(A^l|0,(0|S())^c,321982955,-1798288965)),0|(l=0|S()),31))^c|0,(0|S())^l,0|x,0|_),c=0|S(),0|i[(A=B+(l<<2)|0)>>2])do{l=0|Ft(0|(A=0|Pt(0|l,0|c,1,0)),0|S(),0|x,0|_),c=0|S(),A=B+(l<<2)|0}while(0|i[A>>2]);i[A>>2]=L+(u<<5),u=0|Pt(0|u,0|f,1,0),f=0|S()}while((0|f)<(0|w)|(0|f)==(0|w)&u>>>0<T>>>0);p=0,m=0;do{if(u=L+(p<<5)|0,!(0|r[(f=L+(p<<5)+9|0)|0])){if(0|le(0|i[(R=u)>>2],0|i[R+4>>2],P)){k=39;break}l=0|Vt(0|(d=0|i[(h=P)>>2]),0|(h=0|i[h+4>>2]),30),A=0|Vt(0|(l=0|Ot(l^d|0,(0|S())^h,484763065,-1084733587)),0|(c=0|S()),27),l=0|Dt((A=0|Vt(0|(c=0|Ot(A^l|0,(0|S())^c,321982955,-1798288965)),0|(l=0|S()),31))^c|0,(0|S())^l,0|x,0|_),c=0|S(),A=0|i[B+(l<<2)>>2];e:do{if(0|A){for(;(0|i[(R=A)>>2])!=(0|d)||(0|i[R+4>>2])!=(0|h);)if(l=0|Ft(0|(A=0|Pt(0|l,0|c,1,0)),0|S(),0|x,0|_),c=0|S(),!(A=0|i[B+(l<<2)>>2]))break e;r[f|0]=1,r[A+9|0]=1,l=A+16|0,i[16+(0|i[(R=L+(p<<5)+12|0)>>2])>>2]=i[l>>2],n=A+12|0,I=0|i[L+(p<<5)+16>>2],i[I+12>>2]=i[n>>2],i[16+(0|i[n>>2])>>2]=I,i[12+(0|i[l>>2])>>2]=i[R>>2],l=0|ae(u),R=0|ae(A),A=(I=(0|(n=0|i[(A=l+24|0)+4>>2]))<(0|(C=0|i[(I=R+24|0)+4>>2]))|((0|n)==(0|C)?(0|i[A>>2])>>>0<(0|i[I>>2])>>>0:0))?l:R,(0|(l=I?R:l))!=(0|A)&&(C=A+24|0,C=0|Pt(0|i[(I=R=l+24|0)>>2],0|i[I+4>>2],0|i[C>>2],0|i[C+4>>2]),I=0|S(),i[R>>2]=C,i[R+4>>2]=I,i[A+20>>2]=l)}}while(0)}p=0|Pt(0|p,0|m,1,0),m=0|S()}while((0|m)<(0|w)|(0|m)==(0|w)&p>>>0<T>>>0);39==(0|k)&&M(27634,26956,258,27001),A=0,l=0;do{r[L+(A<<5)+8|0]=0,A=0|Pt(0|A,0|l,1,0),l=0|S()}while((0|l)<(0|w)|(0|l)==(0|w)&A>>>0<T>>>0);for(d=0,c=0,f=0,h=0;;){if(A=L+(d<<5)|0,0|r[L+(d<<5)+8|0]||0|r[L+(d<<5)+9|0])u=f;else{l=0|i[(u=A)>>2],u=0|i[u+4>>2];do{r[A+8|0]=1,R=A=0|i[A+12>>2]}while((0|i[R>>2])!=(0|l)||(0|i[R+4>>2])!=(0|u));c=0|Pt(0|c,0|f,1,0),u=0|S()}if(d=0|Pt(0|d,0|h,1,0),!((0|(h=0|S()))<(0|w)|(0|h)==(0|w)&d>>>0<T>>>0))break;f=u}A=0,l=0;do{r[L+(A<<5)+8|0]=0,A=0|Pt(0|A,0|l,1,0),l=0|S()}while((0|l)<(0|w)|(0|l)==(0|w)&A>>>0<T>>>0);I=c,C=u,A=1}else I=0,C=0,A=0;R=0|Mt(24*I|0);e:do{if(0|R){t:do{if(A){e=0,x=0,n=0,t=0;n:for(;;){if(A=L+(e<<5)|0,0|r[L+(e<<5)+8|0]||0|r[L+(e<<5)+9|0])l=n,A=x;else{v=0|i[(y=A)>>2],y=0|i[y+4>>2],l=0,c=0;do{l=0|Pt(0|l,0|c,2,0),c=0|S(),_=A=0|i[A+12>>2]}while((0|i[_>>2])!=(0|v)||(0|i[_+4>>2])!=(0|y));if(!(b=0|Mt(l<<4)))break;l=v,c=y,g=0,m=0,u=0,f=0;do{if(0|Ae(l,c,E)){k=69;break n}if(p=((0|(h=(_=0|i[E>>2])+-1|0))<0)<<31>>31,(0|_)>1){c=u,d=0,l=f,u=0;do{f=E+8+(d<<4)|0,i[(_=b+(c<<4)|0)>>2]=i[f>>2],i[_+4>>2]=i[f+4>>2],i[_+8>>2]=i[f+8>>2],i[_+12>>2]=i[f+12>>2],c=0|Pt(0|c,0|l,1,0),l=0|S(),d=0|Pt(0|d,0|u,1,0),u=0|S()}while((0|u)<(0|p)|(0|u)==(0|p)&d>>>0<h>>>0);u=c,f=l}g=0|Pt(0|g,0|m,0|h,0|p),m=0|S(),r[A+8|0]=1,A=0|i[A+12>>2],l=0|i[(c=A)>>2],c=0|i[c+4>>2]}while(!((0|l)==(0|v)&(0|c)==(0|y)));if(!(l=0|It(b,g<<4))){k=75;break}y=0|ae(A),_=0|i[y+4>>2],i[(A=R+(24*n|0)|0)>>2]=i[y>>2],i[A+4>>2]=_,i[(A=R+(24*n|0)+16|0)>>2]=g,i[R+(24*n|0)+20>>2]=l,i[P>>2]=i[A>>2],i[P+4>>2]=i[A+4>>2],z(P,R+(24*n|0)+8|0),l=0|Pt(0|n,0|x,1,0),A=0|S()}if(e=0|Pt(0|e,0|t,1,0),!((0|(t=0|S()))<(0|w)|(0|t)==(0|w)&e>>>0<T>>>0))break t;x=A,n=l}if(69==(0|k)?M(27634,26956,351,27016):75==(0|k)&&Et(b),(0|x)>0|!(0|x)&n>>>0>0)for(u=0,f=0,A=n,c=x;(l=0|i[R+(24*u|0)+20>>2])?(Et(l),l=x,A=n):l=c,u=0|Pt(0|u,0|f,1,0),(0|(f=0|S()))<(0|l)|(0|f)==(0|l)&u>>>0<A>>>0;)c=l;Et(R);break e}}while(0);gt(R,I,24,2);t:do{if(!(0|I)&!(0|C)){if(0|(_=0|Mt(192))){if(i[_+16>>2]=0,i[_+20>>2]=0,i[(m=_+8|0)>>2]=3,A=0|Mt(48),i[(g=_+12|0)>>2]=A,0|A){i[A>>2]=i[3860],i[A+4>>2]=i[3861],i[A+8>>2]=i[3862],i[A+12>>2]=i[3863],i[(p=A+16|0)>>2]=i[3864],i[p+4>>2]=i[3865],i[p+8>>2]=i[3866],i[p+12>>2]=i[3867],i[(p=A+32|0)>>2]=i[3868],i[p+4>>2]=i[3869],i[p+8>>2]=i[3870],i[p+12>>2]=i[3871],i[P>>2]=i[m>>2],i[P+4>>2]=i[m+4>>2],z(P,_),i[_+40>>2]=0,i[_+44>>2]=0,i[(p=_+32|0)>>2]=3,A=0|Mt(48),i[(b=_+36|0)>>2]=A;do{if(A){if(i[A>>2]=i[3872],i[A+4>>2]=i[3873],i[A+8>>2]=i[3874],i[A+12>>2]=i[3875],i[(h=A+16|0)>>2]=i[3876],i[h+4>>2]=i[3877],i[h+8>>2]=i[3878],i[h+12>>2]=i[3879],i[(h=A+32|0)>>2]=i[3880],i[h+4>>2]=i[3881],i[h+8>>2]=i[3882],i[h+12>>2]=i[3883],i[P>>2]=i[p>>2],i[P+4>>2]=i[p+4>>2],z(P,_+24|0),i[_+64>>2]=0,i[_+68>>2]=0,i[(h=_+56|0)>>2]=3,A=0|Mt(48),i[(v=_+60|0)>>2]=A,!A){u=0,f=2;break}if(i[A>>2]=i[3884],i[A+4>>2]=i[3885],i[A+8>>2]=i[3886],i[A+12>>2]=i[3887],i[(d=A+16|0)>>2]=i[3888],i[d+4>>2]=i[3889],i[d+8>>2]=i[3890],i[d+12>>2]=i[3891],i[(d=A+32|0)>>2]=i[3892],i[d+4>>2]=i[3893],i[d+8>>2]=i[3894],i[d+12>>2]=i[3895],i[P>>2]=i[h>>2],i[P+4>>2]=i[h+4>>2],z(P,_+48|0),i[_+88>>2]=0,i[_+92>>2]=0,i[(d=_+80|0)>>2]=3,A=0|Mt(48),i[(y=_+84|0)>>2]=A,!A){u=0,f=3;break}if(i[A>>2]=i[3896],i[A+4>>2]=i[3897],i[A+8>>2]=i[3898],i[A+12>>2]=i[3899],i[(f=A+16|0)>>2]=i[3900],i[f+4>>2]=i[3901],i[f+8>>2]=i[3902],i[f+12>>2]=i[3903],i[(f=A+32|0)>>2]=i[3904],i[f+4>>2]=i[3905],i[f+8>>2]=i[3906],i[f+12>>2]=i[3907],i[P>>2]=i[d>>2],i[P+4>>2]=i[d+4>>2],z(P,_+72|0),i[_+112>>2]=0,i[_+116>>2]=0,i[(f=_+104|0)>>2]=3,A=0|Mt(48),i[(e=_+108|0)>>2]=A,!A){u=0,f=4;break}if(i[A>>2]=i[3908],i[A+4>>2]=i[3909],i[A+8>>2]=i[3910],i[A+12>>2]=i[3911],i[(u=A+16|0)>>2]=i[3912],i[u+4>>2]=i[3913],i[u+8>>2]=i[3914],i[u+12>>2]=i[3915],i[(u=A+32|0)>>2]=i[3916],i[u+4>>2]=i[3917],i[u+8>>2]=i[3918],i[u+12>>2]=i[3919],i[P>>2]=i[f>>2],i[P+4>>2]=i[f+4>>2],z(P,_+96|0),i[_+136>>2]=0,i[_+140>>2]=0,i[(u=_+128|0)>>2]=3,A=0|Mt(48),i[(t=_+132|0)>>2]=A,!A){u=0,f=5;break}if(i[A>>2]=i[3920],i[A+4>>2]=i[3921],i[A+8>>2]=i[3922],i[A+12>>2]=i[3923],i[(c=A+16|0)>>2]=i[3924],i[c+4>>2]=i[3925],i[c+8>>2]=i[3926],i[c+12>>2]=i[3927],i[(c=A+32|0)>>2]=i[3928],i[c+4>>2]=i[3929],i[c+8>>2]=i[3930],i[c+12>>2]=i[3931],i[P>>2]=i[u>>2],i[P+4>>2]=i[u+4>>2],z(P,_+120|0),i[_+160>>2]=0,i[_+164>>2]=0,i[(c=_+152|0)>>2]=3,A=0|Mt(48),i[(n=_+156|0)>>2]=A,!A){u=0,f=6;break}if(i[A>>2]=i[3932],i[A+4>>2]=i[3933],i[A+8>>2]=i[3934],i[A+12>>2]=i[3935],i[(l=A+16|0)>>2]=i[3936],i[l+4>>2]=i[3937],i[l+8>>2]=i[3938],i[l+12>>2]=i[3939],i[(l=A+32|0)>>2]=i[3940],i[l+4>>2]=i[3941],i[l+8>>2]=i[3942],i[l+12>>2]=i[3943],i[P>>2]=i[c>>2],i[P+4>>2]=i[c+4>>2],z(P,_+144|0),i[_+184>>2]=0,i[_+188>>2]=0,i[(l=_+176|0)>>2]=3,A=0|Mt(48),i[(x=_+180|0)>>2]=A,!A){u=0,f=7;break}if(i[A>>2]=i[3944],i[A+4>>2]=i[3945],i[A+8>>2]=i[3946],i[A+12>>2]=i[3947],i[(E=A+16|0)>>2]=i[3948],i[E+4>>2]=i[3949],i[E+8>>2]=i[3950],i[E+12>>2]=i[3951],i[(A=A+32|0)>>2]=i[3952],i[A+4>>2]=i[3953],i[A+8>>2]=i[3954],i[A+12>>2]=i[3955],i[P>>2]=i[l>>2],i[P+4>>2]=i[l+4>>2],z(P,_+168|0),gt(_,8,24,3),A=0|Mt(128),i[o+4>>2]=A,0|A){i[o>>2]=8,i[A>>2]=i[m>>2],i[A+4>>2]=i[m+4>>2],i[A+8>>2]=i[m+8>>2],i[A+12>>2]=i[m+12>>2],i[(k=A+16|0)>>2]=i[p>>2],i[k+4>>2]=i[p+4>>2],i[k+8>>2]=i[p+8>>2],i[k+12>>2]=i[p+12>>2],i[(k=A+32|0)>>2]=i[h>>2],i[k+4>>2]=i[h+4>>2],i[k+8>>2]=i[h+8>>2],i[k+12>>2]=i[h+12>>2],i[(k=A+48|0)>>2]=i[d>>2],i[k+4>>2]=i[d+4>>2],i[k+8>>2]=i[d+8>>2],i[k+12>>2]=i[d+12>>2],i[(k=A+64|0)>>2]=i[f>>2],i[k+4>>2]=i[f+4>>2],i[k+8>>2]=i[f+8>>2],i[k+12>>2]=i[f+12>>2],i[(k=A+80|0)>>2]=i[u>>2],i[k+4>>2]=i[u+4>>2],i[k+8>>2]=i[u+8>>2],i[k+12>>2]=i[u+12>>2],i[(k=A+96|0)>>2]=i[c>>2],i[k+4>>2]=i[c+4>>2],i[k+8>>2]=i[c+8>>2],i[k+12>>2]=i[c+12>>2],i[(k=A+112|0)>>2]=i[l>>2],i[k+4>>2]=i[l+4>>2],i[k+8>>2]=i[l+8>>2],i[k+12>>2]=i[l+12>>2],Et(_),k=158;break t}0|(A=0|i[g>>2])&&Et(A),0|(A=0|i[b>>2])&&Et(A),0|(A=0|i[v>>2])&&Et(A),0|(A=0|i[y>>2])&&Et(A),0|(A=0|i[e>>2])&&Et(A),0|(A=0|i[t>>2])&&Et(A),0|(A=0|i[n>>2])&&Et(A),0|(A=0|i[x>>2])&&Et(A),Et(_);break t}u=0,f=1}while(0);A=0,c=0;do{0|(l=0|i[_+(24*A|0)+12>>2])&&Et(l),A=0|Pt(0|A,0|c,1,0),c=0|S()}while(c>>>0<u>>>0|(0|c)==(0|u)&A>>>0<f>>>0)}Et(_),k=152}}else{if((0|C)>0|!(0|C)&I>>>0>0){c=0,u=0,f=0,l=0,A=0,d=0;do{P=u,k=f,l=0|Pt(0|l,0|A,1&((0|(u=0|i[(E=R+(24*c|0)|0)>>2]))!=(0|P)|(0|(f=0|i[E+4>>2]))!=(0|k)),0),A=0|S(),c=0|Pt(0|c,0|d,1,0),d=0|S()}while((0|d)<(0|C)|(0|d)==(0|C)&c>>>0<I>>>0);y=l,v=A}else y=0,v=0;if(e=0|Mt(24*y|0)){n:do{if((0|C)>=0){for(m=0,g=0,l=0,c=0,b=0,u=0;;){if((0|m)==(0|I)&(0|g)==(0|C)||(k=R+(24*m|0)|0,(0|i[(P=R+(24*l|0)|0)>>2])!=(0|i[k>>2])||(0|i[P+4>>2])!=(0|i[k+4>>2]))){if(h=R+(24*l|0)|0,p=0|Pt(0|(k=0|Nt(0|m,0|g,0|l,0|c)),0|(P=0|S()),-1,-1),c=0|S(),(0|P)>0|!(0|P)&k>>>0>1){if(!(A=0|Mt(p<<3)))break;f=0,d=0;do{k=f,f=0|Pt(0|f,0|d,1,0),d=0|S(),P=0|i[(E=h+(24*f|0)+16|0)+4>>2],i[(k=A+(k<<3)|0)>>2]=i[E>>2],i[k+4>>2]=P}while((0|d)<(0|c)|(0|d)==(0|c)&f>>>0<p>>>0)}else A=0;k=0|i[(P=R+(24*l|0)+16|0)+4>>2],i[(c=e+(24*u|0)+8|0)>>2]=i[P>>2],i[c+4>>2]=k,i[e+(24*u|0)+16>>2]=p,i[e+(24*u|0)+20>>2]=A,a[e+(24*u|0)>>3]=+a[R+(24*l|0)+8>>3],u=0|Pt(0|u,0|b,1,0),l=m,c=g,A=0|S()}else A=b;if(k=m,m=0|Pt(0|m,0|g,1,0),P=g,g=0|S(),!((0|P)<(0|C)|(0|P)==(0|C)&k>>>0<I>>>0))break n;b=A}if((0|b)>0|!(0|b)&u>>>0>0){A=0,c=0;do{0|(l=0|i[e+(24*A|0)+20>>2])&&Et(l),A=0|Pt(0|A,0|c,1,0),c=0|S()}while((0|c)<(0|b)|(0|c)==(0|b)&A>>>0<u>>>0)}Et(e),k=152;break t}}while(0);if(gt(e,y,24,3),A=0|Mt(y<<4),i[(c=o+4|0)>>2]=A,A){i[o>>2]=y;do{if((0|v)>0|!(0|v)&y>>>0>0){if(o=e+8|0,i[A>>2]=i[o>>2],i[A+4>>2]=i[o+4>>2],i[A+8>>2]=i[o+8>>2],i[A+12>>2]=i[o+12>>2],1==(0|y)&!(0|v))break;if(k=e+32|0,i[(o=A+16|0)>>2]=i[k>>2],i[o+4>>2]=i[k+4>>2],i[o+8>>2]=i[k+8>>2],i[o+12>>2]=i[k+12>>2],!((0|v)>0|!(0|v)&y>>>0>2))break;A=2,l=0;do{o=(0|i[c>>2])+(A<<4)|0,k=e+(24*A|0)+8|0,i[o>>2]=i[k>>2],i[o+4>>2]=i[k+4>>2],i[o+8>>2]=i[k+8>>2],i[o+12>>2]=i[k+12>>2],A=0|Pt(0|A,0|l,1,0),l=0|S()}while((0|l)<(0|v)|(0|l)==(0|v)&A>>>0<y>>>0)}}while(0);Et(e),k=158;break}if((0|v)>0|!(0|v)&y>>>0>0){A=0,c=0;do{0|(l=0|i[e+(24*A|0)+20>>2])&&Et(l),A=0|Pt(0|A,0|c,1,0),c=0|S()}while((0|c)<(0|v)|(0|c)==(0|v)&A>>>0<y>>>0)}Et(e),k=152;break}k=152}}while(0);if(158==(0|k))return Et(L),Et(B),Et(R),N=s,0|(B=0);if(152==(0|k)&&(0|C)>0|!(0|C)&I>>>0>0)for(u=0,f=0,A=I,c=C;(l=0|i[R+(24*u|0)+20>>2])?(Et(l),l=C,A=I):l=c,u=0|Pt(0|u,0|f,1,0),(0|(f=0|S()))<(0|l)|(0|f)==(0|l)&u>>>0<A>>>0;)c=l;return Et(R),Et(L),Et(B),N=s,0|(B=13)}}while(0);return Et(L),Et(B),N=s,0|(B=13)}return 159==(0|k)?(N=s,0|A):0}function ae(e){var t,n=0;return(0|(n=0|i[(t=(e|=0)+20|0)>>2]))==(0|e)?0|e:(n=0|ae(n),i[t>>2]=n,0|n)}function oe(e,t){var n=0;switch(n=0|Vt(0|(e|=0),0|(t|=0),56),S(),7&n){case 0:case 7:return 0|(n=0)}return n=-2130706433&t|134217728,!0&268435456==(2013265920&t)?!0&16777216==(117440512&t)&!!(0|Se(e,n))?0|(n=0):0|(n=0|xe(e,n)):0|(n=0)}function se(e,t,n){n|=0;var r,a=0;return r=!(0|Se(e|=0,t|=0)),t&=-2130706433,i[(a=n)>>2]=r?e:0,i[a+4>>2]=r?285212672|t:0,i[(a=n+8|0)>>2]=e,i[a+4>>2]=301989888|t,i[(a=n+16|0)>>2]=e,i[a+4>>2]=318767104|t,i[(a=n+24|0)>>2]=e,i[a+4>>2]=335544320|t,i[(a=n+32|0)>>2]=e,i[a+4>>2]=352321536|t,i[(n=n+40|0)>>2]=e,i[n+4>>2]=369098752|t,0}function Ae(e,t,n){n|=0;var r,a,o=0,s=0;return a=N,N=N+16|0,r=a,s=-2130706433&(t|=0)|134217728,!0&268435456==(2013265920&t)?(o=0|Vt(0|(e|=0),0|t,56),S(),o=0|function(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0;if(o=N,N=N+16|0,a=o,r=0|Se(e,t),(n+-1|0)>>>0>5)return N=o,0|(a=-1);if(r=!!(0|r),1==(0|n)&r)return N=o,0|(a=-1);do{if(!(0|ht(e,t,a))){if(r){r=(5+(0|i[26416+(n<<2)>>2])-(0|i[a>>2])|0)%5|0;break}r=(6+(0|i[26448+(n<<2)>>2])-(0|i[a>>2])|0)%6|0;break}r=-1}while(0);return a=r,N=o,0|a}(e,s,7&o),-1==(0|o)?(i[n>>2]=0,N=a,0|(s=6)):(0|Fe(e,s,r)&&M(27634,27035,282,27050),t=0|Vt(0|e,0|t,52),S(),t&=15,0|Se(e,s)?de(r,t,o,2,n):ge(r,t,o,2,n),N=a,0|(s=0))):(N=a,0|(s=6))}function le(e,t,n){e|=0,n|=0;var r,a=0,o=0,s=0;return r=N,N=N+16|0,o=r,s=-2130706433&(t|=0)|134217728,!0&268435456==(2013265920&t)?(i[(a=r+8|0)>>2]=0,t=0|Vt(0|e,0|t,56),S(),0|(t=0|F(e,s,7&t,a,o))?(N=r,0|(n=t)):7==(0|(t=0|V(a=0|i[o>>2],o=0|i[o+4>>2],e,s)))?(N=r,0|(n=11)):(e=0|jt(0|t,0,56),s=-2130706433&o|S()|268435456,i[n>>2]=a|e,i[n+4>>2]=s,N=r,0|(n=0))):(N=r,0|(n=6))}function ce(e,t,n){e|=0,t|=0;var r,o,s=0,A=0,p=0,m=0,b=0,v=0,y=0,x=0,_=0,w=0,T=0,M=0,E=0,C=0,I=0,R=0,P=0;i[(n|=0)>>2]=0,y=+a[e>>3],x=+a[e+8>>3],v=+a[e+16>>3],A=0,p=5,s=5,e=0;do{(m=(T=+a[15888+(24*A|0)>>3]-y)*T+(w=+a[15888+(24*A|0)+8>>3]-x)*w+(m=+a[15888+(24*A|0)+16>>3]-v)*m)<s&&(i[n>>2]=A,p=m,e=A,s=m),A=A+1|0}while(20!=(0|A));if((p=+h(+(1-.5*p)))<1e-16)v=0,m=0;else{if(R=+a[16368+(24*e|0)>>3],C=+a[15888+(24*e|0)>>3],I=+a[15888+(24*e|0)+8>>3],m=C*(P=-((E=+a[15888+(24*e|0)+16>>3])+(0*C+0*I)))+0,T=I*P+0,m*=M=(M=+c(+((P=E*P+1)*P+(m*m+T*T))))>0?1/M:0,T*=M,M*=P,w=y+C*(P=-(y*C+x*I+v*E)),w*=x=(x=+c(+((y=v+E*P)*y+(w*w+(s=x+I*P)*s))))>0?1/x:0,s*=x,s=+He(R-+He(+g(+((x*=y)*(I*m-C*T)+(w*(E*T-I*M)+s*(C*M-E*m))),+(M*x+(m*w+T*s))))),m=0|Le(t)?+He(s+-.3334731722518321):s,s=2.618033988749896*+d(+p),(0|t)>0){e=0;do{s*=2.6457513110645907,e=e+1|0}while((0|e)!=(0|t))}v=+u(+m)*s,m=+f(+m)*s}t=n+4|0,i[(o=n+12|0)>>2]=0,p=1.1547005383792515*+l(+m),s=+l(+v)+.5*p,s-=+(0|(e=~~s)),p-=+(0|(A=~~p));do{if(s<.5){if(s<.3333333333333333){if(i[t>>2]=e,p<.5*(s+1)){i[n+8>>2]=A;break}A=A+1|0,i[n+8>>2]=A;break}if(A=(1&!(p<(P=1-s)))+A|0,i[n+8>>2]=A,P<=p&p<2*s){e=e+1|0,i[t>>2]=e;break}i[t>>2]=e;break}if(!(s<.6666666666666666)){if(e=e+1|0,i[t>>2]=e,p<.5*s){i[n+8>>2]=A;break}A=A+1|0,i[n+8>>2]=A;break}if(p<1-s){if(i[n+8>>2]=A,2*s-1<p){i[t>>2]=e;break}}else A=A+1|0,i[n+8>>2]=A;e=e+1|0,i[t>>2]=e}while(0);do{if(v<0){if(1&A){e=~~(+(0|e)-(2*(+((_=0|Nt(0|e,((0|e)<0)<<31>>31,0|(_=(A+1|0)/2|0),((0|_)<0)<<31>>31))>>>0)+4294967296*+(0|S()))+1)),i[t>>2]=e,_=t;break}e=~~(+(0|e)-2*(+((_=0|Nt(0|e,((0|e)<0)<<31>>31,0|(_=(0|A)/2|0),((0|_)<0)<<31>>31))>>>0)+4294967296*+(0|S()))),i[t>>2]=e,_=t;break}_=t}while(0);r=n+8|0,t=0-A|0,m<0?(n=e-((A<<1|1)/2|0)|0,i[_>>2]=n,i[r>>2]=t,A=t):n=e,e=A-n|0,t=0-n|0,(0|n)<0?(i[r>>2]=e,i[o>>2]=t,i[_>>2]=0,b=0):(e=A,b=n,t=0),n=b-e|0,A=t-e|0,(0|e)<0?(i[_>>2]=n,i[o>>2]=A,i[r>>2]=0,b=n,e=0):A=t,n=b-A|0,t=e-A|0,(0|A)<0?(i[_>>2]=n,i[r>>2]=t,i[o>>2]=0,A=0):(t=e,n=b),(0|(e=(0|A)<(0|(e=(0|t)<(0|n)?t:n))?A:e))<=0||(i[_>>2]=n-e,i[r>>2]=t-e,i[o>>2]=A-e)}function ue(e,t,n){t|=0,n|=0;var r,o,s,A;r=N,N=N+16|0,o=r,A=0|i[(e|=0)+12>>2],s=+((0|i[e+8>>2])-A|0),a[o>>3]=+((0|i[e+4>>2])-A|0)-.5*s,a[o+8>>3]=.8660254037844386*s,fe(o,0|i[e>>2],t,0,n),N=r}function fe(e,t,n,r,o){t|=0,n|=0,r|=0,o|=0;var s,A,l,d,h,p=0,b=0,v=0,y=0,x=0,_=0,w=0;if(p=+function(e){e|=0;var t=0,n=0;return n=+a[e>>3],t=+a[e+8>>3],+ +c(+(n*n+t*t))}(e|=0),p<1e-16)return t=15888+(24*t|0)|0,i[o>>2]=i[t>>2],i[o+4>>2]=i[t+4>>2],i[o+8>>2]=i[t+8>>2],i[o+12>>2]=i[t+12>>2],i[o+16>>2]=i[t+16>>2],void(i[o+20>>2]=i[t+20>>2]);if(b=+g(+ +a[e+8>>3],+ +a[e>>3]),(0|n)>0){e=0;do{p*=.37796447300922725,e=e+1|0}while((0|e)!=(0|n))}v=.3333333333333333*p,r?(n=!(0|Le(n)),p=+m(.381966011250105*(n?v:.37796447300922725*v))):(p=+m(.381966011250105*p),0|Le(n)&&(b=+He(b+.3334731722518321))),x=+He(+a[16368+(24*t|0)>>3]-b),v=+a[15888+(24*t|0)>>3],A=+a[15888+(24*t|0)+8>>3],y=v*(w=-((d=+a[15888+(24*t|0)+16>>3])+(0*v+0*A)))+0,b=A*w+0,y*=_=(_=+c(+((w=d*w+1)*w+(y*y+b*b))))>0?1/_:0,b*=_,_*=w,w=+u(+x),x=+f(+x),s=(h=+u(+p))*v+(l=+f(+p))*(w*y+x*(d*b-A*_)),p=h*A+l*(w*b+x*(v*_-d*y)),v=(v=+c(+((b=h*d+l*(w*_+x*(A*y-v*b)))*b+(s*s+p*p))))>0?1/v:0,a[o>>3]=s*v,a[o+8>>3]=p*v,a[o+16>>3]=b*v}function de(e,t,n,r,o){e|=0,t|=0,n|=0,r|=0,o|=0;var s,A,l,c,u,f,d,h,m,b,y,x,_,w,T,S,E,C,I,R,P,k,L,B,O,F,D,U=0,V=0,j=0,z=0,G=0,H=0,q=0,Q=0,K=0,W=0,$=0,J=0,Y=0,X=0,Z=0;if(D=N,N=N+256|0,K=D+224|0,B=D,O=D+208|0,F=D+192|0,C=D+168|0,I=D+152|0,R=D+136|0,P=D+120|0,k=D+104|0,L=D+80|0,i[(U=D+240|0)>>2]=t,i[K>>2]=i[e>>2],i[K+4>>2]=i[e+4>>2],i[K+8>>2]=i[e+8>>2],i[K+12>>2]=i[e+12>>2],he(K,U,B),i[o>>2]=0,(0|(K=r+n+(5==(0|r)&1)|0))<=(0|n))N=D;else{d=O+4|0,u=O+8|0,f=O+12|0,m=F+8|0,b=n+5|0,y=16848+((h=0|i[U>>2])<<2)|0,x=C+8|0,_=16928+(h<<2)|0,w=I+8|0,T=R+8|0,S=P+8|0,E=F+8|0,s=C+8|0,l=C+16|0,A=L+8|0,c=L+16|0,Q=n,r=0,V=0,j=0,z=0;e:for(;;){q=B+((0|Q)%5<<4)|0,i[O>>2]=i[q>>2],i[O+4>>2]=i[q+4>>2],i[O+8>>2]=i[q+8>>2],i[O+12>>2]=i[q+12>>2];do{}while(2==(0|pe(O,h,0,1)));if((0|Q)>(0|n)&!!(0|Le(t))){if(q=0|i[O>>2],e=0|i[d>>2],G=0|i[u>>2],U=0|i[f>>2],W=+(j-z|0),a[F>>3]=+(V-z|0)-.5*W,a[m>>3]=.8660254037844386*W,z=0|i[17008+(80*q|0)+(r<<2)>>2],H=0|i[18608+(80*q|0)+(20*z|0)>>2],(0|(j=0|i[18608+(80*q|0)+(20*z|0)+16>>2]))>0){V=0,r=G;do{r=((J=(0|(G=r+e-((X=(0|(Y=U+e|0))<0)?Y:0)|0))<0)?0:G)-((U=(0|($=U+r-(X?Y:0)-(J?G:0)|0))<0)?$:0)|0,e=(e=(X?0:Y)-(J?G:0)-(U?$:0)|0)-((G=(0|(U=(0|($=U?0:$))<(0|(U=(0|r)<(0|e)?r:e))?$:U))>0)?U:0)|0,r=r-(G?U:0)|0,U=$-(G?U:0)|0,V=V+1|0}while((0|V)<(0|j))}else r=G;switch(X=3*(0|i[y>>2])|0,$=(0|v(X,0|i[18608+(80*q|0)+(20*z|0)+4>>2]))+e|0,G=(0|v(X,0|i[18608+(80*q|0)+(20*z|0)+8>>2]))+r|0,X=(0|v(X,0|i[18608+(80*q|0)+(20*z|0)+12>>2]))+U|0,$=((z=(0|$)<0)?0:$)-((J=(0|(G=G-(z?$:0)|0))<0)?G:0)-((Y=(0|(X=X+(z?0-$|0:0)+(J?0-G|0:0)|0))<0)?X:0)|0,W=+((G=(J?0:G)-(Y?X:0)|0)-((J=(0|(Y=(0|(X=Y?0:X))<(0|(Y=(0|G)<(0|$)?G:$))?X:Y))>0)?Y:0)-(X=X-(J?Y:0)|0)|0),a[C>>3]=+($-(J?Y:0)-X|0)-.5*W,a[x>>3]=.8660254037844386*W,W=+(0|i[_>>2]),a[I>>3]=3*W,a[w>>3]=0,Z=-1.5*W,a[R>>3]=Z,a[T>>3]=2.598076211353316*W,a[P>>3]=Z,a[S>>3]=-2.598076211353316*W,0|i[17008+(80*H|0)+(q<<2)>>2]){case 1:e=R,r=I;break;case 3:e=P,r=R;break;case 2:e=I,r=P;break;default:e=12;break e}ft(F,C,r,e,k),fe(k,H,h,1,L),X=0|i[o>>2],W=+p(+ +a[c>>3]),Z=+g(+ +a[A>>3],+ +a[L>>3]),a[o+8+(X<<4)>>3]=W,a[o+8+(X<<4)+8>>3]=Z,i[o>>2]=1+(0|i[o>>2])}if((0|Q)<(0|b)&&(X=0|i[f>>2],W=+((0|i[u>>2])-X|0),a[F>>3]=+((0|i[d>>2])-X|0)-.5*W,a[E>>3]=.8660254037844386*W,fe(F,0|i[O>>2],h,1,C),X=0|i[o>>2],W=+p(+ +a[l>>3]),Z=+g(+ +a[s>>3],+ +a[C>>3]),a[o+8+(X<<4)>>3]=W,a[o+8+(X<<4)+8>>3]=Z,i[o>>2]=1+(0|i[o>>2])),(0|(Q=Q+1|0))>=(0|K)){e=3;break}r=0|i[O>>2],V=0|i[d>>2],j=0|i[u>>2],z=0|i[f>>2]}3!=(0|e)?12==(0|e)&&M(27073,27120,599,27130):N=D}}function he(e,t,n){e|=0,t|=0,n|=0;var r,a,o,s,A=0,l=0,c=0,u=0,f=0,d=0,h=0,p=0;s=N,N=N+128|0,l=s,u=20208,f=(c=A=s+64|0)+60|0;do{i[c>>2]=i[u>>2],c=c+4|0,u=u+4|0}while((0|c)<(0|f));u=20272,f=(c=l)+60|0;do{i[c>>2]=i[u>>2],c=c+4|0,u=u+4|0}while((0|c)<(0|f));p=(p=!(0|Le(0|i[t>>2])))?A:l,c=0|i[(o=e+4|0)>>2],A=0|i[(r=e+8|0)>>2],l=0|i[(a=e+12|0)>>2],u=A+(c<<1)|0,i[o>>2]=u,A=l+(A<<1)|0,i[r>>2]=A,c=(l<<1)+c|0,i[a>>2]=c,l=A-u|0,f=c-u|0,(0|u)<0&&(i[r>>2]=l,i[a>>2]=f,i[o>>2]=0,A=l,u=0,c=f),f=u-A|0,l=c-A|0,(0|A)<0?(i[o>>2]=f,i[a>>2]=l,i[r>>2]=0,A=0):(l=c,f=u),u=f-l|0,c=A-l|0,(0|l)<0?(i[o>>2]=u,i[r>>2]=c,i[a>>2]=0,l=0):(c=A,u=f),(0|(A=(0|l)<(0|(A=(0|c)<(0|u)?c:u))?l:A))>0&&(l=l-A|0,c=c-A|0,u=u-A|0,i[o>>2]=u,i[r>>2]=c,i[a>>2]=l),d=(c<<1)+u|0,f=l+(u<<1)|0,i[o>>2]=f,i[r>>2]=d,c=(l<<1)+c|0,i[a>>2]=c,A=d-f|0,l=c-f|0,(0|f)<0?(i[r>>2]=A,i[a>>2]=l,i[o>>2]=0,f=0,c=l):A=d,u=f-A|0,l=c-A|0,(0|A)<0?(i[o>>2]=u,i[a>>2]=l,i[r>>2]=0,f=u,A=0):l=c,u=f-l|0,c=A-l|0,(0|l)<0?(i[o>>2]=u,i[r>>2]=c,i[a>>2]=0,l=0):(c=A,u=f),(0|(A=(0|l)<(0|(A=(0|c)<(0|u)?c:u))?l:A))>0&&(i[o>>2]=u-A,i[r>>2]=c-A,i[a>>2]=l-A),0|Le(0|i[t>>2])&&(c=0|i[o>>2],A=(3*(u=0|i[r>>2])|0)+c|0,c=(l=0|i[a>>2])+(3*c|0)|0,i[o>>2]=c,i[r>>2]=A,u=(3*l|0)+u|0,i[a>>2]=u,l=A-c|0,f=u-c|0,(0|c)<0?(i[r>>2]=l,i[a>>2]=f,i[o>>2]=0,A=l,d=0):(d=c,f=u),c=d-A|0,l=f-A|0,(0|A)<0?(i[o>>2]=c,i[a>>2]=l,i[r>>2]=0,d=c,u=0):(u=A,l=f),c=d-l|0,A=u-l|0,(0|l)<0?(i[o>>2]=c,i[r>>2]=A,i[a>>2]=0,u=A,l=0):c=d,(0|(A=(0|l)<(0|(A=(0|u)<(0|c)?u:c))?l:A))>0&&(i[o>>2]=c-A,i[r>>2]=u-A,i[a>>2]=l-A),i[t>>2]=1+(0|i[t>>2])),i[n>>2]=i[e>>2],l=0|i[r>>2],A=0|i[a>>2],t=0|i[p+4>>2],h=0|i[p+8>>2],u=(0|i[p>>2])+(0|i[o>>2])|0,i[(d=n+4|0)>>2]=u,l=t+l|0,i[(t=n+8|0)>>2]=l,A=h+A|0,i[(h=n+12|0)>>2]=A,c=l-u|0,(0|u)<0&&(A=A-u|0,i[t>>2]=c,i[h>>2]=A,i[d>>2]=0,l=c,u=0),(0|l)<0&&(u=u-l|0,i[d>>2]=u,A=A-l|0,i[h>>2]=A,i[t>>2]=0,l=0),f=u-A|0,c=l-A|0,(0|A)<0?(i[d>>2]=f,i[t>>2]=c,i[h>>2]=0,u=f,A=0):c=l,(0|(l=(0|A)<(0|(l=(0|c)<(0|u)?c:u))?A:l))>0&&(i[d>>2]=u-l,i[t>>2]=c-l,i[h>>2]=A-l),i[n+16>>2]=i[e>>2],l=0|i[r>>2],A=0|i[a>>2],t=0|i[p+16>>2],h=0|i[p+20>>2],u=(0|i[p+12>>2])+(0|i[o>>2])|0,i[(d=n+20|0)>>2]=u,l=t+l|0,i[(t=n+24|0)>>2]=l,A=h+A|0,i[(h=n+28|0)>>2]=A,c=l-u|0,(0|u)<0&&(A=A-u|0,i[t>>2]=c,i[h>>2]=A,i[d>>2]=0,l=c,u=0),(0|l)<0&&(u=u-l|0,i[d>>2]=u,A=A-l|0,i[h>>2]=A,i[t>>2]=0,l=0),f=u-A|0,c=l-A|0,(0|A)<0?(i[d>>2]=f,i[t>>2]=c,i[h>>2]=0,u=f,A=0):c=l,(0|(l=(0|A)<(0|(l=(0|c)<(0|u)?c:u))?A:l))>0&&(i[d>>2]=u-l,i[t>>2]=c-l,i[h>>2]=A-l),i[n+32>>2]=i[e>>2],l=0|i[r>>2],A=0|i[a>>2],t=0|i[p+28>>2],h=0|i[p+32>>2],u=(0|i[p+24>>2])+(0|i[o>>2])|0,i[(d=n+36|0)>>2]=u,l=t+l|0,i[(t=n+40|0)>>2]=l,A=h+A|0,i[(h=n+44|0)>>2]=A,c=l-u|0,(0|u)<0&&(A=A-u|0,i[t>>2]=c,i[h>>2]=A,i[d>>2]=0,l=c,u=0),(0|l)<0&&(u=u-l|0,i[d>>2]=u,A=A-l|0,i[h>>2]=A,i[t>>2]=0,l=0),f=u-A|0,c=l-A|0,(0|A)<0?(i[d>>2]=f,i[t>>2]=c,i[h>>2]=0,u=f,A=0):c=l,(0|(l=(0|A)<(0|(l=(0|c)<(0|u)?c:u))?A:l))>0&&(i[d>>2]=u-l,i[t>>2]=c-l,i[h>>2]=A-l),i[n+48>>2]=i[e>>2],l=0|i[r>>2],A=0|i[a>>2],t=0|i[p+40>>2],h=0|i[p+44>>2],u=(0|i[p+36>>2])+(0|i[o>>2])|0,i[(d=n+52|0)>>2]=u,l=t+l|0,i[(t=n+56|0)>>2]=l,A=h+A|0,i[(h=n+60|0)>>2]=A,c=l-u|0,(0|u)<0&&(A=A-u|0,i[t>>2]=c,i[h>>2]=A,i[d>>2]=0,l=c,u=0),(0|l)<0&&(u=u-l|0,i[d>>2]=u,A=A-l|0,i[h>>2]=A,i[t>>2]=0,l=0),f=u-A|0,c=l-A|0,(0|A)<0?(i[d>>2]=f,i[t>>2]=c,i[h>>2]=0,u=f,A=0):c=l,(0|(l=(0|A)<(0|(l=(0|c)<(0|u)?c:u))?A:l))>0&&(i[d>>2]=u-l,i[t>>2]=c-l,i[h>>2]=A-l),i[n+64>>2]=i[e>>2],c=0|i[r>>2],A=0|i[a>>2],h=0|i[p+52>>2],d=0|i[p+56>>2],u=(0|i[p+48>>2])+(0|i[o>>2])|0,i[(t=n+68|0)>>2]=u,c=h+c|0,i[(h=n+72|0)>>2]=c,A=d+A|0,i[(d=n+76|0)>>2]=A,l=c-u|0,(0|u)<0?(A=A-u|0,i[h>>2]=l,i[d>>2]=A,i[t>>2]=0,c=0):(l=c,c=u),(0|l)<0&&(c=c-l|0,i[t>>2]=c,A=A-l|0,i[d>>2]=A,i[h>>2]=0,l=0),f=c-A|0,u=l-A|0,(0|A)<0?(i[t>>2]=f,i[h>>2]=u,i[d>>2]=0,c=f,A=0):u=l,(0|(l=(0|A)<(0|(l=(0|u)<(0|c)?u:c))?A:l))<=0||(i[t>>2]=c-l,i[h>>2]=u-l,i[d>>2]=A-l),N=s}function pe(e,t,n,r){e|=0,n|=0,r|=0;var a,o,s,A=0,l=0,c=0,u=0,f=0,d=0,h=0,p=0,m=0,g=0,b=0;if(d=0|i[16928+((t|=0)<<2)>>2],d=(s=!!(0|r))?3*d|0:d,u=0|i[(o=e+4|0)>>2],l=0|i[(a=e+8|0)>>2],s){if((0|(A=l+u+(r=0|i[(c=e+12|0)>>2])|0))==(0|d))return 0|(d=1);f=c}else r=A=0|i[(f=e+12|0)>>2],A=l+u+A|0;if((0|A)<=(0|d))return 0|(d=0);do{if((0|r)>0){if(A=0|i[e>>2],(0|l)>0){A=18608+(80*A|0)+60|0,c=u;break}A=18608+(80*A|0)+40|0,n?(n=((h=(0|(n=l+(c=u-d|0)|0))<0)?0:n)-((u=(0|(l=r+l-(h?n:0)|0))<0)?l:0)-((c=(0|(r=r+c-(h?n:0)-(u?l:0)|0))<0)?r:0)|0,l=(l=(u?0:l)-(c?r:0)|0)-((u=(0|(c=(0|(r=c?0:r))<(0|(c=(0|l)<(0|n)?l:n))?r:c))>0)?c:0)|0,r=r-(u?c:0)|0,c=n-(u?c:0)+d|0,i[o>>2]=c,i[a>>2]=l,i[f>>2]=r):c=u}else A=18608+(80*(0|i[e>>2])|0)+20|0,c=u}while(0);if(i[e>>2]=i[A>>2],(0|(u=0|i[A+16>>2]))>0){n=0;do{(0|(e=(0|(r=(l=(0|(c=r+l-(b=(p=(0|(h=r+c|0))<0)?h:0)-(e=(g=(0|(m=l+c-b|0))<0)?m:0)|0))<0)?0:c))<(0|(e=(0|(l=(g?0:m)-(c=l?c:0)|0))<(0|(c=(p?0:h)-e-c|0))?l:c))?r:e))>0&&(c=c-e|0,l=l-e|0,r=r-e|0),n=n+1|0}while((0|n)<(0|u));i[o>>2]=c,i[a>>2]=l,i[f>>2]=r}return m=0|i[16848+(t<<2)>>2],g=0|v(m=s?3*m|0:m,0|i[A+8>>2]),b=0|v(m,0|i[A+12>>2]),c=(0|v(m,0|i[A+4>>2]))+c|0,i[o>>2]=c,l=g+l|0,i[a>>2]=l,r=b+r|0,i[f>>2]=r,A=l-c|0,(0|c)<0?(r=r-c|0,i[a>>2]=A,i[f>>2]=r,i[o>>2]=0,l=0):(A=l,l=c),(0|A)<0?(e=l-A|0,i[o>>2]=e,r=r-A|0,i[f>>2]=r,i[a>>2]=0,c=0):(e=l,c=A),l=e-r|0,A=c-r|0,(0|r)<0?(i[o>>2]=l,i[a>>2]=A,i[f>>2]=0,r=0):(A=c,l=e),(0|(c=(0|r)<(0|(c=(0|A)<(0|l)?A:l))?r:c))>0&&(l=l-c|0,A=A-c|0,r=r-c|0,i[o>>2]=l,i[a>>2]=A,i[f>>2]=r),s?0|(b=(A+l+r|0)==(0|d)?1:2):0|(b=2)}function me(e,t){e|=0,t|=0;var n=0;do{n=0|pe(e,t,0,1)}while(2==(0|n));return 0|n}function ge(e,t,n,r,o){e|=0,t|=0,n|=0,r|=0,o|=0;var s,A,l,c,u,f,d,h,m,b,v,y,x,_,w,T,S,E,C,I,R,P,k,L,B,O,F,D,U=0,V=0,j=0,z=0,G=0,H=0,q=0;if(D=N,N=N+272|0,V=D+240|0,B=D,O=D+224|0,F=D+208|0,C=D+184|0,I=D+168|0,R=D+152|0,P=D+136|0,k=D+120|0,L=D+96|0,i[(U=D+256|0)>>2]=t,i[V>>2]=i[e>>2],i[V+4>>2]=i[e+4>>2],i[V+8>>2]=i[e+8>>2],i[V+12>>2]=i[e+12>>2],be(V,U,B),i[o>>2]=0,(0|(E=r+n+(6==(0|r)&1)|0))<=(0|n))N=D;else{v=n+6|0,y=F+8|0,x=C+8|0,_=16928+((b=0|i[U>>2])<<2)|0,w=I+8|0,T=R+8|0,S=P+8|0,h=0|i[V>>2],u=O+4|0,f=O+8|0,d=O+12|0,m=F+8|0,s=C+8|0,l=C+16|0,A=L+8|0,c=L+16|0,V=0,j=n,r=-1;e:for(;;){if(e=B+((U=(0|j)%6|0)<<4)|0,i[O>>2]=i[e>>2],i[O+4>>2]=i[e+4>>2],i[O+8>>2]=i[e+8>>2],i[O+12>>2]=i[e+12>>2],e=V,V=0|pe(O,b,0,1),(0|j)>(0|n)&!!(0|Le(t))&&1!=(0|e)&(0|(z=0|i[O>>2]))!=(0|r)){switch(e=0|i[B+((q=(U+5|0)%6|0)<<4)+12>>2],G=+((0|i[B+(q<<4)+8>>2])-e|0),a[F>>3]=+((0|i[B+(q<<4)+4>>2])-e|0)-.5*G,a[y>>3]=.8660254037844386*G,e=0|i[B+(U<<4)+12>>2],G=+((0|i[B+(U<<4)+8>>2])-e|0),a[C>>3]=+((0|i[B+(U<<4)+4>>2])-e|0)-.5*G,a[x>>3]=.8660254037844386*G,G=+(0|i[_>>2]),a[I>>3]=3*G,a[w>>3]=0,H=-1.5*G,a[R>>3]=H,a[T>>3]=2.598076211353316*G,a[P>>3]=H,a[S>>3]=-2.598076211353316*G,0|i[17008+(80*h|0)+(((0|r)==(0|h)?z:r)<<2)>>2]){case 1:e=R,r=I;break;case 3:e=P,r=R;break;case 2:e=I,r=P;break;default:e=8;break e}ft(F,C,r,e,k),0|dt(F,k)||0|dt(C,k)||(fe(k,h,b,1,L),q=0|i[o>>2],G=+p(+ +a[c>>3]),H=+g(+ +a[A>>3],+ +a[L>>3]),a[o+8+(q<<4)>>3]=G,a[o+8+(q<<4)+8>>3]=H,i[o>>2]=1+(0|i[o>>2]))}if((0|j)<(0|v)&&(q=0|i[d>>2],G=+((0|i[f>>2])-q|0),a[F>>3]=+((0|i[u>>2])-q|0)-.5*G,a[m>>3]=.8660254037844386*G,fe(F,0|i[O>>2],b,1,C),q=0|i[o>>2],G=+p(+ +a[l>>3]),H=+g(+ +a[s>>3],+ +a[C>>3]),a[o+8+(q<<4)>>3]=G,a[o+8+(q<<4)+8>>3]=H,i[o>>2]=1+(0|i[o>>2])),(0|(j=j+1|0))>=(0|E)){e=3;break}r=0|i[O>>2]}3!=(0|e)?8==(0|e)&&M(27157,27120,766,27202):N=D}}function be(e,t,n){e|=0,t|=0,n|=0;var r,a,o,s,A=0,l=0,c=0,u=0,f=0,d=0,h=0,p=0,m=0;s=N,N=N+160|0,l=s,u=20336,f=(c=A=s+80|0)+72|0;do{i[c>>2]=i[u>>2],c=c+4|0,u=u+4|0}while((0|c)<(0|f));u=20416,f=(c=l)+72|0;do{i[c>>2]=i[u>>2],c=c+4|0,u=u+4|0}while((0|c)<(0|f));m=(m=!(0|Le(0|i[t>>2])))?A:l,c=0|i[(o=e+4|0)>>2],A=0|i[(r=e+8|0)>>2],l=0|i[(a=e+12|0)>>2],u=A+(c<<1)|0,i[o>>2]=u,A=l+(A<<1)|0,i[r>>2]=A,c=(l<<1)+c|0,i[a>>2]=c,l=A-u|0,f=c-u|0,(0|u)<0&&(i[r>>2]=l,i[a>>2]=f,i[o>>2]=0,A=l,u=0,c=f),f=u-A|0,l=c-A|0,(0|A)<0?(i[o>>2]=f,i[a>>2]=l,i[r>>2]=0,A=0):(l=c,f=u),u=f-l|0,c=A-l|0,(0|l)<0?(i[o>>2]=u,i[r>>2]=c,i[a>>2]=0,l=0):(c=A,u=f),(0|(A=(0|l)<(0|(A=(0|c)<(0|u)?c:u))?l:A))>0&&(l=l-A|0,c=c-A|0,u=u-A|0,i[o>>2]=u,i[r>>2]=c,i[a>>2]=l),d=(c<<1)+u|0,f=l+(u<<1)|0,i[o>>2]=f,i[r>>2]=d,c=(l<<1)+c|0,i[a>>2]=c,A=d-f|0,l=c-f|0,(0|f)<0?(i[r>>2]=A,i[a>>2]=l,i[o>>2]=0,f=0,c=l):A=d,u=f-A|0,l=c-A|0,(0|A)<0?(i[o>>2]=u,i[a>>2]=l,i[r>>2]=0,f=u,A=0):l=c,u=f-l|0,c=A-l|0,(0|l)<0?(i[o>>2]=u,i[r>>2]=c,i[a>>2]=0,l=0):(c=A,u=f),(0|(A=(0|l)<(0|(A=(0|c)<(0|u)?c:u))?l:A))>0&&(i[o>>2]=u-A,i[r>>2]=c-A,i[a>>2]=l-A),0|Le(0|i[t>>2])&&(c=0|i[o>>2],A=(3*(u=0|i[r>>2])|0)+c|0,c=(l=0|i[a>>2])+(3*c|0)|0,i[o>>2]=c,i[r>>2]=A,u=(3*l|0)+u|0,i[a>>2]=u,l=A-c|0,f=u-c|0,(0|c)<0?(i[r>>2]=l,i[a>>2]=f,i[o>>2]=0,A=l,d=0):(d=c,f=u),c=d-A|0,l=f-A|0,(0|A)<0?(i[o>>2]=c,i[a>>2]=l,i[r>>2]=0,d=c,u=0):(u=A,l=f),c=d-l|0,A=u-l|0,(0|l)<0?(i[o>>2]=c,i[r>>2]=A,i[a>>2]=0,u=A,l=0):c=d,(0|(A=(0|l)<(0|(A=(0|u)<(0|c)?u:c))?l:A))>0&&(i[o>>2]=c-A,i[r>>2]=u-A,i[a>>2]=l-A),i[t>>2]=1+(0|i[t>>2])),d=0;do{i[n+(d<<4)>>2]=i[e>>2],l=0|i[r>>2],A=0|i[a>>2],h=0|i[m+(12*d|0)+4>>2],p=0|i[m+(12*d|0)+8>>2],u=(0|i[m+(12*d|0)>>2])+(0|i[o>>2])|0,i[(t=n+(d<<4)+4|0)>>2]=u,l=h+l|0,i[(h=n+(d<<4)+8|0)>>2]=l,A=p+A|0,i[(p=n+(d<<4)+12|0)>>2]=A,c=l-u|0,(0|u)<0&&(A=A-u|0,i[h>>2]=c,i[p>>2]=A,i[t>>2]=0,l=c,u=0),(0|l)<0&&(u=u-l|0,i[t>>2]=u,A=A-l|0,i[p>>2]=A,i[h>>2]=0,l=0),f=u-A|0,c=l-A|0,(0|A)<0?(i[t>>2]=f,i[h>>2]=c,i[p>>2]=0,u=f,A=0):c=l,(0|(l=(0|A)<(0|(l=(0|c)<(0|u)?c:u))?A:l))>0&&(i[t>>2]=u-l,i[h>>2]=c-l,i[p>>2]=A-l),d=d+1|0}while(6!=(0|d));N=s}function ve(e,t){return t=0|Vt(0|(e|=0),0|(t|=0),52),S(),15&t}function ye(e,t){return t=0|Vt(0|(e|=0),0|(t|=0),45),S(),127&t}function xe(e,t){e|=0;var n=0,i=0,a=0,o=0;return!0&134217728==(-16777216&(t|=0))?(i=0|Vt(0|e,0|t,52),S(),i&=15,n=0|Vt(0|e,0|t,45),S(),(n&=127)>>>0>121?0|(e=0):!(613566756&(o=0|jt(0|(a=0|Vt(0|e,0|t,0|(o=3*(15^i)|0))),0|S(),0|o))&(0|Nt(-1227133514,-1171,0|o,0|(a=0|S()))))&!(4681&a&S())&&15==(0|i)|!(0|(o=0|Vt(0|(0|jt(0|~e,0|~t,0|(o=19+(3*i|0)|0))),0|S(),0|o)))&!(0|S())?0|r[20496+n|0]?!(0|e)&!(0|(t&=8191))?0|(o=1):(o=0|zt(0|e,0|t,0),S(),0|!!((63-o|0)%3|0)):0|(o=1):0|(o=0)):0|(e=0)}function _e(e,t,n,r){e|=0,n|=0,r|=0;var a=0,o=0,s=0,A=0;if(a=0|jt(0|(t|=0),0,52),o=0|S(),n=0|jt(0|n,0,45),n=0|o|S()|134225919,(0|t)<1)return o=-1,r=n,i[(t=e)>>2]=o,void(i[(e=e+4|0)>>2]=r);for(o=1,a=-1;A=0|jt(7,0,0|(s=3*(15-o|0)|0)),n&=~S(),a=a&~A|(s=0|jt(0|r,0,0|s)),n=0|n|S(),(0|o)!=(0|t);)o=o+1|0;i[(s=A=e)>>2]=a,i[(A=A+4|0)>>2]=n}function we(e,t,n,r){n|=0,r|=0;var a=0,o=0;if(o=0|Vt(0|(e|=0),0|(t|=0),52),S(),n>>>0>15)return 0|(r=4);if((0|(o&=15))<(0|n))return 0|(r=12);if((0|o)==(0|n))return i[r>>2]=e,i[r+4>>2]=t,0|(r=0);if(a=0|jt(0|n,0,52),a|=e,e=S()|-15728641&t,(0|o)>(0|n))do{t=0|jt(7,0,3*(14-n|0)|0),n=n+1|0,a|=t,e=0|S()|e}while((0|n)<(0|o));return i[r>>2]=a,i[r+4>>2]=e,0|(r=0)}function Te(e,t,n,r){n|=0,r|=0;var a=0,o=0,s=0;if(o=0|Vt(0|(e|=0),0|(t|=0),52),S(),!((0|n)<16&(0|(o&=15))<=(0|n)))return 0|(r=4);a=n-o|0,n=0|Vt(0|e,0|t,45),S();e:do{if(0|G(127&n)){t:do{if(0|o){for(n=1;!((s=0|jt(7,0,3*(15-n|0)|0))&e|0)&!((0|S())&t);){if(!(n>>>0<o>>>0))break t;n=n+1|0}n=0|Ze(7,0,a,((0|a)<0)<<31>>31),a=0|S();break e}}while(0);n=0|Pt(0|(n=0|Ot(0|(n=0|Ze(7,0,a,((0|a)<0)<<31>>31)),0|S(),5,0)),0|S(),-5,-1),n=0|Pt(0|(n=0|Bt(0|n,0|S(),6,0)),0|S(),1,0),a=0|S()}else n=0|Ze(7,0,a,((0|a)<0)<<31>>31),a=0|S()}while(0);return i[(s=r)>>2]=n,i[s+4>>2]=a,0|(s=0)}function Se(e,t){var n=0,r=0,i=0;if(i=0|Vt(0|(e|=0),0|(t|=0),45),S(),!(0|G(127&i)))return 0|(i=0);i=0|Vt(0|e,0|t,52),S(),i&=15;e:do{if(i)for(r=1;;){if(n=0|Vt(0|e,0|t,3*(15-r|0)|0),S(),0|(n&=7))break e;if(!(r>>>0<i>>>0)){n=0;break}r=r+1|0}else n=0}while(0);return 0|(i=1&!(0|n))}function Me(e,t,n,r){return e|=0,t|=0,(0|(r|=0))<(0|(n|=0))?(r=e,T(0|(n=t)),0|r):(n=0|jt(-1,-1,3+(3*(r-n|0)|0)|0),r=0|jt(0|~n,0|~S(),3*(15-r|0)|0),n=~S()&t,r=~r&e,T(0|n),0|r)}function Ee(e,t,n,r){n|=0,r|=0;var a=0;return a=0|Vt(0|(e|=0),0|(t|=0),52),S(),(0|n)<16&(0|(a&=15))<=(0|n)?((0|a)<(0|n)&&(a=0|jt(-1,-1,3+(3*(n+-1-a|0)|0)|0),a=0|jt(0|~a,0|~S(),3*(15-n|0)|0),t=~S()&t,e&=~a),a=0|jt(0|n,0,52),n=-15728641&t|S(),i[r>>2]=e|a,i[r+4>>2]=n,0|(r=0)):0|(r=4)}function Ce(e,t){var n=0,r=0,i=0;if(i=0|Vt(0|(e|=0),0|(t|=0),52),S(),!(i&=15))return 0|(i=0);for(r=1;;){if(n=0|Vt(0|e,0|t,3*(15-r|0)|0),S(),0|(n&=7)){r=5;break}if(!(r>>>0<i>>>0)){n=0,r=5;break}r=r+1|0}return 5==(0|r)?0|n:0}function Ie(e,t){var n=0,r=0,i=0,a=0,o=0,s=0,A=0,l=0,c=0;if(c=0|Vt(0|(e|=0),0|(t|=0),52),S(),!(c&=15))return c=e,T(0|(l=t)),0|c;for(l=1,n=0;;){switch(a=e&~(s=0|jt(7,0,0|(r=3*(15-l|0)|0))),o=t&~(A=0|S()),e=0|Vt(0|e,0|t,0|r),S(),7&e){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;break;default:e&=7}e=(r=0|jt(0|e,0,0|r))|a,t=(i=0|S())|o;e:do{if(!n)if(!(r&s|0)&!(i&A|0))n=0;else if(o=0|Vt(0|e,0|t,52),S(),o&=15){n=1;t:for(;;){switch(A=0|Vt(0|e,0|t,3*(15-n|0)|0),S(),7&A){case 1:break t;case 0:break;default:n=1;break e}if(!(n>>>0<o>>>0)){n=1;break e}n=n+1|0}for(a=1;;){switch(n=0|Vt(0|e,0|t,0|(i=3*(15-a|0)|0)),S(),r=e&~(r=0|jt(7,0,0|i)),t&=~S(),7&n){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;break;default:e=7&n}if(e=0|jt(0|e,0,0|i),e|=r,t=0|S()|t,!(a>>>0<o>>>0)){n=1;break e}a=a+1|0}}else n=1}while(0);if(!(l>>>0<c>>>0))break;l=l+1|0}return T(0|t),0|e}function Re(e,t){var n=0,r=0,i=0,a=0,o=0;if(o=0|Vt(0|(e|=0),0|(t|=0),52),S(),!(o&=15))return o=e,T(0|(a=t)),0|o;for(a=1;;){switch(n=0|Vt(0|e,0|t,0|(i=3*(15-a|0)|0)),S(),r=e&~(r=0|jt(7,0,0|i)),t&=~S(),7&n){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;break;default:e=7&n}if(e=0|jt(0|e,0,0|i),e|=r,t=0|S()|t,!(a>>>0<o>>>0))break;a=a+1|0}return T(0|t),0|e}function Pe(e,t){var n=0,r=0,i=0,a=0,o=0,s=0,A=0,l=0,c=0;if(c=0|Vt(0|(e|=0),0|(t|=0),52),S(),!(c&=15))return c=e,T(0|(l=t)),0|c;for(l=1,n=0;;){switch(a=e&~(s=0|jt(7,0,0|(r=3*(15-l|0)|0))),o=t&~(A=0|S()),e=0|Vt(0|e,0|t,0|r),S(),7&e){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;break;default:e&=7}e=(r=0|jt(0|e,0,0|r))|a,t=(i=0|S())|o;e:do{if(!n)if(!(r&s|0)&!(i&A|0))n=0;else if(o=0|Vt(0|e,0|t,52),S(),o&=15){n=1;t:for(;;){switch(A=0|Vt(0|e,0|t,3*(15-n|0)|0),S(),7&A){case 1:break t;case 0:break;default:n=1;break e}if(!(n>>>0<o>>>0)){n=1;break e}n=n+1|0}for(a=1;;){switch(r=e&~(r=0|jt(7,0,0|(n=3*(15-a|0)|0))),i=t&~S(),e=0|Vt(0|e,0|t,0|n),S(),7&e){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;break;default:e&=7}if(e=0|jt(0|e,0,0|n),e|=r,t=0|S()|i,!(a>>>0<o>>>0)){n=1;break e}a=a+1|0}}else n=1}while(0);if(!(l>>>0<c>>>0))break;l=l+1|0}return T(0|t),0|e}function Ne(e,t){var n=0,r=0,i=0,a=0,o=0;if(o=0|Vt(0|(e|=0),0|(t|=0),52),S(),!(o&=15))return o=e,T(0|(a=t)),0|o;for(a=1;;){switch(n=e&~(n=0|jt(7,0,0|(r=3*(15-a|0)|0))),i=t&~S(),e=0|Vt(0|e,0|t,0|r),S(),7&e){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;break;default:e&=7}if(e=0|jt(0|e,0,0|r),e|=n,t=0|S()|i,!(a>>>0<o>>>0))break;a=a+1|0}return T(0|t),0|e}function ke(e,t){e|=0;var n,r=0,a=0,o=0,s=0,A=0,l=0,c=0,u=0,f=0,d=0,h=0,p=0,m=0,g=0,b=0,v=0,y=0,x=0,_=0,w=0,M=0;if(n=N,N=N+16|0,x=n,jt(0|(t|=0),0,52),r=134225919|S(),!t)return(0|i[e+4>>2])>2||(0|i[e+8>>2])>2||(0|i[e+12>>2])>2?(x=0,T(0|(y=0)),N=n,0|x):(jt(0|q(e),0,45),y=0|S()|r,x=-1,T(0|y),N=n,0|x);i[x>>2]=i[e>>2],i[x+4>>2]=i[e+4>>2],i[x+8>>2]=i[e+8>>2],i[x+12>>2]=i[e+12>>2],y=x+4|0;e:do{if((0|t)>0)for(b=x+12|0,m=t,d=0|i[(g=x+8|0)>>2],h=0|i[b>>2],t=-1,f=0|i[x+4>>2];;){p=m,m=m+-1|0,e=f-h|0,a=d-h|0,1&p?(s=0|St(.14285714285714285*+((3*e|0)-a|0)),i[y>>2]=s,e=0|St(.14285714285714285*+((a<<1)+e|0)),i[g>>2]=e,i[b>>2]=0,a=e-s|0,o=0-s|0,(0|s)<0?(i[g>>2]=a,i[b>>2]=o,i[y>>2]=0,e=a,A=0):(A=s,o=0),s=A-e|0,a=o-e|0,(0|e)<0?(i[y>>2]=s,i[b>>2]=a,i[g>>2]=0,A=s,s=0):(a=o,s=e),e=A-a|0,o=s-a|0,(0|a)<0?(i[y>>2]=e,i[g>>2]=o,i[b>>2]=0,s=0):(o=s,e=A,s=a),(0|(a=(0|s)<(0|(a=(0|o)<(0|e)?o:e))?s:a))>0&&(s=s-a|0,o=o-a|0,e=e-a|0,i[y>>2]=e,i[g>>2]=o,i[b>>2]=s),c=(u=(0|(l=(0|(M=(l=(0|(a=(3*s|0)+e-((_=(0|(w=o+(3*e|0)|0))<0)?w:0)-((c=(0|(u=s+(3*o|0)-(_?w:0)|0))<0)?u:0)|0))<0)?0:a))<(0|(l=(0|(A=(c?0:u)-(l?a:0)|0))<(0|(a=(_?0:w)-(c?u:0)-(l?a:0)|0))?A:a))?M:l))>0)?l:0,A=A-(u?l:0)|0,l=M-(u?l:0)|0,u=s):(l=0|St(.14285714285714285*+((e<<1)+a|0)),i[y>>2]=l,o=0|St(.14285714285714285*+((3*a|0)-e|0)),i[g>>2]=o,i[b>>2]=0,a=o-l|0,e=0-l|0,(0|l)<0?(i[g>>2]=a,i[b>>2]=e,i[y>>2]=0,o=a,l=0):e=0,A=l-o|0,a=e-o|0,(0|o)<0?(i[y>>2]=A,i[b>>2]=a,i[g>>2]=0,s=a,o=0):(s=e,A=l),e=A-s|0,a=o-s|0,(0|s)<0?(i[y>>2]=e,i[g>>2]=a,i[b>>2]=0,o=a,s=0):e=A,(0|(a=(0|s)<(0|(a=(0|o)<(0|e)?o:e))?s:a))>0&&(s=s-a|0,o=o-a|0,e=e-a|0,i[y>>2]=e,i[g>>2]=o,i[b>>2]=s),c=(u=(0|(l=(0|(_=(l=(0|(a=(3*s|0)+o-((M=(0|(w=s+(3*e|0)|0))<0)?w:0)-((c=(0|(u=(3*o|0)+e-(M?w:0)|0))<0)?u:0)|0))<0)?0:a))<(0|(l=(0|(A=(c?0:u)-(l?a:0)|0))<(0|(a=(M?0:w)-(c?u:0)-(l?a:0)|0))?A:a))?_:l))>0)?l:0,A=A-(u?l:0)|0,l=_-(u?l:0)|0,u=s),l=(f=(0|(h=h-l+((s=(0|(a=f+(c-a)|0))<0)?0-a|0:0)+((A=(0|(c=d-A-(s?a:0)|0))<0)?0-c|0:0)|0))<0)?0:h,M=(A?0:c)-(f?h:0)|0,h=(h=(s?0:a)-(A?c:0)-(f?h:0)|0)-((c=(0|(f=(0|l)<(0|(f=(0|M)<(0|h)?M:h))?l:f))>0)?f:0)|0,a=t&~(a=0|jt(7,0,0|(A=3*(15-p|0)|0))),s=r&~S(),t=(t=(r=(0|(w=l-(c?f:0)-(w=(d=(0|h)<0)?h:0)+((_=(0|(M=M-(c?f:0)-w|0))<0)?0-M|0:0)|0))<0)?0:w)-(M=(0|(M=(0|t)<(0|(M=(0|(r=(_?0:M)-(w=r?w:0)|0))<(0|(w=(d?0:h)-(_?M:0)-w|0))?r:w))?t:M))>0?M:0)|0,r=r-M|0;t:do{switch(w-M|0){case 0:switch(0|r){case 0:t=0|t?1==(0|t)?1:7:0;break t;case 1:t=0|t?1==(0|t)?3:7:2;break t;default:v=36;break t}case 1:switch(0|r){case 0:t=0|t?1==(0|t)?5:7:4;break t;case 1:if(t){v=36;break t}t=6;break t;default:v=36;break t}default:v=36}}while(0);if(36==(0|v)&&(v=0,t=7),t=0|jt(0|t,0,0|A),t|=a,r=0|S()|s,(0|p)<=1)break e;d=o,h=u,f=e}else t=-1,e=0|i[y>>2]}while(0);e:do{if((0|e)<=2&&(0|i[x+8>>2])<=2&&(0|i[x+12>>2])<=2){if(t|=e=0|jt(0|(a=0|q(x)),0,45),e=S()|-1040385&r,c=0|Q(x),!(0|G(a))){if((0|c)<=0)break;for(l=0;;){A=0|Vt(0|t,0|e,52),S(),A&=15;t:do{if(A)for(s=1;;){switch(r=0|Vt(0|t,0|e,0|(o=3*(15-s|0)|0)),S(),t&=~(a=0|jt(7,0,0|o)),a=e&~S(),7&r){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;break;default:e=7&r}if(t|=e=0|jt(0|e,0,0|o),e=0|S()|a,!(s>>>0<A>>>0))break t;s=s+1|0}}while(0);if((0|(l=l+1|0))==(0|c))break e}}A=0|Vt(0|t,0|e,52),S(),A&=15;t:do{if(A){r=1;n:for(;;){switch(M=0|Vt(0|t,0|e,3*(15-r|0)|0),S(),7&M){case 1:break n;case 0:break;default:break t}if(!(r>>>0<A>>>0))break t;r=r+1|0}if(0|K(a,0|i[x>>2]))for(s=1;;){switch(a=t&~(a=0|jt(7,0,0|(r=3*(15-s|0)|0))),o=e&~S(),e=0|Vt(0|t,0|e,0|r),S(),7&e){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;break;default:e&=7}if(t=0|jt(0|e,0,0|r),t|=a,e=0|S()|o,!(s>>>0<A>>>0))break t;s=s+1|0}else for(s=1;;){switch(r=0|Vt(0|t,0|e,0|(o=3*(15-s|0)|0)),S(),t&=~(a=0|jt(7,0,0|o)),a=e&~S(),7&r){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;break;default:e=7&r}if(t|=e=0|jt(0|e,0,0|o),e=0|S()|a,!(s>>>0<A>>>0))break t;s=s+1|0}}}while(0);if((0|c)>0){r=0;do{t=0|Ie(t,e),e=0|S(),r=r+1|0}while((0|r)!=(0|c))}}else t=0,e=0}while(0);return M=t,T(0|(w=e)),N=n,0|M}function Le(e){return(0|(e|=0))%2|0}function Be(e,t,n){n|=0;var r,s,A,l,c=0,d=0,h=0,p=0,m=0;if(A=N,N=N+64|0,s=A+24|0,p=A+48|0,m=A,(t|=0)>>>0>15)return N=A,0|(m=4);if(r=+a[(e|=0)>>3],a[o>>3]=r,!(2146435072&~i[o+4>>2]))return N=A,0|(m=3);if(c=+a[e+8>>3],a[o>>3]=c,!(2146435072&~i[o+4>>2]))return N=A,0|(m=3);l=(d=+u(+r))*+u(+c),d*=+f(+c),c=+f(+r),a[m>>3]=l,a[m+8>>3]=d,a[m+16>>3]=c,a[o>>3]=l;do{if(2146435072&~i[o+4>>2]&&(a[o>>3]=c,e=0|i[o+4>>2],a[o>>3]=d,!(!(2146435072&~i[o+4>>2])|!0&!(2146435072&~e)))){if(i[s>>2]=i[m>>2],i[s+4>>2]=i[m+4>>2],i[s+8>>2]=i[m+8>>2],i[s+12>>2]=i[m+12>>2],i[s+16>>2]=i[m+16>>2],i[s+20>>2]=i[m+20>>2],ce(s,t,p),p=0|ke(p,t),m=0|S(),i[n>>2]=p,i[n+4>>2]=m,!(!(0|p)&!(0|m))){h=0;break}M(27634,27225,1073,27248)}else h=2}while(0);return N=A,0|(m=h)}function Oe(e,t,n){var r,a,o=0,s=0,A=0,l=0,c=0,u=0,f=0,d=0,h=0,p=0;if(a=(n|=0)+4|0,p=0|Vt(0|(e|=0),0|(t|=0),52),S(),p&=15,h=0|Vt(0|e,0|t,45),S(),o=!(0|p),0|G(127&h)){if(o)return 0|(p=1);o=1}else{if(o)return 0|(p=0);o=0|i[a>>2]||0|i[n+8>>2]?1:1&!!(0|i[n+12>>2])}for(h=n+8|0,r=n+12|0,d=1,n=0|i[a>>2],l=0|i[h>>2],A=0|i[r>>2];s=3*n|0,c=3*l|0,f=3*A|0,1&d?(u=l+s|0,i[a>>2]=u,A=A+c|0,i[h>>2]=A,s=f+n|0,i[r>>2]=s,n=A-u|0,l=s-u|0,(0|u)<0?(i[h>>2]=n,i[r>>2]=l,i[a>>2]=0,c=0,s=l):(n=A,c=u),l=c-n|0,A=s-n|0,(0|n)<0?(i[a>>2]=l,i[r>>2]=A,i[h>>2]=0,c=l,s=0):(A=s,s=n),n=c-A|0,l=s-A|0,(0|A)<0?(i[a>>2]=n,i[h>>2]=l,i[r>>2]=0,A=0):(l=s,n=c),(0|(s=(0|A)<(0|(s=(0|l)<(0|n)?l:n))?A:s))>0&&(A=A-s|0,l=l-s|0,n=n-s|0,i[a>>2]=n,i[h>>2]=l,i[r>>2]=A)):(u=c+n|0,c=A+s|0,i[a>>2]=c,i[h>>2]=u,s=f+l|0,i[r>>2]=s,n=u-c|0,A=s-c|0,(0|c)<0?(i[h>>2]=n,i[r>>2]=A,i[a>>2]=0,c=0,s=A):n=u,l=c-n|0,A=s-n|0,(0|n)<0?(i[a>>2]=l,i[r>>2]=A,i[h>>2]=0,c=l,s=0):(A=s,s=n),n=c-A|0,l=s-A|0,(0|A)<0?(i[a>>2]=n,i[h>>2]=l,i[r>>2]=0,A=0):(l=s,n=c),(0|(s=(0|A)<(0|(s=(0|l)<(0|n)?l:n))?A:s))>0&&(A=A-s|0,l=l-s|0,n=n-s|0,i[a>>2]=n,i[h>>2]=l,i[r>>2]=A)),s=0|Vt(0|e,0|t,3*(15-d|0)|0),S(),((s&=7)+-1|0)>>>0<6&&(u=0|i[22032+(12*s|0)+4>>2],f=0|i[22032+(12*s|0)+8>>2],c=(0|i[22032+(12*s|0)>>2])+n|0,i[a>>2]=c,l=u+l|0,i[h>>2]=l,n=f+A|0,i[r>>2]=n,A=l-c|0,s=n-c|0,(0|c)<0&&(i[h>>2]=A,i[r>>2]=s,i[a>>2]=0,c=0,n=s,l=A),s=c-l|0,A=n-l|0,(0|l)<0?(i[a>>2]=s,i[r>>2]=A,i[h>>2]=0,c=s,l=0):A=n,n=c-A|0,s=l-A|0,(0|A)<0?(i[a>>2]=n,i[h>>2]=s,i[r>>2]=0,l=s,A=0):n=c,(0|(s=(0|A)<(0|(s=(0|l)<(0|n)?l:n))?A:s))>0&&(A=A-s|0,l=l-s|0,n=n-s|0,i[a>>2]=n,i[h>>2]=l,i[r>>2]=A)),d>>>0<p>>>0;)d=d+1|0;return 0|o}function Fe(e,t,n){n|=0;var r,a,o,s=0,A=0,l=0,c=0,u=0,f=0,d=0,h=0,p=0;if(o=N,N=N+16|0,a=o,h=0|Vt(0|(e|=0),0|(t|=0),45),S(),(h&=127)>>>0>121)return i[n>>2]=0,i[n+4>>2]=0,i[n+8>>2]=0,i[n+12>>2]=0,N=o,0|(p=5);e:do{if(0|G(h)&&(u=0|Vt(0|e,0|t,52),S(),u&=15,0|u)){s=1;t:for(;;){switch(p=0|Vt(0|e,0|t,3*(15-s|0)|0),S(),7&p){case 5:break t;case 0:break;default:d=t;break e}if(!(s>>>0<u>>>0)){d=t;break e}s=s+1|0}for(c=1,s=t;;){switch(A=e&~(A=0|jt(7,0,0|(t=3*(15-c|0)|0))),l=s&~S(),s=0|Vt(0|e,0|s,0|t),S(),7&s){case 1:s=3;break;case 3:s=2;break;case 2:s=6;break;case 6:s=4;break;case 4:s=5;break;case 5:s=1;break;default:s&=7}if(e=0|jt(0|s,0,0|t),e|=A,s=0|S()|l,!(c>>>0<u>>>0)){d=s;break e}c=c+1|0}}else d=t}while(0);if(p=7696+(28*h|0)|0,i[n>>2]=i[p>>2],i[n+4>>2]=i[p+4>>2],i[n+8>>2]=i[p+8>>2],i[n+12>>2]=i[p+12>>2],!(0|Oe(e,d,n)))return N=o,0|(p=0);if(p=n+4|0,i[a>>2]=i[p>>2],i[a+4>>2]=i[p+4>>2],i[a+8>>2]=i[p+8>>2],f=0|Vt(0|e,0|d,52),S(),r=15&f,1&f?(l=0|i[p>>2],s=(3*(A=0|i[(u=n+8|0)>>2])|0)+l|0,l=(t=0|i[(f=n+12|0)>>2])+(3*l|0)|0,i[p>>2]=l,i[u>>2]=s,A=(3*t|0)+A|0,i[f>>2]=A,t=s-l|0,c=A-l|0,(0|l)<0&&(i[u>>2]=t,i[f>>2]=c,i[p>>2]=0,s=t,l=0,A=c),c=l-s|0,t=A-s|0,(0|s)<0?(i[p>>2]=c,i[f>>2]=t,i[u>>2]=0,s=0):(t=A,c=l),l=c-t|0,A=s-t|0,(0|t)<0?(i[p>>2]=l,i[u>>2]=A,i[f>>2]=0,t=0):(A=s,l=c),(0|(s=(0|t)<(0|(s=(0|A)<(0|l)?A:l))?t:s))>0&&(i[p>>2]=l-s,i[u>>2]=A-s,i[f>>2]=t-s),A=r+1|0):A=r,0|G(h)){e:do{if(r)for(t=1;;){if(s=0|Vt(0|e,0|d,3*(15-t|0)|0),S(),0|(s&=7))break e;if(!(t>>>0<r>>>0)){s=0;break}t=t+1|0}else s=0}while(0);s=4==(0|s)&1}else s=0;if(0|pe(n,A,s,0)){if(0|G(h))do{}while(0|pe(n,A,0,0));(0|A)!=(0|r)&&(e=0|i[(u=n+12|0)>>2],t=0|St(.14285714285714285*+(((s=(0|i[p>>2])-e|0)<<1)+(e=(0|i[(c=n+8|0)>>2])-e|0)|0)),i[p>>2]=t,s=0|St(.14285714285714285*+((3*e|0)-s|0)),i[c>>2]=s,i[u>>2]=0,e=s-t|0,A=0-t|0,(0|t)<0?(i[c>>2]=e,i[u>>2]=A,i[p>>2]=0,s=e,t=0):A=0,l=t-s|0,e=A-s|0,(0|s)<0?(i[p>>2]=l,i[u>>2]=e,i[c>>2]=0,t=l,s=0):e=A,l=t-e|0,A=s-e|0,(0|e)<0?(i[p>>2]=l,i[c>>2]=A,i[u>>2]=0,t=l,e=0):A=s,(0|(s=(0|e)<(0|(s=(0|A)<(0|t)?A:t))?e:s))>0&&(i[p>>2]=t-s,i[c>>2]=A-s,i[u>>2]=e-s))}else(0|A)!=(0|r)&&(i[p>>2]=i[a>>2],i[p+4>>2]=i[a+4>>2],i[p+8>>2]=i[a+8>>2]);return N=o,0|(p=0)}function De(e,t,n){n|=0;var r,i,o,s=0,A=0,l=0;return o=N,N=N+48|0,i=o,(s=0|Fe(e|=0,t|=0,r=o+24|0))?(N=o,0|s):(s=0|Vt(0|e,0|t,52),S(),ue(r,15&s,i),l=+p(+ +a[i+16>>3]),A=+g(+ +a[i+8>>3],+ +a[i>>3]),a[n>>3]=l,a[n+8>>3]=A,N=o,0|(s=0))}function Ue(e,t,n){n|=0;var r,i=0,a=0,o=0;if(r=N,N=N+16|0,0|(i=0|Fe(e|=0,t|=0,o=r)))return N=r,0|(o=i);i=0|Vt(0|e,0|t,45),S(),i=!(0|G(127&i)),a=0|Vt(0|e,0|t,52),S(),a&=15;e:do{if(!i){if(0|a)for(i=1;;){if(!(!((0|jt(7,0,3*(15-i|0)|0))&e|0)&!((0|S())&t)))break e;if(!(i>>>0<a>>>0))break;i=i+1|0}return de(o,a,0,5,n),N=r,0|0}}while(0);return ge(o,a,0,6,n),N=r,0|0}function Ve(e,t){t|=0;var n=0,r=0,a=0,o=0,s=0,A=0,l=0;if((e|=0)>>>0>15)return 0|(A=4);if(jt(0|e,0,52),A=134225919|S(),!e){n=0,r=0;do{0|G(r)&&(jt(0|r,0,45),s=0|A|S(),i[(e=t+(n<<3)|0)>>2]=-1,i[e+4>>2]=s,n=n+1|0),r=r+1|0}while(122!=(0|r));return 0|(n=0)}n=0,s=0;do{if(0|G(s)){for(jt(0|s,0,45),r=1,a=-1,o=0|A|S();a&=~(l=0|jt(7,0,3*(15-r|0)|0)),o&=~S(),(0|r)!=(0|e);)r=r+1|0;i[(l=t+(n<<3)|0)>>2]=a,i[l+4>>2]=o,n=n+1|0}s=s+1|0}while(122!=(0|s));return 0|(n=0)}function je(e,t,n,r){e|=0,r|=0;var a=0,o=0,s=0;a=0|Vt(0|(t|=0),0|(n|=0),52),S(),!(0|t)&!(0|n)|(0|r)>15|(0|(a&=15))>(0|r)?(o=-1,t=-1,n=0,a=0):(t=0|Me(t,n,a+1|0,r),s=-15728641&S(),n=0|jt(0|r,0,52),o=a,t=(t=!(0|Se(n|=t,s=0|s|S())))?-1:r,a=s),i[(s=e)>>2]=n,i[s+4>>2]=a,i[e+8>>2]=o,i[e+12>>2]=t}function ze(e,t,n,r){n|=0,r|=0;var a=0,o=0;return a=0|Vt(0|(e|=0),0|(t|=0),52),S(),a&=15,i[(o=r+8|0)>>2]=a,!(0|e)&!(0|t)|(0|n)>15|(0|a)>(0|n)?(i[(n=r)>>2]=0,i[n+4>>2]=0,i[o>>2]=-1,void(i[r+12>>2]=-1)):(e=0|Me(e,t,a+1|0,n),o=-15728641&S(),a=0|jt(0|n,0,52),a|=e,o=0|o|S(),i[(e=r)>>2]=a,i[e+4>>2]=o,e=r+12|0,0|Se(a,o)?void(i[e>>2]=n):void(i[e>>2]=-1))}function Ge(e){var t,n=0,r=0,a=0,o=0,s=0,A=0,l=0,c=0;if(!(!(0|(n=0|i[(r=e|=0)>>2]))&!(0|(r=0|i[r+4>>2]))||(a=0|Vt(0|n,0|r,52),S(),n=0|Pt(0|(l=0|jt(1,0,3*(15^(a&=15))|0)),0|S(),0|n,0|r),r=0|S(),i[(l=e)>>2]=n,i[l+4>>2]=r,(0|a)<(0|(A=0|i[(l=e+8|0)>>2]))))){for(t=e+12|0,s=a;;){if((0|s)==(0|A)){a=5;break}if(c=(0|s)==(0|i[t>>2]),a=0|Vt(0|n,0|r,0|(o=3*(15-s|0)|0)),S(),c&1==(0|(a&=7))&!0){a=7;break}if(!(7==(0|a)&!0)){a=10;break}if(n=0|Pt(0|n,0|r,0|(c=0|jt(1,0,0|o)),0|S()),r=0|S(),i[(c=e)>>2]=n,i[c+4>>2]=r,!((0|s)>(0|A))){a=10;break}s=s+-1|0}if(5==(0|a))return i[(c=e)>>2]=0,i[c+4>>2]=0,i[l>>2]=-1,void(i[t>>2]=-1);if(7==(0|a))return A=0|Pt(0|n,0|r,0|(A=0|jt(1,0,0|o)),0|S()),l=0|S(),i[(c=e)>>2]=A,i[c+4>>2]=l,void(i[t>>2]=s+-1)}}function He(e){var t;return t=(e=+e)<0?e+6.283185307179586:e,+(e>=6.283185307179586?t+-6.283185307179586:t)}function qe(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 Qe(e,t){e|=0;var n,r,i,o=0;return r=+a[(t|=0)>>3],n=+a[e>>3],o=(i=+f(.5*(r-n)))*i+(o=+f(.5*(+a[t+8>>3]-+a[e+8>>3])))*(+u(+r)*+u(+n)*o),2*+g(+ +c(+o),+ +c(+(1-o)))*6371.007180918475}function Ke(e,t){return t|=0,(e|=0)>>>0>15?0|(t=4):(a[t>>3]=+a[20624+(e<<3)>>3],0|(t=0))}function We(e,t){t|=0;var n=0;return(e|=0)>>>0>15?0|(t=4):(n=0|Ot(0|(n=0|Ze(7,0,e,((0|e)<0)<<31>>31)),0|S(),120,0),e=0|S(),i[t>>2]=2|n,i[t+4>>2]=e,0|(t=0))}function $e(e,t,n,a,o){n|=0,a|=0,o|=0;var s,A=0,l=0,c=0,u=0,f=0,d=0,h=0,p=0,m=0,g=0,b=0,v=0,y=0;if(s=N,N=N+16|0,v=s,d=0|Vt(0|(e|=0),0|(t|=0),52),S(),d&=15,m=0|Vt(0|n,0|a,52),S(),(0|d)!=(15&m))return N=s,0|(v=12);if(u=0|Vt(0|e,0|t,45),S(),u&=127,f=0|Vt(0|n,0|a,45),S(),u>>>0>121|(f&=127)>>>0>121)return N=s,0|(v=5);if(m=(0|u)!=(0|f)){if(7==(0|(l=0|$(u,f))))return N=s,0|(v=1);7==(0|(c=0|$(f,u)))?M(27291,27315,164,27325):(b=l,A=c)}else b=0,A=0;h=0|G(u),p=0|G(f),i[v>>2]=0,i[v+4>>2]=0,i[v+8>>2]=0,i[v+12>>2]=0;do{if(b){l=(0|(f=0|i[4272+(28*u|0)+(b<<2)>>2]))>0;e:do{if(p)if(l)for(u=0,c=n,l=a;;){switch(c=0|Pe(c,l),l=0|S(),0|A){case 5:case 1:A=3;break;case 3:A=2;break;case 2:A=6;break;case 6:A=4;break;case 4:A=5}if((0|(u=u+1|0))==(0|f)){f=A,u=c,c=l;break e}}else f=A,u=n,c=a;else if(l)for(u=0,c=n,l=a;;){switch(c=0|Ne(c,l),l=0|S(),0|A){case 1:A=3;break;case 3:A=2;break;case 2:A=6;break;case 6:A=4;break;case 4:A=5;break;case 5:A=1}if((0|(u=u+1|0))==(0|f)){f=A,u=c,c=l;break e}}else f=A,u=n,c=a}while(0);if(Oe(u,c,v),m||M(27340,27315,194,27325),(l=!!(0|h))&(A=!!(0|p))&&M(27367,27315,195,27325),l){if(7==(0|(A=0|Ce(e,t)))){A=5;break}if(0|r[21968+(7*A|0)+b|0]){A=1;break}m=p=0|i[21136+(28*A|0)+(b<<2)>>2]}else if(A){if(7==(0|(A=0|Ce(u,c)))){A=5;break}if(0|r[21968+(7*A|0)+f|0]){A=1;break}m=0,p=0|i[21136+(28*f|0)+(A<<2)>>2]}else m=0,p=0;if((m|p|0)>=0){if((0|p)>0){a=v+8|0,h=v+12|0,f=0,c=0|i[(n=v+4|0)>>2],l=0|i[a>>2],A=0|i[h>>2];do{(0|(u=(0|(A=(y=(0|(c=A+c-(y=(t=(0|(g=l+c|0))<0)?g:0)-(u=(e=(0|(l=A+l-y|0))<0)?l:0)|0))<0)?0:c))<(0|(u=(0|(l=(e?0:l)-(c=y?c:0)|0))<(0|(c=(t?0:g)-u-c|0))?l:c))?A:u))>0&&(c=c-u|0,l=l-u|0,A=A-u|0),f=f+1|0}while((0|f)!=(0|p));i[n>>2]=c,i[a>>2]=l,i[h>>2]=A}if((b+-1|0)>>>0<6?(A=0|i[22032+(12*b|0)>>2],c=0|i[22032+(12*b|0)+4>>2],A=A-(l=(0|(l=(0|(y=0|i[22032+(12*b|0)+8>>2]))<(0|(l=(0|c)<(0|A)?c:A))?y:l))>0?l:0)|0,c=c-l|0,l=y-l|0):(A=0,c=0,l=0),d)for(;;){if(u=3*A|0,f=3*c|0,n=3*l|0,0|Le(d)?(A=(y=(0|(l=(0|(b=(l=(0|(c=A+n-((e=(0|(t=u+c|0))<0)?t:0)-((g=(0|(y=f+l-(e?t:0)|0))<0)?y:0)|0))<0)?0:c))<(0|(l=(0|(u=(g?0:y)-(l?c:0)|0))<(0|(c=(e?0:t)-(g?y:0)-(l?c:0)|0))?u:c))?b:l))>0)?l:0,u=u-(y?l:0)|0,l=b-(y?l:0)|0):(A=(y=(0|(l=(0|(b=(l=(0|(c=n+c-((t=(0|(g=u+l|0))<0)?g:0)-((A=(0|(y=f+A-(t?g:0)|0))<0)?y:0)|0))<0)?0:c))<(0|(l=(0|(u=(A?0:y)-(l?c:0)|0))<(0|(c=(t?0:g)-(A?y:0)-(l?c:0)|0))?u:c))?b:l))>0)?l:0,u=u-(y?l:0)|0,l=b-(y?l:0)|0),A=c-A|0,!((0|d)>1)){c=u;break}d=d+-1|0,c=u}if((0|m)>0){u=0;do{l=(l=(A=(0|(b=A+l-((e=(0|(t=A+c|0))<0)?t:0)-((g=(0|(y=c+l-(e?t:0)|0))<0)?y:0)|0))<0)?0:b)-((y=(0|(A=(0|l)<(0|(A=(0|(c=(g?0:y)-(A?b:0)|0))<(0|(b=(e?0:t)-(g?y:0)-(A?b:0)|0))?c:b))?l:A))>0)?A:0)|0,c=c-(y?A:0)|0,A=b-(y?A:0)|0,u=u+1|0}while((0|u)!=(0|m))}n=v+4|0,b=0|i[(d=v+8|0)>>2],y=0|i[(a=v+12|0)>>2],u=(0|i[n>>2])+A|0,i[n>>2]=u,c=b+c|0,i[d>>2]=c,A=y+l|0,i[a>>2]=A,l=c-u|0,(0|u)<0?(A=A-u|0,i[d>>2]=l,i[a>>2]=A,i[n>>2]=0,c=0):(l=c,c=u),(0|l)<0&&(c=c-l|0,i[n>>2]=c,A=A-l|0,i[a>>2]=A,i[d>>2]=0,l=0),f=c-A|0,u=l-A|0,(0|A)<0?(i[n>>2]=f,i[d>>2]=u,i[a>>2]=0,c=f,A=0):u=l,(0|(l=(0|A)<(0|(l=(0|u)<(0|c)?u:c))?A:l))>0?(i[n>>2]=c-l,i[d>>2]=u-l,i[a>>2]=A-l,g=77):g=77}else A=5}else if(Oe(n,a,v),!!(0|h)&!!(0|p))if((0|f)!=(0|u)&&M(27398,27315,264,27325),7==(0|(l=0|Ce(e,t)))|7==(0|(A=0|Ce(n,a))))A=5;else if(0|r[21968+(7*l|0)+A|0])A=1;else if((0|(n=0|i[21136+(28*l|0)+(A<<2)>>2]))>0){a=v+8|0,h=v+12|0,f=0,c=0|i[(d=v+4|0)>>2],l=0|i[a>>2],A=0|i[h>>2];do{(0|(u=(0|(A=(e=(0|(c=A+c-(e=(g=(0|(b=l+c|0))<0)?b:0)-(u=(t=(0|(l=A+l-e|0))<0)?l:0)|0))<0)?0:c))<(0|(u=(0|(l=(t?0:l)-(c=e?c:0)|0))<(0|(c=(g?0:b)-u-c|0))?l:c))?A:u))>0&&(c=c-u|0,l=l-u|0,A=A-u|0),f=f+1|0}while((0|f)!=(0|n));i[d>>2]=c,i[a>>2]=l,i[h>>2]=A,g=77}else g=77;else g=77}while(0);return 77==(0|g)&&(A=v+4|0,i[o>>2]=i[A>>2],i[o+4>>2]=i[A+4>>2],i[o+8>>2]=i[A+8>>2],A=0),N=s,0|(y=A)}function Je(e,t,n,r){n|=0,r|=0;var a=0,o=0,s=0,A=0,l=0,c=0,u=0,f=0,d=0,h=0,p=0,m=0,g=0,b=0,v=0,y=0,x=0,_=0,w=0,T=0,E=0;if(o=0|Vt(0|(e|=0),0|(t|=0),52),S(),o&=15,x=0|Vt(0|e,0|t,45),S(),(x&=127)>>>0>121)return 0|(r=5);if(g=0|G(x),jt(0|o,0,52),A=134225919|S(),i[(s=r)>>2]=-1,i[s+4>>2]=A,s=0|i[n>>2],A=0|i[n+4>>2],n=0|i[n+8>>2],!o){a=(a=(n=(0|(b=n-(b=(t=(0|s)<0)?s:0)+((g=(0|(y=A-b|0))<0)?0-y|0:0)|0))<0)?0:b)-(y=(0|(y=(0|a)<(0|(y=(0|(n=(g?0:y)-(b=n?b:0)|0))<(0|(b=(t?0:s)-(g?y:0)-b|0))?n:b))?a:y))>0?y:0)|0,n=n-y|0;e:do{switch(b-y|0){case 0:switch(0|n){case 0:if(a){a=1==(0|a)?1:7,v=11;break e}a=0;break e;case 1:if(a){a=1==(0|a)?3:7,v=11;break e}a=2;break e;default:return 0|(r=1)}case 1:switch(0|n){case 0:if(a){a=1==(0|a)?5:7,v=11;break e}a=4;break e;case 1:if(!a){a=6;break e}return 0|(a=1);default:return 0|(r=1)}default:return 0|(r=1)}}while(0);return 11==(0|v)&&7==(0|a)||127==(0|(a=0|W(x,a)))?0|(r=1):(y=0|jt(0|a,0,45),x=0|S(),x=-1040385&i[(v=r)+4>>2]|x,i[r>>2]=i[v>>2]|y,i[r+4>>2]=x,0|(r=0))}for(;;){if(m=o,o=o+-1|0,l=(p=s-n|0)>>>0>715827881|(h=A-n|0)>>>0>715827881,0|Le(m)){if(l){if(f=2147483647-p|0,d=-2147483648-p|0,(u=(0|p)>0)?(0|f)<(0|p):(0|d)>(0|p)){a=1,v=107;break}if(E=p<<1,u?(2147483647-E|0)<(0|p):(-2147483648-E|0)>(0|p)){a=1,v=107;break}if((0|h)>0?(2147483647-h|0)<(0|h):(-2147483648-h|0)>(0|h)){a=1,v=107;break}if(l=3*p|0,c=h<<1,(u?(0|f)<(0|c):(0|d)>(0|c))||((0|p)>-1?(-2147483648|l)>=(0|h):(-2147483648^l)<(0|h))){a=1,v=107;break}}else l=3*p|0,c=h<<1;if(f=0|St(.14285714285714285*+(l-h|0)),l=(c=(0|(u=0|St(.14285714285714285*+(c+p|0))))<(0|f))?f:u,(0|(c=c?u:f))<0){if(-2147483648==(0|c)||((0|l)>0?(2147483647-l|0)<(0|c):(-2147483648-l|0)>(0|c))){v=24;break}if((0|l)>-1?(-2147483648|l)>=(0|c):(-2147483648^l)<(0|c)){v=24;break}}d=((d=(0|f)<0)?0:f)-((w=(0|(h=u-(d?f:0)|0))<0)?h:0)-((p=(0|(_=(d?0-f|0:0)-(w?h:0)|0))<0)?_:0)|0,h=(w?0:h)-(p?_:0)|0,d=d-((w=(0|(p=(0|(_=p?0:_))<(0|(p=(0|h)<(0|d)?h:d))?_:p))>0)?p:0)|0,h=h-(w?p:0)|0,l=(E=(0|(u=(0|(T=(u=(0|(f=(3*(p=_-(w?p:0)|0)|0)+d-((_=(0|(w=(3*d|0)+h|0))<0)?w:0)-((l=(0|(E=(3*h|0)+p-(_?w:0)|0))<0)?E:0)|0))<0)?0:f))<(0|(u=(0|(c=(l?0:E)-(u?f:0)|0))<(0|(f=(_?0:w)-(l?E:0)-(u?f:0)|0))?c:f))?T:u))>0)?u:0,c=c-(E?u:0)|0,u=T-(E?u:0)|0}else{if(l){if((c=(0|p)>0)?(2147483647-p|0)<(0|p):(-2147483648-p|0)>(0|p)){a=1,v=107;break}if(l=p<<1,(u=(0|h)>0)?(2147483647-h|0)<(0|h):(-2147483648-h|0)>(0|h)){a=1,v=107;break}if(d=h<<1,u?(2147483647-d|0)<(0|h):(-2147483648-d|0)>(0|h)){a=1,v=107;break}if(c?(2147483647-l|0)<(0|h):(-2147483648-l|0)>(0|h)){a=1,v=107;break}if(c=3*h|0,(0|h)>-1?(-2147483648|c)>=(0|p):(-2147483648^c)<(0|p)){a=1,v=107;break}}else l=p<<1,c=3*h|0;if(f=0|St(.14285714285714285*+(l+h|0)),l=(c=(0|(u=0|St(.14285714285714285*+(c-p|0))))<(0|f))?f:u,(0|(c=c?u:f))<0){if(-2147483648==(0|c)||((0|l)>0?(2147483647-l|0)<(0|c):(-2147483648-l|0)>(0|c))){v=36;break}if((0|l)>-1?(-2147483648|l)>=(0|c):(-2147483648^l)<(0|c)){v=36;break}}d=((d=(0|f)<0)?0:f)-((T=(0|(h=u-(d?f:0)|0))<0)?h:0)-((p=(0|(E=(d?0-f|0:0)-(T?h:0)|0))<0)?E:0)|0,h=(T?0:h)-(p?E:0)|0,d=d-((T=(0|(p=(0|(E=p?0:E))<(0|(p=(0|h)<(0|d)?h:d))?E:p))>0)?p:0)|0,h=h-(T?p:0)|0,l=(_=(0|(u=(0|(w=(u=(0|(f=(3*(p=E-(T?p:0)|0)|0)+h-((E=(0|(T=(3*d|0)+p|0))<0)?T:0)-((l=(0|(_=(3*h|0)+d-(E?T:0)|0))<0)?_:0)|0))<0)?0:f))<(0|(u=(0|(c=(l?0:_)-(u?f:0)|0))<(0|(f=(E?0:T)-(l?_:0)-(u?f:0)|0))?c:f))?w:u))>0)?u:0,c=c-(_?u:0)|0,u=w-(_?u:0)|0}u=(s=(0|(_=n-u+((T=(0|(l=s+(l-f)|0))<0)?0-l|0:0)+((f=(0|(c=A-c-(T?l:0)|0))<0)?0-c|0:0)|0))<0)?0:_,E=(f?0:c)-(s?_:0)|0,_=(_=(T?0:l)-(f?c:0)-(s?_:0)|0)-((n=(0|(s=(0|u)<(0|(s=(0|E)<(0|_)?E:_))?u:s))>0)?s:0)|0,f=0|i[(c=r)>>2],c=0|i[c+4>>2],l=f&~(l=0|jt(7,0,0|(A=3*(15-m|0)|0))),c&=~S(),n=(n=(s=(0|(T=u-(n?s:0)-(T=(f=(0|_)<0)?_:0)+((w=(0|(E=E-(n?s:0)-T|0))<0)?0-E|0:0)|0))<0)?0:T)-(E=(0|(E=(0|n)<(0|(E=(0|(s=(w?0:E)-(T=s?T:0)|0))<(0|(T=(f?0:_)-(w?E:0)-T|0))?s:T))?n:E))>0?E:0)|0,s=s-E|0;e:do{switch(T-E|0){case 0:switch(0|s){case 0:n=0|n?1==(0|n)?1:7:0;break e;case 1:n=0|n?1==(0|n)?3:7:2;break e;default:v=45;break e}case 1:switch(0|s){case 0:n=0|n?1==(0|n)?5:7:4;break e;case 1:if(n){v=45;break e}n=6;break e;default:v=45;break e}default:v=45}}while(0);if(45==(0|v)&&(v=0,n=7),w=0|jt(0|n,0,0|A),T=0|S()|c,i[(E=r)>>2]=w|l,i[E+4>>2]=T,(0|m)<=1){v=47;break}s=d,A=h,n=p}if(24==(0|v))M(27634,27425,416,27447);else if(36==(0|v))M(27634,27425,464,27461);else{if(47==(0|v)){if((0|d)>1|(0|h)>1|(0|p)>1)return 0|(E=1);n=(n=(o=(0|(T=p-(T=(_=(0|d)<0)?d:0)+((w=(0|(E=h-T|0))<0)?0-E|0:0)|0))<0)?0:T)-(E=(0|(E=(0|n)<(0|(E=(0|(o=(w?0:E)-(T=o?T:0)|0))<(0|(T=(_?0:d)-(w?E:0)-T|0))?o:T))?n:E))>0?E:0)|0,o=o-E|0;e:do{switch(T-E|0){case 0:switch(0|o){case 0:o=0|n?1==(0|n)?1:7:0;break e;case 1:o=0|n?1==(0|n)?3:7:2;break e;default:v=55;break e}case 1:switch(0|o){case 0:o=0|n?1==(0|n)?5:7:4;break e;case 1:if(n){v=55;break e}o=6;break e;default:v=55;break e}default:v=55}}while(0);55==(0|v)&&(o=7),c=127==(0|(A=0|W(x,o)))?0:0|G(A);e:do{if(o){if(g){if(7==(0|(n=0|Ce(e,t))))return 0|(E=5);s=0|i[21344+(28*n|0)+(o<<2)>>2];t:do{if((0|s)>0)for(n=o,o=0;;){switch(0|n){case 1:n=5;break;case 5:n=4;break;case 4:n=6;break;case 6:n=2;break;case 2:n=3;break;case 3:n=1}if((0|(o=o+1|0))==(0|s))break t}else n=o}while(0);if(1==(0|n))return 0|(E=9);127==(0|(o=0|W(x,n)))&&M(27476,27315,415,27506),0|G(o)?M(27521,27315,416,27506):(a=o,y=s,b=n)}else a=A,y=0,b=o;if((0|(l=0|i[4272+(28*x|0)+(b<<2)>>2]))<=-1&&M(27552,27315,423,27506),!c){if((0|y)<0)return 0|(E=5);if(0|y){n=0,o=0|i[(s=r)>>2],s=0|i[s+4>>2];do{o=0|Re(o,s),s=0|S(),i[(E=r)>>2]=o,i[E+4>>2]=s,n=n+1|0}while((0|n)<(0|y))}if((0|l)<=0){v=104;break}for(n=0,o=0|i[(s=r)>>2],s=0|i[s+4>>2];;)if(o=0|Re(o,s),s=0|S(),i[(E=r)>>2]=o,i[E+4>>2]=s,(0|(n=n+1|0))==(0|l)){v=104;break e}}if(7==(0|(A=0|$(a,x)))&&M(27291,27315,432,27506),o=0|i[(n=r)>>2],n=0|i[n+4>>2],(0|l)>0){s=0;do{o=0|Re(o,n),n=0|S(),i[(E=r)>>2]=o,i[E+4>>2]=n,s=s+1|0}while((0|s)!=(0|l))}if(7==(0|(n=0|Ce(o,n)))&&M(27634,27315,444,27506),o=0|H(a),(0|(o=0|i[(o?21760:21552)+(28*A|0)+(n<<2)>>2]))<0&&M(27634,27315,458,27506),o){n=0,s=0|i[(A=r)>>2],A=0|i[A+4>>2];do{s=0|Ie(s,A),A=0|S(),i[(E=r)>>2]=s,i[E+4>>2]=A,n=n+1|0}while((0|n)<(0|o));v=104}else v=104}else if(!!(0|g)&!!(0|c)){if(7==(0|(a=0|Ce(e,t)))|7==(0|(n=0|Ce(0|i[(n=r)>>2],0|i[n+4>>2]))))return 0|(E=5);if((0|(n=0|i[21344+(28*a|0)+(n<<2)>>2]))<0)return 0|(E=5);if(n){a=0,o=0|i[(s=r)>>2],s=0|i[s+4>>2];do{o=0|Re(o,s),s=0|S(),i[(E=r)>>2]=o,i[E+4>>2]=s,a=a+1|0}while((0|a)<(0|n));a=A,v=104}else a=A,v=105}else a=A,v=104}while(0);return 104==(0|v)&&c&&(v=105),105==(0|v)&&1==(0|Ce(0|i[(E=r)>>2],0|i[E+4>>2]))?0|(E=9):(_=0|i[(T=r)>>2],T=-1040385&i[T+4>>2],w=0|jt(0|a,0,45),T=0|T|S(),i[(E=r)>>2]=_|w,i[E+4>>2]=T,0|(E=0))}if(107==(0|v))return 0|a}return 0}function Ye(e,t,n,r,a){n|=0,r|=0,a|=0;var o,s,A=0,l=0,c=0;return o=N,N=N+32|0,c=o,0|(A=0|$e(e|=0,t|=0,e,t,l=o+12|0))?(N=o,0|(c=A)):0|(e=0|$e(e,t,n,r,c))?(N=o,0|(c=e)):(t=(0|(n=(r=(s=(0|(e=(0|i[l>>2])-(0|i[c>>2])|0))<0)?0-e|0:0)+((0|i[l+4>>2])-(0|i[c+4>>2]))|0))<0,l=(l=(A=(0|(r=(0|i[l+8>>2])-(0|i[c+8>>2])+r+(t?0-n|0:0)|0))<0)?0:r)-(c=(0|(c=(0|l)<(0|(c=(0|(A=(t?0:n)-(r=A?r:0)|0))<(0|(r=(s?0:e)-(t?n:0)-r|0))?A:r))?l:c))>0?c:0)|0,A=A-c|0,l=(0|(c=(0|(c=r-c|0))>-1?c:0-c|0))>(0|(l=(0|(A=(0|A)>-1?A:0-A|0))>(0|(l=(0|l)>-1?l:0-l|0))?A:l))?c:l,i[(c=a)>>2]=l,i[c+4>>2]=((0|l)<0)<<31>>31,N=o,0|(c=0))}function Xe(e,t,n,r,a,o,s,A,c,u,f){e|=0,t|=0,n|=0,r|=0,a|=0,o|=0,s|=0,A|=0,c|=0,u|=0,f|=0;var d,h,p,m,g,b,v,y=0,x=0,_=0,w=0,T=0,E=0,C=0,I=0,R=0,P=0,k=0;if(v=N,N=N+48|0,x=v+12|0,b=v,i[(y=v+24|0)>>2]=0,i[y+4>>2]=0,i[y+8>>2]=0,i[x>>2]=0,i[x+4>>2]=0,i[x+8>>2]=0,0|$e(e,t,e,t,y)&&M(27634,27315,696,27575),0|$e(e,t,n,r,x)&&M(27634,27315,701,27575),n=(r=0|i[(T=y+8|0)>>2])-(0|i[y>>2])|0,i[y>>2]=n,r=(0|i[(P=y+4|0)>>2])-r|0,i[P>>2]=r,y=0-(P=r+n|0)|0,i[T>>2]=y,E=(C=0|i[(T=x+8|0)>>2])-(0|i[x>>2])|0,i[x>>2]=E,C=(0|i[(R=x+4|0)>>2])-C|0,i[R>>2]=C,R=C+E|0,i[T>>2]=0-R,m=(I=1/(+(a>>>0)+4294967296*+(0|o)))*+(E-n|0),g=I*+(C-r|0),I*=+(P-R|0),i[b>>2]=n,i[(R=b+4|0)>>2]=r,i[(P=b+8|0)>>2]=y,(0|o)<0)return N=v,0|(u=0);for(p=+(0|n),h=+(0|r),d=+(0|y),E=0,C=0;;){if(k=m*(w=+(E>>>0)+4294967296*+(0|C))+p,_=g*w+h,w=I*w+d,r=~~+qt(+k),y=~~+qt(+_),n=~~+qt(+w),(k=+l(+(+(0|r)-k)))>(_=+l(+(+(0|y)-_)))&k>(w=+l(+(+(0|n)-w)))?r=0-(x=n+y|0)|0:(x=0-r|0,_>w&&(y=x-n|0)),i[R>>2]=y,i[b>>2]=x,i[P>>2]=0,n=r+y|0,(0|r)>0?(i[R>>2]=n,i[P>>2]=r,i[b>>2]=0,x=0):(n=y,r=0),(0|n)<0?(y=x-n|0,i[b>>2]=y,r=r-n|0,i[P>>2]=r,i[R>>2]=0,x=y-r|0,n=0-r|0,(0|r)<0?(i[b>>2]=x,i[R>>2]=n,i[P>>2]=0,T=n,r=0):(T=0,x=y)):T=n,(0|(n=(0|r)<(0|(n=(0|T)<(0|x)?T:x))?r:n))>0&&(i[b>>2]=x-n,i[R>>2]=T-n,i[P>>2]=r-n),n=0|Pt(0|(n=0|Ot(0|E,0|C,0|u,0|f)),0|S(),0|A,0|c),S(),0|(n=0|Je(e,t,b,s+(n<<3)|0))){r=20;break}if(T=E,E=0|Pt(0|E,0|C,1,0),x=C,C=0|S(),!((0|x)<(0|o)|(0|x)==(0|o)&T>>>0<a>>>0)){n=0,r=20;break}}return 20==(0|r)?(N=v,0|n):0}function Ze(e,t,n,r){e|=0,t|=0;var i=0,a=0,o=0;if(!(0|(n|=0))&!(0|(r|=0)))return a=1,T(0|(i=0)),0|a;a=e,i=t,e=1,t=0;do{e=0|Ot(0|((o=!0&!(1&n))?1:a),0|(o?0:i),0|e,0|t),t=0|S(),n=0|Ut(0|n,0|r,1),r=0|S(),a=0|Ot(0|a,0|i,0|a,0|i),i=0|S()}while(!(!(0|n)&!(0|r)));return T(0|t),0|e}function et(e,t,n,r){n|=0,r|=0;var o,s=0,A=0,l=0,c=0,f=0,d=0;o=N,N=N+16|0,A=o,l=0|Vt(0|(e|=0),0|(t|=0),52),S(),l&=15;do{if(l){if(!(s=0|De(e,t,A))){f=+a[A>>3],c=1/+u(+f),d=+a[26032+(l<<3)>>3],a[n>>3]=f+d,a[n+8>>3]=f-d,f=+a[A+8>>3],c*=d,a[n+16>>3]=c+f,a[n+24>>3]=f-c;break}return N=o,0|(l=s)}if(s=0|Vt(0|e,0|t,45),S(),(s&=127)>>>0>121)return N=o,0|(l=5);A=22128+(s<<5)|0,i[n>>2]=i[A>>2],i[n+4>>2]=i[A+4>>2],i[n+8>>2]=i[A+8>>2],i[n+12>>2]=i[A+12>>2],i[n+16>>2]=i[A+16>>2],i[n+20>>2]=i[A+20>>2],i[n+24>>2]=i[A+24>>2],i[n+28>>2]=i[A+28>>2];break}while(0);return function(e,t){t=+t;var n,r,i,o,s,A,l,c=0,u=0;c=(o=+a[(i=16+(e|=0)|0)>>3])-(r=+a[(n=e+24|0)>>3]),c=o<r?c+6.283185307179586:c,u=+a[e>>3],c=.5*(c*t-c),u+=t=.5*((l=u-(A=+a[(s=e+8|0)>>3]))*t-l),a[e>>3]=u>1.5707963267948966?1.5707963267948966:u,t=A-t,a[s>>3]=t<-1.5707963267948966?-1.5707963267948966:t,t=(t=o+c)>3.141592653589793?t+-6.283185307179586:t,a[i>>3]=t<-3.141592653589793?t+6.283185307179586:t,t=(t=r-c)>3.141592653589793?t+-6.283185307179586:t,a[n>>3]=t<-3.141592653589793?t+6.283185307179586:t}(n,r?1.4:1.1),(0|i[(r=26160+(l<<3)|0)>>2])==(0|e)&&(0|i[r+4>>2])==(0|t)&&(a[n>>3]=1.5707963267948966),(0|i[(l=26288+(l<<3)|0)>>2])==(0|e)&&(0|i[l+4>>2])==(0|t)&&(a[n+8>>3]=-1.5707963267948966),1.5707963267948966!=+a[n>>3]&&-1.5707963267948966!=+a[n+8>>3]?(N=o,0|(l=0)):(a[n+16>>3]=3.141592653589793,a[n+24>>3]=-3.141592653589793,N=o,0|(l=0))}function tt(e,t,n,a){e|=0,t|=0,n|=0,a|=0;var o,s,A,l=0,c=0,u=0,f=0;A=N,N=N+48|0,o=A+40|0,s=A,_e(c=A+32|0,0,0,0),u=0|i[c>>2],c=0|i[c+4>>2];do{if(n>>>0<=15){if(0|(l=0|ot(a))){i[(a=s)>>2]=0,i[a+4>>2]=0,i[s+8>>2]=l,i[s+12>>2]=-1,u=s+29|0,i[(a=s+16|0)>>2]=0,i[a+4>>2]=0,i[a+8>>2]=0,r[a+12|0]=0,r[u|0]=0|r[o|0],r[u+1|0]=0|r[o+1|0],r[u+2|0]=0|r[o+2|0];break}if(l=0|Ct(1+(0|i[t+8>>2])|0,32)){st(t,l),i[(f=s)>>2]=u,i[f+4>>2]=c,i[s+8>>2]=0,i[s+12>>2]=n,i[s+16>>2]=a,i[s+20>>2]=t,i[s+24>>2]=l,r[s+28|0]=0,r[(u=s+29|0)|0]=0|r[o|0],r[u+1|0]=0|r[o+1|0],r[u+2|0]=0|r[o+2|0];break}i[(a=s)>>2]=0,i[a+4>>2]=0,i[s+8>>2]=13,i[s+12>>2]=-1,u=s+29|0,i[(a=s+16|0)>>2]=0,i[a+4>>2]=0,i[a+8>>2]=0,r[a+12|0]=0,r[u|0]=0|r[o|0],r[u+1|0]=0|r[o+1|0],r[u+2|0]=0|r[o+2|0];break}i[(u=s)>>2]=0,i[u+4>>2]=0,i[s+8>>2]=4,i[s+12>>2]=-1,f=s+29|0,i[(u=s+16|0)>>2]=0,i[u+4>>2]=0,i[u+8>>2]=0,r[u+12|0]=0,r[f|0]=0|r[o|0],r[f+1|0]=0|r[o+1|0],r[f+2|0]=0|r[o+2|0]}while(0);nt(s),i[e>>2]=i[s>>2],i[e+4>>2]=i[s+4>>2],i[e+8>>2]=i[s+8>>2],i[e+12>>2]=i[s+12>>2],i[e+16>>2]=i[s+16>>2],i[e+20>>2]=i[s+20>>2],i[e+24>>2]=i[s+24>>2],i[e+28>>2]=i[s+28>>2],N=A}function nt(e){var t,n,a,o,s=0,A=0,l=0,c=0,u=0,f=0,d=0,h=0,p=0,m=0,g=0,b=0,v=0,y=0,x=0,_=0;if(o=N,N=N+336|0,t=o+168|0,n=o,!(0|(A=0|i[(l=e|=0)>>2]))&!(0|(l=0|i[l+4>>2])))N=o;else{if(0|r[(s=e+28|0)|0]?(A=0|rt(A,l),l=0|S()):r[s|0]=1,!(0|i[i[(a=e+20|0)>>2]>>2]))return 0|(A=0|i[(s=e+24|0)>>2])&&Et(A),i[(_=e)>>2]=0,i[_+4>>2]=0,i[e+8>>2]=0,i[a>>2]=0,i[e+12>>2]=-1,i[e+16>>2]=0,i[s>>2]=0,void(N=o);c=15&(s=0|i[(_=e+16|0)>>2]);e:do{if(!(0|A)&!(0|l))x=e+24|0;else{v=e+12|0,g=3==(0|c),m=255&s,h=3==(1|c),b=e+24|0,p=(c+-1|0)>>>0<3,f=3==(2|c),d=n+8|0;t:for(;;){if(u=0|Vt(0|A,0|l,52),S(),(0|(u&=15))==(0|i[v>>2])){switch(15&m){case 0:case 2:case 3:if(0|(c=0|De(A,l,t))){y=15;break t}if(0|At(0|i[a>>2],0|i[b>>2],t)){y=19;break t}}if(h&&(c=0|i[4+(0|i[a>>2])>>2],i[t>>2]=i[c>>2],i[t+4>>2]=i[c+4>>2],i[t+8>>2]=i[c+8>>2],i[t+12>>2]=i[c+12>>2],0|X(26896,t))){if(0|Be(0|i[4+(0|i[a>>2])>>2],u,n)){y=25;break}if((0|i[(c=n)>>2])==(0|A)&&(0|i[c+4>>2])==(0|l)){y=29;break}}if(p){if(0|(c=0|Ue(A,l,t))){y=32;break}if(0|et(A,l,n,0)){y=36;break}if(f&&0|lt(0|i[a>>2],0|i[b>>2],t,n)){y=42;break}if(h&&0|ut(0|i[a>>2],0|i[b>>2],t,n)){y=42;break}}if(g){if(s=0|et(A,l,t,1),c=0|i[b>>2],0|s){y=45;break}if(0|Z(c,t)){if(te(n,t),0|ee(t,0|i[b>>2])){y=53;break}if(0|At(0|i[a>>2],0|i[b>>2],d)){y=53;break}if(0|ut(0|i[a>>2],0|i[b>>2],n,t)){y=53;break}}}}do{if((0|u)<(0|i[v>>2])){if(s=0|et(A,l,t,1),c=0|i[b>>2],0|s){y=58;break t}if(!(0|Z(c,t))){y=73;break}if(0|ee(0|i[b>>2],t)&&(te(n,t),0|lt(0|i[a>>2],0|i[b>>2],n,t))){y=65;break t}if(0|(A=0|Ee(A,l,u+1|0,n))){y=67;break t}A=0|i[(l=n)>>2],l=0|i[l+4>>2]}else y=73}while(0);if(73==(0|y)&&(y=0,A=0|rt(A,l),l=0|S()),!(0|A)&!(0|l)){x=b;break e}}switch(0|y){case 15:0|(s=0|i[b>>2])&&Et(s),i[(y=e)>>2]=0,i[y+4>>2]=0,i[a>>2]=0,i[v>>2]=-1,i[_>>2]=0,i[b>>2]=0,i[e+8>>2]=c,y=20;break;case 19:i[e>>2]=A,i[e+4>>2]=l,y=20;break;case 25:M(27634,27600,470,27611);break;case 29:case 42:return i[e>>2]=A,i[e+4>>2]=l,void(N=o);case 32:return 0|(s=0|i[b>>2])&&Et(s),i[(x=e)>>2]=0,i[x+4>>2]=0,i[a>>2]=0,i[v>>2]=-1,i[_>>2]=0,i[b>>2]=0,i[e+8>>2]=c,void(N=o);case 36:M(27634,27600,493,27611);break;case 45:0|c&&Et(c),i[(y=e)>>2]=0,i[y+4>>2]=0,i[a>>2]=0,i[v>>2]=-1,i[_>>2]=0,i[b>>2]=0,i[e+8>>2]=s,y=55;break;case 53:i[e>>2]=A,i[e+4>>2]=l,y=55;break;case 58:0|c&&Et(c),i[(y=e)>>2]=0,i[y+4>>2]=0,i[a>>2]=0,i[v>>2]=-1,i[_>>2]=0,i[b>>2]=0,i[e+8>>2]=s,y=71;break;case 65:i[e>>2]=A,i[e+4>>2]=l,y=71;break;case 67:return 0|(s=0|i[b>>2])&&Et(s),i[(x=e)>>2]=0,i[x+4>>2]=0,i[a>>2]=0,i[v>>2]=-1,i[_>>2]=0,i[b>>2]=0,i[e+8>>2]=A,void(N=o)}if(20==(0|y))return void(N=o);if(55==(0|y))return void(N=o);if(71==(0|y))return void(N=o)}}while(0);0|(s=0|i[x>>2])&&Et(s),i[(y=e)>>2]=0,i[y+4>>2]=0,i[e+8>>2]=0,i[a>>2]=0,i[e+12>>2]=-1,i[_>>2]=0,i[x>>2]=0,N=o}}function rt(e,t){var n,r=0,a=0,o=0,s=0,A=0,l=0,c=0,u=0,f=0;n=N,N=N+16|0,f=n,a=0|Vt(0|(e|=0),0|(t|=0),52),S(),a&=15,r=0|Vt(0|e,0|t,45),S();do{if(a){for(;r=0|jt(a+4095|0,0,52),o=S()|-15728641&t,r=r|e|(A=0|jt(7,0,0|(s=3*(15-a|0)|0))),o|=l=0|S(),c=0|Vt(0|e,0|t,0|s),S(),a=a+-1|0,!((c&=7)>>>0<6);){if(!a){u=4;break}t=o,e=r}if(4==(0|u)){r=0|Vt(0|r,0|o,45),S();break}return f=0|jt(((f=!(0|c)&!!(0|Se(r,o)))?2:1)+c|0,0,0|s),u=0|S()|t&~l,f|=e&~A,T(0|u),N=n,0|f}}while(0);return(r&=127)>>>0>120?(f=0,T(0|(u=0)),N=n,0|f):(_e(f,0,r+1|0,0),u=0|i[f+4>>2],f=0|i[f>>2],T(0|u),N=n,0|f)}function it(e,t,n){e|=0;var r,o=0,s=0,A=0,l=0,c=0,u=0,f=0,d=0,h=0;if(!(0|X(t|=0,n|=0)))return 0|(h=0);if(t=0|function(e){return+a[16+(e|=0)>>3]<+a[e+24>>3]|0}(t),o=+a[n>>3],s=t&(s=+a[n+8>>3])<0?s+6.283185307179586:s,(0|(h=0|i[e>>2]))<=0)return 0|(h=0);if(r=0|i[e+4>>2],t){t=0,d=s,n=-1,e=0;e:for(;;){for(f=e;l=+a[r+(f<<4)>>3],s=+a[r+(f<<4)+8>>3],A=+a[r+((e=(n+2|0)%(0|h)|0)<<4)>>3],c=+a[r+(e<<4)+8>>3],l>A?(u=l,l=c):(u=A,A=l,l=s,s=c),(o=o==A|o==u?o+2220446049250313e-31:o)<A|o>u;){if((0|(n=f+1|0))>=(0|h)){n=22;break e}e=f,f=n,n=e}if(((u=(c=l<0?l+6.283185307179586:l)+(o-A)/(u-A)*((l=s<0?s+6.283185307179586:s)-c))<0?u+6.283185307179586:u)>(d=c==d|l==d?d+-2220446049250313e-31:d)&&(t^=1),(0|(e=f+1|0))>=(0|h)){n=22;break}n=f}if(22==(0|n))return 0|t}else{t=0,d=s,n=-1,e=0;e:for(;;){for(f=e;l=+a[r+(f<<4)>>3],s=+a[r+(f<<4)+8>>3],A=+a[r+((e=(n+2|0)%(0|h)|0)<<4)>>3],c=+a[r+(e<<4)+8>>3],l>A?(u=l,l=c):(u=A,A=l,l=s,s=c),(o=o==A|o==u?o+2220446049250313e-31:o)<A|o>u;){if((0|(n=f+1|0))>=(0|h)){n=22;break e}e=f,f=n,n=e}if(l+(o-A)/(u-A)*(s-l)>(d=l==d|s==d?d+-2220446049250313e-31:d)&&(t^=1),(0|(e=f+1|0))>=(0|h)){n=22;break}n=f}if(22==(0|n))return 0|t}return 0}function at(e,t){t|=0;var n,r,o,s,A,c=0,u=0,f=0,d=0,h=0,p=0,m=0,g=0,b=0,v=0,y=0,x=0;if(!(r=0|i[(e|=0)>>2]))return i[t>>2]=0,i[t+4>>2]=0,i[t+8>>2]=0,i[t+12>>2]=0,i[t+16>>2]=0,i[t+20>>2]=0,i[t+24>>2]=0,void(i[t+28>>2]=0);if(a[(o=t+8|0)>>3]=17976931348623157e292,a[(s=t+24|0)>>3]=17976931348623157e292,a[t>>3]=-17976931348623157e292,a[(A=t+16|0)>>3]=-17976931348623157e292,!((0|r)<=0)){for(n=0|i[e+4>>2],g=17976931348623157e292,b=-17976931348623157e292,v=0,e=-1,d=17976931348623157e292,h=17976931348623157e292,m=-17976931348623157e292,u=-17976931348623157e292,y=0;c=+a[n+(y<<4)>>3],p=+a[n+(y<<4)+8>>3],f=+a[n+(((0|(e=e+2|0))==(0|r)?0:e)<<4)+8>>3],c<d&&(a[o>>3]=c,d=c),p<h&&(a[s>>3]=p,h=p),c>m?a[t>>3]=c:c=m,p>u&&(a[A>>3]=p,u=p),g=p>0&p<g?p:g,b=p<0&p>b?p:b,v|=+l(+(p-f))>3.141592653589793,(0|(e=y+1|0))!=(0|r);)x=y,m=c,y=e,e=x;v&&(a[A>>3]=b,a[s>>3]=g)}}function ot(e){return 0|((e|=0)>>>0<4?0:15)}function st(e,t){t|=0;var n,r=0,o=0,s=0,A=0,c=0,u=0,f=0,d=0,h=0,p=0,m=0,g=0,b=0,v=0,y=0,x=0,_=0,w=0,T=0,S=0,M=0;if(b=0|i[(e|=0)>>2]){if(a[(v=t+8|0)>>3]=17976931348623157e292,a[(y=t+24|0)>>3]=17976931348623157e292,a[t>>3]=-17976931348623157e292,a[(x=t+16|0)>>3]=-17976931348623157e292,(0|b)>0){for(s=0|i[e+4>>2],m=17976931348623157e292,g=-17976931348623157e292,o=0,r=-1,f=17976931348623157e292,d=17976931348623157e292,p=-17976931348623157e292,c=-17976931348623157e292,_=0;A=+a[s+(_<<4)>>3],h=+a[s+(_<<4)+8>>3],u=+a[s+(((0|(S=r+2|0))==(0|b)?0:S)<<4)+8>>3],A<f&&(a[v>>3]=A,f=A),h<d&&(a[y>>3]=h,d=h),A>p?a[t>>3]=A:A=p,h>c&&(a[x>>3]=h,c=h),m=h>0&h<m?h:m,g=h<0&h>g?h:g,o|=+l(+(h-u))>3.141592653589793,(0|(r=_+1|0))!=(0|b);)S=_,p=A,_=r,r=S;o&&(a[x>>3]=g,a[y>>3]=m)}}else i[t>>2]=0,i[t+4>>2]=0,i[t+8>>2]=0,i[t+12>>2]=0,i[t+16>>2]=0,i[t+20>>2]=0,i[t+24>>2]=0,i[t+28>>2]=0;if(!((0|(r=0|i[(S=e+8|0)>>2]))<=0)){n=e+12|0,T=0;do{if(s=0|i[n>>2],o=T,y=t+((T=T+1|0)<<5)|0,x=0|i[s+(o<<3)>>2]){if(a[(_=t+(T<<5)+8|0)>>3]=17976931348623157e292,a[(e=t+(T<<5)+24|0)>>3]=17976931348623157e292,a[y>>3]=-17976931348623157e292,a[(w=t+(T<<5)+16|0)>>3]=-17976931348623157e292,(0|x)>0){for(b=0|i[s+(o<<3)+4>>2],m=17976931348623157e292,g=-17976931348623157e292,s=0,o=-1,v=0,f=17976931348623157e292,d=17976931348623157e292,h=-17976931348623157e292,c=-17976931348623157e292;A=+a[b+(v<<4)>>3],p=+a[b+(v<<4)+8>>3],u=+a[b+(((0|(o=o+2|0))==(0|x)?0:o)<<4)+8>>3],A<f&&(a[_>>3]=A,f=A),p<d&&(a[e>>3]=p,d=p),A>h?a[y>>3]=A:A=h,p>c&&(a[w>>3]=p,c=p),m=p>0&p<m?p:m,g=p<0&p>g?p:g,s|=+l(+(p-u))>3.141592653589793,(0|(o=v+1|0))!=(0|x);)M=v,v=o,h=A,o=M;s&&(a[w>>3]=g,a[e>>3]=m)}}else i[y>>2]=0,i[y+4>>2]=0,i[y+8>>2]=0,i[y+12>>2]=0,i[y+16>>2]=0,i[y+20>>2]=0,i[y+24>>2]=0,i[y+28>>2]=0,r=0|i[S>>2]}while((0|T)<(0|r))}}function At(e,t,n){var r=0,a=0,o=0;if(!(0|it(e|=0,t|=0,n|=0)))return 0|(a=0);if((0|i[(a=e+8|0)>>2])<=0)return 0|(a=1);for(r=e+12|0,e=0;;){if(o=e,e=e+1|0,0|it((0|i[r>>2])+(o<<3)|0,t+(e<<5)|0,n)){e=0,r=6;break}if((0|e)>=(0|i[a>>2])){e=1,r=6;break}}return 6==(0|r)?0|e:0}function lt(e,t,n,r){r|=0;var a,o,s=0,A=0,l=0,c=0,u=0;if(o=N,N=N+16|0,a=o,!(0|it(e|=0,t|=0,l=(n|=0)+8|0)))return N=o,0|(c=0);c=e+8|0;e:do{if((0|i[c>>2])>0){for(A=e+12|0,s=0;;){if(u=s,s=s+1|0,0|it((0|i[A>>2])+(u<<3)|0,t+(s<<5)|0,l)){s=0;break}if((0|s)>=(0|i[c>>2]))break e}return N=o,0|s}}while(0);if(0|ct(e,t,n,r))return N=o,0|(u=0);i[a>>2]=i[n>>2],i[a+4>>2]=l,s=0|i[c>>2];e:do{if((0|s)>0)for(e=e+12|0,l=0,A=s;;){if(s=0|i[e>>2],(0|i[s+(l<<3)>>2])>0){if(0|it(a,r,0|i[s+(l<<3)+4>>2])){s=0;break e}if(s=l+1|0,0|ct((0|i[e>>2])+(l<<3)|0,t+(s<<5)|0,n,r)){s=0;break e}A=0|i[c>>2]}else s=l+1|0;if(!((0|s)<(0|A))){s=1;break}l=s}else s=1}while(0);return N=o,0|(u=s)}function ct(e,t,n,r){e|=0,n|=0;var o,s,A,l,c,u,f=0,d=0,h=0,p=0,m=0,g=0,b=0,v=0,y=0,x=0,_=0,w=0,T=0,S=0,M=0;if(u=N,N=N+176|0,l=u+172|0,f=u+168|0,c=u,!(0|Z(t|=0,r|=0)))return N=u,0|(e=0);if(function(e,t,n,r){var o,s,A,l,c;t|=0,n|=0,r|=0,e=(s=+a[16+(e|=0)>>3])<(c=+a[e+24>>3]),o=(l=+a[t+16>>3])<(A=+a[t+24>>3]),t=c-l<A-s,i[n>>2]=e?o|t?1:2:0,i[r>>2]=o?e?1:t?2:1:0}(t,r,l,f),Qt(0|c,0|n,168),(0|i[n>>2])>0){t=0;do{_=+qe(+a[(S=c+8+(t<<4)+8|0)>>3],0|i[f>>2]),a[S>>3]=_,t=t+1|0}while((0|t)<(0|i[n>>2]))}s=+a[r>>3],A=+a[r+8>>3],_=+qe(+a[r+16>>3],0|i[f>>2]),o=+qe(+a[r+24>>3],0|i[f>>2]);e:do{if((0|i[e>>2])>0){if(r=e+4|0,(0|(f=0|i[c>>2]))<=0)for(t=0;;)if((0|(t=t+1|0))>=(0|i[e>>2])){t=0;break e}for(n=0;;){if(t=0|i[r>>2],y=+a[t+(n<<4)>>3],x=+qe(+a[t+(n<<4)+8>>3],0|i[l>>2]),t=0|i[r>>2],S=(0|(n=n+1|0))%(0|i[e>>2])|0,d=+a[t+(S<<4)>>3],h=+qe(+a[t+(S<<4)+8>>3],0|i[l>>2]),!(y>=s)|!(d>=s)&&!(y<=A)|!(d<=A)&&!(x<=o)|!(h<=o)&&!(x>=_)|!(h>=_)){v=d-y,g=h-x,t=0;do{if(M=t,S=(0|(t=t+1|0))==(0|f)?0:t,d=+a[c+8+(M<<4)+8>>3],h=+a[c+8+(S<<4)+8>>3]-d,p=+a[c+8+(M<<4)>>3],!(0==(b=v*h-g*(m=+a[c+8+(S<<4)>>3]-p))||(w=x-d,T=y-p,m=(w*m-h*T)/b,m<0|m>1))&&(b=(v*w-g*T)/b)>=0&b<=1){t=1;break e}}while((0|t)<(0|f))}if((0|n)>=(0|i[e>>2])){t=0;break}}}else t=0}while(0);return N=u,0|(M=t)}function ut(e,t,n,r){var a=0,o=0,s=0;if(0|ct(e|=0,t|=0,n|=0,r|=0))return 0|(o=1);if((0|i[(o=e+8|0)>>2])<=0)return 0|(o=0);for(a=e+12|0,e=0;;){if(s=e,e=e+1|0,0|ct((0|i[a>>2])+(s<<3)|0,t+(e<<5)|0,n,r)){e=1,a=6;break}if((0|e)>=(0|i[o>>2])){e=0,a=6;break}}return 6==(0|a)?0|e:0}function ft(e,t,n,r,i){t|=0,n|=0,r|=0,i|=0;var o,s,A,l,c,u,f,d=0;l=+a[(e|=0)>>3],A=+a[t>>3]-l,s=+a[e+8>>3],o=+a[t+8>>3]-s,u=+a[n>>3],d=((d=+a[r>>3]-u)*(s-(f=+a[n+8>>3]))-(l-u)*(c=+a[r+8>>3]-f))/(A*c-o*d),a[i>>3]=l+A*d,a[i+8>>3]=s+o*d}function dt(e,t){return t|=0,+l(+(+a[(e|=0)>>3]-+a[t>>3]))<1.1920928955078125e-7?0|(t=+l(+(+a[e+8>>3]-+a[t+8>>3]))<1.1920928955078125e-7):0|(t=0)}function ht(e,t,n){n|=0;var r,a,o,s,A=0,l=0,c=0,u=0;if(s=N,N=N+32|0,u=s,0|(A=0|Fe(e|=0,t|=0,a=s+16|0)))return N=s,0|(n=A);r=0|ye(e,t),o=0|Ce(e,t),function(e,t){e=7696+(28*(e|=0)|0)|0,i[(t|=0)>>2]=i[e>>2],i[t+4>>2]=i[e+4>>2],i[t+8>>2]=i[e+8>>2],i[t+12>>2]=i[e+12>>2]}(r,u),A=0|function(e,t){e|=0;var n=0,r=0;if((t|=0)>>>0>20)return-1;do{if((0|i[11120+(216*t|0)>>2])!=(0|e))if((0|i[11120+(216*t|0)+8>>2])!=(0|e))if((0|i[11120+(216*t|0)+16>>2])!=(0|e))if((0|i[11120+(216*t|0)+24>>2])!=(0|e))if((0|i[11120+(216*t|0)+32>>2])!=(0|e))if((0|i[11120+(216*t|0)+40>>2])!=(0|e))if((0|i[11120+(216*t|0)+48>>2])!=(0|e))if((0|i[11120+(216*t|0)+56>>2])!=(0|e))if((0|i[11120+(216*t|0)+64>>2])!=(0|e))if((0|i[11120+(216*t|0)+72>>2])!=(0|e))if((0|i[11120+(216*t|0)+80>>2])!=(0|e))if((0|i[11120+(216*t|0)+88>>2])!=(0|e))if((0|i[11120+(216*t|0)+96>>2])!=(0|e))if((0|i[11120+(216*t|0)+104>>2])!=(0|e))if((0|i[11120+(216*t|0)+112>>2])!=(0|e))if((0|i[11120+(216*t|0)+120>>2])!=(0|e))if((0|i[11120+(216*t|0)+128>>2])!=(0|e)){if((0|i[11120+(216*t|0)+136>>2])!=(0|e)){if((0|i[11120+(216*t|0)+144>>2])==(0|e)){e=0,n=2,r=0;break}if((0|i[11120+(216*t|0)+152>>2])==(0|e)){e=0,n=2,r=1;break}if((0|i[11120+(216*t|0)+160>>2])==(0|e)){e=0,n=2,r=2;break}if((0|i[11120+(216*t|0)+168>>2])==(0|e)){e=1,n=2,r=0;break}if((0|i[11120+(216*t|0)+176>>2])==(0|e)){e=1,n=2,r=1;break}if((0|i[11120+(216*t|0)+184>>2])==(0|e)){e=1,n=2,r=2;break}if((0|i[11120+(216*t|0)+192>>2])==(0|e)){e=2,n=2,r=0;break}if((0|i[11120+(216*t|0)+200>>2])==(0|e)){e=2,n=2,r=1;break}if((0|i[11120+(216*t|0)+208>>2])==(0|e)){e=2,n=2,r=2;break}return-1}e=2,n=1,r=2}else e=2,n=1,r=1;else e=2,n=1,r=0;else e=1,n=1,r=2;else e=1,n=1,r=1;else e=1,n=1,r=0;else e=0,n=1,r=2;else e=0,n=1,r=1;else e=0,n=1,r=0;else e=2,n=0,r=2;else e=2,n=0,r=1;else e=2,n=0,r=0;else e=1,n=0,r=2;else e=1,n=0,r=1;else e=1,n=0,r=0;else e=0,n=0,r=2;else e=0,n=0,r=1;else e=0,n=0,r=0}while(0);return 0|i[11120+(216*t|0)+(72*n|0)+(24*e|0)+(r<<3)+4>>2]}(r,0|i[a>>2]);do{if(0|G(r)){switch(0|r){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(27634,27636,75,27645)}if(c=0|i[26480+(24*l|0)+8>>2],t=0|i[26480+(24*l|0)+16>>2],(0|(e=0|i[a>>2]))!=(0|i[u>>2])&&(u=0|H(r))|(0|(e=0|i[a>>2]))==(0|t)&&(A=(A+1|0)%6|0),3==(0|o)&(0|e)==(0|t)){A=(A+5|0)%6|0;break}5==(0|o)&(0|e)==(0|c)&&(A=(A+1|0)%6|0)}}while(0);return i[n>>2]=A,N=s,0|(n=0)}function pt(e,t,n,r){n|=0,r|=0;var a,o,s,A,l,c=0,u=0,f=0,d=0,h=0,p=0,m=0,g=0,b=0,v=0,y=0;if(l=N,N=N+32|0,y=l+24|0,A=l+20|0,s=l+8|0,o=l+16|0,a=l,h=(h=!(0|Se(e|=0,t|=0)))?6:5,m=0|Vt(0|e,0|t,52),S(),h>>>0<=n>>>0)return N=l,0|(r=2);!(g=!(0|(m&=15)))&&!((b=0|jt(7,0,3*(15^m)|0))&e|0)&!((0|S())&t)?c=n:u=4;e:do{if(4==(0|u)){if((0|((c=!!(0|Se(e,t)))?4:5))<(0|n))return N=l,0|(r=1);if(0|ht(e,t,y))return N=l,0|(r=1);if(u=(0|i[y>>2])+n|0,7==(0|(b=0|i[(c=c?26768+((0|u)%5<<2)|0:26800+((0|u)%6<<2)|0)>>2])))return N=l,0|(r=1);i[A>>2]=0,c=0|F(e,t,b,A,s);do{if(!c){if(p=0|i[(d=s)>>2],u=(f=(d=0|i[d+4>>2])>>>0<t>>>0|(0|d)==(0|t)&p>>>0<e>>>0)?p:e,f=f?d:t,!g&&!(p&(g=0|jt(7,0,3*(15^m)|0))|0)&!(d&(0|S())))c=n;else{if(d=(n+-1+h|0)%(0|h)|0,c=0|Se(e,t),(0|d)<0&&M(27634,27636,248,27661),(0|((h=!!(0|c))?4:5))<(0|d)&&M(27634,27636,248,27661),0|ht(e,t,y)&&M(27634,27636,248,27661),c=(0|i[y>>2])+d|0,7==(0|(d=0|i[(c=h?26768+((0|c)%5<<2)|0:26800+((0|c)%6<<2)|0)>>2]))&&M(27634,27636,248,27661),i[o>>2]=0,0|(c=0|F(e,t,d,o,a)))break;h=0|i[(p=a)>>2],p=0|i[p+4>>2];do{if(p>>>0<f>>>0|(0|p)==(0|f)&h>>>0<u>>>0){if(u=0|Se(h,p)?0|V(h,p,e,t):0|i[26864+(((0|i[o>>2])+(0|i[26832+(d<<2)>>2])|0)%6<<2)>>2],c=0|Se(h,p),(u+-1|0)>>>0>5){c=-1,u=h,f=p;break}if(1==(0|u)&(c=!!(0|c))){c=-1,u=h,f=p;break}do{if(!(0|ht(h,p,y))){if(c){c=(5+(0|i[26416+(u<<2)>>2])-(0|i[y>>2])|0)%5|0;break}c=(6+(0|i[26448+(u<<2)>>2])-(0|i[y>>2])|0)%6|0;break}c=-1}while(0);u=h,f=p}else c=n}while(0);p=0|i[(d=s)>>2],d=0|i[d+4>>2]}if((0|u)==(0|p)&(0|f)==(0|d)){if(e=(h=!!(0|Se(p,d)))?0|V(p,d,e,t):0|i[26864+(((0|i[A>>2])+(0|i[26832+(b<<2)>>2])|0)%6<<2)>>2],c=0|Se(p,d),(e+-1|0)>>>0<=5&&!(1==(0|e)&(v=!!(0|c))))do{if(!(0|ht(p,d,y))){if(v){c=(5+(0|i[26416+(e<<2)>>2])-(0|i[y>>2])|0)%5|0;break}c=(6+(0|i[26448+(e<<2)>>2])-(0|i[y>>2])|0)%6|0;break}c=-1}while(0);else c=-1;c=6==(0|(c=c+1|0))|h&5==(0|c)?0:c}t=f,e=u;break e}}while(0);return N=l,0|(r=c)}}while(0);return v=0|jt(0|c,0,56),y=S()|-2130706433&t|536870912,i[r>>2]=v|e,i[r+4>>2]=y,N=l,0|(r=0)}function mt(e,t){e|=0;var n,r,a=0,o=0;return r=N,N=N+16|0,n=r,!0&536870912==(2013265920&(t|=0))&&0|xe(e,a=-2130706433&t|134217728)?(o=0|Vt(0|e,0|t,56),S(),a=(o=!(0|pt(e,a,7&o,n)))&((0|i[(a=n)>>2])==(0|e)?(0|i[a+4>>2])==(0|t):0)&1,N=r,0|a):(N=r,0|(a=0))}function gt(e,t,n,r){e|=0,r|=0;var a,o,s,A=0,l=0,c=0,u=0,f=0,d=0;s=N,N=N+208|0,a=s,o=s+192|0,c=0|v(n|=0,t|=0),i[(u=o)>>2]=1,i[u+4>>2]=0;e:do{if(0|c){for(u=0-n|0,i[a+4>>2]=n,i[a>>2]=n,A=2,t=n,l=n;t=t+n+l|0,i[a+(A<<2)>>2]=t,t>>>0<c>>>0;)d=l,A=A+1|0,l=t,t=d;if((l=e+c+u|0)>>>0>e>>>0){c=l,A=1,t=1;do{do{if(3&~t){if((0|i[a+((t=A+-1|0)<<2)>>2])>>>0<(c-e|0)>>>0?bt(e,n,r,A,a):yt(e,n,r,o,A,0,a),1==(0|A)){xt(o,1),A=0;break}xt(o,t),A=1;break}bt(e,n,r,A,a),vt(o,2),A=A+2|0}while(0);t=1|i[o>>2],i[o>>2]=t,e=e+n|0}while(e>>>0<l>>>0)}else A=1,t=1;for(yt(e,n,r,o,A,0,a),l=o+4|0;;){if(1==(0|A)&1==(0|t)){if(!(0|i[l>>2]))break e;f=19}else(0|A)<2?f=19:(xt(o,2),d=A+-2|0,i[o>>2]=7^i[o>>2],vt(o,1),yt(e+(0-(0|i[a+(d<<2)>>2]))+u|0,n,r,o,A+-1|0,1,a),xt(o,1),t=1|i[o>>2],i[o>>2]=t,yt(e=e+u|0,n,r,o,d,1,a),A=d);19==(0|f)&&(f=0,vt(o,t=0|_t(o)),e=e+u|0,A=t+A|0,t=0|i[o>>2])}}}while(0);N=s}function bt(e,t,n,r,a){e|=0,t|=0,n|=0,r|=0,a|=0;var o,s,A=0,l=0,c=0,u=0,f=0;s=N,N=N+240|0,i[(o=s)>>2]=e;e:do{if((0|r)>1)for(f=0-t|0,c=e,A=r,r=1,l=e;;){if(e=(c=c+f|0)+(0-(0|i[a+((u=A+-2|0)<<2)>>2]))|0,(0|Yt[3&n](l,e))>-1&&(0|Yt[3&n](l,c))>-1)break e;if(l=o+(r<<2)|0,(0|Yt[3&n](e,c))>-1?(i[l>>2]=e,A=A+-1|0):(i[l>>2]=c,e=c,A=u),r=r+1|0,(0|A)<=1)break e;c=e,l=0|i[o>>2]}else r=1}while(0);Tt(t,o,r),N=s}function vt(e,t){var n,r=0,a=0;n=(e|=0)+4|0,(t|=0)>>>0>31?(a=0|i[n>>2],i[e>>2]=a,i[n>>2]=0,t=t+-32|0,r=0):(r=0|i[n>>2],a=0|i[e>>2]),i[e>>2]=r<<32-t|a>>>t,i[n>>2]=r>>>t}function yt(e,t,n,r,a,o,s){e|=0,t|=0,n|=0,a|=0,o|=0,s|=0;var A,l,c,u,f=0,d=0,h=0,p=0;u=N,N=N+240|0,l=u+232|0,c=u,p=0|i[(r|=0)>>2],i[l>>2]=p,d=0|i[r+4>>2],i[(A=l+4|0)>>2]=d,i[c>>2]=e;e:do{if(1!=(0|p)|!!(0|d)&&(h=0-t|0,f=e+(0-(0|i[s+(a<<2)>>2]))|0,(0|Yt[3&n](f,e))>=1))for(r=1,o=!(0|o),d=f;;){if(o&(0|a)>1){if(o=e+h|0,f=0|i[s+(a+-2<<2)>>2],(0|Yt[3&n](o,d))>-1){f=10;break e}if((0|Yt[3&n](o+(0-f)|0,d))>-1){f=10;break e}}if(o=r+1|0,i[c+(r<<2)>>2]=d,vt(l,p=0|_t(l)),a=p+a|0,!(1!=(0|i[l>>2])|!!(0|i[A>>2]))){r=o,e=d,f=10;break e}if(e=d+(0-(0|i[s+(a<<2)>>2]))|0,(0|Yt[3&n](e,0|i[c>>2]))<1){e=d,r=o,o=0,f=9;break}p=d,r=o,o=1,d=e,e=p}else r=1,f=9}while(0);9!=(0|f)||0|o||(f=10),10==(0|f)&&(Tt(t,c,r),bt(e,t,n,a,s)),N=u}function xt(e,t){var n,r=0,a=0;n=(e|=0)+4|0,(t|=0)>>>0>31?(a=0|i[e>>2],i[n>>2]=a,i[e>>2]=0,t=t+-32|0,r=0):(r=0|i[e>>2],a=0|i[n>>2]),i[n>>2]=r>>>(32-t|0)|a<<t,i[e>>2]=r<<t}function _t(e){var t=0;return(t=0|wt((0|i[(e|=0)>>2])-1|0))?0|t:0|(0|(t=0|wt(0|i[e+4>>2]))?t+32:0)}function wt(e){var t=0;if(e|=0)if(1&e)e=0;else for(t=e,e=0;e=e+1|0,!(2&t);)t>>>=1;else e=32;return 0|e}function Tt(e,t,n){e|=0,t|=0,n|=0;var r,a=0,o=0,s=0,A=0;r=N,N=N+256|0,a=r;e:do{if((0|n)>=2&&(s=t+(n<<2)|0,i[s>>2]=a,0|e))for(;;){o=e>>>0<256?e:256,Qt(0|a,0|i[t>>2],0|o),a=0;do{A=t+(a<<2)|0,a=a+1|0,Qt(0|i[A>>2],0|i[t+(a<<2)>>2],0|o),i[A>>2]=(0|i[A>>2])+o}while((0|a)!=(0|n));if(!(e=e-o|0))break e;a=0|i[s>>2]}}while(0);N=r}function St(e){return 0|+$t(+(e=+e))}function Mt(e){e|=0;var t,n=0,r=0,a=0,o=0,s=0,A=0,l=0,c=0,u=0,f=0,d=0,h=0,p=0,m=0,g=0,b=0,v=0,y=0,x=0,_=0;t=N,N=N+16|0,h=t;do{if(e>>>0<245){if(e=(u=e>>>0<11?16:e+11&-8)>>>3,3&(r=(d=0|i[6921])>>>e))return a=0|i[(r=(e=27724+((n=(1&r^1)+e|0)<<1<<2)|0)+8|0)>>2],(0|(s=0|i[(o=a+8|0)>>2]))==(0|e)?i[6921]=d&~(1<<n):(i[s+12>>2]=e,i[r>>2]=s),_=n<<3,i[a+4>>2]=3|_,i[(_=a+_+4|0)>>2]=1|i[_>>2],N=t,0|(_=o);if(u>>>0>(f=0|i[6923])>>>0){if(0|r)return n=((n=r<<e&((n=2<<e)|0-n))&0-n)-1|0,s=0|i[(e=(n=27724+((a=((r=(n>>>=l=n>>>12&16)>>>5&8)|l|(s=(n>>>=r)>>>2&4)|(e=(n>>>=s)>>>1&2)|(a=(n>>>=e)>>>1&1))+(n>>>a)|0)<<1<<2)|0)+8|0)>>2],(0|(r=0|i[(l=s+8|0)>>2]))==(0|n)?(e=d&~(1<<a),i[6921]=e):(i[r+12>>2]=n,i[e>>2]=r,e=d),A=(_=a<<3)-u|0,i[s+4>>2]=3|u,i[(o=s+u|0)+4>>2]=1|A,i[s+_>>2]=A,0|f&&(a=0|i[6926],r=27724+((n=f>>>3)<<1<<2)|0,e&(n=1<<n)?n=0|i[(e=r+8|0)>>2]:(i[6921]=e|n,n=r,e=r+8|0),i[e>>2]=a,i[n+12>>2]=a,i[a+8>>2]=n,i[a+12>>2]=r),i[6923]=A,i[6926]=o,N=t,0|(_=l);if(s=0|i[6922]){for(r=(s&0-s)-1|0,r=c=0|i[27988+(((a=(r>>>=o=r>>>12&16)>>>5&8)|o|(A=(r>>>=a)>>>2&4)|(l=(r>>>=A)>>>1&2)|(c=(r>>>=l)>>>1&1))+(r>>>c)<<2)>>2],l=c,c=(-8&i[c+4>>2])-u|0;(e=0|i[r+16>>2])||(e=0|i[r+20>>2]);)r=e,l=(o=(A=(-8&i[e+4>>2])-u|0)>>>0<c>>>0)?e:l,c=o?A:c;if((A=l+u|0)>>>0>l>>>0){o=0|i[l+24>>2],n=0|i[l+12>>2];do{if((0|n)==(0|l)){if(!(n=0|i[(e=l+20|0)>>2])&&!(n=0|i[(e=l+16|0)>>2])){r=0;break}for(;;)if(r=0|i[(a=n+20|0)>>2])n=r,e=a;else{if(!(r=0|i[(a=n+16|0)>>2]))break;n=r,e=a}i[e>>2]=0,r=n}else r=0|i[l+8>>2],i[r+12>>2]=n,i[n+8>>2]=r,r=n}while(0);do{if(0|o){if(n=0|i[l+28>>2],(0|l)==(0|i[(e=27988+(n<<2)|0)>>2])){if(i[e>>2]=r,!r){i[6922]=s&~(1<<n);break}}else if(i[((0|i[(_=o+16|0)>>2])==(0|l)?_:o+20)>>2]=r,!r)break;i[r+24>>2]=o,0|(n=0|i[l+16>>2])&&(i[r+16>>2]=n,i[n+24>>2]=r),0|(n=0|i[l+20>>2])&&(i[r+20>>2]=n,i[n+24>>2]=r)}}while(0);return c>>>0<16?(_=c+u|0,i[l+4>>2]=3|_,i[(_=l+_+4|0)>>2]=1|i[_>>2]):(i[l+4>>2]=3|u,i[A+4>>2]=1|c,i[A+c>>2]=c,0|f&&(a=0|i[6926],r=27724+((n=f>>>3)<<1<<2)|0,(n=1<<n)&d?n=0|i[(e=r+8|0)>>2]:(i[6921]=n|d,n=r,e=r+8|0),i[e>>2]=a,i[n+12>>2]=a,i[a+8>>2]=n,i[a+12>>2]=r),i[6923]=c,i[6926]=A),N=t,0|(_=l+8|0)}d=u}else d=u}else d=u}else if(e>>>0<=4294967231)if(u=-8&(e=e+11|0),a=0|i[6922]){o=0-u|0,c=(e>>>=8)?u>>>0>16777215?31:u>>>((c=14-((l=((g=e<<(d=(e+1048320|0)>>>16&8))+520192|0)>>>16&4)|d|(c=((g<<=l)+245760|0)>>>16&2))+(g<<c>>>15)|0)+7|0)&1|c<<1:0,r=0|i[27988+(c<<2)>>2];e:do{if(r)for(e=0,l=u<<(31==(0|c)?0:25-(c>>>1)|0),s=0;;){if((A=(-8&i[r+4>>2])-u|0)>>>0<o>>>0){if(!A){e=r,o=0,g=65;break e}e=r,o=A}if(s=!(0|(g=0|i[r+20>>2]))|(0|g)==(0|(r=0|i[r+16+(l>>>31<<2)>>2]))?s:g,!r){r=s,g=61;break}l<<=1}else r=0,e=0,g=61}while(0);if(61==(0|g)){if(!(0|r)&!(0|e)){if(!(e=((e=2<<c)|0-e)&a)){d=u;break}d=(e&0-e)-1|0,e=0,r=0|i[27988+(((s=(d>>>=A=d>>>12&16)>>>5&8)|A|(l=(d>>>=s)>>>2&4)|(c=(d>>>=l)>>>1&2)|(r=(d>>>=c)>>>1&1))+(d>>>r)<<2)>>2]}r?g=65:(l=e,A=o)}if(65==(0|g))for(s=r;;){if(o=(r=(d=(-8&i[s+4>>2])-u|0)>>>0<o>>>0)?d:o,e=r?s:e,(r=0|i[s+16>>2])||(r=0|i[s+20>>2]),!r){l=e,A=o;break}s=r}if(0|l&&A>>>0<((0|i[6923])-u|0)>>>0&&(f=l+u|0)>>>0>l>>>0){s=0|i[l+24>>2],n=0|i[l+12>>2];do{if((0|n)==(0|l)){if(!(n=0|i[(e=l+20|0)>>2])&&!(n=0|i[(e=l+16|0)>>2])){n=0;break}for(;;)if(r=0|i[(o=n+20|0)>>2])n=r,e=o;else{if(!(r=0|i[(o=n+16|0)>>2]))break;n=r,e=o}i[e>>2]=0}else _=0|i[l+8>>2],i[_+12>>2]=n,i[n+8>>2]=_}while(0);do{if(s){if(e=0|i[l+28>>2],(0|l)==(0|i[(r=27988+(e<<2)|0)>>2])){if(i[r>>2]=n,!n){a&=~(1<<e),i[6922]=a;break}}else if(i[((0|i[(_=s+16|0)>>2])==(0|l)?_:s+20)>>2]=n,!n)break;i[n+24>>2]=s,0|(e=0|i[l+16>>2])&&(i[n+16>>2]=e,i[e+24>>2]=n),(e=0|i[l+20>>2])&&(i[n+20>>2]=e,i[e+24>>2]=n)}}while(0);e:do{if(A>>>0<16)_=A+u|0,i[l+4>>2]=3|_,i[(_=l+_+4|0)>>2]=1|i[_>>2];else{if(i[l+4>>2]=3|u,i[f+4>>2]=1|A,i[f+A>>2]=A,n=A>>>3,A>>>0<256){r=27724+(n<<1<<2)|0,(e=0|i[6921])&(n=1<<n)?n=0|i[(e=r+8|0)>>2]:(i[6921]=e|n,n=r,e=r+8|0),i[e>>2]=f,i[n+12>>2]=f,i[f+8>>2]=n,i[f+12>>2]=r;break}if(n=27988+((r=(n=A>>>8)?A>>>0>16777215?31:A>>>((r=14-((y=((_=n<<(x=(n+1048320|0)>>>16&8))+520192|0)>>>16&4)|x|(r=((_<<=y)+245760|0)>>>16&2))+(_<<r>>>15)|0)+7|0)&1|r<<1:0)<<2)|0,i[f+28>>2]=r,i[(e=f+16|0)+4>>2]=0,i[e>>2]=0,!(a&(e=1<<r))){i[6922]=a|e,i[n>>2]=f,i[f+24>>2]=n,i[f+12>>2]=f,i[f+8>>2]=f;break}n=0|i[n>>2];t:do{if((-8&i[n+4>>2])!=(0|A)){for(a=A<<(31==(0|r)?0:25-(r>>>1)|0);e=0|i[(r=n+16+(a>>>31<<2)|0)>>2];){if((-8&i[e+4>>2])==(0|A)){n=e;break t}a<<=1,n=e}i[r>>2]=f,i[f+24>>2]=n,i[f+12>>2]=f,i[f+8>>2]=f;break e}}while(0);_=0|i[(x=n+8|0)>>2],i[_+12>>2]=f,i[x>>2]=f,i[f+8>>2]=_,i[f+12>>2]=n,i[f+24>>2]=0}}while(0);return N=t,0|(_=l+8|0)}d=u}else d=u;else d=-1}while(0);if((r=0|i[6923])>>>0>=d>>>0)return n=r-d|0,e=0|i[6926],n>>>0>15?(_=e+d|0,i[6926]=_,i[6923]=n,i[_+4>>2]=1|n,i[e+r>>2]=n,i[e+4>>2]=3|d):(i[6923]=0,i[6926]=0,i[e+4>>2]=3|r,i[(_=e+r+4|0)>>2]=1|i[_>>2]),N=t,0|(_=e+8|0);if((A=0|i[6924])>>>0>d>>>0)return y=A-d|0,i[6924]=y,x=(_=0|i[6927])+d|0,i[6927]=x,i[x+4>>2]=1|y,i[_+4>>2]=3|d,N=t,0|(_=_+8|0);if(0|i[7039]?e=0|i[7041]:(i[7041]=4096,i[7040]=4096,i[7042]=-1,i[7043]=-1,i[7044]=0,i[7032]=0,i[7039]=-16&h^1431655768,e=4096),l=d+48|0,(u=(s=e+(c=d+47|0)|0)&(o=0-e|0))>>>0<=d>>>0)return N=t,0|(_=0);if(0|(e=0|i[7031])&&(h=(f=0|i[7029])+u|0)>>>0<=f>>>0|h>>>0>e>>>0)return N=t,0|(_=0);e:do{if(4&i[7032])n=0,g=143;else{r=0|i[6927];t:do{if(r){for(a=28132;!((h=0|i[a>>2])>>>0<=r>>>0&&(h+(0|i[a+4>>2])|0)>>>0>r>>>0);){if(!(e=0|i[a+8>>2])){g=128;break t}a=e}if((n=s-A&o)>>>0<2147483647)if((0|(e=0|Jt(0|n)))==((0|i[a>>2])+(0|i[a+4>>2])|0)){if(-1!=(0|e)){A=n,s=e,g=145;break e}}else a=e,g=136;else n=0}else g=128}while(0);do{if(128==(0|g))if(-1!=(0|(r=0|Jt(0)))&&(n=r,m=(n=((m=(p=0|i[7040])+-1|0)&n|0?(m+n&0-p)-n|0:0)+u|0)+(p=0|i[7029])|0,n>>>0>d>>>0&n>>>0<2147483647)){if(0|(h=0|i[7031])&&m>>>0<=p>>>0|m>>>0>h>>>0){n=0;break}if((0|(e=0|Jt(0|n)))==(0|r)){A=n,s=r,g=145;break e}a=e,g=136}else n=0}while(0);do{if(136==(0|g)){if(r=0-n|0,!(l>>>0>n>>>0&n>>>0<2147483647&-1!=(0|a))){if(-1==(0|a)){n=0;break}A=n,s=a,g=145;break e}if((e=c-n+(e=0|i[7041])&0-e)>>>0>=2147483647){A=n,s=a,g=145;break e}if(-1==(0|Jt(0|e))){Jt(0|r),n=0;break}A=e+n|0,s=a,g=145;break e}}while(0);i[7032]=4|i[7032],g=143}}while(0);if(143==(0|g)&&u>>>0<2147483647&&!(-1==(0|(y=0|Jt(0|u)))|1^(v=(b=(m=0|Jt(0))-y|0)>>>0>(d+40|0)>>>0)|y>>>0<m>>>0&-1!=(0|y)&-1!=(0|m)^1)&&(A=v?b:n,s=y,g=145),145==(0|g)){n=(0|i[7029])+A|0,i[7029]=n,n>>>0>(0|i[7030])>>>0&&(i[7030]=n),c=0|i[6927];e:do{if(c){for(n=28132;;){if((0|s)==((e=0|i[n>>2])+(r=0|i[n+4>>2])|0)){g=154;break}if(!(a=0|i[n+8>>2]))break;n=a}if(!(154!=(0|g)||(x=n+4|0,8&i[n+12>>2]))&&s>>>0>c>>>0&e>>>0<=c>>>0){i[x>>2]=r+A,x=c+(y=7&(y=c+8|0)?0-y&7:0)|0,y=(_=(0|i[6924])+A|0)-y|0,i[6927]=x,i[6924]=y,i[x+4>>2]=1|y,i[c+_+4>>2]=40,i[6928]=i[7043];break}for(s>>>0<(0|i[6925])>>>0&&(i[6925]=s),r=s+A|0,n=28132;;){if((0|i[n>>2])==(0|r)){g=162;break}if(!(e=0|i[n+8>>2]))break;n=e}if(162==(0|g)&&!(8&i[n+12>>2])){i[n>>2]=s,i[(f=n+4|0)>>2]=(0|i[f>>2])+A,u=(f=s+(7&(f=s+8|0)?0-f&7:0)|0)+d|0,l=(n=r+(7&(n=r+8|0)?0-n&7:0)|0)-f-d|0,i[f+4>>2]=3|d;t:do{if((0|c)==(0|n))_=(0|i[6924])+l|0,i[6924]=_,i[6927]=u,i[u+4>>2]=1|_;else{if((0|i[6926])==(0|n)){_=(0|i[6923])+l|0,i[6923]=_,i[6926]=u,i[u+4>>2]=1|_,i[u+_>>2]=_;break}if(1==(3&(e=0|i[n+4>>2]))){A=-8&e,a=e>>>3;n:do{if(e>>>0<256){if(e=0|i[n+8>>2],(0|(r=0|i[n+12>>2]))==(0|e)){i[6921]=i[6921]&~(1<<a);break}i[e+12>>2]=r,i[r+8>>2]=e;break}s=0|i[n+24>>2],e=0|i[n+12>>2];do{if((0|e)==(0|n)){if(e=0|i[(a=(r=n+16|0)+4|0)>>2])r=a;else if(!(e=0|i[r>>2])){e=0;break}for(;;)if(a=0|i[(o=e+20|0)>>2])e=a,r=o;else{if(!(a=0|i[(o=e+16|0)>>2]))break;e=a,r=o}i[r>>2]=0}else _=0|i[n+8>>2],i[_+12>>2]=e,i[e+8>>2]=_}while(0);if(!s)break;a=27988+((r=0|i[n+28>>2])<<2)|0;do{if((0|i[a>>2])==(0|n)){if(i[a>>2]=e,0|e)break;i[6922]=i[6922]&~(1<<r);break n}if(i[((0|i[(_=s+16|0)>>2])==(0|n)?_:s+20)>>2]=e,!e)break n}while(0);if(i[e+24>>2]=s,0|(a=0|i[(r=n+16|0)>>2])&&(i[e+16>>2]=a,i[a+24>>2]=e),!(r=0|i[r+4>>2]))break;i[e+20>>2]=r,i[r+24>>2]=e}while(0);n=n+A|0,o=A+l|0}else o=l;if(i[(n=n+4|0)>>2]=-2&i[n>>2],i[u+4>>2]=1|o,i[u+o>>2]=o,n=o>>>3,o>>>0<256){r=27724+(n<<1<<2)|0,(e=0|i[6921])&(n=1<<n)?n=0|i[(e=r+8|0)>>2]:(i[6921]=e|n,n=r,e=r+8|0),i[e>>2]=u,i[n+12>>2]=u,i[u+8>>2]=n,i[u+12>>2]=r;break}n=o>>>8;do{if(n){if(o>>>0>16777215){a=31;break}a=o>>>((a=14-((y=((_=n<<(x=(n+1048320|0)>>>16&8))+520192|0)>>>16&4)|x|(a=((_<<=y)+245760|0)>>>16&2))+(_<<a>>>15)|0)+7|0)&1|a<<1}else a=0}while(0);if(n=27988+(a<<2)|0,i[u+28>>2]=a,i[(e=u+16|0)+4>>2]=0,i[e>>2]=0,!((e=0|i[6922])&(r=1<<a))){i[6922]=e|r,i[n>>2]=u,i[u+24>>2]=n,i[u+12>>2]=u,i[u+8>>2]=u;break}n=0|i[n>>2];n:do{if((-8&i[n+4>>2])!=(0|o)){for(a=o<<(31==(0|a)?0:25-(a>>>1)|0);e=0|i[(r=n+16+(a>>>31<<2)|0)>>2];){if((-8&i[e+4>>2])==(0|o)){n=e;break n}a<<=1,n=e}i[r>>2]=u,i[u+24>>2]=n,i[u+12>>2]=u,i[u+8>>2]=u;break t}}while(0);_=0|i[(x=n+8|0)>>2],i[_+12>>2]=u,i[x>>2]=u,i[u+8>>2]=_,i[u+12>>2]=n,i[u+24>>2]=0}}while(0);return N=t,0|(_=f+8|0)}for(n=28132;!((e=0|i[n>>2])>>>0<=c>>>0&&(_=e+(0|i[n+4>>2])|0)>>>0>c>>>0);)n=0|i[n+8>>2];n=(e=(e=(o=_+-47|0)+(7&(e=o+8|0)?0-e&7:0)|0)>>>0<(o=c+16|0)>>>0?c:e)+8|0,x=s+(y=7&(y=s+8|0)?0-y&7:0)|0,y=(r=A+-40|0)-y|0,i[6927]=x,i[6924]=y,i[x+4>>2]=1|y,i[s+r+4>>2]=40,i[6928]=i[7043],i[(r=e+4|0)>>2]=27,i[n>>2]=i[7033],i[n+4>>2]=i[7034],i[n+8>>2]=i[7035],i[n+12>>2]=i[7036],i[7033]=s,i[7034]=A,i[7036]=0,i[7035]=n,n=e+24|0;do{x=n,i[(n=n+4|0)>>2]=7}while((x+8|0)>>>0<_>>>0);if((0|e)!=(0|c)){if(s=e-c|0,i[r>>2]=-2&i[r>>2],i[c+4>>2]=1|s,i[e>>2]=s,n=s>>>3,s>>>0<256){r=27724+(n<<1<<2)|0,(e=0|i[6921])&(n=1<<n)?n=0|i[(e=r+8|0)>>2]:(i[6921]=e|n,n=r,e=r+8|0),i[e>>2]=c,i[n+12>>2]=c,i[c+8>>2]=n,i[c+12>>2]=r;break}if(r=27988+((a=(n=s>>>8)?s>>>0>16777215?31:s>>>((a=14-((y=((_=n<<(x=(n+1048320|0)>>>16&8))+520192|0)>>>16&4)|x|(a=((_<<=y)+245760|0)>>>16&2))+(_<<a>>>15)|0)+7|0)&1|a<<1:0)<<2)|0,i[c+28>>2]=a,i[c+20>>2]=0,i[o>>2]=0,!((n=0|i[6922])&(e=1<<a))){i[6922]=n|e,i[r>>2]=c,i[c+24>>2]=r,i[c+12>>2]=c,i[c+8>>2]=c;break}n=0|i[r>>2];t:do{if((-8&i[n+4>>2])!=(0|s)){for(a=s<<(31==(0|a)?0:25-(a>>>1)|0);e=0|i[(r=n+16+(a>>>31<<2)|0)>>2];){if((-8&i[e+4>>2])==(0|s)){n=e;break t}a<<=1,n=e}i[r>>2]=c,i[c+24>>2]=n,i[c+12>>2]=c,i[c+8>>2]=c;break e}}while(0);_=0|i[(x=n+8|0)>>2],i[_+12>>2]=c,i[x>>2]=c,i[c+8>>2]=_,i[c+12>>2]=n,i[c+24>>2]=0}}else!(0|(_=0|i[6925]))|s>>>0<_>>>0&&(i[6925]=s),i[7033]=s,i[7034]=A,i[7036]=0,i[6930]=i[7039],i[6929]=-1,i[6934]=27724,i[6933]=27724,i[6936]=27732,i[6935]=27732,i[6938]=27740,i[6937]=27740,i[6940]=27748,i[6939]=27748,i[6942]=27756,i[6941]=27756,i[6944]=27764,i[6943]=27764,i[6946]=27772,i[6945]=27772,i[6948]=27780,i[6947]=27780,i[6950]=27788,i[6949]=27788,i[6952]=27796,i[6951]=27796,i[6954]=27804,i[6953]=27804,i[6956]=27812,i[6955]=27812,i[6958]=27820,i[6957]=27820,i[6960]=27828,i[6959]=27828,i[6962]=27836,i[6961]=27836,i[6964]=27844,i[6963]=27844,i[6966]=27852,i[6965]=27852,i[6968]=27860,i[6967]=27860,i[6970]=27868,i[6969]=27868,i[6972]=27876,i[6971]=27876,i[6974]=27884,i[6973]=27884,i[6976]=27892,i[6975]=27892,i[6978]=27900,i[6977]=27900,i[6980]=27908,i[6979]=27908,i[6982]=27916,i[6981]=27916,i[6984]=27924,i[6983]=27924,i[6986]=27932,i[6985]=27932,i[6988]=27940,i[6987]=27940,i[6990]=27948,i[6989]=27948,i[6992]=27956,i[6991]=27956,i[6994]=27964,i[6993]=27964,i[6996]=27972,i[6995]=27972,x=s+(y=7&(y=s+8|0)?0-y&7:0)|0,y=(_=A+-40|0)-y|0,i[6927]=x,i[6924]=y,i[x+4>>2]=1|y,i[s+_+4>>2]=40,i[6928]=i[7043]}while(0);if((n=0|i[6924])>>>0>d>>>0)return y=n-d|0,i[6924]=y,x=(_=0|i[6927])+d|0,i[6927]=x,i[x+4>>2]=1|y,i[_+4>>2]=3|d,N=t,0|(_=_+8|0)}return i[(_=27680)>>2]=12,N=t,0|(_=0)}function Et(e){var t=0,n=0,r=0,a=0,o=0,s=0,A=0,l=0;if(e|=0){n=e+-8|0,a=0|i[6925],l=n+(t=-8&(e=0|i[e+-4>>2]))|0;do{if(1&e)A=n,s=n;else{if(r=0|i[n>>2],!(3&e))return;if(o=r+t|0,(s=n+(0-r)|0)>>>0<a>>>0)return;if((0|i[6926])==(0|s)){if(3&~(t=0|i[(e=l+4|0)>>2])){A=s,t=o;break}return i[6923]=o,i[e>>2]=-2&t,i[s+4>>2]=1|o,void(i[s+o>>2]=o)}if(n=r>>>3,r>>>0<256){if(e=0|i[s+8>>2],(0|(t=0|i[s+12>>2]))==(0|e)){i[6921]=i[6921]&~(1<<n),A=s,t=o;break}i[e+12>>2]=t,i[t+8>>2]=e,A=s,t=o;break}a=0|i[s+24>>2],e=0|i[s+12>>2];do{if((0|e)==(0|s)){if(e=0|i[(n=(t=s+16|0)+4|0)>>2])t=n;else if(!(e=0|i[t>>2])){e=0;break}for(;;)if(n=0|i[(r=e+20|0)>>2])e=n,t=r;else{if(!(n=0|i[(r=e+16|0)>>2]))break;e=n,t=r}i[t>>2]=0}else A=0|i[s+8>>2],i[A+12>>2]=e,i[e+8>>2]=A}while(0);if(a){if(t=0|i[s+28>>2],(0|i[(n=27988+(t<<2)|0)>>2])==(0|s)){if(i[n>>2]=e,!e){i[6922]=i[6922]&~(1<<t),A=s,t=o;break}}else if(i[((0|i[(A=a+16|0)>>2])==(0|s)?A:a+20)>>2]=e,!e){A=s,t=o;break}i[e+24>>2]=a,0|(n=0|i[(t=s+16|0)>>2])&&(i[e+16>>2]=n,i[n+24>>2]=e),(t=0|i[t+4>>2])?(i[e+20>>2]=t,i[t+24>>2]=e,A=s,t=o):(A=s,t=o)}else A=s,t=o}}while(0);if(!(s>>>0>=l>>>0)&&1&(r=0|i[(e=l+4|0)>>2])){if(2&r)i[e>>2]=-2&r,i[A+4>>2]=1|t,i[s+t>>2]=t,a=t;else{if((0|i[6927])==(0|l)){if(l=(0|i[6924])+t|0,i[6924]=l,i[6927]=A,i[A+4>>2]=1|l,(0|A)!=(0|i[6926]))return;return i[6926]=0,void(i[6923]=0)}if((0|i[6926])==(0|l))return l=(0|i[6923])+t|0,i[6923]=l,i[6926]=s,i[A+4>>2]=1|l,void(i[s+l>>2]=l);a=(-8&r)+t|0,n=r>>>3;do{if(r>>>0<256){if(t=0|i[l+8>>2],(0|(e=0|i[l+12>>2]))==(0|t)){i[6921]=i[6921]&~(1<<n);break}i[t+12>>2]=e,i[e+8>>2]=t;break}o=0|i[l+24>>2],e=0|i[l+12>>2];do{if((0|e)==(0|l)){if(e=0|i[(n=(t=l+16|0)+4|0)>>2])t=n;else if(!(e=0|i[t>>2])){n=0;break}for(;;)if(n=0|i[(r=e+20|0)>>2])e=n,t=r;else{if(!(n=0|i[(r=e+16|0)>>2]))break;e=n,t=r}i[t>>2]=0,n=e}else n=0|i[l+8>>2],i[n+12>>2]=e,i[e+8>>2]=n,n=e}while(0);if(0|o){if(e=0|i[l+28>>2],(0|i[(t=27988+(e<<2)|0)>>2])==(0|l)){if(i[t>>2]=n,!n){i[6922]=i[6922]&~(1<<e);break}}else if(i[((0|i[(r=o+16|0)>>2])==(0|l)?r:o+20)>>2]=n,!n)break;i[n+24>>2]=o,0|(t=0|i[(e=l+16|0)>>2])&&(i[n+16>>2]=t,i[t+24>>2]=n),0|(e=0|i[e+4>>2])&&(i[n+20>>2]=e,i[e+24>>2]=n)}}while(0);if(i[A+4>>2]=1|a,i[s+a>>2]=a,(0|A)==(0|i[6926]))return void(i[6923]=a)}if(e=a>>>3,a>>>0<256)return n=27724+(e<<1<<2)|0,(t=0|i[6921])&(e=1<<e)?e=0|i[(t=n+8|0)>>2]:(i[6921]=t|e,e=n,t=n+8|0),i[t>>2]=A,i[e+12>>2]=A,i[A+8>>2]=e,void(i[A+12>>2]=n);e=27988+((r=(e=a>>>8)?a>>>0>16777215?31:a>>>((r=14-((o=((l=e<<(s=(e+1048320|0)>>>16&8))+520192|0)>>>16&4)|s|(r=((l<<=o)+245760|0)>>>16&2))+(l<<r>>>15)|0)+7|0)&1|r<<1:0)<<2)|0,i[A+28>>2]=r,i[A+20>>2]=0,i[A+16>>2]=0,t=0|i[6922],n=1<<r;e:do{if(t&n){e=0|i[e>>2];t:do{if((-8&i[e+4>>2])!=(0|a)){for(r=a<<(31==(0|r)?0:25-(r>>>1)|0);t=0|i[(n=e+16+(r>>>31<<2)|0)>>2];){if((-8&i[t+4>>2])==(0|a)){e=t;break t}r<<=1,e=t}i[n>>2]=A,i[A+24>>2]=e,i[A+12>>2]=A,i[A+8>>2]=A;break e}}while(0);l=0|i[(s=e+8|0)>>2],i[l+12>>2]=A,i[s>>2]=A,i[A+8>>2]=l,i[A+12>>2]=e,i[A+24>>2]=0}else i[6922]=t|n,i[e>>2]=A,i[A+24>>2]=e,i[A+12>>2]=A,i[A+8>>2]=A}while(0);if(l=(0|i[6929])-1|0,i[6929]=l,!(0|l)){for(e=28140;e=0|i[e>>2];)e=e+8|0;i[6929]=-1}}}}function Ct(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|Mt(n))&&3&i[e+-4>>2]?(Wt(0|e,0,0|n),0|e):0|e}function It(e,t){t|=0;var n=0,r=0;return(e|=0)?t>>>0>4294967231?(i[(t=27680)>>2]=12,0|(t=0)):(n=0|function(e,t){e|=0,t|=0;var n=0,r=0,a=0,o=0,s=0,A=0,l=0,c=0,u=0,f=0;if(u=e+4|0,f=0|i[u>>2],n=-8&f,A=e+n|0,!(3&f))return t>>>0<256?0|(e=0):n>>>0>=(t+4|0)>>>0&&(n-t|0)>>>0<=i[7041]<<1>>>0?0|e:0|(e=0);if(n>>>0>=t>>>0)return(n=n-t|0)>>>0<=15||(c=e+t|0,i[u>>2]=1&f|t|2,i[c+4>>2]=3|n,i[(f=A+4|0)>>2]=1|i[f>>2],Rt(c,n)),0|e;if((0|i[6927])==(0|A))return n=(c=(0|i[6924])+n|0)-t|0,r=e+t|0,c>>>0<=t>>>0?0|(e=0):(i[u>>2]=1&f|t|2,i[r+4>>2]=1|n,i[6927]=r,i[6924]=n,0|e);if((0|i[6926])==(0|A))return(r=(0|i[6923])+n|0)>>>0<t>>>0?0|(e=0):((n=r-t|0)>>>0>15?(c=e+t|0,r=e+r|0,i[u>>2]=1&f|t|2,i[c+4>>2]=1|n,i[r>>2]=n,i[(r=r+4|0)>>2]=-2&i[r>>2],r=c):(i[u>>2]=1&f|r|2,i[(r=e+r+4|0)>>2]=1|i[r>>2],r=0,n=0),i[6923]=n,i[6926]=r,0|e);if(r=0|i[A+4>>2],2&r)return 0|(e=0);if(l=(-8&r)+n|0,l>>>0<t>>>0)return 0|(e=0);c=l-t|0,a=r>>>3;do{if(r>>>0<256){if(r=0|i[A+8>>2],(0|(n=0|i[A+12>>2]))==(0|r)){i[6921]=i[6921]&~(1<<a);break}i[r+12>>2]=n,i[n+8>>2]=r;break}s=0|i[A+24>>2],n=0|i[A+12>>2];do{if((0|n)==(0|A)){if(n=0|i[(a=(r=A+16|0)+4|0)>>2])r=a;else if(!(n=0|i[r>>2])){a=0;break}for(;;)if(a=0|i[(o=n+20|0)>>2])n=a,r=o;else{if(!(a=0|i[(o=n+16|0)>>2]))break;n=a,r=o}i[r>>2]=0,a=n}else a=0|i[A+8>>2],i[a+12>>2]=n,i[n+8>>2]=a,a=n}while(0);if(0|s){if(n=0|i[A+28>>2],(0|i[(r=27988+(n<<2)|0)>>2])==(0|A)){if(i[r>>2]=a,!a){i[6922]=i[6922]&~(1<<n);break}}else if(i[((0|i[(o=s+16|0)>>2])==(0|A)?o:s+20)>>2]=a,!a)break;i[a+24>>2]=s,0|(r=0|i[(n=A+16|0)>>2])&&(i[a+16>>2]=r,i[r+24>>2]=a),0|(n=0|i[n+4>>2])&&(i[a+20>>2]=n,i[n+24>>2]=a)}}while(0);return c>>>0<16?(i[u>>2]=1&f|l|2,i[(f=e+l+4|0)>>2]=1|i[f>>2],0|e):(A=e+t|0,i[u>>2]=1&f|t|2,i[A+4>>2]=3|c,i[(f=e+l+4|0)>>2]=1|i[f>>2],Rt(A,c),0|e)}(e+-8|0,t>>>0<11?16:t+11&-8),0|n?0|(t=n+8|0):(n=0|Mt(t))?(Qt(0|n,0|e,0|((r=(-8&(r=0|i[e+-4>>2]))-(3&r?4:8)|0)>>>0<t>>>0?r:t)),Et(e),0|(t=n)):0|(t=0)):0|(t=0|Mt(t))}function Rt(e,t){var n=0,r=0,a=0,o=0,s=0,A=0;A=(e|=0)+(t|=0)|0,n=0|i[e+4>>2];do{if(1&n)s=e;else{if(a=0|i[e>>2],!(3&n))return;if(s=e+(0-a)|0,t=a+t|0,(0|i[6926])==(0|s)){if(3&~(n=0|i[(e=A+4|0)>>2]))break;return i[6923]=t,i[e>>2]=-2&n,i[s+4>>2]=1|t,void(i[A>>2]=t)}if(r=a>>>3,a>>>0<256){if(e=0|i[s+8>>2],(0|(n=0|i[s+12>>2]))==(0|e)){i[6921]=i[6921]&~(1<<r);break}i[e+12>>2]=n,i[n+8>>2]=e;break}o=0|i[s+24>>2],e=0|i[s+12>>2];do{if((0|e)==(0|s)){if(e=0|i[(r=(n=s+16|0)+4|0)>>2])n=r;else if(!(e=0|i[n>>2])){e=0;break}for(;;)if(r=0|i[(a=e+20|0)>>2])e=r,n=a;else{if(!(r=0|i[(a=e+16|0)>>2]))break;e=r,n=a}i[n>>2]=0}else a=0|i[s+8>>2],i[a+12>>2]=e,i[e+8>>2]=a}while(0);if(o){if(n=0|i[s+28>>2],(0|i[(r=27988+(n<<2)|0)>>2])==(0|s)){if(i[r>>2]=e,!e){i[6922]=i[6922]&~(1<<n);break}}else if(i[((0|i[(a=o+16|0)>>2])==(0|s)?a:o+20)>>2]=e,!e)break;i[e+24>>2]=o,0|(r=0|i[(n=s+16|0)>>2])&&(i[e+16>>2]=r,i[r+24>>2]=e),(n=0|i[n+4>>2])&&(i[e+20>>2]=n,i[n+24>>2]=e)}}}while(0);if(2&(r=0|i[(e=A+4|0)>>2]))i[e>>2]=-2&r,i[s+4>>2]=1|t,i[s+t>>2]=t,a=t;else{if((0|i[6927])==(0|A)){if(A=(0|i[6924])+t|0,i[6924]=A,i[6927]=s,i[s+4>>2]=1|A,(0|s)!=(0|i[6926]))return;return i[6926]=0,void(i[6923]=0)}if((0|i[6926])==(0|A))return A=(0|i[6923])+t|0,i[6923]=A,i[6926]=s,i[s+4>>2]=1|A,void(i[s+A>>2]=A);a=(-8&r)+t|0,n=r>>>3;do{if(r>>>0<256){if(e=0|i[A+8>>2],(0|(t=0|i[A+12>>2]))==(0|e)){i[6921]=i[6921]&~(1<<n);break}i[e+12>>2]=t,i[t+8>>2]=e;break}o=0|i[A+24>>2],t=0|i[A+12>>2];do{if((0|t)==(0|A)){if(t=0|i[(n=(e=A+16|0)+4|0)>>2])e=n;else if(!(t=0|i[e>>2])){n=0;break}for(;;)if(n=0|i[(r=t+20|0)>>2])t=n,e=r;else{if(!(n=0|i[(r=t+16|0)>>2]))break;t=n,e=r}i[e>>2]=0,n=t}else n=0|i[A+8>>2],i[n+12>>2]=t,i[t+8>>2]=n,n=t}while(0);if(0|o){if(t=0|i[A+28>>2],(0|i[(e=27988+(t<<2)|0)>>2])==(0|A)){if(i[e>>2]=n,!n){i[6922]=i[6922]&~(1<<t);break}}else if(i[((0|i[(r=o+16|0)>>2])==(0|A)?r:o+20)>>2]=n,!n)break;i[n+24>>2]=o,0|(e=0|i[(t=A+16|0)>>2])&&(i[n+16>>2]=e,i[e+24>>2]=n),0|(t=0|i[t+4>>2])&&(i[n+20>>2]=t,i[t+24>>2]=n)}}while(0);if(i[s+4>>2]=1|a,i[s+a>>2]=a,(0|s)==(0|i[6926]))return void(i[6923]=a)}if(t=a>>>3,a>>>0<256)return n=27724+(t<<1<<2)|0,(e=0|i[6921])&(t=1<<t)?t=0|i[(e=n+8|0)>>2]:(i[6921]=e|t,t=n,e=n+8|0),i[e>>2]=s,i[t+12>>2]=s,i[s+8>>2]=t,void(i[s+12>>2]=n);if(t=27988+((r=(t=a>>>8)?a>>>0>16777215?31:a>>>((r=14-((n=((A=t<<(o=(t+1048320|0)>>>16&8))+520192|0)>>>16&4)|o|(r=((A<<=n)+245760|0)>>>16&2))+(A<<r>>>15)|0)+7|0)&1|r<<1:0)<<2)|0,i[s+28>>2]=r,i[s+20>>2]=0,i[s+16>>2]=0,!((e=0|i[6922])&(n=1<<r)))return i[6922]=e|n,i[t>>2]=s,i[s+24>>2]=t,i[s+12>>2]=s,void(i[s+8>>2]=s);t=0|i[t>>2];e:do{if((-8&i[t+4>>2])!=(0|a)){for(r=a<<(31==(0|r)?0:25-(r>>>1)|0);e=0|i[(n=t+16+(r>>>31<<2)|0)>>2];){if((-8&i[e+4>>2])==(0|a)){t=e;break e}r<<=1,t=e}return i[n>>2]=s,i[s+24>>2]=t,i[s+12>>2]=s,void(i[s+8>>2]=s)}}while(0);A=0|i[(o=t+8|0)>>2],i[A+12>>2]=s,i[o>>2]=s,i[s+8>>2]=A,i[s+12>>2]=t,i[s+24>>2]=0}function Pt(e,t,n,r){return 0|(T((t|=0)+(r|=0)+((n=(e|=0)+(n|=0)>>>0)>>>0<e>>>0|0)>>>0|0),n)}function Nt(e,t,n,r){return 0|(T(0|(r=(t|=0)-(r|=0)-((n|=0)>>>0>(e|=0)>>>0|0)>>>0)),e-n>>>0)}function kt(e){return 0|((e|=0)?31-(0|_(e^e-1)):32)}function Lt(e,t,n,r,a){a|=0;var o=0,s=0,A=0,l=0,c=0,u=0,f=0,d=0,h=0,p=0;if(u=e|=0,s=n|=0,A=d=r|=0,!(c=l=t|=0))return o=!!(0|a),A?o?(i[a>>2]=0|e,i[a+4>>2]=0&t,a=0,0|(T(0|(d=0)),a)):(a=0,0|(T(0|(d=0)),a)):(o&&(i[a>>2]=(u>>>0)%(s>>>0),i[a+4>>2]=0),a=(u>>>0)/(s>>>0)>>>0,0|(T(0|(d=0)),a));o=!(0|A);do{if(s){if(!o){if((o=(0|_(0|A))-(0|_(0|c))|0)>>>0<=31){s=f=o+1|0,e=u>>>(f>>>0)&(t=o-31>>31)|c<<(A=31-o|0),t&=c>>>(f>>>0),o=0,A=u<<A;break}return a?(i[a>>2]=0|e,i[a+4>>2]=l|0&t,a=0,0|(T(0|(d=0)),a)):(a=0,0|(T(0|(d=0)),a))}if((o=s-1|0)&s|0){s=A=33+(0|_(0|s))-(0|_(0|c))|0,e=(f=32-A|0)-1>>31&c>>>((h=A-32|0)>>>0)|(c<<f|u>>>(A>>>0))&(t=h>>31),t&=c>>>(A>>>0),o=u<<(p=64-A|0)&(l=f>>31),A=(c<<p|u>>>(h>>>0))&l|u<<f&A-33>>31;break}return 0|a&&(i[a>>2]=o&u,i[a+4>>2]=0),1==(0|s)?(p=0|e,0|(T(0|(h=l|0&t)),p)):(h=c>>>((p=0|kt(0|s))>>>0)|0,p=c<<32-p|u>>>(p>>>0),0|(T(0|h),p))}if(o)return 0|a&&(i[a>>2]=(c>>>0)%(s>>>0),i[a+4>>2]=0),p=(c>>>0)/(s>>>0)>>>0,0|(T(0|(h=0)),p);if(!u)return 0|a&&(i[a>>2]=0,i[a+4>>2]=(c>>>0)%(A>>>0)),p=(c>>>0)/(A>>>0)>>>0,0|(T(0|(h=0)),p);if(!((o=A-1|0)&A))return 0|a&&(i[a>>2]=0|e,i[a+4>>2]=o&c|0&t),h=0,p=c>>>((0|kt(0|A))>>>0),0|(T(0|h),p);if((o=(0|_(0|A))-(0|_(0|c))|0)>>>0<=30){s=t=o+1|0,e=c<<(A=31-o|0)|u>>>(t>>>0),t=c>>>(t>>>0),o=0,A=u<<A;break}return a?(i[a>>2]=0|e,i[a+4>>2]=l|0&t,p=0,0|(T(0|(h=0)),p)):(p=0,0|(T(0|(h=0)),p))}while(0);if(s){c=0|Pt(0|(f=0|n),0|(u=d|0&r),-1,-1),n=0|S(),l=A,A=0;do{r=l,l=o>>>31|l<<1,o=A|o<<1,Nt(0|c,0|n,0|(r=e<<1|r>>>31),0|(d=e>>>31|t<<1)),A=1&(h=(p=0|S())>>31|((0|p)<0?-1:0)<<1),e=0|Nt(0|r,0|d,h&f|0,(((0|p)<0?-1:0)>>31|((0|p)<0?-1:0)<<1)&u),t=0|S(),s=s-1|0}while(0|s);c=l,l=0}else c=A,l=0,A=0;return s=0,0|a&&(i[a>>2]=e,i[a+4>>2]=t),p=o<<1&-2|A,0|(T(0|(h=(0|o)>>>31|(c|s)<<1|l)),p)}function Bt(e,t,n,r){n|=0;var i,a,o,s,A;return a=(r|=0)>>31|((0|r)<0?-1:0)<<1,i=((0|r)<0?-1:0)>>31|((0|r)<0?-1:0)<<1,o=0|Nt((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),e=a^A,t=i^s,0|Nt((0|Lt(o,0|S(),0|Nt(a^n|0,i^r|0,0|a,0|i),0|S(),0))^e,(0|S())^t,0|e,0|t)}function Ot(e,t,n,r){t|=0,r|=0;var i,a;return n=0|function(e,t){var n,r,i,a=0;return e=((n=0|v(a=65535&(t|=0),i=65535&(e|=0)))>>>16)+(0|v(a,r=e>>>16))|0,t=0|v(a=t>>>16,i),0|(T((e>>>16)+(0|v(a,r))+(((65535&e)+t|0)>>>16)|0),e+t<<16|65535&n)}(i=e|=0,a=n|=0),e=0|S(),0|(T((0|v(t,a))+(0|v(r,i))+e|0&e),n)}function Ft(e,t,n,r){n|=0;var a,o,s,A,l,c;return a=N,N=N+16|0,A=0|a,c=(r|=0)>>31|((0|r)<0?-1:0)<<1,l=((0|r)<0?-1:0)>>31|((0|r)<0?-1:0)<<1,Lt(e=0|Nt((s=(t|=0)>>31|((0|t)<0?-1:0)<<1)^(e|=0)|0,(o=((0|t)<0?-1:0)>>31|((0|t)<0?-1:0)<<1)^t|0,0|s,0|o),t=0|S(),0|Nt(c^n|0,l^r|0,0|c,0|l),0|S(),A),r=0|Nt(i[A>>2]^s|0,i[A+4>>2]^o|0,0|s,0|o),n=0|S(),N=a,0|(T(0|n),r)}function Dt(e,t,n,r){var a,o;return o=N,N=N+16|0,Lt(e|=0,t|=0,n|=0,r|=0,a=0|o),N=o,0|(T(0|i[a+4>>2]),i[a>>2])}function Ut(e,t,n){return e|=0,t|=0,(0|(n|=0))<32?(T(t>>n|0),e>>>n|(t&(1<<n)-1)<<32-n):(T(0|((0|t)<0?-1:0)),t>>n-32)}function Vt(e,t,n){return e|=0,t|=0,(0|(n|=0))<32?(T(t>>>n|0),e>>>n|(t&(1<<n)-1)<<32-n):(T(0),t>>>n-32|0)}function jt(e,t,n){return e|=0,t|=0,(0|(n|=0))<32?(T(t<<n|(e&(1<<n)-1<<32-n)>>>32-n),e<<n):(T(e<<n-32),0)}function zt(e,t,n){return e|=0,32==(0|(t=0|_(t|=0)))&&(t=t+(0|_(e))|0),T(0),0|t}function Gt(e,t){return t=+t,(e=+e)!=e?+t:t!=t?+e:+x(+e,+t)}function Ht(e,t){return t=+t,(e=+e)!=e?+t:t!=t?+e:+y(+e,+t)}function qt(e){return(e=+e)>=0?+A(e+.5):+b(e-.5)}function Qt(e,t,n){e|=0,t|=0;var a,o,s=0;if((0|(n|=0))>=8192)return I(0|e,0|t,0|n),0|e;if(o=0|e,a=e+n|0,(3&e)==(3&t)){for(;3&e;){if(!n)return 0|o;r[e|0]=0|r[t|0],e=e+1|0,t=t+1|0,n=n-1|0}for(s=(n=-4&a)-64|0;(0|e)<=(0|s);)i[e>>2]=i[t>>2],i[e+4>>2]=i[t+4>>2],i[e+8>>2]=i[t+8>>2],i[e+12>>2]=i[t+12>>2],i[e+16>>2]=i[t+16>>2],i[e+20>>2]=i[t+20>>2],i[e+24>>2]=i[t+24>>2],i[e+28>>2]=i[t+28>>2],i[e+32>>2]=i[t+32>>2],i[e+36>>2]=i[t+36>>2],i[e+40>>2]=i[t+40>>2],i[e+44>>2]=i[t+44>>2],i[e+48>>2]=i[t+48>>2],i[e+52>>2]=i[t+52>>2],i[e+56>>2]=i[t+56>>2],i[e+60>>2]=i[t+60>>2],e=e+64|0,t=t+64|0;for(;(0|e)<(0|n);)i[e>>2]=i[t>>2],e=e+4|0,t=t+4|0}else for(n=a-4|0;(0|e)<(0|n);)r[e|0]=0|r[t|0],r[e+1|0]=0|r[t+1|0],r[e+2|0]=0|r[t+2|0],r[e+3|0]=0|r[t+3|0],e=e+4|0,t=t+4|0;for(;(0|e)<(0|a);)r[e|0]=0|r[t|0],e=e+1|0,t=t+1|0;return 0|o}function Kt(e,t,n){var i=0;if((0|(t|=0))<(0|(e|=0))&(0|e)<(t+(n|=0)|0)){for(i=e,t=t+n|0,e=e+n|0;(0|n)>0;)t=t-1|0,n=n-1|0,r[(e=e-1|0)|0]=0|r[t|0];e=i}else Qt(e,t,n);return 0|e}function Wt(e,t,n){t|=0;var a,o=0,s=0,A=0;if(a=(e|=0)+(n|=0)|0,t&=255,(0|n)>=67){for(;3&e;)r[e|0]=t,e=e+1|0;for(A=t|t<<8|t<<16|t<<24,s=(o=-4&a)-64|0;(0|e)<=(0|s);)i[e>>2]=A,i[e+4>>2]=A,i[e+8>>2]=A,i[e+12>>2]=A,i[e+16>>2]=A,i[e+20>>2]=A,i[e+24>>2]=A,i[e+28>>2]=A,i[e+32>>2]=A,i[e+36>>2]=A,i[e+40>>2]=A,i[e+44>>2]=A,i[e+48>>2]=A,i[e+52>>2]=A,i[e+56>>2]=A,i[e+60>>2]=A,e=e+64|0;for(;(0|e)<(0|o);)i[e>>2]=A,e=e+4|0}for(;(0|e)<(0|a);)r[e|0]=t,e=e+1|0;return a-n|0}function $t(e){return(e=+e)>=0?+A(e+.5):+b(e-.5)}function Jt(e){e|=0;var t,n,r;return r=0|C(),(0|e)>0&(0|(t=(n=0|i[s>>2])+e|0))<(0|n)|(0|t)<0?(P(0|t),E(12),-1):(0|t)>(0|r)&&!(0|R(0|t))?(E(12),-1):(i[s>>2]=t,0|n)}var Yt=[function(e,t){return w(0),0},function(e,t){t|=0;var n=0,r=0;return e=0|i[(r=e|=0)>>2],r=0|i[r+4>>2],t=0|i[(n=t)>>2],0|(r>>>0<(n=0|i[n+4>>2])>>>0|(0|r)==(0|n)&e>>>0<t>>>0?-1:1&(r>>>0>n>>>0|(0|r)==(0|n)&e>>>0>t>>>0))},function(e,t){t|=0;var n,r,o,s,A=0,l=0;return s=0|i[(l=e|=0)>>2],l=0|i[l+4>>2],o=0|i[(A=t)>>2],l>>>0<(A=0|i[A+4>>2])>>>0|(0|l)==(0|A)&s>>>0<o>>>0?0|(t=-1):l>>>0>A>>>0|(0|l)==(0|A)&s>>>0>o>>>0?0|(t=1):(r=+a[e+8>>3])<(n=+a[t+8>>3])?0|(t=-1):0|(t=r>n&1)},function(e,t){var n,r;return t|=0,0|((r=+a[(e|=0)>>3])>(n=+a[t>>3])?-1:r<n&1)}];return{___divdi3:Bt,___muldi3:Ot,___remdi3:Ft,___uremdi3:Dt,_areNeighborCells:function(e,t,n,r,a){a|=0;var o,s,A,l=0,c=0,u=0,f=0;if(A=N,N=N+64|0,s=A,o=A+56|0,!(!0&134217728==(2013265920&(t|=0))&!0&134217728==(2013265920&(r|=0))))return N=A,0|(a=5);if((0|(e|=0))==(0|(n|=0))&(0|t)==(0|r))return i[a>>2]=0,N=A,0|(a=0);if(c=0|Vt(0|e,0|t,52),S(),c&=15,f=0|Vt(0|n,0|r,52),S(),(0|c)!=(15&f))return N=A,0|(a=12);if(l=c+-1|0,c>>>0>1){we(e,t,l,s),we(n,r,l,o),u=0|i[(f=s)>>2],f=0|i[f+4>>2];e:do{if((0|u)==(0|i[o>>2])&&(0|f)==(0|i[o+4>>2])){l=0|Vt(0|e,0|t,0|(c=3*(15^c)|0)),S(),l&=7,c=0|Vt(0|n,0|r,0|c),S(),c&=7;do{if(!(0|l)|!(0|c))i[a>>2]=1,l=0;else if(7==(0|l))l=5;else{if(1==(0|l)|1==(0|c)&&0|Se(u,f)){l=5;break}if((0|i[15824+(l<<2)>>2])!=(0|c)&&(0|i[15856+(l<<2)>>2])!=(0|c))break e;i[a>>2]=1,l=0}}while(0);return N=A,0|(a=l)}}while(0)}c=(l=s)+56|0;do{i[l>>2]=0,l=l+4|0}while((0|l)<(0|c));return k(e,t,1,s),l=(0|i[(t=s)>>2])==(0|n)&&(0|i[t+4>>2])==(0|r)||(0|i[(t=s+8|0)>>2])==(0|n)&&(0|i[t+4>>2])==(0|r)||(0|i[(t=s+16|0)>>2])==(0|n)&&(0|i[t+4>>2])==(0|r)||(0|i[(t=s+24|0)>>2])==(0|n)&&(0|i[t+4>>2])==(0|r)||(0|i[(t=s+32|0)>>2])==(0|n)&&(0|i[t+4>>2])==(0|r)||(0|i[(t=s+40|0)>>2])==(0|n)&&(0|i[t+4>>2])==(0|r)?1:1&((0|i[(l=s+48|0)>>2])==(0|n)?(0|i[l+4>>2])==(0|r):0),i[a>>2]=l,N=A,0|(a=0)},_bitshift64Ashr:Ut,_bitshift64Lshr:Vt,_bitshift64Shl:jt,_calloc:Ct,_cellAreaKm2:function(e,t,n){n|=0;var r,o,s,A=0;return s=N,N=N+192|0,r=s+176|0,A=s+168|0,(e=0|Ue(e|=0,t|=0,o=s))?(N=s,0|(A=e)):(i[A>>2]=i[o>>2],i[A+4>>2]=o+8,i[r>>2]=i[A>>2],i[r+4>>2]=i[A+4>>2],z(r,n),a[n>>3]=40589732.49931477*+a[n>>3],N=s,0|(A=0))},_cellAreaM2:function(e,t,n){n|=0;var r,o,s,A=0;return s=N,N=N+192|0,r=s+176|0,A=s+168|0,(e=0|Ue(e|=0,t|=0,o=s))?(N=s,0|(A=e)):(i[A>>2]=i[o>>2],i[A+4>>2]=o+8,i[r>>2]=i[A>>2],i[r+4>>2]=i[A+4>>2],z(r,n),a[n>>3]=40589732.49931477*+a[n>>3]*1e6,N=s,0|(A=0))},_cellAreaRads2:function(e,t,n){n|=0;var r,a,o,s=0;return o=N,N=N+192|0,r=o+176|0,s=o+168|0,0|(e=0|Ue(e|=0,t|=0,a=o))?(N=o,0|(s=e)):(i[s>>2]=i[a>>2],i[s+4>>2]=a+8,i[r>>2]=i[s>>2],i[r+4>>2]=i[s+4>>2],z(r,n),N=o,0|(s=0))},_cellToBoundary:Ue,_cellToCenterChild:Ee,_cellToChildPos:function(e,t,n,r){n|=0,r|=0;var a,o=0,s=0,A=0,l=0,c=0,u=0,f=0,d=0,h=0,p=0,m=0,g=0,b=0,v=0;if(a=N,N=N+16|0,b=a,v=0|Vt(0|(e|=0),0|(t|=0),52),S(),v&=15,n>>>0>15)return N=a,0|(v=4);if((0|v)<(0|n))return N=a,0|(v=12);if((0|v)!=(0|n))if(s=0|jt(0|n,0,52),s|=e,l=S()|-15728641&t,(0|v)>(0|n)){c=n;do{g=0|jt(7,0,3*(14-c|0)|0),c=c+1|0,s|=g,l=0|S()|l}while((0|c)<(0|v));g=s}else g=s;else g=e,l=t;m=0|Vt(0|g,0|l,45),S();e:do{if(0|G(127&m)){if(c=0|Vt(0|g,0|l,52),S(),0|(c&=15))for(s=1;;){if(!(!((m=0|jt(7,0,3*(15-s|0)|0))&g|0)&!((0|S())&l))){u=33;break e}if(!(s>>>0<c>>>0))break;s=s+1|0}if(i[(m=r)>>2]=0,i[m+4>>2]=0,(0|v)>(0|n)){for(m=-15728641&t,p=v;;){if(h=p,(p=p+-1|0)>>>0>15|(0|v)<(0|p)){u=19;break}if((0|v)!=(0|p))if(s=0|jt(0|p,0,52),s|=e,c=0|S()|m,(0|v)<(0|h))d=s;else{u=p;do{d=0|jt(7,0,3*(14-u|0)|0),u=u+1|0,s|=d,c=0|S()|c}while((0|u)<(0|v));d=s}else d=e,c=t;if(f=0|Vt(0|d,0|c,45),S(),0|G(127&f)){f=0|Vt(0|d,0|c,52),S(),f&=15;t:do{if(f)for(u=1;;){if(s=0|Vt(0|d,0|c,3*(15-u|0)|0),S(),0|(s&=7))break t;if(!(u>>>0<f>>>0)){s=0;break}u=u+1|0}else s=0}while(0);s=1&!(0|s)}else s=0;if(c=0|Vt(0|e,0|t,3*(15-h|0)|0),S(),7==(0|(c&=7))){o=5,u=42;break}if(1==(0|c)&(s=!!(0|s))){o=5,u=42;break}if(0|(d=c+((!!(0|c)&s)<<31>>31)|0)&&(u=0|Ze(7,0,u=v-h|0,((0|u)<0)<<31>>31),f=0|S(),s?(s=0|Pt(0|(s=0|Ot(0|u,0|f,5,0)),0|S(),-5,-1),s=0|Pt(0|(s=0|Bt(0|s,0|S(),6,0)),0|S(),1,0),c=0|S()):(s=u,c=f),h=0|Pt(0|s,0|c,0|(h=0|Ot(0|u,0|f,0|(h=d+-1|0),((0|h)<0)<<31>>31)),0|S()),f=0|Pt(0|h,0|(d=0|S()),0|i[(f=r)>>2],0|i[f+4>>2]),d=0|S(),i[(h=r)>>2]=f,i[h+4>>2]=d),(0|p)<=(0|n)){u=37;break}}if(19==(0|u))M(27634,27225,1407,27259);else{if(37==(0|u)){o=0|i[(A=r)+4>>2],A=0|i[A>>2];break}if(42==(0|u))return N=a,0|o}}else o=0,A=0}else u=33}while(0);e:do{if(33==(0|u)){if(i[(m=r)>>2]=0,i[m+4>>2]=0,(0|v)>(0|n)){for(s=v;;){if(o=0|Vt(0|e,0|t,3*(15-s|0)|0),S(),7==(0|(o&=7))){o=5;break}if(o=0|Ot(0|(A=0|Ze(7,0,A=v-s|0,((0|A)<0)<<31>>31)),0|S(),0|o,0),A=0|S(),A=0|Pt(0|i[(m=r)>>2],0|i[m+4>>2],0|o,0|A),o=0|S(),i[(m=r)>>2]=A,i[m+4>>2]=o,(0|(s=s+-1|0))<=(0|n))break e}return N=a,0|o}o=0,A=0}}while(0);return 0|Te(g,l,v,b)&&M(27634,27225,1367,27274),((0|o)>-1|-1==(0|o)&A>>>0>4294967295)&((0|(b=0|i[(v=b)+4>>2]))>(0|o)|((0|b)==(0|o)?(0|i[v>>2])>>>0>A>>>0:0))?(N=a,0|(v=0)):(M(27634,27225,1447,27259),0)},_cellToChildren:function(e,t,n,r){r|=0;var a,o,s=0,A=0;if(o=N,N=N+16|0,je(a=o,e|=0,t|=0,n|=0),!(0|(e=0|i[(t=a)>>2]))&!(0|(t=0|i[t+4>>2])))return N=o,0;s=0,n=0;do{i[(A=r+(s<<3)|0)>>2]=e,i[A+4>>2]=t,s=0|Pt(0|s,0|n,1,0),n=0|S(),Ge(a),e=0|i[(A=a)>>2],t=0|i[A+4>>2]}while(!(!(0|e)&!(0|t)));return N=o,0},_cellToChildrenSize:Te,_cellToLatLng:De,_cellToLocalIj:function(e,t,n,r,a,o){o|=0;var s,A=0;return s=N,N=N+16|0,A=s,0|(a|=0)?(N=s,0|(A=15)):((e=0|$e(e|=0,t|=0,n|=0,r|=0,A))||(a=0|i[A+4>>2],e=0|i[A+8>>2],i[o>>2]=(0|i[A>>2])-e,i[o+4>>2]=a-e,e=0),N=s,0|(A=e))},_cellToParent:we,_cellToVertex:pt,_cellToVertexes:function(e,t,n){n|=0;var r,a=0,o=0;return o=!(0|Se(e|=0,t|=0)),r=!(0|(a=0|pt(e,t,0,n))),o?r?0|(a=0|pt(e,t,1,n+8|0))||0|(a=0|pt(e,t,2,n+16|0))||0|(a=0|pt(e,t,3,n+24|0))||(a=0|pt(e,t,4,n+32|0))?0|(o=a):0|pt(e,t,5,n+40|0):0|(o=a):r?0|(a=0|pt(e,t,1,n+8|0))||0|(a=0|pt(e,t,2,n+16|0))||0|(a=0|pt(e,t,3,n+24|0))||0|(a=0|pt(e,t,4,n+32|0))?0|(o=a):(i[(o=n+40|0)>>2]=0,i[o+4>>2]=0,0|(o=0)):0|(o=a)},_cellsToDirectedEdge:function(e,t,n,r,a){return a|=0,7==(0|(n=0|V(e|=0,t|=0,n|=0,r|=0)))?0|(a=11):(r=0|jt(0|n,0,56),t=-2130706433&t|S()|268435456,i[a>>2]=e|r,i[a+4>>2]=t,0|(a=0))},_cellsToLinkedMultiPolygon:function(e,t,n){n|=0;var r,a,o=0,s=0,A=0,l=0,c=0;if(a=N,N=N+16|0,0|(e=0|ie(e|=0,t|=0,((0|t)<0)<<31>>31,A=a)))return N=a,0|(A=e);if(r=0|function(e,t){e|=0,t|=0;var n=0,r=0,a=0,o=0,s=0,A=0,l=0,c=0,u=0,f=0,d=0,h=0,p=0,m=0,g=0,b=0;if(i[t>>2]=0,g=t+4|0,i[g>>2]=0,b=t+8|0,i[b>>2]=0,m=0|i[e>>2],(0|m)<=0)return 0|(t=0);p=e+4|0,e=t,h=0;e:for(;;){if(h){if(!(n=0|Ct(1,12))){n=5;break}i[e+8>>2]=n,e=n}if(l=0|i[p>>2],!(c=0|Ct(1,12))){e=13,n=37;break}if(r=0|i[(d=e+4|0)>>2],i[(0|r?r+8:e)>>2]=c,i[d>>2]=c,(0|(r=0|i[l+(h<<4)>>2]))<3){e=1,n=37;break}a=l+(h<<4)+4|0,o=c+4|0,n=0,s=0;do{if(A=s,!(s=0|Mt(24))){e=13,n=37;break e}Kt(0|s,(0|i[a>>2])+(n<<4)|0,16),i[s+16>>2]=0,A?i[A+16>>2]=s:i[c>>2]=s,i[o>>2]=s,n=n+1|0}while((0|n)<(0|r));if((0|(f=0|i[l+(h<<4)+8>>2]))>0){u=l+(h<<4)+12|0,l=0;do{if(r=0|i[u>>2],n=c,!(c=0|Ct(1,12))){e=13,n=37;break e}if(i[n+8>>2]=c,i[d>>2]=c,(0|(A=0|i[r+(l<<3)>>2]))<3){e=1,n=37;break e}r=r+(l<<3)+4|0,a=c+4|0,n=0,o=0;do{if(s=o,!(o=0|Mt(24))){e=13,n=37;break e}Kt(0|o,(0|i[r>>2])+(n<<4)|0,16),i[o+16>>2]=0,s?i[s+16>>2]=o:i[c>>2]=o,i[a>>2]=o,n=n+1|0}while((0|n)<(0|A));l=l+1|0}while((0|l)<(0|f))}if((0|(h=h+1|0))>=(0|m)){e=0,n=50;break}}if(5==(0|n)){if(!t)return 0|(t=13);for(r=1,a=t;;){if(0|(e=0|i[a>>2]))do{if(0|(n=0|i[e>>2]))do{m=n,n=0|i[n+16>>2],Et(m)}while(0|n);m=e,e=0|i[e+8>>2],Et(m)}while(0|e);if(e=a,a=0|i[a+8>>2],r?(i[t>>2]=0,i[g>>2]=0,i[b>>2]=0):Et(e),!a){e=13;break}r=0}return 0|e}if(37==(0|n)){if(!t)return 0|(t=e);for(a=1,o=t;;){if(0|(n=0|i[o>>2]))do{if(0|(r=0|i[n>>2]))do{m=r,r=0|i[r+16>>2],Et(m)}while(0|r);m=n,n=0|i[n+8>>2],Et(m)}while(0|n);if(n=o,o=0|i[o+8>>2],a?(i[t>>2]=0,i[g>>2]=0,i[b>>2]=0):Et(n),!o)break;a=0}return 0|e}if(50==(0|n))return 0|e;return 0}(A,n),n=A+4|0,(0|i[A>>2])>0){t=0;do{if(s=0|i[n>>2],Et(0|i[(o=s+(t<<4)+4|0)>>2]),i[o>>2]=0,i[s+(t<<4)>>2]=0,o=s+(t<<4)+8|0,s=s+(t<<4)+12|0,(0|i[o>>2])>0){e=0;do{l=0|i[s>>2],Et(0|i[(c=l+(e<<3)+4|0)>>2]),i[c>>2]=0,i[l+(e<<3)>>2]=0,e=e+1|0}while((0|e)<(0|i[o>>2]))}Et(0|i[s>>2]),i[s>>2]=0,i[o>>2]=0,t=t+1|0}while((0|t)<(0|i[A>>2]))}return Et(0|i[n>>2]),i[n>>2]=0,i[A>>2]=0,N=a,0|(c=r)},_childPosToCell:function(e,t,n,r,a,o){e|=0,t|=0,o|=0;var s,A=0,l=0,c=0,u=0,f=0,d=0,h=0,p=0,m=0;if(s=N,N=N+16|0,A=s,(a|=0)>>>0>15)return N=s,0|(o=4);if(l=0|Vt(0|(n|=0),0|(r|=0),52),S(),(0|(l&=15))>(0|a))return N=s,0|(o=12);if(0|Te(n,r,a,A)&&M(27634,27225,1367,27274),!(((0|t)>-1|-1==(0|t)&e>>>0>4294967295)&((0|(u=0|i[(f=A)+4>>2]))>(0|t)|((0|u)==(0|t)?(0|i[f>>2])>>>0>e>>>0:0))))return N=s,0|(o=2);f=a-l|0,a=0|jt(0|a,0,52),c=S()|-15728641&r,i[(u=o)>>2]=a|n,i[u+4>>2]=c,u=0|Vt(0|n,0|r,45),S();e:do{if(0|G(127&u)){if(0|l)for(A=1;;){if(!(!((u=0|jt(7,0,3*(15-A|0)|0))&n|0)&!((0|S())&r)))break e;if(!(A>>>0<l>>>0))break;A=A+1|0}if((0|f)<1)return N=s,0|(o=0);for(u=15^l,r=-1,c=1,A=1;;){l=0|Ze(7,0,l=f-c|0,((0|l)<0)<<31>>31),n=0|S();do{if(A){if(A=0|Bt(0|(A=0|Pt(0|(A=0|Ot(0|l,0|n,5,0)),0|S(),-5,-1)),0|S(),6,0),(0|t)>(0|(a=0|S()))|(0|t)==(0|a)&e>>>0>A>>>0){t=0|Nt(0|(t=0|Pt(0|e,0|t,-1,-1)),0|S(),0|A,0|a),A=0|S(),p=0|i[(d=o)>>2],d=0|i[d+4>>2],h=0|jt(7,0,0|(m=3*(u+r|0)|0)),d&=~S(),m=0|jt(0|(a=0|Pt(0|(r=0|Bt(0|t,0|A,0|l,0|n)),0|(e=0|S()),2,0)),0|S(),0|m),d=0|S()|d,i[(a=o)>>2]=m|p&~h,i[a+4>>2]=d,e=0|Nt(0|t,0|A,0|(e=0|Ot(0|r,0|e,0|l,0|n)),0|S()),A=0,t=0|S();break}h=0|i[(m=o)>>2],m=0|i[m+4>>2],p=0|jt(7,0,3*(u+r|0)|0),m&=~S(),i[(A=o)>>2]=h&~p,i[A+4>>2]=m,A=1;break}a=0|i[(h=o)>>2],h=0|i[h+4>>2],d=0|jt(7,0,0|(r=3*(u+r|0)|0)),h&=~S(),r=0|jt(0|(m=0|Bt(0|e,0|t,0|l,0|n)),0|(A=0|S()),0|r),h=0|S()|h,i[(p=o)>>2]=r|a&~d,i[p+4>>2]=h,e=0|Nt(0|e,0|t,0|(A=0|Ot(0|m,0|A,0|l,0|n)),0|S()),A=0,t=0|S()}while(0);if(!((0|f)>(0|c))){t=0;break}r=~c,c=c+1|0}return N=s,0|t}}while(0);if((0|f)<1)return N=s,0|(m=0);for(a=15^l,A=1;;){if(p=0|Ze(7,0,p=f-A|0,((0|p)<0)<<31>>31),m=0|S(),n=0|i[(c=o)>>2],c=0|i[c+4>>2],r=0|jt(7,0,0|(l=3*(a-A|0)|0)),c&=~S(),l=0|jt(0|(d=0|Bt(0|e,0|t,0|p,0|m)),0|(h=0|S()),0|l),c=0|S()|c,i[(u=o)>>2]=l|n&~r,i[u+4>>2]=c,e=0|Nt(0|e,0|t,0|(m=0|Ot(0|d,0|h,0|p,0|m)),0|S()),t=0|S(),(0|f)<=(0|A)){t=0;break}A=A+1|0}return N=s,0|t},_compactCells:function(e,t,n,r){t|=0;var a,o=0,s=0,A=0,l=0,c=0,u=0,f=0,d=0,h=0,p=0,m=0,g=0,b=0,v=0,y=0,x=0,_=0,w=0,T=0,E=0,C=0,I=0,R=0,P=0,N=0;if(!(0|(n|=0))&!(0|(r|=0)))return 0|(N=0);if(s=0|i[(o=e|=0)>>2],!0&!(15728640&(o=0|i[o+4>>2]))){if(!((0|r)>0|!(0|r)&n>>>0>0))return 0|(N=0);if(i[(N=t)>>2]=s,i[N+4>>2]=o,1==(0|n)&!(0|r))return 0|(N=0);o=1,s=0;do{P=0|i[(R=e+(o<<3)|0)+4>>2],i[(N=t+(o<<3)|0)>>2]=i[R>>2],i[N+4>>2]=P,o=0|Pt(0|o,0|s,1,0),s=0|S()}while((0|s)<(0|r)|(0|s)==(0|r)&o>>>0<n>>>0);return 0|(o=0)}if(!(P=0|Mt(a=n<<3)))return 0|(N=13);if(Qt(0|P,0|e,0|a),!(R=0|Ct(n,8)))return Et(P),0|(N=13);e:for(;;){C=0|Vt(0|(u=0|i[(o=P)>>2]),0|(o=0|i[o+4>>2]),52),S(),I=(C&=15)+-1|0,E=!!(0|C),T=(0|r)>0|!(0|r)&n>>>0>0;t:do{if(E&T){if(y=0|jt(0|I,0,52),x=0|S(),I>>>0>15){if(!(!(0|u)&!(0|o))){N=16;break e}for(s=0,e=0;;){if(s=0|Pt(0|s,0|e,1,0),!((0|(e=0|S()))<(0|r)|(0|e)==(0|r)&s>>>0<n>>>0))break t;if(!(!(0|(w=0|i[(A=P+(s<<3)|0)>>2]))&!(0|(A=0|i[A+4>>2])))){o=A,N=16;break e}}}for(l=u,e=o,s=0,A=0;;){if(!(!(0|l)&!(0|e))){if(!(!0&!(117440512&e))){N=21;break e}if(f=0|Vt(0|l,0|e,52),S(),(0|(f&=15))<(0|I)){o=12,N=27;break e}if((0|f)!=(0|I)&&(l|=y,e=-15728641&e|x,f>>>0>=C>>>0)){c=I;do{w=0|jt(7,0,3*(14-c|0)|0),c=c+1|0,l|=w,e=0|S()|e}while(c>>>0<f>>>0)}if(h=0|Dt(0|l,0|e,0|n,0|r),p=0|S(),!(!(0|(d=0|i[(f=c=R+(h<<3)|0)>>2]))&!(0|(f=0|i[f+4>>2])))){b=0,v=0;do{if((0|b)>(0|r)|(0|b)==(0|r)&v>>>0>n>>>0){N=31;break e}if((0|d)==(0|l)&(-117440513&f)==(0|e)){m=0|Vt(0|d,0|f,56),S(),g=(m&=7)+1|0,w=0|Vt(0|d,0|f,45),S();n:do{if(0|G(127&w)){if(d=0|Vt(0|d,0|f,52),S(),!(d&=15)){f=6;break}for(f=1;;){if(!(!((w=0|jt(7,0,3*(15-f|0)|0))&l|0)&!((0|S())&e))){f=7;break n}if(!(f>>>0<d>>>0)){f=6;break}f=f+1|0}}else f=7}while(0);if((m+2|0)>>>0>f>>>0){N=41;break e}w=0|jt(0|g,0,56),e=S()|-117440513&e,i[(_=c)>>2]=0,i[_+4>>2]=0,l|=w}else h=0|Ft(0|(h=0|Pt(0|h,0|p,1,0)),0|S(),0|n,0|r),p=0|S();v=0|Pt(0|v,0|b,1,0),b=0|S(),d=0|i[(f=c=R+(h<<3)|0)>>2],f=0|i[f+4>>2]}while(!(!(0|d)&!(0|f)))}i[(w=c)>>2]=l,i[w+4>>2]=e}if(s=0|Pt(0|s,0|A,1,0),!((0|(A=0|S()))<(0|r)|(0|A)==(0|r)&s>>>0<n>>>0))break t;l=0|i[(e=P+(s<<3)|0)>>2],e=0|i[e+4>>2]}}}while(0);if(w=0|Pt(0|n,0|r,5,0),(_=0|S())>>>0<0|!(0|_)&w>>>0<11){N=85;break}if(w=0|Bt(0|n,0|r,6,0),S(),!(w=0|Ct(w,8))){N=48;break}do{if(T){for(g=0,e=0,m=0,b=0;;){if(!(0|(s=0|i[(A=f=R+(g<<3)|0)>>2]))&!(0|(A=0|i[A+4>>2])))_=m;else{d=0|Vt(0|s,0|A,56),S(),l=(d&=7)+1|0,h=-117440513&A,_=0|Vt(0|s,0|A,45),S();t:do{if(0|G(127&_)){if(p=0|Vt(0|s,0|A,52),S(),0|(p&=15))for(c=1;;){if(!(!(s&(_=0|jt(7,0,3*(15-c|0)|0))|0)&!(h&(0|S()))))break t;if(!(c>>>0<p>>>0))break;c=c+1|0}s|=A=0|jt(0|l,0,56),A=0|S()|h,i[(l=f)>>2]=s,i[l+4>>2]=A,l=d+2|0}}while(0);7==(0|l)?(i[(_=w+(e<<3)|0)>>2]=s,i[_+4>>2]=-117440513&A,e=0|Pt(0|e,0|m,1,0),_=0|S()):_=m}if(g=0|Pt(0|g,0|b,1,0),!((0|(b=0|S()))<(0|r)|(0|b)==(0|r)&g>>>0<n>>>0))break;m=_}if(T){if(v=I>>>0>15,y=0|jt(0|I,0,52),x=0|S(),!E){for(s=0,c=0,l=0,A=0;!(0|u)&!(0|o)||(i[(I=t+(s<<3)|0)>>2]=u,i[I+4>>2]=o,s=0|Pt(0|s,0|c,1,0),c=0|S()),l=0|Pt(0|l,0|A,1,0),(0|(A=0|S()))<(0|r)|(0|A)==(0|r)&l>>>0<n>>>0;)u=0|i[(o=P+(l<<3)|0)>>2],o=0|i[o+4>>2];o=_;break}for(s=0,c=0,A=0,l=0;;){do{if(!(!(0|u)&!(0|o))){if(p=0|Vt(0|u,0|o,52),S(),v|(0|(p&=15))<(0|I)){N=80;break e}if((0|p)!=(0|I)){if(f=u|y,d=-15728641&o|x,p>>>0>=C>>>0){h=I;do{E=0|jt(7,0,3*(14-h|0)|0),h=h+1|0,f|=E,d=0|S()|d}while(h>>>0<p>>>0)}}else f=u,d=o;m=0|Dt(0|f,0|d,0|n,0|r),h=0,p=0,b=0|S();do{if((0|h)>(0|r)|(0|h)==(0|r)&p>>>0>n>>>0){N=81;break e}if((-117440513&(g=0|i[(E=R+(m<<3)|0)+4>>2]))==(0|d)&&(0|i[E>>2])==(0|f)){N=65;break}m=0|Ft(0|(E=0|Pt(0|m,0|b,1,0)),0|S(),0|n,0|r),b=0|S(),p=0|Pt(0|p,0|h,1,0),h=0|S(),E=R+(m<<3)|0}while((0|i[E>>2])!=(0|f)||(0|i[E+4>>2])!=(0|d));if(65==(0|N)&&(N=0,!0&100663296==(117440512&g)))break;i[(E=t+(s<<3)|0)>>2]=u,i[E+4>>2]=o,s=0|Pt(0|s,0|c,1,0),c=0|S()}}while(0);if(A=0|Pt(0|A,0|l,1,0),!((0|(l=0|S()))<(0|r)|(0|l)==(0|r)&A>>>0<n>>>0))break;u=0|i[(o=P+(A<<3)|0)>>2],o=0|i[o+4>>2]}o=_}else s=0,o=_}else s=0,e=0,o=0}while(0);if(Wt(0|R,0,0|a),Qt(0|P,0|w,e<<3),Et(w),!(0|e)&!(0|o)){N=89;break}t=t+(s<<3)|0,r=o,n=e}if(16==(0|N))!0&!(117440512&o)?(o=4,N=27):N=21;else if(31==(0|N))M(27634,27225,620,27235);else{if(41==(0|N))return Et(P),Et(R),0|(N=10);if(48==(0|N))return Et(P),Et(R),0|(N=13);80==(0|N)?M(27634,27225,711,27235):81==(0|N)?M(27634,27225,723,27235):85==(0|N)&&(Qt(0|t,0|P,n<<3),N=89)}return 21==(0|N)?(Et(P),Et(R),0|(N=5)):27==(0|N)?(Et(P),Et(R),0|(N=o)):89==(0|N)?(Et(P),Et(R),0|(N=0)):0},_constructCell:function(e,t,n,a){n|=0,a|=0;var o=0,s=0,A=0,l=0,c=0,u=0;if((e|=0)>>>0>15)return 0|(a=4);if((t|=0)>>>0>121)return 0|(a=17);A=0|jt(0|e,0,52),o=0|S(),l=0|jt(0|t,0,45),o=0|o|S()|134225919;e:do{if((0|e)>=1){for(l=1,A=!!(0|r[20496+t|0]),s=-1;;){if((t=0|i[n+(l+-1<<2)>>2])>>>0>6){o=18,t=10;break}if(!(!(0|t)|1^A)){if(1==(0|t)){o=19,t=10;break}A=0}if(c=0|jt(7,0,0|(u=3*(15-l|0)|0)),o&=~S(),s=(t=0|jt(0|t,((0|t)<0)<<31>>31,0|u))|s&~c,o=0|S()|o,!((0|l)<(0|e)))break e;l=l+1|0}if(10==(0|t))return 0|o}else s=-1}while(0);return i[(u=a)>>2]=s,i[u+4>>2]=o,0|(u=0)},_destroyLinkedMultiPolygon:function(e){var t,n,r=0,a=0,o=0,s=0,A=0;if(e|=0)for(t=e+4|0,n=e+8|0,o=1,s=e;;){if(0|(r=0|i[s>>2]))do{if(0|(a=0|i[r>>2]))do{A=a,a=0|i[a+16>>2],Et(A)}while(0|a);A=r,r=0|i[r+8>>2],Et(A)}while(0|r);if(r=s,s=0|i[s+8>>2],o?(i[e>>2]=0,i[t>>2]=0,i[n>>2]=0):Et(r),!s)break;o=0}},_directedEdgeToBoundary:Ae,_directedEdgeToCells:function(e,t,n){e|=0;var r,a,o,s=0;return r=N,N=N+16|0,s=r,!0&268435456==(2013265920&(t|=0))?(a=-2130706433&t|134217728,i[(o=n|=0)>>2]=e,i[o+4>>2]=a,i[s>>2]=0,t=0|Vt(0|e,0|t,56),S(),s=0|F(e,a,7&t,s,n+8|0),N=r,0|s):(N=r,0|(s=6))},_edgeLengthKm:function(e,t,n){n|=0;var r,o=0,s=0,A=0,l=0,d=0,h=0,p=0;if(r=N,N=N+176|0,0|(e=0|Ae(e|=0,t|=0,l=r)))return l=e,A=+a[n>>3],A*=6371.007180918475,a[n>>3]=A,N=r,0|l;if(a[n>>3]=0,(0|(e=0|i[l>>2]))<=1)return l=0,A=0,A*=6371.007180918475,a[n>>3]=A,N=r,0|l;t=e+-1|0,e=0,o=+a[l+8>>3],s=+a[l+16>>3],A=0;do{h=o,o=+a[l+8+((e=e+1|0)<<4)>>3],p=+f(.5*(o-h)),d=s,s=+a[l+8+(e<<4)+8>>3],d=p*p+(d=+f(.5*(s-d)))*(+u(+h)*+u(+o)*d),A+=2*+g(+ +c(+d),+ +c(+(1-d)))}while((0|e)!=(0|t));return a[n>>3]=A,l=0,p=A,p*=6371.007180918475,a[n>>3]=p,N=r,0|l},_edgeLengthM:function(e,t,n){n|=0;var r,o=0,s=0,A=0,l=0,d=0,h=0,p=0;if(r=N,N=N+176|0,0|(e=0|Ae(e|=0,t|=0,l=r)))return l=e,A=+a[n>>3],A*=6371.007180918475,A*=1e3,a[n>>3]=A,N=r,0|l;if(a[n>>3]=0,(0|(e=0|i[l>>2]))<=1)return l=0,A=0,A*=6371.007180918475,A*=1e3,a[n>>3]=A,N=r,0|l;t=e+-1|0,e=0,o=+a[l+8>>3],s=+a[l+16>>3],A=0;do{h=o,o=+a[l+8+((e=e+1|0)<<4)>>3],p=+f(.5*(o-h)),d=s,s=+a[l+8+(e<<4)+8>>3],d=p*p+(d=+f(.5*(s-d)))*(+u(+h)*+u(+o)*d),A+=2*+g(+ +c(+d),+ +c(+(1-d)))}while((0|e)!=(0|t));return a[n>>3]=A,l=0,p=A,p*=6371.007180918475,p*=1e3,a[n>>3]=p,N=r,0|l},_edgeLengthRads:function(e,t,n){n|=0;var r,o=0,s=0,A=0,l=0,d=0,h=0,p=0;if(r=N,N=N+176|0,0|(e=0|Ae(e|=0,t|=0,l=r)))return N=r,0|(l=e);if(a[n>>3]=0,(0|(e=0|i[l>>2]))<=1)return N=r,0|(l=0);t=e+-1|0,e=0,o=+a[l+8>>3],s=+a[l+16>>3],A=0;do{h=o,o=+a[l+8+((e=e+1|0)<<4)>>3],p=+f(.5*(o-h)),d=s,s=+a[l+8+(e<<4)+8>>3],d=p*p+(d=+f(.5*(s-d)))*(+u(+o)*+u(+h)*d),A+=2*+g(+ +c(+d),+ +c(+(1-d)))}while((0|e)<(0|t));return a[n>>3]=A,N=r,0|(l=0)},_emscripten_replace_memory:function(e){return r=new Int8Array(e),new Uint8Array(e),i=new Int32Array(e),new Float32Array(e),a=new Float64Array(e),n=e,!0},_free:Et,_getBaseCellNumber:ye,_getDirectedEdgeDestination:function(e,t,n){e|=0,t|=0,n|=0;var r,a,o=0;return r=N,N=N+16|0,i[(o=r)>>2]=0,!0&268435456==(2013265920&t)?(a=0|Vt(0|e,0|t,56),S(),o=0|F(e,-2130706433&t|134217728,7&a,o,n),N=r,0|o):(N=r,0|(o=6))},_getDirectedEdgeOrigin:function(e,t,n){return e|=0,n|=0,!0&268435456==(2013265920&(t|=0))?(i[n>>2]=e,i[n+4>>2]=-2130706433&t|134217728,0|(n=0)):0|(n=6)},_getHexagonAreaAvgKm2:Ke,_getHexagonAreaAvgM2:function(e,t){return t|=0,(e|=0)>>>0>15?0|(t=4):(a[t>>3]=+a[20752+(e<<3)>>3],0|(t=0))},_getHexagonEdgeLengthAvgKm:function(e,t){return t|=0,(e|=0)>>>0>15?0|(t=4):(a[t>>3]=+a[20880+(e<<3)>>3],0|(t=0))},_getHexagonEdgeLengthAvgM:function(e,t){return t|=0,(e|=0)>>>0>15?0|(t=4):(a[t>>3]=+a[21008+(e<<3)>>3],0|(t=0))},_getIcosahedronFaces:function e(t,n,r){r|=0;var a,o=0,s=0,A=0,l=0,c=0,u=0,f=0,d=0;a=N,N=N+128|0,f=a+112|0,A=a+96|0,d=a,s=0|Vt(0|(t|=0),0|(n|=0),52),S(),c=15&s,i[f>>2]=c,l=0|Vt(0|t,0|n,45),S(),l&=127;e:do{if(0|G(l)){if(0|c)for(o=1;;){if(!(!((u=0|jt(7,0,3*(15-o|0)|0))&t|0)&!((0|S())&n))){s=0;break e}if(!(o>>>0<c>>>0))break;o=o+1|0}if(!(1&s))return u=0|jt(c+1|0,0,52),d=S()|-15728641&n,d=0|e((u|t)&~(f=0|jt(7,0,3*(14-c|0)|0)),d&~S(),r),N=a,0|d;s=1}else s=0}while(0);if(!(o=0|Fe(t,n,A))){s?(he(A,f,d),u=5):(be(A,f,d),u=6);e:do{if(0|G(l))if(c)for(o=1;;){if(!(!((l=0|jt(7,0,3*(15-o|0)|0))&t|0)&!((0|S())&n))){t=2;break e}if(!(o>>>0<c>>>0)){t=5;break}o=o+1|0}else t=5;else t=2}while(0);Wt(0|r,-1,t<<2);e:do{if(s)for(A=0;;){if(me(l=d+(A<<4)|0,0|i[f>>2]),l=0|i[l>>2],-1==(0|(c=0|i[r>>2]))|(0|c)==(0|l))o=r;else{s=0;do{if((s=s+1|0)>>>0>=t>>>0){o=1;break e}c=0|i[(o=r+(s<<2)|0)>>2]}while(!(-1==(0|c)|(0|c)==(0|l)))}if(i[o>>2]=l,(A=A+1|0)>>>0>=u>>>0){o=0;break}}else for(A=0;;){if(pe(l=d+(A<<4)|0,0|i[f>>2],0,1),l=0|i[l>>2],-1==(0|(c=0|i[r>>2]))|(0|c)==(0|l))o=r;else{s=0;do{if((s=s+1|0)>>>0>=t>>>0){o=1;break e}c=0|i[(o=r+(s<<2)|0)>>2]}while(!(-1==(0|c)|(0|c)==(0|l)))}if(i[o>>2]=l,(A=A+1|0)>>>0>=u>>>0){o=0;break}}}while(0)}return N=a,0|(d=o)},_getIndexDigit:function(e,t,n,r){return r|=0,((n|=0)+-1|0)>>>0>14?0|(r=4):(n=0|Vt(0|(e|=0),0|(t|=0),3*(15-n|0)|0),S(),i[r>>2]=7&n,0|(r=0))},_getNumCells:We,_getPentagons:Ve,_getRes0Cells:function(e){e|=0;var t=0,n=0,r=0;t=0;do{jt(0|t,0,45),r=134225919|S(),i[(n=e+(t<<3)|0)>>2]=-1,i[n+4>>2]=r,t=t+1|0}while(122!=(0|t));return 0},_getResolution:ve,_greatCircleDistanceKm:Qe,_greatCircleDistanceM:function(e,t){e|=0;var n,r,i,o=0;return r=+a[(t|=0)>>3],n=+a[e>>3],o=(i=+f(.5*(r-n)))*i+(o=+f(.5*(+a[t+8>>3]-+a[e+8>>3])))*(+u(+r)*+u(+n)*o),2*+g(+ +c(+o),+ +c(+(1-o)))*6371.007180918475*1e3},_greatCircleDistanceRads:function(e,t){e|=0;var n,r,i,o=0;return r=+a[(t|=0)>>3],n=+a[e>>3],o=(i=+f(.5*(r-n)))*i+(o=+f(.5*(+a[t+8>>3]-+a[e+8>>3])))*(+u(+r)*+u(+n)*o),2*+g(+ +c(+o),+ +c(+(1-o)))},_gridDisk:k,_gridDiskDistances:L,_gridDistance:Ye,_gridPathCells:function(e,t,n,r,a){a|=0;var o,s,A=0,l=0;return s=N,N=N+16|0,0|(l=0|Ye(e|=0,t|=0,n|=0,r|=0,A=s))?(N=s,0|(a=l)):!(0|(A=0|i[(l=A)>>2]))&!(0|(l=0|i[l+4>>2]))?(i[a>>2]=e,i[a+4>>2]=t,N=s,0|(a=0)):(o=0|Xe(e,t,n,r,A,l,a,0,0,1,0))?(a=!(0|Xe(n,r,e,t,A,l,a,A,l,-1,-1)),N=s,0|(a=a?0:o)):(N=s,0|(a=0))},_gridPathCellsSize:function(e,t,n,r,a){a|=0;var o,s=0;return o=N,N=N+16|0,0|(e=0|Ye(e|=0,t|=0,n|=0,r|=0,s=o))?(N=o,0|(s=e)):(n=0|Pt(0|i[(n=s)>>2],0|i[n+4>>2],1,0),r=0|S(),i[(s=a)>>2]=n,i[s+4>>2]=r,N=o,0|(s=0))},_gridRing:function(e,t,n,r){return 0|D(e|=0,t|=0,n|=0,r|=0)?(Wt(0|r,0,48*n|0),0|(r=0|U(e,t,n,r))):0|(r=0)},_gridRingUnsafe:D,_i64Add:Pt,_i64Subtract:Nt,_isPentagon:Se,_isResClassIII:function(e,t){return t=0|Vt(0|(e|=0),0|(t|=0),52),S(),1&t},_isValidCell:xe,_isValidDirectedEdge:oe,_isValidIndex:function(e,t){e|=0;var n=0,i=0,a=0,o=0;if(!0&134217728==(-16777216&(t|=0))&&(i=0|Vt(0|e,0|t,52),S(),i&=15,n=0|Vt(0|e,0|t,45),S(),(n&=127)>>>0<=121)&&!(613566756&(o=0|jt(0|(a=0|Vt(0|e,0|t,0|(o=3*(15^i)|0))),0|S(),0|o))&(0|Nt(-1227133514,-1171,0|o,0|(a=0|S()))))&!(4681&a&S())&&15==(0|i)|!(0|(o=0|Vt(0|(0|jt(0|~e,0|~t,0|(o=19+(3*i|0)|0))),0|S(),0|o)))&!(0|S())){if(!(0|r[20496+n|0]))return 0|(o=1);if(!(0|e)&!(0|(n=8191&t)))return 0|(o=1);if(o=0|zt(0|e,0|n,0),S(),(63-o|0)%3|0)return 0|(o=1)}return 0|oe(e,t)?0|(o=1):0|(o=1&!!(0|mt(e,t)))},_isValidVertex:mt,_latLngToCell:Be,_llvm_ctlz_i64:zt,_llvm_maxnum_f64:Gt,_llvm_minnum_f64:Ht,_llvm_round_f64:qt,_localIjToCell:function(e,t,n,r,a){e|=0,t|=0,a|=0;var o,s,A,l=0,c=0,u=0,f=0;return A=N,N=N+16|0,f=A,0|(r|=0)?(N=A,0|(f=15)):(u=0|i[(n|=0)>>2],c=0|i[n+4>>2],i[f>>2]=u,i[(o=f+4|0)>>2]=c,i[(s=f+8|0)>>2]=0,r=(n=(0|c)<(0|u))?u:c,(0|(n=n?c:u))<0&&(-2147483648==(0|n)||((0|r)>0?(2147483647-r|0)<(0|n):(-2147483648-r|0)>(0|n))||((0|r)>-1?(-2147483648|r)>=(0|n):(-2147483648^r)<(0|n)))?r=1:l=5,5==(0|l)&&(r=c-u|0,l=0-u|0,(0|u)<0?(i[o>>2]=r,i[s>>2]=l,i[f>>2]=0,u=0):(r=c,l=0),c=u-r|0,n=l-r|0,(0|r)<0?(i[f>>2]=c,i[s>>2]=n,i[o>>2]=0,u=c,r=0):n=l,c=u-n|0,l=r-n|0,(0|n)<0?(i[f>>2]=c,i[o>>2]=l,i[s>>2]=0,n=0):(l=r,c=u),(0|(r=(0|n)<(0|(r=(0|l)<(0|c)?l:c))?n:r))>0&&(i[f>>2]=c-r,i[o>>2]=l-r,i[s>>2]=n-r),r=0|Je(e,t,f,a)),N=A,0|(f=r))},_malloc:Mt,_maxFaceCount:function(e,t,n){n|=0;var r=0,a=0;if(a=0|Vt(0|(e|=0),0|(t|=0),45),S(),!(0|G(127&a)))return a=2,i[n>>2]=a,0;if(a=0|Vt(0|e,0|t,52),S(),!(a&=15))return a=5,i[n>>2]=a,0;for(r=1;;){if(!(!((0|jt(7,0,3*(15-r|0)|0))&e|0)&!((0|S())&t))){r=2,e=6;break}if(!(r>>>0<a>>>0)){r=5,e=6;break}r=r+1|0}return 6==(0|e)?(i[n>>2]=r,0):0},_maxGridDiskSize:function(e,t){t|=0;var n=0,r=0,a=0;return(0|(e|=0))<0?0|(t=2):(0|e)>13780509?0|(t=0|We(15,t)):(a=0|Ot(0|e,0|(n=((0|e)<0)<<31>>31),3,0),r=0|S(),n=0|Pt(0|e,0|n,1,0),n=0|Pt(0|(n=0|Ot(0|a,0|r,0|n,0|S())),0|S(),1,0),e=0|S(),i[t>>2]=n,i[t+4>>2]=e,0|(t=0))},_maxPolygonToCellsSize:function(e,t,n,r){e|=0,t|=0,r|=0;var a,o=0,s=0,A=0,l=0,c=0;if(a=N,N=N+48|0,o=a+16|0,s=a+8|0,A=a,0|(n=0|ot(n|=0)))return N=a,0|(A=n);if(l=0|i[(c=e)+4>>2],i[(n=s)>>2]=i[c>>2],i[n+4>>2]=l,at(s,o),!(n=0|ne(o,t,A))){if(t=0|i[s>>2],(0|(s=0|i[e+8>>2]))>0){o=0|i[e+12>>2],n=0;do{t=(0|i[o+(n<<3)>>2])+t|0,n=n+1|0}while((0|n)<(0|s))}o=0|i[(n=A)>>2],(0|(n=0|i[n+4>>2]))<(0|(s=((0|t)<0)<<31>>31))|(0|n)==(0|s)&o>>>0<t>>>0?(i[(n=A)>>2]=t,i[n+4>>2]=s,n=s):t=o,l=0|Pt(0|t,0|n,12,0),c=0|S(),i[(n=A)>>2]=l,i[n+4>>2]=c,i[(n=r)>>2]=l,i[n+4>>2]=c,n=0}return N=a,0|(c=n)},_maxPolygonToCellsSizeExperimental:function(e,t,n,o){t|=0,n|=0,o|=0;var s,A,c=0,f=0,d=0,h=0,p=0,m=0,g=0,b=0;if(A=N,N=N+48|0,p=A+32|0,h=A+40|0,s=A,!(0|i[(e|=0)>>2]))return i[(m=o)>>2]=0,i[m+4>>2]=0,N=A,0|(m=0);_e(p,0,0,0),c=0|i[(d=p)>>2],d=0|i[d+4>>2];do{if(t>>>0>15)i[(m=s)>>2]=0,i[m+4>>2]=0,i[s+8>>2]=4,i[s+12>>2]=-1,n=s+29|0,i[(m=s+16|0)>>2]=0,i[m+4>>2]=0,i[m+8>>2]=0,r[m+12|0]=0,r[n|0]=0|r[h|0],r[n+1|0]=0|r[h+1|0],r[n+2|0]=0|r[h+2|0],n=4,m=9;else{if(0|(n=0|ot(n))){i[(p=s)>>2]=0,i[p+4>>2]=0,i[s+8>>2]=n,i[s+12>>2]=-1,m=s+29|0,i[(p=s+16|0)>>2]=0,i[p+4>>2]=0,i[p+8>>2]=0,r[p+12|0]=0,r[m|0]=0|r[h|0],r[m+1|0]=0|r[h+1|0],r[m+2|0]=0|r[h+2|0],m=9;break}if(!(n=0|Ct(1+(0|i[e+8>>2])|0,32))){i[(m=s)>>2]=0,i[m+4>>2]=0,i[s+8>>2]=13,i[s+12>>2]=-1,n=s+29|0,i[(m=s+16|0)>>2]=0,i[m+4>>2]=0,i[m+8>>2]=0,r[m+12|0]=0,r[n|0]=0|r[h|0],r[n+1|0]=0|r[h+1|0],r[n+2|0]=0|r[h+2|0],n=13,m=9;break}st(e,n),i[(b=s)>>2]=c,i[b+4>>2]=d,i[(d=s+8|0)>>2]=0,i[s+12>>2]=t,i[s+20>>2]=e,i[s+24>>2]=n,r[s+28|0]=0,r[(c=s+29|0)|0]=0|r[h|0],r[c+1|0]=0|r[h+1|0],r[c+2|0]=0|r[h+2|0],i[s+16>>2]=3,g=+Y(n),g*=+J(n),f=+l(+ +a[n>>3]),f=g/+u(+ +Ht(+f,+ +l(+ +a[n+8>>3])))*6371.007180918475*6371.007180918475,n=0|i[(c=s+12|0)>>2];e:do{if((0|n)>0)do{if(Ke(n+-1|0,p),!(f/+a[p>>3]>10))break e;n=(b=0|i[c>>2])+-1|0,i[c>>2]=n}while((0|b)>1)}while(0);if(nt(s),i[(c=o)>>2]=0,i[c+4>>2]=0,!(!(0|(n=0|i[(c=s)>>2]))&!(0|(c=0|i[c+4>>2]))))do{Te(n,c,t,p),h=p,h=0|Pt(0|i[(e=o)>>2],0|i[e+4>>2],0|i[h>>2],0|i[h+4>>2]),e=0|S(),i[(b=o)>>2]=h,i[b+4>>2]=e,nt(s),n=0|i[(b=s)>>2],c=0|i[b+4>>2]}while(!(!(0|n)&!(0|c)));n=0|i[d>>2]}}while(0);return N=A,0|(b=n)},_memcpy:Qt,_memmove:Kt,_memset:Wt,_originToDirectedEdges:se,_pentagonCount:function(){return 12},_polygonToCells:function(e,t,n,r){e|=0,t|=0,r|=0;var a,o,s,A,l=0,c=0,u=0,f=0,d=0,h=0,p=0,m=0,g=0,b=0,v=0,y=0,x=0,_=0,w=0,T=0,M=0,E=0,C=0,I=0,R=0,P=0,k=0,L=0,F=0,D=0,U=0;if(A=N,N=N+112|0,a=A+80|0,d=A+72|0,o=A,s=A+56|0,0|(l=0|ot(n|=0)))return N=A,0|(U=l);if(!(U=0|Mt(32+(i[(h=e+8|0)>>2]<<5)|0)))return N=A,0|(U=13);if(st(e,U),!(l=0|ot(n))){if(D=0|i[(F=e)+4>>2],i[(l=d)>>2]=i[F>>2],i[l+4>>2]=D,at(d,a),l=0|ne(a,t,o))F=0,D=0;else{if(l=0|i[d>>2],(0|(c=0|i[h>>2]))>0){u=0|i[e+12>>2],n=0;do{l=(0|i[u+(n<<3)>>2])+l|0,n=n+1|0}while((0|n)!=(0|c));n=l}else n=l;c=0|i[(l=o)>>2],(0|(l=0|i[l+4>>2]))<(0|(u=((0|n)<0)<<31>>31))|(0|l)==(0|u)&c>>>0<n>>>0?(i[(l=o)>>2]=n,i[l+4>>2]=u,l=u):n=c,F=0|Pt(0|n,0|l,12,0),D=0|S(),i[(l=o)>>2]=F,i[l+4>>2]=D,l=0}if(!l){if(!(n=0|Ct(F,8)))return Et(U),N=A,0|(U=13);if(!(f=0|Ct(F,8)))return Et(U),Et(n),N=A,0|(U=13);i[(k=a)>>2]=0,i[k+4>>2]=0,L=0|i[(k=e)+4>>2],i[(l=d)>>2]=i[k>>2],i[l+4>>2]=L,l=0|j(d,F,D,t,a,n,f);e:do{if(l)Et(n),Et(f),Et(U);else{t:do{if((0|i[h>>2])>0){for(u=e+12|0,c=0;l=0|j((0|i[u>>2])+(c<<3)|0,F,D,t,a,n,f),c=c+1|0,!(0|l);)if((0|c)>=(0|i[h>>2]))break t;Et(n),Et(f),Et(U);break e}}while(0);(0|D)>0|!(0|D)&F>>>0>0&&Wt(0|f,0,F<<3),k=0|i[(L=a)+4>>2];t:do{if((0|k)>0|!(0|k)&(0|i[L>>2])>>>0>0){I=n,R=f,P=n,k=f,L=n,l=n,M=n,E=f,C=f,n=f;n:for(;;){for(x=0,_=0,w=0,T=0,c=0,u=0;;){d=(f=o)+56|0;do{i[f>>2]=0,f=f+4|0}while((0|f)<(0|d));if(0|B(h=0|i[(t=I+(x<<3)|0)>>2],t=0|i[t+4>>2],1,o,0)){d=(f=o)+56|0;do{i[f>>2]=0,f=f+4|0}while((0|f)<(0|d));0|(f=0|Ct(7,4))&&(O(h,t,1,o,f,7,0,0),Et(f))}for(y=0;;){b=0|i[(v=o+(y<<3)|0)>>2],v=0|i[v+4>>2];r:do{if(!(0|b)&!(0|v))f=c,d=u;else{if(p=0|Dt(0|b,0|v,0|F,0|D),h=0|S(),!(!(0|(d=0|i[(t=f=r+(p<<3)|0)>>2]))&!(0|(t=0|i[t+4>>2])))){m=0,g=0;do{if((0|m)>(0|D)|(0|m)==(0|D)&g>>>0>F>>>0)break n;if((0|d)==(0|b)&(0|t)==(0|v)){f=c,d=u;break r}p=0|Ft(0|(f=0|Pt(0|p,0|h,1,0)),0|S(),0|F,0|D),h=0|S(),g=0|Pt(0|g,0|m,1,0),m=0|S(),d=0|i[(t=f=r+(p<<3)|0)>>2],t=0|i[t+4>>2]}while(!(!(0|d)&!(0|t)))}if(!(0|b)&!(0|v)){f=c,d=u;break}De(b,v,s),0|At(e,U,s)&&(g=0|Pt(0|c,0|u,1,0),u=0|S(),i[(m=f)>>2]=b,i[m+4>>2]=v,i[(c=R+(c<<3)|0)>>2]=b,i[c+4>>2]=v,c=g),f=c,d=u}}while(0);if((y=y+1|0)>>>0>=7)break;c=f,u=d}if(x=0|Pt(0|x,0|_,1,0),_=0|S(),w=0|Pt(0|w,0|T,1,0),T=0|S(),c=0|i[(u=a)>>2],!((0|T)<(0|(u=0|i[u+4>>2]))|(0|T)==(0|u)&w>>>0<c>>>0))break;c=f,u=d}if((0|u)>0|!(0|u)&c>>>0>0){c=0,u=0;do{i[(T=I+(c<<3)|0)>>2]=0,i[T+4>>2]=0,c=0|Pt(0|c,0|u,1,0),u=0|S(),w=0|i[(T=a)+4>>2]}while((0|u)<(0|w)|((0|u)==(0|w)?c>>>0<(0|i[T>>2])>>>0:0))}if(i[(T=a)>>2]=f,i[T+4>>2]=d,!((0|d)>0|!(0|d)&f>>>0>0))break t;y=n,x=C,_=L,w=E,T=R,n=M,C=l,E=P,M=y,l=x,L=k,k=_,P=w,R=I,I=T}Et(P),Et(k),Et(U),l=1;break e}l=f}while(0);Et(U),Et(n),Et(l),l=0}}while(0);return N=A,0|(U=l)}}return Et(U),N=A,0|(U=l)},_polygonToCellsExperimental:function(e,t,n,r,a,o){r|=0,a|=0,o|=0;var s,A,l,c=0,u=0,f=0,d=0,h=0,p=0,m=0,g=0;l=N,N=N+160|0,u=l+64|0,h=l+112|0,g=l,tt(d=l+80|0,e|=0,t|=0,n|=0),je(u,0|i[(f=d)>>2],0|i[f+4>>2],t),s=0|i[(f=u)>>2],f=0|i[f+4>>2],c=0|i[d+8>>2],i[(p=h+4|0)>>2]=i[d>>2],i[p+4>>2]=i[d+4>>2],i[p+8>>2]=i[d+8>>2],i[p+12>>2]=i[d+12>>2],i[p+16>>2]=i[d+16>>2],i[p+20>>2]=i[d+20>>2],i[p+24>>2]=i[d+24>>2],i[p+28>>2]=i[d+28>>2],i[(p=g)>>2]=s,i[p+4>>2]=f,i[(p=g+8|0)>>2]=c,t=h,n=(e=g+12|0)+36|0;do{i[e>>2]=i[t>>2],e=e+4|0,t=t+4|0}while((0|e)<(0|n));if(i[(h=g+48|0)>>2]=i[u>>2],i[h+4>>2]=i[u+4>>2],i[h+8>>2]=i[u+8>>2],i[h+12>>2]=i[u+12>>2],!(0|s)&!(0|f))return N=l,0|(g=c);n=g+16|0,A=g+24|0,d=g+28|0,c=0,u=0,t=s,e=f;do{if(!((0|c)<(0|a)|(0|c)==(0|a)&u>>>0<r>>>0)){m=4;break}if(f=u,u=0|Pt(0|u,0|c,1,0),c=0|S(),i[(f=o+(f<<3)|0)>>2]=t,i[f+4>>2]=e,Ge(h),!(0|(t=0|i[(e=h)>>2]))&!(0|(e=0|i[e+4>>2]))){if(nt(n),!(0|(e=0|i[(t=n)>>2]))&!(0|(t=0|i[t+4>>2]))){m=10;break}ze(e,t,0|i[d>>2],h),t=0|i[(e=h)>>2],e=0|i[e+4>>2]}i[(f=g)>>2]=t,i[f+4>>2]=e}while(!(!(0|t)&!(0|e)));return 4==(0|m)?(0|(t=0|i[(e=g+40|0)>>2])&&Et(t),i[(m=g+16|0)>>2]=0,i[m+4>>2]=0,i[A>>2]=0,i[g+36>>2]=0,i[d>>2]=-1,i[g+32>>2]=0,i[e>>2]=0,ze(0,0,0,h),i[g>>2]=0,i[g+4>>2]=0,i[p>>2]=0,N=l,0|(g=14)):(10==(0|m)&&(i[g>>2]=0,i[g+4>>2]=0,i[p>>2]=i[A>>2]),g=0|i[p>>2],N=l,0|g)},_readInt64AsDoubleFromPointer:function(e){return+(+((0|i[(e|=0)>>2])>>>0)+4294967296*+(0|i[e+4>>2]))},_res0CellCount:function(){return 122},_reverseDirectedEdge:le,_round:$t,_sbrk:Jt,_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,r,a,o,s){e|=0,r|=0,a|=0,o|=0;var A,l=0,c=0,u=0,f=0,d=0,h=0,p=0,m=0;if(A=N,N=N+16|0,m=A,!((0|(n|=0))>0|!(0|n)&(t|=0)>>>0>0))return N=A,0|(m=0);if((0|(s|=0))>=16)return N=A,0|(m=12);h=0,p=0,d=0,l=0;e:for(;;){if(f=0|Vt(0|(c=0|i[(u=e+(h<<3)|0)>>2]),0|(u=0|i[u+4>>2]),52),S(),(15&f)>(0|s)){l=12,c=11;break}if(je(m,c,u,s),!(0|(u=0|i[(f=m)>>2]))&!(0|(f=0|i[f+4>>2])))c=d;else{c=d;do{if(!((0|l)<(0|o)|(0|l)==(0|o)&c>>>0<a>>>0)){c=10;break e}i[(d=r+(c<<3)|0)>>2]=u,i[d+4>>2]=f,c=0|Pt(0|c,0|l,1,0),l=0|S(),Ge(m),u=0|i[(d=m)>>2],f=0|i[d+4>>2]}while(!(!(0|u)&!(0|f)))}if(h=0|Pt(0|h,0|p,1,0),!((0|(p=0|S()))<(0|n)|(0|p)==(0|n)&h>>>0<t>>>0)){l=0,c=11;break}d=c}return 10==(0|c)?(N=A,0|(m=14)):11==(0|c)?(N=A,0|l):0},_uncompactCellsSize:function(e,t,n,r,a){e|=0,t|=0,n|=0,r|=0,a|=0;var o,s,A=0,l=0,c=0,u=0,f=0,d=0;s=N,N=N+16|0,o=s;e:do{if((0|n)>0|!(0|n)&t>>>0>0){for(f=0,l=0,A=0,d=0;;){if(!(!(0|(c=0|i[(u=e+(f<<3)|0)>>2]))&!(0|(u=0|i[u+4>>2]))||(u=!(0|Te(c,u,r,o)),l=0|Pt(0|i[(c=o)>>2],0|i[c+4>>2],0|l,0|A),A=0|S(),u))){A=12;break}if(f=0|Pt(0|f,0|d,1,0),!((0|(d=0|S()))<(0|n)|(0|d)==(0|n)&f>>>0<t>>>0))break e}return N=s,0|A}l=0,A=0}while(0);return i[a>>2]=l,i[a+4>>2]=A,N=s,0|(a=0)},_vertexToLatLng:function(e,t,n){n|=0;var r,a,o,s,A=0,l=0;return s=N,N=N+192|0,a=s,o=s+168|0,A=0|Vt(0|(e|=0),0|(t|=0),56),S(),A&=7,0|(r=0|Fe(e,l=-2130706433&t|134217728,o))?(N=s,0|(l=r)):(t=0|Vt(0|e,0|t,52),S(),t&=15,0|Se(e,l)?de(o,t,A,1,a):ge(o,t,A,1,a),l=a+8|0,i[n>>2]=i[l>>2],i[n+4>>2]=i[l+4>>2],i[n+8>>2]=i[l+8>>2],i[n+12>>2]=i[l+12>>2],N=s,0|(l=0))},dynCall_iii:function(e,t,n){return t|=0,n|=0,0|Yt[3&(e|=0)](0|t,0|n)},establishStackSpace:function(e,t){N=e|=0},stackAlloc:function(e){var t;return t=N,N=(N=N+(e|=0)|0)+15&-16,0|t},stackRestore:function(e){N=e|=0},stackSave:function(){return 0|N}}}({Math:Math,Int8Array:Int8Array,Int32Array:Int32Array,Uint8Array:Uint8Array,Float32Array:Float32Array,Float64Array:Float64Array},{a:le,b:function(e){l=e},c:function(){return l},d:function(e,t,n,r){le("Assertion failed: "+x(e)+", at: "+[t?x(t):"unknown filename",n,r?x(r):"unknown function"])},e:function(e){return n.___errno_location&&(g[n.___errno_location()>>2]=e),e},f:K,g:function(e,t,n){p.set(p.subarray(t,t+n),e)},h:function(e){var t=K(),n=16777216,r=2130706432;if(e>r)return!1;for(var i=Math.max(t,16777216);i<e;)i=i<=536870912?_(2*i,n):Math.min(_((3*i+2147483648)/4,n),r);return!!W(i)},i:function(e){le("OOM")},j:H,k:q,l:W,m:Q,n:function(){var e=Q();return n.extraStackTrace&&(e+="\n"+n.extraStackTrace()),q(e)},o:28400,p:28384},d);n.___divdi3=Y.___divdi3,n.___muldi3=Y.___muldi3,n.___remdi3=Y.___remdi3,n.___uremdi3=Y.___uremdi3,n._areNeighborCells=Y._areNeighborCells,n._bitshift64Ashr=Y._bitshift64Ashr,n._bitshift64Lshr=Y._bitshift64Lshr,n._bitshift64Shl=Y._bitshift64Shl,n._calloc=Y._calloc,n._cellAreaKm2=Y._cellAreaKm2,n._cellAreaM2=Y._cellAreaM2,n._cellAreaRads2=Y._cellAreaRads2,n._cellToBoundary=Y._cellToBoundary,n._cellToCenterChild=Y._cellToCenterChild,n._cellToChildPos=Y._cellToChildPos,n._cellToChildren=Y._cellToChildren,n._cellToChildrenSize=Y._cellToChildrenSize,n._cellToLatLng=Y._cellToLatLng,n._cellToLocalIj=Y._cellToLocalIj,n._cellToParent=Y._cellToParent,n._cellToVertex=Y._cellToVertex,n._cellToVertexes=Y._cellToVertexes,n._cellsToDirectedEdge=Y._cellsToDirectedEdge,n._cellsToLinkedMultiPolygon=Y._cellsToLinkedMultiPolygon,n._childPosToCell=Y._childPosToCell,n._compactCells=Y._compactCells,n._constructCell=Y._constructCell,n._destroyLinkedMultiPolygon=Y._destroyLinkedMultiPolygon,n._directedEdgeToBoundary=Y._directedEdgeToBoundary,n._directedEdgeToCells=Y._directedEdgeToCells,n._edgeLengthKm=Y._edgeLengthKm,n._edgeLengthM=Y._edgeLengthM,n._edgeLengthRads=Y._edgeLengthRads;var X=n._emscripten_replace_memory=Y._emscripten_replace_memory;n._free=Y._free,n._getBaseCellNumber=Y._getBaseCellNumber,n._getDirectedEdgeDestination=Y._getDirectedEdgeDestination,n._getDirectedEdgeOrigin=Y._getDirectedEdgeOrigin,n._getHexagonAreaAvgKm2=Y._getHexagonAreaAvgKm2,n._getHexagonAreaAvgM2=Y._getHexagonAreaAvgM2,n._getHexagonEdgeLengthAvgKm=Y._getHexagonEdgeLengthAvgKm,n._getHexagonEdgeLengthAvgM=Y._getHexagonEdgeLengthAvgM,n._getIcosahedronFaces=Y._getIcosahedronFaces,n._getIndexDigit=Y._getIndexDigit,n._getNumCells=Y._getNumCells,n._getPentagons=Y._getPentagons,n._getRes0Cells=Y._getRes0Cells,n._getResolution=Y._getResolution,n._greatCircleDistanceKm=Y._greatCircleDistanceKm,n._greatCircleDistanceM=Y._greatCircleDistanceM,n._greatCircleDistanceRads=Y._greatCircleDistanceRads,n._gridDisk=Y._gridDisk,n._gridDiskDistances=Y._gridDiskDistances,n._gridDistance=Y._gridDistance,n._gridPathCells=Y._gridPathCells,n._gridPathCellsSize=Y._gridPathCellsSize,n._gridRing=Y._gridRing,n._gridRingUnsafe=Y._gridRingUnsafe,n._i64Add=Y._i64Add,n._i64Subtract=Y._i64Subtract,n._isPentagon=Y._isPentagon,n._isResClassIII=Y._isResClassIII,n._isValidCell=Y._isValidCell,n._isValidDirectedEdge=Y._isValidDirectedEdge,n._isValidIndex=Y._isValidIndex,n._isValidVertex=Y._isValidVertex,n._latLngToCell=Y._latLngToCell,n._llvm_ctlz_i64=Y._llvm_ctlz_i64,n._llvm_maxnum_f64=Y._llvm_maxnum_f64,n._llvm_minnum_f64=Y._llvm_minnum_f64,n._llvm_round_f64=Y._llvm_round_f64,n._localIjToCell=Y._localIjToCell,n._malloc=Y._malloc,n._maxFaceCount=Y._maxFaceCount,n._maxGridDiskSize=Y._maxGridDiskSize,n._maxPolygonToCellsSize=Y._maxPolygonToCellsSize,n._maxPolygonToCellsSizeExperimental=Y._maxPolygonToCellsSizeExperimental,n._memcpy=Y._memcpy,n._memmove=Y._memmove,n._memset=Y._memset,n._originToDirectedEdges=Y._originToDirectedEdges,n._pentagonCount=Y._pentagonCount,n._polygonToCells=Y._polygonToCells,n._polygonToCellsExperimental=Y._polygonToCellsExperimental,n._readInt64AsDoubleFromPointer=Y._readInt64AsDoubleFromPointer,n._res0CellCount=Y._res0CellCount,n._reverseDirectedEdge=Y._reverseDirectedEdge,n._round=Y._round,n._sbrk=Y._sbrk,n._sizeOfCellBoundary=Y._sizeOfCellBoundary,n._sizeOfCoordIJ=Y._sizeOfCoordIJ,n._sizeOfGeoLoop=Y._sizeOfGeoLoop,n._sizeOfGeoPolygon=Y._sizeOfGeoPolygon,n._sizeOfH3Index=Y._sizeOfH3Index,n._sizeOfLatLng=Y._sizeOfLatLng,n._sizeOfLinkedGeoPolygon=Y._sizeOfLinkedGeoPolygon,n._uncompactCells=Y._uncompactCells,n._uncompactCellsSize=Y._uncompactCellsSize,n._vertexToLatLng=Y._vertexToLatLng,n.establishStackSpace=Y.establishStackSpace;var Z,ee,te=n.stackAlloc=Y.stackAlloc,ne=n.stackRestore=Y.stackRestore,re=n.stackSave=Y.stackSave;if(n.dynCall_iii=Y.dynCall_iii,n.asm=Y,n.cwrap=function(e,t,n,r){var i=(n=n||[]).every(function(e){return"number"===e});return"string"!==t&&i&&!r?u(e):function(){return f(e,t,n,arguments)}},n.setValue=function(e,t,n,r){switch("*"===(n=n||"i8").charAt(n.length-1)&&(n="i32"),n){case"i1":case"i8":h[e|0]=t;break;case"i16":m[e>>1]=t;break;case"i32":g[e>>2]=t;break;case"i64":V=[t>>>0,(U=t,+N(U)>=1?U>0?(0|B(+L(U/4294967296),4294967295))>>>0:~~+k((U-+(~~U>>>0))/4294967296)>>>0:0)],g[e>>2]=V[0],g[e+4>>2]=V[1];break;case"float":b[e>>2]=t;break;case"double":v[e>>3]=t;break;default:le("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 m[e>>1];case"i32":case"i64":return g[e>>2];case"float":return b[e>>2];case"double":return v[e>>3];default:le("invalid type for getValue: "+t)}return null},j){G(j)||(Z=j,j=n.locateFile?n.locateFile(Z,o):o+Z),O++,n.monitorRunDependencies&&n.monitorRunDependencies(O);var ie=function(e){e.byteLength&&(e=new Uint8Array(e)),p.set(e,8),n.memoryInitializerRequest&&delete n.memoryInitializerRequest.response,function(){if(O--,n.monitorRunDependencies&&n.monitorRunDependencies(O),0==O&&(null!==F&&(clearInterval(F),F=null),D)){var e=D;D=null,e()}}()},ae=function(){i(j,ie,function(){throw"could not load memory initializer "+j})},oe=J(j);if(oe)ie(oe.buffer);else if(n.memoryInitializerRequest){var se=function(){var e=n.memoryInitializerRequest,t=e.response;if(200!==e.status&&0!==e.status){var r=J(n.memoryInitializerRequestURL);if(!r)return console.warn("a problem seems to have happened with Module.memoryInitializerRequest, status: "+e.status+", retrying "+j),void ae();t=r.buffer}ie(t)};n.memoryInitializerRequest.response?setTimeout(se,0):n.memoryInitializerRequest.addEventListener("load",se)}else ae()}function Ae(e){function t(){ee||(ee=!0,c||(S(E),S(C),n.onRuntimeInitialized&&n.onRuntimeInitialized(),function(){if(n.postRun)for("function"==typeof n.postRun&&(n.postRun=[n.postRun]);n.postRun.length;)P(n.postRun.shift());S(I)}()))}e=e||a,O>0||(!function(){if(n.preRun)for("function"==typeof n.preRun&&(n.preRun=[n.preRun]);n.preRun.length;)R(n.preRun.shift());S(M)}(),O>0||(n.setStatus?(n.setStatus("Running..."),setTimeout(function(){setTimeout(function(){n.setStatus("")},1),t()},1)):t()))}function le(e){throw n.onAbort&&n.onAbort(e),s(e+=""),A(e),c=!0,"abort("+e+"). Build with -s ASSERTIONS=1 for more info."}if(D=function e(){ee||Ae(),ee||(D=e)},n.run=Ae,n.abort=le,n.preInit)for("function"==typeof n.preInit&&(n.preInit=[n.preInit]);n.preInit.length>0;)n.preInit.pop()();return Ae(),e}("object"==typeof Lr?Lr:{}),Br="number",Or={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"},Fr={1e3:"Unknown unit",1001:"Array length out of bounds",1002:"Got unexpected null value for H3 index"};function Dr(e,t,n){var r=n&&"value"in n,i=new Error((e[t]||"Unknown error")+" (code: "+t+(r?", value: "+n.value:"")+")");return i.code=t,i}function Ur(e,t){return Dr(Or,e,2===arguments.length?{value:t}:{})}function Vr(e,t){return Dr(Fr,e,2===arguments.length?{value:t}:{})}function jr(e){if(0!==e)throw Ur(e)}var zr={};[["sizeOfH3Index",Br],["sizeOfLatLng",Br],["sizeOfCellBoundary",Br],["sizeOfGeoLoop",Br],["sizeOfGeoPolygon",Br],["sizeOfLinkedGeoPolygon",Br],["sizeOfCoordIJ",Br],["readInt64AsDoubleFromPointer",Br],["isValidCell",Br,[Br,Br]],["isValidIndex",Br,[Br,Br]],["latLngToCell",Br,[Br,Br,Br,Br]],["cellToLatLng",Br,[Br,Br,Br]],["cellToBoundary",Br,[Br,Br,Br]],["maxGridDiskSize",Br,[Br,Br]],["gridDisk",Br,[Br,Br,Br,Br]],["gridDiskDistances",Br,[Br,Br,Br,Br,Br]],["gridRing",Br,[Br,Br,Br,Br]],["gridRingUnsafe",Br,[Br,Br,Br,Br]],["maxPolygonToCellsSize",Br,[Br,Br,Br,Br]],["polygonToCells",Br,[Br,Br,Br,Br]],["maxPolygonToCellsSizeExperimental",Br,[Br,Br,Br,Br]],["polygonToCellsExperimental",Br,[Br,Br,Br,Br,Br,Br]],["cellsToLinkedMultiPolygon",Br,[Br,Br,Br]],["destroyLinkedMultiPolygon",null,[Br]],["compactCells",Br,[Br,Br,Br,Br]],["uncompactCells",Br,[Br,Br,Br,Br,Br,Br]],["uncompactCellsSize",Br,[Br,Br,Br,Br,Br]],["isPentagon",Br,[Br,Br]],["isResClassIII",Br,[Br,Br]],["getBaseCellNumber",Br,[Br,Br]],["getResolution",Br,[Br,Br]],["getIndexDigit",Br,[Br,Br,Br]],["constructCell",Br,[Br,Br,Br,Br]],["maxFaceCount",Br,[Br,Br,Br]],["getIcosahedronFaces",Br,[Br,Br,Br]],["cellToParent",Br,[Br,Br,Br,Br]],["cellToChildren",Br,[Br,Br,Br,Br]],["cellToCenterChild",Br,[Br,Br,Br,Br]],["cellToChildrenSize",Br,[Br,Br,Br,Br]],["cellToChildPos",Br,[Br,Br,Br,Br]],["childPosToCell",Br,[Br,Br,Br,Br,Br,Br]],["areNeighborCells",Br,[Br,Br,Br,Br,Br]],["cellsToDirectedEdge",Br,[Br,Br,Br,Br,Br]],["getDirectedEdgeOrigin",Br,[Br,Br,Br]],["getDirectedEdgeDestination",Br,[Br,Br,Br]],["isValidDirectedEdge",Br,[Br,Br]],["directedEdgeToCells",Br,[Br,Br,Br]],["originToDirectedEdges",Br,[Br,Br,Br]],["directedEdgeToBoundary",Br,[Br,Br,Br]],["reverseDirectedEdge",Br,[Br,Br,Br]],["gridDistance",Br,[Br,Br,Br,Br,Br]],["gridPathCells",Br,[Br,Br,Br,Br,Br]],["gridPathCellsSize",Br,[Br,Br,Br,Br,Br]],["cellToLocalIj",Br,[Br,Br,Br,Br,Br,Br]],["localIjToCell",Br,[Br,Br,Br,Br,Br]],["getHexagonAreaAvgM2",Br,[Br,Br]],["getHexagonAreaAvgKm2",Br,[Br,Br]],["getHexagonEdgeLengthAvgM",Br,[Br,Br]],["getHexagonEdgeLengthAvgKm",Br,[Br,Br]],["greatCircleDistanceM",Br,[Br,Br]],["greatCircleDistanceKm",Br,[Br,Br]],["greatCircleDistanceRads",Br,[Br,Br]],["cellAreaM2",Br,[Br,Br,Br]],["cellAreaKm2",Br,[Br,Br,Br]],["cellAreaRads2",Br,[Br,Br,Br]],["edgeLengthM",Br,[Br,Br,Br]],["edgeLengthKm",Br,[Br,Br,Br]],["edgeLengthRads",Br,[Br,Br,Br]],["getNumCells",Br,[Br,Br]],["getRes0Cells",Br,[Br]],["res0CellCount",Br],["getPentagons",Br,[Br,Br]],["pentagonCount",Br],["cellToVertex",Br,[Br,Br,Br,Br]],["cellToVertexes",Br,[Br,Br,Br]],["vertexToLatLng",Br,[Br,Br,Br]],["isValidVertex",Br,[Br,Br]]].forEach(function(e){zr[e[0]]=Lr.cwrap.apply(Lr,e)});var Gr=16,Hr=zr.sizeOfH3Index(),qr=zr.sizeOfLatLng(),Qr=zr.sizeOfCellBoundary(),Kr=(zr.sizeOfGeoPolygon(),zr.sizeOfGeoLoop(),zr.sizeOfLinkedGeoPolygon()),Wr=(zr.sizeOfCoordIJ(),"m"),$r="km";Math.pow(2,32),Math.pow(2,31);var Jr=/[^0-9a-fA-F]/;function Yr(e){if(Array.isArray(e)&&2===e.length&&Number.isInteger(e[0])&&Number.isInteger(e[1]))return e;if("string"!=typeof e||Jr.test(e))return[0,0];var t=parseInt(e.substring(0,e.length-8),Gr);return[parseInt(e.substring(e.length-8),Gr),t]}function Xr(e){if(e>=0)return e.toString(Gr);var t=Zr(8,(e&=2147483647).toString(Gr));return t=(parseInt(t[0],Gr)+8).toString(Gr)+t.substring(1)}function Zr(e,t){for(var n=e-t.length,r="",i=0;i<n;i++)r+="0";return r+=t}function ei(e,t){void 0===t&&(t=0);var n=Lr.getValue(e+Hr*t,"i32"),r=Lr.getValue(e+Hr*t+4,"i32");return r?function(e,t){return Xr(t)+Zr(8,Xr(e))}(n,r):null}function ti(e,t,n){Lr.HEAPU32.set(Yr(e),t/4+2*n)}function ni(e){return 180*Lr.getValue(e,"double")/Math.PI}function ri(e){return[ni(e),ni(e+8)]}function ii(e){return[ni(e+8),ni(e)]}function ai(e){var t=Yr(e),n=t[0],r=t[1];return Boolean(zr.isPentagon(n,r))}function oi(e){var t=Yr(e),n=t[0],r=t[1];return zr.isValidCell(n,r)?zr.getResolution(n,r):-1}function si(e,t,n){var r=Lr._malloc(qr);Lr.HEAPF64.set([e,t].map(di),r/8);var i=Lr._malloc(Hr);try{return jr(zr.latLngToCell(r,n,i)),function(e){if(!e)throw Vr(1002);return e}(ei(i))}finally{Lr._free(i),Lr._free(r)}}function Ai(e){var t=Lr._malloc(qr),n=Yr(e),r=n[0],i=n[1];try{return jr(zr.cellToLatLng(r,i,t)),ri(t)}finally{Lr._free(t)}}function li(e,t){var n=Lr._malloc(Qr),r=Yr(e),i=r[0],a=r[1];try{return jr(zr.cellToBoundary(i,a,n)),function(e,t,n){for(var r=Lr.getValue(e,"i32"),i=e+8,a=[],o=t?ii:ri,s=0;s<2*r;s+=2)a.push(o(i+8*s));return n&&a.push(a[0]),a}(n,t,t)}finally{Lr._free(n)}}function ci(e,t){if(!e||!e.length)return[];var n=e.length,r=Lr._calloc(n,Hr);!function(e,t){for(var n=t.length,r=0;r<n;r++)ti(t[r],e,r)}(r,e);var i=Lr._calloc(Kr);try{return jr(zr.cellsToLinkedMultiPolygon(r,n,i)),function(e,t){for(var n,r,i,a,o=[],s=t?ii:ri;e;){for(o.push(n=[]),r=Lr.getValue(e,"i8*");r;){for(n.push(i=[]),a=Lr.getValue(r,"i8*");a;)i.push(s(a)),a=Lr.getValue(a+16,"i8*");t&&i.push(i[0]),r=Lr.getValue(r+8,"i8*")}e=Lr.getValue(e+8,"i8*")}return o}(i,t)}finally{zr.destroyLinkedMultiPolygon(i),Lr._free(i),Lr._free(r)}}function ui(e,t){var n,r=Yr(e),i=r[0],a=r[1],o=Yr(t),s=o[0],A=o[1],l=Lr._malloc(8);try{return jr(zr.gridDistance(i,a,s,A,l)),n=l,zr.readInt64AsDoubleFromPointer(n)}finally{Lr._free(l)}}function fi(e,t){!function(e){if("number"!=typeof e||e<0||e>15||Math.floor(e)!==e)throw Ur(4,e)}(e);var n,r,i=Lr._malloc(8);try{switch(t){case Wr:jr(zr.getHexagonEdgeLengthAvgM(e,i));break;case $r:jr(zr.getHexagonEdgeLengthAvgKm(e,i));break;default:throw Vr(1e3,t)}return n=i,void 0===r&&(r=0),Lr.getValue(n+8*r,"double")}finally{Lr._free(i)}}function di(e){return e*Math.PI/180}function hi(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 pi(e,t,n){const r=e(t,n),[i,a]=Ai(r);return[a,i]}function mi(e,t=1){const r=li(e,!0);return 1!==t?function(e,t,r){const[i,a]=Ai(e),o=t.length;hi(t,a);const s=t[0]===t[o-1]?o-1:o;for(let A=0;A<s;A++)t[A][0]=n.lerp$2(a,t[A][0],r),t[A][1]=n.lerp$2(i,t[A][1],r)}(e,r,t):hi(r),r}function gi(e){const t=new Float64Array(2*e.length);let n=0;for(const r of e)t[n++]=r[0],t[n++]=r[1];return t}var bi=class extends st{indexToBounds(){const{data:e,getPentagon:t}=this.props;return{data:e,_normalize:!1,_windingOrder:"CCW",positionFormat:"XY",getPolygon:(e,n)=>{const r=t(e,n);return gi(Pr("string"==typeof r?BigInt(`0x${r}`):r,{closedRing:!0,segments:"auto"}))}}}};function vi(e){return"string"==typeof e?e.charAt(0).toLowerCase()+e.slice(1):e}function yi(e){if(Array.isArray(e))return e.map(e=>yi(e));if(e&&"object"==typeof e){const t={};for(const[n,r]of Object.entries(e))t[vi(n)]=yi(r);return t}return e}bi.layerName="A5Layer",bi.defaultProps={getPentagon:{type:"accessor",value:e=>e.pentagon}};var xi=new RegExp("^[: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][: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\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$");var _i=function(e){const t=xi.exec(e);return!(null==t)};var wi=["hasOwnProperty","toString","valueOf","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"],Ti=["__proto__","constructor","prototype"],Si={allowBooleanAttributes:!1,unpairedTags:[]};function Mi(e){return" "===e||"\t"===e||"\n"===e||"\r"===e}function Ei(e,t){const n=t;for(;t<e.length;t++)if("?"==e[t]||" "==e[t]){const r=e.substr(n,t-n);if(t>5&&"xml"===r)return Li("InvalidXml","XML declaration allowed only at the start of the document.",Fi(e,t));if("?"==e[t]&&">"==e[t+1]){t++;break}continue}return t}function Ci(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}var Ii='"',Ri="'";function Pi(e,t){let n="",r="",i=!1;for(;t<e.length;t++){if(e[t]===Ii||e[t]===Ri)""===r?r=e[t]:r!==e[t]||(r="");else if(">"===e[t]&&""===r){i=!0;break}n+=e[t]}return""===r&&{value:n,index:t,tagClosed:i}}function Ni(e,t){const n=function(e){const t=[],n=e.length;let r=0;for(;r<n;){const i=r;for(;r<n&&Mi(e[r]);)r++;if(r>=n)break;if("="===e[r]){r=i+1;continue}const a=e.slice(i,r),o=r;for(;r<n&&!Mi(e[r])&&"="!==e[r];)r++;const s=e.slice(o,r);let A,l,c,u=r;for(;u<n&&Mi(e[u]);)u++;u<n&&"="===e[u]&&(A=e.slice(r,u+1),r=u+1);let f=r;for(;f<n&&Mi(e[f]);)f++;if(f<n&&('"'===e[f]||"'"===e[f])){const t=f+1,n=e.indexOf(e[f],t);-1!==n&&(l=e[f],c=e.slice(t,n),r=n+1)}const d={startIndex:i};d[1]=a,d[2]=s,d[3]=A,d[4]=void 0!==l||void 0,d[5]=l,d[6]=c,t.push(d)}return t}(e),r={};for(let i=0;i<n.length;i++){if(0===n[i][1].length)return Li("InvalidAttr","Attribute '"+n[i][2]+"' has no space in starting.",Di(n[i]));if(void 0!==n[i][3]&&void 0===n[i][4])return Li("InvalidAttr","Attribute '"+n[i][2]+"' is without value.",Di(n[i]));if(void 0===n[i][3]&&!t.allowBooleanAttributes)return Li("InvalidAttr","boolean attribute '"+n[i][2]+"' is not allowed.",Di(n[i]));const e=n[i][2];if(!Bi(e))return Li("InvalidAttr","Attribute '"+e+"' is an invalid name.",Di(n[i]));if(Object.prototype.hasOwnProperty.call(r,e))return Li("InvalidAttr","Attribute '"+e+"' is repeated.",Di(n[i]));r[e]=1}return!0}function ki(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 Li(e,t,n){return{err:{code:e,msg:t,line:n.line||n,col:n.col}}}function Bi(e){return _i(e)}function Oi(e){return _i(e)}function Fi(e,t){const n=e.substring(0,t).split(/\r?\n/);return{line:n.length,col:n[n.length-1].length+1}}function Di(e){return e.startIndex+e[1].length}var Ui={cent:"¢",pound:"£",curren:"¤",yen:"¥",euro:"€",dollar:"$",fnof:"ƒ",inr:"₹",af:"؋",birr:"ብር",peso:"₱",rub:"₽",won:"₩",yuan:"¥",cedil:"¸"},Vi={amp:"&",apos:"'",gt:">",lt:"<",quot:'"'},ji={nbsp:" ",copy:"©",reg:"®",trade:"™",mdash:"—",ndash:"–",hellip:"…",laquo:"«",raquo:"»",lsquo:"‘",rsquo:"’",ldquo:"“",rdquo:"”",bull:"•",para:"¶",sect:"§",deg:"°",frac12:"½",frac14:"¼",frac34:"¾"},zi=Object.freeze({ALLOW:"allow",BLOCK:"block",THROW:"throw"}),Gi=new Set("!?\\\\/[]$%{}^&*()<>|+");function Hi(e){if("#"===e[0])throw new Error(`[EntityReplacer] Invalid character '#' in entity name: "${e}"`);for(const t of e)if(Gi.has(t))throw new Error(`[EntityReplacer] Invalid character '${t}' in entity name: "${e}"`);return e}function qi(...e){const t=Object.create(null);for(const n of e)if(n)for(const e of Object.keys(n)){const r=n[e];if("string"==typeof r)t[e]=r;else if(r&&"object"==typeof r&&void 0!==r.val){const n=r.val;"string"==typeof n&&(t[e]=n)}}return t}var Qi="external",Ki="base",Wi="all";var $i=Object.freeze({allow:0,leave:1,remove:2,throw:3}),Ji=new Set([9,10,13]);var Yi=class{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??Qi)&&t!==Qi?t===Wi?new Set([Wi]):t===Ki?new Set([Ki]):Array.isArray(t)?new Set(t):new Set([Qi]):new Set([Qi]),this._numericAllowed=e.numericAllowed??!0,this._baseMap=qi(Vi,e.namedEntities||null),this._externalMap=Object.create(null),this._inputMap=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:$i.allow,nullLevel:$i.remove};const t=1.1===e.xmlVersion?1.1:1,n=$i[e.onNCR]??$i.allow,r=$i[e.nullNCR]??$i.remove;return{xmlVersion:t,onLevel:n,nullLevel:Math.max(r,$i.remove)}}(e.ncr);this._ncrXmlVersion=n.xmlVersion,this._ncrOnLevel=n.onLevel,this._ncrNullLevel=n.nullLevel,this._onExternalEntity="function"==typeof e.onExternalEntity?e.onExternalEntity:null,this._onInputEntity="function"==typeof e.onInputEntity?e.onInputEntity:null}_applyRegistrationHook(e,t,n,r){if(!e)return!0;const i=e(t,n);if(i===zi.BLOCK)return!1;if(i===zi.THROW)throw new Error(`[EntityDecoder] Registration of ${r} entity "&${t};" was rejected by hook`);return!0}setExternalEntities(e){if(e)for(const r of Object.keys(e))Hi(r);if(!this._onExternalEntity)return void(this._externalMap=qi(e));const t=qi(e),n=Object.create(null);for(const[r,i]of Object.entries(t))this._applyRegistrationHook(this._onExternalEntity,r,i,"external")&&(n[r]=i);this._externalMap=n}addExternalEntity(e,t){Hi(e),"string"==typeof t&&-1===t.indexOf("&")&&this._applyRegistrationHook(this._onExternalEntity,e,t,"external")&&(this._externalMap[e]=t)}addInputEntities(e){if(this._totalExpansions=0,this._expandedLength=0,!this._onInputEntity)return void(this._inputMap=qi(e));const t=qi(e),n=Object.create(null);for(const[r,i]of Object.entries(t))this._applyRegistrationHook(this._onInputEntity,r,i,"input")&&(n[r]=i);this._inputMap=n}reset(){return this._inputMap=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;if(-1===e.indexOf("&"))return e;const t=e,n=[],r=e.length;let i=0,a=0;const o=this._maxTotalExpansions>0,s=this._maxExpandedLength>0,A=o||s;for(;a<r;){if(38!==e.charCodeAt(a)){a++;continue}let t=a+1;for(;t<r&&59!==e.charCodeAt(t)&&t-a<=32;)t++;if(t>=r||59!==e.charCodeAt(t)){a++;continue}const l=e.slice(a+1,t);if(0===l.length){a++;continue}let c,u;if(this._removeSet.has(l))c="",void 0===u&&(u=Qi);else{if(this._leaveSet.has(l)){a++;continue}if(35===l.charCodeAt(0)){const e=this._resolveNCR(l);if(void 0===e){a++;continue}c=e,u=Ki}else{const e=this._resolveName(l);c=e?.value,u=e?.tier}}if(void 0!==c){if(a>i&&n.push(e.slice(i,a)),n.push(c),i=t+1,a=i,A&&this._tierCounts(u)){if(o&&(this._totalExpansions++,this._totalExpansions>this._maxTotalExpansions))throw new Error(`[EntityReplacer] Entity expansion count limit exceeded: ${this._totalExpansions} > ${this._maxTotalExpansions}`);if(s){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 a++}i<r&&n.push(e.slice(i));const l=0===n.length?e:n.join("");return this._postCheck(l,t)}_tierCounts(e){return!!this._limitTiers.has(Wi)||this._limitTiers.has(e)}_resolveName(e){return e in this._inputMap?{value:this._inputMap[e],tier:Qi}:e in this._externalMap?{value:this._externalMap[e],tier:Qi}:e in this._baseMap?{value:this._baseMap[e],tier:Ki}:void 0}_classifyNCR(e){return 0===e?this._ncrNullLevel:e>=55296&&e<=57343||1===this._ncrXmlVersion&&e>=1&&e<=31&&!Ji.has(e)?$i.remove:-1}_applyNCRAction(e,t,n){switch(e){case $i.allow:return String.fromCodePoint(n);case $i.remove:return"";case $i.leave:return;case $i.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 r=this._classifyNCR(n);if(!this._numericAllowed&&r<$i.remove)return;const i=-1===r?this._ncrOnLevel:Math.max(this._ncrOnLevel,r);return this._applyNCRAction(i,e,n)}},Xi=e=>wi.includes(e)?"__"+e:e,Zi={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,unicode:!1},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:Xi};function ea(e,t){if("string"!=typeof e)return;const n=e.toLowerCase();if(wi.some(e=>n===e.toLowerCase()))throw new Error(`[SECURITY] Invalid ${t}: "${e}" is a reserved JavaScript keyword that could cause prototype pollution`);if(Ti.some(e=>n===e.toLowerCase()))throw new Error(`[SECURITY] Invalid ${t}: "${e}" is a reserved JavaScript keyword that could cause prototype pollution`)}function ta(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"}:ta(!0)}var na,ra=function(e){const t=Object.assign({},Zi,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:r,name:i}of n)r&&ea(r,i);return null===t.onDangerousProperty&&(t.onDangerousProperty=Xi),t.processEntities=ta(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};na="function"!=typeof Symbol?"@@xmlMetadata":Symbol("XML Node Metadata");var ia=class{constructor(e){this.tagname=e,this.child=[],this[":@"]=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}),this.addStartIndex(t)}addStartIndex(e){void 0!==e&&(this.child[this.child.length-1][na]={startIndex:e})}addEndIndex(e){const t=this.child[this.child.length-1];void 0!==t&&void 0!==t[na]&&void 0===t[na].endIndex&&(t[na].endIndex=e)}static getMetaDataSymbol(){return na}},aa=":A-Za-z_À-ÖØ-öø-˿Ͱ-ͽͿ-҆҈-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�",oa=":A-Za-z_À-˿Ͱ-ͽͿ-҆҈-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�𐀀-󯿿",sa=oa+"\\-\\.\\d·̀-ͯ҇‿-⁀",Aa=(e,t,n="")=>{const r=`[${e.replace(":","")}][${t.replace(":","")}]*`;return{name:new RegExp(`^[${e}][${t}]*$`,n),ncName:new RegExp(`^${r}$`,n),qName:new RegExp(`^${r}(?::${r})?$`,n),nmToken:new RegExp(`^[${t}]+$`,n),nmTokens:new RegExp(`^[${t}]+(?:\\s+[${t}]+)*$`,n)}},la=Aa(aa,aa+"\\-\\.\\d·̀-ͯ‿-⁀"),ca=Aa(oa,sa,"u"),ua=Aa(":A-Za-z_",":A-Za-z_\\-\\.\\d"),fa=(e,{xmlVersion:t="1.0",asciiOnly:n=!1}={})=>((e="1.0",t=!1)=>t?ua:"1.1"===e?ca:la)(t,n).qName.test(e),da=class{constructor(e,t){this.suppressValidationErr=!e,this.options=e,this.xmlVersion=t||1}setXmlVersion(e=1){this.xmlVersion=e}readDocType(e,t){const n=Object.create(null);let r=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 i=1,a=!1,o=!1,s=null,A="";for(;t<e.length;t++)if(null===s)if(a||o||'"'!==e[t]&&"'"!==e[t])if("<"!==e[t]||o)if(">"===e[t]){if(o?"-"===e[t-1]&&"-"===e[t-2]&&(o=!1,i--):i--,0===i)break}else"["===e[t]?a=!0:A+=e[t];else{if(a&&pa(e,"!ENTITY",t)){let i,a;if(t+=7,[i,a,t]=this.readEntityExp(e,t+1,this.suppressValidationErr),-1===a.indexOf("&")){if(!1!==this.options.enabled&&null!=this.options.maxEntityCount&&r>=this.options.maxEntityCount)throw new Error(`Entity count (${r+1}) exceeds maximum allowed (${this.options.maxEntityCount})`);n[i]=a,r++}}else if(a&&pa(e,"!ELEMENT",t)){t+=8;const{index:n}=this.readElementExp(e,t+1);t=n}else if(a&&pa(e,"!ATTLIST",t))t+=8;else if(a&&pa(e,"!NOTATION",t)){t+=9;const{index:n}=this.readNotationExp(e,t+1,this.suppressValidationErr);t=n}else{if(!pa(e,"!--",t))throw new Error("Invalid DOCTYPE");o=!0}i++,A=""}else s=e[t],A+=e[t];else e[t]===s&&(s=null),A+=e[t];if(null!==s||0!==i)throw new Error("Unclosed DOCTYPE")}return{entities:n,i:t}}readEntityExp(e,t){const n=t=ha(e,t);for(;t<e.length&&!/\s/.test(e[t])&&'"'!==e[t]&&"'"!==e[t];)t++;let r=e.substring(n,t);if(ma(r,{xmlVersion:this.xmlVersion}),t=ha(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 i="";if([t,i]=this.readIdentifierVal(e,t,"entity"),!1!==this.options.enabled&&null!=this.options.maxEntitySize&&i.length>this.options.maxEntitySize)throw new Error(`Entity "${r}" size (${i.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`);return[r,i,--t]}readNotationExp(e,t){const n=t=ha(e,t);for(;t<e.length&&!/\s/.test(e[t]);)t++;let r=e.substring(n,t);!this.suppressValidationErr&&ma(r,{xmlVersion:this.xmlVersion}),t=ha(e,t);const i=e.substring(t,t+6).toUpperCase();if(!this.suppressValidationErr&&"SYSTEM"!==i&&"PUBLIC"!==i)throw new Error(`Expected SYSTEM or PUBLIC, found "${i}"`);t+=i.length,t=ha(e,t);let a=null,o=null;if("PUBLIC"===i)[t,a]=this.readIdentifierVal(e,t,"publicIdentifier"),'"'!==e[t=ha(e,t)]&&"'"!==e[t]||([t,o]=this.readIdentifierVal(e,t,"systemIdentifier"));else if("SYSTEM"===i&&([t,o]=this.readIdentifierVal(e,t,"systemIdentifier"),!this.suppressValidationErr&&!o))throw new Error("Missing mandatory system identifier for SYSTEM notation");return{notationName:r,publicIdentifier:a,systemIdentifier:o,index:--t}}readIdentifierVal(e,t,n){let r="";const i=e[t];if('"'!==i&&"'"!==i)throw new Error(`Expected quoted string, found "${i}"`);const a=++t;for(;t<e.length&&e[t]!==i;)t++;if(r=e.substring(a,t),e[t]!==i)throw new Error(`Unterminated ${n} value`);return[++t,r]}readElementExp(e,t){const n=t=ha(e,t);for(;t<e.length&&!/\s/.test(e[t]);)t++;let r=e.substring(n,t);if(!this.suppressValidationErr&&!fa(r,{xmlVersion:this.xmlVersion}))throw new Error(`Invalid element name: "${r}"`);let i="";if("E"===e[t=ha(e,t)]&&pa(e,"MPTY",t))t+=4;else if("A"===e[t]&&pa(e,"NY",t))t+=2;else if("("===e[t]){const n=++t;for(;t<e.length&&")"!==e[t];)t++;if(i=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:r,contentModel:i.trim(),index:t}}readAttlistExp(e,t){let n=t=ha(e,t);for(;t<e.length&&!/\s/.test(e[t]);)t++;let r=e.substring(n,t);for(ma(r,{xmlVersion:this.xmlVersion}),n=t=ha(e,t);t<e.length&&!/\s/.test(e[t]);)t++;let i=e.substring(n,t);if(!ma(i,{xmlVersion:this.xmlVersion}))throw new Error(`Invalid attribute name: "${i}"`);t=ha(e,t);let a="";if("NOTATION"===e.substring(t,t+8).toUpperCase()){if(a="NOTATION","("!==e[t=ha(e,t+=8)])throw new Error(`Expected '(', found "${e[t]}"`);t++;let n=[];for(;t<e.length&&")"!==e[t];){const r=t;for(;t<e.length&&"|"!==e[t]&&")"!==e[t];)t++;let i=e.substring(r,t);if(i=i.trim(),!ma(i,{xmlVersion:this.xmlVersion}))throw new Error(`Invalid notation name: "${i}"`);n.push(i),"|"===e[t]&&(t++,t=ha(e,t))}if(")"!==e[t])throw new Error("Unterminated list of notations");t++,a+=" ("+n.join("|")+")"}else{const n=t;for(;t<e.length&&!/\s/.test(e[t]);)t++;if(a+=e.substring(n,t),!this.suppressValidationErr&&!["CDATA","ID","IDREF","IDREFS","ENTITY","ENTITIES","NMTOKEN","NMTOKENS"].includes(a.toUpperCase()))throw new Error(`Invalid attribute type: "${a}"`)}t=ha(e,t);let o="";return"#REQUIRED"===e.substring(t,t+8).toUpperCase()?(o="#REQUIRED",t+=8):"#IMPLIED"===e.substring(t,t+7).toUpperCase()?(o="#IMPLIED",t+=7):[t,o]=this.readIdentifierVal(e,t,"ATTLIST"),{elementName:r,attributeName:i,attributeType:a,defaultValue:o,index:t}}},ha=(e,t)=>{for(;t<e.length&&/\s/.test(e[t]);)t++;return t};function pa(e,t,n){for(let r=0;r<t.length;r++)if(t[r]!==e[n+r+1])return!1;return!0}function ma(e,t){if(fa(e,{xmlVersion:t}))return e;throw new Error(`Invalid entity name ${e}`)}var ga=new Map,ba=new Uint8Array(63904).fill(255);for(const ev of[48,1632,1776,2406,2534,2662,2790,2918,3046,3174,3302,3430,3558,3664,3792,3872,4160,4240,6112,6160,6470,6608,6784,6800,6992,7088,7232,7248,65296,120782,120792,120802,120812,120822,66720,68912,69734,69872,69942,70096,70384,70736,70864,71248,71360,71472,71904,72016,72688,72784,73040,73120,73552,92768,92864,93008,123200,123632,124144,125264,130032])for(let e=0;e<10;e++){const t=ev+e;t<=65535?ba[t-1632]=e:ga.set(t,e)}var va=new Set([8722,65293,65123]);var ya=/^[-+]?0x[a-fA-F0-9]+$/,xa=/^0b[01]+$/,_a=/^0o[0-7]+$/,wa=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,Ta={hex:!0,binary:!1,octal:!1,leadingZeros:!0,decimalPoint:".",eNotation:!0,infinity:"original",unicode:!1};function Sa(e,t={}){if(t=Object.assign({},Ta,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.unicode&&(n=function(e){if("string"!=typeof e)return e;const t=e.length;if(0===t)return e;let n=-1;for(let i=0;i<t;i++){const r=e.charCodeAt(i);if(!(r>=48&&r<=57||45===r))if(r<1632){if(va.has(r)){n=i;break}}else if(r>=55296&&r<=56319){if(i+1<t){const t=e.charCodeAt(i+1);if(t>=56320&&t<=57343){const e=65536+(r-55296<<10)+(t-56320);if(ga.has(e)){n=i;break}}}}else if(255!==ba[r-1632]||va.has(r)){n=i;break}}if(-1===n)return e;const r=[];n>0&&r.push(e.slice(0,n));for(let i=n;i<t;i++){const n=e.charCodeAt(i);if(n>=48&&n<=57||45===n){r.push(e[i]);continue}if(n<1632){r.push(va.has(n)?"-":e[i]);continue}if(n>=55296&&n<=56319){if(i+1<t){const t=e.charCodeAt(i+1);if(t>=56320&&t<=57343){const e=65536+(n-55296<<10)+(t-56320),a=ga.get(e);if(void 0!==a){r.push(String.fromCharCode(a+48)),i++;continue}}}r.push(e[i]);continue}if(va.has(n)){r.push("-");continue}const a=ba[n-1632];r.push(255!==a?String.fromCharCode(a+48):e[i])}return r.join("")}(n),"0"===n))return 0;if(t.hex&&ya.test(n))return Ea(n,16);if(t.binary&&xa.test(n))return Ea(n,2);if(t.octal&&_a.test(n))return Ea(n,8);if(isFinite(n)){if(n.includes("e")||n.includes("E"))return function(e,t,n){if(!n.eNotation)return e;const r=t.match(Ma);if(r){let i=r[1]||"";const a=-1===r[3].indexOf("e")?"E":"e",o=r[2],s=i?t[o.length+1]===a:t[o.length]===a;return o.length>1&&s?e:(1!==o.length||!r[3].startsWith(`.${a}`)&&r[3][0]!==a)&&o.length>0?n.leadingZeros&&!s?Number(t):e:Number(t)}return e}(e,n,t);{const r=wa.exec(n);if(r){const i=r[1]||"",a=r[2];let o=function(e){if(e&&-1!==e.indexOf(".")){let t=e.length;for(;t>0&&48===e.charCodeAt(t-1);)t--;return"."===(e=e.slice(0,t))?e="0":"."===e[0]?e="0"+e:"."===e[e.length-1]&&(e=e.substring(0,e.length-1)),e}return e}(r[3]);const s=i?"."===n[a.length+1]:"."===n[a.length];if(!t.leadingZeros&&(a.length>1||1===a.length&&!s))return e;{const r=Number(n),s=String(r);if(0===r)return r;if(-1!==s.search(/[eE]/))return t.eNotation?r:e;if(-1!==n.indexOf("."))return"0"===s||s===o||s===`${i}${o}`?r:e;let A=a?o:n;return a?A===s||i+A===s?r:e:A===s||A===i+s?r:e}}return e}}{const r=Number(n);return Number.isNaN(r)?e:function(e,t,n){const r=t===1/0;switch(n.infinity.toLowerCase()){case"null":return null;case"infinity":return t;case"string":return r?"Infinity":"-Infinity";default:return e}}(e,r,t)}}var Ma=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;function Ea(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")}var Ca=class{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,r="";for(;n<e.length;)e[n]===this.separator?n+1<e.length&&e[n+1]===this.separator?(r.trim()&&(t.push(this._parseSegment(r.trim())),r=""),t.push({type:"deep-wildcard"}),n+=2):(r.trim()&&t.push(this._parseSegment(r.trim())),r="",n++):(r+=e[n],n++);return r.trim()&&t.push(this._parseSegment(r.trim())),t}_parseSegment(e){const t={type:"tag"};let n=null,r=e;const i=e.match(/^([^\[]+)(\[[^\]]*\])(.*)$/);if(i&&(r=i[1]+i[3],i[2])){const e=i[2].slice(1,-1);e&&(n=e)}let a,o,s=r;if(r.includes("::")){const t=r.indexOf("::");if(a=r.substring(0,t).trim(),s=r.substring(t+2).trim(),!a)throw new Error(`Invalid namespace in pattern: ${e}`)}let A=null;if(s.includes(":")){const e=s.lastIndexOf(":"),t=s.substring(0,e).trim(),n=s.substring(e+1).trim();["first","last","odd","even"].includes(n)||/^nth\(\d+\)$/.test(n)?(o=t,A=n):o=s}else o=s;if(!o)throw new Error(`Invalid segment pattern: ${e}`);if(t.tag=o,a&&(t.namespace=a),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}},Ia=class{constructor(){this._byDepthAndTag=new Map,this._wildcardByDepth=new Map,this._deepWildcards=[],this._deepByTerminalTag=new Map,this._patterns=new Set,this._sealed=!1}add(e){if(this._sealed)throw new TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions.");if(this._patterns.has(e.pattern))return this;if(this._patterns.add(e.pattern),e.hasDeepWildcard()){const t=e.segments[e.segments.length-1];if(t&&"deep-wildcard"!==t.type&&"*"!==t.tag){const n=t.tag;this._deepByTerminalTag.has(n)||this._deepByTerminalTag.set(n,[]),this._deepByTerminalTag.get(n).push(e)}else this._deepWildcards.push(e);return this}const t=e.length,n=e.segments[e.segments.length-1]?.tag;if(n&&"*"!==n){const r=`${t}:${n}`;this._byDepthAndTag.has(r)||this._byDepthAndTag.set(r,[]),this._byDepthAndTag.get(r).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=e.getCurrentTag(),r=`${t}:${n}`,i=this._byDepthAndTag.get(r);if(i)for(let s=0;s<i.length;s++)if(e.matches(i[s]))return i[s];const a=this._wildcardByDepth.get(t);if(a)for(let s=0;s<a.length;s++)if(e.matches(a[s]))return a[s];const o=this._deepByTerminalTag.get(n);if(o)for(let s=0;s<o.length;s++)if(e.matches(o[s]))return o[s];for(let s=0;s<this._deepWildcards.length;s++)if(e.matches(this._deepWildcards[s]))return this._deepWildcards[s];return null}},Ra=class{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}getAnyParentAttr(e){return this._matcher.getAnyParentAttr(e)}hasAnyParentAttr(e){return this._matcher.hasAnyParentAttr(e)}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)}},Pa=class{constructor(e={}){this.separator=e.separator||".",this.path=[],this.siblingStacks=[],this._pathStringCache=null,this._view=new Ra(this),this._keptAttrs=[]}push(e,t=null,n=null,r=null){this._pathStringCache=null,this.path.length>0&&(this.path[this.path.length-1].values=void 0);const i=this.path.length;let a=this.siblingStacks[i];a||(a={counts:new Map,total:0},this.siblingStacks[i]=a);const o=n?`${n}:${e}`:e,s=a.counts.get(o)||0,A=a.total;a.counts.set(o,s+1),a.total++;const l={tag:e,position:A,counter:s};null!=n&&(l.namespace=n),null!=t&&(l.values=t),this.path.push(l);const c=this.path.length,u=null!==r?r.keep:null;if(null!=u&&u.length>0&&t)for(let f=0;f<u.length;f++){const e=u[f];void 0!==t[e]&&this._keptAttrs.push({depth:c,name:e,value:t[e]})}}pop(){if(0===this.path.length)return;this._pathStringCache=null;const e=this.path.pop();this.siblingStacks.length>this.path.length+1&&(this.siblingStacks.length=this.path.length+1);const t=this.path.length+1;for(;this._keptAttrs.length>0&&this._keptAttrs[this._keptAttrs.length-1].depth>=t;)this._keptAttrs.pop();return 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}getAnyParentAttr(e){const t=this._keptAttrs;for(let n=t.length-1;n>=0;n--)if(t[n].name===e)return t[n].value}hasAnyParentAttr(e){const t=this._keptAttrs;for(let n=t.length-1;n>=0;n--)if(t[n].name===e)return!0;return!1}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=[],this._keptAttrs=[]}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 r=e[n];if("deep-wildcard"===r.type){if(n--,n<0)return!0;const r=e[n];let i=!1;for(let e=t;e>=0;e--)if(this._matchSegment(r,this.path[e],e===this.path.length-1)){t=e-1,n--,i=!0;break}if(!i)return!1}else{if(!this._matchSegment(r,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 r=t.counter??0;if("first"===e.position&&0!==r)return!1;if("odd"===e.position&&r%2!=1)return!1;if("even"===e.position&&r%2!=0)return!1;if("nth"===e.position&&r!==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=>e?{counts:new Map(e.counts),total:e.total}:e),keptAttrs:this._keptAttrs.map(e=>({...e}))}}restore(e){this._pathStringCache=null,this.path=e.path.map(e=>({...e})),this.siblingStacks=e.siblingStacks.map(e=>e?{counts:new Map(e.counts),total:e.total}:e),this._keptAttrs=(e.keptAttrs||[]).map(e=>({...e}))}readOnly(){return this._view}},Na=[{id:"html-script-open",description:"<script opening tag",pattern:/<script[\s>/]/i},{id:"html-script-close",description:"<\/script closing tag",pattern:/<\/script[\s>]/i},{id:"html-javascript-protocol",description:"javascript: URI scheme (with optional whitespace/encoding)",pattern:/j[\t\n\r ]*a[\t\n\r ]*v[\t\n\r ]*a[\t\n\r ]*s[\t\n\r ]*c[\t\n\r ]*r[\t\n\r ]*i[\t\n\r ]*p[\t\n\r ]*t[\t\n\r ]*:/i},{id:"html-vbscript-protocol",description:"vbscript: URI scheme",pattern:/vbscript[\t\n\r ]*:/i},{id:"html-data-html",description:"data:text/html URI — can execute scripts in browsers",pattern:/data[\t\n\r ]*:[\t\n\r ]*text\/html/i},{id:"html-data-xhtml",description:"data:application/xhtml+xml URI",pattern:/data[\t\n\r ]*:[\t\n\r ]*application\/xhtml/i},{id:"html-data-svg",description:"data:image/svg+xml URI — can execute scripts",pattern:/data[\t\n\r ]*:[\t\n\r ]*image\/svg\+xml/i},{id:"html-inline-event-handler",description:"Inline event handler attributes: onclick=, onerror=, onload=, etc.",pattern:/\bon\w{1,30}\s*=/i},{id:"html-entity-obfuscated-script",description:"HTML-entity-encoded <script (e.g. &#x3C;script or &lt;script)",pattern:/(?:&#x0*3[Cc];?|&#0*60;?|&lt;)\s*script/i},{id:"html-entity-obfuscated-javascript",description:'HTML-entity-encoded javascript: (partial — catches common &#106; or &#x6a; for "j")',pattern:/(?:&#x0*6[Aa];?|&#0*106;?)\s*(?:&#x0*61;?|a)[\s\S]{0,80}script\s*:/i},{id:"html-style-expression",description:"CSS expression() — IE-era code execution in style attributes",pattern:/style[\s\S]{0,20}expression\s*\(/i},{id:"html-object-embed",description:"<object or <embed tags that can load active content",pattern:/<(?:object|embed)[\s>/]/i},{id:"html-base-tag",description:"<base href= — can hijack all relative URLs on a page",pattern:/<base[\s>]/i},{id:"html-meta-refresh",description:'<meta http-equiv="refresh" — can redirect users',pattern:/<meta[\s\S]{0,40}http-equiv[\s\S]{0,20}refresh/i},{id:"html-srcdoc",description:"srcdoc= attribute on iframes — embeds HTML that can run scripts",pattern:/srcdoc\s*=/i},{id:"html-iframe",description:"<iframe tag",pattern:/<iframe[\s>/]/i},{id:"html-form",description:"<form tag — can be used for phishing / credential harvesting injection",pattern:/<form[\s>/]/i}],ka=[{id:"xml-cdata-injection",description:"CDATA section injection: <![CDATA[ breaks out of text node context",pattern:/<!\[CDATA\[/i},{id:"xml-cdata-close",description:"CDATA close sequence: ]]> can terminate an enclosing CDATA section",pattern:/\]\]>/},{id:"xml-processing-instruction",description:"XML processing instruction: <?xml-stylesheet or <?php etc.",pattern:/<\?(?:xml[\- ]|php|asp)/i},{id:"xml-doctype-injection",description:"DOCTYPE declaration embedded in content — can define entities",pattern:/<!DOCTYPE(?:[\s[]|$)/i},{id:"xml-entity-system",description:"SYSTEM keyword — used in external entity declarations (XXE)",pattern:/\bSYSTEM\s+["']/i},{id:"xml-entity-public",description:"PUBLIC keyword — used in external entity declarations (XXE)",pattern:/\bPUBLIC\s+["']/i},{id:"xml-entity-declaration",description:"<!ENTITY declaration — defines entities, potential XXE or entity expansion",pattern:/<!ENTITY[\s%]/i},{id:"xml-billion-laughs",description:"Entity reference chaining / billion laughs: repeated &eX; style references",pattern:/(?:&\w{1,20};){3,}/},{id:"xml-namespace-confusion",description:"xmlns: attribute injection — can redefine namespaces to confuse parsers",pattern:/\bxmlns(?::\w{1,40})?\s*=/i},{id:"xml-comment-injection",description:"\x3c!-- comment injection — can hide content from some parsers",pattern:/<!--/},{id:"xml-comment-close",description:"--\x3e closes an enclosing XML comment",pattern:/-->/},{id:"xml-pi-close",description:"?> closes an enclosing processing instruction",pattern:/\?>/}],La=[{id:"svg-script-element",description:"<script element inside SVG executes JavaScript",pattern:/<script[\s>/]/i},{id:"svg-xlink-href-javascript",description:"xlink:href with javascript: — classic SVG XSS via <a> or <use>",pattern:/xlink\s*:\s*href\s*=\s*["']?\s*javascript\s*:/i},{id:"svg-href-javascript",description:"href= with javascript: in SVG context (<a>, <animate>, etc.)",pattern:/href\s*=\s*["']?\s*javascript\s*:/i},{id:"svg-foreignobject",description:"<foreignObject embeds HTML inside SVG — can execute scripts",pattern:/<foreignObject[\s>/]/i},{id:"svg-use-external",description:"<use xlink:href or href pointing to external resource (non-fragment URL)",pattern:/<use[\s\S]{0,60}(?:xlink\s*:\s*)?href\s*=\s*(?:["'][^#]|[^"'#\s>])/i},{id:"svg-animate-href",description:'<animate attributeName="href" — can dynamically change href to javascript:',pattern:/<animate[\s\S]{0,80}attributeName\s*=\s*["'][\s]*href["']/i},{id:"svg-animate-xlinkhref",description:'<animate attributeName="xlink:href"',pattern:/<animate[\s\S]{0,80}attributeName\s*=\s*["'][\s]*xlink\s*:\s*href["']/i},{id:"svg-set-javascript",description:'<set to="javascript:..." — sets an attribute to a javascript: URI',pattern:/<set[\s\S]{0,80}to\s*=\s*["']?\s*javascript\s*:/i},{id:"svg-event-handler",description:"SVG-specific event handler attributes: onload=, onerror=, onactivate=, etc.",pattern:/\bon(?:load|error|activate|begin|end|repeat|focus|blur|click|mouse\w{1,20}|key\w{1,20})\s*=/i},{id:"svg-handler-generic",description:"Generic on* handler catch-all for SVG attributes",pattern:/\bon\w{1,30}\s*=/i},{id:"svg-filter-feimage",description:"<feImage href= — filter primitive that can load external resources",pattern:/<feImage[\s\S]{0,80}(?:xlink\s*:\s*)?href\s*=/i},{id:"svg-image-external",description:"<image xlink:href with http/https or javascript protocol",pattern:/<image[\s\S]{0,80}(?:xlink\s*:\s*)?href\s*=\s*["']?\s*(?:https?|javascript)\s*:/i},{id:"svg-style-javascript",description:"style= attribute containing javascript: (e.g. background:url(javascript:...))",pattern:/style\s*=[\s\S]{0,60}javascript\s*:/i}],Ba=[{id:"sql-block-comment-open",description:"SQL block comment open: /* ... */ — unusual in legitimate user text",pattern:/\/\*/},{id:"sql-union-select",description:"UNION SELECT — most common SQL injection aggregation attack",pattern:/\bUNION\s{1,20}(?:ALL\s{1,20})?SELECT\b/i},{id:"sql-drop-table",description:"DROP TABLE — destructive DDL injection",pattern:/\bDROP\s{1,20}TABLE\b/i},{id:"sql-drop-database",description:"DROP DATABASE — destructive DDL injection",pattern:/\bDROP\s{1,20}DATABASE\b/i},{id:"sql-insert-into",description:"INSERT INTO — data injection",pattern:/\bINSERT\s{1,20}INTO\b/i},{id:"sql-delete-from",description:"DELETE FROM — data deletion injection",pattern:/\bDELETE\s{1,20}FROM\b/i},{id:"sql-update-set",description:"UPDATE ... SET — data modification injection",pattern:/\bUPDATE\b[\s\S]{1,60}\bSET\b/i},{id:"sql-exec-xp",description:"EXEC xp_ — MSSQL extended stored procedure execution",pattern:/\bEXEC(?:UTE)?\s{1,20}xp_/i},{id:"sql-tautology-string",description:'Classic string tautology: \' OR \'1\'=\'1 or " OR "1"="1"',pattern:/'\s{0,10}OR\s{0,10}'[^']{0,20}'\s*=\s*'[^']{0,20}/i},{id:"sql-tautology-numeric",description:"Numeric tautology: OR 1=1",pattern:/\bOR\s{1,10}1\s*=\s*1\b/i},{id:"sql-always-true-zero",description:"Numeric tautology: OR 0=0",pattern:/\bOR\s{1,10}0\s*=\s*0\b/i},{id:"sql-sleep-benchmark",description:"Time-based blind injection: SLEEP() or BENCHMARK()",pattern:/\b(?:SLEEP|BENCHMARK)\s*\(/i},{id:"sql-waitfor-delay",description:"MSSQL time-based blind injection: WAITFOR DELAY",pattern:/\bWAITFOR\s{1,20}DELAY\b/i},{id:"sql-char-function",description:"CHAR() function — used to obfuscate injected strings",pattern:/\bCHAR\s*\(\s*\d{1,3}/i},{id:"sql-information-schema",description:"INFORMATION_SCHEMA — reconnaissance query for table/column enumeration",pattern:/\bINFORMATION_SCHEMA\b/i}],Oa=[{id:"shell-path-traversal-unix",description:"Unix path traversal: ../ — climbing the directory tree",pattern:/\.\.\//},{id:"shell-path-traversal-windows",description:"Windows path traversal: ..\\ — climbing the directory tree",pattern:/\.\.\\/},{id:"shell-path-traversal-encoded",description:"URL-encoded path traversal: %2e%2e or %2f variants",pattern:/%2e%2e|%2f\.\.|\.\.%2f/i},{id:"shell-null-byte",description:"Null byte injection: \\x00 or %00 — truncates strings in C-backed functions",pattern:/\x00|%00/},{id:"shell-semicolon",description:"Semicolon command separator: cmd1; cmd2",pattern:/;/},{id:"shell-pipe",description:"Pipe operator: cmd1 | cmd2",pattern:/\|/},{id:"shell-and-operator",description:"AND operator: cmd1 && cmd2",pattern:/&&/},{id:"shell-or-operator",description:"OR operator: cmd1 || cmd2",pattern:/\|\|/},{id:"shell-backtick",description:"Backtick command substitution: `cmd`",pattern:/`/},{id:"shell-dollar-paren",description:"Dollar-paren command substitution: $(cmd)",pattern:/\$\(/},{id:"shell-dollar-brace",description:"Dollar-brace variable expansion: ${var} — can be abused for injection",pattern:/\$\{/},{id:"shell-redirect-out",description:"Output redirection: cmd > file or cmd >> file",pattern:/>{1,2}/},{id:"shell-redirect-in",description:"Input redirection: cmd < file",pattern:/</},{id:"shell-newline-injection",description:"Newline injection: \\n or \\r — can inject new shell commands",pattern:/[\n\r]/},{id:"shell-glob-star",description:"Glob expansion: * or ? — can expand to unintended files",pattern:/[/\\][*?]/},{id:"shell-absolute-root",description:"Absolute root path injection: string starting with / or \\ (Windows UNC)",pattern:/^(?:\/|\\\\)/},{id:"shell-windows-drive",description:"Windows drive letter path injection: C:\\ or D:/",pattern:/^[a-zA-Z]:[/\\]/},{id:"shell-curl-wget",description:"curl/wget with URL or flags — can exfiltrate data or download payloads",pattern:/\b(?:curl|wget)\s+(?:https?:\/\/|ftp:\/\/|-)/i}],Fa=[{id:"redos-nested-quantifier-plus",description:"Nested + quantifier inside a group with outer quantifier: (a+)+, (.+b)*, etc.",pattern:/\([^)]*\+[^)]*\)[+*]/},{id:"redos-nested-quantifier-star",description:"Nested * quantifier: (a*)* or (a*)+ — catastrophic backtracking",pattern:/\([^)]*\*[^)]*\)[*+]/},{id:"redos-nested-groups",description:"Doubly nested quantified groups: ((a+)+) — guaranteed catastrophic",pattern:/\(\([^)]{0,40}\)[+*]\)[+*]/},{id:"redos-alternation-overlap",description:"Overlapping alternation under quantifier: (a|a)+ — ambiguous NFA paths",pattern:/\(([^|()]{1,20})\|(?:\1)(?:\|[^|()]{1,20}){0,5}\)[+*?]{1,2}/},{id:"redos-star-plus-concat",description:"(x*x)+ pattern — triggers super-linear backtracking",pattern:/\([^)]{0,10}\*[^)]{0,10}\)[+*]/},{id:"redos-dot-star-greedy",description:"(.*){n,} or (.+){n,} — repeated greedy dot quantifiers",pattern:/\(\.[*+]\)\{?\d/},{id:"redos-large-repetition",description:"Very large fixed or range repetition count {1000,} or {1000,n} — denial of service via backtracking",pattern:/\{\d{4,}(?:,\d*)?\}/},{id:"redos-catastrophic-alternation",description:"Long alternation with many similar branches — polynomial backtracking risk",pattern:/\([^)]{0,200}(?:\|[^|)]{0,50}){9,}\)/}],Da="[\"'\\s]*:",Ua=[{id:"nosql-where-operator",description:"$where — executes arbitrary JavaScript server-side in MongoDB",pattern:new RegExp(`\\$where${Da}`,"i")},{id:"nosql-ne-operator",description:'$ne — "not equal" operator used to bypass equality checks',pattern:new RegExp(`\\$ne${Da}`,"i")},{id:"nosql-gt-operator",description:'$gt — "greater than" used to bypass password/value checks',pattern:new RegExp(`\\$gte?${Da}`,"i")},{id:"nosql-lt-operator",description:'$lt / $lte — "less than" bypass variants',pattern:new RegExp(`\\$lte?${Da}`,"i")},{id:"nosql-regex-operator",description:"$regex — can be used to extract data character by character (blind injection)",pattern:new RegExp(`\\$regex${Da}`,"i")},{id:"nosql-or-operator",description:"$or — logical OR; used to create always-true conditions",pattern:new RegExp(`\\$or${Da}\\s*\\[`,"i")},{id:"nosql-and-operator",description:"$and — logical AND operator injection",pattern:new RegExp(`\\$and${Da}\\s*\\[`,"i")},{id:"nosql-nor-operator",description:"$nor — logical NOR operator injection",pattern:new RegExp(`\\$nor${Da}\\s*\\[`,"i")},{id:"nosql-exists-operator",description:"$exists — can enumerate fields to determine schema",pattern:new RegExp(`\\$exists${Da}`,"i")},{id:"nosql-in-operator",description:"$in — matches any value in a list; can enumerate values",pattern:new RegExp(`\\$in${Da}\\s*\\[`,"i")},{id:"nosql-expr-operator",description:"$expr — allows aggregation expressions in queries (MongoDB 3.6+)",pattern:new RegExp(`\\$expr${Da}`,"i")},{id:"nosql-function-operator",description:"$function — executes arbitrary JavaScript in MongoDB 4.4+",pattern:new RegExp(`\\$function${Da}`,"i")},{id:"nosql-accumulator-operator",description:"$accumulator — custom aggregation with arbitrary JS execution",pattern:new RegExp(`\\$accumulator${Da}`,"i")},{id:"nosql-proto-pollution",description:"__proto__ — prototype pollution via object key injection",pattern:/__proto__/},{id:"nosql-constructor-prototype",description:"constructor.prototype — alternative prototype pollution vector (dot notation or JSON key)",pattern:/constructor[\s"':.,{\[]*prototype/i},{id:"nosql-proto-bracket",description:'["__proto__"] — bracket-notation prototype pollution',pattern:/\[["']__proto__["']\]/}],Va=[{id:"log-crlf-injection",description:"CRLF injection: literal \\r or \\n embeds fake log lines",pattern:/[\r\n]/},{id:"log-url-encoded-crlf",description:"URL-encoded CRLF: %0d, %0a, %0D, %0A — decoded by some log parsers",pattern:/%0[dDaA]/},{id:"log-unicode-newline",description:"Unicode newline variants: U+2028 (line separator), U+2029 (paragraph separator)",pattern:/[\u2028\u2029]/},{id:"log-log4shell-jndi",description:"Log4Shell: ${jndi:...} triggers remote code execution in Apache Log4j",pattern:/\$\{jndi\s*:/i},{id:"log-log4shell-obfuscated",description:"Obfuscated Log4Shell: ${::-j}... lookup-bypass prefix used to evade WAF detection",pattern:/\$\{::-/},{id:"log-log4j-lookup",description:"Log4j lookup syntax: ${env:...}, ${sys:...}, ${ctx:...} — data exfiltration",pattern:/\$\{(?:env|sys|ctx|main|map|sd|web|docker|k8s|spring)\s*:/i},{id:"log-ssti-double-brace",description:"SSTI double-brace: {{expression}} — Jinja2, Twig, Handlebars, etc.",pattern:/\{\{[\s\S]{0,80}\}\}/},{id:"log-ssti-hash-brace",description:"SSTI hash-brace: #{expression} — Thymeleaf, Velocity, Ruby ERB",pattern:/#\{[\s\S]{0,80}\}/},{id:"log-ssti-dollar-brace",description:"SSTI/EL injection: ${expression with operators or method calls} — JSP EL, Freemarker, SpEL",pattern:/\$\{[^}]*(?:\.|\(|\*|\+|\bclass\b|\bruntime\b|\bprocess\b|\bexec\b)[^}]{0,80}\}/i},{id:"log-ssti-percent-tag",description:"SSTI ERB/ASP tag: <%= expression %> — Ruby ERB, ASP",pattern:/<%=[\s\S]{0,80}%>/},{id:"log-null-byte",description:"Null byte: \\x00 or %00 — can truncate log entries in C-backed loggers",pattern:/\x00|%00/},{id:"log-ansi-escape",description:"ANSI escape sequence: ESC[ — can manipulate terminal output when logs are tailed",pattern:/\x1b\[/}],ja=[...Ba,{id:"sql-line-comment",description:"SQL line comment: -- followed by whitespace or end of string",pattern:/--(?:\s|$)/},{id:"sql-stacked-query",description:"Stacked queries: semicolon immediately followed by a SQL keyword",pattern:/;\s{0,10}(?:SELECT|INSERT|UPDATE|DELETE|DROP|CREATE|ALTER|EXEC)\b/i},{id:"sql-hex-encoding",description:"Hex-encoded string injection: 0x41414141 style (MySQL)",pattern:/\b0x[0-9a-f]{4,}/i}],za=Object.freeze({colon:":",Tab:"\t",NewLine:"\n"}),Ga=/&(?:#[xX]0*([0-9a-fA-F]{1,6});?|#0*([0-9]{1,7});?|([a-zA-Z][a-zA-Z0-9]{1,15});)/g;Na.label="HTML",ka.label="XML",La.label="SVG",Na.decodeEntities=!0,ka.decodeEntities=!0,La.decodeEntities=!0,Ba.label="SQL",ja.label="SQL-STRICT",Oa.label="SHELL",Fa.label="REDOS",Ua.label="NOSQL",Va.label="LOG";Object.freeze({HTML:Na,XML:ka,SVG:La,SQL:Ba,"SQL-STRICT":ja,SHELL:Oa,REDOS:Fa,NOSQL:Ua,LOG:Va});function Ha(e,t){if(!t.decodeEntities)return null;const n=-1===(r=e).indexOf("&")?r:r.replace(Ga,(e,t,n,r)=>{if(void 0!==r)return Object.prototype.hasOwnProperty.call(za,r)?za[r]:e;const i=void 0!==t?parseInt(t,16):parseInt(n,10);return!Number.isFinite(i)||i>1114111?e:String.fromCodePoint(i)});var r;return n===e?null:n}function qa(e,t){const n=t.label??"CUSTOM",r=Ha(e,t);for(const i of t)if(i.pattern.test(e)||null!==r&&i.pattern.test(r))return{context:n,id:i.id,description:i.description,pattern:i.pattern};return null}function Qa(e,t){!function(e){if("string"!=typeof e)throw new TypeError("is-unsafe: first argument must be a string, got "+typeof e)}(e),function(e){if(!(e instanceof RegExp)){if(!Array.isArray(e))throw new TypeError("is-unsafe: second argument must be a PatternList (e.g. HTML), an array of PatternLists (e.g. [HTML, XML]), or a RegExp. Got: "+typeof e);if(0===e.length)throw new TypeError("is-unsafe: context must not be an empty array");if(Array.isArray(e[0]))for(const t of e)if(!Array.isArray(t)||0===t.length)throw new TypeError("is-unsafe: each context in the array must be a non-empty pattern array (PatternList)")}}(t);const{lists:n,regex:r}=function(e){return e instanceof RegExp?{lists:null,regex:e}:Array.isArray(e[0])?{lists:e,regex:null}:{lists:[e],regex:null}}(t);if(r)return r.test(e);for(const i of n)if(null!==qa(e,i))return!0;return!1}function Ka(e,t){if(!e)return{};const n=t.attributesGroupName?e[t.attributesGroupName]:e;if(!n)return{};const r={};for(const i in n)if(i.startsWith(t.attributeNamePrefix)){r[i.substring(t.attributeNamePrefix.length)]=n[i]}else r[i]=n[i];return r}function Wa(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}}var $a=class{constructor(e,t){var n;this.options=e,this.currentNode=null,this.tagsNodeStack=[],this.parseXml=eo,this.parseTextData=Ja,this.resolveNameSpace=Ya,this.buildAttributesMap=Za,this.isItStopNode=ao,this.replaceEntitiesValue=ro,this.readStopNodeData=lo,this.saveTextToParentTag=io,this.addChild=no,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,this.doctypefound=!1;let r={...Vi};this.options.entityDecoder?this.entityDecoder=this.options.entityDecoder:("object"==typeof this.options.htmlEntities?r=this.options.htmlEntities:!0===this.options.htmlEntities&&(r={...ji,...Ui}),this.entityDecoder=new Yi({namedEntities:{...r,...t},numericAllowed:this.options.htmlEntities,limit:{maxTotalExpansions:this.options.processEntities.maxTotalExpansions,maxExpandedLength:this.options.processEntities.maxExpandedLength,applyLimitsTo:this.options.processEntities.appliesTo},onInputEntity:(e,t)=>Qa(t,[Na,ka])?zi.BLOCK:zi.ALLOW})),this.matcher=new Pa,this.readonlyMatcher=this.matcher.readOnly(),this.isCurrentNodeStopNode=!1,this.stopNodeExpressionsSet=new Ia;const i=this.options.stopNodes;if(i&&i.length>0){for(let e=0;e<i.length;e++){const t=i[e];"string"==typeof t?this.stopNodeExpressionsSet.add(new Ca(t)):t instanceof Ca&&this.stopNodeExpressionsSet.add(t)}this.stopNodeExpressionsSet.seal()}}};function Ja(e,t,n,r,i,a,o){const s=this.options;if(void 0!==e&&(s.trimValues&&!r&&(e=e.trim()),e.length>0)){o||(e=this.replaceEntitiesValue(e,t,n));const r=s.jPath?n.toString():n,A=s.tagValueProcessor(t,e,r,i,a);return null==A?e:typeof A!=typeof e||A!==e?A:s.trimValues||e.trim()===e?co(e,s.parseTagValue,s.numberParseOptions):e}}function Ya(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}var Xa=new RegExp("([^\\s=]+)\\s*(=\\s*(['\"])([\\s\\S]*?)\\3)?","gm");function Za(e,t,n,r=!1){const i=this.options;if(!0===r||!0!==i.ignoreAttributes&&"string"==typeof e){const r=function(e,t){const n=[];let r=t.exec(e);for(;r;){const i=[];i.startIndex=t.lastIndex-r[0].length;const a=r.length;for(let e=0;e<a;e++)i.push(r[e]);n.push(i),r=t.exec(e)}return n}(e,Xa),a=r.length,o={},s=new Array(a);let A=!1;const l={};for(let e=0;e<a;e++){const t=this.resolveNameSpace(r[e][1]),a=r[e][4];if(t.length&&void 0!==a){let r=a;i.trimValues&&(r=r.trim()),r=this.replaceEntitiesValue(r,n,this.readonlyMatcher),s[e]=r,l[t]=r,A=!0}}A&&"object"==typeof t&&t.updateCurrent&&t.updateCurrent(l);const c=i.jPath?t.toString():this.readonlyMatcher;let u=!1;for(let e=0;e<a;e++){const t=this.resolveNameSpace(r[e][1]);if(this.ignoreAttributesFn(t,c))continue;let n=i.attributeNamePrefix+t;if(t.length)if(i.transformAttributeName&&(n=i.transformAttributeName(n)),n=fo(n,i),void 0!==r[e][4]){const r=s[e],a=i.attributeValueProcessor(t,r,c);o[n]=null==a?r:typeof a!=typeof r||a!==r?a:co(r,i.parseAttributeValue,i.numberParseOptions),u=!0}else i.allowBooleanAttributes&&(o[n]=!0,u=!0)}if(!u)return;if(i.attributesGroupName&&!i.preserveOrder){const e={};return e[i.attributesGroupName]=o,e}return o}}var eo=function(e){const t=this.options,n=t.captureMetaData?[]:void 0;e=e.replace(/\r\n?/g,t.captureMetaData?(e,t)=>(2===e.length&&n.push(t-n.length),"\n"):"\n");const r=new ia("!xml");let i=r,a="";this.matcher.reset(),this.entityDecoder.reset(),this.entityExpansionCount=0,this.currentExpandedLength=0,this.doctypefound=!1;const o=new da(t.processEntities),s=e.length;for(let A=0;A<s;A++)if("<"===e[A]){const l=e.charCodeAt(A+1);if(47===l){const o=oo(e,">",A,"Closing Tag is not closed.");let s=e.substring(A+2,o).trim();if(t.removeNSPrefix){const e=s.indexOf(":");-1!==e&&(s=s.substr(e+1))}s=uo(t.transformTagName,s,"",t).tagName,i&&(a=this.saveTextToParentTag(a,i,this.readonlyMatcher));const l=this.matcher.getCurrentTag();if(s&&t.unpairedTagsSet.has(s))throw new Error(`Unpaired tag can not be used as closing tag: </${s}>`);l&&t.unpairedTagsSet.has(l)&&(this.matcher.pop(),this.tagsNodeStack.pop()),this.matcher.pop(),this.isCurrentNodeStopNode=!1,i=this.tagsNodeStack.pop()||r,t.captureMetaData&&i&&i.addEndIndex(to(o+1,n)),a="",A=o}else if(63===l){let r=Ao(e,A,!1,"?>");if(!r)throw new Error("Pi Tag is not closed.");a=this.saveTextToParentTag(a,i,this.readonlyMatcher);const s=this.buildAttributesMap(r.tagExp,this.matcher,r.tagName,!0);if(s){const e=s[this.options.attributeNamePrefix+"version"];this.entityDecoder.setXmlVersion(Number(e)||1),o.setXmlVersion(Number(e)||1)}if(t.ignoreDeclaration&&"?xml"===r.tagName||t.ignorePiTags);else{const e=new ia(r.tagName);e.add(t.textNodeName,""),r.tagName!==r.tagExp&&r.attrExpPresent&&!0!==t.ignoreAttributes&&(e[":@"]=s);const a=t.captureMetaData?to(A,n):A;this.addChild(i,e,this.readonlyMatcher,a),t.captureMetaData&&i.addEndIndex(to(r.closeIndex+2,n))}A=r.closeIndex+1}else if(33===l&&45===e.charCodeAt(A+2)&&45===e.charCodeAt(A+3)){const n=oo(e,"--\x3e",A+4,"Comment is not closed.");if(t.commentPropName){const r=e.substring(A+4,n-2);a=this.saveTextToParentTag(a,i,this.readonlyMatcher),i.add(t.commentPropName,[{[t.textNodeName]:r}])}A=n}else if(33===l&&68===e.charCodeAt(A+2)){if(this.doctypefound)throw new Error("Multiple DOCTYPE declarations found.");this.doctypefound=!0;const t=o.readDocType(e,A);this.entityDecoder.addInputEntities(t.entities),A=t.i}else if(33===l&&91===e.charCodeAt(A+2)){const n=oo(e,"]]>",A,"CDATA is not closed.")-2,r=e.substring(A+9,n);a=this.saveTextToParentTag(a,i,this.readonlyMatcher);let o=this.parseTextData(r,i.tagname,this.readonlyMatcher,!0,!1,!0,!0);null==o&&(o=""),t.cdataPropName?i.add(t.cdataPropName,[{[t.textNodeName]:r}]):i.add(t.textNodeName,o),A=n+2}else{let o=Ao(e,A,t.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 l=o.tagName;const c=o.rawTagName;let u=o.tagExp,f=o.attrExpPresent,d=o.closeIndex;if(({tagName:l,tagExp:u}=uo(t.transformTagName,l,u,t)),t.strictReservedNames&&(l===t.commentPropName||l===t.cdataPropName||l===t.textNodeName||l===t.attributesGroupName))throw new Error(`Invalid tag name: ${l}`);i&&a&&"!xml"!==i.tagname&&(a=this.saveTextToParentTag(a,i,this.readonlyMatcher,!1));const h=i;h&&t.unpairedTagsSet.has(h.tagname)&&(i=this.tagsNodeStack.pop(),this.matcher.pop());let p=!1;u.length>0&&u.lastIndexOf("/")===u.length-1&&(p=!0,"/"===l[l.length-1]?(l=l.substr(0,l.length-1),u=l):u=u.substr(0,u.length-1),f=l!==u);let m,g=null;m=Wa(c),l!==r.tagname&&this.matcher.push(l,{},m),l!==u&&f&&(g=this.buildAttributesMap(u,this.matcher,l),g&&Ka(g,t)),l!==r.tagname&&(this.isCurrentNodeStopNode=this.isItStopNode());const b=t.captureMetaData?to(A,n):A;if(this.isCurrentNodeStopNode){let r="";if(p)A=o.closeIndex;else if(t.unpairedTagsSet.has(l))A=o.closeIndex;else{const t=this.readStopNodeData(e,c,d+1);if(!t)throw new Error(`Unexpected end of ${c}`);A=t.i,r=t.tagContent}const a=new ia(l);g&&(a[":@"]=g),a.add(t.textNodeName,r),this.matcher.pop(),this.isCurrentNodeStopNode=!1,this.addChild(i,a,this.readonlyMatcher,b),t.captureMetaData&&i.addEndIndex(to(A+1,n))}else{if(p){({tagName:l,tagExp:u}=uo(t.transformTagName,l,u,t));const e=new ia(l);g&&(e[":@"]=g),this.addChild(i,e,this.readonlyMatcher,b),t.captureMetaData&&i.addEndIndex(to(d+1,n)),this.matcher.pop(),this.isCurrentNodeStopNode=!1}else{if(t.unpairedTagsSet.has(l)){const e=new ia(l);g&&(e[":@"]=g),this.addChild(i,e,this.readonlyMatcher,b),t.captureMetaData&&i.addEndIndex(to(o.closeIndex+1,n)),this.matcher.pop(),this.isCurrentNodeStopNode=!1,A=o.closeIndex;continue}{const e=new ia(l);if(this.tagsNodeStack.length>t.maxNestedTags)throw new Error("Maximum nested tags exceeded");this.tagsNodeStack.push(i),g&&(e[":@"]=g),this.addChild(i,e,this.readonlyMatcher,b),i=e}}a="",A=d}}}else a+=e[A];return r.child};function to(e,t){let n=0,r=t.length;for(;n<r;){const i=Math.floor((n+r)/2);t[i]<e?n=i+1:r=i}return e+n}function no(e,t,n,r){this.options.captureMetaData||(r=void 0);const i=this.options.jPath?n.toString():n,a=this.options.updateTag(t.tagname,i,t[":@"]);!1===a||("string"==typeof a?(t.tagname=a,e.addChild(t,r)):e.addChild(t,r))}function ro(e,t,n){const r=this.options.processEntities;if(!r||!r.enabled)return e;if(r.allowedTags){const i=this.options.jPath?n.toString():n;if(!(Array.isArray(r.allowedTags)?r.allowedTags.includes(t):r.allowedTags(t,i)))return e}if(r.tagFilter){const i=this.options.jPath?n.toString():n;if(!r.tagFilter(t,i))return e}return this.entityDecoder.decode(e)}function io(e,t,n,r){return e&&(void 0===r&&(r=0===t.child.length),void 0!==(e=this.parseTextData(e,t.tagname,n,!1,!!t[":@"]&&0!==Object.keys(t[":@"]).length,r))&&""!==e&&t.add(this.options.textNodeName,e),e=""),e}function ao(){return 0!==this.stopNodeExpressionsSet.size&&this.matcher.matchesAny(this.stopNodeExpressionsSet)}function oo(e,t,n,r){const i=e.indexOf(t,n);if(-1===i)throw new Error(r);return i+t.length-1}function so(e,t,n,r){const i=e.indexOf(t,n);if(-1===i)throw new Error(r);return i}function Ao(e,t,n,r=">"){const i=function(e,t,n=">"){let r=0;const i=e.length,a=n.charCodeAt(0),o=n.length>1?n.charCodeAt(1):-1;let s="",A=t;for(let l=t;l<i;l++){const t=e.charCodeAt(l);if(r)t===r&&(r=0);else if(34===t||39===t)r=t;else if(t===a){if(-1===o)return s+=e.substring(A,l),{data:s,index:l};if(e.charCodeAt(l+1)===o)return s+=e.substring(A,l),{data:s,index:l}}else 9!==t||r||(s+=e.substring(A,l)+" ",A=l+1)}}(e,t+1,r);if(!i)return;let a=i.data;const o=i.index,s=a.search(/\s/);let A=a,l=!0;-1!==s&&(A=a.substring(0,s),a=a.substring(s+1).trimStart());const c=A;if(n){const e=A.indexOf(":");-1!==e&&(A=A.substr(e+1),l=A!==i.data.substr(e+1))}return{tagName:A,tagExp:a,closeIndex:o,attrExpPresent:l,rawTagName:c}}function lo(e,t,n){const r=n;let i=1,a=!1,o=-1;const s=e.length;for(;n<s;n++)if("<"===e[n]){const s=e.charCodeAt(n+1);if(47===s){const a=so(e,">",n,`${t} is not closed`);if(e.substring(n+2,a).trim()===t&&(i--,0===i))return{tagContent:e.substring(r,n),i:a};n=a}else if(63===s)n=oo(e,"?>",n+1,"StopNode is not closed.");else if(33===s&&45===e.charCodeAt(n+2)&&45===e.charCodeAt(n+3))n=oo(e,"--\x3e",n+3,"StopNode is not closed.");else if(33===s&&91===e.charCodeAt(n+2))n=oo(e,"]]>",n,"StopNode is not closed.")-2;else{const r=a?void 0:Ao(e,n,!1);if(r)r.tagName===t&&"/"!==r.tagExp[r.tagExp.length-1]&&i++,n=r.closeIndex;else{if(a=!0,o<n&&(o=e.indexOf(">",n),-1===o))return;const r=e.indexOf("<",n+1);if(-1===r||r>o){const r=e.substring(n+1,o),a=r.search(/\s/);(-1===a?r:r.substring(0,a))===t&&"/"!==r[r.length-1]&&i++,n=o}}}}}function co(e,t,n){if(t&&"string"==typeof e){const t=e.trim();return"true"===t||"false"!==t&&Sa(e,n)}return function(e){return void 0!==e}(e)?e:""}function uo(e,t,n,r){if(e){const r=e(t);n===t&&(n=r),t=r}return{tagName:t=fo(t,r),tagExp:n}}function fo(e,t){if(Ti.includes(e))throw new Error(`[SECURITY] Invalid name: "${e}" is a reserved JavaScript keyword that could cause prototype pollution`);return wi.includes(e)?t.onDangerousProperty(e):e}var ho=ia.getMetaDataSymbol();function po(e,t){if(!e||"object"!=typeof e)return{};if(!t)return e;const n={};for(const r in e)if(r.startsWith(t)){n[r.substring(t.length)]=e[r]}else n[r]=e[r];return n}function mo(e,t,n,r){return go(e,t,n,r)}function go(e,t,n,r){let i;const a={};for(let o=0;o<e.length;o++){const s=e[o],A=bo(s);if(void 0!==A&&A!==t.textNodeName){const e=po(s[":@"]||{},t.attributeNamePrefix);n.push(A,e)}if(A===t.textNodeName)void 0===i?i=s[A]:i+=""+s[A];else{if(void 0===A)continue;if(s[A]){let e=go(s[A],t,n,r);const i=yo(e,t);if(0===Object.keys(e).length&&t.alwaysCreateTextNode&&(e[t.textNodeName]=""),s[":@"]?vo(e,s[":@"],r,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!==s[ho]&&"object"==typeof e&&null!==e&&(e[ho]=s[ho]),void 0!==a[A]&&Object.prototype.hasOwnProperty.call(a,A))Array.isArray(a[A])||(a[A]=[a[A]]),a[A].push(e);else{const n=t.jPath?r.toString():r;t.isArray(A,n,i)?a[A]=[e]:a[A]=e}void 0!==A&&A!==t.textNodeName&&n.pop()}}}return"string"==typeof i?i.length>0&&(a[t.textNodeName]=i):void 0!==i&&(a[t.textNodeName]=i),a}function bo(e){const t=Object.keys(e);for(let n=0;n<t.length;n++){const e=t[n];if(":@"!==e)return e}}function vo(e,t,n,r){if(t){const i=Object.keys(t),a=i.length;for(let o=0;o<a;o++){const a=i[o],s=a.startsWith(r.attributeNamePrefix)?a.substring(r.attributeNamePrefix.length):a,A=r.jPath?n.toString()+"."+s:n;r.isArray(a,A,!0,!0)?e[a]=[t[a]]:e[a]=t[a]}}}function yo(e,t){const{textNodeName:n}=t,r=Object.keys(e).length;return 0===r||!(1!==r||!e[n]&&"boolean"!=typeof e[n]&&0!==e[n])}var xo=class{constructor(e){this.externalEntities={},this.options=ra(e)}parse(e,t){if("string"!=typeof e&&e.toString)e=e instanceof Uint8Array&&("undefined"==typeof Buffer||!Buffer.isBuffer(e))?new TextDecoder("utf-8",{ignoreBOM:!0}).decode(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({},Si,t);const n=[];let r=!1,i=!1;"\ufeff"===e[0]&&(e=e.substr(1));for(let a=0;a<e.length;a++)if("<"===e[a]&&"?"===e[a+1]){if(a+=2,a=Ei(e,a),a.err)return a}else{if("<"!==e[a]){if(Mi(e[a]))continue;return Li("InvalidChar","char '"+e[a]+"' is not expected.",Fi(e,a))}{let o=a;if(a++,"!"===e[a]){a=Ci(e,a);continue}{let s=!1;"/"===e[a]&&(s=!0,a++);let A="";for(;a<e.length&&">"!==e[a]&&" "!==e[a]&&"\t"!==e[a]&&"\n"!==e[a]&&"\r"!==e[a];a++)A+=e[a];if(A=A.trim(),"/"===A[A.length-1]&&(A=A.substring(0,A.length-1),a--),!Oi(A)){let t;return t=0===A.trim().length?"Invalid space after '<'.":"Tag '"+A+"' is an invalid name.",Li("InvalidTag",t,Fi(e,a))}const l=Pi(e,a);if(!1===l)return Li("InvalidAttr","Attributes for '"+A+"' have open quote.",Fi(e,a));let c=l.value;if(a=l.index,"/"===c[c.length-1]){const n=a-c.length;c=c.substring(0,c.length-1);const i=Ni(c,t);if(!0!==i)return Li(i.err.code,i.err.msg,Fi(e,n+i.err.line));r=!0}else if(s){if(!l.tagClosed)return Li("InvalidTag","Closing tag '"+A+"' doesn't have proper closing.",Fi(e,a));if(c.trim().length>0)return Li("InvalidTag","Closing tag '"+A+"' can't have attributes or invalid starting.",Fi(e,o));if(0===n.length)return Li("InvalidTag","Closing tag '"+A+"' has not been opened.",Fi(e,o));{const t=n.pop();if(A!==t.tagName){let n=Fi(e,t.tagStartPos);return Li("InvalidTag","Expected closing tag '"+t.tagName+"' (opened in line "+n.line+", col "+n.col+") instead of closing tag '"+A+"'.",Fi(e,o))}0==n.length&&(i=!0)}}else{const s=Ni(c,t);if(!0!==s)return Li(s.err.code,s.err.msg,Fi(e,a-c.length+s.err.line));if(!0===i)return Li("InvalidXml","Multiple possible root nodes found.",Fi(e,a));-1!==t.unpairedTags.indexOf(A)||n.push({tagName:A,tagStartPos:o}),r=!0}for(a++;a<e.length;a++)if("<"===e[a]){if("!"===e[a+1]){a++,a=Ci(e,a);continue}if("?"!==e[a+1])break;if(a=Ei(e,++a),a.err)return a}else if("&"===e[a]){const t=ki(e,a);if(-1==t)return Li("InvalidChar","char '&' is not expected.",Fi(e,a));a=t}else if(!0===i&&!Mi(e[a]))return Li("InvalidXml","Extra text at the end",Fi(e,a));"<"===e[a]&&a--}}}return r?1==n.length?Li("InvalidTag","Unclosed tag '"+n[0].tagName+"'.",Fi(e,n[0].tagStartPos)):!(n.length>0)||Li("InvalidXml","Invalid '"+JSON.stringify(n.map(e=>e.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1}):Li("InvalidXml","Start tag expected.",1)}(e,t);if(!0!==n)throw Error(`${n.err.msg}:${n.err.line}:${n.err.col}`)}const n=new $a(this.options,this.externalEntities),r=n.parseXml(e);return this.options.preserveOrder||void 0===r?r:mo(r,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 ia.getMetaDataSymbol()}};function _o(e,t){if(t?._parser&&"fast-xml-parser"!==t._parser)throw new Error(t?._parser);const n=function(e,t){return new xo({ignoreAttributes:!1,attributeNamePrefix:"",...t}).parse(e)}(e,{allowBooleanAttributes:!0,ignoreDeclaration:!0,removeNSPrefix:t?.removeNSPrefix,textNodeName:t?.textNodeName,isArray:(e,n,r,i)=>Boolean(t?.arrayPaths?.some(e=>n===e)),...t?._fastXML});return t?.uncapitalizeKeys?yi(n):n}var wo={dataType:null,batchType:null,name:"XML",id:"xml",module:"xml",version:"4.5.4",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)=>_o((new TextDecoder).decode(e),{...wo.options.xml,...t?.xml}),parseTextSync:(e,t)=>_o(e,{...wo.options.xml,...t?.xml})};var To={dataType:null,batchType:null,id:"wms-error",name:"WMS Error",module:"wms",version:"4.5.4",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)=>So((new TextDecoder).decode(e),t),parseSync:(e,t)=>So((new TextDecoder).decode(e),t),parseTextSync:(e,t)=>So(e,t)};function So(e,t){const n={...To.options.wms,...t?.wms},r=function(e,t){const n=wo.parseTextSync?.(e,t),r=n?.ServiceExceptionReport?.ServiceException||n?.["ogc:ServiceExceptionReport"]?.["ogc:ServiceException"];return"string"==typeof r?r:r.value||r.code||"Unknown error"}(e,n),i=n.minimalErrors?r:`WMS Service error: ${r}`;if(n.throwOnError)throw new Error(i);return i}function Mo(e){return Array.isArray(e)?e:e?[e]:[]}function Eo(e){const t=Mo(e);return t.length>0&&t.every(e=>"string"==typeof e)?t:[]}function Co(e,t=void 0){switch(typeof e){case"number":return e;case"string":return parseFloat(e);default:return}}function Io(e,t=void 0){switch(typeof e){case"number":return e;case"string":return parseInt(e,10);default:return}}function Ro(e){switch(e){case"true":case"1":return!0;default:return!1}}function Po(e,t){const n=wo.parseTextSync?.(e,t),r=n.WMT_MS_Capabilities||n.WMS_Capabilities||n,i=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:Eo(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:Io(e.Service?.LayerLimit),maxWidth:Io(e.Service?.maxWidth),maxHeight:Io(e.Service?.maxHeight),layers:[],requests:No(e.Capability?.Request),exceptions:ko(e.Exception)},n=Mo(e.Capability?.Layer);for(const r of n)t.layers.push(Lo(r));for(const[r,i]of Object.entries(t))void 0===i&&delete t[r];return t}(r);if(t?.inheritedLayerProps)for(const a of i.layers)Bo(a,null);return t?.includeRawJSON&&(i.json=r),t?.includeXMLText&&(i.xml=e),i}function No(e){const t={};for(const[n,r]of Object.entries(e||{}))t[n]={mimeTypes:Eo(r?.Format)};return t}function ko(e){if(Mo(e?.Format).length>0)return{mimeTypes:Eo(e)}}function Lo(e){const t={title:String(e?.Title||""),name:e?.Name&&String(e?.Name),abstract:e?.Name&&String(e?.Abstract),keywords:Eo(e.KeywordList?.Keyword)},n=e?.CRS||e?.SRS;n&&Array.isArray(n)&&n.every(e=>"string"==typeof e)&&(t.crs=n);let r=e?.EX_GeographicBoundingBox&&function(e){const{westBoundLongitude:t,northBoundLatitude:n,eastBoundLongitude:r,southBoundLatitude:i}=e;return[[t,i],[r,n]]}(e?.EX_GeographicBoundingBox);r&&(t.geographicBoundingBox=r),r=e?.LatLonBoundingBox&&function(e){const{minx:t,miny:n,maxx:r,maxy:i}=e;return[[t,n],[r,i]]}(e?.LatLonBoundingBox),r&&(t.geographicBoundingBox=r);const i=e?.BoundingBox&&(a=e?.BoundingBox,Mo(a).map(e=>function(e){const{CRS:t,SRS:n,minx:r,miny:i,maxx:a,maxy:o,resx:s,resy:A}=e,l={crs:t||n,boundingBox:[[Co(r),Co(i)],[Co(a),Co(o)]]};return s&&(l.xResolution=s),A&&(l.yResolution=A),l}(e)));var a;i&&i.length>0&&(t.boundingBoxes=i);const o=Mo(e?.Dimension).map(e=>function(e){const{name:t,units:n,value:r}=e,i={name:t,units:n,extent:r};e.unitSymbol&&(i.unitSymbol=e.unitSymbol);e.default&&(i.defaultValue=e.default);e.multipleValues&&(i.multipleValues=Ro(e.multipleValues));e.nearestValue&&(i.nearestValue=Ro(e.nearestValue));e.current&&(i.current=Ro(e.current));return i}(e));o.length&&(t.dimensions=o),e?.opaque&&(t.opaque=Ro(e?.opaque)),e?.cascaded&&(t.cascaded=Ro(e?.cascaded)),e?.queryable&&(t.queryable=Ro(e?.queryable));const s=Mo(e?.Layer),A=[];for(const l of s)A.push(Lo(l));A.length>0&&(t.layers=A);for(const[l,c]of Object.entries(t))void 0===c&&delete t[l];return t}function Bo(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||[])Bo(n,e)}var Oo={dataType:null,batchType:null,id:"wms-capabilities",name:"WMS Capabilities",module:"wms",version:"4.5.4",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)=>Po((new TextDecoder).decode(e),t?.wms),parseTextSync:(e,t)=>Po(e,t?.wms)};function Fo(e,t){const n=(wo.parseTextSync?.(e,t)).FeatureInfoResponse?.FIELDS||[];return{features:(Array.isArray(n)?n:[n]).map(e=>function(e){return{attributes:e||{},type:"",bounds:{bottom:0,top:0,left:0,right:0}}}(e))}}var Do={...Oo,dataType:null,id:"wms-feature-info",name:"WMS FeatureInfo",parse:async(e,t)=>Fo((new TextDecoder).decode(e),t),parseTextSync:(e,t)=>Fo(e,t)};function Uo(e,t){return wo.parseTextSync?.(e,t)}var Vo={...Oo,dataType:null,id:"wms-layer-description",name:"WMS DescribeLayer",parse:async(e,t)=>Uo((new TextDecoder).decode(e),t),parseTextSync:(e,t)=>Uo(e,t)},jo={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 zo(e,t)},zo=class extends b{substituteCRS84;flipCRS;wmsParameters;vendorParameters;capabilities=null;constructor(e,t){super(e,t,jo.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,...r}=e,i={bbox:t?[...t[0],...t[1]]:n,...r};return await this.getMap(i)}normalizeMetadata(e){return e}async getCapabilities(e,t){const n=this.getCapabilitiesURL(e,t),r=await this.fetch(n),i=await r.arrayBuffer();this._checkResponse(r,i);const a=await Oo.parse(i,this.loadOptions);return this.capabilities=a,a}async getMap(e,t){const n=this.getMapURL(e,t),i=await this.fetch(n),a=await i.arrayBuffer();this._checkResponse(i,a);try{return await r.ImageLoader.parse(a,this.loadOptions)}catch{throw this._parseError(a)}}async getFeatureInfo(e,t){const n=this.getFeatureInfoURL(e,t),r=await this.fetch(n),i=await r.arrayBuffer();return this._checkResponse(r,i),await Do.parse(i,this.loadOptions)}async getFeatureInfoText(e,t){const n=this.getFeatureInfoURL(e,t),r=await this.fetch(n),i=await r.arrayBuffer();return this._checkResponse(r,i),(new TextDecoder).decode(i)}async describeLayer(e,t){const n=this.describeLayerURL(e,t),r=await this.fetch(n),i=await r.arrayBuffer();return this._checkResponse(r,i),await Vo.parse(i,this.loadOptions)}async getLegendGraphic(e,t){const n=this.getLegendGraphicURL(e,t),i=await this.fetch(n),a=await i.arrayBuffer();this._checkResponse(i,a);try{return await r.ImageLoader.parse(a,this.loadOptions)}catch{throw this._parseError(a)}}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:r}=e;e.bbox=n?[...n[0],...n[1]]:r;const i={version:this.wmsParameters.version,info_format:this.wmsParameters.info_format,layers:this.wmsParameters.layers,query_layers:this.wmsParameters.query_layers,styles:this.wmsParameters.styles,crs:this.wmsParameters.crs,...e};return this._getWMSUrl("GetFeatureInfo",i,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("?"),r=n.split("&"),i={};for(const a of r){const[e,t]=a.split("=");i[e]=t}return{url:t,parameters:i}}_getWMSUrl(e,t,n){let r=this.url,i=!0;const a={service:"WMS",version:t.version,request:e,...t,...this.vendorParameters,...n},o=["transparent","time","elevation"];for(const[s,A]of Object.entries(a))o.includes(s)&&!A||(r+=i?"?":"&",i=!1,r+=this._getURLParameter(s,A,t));return encodeURI(r)}_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 r=this._flipBoundingBox(t,n);r&&(t=r);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 r=e.headers["content-type"];if(!e.ok||To.mimeTypes.includes(r)){const e=n.mergeOptions(this.loadOptions,{wms:{throwOnError:!0}}),r=To.parseSync?.(t,e);throw new Error(r)}}_parseError(e){const t=To.parseSync?.(e,this.options.core?.loadOptions);return new Error(t)}},Go=6378137*Math.PI;function Ho(e){const t=n.lngLatToWorld(e);return t[0]=(t[0]/256-1)*Go,t[1]=(t[1]/256-1)*Go,t}var qo={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)=>console.error(t,e)}},Qo=class extends t.CompositeLayer{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:r}){const{viewport:i}=this.context;e.dataChanged||t.serviceType!==r.serviceType?(this.state.imageSource=this._createImageSource(t),this._loadMetadata(),this.debounce(()=>this.loadImage(i,"image source changed"),0)):n.deepEqual(t.layers,r.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:r,lastRequestParameters:i}=this.state;return r&&new t.BitmapLayer({...this.getSubLayerProps({id:"bitmap"}),_imageCoordinateSystem:"EPSG:4326"===i.srs?n.COORDINATE_SYSTEM.LNGLAT:n.COORDINATE_SYSTEM.CARTESIAN,bounds:e,image:r})}async getFeatureInfoText(e,t){const{lastRequestParameters:n}=this.state;return n?await(this.state.imageSource.getFeatureInfoText?.({...n,query_layers:n.layers,x:e,y:t,info_format:"application/vnd.ogc.gml"})):""}_createImageSource(e){if(e.data instanceof v)return e.data;if("string"==typeof e.data)return function(e,t,n){const r=n?.core?.type||n.type||"auto",i="auto"===r?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}(r,t);if(!i)throw new Error("Not a valid source type");return i.createDataSource(e,n)}(e.data,[jo],{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:r}=this.props;if("wms"===r&&0===n.length)return;const i=e.getBounds(),{width:a,height:o}=e,s=this.getRequestId();let{srs:A}=this.props;"auto"===A&&(A=e.resolution?"EPSG:4326":"EPSG:3857");const l={width:a,height:o,boundingBox:[[i[0],i[1]],[i[2],i[3]]],layers:n,crs:A};"EPSG:3857"===A&&(l.boundingBox=[Ho([i[0],i[1]]),Ho([i[2],i[3]])]);try{this.state.loadCounter++,this.props.onImageLoadStart(s);const e=await this.state.imageSource.getImage(l);this.state.lastRequestId<s&&(this.getCurrentLayer()?.props.onImageLoad(s),this.setState({image:e,bounds:i,lastRequestParameters:l,lastRequestId:s}))}catch(c){this.raiseError(c,"Load image"),this.getCurrentLayer()?.props.onImageLoadError(s,c)}finally{this.state.loadCounter--}}getRequestId(){return this.state._nextRequestId++}debounce(e,t=500){clearTimeout(this.state._timeoutId),this.state._timeoutId=setTimeout(()=>e(),t)}};Qo.layerName="WMSLayer",Qo.defaultProps=qo;var Ko=class extends t.ArcLayer{};Ko.layerName="GreatCircleLayer",Ko.defaultProps={getHeight:{type:"accessor",value:0},greatCircle:!0};var Wo=e.__commonJSMin((e,t,n)=>{!function(e,n){"function"==typeof define&&define.amd?define([],n):"function"==typeof require&&"object"==typeof t&&t&&t.exports?t.exports=n():(e.dcodeIO=e.dcodeIO||{}).Long=n()}(n,function(){"use strict";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={},r={};function i(e,t){var i,a,s;return t?(s=0<=(e>>>=0)&&e<256)&&(a=r[e])?a:(i=o(e,(0|e)<0?-1:0,!0),s&&(r[e]=i),i):(s=-128<=(e|=0)&&e<128)&&(a=n[e])?a:(i=o(e,e<0?-1:0,!1),s&&(n[e]=i),i)}function a(e,t){if(isNaN(e)||!isFinite(e))return t?p:h;if(t){if(e<0)return p;if(e>=u)return y}else{if(e<=-f)return x;if(e+1>=f)return v}return e<0?a(-e,t).neg():o(e%c|0,e/c|0,t)}function o(t,n,r){return new e(t,n,r)}e.fromInt=i,e.fromNumber=a,e.fromBits=o;var s=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 h;if("number"==typeof t?(n=t,t=!1):t=!!t,(n=n||10)<2||36<n)throw RangeError("radix");var r;if((r=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===r)return A(e.substring(1),t,n).neg();for(var i=a(s(n,8)),o=h,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=a(s(n,c));o=o.mul(f).add(a(u))}else o=(o=o.mul(i)).add(a(u))}return o.unsigned=t,o}function l(t){return t instanceof e?t:"number"==typeof t?a(t):"string"==typeof t?A(t):o(t.low,t.high,t.unsigned)}e.fromString=A,e.fromValue=l;var c=4294967296,u=c*c,f=u/2,d=i(1<<24),h=i(0);e.ZERO=h;var p=i(0,!0);e.UZERO=p;var m=i(1);e.ONE=m;var g=i(1,!0);e.UONE=g;var b=i(-1);e.NEG_ONE=b;var v=o(-1,2147483647,!1);e.MAX_VALUE=v;var y=o(-1,-1,!0);e.MAX_UNSIGNED_VALUE=y;var x=o(0,-2147483648,!1);e.MIN_VALUE=x;var _=e.prototype;return _.toInt=function(){return this.unsigned?this.low>>>0:this.low},_.toNumber=function(){return this.unsigned?(this.high>>>0)*c+(this.low>>>0):this.high*c+(this.low>>>0)},_.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(x)){var t=a(e),n=this.div(t),r=n.mul(t).sub(this);return n.toString(e)+r.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var i=a(s(e,6),this.unsigned),o=this,A="";;){var l=o.div(i),c=(o.sub(l.mul(i)).toInt()>>>0).toString(e);if((o=l).isZero())return c+A;for(;c.length<6;)c="0"+c;A=""+c+A}},_.getHighBits=function(){return this.high},_.getHighBitsUnsigned=function(){return this.high>>>0},_.getLowBits=function(){return this.low},_.getLowBitsUnsigned=function(){return this.low>>>0},_.getNumBitsAbs=function(){if(this.isNegative())return this.eq(x)?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},_.isZero=function(){return 0===this.high&&0===this.low},_.isNegative=function(){return!this.unsigned&&this.high<0},_.isPositive=function(){return this.unsigned||this.high>=0},_.isOdd=function(){return!(1&~this.low)},_.isEven=function(){return!(1&this.low)},_.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)},_.eq=_.equals,_.notEquals=function(e){return!this.eq(e)},_.neq=_.notEquals,_.lessThan=function(e){return this.comp(e)<0},_.lt=_.lessThan,_.lessThanOrEqual=function(e){return this.comp(e)<=0},_.lte=_.lessThanOrEqual,_.greaterThan=function(e){return this.comp(e)>0},_.gt=_.greaterThan,_.greaterThanOrEqual=function(e){return this.comp(e)>=0},_.gte=_.greaterThanOrEqual,_.compare=function(e){if(t(e)||(e=l(e)),this.eq(e))return 0;var n=this.isNegative(),r=e.isNegative();return n&&!r?-1:!n&&r?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},_.comp=_.compare,_.negate=function(){return!this.unsigned&&this.eq(x)?x:this.not().add(m)},_.neg=_.negate,_.add=function(e){t(e)||(e=l(e));var n=this.high>>>16,r=65535&this.high,i=this.low>>>16,a=65535&this.low,s=e.high>>>16,A=65535&e.high,c=e.low>>>16,u=0,f=0,d=0,h=0;return d+=(h+=a+(65535&e.low))>>>16,f+=(d+=i+c)>>>16,u+=(f+=r+A)>>>16,u+=n+s,o((d&=65535)<<16|(h&=65535),(u&=65535)<<16|(f&=65535),this.unsigned)},_.subtract=function(e){return t(e)||(e=l(e)),this.add(e.neg())},_.sub=_.subtract,_.multiply=function(e){if(this.isZero())return h;if(t(e)||(e=l(e)),e.isZero())return h;if(this.eq(x))return e.isOdd()?x:h;if(e.eq(x))return this.isOdd()?x:h;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(d)&&e.lt(d))return a(this.toNumber()*e.toNumber(),this.unsigned);var n=this.high>>>16,r=65535&this.high,i=this.low>>>16,s=65535&this.low,A=e.high>>>16,c=65535&e.high,u=e.low>>>16,f=65535&e.low,p=0,m=0,g=0,b=0;return g+=(b+=s*f)>>>16,m+=(g+=i*f)>>>16,g&=65535,m+=(g+=s*u)>>>16,p+=(m+=r*f)>>>16,m&=65535,p+=(m+=i*u)>>>16,m&=65535,p+=(m+=s*c)>>>16,p+=n*f+r*u+i*c+s*A,o((g&=65535)<<16|(b&=65535),(p&=65535)<<16|(m&=65535),this.unsigned)},_.mul=_.multiply,_.divide=function(e){if(t(e)||(e=l(e)),e.isZero())throw Error("division by zero");if(this.isZero())return this.unsigned?p:h;var n,r,i;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return p;if(e.gt(this.shru(1)))return g;i=p}else{if(this.eq(x))return e.eq(m)||e.eq(b)?x:e.eq(x)?m:(n=this.shr(1).div(e).shl(1)).eq(h)?e.isNegative()?m:b:(r=this.sub(e.mul(n)),i=n.add(r.div(e)));if(e.eq(x))return this.unsigned?p:h;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=h}for(r=this;r.gte(e);){n=Math.max(1,Math.floor(r.toNumber()/e.toNumber()));for(var o=Math.ceil(Math.log(n)/Math.LN2),A=o<=48?1:s(2,o-48),c=a(n),u=c.mul(e);u.isNegative()||u.gt(r);)u=(c=a(n-=A,this.unsigned)).mul(e);c.isZero()&&(c=m),i=i.add(c),r=r.sub(u)}return i},_.div=_.divide,_.modulo=function(e){return t(e)||(e=l(e)),this.sub(this.div(e).mul(e))},_.mod=_.modulo,_.not=function(){return o(~this.low,~this.high,this.unsigned)},_.and=function(e){return t(e)||(e=l(e)),o(this.low&e.low,this.high&e.high,this.unsigned)},_.or=function(e){return t(e)||(e=l(e)),o(this.low|e.low,this.high|e.high,this.unsigned)},_.xor=function(e){return t(e)||(e=l(e)),o(this.low^e.low,this.high^e.high,this.unsigned)},_.shiftLeft=function(e){return t(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?o(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):o(0,this.low<<e-32,this.unsigned)},_.shl=_.shiftLeft,_.shiftRight=function(e){return t(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?o(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):o(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},_.shr=_.shiftRight,_.shiftRightUnsigned=function(e){if(t(e)&&(e=e.toInt()),0===(e&=63))return this;var n=this.high;return e<32?o(this.low>>>e|n<<32-e,n>>>e,this.unsigned):o(32===e?n:n>>>e-32,0,this.unsigned)},_.shru=_.shiftRightUnsigned,_.toSigned=function(){return this.unsigned?o(this.low,this.high,!1):this},_.toUnsigned=function(){return this.unsigned?this:o(this.low,this.high,!0)},_.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},_.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]},_.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})}),$o=e.__toESM(Wo(),1),Jo=180/Math.PI;function Yo(e,t,n){const r=1<<t;return[(e[0]+n[0])/r,(e[1]+n[1])/r]}function Xo(e){return e>=.5?1/3*(4*e*e-1):1/3*(1-4*(1-e)*(1-e))}function Zo(e){return[Xo(e[0]),Xo(e[1])]}function es(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 ts([e,t,n]){const r=Math.atan2(n,Math.sqrt(e*e+t*t));return[Math.atan2(t,e)*Jo,r*Jo]}function ns(e,t,n,r){if(0===r){1===n&&(t[0]=e-1-t[0],t[1]=e-1-t[1]);const r=t[0];t[0]=t[1],t[1]=r}}function rs(e){if("string"==typeof e){if(e.indexOf("/")>0)return e;e=function(e){const t=e.padEnd(16,"0");return $o.default.fromString(t,16)}(e)}return function(e){let t=$o.default.fromString(e,!0,10).toString(2);for(;t.length<64;)t="0"+t;const n=t.lastIndexOf("1"),r=t.substring(0,3),i=t.substring(3,n),a=i.length/2,o=$o.default.fromString(r,!0,2).toString(10);let s=$o.default.fromString(i,!0,2).toString(4);for(;s.length<a;)s="0"+s;return`${o}/${s}`}(e.toString())}function is(e){return function({face:e,ij:t,level:n}){const r=[[0,0],[0,1],[1,1],[1,0],[0,0]],i=Math.max(1,Math.ceil(100*Math.pow(2,-n))),a=new Float64Array(4*i*2+2);let o=0,s=0;for(let A=0;A<4;A++){const l=r[A].slice(0),c=r[A+1],u=(c[0]-l[0])/i,f=(c[1]-l[1])/i;for(let r=0;r<i;r++){l[0]+=u,l[1]+=f;const r=ts(es(e,Zo(Yo(t,n,l))));Math.abs(r[1])>89.999&&(r[0]=s);const i=r[0]-s;r[0]+=i>180?-360:i<-180?360:0,a[o++]=r[0],a[o++]=r[1],s=r[0]}}return a[o++]=a[0],a[o++]=a[1],a}(function(e){const t=e.split("/"),n=parseInt(t[0],10),r=t[1],i=r.length,a=[0,0];let o;for(let s=i-1;s>=0;s--){o=i-s;const e=r[s];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);ns(A,a,t,n),a[0]+=A*t,a[1]+=A*n}if(n%2==1){const e=a[0];a[0]=a[1],a[1]=e}return{face:n,ij:a,level:o}}(rs(e)))}var as=class extends st{indexToBounds(){const{data:e,getS2Token:t}=this.props;return{data:e,_normalize:!1,positionFormat:"XY",getPolygon:(e,n)=>is(t(e,n))}}};as.layerName="S2Layer",as.defaultProps={getS2Token:{type:"accessor",value:e=>e.token}};function os(e,t=1){const[r,i]=function(e,t){let n=0,r=0,i=1<<e.length;const a=i/512;for(let o=0;o<e.length;o++){i>>=1;const t=parseInt(e[o]);t%2&&(n|=i),t>1&&(r|=i)}return[[n/a,512-r/a],[(n+t)/a,512-(r+t)/a]]}(e,t),[a,o]=n.worldToLngLat(r),[s,A]=n.worldToLngLat(i);return[s,o,s,A,a,A,a,o,s,o]}var ss=class extends st{indexToBounds(){const{data:e,extruded:t,getQuadkey:n}=this.props,r=t?.99:1;return{data:e,_normalize:!1,positionFormat:"XY",getPolygon:(e,t)=>os(n(e,t),r),updateTriggers:{getPolygon:r}}}};ss.layerName="QuadkeyLayer",ss.defaultProps={getQuadkey:{type:"accessor",value:e=>e.quadkey}};var As=class{constructor(e){this.index=e,this.isVisible=!1,this.isSelected=!1,this.parent=null,this.children=[],this.content=null,this._loader=void 0,this._abortController=null,this._loaderId=0,this._isLoaded=!1,this._isCancelled=!1,this._needsReload=!1}get bbox(){return this._bbox}set bbox(e){this._bbox||(this._bbox=e,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)||console.error("byteLength not defined in tile data"),e}async _loadData({getData:e,getRequestPriority:t,requestScheduler:n,onLoad:r,onError:i}){const{index:a,id:o,bbox:s,userData:A,zoom:l}=this,c=this._loaderId;this._abortController=new AbortController;const{signal:u}=this._abortController,f=await n.scheduleRequest(this,t);if(!f)return void(this._isCancelled=!0);if(this._isCancelled)return void f.done();let d,h=null;try{h=await e({index:a,id:o,bbox:s,userData:A,zoom:l,signal:u})}catch(p){d=p||!0}finally{f.done()}c===this._loaderId&&(this._loader=void 0,this.content=h,!this._isCancelled||h?(this._isLoaded=!0,this._isCancelled=!1,d?i(d,this):r(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())}},ls=-1,cs=0,us=1,fs=new n.Vector3,ds=new n.Vector3,hs=class e{constructor(e=[0,0,0],t=[0,0,0],r){r=r||fs.copy(e).add(t).scale(.5),this.center=new n.Vector3(r),this.halfDiagonal=new n.Vector3(t).subtract(this.center),this.minimum=new n.Vector3(e),this.maximum=new n.Vector3(t)}clone(){return new e(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=ds.from(e.normal),r=t.x*Math.abs(n.x)+t.y*Math.abs(n.y)+t.z*Math.abs(n.z),i=this.center.dot(n)+e.distance;return i-r>0?us:i+r<0?ls:cs}distanceTo(e){return Math.sqrt(this.distanceSquaredTo(e))}distanceSquaredTo(e){const t=fs.from(e).subtract(this.center),{halfDiagonal:n}=this;let r,i=0;return r=Math.abs(t.x)-n.x,r>0&&(i+=r*r),r=Math.abs(t.y)-n.y,r>0&&(i+=r*r),r=Math.abs(t.z)-n.z,r>0&&(i+=r*r),i}},ps=new n.Vector3,ms=new n.Vector3,gs=class e{constructor(e=[0,0,0],t=0){this.radius=-0,this.center=new n.Vector3,this.fromCenterRadius(e,t)}fromCenterRadius(e,t){return this.center.from(e),this.radius=t,this}fromCornerPoints(e,t){return t=ps.from(t),this.center=(new n.Vector3).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 e(this.center,this.radius)}union(e){const t=this.center,n=this.radius,r=e.center,i=e.radius,a=ps.copy(r).subtract(t),o=a.magnitude();if(n>=o+i)return this.clone();if(i>=o+n)return e.clone();const s=.5*(n+o+i);return ms.copy(a).scale((-n+s)/o).add(t),this.center.copy(ms),this.radius=s,this}expand(e){const t=ps.from(e).subtract(this.center).magnitude();return t>this.radius&&(this.radius=t),this}transform(e){this.center.transform(e);const t=n.getScaling(ps,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=ps.from(e).subtract(this.center);return Math.max(0,t.len()-this.radius)}intersectPlane(e){const t=this.center,n=this.radius,r=e.normal.dot(t)+e.distance;return r<-n?ls:r<n?cs:us}},bs=new n.Vector3,vs=new n.Vector3,ys=new n.Vector3,xs=new n.Vector3,_s=new n.Vector3,ws=new n.Vector3,Ts=new n.Vector3,Ss=0,Ms=1,Es=2,Cs=3,Is=4,Rs=5,Ps=6,Ns=7,ks=8,Ls=class e{constructor(e=[0,0,0],t=[0,0,0,0,0,0,0,0,0]){this.center=(new n.Vector3).from(e),this.halfAxes=new L(t)}get halfSize(){const e=this.halfAxes.getColumn(0),t=this.halfAxes.getColumn(1),r=this.halfAxes.getColumn(2);return[new n.Vector3(e).len(),new n.Vector3(t).len(),new n.Vector3(r).len()]}get quaternion(){const e=this.halfAxes.getColumn(0),t=this.halfAxes.getColumn(1),i=this.halfAxes.getColumn(2),a=new n.Vector3(e).normalize(),o=new n.Vector3(t).normalize(),s=new n.Vector3(i).normalize();return(new r.Quaternion).fromMatrix3(new L([...a,...o,...s]))}fromCenterHalfSizeQuaternion(e,t,i){const a=new r.Quaternion(i),o=(new L).fromQuaternion(a);return o[0]=o[0]*t[0],o[1]=o[1]*t[0],o[2]=o[2]*t[0],o[3]=o[3]*t[1],o[4]=o[4]*t[1],o[5]=o[5]*t[1],o[6]=o[6]*t[2],o[7]=o[7]*t[2],o[8]=o[8]*t[2],this.center=(new n.Vector3).from(e),this.halfAxes=o,this}clone(){return new e(this.center,this.halfAxes)}equals(e){return this===e||Boolean(e)&&this.center.equals(e.center)&&this.halfAxes.equals(e.halfAxes)}getBoundingSphere(e=new gs){const t=this.halfAxes,n=t.getColumn(0,ys),r=t.getColumn(1,xs),i=t.getColumn(2,_s),a=bs.copy(n).add(r).add(i);return e.center.copy(this.center),e.radius=a.magnitude(),e}intersectPlane(e){const t=this.center,n=e.normal,r=this.halfAxes,i=n.x,a=n.y,o=n.z,s=Math.abs(i*r[Ss]+a*r[Ms]+o*r[Es])+Math.abs(i*r[Cs]+a*r[Is]+o*r[Rs])+Math.abs(i*r[Ps]+a*r[Ns]+o*r[ks]),A=n.dot(t)+e.distance;return A<=-s?ls:A>=s?us:cs}distanceTo(e){return Math.sqrt(this.distanceSquaredTo(e))}distanceSquaredTo(e){const t=vs.from(e).subtract(this.center),n=this.halfAxes,r=n.getColumn(0,ys),i=n.getColumn(1,xs),a=n.getColumn(2,_s),o=r.magnitude(),s=i.magnitude(),A=a.magnitude();r.normalize(),i.normalize(),a.normalize();let l,c=0;return l=Math.abs(t.dot(r))-o,l>0&&(c+=l*l),l=Math.abs(t.dot(i))-s,l>0&&(c+=l*l),l=Math.abs(t.dot(a))-A,l>0&&(c+=l*l),c}computePlaneDistances(e,t,n=[-0,-0]){let r=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY;const a=this.center,o=this.halfAxes,s=o.getColumn(0,ys),A=o.getColumn(1,xs),l=o.getColumn(2,_s),c=ws.copy(s).add(A).add(l).add(a),u=Ts.copy(c).subtract(e);let f=t.dot(u);return r=Math.min(f,r),i=Math.max(f,i),c.copy(a).add(s).add(A).subtract(l),u.copy(c).subtract(e),f=t.dot(u),r=Math.min(f,r),i=Math.max(f,i),c.copy(a).add(s).subtract(A).add(l),u.copy(c).subtract(e),f=t.dot(u),r=Math.min(f,r),i=Math.max(f,i),c.copy(a).add(s).subtract(A).subtract(l),u.copy(c).subtract(e),f=t.dot(u),r=Math.min(f,r),i=Math.max(f,i),a.copy(c).subtract(s).add(A).add(l),u.copy(c).subtract(e),f=t.dot(u),r=Math.min(f,r),i=Math.max(f,i),a.copy(c).subtract(s).add(A).subtract(l),u.copy(c).subtract(e),f=t.dot(u),r=Math.min(f,r),i=Math.max(f,i),a.copy(c).subtract(s).subtract(A).add(l),u.copy(c).subtract(e),f=t.dot(u),r=Math.min(f,r),i=Math.max(f,i),a.copy(c).subtract(s).subtract(A).subtract(l),u.copy(c).subtract(e),f=t.dot(u),r=Math.min(f,r),i=Math.max(f,i),n[0]=r,n[1]=i,n}transform(e){this.center.transformAsPoint(e);const t=this.halfAxes.getColumn(0,ys);t.transformAsPoint(e);const n=this.halfAxes.getColumn(1,xs);n.transformAsPoint(e);const r=this.halfAxes.getColumn(2,_s);return r.transformAsPoint(e),this.halfAxes=new L([...t,...n,...r]),this}getTransform(){throw new Error("not implemented")}},Bs=new n.Vector3,Os=new n.Vector3,Fs=class e{constructor(e=[0,0,1],t=0){this.normal=new n.Vector3,this.distance=-0,this.fromNormalDistance(e,t)}fromNormalDistance(e,t){return n.assert$1(Number.isFinite(t)),this.normal.from(e).normalize(),this.distance=t,this}fromPointNormal(e,t){e=Bs.from(e),this.normal.from(t).normalize();const n=-this.normal.dot(e);return this.distance=n,this}fromCoefficients(e,t,r,i){return this.normal.set(e,t,r),n.assert$1(n.equals(this.normal.len(),1)),this.distance=i,this}clone(){return new e(this.normal,this.distance)}equals(e){return n.equals(this.distance,e.distance)&&n.equals(this.normal,e.normal)}getPointDistance(e){return this.normal.dot(e)+this.distance}transform(e){const t=Os.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=Bs.from(e),r=this.getPointDistance(n),i=Os.copy(this.normal).scale(r);return n.subtract(i).to(t)}},Ds=[new n.Vector3([1,0,0]),new n.Vector3([0,1,0]),new n.Vector3([0,0,1])],Us=new n.Vector3,Vs=new n.Vector3,js=class e{constructor(e=[]){this.planes=e}fromBoundingSphere(e){this.planes.length=2*Ds.length;const t=e.center,n=e.radius;let r=0;for(const i of Ds){let e=this.planes[r],a=this.planes[r+1];e||(e=this.planes[r]=new Fs),a||(a=this.planes[r+1]=new Fs);const o=Us.copy(i).scale(-n).add(t);e.fromPointNormal(o,i);const s=Us.copy(i).scale(n).add(t),A=Vs.copy(i).negate();a.fromPointNormal(s,A),r+=2}return this}computeVisibility(e){let t=us;for(const n of this.planes)switch(e.intersectPlane(n)){case ls:return ls;case cs:t=cs}return t}computeVisibilityWithPlaneMask(t,r){if(n.assert$1(Number.isFinite(r),"parentPlaneMask is required."),r===e.MASK_OUTSIDE||r===e.MASK_INSIDE)return r;let i=e.MASK_INSIDE;const a=this.planes;for(let n=0;n<this.planes.length;++n){const o=n<31?1<<n:0;if(n<31&&0===(r&o))continue;const s=a[n],A=t.intersectPlane(s);if(A===ls)return e.MASK_OUTSIDE;A===cs&&(i|=o)}return i}};js.MASK_OUTSIDE=4294967295,js.MASK_INSIDE=0,js.MASK_INDETERMINATE=2147483647;new n.Vector3,new n.Vector3,new n.Vector3,new n.Vector3,new n.Vector3,new n.Vector3,new n.Vector3,new n.Vector3,new n.Vector3,new n.Vector3,new n.Vector3,new n.Vector3,new n.Vector3,new n.Vector3,new n.Vector3,new n.Vector3,new n.Vector3;var zs=new L,Gs=new L,Hs=new L,qs=new L,Qs=new L;function Ks(e,t={}){let n=0,r=0;const i=Gs,a=Hs;i.identity(),a.copy(e);const o=1e-20*function(e){let t=0;for(let n=0;n<9;++n){const r=e[n];t+=r*r}return Math.sqrt(t)}(a);for(;r<10&&Js(a)>o;)Ys(a,qs),Qs.copy(qs).transpose(),a.multiplyRight(qs),a.multiplyLeft(Qs),i.multiplyRight(qs),++n>2&&(++r,n=0);return t.unitary=i.toTarget(t.unitary),t.diagonal=a.toTarget(t.diagonal),t}var Ws=[1,0,0],$s=[2,2,1];function Js(e){let t=0;for(let n=0;n<3;++n){const r=e[zs.getElementIndex($s[n],Ws[n])];t+=2*r*r}return Math.sqrt(t)}function Ys(e,t){let n=0,r=1;for(let A=0;A<3;++A){const t=Math.abs(e[zs.getElementIndex($s[A],Ws[A])]);t>n&&(r=A,n=t)}const i=Ws[r],a=$s[r];let o=1,s=0;if(Math.abs(e[zs.getElementIndex(a,i)])>1e-15){const t=(e[zs.getElementIndex(a,a)]-e[zs.getElementIndex(i,i)])/2/e[zs.getElementIndex(a,i)];let n;n=t<0?-1/(-t+Math.sqrt(1+t*t)):1/(t+Math.sqrt(1+t*t)),o=1/Math.sqrt(1+n*n),s=n*o}return L.IDENTITY.to(t),t[zs.getElementIndex(i,i)]=t[zs.getElementIndex(a,a)]=o,t[zs.getElementIndex(a,i)]=s,t[zs.getElementIndex(i,a)]=-s,t}var Xs=new n.Vector3,Zs=new n.Vector3,eA=new n.Vector3,tA=new n.Vector3,nA=new n.Vector3,rA=new L,iA={diagonal:new L,unitary:new L};function aA(e,t=new Ls){if(!e||0===e.length)return t.halfAxes=new L([0,0,0,0,0,0,0,0,0]),t.center=new n.Vector3,t;const r=e.length,i=new n.Vector3(0,0,0);for(const n of e)i.add(n);const a=1/r;i.multiplyByScalar(a);let o=0,s=0,A=0,l=0,c=0,u=0;for(const n of e){const e=Xs.copy(n).subtract(i);o+=e.x*e.x,s+=e.x*e.y,A+=e.x*e.z,l+=e.y*e.y,c+=e.y*e.z,u+=e.z*e.z}o*=a,s*=a,A*=a,l*=a,c*=a,u*=a;const f=rA;f[0]=o,f[1]=s,f[2]=A,f[3]=s,f[4]=l,f[5]=c,f[6]=A,f[7]=c,f[8]=u;const{unitary:d}=Ks(f,iA),h=t.halfAxes.copy(d);let p=h.getColumn(0,eA),m=h.getColumn(1,tA),g=h.getColumn(2,nA),b=-Number.MAX_VALUE,v=-Number.MAX_VALUE,y=-Number.MAX_VALUE,x=Number.MAX_VALUE,_=Number.MAX_VALUE,w=Number.MAX_VALUE;for(const n of e)Xs.copy(n),b=Math.max(Xs.dot(p),b),v=Math.max(Xs.dot(m),v),y=Math.max(Xs.dot(g),y),x=Math.min(Xs.dot(p),x),_=Math.min(Xs.dot(m),_),w=Math.min(Xs.dot(g),w);p=p.multiplyByScalar(.5*(x+b)),m=m.multiplyByScalar(.5*(_+v)),g=g.multiplyByScalar(.5*(w+y)),t.center.copy(p).add(m).add(g);const T=Zs.set(b-x,v-_,y-w).multiplyByScalar(.5),S=new L([T[0],0,0,0,T[1],0,0,0,T[2]]);return t.halfAxes.multiplyRight(S),t}var oA=512,sA=[[.5,.5],[0,0],[0,1],[1,0],[1,1]],AA=sA.concat([[0,.5],[.5,0],[1,.5],[.5,1]]),lA=AA.concat([[.25,.5],[.75,.5]]),cA=class e{constructor(e,t,n){this.x=e,this.y=t,this.z=n}get children(){if(!this._children){const t=2*this.x,n=2*this.y,r=this.z+1;this._children=[new e(t,n,r),new e(t,n+1,r),new e(t+1,n,r),new e(t+1,n+1,r)]}return this._children}update(e){const{viewport:t,cullingVolume:n,elevationBounds:r,minZ:i,maxZ:a,bounds:o,offset:s,project:A}=e,l=this.getBoundingVolume(r,s,A);if(o&&!this.insideBounds(o))return!1;if(n.computeVisibility(l)<0)return!1;if(A&&this.beyondHorizon(t.cameraPosition,A,r[1]))return!1;if(!this.childVisible){let{z:e}=this;if(e<a&&e>=i){const n=l.distanceTo(t.cameraPosition)*t.scale/t.height;e+=Math.floor(Math.log2(n))}if(e>=a)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}beyondHorizon(e,t,n){const r=e[0],i=e[1],a=e[2],o=Math.sqrt(r*r+i*i+a*a),s=180*Math.atan2(r,-i)/Math.PI,A=180*Math.asin(a/o)/Math.PI,[l,c]=vA(this.x,this.y,this.z),[u,f]=vA(this.x+1,this.y+1,this.z),d=(l+u)/2,h=d+((s-d+540)%360-180),p=t([Math.max(l,Math.min(h,u)),Math.max(f,Math.min(A,c)),n]);return p[0]*r+p[1]*i+p[2]*a<=p[0]*p[0]+p[1]*p[1]+p[2]*p[2]}insideBounds([e,t,n,r]){const i=Math.pow(2,this.z),a=oA/i;return this.x*a<n&&this.y*a<r&&(this.x+1)*a>e&&(this.y+1)*a>t}getBoundingVolume(e,t,n){if(n){const t=this.z<1?lA:this.z<2?AA:sA,r=[];for(const i of t){const t=vA(this.x+i[0],this.y+i[1],this.z);t[2]=e[0],r.push(n(t)),e[0]!==e[1]&&(t[2]=e[1],r.push(n(t)))}return aA(r)}const r=Math.pow(2,this.z),i=oA/r,a=this.x*i+t*oA,o=oA-(this.y+1)*i;return new hs([a,o,e[0]],[a+i,o+i,e[1]])}};var uA=512,fA=[-1/0,-1/0,1/0,1/0],dA={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 r=0;r<n;r++)if(e[r]!==t[r])return!1;return!0}};function hA(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 pA(e,t){if(!e||!e.length)return null;const{index:n,id:r}=t;if(Array.isArray(e)){const t=(i=r,Math.abs(i.split("").reduce((e,t)=>(e<<5)-e+t.charCodeAt(0)|0,0))%e.length);e=e[t]}var i;let a=e;for(const o of Object.keys(n)){const e=new RegExp(`{${o}}`,"g");a=a.replace(e,String(n[o]))}return Number.isInteger(n.y)&&Number.isInteger(n.z)&&(a=a.replace(/\{-y\}/g,String(Math.pow(2,n.z)-n.y-1))),a}function mA({viewport:e,z:t,cullRect:n}){return(e.subViewports||[e]).map(e=>gA(e,t||0,n))}function gA(e,t,n){if(!Array.isArray(t)){const r=n.x-e.x,i=n.y-e.y,{width:a,height:o}=n,s={targetZ:t},A=e.unproject([r,i],s),l=e.unproject([r+a,i],s),c=e.unproject([r,i+o],s),u=e.unproject([r+a,i+o],s);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 r=gA(e,t[0],n),i=gA(e,t[1],n);return[Math.min(r[0],i[0]),Math.min(r[1],i[1]),Math.max(r[2],i[2]),Math.max(r[3],i[3])]}function bA(e,t){return Math.pow(2,e)*uA/t}function vA(e,t,n){const r=bA(n,uA),i=e/r*360-180,a=Math.PI-2*Math.PI*t/r;return[i,180/Math.PI*Math.atan(.5*(Math.exp(a)-Math.exp(-a)))]}function yA(e,t,n,r){const i=bA(n,r);return[e/i*uA,t/i*uA]}function xA(e,t,n,r,i=uA){if(e.isGeospatial){const[e,i]=vA(t,n,r),[a,o]=vA(t+1,n+1,r);return{west:e,north:i,east:a,south:o}}const[a,o]=yA(t,n,r,i),[s,A]=yA(t+1,n+1,r,i);return{left:a,top:o,right:s,bottom:A}}function _A(e,t,n,r,i){const[a,o,s,A]=function(e,t,n){return n?hA(e,n).map(e=>e*t/uA):e.map(e=>e*t/uA)}(function(e,t,n){let r;if(t&&2===t.length){const[n,i]=t,a=e.getBounds({z:n}),o=e.getBounds({z:i});r=[Math.min(a[0],o[0]),Math.min(a[1],o[1]),Math.max(a[2],o[2]),Math.max(a[3],o[3])]}else r=e.getBounds();return e.isGeospatial?[Math.max(r[0],n[0]),Math.max(r[1],n[1]),Math.min(r[2],n[2]),Math.min(r[3],n[3])]:[Math.max(Math.min(r[0],n[2]),n[0]),Math.max(Math.min(r[1],n[3]),n[1]),Math.min(Math.max(r[2],n[0]),n[2]),Math.min(Math.max(r[3],n[1]),n[3])]}(e,null,r),bA(t,n),i),l=[];for(let c=Math.floor(a);c<s;c++)for(let e=Math.floor(o);e<A;e++)l.push({x:c,y:e,z:t});return l}function wA({viewport:e,maxZoom:t,minZoom:i,zRange:a,extent:o,tileSize:s=uA,modelMatrix:A,modelMatrixInverse:l,zoomOffset:c=0,visibleMinZoom:u,visibleMaxZoom:f}){let d=e.isGeospatial?Math.round(e.zoom+Math.log2(uA/s)+c):Math.ceil(e.zoom+c);if("number"==typeof i&&Number.isFinite(i)&&d<i){if(!o)return[];d=i}if("number"==typeof t&&Number.isFinite(t)&&d>t&&(d=t),null!=u&&e.zoom<u)return[];if(null!=f&&e.zoom>f)return[];let h=o;return A&&l&&o&&!e.isGeospatial&&(h=hA(o,A)),e.isGeospatial?function(e,t,i,a){const o=e instanceof r.GlobeViewport?e.projectPosition:null,s=Object.values(e.getFrustumPlanes()).map(({normal:e,distance:t})=>new Fs(e.clone().negate(),t)),A=new js(s),l=e.distanceScales.unitsPerMeter[2],c=i&&i[0]*l||0,u=i&&i[1]*l||0,f=e instanceof n.WebMercatorViewport&&e.pitch<=60?t:0;if(a){const[e,t,r,i]=a,o=n.lngLatToWorld([e,i]),s=n.lngLatToWorld([r,t]);a=[o[0],oA-o[1],s[0],oA-s[1]]}const d=new cA(0,0,0),h={viewport:e,project:o,cullingVolume:A,elevationBounds:[c,u],minZ:f,maxZ:t,bounds:a,offset:0};if(d.update(h),e instanceof n.WebMercatorViewport&&e.subViewports&&e.subViewports.length>1){for(h.offset=-1;d.update(h)&&!(--h.offset<-3););for(h.offset=1;d.update(h)&&!(++h.offset>3););}return d.getSelected()}(e,d,a,o):_A(e,d,s,h||fA,l)}function TA(e,t){if(e===t)return!0;if(Array.isArray(e)){const n=e.length;if(!t||t.length!==n)return!1;for(let r=0;r<n;r++)if(e[r]!==t[r])return!1;return!0}return!1}var SA="never",MA="no-overlap",EA="best-available",CA=99999999,IA={[EA]:function(e){for(const t of e)t.state=0;for(const t of e)t.isSelected&&!NA(t)&&kA(t);for(const t of e)t.isVisible=Boolean(2&t.state)},[MA]:function(e){for(const n of e)n.state=0;for(const n of e)n.isSelected&&NA(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&&kA(n)},[SA]:()=>{}},RA={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:()=>{}},PA=class{constructor(e){this._getCullBounds=function(e){let t,n={};return r=>{for(const i in r)if(!TA(r[i],n[i])){t=e(r),n=r;break}return t}}(mA),this.opts={...RA,...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 g({throttleRequests:this.opts.maxRequests>0||this.opts.debounceTime>0,maxRequests:this.opts.maxRequests,debounceTime:this.opts.debounceTime}),this._cache=new Map,this._tiles=[],this._dirty=!1,this._cacheByteSize=0,this._viewport=null,this._zRange=null,this._selectedTiles=null,this._frameNumber=0,this._modelMatrix=new n.Matrix4,this._modelMatrixInverse=new n.Matrix4}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:r}={zRange:null,modelMatrix:null}){const i=r?new n.Matrix4(r):new n.Matrix4,a=!i.equals(this._modelMatrix);if(this._viewport&&e.equals(this._viewport)&&n.equals(this._zRange,t)&&!a)this.needsReload&&(this._selectedTiles=this._selectedTiles.map(e=>this._getTile(e.index,!0)));else{a&&(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,r){if(!e.isVisible)return!1;if(t&&this._viewport){const i=this._getCullBounds({viewport:this._viewport,z:this._zRange,cullRect:t});let{bbox:a}=e;for(const[e,t,o,s]of i){let i;if("west"in a)i=a.west<o&&a.east>e&&a.south<s&&a.north>t;else{if(r&&!n.Matrix4.IDENTITY.equals(r)){const[e,t,n,i]=hA([a.left,a.top,a.right,a.bottom],r);a={left:e,top:t,right:n,bottom:i}}const A=Math.min(a.top,a.bottom),l=Math.max(a.top,a.bottom);i=a.left<o&&a.right>e&&A<s&&l>t}if(i)return!0}return!1}return!0}getTileIndices({viewport:e,maxZoom:t,minZoom:n,zRange:r,modelMatrix:i,modelMatrixInverse:a}){const{tileSize:o,extent:s,zoomOffset:A,visibleMinZoom:l,visibleMaxZoom:c}=this.opts;return wA({viewport:e,maxZoom:t,minZoom:n,zRange:r,tileSize:o,extent:s,modelMatrix:i,modelMatrixInverse:a,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:xA(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||"best-available",t=new Array(this._cache.size);let n=0;for(const r of this._cache.values())t[n++]=r.isVisible,r.isSelected=!1,r.isVisible=!1;for(const r of this._selectedTiles)r.isSelected=!0,r.isVisible=!0;("function"==typeof e?e:IA[e])(Array.from(this._cache.values())),n=0;for(const r of this._cache.values())if(t[n++]!==r.isVisible)return!0;return!1}_getRequestPriority(e){if(!e.isSelected&&!e.isVisible)return-1;const t=this._getTileDistancePriority(e);return e.isSelected?0+t:1e8+t}_getTileDistancePriority(e){const{width:t,height:n}=this._viewport||{};if(!this._viewport||!t||!n)return 0;try{const r=this._getTileScreenCorners(e.bbox),i=[t/2,n/2];if(4===r.length){if(this._isPointInPolygon(i,r))return 0;const e=r.reduce((e,t,n)=>{const a=r[(n+1)%r.length];return Math.min(e,this._getPointToSegmentDistanceSquared(i,t,a))},Number.MAX_SAFE_INTEGER);return Math.min(e,CA)}}catch{}return CA}_getTileScreenCorners(e){return("west"in e?[[e.west,e.south],[e.east,e.south],[e.east,e.north],[e.west,e.north]]:[[e.left,e.top],[e.right,e.top],[e.right,e.bottom],[e.left,e.bottom]]).map(e=>this._viewport.project(e)).filter(([e,t])=>Number.isFinite(e)&&Number.isFinite(t))}_isPointInPolygon(e,t){let n=!1;const[r,i]=e;for(let a=0,o=t.length-1;a<t.length;o=a++){const[e,s]=t[a],[A,l]=t[o];s>i!=l>i&&r<(A-e)*(i-s)/(l-s)+e&&(n=!n)}return n}_getPointToSegmentDistanceSquared(e,t,n){const[r,i]=e,[a,o]=t,[s,A]=n,l=s-a,c=A-o,u=l*l+c*c,f=u?Math.max(0,Math.min(1,((r-a)*l+(i-o)*c)/u)):0,d=r-(a+f*l),h=i-(o+f*c);return d*d+h*h}_pruneRequests(){const{maxRequests:e=0}=this.opts,t=[];let n=0;for(const r of this._cache.values())r.isLoading&&(n++,r.isSelected||r.isVisible||t.push(r));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),r=t.maxCacheByteSize??1/0;if(e.size>n||this._cacheByteSize>r){for(const[i,a]of e)if(a.isVisible||a.isSelected||(this._cacheByteSize-=null!==t.maxCacheByteSize?a.byteLength:0,e.delete(i),this.opts.onTileUnload?.(a)),e.size<=n&&this._cacheByteSize<=r)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 r=this._cache.get(n),i=!1;return!r&&t?(r=new As(e),Object.assign(r,this.getTileMetadata(r.index)),Object.assign(r,{id:n,zoom:this.getTileZoom(r.index)}),i=!0,this._cache.set(n,r),this._dirty=!0):r&&r.needsReload&&(i=!0),r&&i&&r.loadData({getData:this.opts.getTileData,getRequestPriority:this._getRequestPriority.bind(this),requestScheduler:this._requestScheduler,onLoad:this.onTileLoad,onError:this.opts.onTileError}),r}_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 NA(e){let t=e;for(;t;){if(t.isLoaded||t.content)return t.state|=2,!0;t=t.parent}return!1}function kA(e){for(const t of e.children)t.isLoaded||t.content?t.state|=2:kA(t)}var LA={TilesetClass:PA,data:{type:"data",value:[]},dataComparator:dA.equal,renderSubLayers:{type:"function",value:e=>new t.GeoJsonLayer(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=>console.error(e)},extent:{type:"array",optional:!0,value:null,compare:!0},tileSize:512,maxZoom:null,minZoom:0,maxCacheSize:null,maxCacheByteSize:null,refinementStrategy:EA,zRange:null,maxRequests:6,debounceTime:0,zoomOffset:0,visibleMinZoom:null,visibleMaxZoom:null},BA=class extends t.CompositeLayer{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,r=e.dataChanged||e.updateTriggersChanged&&(e.updateTriggersChanged.all||e.updateTriggersChanged.getTileData);t?n&&(t.setOptions(this._getTilesetOptions()),r?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:r,extent:i,maxZoom:a,minZoom:o,maxRequests:s,debounceTime:A,zoomOffset:l,visibleMinZoom:c,visibleMaxZoom:u}=this.props;return{maxCacheSize:t,maxCacheByteSize:n,maxZoom:a,minZoom:o,tileSize:e,refinementStrategy:r,extent:i,maxRequests:s,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,r=e.update(this.context.viewport,{zRange:t,modelMatrix:n}),{isLoaded:i}=e,a=this.state.isLoaded!==i,o=this.state.frameNumber!==r;i&&(a||o)&&this._onViewportLoad(),o&&this.setState({frameNumber:r}),this.state.isLoaded=i}_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:r}=this.props,{signal:i}=e;return e.url="string"==typeof t||Array.isArray(t)?pA(t,e):null,n?n(e):r&&e.url?r(e.url,{propName:"data",layer:this,signal:i}):null}renderSubLayers(e){return this.props.renderSubLayers(e)}getSubLayerPropsByTile(e){return null}getPickingInfo(e){const t=e.sourceLayer,n=t.props.tile,r=e.info;return r.picked&&(r.tile=n),r.sourceTile=n,r.sourceTileSubLayer=t,r}_updateAutoHighlight(e){e.sourceTileSubLayer.updateAutoHighlight(e)}renderLayers(){const{visibleMinZoom:e,visibleMaxZoom:t,minZoom:r,extent:i}=this.props,a=this.context.viewport.zoom;if(null!=e&&a<e||null!=t&&a>t||null!=r&&!i&&a<r){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 r=this.renderSubLayers({...this.props,...this.getSubLayerProps({id:e.id,updateTriggers:this.props.updateTriggers}),data:e.content,_offset:0,tile:e});e.layers=n.flatten(r,Boolean).map(n=>n.clone({tile:e,...t}))}else;return e.layers})}filterSubLayer({layer:e,cullRect:t}){const{tile:r}=e.props,{modelMatrix:i}=this.props;return this.state.tileset.isTileVisible(r,t,i?new n.Matrix4(i):null)}};BA.defaultProps=LA,BA.layerName="TileLayer";var OA="layout(std140) uniform tripsUniforms {\n bool fadeTrail;\n float trailLength;\n float currentTime;\n} trips;\n",FA={name:"trips",source:"struct TripsUniforms {\n fadeTrail: f32,\n trailLength: f32,\n currentTime: f32,\n};\n\n@group(0) @binding(auto)\nvar<uniform> trips: TripsUniforms;\n",vs:OA,fs:OA,uniformTypes:{fadeTrail:"f32",trailLength:"f32",currentTime:"f32"}};function DA(e,t=e.length,n=!1){const r=new Float32Array(2*t);if(0===e.length)return r;const i=t>e.length,a=n?e.length:Math.max(e.length-1,1);for(let o=0;o<t;o++){const t=i?o%a:Math.min(o,e.length-1),n=i?(t+1)%a:Math.min(t+1,e.length-1);r[2*o]=e[t],r[2*o+1]=e[n]}return r}var UA={" @location(12) rowIndexes: u32,":"\n @location(13) instanceTimestamps: vec2<f32>,"," @location(5) vJointType: f32,":"\n @location(6) vTime: f32,"," attributes.instanceColors.a * layer.opacity\n );":"\n\n varyings.vTime = mix(\n attributes.instanceTimestamps.x,\n attributes.instanceTimestamps.y,\n varyings.vPathPosition.y / varyings.vPathLength\n );\n\n if (trips.fadeTrail > 0.5) {\n varyings.vColor.a *=\n 1.0 - (trips.currentTime - varyings.vTime) / trips.trailLength;\n }"," // DECKGL_FILTER_COLOR":"\n if (\n varyings.vTime > trips.currentTime ||\n (trips.fadeTrail > 0.5 && varyings.vTime < trips.currentTime - trips.trailLength)\n ) {\n discard;\n }"},VA={"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:DECKGL_FILTER_COLOR":"if(vTime > trips.currentTime || (trips.fadeTrail && (vTime < trips.currentTime - trips.trailLength))) {\n discard;\n}\nif(trips.fadeTrail) {\n color.a *= 1.0 - (trips.currentTime - vTime) / trips.trailLength;\n}\n"},jA=class extends t.PathLayer{getShaders(){const e=super.getShaders();return e.inject="webgpu"===this.context.device.type?UA:VA,e.modules=[...e.modules,FA],e}initializeState(){super.initializeState(),this.getAttributeManager().addInstanced({..."webgpu"===this.context.device.type?{instanceTimestamps:{size:2,accessor:"getTimestamps",update:this.calculateWebGPUTimestamps,bufferGroup:"path-instance-data"}}:{timestamps:{size:1,accessor:"getTimestamps",shaderAttributes:{instanceTimestamps:{vertexOffset:0},instanceNextTimestamps:{vertexOffset:1}}}}})}calculateWebGPUTimestamps(e,{data:n,props:r}){const{pathTesselator:i}=this.state,{instanceCount:a,vertexStarts:o}=i,s=new Float32Array(2*a),{iterable:A,objectInfo:l}=t.createIterable(n);for(const t of A){l.index++;const e=o[l.index],n=o[l.index+1]??a;if(n<=e)continue;const i=r.getTimestamps?.(t,l)??[];s.set(DA(i,n-e,"loop"===r._pathType),2*e)}e.startIndices=o,e.value=s}draw(e){const{fadeTrail:t,trailLength:n,currentTime:r}=this.props,i={fadeTrail:t,trailLength:n,currentTime:r};this.state.model.shaderInputs.setProps({trips:i}),super.draw(e)}};jA.layerName="TripsLayer",jA.defaultProps={fadeTrail:!0,trailLength:{type:"number",value:120,min:0},currentTime:{type:"number",value:0,min:0},getTimestamps:{type:"accessor",value:e=>e.timestamps}};var zA={...t.PolygonLayer.defaultProps,highPrecision:"auto",coverage:{type:"number",min:0,max:1,value:1},centerHexagon:null,getHexagon:{type:"accessor",value:e=>e.hexagon},extruded:!0},GA=class e extends t.CompositeLayer{initializeState(){e._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,n=!1,r=!1;const{iterable:i,objectInfo:a}=t.createIterable(this.props.data);for(const t of i){a.index++;const i=this.props.getHexagon(t,a),o=oi(i);if(e<0){if(e=o,!this.props.highPrecision)break}else if(e!==o){r=!0;break}if(ai(i)){n=!0;break}}return{resolution:e,edgeLengthKM:e>=0?fi(e,"km"):0,hasMultipleRes:r,hasPentagon:n}}_shouldUseHighPrecision(){if("auto"===this.props.highPrecision){const{resolution:e,hasPentagon:t,hasMultipleRes:n}=this.state,{viewport:r}=this.context;return Boolean(r?.resolution)||n||t||e>=0&&e<=5}return this.props.highPrecision}_updateVertices(e){if(this._shouldUseHighPrecision())return;const{resolution:t,edgeLengthKM:n,centerHex:r}=this.state;if(t<0)return;const i=this.props.centerHexagon||si(e.latitude,e.longitude,t);if(r===i)return;if(r)try{if(ui(r,i)*n<10)return}catch{}const{unitsPerMeter:a}=e.distanceScales;let o=mi(i);const[s,A]=Ai(i),[l,c]=e.projectFlat([A,s]);o=o.map(t=>{const n=e.projectFlat(t);return[(n[0]-l)/a[0],(n[1]-c)/a[1]]}),this.setState({centerHex:i,vertices:o})}renderLayers(){return this._shouldUseHighPrecision()?this._renderPolygonLayer():this._renderColumnLayer()}_getForwardProps(){const{elevationScale:e,material:t,coverage:n,extruded:r,wireframe:i,stroked:a,filled:o,lineWidthUnits:s,lineWidthScale:A,lineWidthMinPixels:l,lineWidthMaxPixels:c,getFillColor:u,getElevation:f,getLineColor:d,getLineWidth:h,transitions:p,updateTriggers:m}=this.props;return{elevationScale:e,extruded:r,coverage:n,wireframe:i,stroked:a,filled:o,lineWidthUnits:s,lineWidthScale:A,lineWidthMinPixels:l,lineWidthMaxPixels:c,material:t,getElevation:f,getFillColor:u,getLineColor:d,getLineWidth:h,transitions:p,updateTriggers:{getFillColor:m.getFillColor,getElevation:m.getElevation,getLineColor:m.getLineColor,getLineWidth:m.getLineWidth}}}_renderPolygonLayer(){const{data:e,getHexagon:n,updateTriggers:r,coverage:i}=this.props,a=this.getSubLayerClass("hexagon-cell-hifi",t.PolygonLayer),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}(r.getHexagon,i),new a(o,this.getSubLayerProps({id:"hexagon-cell-hifi",updateTriggers:o.updateTriggers}),{data:e,_normalize:!1,_windingOrder:"CCW",positionFormat:"XY",getPolygon:(e,t)=>gi(mi(n(e,t),i))})}_renderColumnLayer(){const{data:e,getHexagon:n,updateTriggers:r}=this.props,i=this.getSubLayerClass("hexagon-cell",t.ColumnLayer),a=this._getForwardProps();return a.updateTriggers.getPosition=r.getHexagon,new i(a,this.getSubLayerProps({id:"hexagon-cell",flatShading:!0,updateTriggers:a.updateTriggers}),{data:e,diskResolution:6,radius:1,vertices:this.state.vertices,getPosition:pi.bind(null,n)})}};GA.defaultProps=zA,GA.layerName="H3HexagonLayer",GA._checkH3Lib=()=>{};var HA=class extends st{initializeState(){GA._checkH3Lib()}updateState({props:e,changeFlags:n}){if(n.dataChanged||n.updateTriggersChanged&&n.updateTriggersChanged.getHexagons){const{data:n,getHexagons:r}=e,i=[],{iterable:a,objectInfo:o}=t.createIterable(n);for(const e of a){o.index++;const t=ci(r(e,o),!0);for(const n of t){for(const e of n)hi(e);i.push(this.getSubLayerRow({polygon:n},e,o.index))}}this.setState({polygons:i})}}indexToBounds(){const{getElevation:e,getFillColor:t,getLineColor:n,getLineWidth:r}=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(r)}}};HA.layerName="H3ClusterLayer",HA.defaultProps={getHexagons:{type:"accessor",value:e=>e.hexagons}};var qA=Math.PI/180,QA=new Float32Array(16),KA=new Float32Array(12);function WA(e,t,n){const r=t[0]*qA,i=t[1]*qA,a=t[2]*qA,o=Math.sin(a),s=Math.sin(r),A=Math.sin(i),l=Math.cos(a),c=Math.cos(r),u=Math.cos(i),f=n[0],d=n[1],h=n[2];e[0]=f*u*c,e[1]=f*A*c,e[2]=f*-s,e[3]=d*(-A*l+u*s*o),e[4]=d*(u*l+A*s*o),e[5]=d*c*o,e[6]=h*(A*o+u*s*l),e[7]=h*(-u*o+A*s*l),e[8]=h*c*l}function $A(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)}var JA={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:n,endRow:r}){const{data:i,getOrientation:a,getScale:o,getTranslation:s,getTransformMatrix:A}=this.props,l=Array.isArray(A),c=l&&16===A.length,u=Array.isArray(o),f=Array.isArray(a),d=Array.isArray(s),h=c||!l&&Boolean(A(i[0]));e.constant=h?c:f&&u&&d;const p=e.value;if(e.constant){let t;h?(QA.set(A),t=$A(QA)):(t=KA,WA(t,a,o),t.set(s,9)),e.value=new Float32Array(t)}else{let l=n*e.size;const{iterable:m,objectInfo:g}=t.createIterable(i,n,r);for(const e of m){let t;if(g.index++,h)QA.set(c?A:A(e,g)),t=$A(QA);else{t=KA;WA(t,f?a:a(e,g),u?o:o(e,g)),t.set(d?s:s(e,g),9)}p[l++]=t[0],p[l++]=t[1],p[l++]=t[2],p[l++]=t[3],p[l++]=t[4],p[l++]=t[5],p[l++]=t[6],p[l++]=t[7],p[l++]=t[8],p[l++]=t[9],p[l++]=t[10],p[l++]=t[11]}}}};function YA(e,t){return"cartesian"===t||"meter-offsets"===t||"default"===t&&!e.isGeospatial}var XA="layout(std140) uniform simpleMeshUniforms {\n float sizeScale;\n bool composeModelMatrix;\n bool hasTexture;\n bool flatShading;\n} simpleMesh;\n",ZA={name:"simpleMesh",source:"struct SimpleMeshUniforms {\n sizeScale: f32,\n composeModelMatrix: f32,\n hasTexture: f32,\n flatShading: f32,\n};\n\n@group(0) @binding(auto) var<uniform> simpleMesh: SimpleMeshUniforms;\n@group(0) @binding(auto) var simpleMeshTexture: texture_2d<f32>;\n@group(0) @binding(auto) var simpleMeshTextureSampler: sampler;\n",vs:XA,fs:XA,uniformTypes:{sizeScale:"f32",composeModelMatrix:"f32",hasTexture:"f32",flatShading:"f32"}};function el(e){const t=e.positions||e.POSITION;n.defaultLogger.assert(t,'no "postions" or "POSITION" attribute in mesh');const r=t.value.length/t.size;let i=e.COLOR_0||e.colors;i||(i={size:3,value:new Float32Array(3*r).fill(1)});let a=e.NORMAL||e.normals;a||(a={size:3,value:new Float32Array(3*r).fill(0)});let o=e.TEXCOORD_0||e.texCoords;return o||(o={size:2,value:new Float32Array(2*r).fill(0)}),{positions:t,colors:i,normals:a,texCoords:o}}function tl(e){return e instanceof t.Geometry?(e.attributes=el(e.attributes),e):e.attributes?new t.Geometry({...e,topology:"triangle-list",attributes:el(e.attributes)}):new t.Geometry({topology:"triangle-list",attributes:el(e)})}var nl=class extends t.Layer{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 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 = picking_getPickingColorFromInstanceID();\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",source:"struct Attributes {\n @builtin(instance_index) instanceIndex: u32,\n @location(0) positions: vec3<f32>,\n @location(1) normals: vec3<f32>,\n @location(2) colors: vec3<f32>,\n @location(3) texCoords: vec2<f32>,\n @location(4) instancePositions: vec3<f32>,\n @location(5) instancePositions64Low: vec3<f32>,\n @location(6) instanceColors: vec4<f32>,\n @location(7) instanceModelMatrixCol0: vec3<f32>,\n @location(8) instanceModelMatrixCol1: vec3<f32>,\n @location(9) instanceModelMatrixCol2: vec3<f32>,\n @location(10) instanceTranslation: vec3<f32>,\n};\n\nstruct Varyings {\n @builtin(position) position: vec4<f32>,\n @location(0) color: vec4<f32>,\n @location(1) texCoords: vec2<f32>,\n @location(2) normal: vec3<f32>,\n @location(3) positionCommon: vec3<f32>,\n @location(4) pickingColor: vec3<f32>,\n};\n\n@vertex\nfn vertexMain(attributes: Attributes) -> Varyings {\n var varyings: Varyings;\n\n geometry.worldPosition = attributes.instancePositions;\n geometry.uv = attributes.texCoords;\n geometry.pickingColor = picking_getPickingColorFromIndex(attributes.instanceIndex);\n\n let instanceModelMatrix = mat3x3<f32>(\n attributes.instanceModelMatrixCol0,\n attributes.instanceModelMatrixCol1,\n attributes.instanceModelMatrixCol2\n );\n let meshPosition =\n (instanceModelMatrix * attributes.positions) * simpleMesh.sizeScale +\n attributes.instanceTranslation;\n\n if (simpleMesh.composeModelMatrix > 0.5) {\n geometry.normal = project_normal(instanceModelMatrix * attributes.normals);\n geometry.worldPosition += meshPosition;\n let projected = project_position_to_clipspace_and_commonspace(\n attributes.instancePositions + meshPosition,\n attributes.instancePositions64Low,\n vec3<f32>(0.0)\n );\n geometry.position = projected.commonPosition;\n varyings.position = projected.clipPosition;\n } else {\n let projected = project_position_to_clipspace_and_commonspace(\n attributes.instancePositions,\n attributes.instancePositions64Low,\n project_size_vec3(meshPosition)\n );\n geometry.position = projected.commonPosition;\n geometry.normal = project_normal(instanceModelMatrix * attributes.normals);\n varyings.position = projected.clipPosition;\n }\n\n varyings.color = vec4<f32>(\n attributes.colors * attributes.instanceColors.rgb,\n attributes.instanceColors.a\n );\n varyings.texCoords = attributes.texCoords;\n varyings.normal = geometry.normal;\n varyings.positionCommon = geometry.position.xyz;\n varyings.pickingColor = geometry.pickingColor;\n return varyings;\n}\n\n@fragment\nfn fragmentMain(varyings: Varyings) -> @location(0) vec4<f32> {\n geometry.uv = varyings.texCoords;\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 var color = varyings.color;\n if (simpleMesh.hasTexture > 0.5) {\n color = textureSample(simpleMeshTexture, simpleMeshTextureSampler, varyings.texCoords);\n }\n\n var normal = varyings.normal;\n if (simpleMesh.flatShading > 0.5) {\n // WebGPU's screen-space Y axis reverses the derivative orientation used by GLSL flat shading.\n normal = normalize(cross(dpdy(varyings.positionCommon), dpdx(varyings.positionCommon)));\n }\n\n color = vec4<f32>(\n lighting_getLightColor2(color.rgb, project.cameraPosition, varyings.positionCommon, normal),\n color.a * layer.opacity\n );\n\n if (picking.isHighlightActive > 0.5) {\n let highlightedColor = picking_normalizeColor(picking.highlightedObjectColor);\n if (picking_isColorZero(abs(varyings.pickingColor - highlightedColor))) {\n let blendedAlpha = picking.highlightColor.a + color.a * (1.0 - picking.highlightColor.a);\n if (blendedAlpha > 0.0) {\n color = vec4<f32>(\n mix(color.rgb, picking.highlightColor.rgb, picking.highlightColor.a / blendedAlpha),\n blendedAlpha\n );\n }\n }\n }\n\n return deckgl_premultiplied_alpha(color);\n}\n",modules:[t.project32_default,t.color_default,t.phongMaterial,t.picking_default,ZA]})}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}=tl(t);n.POSITION=n.POSITION||n.positions,e=function(e){let t=1/0,n=1/0,r=1/0,i=-1/0,a=-1/0,o=-1/0;const s=e.POSITION?e.POSITION.value:[],A=s&&s.length;for(let l=0;l<A;l+=3){const e=s[l],A=s[l+1],c=s[l+2];t=e<t?e:t,n=A<n?A:n,r=c<r?c:r,i=e>i?e:i,a=A>a?A:a,o=c>o?c:o}return[[t,n,r],[i,a,o]]}(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:JA}),this.setState({emptyTexture:this.context.device.createTexture({data:new Uint8Array(4),width:1,height:1})})}updateState(e){super.updateState(e);const{props:t,oldProps:r,changeFlags:i}=e;if(t.mesh!==r.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!==r.texture&&t.texture instanceof n.Texture&&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:r}=this.context,{sizeScale:i,coordinateSystem:a,_instanced:o}=this.props,s={sizeScale:i,composeModelMatrix:!o||YA(n,a),flatShading:!this.state.hasNormals};t.shaderInputs.setProps({simpleMesh:s}),t.draw(r)}get isLoaded(){return Boolean(this.state?.model&&super.isLoaded)}getModel(e){const n=new t.Model(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:tl(e),isInstanced:!0});return n.shaderInputs.setProps({simpleMesh:this.getTextureProps(this.props.texture)}),n}setTexture(e){const{model:t}=this.state;t&&t.shaderInputs.setProps({simpleMesh:this.getTextureProps(e)})}getTextureProps(e){const t=e||this.state.emptyTexture;return{..."webgpu"===this.context.device.type?{simpleMeshTexture:t}:{sampler:t},hasTexture:Boolean(e)}}};nl.defaultProps={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}},nl.layerName="SimpleMeshLayer";var rl;function il(e,t){const r=t.materialFactory||new ae(e,{modules:[G]}),i={...t.parsedPPBRMaterial.uniforms};delete i.camera;const s=Object.fromEntries(Object.entries({...i,...t.parsedPPBRMaterial.bindings}).filter(([e,t])=>r.ownsBinding(e)&&function(e){return e instanceof a.Buffer||e instanceof we||e instanceof n.Sampler||e instanceof n.Texture||e instanceof o.TextureView}(t))),A=r.createMaterial({id:t.id,bindings:s});return A.setProps({pbrMaterial:i}),A}function al(e,r){const{id:i,geometry:o,parsedPPBRMaterial:s,vertexCount:A,modelOptions:l={},instanceMatrices:c,morphTargets:u=[]}=r,f=l.userData?.gltfAnimatedCrowd;if(f&&c)throw new Error("Nested glTF crowd instancing is unsupported");a.log.info(4,"createGLTFModel defines: ",s.defines)();const d=[],h={},p=[],m=[],g=[],b=Boolean(f?.gpuAnimation);if(c||f)for(let t=0;t<4;t++){const n=new Float32Array(4*(f?.capacity||c?.length||0));c?.forEach((e,r)=>{for(let i=0;i<4;i++)n[4*r+i]=e[4*t+i]});const r=`instanceModelMatrixCol${t}`,o=e.createBuffer({id:`${i||"gltf"}-${r}`,data:n,usage:a.Buffer.VERTEX|a.Buffer.COPY_DST});h[r]=o,p.push({name:r,format:"float32x4",stepMode:"instance"}),d.push(o),m.push(o),g.push(n)}let v,y,x,_;if(f&&b){v=new Float32Array(4*f.capacity),x=new Float32Array(4*f.capacity);for(const[t,n]of[["instanceAnimationFrames",v],["instanceAnimationBlend",x]]){const r=e.createBuffer({id:`${i||"gltf"}-${t}`,data:n,usage:a.Buffer.VERTEX|a.Buffer.COPY_DST});h[t]=r,p.push({name:t,format:"float32x4",stepMode:"instance"}),d.push(r),"instanceAnimationFrames"===t?y=r:_=r}}const w=Boolean(s.defines.HAS_SKIN),T=Boolean(f&&w&&!b);let S,M;f&&T&&(M=new Float32Array(f.capacity*f.jointsPerInstance*16),S="webgpu"===e.type?e.createBuffer({id:`${i||"gltf"}-crowd-joint-matrices`,byteLength:M.byteLength,usage:a.Buffer.STORAGE|a.Buffer.COPY_DST}):e.createTexture({id:`${i||"gltf"}-crowd-joint-matrices`,format:"rgba32float",width:4*f.jointsPerInstance,height:f.capacity,usage:n.Texture.SAMPLE|n.Texture.COPY_DST,sampler:{minFilter:"nearest",magFilter:"nearest",mipmapFilter:"nearest"}}),d.push(S));const E=f?u.length:0,C=Math.floor((o.attributes.POSITION?.value.length||0)/3);let I,R,P;if(f&&E>0&&C>0){const t=new Float32Array(3*E*C*4);for(const[e,n]of u.entries())for(const[r,i]of["POSITION","NORMAL","TANGENT"].entries()){const a=n[i];if(!a)continue;const o="TANGENT"===i&&a.length===4*C?4:3;for(let n=0;n<C;n++){const i=4*((3*e+r)*C+n),s=n*o;t[i]=a[s]||0,t[i+1]=a[s+1]||0,t[i+2]=a[s+2]||0}}if(I=ol(e,`${i||"gltf"}-crowd-morph-targets`,t,C,3*E),d.push(I),!b){const t=Math.ceil(E/4);R=new Float32Array(f.capacity*t*4),P=ol(e,`${i||"gltf"}-crowd-morph-weights`,R,t,f.capacity),d.push(P)}}const N=w&&f?f.jointsPerInstance:0,k=4+4*N+E;let L,B;f?.gpuAnimation&&(B=new Float32Array(f.gpuAnimation.frameCount*k*4),L=ol(e,`${i||"gltf"}-crowd-animation-frames`,B,k,f.gpuAnimation.frameCount),d.push(L));let F="\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#ifdef HAS_GLTF_INSTANCING\n @location(8) instanceModelMatrixCol0: vec4f,\n @location(9) instanceModelMatrixCol1: vec4f,\n @location(10) instanceModelMatrixCol2: vec4f,\n @location(11) instanceModelMatrixCol3: vec4f,\n @builtin(instance_index) instanceIndex: u32,\n#endif\n#ifdef HAS_GPU_CROWD_ANIMATION\n @location(12) instanceAnimationFrames: vec4f,\n @location(13) instanceAnimationBlend: vec4f,\n#endif\n#ifdef HAS_INSTANCED_MORPH\n @builtin(vertex_index) vertexIndex: u32,\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#ifdef HAS_GLTF_INSTANCING\nfn getGLTFInstanceNormalMatrix(matrix: mat3x3f) -> mat3x3f {\n let firstCofactor = cross(matrix[1], matrix[2]);\n let inverseDeterminant = 1.0 / dot(matrix[0], firstCofactor);\n return mat3x3f(\n firstCofactor,\n cross(matrix[2], matrix[0]),\n cross(matrix[0], matrix[1])\n ) * inverseDeterminant;\n}\n#endif\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\n#ifdef HAS_INSTANCED_MORPH\n var animationFrames = vec4f(0.0);\n var animationBlend = vec4f(0.0);\n#ifdef HAS_GPU_CROWD_ANIMATION\n animationFrames = inputs.instanceAnimationFrames;\n animationBlend = inputs.instanceAnimationBlend;\n#endif\n position = vec4f(\n position.xyz + getGPUCrowdMorphDelta(\n inputs.instanceIndex,\n inputs.vertexIndex,\n 0u,\n u32(CROWD_MORPH_VERTEX_COUNT),\n u32(CROWD_MORPH_TARGET_COUNT),\n u32(CROWD_ANIMATION_JOINT_COUNT),\n animationFrames,\n animationBlend,\n u32(CROWD_ANIMATION_FRAME_STRIDE)\n ),\n 1.0\n );\n#ifdef HAS_NORMALS\n normal = normalize(normal + getGPUCrowdMorphDelta(\n inputs.instanceIndex,\n inputs.vertexIndex,\n 1u,\n u32(CROWD_MORPH_VERTEX_COUNT),\n u32(CROWD_MORPH_TARGET_COUNT),\n u32(CROWD_ANIMATION_JOINT_COUNT),\n animationFrames,\n animationBlend,\n u32(CROWD_ANIMATION_FRAME_STRIDE)\n ));\n#endif\n#ifdef HAS_TANGENTS\n tangent = vec4f(normalize(tangent.xyz + getGPUCrowdMorphDelta(\n inputs.instanceIndex,\n inputs.vertexIndex,\n 2u,\n u32(CROWD_MORPH_VERTEX_COUNT),\n u32(CROWD_MORPH_TARGET_COUNT),\n u32(CROWD_ANIMATION_JOINT_COUNT),\n animationFrames,\n animationBlend,\n u32(CROWD_ANIMATION_FRAME_STRIDE)\n )), tangent.w);\n#endif\n#endif\n\n#ifdef HAS_SKIN\n#ifdef HAS_GPU_CROWD_ANIMATION\n let skinMatrix = getGPUAnimatedSkinMatrix(\n inputs.WEIGHTS_0,\n inputs.JOINTS_0,\n inputs.instanceAnimationFrames,\n inputs.instanceAnimationBlend,\n u32(CROWD_ANIMATION_FRAME_STRIDE)\n );\n#else\n#ifdef HAS_INSTANCED_SKIN\n let skinMatrix = getInstancedSkinMatrix(\n inputs.WEIGHTS_0,\n inputs.JOINTS_0,\n inputs.instanceIndex,\n u32(CROWD_JOINTS_PER_INSTANCE)\n );\n#else\n let skinMatrix = getSkinMatrix(inputs.WEIGHTS_0, inputs.JOINTS_0);\n#endif\n#endif\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#ifdef HAS_GLTF_INSTANCING\n var instanceMatrix = mat4x4f(\n inputs.instanceModelMatrixCol0,\n inputs.instanceModelMatrixCol1,\n inputs.instanceModelMatrixCol2,\n inputs.instanceModelMatrixCol3\n );\n#ifdef HAS_GPU_CROWD_ANIMATION\n instanceMatrix *= sampleGPUAnimationMatrix(\n inputs.instanceAnimationFrames,\n inputs.instanceAnimationBlend,\n 0u,\n u32(CROWD_ANIMATION_FRAME_STRIDE)\n );\n#endif\n position = instanceMatrix * position;\n normal = normalize(getGLTFInstanceNormalMatrix(mat3x3f(\n instanceMatrix[0].xyz,\n instanceMatrix[1].xyz,\n instanceMatrix[2].xyz\n )) * normal);\n#ifdef HAS_TANGENTS\n tangent = vec4f(normalize((instanceMatrix * 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";for(const[t,n]of[["CROWD_JOINTS_PER_INSTANCE",f?.jointsPerInstance||0],["CROWD_MORPH_VERTEX_COUNT",C],["CROWD_MORPH_TARGET_COUNT",E],["CROWD_ANIMATION_JOINT_COUNT",N],["CROWD_ANIMATION_FRAME_STRIDE",k]])F=F.replaceAll(`u32(${t})`,`u32(${n})`);const U={id:i,source:F,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 #ifdef HAS_GLTF_INSTANCING\n in vec4 instanceModelMatrixCol0;\n in vec4 instanceModelMatrixCol1;\n in vec4 instanceModelMatrixCol2;\n in vec4 instanceModelMatrixCol3;\n #endif\n\n #ifdef HAS_GPU_CROWD_ANIMATION\n in vec4 instanceAnimationFrames;\n in vec4 instanceAnimationBlend;\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_INSTANCED_MORPH\n vec4 animationFrames = vec4(0.0);\n vec4 animationBlend = vec4(0.0);\n #ifdef HAS_GPU_CROWD_ANIMATION\n animationFrames = instanceAnimationFrames;\n animationBlend = instanceAnimationBlend;\n #endif\n pos.xyz += getGPUCrowdMorphDelta(\n uint(gl_InstanceID),\n uint(gl_VertexID),\n 0u,\n uint(CROWD_MORPH_TARGET_COUNT),\n uint(CROWD_ANIMATION_JOINT_COUNT),\n animationFrames,\n animationBlend\n );\n #ifdef HAS_NORMALS\n _NORMAL.xyz = normalize(_NORMAL.xyz + getGPUCrowdMorphDelta(\n uint(gl_InstanceID),\n uint(gl_VertexID),\n 1u,\n uint(CROWD_MORPH_TARGET_COUNT),\n uint(CROWD_ANIMATION_JOINT_COUNT),\n animationFrames,\n animationBlend\n ));\n #endif\n #ifdef HAS_TANGENTS\n _TANGENT.xyz = normalize(_TANGENT.xyz + getGPUCrowdMorphDelta(\n uint(gl_InstanceID),\n uint(gl_VertexID),\n 2u,\n uint(CROWD_MORPH_TARGET_COUNT),\n uint(CROWD_ANIMATION_JOINT_COUNT),\n animationFrames,\n animationBlend\n ));\n #endif\n #endif\n\n #ifdef HAS_SKIN\n #ifdef HAS_GPU_CROWD_ANIMATION\n mat4 skinMat = getGPUAnimatedSkinMatrix(\n WEIGHTS_0,\n JOINTS_0,\n instanceAnimationFrames,\n instanceAnimationBlend\n );\n #else\n #ifdef HAS_INSTANCED_SKIN\n mat4 skinMat = getInstancedSkinMatrix(\n WEIGHTS_0,\n JOINTS_0,\n uint(gl_InstanceID),\n uint(CROWD_JOINTS_PER_INSTANCE)\n );\n #else\n mat4 skinMat = getSkinMatrix(WEIGHTS_0, JOINTS_0);\n #endif\n #endif\n pos = skinMat * pos;\n _NORMAL = skinMat * _NORMAL;\n _TANGENT = vec4((skinMat * vec4(_TANGENT.xyz, 0.)).xyz, _TANGENT.w);\n #endif\n\n #ifdef HAS_GLTF_INSTANCING\n mat4 instanceMatrix = mat4(\n instanceModelMatrixCol0,\n instanceModelMatrixCol1,\n instanceModelMatrixCol2,\n instanceModelMatrixCol3\n );\n #ifdef HAS_GPU_CROWD_ANIMATION\n instanceMatrix *= sampleGPUAnimationMatrix(\n instanceAnimationFrames,\n instanceAnimationBlend,\n 0\n );\n #endif\n pos = instanceMatrix * pos;\n _NORMAL = vec4(normalize(transpose(inverse(mat3(instanceMatrix))) * _NORMAL.xyz), 0.0);\n _TANGENT = vec4(normalize(mat3(instanceMatrix) * _TANGENT.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:o,topology:o.topology,vertexCount:A,modules:[G,O,...f?[D]:[]],...l,...c||f?{attributes:{...l.attributes,...h},bufferLayout:[...l.bufferLayout||[],...p],instanceCount:c?.length||0,isInstanced:!0}:{},defines:{...s.defines,...l.defines,...c||f?{HAS_GLTF_INSTANCING:!0}:{},...T?{HAS_INSTANCED_SKIN:!0,CROWD_JOINTS_PER_INSTANCE:f.jointsPerInstance}:{},...b?{HAS_GPU_CROWD_ANIMATION:!0,CROWD_ANIMATION_FRAME_STRIDE:k}:{},...I?{HAS_INSTANCED_MORPH:!0,CROWD_MORPH_TARGET_COUNT:E}:{},...f?{CROWD_ANIMATION_JOINT_COUNT:N}:{}},parameters:{depthWriteEnabled:!0,depthCompare:"less",depthFormat:"depth24plus",cullMode:"back",...s.parameters,...l.parameters}},V=r.material||il(e,{id:i?`${i}-material`:void 0,parsedPPBRMaterial:s});U.material=V;const j=new t.Model(e,U),z={...s.uniforms,...l.uniforms,...s.bindings,...l.bindings},H=function(e,t,n){const r=new Map;for(const a of e){for(const e of Object.keys(a.uniformTypes||{}))r.set(e,a.name);for(const e of a.bindingLayout||[])r.set(e.name,a.name)}const i={};for(const[a,o]of Object.entries(n)){if(void 0===o)continue;const e=r.get(a);e&&!t.ownsModule(e)&&(i[e]||={},i[e][a]=o)}return i}(j.shaderInputs.getModules(),V,z);j.shaderInputs.setProps(H),S&&j.shaderInputs.setProps({skin:{jointMatrices:[],skinJointMatrices:S}}),(L||I||P)&&j.shaderInputs.setProps({gpuAnimation:{...L?{gpuAnimationFrames:L}:{},...I?{gpuMorphTargets:I}:{},...P?{gpuMorphWeights:P}:{}}});const q=new ke({managedResources:d,model:j,bounds:r.bounds,instanceMatrices:c});return f&&(q.userData.gltfAnimatedCrowd={transformBuffers:m,transformColumns:g,skinJointMatrices:S,jointMatrices:M,jointsPerInstance:f.jointsPerInstance,morphTargetCount:E,morphTargetData:I,morphWeights:R,morphWeightData:P,animationFrames:L,animationFrameValues:B,animationFrameStride:k,animationJointCount:N,animationParameters:v,animationParameterBuffer:y,animationBlend:x,animationBlendBuffer:_}),q}function ol(e,t,r,i,o){if("webgpu"===e.type)return e.createBuffer({id:t,data:r,usage:a.Buffer.STORAGE|a.Buffer.COPY_DST});const s=e.createTexture({id:t,format:"rgba32float",width:i,height:o,usage:n.Texture.SAMPLE|n.Texture.COPY_DST,sampler:{minFilter:"nearest",magFilter:"nearest",mipmapFilter:"nearest"}});return s.writeData(r,{width:i,height:o}),s}function sl(e,t,n){if(!e)return[...n];const r=e.value;return n.map((n,i)=>{const a=r[t*e.size+i];return void 0===a?n:e.normalized?e.value instanceof Int8Array?Math.max(a/127,-1):e.value instanceof Int16Array?Math.max(a/32767,-1):e.value instanceof Uint8Array?a/255:e.value instanceof Uint16Array?a/65535:a:a})}function Al(e){switch(e){case"VEC2":return 2;case"VEC3":return 3;case"VEC4":return 4;default:return 1}}function ll(e,t){e.userData.morphWeights=[...t];const n=e.userData.morphMeshes||[];for(const r of n)r.preorderTraversal(e=>{if(!(e instanceof ke))return;const n=e.userData.morphTargets;n&&(ee(e.model,n.geometry,n.targets,t),e.userData.morphWeights=[...t])})}function cl(e){switch(e){case rl.POINTS:return"point-list";case rl.LINES:return"line-list";case rl.LINE_STRIP:return"line-strip";case rl.TRIANGLES:return"triangle-list";case rl.TRIANGLE_STRIP:return"triangle-strip";default:throw new Error(String(e))}}!function(e){e[e.POINTS=0]="POINTS",e[e.LINES=1]="LINES",e[e.LINE_LOOP=2]="LINE_LOOP",e[e.LINE_STRIP=3]="LINE_STRIP",e[e.TRIANGLES=4]="TRIANGLES",e[e.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",e[e.TRIANGLE_FAN=6]="TRIANGLE_FAN",e[e.ONE=1]="ONE",e[e.SRC_ALPHA=770]="SRC_ALPHA",e[e.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",e[e.FUNC_ADD=32774]="FUNC_ADD",e[e.LINEAR=9729]="LINEAR",e[e.NEAREST=9728]="NEAREST",e[e.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",e[e.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",e[e.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",e[e.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",e[e.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",e[e.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",e[e.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",e[e.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",e[e.REPEAT=10497]="REPEAT",e[e.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",e[e.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL"}(rl||(rl={}));var ul=[dl("baseColor","pbr_baseColorSampler","baseColorTexture",["pbrMetallicRoughness","baseColorTexture"]),dl("metallicRoughness","pbr_metallicRoughnessSampler","metallicRoughnessTexture",["pbrMetallicRoughness","metallicRoughnessTexture"]),dl("normal","pbr_normalSampler","normalTexture",["normalTexture"]),dl("occlusion","pbr_occlusionSampler","occlusionTexture",["occlusionTexture"]),dl("emissive","pbr_emissiveSampler","emissiveTexture",["emissiveTexture"]),dl("specularColor","pbr_specularColorSampler","KHR_materials_specular.specularColorTexture",["extensions","KHR_materials_specular","specularColorTexture"]),dl("specularIntensity","pbr_specularIntensitySampler","KHR_materials_specular.specularTexture",["extensions","KHR_materials_specular","specularTexture"]),dl("transmission","pbr_transmissionSampler","KHR_materials_transmission.transmissionTexture",["extensions","KHR_materials_transmission","transmissionTexture"]),dl("thickness","pbr_thicknessSampler","KHR_materials_volume.thicknessTexture",["extensions","KHR_materials_volume","thicknessTexture"]),dl("clearcoat","pbr_clearcoatSampler","KHR_materials_clearcoat.clearcoatTexture",["extensions","KHR_materials_clearcoat","clearcoatTexture"]),dl("clearcoatRoughness","pbr_clearcoatRoughnessSampler","KHR_materials_clearcoat.clearcoatRoughnessTexture",["extensions","KHR_materials_clearcoat","clearcoatRoughnessTexture"]),dl("clearcoatNormal","pbr_clearcoatNormalSampler","KHR_materials_clearcoat.clearcoatNormalTexture",["extensions","KHR_materials_clearcoat","clearcoatNormalTexture"]),dl("sheenColor","pbr_sheenColorSampler","KHR_materials_sheen.sheenColorTexture",["extensions","KHR_materials_sheen","sheenColorTexture"]),dl("sheenRoughness","pbr_sheenRoughnessSampler","KHR_materials_sheen.sheenRoughnessTexture",["extensions","KHR_materials_sheen","sheenRoughnessTexture"]),dl("iridescence","pbr_iridescenceSampler","KHR_materials_iridescence.iridescenceTexture",["extensions","KHR_materials_iridescence","iridescenceTexture"]),dl("iridescenceThickness","pbr_iridescenceThicknessSampler","KHR_materials_iridescence.iridescenceThicknessTexture",["extensions","KHR_materials_iridescence","iridescenceThicknessTexture"]),dl("anisotropy","pbr_anisotropySampler","KHR_materials_anisotropy.anisotropyTexture",["extensions","KHR_materials_anisotropy","anisotropyTexture"]),dl("bump","pbr_bumpSampler","EXT_materials_bump.bumpTexture",["extensions","EXT_materials_bump","bumpTexture"]),dl("diffuseTransmission","pbr_diffuseTransmissionSampler","KHR_materials_diffuse_transmission.diffuseTransmissionTexture",["extensions","KHR_materials_diffuse_transmission","diffuseTransmissionTexture"]),dl("diffuseTransmissionColor","pbr_diffuseTransmissionColorSampler","KHR_materials_diffuse_transmission.diffuseTransmissionColorTexture",["extensions","KHR_materials_diffuse_transmission","diffuseTransmissionColorTexture"]),dl("multiscatterColor","pbr_multiscatterColorSampler","KHR_materials_volume_scatter.multiscatterColorTexture",["extensions","KHR_materials_volume_scatter","multiscatterColorTexture"])],fl=new Map(ul.map(e=>[e.slot,e]));function dl(e,t,n,r){return{slot:e,binding:t,displayName:n,pathSegments:r,colorSpace:"baseColor"===e||"emissive"===e||"specularColor"===e||"sheenColor"===e||"diffuseTransmissionColor"===e||"multiscatterColor"===e?"srgb":"linear",uvSetUniform:`${e}UVSet`,uvTransformUniform:`${e}UVTransform`}}function hl(e){const t=fl.get(e);if(!t)throw new Error(`Unknown PBR texture transform slot ${e}`);return t}function pl(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 ml(e){return(e?.extensions?.KHR_texture_transform)?.texCoord??e?.texCoord??0}function gl(e){const t=(new L).set(1,0,0,0,1,0,e.offset[0],e.offset[1],1),n=(new L).set(Math.cos(e.rotation),Math.sin(e.rotation),0,-Math.sin(e.rotation),Math.cos(e.rotation),0,0,0,1),r=(new L).set(e.scale[0],0,0,0,e.scale[1],0,0,0,1);return Array.from(t.multiplyRight(n).multiplyRight(r))}function bl(e,t){const n=new L(gl(e)),r=new L(gl(t)),i=new L(n).invert();return Array.from(r.multiplyRight(i))}function vl(e={}){const t=e.wrapS??e.parameters?.[rl.TEXTURE_WRAP_S],n=e.wrapT??e.parameters?.[rl.TEXTURE_WRAP_T],r=e.magFilter??e.parameters?.[rl.TEXTURE_MAG_FILTER],i=e.minFilter??e.parameters?.[rl.TEXTURE_MIN_FILTER],a=yl(t),o=yl(n),s=function(e){switch(e){case rl.NEAREST:return"nearest";case rl.LINEAR:return"linear";default:return}}(r);return{...a?{addressModeU:a}:{},...o?{addressModeV:o}:{},...s?{magFilter:s}:{},...xl(i)}}function yl(e){switch(e){case rl.CLAMP_TO_EDGE:return"clamp-to-edge";case rl.REPEAT:return"repeat";case rl.MIRRORED_REPEAT:return"mirror-repeat";default:return}}function xl(e){switch(e){case rl.NEAREST:return{minFilter:"nearest"};case rl.LINEAR:return{minFilter:"linear"};case rl.NEAREST_MIPMAP_NEAREST:return{minFilter:"nearest",mipmapFilter:"nearest"};case rl.LINEAR_MIPMAP_NEAREST:return{minFilter:"linear",mipmapFilter:"nearest"};case rl.NEAREST_MIPMAP_LINEAR:return{minFilter:"nearest",mipmapFilter:"linear"};case rl.LINEAR_MIPMAP_LINEAR:return{minFilter:"linear",mipmapFilter:"linear"};default:return{}}}var _l={NORMAL:["NORMAL","normals"],TANGENT:["TANGENT"],TEXCOORD_0:["TEXCOORD_0","texCoords"],TEXCOORD_1:["TEXCOORD_1","texCoords1"],JOINTS_0:["JOINTS_0"],WEIGHTS_0:["WEIGHTS_0"],COLOR_0:["COLOR_0","colors"]};function wl(e,t,n,r){const i={defines:{MANUAL_SRGB:!0},bindings:{},uniforms:{camera:[0,0,0],metallicRoughnessValues:[1,1]},parameters:{},glParameters:{},generatedTextures:[]};i.defines.USE_TEX_LOD=!0;const{imageBasedLightingEnvironment:o}=r;return o&&(i.bindings.pbr_diffuseEnvSampler=o.diffuseEnvSampler.texture,i.bindings.pbr_specularEnvSampler=o.specularEnvSampler.texture,i.bindings.pbr_brdfLUT=o.brdfLutTexture.texture,i.uniforms.IBLenabled=!0,i.uniforms.scaleIBLAmbient=[1,1]),r?.pbrDebug&&(i.defines.PBR_DEBUG=!0,i.uniforms.scaleDiffBaseMR=[0,0,0,0],i.uniforms.scaleFGDSpec=[0,0,0,0]),Sl(n,"NORMAL")&&(i.defines.HAS_NORMALS=!0),Sl(n,"TANGENT")&&r?.useTangents&&(i.defines.HAS_TANGENTS=!0),Sl(n,"TEXCOORD_0")&&(i.defines.HAS_UV=!0),Sl(n,"TEXCOORD_1")&&(i.defines.HAS_UV_1=!0),Sl(n,"JOINTS_0")&&Sl(n,"WEIGHTS_0")&&(i.defines.HAS_SKIN=!0),Sl(n,"COLOR_0")&&(i.defines.HAS_COLORS=!0),r?.imageBasedLightingEnvironment&&(i.defines.USE_IBL=!0),r?.lights&&(i.defines.USE_LIGHTS=!0),t&&(!1!==r.validateAttributes&&function(e,t){const n=Tl(e,0);n.length>0&&!Sl(t,"TEXCOORD_0")&&a.log.warn(`glTF material uses ${n.join(", ")} but primitive is missing TEXCOORD_0; textured shading will sample the default UV coordinates`)();const r=Tl(e,1);r.length>0&&!Sl(t,"TEXCOORD_1")&&a.log.warn(`glTF material uses ${r.join(", ")} with TEXCOORD_1 but primitive is missing TEXCOORD_1; those textures will be skipped`)();if(Boolean(e.unlit||e.extensions?.KHR_materials_unlit)||Sl(t,"NORMAL"))return;const i=e.normalTexture?"lit PBR shading with normalTexture":"lit PBR shading";a.log.warn(`glTF primitive is missing NORMAL while using ${i}; shading will fall back to geometric normals`)()}(t,n),function(e,t,n,r,i){n.uniforms.unlit=Boolean(t.unlit||t.extensions?.KHR_materials_unlit),t.pbrMetallicRoughness&&function(e,t,n,r,i){t.baseColorTexture&&El(e,t.baseColorTexture,"pbr_baseColorSampler",n,{featureOptions:{define:"HAS_BASECOLORMAP",enabledUniformName:"baseColorMapEnabled"},gltf:i,attributes:r,textureTransformSlot:"baseColor"});n.uniforms.baseColorFactor=t.baseColorFactor||[1,1,1,1],t.metallicRoughnessTexture&&El(e,t.metallicRoughnessTexture,"pbr_metallicRoughnessSampler",n,{featureOptions:{define:"HAS_METALROUGHNESSMAP",enabledUniformName:"metallicRoughnessMapEnabled"},gltf:i,attributes:r,textureTransformSlot:"metallicRoughness"});const{metallicFactor:a=1,roughnessFactor:o=1}=t;n.uniforms.metallicRoughnessValues=[a,o]}(e,t.pbrMetallicRoughness,n,r,i);if(t.normalTexture){El(e,t.normalTexture,"pbr_normalSampler",n,{featureOptions:{define:"HAS_NORMALMAP",enabledUniformName:"normalMapEnabled"},gltf:i,attributes:r,textureTransformSlot:"normal"});const{scale:a=1}=t.normalTexture;n.uniforms.normalScale=a}if(t.occlusionTexture){El(e,t.occlusionTexture,"pbr_occlusionSampler",n,{featureOptions:{define:"HAS_OCCLUSIONMAP",enabledUniformName:"occlusionMapEnabled"},gltf:i,attributes:r,textureTransformSlot:"occlusion"});const{strength:a=1}=t.occlusionTexture;n.uniforms.occlusionStrength=a}n.uniforms.emissiveFactor=t.emissiveFactor||[0,0,0],t.emissiveTexture&&El(e,t.emissiveTexture,"pbr_emissiveSampler",n,{featureOptions:{define:"HAS_EMISSIVEMAP",enabledUniformName:"emissiveMapEnabled"},gltf:i,attributes:r,textureTransformSlot:"emissive"});switch(function(e,t,n,r,i={}){if(!t)return;(function(e){return Boolean(e.KHR_materials_specular||e.KHR_materials_ior||e.EXT_materials_bump||e.KHR_materials_transmission||e.KHR_materials_diffuse_transmission||e.KHR_materials_volume||e.KHR_materials_volume_scatter||e.KHR_materials_dispersion||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,r,i={}){if(!t)return;t.specularColorFactor&&(n.uniforms.specularColorFactor=t.specularColorFactor);void 0!==t.specularFactor&&(n.uniforms.specularIntensityFactor=t.specularFactor);t.specularColorTexture&&El(e,t.specularColorTexture,"pbr_specularColorSampler",n,{featureOptions:{define:"HAS_SPECULARCOLORMAP",enabledUniformName:"specularColorMapEnabled"},gltf:r,attributes:i,textureTransformSlot:"specularColor"});t.specularTexture&&El(e,t.specularTexture,"pbr_specularIntensitySampler",n,{featureOptions:{define:"HAS_SPECULARINTENSITYMAP",enabledUniformName:"specularIntensityMapEnabled"},gltf:r,attributes:i,textureTransformSlot:"specularIntensity"})})(e,t.KHR_materials_specular,n,r,i),function(e,t){void 0!==e?.ior&&(t.uniforms.ior=e.ior)}(t.KHR_materials_ior,n),function(e,t,n,r,i={}){if(!t)return;n.uniforms.bumpFactor=Math.max(t.bumpFactor??1,0),t.bumpTexture&&El(e,t.bumpTexture,"pbr_bumpSampler",n,{featureOptions:{define:"HAS_BUMPMAP",enabledUniformName:"bumpMapEnabled"},gltf:r,attributes:i,textureTransformSlot:"bump"})}(e,t.EXT_materials_bump,n,r,i),function(e,t,n,r,i={}){if(!t)return;void 0!==t.transmissionFactor&&(n.uniforms.transmissionFactor=t.transmissionFactor);t.transmissionTexture&&El(e,t.transmissionTexture,"pbr_transmissionSampler",n,{featureOptions:{define:"HAS_TRANSMISSIONMAP",enabledUniformName:"transmissionMapEnabled"},gltf:r,attributes:i,textureTransformSlot:"transmission"});((t.transmissionFactor??0)>0||t.transmissionTexture)&&(a.log.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=rl.FUNC_ADD,e.glParameters.blendFunc=[rl.ONE,rl.ONE_MINUS_SRC_ALPHA,rl.ONE,rl.ONE_MINUS_SRC_ALPHA]}(n))}(e,t.KHR_materials_transmission,n,r,i),function(e,t,n,r,i={}){if(!t)return;n.uniforms.diffuseTransmissionFactor=Math.min(Math.max(t.diffuseTransmissionFactor??0,0),1),n.uniforms.diffuseTransmissionColorFactor=t.diffuseTransmissionColorFactor||[1,1,1],t.diffuseTransmissionTexture&&El(e,t.diffuseTransmissionTexture,"pbr_diffuseTransmissionSampler",n,{featureOptions:{define:"HAS_DIFFUSETRANSMISSIONMAP",enabledUniformName:"diffuseTransmissionMapEnabled"},gltf:r,attributes:i,textureTransformSlot:"diffuseTransmission"});t.diffuseTransmissionColorTexture&&El(e,t.diffuseTransmissionColorTexture,"pbr_diffuseTransmissionColorSampler",n,{featureOptions:{define:"HAS_DIFFUSETRANSMISSIONCOLORMAP",enabledUniformName:"diffuseTransmissionColorMapEnabled"},gltf:r,attributes:i,textureTransformSlot:"diffuseTransmissionColor"})}(e,t.KHR_materials_diffuse_transmission,n,r,i),function(e,t,n,r,i={}){if(!t)return;void 0!==t.thicknessFactor&&(n.uniforms.thicknessFactor=t.thicknessFactor);t.thicknessTexture&&El(e,t.thicknessTexture,"pbr_thicknessSampler",n,{featureOptions:{define:"HAS_THICKNESSMAP"},gltf:r,attributes:i,textureTransformSlot:"thickness"});void 0!==t.attenuationDistance&&(n.uniforms.attenuationDistance=t.attenuationDistance);t.attenuationColor&&(n.uniforms.attenuationColor=t.attenuationColor)}(e,t.KHR_materials_volume,n,r,i),function(e,t,n,r,i,a={}){if(!t||!n)return;r.uniforms.multiscatterColorFactor=t.multiscatterColorFactor||t.multiscatterColor||[0,0,0],r.uniforms.scatterAnisotropy=Math.min(Math.max(t.scatterAnisotropy??0,-.999),.999),t.multiscatterColorTexture&&El(e,t.multiscatterColorTexture,"pbr_multiscatterColorSampler",r,{featureOptions:{define:"HAS_MULTISCATTERCOLORMAP",enabledUniformName:"multiscatterColorMapEnabled"},gltf:i,attributes:a,textureTransformSlot:"multiscatterColor"})}(e,t.KHR_materials_volume_scatter,t.KHR_materials_volume,n,r,i),function(e,t){void 0!==e?.dispersion&&(t.uniforms.dispersion=Math.max(e.dispersion,0))}(t.KHR_materials_dispersion,n),function(e,t,n,r,i={}){if(!t)return;void 0!==t.clearcoatFactor&&(n.uniforms.clearcoatFactor=t.clearcoatFactor);void 0!==t.clearcoatRoughnessFactor&&(n.uniforms.clearcoatRoughnessFactor=t.clearcoatRoughnessFactor);t.clearcoatTexture&&El(e,t.clearcoatTexture,"pbr_clearcoatSampler",n,{featureOptions:{define:"HAS_CLEARCOATMAP",enabledUniformName:"clearcoatMapEnabled"},gltf:r,attributes:i,textureTransformSlot:"clearcoat"});t.clearcoatRoughnessTexture&&El(e,t.clearcoatRoughnessTexture,"pbr_clearcoatRoughnessSampler",n,{featureOptions:{define:"HAS_CLEARCOATROUGHNESSMAP",enabledUniformName:"clearcoatRoughnessMapEnabled"},gltf:r,attributes:i,textureTransformSlot:"clearcoatRoughness"});t.clearcoatNormalTexture&&El(e,t.clearcoatNormalTexture,"pbr_clearcoatNormalSampler",n,{featureOptions:{define:"HAS_CLEARCOATNORMALMAP"},gltf:r,attributes:i,textureTransformSlot:"clearcoatNormal"})}(e,t.KHR_materials_clearcoat,n,r,i),function(e,t,n,r,i={}){if(!t)return;t.sheenColorFactor&&(n.uniforms.sheenColorFactor=t.sheenColorFactor);void 0!==t.sheenRoughnessFactor&&(n.uniforms.sheenRoughnessFactor=t.sheenRoughnessFactor);t.sheenColorTexture&&El(e,t.sheenColorTexture,"pbr_sheenColorSampler",n,{featureOptions:{define:"HAS_SHEENCOLORMAP",enabledUniformName:"sheenColorMapEnabled"},gltf:r,attributes:i,textureTransformSlot:"sheenColor"});t.sheenRoughnessTexture&&El(e,t.sheenRoughnessTexture,"pbr_sheenRoughnessSampler",n,{featureOptions:{define:"HAS_SHEENROUGHNESSMAP",enabledUniformName:"sheenRoughnessMapEnabled"},gltf:r,attributes:i,textureTransformSlot:"sheenRoughness"})}(e,t.KHR_materials_sheen,n,r,i),function(e,t,n,r,i={}){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&&El(e,t.iridescenceTexture,"pbr_iridescenceSampler",n,{featureOptions:{define:"HAS_IRIDESCENCEMAP",enabledUniformName:"iridescenceMapEnabled"},gltf:r,attributes:i,textureTransformSlot:"iridescence"});t.iridescenceThicknessTexture&&El(e,t.iridescenceThicknessTexture,"pbr_iridescenceThicknessSampler",n,{featureOptions:{define:"HAS_IRIDESCENCETHICKNESSMAP"},gltf:r,attributes:i,textureTransformSlot:"iridescenceThickness"})}(e,t.KHR_materials_iridescence,n,r,i),function(e,t,n,r,i={}){if(!t)return;void 0!==t.anisotropyStrength&&(n.uniforms.anisotropyStrength=t.anisotropyStrength);void 0!==t.anisotropyRotation&&(n.uniforms.anisotropyRotation=t.anisotropyRotation);t.anisotropyTexture&&El(e,t.anisotropyTexture,"pbr_anisotropySampler",n,{featureOptions:{define:"HAS_ANISOTROPYMAP",enabledUniformName:"anisotropyMapEnabled"},gltf:r,attributes:i,textureTransformSlot:"anisotropy"})}(e,t.KHR_materials_anisotropy,n,r,i),function(e,t){void 0!==e?.emissiveStrength&&(t.uniforms.emissiveStrength=e.emissiveStrength)}(t.KHR_materials_emissive_strength,n)}(e,t.extensions,n,i,r),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":a.log.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=rl.FUNC_ADD,e.glParameters.blendFunc=[rl.SRC_ALPHA,rl.ONE_MINUS_SRC_ALPHA,rl.ONE,rl.ONE_MINUS_SRC_ALPHA]}(n)}}(e,t,i,n,r.gltf)),i}function Tl(e,t){const n=[];for(const r of ul){const i=Ml(e,r.pathSegments);i&&(ml(i)===t&&n.push(r.displayName))}return n}function Sl(e,t){return _l[t].some(t=>Boolean(e[t]))}function Ml(e,t){let n=e;for(const r of t)if(n=n?.[r],!n)return null;return n}function El(e,t,r,i,o={}){const{featureOptions:s={},gltf:A,attributes:l={},textureTransformSlot:c}=o,{define:u,enabledUniformName:f}=s,d=ml(t);if(d>1)return void a.log.warn(`Skipping ${String(r)} because ${d} is not supported; only TEXCOORD_0 and TEXCOORD_1 are currently available`)();if(1===d&&!Sl(l,"TEXCOORD_1"))return void a.log.warn(`Skipping ${String(r)} because it requires TEXCOORD_1 but the primitive does not provide TEXCOORD_1`)();const h=function(e,t){if(e.texture||void 0===e.index||!t?.textures)return e;const n=t.textures[e.index];return n?"texture"in n&&n.texture?{...n,...e,texture:n.texture}:"source"in n?{...e,texture:n}:e:e}(t,A),p=h.texture?.source?.image;if(!p)return void a.log.warn(`Skipping unresolved glTF texture for ${String(r)}`)();const m=function(e,t,r){if("compressed"in t)return function(e,t,r){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 a.log.warn("createCompressedTexture: compressed image has no valid mip levels, creating fallback")(),Cl(e,r);const o=i[0],s=o.width??t.width??0,A=o.height??t.height??0;if(s<=0||A<=0)return a.log.warn("createCompressedTexture: base level has invalid dimensions, creating fallback")(),Cl(e,r);const l=Il(o);if(!l)return a.log.warn("createCompressedTexture: compressed image has no textureFormat, creating fallback")(),Cl(e,r);if(!e.isTextureFormatSupported(l))return a.log.warn(`createCompressedTexture: ${e.type} device does not support '${l}', creating fallback`)(),Cl(e,r);const c=function(e,t,r){const{blockWidth:i=1,blockHeight:a=1}=n.textureFormatDecoder.getInfo(r);let o=1;for(let n=1;;n++){const r=Math.max(1,e>>n),s=Math.max(1,t>>n);if(r<i||s<a)break;o++}return o}(s,A,l),u=Math.min(i.length,c);let f=1;for(let n=1;n<u;n++){const e=i[n];if(!e.data||e.width<=0||e.height<=0){a.log.warn(`createCompressedTexture: mip level ${n} has invalid data/dimensions, truncating`)();break}const t=Il(e);if(t&&t!==l){a.log.warn(`createCompressedTexture: mip level ${n} format '${t}' differs from base '${l}', truncating`)();break}const r=Math.max(1,s>>n),o=Math.max(1,A>>n);if(e.width!==r||e.height!==o){a.log.warn(`createCompressedTexture: mip level ${n} dimensions ${e.width}x${e.height} don't match expected ${r}x${o}, truncating`)();break}f++}const d=e.createTexture({...r,format:l,usage:n.Texture.TEXTURE|n.Texture.COPY_DST,width:s,height:A,mipLevels:f,data:o.data});for(let n=1;n<f;n++)d.writeData(i[n].data,{width:i[n].width,height:i[n].height,mipLevel:n});return d}(e,t,{id:r.id,sampler:r.sampler});const i=void 0!==r.width&&void 0!==r.height?{width:r.width,height:r.height}:e.getExternalImageSize(t),o="nearest"===r.sampler.mipmapFilter||"linear"===r.sampler.mipmapFilter,s=o?e.getMipLevelCount(i.width,i.height):1,A=e.createTexture({id:r.id,sampler:r.sampler,width:i.width,height:i.height,mipLevels:s,...o?{usage:n.Texture.SAMPLE|n.Texture.RENDER|n.Texture.COPY_DST|n.Texture.COPY_SRC}:{},...r.colorSpace?{format:"srgb"===r.colorSpace?"rgba8unorm-srgb":"rgba8unorm"}:{},data:t});s>1&&("webgl"===e.type?A.generateMipmapsWebGL():"webgpu"===e.type&&e.generateMipmapsWebGPU(A));return A}(e,p,{id:h.uniformName||h.id,sampler:{addressModeU:"repeat",addressModeV:"repeat",minFilter:"linear",magFilter:"linear",...vl(h.texture.sampler)}});if(i.bindings[r]=m,u&&(i.defines[u]=!0),f&&(i.uniforms[f]=!0),c){const e=hl(c);i.uniforms[e.uvSetUniform]=d,i.uniforms[e.uvTransformUniform]=gl(pl(t))}i.generatedTextures.push(m)}function Cl(e,t){return e.createTexture({...t,format:"rgba8unorm",width:1,height:1,mipLevels:1})}function Il(e){return e.textureFormat}var Rl={modelOptions:{},pbrDebug:!1,imageBasedLightingEnvironment:void 0,lights:!0,useTangents:!1,useByteColors:!0,strictExtensions:!1};function Pl(e,t,r={}){const i=new Set,a={...Rl,...r,generatedTextures:i},o=new ae(e,{modules:[G]}),s=(t.materials||[]).map((n,r)=>il(e,{id:Ll(n,r),parsedPPBRMaterial:Nl(e,n,{},{...a,gltf:t,validateAttributes:!1}),materialFactory:o})),A=new Map;(t.materials||[]).forEach((e,t)=>{A.set(e.id,s[t])});const l=new Map;t.meshes.forEach((n,r)=>{const i=kl(e,n,t,A,a);l.set(n.id,i)});const c=new Map,u=new Map,f=new Set,d=new Set,h=new Set;return t.nodes.forEach((e,t)=>{const n=function(e,t){return new Ne({id:t.name||t.id,children:[],matrix:t.matrix,display:!1!==t.extensions?.KHR_node_visibility?.visible,position:t.translation,rotation:t.rotation,scale:t.scale})}(0,e);c.set(t,n),u.set(e.id,n)}),t.nodes.forEach((r,i)=>{if(c.get(i).add((r.children??[]).map(({id:e})=>{const t=u.get(e);if(!t)throw new Error(`Cannot find child ${e} of node ${i}`);return t})),r.mesh){const o=r.mesh,s=function(e,t){const r=t.extensions?.EXT_mesh_gpu_instancing?.attributes;if(!r||"object"!=typeof r)return null;const i={};let a;for(const[n,s]of Object.entries(r)){const t="number"==typeof s?e.accessors[s]:s;if(!t||!ArrayBuffer.isView(t.value))throw new Error(`Invalid glTF instance accessor for ${n}`);if(void 0!==a&&t.count!==a)throw new Error("glTF instance attributes must have matching accessor counts");a=t.count,i[n]={value:t.value,size:t.components||Al(t.type),count:t.count,normalized:Boolean(t.normalized)}}const o=[];for(let s=0;s<(a||0);s++){const e=sl(i.TRANSLATION,s,[0,0,0]),t=sl(i.ROTATION,s,[0,0,0,1]),r=sl(i.SCALE,s,[1,1,1]),a=Math.hypot(...t);if(a>0)for(let n=0;n<t.length;n++)t[n]/=a;o.push((new n.Matrix4).translate(e).multiplyRight((new n.Matrix4).fromQuaternion(t)).scale(r))}return{matrices:o,attributes:i}}(t,r),u=o.primitives.some(e=>Boolean(e.targets?.length)),p=s||u&&f.has(o.id)?kl(e,o,t,A,a,s||void 0):l.get(o.id);if(!p)throw new Error(`Cannot find mesh child ${r.mesh.id} of node ${i}`);const m=c.get(i),g=l.get(o.id),b=d.has(o.id)&&(void 0!==r.skin||h.has(o.id))&&p===g?kl(e,o,t,A,a):p;if(m.add(b),m.userData.gltfMesh=b,d.add(o.id),void 0!==r.skin&&h.add(o.id),u){f.add(o.id);const e=o.primitives.find(e=>e.targets?.length)?.targets?.length||0,t=r.weights||o.weights||new Array(e).fill(0);m.userData.morphMeshes=[b],a.modelOptions?.userData?.gltfAnimatedCrowd?m.userData.morphWeights=[...t]:ll(m,t)}}}),{scenes:t.scenes.map(e=>{const t=(e.nodes||[]).map(({id:t})=>{const n=u.get(t);if(!n)throw new Error(`Cannot find child ${t} of scene ${e.name||e.id}`);return n});return new Ne({id:e.name||e.id,children:t})}),materials:s,gltfMeshIdToNodeMap:l,gltfNodeIdToNodeMap:u,gltfNodeIndexToNodeMap:c,generatedTextures:i}}function Nl(e,t,n,r){const i=wl(e,t,n,r);for(const a of i.generatedTextures)r.generatedTextures.add(a);return i}function kl(e,n,r,i,a,o){const s=(n.primitives||[]).map((s,A)=>function({device:e,gltfPrimitive:n,primitiveIndex:r,gltfMesh:i,gltf:a,gltfMaterialIdToMaterialMap:o,options:s,instancing:A}){const l=n.name||`${i.name||i.id}-primitive-${r}`,c=function(e){let t=1/0;for(const n of Object.values(e))if(n){const{value:e,size:r,components:i}=n,a=r??i;void 0!==e?.length&&a>=1&&(t=Math.min(t,e.length/a))}if(!Number.isFinite(t))throw new Error("Could not determine vertex count from attributes");return t}(n.attributes),u=function(e,n,r){const i={};for(const[t,a]of Object.entries(n.attributes)){const{components:e,size:r,value:o,normalized:s}=a,A="POSITION"===t||"NORMAL"===t||"TANGENT"===t,l=Boolean(n.targets?.length&&A);i[t]={size:r??e,value:l?Z({value:o,normalized:s}):o,normalized:!l&&s}}return new t.Geometry({id:e,topology:r.topology,indices:r.indices??n.indices?.value,attributes:i})}(l,n,function(e,t,n){if(e!==rl.LINE_LOOP&&e!==rl.TRIANGLE_FAN)return{topology:cl(e)};const r=t?.length??n,i=e===rl.LINE_LOOP?r>=2?2*r:0:r>=3?3*(r-2):0,a=new(t instanceof Uint32Array||!t&&n>65536?Uint32Array:Uint16Array)(i),o=e=>t?.[e]??e;if(e===rl.LINE_LOOP){for(let e=0;e<r;e++)a[2*e]=o(e),a[2*e+1]=o((e+1)%r);return{topology:"line-list",indices:a}}for(let s=0;s<r-2;s++)a[3*s]=o(0),a[3*s+1]=o(s+1),a[3*s+2]=o(s+2);return{topology:"triangle-list",indices:a}}(n.mode??4,n.indices?.value,c)),f=u.vertexCount,d=function(e,t,n){if(!e.targets?.length)return;const r={};for(const i of["POSITION","NORMAL","TANGENT"]){const e=n.attributes[i]?.value;e instanceof Float32Array&&(r[i]=new Float32Array(e))}return{geometry:n,baseAttributes:r,targets:e.targets.map(e=>{const n={};for(const r of["POSITION","NORMAL","TANGENT"]){const i=e[r],a="number"==typeof i?t.accessors[i]:i;a?.value&&ArrayBuffer.isView(a.value)&&(n[r]=Z(a))}return n})}}(n,a,u),h=Nl(e,n.material,u.attributes,{...s,gltf:a}),p=al(e,{id:l,geometry:u,material:n.material&&o.get(n.material.id)||null,parsedPPBRMaterial:h,modelOptions:s.modelOptions,vertexCount:f,bounds:[n.attributes.POSITION.min,n.attributes.POSITION.max],instanceMatrices:A?.matrices,morphTargets:d?.targets});A&&(p.userData.gltfInstancing=A);const m=n.extensions?.KHR_materials_variants?.mappings||[];if(m.length){const t=new Map;for(const n of m){const r="number"==typeof n.material?a.materials[n.material]:n.material,i=r&&o.get(r.id);if(!i)continue;const A=Nl(e,r,u.attributes,{...s,gltf:a});for(const e of n.variants||[])t.set(e,{material:i,parameters:{...p.model.parameters,...A.parameters,depthWriteEnabled:"BLEND"!==r.alphaMode,cullMode:r.doubleSided?"none":"back"}})}p.userData.gltfMaterialVariants={defaultMaterial:p.model.material,defaultParameters:{...p.model.parameters},mappings:t}}d&&(p.userData.morphTargets=d);return p}({device:e,gltfPrimitive:s,primitiveIndex:A,gltfMesh:n,gltf:r,gltfMaterialIdToMaterialMap:i,options:a,instancing:o}));return new Ne({id:n.name||n.id,children:s})}function Ll(e,t){return e.name||e.id||`material-${t}`}function Bl(e,t={}){const n=t.lightDefinitions||e.lights||e.extensions?.KHR_lights_punctual?.lights;if(!n||!Array.isArray(n)||0===n.length)return[];const r=[],i=function(e){const t=new Map;for(const n of e)for(const e of n.children||[])t.set(e.id,n);return t}(e.nodes||[]),a=new Map;for(const o of e.nodes||[]){if(!Ol(o,i,t.nodeVisibility))continue;const e=o.light??o.extensions?.KHR_lights_punctual?.light;if("number"!=typeof e||t.nodeIdentifiers&&!t.nodeIdentifiers.has(o.id))continue;const s=n[e];if(!s)continue;const A=Fl(s.color||[1,1,1],t.useByteColors??!0),l=s.intensity??1,c=s.range,u=jl(o,i,a);switch(s.type){case"directional":r.push(Ul(u,A,l));break;case"point":r.push(Dl(u,A,l,c));break;case"spot":r.push(Vl(u,A,l,c,s.spot))}}return r}function Ol(e,t,n){let r=e;for(;r;){const e=n?.get(r.id);if(e?!e.display:!1===r.extensions?.KHR_node_visibility?.visible)return!1;r=t.get(r.id)}return!0}function Fl(e,n){return n?e.map(e=>255*e):t.normalizeByteColor3(e,!1)}function Dl(e,t,n,r){let i=[1,0,0];return void 0!==r&&r>0&&(i=[1,0,1/(r*r)]),{type:"point",position:zl(e),color:t,intensity:n,attenuation:i}}function Ul(e,t,n){return{type:"directional",direction:Gl(e),color:t,intensity:n}}function Vl(e,t,n,r,i={}){let a=[1,0,0];return void 0!==r&&r>0&&(a=[1,0,1/(r*r)]),{type:"spot",position:zl(e),direction:Gl(e),color:t,intensity:n,attenuation:a,innerConeAngle:i.innerConeAngle??0,outerConeAngle:i.outerConeAngle??Math.PI/4}}function jl(e,t,r){const i=r.get(e.id);if(i)return i;const a=function(e){if(e.matrix)return new n.Matrix4(e.matrix);const t=new n.Matrix4;e.translation&&t.translate(e.translation);e.rotation&&t.multiplyRight((new n.Matrix4).fromQuaternion(e.rotation));e.scale&&t.scale(e.scale);return t}(e),o=t.get(e.id),s=o?new n.Matrix4(jl(o,t,r)).multiplyRight(a):a;return r.set(e.id,s),s}function zl(e){return e.transformAsPoint([0,0,0])}function Gl(e){return e.transformDirection([0,0,-1])}var Hl=class extends H{animation;gltfNodeIdToNodeMap;onVisibilityChange;cameras;lightDefinitions;onLightChange;materials;clip;mixer;action;materialTextureTransformState=new Map;constructor(e){if(super({name:e.animation.name||"unnamed"}),this.animation=e.animation,this.gltfNodeIdToNodeMap=e.gltfNodeIdToNodeMap,this.onVisibilityChange=e.onVisibilityChange,this.cameras=e.cameras||[],this.lightDefinitions=e.lightDefinitions||[],this.onLightChange=e.onLightChange,this.materials=e.materials||[],this.animation.name||="unnamed",this.name=this.animation.name,this.animation.channels.some(e=>"material"===e.type||"textureTransform"===e.type)&&!this.materials.length)throw new Error(`Animation ${this.animation.name} targets materials, but GLTFAnimator was created without a materials array`);this.mixer=e.mixer||new X,this.clip=new J({name:this.name,tracks:this.animation.channels.map(e=>this.createAnimationTrack(e))}),this.action=this.mixer.clipAction(this.clip).play()}applyTime(e){this.action.setTime(e),this.mixer.update(0)}createAnimationTrack(e){const t=function(e){switch(e){case"STEP":case"LINEAR":case"CUBICSPLINE":return e;default:throw new Error(`Unsupported animation interpolation: ${e}`)}}(e.sampler.interpolation);if("node"===e.type)return new $({name:`${e.targetNodeId}.${e.path}`,times:e.sampler.input,values:e.sampler.output,interpolation:t,valueType:"rotation"===e.path?"quaternion":"vector",binding:{id:`node:${e.targetNodeId}:${e.path}`,getValue:()=>this.getNodeAnimationValue(e.targetNodeId,e.path),setValue:t=>this.applyNodeAnimationValue(e.targetNodeId,e.path,t)}});if("camera"===e.type||"light"===e.type)return new $({name:e.pointer,times:e.sampler.input,values:e.sampler.output,interpolation:t,binding:{id:e.pointer,getValue:()=>this.getSceneAnimationValue(e),setValue:t=>this.applySceneAnimationValue(e,t)}});const n=this.materials[e.targetMaterialIndex];if(!n)throw new Error(`Cannot find animation target material ${e.targetMaterialIndex} for ${e.pointer}`);return new $({name:e.pointer,times:e.sampler.input,values:e.sampler.output,interpolation:t,binding:{id:e.pointer,getValue:"material"===e.type?()=>function(e,t){const n=e.shaderInputs.getUniformValues().pbrMaterial?.[t.property];return Array.isArray(n)?void 0===t.component?[...n]:[n[t.component]]:"number"==typeof n?[n]:[]}(n,e):void 0,setValue:t=>{"material"===e.type?function(e,t,n){const r=void 0!==t.component?{[t.property]:Kl(Ql(e,t.property),t.component,n[0])}:{[t.property]:1===n.length?n[0]:n};e.setProps({pbrMaterial:r})}(n,e,t):function(e,t,n,r){const i=hl(t.textureSlot),a=function(e,t,n){const r=e.get(t)||{};let i=r[n.textureSlot];i||(i={offset:[...n.baseTransform.offset],rotation:n.baseTransform.rotation,scale:[...n.baseTransform.scale]},r[n.textureSlot]=i,e.set(t,r));return i}(r,e,t);switch(t.path){case"offset":void 0!==t.component?a.offset[t.component]=n[0]:a.offset=[n[0],n[1]];break;case"rotation":a.rotation=n[0];break;case"scale":void 0!==t.component?a.scale[t.component]=n[0]:a.scale=[n[0],n[1]]}e.setProps({pbrMaterial:{[i.uvTransformUniform]:bl(t.baseTransform,a)}})}(n,e,t,this.materialTextureTransformState)}}})}getNodeAnimationValue(e,t){const n=this.getTargetNode(e);switch(t){case"translation":return Array.from(n.position);case"rotation":return Array.from(n.rotation);case"scale":return Array.from(n.scale);case"weights":return Array.from(n.userData.morphWeights||[]);case"visibility":return[n.display?1:0];default:return[]}}applyNodeAnimationValue(e,t,n){const r=this.getTargetNode(e);switch(t){case"translation":r.setPosition(n).updateMatrix();break;case"rotation":r.setRotation(n).updateMatrix();break;case"scale":r.setScale(n).updateMatrix();break;case"weights":ll(r,n);break;case"visibility":r.setProps({display:0!==n[0]}),this.onVisibilityChange?.();break;default:a.log.warn(`Bad animation path ${t}`)()}}getTargetNode(e){const t=this.gltfNodeIdToNodeMap.get(e);if(!t)throw new Error(`Cannot find animation target node ${e}`);return t}getSceneAnimationValue(e){if("camera"===e.type){const t=this.cameras[e.targetCameraIndex]?.[e.projection]?.[e.property];return"number"==typeof t?[t]:[]}const t=this.lightDefinitions[e.targetLightIndex],n="innerConeAngle"===e.property||"outerConeAngle"===e.property?t?.spot?.[e.property]:t?.[e.property];return Array.isArray(n)?void 0===e.component?[...n]:[n[e.component]]:"number"==typeof n?[n]:[]}applySceneAnimationValue(e,t){if("camera"===e.type){const n=this.cameras[e.targetCameraIndex];return void(n?.[e.projection]&&(n[e.projection][e.property]=t[0]))}const n=this.lightDefinitions[e.targetLightIndex];if(n){if("innerConeAngle"===e.property||"outerConeAngle"===e.property)n.spot||={},n.spot[e.property]=t[0];else if(void 0!==e.component){const r=[...n[e.property]||[1,1,1]];r[e.component]=t[0],n[e.property]=r}else n[e.property]=1===t.length?t[0]:[...t];this.onLightChange?.()}}},ql=class extends q{mixer;activeClip;onUpdate;previousTimeSeconds;constructor(e){const t=new X;super(e.animations.map((n,r)=>{const i=n.name||`Animation-${r}`;return new Hl({gltfNodeIdToNodeMap:e.gltfNodeIdToNodeMap,onVisibilityChange:e.onVisibilityChange,cameras:e.cameras,lightDefinitions:e.lightDefinitions,onLightChange:e.onLightChange,materials:e.materials,mixer:t,animation:{name:i,channels:n.channels}})})),this.mixer=t,this.onUpdate=e.onUpdate,this.activeClip=this.clips[0]?.name,!1===e.autoplay?this.clips.forEach(e=>{e.playing=!1,e.action.stop()}):"first"===e.autoplay&&this.activeClip&&this.selectClip(this.activeClip)}setUpdateHandler(e){return this.onUpdate=e,this}setTime(e){const t=e/1e3,n=void 0===this.previousTimeSeconds?0:t-this.previousTimeSeconds;this.previousTimeSeconds=t;const r=n*this.mixer.timeScale;this.clips.forEach(e=>{if(!e.playing)return void e.action.stop();if(e.action.paused)return;e.action.resume();const n=Math.max(0,t-e.startTime)*e.speed;e.action.setTime(n-r*e.action.timeScale)}),this.mixer.update(n),this.onUpdate?.()}update(e){this.mixer.update(e),this.onUpdate?.()}selectClip(e,t={}){const n=this.clips.find(t=>t.name===e);if(!n)throw new Error(`Unknown animation clip: ${e}`);const r=this.clips.find(e=>e.name===this.activeClip),i=t.crossFadeDuration||0;for(const a of this.clips)a===n||i>0&&a===r||(a.playing=!1,a.action.stop());return n.playing=!0,i>0&&r&&r!==n?(r.playing=!0,r.action.crossFadeTo(n.action,i)):n.action.reset().setEffectiveWeight(1).play(),this.activeClip=e,n}};function Ql(e,t){const n=e.shaderInputs.getUniformValues().pbrMaterial?.[t];return Array.isArray(n)?[...n]:[]}function Kl(e,t,n){const r=[...e];return r[t]=n,r}var Wl=class{bindings;scenes;constructor(e){this.scenes=e.scenes,this.bindings=function(e){const{gltf:t,gltfNodeIndexToNodeMap:n}=e,r=[],i=t.skins||[],a=new Set;for(const o of e.scenes)o.preorderTraversal(e=>{e instanceof Ne&&a.add(e)});for(const[o,s]of t.nodes.entries()){const e=s.skin;if(void 0===e||!s.mesh)continue;const A=$l(t,e),l=i[A],c=n.get(o);if(!l||!c||!a.has(c))continue;const u=l.joints.flatMap(e=>{const t=n.get(e);return t?[t]:[]});if(u.length!==l.joints.length)continue;const f=s.mesh,d=c.userData.gltfMesh,h=d instanceof Ne?d:c.children.find(e=>e instanceof Ne&&e.id===(f.name||f.id));if(!(h instanceof Ne))continue;const p=h.children.flatMap(e=>e instanceof ke?[e]:[]),m=l.inverseBindMatrices?.value;r.push({nodeIndex:o,skinIndex:A,node:c,joints:u,...m instanceof Float32Array?{inverseBindMatrices:m}:{},jointMatrices:new Float32Array(16*u.length),models:p})}return r}(e),this.update()}update(){if(0===this.bindings.length)return;const e=new Map;for(const t of this.scenes)t.preorderTraversal((t,{worldMatrix:r})=>{t instanceof Ne&&e.set(t,new n.Matrix4(r))});for(const t of this.bindings){ie({joints:t.joints,meshNode:t.node,worldMatrices:e,inverseBindMatrices:t.inverseBindMatrices,target:t.jointMatrices});for(const e of t.models)e.model.shaderInputs.setProps({skin:{jointMatrices:t.jointMatrices}})}}getBinding(e){return this.bindings.find(t=>"number"==typeof e?t.nodeIndex===e:t.node===e)}};function $l(e,t){return"number"==typeof t?t:(e.skins||[]).findIndex(n=>{if(n===t||t.id&&n.id===t.id)return!0;if(n.joints.length!==t.joints?.length||!n.joints.every((e,n)=>e===t.joints?.[n]))return!1;if("number"==typeof t.inverseBindMatrices){const r=e.accessors[t.inverseBindMatrices];return!n.inverseBindMatrices||n.inverseBindMatrices===r}return!0})}var Jl={supportLevel:"none",standardStatus:"unknown",comment:"Not currently listed in the luma.gl glTF extension support registry."},Yl={KHR_draco_mesh_compression:{supportLevel:"built-in",standardStatus:"ratified",comment:"Decoded by loaders.gl before luma.gl builds the scenegraph."},EXT_meshopt_compression:{supportLevel:"built-in",standardStatus:"ratified",comment:"EXT meshopt-compressed buffer views are decoded by loaders.gl before rendering."},KHR_meshopt_compression:{supportLevel:"none",standardStatus:"release-candidate",comment:"The installed loaders.gl GLTFLoader supports EXT_meshopt_compression, not the KHR release candidate."},KHR_mesh_quantization:{supportLevel:"built-in",standardStatus:"ratified",comment:"Loader-materialized quantized accessors retain their typed values and normalization."},EXT_mesh_features:{supportLevel:"loader-only",standardStatus:"ratified",comment:"Feature identifiers are decoded by loaders.gl; automatic rendering and picking are application-owned."},EXT_structural_metadata:{supportLevel:"loader-only",standardStatus:"ratified",comment:"Structural metadata is decoded by loaders.gl; automatic rendering and querying are application-owned."},KHR_lights_punctual:{supportLevel:"built-in",standardStatus:"ratified",comment:"Parsed into luma.gl Light objects."},KHR_materials_unlit:{supportLevel:"built-in",standardStatus:"ratified",comment:"Unlit materials bypass the default lighting path."},KHR_materials_emissive_strength:{supportLevel:"built-in",standardStatus:"ratified",comment:"Applied by the stock PBR shader."},KHR_texture_basisu:{supportLevel:"built-in",standardStatus:"ratified",comment:"BasisU / KTX2 textures pass through when the device supports them."},KHR_texture_transform:{supportLevel:"built-in",standardStatus:"ratified",comment:"Per-slot UV transforms and animated pointers are applied at runtime; avoid duplicate legacy loader-side baking."},EXT_texture_webp:{supportLevel:"loader-only",standardStatus:"ratified",comment:"Texture source is resolved during load; final support depends on browser and device decode support."},EXT_texture_avif:{supportLevel:"none",standardStatus:"ratified",comment:"The image loader can decode supported AVIF images, but GLTFLoader does not select EXT_texture_avif sources."},KHR_materials_specular:{supportLevel:"built-in",standardStatus:"ratified",comment:"The stock shader now applies specular factors and textures to the dielectric F0 term."},KHR_materials_ior:{supportLevel:"built-in",standardStatus:"ratified",comment:"The stock shader now drives dielectric reflectance from the glTF IOR value."},KHR_materials_transmission:{supportLevel:"built-in",standardStatus:"ratified",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",standardStatus:"ratified",comment:"Thickness and attenuation now tint transmitted light in the stock shader."},KHR_materials_clearcoat:{supportLevel:"built-in",standardStatus:"ratified",comment:"The stock shader now adds a secondary clearcoat specular lobe."},KHR_materials_sheen:{supportLevel:"built-in",standardStatus:"ratified",comment:"The stock shader now adds a sheen lobe for cloth-like materials."},KHR_materials_iridescence:{supportLevel:"built-in",standardStatus:"ratified",comment:"The stock shader now tints specular response with a view-dependent thin-film iridescence approximation."},KHR_materials_anisotropy:{supportLevel:"built-in",standardStatus:"ratified",comment:"The stock shader now shapes highlights and IBL response with an anisotropy-direction approximation."},KHR_materials_pbrSpecularGlossiness:{supportLevel:"loader-only",standardStatus:"archived",comment:"Extension data can be loaded, but it is not translated into the default metallic-roughness material path."},KHR_materials_variants:{supportLevel:"parsed-and-wired",standardStatus:"ratified",comment:"Primitive material variants can be selected and restored on the generated scenegraph."},EXT_mesh_gpu_instancing:{supportLevel:"built-in",standardStatus:"ratified",comment:"Accessor-backed instance transforms use one instanced draw per source primitive."},KHR_node_visibility:{supportLevel:"parsed-and-wired",standardStatus:"ratified",comment:"Recursive node visibility controls rendered geometry, punctual lights, and animation."},KHR_animation_pointer:{supportLevel:"parsed-and-wired",standardStatus:"ratified",comment:"Node transforms, morph weights and visibility, material factors, texture transforms, camera projections, and punctual lights are wired to runtime updates."},EXT_materials_bump:{supportLevel:"built-in",standardStatus:"draft",comment:"The experimental bump-map draft perturbs the canonical surface normal from a linear height texture."},KHR_materials_diffuse_transmission:{supportLevel:"built-in",standardStatus:"release-candidate",comment:"The Khronos release candidate adds energy-conserving back-lit diffuse transmission and independent color/factor textures."},KHR_materials_dispersion:{supportLevel:"parsed-and-wired",standardStatus:"ratified",comment:"The canonical PBR shader separates red, green, and blue transmission using wavelength-dependent refraction."},KHR_materials_volume_scatter:{supportLevel:"parsed-and-wired",standardStatus:"draft",comment:"The unratified volume-scattering draft is approximated per surface; random-walk and screen-space diffusion are not implemented."},KHR_xmp:{supportLevel:"none",standardStatus:"archived",comment:"Metadata payloads remain in the loaded glTF, but luma.gl does not interpret them."},KHR_xmp_json_ld:{supportLevel:"none",standardStatus:"ratified",comment:"Metadata is preserved in the glTF, but luma.gl does not interpret it."},EXT_lights_image_based:{supportLevel:"none",standardStatus:"multi-vendor",comment:"Use loadPBREnvironment() or custom environment setup instead."},EXT_texture_video:{supportLevel:"none",standardStatus:"multi-vendor",comment:"Video textures are not created automatically by the stock pipeline."},MSFT_lod:{supportLevel:"parsed-and-wired",standardStatus:"vendor",comment:"Node levels are parsed and selected by opt-in animated crowds; material LOD and GPU-driven selection are not implemented."}};function Xl(e,t){const n=Array.from(function(e){const t=e,n=new Set;tc(n,e.extensionsUsed),tc(n,e.extensionsRequired),tc(n,t.extensionsRemoved),tc(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(),r=new Set(e.extensionsRequired||[]),i=n.map(n=>{const i=Yl[n]||Jl,a=function(e,t,n,r){if("KHR_texture_basisu"!==e||!r)return t;const i=function(e){const t=[];for(const n of e.textures||[]){const e=n?.source?.image;if(!e?.compressed)continue;const r=Array.isArray(e.data)?e.data[0]:Array.isArray(e.mipmaps)?e.mipmaps[0]:void 0;t.push(r?.textureFormat??null)}return t}(n).find(e=>null===e||!r.isTextureFormatSupported(e));return void 0===i?t:{supportLevel:"none",comment:null===i?`The ${r.type} device cannot use a BasisU texture whose transcoded GPU format is missing.`:`The ${r.type} device does not support the transcoded BasisU texture format '${i}'.`}}(n,i,e,t);return[n,{extensionName:n,required:r.has(n),supported:(o=a.supportLevel,"built-in"===o||"parsed-and-wired"===o),supportLevel:a.supportLevel,standardStatus:i.standardStatus,comment:a.comment}];var o});return new Map(i)}function Zl(e,t){const n=function(e,t){return Array.from(Xl(e,t).values()).filter(e=>e.required&&!e.supported)}(e,t);if(n.length)throw new Error(`Unsupported required glTF extensions: ${n.map(e=>e.extensionName).join(", ")}`)}function ec(e){return Yl[e]||null}function tc(e,t=[]){for(const n of t)e.add(n)}function nc(e){const t=e.animations||[],n=new Map,r=new Map;return t.flatMap((t,i)=>{const o=t.name||`Animation-${i}`,s=new Map,A=t.channels.flatMap(({sampler:i,target:o})=>{const A=function(e,t){let n;if("weights"===t.path)n=t.node;else{if("pointer"!==t.path)return;{const e=t.extensions?.KHR_animation_pointer?.pointer,r="string"==typeof e?/^\/nodes\/(\d+)\/weights$/.exec(e):null;if(!r)return;n=Number(r[1])}}const r=e.nodes[n??0],i="number"==typeof r?.mesh?e.meshes[r.mesh]:r?.mesh;return r?.weights?.length||i?.weights?.length||i?.primitives?.[0]?.targets?.length||1}(e,o),l=`${i}:${A??0}`;let c=s.get(l);if(!c){const a=t.samplers[i];if(!a)throw new Error(`Cannot find animation sampler ${i}`);const{input:o,interpolation:u="LINEAR",output:f}=a,d=function(e,t){if(t.has(e))return t.get(e);const{value:n,components:r}=lc(e);cc(1===r,"accessorToJsArray1D must have exactly 1 component");const i=Array.from(n);return t.set(e,i),i}(e.accessors[o],n),h=function(e,t){if(t.has(e))return t.get(e);const{value:n,components:r}=lc(e);cc(r>=1,"accessorToJsArray2D must have at least 1 component");const i=[];for(let a=0;a<n.length;a+=r)i.push(Array.from(n.slice(a,a+r)));return t.set(e,i),i}(e.accessors[f],r);c={input:d,interpolation:u,output:void 0!==A?rc(h,d.length,u,A):h},s.set(l,c)}const u=function(e,t,n){if("pointer"===t.path)return function(e,t,n){const r=t.extensions?.KHR_animation_pointer?.pointer;if("string"!=typeof r||!r.startsWith("/"))return a.log.warn("KHR_animation_pointer channel is missing a valid JSON pointer and will be skipped")(),null;const i=function(e){return e.slice(1).split("/").map(e=>e.replace(/~1/g,"/").replace(/~0/g,"~"))}(r);switch(i[0]){case"nodes":return function(e,t,n,r){const i=5===t.length&&"extensions"===t[2]&&"KHR_node_visibility"===t[3]&&"visible"===t[4];if(3!==t.length&&!i)return Ac(r,"node pointers must target transforms, morph weights, or KHR_node_visibility.visible"),null;const o=Number(t[1]),s=e.nodes[o];if(!Number.isInteger(o)||!s)return a.log.warn(`KHR_animation_pointer target ${r} references a missing node and will be skipped`)(),null;if(i&&"STEP"!==n.interpolation)return Ac(r,"boolean visibility animation requires STEP interpolation"),null;const A=i?"visibility":ic(t[2]);if(!A)return Ac(r,`node property "${t[2]}" has no runtime animation mapping`),null;return{type:"node",sampler:n,targetNodeId:s.id,path:A}}(e,i,n,r);case"materials":return function(e,t,n,r){if(t.length<3)return Ac(r,"material pointers must include a material index and target property path"),null;const i=Number(t[1]),o=e.materials[i];if(!Number.isInteger(i)||!o)return a.log.warn(`KHR_animation_pointer target ${r} 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 r=function(e){return ul.find(t=>t.pathSegments.length===e.length&&t.pathSegments.every((t,n)=>e[n]===t))||null}(t.slice(0,n));if(!r)return{reason:oc(t.slice(0,n))};const i=function(e,t){let n=e;for(const r of t)if(n=n?.[r],!n)return null;return n}(e,r.pathSegments);if(!i)return{reason:`texture-transform target "${t.slice(0,n).join("/")}" does not exist on the referenced material`};const a=t[n+2];if("texCoord"===a)return{reason:"animated KHR_texture_transform.texCoord is unsupported because texCoord selection is structural, not a runtime float/vector update"};if("offset"!==a&&"rotation"!==a&&"scale"!==a)return{reason:`KHR_texture_transform property "${a}" is not animatable; supported properties are offset, rotation, and scale`};const o=t[n+3];if(t.length>n+4)return{reason:`KHR_texture_transform.${a} does not support nested property paths`};let s;if(void 0!==o){if(s=Number(o),"rotation"===a)return{reason:"KHR_texture_transform.rotation does not support component indices"};if(!Number.isInteger(s)||s<0||s>1)return{reason:`KHR_texture_transform.${a} component index "${o}" is invalid; only 0 and 1 are supported`}}return{type:"textureTransform",textureSlot:r.slot,path:a,component:s,baseTransform:pl(i)}}(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:ac(t)};case"pbrMetallicRoughness/metallicFactor":return e.pbrMetallicRoughness?{type:"material",property:"metallicRoughnessValues",component:0}:{reason:ac(t)};case"pbrMetallicRoughness/roughnessFactor":return e.pbrMetallicRoughness?{type:"material",property:"metallicRoughnessValues",component:1}:{reason:ac(t)};case"normalTexture/scale":return e.normalTexture?{type:"material",property:"normalScale"}:{reason:ac(t)};case"occlusionTexture/strength":return e.occlusionTexture?{type:"material",property:"occlusionStrength"}:{reason:ac(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:ac(t)};case"extensions/KHR_materials_specular/specularColorFactor":return e.extensions?.KHR_materials_specular?{type:"material",property:"specularColorFactor"}:{reason:ac(t)};case"extensions/KHR_materials_ior/ior":return e.extensions?.KHR_materials_ior?{type:"material",property:"ior"}:{reason:ac(t)};case"extensions/EXT_materials_bump/bumpFactor":return e.extensions?.EXT_materials_bump?{type:"material",property:"bumpFactor"}:{reason:ac(t)};case"extensions/KHR_materials_diffuse_transmission/diffuseTransmissionFactor":return e.extensions?.KHR_materials_diffuse_transmission?{type:"material",property:"diffuseTransmissionFactor"}:{reason:ac(t)};case"extensions/KHR_materials_diffuse_transmission/diffuseTransmissionColorFactor":return e.extensions?.KHR_materials_diffuse_transmission?{type:"material",property:"diffuseTransmissionColorFactor"}:{reason:ac(t)};case"extensions/KHR_materials_volume_scatter/multiscatterColorFactor":case"extensions/KHR_materials_volume_scatter/multiscatterColor":return e.extensions?.KHR_materials_volume_scatter?{type:"material",property:"multiscatterColorFactor"}:{reason:ac(t)};case"extensions/KHR_materials_volume_scatter/scatterAnisotropy":return e.extensions?.KHR_materials_volume_scatter?{type:"material",property:"scatterAnisotropy"}:{reason:ac(t)};case"extensions/KHR_materials_dispersion/dispersion":return e.extensions?.KHR_materials_dispersion?{type:"material",property:"dispersion"}:{reason:ac(t)};case"extensions/KHR_materials_transmission/transmissionFactor":return e.extensions?.KHR_materials_transmission?{type:"material",property:"transmissionFactor"}:{reason:ac(t)};case"extensions/KHR_materials_volume/thicknessFactor":return e.extensions?.KHR_materials_volume?{type:"material",property:"thicknessFactor"}:{reason:ac(t)};case"extensions/KHR_materials_volume/attenuationDistance":return e.extensions?.KHR_materials_volume?{type:"material",property:"attenuationDistance"}:{reason:ac(t)};case"extensions/KHR_materials_volume/attenuationColor":return e.extensions?.KHR_materials_volume?{type:"material",property:"attenuationColor"}:{reason:ac(t)};case"extensions/KHR_materials_clearcoat/clearcoatFactor":return e.extensions?.KHR_materials_clearcoat?{type:"material",property:"clearcoatFactor"}:{reason:ac(t)};case"extensions/KHR_materials_clearcoat/clearcoatRoughnessFactor":return e.extensions?.KHR_materials_clearcoat?{type:"material",property:"clearcoatRoughnessFactor"}:{reason:ac(t)};case"extensions/KHR_materials_sheen/sheenColorFactor":return e.extensions?.KHR_materials_sheen?{type:"material",property:"sheenColorFactor"}:{reason:ac(t)};case"extensions/KHR_materials_sheen/sheenRoughnessFactor":return e.extensions?.KHR_materials_sheen?{type:"material",property:"sheenRoughnessFactor"}:{reason:ac(t)};case"extensions/KHR_materials_iridescence/iridescenceFactor":return e.extensions?.KHR_materials_iridescence?{type:"material",property:"iridescenceFactor"}:{reason:ac(t)};case"extensions/KHR_materials_iridescence/iridescenceIor":return e.extensions?.KHR_materials_iridescence?{type:"material",property:"iridescenceIor"}:{reason:ac(t)};case"extensions/KHR_materials_iridescence/iridescenceThicknessMinimum":return e.extensions?.KHR_materials_iridescence?{type:"material",property:"iridescenceThicknessRange",component:0}:{reason:ac(t)};case"extensions/KHR_materials_iridescence/iridescenceThicknessMaximum":return e.extensions?.KHR_materials_iridescence?{type:"material",property:"iridescenceThicknessRange",component:1}:{reason:ac(t)};case"extensions/KHR_materials_anisotropy/anisotropyStrength":return e.extensions?.KHR_materials_anisotropy?{type:"material",property:"anisotropyStrength"}:{reason:ac(t)};case"extensions/KHR_materials_anisotropy/anisotropyRotation":return e.extensions?.KHR_materials_anisotropy?{type:"material",property:"anisotropyRotation"}:{reason:ac(t)};case"extensions/KHR_materials_emissive_strength/emissiveStrength":return e.extensions?.KHR_materials_emissive_strength?{type:"material",property:"emissiveStrength"}:{reason:ac(t)};default:return{reason:ac(t)}}}(o,t.slice(2));if("reason"in s)return Ac(r,s.reason),null;return{sampler:n,pointer:r,targetMaterialIndex:i,...s}}(e,i,n,r);case"cameras":return function(e,t,n,r){const i=Number(t[1]),a=e.cameras?.[i],o=t[2],s=t[3];if(4!==t.length||!Number.isInteger(i)||!a||"perspective"!==o&&"orthographic"!==o||a.type!==o||!("perspective"===o?["aspectRatio","yfov","znear","zfar"]:["xmag","ymag","znear","zfar"]).includes(s))return Ac(r,"camera pointers must target a supported projection property"),null;return{type:"camera",sampler:n,pointer:r,targetCameraIndex:i,projection:o,property:s}}(e,i,n,r);case"extensions":if("KHR_lights_punctual"===i[1])return function(e,t,n,r){const i=Number(t[3]),a=e.lights||e.extensions?.KHR_lights_punctual?.lights,o="spot"===t[4],s=o?t[5]:t[4],A=o||"color"!==s?void 0:t[5],l=["color","intensity","range","innerConeAngle","outerConeAngle"],c=o||void 0!==A?6:5;if("lights"!==t[2]||t.length!==c||!Number.isInteger(i)||!Array.isArray(a)||!a[i]||!l.includes(s)||o&&"innerConeAngle"!==s&&"outerConeAngle"!==s||void 0!==A&&(!/^[0-2]$/.test(A)||"color"!==s))return Ac(r,"punctual-light pointers must target supported typed light properties"),null;return{type:"light",sampler:n,pointer:r,targetLightIndex:i,property:s,...void 0===A?{}:{component:Number(A)}}}(e,i,n,r)}return Ac(r,`top-level target "${i[0]}" has no runtime animation mapping`),null}(e,t,n);const r=ic(t.path);if(!r)return null;const i=e.nodes[t.node??0];if(!i)throw new Error(`Cannot find animation target ${t.node}`);return{type:"node",sampler:n,targetNodeId:i.id,path:r}}(e,o,c);return u?[u]:[]});return A.length?[{name:o,channels:A}]:[]})}function rc(e,t,n,r){const i="CUBICSPLINE"===n?3:1,a=e.length/(Math.max(t,1)*i),o=r>1?r:Number.isInteger(a)&&a>1?a:r;if(o<=1)return e;const s=e.flat(),A=[];for(let l=0;l<s.length;l+=o)A.push(s.slice(l,l+o));return A}function ic(e){switch(e){case"translation":case"rotation":case"scale":case"weights":return e;default:return null}}function ac(e){const t=sc(e);if(t){const e=ec(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 oc(e){const t=sc(e);if(t){const e=ec(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 sc(e){const t=e.indexOf("extensions"),n=e[t+1];return t>=0&&n?n:null}function Ac(e,t){a.log.warn(`KHR_animation_pointer target ${e} will be skipped because ${t}`)()}function lc(e){if(e.value)return{value:e.value,components:e.components};const t=e.bufferView?.data;cc(void 0!==t),cc(5126===e.componentType);const n="SCALAR"===e.type?1:Number(e.type.slice(3));return{value:new Float32Array(t.buffer,t.byteOffset+(e.byteOffset||0),e.count*n),components:n}}function cc(e,t){if(!e)throw new Error(t)}var uc=class{variants;names;activeVariant=null;modelNodes;constructor(e,t){const n=e.extensions?.KHR_materials_variants?.variants||[];this.variants=n.map((e,t)=>({name:e.name||`Variant-${t}`,index:t})),this.names=this.variants.map(e=>e.name);const r=new Set;for(const i of t)i.preorderTraversal(e=>{e instanceof ke&&e.userData.gltfMaterialVariants&&r.add(e)});this.modelNodes=Array.from(r)}selectVariant(e){const t=this.variants.find(t=>t.name===e);if(!t)throw new Error(`Unknown glTF material variant: ${e}`);for(const n of this.modelNodes){const e=n.userData.gltfMaterialVariants,r=e.mappings.get(t.index);n.model.setMaterial(r?.material||e.defaultMaterial),n.model.setParameters(r?.parameters||e.defaultParameters)}this.activeVariant=e}resetVariant(){for(const e of this.modelNodes){const t=e.userData.gltfMaterialVariants;e.model.setMaterial(t.defaultMaterial),e.model.setParameters(t.defaultParameters)}this.activeVariant=null}};function fc(e,t,n){n?.strictExtensions&&Zl(t,e);const{scenes:r,materials:i,gltfMeshIdToNodeMap:a,gltfNodeIdToNodeMap:o,gltfNodeIndexToNodeMap:s,generatedTextures:A}=Pl(e,t,n),l=nc(t),c=(t.lights||t.extensions?.KHR_lights_punctual?.lights||[]).map(e=>({...e,...Array.isArray(e.color)?{color:[...e.color]}:{},...e.spot?{spot:{...e.spot}}:{}})),u=(t.cameras||[]).map(e=>{const t={...e};return e.perspective&&(t.perspective={...e.perspective}),e.orthographic&&(t.orthographic={...e.orthographic}),t}),f={useByteColors:n?.useByteColors??!0,nodeVisibility:o,lightDefinitions:c},d=Bl(t,f),h=()=>{d.splice(0,d.length,...Bl(t,f))},p=new ql({onVisibilityChange:h,cameras:u,lightDefinitions:c,onLightChange:h,animations:l,gltfNodeIdToNodeMap:o,materials:i}),m=new uc(t,r),g=Xl(t,e),b=r.map(e=>dc(e.getBounds())),v=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 dc(t)}(b),y=new Wl({gltf:t,scenes:r,gltfNodeIndexToNodeMap:s});p.setUpdateHandler(()=>y.update());let x=!1;return{scenes:r,materials:i,variants:m,cameras:u,animator:p,animations:l,lights:d,extensionSupport:g,sceneBounds:b,modelBounds:v,gltfMeshIdToNodeMap:a,gltfNodeIdToNodeMap:o,gltfNodeIndexToNodeMap:s,skins:y,gltf:t,destroy:()=>{if(x)return;x=!0;const e=new Set([...r,...a.values(),...o.values()]),t=new Set,n=new Set(i);for(const r of e)r.preorderTraversal(e=>{e instanceof ke&&(t.add(e),e.model?.material&&n.add(e.model.material))});for(const r of t)r.destroy();for(const r of e)r.destroy();for(const r of n)r.destroy();for(const r of A)r.destroy();A.clear()}}}function dc(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]],r=[t[0][0]+.5*n[0],t[0][1]+.5*n[1],t[0][2]+.5*n[2]],i=.5*Math.max(n[0],n[1],n[2]),a=Math.max(.5*Math.hypot(n[0],n[1],n[2]),.001);return{bounds:t,center:r,size:n,radius:a,recommendedOrbitDistance:Math.max(Math.max(i,.001)/Math.tan(Math.PI/6)*1.15,1.1*a)}}var hc=function(){var e=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]),t=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if("object"!=typeof WebAssembly)return{supported:!1};var n,r=WebAssembly.validate(e)?a("b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuixkbbebeeddddilve9Weeeviebeoweuecj:Gdkr;Neqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949WbwY9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVJ9V29VVbDl79IV9Rbqq:I9Dklbzik94evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaeai86b:q:W:cjbaecitab8Piw83i:q:G:cjbaecefgecjd9hmbkk:SBlEud97dur978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnalTmbcuhoaiRbbgrc;WeGc:Ge9hmbarcsGgwce0mbc9:hoalcufadcd4cbawEgDadfgrcKcaawEgqaraq0Egk6mbaialfgxar9RhodnadTgmmbavaoad;8qbbkaicefhPcj;abad9Uc;WFbGcjdadca0EhsdndndnadTmbaoadfhzcbhHinaeaH9nmdaxaP9RaD6miabaHad2fgOavcjdfasaeaH9RaHasfae6EgAaAcsfgoc9WGgCSEhXaPaDfhQaocl4cifcd4hLavcj;cbfaCcetfhKavcj;cbfaCci2fhYavcj;cbfaCfh8AcbhEaoc;ab6h3incbh5dnawTmbaPaEcd4fRbbh5kcbh8Eavcj;cbfh8Findndndndna5a8Ecet4ciGgoc9:fPdebdkaxaQ9RaC6mwdnaCTmbavcj;cbfa8EaC2faQaC;8qbbkaQaAfhQxdkaCTmeavcj;cbfa8EaC2fcbaC;8kbxekaxaQ9RaL6moaoclVcbawEhraQaLfhocbhidna3mbaxao9Rc;Gb6mbcbhlina8FalfhidndndndndndnaQalco4fRbbgqciGarfPDbedibledibkaipxbbbbbbbbbbbbbbbbpklbxlkaiaopbblaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLgacdp:meaapmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9oghpxiiiiiiiiiiiiiiiip8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbagRb:q:W:cjbggpsaap5e9cjF;8;4;W;G;ab9:9cU1:Ng8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spklbagaoclffa8JRb:q:W:cjbfhoxikaiaopbbwaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLpxssssssssssssssssp9oghpxssssssssssssssssp8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbagRb:q:W:cjbggpsaap5e9cjF;8;4;W;G;ab9:9cU1:Ng8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spklbagaocwffa8JRb:q:W:cjbfhoxdkaiaopbbbpklbaoczfhoxekaiaopbbdaoRbbggcitpbi:q:G:cjbagRb:q:W:cjbggpsaoRbeg8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbagaocdffa8JRb:q:W:cjbfhokdndndndndndnaqcd4ciGarfPDbedibledibkaiczfpxbbbbbbbbbbbbbbbbpklbxlkaiczfaopbblaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLgacdp:meaapmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9oghpxiiiiiiiiiiiiiiiip8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbagRb:q:W:cjbggpsaap5e9cjF;8;4;W;G;ab9:9cU1:Ng8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spklbagaoclffa8JRb:q:W:cjbfhoxikaiczfaopbbwaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLpxssssssssssssssssp9oghpxssssssssssssssssp8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbagRb:q:W:cjbggpsaap5e9cjF;8;4;W;G;ab9:9cU1:Ng8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spklbagaocwffa8JRb:q:W:cjbfhoxdkaiczfaopbbbpklbaoczfhoxekaiczfaopbbdaoRbbggcitpbi:q:G:cjbagRb:q:W:cjbggpsaoRbeg8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbagaocdffa8JRb:q:W:cjbfhokdndndndndndnaqcl4ciGarfPDbedibledibkaicafpxbbbbbbbbbbbbbbbbpklbxlkaicafaopbblaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLgacdp:meaapmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9oghpxiiiiiiiiiiiiiiiip8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbagRb:q:W:cjbggpsaap5e9cjF;8;4;W;G;ab9:9cU1:Ng8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spklbagaoclffa8JRb:q:W:cjbfhoxikaicafaopbbwaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLpxssssssssssssssssp9oghpxssssssssssssssssp8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbagRb:q:W:cjbggpsaap5e9cjF;8;4;W;G;ab9:9cU1:Ng8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spklbagaocwffa8JRb:q:W:cjbfhoxdkaicafaopbbbpklbaoczfhoxekaicafaopbbdaoRbbggcitpbi:q:G:cjbagRb:q:W:cjbggpsaoRbeg8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbagaocdffa8JRb:q:W:cjbfhokdndndndndndnaqco4arfPDbedibledibkaic8Wfpxbbbbbbbbbbbbbbbbpklbxlkaic8Wfaopbblaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLgacdp:meaapmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9oghpxiiiiiiiiiiiiiiiip8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Ngicitpbi:q:G:cjbaiRb:q:W:cjbgipsaap5e9cjF;8;4;W;G;ab9:9cU1:Ngqcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spklbaiaoclffaqRb:q:W:cjbfhoxikaic8Wfaopbbwaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLpxssssssssssssssssp9oghpxssssssssssssssssp8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Ngicitpbi:q:G:cjbaiRb:q:W:cjbgipsaap5e9cjF;8;4;W;G;ab9:9cU1:Ngqcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spklbaiaocwffaqRb:q:W:cjbfhoxdkaic8Wfaopbbbpklbaoczfhoxekaic8WfaopbbdaoRbbgicitpbi:q:G:cjbaiRb:q:W:cjbgipsaoRbegqcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbaiaocdffaqRb:q:W:cjbfhokalc;abfhialcjefaC0meaihlaxao9Rc;Fb0mbkkdnaiaC9pmbaici4hlinaxao9RcK6mwa8FaifhqdndndndndndnaQaico4fRbbalcoG4ciGarfPDbedibledibkaqpxbbbbbbbbbbbbbbbbpkbbxlkaqaopbblaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLgacdp:meaapmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9oghpxiiiiiiiiiiiiiiiip8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbagRb:q:W:cjbggpsaap5e9cjF;8;4;W;G;ab9:9cU1:Ng8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spkbbagaoclffa8JRb:q:W:cjbfhoxikaqaopbbwaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLpxssssssssssssssssp9oghpxssssssssssssssssp8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbagRb:q:W:cjbggpsaap5e9cjF;8;4;W;G;ab9:9cU1:Ng8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spkbbagaocwffa8JRb:q:W:cjbfhoxdkaqaopbbbpkbbaoczfhoxekaqaopbbdaoRbbggcitpbi:q:G:cjbagRb:q:W:cjbggpsaoRbeg8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpkbbagaocdffa8JRb:q:W:cjbfhokalcdfhlaiczfgiaC6mbkkaohQaoTmoka8FaCfh8Fa8Ecefg8Ecl9hmbkdndndndnawTmbazaEcd4fRbbglciGPlbedwbkaCTmdaXaEfhlavaEfpbdbh8Kcbhoinalavcj;cbfaofpblbg8La8Aaofpblbg8MpmbzeHdOiAlCvXoQrLg8NaKaofpblbgyaYaofpblbg8PpmbzeHdOiAlCvXoQrLgIpmbezHdiOAlvCXorQLgacep9Taapxeeeeeeeeeeeeeeeeghp9op9Hp9rgaa8Kp9Ug8Kp9Abbbaladfgla8Kaaaapmlvorlvorlvorlvorp9Ug8Kp9Abbbaladfgla8KaaaapmwDqkwDqkwDqkwDqkp9Ug8Kp9Abbbaladfgla8KaaaapmxmPsxmPsxmPsxmPsp9Ug8Kp9Abbbaladfgla8Ka8NaIpmwDKYqk8AExm35Ps8E8Fgacep9Taaahp9op9Hp9rgap9Ug8Kp9Abbbaladfgla8Kaaaapmlvorlvorlvorlvorp9Ug8Kp9Abbbaladfgla8KaaaapmwDqkwDqkwDqkwDqkp9Ug8Kp9Abbbaladfgla8KaaaapmxmPsxmPsxmPsxmPsp9Ug8Kp9Abbbaladfgla8Ka8La8MpmwKDYq8AkEx3m5P8Es8Fg8Laya8PpmwKDYq8AkEx3m5P8Es8Fg8MpmbezHdiOAlvCXorQLgacep9Taaahp9op9Hp9rgap9Ug8Kp9Abbbaladfgla8Kaaaapmlvorlvorlvorlvorp9Ug8Kp9Abbbaladfgla8KaaaapmwDqkwDqkwDqkwDqkp9Ug8Kp9Abbbaladfgla8KaaaapmxmPsxmPsxmPsxmPsp9Ug8Kp9Abbbaladfgla8Ka8La8MpmwDKYqk8AExm35Ps8E8Fgacep9Taaahp9op9Hp9rgap9Ughp9Abbbaladfglahaaaapmlvorlvorlvorlvorp9Ughp9AbbbaladfglahaaaapmwDqkwDqkwDqkwDqkp9Ughp9AbbbaladfglahaaaapmxmPsxmPsxmPsxmPsp9Ug8Kp9AbbbaladfhlaoczfgoaC6mbxikkaCTmeaXaEfhlavaEfpbdbh8Kcbhoinalavcj;cbfaofpblbg8La8Aaofpblbg8MpmbzeHdOiAlCvXoQrLg8NaKaofpblbgyaYaofpblbg8PpmbzeHdOiAlCvXoQrLgIpmbezHdiOAlvCXorQLgacep:neaapxebebebebebebebebghp9op:bep9rgaa8Kp:oeg8Kp9Abbbaladfgla8Kaaaapmlvorlvorlvorlvorp:oeg8Kp9Abbbaladfgla8KaaaapmwDqkwDqkwDqkwDqkp:oeg8Kp9Abbbaladfgla8KaaaapmxmPsxmPsxmPsxmPsp:oeg8Kp9Abbbaladfgla8Ka8NaIpmwDKYqk8AExm35Ps8E8Fgacep:neaaahp9op:bep9rgap:oeg8Kp9Abbbaladfgla8Kaaaapmlvorlvorlvorlvorp:oeg8Kp9Abbbaladfgla8KaaaapmwDqkwDqkwDqkwDqkp:oeg8Kp9Abbbaladfgla8KaaaapmxmPsxmPsxmPsxmPsp:oeg8Kp9Abbbaladfgla8Ka8La8MpmwKDYq8AkEx3m5P8Es8Fg8Laya8PpmwKDYq8AkEx3m5P8Es8Fg8MpmbezHdiOAlvCXorQLgacep:neaaahp9op:bep9rgap:oeg8Kp9Abbbaladfgla8Kaaaapmlvorlvorlvorlvorp:oeg8Kp9Abbbaladfgla8KaaaapmwDqkwDqkwDqkwDqkp:oeg8Kp9Abbbaladfgla8KaaaapmxmPsxmPsxmPsxmPsp:oeg8Kp9Abbbaladfgla8Ka8La8MpmwDKYqk8AExm35Ps8E8Fgacep:neaaahp9op:bep9rgap:oeghp9Abbbaladfglahaaaapmlvorlvorlvorlvorp:oeghp9AbbbaladfglahaaaapmwDqkwDqkwDqkwDqkp:oeghp9AbbbaladfglahaaaapmxmPsxmPsxmPsxmPsp:oeg8Kp9AbbbaladfhlaoczfgoaC6mbxdkkaCTmbaXaEfhrcbhocbalcl4gl9Rc8FGhiavaEfpbdbhhinaravcj;cbfaofpblbg8Ka8Aaofpblbg8LpmbzeHdOiAlCvXoQrLg8MaKaofpblbg8NaYaofpblbgypmbzeHdOiAlCvXoQrLg8PpmbezHdiOAlvCXorQLgaaip:Reaaalp:Tep9qgaahp9rghp9Abbbaradfgrahaaaapmlvorlvorlvorlvorp9rghp9AbbbaradfgrahaaaapmwDqkwDqkwDqkwDqkp9rghp9AbbbaradfgrahaaaapmxmPsxmPsxmPsxmPsp9rghp9Abbbaradfgraha8Ma8PpmwDKYqk8AExm35Ps8E8Fgaaip:Reaaalp:Tep9qgap9rghp9Abbbaradfgrahaaaapmlvorlvorlvorlvorp9rghp9AbbbaradfgrahaaaapmwDqkwDqkwDqkwDqkp9rghp9AbbbaradfgrahaaaapmxmPsxmPsxmPsxmPsp9rghp9Abbbaradfgraha8Ka8LpmwKDYq8AkEx3m5P8Es8Fg8Ka8NaypmwKDYq8AkEx3m5P8Es8Fg8LpmbezHdiOAlvCXorQLgaaip:Reaaalp:Tep9qgap9rghp9Abbbaradfgrahaaaapmlvorlvorlvorlvorp9rghp9AbbbaradfgrahaaaapmwDqkwDqkwDqkwDqkp9rghp9AbbbaradfgrahaaaapmxmPsxmPsxmPsxmPsp9rghp9Abbbaradfgraha8Ka8LpmwDKYqk8AExm35Ps8E8Fgaaip:Reaaalp:Tep9qgap9rghp9Abbbaradfgrahaaaapmlvorlvorlvorlvorp9rghp9AbbbaradfgrahaaaapmwDqkwDqkwDqkwDqkp9rghp9AbbbaradfgrahaaaapmxmPsxmPsxmPsxmPsp9rghp9AbbbaradfhraoczfgoaC6mbkkaEclfgEad6mbkdnaXavcjdf9hmbaAad2goTmbaOavcjdfao;8qbbkdnammbavaXaAcufad2fad;8qbbkaAaHfhHc9:hoaQhPaQmbxlkkaeTmbaDalfhrcbhocuhlinaralaD9RglfaD6mdasaeao9Raoasfae6Eaofgoae6mbkaial9RhPkcbc99axaP9RakSEhoxekc9:hokavcj;kbf8Kjjjjbaokwbz:bjjjbkpPesu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnalaeci9UgrcHf6mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgwce0mbavc;abfcFecje;8kbav9cu83iUav9cu83i8Wav9cu83iyav9cu83iaav9cu83iKav9cu83izav9cu83iwav9cu83ibaialfc9WfhDaicefgiarfhqdndnaeci9pmbaqhexekcmcsawceSEhkcbhxcbhmaqhecbhlcbhoindndnaiRbbgrc;Ve0mbavc;abfaoarcu7gPcl4fcsGcitfgwydlhsawydbhzdndnarcsGgwak9pmbavalaPfcsGcdtfydbaxawEhraxawTgHfhxxekdnaeaD9nmbc9:hoxokdndnawcsSmbcehHamawcetfcWfhrxekaecefhrae8SbbgwcFeGhPdndnawcu9mmbarhexekaecvfheaPcFbGhPcrhwdninar8SbbgHcFbGawtaPVhPaHcu9kmearcefhrawcrfgwc8J9hmbxdkkarcefhekcehHaPce4cbaPceG9R7amfhrkarhmkavc;abfaocitfgwarBdbawasBdlavalcdtfarBdbavc;abfaocefcsGcitfgwazBdbawarBdlaocdfhoaHalfhldnadcd9hmbabar87elabas87edabaz87ebabcofhbxdkabarBdwabasBdlabazBdbabcxfhbxekdnarcpe0mbavalaDarcsGfRbbgwcl4gP9RcsGcdtfydbaxcefgsaPEhravalaw9RcsGcdtfydbasaPTgzfgsawcsGgPEhwaPThPdndnadcd9hmbabaw87elabar87edabax87ebcohHxekabawBdwabarBdlabaxBdbcxhHkavalcdtfaxBdbavc;abfaocitfgOarBdbaOaxBdlavalcefglcsGcdtfarBdbavc;abfaocefcsGcitfgOawBdbaOarBdlavalazfglcsGcdtfawBdbavc;abfaocdfcsGcitfgraxBdbarawBdlaocifhoabaHfhbalaPfhlasaPfhxxekdnaeaD9nmbc9:hoxlkaxcbaeRbbgwEgHarc;:eSgrfhsawcsGhOdndnawcl4gAmbascefhzxekashzavalaA9RcsGcdtfydbhskdndnaOmbazcefhxxekazhxavalaw9RcsGcdtfydbhzkdndnarTmbaecefhrxekaecdfhrae8SbegPcFeGhwdnaPcu9kmbaecofhHawcFbGhwcrhedninar8SbbgPcFbGaetawVhwaPcu9kmearcefhraecrfgec8J9hmbkaHhrxekarcefhrkawce4cbawceG9R7amfgmhHkdndnaAcsSmbarhwxekarcefhwar8SbbgecFeGhPdnaecu9kmbarcvfhsaPcFbGhPcrhedninaw8SbbgrcFbGaetaPVhParcu9kmeawcefhwaecrfgec8J9hmbkashwxekawcefhwkaPce4cbaPceG9R7amfgmhskdndnaOcsSmbawhexekawcefheaw8SbbgrcFeGhPdnarcu9kmbawcvfhzaPcFbGhPcrhrdninae8SbbgwcFbGartaPVhPawcu9kmeaecefhearcrfgrc8J9hmbkazhexekaecefhekaPce4cbaPceG9R7amfgmhzkdndnadcd9hmbabaz87elabas87edabaH87ebcohrxekabazBdwabasBdlabaHBdbcxhrkavc;abfaocitfgwasBdbawaHBdlavalcdtfaHBdbavc;abfaocefcsGcitfgwazBdbawasBdlavalcefglcsGcdtfasBdbavc;abfaocdfcsGcitfgwaHBdbawazBdlavalaATaAcsSVfglcsGcdtfazBdbalaOTaOcsSVfhlaocifhoabarfhbkaocsGhoalcsGhlaicefgiaq6mbkkcbc99aeaDSEhokavc;aef8Kjjjjbaok:clevu8Jjjjjbcz9Rhvdnalaecvf9pmbc9:skdnaiRbbc;:eGc;qeSmbcuskav9cb83iwaicefhoaialfc98fhrdnaeTmbdnadcdSmbcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcdtfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgiBdbalaiBdbawcefgwae9hmbxdkkcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcetfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgi87ebalaiBdbawcefgwae9hmbkkcbc99aoarSEk;Toio97eue97aec98Ghedndnadcl9hmbaeTmecbhdinababpbbbgicKp:RecKp:Sep;6eglaicwp:RecKp:Sep;6ealp;Geaiczp:RecKp:Sep;6egvp;Gep;Kep;Legopxbbbbbbbbbbbbbbbbp:2egralpxbbbjbbbjbbbjbbbjgwp9op9rp;Keglpxbb;:9cbb;:9cbb;:9cbb;:9calalp;Meaoaop;Meavaravawp9op9rp;Keglalp;Mep;Kep;Kep;Jep;Negvp;Mepxbbn0bbn0bbn0bbn0grp;KepxFbbbFbbbFbbbFbbbp9oaipxbbbFbbbFbbbFbbbFp9op9qalavp;Mearp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaoavp;Mearp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbabczfhbadclfgdae6mbxdkkaeTmbcbhdinabczfgDaDpbbbgipxbbbbbbFFbbbbbbFFgwp9oabpbbbgoaipmbediwDqkzHOAKY8AEgvczp:Reczp:Sep;6eglaoaipmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eavczp:Sep;6egvp;Gealp;Gep;Kep;Legipxbbbbbbbbbbbbbbbbp:2egralpxbbbjbbbjbbbjbbbjgqp9op9rp;Keglpxb;:FSb;:FSb;:FSb;:FSalalp;Meaiaip;Meavaravaqp9op9rp;Keglalp;Mep;Kep;Kep;Jep;Negvp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbp9oaiavp;Mearp;Keczp:Rep9qgialavp;Mearp;KepxFFbbFFbbFFbbFFbbp9oglpmwDKYqk8AExm35Ps8E8Fp9qpkbbabaoawp9oaialpmbezHdiOAlvCXorQLp9qpkbbabcafhbadclfgdae6mbkkk;2ileue97euo97dnaec98GgiTmbcbheinabcKfpx:ji:1S:ji:1S:ji:1S:ji:1SabpbbbglabczfgvpbbbgopmlvorxmPsCXQL358E8Fgrczp:Segwpxibbbibbbibbbibbbp9qp;6egDp;NegqaDaDp;MegDaDp;KealaopmbediwDqkzHOAKY8AEgDczp:Reczp:Sep;6eglalp;MeaDczp:Sep;6egoaop;Mearczp:Reczp:Sep;6egrarp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jep;Mepxbbn0bbn0bbn0bbn0gDp;KepxFFbbFFbbFFbbFFbbgkp9oaqaop;MeaDp;Keczp:Rep9qgoaqalp;MeaDp;Keakp9oaqarp;MeaDp;Keczp:Rep9qgDpmwDKYqk8AExm35Ps8E8Fglp5eawclp:RegqpEi:T:j83ibavalp5baqpEd:T:j83ibabcwfaoaDpmbezHdiOAlvCXorQLgDp5eaqpEe:T:j83ibabaDp5baqpEb:T:j83ibabcafhbaeclfgeai6mbkkkuee97dnadcd4ae2c98GgeTmbcbhdinababpbbbgicwp:Recwp:Sep;6eaicep:SepxbbjFbbjFbbjFbbjFp9opxbbjZbbjZbbjZbbjZp:Uep;Mepkbbabczfhbadclfgdae6mbkkk:Sodw97euaec98Ghedndnadcl9hmbaeTmecbhdinabpxbbuJbbuJbbuJbbuJabpbbbgicKp:TeglaicYp:Tep9qgvcdp:Teavp9qgvclp:Teavp9qgop;6ep;Negvaicwp:RecKp:SegraipxFbbbFbbbFbbbFbbbgwp9ogDp:Uep;6ep;Mepxbbn0bbn0bbn0bbn0gqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9oavaDarp:Xeaiczp:RecKp:Segip:Uep;6ep;Meaqp;Keawp9op9qavaDaraip:Uep:Xep;6ep;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qavaoalcep:Rep9oalpxebbbebbbebbbebbbp9op9qp;6ep;Meaqp;KecKp:Rep9qpkbbabczfhbadclfgdae6mbxdkkaeTmbcbhdinabczfgkpxbFu9hbFu9hbFu9hbFu9habpbbbglakpbbbgrpmlvorxmPsCXQL358E8Fgvczp:TegqavcHp:Tep9qgicdp:Teaip9qgiclp:Teaip9qgicwp:Teaip9qgop;6ep;NegialarpmbediwDqkzHOAKY8AEgDpxFFbbFFbbFFbbFFbbglp9ograDczp:Segwp:Ueavczp:Reczp:SegDp:Xep;6ep;Mepxbbn0bbn0bbn0bbn0gvp;Kealp9oaiarawaDp:Uep:Xep;6ep;Meavp;Keczp:Rep9qgwaiaoaqcep:Rep9oaqpxebbbebbbebbbebbbp9op9qp;6ep;Meavp;Keczp:ReaiaDarp:Uep;6ep;Meavp;Kealp9op9qgipmwDKYqk8AExm35Ps8E8FpkbbabawaipmbezHdiOAlvCXorQLpkbbabcafhbadclfgdae6mbkkk9teiucbcbydj:G:cjbgeabcifc98GfgbBdj:G:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkxebcj:Gdklz:zbb"):a("b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuixkbeeeddddillviebeoweuecj:Gdkr;Neqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949WboY9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVJ9V29VVbrl79IV9Rbwq;X8:kdbk:kYi5ud9:du8Jjjjjbcjq9Rgv8Kjjjjbc9:hodnalTmbcuhoaiRbbgrc;WeGc:Ge9hmbarcsGgwce0mbc9:hoalcufadcd4cbawEgDadfgrcKcaawEgqaraq0Egk6mbaicefhxcj;abad9Uc;WFbGcjdadca0EhmaialfgPar9Rgoadfhsavaoadz:jjjjbgzceVhHcbhOdndninaeaO9nmeaPax9RaD6mdamaeaO9RaOamfgoae6EgAcsfglc9WGhCaAcethXaxaDfhiaOaeaoaeao6E9RhQalcl4cifcd4hLazcjdfaAfhKcbhYabaOad2fg8AhEaHh3incbh5dnawTmbaxaYcd4fRbbh5kcbh8Eazcjdfhqinaih8Fdndndndna5a8Ecet4ciGgoc9:fPdebdkaPa8F9RaA6mrazcjdfa8EaA2fa8FaAz:jjjjb8Aa8FaAfhixdkazcjdfa8EaA2fcbaAz:kjjjb8Aa8FhixekaPa8F9RaL6mva8FaLfhidnaCTmbaPai9RcK6mbaocdtc:q:G:cjbfcj:G:cjbawEhaczhrcbhlinargoc9Wfghaqfhrdndndndndndnaaa8Fahco4fRbbalcoG4ciGcdtfydbPDbedvivvvlvkar9cb83bwar9cb83bbxlkarcbaiRbdai8Xbb9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:gg9cjjjjjz:dg8J9qE86bbaqaofgrcGfcbaicdfa8J9c8N1:NfghRbbag9cjjjjjw:dg8J9qE86bbarcVfcbaha8J9c8M1:NfghRbbag9cjjjjjl:dg8J9qE86bbarc7fcbaha8J9c8L1:NfghRbbag9cjjjjjd:dg8J9qE86bbarctfcbaha8J9c8K1:NfghRbbag9cjjjjje:dg8J9qE86bbarc91fcbaha8J9c8J1:NfghRbbag9cjjjj;ab:dg8J9qE86bbarc4fcbaha8J9cg1:NfghRbbag9cjjjja:dg8J9qE86bbarc93fcbaha8J9ch1:NfghRbbag9cjjjjz:dgg9qE86bbarc94fcbahag9ca1:NfghRbbai8Xbe9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:gg9cjjjjjz:dg8J9qE86bbarc95fcbaha8J9c8N1:NfgiRbbag9cjjjjjw:dg8J9qE86bbarc96fcbaia8J9c8M1:NfgiRbbag9cjjjjjl:dg8J9qE86bbarc97fcbaia8J9c8L1:NfgiRbbag9cjjjjjd:dg8J9qE86bbarc98fcbaia8J9c8K1:NfgiRbbag9cjjjjje:dg8J9qE86bbarc99fcbaia8J9c8J1:NfgiRbbag9cjjjj;ab:dg8J9qE86bbarc9:fcbaia8J9cg1:NfgiRbbag9cjjjja:dg8J9qE86bbarcufcbaia8J9ch1:NfgiRbbag9cjjjjz:dgg9qE86bbaiag9ca1:NfhixikaraiRblaiRbbghco4g8Ka8KciSg8KE86bbaqaofgrcGfaiclfa8Kfg8KRbbahcl4ciGg8La8LciSg8LE86bbarcVfa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc7fa8Ka8Lfg8KRbbahciGghahciSghE86bbarctfa8Kahfg8KRbbaiRbeghco4g8La8LciSg8LE86bbarc91fa8Ka8Lfg8KRbbahcl4ciGg8La8LciSg8LE86bbarc4fa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc93fa8Ka8Lfg8KRbbahciGghahciSghE86bbarc94fa8Kahfg8KRbbaiRbdghco4g8La8LciSg8LE86bbarc95fa8Ka8Lfg8KRbbahcl4ciGg8La8LciSg8LE86bbarc96fa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc97fa8Ka8Lfg8KRbbahciGghahciSghE86bbarc98fa8KahfghRbbaiRbigico4g8Ka8KciSg8KE86bbarc99faha8KfghRbbaicl4ciGg8Ka8KciSg8KE86bbarc9:faha8KfghRbbaicd4ciGg8Ka8KciSg8KE86bbarcufaha8KfgrRbbaiciGgiaiciSgiE86bbaraifhixdkaraiRbwaiRbbghcl4g8Ka8KcsSg8KE86bbaqaofgrcGfaicwfa8Kfg8KRbbahcsGghahcsSghE86bbarcVfa8KahfghRbbaiRbeg8Kcl4g8La8LcsSg8LE86bbarc7faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarctfaha8KfghRbbaiRbdg8Kcl4g8La8LcsSg8LE86bbarc91faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc4faha8KfghRbbaiRbig8Kcl4g8La8LcsSg8LE86bbarc93faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc94faha8KfghRbbaiRblg8Kcl4g8La8LcsSg8LE86bbarc95faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc96faha8KfghRbbaiRbvg8Kcl4g8La8LcsSg8LE86bbarc97faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc98faha8KfghRbbaiRbog8Kcl4g8La8LcsSg8LE86bbarc99faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc9:faha8KfghRbbaiRbrgicl4g8Ka8KcsSg8KE86bbarcufaha8KfgrRbbaicsGgiaicsSgiE86bbaraifhixekarai8Pbw83bwarai8Pbb83bbaiczfhikdnaoaC9pmbalcdfhlaoczfhraPai9RcL0mekkaoaC6moaimexokaCmva8FTmvkaqaAfhqa8Ecefg8Ecl9hmbkdndndndnawTmbasaYcd4fRbbgociGPlbedrbkaATmdazaYfh8Fazcjdfhhcbh8EaEhaina8FRbbhraahocbhlinaoahalfRbbgqce4cbaqceG9R7arfgr86bbaoadfhoaAalcefgl9hmbkaacefhaa8Fcefh8FahaAfhha8Ecefg8Ecl9hmbxikkaATmeazaYfhaazcjdfhhcbhoceh8EaKh8FinaEaofhlaa8Vbbhrcbhoinala8FaofRbbcwtahaofRbbgqVc;:FiGce4cbaqceG9R7arfgr87bbaladfhlaQaocefgofmbka8FaXfh8FcdhoaacdfhaahaXfhha8EceGhlcbh8EalmbxdkkaATmbaocl4h8EazaYfRbbhqcwhoa3hlinalRbbaotaqVhqalcefhlaocwfgoca9hmbkcbhhaEh8FaKhainazcjdfahfRbbhrcwhoaahlinalRbbaotarVhralaAfhlaocwfgoca9hmbkara8E94aq7hqcbhoa8Fhlinalaqao486bbalcefhlaocwfgoca9hmbka8Fadfh8FaacefhaahcefghaA9hmbkkaEclfhEa3clfh3aYclfgYad6mbkaza8AaAcufad2fadz:jjjjb8AaAaOfhOaihxaimbkc9:hoxdkcbc99aPax9RakSEhoxekc9:hokavcjqf8Kjjjjbaok:bsesu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnalaeci9UgrcHf6mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgwce0mbavc;abfcFecjez:kjjjb8Aav9cu83iUav9cu83i8Wav9cu83iyav9cu83iaav9cu83iKav9cu83izav9cu83iwav9cu83ibaialfc9WfhDaicefgiarfhqdndnaeci9pmbaqhexekcmcsawceSEhkcbhxcbhmaqhecbhlcbhoindndnaiRbbgrc;Ve0mbavc;abfaoarcu7gPcl4fcsGcitfgwydlhsawydbhzdndnarcsGgwak9pmbavalaPfcsGcdtfydbaxawEhraxawTgHfhxxekdnaeaD9nmbc9:hoxokdndnawcsSmbcehHamawcetfcWfhrxekaecefhrae8SbbgwcFeGhPdndnawcu9mmbarhexekaecvfheaPcFbGhPcrhwdninar8SbbgHcFbGawtaPVhPaHcu9kmearcefhrawcrfgwc8J9hmbxdkkarcefhekcehHaPce4cbaPceG9R7amfhrkarhmkavc;abfaocitfgwarBdbawasBdlavalcdtfarBdbavc;abfaocefcsGcitfgwazBdbawarBdlaocdfhoaHalfhldnadcd9hmbabar87elabas87edabaz87ebabcofhbxdkabarBdwabasBdlabazBdbabcxfhbxekdnarcpe0mbavalaDarcsGfRbbgwcl4gP9RcsGcdtfydbaxcefgsaPEhravalaw9RcsGcdtfydbasaPTgzfgsawcsGgPEhwaPThPdndnadcd9hmbabaw87elabar87edabax87ebcohHxekabawBdwabarBdlabaxBdbcxhHkavalcdtfaxBdbavc;abfaocitfgOarBdbaOaxBdlavalcefglcsGcdtfarBdbavc;abfaocefcsGcitfgOawBdbaOarBdlavalazfglcsGcdtfawBdbavc;abfaocdfcsGcitfgraxBdbarawBdlaocifhoabaHfhbalaPfhlasaPfhxxekdnaeaD9nmbc9:hoxlkaxcbaeRbbgwEgHarc;:eSgrfhsawcsGhOdndnawcl4gAmbascefhzxekashzavalaA9RcsGcdtfydbhskdndnaOmbazcefhxxekazhxavalaw9RcsGcdtfydbhzkdndnarTmbaecefhrxekaecdfhrae8SbegPcFeGhwdnaPcu9kmbaecofhHawcFbGhwcrhedninar8SbbgPcFbGaetawVhwaPcu9kmearcefhraecrfgec8J9hmbkaHhrxekarcefhrkawce4cbawceG9R7amfgmhHkdndnaAcsSmbarhwxekarcefhwar8SbbgecFeGhPdnaecu9kmbarcvfhsaPcFbGhPcrhedninaw8SbbgrcFbGaetaPVhParcu9kmeawcefhwaecrfgec8J9hmbkashwxekawcefhwkaPce4cbaPceG9R7amfgmhskdndnaOcsSmbawhexekawcefheaw8SbbgrcFeGhPdnarcu9kmbawcvfhzaPcFbGhPcrhrdninae8SbbgwcFbGartaPVhPawcu9kmeaecefhearcrfgrc8J9hmbkazhexekaecefhekaPce4cbaPceG9R7amfgmhzkdndnadcd9hmbabaz87elabas87edabaH87ebcohrxekabazBdwabasBdlabaHBdbcxhrkavc;abfaocitfgwasBdbawaHBdlavalcdtfaHBdbavc;abfaocefcsGcitfgwazBdbawasBdlavalcefglcsGcdtfasBdbavc;abfaocdfcsGcitfgwaHBdbawazBdlavalaATaAcsSVfglcsGcdtfazBdbalaOTaOcsSVfhlaocifhoabarfhbkaocsGhoalcsGhlaicefgiaq6mbkkcbc99aeaDSEhokavc;aef8Kjjjjbaok:clevu8Jjjjjbcz9Rhvdnalaecvf9pmbc9:skdnaiRbbc;:eGc;qeSmbcuskav9cb83iwaicefhoaialfc98fhrdnaeTmbdnadcdSmbcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcdtfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgiBdbalaiBdbawcefgwae9hmbxdkkcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcetfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgi87ebalaiBdbawcefgwae9hmbkkcbc99aoarSEk:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk:4ioiue99dud99dud99dnaeTmbcbhiabhlindndnal8Uebgv:YgoJ:ji:1Salcof8UebgrciVgw:Y:vgDNJbbbZJbbb:;avcu9kEMgq:lJbbb9p9DTmbaq:Ohkxekcjjjj94hkkalclf8Uebhvalcdf8UebhxalarcefciGcetfak87ebdndnax:YgqaDNJbbbZJbbb:;axcu9kEMgm:lJbbb9p9DTmbam:Ohxxekcjjjj94hxkabaiarciGgkfcd7cetfax87ebdndnav:YgmaDNJbbbZJbbb:;avcu9kEMgP:lJbbb9p9DTmbaP:Ohvxekcjjjj94hvkalarcufciGcetfav87ebdndnawaw2:ZgPaPMaoaoN:taqaqN:tamamN:tgoJbbbbaoJbbbb9GE:raDNJbbbZMgD:lJbbb9p9DTmbaD:Ohrxekcjjjj94hrkalakcetfar87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2gdTmbinababydbgecwtcw91:Yaece91cjjj98Gcjjj;8if::NUdbabclfhbadcufgdmbkkk:Tvirud99eudndnadcl9hmbaeTmeindndnabRbbgiabcefgl8Sbbgvabcdfgo8Sbbgrf9R:YJbbuJabcifgwRbbgdce4adVgDcd4aDVgDcl4aDVgD:Z:vgqNJbbbZMgk:lJbbb9p9DTmbak:Ohxxekcjjjj94hxkaoax86bbdndnaraif:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohoxekcjjjj94hokalao86bbdndnavaifar9R:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabai86bbdndnaDadcetGadceGV:ZaqNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkawad86bbabclfhbaecufgembxdkkaeTmbindndnab8Vebgiabcdfgl8Uebgvabclfgo8Uebgrf9R:YJbFu9habcofgw8Vebgdce4adVgDcd4aDVgDcl4aDVgDcw4aDVgD:Z:vgqNJbbbZMgk:lJbbb9p9DTmbak:Ohxxekcjjjj94hxkaoax87ebdndnaraif:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohoxekcjjjj94hokalao87ebdndnavaifar9R:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabai87ebdndnaDadcetGadceGV:ZaqNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkawad87ebabcwfhbaecufgembkkk9teiucbcbyd:K:G:cjbgeabcifc98GfgbBd:K:G:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaeczfheaiczfhiadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkk83dbcj:Gdk8Kbbbbdbbblbbbwbbbbbbbebbbdbbblbbbwbbbbc:K:Gdkl8W:qbb"),i=WebAssembly.instantiate(r,{}).then(function(e){(n=e.instance).exports.__wasm_call_ctors()});function a(e){for(var n=new Uint8Array(e.length),r=0;r<e.length;++r){var i=e.charCodeAt(r);n[r]=i>96?i-97:i>64?i-39:i+4}var a=0;for(r=0;r<e.length;++r)n[a++]=n[r]<60?t[n[r]]:64*(n[r]-60)+n[++r];return n.buffer.slice(0,a)}function o(e,t,n,r,i,a,o){var s=e.exports.sbrk,A=r+3&-4,l=s(A*i),c=s(a.length),u=new Uint8Array(e.exports.memory.buffer);u.set(a,c);var f=t(l,r,i,c,a.length);if(0==f&&o&&o(l,A,i),n.set(u.subarray(l,l+r*i)),s(l-s(0)),0!=f)throw new Error("Malformed buffer data: "+f)}var s={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp",COLOR:"meshopt_decodeFilterColor"},A={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"},l=[],c=0;function u(e){var t={object:new Worker(e),pending:0,requests:{}};return t.object.onmessage=function(e){var n=e.data;t.pending-=n.count,t.requests[n.id][n.action](n.value),delete t.requests[n.id]},t}function f(e){var t=e.data;self.ready.then(function(e){if(!t.id)return self.close();try{var n=new Uint8Array(t.count*t.size);o(e,e.exports[t.mode],n,t.count,t.size,t.source,e.exports[t.filter]),self.postMessage({id:t.id,count:t.count,action:"resolve",value:n},[n.buffer])}catch(r){self.postMessage({id:t.id,count:t.count,action:"reject",value:r})}})}return{ready:i,supported:!0,useWorkers:function(e){!function(e){for(var t="self.ready = WebAssembly.instantiate(new Uint8Array(["+new Uint8Array(r)+"]), {}).then(function(result) { result.instance.exports.__wasm_call_ctors(); return result.instance; });self.onmessage = "+f.name+";"+o.toString()+f.toString(),n=new Blob([t],{type:"text/javascript"}),i=URL.createObjectURL(n),a=l.length;a<e;++a)l[a]=u(i);for(a=e;a<l.length;++a)l[a].object.postMessage({});l.length=e,URL.revokeObjectURL(i)}(e)},decodeVertexBuffer:function(e,t,r,i,a){o(n,n.exports.meshopt_decodeVertexBuffer,e,t,r,i,n.exports[s[a]])},decodeIndexBuffer:function(e,t,r,i){o(n,n.exports.meshopt_decodeIndexBuffer,e,t,r,i)},decodeIndexSequence:function(e,t,r,i){o(n,n.exports.meshopt_decodeIndexSequence,e,t,r,i)},decodeGltfBuffer:function(e,t,r,i,a,l){o(n,n.exports[A[a]],e,t,r,i,n.exports[s[l]])},decodeGltfBufferAsync:function(e,t,r,a,u){return l.length>0?function(e,t,n,r,i){for(var a=l[0],o=1;o<l.length;++o)l[o].pending<a.pending&&(a=l[o]);return new Promise(function(o,s){var A=new Uint8Array(n),l=++c;a.pending+=e,a.requests[l]={resolve:o,reject:s},a.object.postMessage({id:l,count:e,size:t,source:A,mode:r,filter:i},[A.buffer])})}(e,t,r,A[a],s[u]):i.then(function(){var i=new Uint8Array(e*t);return o(n,n.exports[A[a]],i,e,t,r,n.exports[s[u]]),i})}}}();function pc(e,t){if(!e)throw new Error(t||"assert failed: gltf")}var mc={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},gc={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},bc=["SCALAR","VEC2","VEC3","VEC4"],vc=new Map([[Int8Array,5120],[Uint8Array,5121],[Int16Array,5122],[Uint16Array,5123],[Uint32Array,5125],[Float32Array,5126],[Float64Array,5130]]),yc={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},xc={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},_c={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function wc(e){return bc[e-1]||bc[0]}function Tc(e){const t=vc.get(e.constructor);if(!t)throw new Error("Illegal typed array");return t}function Sc(e,t){const n=_c[e.componentType],r=yc[e.type],i=xc[e.componentType],a=e.count*r,o=e.count*r*i;return pc(o>=0&&o<=t.byteLength),{ArrayType:n,length:a,byteLength:o,componentByteSize:gc[e.componentType],numberOfComponentsInElement:mc[e.type]}}function Mc(e){let{images:t,bufferViews:n}=e;t=t||[],n=n||[];const r=t.map(e=>e.bufferView);n=n.filter(e=>!r.includes(e));const i=n.reduce((e,t)=>e+t.byteLength,0),a=t.reduce((e,t)=>{const{width:n,height:r}=t.image;return e+n*r},0);return i+Math.ceil(4*a*1.33)}var Ec=class{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];pc(n);const r=(e.byteOffset||0)+n.byteOffset;return new Uint8Array(n.arrayBuffer,r,e.byteLength)}getTypedArrayForAccessor(e){const t=this.getAccessor(e);return function(e,t,n){const r="number"==typeof n?e.accessors?.[n]:n;if(!r)throw new Error(`No gltf accessor ${JSON.stringify(n)}`);const i=e.bufferViews?.[r.bufferView||0];if(!i)throw new Error(`No gltf buffer view for accessor ${i}`);const{arrayBuffer:a,byteOffset:o}=t[i.buffer],s=(o||0)+(r.byteOffset||0)+(i.byteOffset||0),{ArrayType:A,length:l,componentByteSize:c,numberOfComponentsInElement:u}=Sc(r,i),f=c*u,d=i.byteStride||f;if(void 0===i.byteStride||i.byteStride===f)return new A(a,s,l);const h=new A(l);for(let p=0;p<r.count;p++){const e=new A(a,s+p*d,u);h.set(e,p*u)}return h}(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,r=t.byteOffset||0;return new Uint8Array(n,r,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 pc(t),this.json.extensions=this.json.extensions||{},this.json.extensions[e]=t,this.registerUsedExtension(e),t}addRequiredExtension(e,t={}){return pc(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 r={mesh:t};return n&&(r.matrix=n),this.json.nodes.push(r),this.json.nodes.length-1}addMesh(e){const{attributes:t,indices:n,material:r,mode:i=4}=e,a={primitives:[{attributes:this._addAttributes(t),mode:i}]};if(n){const e=this._addIndices(n);a.primitives[0].indices=e}return Number.isFinite(r)&&(a.primitives[0].material=r),this.json.meshes=this.json.meshes||[],this.json.meshes.push(a),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=r.getBinaryImageMetadata(e),i=t||n?.mimeType,a={bufferView:this.addBufferView(e),mimeType:i};return this.json.images=this.json.images||[],this.json.images.push(a),this.json.images.length-1}addBufferView(e,t=0,n=this.byteLength){const r=e.byteLength;pc(Number.isFinite(r)),this.sourceBuffers=this.sourceBuffers||[],this.sourceBuffers.push(e);const i={buffer:t,byteOffset:n,byteLength:r};return this.byteLength+=h(r,4),this.json.bufferViews=this.json.bufferViews||[],this.json.bufferViews.push(i),this.json.bufferViews.length-1}addAccessor(e,t){const n={bufferView:e,type:wc(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 r={min:t.min,max:t.max};r.min&&r.max||(r=this._getAccessorMinMax(e,t.size));const i={size:t.size,componentType:Tc(e),count:Math.round(e.length/t.size),min:r.min,max:r.max};return this.addAccessor(n,Object.assign(i,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 r=0;for(const i of this.sourceBuffers||[])r=p(i,n,r);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 r=e.indexOf(t);r>-1?e.splice(r,1):n=!1}}_addAttributes(e={}){const t={};for(const n in e){const r=e[n];t[this._getGltfAttributeName(n)]=this.addBinaryBuffer(r.value,r)}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 r=e.subarray(0,t);for(const i of r)n.min.push(i),n.max.push(i);for(let i=t;i<e.length;i+=t)for(let r=0;r<t;r++)n.min[0+r]=Math.min(n.min[0+r],e[i+r]),n.max[0+r]=Math.max(n.max[0+r],e[i+r]);return n}};function Cc(e){return(e%1+1)%1}var Ic={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16,BOOLEAN:1,STRING:1,ENUM:1},Rc={INT8:Int8Array,UINT8:Uint8Array,INT16:Int16Array,UINT16:Uint16Array,INT32:Int32Array,UINT32:Uint32Array,INT64:BigInt64Array,UINT64:BigUint64Array,FLOAT32:Float32Array,FLOAT64:Float64Array},Pc={INT8:1,UINT8:1,INT16:2,UINT16:2,INT32:4,UINT32:4,INT64:8,UINT64:8,FLOAT32:4,FLOAT64:8};function Nc(e,t){return Pc[t]*Ic[e]}function kc(e,t,n,r){if("UINT8"!==n&&"UINT16"!==n&&"UINT32"!==n&&"UINT64"!==n)return null;const i=Lc(e.getTypedArrayForBufferView(t),"SCALAR",n,r+1);return i instanceof BigInt64Array||i instanceof BigUint64Array?null:i}function Lc(e,t,r,i=1){const a=Rc[r],o=Pc[r],s=i*Ic[t],A=s*o;let l=e.buffer,c=e.byteOffset;return c%o!==0&&(l=new Uint8Array(l).slice(c,c+A).buffer,c=0),new a(n.ensureArrayBuffer(l),c,s)}function Bc(e,t,n){const r=`TEXCOORD_${t.texCoord||0}`,i=n.attributes[r],a=e.getTypedArrayForAccessor(i),o=e.gltf.json,s=t.index,A=o.textures?.[s]?.source;if(void 0!==A){const n=o.images?.[A]?.mimeType,r=e.gltf.images?.[A];if(r&&void 0!==r.width){const e=[];for(let i=0;i<a.length;i+=2){const o=Fc(r,n,a,i,t.channels);e.push(o)}return e}}return[]}function Oc(e,t,n,r,i){if(!n?.length)return;const a=[];for(const c of n){let e=r.findIndex(e=>e===c);-1===e&&(e=r.push(c)-1),a.push(e)}const o=new Uint32Array(a),s=e.gltf.buffers.push({arrayBuffer:o.buffer,byteOffset:o.byteOffset,byteLength:o.byteLength})-1,A=e.addBufferView(o,s,0),l=e.addAccessor(A,{size:1,componentType:Tc(o),count:o.length});i.attributes[t]=l}function Fc(e,t,n,i,a=[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 l=1;!t||-1===t.indexOf("image/jpeg")&&-1===t.indexOf("image/png")||(l=4);const c=function(e,t,n,r=1){const i=n.width,a=Cc(e)*(i-1),o=Math.round(a),s=n.height,A=Cc(t)*(s-1),l=Math.round(A),c=n.components?n.components:r;return(l*i+o)*c}(s,A,e,l);let u=0;for(const f of a){const t="number"==typeof f?Object.values(o)[f]:o[f],n=c+t.offset,i=r.getImageData(e);if(i.data.length<=n)throw new Error(`${i.data.length} <= ${n}`);u|=i.data[n]<<t.shift}return u}function Dc(e,t,n,r,i){const a=[];for(let o=0;o<t;o++){const t=n[o],s=n[o+1]-n[o];if(s+t>r)break;const A=t/i,l=s/i;a.push(e.slice(A,A+l))}return a}function Uc(e,t,n){const r=[];for(let i=0;i<t;i++){const t=i*n;r.push(e.slice(t,t+n))}return r}function Vc(e,t,n,r){if(n)throw new Error("Not implemented - arrayOffsets for strings is specified");if(r){const n=[],i=new TextDecoder("utf8");let a=0;for(let o=0;o<e;o++){const e=r[o+1]-r[o];if(e+a<=t.length){const r=t.subarray(a,e+a),o=i.decode(r);n.push(o),a+=e}}return n}return[]}var jc=e.__exportAll({createExtMeshFeatures:()=>Kc,decode:()=>Hc,encode:()=>qc,name:()=>Gc}),zc="EXT_mesh_features",Gc=zc;async function Hc(e,t){!function(e,t){const n=e.gltf.json;if(!n.meshes)return;for(const r of n.meshes)for(const n of r.primitives)Qc(e,n,t)}(new Ec(e),t)}function qc(e,t){const n=new Ec(e);return function(e){const t=e.gltf.json.meshes;if(!t)return;for(const n of t)for(const t of n.primitives)Wc(e,t)}(n),n.createBinaryChunk(),n.gltf}function Qc(e,t,n){if(!n?.gltf?.loadBuffers)return;const r=(t.extensions?.[zc])?.featureIds;if(r)for(const i of r){let r;if(void 0!==i.attribute){const n=`_FEATURE_ID_${i.attribute}`,a=t.attributes[n];r=e.getTypedArrayForAccessor(a)}else r=void 0!==i.texture&&n?.gltf?.loadImages?Bc(e,i.texture,t):[];i.data=r}}function Kc(e,t,n,r){t.extensions||(t.extensions={});let i=t.extensions[zc];i||(i={featureIds:[]},t.extensions[zc]=i);const{featureIds:a}=i,o={featureCount:n.length,propertyTable:r,data:n};a.push(o),e.addObjectExtension(t,zc,i)}function Wc(e,t){const n=t.extensions?.[zc];if(!n)return;const r=n.featureIds;r.forEach((n,i)=>{if(n.data){const{accessorKey:a,index:o}=function(e){const t="_FEATURE_ID_",n=Object.keys(e).filter(e=>0===e.indexOf(t));let r=-1;for(const i of n){const e=Number(i.substring(12));e>r&&(r=e)}return r++,{accessorKey:`${t}${r}`,index:r}}(t.attributes),s=new Uint32Array(n.data);r[i]={featureCount:s.length,propertyTable:n.propertyTable,attribute:o},e.gltf.buffers.push({arrayBuffer:s.buffer,byteOffset:s.byteOffset,byteLength:s.byteLength});const A=e.addBufferView(s),l=e.addAccessor(A,{size:1,componentType:Tc(s),count:s.length});t.attributes[a]=l}})}var $c=e.__exportAll({createExtStructuralMetadata:()=>lu,decode:()=>Xc,encode:()=>Zc,name:()=>Yc}),Jc="EXT_structural_metadata",Yc=Jc;async function Xc(e,t){!function(e,t){if(!t.gltf?.loadBuffers)return;const n=e.getExtension(Jc);if(!n)return;t.gltf?.loadImages&&function(e,t){const n=t.propertyTextures,r=e.gltf.json;if(n&&r.meshes)for(const i of r.meshes)for(const r of i.primitives)tu(e,n,r,t)}(e,n);!function(e,t){const n=t.schema;if(!n)return;const r=n.classes,i=t.propertyTables;if(r&&i)for(const a in r){const t=eu(i,a);t&&ru(e,n,t)}}(e,n)}(new Ec(e),t)}function Zc(e,t){const n=new Ec(e);return function(e){const t=e.getExtension(Jc);if(!t)return;if(t.propertyTables)for(const n of t.propertyTables){const r=n.class,i=t.schema?.classes?.[r];n.properties&&i&&Au(n,i,e)}}(n),n.createBinaryChunk(),n.gltf}function eu(e,t){for(const n of e)if(n.class===t)return n;return null}function tu(e,t,n,r){if(!t)return;const i=(n.extensions?.[Jc])?.propertyTextures;if(i)for(const a of i){nu(e,t[a],n,r)}}function nu(e,t,n,r){if(!t.properties)return;r.dataAttributeNames||(r.dataAttributeNames=[]);const i=t.class;for(const a in t.properties){const o=`${i}_${a}`,s=t.properties?.[a];if(!s)continue;s.data||(s.data=[]);const A=s.data,l=Bc(e,s,n);null!==l&&(Oc(e,o,l,A,n),s.data=A,r.dataAttributeNames.push(o))}}function ru(e,t,n){const r=t.classes?.[n.class];if(!r)throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${n.class}`);const i=n.count;for(const a in r.properties){const o=r.properties[a],s=n.properties?.[a];s&&(s.data=iu(e,t,o,i,s))}}function iu(e,t,n,r,i){let a=[];const o=i.values,s=e.getTypedArrayForBufferView(o),A=function(e,t,n,r){return t.array&&void 0===t.count&&void 0!==n.arrayOffsets?kc(e,n.arrayOffsets,n.arrayOffsetType||"UINT32",r):null}(e,n,i,r),l=function(e,t,n){return void 0!==t.stringOffsets?kc(e,t.stringOffsets,t.stringOffsetType||"UINT32",n):null}(e,i,r);switch(n.type){case"SCALAR":case"VEC2":case"VEC3":case"VEC4":case"MAT2":case"MAT3":case"MAT4":a=function(e,t,n,r){const i=e.array,a=e.count,o=Nc(e.type,e.componentType),s=n.byteLength/o;let A;A=e.componentType?Lc(n,e.type,e.componentType,s):n;if(i)return r?Dc(A,t,r,n.length,o):a?Uc(A,t,a):[];return A}(n,r,s,A);break;case"BOOLEAN":throw new Error(`Not implemented - classProperty.type=${n.type}`);case"STRING":a=Vc(r,s,A,l);break;case"ENUM":a=function(e,t,n,r,i){const a=t.enumType;if(!a)throw new Error("Incorrect data in the EXT_structural_metadata extension: classProperty.enumType is not set for type ENUM");const o=e.enums?.[a];if(!o)throw new Error(`Incorrect data in the EXT_structural_metadata extension: schema.enums does't contain ${a}`);const s=o.valueType||"UINT16",A=Nc(t.type,s),l=r.byteLength/A;let c=Lc(r,t.type,s,l);c||(c=r);if(t.array){if(i)return function(e){const{valuesData:t,numberOfElements:n,arrayOffsets:r,valuesDataBytesLength:i,elementSize:a,enumEntry:o}=e,s=[];for(let A=0;A<n;A++){const e=r[A],n=r[A+1]-r[A];if(n+e>i)break;const l=au(t,e/a,n/a,o);s.push(l)}return s}({valuesData:c,numberOfElements:n,arrayOffsets:i,valuesDataBytesLength:r.length,elementSize:A,enumEntry:o});const e=t.count;return e?function(e,t,n,r){const i=[];for(let a=0;a<t;a++){const t=au(e,n*a,n,r);i.push(t)}return i}(c,n,e,o):[]}return au(c,0,n,o)}(t,n,r,s,A);break;default:throw new Error(`Unknown classProperty type ${n.type}`)}return a}function au(e,t,n,r){const i=[];for(let a=0;a<n;a++)if(e instanceof BigInt64Array||e instanceof BigUint64Array)i.push("");else{const n=ou(r,e[t+a]);n?i.push(n.name):i.push("")}return i}function ou(e,t){for(const n of e.values)if(n.value===t)return n;return null}var su="schemaClassId";function Au(e,t,n){for(const r in e.properties){const i=e.properties[r].data;if(i){const a=t.properties[r];if(a){const t=cu(i,a,n);e.properties[r]=t}}}}function lu(e,t,n=su){let r=e.getExtension(Jc);r||(r=e.addExtension(Jc)),r.schema=function(e,t,n){const r=n??{id:"schema_id"},i={properties:{}};for(const a of e){const e={type:a.elementType,componentType:a.componentType};i.properties[a.name]=e}return r.classes={},r.classes[t]=i,r}(t,n,r.schema);const i=function(e,t,n){const r={class:t,count:0};let i=0;const a=n.classes?.[t];for(const o of e){if(0===i&&(i=o.values.length),i!==o.values.length&&o.values.length)throw new Error("Illegal values in attributes");a?.properties[o.name]&&(r.properties||(r.properties={}),r.properties[o.name]={values:0,data:o.values})}return r.count=i,r}(t,n,r.schema);return r.propertyTables||(r.propertyTables=[]),r.propertyTables.push(i)-1}function cu(e,t,n){const r={values:0};if("STRING"===t.type){const{stringData:t,stringOffsets:i}=function(e){const t=new TextEncoder,n=[];let r=0;for(const s of e){const e=t.encode(s);r+=e.length,n.push(e)}const i=new Uint8Array(r),a=[];let o=0;for(const s of n)i.set(s,o),a.push(o),o+=s.length;return a.push(o),{stringData:i,stringOffsets:new Uint32Array(a)}}(e);r.stringOffsets=fu(i,n),r.values=fu(t,n)}else"SCALAR"===t.type&&t.componentType&&(r.values=fu(function(e,t){const n=[];for(const i of e)n.push(Number(i));const r=uu[t];if(!r)throw new Error("Illegal component type");return new r(n)}(e,t.componentType),n));return r}var uu={INT8:Int8Array,UINT8:Uint8Array,INT16:Int16Array,UINT16:Uint16Array,INT32:Int32Array,UINT32:Uint32Array,INT64:Int32Array,UINT64:Uint32Array,FLOAT32:Float32Array,FLOAT64:Float64Array};function fu(e,t){return t.gltf.buffers.push({arrayBuffer:n.ensureArrayBuffer(e.buffer),byteOffset:e.byteOffset,byteLength:e.byteLength}),t.addBufferView(e)}var du=e.__exportAll({decode:()=>mu,name:()=>pu}),hu="EXT_feature_metadata",pu=hu;async function mu(e,t){!function(e,t){if(!t.gltf?.loadBuffers)return;const n=e.getExtension(hu);if(!n)return;t.gltf?.loadImages&&function(e,t){const n=t.schema;if(!n)return;const r=n.classes,{featureTextures:i}=t;if(r&&i)for(const a in r){const t=r[a],n=bu(i,a);n&&yu(e,n,t)}}(e,n);!function(e,t){const n=t.schema;if(!n)return;const r=n.classes,i=t.featureTables;if(r&&i)for(const a in r){const t=gu(i,a);t&&vu(e,n,t)}}(e,n)}(new Ec(e),t)}function gu(e,t){for(const n in e){const r=e[n];if(r.class===t)return r}return null}function bu(e,t){for(const n in e){const r=e[n];if(r.class===t)return r}return null}function vu(e,t,n){if(!n.class)return;const r=t.classes?.[n.class];if(!r)throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${n.class}`);const i=n.count;for(const a in r.properties){const o=r.properties[a],s=n.properties?.[a];s&&(s.data=xu(e,t,o,i,s))}}function yu(e,t,n){const r=t.class;for(const i in n.properties){const n=t?.properties?.[i];n&&(n.data=_u(e,n,r))}}function xu(e,t,n,r,i){let a=[];const o=i.bufferView,s=e.getTypedArrayForBufferView(o),A=function(e,t,n,r){return"ARRAY"===t.type&&void 0===t.componentCount&&void 0!==n.arrayOffsetBufferView?kc(e,n.arrayOffsetBufferView,n.offsetType||"UINT32",r):null}(e,n,i,r),l=function(e,t,n,r){return void 0!==n.stringOffsetBufferView?kc(e,n.stringOffsetBufferView,n.offsetType||"UINT32",r):null}(e,0,i,r);return"STRING"===n.type||"STRING"===n.componentType?a=Vc(r,s,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)&&(a=function(e,t,n,r){const i="ARRAY"===e.type,a=e.componentCount,o="SCALAR",s=e.componentType||e.type,A=Nc(o,s),l=n.byteLength/A,c=Lc(n,o,s,l);if(i)return r?Dc(c,t,r,n.length,A):a?Uc(c,t,a):[];return c}(n,r,s,A)),a}function _u(e,t,n){const r=e.gltf.json;if(!r.meshes)return[];const i=[];for(const a of r.meshes)for(const r of a.primitives)wu(e,n,t,i,r);return i}function wu(e,t,n,r,i){const a=Bc(e,{channels:n.channels,...n.texture},i);a&&Oc(e,t,a,r,i)}var Tu,Su,Mu="basis_transcoder.js",Eu="basis_transcoder.wasm",Cu="basis_encoder.js",Iu="basis_encoder.wasm";async function Ru(e){var t;t=e.modules,globalThis.loaders||={},globalThis.loaders.modules||={},Object.assign(globalThis.loaders.modules,t);const n=function(e){return globalThis.loaders?.modules?.[e]||null}("basis");return n||(Tu||=async function(e){let t=null,n=null;return[t,n]=await Promise.all([await u(Mu,"textures",e),await u(Eu,"textures",e)]),t=t||globalThis.BASIS,await function(e,t){const n={};t&&(n.wasmBinary=t);return y(()=>e(n),e=>{const{BasisFile:t,initializeBasis:n}=e;return n(),{BasisFile:t}})}(t,n)}(e),await Tu)}async function Pu(e){const t=e.modules||{};return t.basisEncoder?t.basisEncoder:(Su=Su||async function(e){let t=null,n=null;return[t,n]=await Promise.all([await u(Cu,"textures",e),await u(Iu,"textures",e)]),t=t||globalThis.BASIS,await function(e,t){const n={};t&&(n.wasmBinary=t);return y(()=>e(n),e=>{const{BasisFile:t,KTX2File:n,BasisEncoder:r,initializeBasis:i}=e;return i(),{BasisFile:t,KTX2File:n,BasisEncoder:r}})}(t,n)}(e),await Su)}var Nu=["","WEBKIT_","MOZ_"],ku={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"]},Lu=null;function Bu(e){if(!Lu){e=e||function(){try{return document.createElement("canvas").getContext("webgl")}catch(e){return null}}()||void 0,Lu=new Set;for(const t of Nu)for(const n in ku)if(e&&e.getExtension(`${t}${n}`))for(const e of ku[n])Lu.add(e)}return Lu}var Ou=[171,75,84,88,32,50,48,187,13,10,26,10];var Fu=Promise.resolve(),Du={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:6,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"}};Object.freeze(Object.keys(Du));function Uu(e,t,n){const r=new e(new Uint8Array(t));try{if(!r.startTranscoding())throw new Error("Failed to start basis transcoding");const e=r.getNumImages(),t=[];for(let i=0;i<e;i++){const e=r.getNumLevels(i),a=[];for(let t=0;t<e;t++)a.push(Vu(r,i,t,n));t.push(a)}return t}finally{r.close(),r.delete()}}function Vu(e,t,n,r){const i=e.getImageWidth(t,n),a=e.getImageHeight(t,n),o=e.getHasAlpha(),{compressed:s,format:A,basisFormat:l,textureFormat:c}=Gu(r,o),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:i,height:a,data:f,compressed:s,...void 0!==A?{format:A}:{},...void 0!==c?{textureFormat:c}:{},hasAlpha:o}}function ju(e,t,n){const r=new e(new Uint8Array(t));try{if(!r.startTranscoding())throw new Error("failed to start KTX2 transcoding");const e=r.getLevels(),t=[];for(let i=0;i<e;i++)t.push(zu(r,i,n));return[t]}finally{r.close(),r.delete()}}function zu(e,t,n){const{alphaFlag:r,height:i,width:a}=e.getImageLevelInfo(t,0,0),{compressed:o,format:s,basisFormat:A,textureFormat:l}=Gu(n,r),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:a,height:i,data:u,compressed:o,...void 0!==s?{format:s}:{},...void 0!==l?{textureFormat:l}:{},levelSize:c,hasAlpha:r}}function Gu(e,t){let n=e.basis?.format||"auto";"auto"===n&&(n=e.basis?.supportedTextureFormats?Hu(e.basis.supportedTextureFormats):Hu()),"object"==typeof n&&(n=t?n.alpha:n.noAlpha);const r=n.toLowerCase(),i=Du[r];if(!i)throw new Error(`Unknown Basis format ${n}`);return i}function Hu(e=Bu()){const t=new Set(e);return qu(t,["astc-4x4-unorm","astc-4x4-unorm-srgb"])?"astc-4x4":qu(t,["bc7-rgba-unorm","bc7-rgba-unorm-srgb"])?{alpha:"bc7-m5",noAlpha:"bc7-m6-opaque-only"}:qu(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"}:qu(t,["pvrtc-rgb4unorm-webgl","pvrtc-rgba4unorm-webgl","pvrtc-rgb2unorm-webgl","pvrtc-rgba2unorm-webgl"])?{alpha:"pvrtc1-4-rgba",noAlpha:"pvrtc1-4-rgb"}:qu(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":qu(t,["atc-rgb-unorm-webgl","atc-rgba-unorm-webgl","atc-rgbai-unorm-webgl"])?{alpha:"atc-rgba-interpolated-alpha",noAlpha:"atc-rgb"}:"rgb565"}function qu(e,t){return t.some(t=>e.has(t))}var Qu={...{dataType:null,batchType:null,name:"Basis",id:"basis",module:"textures",version:"4.5.4",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=c(t);return await async function(e){const t=Fu;let n;Fu=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<Ou.length||t[0]!==Ou[0]||t[1]!==Ou[1]||t[2]!==Ou[2]||t[3]!==Ou[3]||t[4]!==Ou[4]||t[5]!==Ou[5]||t[6]!==Ou[6]||t[7]!==Ou[7]||t[8]!==Ou[8]||t[9]!==Ou[9]||t[10]!==Ou[10]||t[11]!==Ou[11])}(e))return ju((await Pu(n)).KTX2File,e,t);const{BasisFile:r}=await Ru(n);return Uu(r,e,t)}if("encoder"===t.basis.module){const r=await Pu(n);return"ktx2"===t.basis.containerFormat?ju(r.KTX2File,e,t):Uu(r.BasisFile,e,t)}{const{BasisFile:r}=await Ru(n);return Uu(r,e,t)}})}},Ku=!0,Wu=1735152710,$u=1313821514,Ju=5130562;function Yu(e,t,r=0,i={}){const a=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))}`}(a,r+0),s=a.getUint32(r+4,Ku),A=a.getUint32(r+8,Ku);switch(Object.assign(e,{header:{byteOffset:r,byteLength:A,hasBinChunk:!1},type:o,version:s,json:{},binChunks:[]}),r+=12,e.version){case 1:return function(e,t,r){n.assert$3(e.header.byteLength>20);const i=t.getUint32(r+0,Ku),a=t.getUint32(r+4,Ku);return r+=8,n.assert$3(0===a),Xu(e,t,r,i),r+=i,r+=Zu(e,t,r,e.header.byteLength),r}(e,a,r);case 2:return function(e,t,r,i){return n.assert$3(e.header.byteLength>20),function(e,t,n,r){for(;n+8<=e.header.byteLength;){const i=t.getUint32(n+0,Ku),a=t.getUint32(n+4,Ku);switch(n+=8,a){case $u:Xu(e,t,n,i);break;case Ju:Zu(e,t,n,i);break;case 0:r.strict||Xu(e,t,n,i);break;case 1:r.strict||Zu(e,t,n,i)}n+=h(i,4)}}(e,t,r,i),r+e.header.byteLength}(e,a,r,{});default:throw new Error(`Invalid GLB version ${e.version}. Only supports version 1 and 2.`)}}function Xu(e,t,n,r){const i=new Uint8Array(t.buffer,n,r),a=new TextDecoder("utf8").decode(i);return e.json=JSON.parse(a),h(r,4)}function Zu(e,t,n,r){return e.header.hasBinChunk=!0,e.binChunks.push({byteOffset:n,byteLength:r,arrayBuffer:t.buffer}),h(r,4)}function ef(e,t,n){if(e.startsWith("data:")||e.startsWith("http:")||e.startsWith("https:"))return e;const r=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(!r)throw new Error(`'baseUrl' must be provided to resolve relative url ${e}`);return r.endsWith("/")?`${r}${e}`:`${r}/${e}`}async function tf(e,t,n){if(!t.gltf?.decompressMeshes||!t.gltf.loadBuffers)return;!function(e){const t=e.bufferViews||[];for(let r=0;r<t.length;r++){const e=t[r].extensions;if(e?.KHR_meshopt_compression&&e.EXT_meshopt_compression)throw new Error(`glTF bufferView ${r} cannot use both KHR_meshopt_compression and EXT_meshopt_compression.`)}const n=e.buffers||[];for(let r=0;r<n.length;r++){const e=n[r].extensions;if(e?.KHR_meshopt_compression&&e.EXT_meshopt_compression)throw new Error(`glTF buffer ${r} cannot use both KHR_meshopt_compression and EXT_meshopt_compression.`)}}(e.json);const r=new Ec(e),i=e.json.bufferViews||[],a=i.map(e=>async function(e,t,n){const r=e.getObjectExtension(t,n);if(!r)return;const{byteOffset:i=0,byteLength:a,byteStride:o,count:s,mode:A,filter:l="NONE",buffer:c}=r,u=e.gltf.buffers[c],f=e.gltf.buffers[t.buffer],d=new Uint8Array(u.arrayBuffer,u.byteOffset+i,a),h=new Uint8Array(f.arrayBuffer,f.byteOffset+(t.byteOffset||0),t.byteLength);await async function(e,t,n,r,i,a="NONE"){await hc.ready,hc.decodeGltfBuffer(e,t,n,r,i,function(e){return"string"==typeof e?e:["NONE","OCTAHEDRAL","QUATERNION","EXPONENTIAL","COLOR"][e]}(a))}(h,s,o,d,A,l)}(r,e,n));await Promise.all(a);for(const o of i)r.removeObjectExtension(o,n);for(const o of e.json.buffers||[])r.removeObjectExtension(o,n);r.removeExtension(n)}var nf=e.__exportAll({decode:()=>af,name:()=>rf}),rf="EXT_meshopt_compression";async function af(e,t){await tf(e,t,rf)}var of=e.__exportAll({decode:()=>Af,name:()=>sf}),sf="KHR_meshopt_compression";async function Af(e,t){await tf(e,t,sf)}var lf=e.__exportAll({name:()=>uf,preprocess:()=>ff}),cf="EXT_texture_webp",uf=cf;function ff(e,t){const n=new Ec(e);if(!M("image/webp")){if(n.getRequiredExtensions().includes(cf))throw new Error(`gltf: Required extension ${cf} not supported by browser`);return}const{json:r}=n;for(const i of r.textures||[]){const e=n.getObjectExtension(i,cf);e&&(i.source=e.source),n.removeObjectExtension(i,cf)}n.removeExtension(cf)}var df=e.__exportAll({name:()=>pf,preprocess:()=>mf}),hf="EXT_texture_avif",pf=hf;async function mf(e,t){const n=new Ec(e);if(!(await T()).has("image/avif")){if(n.getRequiredExtensions().includes(hf))throw new Error(`gltf: Required extension ${hf} not supported by browser`);return}const{json:r}=n;for(const i of r.textures||[]){const e=n.getObjectExtension(i,hf);e&&(i.source=e.source),n.removeObjectExtension(i,hf)}n.removeExtension(hf)}var gf=e.__exportAll({name:()=>vf,preprocess:()=>yf}),bf="KHR_texture_basisu",vf=bf;function yf(e,t){const n=new Ec(e),{json:r}=n;for(const i of r.textures||[]){const e=n.getObjectExtension(i,bf);e&&(i.source=e.source,n.removeObjectExtension(i,bf))}n.removeExtension(bf)}var xf,_f="https://www.gstatic.com/draco/versioned/decoders/1.5.6",wf="draco_wasm_wrapper.js",Tf="draco_decoder.wasm",Sf="draco_decoder.js",Mf="draco_encoder.js",Ef={[wf]:`${_f}/${wf}`,[Tf]:`${_f}/${Tf}`,[Sf]:`${_f}/${Sf}`,[Mf]:`https://raw.githubusercontent.com/google/draco/1.4.1/javascript/${Mf}`};async function Cf(e={},t){const r=e.modules||{};return r.draco3d?xf||=y(()=>r.draco3d.createDecoderModule({}),e=>({draco:e})):xf||=async function(e,t){let r,i;if("js"===t)r=await u(Ef[Sf],"draco",e,Sf);else try{[r,i]=await Promise.all([await u(Ef[wf],"draco",e,wf),await u(Ef[Tf],"draco",e,Tf)])}catch{r=null,i=null}r=If(r,"DracoDecoderModule"),r=r||globalThis.DracoDecoderModule,r||n.isBrowser||([r,i]=await Promise.all([await u(Ef[wf],"draco",{...e,useLocalLibraries:!0},wf),await u(Ef[Tf],"draco",{...e,useLocalLibraries:!0},Tf)]),r=If(r,"DracoDecoderModule"),r=r||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 y(t=>e({...n,onModuleLoaded:t}),e=>({draco:e}))}(r,i)}(e,t),await xf}function If(e,t){if(e&&"object"==typeof e){if(e.default)return e.default;if(e[t])return e[t]}return e}function Rf(e,t,n){return x(e,t,n?Pf(n.metadata):void 0)}function Pf(e){Object.entries(e);const t={};for(const n in e)t[`${n}.string`]=JSON.stringify(e[n]);return t}var Nf={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},kf={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array},Lf=class{draco;decoder;metadataQuerier;constructor(e){this.draco=e,this.decoder=new this.draco.Decoder,this.metadataQuerier=new this.draco.MetadataQuerier}destroy(){this.draco.destroy(this.decoder),this.draco.destroy(this.metadataQuerier)}parseSync(e,t={}){const n=new this.draco.DecoderBuffer;n.Init(new Int8Array(e),e.byteLength),this._disableAttributeTransforms(t);const r=this.decoder.GetEncodedGeometryType(n),i=r===this.draco.TRIANGULAR_MESH?new this.draco.Mesh:new this.draco.PointCloud;try{let e;switch(r){case this.draco.TRIANGULAR_MESH:e=this.decoder.DecodeBufferToMesh(n,i);break;case this.draco.POINT_CLOUD:e=this.decoder.DecodeBufferToPointCloud(n,i);break;default:throw new Error("DRACO: Unknown geometry type.")}if(!e.ok()||!i.ptr){const t=`DRACO decompression failed: ${e.error_msg()}`;throw new Error(t)}const a=this._getDracoLoaderData(i,r,t),o=this._getMeshData(i,a,t),s=function(e){let t=1/0,n=1/0,r=1/0,i=-1/0,a=-1/0,o=-1/0;const s=e.POSITION?e.POSITION.value:[],A=s&&s.length;for(let l=0;l<A;l+=3){const e=s[l],A=s[l+1],c=s[l+2];t=e<t?e:t,n=A<n?A:n,r=c<r?c:r,i=e>i?e:i,a=A>a?A:a,o=c>o?c:o}return[[t,n,r],[i,a,o]]}(o.attributes),A=function(e,t,n){const r=Pf(t.metadata),i=[],a=function(e){const t={};for(const n in e){const r=e[n];t[r.name||"undefined"]=r}return t}(t.attributes);for(const o in e){const t=Rf(o,e[o],a[o]);i.push(t)}if(n){const e=Rf("indices",n);i.push(e)}return{fields:i,metadata:r}}(o.attributes,a,o.indices);return{loader:"draco",loaderData:a,header:{vertexCount:i.num_points(),boundingBox:s},...o,schema:A}}finally{this.draco.destroy(n),i&&this.draco.destroy(i)}}_getDracoLoaderData(e,t,n){const r=this._getTopLevelMetadata(e),i=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:r,attributes:i}}_getDracoAttributes(e,t){const n={};for(let r=0;r<e.num_attributes();r++){const i=this.decoder.GetAttribute(e,r),a=this._getAttributeMetadata(e,r);n[i.unique_id()]={unique_id:i.unique_id(),attribute_type:i.attribute_type(),data_type:i.data_type(),num_components:i.num_components(),byte_offset:i.byte_offset(),byte_stride:i.byte_stride(),normalized:i.normalized(),attribute_index:r,metadata:a};const o=this._getQuantizationTransform(i,t);o&&(n[i.unique_id()].quantization_transform=o);const s=this._getOctahedronTransform(i,t);s&&(n[i.unique_id()].octahedron_transform=s)}return n}_getMeshData(e,t,n){const r=this._getMeshAttributes(t,e,n);if(!r.POSITION)throw new Error("DRACO: No position attribute found.");if(e instanceof this.draco.Mesh){if("triangle-strip"===n.topology)return{topology:"triangle-strip",mode:4,attributes:r,indices:{value:this._getTriangleStripIndices(e),size:1}};return{topology:"triangle-list",mode:5,attributes:r,indices:{value:this._getTriangleListIndices(e),size:1}}}return{topology:"point-list",mode:0,attributes:r}}_getMeshAttributes(e,t,n){const r={};for(const i of Object.values(e.attributes)){const e=this._deduceAttributeName(i,n);i.name=e;const a=this._getAttributeValues(t,i);if(a){const{value:t,size:n}=a;r[e]={value:t,size:n,byteOffset:i.byte_offset,byteStride:i.byte_stride,normalized:i.normalized}}}return r}_getTriangleListIndices(e){const t=3*e.num_faces(),n=4*t,r=this.draco._malloc(n);try{return this.decoder.GetTrianglesUInt32Array(e,n,r),new Uint32Array(this.draco.HEAPF32.buffer,r,t).slice()}finally{this.draco._free(r)}}_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 r=0;r<t;r++)n[r]=e.GetValue(r);return n}(t)}finally{this.draco.destroy(t)}}_getAttributeValues(e,t){const n=kf[t.data_type];if(!n)return console.warn(`DRACO: Unsupported attribute type ${t.data_type}`),null;const r=t.num_components,i=e.num_points()*r,a=i*n.BYTES_PER_ELEMENT,o=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 s;const A=this.draco._malloc(a);try{const r=this.decoder.GetAttribute(e,t.attribute_index);this.decoder.GetAttributeDataArrayForAllPoints(e,r,o,a,A),s=new n(this.draco.HEAPF32.buffer,A,i).slice()}finally{this.draco._free(A)}return{value:s,size:r}}_deduceAttributeName(e,t){const n=e.unique_id;for(const[a,o]of Object.entries(t.extraAttributes||{}))if(o===n)return a;const r=e.attribute_type;for(const a in Nf)if(this.draco[a]===r)return Nf[a];const i=t.attributeNameEntry||"name";return e.metadata[i]?e.metadata[i].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 r=0;r<n;r++){const n=this.metadataQuerier.GetEntryName(e,r);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 r=function(e){const t=e.size(),n=new Int32Array(t);for(let r=0;r<t;r++)n[r]=e.GetValue(r);return n}(n);return{int:this.metadataQuerier.GetIntEntry(e,t),string:this.metadataQuerier.GetStringEntry(e,t),double:this.metadataQuerier.GetDoubleEntry(e,t),intArray:r}}finally{this.draco.destroy(n)}}_disableAttributeTransforms(e){const{quantizedAttributes:t=[],octahedronAttributes:n=[]}=e,r=[...t,...n];for(const i of r)this.decoder.SkipAttributeTransform(this.draco[i])}_getQuantizationTransform(e,t){const{quantizedAttributes:n=[]}=t,r=e.attribute_type();if(n.map(e=>this.decoder[e]).includes(r)){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,r=e.attribute_type();if(n.map(e=>this.decoder[e]).includes(r)){const t=new this.draco.AttributeQuantizationTransform;try{if(t.InitFromAttribute(e))return{quantization_bits:t.quantization_bits()}}finally{this.draco.destroy(t)}}return null}};var Bf={...{dataType:null,batchType:null,name:"Draco",id:"draco",module:"draco",version:"4.5.4",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 Cf(c(t),t?.draco?.decoderType||"wasm"),r=new Lf(n);try{return r.parseSync(e,t?.draco)}finally{r.destroy()}}};function Of(e){const{buffer:t,size:n,count:r}=function(e){let t=e,n=1,r=0;e&&e.value&&(t=e.value,n=e.size||1);t&&(ArrayBuffer.isView(t)||(t=function(e,t,n=!1){return e?Array.isArray(e)?new t(e):!n||e instanceof t?e:new t(e):null}(t,Float32Array)),r=t.length/n);return{buffer:t,size:n,count:r}}(e);return{value:t,size:n,byteOffset:0,count:r,type:wc(n),componentType:Tc(t)}}var Ff=e.__exportAll({decode:()=>jf,encode:()=>zf,name:()=>Uf,preprocess:()=>Vf}),Df="KHR_draco_mesh_compression",Uf=Df;function Vf(e,t,n){const r=new Ec(e);for(const i of qf(r))r.getObjectExtension(i,Df)}async function jf(e,t,n){if(!t?.gltf?.decompressMeshes)return;const r=new Ec(e),i=[];for(const a of qf(r))r.getObjectExtension(a,Df)&&i.push(Gf(r,a,t,n));await Promise.all(i),r.removeExtension(Df)}function zf(e,t={}){const n=new Ec(e);for(const r of n.json.meshes||[])Hf(r,t),n.addRequiredExtension(Df)}async function Gf(e,t,r,i){const a=e.getObjectExtension(t,Df);if(!a)return;const o=e.getTypedArrayForBufferView(a.bufferView),A=n.sliceArrayBuffer(o.buffer,o.byteOffset),l={...r};delete l["3d-tiles"];const c=await s(A,Bf,l,i),u=function(e){const t={};for(const n in e){const r=e[n];"indices"!==n&&(t[n]=Of(r))}return t}(c.attributes);for(const[n,s]of Object.entries(u))if(n in t.attributes){const r=t.attributes[n],i=e.getAccessor(r);i?.min&&i?.max&&(s.min=i.min,s.max=i.max)}t.attributes=u,c.indices&&(t.indices=Of(c.indices)),e.removeObjectExtension(t,Df),function(e){if(!e.attributes&&Object.keys(e.attributes).length>0)throw new Error("glTF: Empty primitive detected: Draco decompression failure?")}(t)}function Hf(e,t,n=4,r,i){if(!r.DracoWriter)throw new Error("options.gltf.DracoWriter not provided");const a=r.DracoWriter.encodeSync({attributes:e}),o=i?.parseSync?.({attributes:e}),s=r._addFauxAttributes(o.attributes),A=r.addBufferView(a);return{primitives:[{attributes:s,mode:n,extensions:{[Df]:{bufferView:A,attributes:s}}}]}}function*qf(e){for(const t of e.json.meshes||[])for(const e of t.primitives)yield e}var Qf=e.__exportAll({decode:()=>Xf,name:()=>Wf}),Kf="KHR_texture_transform",Wf=Kf,$f=new n.Vector3,Jf=new L,Yf=new L;async function Xf(e,t){const n=new Ec(e);if(!n.hasExtension(Kf)||!t.gltf?.loadBuffers)return;const r=e.json.materials||[];for(let i=0;i<r.length;i++)Zf(i,e,n);r.some(e=>ed(e).length>0)||n.removeExtension(Kf)}function Zf(e,t,n){const r=t.json.materials?.[e],i=ed(r),a=new Map;let o=function(e){let t=-1;for(const n of e.json.meshes||[])for(const e of n.primitives)for(const n of Object.keys(e.attributes)){const e=/^TEXCOORD_(\d+)$/.exec(n);e&&(t=Math.max(t,Number(e[1])))}return t+1}(t);for(const s of i){const r=s.extensions?.[Kf];if(r){const i=r.texCoord??s.texCoord??0,A=td(i,r);let l=a.get(A);if(!l){if(l={sourceTexCoord:i,texCoord:o,matrix:id(r)},!nd(t,e,l))continue;o++,a.set(A,l)}s.texCoord=l.texCoord,n.removeObjectExtension(s,Kf),s.extensions&&0===Object.keys(s.extensions).length&&delete s.extensions}}}function ed(e){if(!e||"object"!=typeof e)return[];const t=e,n=[],r=t.extensions;Number.isFinite(t.index)&&r?.[Kf]&&n.push(t);for(const[i,a]of Object.entries(t))"extras"!==i&&n.push(...ed(a));return n}function td(e,t){const{offset:n=[0,0],rotation:r=0,scale:i=[1,1]}=t;return JSON.stringify([e,n,r,i])}function nd(e,t,n){const r=[],i=e.json.meshes||[];for(const a of i)for(const e of a.primitives){const n=e.material;Number.isFinite(n)&&t===n&&r.push(e)}if(0===r.length||r.some(t=>!function(e,t,n){const r=t.attributes[`TEXCOORD_${n}`];if(!Number.isFinite(r))return!1;const i=e.json.accessors?.[r];if(!i||void 0===i.bufferView||i.sparse)return!1;const a=e.json.bufferViews?.[i.bufferView];return Boolean(a&&e.buffers[a.buffer])}(e,t,n.sourceTexCoord)))return!1;for(const a of r)rd(e,a,n);return!0}function rd(e,t,r){const{sourceTexCoord:i,texCoord:a,matrix:o}=r,s=t.attributes[`TEXCOORD_${i}`];if(Number.isFinite(s)){const r=e.json.accessors?.[s];if(r&&void 0!==r.bufferView){const i=e.json.bufferViews?.[r.bufferView];if(i){const{arrayBuffer:s,byteOffset:A}=e.buffers[i.buffer],l=(A||0)+(r.byteOffset||0)+(i.byteOffset||0),{ArrayType:c,length:u}=Sc(r,i),f=gc[r.componentType],d=mc[r.type],h=i.byteStride||f*d,p=new Float32Array(u);for(let e=0;e<r.count;e++){const t=new c(s,l+e*h,2);$f.set(t[0],t[1],1),$f.transformByMatrix3(o),p.set([$f[0],$f[1]],e*d)}!function(e,t,r,i,a){i.buffers.push({arrayBuffer:n.ensureArrayBuffer(a.buffer),byteOffset:0,byteLength:a.buffer.byteLength}),i.json.bufferViews=i.json.bufferViews||[];const o=i.json.bufferViews;o.push({buffer:i.buffers.length-1,byteLength:a.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"}),r.attributes[`TEXCOORD_${e}`]=s.length-1}(a,r,t,e,p)}}}}function id(e){const{offset:t=[0,0],rotation:n=0,scale:r=[1,1]}=e,i=(new L).set(1,0,0,0,1,0,t[0],t[1],1),a=Jf.set(Math.cos(n),Math.sin(n),0,-Math.sin(n),Math.cos(n),0,0,0,1),o=Yf.set(r[0],0,0,0,r[1],0,0,0,1);return i.multiplyRight(a).multiplyRight(o)}var ad=e.__exportAll({decode:()=>Ad,encode:()=>ld,name:()=>sd}),od="KHR_lights_punctual",sd=od;async function Ad(e){const t=new Ec(e),{json:n}=t,r=t.getExtension(od);r&&(t.json.lights=r.lights,t.removeExtension(od));for(const i of n.nodes||[]){const e=t.getObjectExtension(i,od);e&&(i.light=e.light),t.removeObjectExtension(i,od)}}async function ld(e){const t=new Ec(e),{json:n}=t;if(n.lights){const e=t.addExtension(od);pc(!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,od,e)}delete t.json.lights}}var cd=e.__exportAll({decode:()=>dd,encode:()=>hd,name:()=>fd}),ud="KHR_materials_unlit",fd=ud;async function dd(e){const t=new Ec(e),{json:n}=t;for(const r of n.materials||[])r.extensions&&r.extensions.KHR_materials_unlit&&(r.unlit=!0),t.removeObjectExtension(r,ud);t.removeExtension(ud)}function hd(e){const t=new Ec(e),{json:n}=t;if(t.materials)for(const r of n.materials||[])r.unlit&&(delete r.unlit,t.addObjectExtension(r,ud,{}),t.addExtension(ud))}var pd=e.__exportAll({decode:()=>bd,encode:()=>vd,name:()=>gd}),md="KHR_techniques_webgl",gd=md;async function bd(e){const t=new Ec(e),{json:n}=t,r=t.getExtension(md);if(r){const e=function(e,t){const{programs:n=[],shaders:r=[],techniques:i=[]}=e,a=new TextDecoder;return r.forEach(e=>{if(!Number.isFinite(e.bufferView))throw new Error("KHR_techniques_webgl: no shader code");e.code=a.decode(t.getTypedArrayForBufferView(e.bufferView))}),n.forEach(e=>{e.fragmentShader=r[e.fragmentShader],e.vertexShader=r[e.vertexShader]}),i.forEach(e=>{e.program=n[e.program]}),i}(r,t);for(const r of n.materials||[]){const n=t.getObjectExtension(r,md);n&&(r.technique=Object.assign({},n,e[n.technique]),r.technique.values=yd(r.technique,t)),t.removeObjectExtension(r,md)}t.removeExtension(md)}}async function vd(e,t){}function yd(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}var xd=[$c,jc,of,nf,df,lf,gf,Ff,ad,cd,pd,Qf,du];function _d(e,t){const n=t?.gltf?.excludeExtensions||{};return!(e in n&&!n[e])}var wd="KHR_binary_glTF";var Td={accessors:"accessor",animations:"animation",buffers:"buffer",bufferViews:"bufferView",images:"image",materials:"material",meshes:"mesh",nodes:"node",samplers:"sampler",scenes:"scene",skins:"skin",textures:"texture"},Sd={accessor:"accessors",animations:"animation",buffer:"buffers",bufferView:"bufferViews",image:"images",material:"materials",mesh:"meshes",node:"nodes",sampler:"samplers",scene:"scenes",skin:"skins",texture:"textures"},Md=class{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 void console.warn(`glTF: Unknown version ${n.asset.version}`)}if(!t.normalize)throw new Error("glTF v1 is not supported.");console.warn("Converting glTF v1 to glTF v2 format. This is experimental and may fail."),this._addAsset(n),this._convertTopLevelObjectsToArrays(n),function(e){const t=new Ec(e),{json:n}=t;for(const r of n.images||[]){const e=t.getObjectExtension(r,wd);e&&Object.assign(r,e),t.removeObjectExtension(r,wd)}n.buffers&&n.buffers[0]&&delete n.buffers[0].uri,t.removeExtension(wd)}(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 Td)this._convertTopLevelObjectToArray(e,t)}_convertTopLevelObjectToArray(e,t){const n=e[t];if(n&&!Array.isArray(n)){e[t]=[];for(const r in n){const i=n[r];i.id=i.id||r;const a=e[t].length;e[t].push(i),this.idToIndexMap[t][r]=a}}}_convertObjectIdsToArrayIndices(e){for(const t in Td)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:r}=t;for(const t in e)e[t]=this._convertIdToIndex(e[t],"accessor");n&&(t.indices=this._convertIdToIndex(n,"accessor")),r&&(t.material=this._convertIdToIndex(r,"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]||(console.warn(`gltf v1: json doesn't contain attribute ${t}`),e[t]=[]);for(const n of e[t])for(const e in n){const t=n[e];n[e]=this._convertIdToIndex(t,e)}}_convertIdToIndex(e,t){const n=Sd[t];if(n in this.idToIndexMap){const r=this.idToIndexMap[n][e];if(!Number.isFinite(r))throw new Error(`gltf v1: failed to resolve ${t} with id ${e}`);return r}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,r=e.textures.findIndex(e=>e.id===n);-1!==r&&(t.pbrMetallicRoughness.baseColorTexture={index:r})}}};async function Ed(e,t,n=0,r,i){return function(e,t,n,r){r.core?.baseUrl&&(e.baseUri=r.core?.baseUrl);t instanceof ArrayBuffer&&!function(e,t=0,n={}){const r=new DataView(e),{magic:i=Wu}=n,a=r.getUint32(t,!1);return a===i||a===Wu}(t,n,r.glb)&&(t=(new TextDecoder).decode(t));if("string"==typeof t)e.json=d(t);else if(t instanceof ArrayBuffer){const i={};n=Yu(i,t,n,r.glb),pc("glTF"===i.type,`Invalid GLB magic string ${i.type}`),e._glb=i,e.json=i.json}else pc(!1,"GLTF: must be ArrayBuffer or string");const i=e.json.buffers||[];if(e.buffers=new Array(i.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 a=e.json.images||[];e.images=new Array(a.length).fill({})}(e,t,n,r),function(e,t={}){(new Md).normalize(e,t)}(e,{normalize:r?.gltf?.normalize}),await async function(e,t={},n){const r=xd.filter(e=>_d(e.name,t));for(const i of r)await(i.preprocess?.(e,t,n))}(e,r,i),r?.gltf?.loadBuffers&&e.json.buffers&&await async function(e,t,n){const r=e.json.buffers||[];for(let i=0;i<r.length;++i){const a=r[i];if(a.uri){const{fetch:r}=n;pc(r);const o=ef(a.uri,t,n),s=await((await(n?.fetch?.(o)))?.arrayBuffer?.());e.buffers[i]={arrayBuffer:s,byteOffset:0,byteLength:s.byteLength},delete a.uri}else null===e.buffers[i]&&(e.buffers[i]={arrayBuffer:new ArrayBuffer(a.byteLength),byteOffset:0,byteLength:a.byteLength})}}(e,r,i),r?.gltf?.loadImages&&await async function(e,t,n){const r=function(e){const t=new Set,n=e.json.textures||[];for(const r of n)void 0!==r.source&&t.add(r.source);return Array.from(t).sort()}(e),i=e.json.images||[],a=[];for(const o of r)a.push(Cd(e,i[o],o,t,n));return await Promise.all(a)}(e,r,i),await async function(e,t={},n){const r=xd.filter(e=>_d(e.name,t));for(const i of r)await(i.decode?.(e,t,n))}(e,r,i),e}async function Cd(e,t,i,a,o){let A;if(t.uri&&!t.hasOwnProperty("bufferView")){const e=ef(t.uri,a,o),{fetch:n}=o;A=await(await n(e)).arrayBuffer(),t.bufferView={data:A}}if(Number.isFinite(t.bufferView)){const r=function(e,t,n){const r=e.bufferViews[n];pc(r);const i=t[r.buffer];pc(i);const a=(r.byteOffset||0)+i.byteOffset;return new Uint8Array(i.arrayBuffer,a,r.byteLength)}(e.json,e.buffers,t.bufferView);A=n.sliceArrayBuffer(r.buffer,r.byteOffset,r.byteLength)}pc(A,"glTF image has no data");const l=function(e,t){const n=e.basis,r=n?.format;return{...e,core:{...e.core,mimeType:t},basis:{...n,format:r&&"auto"!==r?r:Hu(n?.supportedTextureFormats)}}}(a,t.mimeType);let c=await s(A,[r.ImageLoader,Qu],l,o);c&&c[0]&&(c={compressed:!0,mipmaps:!1,width:c[0].width,height:c[0].height,data:c[0]}),e.images=e.images||[],e.images[i]=c}var Id={dataType:null,batchType:null,name:"glTF",id:"gltf",module:"gltf",version:"4.5.4",extensions:["gltf","glb"],mimeTypes:["model/gltf+json","model/gltf-binary"],text:!0,binary:!0,tests:["glTF"],parse:async function(e,t={},n){const r={...Id.options,...t};r.gltf={...Id.options.gltf,...r.gltf};const i=t?.glb?.byteOffset||0;return await Ed({},e,i,r,n)},options:{gltf:{normalize:!0,loadBuffers:!0,loadImages:!0,decompressMeshes:!0}}};var Rd={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Pd={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},Nd=10240,kd=10241,Ld=10242,Bd=10243,Od=10497,Fd=9729,Dd=9986,Ud={magFilter:Nd,minFilter:kd,wrapS:Ld,wrapT:Bd},Vd={[Nd]:Fd,[kd]:Dd,[Ld]:Od,[Bd]:Od};var jd=class{baseUri="";jsonUnprocessed;json;buffers=[];images=[];postProcess(e,t={}){const{json:n,buffers:r=[],images:i=[]}=e,{baseUri:a=""}=e;return pc(n),this.baseUri=a,this.buffers=r,this.images=i,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||console.warn(`glTF file error: Could not find ${e}[${t}]`),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,t)=>{const r={...e,attributes:{},indices:void 0,material:void 0},i=e.attributes;for(const n in i)r.attributes[n]=this.getAccessor(i[n]);return void 0!==e.indices&&(r.indices=this.getAccessor(e.indices)),void 0!==e.material&&(r.material=this.getMaterial(e.material)),function(e,t,n){if(2!==e.mode&&6!==e.mode)return e;const r=e.indices?.value,i=e.indices?.count??function(e){const t=Object.values(e.attributes)[0];return pc(t,"glTF primitive must define at least one attribute"),t.count}(e),a=function(e,t){if(!e)return Math.max(0,t-1);let n=0;for(let r=0;r<t;r++)n=Math.max(n,Number(e[r]));return n}(r,i),o=a<=65535?Uint16Array:Uint32Array,s=2===e.mode?function(e,t,n){if(t<2)return new n(0);const r=new n(2*t);for(let i=0;i<t;i++)r[2*i]=Gd(e,i),r[2*i+1]=Gd(e,(i+1)%t);return r}(r,i,o):function(e,t,n){const r=Math.max(0,t-2),i=new n(3*r);for(let a=0;a<r;a++)i[3*a]=Gd(e,0),i[3*a+1]=Gd(e,a+1),i[3*a+2]=Gd(e,a+2);return i}(r,i,o);return e.mode=2===e.mode?1:4,e.indices={id:`${t}-primitive-${n}-portable-indices`,components:1,bytesPerComponent:o.BYTES_PER_ELEMENT,bytesPerElement:o.BYTES_PER_ELEMENT,componentType:o===Uint16Array?5123:5125,normalized:!1,count:s.length,type:"SCALAR",min:s.length?[zd(s)]:void 0,max:s.length?[a]:void 0,value:s},e}(r,n.id,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 r=(i=e.componentType,Pd[i]);var i;const a=(o=e.type,Rd[o]);var o;const s=r*a,A={...e,id:e.id||`accessor-${t}`,bytesPerComponent:r,components:a,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:r}=Sc(A,A.bufferView),i=(A.bufferView.byteOffset||0)+(A.byteOffset||0)+e.byteOffset;let a=n.copyToArrayBuffer(e.arrayBuffer,i,r);A.bufferView.byteStride&&(a=this._getValueFromInterleavedBuffer(e,i,A.bufferView.byteStride,A.bytesPerElement,A.count)),A.value=new t(a)}else{const{ArrayType:e}=Sc(A,{byteLength:A.count*A.bytesPerElement});A.value=new e(A.count*A.components)}return e.sparse&&this._applySparseAccessor(A,e.sparse),A}_applySparseAccessor(e,t){const n=function(e){switch(e){case 5121:return Uint8Array;case 5123:return Uint16Array;case 5125:return Uint32Array;default:throw new Error(`Invalid glTF sparse index component type ${e}`)}}(t.indices.componentType),r=this._getTypedArrayFromBufferView(n,this.getBufferView(t.indices.bufferView),t.indices.byteOffset||0,t.count),i=e.value.constructor,a=this._getTypedArrayFromBufferView(i,this.getBufferView(t.values.bufferView),t.values.byteOffset||0,t.count*e.components);for(let o=0;o<t.count;o++){const t=Number(r[o]);pc(Number.isInteger(t)&&t>=0&&t<e.count,"glTF sparse accessor index is out of bounds");for(let n=0;n<e.components;n++){const r=t*e.components+n,i=o*e.components+n;Reflect.set(e.value,r,a[i])}}}_getTypedArrayFromBufferView(e,t,r,i){const a=i*e.BYTES_PER_ELEMENT;pc(r+a<=t.byteLength,"glTF sparse accessor data exceeds its buffer view");const o=t.buffer,s=o.byteOffset+(t.byteOffset||0)+r;return new e(n.copyToArrayBuffer(o.arrayBuffer,s,a))}_getValueFromInterleavedBuffer(e,t,n,r,i){const a=new Uint8Array(i*r);for(let o=0;o<i;o++){const i=t+o*n;a.set(new Uint8Array(e.arrayBuffer.slice(i,i+r)),o*r)}return a.buffer}_resolveTexture(e,t){return{...e,id:e.id||`texture-${t}`,sampler:"number"==typeof e.sampler?this.getSampler(e.sampler):{id:"default-sampler",parameters:Vd},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 r in n){const e=this._enumSamplerParameter(r);void 0!==e&&(n.parameters[e]=n[r])}return n}_enumSamplerParameter(e){return Ud[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},r=this.images[t];return r&&(n.image=r),n}_resolveBufferView(e,t){const n=e.buffer,r=this.buffers[n].arrayBuffer;let i=this.buffers[n].byteOffset||0;return e.byteOffset&&(i+=e.byteOffset),{id:`bufferView-${t}`,...e,buffer:this.buffers[n],data:new Uint8Array(r,i,e.byteLength)}}_resolveCamera(e,t){const n={...e,id:e.id||`camera-${t}`};return n.perspective,n.orthographic,n}};function zd(e){let t=1/0;for(const n of e)t=Math.min(t,n);return t}function Gd(e,t){return e?Number(e[t]):t}function Hd(e,t){return(new jd).postProcess(e,t)}async function qd(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))}var Qd="layout(std140) uniform scenegraphUniforms {\n float sizeScale;\n float sizeMinPixels;\n float sizeMaxPixels;\n mat4 sceneModelMatrix;\n float composeModelMatrix;\n} scenegraph;\n",Kd={name:"scenegraph",source:"struct ScenegraphUniforms {\n sizeScale: f32,\n sizeMinPixels: f32,\n sizeMaxPixels: f32,\n sceneModelMatrix: mat4x4<f32>,\n composeModelMatrix: f32,\n};\n\n@group(0) @binding(auto)\nvar<uniform> scenegraph: ScenegraphUniforms;\n",vs:Qd,fs:Qd,uniformTypes:{sizeScale:"f32",sizeMinPixels:"f32",sizeMaxPixels:"f32",sceneModelMatrix:"mat4x4<f32>",composeModelMatrix:"f32"}},Wd=G.source.replace(/fn pbr_setPositionNormalTangentUV\([\s\S]*?\n}\n/,"fn pbr_setPositionNormalTangentUV(position: vec4f, normal: vec4f, tangent: vec4f, uv: vec2f)\n{\n fragmentInputs.pbr_vPosition = position.xyz;\n fragmentInputs.pbr_vNormal = normal.xyz;\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 = uv;\n fragmentInputs.pbr_vUV1 = uv;\n}\n").replace(/pbrProjection\.camera/g,"project.cameraPosition"),$d={...G,dependencies:[t.lighting],source:Wd},Jd=[255,255,255,255],Yd={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:Jd},_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:[Id]},Xd=class extends t.Layer{getShaders(){const e={};let n;const r="webgpu"===this.context.device?.type;"pbr"===this.props._lighting?(n=r?$d:G,e.LIGHTING_PBR=1):n=r?$d:{name:"pbrMaterial"};const i=[t.project32_default,t.color_default,t.picking_default,Kd,n];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 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 = picking_getPickingColorFromInstanceID();\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);\nfloat sizeRatio = originalSize == 0.0 ? 0.0 : clampedSize / originalSize;\nvec3 pos = (instanceModelMatrix * (scenegraph.sceneModelMatrix * vec4(positions, 1.0)).xyz) * scenegraph.sizeScale * sizeRatio + instanceTranslation;\nif(scenegraph.composeModelMatrix > 0.5) {\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 = pbr_filterColor(vColor);\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",source:"struct VertexInputs {\n @location(0) positions: vec3<f32>,\n#ifdef HAS_NORMALS\n @location(1) normals: vec3<f32>,\n#endif\n#ifdef HAS_UV\n @location(3) texCoords: vec2<f32>,\n#endif\n @location(6) instancePositions: vec3<f32>,\n @location(7) instancePositions64Low: vec3<f32>,\n @location(8) instanceColors: vec4<f32>,\n @location(10) instanceModelMatrixCol0: vec3<f32>,\n @location(11) instanceModelMatrixCol1: vec3<f32>,\n @location(12) instanceModelMatrixCol2: vec3<f32>,\n @location(13) instanceTranslation: vec3<f32>,\n};\n\nstruct FragmentInputs {\n @builtin(position) position: vec4<f32>,\n @location(0) vColor: vec4<f32>,\n @location(1) vTexCoord: vec2<f32>,\n @location(2) pbrPosition: vec3<f32>,\n @location(3) pbrUV: vec2<f32>,\n @location(4) pbrNormal: vec3<f32>,\n @location(5) pickingColor: vec3<f32>,\n};\n\n@vertex\nfn vertexMain(\n inputs: VertexInputs,\n @builtin(instance_index) instanceIndex: u32\n) -> FragmentInputs {\n var outputs: FragmentInputs;\n\n geometry.worldPosition = inputs.instancePositions;\n geometry.pickingColor = picking_getPickingColorFromIndex(instanceIndex);\n\n var vertexPosition = inputs.positions;\n var texCoord = vec2<f32>(0.0, 0.0);\n var normal = vec3<f32>(0.0, 0.0, 1.0);\n\n#ifdef HAS_UV\n texCoord = inputs.texCoords;\n#endif\n#ifdef HAS_NORMALS\n normal = inputs.normals;\n#endif\n\n geometry.uv = texCoord;\n\n let instanceModelMatrix = mat3x3<f32>(\n inputs.instanceModelMatrixCol0,\n inputs.instanceModelMatrixCol1,\n inputs.instanceModelMatrixCol2\n );\n\n let scenePosition = (scenegraph.sceneModelMatrix * vec4<f32>(vertexPosition, 1.0)).xyz;\n let worldNormal = instanceModelMatrix * (scenegraph.sceneModelMatrix * vec4<f32>(normal, 0.0)).xyz;\n\n let originalSize = project_meter_size_to_pixel(scenegraph.sizeScale);\n let clampedSize = clamp(originalSize, scenegraph.sizeMinPixels, scenegraph.sizeMaxPixels);\n let sizeRatio = select(0.0, clampedSize / originalSize, originalSize > 0.0);\n\n let pos =\n (instanceModelMatrix * scenePosition) * scenegraph.sizeScale * sizeRatio +\n inputs.instanceTranslation;\n\n if (scenegraph.composeModelMatrix > 0.5) {\n geometry.normal = project_normal(worldNormal);\n geometry.worldPosition = inputs.instancePositions + pos;\n geometry.position = vec4<f32>(\n project_position_vec3_f64(inputs.instancePositions + pos, inputs.instancePositions64Low),\n 1.0\n );\n } else {\n let sizeAdjustedPos = project_size_vec3(pos);\n // Scenegraph offsets are east/north/up in globe mode. Use project32's helper so it can\n // rotate the offset onto the local tangent plane before producing the common position.\n let projectResult = project_position_to_clipspace_and_commonspace(\n inputs.instancePositions,\n inputs.instancePositions64Low,\n sizeAdjustedPos\n );\n geometry.position = projectResult.commonPosition;\n geometry.normal = project_normal(worldNormal);\n }\n\n outputs.position = project_common_position_to_clipspace(geometry.position);\n outputs.vColor = inputs.instanceColors;\n outputs.vTexCoord = texCoord;\n outputs.pbrPosition = geometry.position.xyz;\n outputs.pbrUV = texCoord;\n outputs.pbrNormal = geometry.normal;\n outputs.pickingColor = geometry.pickingColor;\n return outputs;\n}\n\n@fragment\nfn fragmentMain(inputs: FragmentInputs) -> @location(0) vec4<f32> {\n fragmentGeometry.uv = inputs.vTexCoord;\n\n if (picking.isActive > 0.5) {\n if (!picking_isColorValid(inputs.pickingColor)) {\n discard;\n }\n return vec4<f32>(inputs.pickingColor, 1.0);\n }\n\n var fragColor = inputs.vColor;\n\n#ifdef LIGHTING_PBR\n fragmentInputs.pbr_vPosition = inputs.pbrPosition;\n // scenegraphPbrMaterial uses the indexed UV fields from the current PBR module.\n fragmentInputs.pbr_vUV0 = inputs.pbrUV;\n fragmentInputs.pbr_vUV1 = vec2<f32>(0.0);\n fragmentInputs.pbr_vNormal = inputs.pbrNormal;\n // Vertex color is part of the material base color and must be applied before lighting.\n fragColor = pbr_filterColor(fragColor);\n#else\n#ifdef HAS_BASECOLORMAP\n fragColor =\n fragColor *\n textureSample(pbr_baseColorSampler, pbr_baseColorSamplerSampler, inputs.vTexCoord);\n#endif\n#endif\n\n fragColor.a *= layer.opacity;\n\n if (picking.isHighlightActive > 0.5) {\n let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);\n if (picking_isColorZero(abs(inputs.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 }\n }\n }\n\n return deckgl_premultiplied_alpha(fragColor);\n}\n",modules:i})}initializeState(){const e=this.getAttributeManager(),t="webgpu"!==this.context.device.type;e.addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),accessor:"getPosition",transition:t},instanceColors:{type:"unorm8",size:this.props.colorFormat.length,accessor:"getColor",defaultValue:Jd,transition:t},instanceModelMatrix:JA})}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 r=null;if(e.scenegraph instanceof Ie)r={scenes:[e.scenegraph]};else if(e.scenegraph&&"object"==typeof e.scenegraph){const n=e.scenegraph,i=fc(t,n.json?Hd(n):n,this._getModelOptions());r=i,qd(i).then(()=>this.setNeedsRedraw()).catch(e=>{this.raiseError(e,"loading glTF")})}const i={layer:this,device:this.context.device},a=e.getScene(r,i),o=e.getAnimator(r,i);if(a instanceof Ne){this._destroyScenegraphAssets(),this._applyAnimationsProp(o,e._animations);const t=[];a.traverse(e=>{e instanceof ke&&t.push(e.model)}),this.setState({scenegraph:a,animator:o,materials:r?.materials||null,models:t,firstDrawSignaled:!1}),this.getAttributeManager().invalidateAll()}else null!==a&&n.defaultLogger.warn("invalid scenegraph:",a)()}_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 r=e.getAnimations();Object.keys(t).sort().forEach(e=>{const i=t[e];if("*"===e)r.forEach(e=>{Object.assign(e,i)});else if(Number.isFinite(Number(e))){const t=Number(e);t>=0&&t<r.length?Object.assign(r[t],i):n.defaultLogger.warn(`animation ${e} not found`)()}else{const t=r.find(({animation:t})=>t.name===e);t?Object.assign(t,i):n.defaultLogger.warn(`animation ${e} not found`)()}})}_getModelOptions(){const{_imageBasedLightingEnvironment:e}=this.props;let t;e&&(t="function"==typeof e?e({device:this.context.device,gl:this.context.gl,layer:this}):e);const n="webgpu"===this.context.device.type?{depthWriteEnabled:!0,depthCompare:"less-equal"}:void 0;return{imageBasedLightingEnvironment:t,modelOptions:{id:this.props.id,isInstanced:!0,bufferLayout:this.getAttributeManager().getBufferLayouts(),parameters:n,...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:r,sizeMinPixels:i,sizeMaxPixels:a,coordinateSystem:o}=this.props,s={camera:t.cameraPosition},A=this.getNumInstances();this.state.scenegraph.traverse((e,{worldMatrix:l})=>{if(e instanceof ke){const{model:c}=e;c.setInstanceCount(A);const u={sizeScale:r,sizeMinPixels:i,sizeMaxPixels:a,composeModelMatrix:YA(t,o)?1:0,sceneModelMatrix:l};c.shaderInputs.setProps({pbrProjection:s,scenegraph:u}),c.draw(n)}}),this.state.firstDrawSignaled||(this.state.firstDrawSignaled=!0,this.props.onFirstDraw?.())}};Xd.defaultProps=Yd,Xd.layerName="ScenegraphLayer";var Zd="layout(std140) uniform meshUniforms {\n bool pickFeatureIds;\n} mesh;\n",eh={name:"mesh",vs:Zd,fs:Zd,source:"struct MeshUniforms {\n pickFeatureIds: f32,\n};\n\n@group(0) @binding(auto) var<uniform> mesh: MeshUniforms;\n",uniformTypes:{pickFeatureIds:"f32"}},th=G.source.replace(/fn pbr_setPositionNormalTangentUV\([\s\S]*?\n}\n/,"fn pbr_setPositionNormalTangentUV(position: vec4f, normal: vec4f, tangent: vec4f, uv: vec2f)\n{\n fragmentInputs.pbr_vPosition = position.xyz;\n fragmentInputs.pbr_vNormal = normal.xyz;\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 = uv;\n fragmentInputs.pbr_vUV1 = uv;\n}\n").replace(/pbrProjection\.camera/g,"project.cameraPosition"),nh={...G,source:th};var rh=class extends nl{getShaders(){const e=super.getShaders();return{...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 float rowIndexes;\nin vec4 instanceColors;\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 = picking_getPickingColorFromIndex(rowIndexes);\n} else {\ngeometry.pickingColor = picking_getPickingColorFromInstanceID();\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",source:"struct VertexInputs {\n @location(0) positions: vec3<f32>,\n#ifdef HAS_NORMALS\n @location(1) normals: vec3<f32>,\n#endif\n @location(2) colors: vec4<f32>,\n#ifdef HAS_UV\n @location(3) texCoords: vec2<f32>,\n#endif\n#ifdef HAS_UV_REGIONS\n @location(4) uvRegions: vec4<f32>,\n#endif\n#ifdef HAS_FEATURE_IDS\n @location(5) rowIndexes: u32,\n#endif\n @location(6) instanceColors: vec4<f32>,\n @location(7) instanceModelMatrixCol0: vec3<f32>,\n @location(8) instanceModelMatrixCol1: vec3<f32>,\n @location(9) instanceModelMatrixCol2: vec3<f32>,\n};\n\nstruct FragmentInputs {\n @builtin(position) position: vec4<f32>,\n @location(0) color: vec4<f32>,\n @location(1) texCoord: vec2<f32>,\n @location(2) pbrPosition: vec3<f32>,\n @location(3) pbrNormal: vec3<f32>,\n @location(4) pickingColor: vec3<f32>,\n};\n\nfn applyUVRegion(uv: vec2<f32>, uvRegion: vec4<f32>) -> vec2<f32> {\n#ifdef HAS_UV_REGIONS\n // https://github.com/Esri/i3s-spec/blob/master/docs/1.7/geometryUVRegion.cmn.md\n return fract(uv) * (uvRegion.zw - uvRegion.xy) + uvRegion.xy;\n#else\n return uv;\n#endif\n}\n\n@vertex\nfn vertexMain(\n inputs: VertexInputs,\n @builtin(instance_index) instanceIndex: u32\n) -> FragmentInputs {\n var outputs: FragmentInputs;\n var texCoord = vec2<f32>(0.0);\n var normal = vec3<f32>(0.0, 0.0, 1.0);\n var uvRegion = vec4<f32>(0.0);\n\n#ifdef HAS_UV\n texCoord = inputs.texCoords;\n#endif\n#ifdef HAS_NORMALS\n normal = inputs.normals;\n#endif\n#ifdef HAS_UV_REGIONS\n uvRegion = inputs.uvRegions;\n#endif\n\n texCoord = applyUVRegion(texCoord, uvRegion);\n geometry.uv = texCoord;\n#ifdef HAS_FEATURE_IDS\n geometry.pickingColor = picking_getPickingColorFromIndex(inputs.rowIndexes);\n#else\n geometry.pickingColor = picking_getPickingColorFromIndex(instanceIndex);\n#endif\n\n let instanceModelMatrix = mat3x3<f32>(\n inputs.instanceModelMatrixCol0,\n inputs.instanceModelMatrixCol1,\n inputs.instanceModelMatrixCol2\n );\n let commonPosition = vec4<f32>(project_position_vec3_f32(inputs.positions), 1.0);\n\n geometry.position = commonPosition;\n geometry.normal = project_normal(instanceModelMatrix * normal);\n\n outputs.position = project_common_position_to_clipspace(commonPosition);\n outputs.color = vec4<f32>(\n inputs.colors.rgb * inputs.instanceColors.rgb,\n inputs.instanceColors.a\n );\n outputs.texCoord = texCoord;\n outputs.pbrPosition = commonPosition.xyz;\n outputs.pbrNormal = geometry.normal;\n outputs.pickingColor = geometry.pickingColor;\n return outputs;\n}\n\n@fragment\nfn fragmentMain(inputs: FragmentInputs) -> @location(0) vec4<f32> {\n fragmentGeometry.uv = inputs.texCoord;\n\n if (picking.isActive > 0.5) {\n if (!picking_isColorValid(inputs.pickingColor)) {\n discard;\n }\n return vec4<f32>(inputs.pickingColor, 1.0);\n }\n\n fragmentInputs.pbr_vPosition = inputs.pbrPosition;\n fragmentInputs.pbr_vUV0 = inputs.texCoord;\n fragmentInputs.pbr_vUV1 = vec2<f32>(0.0);\n fragmentInputs.pbr_vNormal = inputs.pbrNormal;\n\n var color = inputs.color * pbr_filterColor(vec4<f32>(0.0));\n color.a *= layer.opacity;\n\n if (picking.isHighlightActive > 0.5) {\n let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);\n if (picking_isColorZero(abs(inputs.pickingColor - highlightedObjectColor))) {\n let highlightAlpha = picking.highlightColor.a;\n let blendedAlpha = highlightAlpha + color.a * (1.0 - highlightAlpha);\n if (blendedAlpha > 0.0) {\n color = vec4<f32>(\n mix(color.rgb, picking.highlightColor.rgb, highlightAlpha / blendedAlpha),\n blendedAlpha\n );\n }\n }\n }\n\n return deckgl_premultiplied_alpha(color);\n}\n",modules:[...e.modules,nh,eh]}}initializeState(){const{featureIds:e}=this.props;super.initializeState();const t=this.getAttributeManager();e&&t.add({rowIndexes:{type:"uint32",size:1,noAlloc:!0,update:this.calculateFeatureIdsPickingIndexes}})}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 r={pickFeatureIds:Boolean(t)},i={camera:this.context.viewport.cameraPosition};n.shaderInputs.setProps({pbrProjection:i,mesh:r}),super.draw(e)}getModel(e){const{id:n}=this.props,r=this.parseMaterial(this.props.pbrMaterial,e);this.setState({parsedPBRMaterial:r});const i=this.getShaders();return 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),new t.Model(this.context.device,{...this.getShaders(),id:n,geometry:e,bufferLayout:this.getAttributeManager().getBufferLayouts(),defines:{...i.defines,...r?.defines,HAS_UV_REGIONS:e.attributes.uvRegions?1:0,HAS_FEATURE_IDS:this.props.featureIds?1:0},parameters:r?.parameters,isInstanced:!0})}updatePbrMaterialUniforms(e){const{model:t}=this.state;if(t){const{mesh:n}=this.props,r=this.parseMaterial(e,n);this.setState({parsedPBRMaterial:r});const{pbr_baseColorSampler:i}=r.bindings,{emptyTexture:a}=this.state,o=i||a,s={..."webgpu"===this.context.device.type?{simpleMeshTexture:o}:{sampler:o},hasTexture:Boolean(i)},{camera:A,...l}={...r.bindings,...r.uniforms};t.shaderInputs.setProps({simpleMesh:s,pbrMaterial:l})}}parseMaterial(e,t){const n=Boolean(e.pbrMetallicRoughness&&e.pbrMetallicRoughness.baseColorTexture);return wl(this.context.device,{unlit:n,...e},{NORMAL:t.attributes.normals,TEXCOORD_0:t.attributes.texCoords},{pbrDebug:!1,lights:!0,useTangents:!1})}calculateFeatureIdsPickingIndexes(e){const t=this.props.featureIds;e.value=new Uint32Array(t)}finalizeState(e){super.finalizeState(e),this.state.parsedPBRMaterial?.generatedTextures.forEach(e=>e.destroy()),this.setState({parsedPBRMaterial:null})}};rh.layerName="MeshLayer",rh.defaultProps={pbrMaterial:{type:"object",value:null},featureIds:{type:"array",value:null,optional:!0}};var ih=6378137,ah=6378137,oh=6356752.314245179;Math.max(ih,ah,oh);function sh(e){return e}new n.Vector3;function Ah(e,t=[]){return function(e,t=[],n=sh){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,n.config._cartographicRadians?sh:n.toRadians)}function lh(e,t){return function(e,t,n=sh){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,n.config._cartographicRadians?sh:n.toDegrees)}var ch=new n.Vector3,uh={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"}},fh={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},dh={east:new n.Vector3,north:new n.Vector3,up:new n.Vector3,west:new n.Vector3,south:new n.Vector3,down:new n.Vector3},hh=new n.Vector3,ph=new n.Vector3,mh=new n.Vector3;function gh(e,t,r,i,a,o){const s=uh[t]&&uh[t][r];let A,l,c;n.assert$1(s&&(!i||i===s));const u=ch.copy(a);if(n.equals(u.x,0,1e-14)&&n.equals(u.y,0,1e-14)){const e=Math.sign(u.z);A=hh.fromArray(fh[t]),"east"!==t&&"west"!==t&&A.scale(e),l=ph.fromArray(fh[r]),"east"!==r&&"west"!==r&&l.scale(e),c=mh.fromArray(fh[i]),"east"!==i&&"west"!==i&&c.scale(e)}else{const{up:n,east:a,north:o}=dh;a.set(-u.y,u.x,0).normalize(),e.geodeticSurfaceNormal(u,n),o.copy(n).cross(a);const{down:s,west:f,south:d}=dh;s.copy(n).scale(-1),f.copy(a).scale(-1),d.copy(o).scale(-1),A=dh[t],l=dh[r],c=dh[i]}return o[0]=A.x,o[1]=A.y,o[2]=A.z,o[3]=0,o[4]=l.x,o[5]=l.y,o[6]=l.z,o[7]=0,o[8]=c.x,o[9]=c.y,o[10]=c.z,o[11]=0,o[12]=u.x,o[13]=u.y,o[14]=u.z,o[15]=1,o}var bh=new n.Vector3,vh=new n.Vector3,yh=new n.Vector3;var xh=new n.Vector3,_h=new n.Vector3,wh=new n.Vector3,Th=new n.Vector3,Sh=new n.Vector3,Mh=new n.Vector3,Eh=class{constructor(e=0,t=0,r=0){this.centerToleranceSquared=.1,n.assert$1(e>=0),n.assert$1(t>=0),n.assert$1(r>=0),this.radii=new n.Vector3(e,t,r),this.radiiSquared=new n.Vector3(e*e,t*t,r*r),this.radiiToTheFourth=new n.Vector3(e*e*e*e,t*t*t*t,r*r*r*r),this.oneOverRadii=new n.Vector3(0===e?0:1/e,0===t?0:1/t,0===r?0:1/r),this.oneOverRadiiSquared=new n.Vector3(0===e?0:1/(e*e),0===t?0:1/(t*t),0===r?0:1/(r*r)),this.minimumRadius=Math.min(e,t,r),this.maximumRadius=Math.max(e,t,r),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=_h,r=wh,[,,i]=e;this.geodeticSurfaceNormalCartographic(e,n),r.copy(this.radiiSquared).scale(n);const a=Math.sqrt(n.dot(r));return r.scale(1/a),n.scale(i),r.add(n),r.to(t)}cartesianToCartographic(e,t=[0,0,0]){Mh.from(e);const r=this.scaleToGeodeticSurface(Mh,Th);if(!r)return;const i=this.geodeticSurfaceNormal(r,_h),a=Sh;a.copy(Mh).subtract(r);return lh([Math.atan2(i.y,i.x),Math.asin(i.z),Math.sign(n.dot$1(a,Mh))*n.length$1(a)],t)}eastNorthUpToFixedFrame(e,t=new n.Matrix4){return gh(this,"east","north","up",e,t)}localFrameToFixedFrame(e,t,r,i,a=new n.Matrix4){return gh(this,e,t,r,i,a)}geocentricSurfaceNormal(e,t=[0,0,0]){return xh.from(e).normalize().to(t)}geodeticSurfaceNormalCartographic(e,t=[0,0,0]){const n=Ah(e),r=n[0],i=n[1],a=Math.cos(i);return xh.set(a*Math.cos(r),a*Math.sin(r),Math.sin(i)).normalize(),xh.to(t)}geodeticSurfaceNormal(e,t=[0,0,0]){return xh.from(e).scale(this.oneOverRadiiSquared).normalize().to(t)}scaleToGeodeticSurface(e,t){return function(e,t,n=[]){const{oneOverRadii:r,oneOverRadiiSquared:i,centerToleranceSquared:a}=t;bh.from(e);const o=bh.x,s=bh.y,A=bh.z,l=r.x,c=r.y,u=r.z,f=o*o*l*l,d=s*s*c*c,h=A*A*u*u,p=f+d+h,m=Math.sqrt(1/p);if(!Number.isFinite(m))return;const g=vh;if(g.copy(e).scale(m),p<a)return g.to(n);const b=i.x,v=i.y,y=i.z,x=yh;x.set(g.x*b*2,g.y*v*2,g.z*y*2);let _,w,T,S,M=(1-m)*bh.len()/(.5*x.len()),E=0;do{M-=E,_=1/(1+M*b),w=1/(1+M*v),T=1/(1+M*y);const e=_*_,t=w*w,n=T*T;S=f*e+d*t+h*n-1,E=S/(-2*(f*(e*_)*b+d*(t*w)*v+h*(n*T)*y))}while(Math.abs(S)>1e-12);return bh.scale([_,w,T]).to(n)}(e,this,t)}scaleToGeocentricSurface(e,t=[0,0,0]){Th.from(e);const n=Th.x,r=Th.y,i=Th.z,a=this.oneOverRadiiSquared,o=1/Math.sqrt(n*n*a.x+r*r*a.y+i*i*a.z);return Th.multiplyScalar(o).to(t)}transformPositionToScaledSpace(e,t=[0,0,0]){return Th.from(e).scale(this.oneOverRadii).to(t)}transformPositionFromScaledSpace(e,t=[0,0,0]){return Th.from(e).scale(this.radii).to(t)}getSurfaceNormalIntersectionWithZAxis(e,t=0,r=[0,0,0]){n.assert$1(n.equals(this.radii.x,this.radii.y,1e-15)),n.assert$1(this.radii.z>0),Th.from(e);const i=Th.z*(1-this.squaredXOverSquaredZ);if(!(Math.abs(i)>=this.radii.z-t))return Th.set(0,0,i).to(r)}};Eh.WGS84=new Eh(ih,ah,oh);var Ch=class{item;previous;next;constructor(e,t,n){this.item=e,this.previous=t,this.next=n}},Ih=class{head=null;tail=null;_length=0;get length(){return this._length}add(e){const t=new Ch(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}},Rh=class{_list;_sentinel;_trimTiles;constructor(){this._list=new Ih,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 r=t._cacheNode;r&&(this._list.remove(r),t._cacheNode=null,n&&n(e,t))}unloadTiles(e,t){const n=this._trimTiles;this._trimTiles=!1;const r=this._list,i=1024*e.maximumMemoryUsage*1024,a=this._sentinel;let o=r.head;for(;o!==a&&(e.gpuMemoryUsageInBytes>i||n);){const n=o.item;o=o.next,this.unloadTile(e,n,t)}}trim(){this._trimTiles=!0}};function Ph(e,t){n.assert$3(e),n.assert$3(t);const{rtcCenter:r,gltfUpAxis:i}=t,{computedTransform:a,boundingVolume:{center:o}}=e;let s=new n.Matrix4(a);switch(r&&s.translate(r),i){case"Z":break;case"Y":const e=(new n.Matrix4).rotateX(Math.PI/2);s=s.multiplyRight(e);break;case"X":const t=(new n.Matrix4).rotateY(-Math.PI/2);s=s.multiplyRight(t)}t.isQuantized&&s.translate(t.quantizedVolumeOffset).scale(t.quantizedVolumeScale);const A=new n.Vector3(o);t.cartesianModelMatrix=s,t.cartesianOrigin=A;const l=Eh.WGS84.cartesianToCartographic(A,new n.Vector3);t.cartographicModelMatrix=Eh.WGS84.eastNorthUpToFixedFrame(A).invert().multiplyRight(s),t.cartographicOrigin=l;const c=function(e){const t=e.gltf;if(!t)return null;const n="number"==typeof t.scene?t.scene:0,r=(t.scenes?.[n])?.nodes?.[0];if(!r?.matrix)return null;const i=r.matrix;return i[12]*i[12]+i[13]*i[13]+i[14]*i[14]<=Nh?null:r}(t);c&&(t.cartesianModelMatrix=new n.Matrix4(s).multiplyRight(c.matrix),t.cartographicModelMatrix.multiplyRight(c.matrix),c.matrix=n.Matrix4.IDENTITY),t.coordinateSystem||(t.modelMatrix=t.cartographicModelMatrix)}var Nh=1e6**2;var kh=new n.Vector3,Lh=new n.Vector3,Bh=new js([new Fs,new Fs,new Fs,new Fs,new Fs,new Fs]);function Oh(e,t){const{cameraDirection:r,cameraUp:i,height:a}=e,{metersPerUnit:o}=e.distanceScales,s=Dh(e,e.center),A=Eh.WGS84.eastNorthUpToFixedFrame(s),l=e.unprojectPosition(e.cameraPosition),c=Eh.WGS84.cartographicToCartesian(l,new n.Vector3),u=new n.Vector3(A.transformAsVector(new n.Vector3(r).scale(o))).normalize(),f=new n.Vector3(A.transformAsVector(new n.Vector3(i).scale(o))).normalize();!function(e){const t=e.getFrustumPlanes(),n=Fh(t.near,e.cameraPosition),r=Dh(e,n),i=Dh(e,e.cameraPosition,Lh);let a=0;Bh.planes[a++].fromPointNormal(r,kh.copy(r).subtract(i));for(const o in t){if("near"===o)continue;const i=Dh(e,Fh(t[o],n,Lh),Lh);Bh.planes[a++].fromPointNormal(i,kh.copy(r).subtract(i))}}(e);const d=e.constructor,{longitude:h,latitude:p,width:m,bearing:g,zoom:b}=e;return{camera:{position:c,direction:u,up:f},viewport:e,topDownViewport:new d({longitude:h,latitude:p,height:a,width:m,bearing:g,zoom:b,pitch:0}),height:a,cullingVolume:Bh,frameNumber:t,sseDenominator:1.15}}function Fh(e,t,r=new n.Vector3){const i=e.normal.dot(t);return r.copy(e.normal).scale(e.distance-i).add(t),r}function Dh(e,t,r=new n.Vector3){const i=e.unprojectPosition(t);return Eh.WGS84.cartographicToCartesian(i,r)}var Uh=6356752.314245179,Vh=new n.Vector3;function jh(e,t){if(e instanceof Ls){const{halfAxes:n}=e,r=function(e){e.getColumn(0,Vh);const t=e.getColumn(1),n=e.getColumn(2);return Vh.add(t).add(n).len()}(n);return Math.log2(Uh/(r+t[2]))}if(e instanceof gs){const{radius:n}=e;return Math.log2(Uh/(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 zh(e,t,n){Eh.WGS84.cartographicToCartesian([e.xmax,e.ymax,e.zmax],Vh);const r=Math.sqrt(Math.pow(Vh[0]-n[0],2)+Math.pow(Vh[1]-n[1],2)+Math.pow(Vh[2]-n[2],2));return Math.log2(Uh/(r+t[2]))}var Gh,Hh,qh,Qh,Kh=0,Wh=1,$h=3,Jh=4,Yh=5;!function(e){e[e.ADD=1]="ADD",e[e.REPLACE=2]="REPLACE"}(Gh||(Gh={})),function(e){e.EMPTY="empty",e.SCENEGRAPH="scenegraph",e.POINTCLOUD="pointcloud",e.MESH="mesh"}(Hh||(Hh={})),function(e){e.I3S="I3S",e.TILES3D="TILES3D"}(qh||(qh={})),function(e){e.GEOMETRIC_ERROR="geometricError",e.MAX_SCREEN_THRESHOLD="maxScreenThreshold"}(Qh||(Qh={}));var Xh=1;function Zh(e){return null!=e}var ep=new n.Vector3,tp=new n.Vector3,np=new n.Vector3,rp=new n.Vector3,ip=new n.Vector3,ap=new n.Vector3,op=new n.Vector3,sp=new n.Vector3;function Ap(e,t,r){if(n.assert$3(e,"3D Tile: boundingVolume must be defined"),e.box)return cp(e.box,t,r);if(e.region)return function(e){const[t,r,i,a,o,s]=e,A=Eh.WGS84.cartographicToCartesian([n.degrees(t),n.degrees(a),o],np),l=Eh.WGS84.cartographicToCartesian([n.degrees(i),n.degrees(r),s],rp),c=(new n.Vector3).addVectors(A,l).multiplyByScalar(.5);return Eh.WGS84.cartesianToCartographic(c,ip),Eh.WGS84.cartographicToCartesian([n.degrees(i),ip[1],ip[2]],ap),Eh.WGS84.cartographicToCartesian([ip[0],n.degrees(a),ip[2]],op),Eh.WGS84.cartographicToCartesian([ip[0],ip[1],s],sp),cp([...c,...ap.subtract(c),...op.subtract(c),...sp.subtract(c)],new n.Matrix4)}(e.region);if(e.sphere)return function(e,t,r){const i=new n.Vector3(e[0],e[1],e[2]);t.transform(i,i);const a=t.getScale(tp),o=Math.max(Math.max(a[0],a[1]),a[2]),s=e[3]*o;if(Zh(r))return r.center=i,r.radius=s,r;return new gs(i,s)}(e.sphere,t,r);throw new Error("3D Tile: boundingVolume must contain a sphere, region, or box")}function lp(e,t){if(e.box)return function(e){const t=up(),{halfAxes:r}=e,i=new n.Vector3(r.getColumn(0)),a=new n.Vector3(r.getColumn(1)),o=new n.Vector3(r.getColumn(2));for(let n=0;n<2;n++){for(let n=0;n<2;n++){for(let n=0;n<2;n++)ep.copy(e.center),ep.add(i),ep.add(a),ep.add(o),fp(t,ep),o.negate();a.negate()}i.negate()}return t}(t);if(e.region){const[t,r,i,a,o,s]=e.region;return[[n.degrees(t),n.degrees(r),o],[n.degrees(i),n.degrees(a),s]]}if(e.sphere)return function(e){const t=up(),{center:r,radius:i}=e,a=Eh.WGS84.scaleToGeodeticSurface(r,ep);let o;o=a?Eh.WGS84.geodeticSurfaceNormal(a):new n.Vector3(0,0,1);let s=new n.Vector3(o[2],-o[1],0);s.len()>0?s.normalize():s=new n.Vector3(0,1,0);const A=s.clone().cross(o);for(const n of[s,A,o]){tp.copy(n).scale(i);for(let e=0;e<2;e++)ep.copy(r),ep.add(tp),fp(t,ep),tp.negate()}return t}(t);throw new Error("Unkown boundingVolume type")}function cp(e,t,i){const a=new n.Vector3(e[0],e[1],e[2]);t.transform(a,a);let o=[];if(10===e.length){const t=e.slice(3,6),i=new r.Quaternion;i.fromArray(e,6);const a=new n.Vector3([1,0,0]),s=new n.Vector3([0,1,0]),A=new n.Vector3([0,0,1]);a.transformByQuaternion(i),a.scale(t[0]),s.transformByQuaternion(i),s.scale(t[1]),A.transformByQuaternion(i),A.scale(t[2]),o=[...a.toArray(),...s.toArray(),...A.toArray()]}else o=[...e.slice(3,6),...e.slice(6,9),...e.slice(9,12)];const s=t.transformAsVector(o.slice(0,3)),A=t.transformAsVector(o.slice(3,6)),l=t.transformAsVector(o.slice(6,9)),c=new L([s[0],s[1],s[2],A[0],A[1],A[2],l[0],l[1],l[2]]);return Zh(i)?(i.center=a,i.halfAxes=c,i):new Ls(a,c)}function up(){return[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]]}function fp(e,t){Eh.WGS84.cartesianToCartographic(t,ep),e[0][0]=Math.min(e[0][0],ep[0]),e[0][1]=Math.min(e[0][1],ep[1]),e[0][2]=Math.min(e[0][2],ep[2]),e[1][0]=Math.max(e[1][0],ep[0]),e[1][1]=Math.max(e[1][1],ep[1]),e[1][2]=Math.max(e[1][2],ep[2])}new n.Vector3,new n.Vector3,new n.Matrix4,new n.Vector3,new n.Vector3,new n.Vector3;function dp(e,t){if(e.dynamicScreenSpaceError&&e.dynamicScreenSpaceErrorComputedDensity){const n=e.dynamicScreenSpaceErrorComputedDensity,r=e.dynamicScreenSpaceErrorFactor;return function(e,t){const n=e*t;return 1-Math.exp(-n*n)}(t,n)*r}return 0}var hp=new n.Vector3,pp=new n.Vector3,mp=new n.Vector3,gp=new n.Vector3,bp=new n.Vector3,vp=new n.Matrix4,yp=new n.Matrix4;function xp(e,t){const{topDownViewport:n}=t,r=e.header.mbs[1],i=e.header.mbs[0],a=e.header.mbs[2],o=e.header.mbs[3],s=[...e.boundingVolume.center],A=n.unprojectPosition(n.cameraPosition);Eh.WGS84.cartographicToCartesian(A,hp),pp.copy(hp).subtract(s).normalize(),Eh.WGS84.eastNorthUpToFixedFrame(s,vp),yp.copy(vp).invert(),mp.copy(hp).transform(yp);const l=Math.sqrt(mp[0]*mp[0]+mp[1]*mp[1]),c=l*l/mp[2];gp.copy([mp[0],mp[1],c]);const u=gp.transform(vp).subtract(s).normalize(),f=pp.cross(u).normalize().scale(o).add(s),d=Eh.WGS84.cartesianToCartographic(f),h=n.project([i,r,a]),p=n.project(d);return bp.copy(h).subtract(p).magnitude()}var _p=class{_map=new Map;_array;_length;constructor(e=0){this._array=new Array(e),this._length=e}get length(){return this._length}set length(e){this._length=e,e>this._array.length&&(this._array.length=e)}get values(){return this._array}get(e){return n.assert$3(e<this._array.length),this._array[e]}set(e,t){n.assert$3(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){n.assert$3(e>=0),e>this._array.length&&(this._array.length=e)}resize(e){n.assert$3(e>=0),this.length=e}trim(e){null==e&&(e=this.length),this._array.length=e}reset(){this._array=[],this._map=new Map,this._length=0}find(e){return this._map.has(e)}},wp={loadSiblings:!1,skipLevelOfDetail:!1,updateTransforms:!0,onTraversalEnd:()=>{},viewportTraversersMap:{},basePath:""},Tp=class{options;root=null;selectedTiles={};requestedTiles={};emptyTiles={};lastUpdate=(new Date).getTime();updateDebounceTime=1e3;_traversalStack=new _p;_emptyTraversalStack=new _p;_frameNumber=null;traversalFinished(e){return!0}constructor(e){this.options={...wp,...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 r=!1;this.canTraverse(e,t)&&(this.updateChildTiles(e,t),r=this.updateAndPushChildren(e,t,n,e.hasRenderContent?e._selectionDepth+1:e._selectionDepth));const i=e.parent,a=Boolean(!i||i._shouldRefine),o=!r;e.hasRenderContent?e.refine===Gh.ADD?(this.loadTile(e,t),this.selectTile(e,t)):e.refine===Gh.REPLACE&&(this.loadTile(e,t),o&&this.selectTile(e,t)):(this.emptyTiles[e.id]=e,this.loadTile(e,t),o&&this.selectTile(e,t)),this.touchTile(e,t),e._shouldRefine=r&&a}const r=(new Date).getTime();(this.traversalFinished(t)||r-this.lastUpdate>this.updateDebounceTime)&&(this.lastUpdate=r,this.options.onTraversalEnd(t))}updateChildTiles(e,t){const n=e.children;for(const r of n)this.updateTile(r,t)}updateAndPushChildren(e,t,n,r){const{loadSiblings:i,skipLevelOfDetail:a}=this.options,o=e.children;o.sort(this.compareDistanceToCamera.bind(this));const s=e.refine===Gh.REPLACE&&e.hasRenderContent&&!a;let A=!1,l=!0;for(const c of o)if(c._selectionDepth=r,c.isVisibleAndInRequestVolume?(n.find(c)&&n.delete(c),n.push(c),A=!0):(s||i)&&(this.loadTile(c,t),this.touchTile(c,t)),s){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 r=e._screenSpaceError;return n&&(r=e.getScreenSpaceError(t,!0)),r>e.tileset.memoryAdjustedScreenSpaceError}updateTileVisibility(e,t){const n=[];if(this.options.viewportTraversersMap)for(const r in this.options.viewportTraversersMap)this.options.viewportTraversersMap[r]===t.viewport.id&&n.push(r);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 r of e.children)r.updateVisibility(t),n=n||r.isVisibleAndInRequestVolume;return n}executeEmptyTraversal(e,t){let n=!0;const r=this._emptyTraversalStack;for(r.push(e);r.length>0;){const e=r.pop(),i=!e.hasRenderContent&&this.canTraverse(e,t),a=!e.hasRenderContent&&0===e.children.length;if(i||e.contentAvailable||a||(n=!1),this.updateTile(e,t),e.isVisibleAndInRequestVolume||(this.loadTile(e,t),this.touchTile(e,t)),i){const t=e.children;for(const e of t)r.push(e)}}return e.hasEmptyContent||n}},Sp=new n.Vector3;var Mp=class{tileset;header;id;url;parent;refine;type;contentUrl;lodMetricType="geometricError";lodMetricValue=0;boundingVolume=null;content=null;contentState=Kh;gpuMemoryUsageInBytes=0;children=[];depth=0;viewportIds=[];transform=new n.Matrix4;extensions=null;implicitTiling=null;userData={};computedTransform;hasEmptyContent=!1;hasTilesetContent=!1;traverser=new Tp({});_cacheNode=null;_frameNumber=null;_expireDate=null;_expiredContent=null;_boundingBox=void 0;_distanceToCamera=0;_screenSpaceError=0;_visibilityPlaneMask;_visible=void 0;_contentBoundingVolume;_viewerRequestVolume;_initialTransform=new n.Matrix4;_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,r=""){this.header=t,this.tileset=e,this.id=r||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===$h||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===Kh}get contentExpired(){return this.contentState===Jh}get contentFailed(){return this.contentState===Yh}get distanceToCamera(){return this._distanceToCamera}get screenSpaceError(){return this._screenSpaceError}get boundingBox(){return this._boundingBox||(this._boundingBox=lp(this.header.boundingVolume,this.boundingVolume)),this._boundingBox}getScreenSpaceError(e,t){switch(this.tileset.type){case qh.I3S:return xp(this,e);case qh.TILES3D:return function(e,t,n){const r=e.tileset,i=e.parent&&e.parent.lodMetricValue||e.lodMetricValue,a=n?i:e.lodMetricValue;if(0===a)return 0;const o=Math.max(e._distanceToCamera,1e-7),{height:s,sseDenominator:A}=t,{viewDistanceScale:l}=r.options;let c=a*s*(l||1)/(o*A);return c-=dp(r,o),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===Gh.ADD||t;if(n&&!this.isVisible&&void 0!==this._visible)return-1;if(this.tileset._frameNumber-this._touchedFrame>=1)return-1;if(this.contentState===Kh)return-1;const r=this.parent,i=!r||n&&0!==this._screenSpaceError&&!r.hasTilesetContent?this._screenSpaceError:r._screenSpaceError,a=e.root?e.root._screenSpaceError:0;return Math.max(a-i,0)}async loadContent(){if(this.hasEmptyContent)return!1;if(this.content)return!0;this.contentExpired&&(this._expireDate=null),this.contentState=Wh;const e=await this.tileset._requestScheduler.scheduleRequest(this.id,this._getPriority.bind(this));if(!e)return this.contentState=Kh,!1;try{const e=this.tileset.getTileUrl(this.contentUrl),t=this.tileset.loader,r=this.tileset.loadOptions[t.id]||{},i={...this.tileset.loadOptions,[t.id]:{...r,isTileset:"json"===this.type,...this._getLoaderSpecificOptions(t.id)}};return this.content=await n.load(e,t,i),this.tileset.options.contentLoader&&await this.tileset.options.contentLoader(this),this._isTileset()&&this.tileset._initializeTileHeaders(this.content,this),this.contentState=$h,this._onContentLoaded(),!0}catch(t){throw this.contentState=Yh,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=Kh,this.tileDrawn=!0,!0}updateVisibility(e,t){if(this._frameNumber===e.frameNumber)return;const n=this.parent,r=n?n._visibilityPlaneMask:js.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,r),this._visible=this._visibilityPlaneMask!==js.MASK_OUTSIDE,this._inRequestVolume=this.insideViewerRequestVolume(e),this._frameNumber=e.frameNumber,this.viewportIds=t}visibility(e,t){const{cullingVolume:n}=e,{boundingVolume:r}=this;return n.computeVisibilityWithPlaneMask(r,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 Sp.subVectors(t.center,e.position),e.direction.dot(Sp)}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=Jh,this._expiredContent=this.content)}}get extras(){return this.header.extras}_initializeLodMetric(e){"lodMetricType"in e?this.lodMetricType=e.lodMetricType:(this.lodMetricType=this.parent&&this.parent.lodMetricType||this.tileset.lodMetricType,console.warn("3D Tile: Required prop lodMetricType is undefined. Using parent lodMetricType")),"lodMetricValue"in e?this.lodMetricValue=e.lodMetricValue:(this.lodMetricValue=this.parent&&this.parent.lodMetricValue||this.tileset.lodMetricValue,console.warn("3D Tile: Required prop lodMetricValue is undefined. Using parent lodMetricValue"))}_initializeTransforms(e){this.transform=e.transform?new n.Matrix4(e.transform):new n.Matrix4;const t=this.parent,r=this.tileset,i=t&&t.computedTransform?t.computedTransform.clone():r.modelMatrix.clone();this.computedTransform=new n.Matrix4(i).multiplyRight(this.transform);const a=t&&t._initialTransform?t._initialTransform.clone():new n.Matrix4;this._initialTransform=new n.Matrix4(a).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=Kh,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=js.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||Gh.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=Ap(e.boundingVolume,this.computedTransform,this.boundingVolume);const t=e.content;t&&(t.boundingVolume&&(this._contentBoundingVolume=Ap(t.boundingVolume,this.computedTransform,this._contentBoundingVolume)),e.viewerRequestVolume&&(this._viewerRequestVolume=Ap(e.viewerRequestVolume,this.computedTransform,this._viewerRequestVolume)))}_updateTransform(e=new n.Matrix4){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}},Ep=class extends Tp{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 r=e.refine===Gh.REPLACE,i=e._optimChildrenWithinParent===Xh;r&&i&&n&&!this.anyChildrenVisible(e,t)&&(e._visible=!1)}meetsScreenSpaceErrorEarly(e,t){const{parent:n}=e;return!(!n||n.hasTilesetContent||n.refine!==Gh.ADD)&&!this.shouldRefine(e,t,!0)}},Cp=class{frameNumberMap=new Map;register(e,t){const n=this.frameNumberMap.get(e)||new Map,r=n.get(t)||0;n.set(t,r+1),this.frameNumberMap.set(e,n)}deregister(e,t){const n=this.frameNumberMap.get(e);if(!n)return;const r=n.get(t)||1;n.set(t,r-1)}isZero(e,t){return 0===(this.frameNumberMap.get(e)?.get(t)||0)}},Ip="REQUESTED",Rp="COMPLETED",Pp="ERROR",Np=class{_statusMap;pendingTilesRegister=new Cp;constructor(){this._statusMap={}}add(e,t,n,r){if(!this._statusMap[t]){const{frameNumber:i,viewport:{id:a}}=r;this._statusMap[t]={request:e,callback:n,key:t,frameState:r,status:Ip},this.pendingTilesRegister.register(a,i),e().then(e=>{this._statusMap[t].status=Rp;const{frameNumber:n,viewport:{id:i}}=this._statusMap[t].frameState;this.pendingTilesRegister.deregister(i,n),this._statusMap[t].callback(e,r)}).catch(e=>{this._statusMap[t].status=Pp;const{frameNumber:r,viewport:{id:i}}=this._statusMap[t].frameState;this.pendingTilesRegister.deregister(i,r),n(e)})}}update(e,t){if(this._statusMap[e]){const{frameNumber:n,viewport:{id:r}}=this._statusMap[e].frameState;this.pendingTilesRegister.deregister(r,n);const{frameNumber:i,viewport:{id:a}}=t;this.pendingTilesRegister.register(a,i),this._statusMap[e].frameState=t}}find(e){return this._statusMap[e]}hasPendingTiles(e,t){return!this.pendingTilesRegister.isZero(e,t)}},kp=class extends Tp{_tileManager;constructor(e){super(e),this._tileManager=new Np}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*xp(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||[],r=e.children,i=e.tileset;for(const a of n){const n=`${a.id}-${t.viewport.id}`,o=r&&r.find(e=>e.id===n);if(o)o&&this.updateTile(o,t);else{let r=()=>this._loadTile(a.id,i);this._tileManager.find(n)?this._tileManager.update(n,t):(i.tileset.nodePages&&(r=()=>i.tileset.nodePagesTile.formTileFromNodePages(a.id)),this._tileManager.add(r,n,t=>this._onTileLoad(t,e,n),t))}}return!1}async _loadTile(e,t){const{loader:r}=t,i=t.getTileUrl(`${t.url}/nodes/${e}`),a={...t.loadOptions,i3s:{...t.loadOptions.i3s,isTileHeader:!0}};return await n.load(i,r,a)}_onTileLoad(e,t,n){const r=new Mp(t.tileset,e,t,n);t.children.push(r);const i=this._tileManager.find(r.id).frameState;this.updateTile(r,i),this._frameNumber===i.frameNumber&&(this.traversalFinished(i)||(new Date).getTime()-this.lastUpdate>this.updateDebounceTime)&&this.executeTraversal(r,i)}},Lp={description:"",ellipsoid:Eh.WGS84,modelMatrix:new n.Matrix4,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:{}},Bp="Tiles In Tileset(s)",Op="Tiles In Memory",Fp="Tiles In View",Dp="Tiles To Render",Up="Tiles Loaded",Vp="Tiles Loading",jp="Tiles Unloaded",zp="Failed Tile Loads",Gp="Points/Vertices",Hp="Tile Memory Use",qp="Maximum Screen Space Error",Qp=class{options;loadOptions;type;tileset;loader;url;basePath;modelMatrix;ellipsoid;lodMetricType;lodMetricValue;refine;root=null;roots={};asset={};description="";properties;extras=null;attributions={};credits={};stats;contentFormats={draco:!1,meshopt:!1,dds:!1,ktx2:!1};cartographicCenter=null;cartesianCenter=null;zoom=1;boundingVolume=null;dynamicScreenSpaceErrorComputedDensity=0;maximumMemoryUsage=32;gpuMemoryUsageInBytes=0;memoryAdjustedScreenSpaceError=0;_cacheBytes=0;_cacheOverflowBytes=0;_frameNumber=0;_queryParams={};_extensionsUsed=[];_tiles={};_pendingCount=0;selectedTiles=[];traverseCounter=0;geometricError=0;lastUpdatedVieports=null;_requestedTiles=[];_emptyTiles=[];frameStateData={};_traverser;_cache=new Rh;_requestScheduler;_heldTiles=new Set;updatePromise=null;tilesetInitializationPromise;constructor(e,t){this.options={...Lp,...t},this.tileset=e,this.loader=e.loader,this.type=e.type,this.url=e.url,this.basePath=e.basePath||n.dirname(this.url),this.modelMatrix=this.options.modelMatrix,this.ellipsoid=this.options.ellipsoid,this.lodMetricType=e.lodMetricType,this.lodMetricValue=e.lodMetricValue,this.refine=e.root.refine,this.loadOptions=this.options.loadOptions||{},this._traverser=this._initializeTraverser(),this._requestScheduler=new g({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 n.Stats({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 r of t){const e=r.id;this._needTraverse(e)?n.push(e):this.traverseCounter--}for(const r of t){const e=r.id;if(this.roots[e]||(this.roots[e]=this._initializeTileHeaders(this.tileset,null)),!n.includes(e))continue;const t=Oh(r,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],r=Object.values(this._traverser.selectedTiles),[i,a]=function(e,t,n){if(0===n||e.length<=n)return[e,[]];const r=[],{longitude:i,latitude:a}=t.viewport;for(const[l,c]of e.entries()){const[e,t]=c.header.mbs,n=Math.abs(i-e),o=Math.abs(a-t),s=Math.sqrt(o*o+n*n);r.push([l,s])}const o=r.sort((e,t)=>e[1]-t[1]),s=[];for(let l=0;l<n;l++)s.push(e[o[l][0]]);const A=[];for(let l=n;l<o.length;l++)A.push(e[o[l][0]]);return[s,A]}(r,e,this.options.maximumTilesSelected);n.selectedTiles=i;for(const o of a)o.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 r in this.frameStateData){const e=this.frameStateData[r];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 r=this._tiles[e];r&&r.contentAvailable?(r._selectedFrame=this._frameNumber,this.selectedTiles.push(r),n++):this._heldTiles.delete(e)}}else this._heldTiles=t;n>0&&setTimeout(()=>{this.selectTiles()},0);for(const r of this.selectedTiles)this._tiles[r.id]=r;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)),r=new Set(t.map(e=>e.id));let i=e.filter(e=>!r.has(e.id)).length>0;return i=i||t.filter(e=>!n.has(e.id)).length>0,i}_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(Fp).count=this.selectedTiles.length,this.stats.get(Dp).count=e,this.stats.get(Gp).count=t,this.stats.get(qp).count=this.memoryAdjustedScreenSpaceError}async _initializeTileSet(e){this.type===qh.I3S&&(this.calculateViewPropsI3S(),e.root=await e.root),this.root=this._initializeTileHeaders(e,null),this.type===qh.TILES3D&&(this._initializeTiles3DTileset(e),this.calculateViewPropsTiles3D()),this.type===qh.I3S&&this._initializeI3STileset()}calculateViewPropsI3S(){const e=this.tileset.fullExtent;if(e){const{xmin:t,xmax:r,ymin:i,ymax:a,zmin:o,zmax:s}=e;return this.cartographicCenter=new n.Vector3(t+(r-t)/2,i+(a-i)/2,o+(s-o)/2),this.cartesianCenter=new n.Vector3,Eh.WGS84.cartographicToCartesian(this.cartographicCenter,this.cartesianCenter),void(this.zoom=zh(e,this.cartographicCenter,this.cartesianCenter))}const t=this.tileset.store?.extent;if(t){const[e,r,i,a]=t;return this.cartographicCenter=new n.Vector3(e+(i-e)/2,r+(a-r)/2,0),this.cartesianCenter=new n.Vector3,Eh.WGS84.cartographicToCartesian(this.cartographicCenter,this.cartesianCenter),void(this.zoom=function(e,t,n){const[r,i,a,o]=e;return zh({xmin:r,xmax:a,ymin:i,ymax:o,zmin:0,zmax:0},t,n)}(t,this.cartographicCenter,this.cartesianCenter))}console.warn("Extent is not defined in the tileset header"),this.cartographicCenter=new n.Vector3,this.zoom=1}calculateViewPropsTiles3D(){const e=this.root,{center:t}=e.boundingVolume;if(!t)return console.warn("center was not pre-calculated for the root tile"),this.cartographicCenter=new n.Vector3,void(this.zoom=1);0!==t[0]||0!==t[1]||0!==t[2]?(this.cartographicCenter=new n.Vector3,Eh.WGS84.cartesianToCartographic(t,this.cartographicCenter)):this.cartographicCenter=new n.Vector3(0,0,-Eh.WGS84.radii[0]),this.cartesianCenter=t,this.zoom=jh(e.boundingVolume,this.cartographicCenter)}_initializeStats(){this.stats.get(Bp),this.stats.get(Vp),this.stats.get(Op),this.stats.get(Fp),this.stats.get(Dp),this.stats.get(Up),this.stats.get(jp),this.stats.get(zp),this.stats.get(Gp),this.stats.get(Hp,"memory"),this.stats.get(qp)}_initializeTileHeaders(e,t){const n=new Mp(this,e.root,t);if(t&&(t.children.push(n),n.depth=t.depth+1),this.type===qh.TILES3D){const e=[];for(e.push(n);e.length>0;){const t=e.pop();this.stats.get(Bp).incrementCount();const n=t.header.children||[];for(const r of n){const n=new Mp(this,r,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 qh.TILES3D:e=Ep;break;case qh.I3S:e=kp;break;default:e=Tp}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(zp).incrementCount();const n=t.message||t.toString(),r=e.url;console.error(`A 3D tile failed to load: ${e.url} ${n}`),this.options.onTileError(e,n,r)}_onTileLoad(e,t){if(t){if(this.type===qh.I3S){const e=this.tileset?.nodePagesTile?.nodesInNodePages||0;this.stats.get(Bp).reset(),this.stats.get(Bp).addCount(e)}e&&e.content&&Ph(e,e.content),this.updateContentTypes(e),this._addTileToCache(e),this.options.onTileLoad(e)}}updateContentTypes(e){if(this.type===qh.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===qh.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(Vp).incrementCount()}_onEndTileLoading(){this._pendingCount--,this.stats.get(Vp).decrementCount()}_addTileToCache(e){this._cache.add(this,e,t=>t._updateCacheStats(e))}_updateCacheStats(e){this.stats.get(Up).incrementCount(),this.stats.get(Op).incrementCount(),this.gpuMemoryUsageInBytes+=e.gpuMemoryUsageInBytes||0,this.stats.get(Hp).count=this.gpuMemoryUsageInBytes,this.options.memoryAdjustedScreenSpaceError&&this.adjustScreenSpaceError()}_unloadTile(e){this.gpuMemoryUsageInBytes-=e.gpuMemoryUsageInBytes||0,this.stats.get(Op).decrementCount(),this.stats.get(jp).incrementCount(),this.stats.get(Hp).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)}},Kp="4.5.4",Wp={COMPOSITE:"cmpt",POINT_CLOUD:"pnts",BATCHED_3D_MODEL:"b3dm",INSTANCED_3D_MODEL:"i3dm",GEOMETRY:"geom",VECTOR:"vect",GLTF:"glTF"};Object.keys(Wp);function $p(e,t,r){n.assert$3(e instanceof ArrayBuffer);const i=new TextDecoder("utf8"),a=new Uint8Array(e,t,r);return i.decode(a)}var Jp={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,DOUBLE:5130},Yp={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,...Jp},Xp={[Jp.DOUBLE]:Float64Array,[Jp.FLOAT]:Float32Array,[Jp.UNSIGNED_SHORT]:Uint16Array,[Jp.UNSIGNED_INT]:Uint32Array,[Jp.UNSIGNED_BYTE]:Uint8Array,[Jp.BYTE]:Int8Array,[Jp.SHORT]:Int16Array,[Jp.INT]:Int32Array},Zp={DOUBLE:Jp.DOUBLE,FLOAT:Jp.FLOAT,UNSIGNED_SHORT:Jp.UNSIGNED_SHORT,UNSIGNED_INT:Jp.UNSIGNED_INT,UNSIGNED_BYTE:Jp.UNSIGNED_BYTE,BYTE:Jp.BYTE,SHORT:Jp.SHORT,INT:Jp.INT},em="Failed to convert GL type",tm=class e{static fromTypedArray(e){e=ArrayBuffer.isView(e)?e.constructor:e;for(const t in Xp)if(Xp[t]===e)return t;throw new Error(em)}static fromName(e){const t=Zp[e];if(!t)throw new Error(em);return t}static getArrayType(e){switch(e){case Jp.UNSIGNED_SHORT_5_6_5:case Jp.UNSIGNED_SHORT_4_4_4_4:case Jp.UNSIGNED_SHORT_5_5_5_1:return Uint16Array;default:const t=Xp[e];if(!t)throw new Error(em);return t}}static getByteSize(t){return e.getArrayType(t).BYTES_PER_ELEMENT}static validate(t){return Boolean(e.getArrayType(t))}static createTypedArray(t,n,r=0,i){void 0===i&&(i=(n.byteLength-r)/e.getByteSize(t));const a=ArrayBuffer.isView(n)?n.buffer:n;return new(e.getArrayType(t))(a,r,i)}};function nm(e,t=[0,0,0]){const n=e>>11&31,r=e>>5&63,i=31&e;return t[0]=n<<3,t[1]=r<<2,t[2]=i<<3,t}new P,new n.Vector3,new P,new P;function rm(e,t=255){return n.clamp(e,0,t)/t*2-1}function im(e){return e<0?-1:1}function am(e,t,n,r){if(function(e,t){if(!e)throw new Error(`math.gl assertion failed. ${t}`)}(r),e<0||e>n||t<0||t>n)throw new Error(`x and y must be unsigned normalized integers between 0 and ${n}`);if(r.x=rm(e,n),r.y=rm(t,n),r.z=1-(Math.abs(r.x)+Math.abs(r.y)),r.z<0){const e=r.x;r.x=(1-Math.abs(r.y))*im(e),r.y=(1-Math.abs(e))*im(r.y)}return r.normalize()}function om(e,t,n){return am(e,t,255,n)}var sm=class{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=Yp.UNSIGNED_INT,n=1){const r=this.json[e];return r&&Number.isFinite(r.byteOffset)?this._getTypedArrayFromBinary(e,t,n,1,r.byteOffset):r}getPropertyArray(e,t,n){const r=this.json[e];return r&&Number.isFinite(r.byteOffset)?("componentType"in r&&(t=tm.fromName(r.componentType)),this._getTypedArrayFromBinary(e,t,n,this.featuresLength,r.byteOffset)):this._getTypedArrayFromArray(e,t,r)}getProperty(e,t,n,r,i){const a=this.json[e];if(!a)return a;const o=this.getPropertyArray(e,t,n);if(1===n)return o[r];for(let s=0;s<n;++s)i[s]=o[n*r+s];return i}_getTypedArrayFromBinary(e,t,n,r,i){const a=this._cachedTypedArrays;let o=a[e];return o||(o=tm.createTypedArray(t,this.buffer.buffer,this.buffer.byteOffset+i,r*n),a[e]=o),o}_getTypedArrayFromArray(e,t,n){const r=this._cachedTypedArrays;let i=r[e];if(!i){if(ArrayBuffer.isView(n)){const e=n.byteOffset,r=n.byteLength/tm.getByteSize(t);i=tm.createTypedArray(t,n.buffer,e,r)}else i=n instanceof ArrayBuffer?tm.createTypedArray(t,n):new(tm.getArrayType(t))(n);r[e]=i}return i}},Am={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},lm={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]]},cm={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]}};var um=e=>void 0!==e;function fm(e,t,n){if(!t)return null;let r=e.getExtension("3DTILES_batch_table_hierarchy");const i=t.HIERARCHY;return i&&(console.warn("3D Tile Parser: HIERARCHY is deprecated. Use 3DTILES_batch_table_hierarchy."),t.extensions=t.extensions||{},t.extensions["3DTILES_batch_table_hierarchy"]=i,r=i),r?function(e,t){let n,r,i;const a=e.instancesLength,o=e.classes;let s,A=e.classIds,l=e.parentCounts,c=e.parentIds,u=a;um(A.byteOffset)&&(A.componentType=defaultValue(A.componentType,GL.UNSIGNED_SHORT),A.type=AttributeType.SCALAR,i=getBinaryAccessor(A),A=i.createArrayBufferView(t.buffer,t.byteOffset+A.byteOffset,a));if(um(l))for(um(l.byteOffset)&&(l.componentType=defaultValue(l.componentType,GL.UNSIGNED_SHORT),l.type=AttributeType.SCALAR,i=getBinaryAccessor(l),l=i.createArrayBufferView(t.buffer,t.byteOffset+l.byteOffset,a)),s=new Uint16Array(a),u=0,n=0;n<a;++n)s[n]=u,u+=l[n];um(c)&&um(c.byteOffset)&&(c.componentType=defaultValue(c.componentType,GL.UNSIGNED_SHORT),c.type=AttributeType.SCALAR,i=getBinaryAccessor(c),c=i.createArrayBufferView(t.buffer,t.byteOffset+c.byteOffset,u));const f=o.length;for(n=0;n<f;++n){const e=o[n].length,r=o[n].instances,i=getBinaryProperties(e,r,t);o[n].instances=combine(i,r)}const d=new Array(f).fill(0),h=new Uint16Array(a);for(n=0;n<a;++n)r=A[n],h[n]=d[r],++d[r];const p={classes:o,classIds:A,classIndexes:h,parentCounts:l,parentIndexes:s,parentIds:c};return function(e){const t=e.classIds.length;for(let n=0;n<t;++n)hm(e,n,stack)}(p),p}(r,n):null}function dm(e,t,n){if(!e)return;const r=e.parentCounts;return e.parentIds?n(e,t):r>0?function(e,t,n){const r=e.classIds,i=e.parentCounts,a=e.parentIds,o=e.parentIndexes,s=r.length,A=scratchVisited;A.length=Math.max(A.length,s);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 r=n(e,t);if(um(r))return r;const s=i[t],u=o[t];for(let e=0;e<s;++e){const n=a[u+e];n!==t&&c.push(n)}}return null}(e,t,n):function(e,t,n){let r=!0;for(;r;){const i=n(e,t);if(um(i))return i;const a=e.parentIds[t];r=a!==t,t=a}throw new Error("traverseHierarchySingleParent")}(e,t,n)}function hm(e,t,n){const r=e.parentCounts,i=e.parentIds,a=e.parentIndexes,o=e.classIds.length;if(!um(i))return;assert(t<o,`Parent index ${t} exceeds the total number of instances: ${o}`),assert(-1===n.indexOf(t),"Circular dependency detected in the batch table hierarchy."),n.push(t);const s=um(r)?r[t]:1,A=um(r)?a[t]:t;for(let l=0;l<s;++l){const r=i[A+l];r!==t&&hm(e,r,n)}n.pop(t)}function pm(e){return null!=e}var mm=(e,t)=>e,gm={HIERARCHY:!0,extensions:!0,extras:!0},bm=class{json;binary;featureCount;_extensions;_properties;_binaryProperties;_hierarchy;constructor(e,t,r,i={}){n.assert$3(r>=0),this.json=e||{},this.binary=t,this.featureCount=r,this._extensions=this.json?.extensions||{},this._properties={};for(const n in this.json)gm[n]||(this._properties[n]=this.json[n]);this._binaryProperties=this._initializeBinaryProperties(),i["3DTILES_batch_table_hierarchy"]&&(this._hierarchy=fm(this,this.json,this.binary))}getExtension(e){return this.json&&this.json.extensions&&this.json.extensions[e]}memorySizeInBytes(){return 0}isClass(e,t){return this._checkBatchId(e),n.assert$3("string"==typeof t,t),!!this._hierarchy&&pm(dm(this._hierarchy,e,(e,n)=>{const r=e.classIds[n];return e.classes[r].name===t}))}isExactClass(e,t){return n.assert$3("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),n.assert$3("string"==typeof t,t),pm(this._properties[t])||this._hasPropertyInHierarchy(e,t)}getPropertyNames(e,t){this._checkBatchId(e),(t=pm(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),n.assert$3("string"==typeof t,t),this._binaryProperties){const n=this._binaryProperties[t];if(pm(n))return this._getBinaryProperty(n,e)}const r=this._properties[t];if(pm(r))return mm(r[e]);if(this._hierarchy){const n=this._getHierarchyProperty(e,t);if(pm(n))return n}}setProperty(e,t,r){const i=this.featureCount;if(this._checkBatchId(e),n.assert$3("string"==typeof t,t),this._binaryProperties){const n=this._binaryProperties[t];if(n)return void this._setBinaryProperty(n,e,r)}if(this._hierarchy&&this._setHierarchyProperty(this,e,t,r))return;let a=this._properties[t];pm(a)||(this._properties[t]=new Array(i),a=this._properties[t]),a[e]=mm(r)}_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],r=this._initializeBinaryProperty(t,n);r&&(e=e||{},e[t]=r)}return e}_initializeBinaryProperty(e,t){if("byteOffset"in t){const r=t;n.assert$3(this.binary,`Property ${e} requires a batch table binary.`),n.assert$3(r.type,`Property ${e} requires a type.`);const i=function(e,t,r,i){const{componentType:a}=e;n.assert$3(e.componentType);const o="string"==typeof a?tm.fromName(a):a,s=Am[e.type],A=lm[e.type],l=cm[e.type];return r+=e.byteOffset,{values:tm.createTypedArray(o,t,r,s*i),type:o,size:s,unpacker:A,packer:l}}(r,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){return!!this._hierarchy&&pm(dm(this._hierarchy,e,(e,n)=>{const r=e.classIds[n];return pm(e.classes[r].instances[t])}))}_getPropertyNamesInHierarchy(e,t){dm(this._hierarchy,e,(e,n)=>{const r=e.classIds[n],i=e.classes[r].instances;for(const a in i)i.hasOwnProperty(a)&&-1===t.indexOf(a)&&t.push(a)})}_getHierarchyProperty(e,t){return dm(this._hierarchy,e,(e,n)=>{const r=e.classIds[n],i=e.classes[r],a=e.classIndexes[n],o=i.instances[t];return pm(o)?pm(o.typedArray)?this._getBinaryProperty(o,a):mm(o[a]):null})}_setHierarchyProperty(e,t,r,i){return pm(dm(this._hierarchy,t,(e,a)=>{const o=e.classIds[a],s=e.classes[o],A=e.classIndexes[a],l=s.instances[r];return!!pm(l)&&(n.assert$3(a===t,`Inherited property "${r}" is read-only.`),pm(l.typedArray)?this._setBinaryProperty(l,A,i):l[A]=mm(i),!0)}))}};function vm(e,t,n=0){const r=new DataView(t);if(e.magic=r.getUint32(n,!0),n+=4,e.version=r.getUint32(n,!0),n+=4,e.byteLength=r.getUint32(n,!0),n+=4,1!==e.version)throw new Error(`3D Tile Version ${e.version} not supported`);return n}var ym="b3dm tile in legacy format.";function xm(e,t,n){const r=new DataView(t);let i;e.header=e.header||{};let a=r.getUint32(n,!0);n+=4;let o=r.getUint32(n,!0);n+=4;let s=r.getUint32(n,!0);n+=4;let A=r.getUint32(n,!0);return n+=4,s>=570425344?(n-=8,i=a,s=o,A=0,a=0,o=0,console.warn(ym)):A>=570425344&&(n-=4,i=s,s=a,A=o,a=0,o=0,console.warn(ym)),e.header.featureTableJsonByteLength=a,e.header.featureTableBinaryByteLength=o,e.header.batchTableJsonByteLength=s,e.header.batchTableBinaryByteLength=A,e.header.batchLength=i,n}function _m(e,t,n,r){return n=function(e,t,n){const{featureTableJsonByteLength:r,featureTableBinaryByteLength:i,batchLength:a}=e.header||{};if(e.featureTableJson={BATCH_LENGTH:a||0},r&&r>0){const i=$p(t,n,r);e.featureTableJson=JSON.parse(i)}return n+=r||0,e.featureTableBinary=new Uint8Array(t,n,i),n+=i||0,n}(e,t,n),n=function(e,t,n){const{batchTableJsonByteLength:r,batchTableBinaryByteLength:i}=e.header||{};if(r&&r>0){const a=$p(t,n,r);e.batchTableJson=JSON.parse(a),n+=r,i&&i>0&&(e.batchTableBinary=new Uint8Array(t,n,i),e.batchTableBinary=new Uint8Array(e.batchTableBinary),n+=i)}return n}(e,t,n),n}function wm(e,t,n){if(!(t||e&&e.batchIds&&n))return null;const{batchIds:r,isRGB565:i,pointCount:a=0}=e;if(r&&n){const e=new Uint8ClampedArray(3*a);for(let t=0;t<a;t++){const i=r[t],a=n.getProperty(i,"dimensions").map(e=>255*e);e[3*t]=a[0],e[3*t+1]=a[1],e[3*t+2]=a[2]}return{type:Yp.UNSIGNED_BYTE,value:e,size:3,normalized:!0}}if(t&&i){const e=new Uint8ClampedArray(3*a);for(let n=0;n<a;n++){const r=nm(t[n]);e[3*n]=r[0],e[3*n+1]=r[1],e[3*n+2]=r[2]}return{type:Yp.UNSIGNED_BYTE,value:e,size:3,normalized:!0}}return t&&t.length===3*a?{type:Yp.UNSIGNED_BYTE,value:t,size:3,normalized:!0}:{type:Yp.UNSIGNED_BYTE,value:t||new Uint8ClampedArray,size:4,normalized:!0}}var Tm=new n.Vector3;function Sm(e,t,r){return e.isQuantized?r["3d-tiles"]&&r["3d-tiles"].decodeQuantizedPositions?(e.isQuantized=!1,function(e,t){const r=new n.Vector3,i=new Float32Array(3*e.pointCount);for(let n=0;n<e.pointCount;n++)r.set(t[3*n],t[3*n+1],t[3*n+2]).scale(1/e.quantizedRange).multiply(e.quantizedVolumeScale).add(e.quantizedVolumeOffset).toArray(i,3*n);return i}(e,t)):{type:Yp.UNSIGNED_SHORT,value:t,size:3,normalized:!0}:t}async function Mm(e,t,r,i,a){r=_m(e,t,r=xm(e,t,r=vm(e,t,r))),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:A}=function(e){const t=new sm(e.featureTableJson,e.featureTableBinary),n=t.getGlobalProperty("POINTS_LENGTH");if(!Number.isFinite(n))throw new Error("POINTS_LENGTH must be defined");return t.featuresLength=n,e.featuresLength=n,e.pointsLength=n,e.pointCount=n,e.rtcCenter=t.getGlobalProperty("RTC_CENTER",Yp.FLOAT,3),{featureTable:t,batchTable:Em(e,t)}}(e);return await async function(e,t,r,i,a){let o,A,l;const c=e.batchTableJson&&e.batchTableJson.extensions&&e.batchTableJson.extensions["3DTILES_draco_point_compression"];c&&(l=c.properties);const u=t.getExtension("3DTILES_draco_point_compression");if(u){A=u.properties;const t=u.byteOffset,n=u.byteLength;if(!A||!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(A.POSITION),e.hasColors=Number.isFinite(A.RGB)||Number.isFinite(A.RGBA),e.hasNormals=Number.isFinite(A.NORMAL),e.hasBatchIds=Number.isFinite(A.BATCH_ID),e.isTranslucent=Number.isFinite(A.RGBA)}return!o||await async function(e,t,r,i){if(!i)return;const a={...r,draco:{...r?.draco,extraAttributes:t.batchTableProperties||{}}};delete a["3d-tiles"];const o=await s(t.buffer,Bf,a,i),A=o.attributes.POSITION&&o.attributes.POSITION.value,l=o.attributes.COLOR_0&&o.attributes.COLOR_0.value,c=o.attributes.NORMAL&&o.attributes.NORMAL.value,u=o.attributes.BATCH_ID&&o.attributes.BATCH_ID.value,f=A&&o.attributes.POSITION.value.quantization,d=c&&o.attributes.NORMAL.value.quantization;if(f){const t=o.POSITION.data.quantization,r=t.range;e.quantizedVolumeScale=new n.Vector3(r,r,r),e.quantizedVolumeOffset=new n.Vector3(t.minValues),e.quantizedRange=(1<<t.quantizationBits)-1,e.isQuantizedDraco=!0}d&&(e.octEncodedRange=(1<<o.NORMAL.data.quantization.quantizationBits)-1,e.isOctEncodedDraco=!0);const h={};if(t.batchTableProperties)for(const n of Object.keys(t.batchTableProperties))o.attributes[n]&&o.attributes[n].value&&(h[n.toLowerCase()]=o.attributes[n].value);e.attributes={positions:A,colors:wm(e,l,void 0),normals:c,batchIds:u,...h}}(e,{buffer:o,properties:{...A,...l},featureTableProperties:A,batchTableProperties:l,dequantizeInShader:!1},i,a)}(e,o,0,i,a),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",Yp.FLOAT,3);else if(t.hasProperty("POSITION_QUANTIZED")){const r=t.getPropertyArray("POSITION_QUANTIZED",Yp.UNSIGNED_SHORT,3);if(e.isQuantized=!0,e.quantizedRange=65535,e.quantizedVolumeScale=t.getGlobalProperty("QUANTIZED_VOLUME_SCALE",Yp.FLOAT,3),!e.quantizedVolumeScale)throw new Error("QUANTIZED_VOLUME_SCALE must be defined for quantized positions.");if(e.quantizedVolumeOffset=t.getGlobalProperty("QUANTIZED_VOLUME_OFFSET",Yp.FLOAT,3),!e.quantizedVolumeOffset)throw new Error("QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.");e.attributes.positions=Sm(e,r,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 r=null;t.hasProperty("RGBA")?(r=t.getPropertyArray("RGBA",Yp.UNSIGNED_BYTE,4),e.isTranslucent=!0):t.hasProperty("RGB")?r=t.getPropertyArray("RGB",Yp.UNSIGNED_BYTE,3):t.hasProperty("RGB565")&&(r=t.getPropertyArray("RGB565",Yp.UNSIGNED_SHORT,1),e.isRGB565=!0),e.attributes.colors=wm(e,r,n)}t.hasProperty("CONSTANT_RGBA")&&(e.constantRGBA=t.getGlobalProperty("CONSTANT_RGBA",Yp.UNSIGNED_BYTE,4))}(e,o,A),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",Yp.FLOAT,3):t.hasProperty("NORMAL_OCT16P")&&(n=t.getPropertyArray("NORMAL_OCT16P",Yp.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 r=0;r<(e.pointsLength||0);r++)om(t[2*r],t[2*r+1],Tm),Tm.toArray(n,3*r);return{type:Yp.FLOAT,size:2,value:n}}return{type:Yp.FLOAT,size:2,value:t}}(e,n)}}(e,o),r}function Em(e,t){let n=null;if(!e.batchIds&&t.hasProperty("BATCH_ID")&&(e.batchIds=t.getPropertyArray("BATCH_ID",Yp.UNSIGNED_SHORT,1),e.batchIds)){const r=t.getGlobalProperty("BATCH_LENGTH");if(!r)throw new Error("Global property: BATCH_LENGTH must be defined when BATCH_ID is defined.");const{batchTableJson:i,batchTableBinary:a}=e;n=new bm(i,a,r)}return n}var Cm=0,Im=1;function Rm(e,t,r,i){e.rotateYtoZ=!0;const a=(e.byteOffset||0)+(e.byteLength||0)-r;if(0===a)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=n.sliceArrayBuffer(t,r,a),e.gltfByteOffset=0,e.gltfByteLength=a,r%4==0||console.warn(`${e.type}: embedded glb is not aligned to a 4-byte boundary.`),(e.byteOffset||0)+(e.byteLength||0)}async function Pm(e,t,n,r){const i=n?.["3d-tiles"]||{};if(function(e,t){switch(t){case Cm:if(e.gltfArrayBuffer){const t=new Uint8Array(e.gltfArrayBuffer,e.gltfByteOffset);e.gltfUrl=(new TextDecoder).decode(t).replace(/[\s\0]+$/,"")}delete e.gltfArrayBuffer,delete e.gltfByteOffset,delete e.gltfByteLength;break;case Im:break;default:throw new Error("b3dm: Illegal glTF format field")}}(e,t),i.loadGLTF){if(!r)return;if(e.gltfUrl){const{fetch:t}=r;e.gltfArrayBuffer=await(await t(e.gltfUrl,n?.core)).arrayBuffer(),e.gltfByteOffset=0}if(e.gltfArrayBuffer){const t=await s(e.gltfArrayBuffer,Id,n,r);e.gltf=Hd(t),e.gpuMemoryUsageInBytes=Mc(e.gltf),delete e.gltfArrayBuffer,delete e.gltfByteOffset,delete e.gltfByteLength}}}async function Nm(e,t,n,r,i){n=function(e,t,n,r){return n=vm(e,t,n),n=xm(e,t,n),n=_m(e,t,n),n=Rm(e,t,n,r),e.rtcCenter=new sm(e.featureTableJson,e.featureTableBinary).getGlobalProperty("RTC_CENTER",Yp.FLOAT,3),n}(e,t,n,r),await Pm(e,Im,r,i);const a=e?.gltf?.extensions;return a&&a.CESIUM_RTC&&(e.rtcCenter=a.CESIUM_RTC.center),n}async function km(e,t,i,a,o){return i=function(e,t,i,a){if(i=vm(e,t,i),1!==e.version)throw new Error(`Instanced 3D Model version ${e.version} is not supported`);if(i=xm(e,t,i),e.gltfFormat=new DataView(t).getUint32(i,!0),i+=4,i=_m(e,t,i),i=Rm(e,t,i,a),!e?.header?.featureTableJsonByteLength||0===e.header.featureTableJsonByteLength)throw new Error("i3dm parser: featureTableJsonByteLength is zero.");const o=new sm(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");return e.eastNorthUp=o.getGlobalProperty("EAST_NORTH_UP"),e.rtcCenter=o.getGlobalProperty("RTC_CENTER",Yp.FLOAT,3),function(e,t,i,a){const o=new Array(a),s=new n.Vector3;new n.Vector3,new n.Vector3,new n.Vector3;const A=new L,l=new r.Quaternion,c=new n.Vector3,u={},f=new n.Matrix4,d=[],h=[],p=[],m=[];for(let r=0;r<a;r++){let i;if(t.hasProperty("POSITION"))i=t.getProperty("POSITION",Yp.FLOAT,3,r,s);else if(t.hasProperty("POSITION_QUANTIZED")){i=t.getProperty("POSITION_QUANTIZED",Yp.UNSIGNED_SHORT,3,r,s);const e=t.getGlobalProperty("QUANTIZED_VOLUME_OFFSET",Yp.FLOAT,3);if(!e)throw new Error("i3dm parser: QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.");const n=t.getGlobalProperty("QUANTIZED_VOLUME_SCALE",Yp.FLOAT,3);if(!n)throw new Error("i3dm parser: QUANTIZED_VOLUME_SCALE must be defined for quantized positions.");const a=65535;for(let t=0;t<3;t++)i[t]=i[t]/a*n[t]+e[t]}if(!i)throw new Error("i3dm: POSITION or POSITION_QUANTIZED must be defined for each instance.");if(s.copy(i),u.translation=s,e.normalUp=t.getProperty("NORMAL_UP",Yp.FLOAT,3,r,d),e.normalRight=t.getProperty("NORMAL_RIGHT",Yp.FLOAT,3,r,h),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",Yp.UNSIGNED_SHORT,2,r,d),e.octNormalRight=t.getProperty("NORMAL_RIGHT_OCT32P",Yp.UNSIGNED_SHORT,2,r,h),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?(Eh.WGS84.eastNorthUpToFixedFrame(s,f),f.getRotationMatrix3(A)):A.identity()}l.fromMatrix3(A),u.rotation=l,c.set(1,1,1);const a=t.getProperty("SCALE",Yp.FLOAT,1,r,p);Number.isFinite(a)&&c.multiplyByScalar(a);const g=t.getProperty("SCALE_NON_UNIFORM",Yp.FLOAT,3,r,d);g&&c.scale(g),u.scale=c;let b=t.getProperty("BATCH_ID",Yp.UNSIGNED_SHORT,1,r,m);void 0===b&&(b=r);const v=(new n.Matrix4).fromQuaternion(u.rotation);f.identity(),f.translate(u.translation),f.multiplyRight(v),f.scale(u.scale);const y=f.clone();o[r]={modelMatrix:y,batchId:b}}e.instances=o}(e,o,new bm(e.batchTableJson,e.batchTableBinary,s),s),i}(e,t,i,a),await Pm(e,e.gltfFormat||0,a,o),i}async function Lm(e,t=0,n,r,i={shape:"tile3d"}){switch(i.byteOffset=t,i.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),i.type){case Wp.COMPOSITE:return await async function(e,t,n,r,i,a){for(n=vm(e,t,n),e.tilesLength=new DataView(t).getUint32(n,!0),n+=4,e.tiles=[];e.tiles.length<e.tilesLength&&(e.byteLength||0)-n>12;){const o={shape:"tile3d"};e.tiles.push(o),n=await a(t,n,r,i,o)}return n}(i,e,t,n,r,Lm);case Wp.BATCHED_3D_MODEL:return await Nm(i,e,t,n,r);case Wp.GLTF:return await async function(e,t,n,r){if(e.rotateYtoZ=!0,e.gltfUpAxis=n?.["3d-tiles"]?.assetGltfUpAxis?n["3d-tiles"].assetGltfUpAxis:"Y",n?.["3d-tiles"]?.loadGLTF){if(!r)return t.byteLength;const i=await s(t,Id,n,r);e.gltf=Hd(i),e.gpuMemoryUsageInBytes=Mc(e.gltf)}else e.gltfArrayBuffer=t;return t.byteLength}(i,e,n,r);case Wp.INSTANCED_3D_MODEL:return await km(i,e,t,n,r);case Wp.POINT_CLOUD:return await Mm(i,e,t,n,r);default:throw new Error(`3DTileLoader: unknown type ${i.type}`)}}async function Bm(e,t,n,r){const i=Number.isFinite(t.bitstream)?t.bitstream:t.bufferView;if("number"!=typeof i)return;const a=e.bufferViews[i],o=e.buffers[a.buffer];if(!r?.baseUrl)throw new Error("Url is not provided");if(!r.fetch)throw new Error("fetch is not provided");if(o.uri){const e=`${r?.baseUrl||""}/${o.uri}`,n=await(await r.fetch(e)).arrayBuffer();return void(t.explicitBitstream=new Uint8Array(n,a.byteOffset,a.byteLength))}const s=e.buffers.slice(0,a.buffer).reduce((e,t)=>e+t.byteLength,0);t.explicitBitstream=new Uint8Array(n.slice(s,s+o.byteLength),a.byteOffset,a.byteLength)}function Om(e){const t=new DataView(e);return t.getUint32(0,!0)+2**32*t.getUint32(4,!0)}var Fm={dataType:null,batchType:null,id:"3d-tiles-subtree",name:"3D Tiles Subtree",module:"3d-tiles",version:Kp,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 r=Om(e.slice(8,16)),i=new Uint8Array(e,24,r),a=new TextDecoder("utf8").decode(i),o=JSON.parse(a),s=Om(e.slice(16,24));let A=new ArrayBuffer(0);if(s&&(A=e.slice(24+r)),await Bm(o,o.tileAvailability,A,n),Array.isArray(o.contentAvailability))for(const l of o.contentAvailability)await Bm(o,l,A,n);else await Bm(o,o.contentAvailability,A,n);return await Bm(o,o.childSubtreeAvailability,A,n),o},options:{}},Dm=null;try{Dm=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 Um(e,t,n){this.low=0|e,this.high=0|t,this.unsigned=!!n}function Vm(e){return!0===(e&&e.__isLong__)}function jm(e){var t=Math.clz32(e&-e);return e?31-t:t}Um.prototype.__isLong__,Object.defineProperty(Um.prototype,"__isLong__",{value:!0}),Um.isLong=Vm;var zm={},Gm={};function Hm(e,t){var n,r,i;return t?(i=0<=(e>>>=0)&&e<256)&&(r=Gm[e])?r:(n=Qm(e,0,!0),i&&(Gm[e]=n),n):(i=-128<=(e|=0)&&e<128)&&(r=zm[e])?r:(n=Qm(e,e<0?-1:0,!1),i&&(zm[e]=n),n)}function qm(e,t){if(isNaN(e))return t?tg:eg;if(t){if(e<0)return tg;if(e>=Ym)return og}else{if(e<=-Xm)return sg;if(e+1>=Xm)return ag}return e<0?qm(-e,t).neg():Qm(e%Jm|0,e/Jm|0,t)}function Qm(e,t,n){return new Um(e,t,n)}Um.fromInt=Hm,Um.fromNumber=qm,Um.fromBits=Qm;var Km=Math.pow;function Wm(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?tg:eg;if((n=n||10)<2||36<n)throw RangeError("radix");var r;if((r=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===r)return Wm(e.substring(1),t,n).neg();for(var i=qm(Km(n,8)),a=eg,o=0;o<e.length;o+=8){var s=Math.min(8,e.length-o),A=parseInt(e.substring(o,o+s),n);if(s<8){var l=qm(Km(n,s));a=a.mul(l).add(qm(A))}else a=(a=a.mul(i)).add(qm(A))}return a.unsigned=t,a}function $m(e,t){return"number"==typeof e?qm(e,t):"string"==typeof e?Wm(e,t):Qm(e.low,e.high,"boolean"==typeof t?t:e.unsigned)}Um.fromString=Wm,Um.fromValue=$m;var Jm=4294967296,Ym=Jm*Jm,Xm=Ym/2,Zm=Hm(1<<24),eg=Hm(0);Um.ZERO=eg;var tg=Hm(0,!0);Um.UZERO=tg;var ng=Hm(1);Um.ONE=ng;var rg=Hm(1,!0);Um.UONE=rg;var ig=Hm(-1);Um.NEG_ONE=ig;var ag=Qm(-1,2147483647,!1);Um.MAX_VALUE=ag;var og=Qm(-1,-1,!0);Um.MAX_UNSIGNED_VALUE=og;var sg=Qm(0,-2147483648,!1);Um.MIN_VALUE=sg;var Ag=Um.prototype;Ag.toInt=function(){return this.unsigned?this.low>>>0:this.low},Ag.toNumber=function(){return this.unsigned?(this.high>>>0)*Jm+(this.low>>>0):this.high*Jm+(this.low>>>0)},Ag.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(sg)){var t=qm(e),n=this.div(t),r=n.mul(t).sub(this);return n.toString(e)+r.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var i=qm(Km(e,6),this.unsigned),a=this,o="";;){var s=a.div(i),A=(a.sub(s.mul(i)).toInt()>>>0).toString(e);if((a=s).isZero())return A+o;for(;A.length<6;)A="0"+A;o=""+A+o}},Ag.getHighBits=function(){return this.high},Ag.getHighBitsUnsigned=function(){return this.high>>>0},Ag.getLowBits=function(){return this.low},Ag.getLowBitsUnsigned=function(){return this.low>>>0},Ag.getNumBitsAbs=function(){if(this.isNegative())return this.eq(sg)?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},Ag.isSafeInteger=function(){var e=this.high>>21;return!e||!this.unsigned&&(-1===e&&!(0===this.low&&-2097152===this.high))},Ag.isZero=function(){return 0===this.high&&0===this.low},Ag.eqz=Ag.isZero,Ag.isNegative=function(){return!this.unsigned&&this.high<0},Ag.isPositive=function(){return this.unsigned||this.high>=0},Ag.isOdd=function(){return!(1&~this.low)},Ag.isEven=function(){return!(1&this.low)},Ag.equals=function(e){return Vm(e)||(e=$m(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&(this.high===e.high&&this.low===e.low)},Ag.eq=Ag.equals,Ag.notEquals=function(e){return!this.eq(e)},Ag.neq=Ag.notEquals,Ag.ne=Ag.notEquals,Ag.lessThan=function(e){return this.comp(e)<0},Ag.lt=Ag.lessThan,Ag.lessThanOrEqual=function(e){return this.comp(e)<=0},Ag.lte=Ag.lessThanOrEqual,Ag.le=Ag.lessThanOrEqual,Ag.greaterThan=function(e){return this.comp(e)>0},Ag.gt=Ag.greaterThan,Ag.greaterThanOrEqual=function(e){return this.comp(e)>=0},Ag.gte=Ag.greaterThanOrEqual,Ag.ge=Ag.greaterThanOrEqual,Ag.compare=function(e){if(Vm(e)||(e=$m(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},Ag.comp=Ag.compare,Ag.negate=function(){return!this.unsigned&&this.eq(sg)?sg:this.not().add(ng)},Ag.neg=Ag.negate,Ag.add=function(e){Vm(e)||(e=$m(e));var t=this.high>>>16,n=65535&this.high,r=this.low>>>16,i=65535&this.low,a=e.high>>>16,o=65535&e.high,s=e.low>>>16,A=0,l=0,c=0,u=0;return c+=(u+=i+(65535&e.low))>>>16,l+=(c+=r+s)>>>16,A+=(l+=n+o)>>>16,A+=t+a,Qm((c&=65535)<<16|(u&=65535),(A&=65535)<<16|(l&=65535),this.unsigned)},Ag.subtract=function(e){return Vm(e)||(e=$m(e)),this.add(e.neg())},Ag.sub=Ag.subtract,Ag.multiply=function(e){if(this.isZero())return this;if(Vm(e)||(e=$m(e)),Dm)return Qm(Dm.mul(this.low,this.high,e.low,e.high),Dm.get_high(),this.unsigned);if(e.isZero())return this.unsigned?tg:eg;if(this.eq(sg))return e.isOdd()?sg:eg;if(e.eq(sg))return this.isOdd()?sg:eg;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(Zm)&&e.lt(Zm))return qm(this.toNumber()*e.toNumber(),this.unsigned);var t=this.high>>>16,n=65535&this.high,r=this.low>>>16,i=65535&this.low,a=e.high>>>16,o=65535&e.high,s=e.low>>>16,A=65535&e.low,l=0,c=0,u=0,f=0;return u+=(f+=i*A)>>>16,c+=(u+=r*A)>>>16,u&=65535,c+=(u+=i*s)>>>16,l+=(c+=n*A)>>>16,c&=65535,l+=(c+=r*s)>>>16,c&=65535,l+=(c+=i*o)>>>16,l+=t*A+n*s+r*o+i*a,Qm((u&=65535)<<16|(f&=65535),(l&=65535)<<16|(c&=65535),this.unsigned)},Ag.mul=Ag.multiply,Ag.divide=function(e){if(Vm(e)||(e=$m(e)),e.isZero())throw Error("division by zero");if(Dm)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?Qm((this.unsigned?Dm.div_u:Dm.div_s)(this.low,this.high,e.low,e.high),Dm.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?tg:eg;var t,n,r;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return tg;if(e.gt(this.shru(1)))return rg;r=tg}else{if(this.eq(sg))return e.eq(ng)||e.eq(ig)?sg:e.eq(sg)?ng:(t=this.shr(1).div(e).shl(1)).eq(eg)?e.isNegative()?ng:ig:(n=this.sub(e.mul(t)),r=t.add(n.div(e)));if(e.eq(sg))return this.unsigned?tg:eg;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=eg}for(n=this;n.gte(e);){t=Math.max(1,Math.floor(n.toNumber()/e.toNumber()));for(var i=Math.ceil(Math.log(t)/Math.LN2),a=i<=48?1:Km(2,i-48),o=qm(t),s=o.mul(e);s.isNegative()||s.gt(n);)s=(o=qm(t-=a,this.unsigned)).mul(e);o.isZero()&&(o=ng),r=r.add(o),n=n.sub(s)}return r},Ag.div=Ag.divide,Ag.modulo=function(e){return Vm(e)||(e=$m(e)),Dm?Qm((this.unsigned?Dm.rem_u:Dm.rem_s)(this.low,this.high,e.low,e.high),Dm.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},Ag.mod=Ag.modulo,Ag.rem=Ag.modulo,Ag.not=function(){return Qm(~this.low,~this.high,this.unsigned)},Ag.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},Ag.clz=Ag.countLeadingZeros,Ag.countTrailingZeros=function(){return this.low?jm(this.low):jm(this.high)+32},Ag.ctz=Ag.countTrailingZeros,Ag.and=function(e){return Vm(e)||(e=$m(e)),Qm(this.low&e.low,this.high&e.high,this.unsigned)},Ag.or=function(e){return Vm(e)||(e=$m(e)),Qm(this.low|e.low,this.high|e.high,this.unsigned)},Ag.xor=function(e){return Vm(e)||(e=$m(e)),Qm(this.low^e.low,this.high^e.high,this.unsigned)},Ag.shiftLeft=function(e){return Vm(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?Qm(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):Qm(0,this.low<<e-32,this.unsigned)},Ag.shl=Ag.shiftLeft,Ag.shiftRight=function(e){return Vm(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?Qm(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):Qm(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},Ag.shr=Ag.shiftRight,Ag.shiftRightUnsigned=function(e){return Vm(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?Qm(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):Qm(32===e?this.high:this.high>>>e-32,0,this.unsigned)},Ag.shru=Ag.shiftRightUnsigned,Ag.shr_u=Ag.shiftRightUnsigned,Ag.rotateLeft=function(e){var t;return Vm(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?Qm(this.high,this.low,this.unsigned):e<32?(t=32-e,Qm(this.low<<e|this.high>>>t,this.high<<e|this.low>>>t,this.unsigned)):(t=32-(e-=32),Qm(this.high<<e|this.low>>>t,this.low<<e|this.high>>>t,this.unsigned))},Ag.rotl=Ag.rotateLeft,Ag.rotateRight=function(e){var t;return Vm(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?Qm(this.high,this.low,this.unsigned):e<32?(t=32-e,Qm(this.high<<t|this.low>>>e,this.low<<t|this.high>>>e,this.unsigned)):(t=32-(e-=32),Qm(this.low<<t|this.high>>>e,this.high<<t|this.low>>>e,this.unsigned))},Ag.rotr=Ag.rotateRight,Ag.toSigned=function(){return this.unsigned?Qm(this.low,this.high,!1):this},Ag.toUnsigned=function(){return this.unsigned?this:Qm(this.low,this.high,!0)},Ag.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},Ag.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]},Ag.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]},Um.fromBytes=function(e,t,n){return n?Um.fromBytesLE(e,t):Um.fromBytesBE(e,t)},Um.fromBytesLE=function(e,t){return new Um(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},Um.fromBytesBE=function(e,t){return new Um(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&&(Um.fromBigInt=function(e,t){return Qm(Number(BigInt.asIntN(32,e)),Number(BigInt.asIntN(32,e>>BigInt(32))),t)},Um.fromValue=function(e,t){return"bigint"==typeof e?Um.fromBigInt(e,t):$m(e,t)},Ag.toBigInt=function(){var e=BigInt(this.low>>>0);return BigInt(this.unsigned?this.high>>>0:this.high)<<BigInt(32)|e});function lg(e){"X"===e&&(e="");const t=e.padEnd(16,"0");return Um.fromString(t,!0,16)}var cg=180/Math.PI;function ug(e,t,n){const r=1<<t;return[(e[0]+n[0])/r,(e[1]+n[1])/r]}function fg(e){return e>=.5?1/3*(4*e*e-1):1/3*(1-4*(1-e)*(1-e))}function dg(e){return[fg(e[0]),fg(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 pg([e,t,n]){const r=Math.atan2(n,Math.sqrt(e*e+t*t));return[Math.atan2(t,e)*cg,r*cg]}function mg(e,t,n,r){if(0===r){1===n&&(t[0]=e-1-t[0],t[1]=e-1-t[1]);const r=t[0];t[0]=t[1],t[1]=r}}function gg(e){const{face:t,ij:n,level:r}=e,i=[[0,0],[0,1],[1,1],[1,0],[0,0]],a=Math.max(1,Math.ceil(100*Math.pow(2,-r))),o=new Float64Array(4*a*2+2);let s=0,A=0;for(let l=0;l<4;l++){const e=i[l].slice(0),c=i[l+1],u=(c[0]-e[0])/a,f=(c[1]-e[1])/a;for(let i=0;i<a;i++){e[0]+=u,e[1]+=f;const i=pg(hg(t,dg(ug(n,r,e))));Math.abs(i[1])>89.999&&(i[0]=A);const a=i[0]-A;i[0]+=a>180?-360:a<-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 bg(e){const t=function(e){if(e.indexOf("/")>0)return e;const t=lg(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"),r=t.substring(0,3),i=t.substring(3,n),a=i.length/2,o=Um.fromString(r,!0,2).toString(10);let s="";if(0!==a)for(s=Um.fromString(i,!0,2).toString(4);s.length<a;)s="0"+s;return`${o}/${s}`}(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),r=t[1],i=r.length;let a=0;const o=[0,0];for(let s=i-1;s>=0;s--){a=i-s;const e=r[s];let t=0,n=0;"1"===e?n=1:"2"===e?(t=1,n=1):"3"===e&&(t=1);const A=Math.pow(2,a-1);mg(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:a}}(t)}function vg(e){return function(e){const t=dg(ug(e.ij,e.level,[.5,.5]));return pg(hg(e.face,t))}(bg(e))}function yg(e){if(e.length%2!=0)throw new Error("Invalid corners");const t=[],n=[];for(let r=0;r<e.length;r+=2)t.push(e[r]),n.push(e[r+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 xg(e,t){const r=t?.minimumHeight||0,i=t?.maximumHeight||0,a=function(e){let t;if(2===e.face||5===e.face){let n=null,r=0;for(let t=0;t<4;t++){const i=gg(bg(`${e.face}/${t}`));null==n&&(n=new Float64Array(4*i.length)),n.set(i,r),r+=i.length}t=yg(n)}else t=yg(gg(e));return t}(bg(e)),o=a.west,s=a.south,A=a.east,l=a.north,c=[];return c.push(new n.Vector3(o,l,r)),c.push(new n.Vector3(A,l,r)),c.push(new n.Vector3(A,s,r)),c.push(new n.Vector3(o,s,r)),c.push(new n.Vector3(o,l,i)),c.push(new n.Vector3(A,l,i)),c.push(new n.Vector3(A,s,i)),c.push(new n.Vector3(o,s,i)),c}function _g(e){const t=e.token,r={minimumHeight:e.minimumHeight,maximumHeight:e.maximumHeight},i=xg(t,r),a=vg(t),o=a[0],s=a[1],A=Eh.WGS84.cartographicToCartesian([o,s,r.maximumHeight]),l=new n.Vector3(A[0],A[1],A[2]);i.push(l);const c=aA(i);return[...c.center,...c.halfAxes]}var wg={QUADTREE:4,OCTREE:8};function Tg(e,t,n){if(e?.box){const r=function(e,t){const n=function(e){return e.and(e.not().add(1))}(e).shiftRightUnsigned(2);return e.add(Um.fromNumber(2*t+1-4).multiply(n))}(lg(e.s2VolumeInfo.token),t),i=function(e){if(e.isZero())return"X";let t=e.countTrailingZeros();t=(t-t%4)/4;const n=t;t*=4;const r=e.shiftRightUnsigned(t).toString(16).replace(/0+$/,"");return Array(17-n-r.length).join("0")+r}(r),a={...e.s2VolumeInfo};if(a.token=i,"OCTREE"===n){const t=e.s2VolumeInfo,n=t.maximumHeight-t.minimumHeight,r=n/2,i=t.minimumHeight+n/2;t.minimumHeight=i-r,t.maximumHeight=i+r}return{box:_g(a),s2VolumeInfo:a}}}async function Sg(e){const{subtree:t,subtreeData:r={level:0,x:0,y:0,z:0},parentData:i={mortonIndex:0,localLevel:-1,localX:0,localY:0,localZ:0},childIndex:a=0,implicitOptions:o,loaderOptions:s,s2VolumeBox:l}=e,{subdivisionScheme:c,subtreeLevels:u,maximumLevel:f,contentUrlTemplate:d,subtreesUriTemplate:h,basePath:p}=o,m={children:[],lodMetricValue:0,contentUrl:""};if("number"!=typeof f||!Number.isFinite(f))return A.once(`Missing 'maximumLevel' or 'availableLevels' property. The subtree ${d} won't be loaded...`),m;const g=i.localLevel+1,b=r.level+g;if(b>f)return m;const v=wg[c],y=Math.log2(v),x=1&a,_=a>>1&1,w=a>>2&1,T=Eg(i.localX,x,1),S=Eg(i.localY,_,1),M=Eg(i.localZ,w,1),E=Eg(r.x,T,g),C=Eg(r.y,S,g),I=Eg(r.z,M,g),R=Eg(i.mortonIndex,a,y);let P,N,k,L;if(g===u&&Mg(t.childSubtreeAvailability,R)){const e=Cg(`${p}/${h}`,b,E,C,I);P=await n.load(e,Fm,s),L=0,N={level:b,x:E,y:C,z:I},k={mortonIndex:0,localLevel:0,localX:0,localY:0,localZ:0}}else P=t,L=(v**g-1)/(v-1)+R,N=r,k={mortonIndex:R,localLevel:g,localX:T,localY:S,localZ:M};if(!Mg(P.tileAvailability,L))return m;Mg(P.contentAvailability,L)&&(m.contentUrl=Cg(d,b,E,C,I));for(let n=0;n<v;n++){const e=Tg(l,n,c),t=await Sg({subtree:P,subtreeData:N,parentData:k,childIndex:n,implicitOptions:o,loaderOptions:s,s2VolumeBox:e});(t.contentUrl||t.children.length)&&m.children.push(t)}return m.contentUrl||m.children.length?function(e,t,n,r){const{basePath:i,refine:a,getRefine:o,lodMetricType:s,getTileType:A,rootLodMetricValue:l,rootBoundingVolume:c}=n,u=e.contentUrl&&e.contentUrl.replace(`${i}/`,""),f=l/2**t.level,d=function(e,t,n){if(e.region){const{level:r,x:i,y:a,z:o}=t,[s,A,l,c,u,f]=e.region,d=2**r,h=(l-s)/d,[p,m]=[s+h*i,s+h*(i+1)],g=(c-A)/d,[b,v]=[A+g*a,A+g*(a+1)];let y,x;if("OCTREE"===n){const e=(f-u)/d;[y,x]=[u+e*o,u+e*(o+1)]}else[y,x]=[u,f];return{region:[p,b,m,v,y,x]}}if(e.box)return e;throw new Error(`Unsupported bounding volume type ${JSON.stringify(e)}`)}(r?.box?{box:r.box}:c,t,n.subdivisionScheme);return{children:e.children,contentUrl:e.contentUrl,content:{uri:u},id:e.contentUrl,refine:o(a),type:A(e),lodMetricType:s,lodMetricValue:f,geometricError:f,transform:e.transform,boundingVolume:d}}(m,{level:b,x:E,y:C,z:I},o,l):m}function Mg(e,t){let n;return Array.isArray(e)?(n=e[0],e.length>1&&A.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),r=e%8;return 1==(t[n]>>r&1)}(t,n.explicitBitstream)}function Eg(e,t,n){return(e<<n)+t}function Cg(e,t,n,r,i){const a=function(e){const t={};for(const n in e)t[`{${n}}`]=e[n];return t}({level:t,x:n,y:r,z:i});return e.replace(/{level}|{x}|{y}|{z}/gi,e=>a[e])}function Ig(e,t=""){if(!t)return Hh.EMPTY;const n=t.split("?")[0].split(".").pop();switch(n){case"pnts":return Hh.POINTCLOUD;case"i3dm":case"b3dm":case"glb":case"gltf":return Hh.SCENEGRAPH;default:return n||Hh.EMPTY}}function Rg(e){switch(e){case"REPLACE":case"replace":return Gh.REPLACE;case"ADD":case"add":return Gh.ADD;default:return e}}function Pg(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:n.resolve(t,e)}function Ng(e,t){if(!e)return null;let n;if(e.content){const r=e.content.uri||e.content?.url;void 0!==r&&(n=Pg(r,t))}return{...e,id:n,contentUrl:n,lodMetricType:Qh.GEOMETRIC_ERROR,lodMetricValue:e.geometricError,transformMatrix:e.transform,type:Ig(0,n),refine:Rg(e.refine)}}async function kg(e,t,r,i,a){const{subdivisionScheme:o,maximumLevel:s,availableLevels:A,subtreeLevels:l,subtrees:{uri:c}}=i,u=Pg(Cg(c,0,0,0,0),r),f=await n.load(u,Fm,a),d=e.content?.uri,h=d?Pg(d,r):"",p=t?.root?.refine,m=e.geometricError,g=e.boundingVolume.extensions?.["3DTILES_bounding_volume_S2"];g&&(e.boundingVolume={box:_g(g),s2VolumeInfo:g});const b=e.boundingVolume;return await async function(e,t,n,r,i){if(!e)return null;const{children:a,contentUrl:o}=await Sg({subtree:n,implicitOptions:r,loaderOptions:i});let s,A=null;o&&(s=o,A={uri:o.replace(`${t}/`,"")});return{...e,id:s,contentUrl:s,lodMetricType:Qh.GEOMETRIC_ERROR,lodMetricValue:e.geometricError,transformMatrix:e.transform,type:Ig(0,s),refine:Rg(e.refine),content:A||e.content,children:a}}(e,r,f,{contentUrlTemplate:h,subtreesUriTemplate:c,subdivisionScheme:o,subtreeLevels:l,maximumLevel:Number.isFinite(A)?A-1:s,refine:p,basePath:r,lodMetricType:Qh.GEOMETRIC_ERROR,rootLodMetricValue:m,rootBoundingVolume:b,getTileType:Ig,getRefine:Rg},a)}function Lg(e){return e?.extensions?.["3DTILES_implicit_tiling"]||e?.implicitTiling}var Bg={dataType:null,batchType:null,id:"3d-tiles",name:"3D Tiles",module:"3d-tiles",version:Kp,extensions:["cmpt","pnts","b3dm","i3dm"],mimeTypes:["application/octet-stream"],tests:["cmpt","pnts","b3dm","i3dm"],parse:async function(e,t={},r){const i=t["3d-tiles"]||{};let a;a="auto"===i.isTileset?r?.url&&-1!==r.url.indexOf(".json"):i.isTileset;return a?async function(e,t,r){const i=JSON.parse((new TextDecoder).decode(e)),a=r?.url||"",o=function(e){return n.dirname(e)}(a),s=await async function(e,t,n){let r=null;const i=Lg(e.root);r=i&&e.root?await kg(e.root,e,t,i,n):Ng(e.root,t);const a=[];for(a.push(r);a.length>0;){const r=a.pop()||{},i=r.children||[],o=[];for(const s of i){const r=Lg(s);let i;i=r?await kg(s,e,t,r,n):Ng(s,t),i&&(o.push(i),a.push(i))}r.children=o}return r}(i,o,t||{});return{...i,shape:"tileset3d",loader:Bg,url:a,queryString:r?.queryString||"",basePath:o,root:s||i.root,type:qh.TILES3D,lodMetricType:Qh.GEOMETRIC_ERROR,lodMetricValue:i.root?.geometricError||0}}(e,t,r):async function(e,t,n){const r={content:{shape:"tile3d",featureIds:null}};return await Lm(e,0,t,n,r.content),r.content}(e,t,r)},options:{"3d-tiles":{loadGLTF:!0,decodeQuantizedPositions:!1,isTileset:"auto",assetGltfUpAxis:null}}};var Og=[0],Fg={[-1]:n.COORDINATE_SYSTEM.DEFAULT,0:n.COORDINATE_SYSTEM.CARTESIAN,1:n.COORDINATE_SYSTEM.LNGLAT,2:n.COORDINATE_SYSTEM.METER_OFFSETS,3:n.COORDINATE_SYSTEM.LNGLAT_OFFSETS};function Dg(e){return"number"==typeof e?Fg[e]??e:e}var Ug={getPointColor:{type:"accessor",value:[0,0,0,255]},pointSize:1,data:"",loader:Bg,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]}},Vg=class extends t.CompositeLayer{initializeState(){"onTileLoadFail"in this.props&&n.defaultLogger.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 r=n?.[e.id];r&&e.equals(r)||(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:r}){const{tile:i}=e.props,{id:a}=t;if(!i.selected||!i.viewportIds.includes(a))return!1;if(r&&n&&i.content?.cartographicOrigin){const[e,r]=t.project(i.content.cartographicOrigin),a=n.x+n.width/2,o=n.y+n.height/2,s=Math.max(t.width,t.height)/4,A=e-a,l=r-o;if(A*A+l*l>s*s)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||{},r=this.props.loaders?.length?this.props.loaders:this.props.loader,i=Array.isArray(r)?r[0]:r,{tileset:a,...o}=t,s={loadOptions:{...o},...a};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 l=await n.load(A,i,s.loadOptions),c=new Qp(l,{onTileLoad:this._onTileLoad.bind(this),onTileUnload:this._onTileUnload.bind(this),onTileError:this.props.onTileError,onUpdate:()=>this.setNeedsUpdate(),...s});this.setState({tileset3d:c,layerMap:{}}),this._updateTileset(this.state.activeViewports),this.props.onTilesetLoad(c)}_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,r=Object.keys(e).length;n&&r&&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 Hh.POINTCLOUD:return this._makePointCloudLayer(e,t);case Hh.SCENEGRAPH:return this._make3DModelLayer(e);case Hh.MESH:return this._makeSimpleMeshLayer(e,t);default:throw new Error(`Tile3DLayer: Failed to render layer of type ${e.content.type}`)}}_makePointCloudLayer(e,r){const{attributes:i,pointCount:a,constantRGBA:o,cartographicOrigin:s,modelMatrix:A}=e.content,{positions:l,normals:c,colors:u}=i;if(!l)return null;const f=r&&r.props.data||{header:{vertexCount:a},attributes:{POSITION:l,NORMAL:c,COLOR_0:u}},{pointSize:d,getPointColor:h}=this.props;return new(this.getSubLayerClass("pointcloud",t.PointCloudLayer))({pointSize:d},this.getSubLayerProps({id:"pointcloud"}),{id:`${this.id}-pointcloud-${e.id}`,tile:e,data:f,coordinateSystem:n.COORDINATE_SYSTEM.METER_OFFSETS,coordinateOrigin:s,modelMatrix:A,getColor:o||h,_offset:0})}_make3DModelLayer(e){const{gltf:t,instances:r,cartographicOrigin:i,modelMatrix:a}=e.content;return new(this.getSubLayerClass("scenegraph",Xd))({_lighting:"pbr"},this.getSubLayerProps({id:"scenegraph"}),{id:`${this.id}-scenegraph-${e.id}`,tile:e,data:r||Og,scenegraph:t,coordinateSystem:n.COORDINATE_SYSTEM.METER_OFFSETS,coordinateOrigin:i,modelMatrix:a,getTransformMatrix:e=>e.modelMatrix,getPosition:[0,0,0],_offset:0,onFirstDraw:()=>{e.tileDrawn=!0}})}_makeSimpleMeshLayer(e,r){const{attributes:i,indices:a,modelMatrix:o,cartographicOrigin:s,coordinateSystem:A=n.COORDINATE_SYSTEM.METER_OFFSETS,material:l,featureIds:c}=e.content,{_getMeshColor:u}=this.props,f=r&&r.props.mesh||new t.Geometry({topology:"triangle-list",attributes:jg(i),indices:a});return new(this.getSubLayerClass("mesh",rh))(this.getSubLayerProps({id:"mesh"}),{id:`${this.id}-mesh-${e.id}`,tile:e,mesh:f,data:Og,getColor:u(e),pbrMaterial:l,modelMatrix:o,coordinateOrigin:s,coordinateSystem:Dg(A),featureIds:c,_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:r}=n;return e.selected&&(r?n.needsUpdate&&(r=this._getSubLayer(e,r),n.needsUpdate=!1):r=this._getSubLayer(e)),n.layer=r,r}).filter(Boolean):null}};function jg(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}Vg.defaultProps=Ug,Vg.layerName="Tile3DLayer";var zg={dataType:null,batchType:null,name:"Terrain",id:"terrain",module:"terrain",version:"4.5.4",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}}},Gg=[1],Hg={...BA.defaultProps,elevationData:dA,texture:{...dA,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:[zg]};function qg(e){return Array.isArray(e)?e.join(";"):e||""}var Qg=class extends t.CompositeLayer{updateState({props:e,oldProps:t}){const r=e.elevationData!==t.elevationData;if(r){const{elevationData:t}=e,n=t&&(Array.isArray(t)||Kg(t));this.setState({isTiled:n})}const i=r||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&&n.defaultLogger.removed("workerUrl","loadOptions.terrain.workerUrl")()}loadTerrain({elevationData:e,bounds:t,elevationDecoder:n,meshMaxError:r,signal:i}){if(!e)return null;const a=function(e){return!Number.isFinite(e)||e<=0?1:Math.max(e,1)}(r);let o=this.getLoadOptions();o={...o,terrain:{skirtHeight:this.state.isTiled?2*a:0,...o?.terrain,bounds:t,meshMaxError:a,elevationDecoder:n}};const{fetch:s}=this.props;return s(e,{propName:"elevationData",layer:this,loadOptions:o,signal:i})}getTiledTerrainData(e){const{elevationData:t,fetch:n,texture:i,elevationDecoder:a,meshMaxError:o}=this.props,{viewport:s}=this.context,A=pA(t,e),l=i&&pA(i,e),{signal:c}=e;let u=[0,0],f=[0,0];if(s.isGeospatial){const t=e.bbox;u=s.projectFlat([t.west,t.south]),f=s.projectFlat([t.east,t.north])}else{const t=e.bbox;u=[t.left,t.bottom],f=[t.right,t.top]}const d=function(e,t,n){const r=(e[2]-e[0])/t*1,i=(e[3]-e[1])/t*1,a=[e[0]-r,e[1]-i,e[2]+r,e[3]+i];return n?[Math.max(a[0],-180),Math.max(a[1],-90),Math.min(a[2],180),Math.min(a[3],90)]:a}([u[0],u[1],f[0],f[1]],this.props.tileSize,s instanceof r.GlobeViewport),h=this.loadTerrain({elevationData:A,bounds:d,elevationDecoder:a,meshMaxError:o,signal:c}),p=l?n(l,{propName:"texture",layer:this,loaders:[],signal:c}).catch(e=>null):Promise.resolve(null);return Promise.all([h,p])}renderSubLayers(e){const t=this.getSubLayerClass("mesh",nl),{color:i,wireframe:a,material:o}=this.props,{data:s}=e;if(!s)return null;const[A,l]=s,{viewport:c}=this.context,u=c instanceof r.GlobeViewport,f=A?.header?.boundingBox,d=f&&f.every(([e,t])=>e>=-180&&e<=180&&t>=-90&&t<=90),h=u&&d?n.COORDINATE_SYSTEM.LNGLAT:n.COORDINATE_SYSTEM.CARTESIAN;return new t(e,{data:Gg,mesh:A,texture:l,_instanced:!1,coordinateSystem:h,getPosition:e=>[0,0,0],getColor:i,wireframe:a,material:o})}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 r=Math.min(...n.map(e=>e[0])),i=Math.max(...n.map(e=>e[1]));(!t||r<t[0]||i>t[1])&&this.setState({zRange:[r,i]})}renderLayers(){const{color:e,material:t,elevationData:n,texture:r,wireframe:i,meshMaxError:a,elevationDecoder:o,tileSize:s,maxZoom:A,minZoom:l,extent:c,maxRequests:u,onTileLoad:f,onTileUnload:d,onTileError:h,maxCacheSize:p,maxCacheByteSize:m,refinementStrategy:g,zoomOffset:b}=this.props;return this.state.isTiled?new BA(this.getSubLayerProps({id:"tiles"}),{getTileData:this.getTiledTerrainData.bind(this),renderSubLayers:this.renderSubLayers.bind(this),updateTriggers:{getTileData:{elevationData:qg(n),texture:qg(r),meshMaxError:a,elevationDecoder:o,projectionMode:this.context.viewport.projectionMode,zoomOffset:b}},onViewportLoad:this.onViewportLoad.bind(this),zRange:this.state.zRange||null,tileSize:s,maxZoom:A,minZoom:l,extent:c,maxRequests:u,onTileLoad:f,onTileUnload:d,onTileError:h,maxCacheSize:p,maxCacheByteSize:m,refinementStrategy:g,zoomOffset:b}):n?new(this.getSubLayerClass("mesh",nl))(this.getSubLayerProps({id:"mesh"}),{data:Gg,mesh:this.state.terrain,texture:r,_instanced:!1,getPosition:e=>[0,0,0],getColor:e,material:t,wireframe:i}):null}};Qg.defaultProps=Hg,Qg.layerName="TerrainLayer";var Kg=e=>e.includes("{x}")&&(e.includes("{y}")||e.includes("{-y}")),Wg="\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",$g={name:"clip",vs:Wg,uniformTypes:{bounds:"vec4<f32>"}},Jg={"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"},Yg={name:"clip",fs:Wg,uniformTypes:{bounds:"vec4<f32>"}},Xg={"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"},Zg=class extends Le{getShaders(){let e="instancePositions"in this.getAttributeManager().attributes;return void 0!==this.props.clipByInstance&&(e=Boolean(this.props.clipByInstance)),this.state.clipByInstance=e,"webgpu"===this.context.device.type?{}:e?{modules:[$g],inject:Jg}:{modules:[Yg],inject:Xg}}draw(){const{clipBounds:e}=this.props,t={};if(this.state.clipByInstance)t.bounds=e;else{const n=this.projectPosition([e[0],e[1],0]),r=this.projectPosition([e[2],e[3],0]);t.bounds=[Math.min(n[0],r[0]),Math.min(n[1],r[1]),Math.max(n[0],r[0]),Math.max(n[1],r[1])]}"webgpu"===this.context.device.type&&(t.enabled=!0,t.mode=this.state.clipByInstance?"instance":"geometry"),this.setShaderModuleProps({clip:t})}};function eb(e,t,n){switch(e.type){case"Point":return function(e,t,n){const{positions:r}=e,i=nb(r,t,n);return i.length>1?{type:"MultiPoint",coordinates:i}:{type:"Point",coordinates:i[0]}}(e,t,n);case"LineString":return function(e,t=-1/0,n=1/0){const{positions:r}=e,i=e.pathIndices.value.filter(e=>e>=t&&e<=n);if(!(i.length>2))return{type:"LineString",coordinates:nb(r,i[0],i[1])};const a=[];for(let o=0;o<i.length-1;o++){const e=nb(r,i[o],i[o+1]);a.push(e)}return{type:"MultiLineString",coordinates:a}}(e,t,n);case"Polygon":return tb(e,t,n);default:throw new Error(`Unsupported geometry type: ${e?.type}`)}}function tb(e,t=-1/0,n=1/0){const{positions:r}=e,i=e.polygonIndices.value.filter(e=>e>=t&&e<=n),a=e.primitivePolygonIndices.value.filter(e=>e>=t&&e<=n);if(!(i.length>2)){const e=[];for(let t=0;t<a.length-1;t++){const n=nb(r,a[t],a[t+1]);e.push(n)}return{type:"Polygon",coordinates:e}}const o=[];for(let s=0;s<i.length-1;s++){const t=tb(e,i[s],i[s+1]).coordinates;o.push(t)}return{type:"MultiPolygon",coordinates:o}}function nb(e,t,n){t=t||0,n=n||e.value.length/e.size;const r=[];for(let i=t;i<n;i++){const t=Array();for(let n=i*e.size;n<(i+1)*e.size;n++)t.push(Number(e.value[n]));r.push(t)}return r}function rb(e,t,n){const r=function(e){const t={};for(const n of e)if(n.properties)for(const e in n.properties){const r=n.properties[e];t[e]=ub(r,t[e])}return t}(e),i=Object.keys(r).filter(e=>r[e]!==Array);return function(e,t,n){const{pointPositionsCount:r,pointFeaturesCount:i,linePositionsCount:a,linePathsCount:o,lineFeaturesCount:s,polygonPositionsCount:A,polygonObjectsCount:l,polygonRingsCount:c,polygonFeaturesCount:u,propArrayTypes:f,coordLength:d}=t,{numericPropKeys:h=[],PositionDataType:p=Float32Array,triangulate:m=!0}=n,g=e[0]&&"id"in e[0],b=e.length>65535?Uint32Array:Uint16Array,v={type:"Point",positions:new p(r*d),globalFeatureIds:new b(r),featureIds:i>65535?new Uint32Array(r):new Uint16Array(r),numericProps:{},properties:[],fields:[]},y={type:"LineString",pathIndices:a>65535?new Uint32Array(o+1):new Uint16Array(o+1),positions:new p(a*d),globalFeatureIds:new b(a),featureIds:s>65535?new Uint32Array(a):new Uint16Array(a),numericProps:{},properties:[],fields:[]},x={type:"Polygon",polygonIndices:A>65535?new Uint32Array(l+1):new Uint16Array(l+1),primitivePolygonIndices:A>65535?new Uint32Array(c+1):new Uint16Array(c+1),positions:new p(A*d),globalFeatureIds:new b(A),featureIds:u>65535?new Uint32Array(A):new Uint16Array(A),numericProps:{},properties:[],fields:[]};m&&(x.triangles=[]);for(const w of[v,y,x])for(const e of h){const t=f[e];w.numericProps[e]=new t(w.positions.length/d)}y.pathIndices[o]=a,x.polygonIndices[l]=A,x.primitivePolygonIndices[c]=A;const _={pointPosition:0,pointFeature:0,linePosition:0,linePath:0,lineFeature:0,polygonPosition:0,polygonObject:0,polygonRing:0,polygonFeature:0,feature:0};for(const w of e){const e=w.geometry,t=w.properties||{};switch(e.type){case"Point":ib(e,v,_,d,t),v.properties.push(cb(t,h)),g&&v.fields.push({id:w.id}),_.pointFeature++;break;case"LineString":ab(e,y,_,d,t),y.properties.push(cb(t,h)),g&&y.fields.push({id:w.id}),_.lineFeature++;break;case"Polygon":ob(e,x,_,d,t),x.properties.push(cb(t,h)),g&&x.fields.push({id:w.id}),_.polygonFeature++;break;default:throw new Error("Invalid geometry type")}_.feature++}return function(e,t,n,r){const i={shape:"binary-feature-collection",points:{...e,positions:{value:e.positions,size:r},globalFeatureIds:{value:e.globalFeatureIds,size:1},featureIds:{value:e.featureIds,size:1},numericProps:Ab(e.numericProps,1)},lines:{...t,positions:{value:t.positions,size:r},pathIndices:{value:t.pathIndices,size:1},globalFeatureIds:{value:t.globalFeatureIds,size:1},featureIds:{value:t.featureIds,size:1},numericProps:Ab(t.numericProps,1)},polygons:{...n,positions:{value:n.positions,size:r},polygonIndices:{value:n.polygonIndices,size:1},primitivePolygonIndices:{value:n.primitivePolygonIndices,size:1},globalFeatureIds:{value:n.globalFeatureIds,size:1},featureIds:{value:n.featureIds,size:1},numericProps:Ab(n.numericProps,1)}};i.polygons&&n.triangles&&(i.polygons.triangles={value:new Uint32Array(n.triangles),size:1});return i}(v,y,x,d)}(e,{propArrayTypes:r,...t},{numericPropKeys:n&&n.numericPropKeys||i,PositionDataType:n?n.PositionDataType:Float32Array,triangulate:!n||n.triangulate})}function ib(e,t,n,r,i){t.positions.set(e.data,n.pointPosition*r);const a=e.data.length/r;lb(t,i,n.pointPosition,a),t.globalFeatureIds.fill(n.feature,n.pointPosition,n.pointPosition+a),t.featureIds.fill(n.pointFeature,n.pointPosition,n.pointPosition+a),n.pointPosition+=a}function ab(e,t,n,r,i){t.positions.set(e.data,n.linePosition*r);const a=e.data.length/r;lb(t,i,n.linePosition,a),t.globalFeatureIds.fill(n.feature,n.linePosition,n.linePosition+a),t.featureIds.fill(n.lineFeature,n.linePosition,n.linePosition+a);for(let o=0,s=e.indices.length;o<s;++o){const i=e.indices[o],a=o===s-1?e.data.length:e.indices[o+1];t.pathIndices[n.linePath++]=n.linePosition,n.linePosition+=(a-i)/r}}function ob(e,t,n,r,i){t.positions.set(e.data,n.polygonPosition*r);const a=e.data.length/r;lb(t,i,n.polygonPosition,a),t.globalFeatureIds.fill(n.feature,n.polygonPosition,n.polygonPosition+a),t.featureIds.fill(n.polygonFeature,n.polygonPosition,n.polygonPosition+a);for(let o=0,s=e.indices.length;o<s;++o){const i=n.polygonPosition;t.polygonIndices[n.polygonObject++]=i;const a=e.areas[o],s=e.indices[o],A=e.indices[o+1];for(let o=0,l=s.length;o<l;++o){const i=s[o],a=o===l-1?void 0===A?e.data.length:A[0]:s[o+1];t.primitivePolygonIndices[n.polygonRing++]=n.polygonPosition,n.polygonPosition+=(a-i)/r}sb(t,a,s,{startPosition:i,endPosition:n.polygonPosition,coordLength:r})}}function sb(e,t,n,{startPosition:r,endPosition:i,coordLength:a}){if(!e.triangles)return;const o=r*a,s=i*a,A=e.positions.subarray(o,s),l=n[0],c=Be(A,n.slice(1).map(e=>(e-l)/a),a,t);for(let u=0,f=c.length;u<f;++u)e.triangles.push(r+c[u])}function Ab(e,t){const n={};for(const r in e)n[r]={value:e[r],size:t};return n}function lb(e,t,n,r){for(const i in e.numericProps)if(i in t){const a=t[i];e.numericProps[i].fill(a,n,n+r)}}function cb(e,t){const n={};for(const r in e)t.includes(r)||(n[r]=e[r]);return n}function ub(e,t){return t!==Array&&Number.isFinite(e)?t===Float64Array||Math.fround(e)!==e?Float64Array:Float32Array:Array}function fb(e,t){const n=t?.globalFeatureId;return void 0!==n?function(e,t){const n=db(e);for(const r of n){let e=0,n=r.featureIds.value[0];for(let i=0;i<r.featureIds.value.length;i++){const a=r.featureIds.value[i];if(a!==n){if(t===r.globalFeatureIds.value[e])return hb(r,e,i);e=i,n=a}}if(t===r.globalFeatureIds.value[e])return hb(r,e,r.featureIds.value.length)}throw new Error(`featureId:${t} not found`)}(e,n):function(e,t){return function(e){const t=[];for(const n of e){if(0===n.featureIds.value.length)continue;let e=0,r=n.featureIds.value[0];for(let i=0;i<n.featureIds.value.length;i++){const a=n.featureIds.value[i];a!==r&&(t.push(hb(n,e,i)),e=i,r=a)}t.push(hb(n,e,n.featureIds.value.length))}return t}(db(e,t))}(e,t?.type)}function db(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 hb(e,t,n){return{type:"Feature",geometry:eb(e,t,n),properties:mb(e,t,n),...pb(e,t,n)}}function pb(e,t=0,n){return e.fields&&e.fields[e.featureIds.value[t]]}function mb(e,t=0,n){const r=Object.assign({},e.properties[e.featureIds.value[t]]);for(const i in e.numericProps)r[i]=e.numericProps[i].value[t];return r}Zg.defaultProps={clipBounds:[0,0,1,1],clipByInstance:void 0},Zg.extensionName="ClipExtension";var gb=e.__commonJSMin(e=>{e.read=function(e,t,n,r,i){var a,o,s=8*i-r-1,A=(1<<s)-1,l=A>>1,c=-7,u=n?i-1:0,f=n?-1:1,d=e[t+u];for(u+=f,a=d&(1<<-c)-1,d>>=-c,c+=s;c>0;a=256*a+e[t+u],u+=f,c-=8);for(o=a&(1<<-c)-1,a>>=-c,c+=r;c>0;o=256*o+e[t+u],u+=f,c-=8);if(0===a)a=1-l;else{if(a===A)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,r),a-=l}return(d?-1:1)*o*Math.pow(2,a-r)},e.write=function(e,t,n,r,i,a){var o,s,A,l=8*a-i-1,c=(1<<l)-1,u=c>>1,f=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:a-1,h=r?1:-1,p=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,o=c):(o=Math.floor(Math.log(t)/Math.LN2),t*(A=Math.pow(2,-o))<1&&(o--,A*=2),(t+=o+u>=1?f/A:f*Math.pow(2,1-u))*A>=2&&(o++,A/=2),o+u>=c?(s=0,o=c):o+u>=1?(s=(t*A-1)*Math.pow(2,i),o+=u):(s=t*Math.pow(2,u-1)*Math.pow(2,i),o=0));i>=8;e[n+d]=255&s,d+=h,s/=256,i-=8);for(o=o<<i|s,l+=i;l>0;e[n+d]=255&o,d+=h,o/=256,l-=8);e[n+d-h]|=128*p}}),bb=e.__commonJSMin((e,t)=>{t.exports=r;var n=gb();function r(e){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(e)?e:new Uint8Array(e||0),this.pos=0,this.type=0,this.length=this.buf.length}r.Varint=0,r.Fixed64=1,r.Bytes=2,r.Fixed32=5;var i=4294967296,a=1/i,o="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");function s(e){return e.type===r.Bytes?e.readVarint()+e.pos:e.pos+1}function A(e,t,n){return n?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function l(e,t,n){var r=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));n.realloc(r);for(var i=n.pos-1;i>=e;i--)n.buf[i+r]=n.buf[i]}function c(e,t){for(var n=0;n<e.length;n++)t.writeVarint(e[n])}function u(e,t){for(var n=0;n<e.length;n++)t.writeSVarint(e[n])}function f(e,t){for(var n=0;n<e.length;n++)t.writeFloat(e[n])}function d(e,t){for(var n=0;n<e.length;n++)t.writeDouble(e[n])}function h(e,t){for(var n=0;n<e.length;n++)t.writeBoolean(e[n])}function p(e,t){for(var n=0;n<e.length;n++)t.writeFixed32(e[n])}function m(e,t){for(var n=0;n<e.length;n++)t.writeSFixed32(e[n])}function g(e,t){for(var n=0;n<e.length;n++)t.writeFixed64(e[n])}function b(e,t){for(var n=0;n<e.length;n++)t.writeSFixed64(e[n])}function v(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+16777216*e[t+3]}function y(e,t,n){e[n]=t,e[n+1]=t>>>8,e[n+2]=t>>>16,e[n+3]=t>>>24}function x(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+(e[t+3]<<24)}r.prototype={destroy:function(){this.buf=null},readFields:function(e,t,n){for(n=n||this.length;this.pos<n;){var r=this.readVarint(),i=r>>3,a=this.pos;this.type=7&r,e(i,t,this),this.pos===a&&this.skip(r)}return t},readMessage:function(e,t){return this.readFields(e,t,this.readVarint()+this.pos)},readFixed32:function(){var e=v(this.buf,this.pos);return this.pos+=4,e},readSFixed32:function(){var e=x(this.buf,this.pos);return this.pos+=4,e},readFixed64:function(){var e=v(this.buf,this.pos)+v(this.buf,this.pos+4)*i;return this.pos+=8,e},readSFixed64:function(){var e=v(this.buf,this.pos)+x(this.buf,this.pos+4)*i;return this.pos+=8,e},readFloat:function(){var e=n.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=n.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(e){var t,n=this.buf,r=n[this.pos++];return t=127&r,r<128?t:(t|=(127&(r=n[this.pos++]))<<7,r<128?t:(t|=(127&(r=n[this.pos++]))<<14,r<128?t:(t|=(127&(r=n[this.pos++]))<<21,r<128?t:function(e,t,n){var r,i=n.buf,a=i[n.pos++];if(r=(112&a)>>4,a<128)return A(e,r,t);if(a=i[n.pos++],r|=(127&a)<<3,a<128)return A(e,r,t);if(a=i[n.pos++],r|=(127&a)<<10,a<128)return A(e,r,t);if(a=i[n.pos++],r|=(127&a)<<17,a<128)return A(e,r,t);if(a=i[n.pos++],r|=(127&a)<<24,a<128)return A(e,r,t);if(a=i[n.pos++],r|=(1&a)<<31,a<128)return A(e,r,t);throw new Error("Expected varint not more than 10 bytes")}(t|=(15&(r=n[this.pos]))<<28,e,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var e=this.readVarint();return e%2==1?(e+1)/-2:e/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=12&&o?function(e,t,n){return o.decode(e.subarray(t,n))}(this.buf,t,e):function(e,t,n){var r="",i=t;for(;i<n;){var a,o,s,A=e[i],l=null,c=A>239?4:A>223?3:A>191?2:1;if(i+c>n)break;1===c?A<128&&(l=A):2===c?128==(192&(a=e[i+1]))&&(l=(31&A)<<6|63&a)<=127&&(l=null):3===c?(a=e[i+1],o=e[i+2],128==(192&a)&&128==(192&o)&&((l=(15&A)<<12|(63&a)<<6|63&o)<=2047||l>=55296&&l<=57343)&&(l=null)):4===c&&(a=e[i+1],o=e[i+2],s=e[i+3],128==(192&a)&&128==(192&o)&&128==(192&s)&&((l=(15&A)<<18|(63&a)<<12|(63&o)<<6|63&s)<=65535||l>=1114112)&&(l=null)),null===l?(l=65533,c=1):l>65535&&(l-=65536,r+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),r+=String.fromCharCode(l),i+=c}return r}(this.buf,t,e)},readBytes:function(){var e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t},readPackedVarint:function(e,t){if(this.type!==r.Bytes)return e.push(this.readVarint(t));var n=s(this);for(e=e||[];this.pos<n;)e.push(this.readVarint(t));return e},readPackedSVarint:function(e){if(this.type!==r.Bytes)return e.push(this.readSVarint());var t=s(this);for(e=e||[];this.pos<t;)e.push(this.readSVarint());return e},readPackedBoolean:function(e){if(this.type!==r.Bytes)return e.push(this.readBoolean());var t=s(this);for(e=e||[];this.pos<t;)e.push(this.readBoolean());return e},readPackedFloat:function(e){if(this.type!==r.Bytes)return e.push(this.readFloat());var t=s(this);for(e=e||[];this.pos<t;)e.push(this.readFloat());return e},readPackedDouble:function(e){if(this.type!==r.Bytes)return e.push(this.readDouble());var t=s(this);for(e=e||[];this.pos<t;)e.push(this.readDouble());return e},readPackedFixed32:function(e){if(this.type!==r.Bytes)return e.push(this.readFixed32());var t=s(this);for(e=e||[];this.pos<t;)e.push(this.readFixed32());return e},readPackedSFixed32:function(e){if(this.type!==r.Bytes)return e.push(this.readSFixed32());var t=s(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed32());return e},readPackedFixed64:function(e){if(this.type!==r.Bytes)return e.push(this.readFixed64());var t=s(this);for(e=e||[];this.pos<t;)e.push(this.readFixed64());return e},readPackedSFixed64:function(e){if(this.type!==r.Bytes)return e.push(this.readSFixed64());var t=s(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed64());return e},skip:function(e){var t=7&e;if(t===r.Varint)for(;this.buf[this.pos++]>127;);else if(t===r.Bytes)this.pos=this.readVarint()+this.pos;else if(t===r.Fixed32)this.pos+=4;else{if(t!==r.Fixed64)throw new Error("Unimplemented type: "+t);this.pos+=8}},writeTag:function(e,t){this.writeVarint(e<<3|t)},realloc:function(e){for(var t=this.length||16;t<this.pos+e;)t*=2;if(t!==this.length){var n=new Uint8Array(t);n.set(this.buf),this.buf=n,this.length=t}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(e){this.realloc(4),y(this.buf,e,this.pos),this.pos+=4},writeSFixed32:function(e){this.realloc(4),y(this.buf,e,this.pos),this.pos+=4},writeFixed64:function(e){this.realloc(8),y(this.buf,-1&e,this.pos),y(this.buf,Math.floor(e*a),this.pos+4),this.pos+=8},writeSFixed64:function(e){this.realloc(8),y(this.buf,-1&e,this.pos),y(this.buf,Math.floor(e*a),this.pos+4),this.pos+=8},writeVarint:function(e){(e=+e||0)>268435455||e<0?function(e,t){var n,r;e>=0?(n=e%4294967296|0,r=e/4294967296|0):(r=~(-e/4294967296),4294967295^(n=~(-e%4294967296))?n=n+1|0:(n=0,r=r+1|0));if(e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),function(e,t,n){n.buf[n.pos++]=127&e|128,e>>>=7,n.buf[n.pos++]=127&e|128,e>>>=7,n.buf[n.pos++]=127&e|128,e>>>=7,n.buf[n.pos++]=127&e|128,e>>>=7,n.buf[n.pos]=127&e}(n,0,t),function(e,t){var n=(7&e)<<4;if(t.buf[t.pos++]|=n|((e>>>=3)?128:0),!e)return;if(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),!e)return;if(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),!e)return;if(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),!e)return;if(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),!e)return;t.buf[t.pos++]=127&e}(r,t)}(e,this):(this.realloc(4),this.buf[this.pos++]=127&e|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=e>>>7&127))))},writeSVarint:function(e){this.writeVarint(e<0?2*-e-1:2*e)},writeBoolean:function(e){this.writeVarint(Boolean(e))},writeString:function(e){e=String(e),this.realloc(4*e.length),this.pos++;var t=this.pos;this.pos=function(e,t,n){for(var r,i,a=0;a<t.length;a++){if((r=t.charCodeAt(a))>55295&&r<57344){if(!i){r>56319||a+1===t.length?(e[n++]=239,e[n++]=191,e[n++]=189):i=r;continue}if(r<56320){e[n++]=239,e[n++]=191,e[n++]=189,i=r;continue}r=i-55296<<10|r-56320|65536,i=null}else i&&(e[n++]=239,e[n++]=191,e[n++]=189,i=null);r<128?e[n++]=r:(r<2048?e[n++]=r>>6|192:(r<65536?e[n++]=r>>12|224:(e[n++]=r>>18|240,e[n++]=r>>12&63|128),e[n++]=r>>6&63|128),e[n++]=63&r|128)}return n}(this.buf,e,this.pos);var n=this.pos-t;n>=128&&l(t,n,this),this.pos=t-1,this.writeVarint(n),this.pos+=n},writeFloat:function(e){this.realloc(4),n.write(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),n.write(this.buf,e,this.pos,!0,52,8),this.pos+=8},writeBytes:function(e){var t=e.length;this.writeVarint(t),this.realloc(t);for(var n=0;n<t;n++)this.buf[this.pos++]=e[n]},writeRawMessage:function(e,t){this.pos++;var n=this.pos;e(t,this);var r=this.pos-n;r>=128&&l(n,r,this),this.pos=n-1,this.writeVarint(r),this.pos+=r},writeMessage:function(e,t,n){this.writeTag(e,r.Bytes),this.writeRawMessage(t,n)},writePackedVarint:function(e,t){t.length&&this.writeMessage(e,c,t)},writePackedSVarint:function(e,t){t.length&&this.writeMessage(e,u,t)},writePackedBoolean:function(e,t){t.length&&this.writeMessage(e,h,t)},writePackedFloat:function(e,t){t.length&&this.writeMessage(e,f,t)},writePackedDouble:function(e,t){t.length&&this.writeMessage(e,d,t)},writePackedFixed32:function(e,t){t.length&&this.writeMessage(e,p,t)},writePackedSFixed32:function(e,t){t.length&&this.writeMessage(e,m,t)},writePackedFixed64:function(e,t){t.length&&this.writeMessage(e,g,t)},writePackedSFixed64:function(e,t){t.length&&this.writeMessage(e,b,t)},writeBytesField:function(e,t){this.writeTag(e,r.Bytes),this.writeBytes(t)},writeFixed32Field:function(e,t){this.writeTag(e,r.Fixed32),this.writeFixed32(t)},writeSFixed32Field:function(e,t){this.writeTag(e,r.Fixed32),this.writeSFixed32(t)},writeFixed64Field:function(e,t){this.writeTag(e,r.Fixed64),this.writeFixed64(t)},writeSFixed64Field:function(e,t){this.writeTag(e,r.Fixed64),this.writeSFixed64(t)},writeVarintField:function(e,t){this.writeTag(e,r.Varint),this.writeVarint(t)},writeSVarintField:function(e,t){this.writeTag(e,r.Varint),this.writeSVarint(t)},writeStringField:function(e,t){this.writeTag(e,r.Bytes),this.writeString(t)},writeFloatField:function(e,t){this.writeTag(e,r.Fixed32),this.writeFloat(t)},writeDoubleField:function(e,t){this.writeTag(e,r.Fixed64),this.writeDouble(t)},writeBooleanField:function(e,t){this.writeVarintField(e,Boolean(t))}}});function vb(e){let t=0;for(let n,r,i=0,a=e.length-1;i<e.length;a=i++)n=e[i],r=e[a],t+=(r[0]-n[0])*(n[1]+r[1]);return t}function yb(e,t){if(Array.isArray(e[0])){for(const n of e)yb(n,t);return}const n=e;n[0]/=t,n[1]/=t}function xb(e,t){for(let n=0;n<e.length;++n)e[n]/=t}function _b(e,t,n){if("number"!=typeof e[0][0]){for(const r of e)_b(r,t,n);return}const r=n*Math.pow(2,t.z),i=n*t.x,a=n*t.y;for(let o=0;o<e.length;o++){const t=e[o];t[0]=360*(t[0]+i)/r-180;const n=180-360*(t[1]+a)/r;t[1]=360/Math.PI*Math.atan(Math.exp(n*Math.PI/180))-90}}var wb=class{properties;extent;type;id;_pbf;_geometry;_keys;_values;_geometryInfo;static types=["Unknown","Point","LineString","Polygon"];constructor(e,t,n,r,i,a){this.properties={},this.extent=n,this.type=0,this.id=null,this._pbf=e,this._geometry=-1,this._keys=r,this._values=i,this._geometryInfo=a,e.readFields(Sb,this,t)}toGeoJSONFeature(e,t){const n=this.loadGeometry();return Tb(this,n,"wgs84"===e?e=>_b(e,t,this.extent):yb)}toBinaryFeature(e,t){const n=this.loadFlatGeometry();return"wgs84"===e?this._toBinaryCoordinates(n,e=>function(e,t,n){const{x:r,y:i,z:a}=t,o=n*Math.pow(2,a),s=n*r,A=n*i;for(let l=0,c=e.length;l<c;l+=2){e[l]=360*(e[l]+s)/o-180;const t=180-360*(e[l+1]+A)/o;e[l+1]=360/Math.PI*Math.atan(Math.exp(t*Math.PI/180))-90}}(e,t,this.extent)):this._toBinaryCoordinates(n,xb)}bbox(){const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos;let n=1,r=0,i=0,a=0,o=1/0,s=-1/0,A=1/0,l=-1/0;for(;e.pos<t;){if(r<=0){const t=e.readVarint();n=7&t,r=t>>3}if(r--,1===n||2===n)i+=e.readSVarint(),a+=e.readSVarint(),i<o&&(o=i),i>s&&(s=i),a<A&&(A=a),a>l&&(l=a);else if(7!==n)throw new Error(`unknown command ${n}`)}return[o,A,s,l]}_toBinaryCoordinates(e,n){let r;n(e.data,this.extent);switch(this.type){case 1:this._geometryInfo.pointFeaturesCount++,this._geometryInfo.pointPositionsCount+=e.indices.length,r={type:"Point",...e};break;case 2:this._geometryInfo.lineFeaturesCount++,this._geometryInfo.linePathsCount+=e.indices.length,this._geometryInfo.linePositionsCount+=e.data.length/2,r={type:"LineString",...e};break;case 3:r=function(e){const n=e.indices.length,r="Polygon";if(n<=1)return{type:r,data:e.data,areas:[[t.getPolygonSignedArea(e.data)]],indices:[e.indices]};const i=[],a=[];let o,s=[],A=[],l=0;for(let c,u,f=0;f<n;f++){u=e.indices[f]-l,c=e.indices[f+1]-l||e.data.length;const n=e.data.slice(u,c),r=t.getPolygonSignedArea(n);if(0===r){const t=e.data.slice(0,u),n=e.data.slice(c);e.data=t.concat(n),l+=c-u;continue}void 0===o&&(o=r<0),o===r<0?(A.length&&(i.push(s),a.push(A)),A=[u],s=[r]):(s.push(r),A.push(u))}return s&&i.push(s),A.length&&a.push(A),{type:r,areas:i,indices:a,data:e.data}}(e),this._geometryInfo.polygonFeaturesCount++,this._geometryInfo.polygonObjectsCount+=r.indices.length;for(const e of r.indices)this._geometryInfo.polygonRingsCount+=e.length;this._geometryInfo.polygonPositionsCount+=r.data.length/2;break;default:throw new Error(`Invalid geometry type: ${this.type}`)}const i={type:"Feature",geometry:r,properties:this.properties};return null!==this.id&&(i.id=this.id),i}loadGeometry(){const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos;let n=1,r=0,i=0,a=0;const o=[];let s;for(;e.pos<t;){if(r<=0){const t=e.readVarint();n=7&t,r=t>>3}switch(r--,n){case 1:case 2:i+=e.readSVarint(),a+=e.readSVarint(),1===n&&(s&&o.push(s),s=[]),s&&s.push([i,a]);break;case 7:s&&s.push(s[0].slice());break;default:throw new Error(`unknown command ${n}`)}}return s&&o.push(s),o}loadFlatGeometry(){const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos;let n,r=1,i=0,a=0,o=0,s=0;const A=[],l=[];for(;e.pos<t;)if(i<=0&&(n=e.readVarint(),r=7&n,i=n>>3),i--,1===r||2===r)a+=e.readSVarint(),o+=e.readSVarint(),1===r&&A.push(s),l.push(a,o),s+=2;else{if(7!==r)throw new Error(`unknown command ${r}`);if(s>0){const e=A[A.length-1];l.push(l[e],l[e+1]),s+=2}}return{data:l,indices:A}}};function Tb(e,t,n){let r,i,a,o=wb.types[e.type];switch(e.type){case 1:const o=[];for(r=0;r<t.length;r++)o[r]=t[r][0];a=o,n(a,e.extent);break;case 2:for(a=t,r=0;r<a.length;r++)n(a[r],e.extent);break;case 3:for(a=function(e){const t=e.length;if(t<=1)return[e];const n=[];let r,i;for(let a=0;a<t;a++){const t=vb(e[a]);0!==t&&(void 0===i&&(i=t<0),i===t<0?(r&&n.push(r),r=[e[a]]):r&&r.push(e[a]))}return r&&n.push(r),n}(t),r=0;r<a.length;r++)for(i=0;i<a[r].length;i++)n(a[r][i],e.extent);break;default:throw new Error("illegal vector tile type")}1===a.length?a=a[0]:o=`Multi${o}`;const s={type:"Feature",geometry:{type:o,coordinates:a},properties:e.properties};return null!==e.id&&(s.id=e.id),s}function Sb(e,t,n){t&&n&&(1===e?t.id=n.readVarint():2===e?function(e,t){const n=e.readVarint()+e.pos;for(;e.pos<n;){const n=t._keys[e.readVarint()],r=t._values[e.readVarint()];t.properties[n]=r}}(n,t):3===e?t.type=n.readVarint():4===e&&(t._geometry=n.pos))}var Mb=class{version;name;extent;length;_pbf;_keys;_values;_features;constructor(e,t){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=e,this._keys=[],this._values=[],this._features=[],e.readFields(Eb,this,t),this.length=this._features.length}getGeoJSONFeature(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];const t=this._pbf.readVarint()+this._pbf.pos;return new wb(this._pbf,t,this.extent,this._keys,this._values)}getBinaryFeature(e,t){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];const n=this._pbf.readVarint()+this._pbf.pos;return new wb(this._pbf,n,this.extent,this._keys,this._values,t)}};function Eb(e,t,n){t&&n&&(15===e?t.version=n.readVarint():1===e?t.name=n.readString():5===e?t.extent=n.readVarint():2===e?t._features.push(n.pos):3===e?t._keys.push(n.readString()):4===e&&t._values.push(function(e){let t=null;const n=e.readVarint()+e.pos;for(;e.pos<n;){const n=e.readVarint()>>3;t=1===n?e.readString():2===n?e.readFloat():3===n?e.readDouble():4===n?e.readVarint64():5===n?e.readVarint():6===n?e.readSVarint():7===n?e.readBoolean():null}return t}(n)))}var Cb=class{layers;constructor(e,t){this.layers=e.readFields(Ib,{},t)}};function Ib(e,t,n){if(3===e&&n){const e=new Mb(n,n.readVarint()+n.pos);e.length&&t&&(t[e.name]=e)}}var Rb=e.__toESM(bb(),1);function Pb(e,t){const r=function(e){if(!e?.mvt)throw new Error("mvt options required");if("wgs84"===e.mvt?.coordinates&&!e.mvt.tileIndex)throw new Error("MVT Loader: WGS84 coordinates need tileIndex property");e.gis&&n.log.warn('MVTLoader: "options.gis" is deprecated, use "options.mvt.shape" instead')();return e.mvt}(t),i=t?.gis?.format||t?.mvt?.shape||t?.shape;switch(i){case"columnar-table":return{shape:"columnar-table",data:Nb(e,r)};case"geojson-table":return{shape:"geojson-table",type:"FeatureCollection",features:kb(e,r)};case"geojson":return kb(e,r);case"binary-geometry":case"binary":return Nb(e,r);default:throw new Error(i||"undefined shape")}}function Nb(e,t){const[n,r]=function(e,t){const n=[],r={coordLength:2,pointPositionsCount:0,pointFeaturesCount:0,linePositionsCount:0,linePathsCount:0,lineFeaturesCount:0,polygonPositionsCount:0,polygonObjectsCount:0,polygonRingsCount:0,polygonFeaturesCount:0};if(e.byteLength<=0)return[n,r];const i=new Cb(new Rb.default(e));return(t&&Array.isArray(t.layers)?t.layers:Object.keys(i.layers)).forEach(e=>{const a=i.layers[e];if(a)for(let i=0;i<a.length;i++){const o=Bb(a.getBinaryFeature(i,r),t,e);n.push(o)}}),[n,r]}(e,t),i=rb(n,r);return i.byteLength=e.byteLength,i}function kb(e,t){if(e.byteLength<=0)return[];const n=[],r=new Cb(new Rb.default(e));return(Array.isArray(t.layers)?t.layers:Object.keys(r.layers)).forEach(e=>{const i=r.layers[e];if(i)for(let r=0;r<i.length;r++){const a=Lb(i.getGeoJSONFeature(r),t,e);n.push(a)}}),n}function Lb(e,t,n){const r=e.toGeoJSONFeature(t.coordinates||"local",t.tileIndex);return t.layerProperty&&(r.properties||={},r.properties[t.layerProperty]=n),r}function Bb(e,t,n){const r=e.toBinaryFeature(t.coordinates||"local",t.tileIndex);return t.layerProperty&&r.properties&&(r.properties[t.layerProperty]=n),r}var Ob={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.5.4",worker:!0,options:{mvt:{shape:"geojson",coordinates:"local",layerProperty:"layerName",layers:void 0,tileIndex:void 0}}},Fb={Point:Db,MultiPoint:function(e,t,n){return Ub(e,t,n)},LineString:Vb,MultiLineString:function(e,t,n){return e.map(e=>Vb(e,t,n))},Polygon:jb,MultiPolygon:function(e,t,n){return e.map(e=>jb(e,t,n))}};function Db([e,t],[r,i],a){const o=n.lerp$2(r[0],i[0],e),s=n.lerp$2(r[1],i[1],t);return a.unprojectFlat([o,s])}function Ub(e,t,n){return e.map(e=>Db(e,t,n))}function Vb(e,t,n){return Ub(e,t,n)}function jb(e,t,n){return e.map(e=>Ub(e,t,n))}var zb=["points","lines","polygons"];function Gb(e,t,n,r){const i=e.featureIds.value;if(!i.length)return-1;let a=0,o=i[i.length-1]+1;if(r){const t=function(e,t){if(!e.__layers){const t={},{properties:n}=e;for(let e=0;e<n.length;e++){const{layerName:r}=n[e];r&&(t[r]?t[r][1]=e:t[r]=[e,e])}e.__layers=t}return e.__layers[t]}(e,r);if(!t)return-1;a=t[0],o=t[1]+1}let s=-1;if(t in e.numericProps){const r=e.numericProps[t].value.findIndex((e,t)=>e===n&&i[t]>=a&&i[t]<o);return r>=0?e.globalFeatureIds.value[r]:-1}return t?s=Hb(e.properties,e=>e[t]===n,a,o):e.fields&&(s=Hb(e.fields,e=>e.id===n,a,o)),s>=0?function(e,t){if(!e.__ids){const t=[],n=e.featureIds.value,r=e.globalFeatureIds.value;for(let e=0;e<n.length;e++)t[n[e]]=r[e];e.__ids=t}return e.__ids[t]}(e,s):-1}function Hb(e,t,n,r){for(let i=n;i<r;i++)if(t(e[i],i))return i;return-1}var qb={...t.GeoJsonLayer.defaultProps,data:dA,onDataLoad:{type:"function",value:null,optional:!0,compare:!1},uniqueIdProperty:"",highlightedFeatureId:null,loaders:[Ob],binary:!0},Qb=class extends BA{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:r}){r.dataChanged&&this._updateTileData(),this.state?.data&&(super.updateState({props:e,oldProps:t,context:n,changeFlags:r}),this._setWGS84PropertyForTiles());const{highlightColor:i}=e;i!==t.highlightColor&&Array.isArray(i)&&this.setState({highlightColor:i})}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:r,fetch:i}=this.props;this.setState({data:null,tileJSON:null});try{t=await i(e,{propName:"data",layer:this,loaders:[]})}catch(n){this.raiseError(n,"loading TileJSON"),e=null}r&&r(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:r}=this.props;return t&&(Number.isFinite(t.minzoom)&&t.minzoom>n&&(e.minZoom=t.minzoom),Number.isFinite(t.maxzoom)&&(!Number.isFinite(r)||t.maxzoom<r)&&(e.maxZoom=t.maxzoom)),e}renderLayers(){return this.state?.data?super.renderLayers():null}getTileData(e){const{data:t,binary:n}=this.state,{index:r,signal:i}=e,a=pA(t,e);if(!a)return Promise.reject("Invalid URL");let o=this.getLoadOptions();const{fetch:s}=this.props;return o={...o,core:{...o?.core,mimeType:"application/x-protobuf"},mvt:{...o?.mvt,shape:n?"binary":"geojson",coordinates:this.context.viewport.resolution?"wgs84":"local",tileIndex:r}},s(a,{propName:"data",layer:this,loadOptions:o,signal:i})}renderSubLayers(e){const{x:r,y:i,z:a}=e.tile.index,o=Math.pow(2,a),s=512/o,A=-s,l=512*r/o,c=512*(1-i/o),u=(new n.Matrix4).scale([s,A,1]);e.autoHighlight=!1,this.context.viewport.resolution||(e.modelMatrix=u,e.coordinateOrigin=[l,c,0],e.coordinateSystem=n.COORDINATE_SYSTEM.CARTESIAN,e.extensions=[...e.extensions||[],new Zg]);const f=super.renderSubLayers(e);return!this.state.binary||f instanceof t.GeoJsonLayer||n.defaultLogger.warn("renderSubLayers() must return GeoJsonLayer when using binary:true")(),f}_updateAutoHighlight(e){const{uniqueIdProperty:t}=this.props,{hoveredFeatureId:n,hoveredFeatureLayerName:r}=this.state,i=e.object;let a=null,o=null;i&&(a=Kb(i,t),o=Wb(i));let{highlightColor:s}=this.props;"function"==typeof s&&(s=s(e)),n===a&&r===o||this.setState({highlightColor:s,hoveredFeatureId:a,hoveredFeatureLayerName:o})}_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=fb(n,{globalFeatureId:t.index})}return t.object&&!this._isWGS84()&&(t.object=Jb(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:r}=this.state,{uniqueIdProperty:i,highlightedFeatureId:a}=this.props,o=e.content,s=$b(a);if(!$b(t)&&!s)return-1;const A=s?a:t;return Array.isArray(o)?o.findIndex(e=>{const t=Kb(e,i)===A,r=s||Wb(e)===n;return t&&r}):o&&r?function(e,t,n,r){for(const i of zb){const a=e[i]&&Gb(e[i],t,n,r);if(a>=0)return a}return-1}(o,i,A,s?"":n):-1}_pickObjects(e){const{deck:t,viewport:n}=this.context,r=n.width,i=n.height,a=n.x,o=n.y,s=[this.id];return t.pickObjects({x:a,y:o,width:r,height:i,layerIds:s,maxObjects:e})}getRenderedFeatures(e=null){const t=this._pickObjects(e),n=new Set,r=[];for(const i of t){const e=Kb(i.object,this.props.uniqueIdProperty);void 0===e?r.push(i.object):n.has(e)||(n.add(e),r.push(i.object))}return r}_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;return void 0===t._contentWGS84&&function(e){return Number.isFinite(e.west)&&Number.isFinite(e.north)&&Number.isFinite(e.east)&&Number.isFinite(e.south)}(e)&&(t._contentWGS84=(this.state.binary?fb(t.content):t.content).map(t=>Jb(t,e,this.context.viewport))),t._contentWGS84}})})}};function Kb(e,t){return e.properties&&t?e.properties[t]:"id"in e?e.id:void 0}function Wb(e){return e.properties?.layerName||null}function $b(e){return null!=e&&""!==e}function Jb(e,t,n){const r={...e,geometry:{type:e.geometry.type}};return Object.defineProperty(r.geometry,"coordinates",{get:()=>function(e,t,n){const r=[n.projectFlat([t.west,t.north]),n.projectFlat([t.east,t.south])];return{...e,coordinates:Fb[e.type](e.coordinates,r,n)}}(e.geometry,t,n).coordinates}),r}Qb.layerName="MVTLayer",Qb.defaultProps=qb;var Yb={};for(let ev=0;ev<32;ev++)Yb["0123456789bcdefghjkmnpqrstuvwxyz".charAt(ev)]=ev;function Xb(e){const[t,n,r,i]=function(e){let t,n=!0,r=90,i=-90,a=180,o=-180,s=0;for(let A=0,l=e.length;A<l;A++){const l=e[A].toLowerCase();s=Yb[l];for(let e=4;e>=0;e--){const A=s>>e&1;n?(t=(a+o)/2,1===A?o=t:a=t):(t=(r+i)/2,1===A?i=t:r=t),n=!n}}return[i,o,r,a]}(e);return[i,r,i,t,n,t,n,r,i,r]}var Zb=class extends st{indexToBounds(){const{data:e,getGeohash:t}=this.props;return{data:e,_normalize:!1,positionFormat:"XY",getPolygon:(e,n)=>Xb(t(e,n))}}};Zb.layerName="GeohashLayer",Zb.defaultProps={getGeohash:{type:"accessor",value:e=>e.geohash}},exports.A5Layer=bi,exports.GeohashLayer=Zb,exports.GreatCircleLayer=Ko,exports.H3ClusterLayer=HA,exports.H3HexagonLayer=GA,exports.MVTLayer=Qb,exports.QuadkeyLayer=ss,exports.S2Layer=as,exports.TerrainLayer=Qg,exports.Tile3DLayer=Vg,exports.TileLayer=BA,exports.TripsLayer=jA,exports._GeoCellLayer=st,exports._Tile2DHeader=As,exports._Tileset2D=PA,exports._WMSLayer=Qo,exports._getURLFromTemplate=pA;
1
+ /*! Web-kit v1.2.0-develop.14 | (c) 2026 MapVX */
2
+ !function(){try{var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="cd419d2f-5de3-4a37-90e2-ba1148110fe4",e._sentryDebugIdIdentifier="sentry-dbid-cd419d2f-5de3-4a37-90e2-ba1148110fe4")}catch(e){}}();const e=require("./rolldown-runtime-S4XI6pHy.cjs"),t=require("./dist-B06OgE5W.cjs"),n=require("./debug-hooks-CMF1BR-2.cjs"),r=require("./globe-viewport-s9VMxxMl.cjs"),i=require("./expression-Dq2zVyIz.cjs"),a=require("./shader-type-decoder-CplMa6Zn.cjs"),o=require("./webgl-device-CR_IOS1K.cjs");async function s(e,t,n,r){return r._parse(e,t,n,r)}globalThis.probe||(globalThis.probe=a.probe);var A=new a.ProbeLog({id:"@probe.gl/log"});var l={};function c(e={}){const t=e.useLocalLibraries??e.core?.useLocalLibraries,n=e.CDN??e.core?.CDN,r=e.modules;return{...void 0!==t?{useLocalLibraries:t}:{},...void 0!==n?{CDN:n}:{},...void 0!==r?{modules:r}:{}}}async function u(e,t=null,r={},i=null){if(t){const a=r.modules?.[i||e];if(void 0!==a&&"string"!=typeof a)return a;e=function(e,t,r={},i=null){if(r?.core)throw new Error("loadLibrary: options.core must be pre-normalized");i=i||e;const a=r.modules||{};if("string"==typeof a[i])return a[i];if(!r.useLocalLibraries&&e.startsWith("http"))return e;if(!n.isBrowser)return`modules/${t}/dist/libs/${i}`;if(r.CDN)return n.assert$2(r.CDN.startsWith("http")),`${r.CDN}/${t}@${n.VERSION}/dist/libs/${i}`;return n.isWorker?`../src/libs/${i}`:`modules/${t}/src/libs/${i}`}(e,t,r,i)}return l[e]=l[e]||async function(e){if(e.endsWith("wasm"))return await async function(e){const{readFileAsArrayBuffer:t}=globalThis.loaders||{};if(n.isBrowser||!t||e.startsWith("http"))return await(await fetch(e)).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(!n.isBrowser){const{requireFromFile:n}=globalThis.loaders||{};try{const t=await(n?.(e));return t||!e.includes("/dist/libs/")?t:await(n?.(e.replace("/dist/libs/","/src/libs/")))}catch(t){if(e.includes("/dist/libs/"))try{return await(n?.(e.replace("/dist/libs/","/src/libs/")))}catch{}return console.error(t),null}}return n.isWorker?importScripts(e):function(e,t){if(!n.isBrowser){const{requireFromString:n}=globalThis.loaders||{};return n?.(e,t)}if(n.isWorker)return eval.call(globalThis,e),null;const r=document.createElement("script");r.id=t;try{r.appendChild(document.createTextNode(e))}catch(Gt){r.text=e}return document.body.appendChild(r),null}(await async function(e){const{readFileAsText:t}=globalThis.loaders||{};if(n.isBrowser||!t||e.startsWith("http"))return await(await fetch(e)).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),e)}(e),await l[e]}function f(e,t,n){if(e.byteLength<=t+n)return"";const r=new DataView(e);let i="";for(let a=0;a<n;a++)i+=String.fromCharCode(r.getUint8(t+a));return i}function d(e){try{return JSON.parse(e)}catch(t){throw new Error(`Failed to parse JSON from data starting with "${function(e,t=5){return"string"==typeof e?e.slice(0,t):ArrayBuffer.isView(e)?f(e.buffer,e.byteOffset,t):e instanceof ArrayBuffer?f(e,0,t):""}(e)}"`)}}function h(e,t){return n.assert$3(e>=0),n.assert$3(t>0),e+(t-1)&~(t-1)}function p(e,t,n){let r;if(e instanceof ArrayBuffer)r=new Uint8Array(e);else{const t=e.byteOffset,n=e.byteLength;r=new Uint8Array(e.buffer||e.arrayBuffer,t,n)}return t.set(r,n),n+h(r.byteLength,4)}var m={id:"request-scheduler",throttleRequests:!0,maxRequests:6,debounceTime:0},g=class{props;stats;activeRequestCount=0;requestQueue=[];requestMap=new Map;updateTimer=null;constructor(e={}){this.props={...m,...e},this.stats=new n.Stats({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},r=new Promise(e=>(n.resolve=e,n));return this.requestQueue.push(n),this.requestMap.set(e,r),this._issueNewRequests(),r}_issueRequest(e){const{handle:t,resolve:n}=e;let r=!1;const i=()=>{r||(r=!0,this.requestMap.delete(t),this.activeRequestCount--,null===this.updateTimer&&(this.updateTimer=setTimeout(()=>this._issueNewRequestsAsync(),0)))};return this.activeRequestCount++,n?n({done:i}):Promise.resolve({done:i})}_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)}},b=class e{static defaultOptions={core:{type:"auto",attributions:[],loadOptions:{},loaders:[]}};optionsType;options;data;url;loadOptions;fetch;_needsRefresh=!0;constructor(t,r,i){this.options=i?n.mergeOptions({...i,core:e.defaultOptions},r):{...r},this.data=t,this.url="string"==typeof t?n.resolvePath(t):"",this.loadOptions=function(e){const t={...e};e?.core&&(t.core={...e.core});const n="string"==typeof t.baseUri?t.baseUri:void 0,r="string"==typeof t.baseUrl?t.baseUrl:void 0;void 0===n&&void 0===r||(t.core||={},void 0===t.core.baseUrl&&(t.core.baseUrl=r??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;return n&&"function"!=typeof n?e=>fetch(e,n):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}};var v=class{static type="template";static testURL=e=>!1};function y(e,t){return new Promise((n,r)=>{let i=!1;function a(e){i||(i=!0,r(e))}function o(e){if(!i){i=!0;try{n(t(e))}catch(a){r(a)}}}try{e(o,a)?.then(o,a)}catch(s){a(s)}})}function x(e,t,n){const r=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),i=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:r}]},nullable:!1,metadata:i}}var _=["image/png","image/jpeg","image/gif","image/webp","image/avif","image/tiff","image/svg","image/svg+xml","image/bmp","image/vnd.microsoft.icon"],w=null;async function T(){return w||(w=async function(){const e=new Set;for(const t of _)(n.isBrowser$1?await I(t):E(t))&&e.add(t);return e}()),await w}var S={};function M(e){if(void 0===S[e]){const t=n.isBrowser$1?function(e){switch(e){case"image/avif":case"image/webp":return function(e){try{return 0===document.createElement("canvas").toDataURL(e).indexOf(`data:${e}`)}catch{return!1}}(e);default:return!0}}(e):E(e);S[e]=t}return S[e]}function E(e){const t=globalThis.loaders?.imageFormatsNode||["image/png","image/jpeg","image/gif"],n=globalThis.loaders?.parseImageNode;return Boolean(n)&&t.includes(e)}var C={"image/avif":"data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A=","image/webp":"data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA"};async function I(e){const t=C[e];return!t||await async function(e){return new Promise(t=>{const n=new Image;n.src=e,n.onload=()=>t(n.height>0),n.onerror=()=>t(!1)})}(t)}var R,P=class extends n.Vector{constructor(e=0,t=0){super(2),n.isArray(e)&&1===arguments.length?this.copy(e):(n.config.debug&&(n.checkNumber(e),n.checkNumber(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 n.config.debug&&(n.checkNumber(e.x),n.checkNumber(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 n.transformMat4$2(this,this,e),this.check()}transformAsVector(e){return n.vec2_transformMat4AsVector(this,this,e),this.check()}transformByMatrix3(e){return n.transformMat3$1(this,this,e),this.check()}transformByMatrix2x3(e){return n.transformMat2d(this,this,e),this.check()}transformByMatrix2(e){return n.transformMat2(this,this,e),this.check()}};!function(e){e[e.COL0ROW0=0]="COL0ROW0",e[e.COL0ROW1=1]="COL0ROW1",e[e.COL0ROW2=2]="COL0ROW2",e[e.COL1ROW0=3]="COL1ROW0",e[e.COL1ROW1=4]="COL1ROW1",e[e.COL1ROW2=5]="COL1ROW2",e[e.COL2ROW0=6]="COL2ROW0",e[e.COL2ROW1=7]="COL2ROW1",e[e.COL2ROW2=8]="COL2ROW2"}(R||(R={}));var N,k=Object.freeze([1,0,0,0,1,0,0,0,1]),L=class extends n.Matrix{static get IDENTITY(){return function(){B||(B=new L,Object.freeze(B));return B}()}static get ZERO(){return function(){N||(N=new L([0,0,0,0,0,0,0,0,0]),Object.freeze(N));return N}()}get ELEMENTS(){return 9}get RANK(){return 3}get INDICES(){return R}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(k)}fromObject(e){return this.check()}fromQuaternion(e){return r.fromQuat(this,e),this.check()}set(e,t,n,r,i,a,o,s,A){return this[0]=e,this[1]=t,this[2]=n,this[3]=r,this[4]=i,this[5]=a,this[6]=o,this[7]=s,this[8]=A,this.check()}setRowMajor(e,t,n,r,i,a,o,s,A){return this[0]=e,this[1]=r,this[2]=o,this[3]=t,this[4]=i,this[5]=s,this[6]=n,this[7]=a,this[8]=A,this.check()}determinant(){return r.determinant(this)}transpose(){return r.transpose(this,this),this.check()}invert(){return r.invert(this,this),this.check()}multiplyLeft(e){return r.multiply(this,e,this),this.check()}multiplyRight(e){return r.multiply(this,this,e),this.check()}rotate(e){return r.rotate(this,this,e),this.check()}scale(e){return Array.isArray(e)?r.scale(this,this,e):r.scale(this,this,[e,e]),this.check()}translate(e){return r.translate(this,this,e),this.check()}transform(e,t){let r;switch(e.length){case 2:r=n.transformMat3$1(t||[-0,-0],e,this);break;case 3:r=n.transformMat3(t||[-0,-0,-0],e,this);break;case 4:r=n.vec4_transformMat3(t||[-0,-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return n.checkVector(r,e.length),r}transformVector(e,t){return this.transform(e,t)}transformVector2(e,t){return this.transform(e,t)}transformVector3(e,t){return this.transform(e,t)}},B=null;var O={props:{},uniforms:{},bindings:{},name:"skin",bindingLayout:[{name:"skin",group:0},{name:"skinJointMatrices",group:0,visibility:1}],dependencies:[],source:"\nstruct skinUniforms {\n jointMatrix: array<mat4x4<f32>, 64>,\n};\n\n@group(0) @binding(auto) var<uniform> skin: skinUniforms;\n\n#ifdef HAS_INSTANCED_SKIN\n@group(0) @binding(auto) var<storage, read> skinJointMatrices: array<mat4x4<f32>>;\n\nfn getInstancedSkinMatrix(\n weights: vec4f,\n joints: vec4u,\n instanceIndex: u32,\n jointsPerInstance: u32\n) -> mat4x4<f32> {\n let firstJoint = instanceIndex * jointsPerInstance;\n return (weights.x * skinJointMatrices[firstJoint + joints.x])\n + (weights.y * skinJointMatrices[firstJoint + joints.y])\n + (weights.z * skinJointMatrices[firstJoint + joints.z])\n + (weights.w * skinJointMatrices[firstJoint + joints.w]);\n}\n#endif\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\n#ifdef HAS_INSTANCED_SKIN\nuniform highp sampler2D skinJointMatrices;\n\nmat4 getInstancedJointMatrix(uint jointIndex, uint instanceIndex) {\n int firstColumn = int(jointIndex * 4u);\n int row = int(instanceIndex);\n return mat4(\n texelFetch(skinJointMatrices, ivec2(firstColumn, row), 0),\n texelFetch(skinJointMatrices, ivec2(firstColumn + 1, row), 0),\n texelFetch(skinJointMatrices, ivec2(firstColumn + 2, row), 0),\n texelFetch(skinJointMatrices, ivec2(firstColumn + 3, row), 0)\n );\n}\n\nmat4 getInstancedSkinMatrix(\n vec4 weights,\n uvec4 joints,\n uint instanceIndex,\n uint jointsPerInstance\n) {\n return (weights.x * getInstancedJointMatrix(joints.x, instanceIndex))\n + (weights.y * getInstancedJointMatrix(joints.y, instanceIndex))\n + (weights.z * getInstancedJointMatrix(joints.z, instanceIndex))\n + (weights.w * getInstancedJointMatrix(joints.w, instanceIndex));\n}\n#endif\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:64},getUniforms:(e={},t)=>{const{jointMatrices:r,skinJointMatrices:i,scenegraphsFromGLTF:a,skinIndex:o=0,meshWorldMatrix:s}=e,A=i?{skinJointMatrices:i}:{};if(r)return{jointMatrix:F(r),...A};const l=a?.gltf?.skins?.[o];if(!l)return{jointMatrix:[],...A};const{inverseBindMatrices:c,joints:u,skeleton:f}=l,d=a.gltfNodeIndexToNodeMap,h=new Map,p=void 0===f?void 0:d?.get(f),m=p?[p]:a.scenes||[];for(const n of m)n.preorderTraversal((e,{worldMatrix:t})=>{h.set(e.id,t)});const g=s?new n.Matrix4(s).invert():null,b=new Float32Array(1024),v=c?.value;for(let y=0;y<Math.min(u.length,64);y++){const e=d?.get(u[y]);if(!e)continue;const t=h.get(e.id)||e.matrix,r=g?new n.Matrix4(g).multiplyRight(t):new n.Matrix4(t);v&&v.length>=16*(y+1)&&r.multiplyRight(new n.Matrix4(Array.from(v.slice(16*y,16*(y+1))))),b.set(r,16*y)}return{jointMatrix:b,...A}},uniformTypes:{jointMatrix:["mat4x4<f32>",64]}};function F(e){const t=new Float32Array(1024);return t.set(e instanceof Float32Array?e.subarray(0,t.length):e.slice(0,t.length)),t}var D={name:"gpuAnimation",props:{},uniforms:{},bindings:{},source:"\n#ifdef HAS_GPU_CROWD_ANIMATION\n@group(0) @binding(auto) var<storage, read> gpuAnimationFrames: array<vec4f>;\n\nfn readGPUAnimationFrame(frame: u32, offset: u32, frameStride: u32) -> vec4f {\n return gpuAnimationFrames[frame * frameStride + offset];\n}\n\nfn sampleGPUAnimationFrame(\n frames: vec4f,\n blend: vec4f,\n offset: u32,\n frameStride: u32\n) -> vec4f {\n let first = mix(\n readGPUAnimationFrame(u32(frames.x), offset, frameStride),\n readGPUAnimationFrame(u32(frames.y), offset, frameStride),\n frames.z\n );\n if (blend.w <= 0.0) {\n return first;\n }\n let second = mix(\n readGPUAnimationFrame(u32(blend.x), offset, frameStride),\n readGPUAnimationFrame(u32(blend.y), offset, frameStride),\n blend.z\n );\n return mix(first, second, blend.w);\n}\n\nfn sampleGPUAnimationMatrix(\n frames: vec4f,\n blend: vec4f,\n firstColumn: u32,\n frameStride: u32\n) -> mat4x4f {\n return mat4x4f(\n sampleGPUAnimationFrame(frames, blend, firstColumn, frameStride),\n sampleGPUAnimationFrame(frames, blend, firstColumn + 1u, frameStride),\n sampleGPUAnimationFrame(frames, blend, firstColumn + 2u, frameStride),\n sampleGPUAnimationFrame(frames, blend, firstColumn + 3u, frameStride)\n );\n}\n\nfn getGPUAnimatedSkinMatrix(\n weights: vec4f,\n joints: vec4u,\n frames: vec4f,\n blend: vec4f,\n frameStride: u32\n) -> mat4x4f {\n return weights.x * sampleGPUAnimationMatrix(frames, blend, 4u + joints.x * 4u, frameStride)\n + weights.y * sampleGPUAnimationMatrix(frames, blend, 4u + joints.y * 4u, frameStride)\n + weights.z * sampleGPUAnimationMatrix(frames, blend, 4u + joints.z * 4u, frameStride)\n + weights.w * sampleGPUAnimationMatrix(frames, blend, 4u + joints.w * 4u, frameStride);\n}\n#endif\n\n#ifdef HAS_INSTANCED_MORPH\n@group(0) @binding(auto) var<storage, read> gpuMorphTargets: array<vec4f>;\n\n#ifndef HAS_GPU_CROWD_ANIMATION\n@group(0) @binding(auto) var<storage, read> gpuMorphWeights: array<vec4f>;\n#endif\n\nfn getGPUCrowdMorphWeight(\n instanceIndex: u32,\n targetIndex: u32,\n targetCount: u32,\n jointsPerInstance: u32,\n frames: vec4f,\n blend: vec4f,\n frameStride: u32\n) -> f32 {\n#ifdef HAS_GPU_CROWD_ANIMATION\n let offset = 4u + jointsPerInstance * 4u + targetIndex;\n return sampleGPUAnimationFrame(frames, blend, offset, frameStride).x;\n#else\n let packedCount = (targetCount + 3u) / 4u;\n let packedWeights = gpuMorphWeights[instanceIndex * packedCount + targetIndex / 4u];\n return packedWeights[targetIndex % 4u];\n#endif\n}\n\nfn getGPUCrowdMorphDelta(\n instanceIndex: u32,\n vertexIndex: u32,\n attributeIndex: u32,\n vertexCount: u32,\n targetCount: u32,\n jointsPerInstance: u32,\n frames: vec4f,\n blend: vec4f,\n frameStride: u32\n) -> vec3f {\n var result = vec3f(0.0);\n for (var targetIndex = 0u; targetIndex < targetCount; targetIndex++) {\n let weight = getGPUCrowdMorphWeight(\n instanceIndex,\n targetIndex,\n targetCount,\n jointsPerInstance,\n frames,\n blend,\n frameStride\n );\n let offset = (targetIndex * 3u + attributeIndex) * vertexCount + vertexIndex;\n result += gpuMorphTargets[offset].xyz * weight;\n }\n return result;\n}\n#endif\n",vs:"\n#ifdef HAS_GPU_CROWD_ANIMATION\nuniform highp sampler2D gpuAnimationFrames;\n\nvec4 sampleGPUAnimationFrame(vec4 frames, vec4 blend, int offset) {\n vec4 first = mix(\n texelFetch(gpuAnimationFrames, ivec2(offset, int(frames.x)), 0),\n texelFetch(gpuAnimationFrames, ivec2(offset, int(frames.y)), 0),\n frames.z\n );\n if (blend.w <= 0.0) {\n return first;\n }\n vec4 second = mix(\n texelFetch(gpuAnimationFrames, ivec2(offset, int(blend.x)), 0),\n texelFetch(gpuAnimationFrames, ivec2(offset, int(blend.y)), 0),\n blend.z\n );\n return mix(first, second, blend.w);\n}\n\nmat4 sampleGPUAnimationMatrix(vec4 frames, vec4 blend, int firstColumn) {\n return mat4(\n sampleGPUAnimationFrame(frames, blend, firstColumn),\n sampleGPUAnimationFrame(frames, blend, firstColumn + 1),\n sampleGPUAnimationFrame(frames, blend, firstColumn + 2),\n sampleGPUAnimationFrame(frames, blend, firstColumn + 3)\n );\n}\n\nmat4 getGPUAnimatedSkinMatrix(vec4 weights, uvec4 joints, vec4 frames, vec4 blend) {\n return weights.x * sampleGPUAnimationMatrix(frames, blend, 4 + int(joints.x) * 4)\n + weights.y * sampleGPUAnimationMatrix(frames, blend, 4 + int(joints.y) * 4)\n + weights.z * sampleGPUAnimationMatrix(frames, blend, 4 + int(joints.z) * 4)\n + weights.w * sampleGPUAnimationMatrix(frames, blend, 4 + int(joints.w) * 4);\n}\n#endif\n\n#ifdef HAS_INSTANCED_MORPH\nuniform highp sampler2D gpuMorphTargets;\n\n#ifndef HAS_GPU_CROWD_ANIMATION\nuniform highp sampler2D gpuMorphWeights;\n#endif\n\nfloat getGPUCrowdMorphWeight(\n uint instanceIndex,\n uint targetIndex,\n uint jointsPerInstance,\n vec4 frames,\n vec4 blend\n) {\n#ifdef HAS_GPU_CROWD_ANIMATION\n int offset = 4 + int(jointsPerInstance) * 4 + int(targetIndex);\n return sampleGPUAnimationFrame(frames, blend, offset).x;\n#else\n vec4 packedWeights = texelFetch(\n gpuMorphWeights,\n ivec2(int(targetIndex / 4u), int(instanceIndex)),\n 0\n );\n return packedWeights[int(targetIndex % 4u)];\n#endif\n}\n\nvec3 getGPUCrowdMorphDelta(\n uint instanceIndex,\n uint vertexIndex,\n uint attributeIndex,\n uint targetCount,\n uint jointsPerInstance,\n vec4 frames,\n vec4 blend\n) {\n vec3 result = vec3(0.0);\n for (uint targetIndex = 0u; targetIndex < targetCount; targetIndex++) {\n float weight = getGPUCrowdMorphWeight(\n instanceIndex,\n targetIndex,\n jointsPerInstance,\n frames,\n blend\n );\n result += texelFetch(\n gpuMorphTargets,\n ivec2(int(vertexIndex), int(targetIndex * 3u + attributeIndex)),\n 0\n ).xyz * weight;\n }\n return result;\n}\n#endif\n",fs:"",bindingLayout:[{name:"gpuAnimationFrames",group:0,visibility:1},{name:"gpuMorphTargets",group:0,visibility:1},{name:"gpuMorphWeights",group:0,visibility:1}],getUniforms:(e={})=>e},U="#ifdef USE_IBL\nuniform samplerCube pbr_diffuseEnvSampler;\nuniform samplerCube pbr_specularEnvSampler;\nuniform sampler2D pbr_brdfLUT;\n#endif\n",V={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:U,fs:U},j="layout(std140) uniform pbrProjectionUniforms {\n mat4 modelViewProjectionMatrix;\n mat4 modelMatrix;\n mat4 normalMatrix;\n vec3 camera;\n} pbrProjection;\n",z={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:j,fs:j,getUniforms:e=>e,uniformTypes:{modelViewProjectionMatrix:"mat4x4<f32>",modelMatrix:"mat4x4<f32>",normalMatrix:"mat4x4<f32>",camera:"vec3<f32>"}},G={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,dispersion:0,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],bumpFactor:1,bumpMapEnabled:!1,diffuseTransmissionFactor:0,diffuseTransmissionMapEnabled:!1,diffuseTransmissionColorFactor:[1,1,1],diffuseTransmissionColorMapEnabled:!1,multiscatterColorFactor:[0,0,0],multiscatterColorMapEnabled:!1,scatterAnisotropy:0,bumpUVSet:0,bumpUVTransform:[1,0,0,0,1,0,0,0,1],diffuseTransmissionUVSet:0,diffuseTransmissionUVTransform:[1,0,0,0,1,0,0,0,1],diffuseTransmissionColorUVSet:0,diffuseTransmissionColorUVTransform:[1,0,0,0,1,0,0,0,1],multiscatterColorUVSet:0,multiscatterColorUVTransform:[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},{name:"pbr_bumpSampler",group:3},{name:"pbr_diffuseTransmissionSampler",group:3},{name:"pbr_diffuseTransmissionColorSampler",group:3},{name:"pbr_multiscatterColorSampler",group:3}],dependencies:[t.lighting,V,z],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 dispersion: 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 bumpFactor: f32,\n bumpMapEnabled: i32,\n diffuseTransmissionFactor: f32,\n diffuseTransmissionMapEnabled: i32,\n diffuseTransmissionColorFactor: vec3f,\n diffuseTransmissionColorMapEnabled: i32,\n multiscatterColorFactor: vec3f,\n multiscatterColorMapEnabled: i32,\n scatterAnisotropy: f32,\n\n bumpUVSet: i32,\n bumpUVTransform: mat3x3f,\n diffuseTransmissionUVSet: i32,\n diffuseTransmissionUVTransform: mat3x3f,\n diffuseTransmissionColorUVSet: i32,\n diffuseTransmissionColorUVTransform: mat3x3f,\n multiscatterColorUVSet: i32,\n multiscatterColorUVTransform: 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#ifdef HAS_BUMPMAP\n@group(3) @binding(auto) var pbr_bumpSampler: texture_2d<f32>;\n@group(3) @binding(auto) var pbr_bumpSamplerSampler: sampler;\n#endif\n#ifdef HAS_DIFFUSETRANSMISSIONMAP\n@group(3) @binding(auto) var pbr_diffuseTransmissionSampler: texture_2d<f32>;\n@group(3) @binding(auto) var pbr_diffuseTransmissionSamplerSampler: sampler;\n#endif\n#ifdef HAS_DIFFUSETRANSMISSIONCOLORMAP\n@group(3) @binding(auto) var pbr_diffuseTransmissionColorSampler: texture_2d<f32>;\n@group(3) @binding(auto) var pbr_diffuseTransmissionColorSamplerSampler: sampler;\n#endif\n#ifdef HAS_MULTISCATTERCOLORMAP\n@group(3) @binding(auto) var pbr_multiscatterColorSampler: texture_2d<f32>;\n@group(3) @binding(auto) var pbr_multiscatterColorSamplerSampler: 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 l: vec3f, // direction from the surface toward the current light\n h: vec3f // half vector between the current light and camera\n};\n\nconst M_PI = 3.141592653589793;\nconst c_MinRoughness = 0.04;\n\n// Widen sub-pixel specular lobes using the screen-space normal footprint.\n// This is geometric specular antialiasing: the normal variance is converted\n// into an additional squared perceptual roughness before evaluating BRDFs.\nfn widenSpecularRoughness(perceptualRoughness: f32, normal: vec3f) -> f32 {\n let normalDerivativeX = dpdx(normal);\n let normalDerivativeY = dpdy(normal);\n let normalVariance =\n dot(normalDerivativeX, normalDerivativeX) +\n dot(normalDerivativeY, normalDerivativeY);\n let kernelRoughnessSquared = min(2.0 * normalVariance, 1.0);\n return clamp(\n sqrt(perceptualRoughness * perceptualRoughness + kernelRoughnessSquared),\n c_MinRoughness,\n 1.0\n );\n}\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_dy, pos_dx);\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#ifdef HAS_BUMPMAP\n let bumpUV = getMaterialUV(pbrMaterial.bumpUVSet, pbrMaterial.bumpUVTransform);\n let bumpTexelSize = 1.0 / vec2f(textureDimensions(pbr_bumpSampler, 0));\n let bumpHeight = textureSample(pbr_bumpSampler, pbr_bumpSamplerSampler, bumpUV).r;\n let bumpGradient = vec2f(\n textureSample(\n pbr_bumpSampler,\n pbr_bumpSamplerSampler,\n bumpUV + vec2f(bumpTexelSize.x, 0.0)\n ).r - bumpHeight,\n textureSample(\n pbr_bumpSampler,\n pbr_bumpSamplerSampler,\n bumpUV + vec2f(0.0, bumpTexelSize.y)\n ).r - bumpHeight\n );\n n = normalize(n - pbrMaterial.bumpFactor *\n (tbn[0] * bumpGradient.x + tbn[1] * bumpGradient.y));\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#ifdef USE_SCENE_ENVIRONMENT\n let maximumMipLevel = max(pbrScene.environmentMipCount - 1.0, 0.0);\n let rotationSine = sin(pbrScene.environmentRotation);\n let rotationCosine = cos(pbrScene.environmentRotation);\n let environmentRotation = mat2x2f(\n vec2f(rotationCosine, rotationSine),\n vec2f(-rotationSine, rotationCosine)\n );\n let rotatedNormal = environmentRotation * n.xz;\n let rotatedReflection = environmentRotation * reflection.xz;\n let environmentNormal = vec3f(rotatedNormal.x, n.y, rotatedNormal.y);\n let environmentReflection = vec3f(rotatedReflection.x, reflection.y, rotatedReflection.y);\n#else\n let maximumMipLevel = 9.0;\n let environmentNormal = n;\n let environmentReflection = reflection;\n#endif\n let lod = pbrInfo.perceptualRoughness * maximumMipLevel;\n // retrieve a scale and bias to F0. See [1], Figure 3\n let brdfSample = textureSampleLevel(\n pbr_brdfLUT,\n pbr_brdfLUTSampler,\n vec2f(pbrInfo.NdotV, 1.0 - pbrInfo.perceptualRoughness),\n 0.0\n );\n let diffuseSample = textureSampleLevel(\n pbr_diffuseEnvSampler,\n pbr_diffuseEnvSamplerSampler,\n environmentNormal,\n 0.0\n );\n var specularSample = textureSampleLevel(\n pbr_specularEnvSampler,\n pbr_specularEnvSamplerSampler,\n environmentReflection,\n 0.0\n );\n#ifdef USE_TEX_LOD\n specularSample = textureSampleLevel(\n pbr_specularEnvSampler,\n pbr_specularEnvSamplerSampler,\n environmentReflection,\n lod\n );\n#endif\n\n#ifdef USE_SCENE_ENVIRONMENT\n let brdf = brdfSample.rgb;\n let diffuseLight = diffuseSample.rgb;\n let specularLight = specularSample.rgb;\n#else\n let brdf = SRGBtoLINEAR(brdfSample).rgb;\n let diffuseLight = SRGBtoLINEAR(diffuseSample).rgb;\n let specularLight = SRGBtoLINEAR(specularSample).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#ifdef USE_SCENE_ENVIRONMENT\n return (diffuse + specular) * max(pbrScene.environmentIntensity, 0.0);\n#else\n return diffuse + specular;\n#endif\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 encodeLinearSRGB(linearColor: vec3f) -> vec3f {\n let positiveColor = max(linearColor, vec3f(0.0));\n return select(\n positiveColor * 12.92,\n 1.055 * pow(positiveColor, vec3f(1.0 / 2.4)) - 0.055,\n positiveColor > vec3f(0.0031308)\n );\n}\n\nfn toneMapKhronosPBRNeutral(inputColor: vec3f) -> vec3f {\n let startCompression = 0.76;\n let darkestChannel = min(inputColor.r, min(inputColor.g, inputColor.b));\n let offset = select(\n 0.04,\n darkestChannel - 6.25 * darkestChannel * darkestChannel,\n darkestChannel < 0.08\n );\n var color = inputColor - vec3f(offset);\n let peak = maxComponent(color);\n if (peak < startCompression) {\n return color;\n }\n\n let compressionRange = 1.0 - startCompression;\n let compressedPeak = 1.0 - compressionRange * compressionRange /\n (peak + compressionRange - startCompression);\n color *= compressedPeak / max(peak, 0.0001);\n let desaturation = 1.0 - 1.0 / (0.15 * (peak - compressedPeak) + 1.0);\n return mix(color, vec3f(compressedPeak), desaturation);\n}\n\nfn applySceneColorManagement(sceneColor: vec3f) -> vec3f {\n#ifdef USE_SCENE_COLOR_MANAGEMENT\n var color = max(sceneColor, vec3f(0.0)) * max(pbrScene.exposure, 0.0);\n if (pbrScene.toneMapMode == 1) {\n color /= vec3f(1.0) + color;\n } else if (pbrScene.toneMapMode == 2) {\n color = toneMapKhronosPBRNeutral(color);\n } else if (pbrScene.toneMapMode == 3) {\n color = clamp(\n (color * (2.51 * color + 0.03)) / (color * (2.43 * color + 0.59) + 0.14),\n vec3f(0.0),\n vec3f(1.0)\n );\n }\n if (pbrScene.outputEncoding == 0) {\n return color;\n }\n return encodeLinearSRGB(color);\n#else\n return pow(max(sceneColor, vec3f(0.0)), vec3f(1.0 / 2.2));\n#endif\n}\n\nfn dielectricSchlick(reflectance: f32, cosine: f32) -> f32 {\n return reflectance + (1.0 - reflectance) * pow(clamp(1.0 - cosine, 0.0, 1.0), 5.0);\n}\n\nfn evaluateIridescenceSensitivity(opticalPathDifference: f32, phaseShift: vec3f) -> vec3f {\n let phase = 2.0 * M_PI * opticalPathDifference * 1.0e-9;\n let sensitivity = vec3f(5.4856e-13, 4.4201e-13, 5.2481e-13);\n let position = vec3f(1.6810e6, 1.7953e6, 2.2084e6);\n let variance = vec3f(4.3278e9, 9.3046e9, 6.6121e9);\n var xyz = sensitivity * sqrt(2.0 * M_PI * variance) *\n cos(position * phase + phaseShift) * exp(-phase * phase * variance);\n xyz.x += 9.7470e-14 * sqrt(2.0 * M_PI * 4.5282e9) *\n cos(2.2399e6 * phase + phaseShift.x) * exp(-4.5282e9 * phase * phase);\n xyz /= 1.0685e-7;\n return mat3x3f(\n vec3f(3.2404542, -0.9692660, 0.0556434),\n vec3f(-1.5371385, 1.8760108, -0.2040259),\n vec3f(-0.4985314, 0.0415560, 1.0572252)\n ) * xyz;\n}\n\nfn getIridescenceTint(\n iridescence: f32,\n thickness: f32,\n NdotV: f32,\n baseReflectance: vec3f\n) -> vec3f {\n if (iridescence <= 0.0 || thickness <= 0.0) {\n return baseReflectance;\n }\n\n let filmIor = max(pbrMaterial.iridescenceIor, 1.0);\n let sineSquared = (1.0 - NdotV * NdotV) / (filmIor * filmIor);\n let cosineSquared = 1.0 - sineSquared;\n if (cosineSquared <= 0.0) {\n return mix(baseReflectance, vec3f(1.0), iridescence);\n }\n let filmCosine = sqrt(cosineSquared);\n let firstInterfaceReflectance = dielectricSchlick(getDielectricF0(filmIor), NdotV);\n let transmittedEnergy = 1.0 - firstInterfaceReflectance;\n let squareRootReflectance = sqrt(clamp(baseReflectance, vec3f(0.0), vec3f(0.9999)));\n let baseIor = (vec3f(1.0) + squareRootReflectance) /\n (vec3f(1.0) - squareRootReflectance);\n var secondInterfaceF0 = (baseIor - vec3f(filmIor)) / (baseIor + vec3f(filmIor));\n secondInterfaceF0 *= secondInterfaceF0;\n let secondInterfaceReflectance = secondInterfaceF0 +\n (vec3f(1.0) - secondInterfaceF0) * pow(1.0 - filmCosine, 5.0);\n let phaseShift = vec3f(M_PI) + select(\n vec3f(0.0),\n vec3f(M_PI),\n baseIor < vec3f(filmIor)\n );\n let opticalPathDifference = 2.0 * filmIor * thickness * filmCosine;\n let combinedReflectance = clamp(\n firstInterfaceReflectance * secondInterfaceReflectance,\n vec3f(0.00001),\n vec3f(0.9999)\n );\n let recurringAmplitude = sqrt(combinedReflectance);\n let interfaceResponse = transmittedEnergy * transmittedEnergy * secondInterfaceReflectance /\n (vec3f(1.0) - combinedReflectance);\n var reflectedSpectrum = vec3f(firstInterfaceReflectance) + interfaceResponse;\n var harmonicAmplitude = interfaceResponse - vec3f(transmittedEnergy);\n for (var harmonic = 1; harmonic <= 2; harmonic++) {\n harmonicAmplitude *= recurringAmplitude;\n reflectedSpectrum += harmonicAmplitude * 2.0 * evaluateIridescenceSensitivity(\n f32(harmonic) * opticalPathDifference,\n f32(harmonic) * phaseShift\n );\n }\n return mix(baseReflectance, clamp(reflectedSpectrum, vec3f(0.0), vec3f(1.0)), 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\n// KHR_materials_volume_scatter is an active draft. This evaluates a local,\n// thickness-aware single-scattering approximation rather than random walk.\nfn getDiffuseTransmissionAttenuation(\n pbrInfo: PBRInfo,\n multiscatterColor: vec3f,\n thickness: f32\n) -> vec3f {\n let volumeAttenuation = getVolumeAttenuation(thickness);\n let scatteringStrength = maxComponent(multiscatterColor);\n if (thickness <= 0.0 || scatteringStrength <= 0.0001) {\n return volumeAttenuation;\n }\n\n let anisotropy = clamp(pbrMaterial.scatterAnisotropy, -0.95, 0.95);\n let scatteringCosine = clamp(dot(-pbrInfo.v, pbrInfo.l), -1.0, 1.0);\n let phaseDenominator = max(\n 1.0 + anisotropy * anisotropy - 2.0 * anisotropy * scatteringCosine,\n 0.0001\n );\n let phaseWeight = clamp(\n (1.0 - anisotropy * anisotropy) / pow(phaseDenominator, 1.5),\n 0.0,\n 4.0\n );\n let scatteringDepth = thickness / max(pbrMaterial.attenuationDistance, 0.0001);\n let scatteringProbability = 1.0 - exp(-scatteringDepth);\n let scatteringColor = clamp(multiscatterColor, vec3f(0.0), vec3f(1.0));\n return mix(\n volumeAttenuation,\n volumeAttenuation * mix(vec3f(1.0), scatteringColor * phaseWeight, scatteringColor),\n scatteringProbability\n );\n}\n\nfn calculateDiffuseTransmissionLight(\n pbrInfo: PBRInfo,\n lightColor: vec3f,\n diffuseTransmissionColor: vec3f,\n diffuseTransmission: f32,\n multiscatterColor: vec3f,\n thickness: f32\n) -> vec3f {\n let oppositeHemisphere = max(dot(-pbrInfo.n, pbrInfo.l), 0.0);\n if (oppositeHemisphere <= 0.0 || diffuseTransmission <= 0.0) {\n return vec3f(0.0);\n }\n\n let nonReflectedEnergy = vec3f(1.0) - clamp(pbrInfo.reflectance0, vec3f(0.0), vec3f(1.0));\n let attenuatedColor = getDiffuseTransmissionAttenuation(\n pbrInfo,\n multiscatterColor,\n thickness\n );\n return lightColor * diffuseTransmissionColor * nonReflectedEnergy *\n attenuatedColor * (diffuseTransmission * oppositeHemisphere / M_PI);\n}\n\n#ifdef USE_IBL\nfn calculateDiffuseTransmissionIBL(\n pbrInfo: PBRInfo,\n diffuseTransmissionColor: vec3f,\n diffuseTransmission: f32,\n multiscatterColor: vec3f,\n thickness: f32\n) -> vec3f {\n if (diffuseTransmission <= 0.0) {\n return vec3f(0.0);\n }\n\n#ifdef USE_SCENE_ENVIRONMENT\n let rotationSine = sin(pbrScene.environmentRotation);\n let rotationCosine = cos(pbrScene.environmentRotation);\n let environmentRotation = mat2x2f(\n vec2f(rotationCosine, rotationSine),\n vec2f(-rotationSine, rotationCosine)\n );\n let rotatedNormal = environmentRotation * -pbrInfo.n.xz;\n let oppositeNormal = vec3f(rotatedNormal.x, -pbrInfo.n.y, rotatedNormal.y);\n let environmentColor = textureSampleLevel(\n pbr_diffuseEnvSampler,\n pbr_diffuseEnvSamplerSampler,\n oppositeNormal,\n 0.0\n ).rgb * max(pbrScene.environmentIntensity, 0.0);\n#else\n let environmentColor = SRGBtoLINEAR(\n textureSampleLevel(pbr_diffuseEnvSampler, pbr_diffuseEnvSamplerSampler, -pbrInfo.n, 0.0)\n ).rgb;\n#endif\n let nonReflectedEnergy = vec3f(1.0) - clamp(pbrInfo.reflectance0, vec3f(0.0), vec3f(1.0));\n return environmentColor * diffuseTransmissionColor * nonReflectedEnergy *\n getDiffuseTransmissionAttenuation(pbrInfo, multiscatterColor, thickness) *\n diffuseTransmission * pbrMaterial.scaleIBLAmbient.x;\n}\n#endif\n\n#ifdef USE_TRANSMISSION_FRAMEBUFFER\nfn sampleTransmittedSceneColor(\n position: vec3f,\n normal: vec3f,\n viewDirection: vec3f,\n thickness: f32,\n perceptualRoughness: f32,\n indexOfRefraction: f32\n) -> vec3f {\n let refractionDirection = refract(\n -viewDirection,\n normal,\n 1.0 / max(indexOfRefraction, 1.0)\n );\n let refractedPosition = position + refractionDirection * thickness;\n let clipPosition = pbrScene.projectionMatrix *\n pbrScene.viewMatrix * vec4f(refractedPosition, 1.0);\n var textureCoordinate = clipPosition.xy / max(clipPosition.w, 0.0001) * 0.5 + 0.5;\n textureCoordinate.y = 1.0 - textureCoordinate.y;\n textureCoordinate = clamp(textureCoordinate, vec2f(0.001), vec2f(0.999));\n\n let blurRadius = perceptualRoughness * perceptualRoughness * 8.0 /\n max(pbrScene.framebufferSize, vec2f(1.0));\n var sceneColor = textureSampleLevel(\n pbr_transmissionFramebufferSampler,\n pbr_transmissionFramebufferSamplerSampler,\n textureCoordinate,\n 0.0\n ).rgb * 0.4;\n sceneColor += textureSampleLevel(\n pbr_transmissionFramebufferSampler,\n pbr_transmissionFramebufferSamplerSampler,\n textureCoordinate + vec2f(blurRadius.x, 0.0),\n 0.0\n ).rgb * 0.15;\n sceneColor += textureSampleLevel(\n pbr_transmissionFramebufferSampler,\n pbr_transmissionFramebufferSamplerSampler,\n textureCoordinate - vec2f(blurRadius.x, 0.0),\n 0.0\n ).rgb * 0.15;\n sceneColor += textureSampleLevel(\n pbr_transmissionFramebufferSampler,\n pbr_transmissionFramebufferSamplerSampler,\n textureCoordinate + vec2f(0.0, blurRadius.y),\n 0.0\n ).rgb * 0.15;\n sceneColor += textureSampleLevel(\n pbr_transmissionFramebufferSampler,\n pbr_transmissionFramebufferSamplerSampler,\n textureCoordinate - vec2f(0.0, blurRadius.y),\n 0.0\n ).rgb * 0.15;\n return max(sceneColor, vec3f(0.0));\n}\n\nfn getTransmittedSceneColor(\n position: vec3f,\n normal: vec3f,\n viewDirection: vec3f,\n thickness: f32,\n perceptualRoughness: f32\n) -> vec3f {\n if (pbrMaterial.dispersion <= 0.0) {\n return sampleTransmittedSceneColor(\n position,\n normal,\n viewDirection,\n thickness,\n perceptualRoughness,\n pbrMaterial.ior\n );\n }\n\n let halfSpread = (max(pbrMaterial.ior, 1.0) - 1.0) * 0.025 * pbrMaterial.dispersion;\n let indicesOfRefraction = max(\n vec3f(pbrMaterial.ior - halfSpread, pbrMaterial.ior, pbrMaterial.ior + halfSpread),\n vec3f(1.0)\n );\n return vec3f(\n sampleTransmittedSceneColor(\n position, normal, viewDirection, thickness, perceptualRoughness, indicesOfRefraction.r\n ).r,\n sampleTransmittedSceneColor(\n position, normal, viewDirection, thickness, perceptualRoughness, indicesOfRefraction.g\n ).g,\n sampleTransmittedSceneColor(\n position, normal, viewDirection, thickness, perceptualRoughness, indicesOfRefraction.b\n ).b\n );\n}\n#endif\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 basePBRInfo.l,\n basePBRInfo.h\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 alpha = max(sheenRoughness * sheenRoughness, 0.0001);\n let inverseAlpha = 1.0 / alpha;\n let sineSquared = max(1.0 - pbrInfo.NdotH * pbrInfo.NdotH, 0.0);\n let distribution = (2.0 + inverseAlpha) * pow(sineSquared, inverseAlpha * 0.5) /\n (2.0 * M_PI);\n let visibility = 1.0 / max(\n 4.0 * (pbrInfo.NdotL + pbrInfo.NdotV - pbrInfo.NdotL * pbrInfo.NdotV),\n 0.0001\n );\n return pbrInfo.NdotL * lightColor * sheenColor * distribution * visibility *\n (1.0 - pbrInfo.metalness);\n}\n\nfn calculateAnisotropicLightColor(\n pbrInfo: PBRInfo,\n lightColor: vec3f,\n anisotropyTangent: vec3f,\n anisotropyStrength: f32\n) -> vec3f {\n if (anisotropyStrength <= 0.0) {\n return calculateFinalColor(pbrInfo, lightColor);\n }\n\n let anisotropyBitangent = normalize(cross(pbrInfo.n, anisotropyTangent));\n let tangentRoughness = mix(\n pbrInfo.alphaRoughness,\n 1.0,\n anisotropyStrength * anisotropyStrength\n );\n let bitangentRoughness = clamp(pbrInfo.alphaRoughness, 0.001, 1.0);\n let roughnessProduct = tangentRoughness * bitangentRoughness;\n let distributionVector = vec3f(\n bitangentRoughness * dot(anisotropyTangent, pbrInfo.h),\n tangentRoughness * dot(anisotropyBitangent, pbrInfo.h),\n roughnessProduct * pbrInfo.NdotH\n );\n let distributionFactor = roughnessProduct /\n max(dot(distributionVector, distributionVector), 0.000001);\n let distribution = roughnessProduct * distributionFactor * distributionFactor / M_PI;\n let viewMask = pbrInfo.NdotL * length(vec3f(\n tangentRoughness * dot(anisotropyTangent, pbrInfo.v),\n bitangentRoughness * dot(anisotropyBitangent, pbrInfo.v),\n pbrInfo.NdotV\n ));\n let lightMask = pbrInfo.NdotV * length(vec3f(\n tangentRoughness * dot(anisotropyTangent, pbrInfo.l),\n bitangentRoughness * dot(anisotropyBitangent, pbrInfo.l),\n pbrInfo.NdotL\n ));\n let visibility = clamp(0.5 / max(viewMask + lightMask, 0.000001), 0.0, 1.0);\n let fresnel = specularReflection(pbrInfo);\n let diffuseContribution = (vec3f(1.0) - fresnel) * diffuse(pbrInfo);\n return pbrInfo.NdotL * lightColor *\n (diffuseContribution + fresnel * distribution * visibility);\n}\n\nfn getAnisotropicReflection(\n pbrInfo: PBRInfo,\n anisotropyTangent: vec3f,\n anisotropyStrength: f32\n) -> vec3f {\n if (anisotropyStrength <= 0.0) {\n return -normalize(reflect(pbrInfo.v, pbrInfo.n));\n }\n let anisotropyBitangent = normalize(cross(pbrInfo.n, anisotropyTangent));\n var anisotropicNormal = normalize(cross(anisotropyBitangent, pbrInfo.v));\n anisotropicNormal = normalize(cross(anisotropicNormal, anisotropyBitangent));\n let bend = anisotropyStrength * (1.0 - pbrInfo.perceptualRoughness);\n return -normalize(reflect(pbrInfo.v, normalize(mix(pbrInfo.n, anisotropicNormal, bend))));\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 var color = calculateAnisotropicLightColor(\n pbrInfo,\n lightColor,\n anisotropyTangent,\n anisotropyStrength\n );\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 (*pbrInfo).l = (*pbrInfo).n;\n (*pbrInfo).h = (*pbrInfo).n;\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 (*pbrInfo).l = l;\n (*pbrInfo).h = h;\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(vertexColor: 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 let diffuseTransmissionUV = getMaterialUV(\n pbrMaterial.diffuseTransmissionUVSet,\n pbrMaterial.diffuseTransmissionUVTransform\n );\n let diffuseTransmissionColorUV = getMaterialUV(\n pbrMaterial.diffuseTransmissionColorUVSet,\n pbrMaterial.diffuseTransmissionColorUVTransform\n );\n let multiscatterColorUV = getMaterialUV(\n pbrMaterial.multiscatterColorUVSet,\n pbrMaterial.multiscatterColorUVTransform\n );\n\n // The albedo may be defined from a base texture or a flat color\n var baseColor: vec4<f32> = pbrMaterial.baseColorFactor * vertexColor;\n #ifdef HAS_BASECOLORMAP\n baseColor = SRGBtoLINEAR(\n textureSample(pbr_baseColorSampler, pbr_baseColorSamplerSampler, baseColorUV)\n ) * pbrMaterial.baseColorFactor * vertexColor;\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 perceptualRoughness = widenSpecularRoughness(perceptualRoughness, n);\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.dispersion > 0.0001 ||\n pbrMaterial.transmissionMapEnabled != 0 ||\n pbrMaterial.transmissionFactor > 0.0001 ||\n pbrMaterial.diffuseTransmissionMapEnabled != 0 ||\n pbrMaterial.diffuseTransmissionColorMapEnabled != 0 ||\n pbrMaterial.diffuseTransmissionFactor > 0.0001 ||\n pbrMaterial.multiscatterColorMapEnabled != 0 ||\n maxComponent(pbrMaterial.multiscatterColorFactor) > 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 n\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>(applySceneColorManagement(color), 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 diffuseTransmission = clamp(pbrMaterial.diffuseTransmissionFactor, 0.0, 1.0);\n #ifdef HAS_DIFFUSETRANSMISSIONMAP\n if (pbrMaterial.diffuseTransmissionMapEnabled != 0) {\n diffuseTransmission *= textureSample(\n pbr_diffuseTransmissionSampler,\n pbr_diffuseTransmissionSamplerSampler,\n diffuseTransmissionUV\n ).a;\n }\n #endif\n diffuseTransmission *= (1.0 - metallic) * (1.0 - transmission);\n var diffuseTransmissionColor = pbrMaterial.diffuseTransmissionColorFactor;\n #ifdef HAS_DIFFUSETRANSMISSIONCOLORMAP\n if (pbrMaterial.diffuseTransmissionColorMapEnabled != 0) {\n diffuseTransmissionColor *= SRGBtoLINEAR(\n textureSample(\n pbr_diffuseTransmissionColorSampler,\n pbr_diffuseTransmissionColorSamplerSampler,\n diffuseTransmissionColorUV\n )\n ).rgb;\n }\n #endif\n var multiscatterColor = pbrMaterial.multiscatterColorFactor;\n #ifdef HAS_MULTISCATTERCOLORMAP\n if (pbrMaterial.multiscatterColorMapEnabled != 0) {\n multiscatterColor *= SRGBtoLINEAR(\n textureSample(\n pbr_multiscatterColorSampler,\n pbr_multiscatterColorSamplerSampler,\n multiscatterColorUV\n )\n ).rgb;\n }\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 clearcoatRoughness = widenSpecularRoughness(clearcoatRoughness, clearcoatNormal);\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 // 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 dielectricSpecularF0 = getIridescenceTint(\n iridescence,\n iridescenceThickness,\n NdotV,\n dielectricSpecularF0\n );\n var diffuseColor = baseColor.rgb * (vec3f(1.0) - dielectricSpecularF0);\n diffuseColor *= (1.0 - metallic) * (1.0 - transmission) * (1.0 - diffuseTransmission);\n var specularColor = mix(dielectricSpecularF0, baseColor.rgb, metallic);\n\n let clearcoatViewFresnel = dielectricSchlick(\n 0.04,\n clamp(abs(dot(clearcoatNormal, v)), 0.0, 1.0)\n );\n let sheenDirectionalAlbedo = maxComponent(sheenColor) *\n (0.157 + 0.343 * (1.0 - NdotV)) * (1.0 - sheenRoughness * 0.5);\n let baseLayerEnergy = (1.0 - clearcoatFactor * clearcoatViewFresnel) *\n (1.0 - clamp(sheenDirectionalAlbedo, 0.0, 1.0));\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 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 (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 color += calculateDiffuseTransmissionLight(\n pbrInfo,\n lighting_getDirectionalLight(i).color,\n diffuseTransmissionColor,\n diffuseTransmission,\n multiscatterColor,\n thickness\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 color += calculateDiffuseTransmissionLight(\n pbrInfo,\n lighting_getPointLight(i).color / attenuation,\n diffuseTransmissionColor,\n diffuseTransmission,\n multiscatterColor,\n thickness\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 color += calculateDiffuseTransmissionLight(\n pbrInfo,\n lighting_getSpotLight(i).color / attenuation,\n diffuseTransmissionColor,\n diffuseTransmission,\n multiscatterColor,\n thickness\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(\n pbrInfo,\n n,\n getAnisotropicReflection(pbrInfo, anisotropyTangent, anisotropyStrength)\n );\n color += calculateClearcoatIBLContribution(\n pbrInfo,\n clearcoatNormal,\n -normalize(reflect(v, clearcoatNormal)),\n clearcoatFactor,\n clearcoatRoughness\n );\n color += calculateDiffuseTransmissionIBL(\n pbrInfo,\n diffuseTransmissionColor,\n diffuseTransmission,\n multiscatterColor,\n thickness\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 #ifdef USE_TRANSMISSION_FRAMEBUFFER\n let dielectricFresnel = getDielectricF0(pbrMaterial.ior);\n let transmissionFresnel = dielectricFresnel +\n (1.0 - dielectricFresnel) * pow(1.0 - NdotV, 5.0);\n let transmittedColor = getTransmittedSceneColor(\n fragmentInputs.pbr_vPosition,\n n,\n v,\n thickness,\n perceptualRoughness\n );\n color += transmittedColor * getVolumeAttenuation(thickness) *\n transmission * (1.0 - transmissionFresnel);\n #else\n color = mix(color, color * getVolumeAttenuation(thickness), transmission);\n #endif\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 #ifdef USE_TRANSMISSION_FRAMEBUFFER\n let alpha = clamp(baseColor.a, 0.0, 1.0);\n #else\n let alpha = clamp(baseColor.a * (1.0 - transmission), 0.0, 1.0);\n #endif\n return vec4<f32>(applySceneColorManagement(color), 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 float dispersion;\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\n float bumpFactor;\n bool bumpMapEnabled;\n float diffuseTransmissionFactor;\n bool diffuseTransmissionMapEnabled;\n vec3 diffuseTransmissionColorFactor;\n bool diffuseTransmissionColorMapEnabled;\n vec3 multiscatterColorFactor;\n bool multiscatterColorMapEnabled;\n float scatterAnisotropy;\n\n int bumpUVSet;\n mat3 bumpUVTransform;\n int diffuseTransmissionUVSet;\n mat3 diffuseTransmissionUVTransform;\n int diffuseTransmissionColorUVSet;\n mat3 diffuseTransmissionColorUVTransform;\n int multiscatterColorUVSet;\n mat3 multiscatterColorUVTransform;\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#ifdef HAS_BUMPMAP\nuniform sampler2D pbr_bumpSampler;\n#endif\n#ifdef HAS_DIFFUSETRANSMISSIONMAP\nuniform sampler2D pbr_diffuseTransmissionSampler;\n#endif\n#ifdef HAS_DIFFUSETRANSMISSIONCOLORMAP\nuniform sampler2D pbr_diffuseTransmissionColorSampler;\n#endif\n#ifdef HAS_MULTISCATTERCOLORMAP\nuniform sampler2D pbr_multiscatterColorSampler;\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 vec3 l; // direction from the surface toward the current light\n vec3 h; // half vector between the current light and camera\n};\n\nconst float M_PI = 3.141592653589793;\nconst float c_MinRoughness = 0.04;\n\n// Widen sub-pixel specular lobes using the screen-space normal footprint.\n// This is geometric specular antialiasing: the normal variance is converted\n// into an additional squared perceptual roughness before evaluating BRDFs.\nfloat widenSpecularRoughness(float perceptualRoughness, vec3 normal)\n{\n vec3 normalDerivativeX = dFdx(normal);\n vec3 normalDerivativeY = dFdy(normal);\n float normalVariance =\n dot(normalDerivativeX, normalDerivativeX) +\n dot(normalDerivativeY, normalDerivativeY);\n float kernelRoughnessSquared = min(2.0 * normalVariance, 1.0);\n return clamp(\n sqrt(perceptualRoughness * perceptualRoughness + kernelRoughnessSquared),\n c_MinRoughness,\n 1.0\n );\n}\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#ifdef HAS_BUMPMAP\n vec2 bumpUV = getMaterialUV(pbrMaterial.bumpUVSet, pbrMaterial.bumpUVTransform);\n vec2 bumpTexelSize = 1.0 / vec2(textureSize(pbr_bumpSampler, 0));\n float bumpHeight = texture(pbr_bumpSampler, bumpUV).r;\n vec2 bumpGradient = vec2(\n texture(pbr_bumpSampler, bumpUV + vec2(bumpTexelSize.x, 0.0)).r - bumpHeight,\n texture(pbr_bumpSampler, bumpUV + vec2(0.0, bumpTexelSize.y)).r - bumpHeight\n );\n n = normalize(n - pbrMaterial.bumpFactor *\n (tbn[0] * bumpGradient.x + tbn[1] * bumpGradient.y));\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#ifdef USE_SCENE_ENVIRONMENT\n float maximumMipLevel = max(pbrScene.environmentMipCount - 1.0, 0.0);\n float rotationSine = sin(pbrScene.environmentRotation);\n float rotationCosine = cos(pbrScene.environmentRotation);\n mat2 environmentRotation = mat2(rotationCosine, rotationSine, -rotationSine, rotationCosine);\n vec3 environmentNormal = vec3(environmentRotation * n.xz, n.y).xzy;\n vec3 environmentReflection = vec3(environmentRotation * reflection.xz, reflection.y).xzy;\n#else\n float maximumMipLevel = 9.0;\n vec3 environmentNormal = n;\n vec3 environmentReflection = reflection;\n#endif\n float lod = pbrInfo.perceptualRoughness * maximumMipLevel;\n // retrieve a scale and bias to F0. See [1], Figure 3\n vec4 brdfSample = texture(pbr_brdfLUT,\n vec2(pbrInfo.NdotV, 1.0 - pbrInfo.perceptualRoughness));\n vec4 diffuseSample = texture(pbr_diffuseEnvSampler, environmentNormal);\n\n#ifdef USE_TEX_LOD\n vec4 specularSample = textureLod(pbr_specularEnvSampler, environmentReflection, lod);\n#else\n vec4 specularSample = texture(pbr_specularEnvSampler, environmentReflection);\n#endif\n\n#ifdef USE_SCENE_ENVIRONMENT\n vec3 brdf = brdfSample.rgb;\n vec3 diffuseLight = diffuseSample.rgb;\n vec3 specularLight = specularSample.rgb;\n#else\n vec3 brdf = SRGBtoLINEAR(brdfSample).rgb;\n vec3 diffuseLight = SRGBtoLINEAR(diffuseSample).rgb;\n vec3 specularLight = SRGBtoLINEAR(specularSample).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#ifdef USE_SCENE_ENVIRONMENT\n return (diffuse + specular) * max(pbrScene.environmentIntensity, 0.0);\n#else\n return diffuse + specular;\n#endif\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 encodeLinearSRGB(vec3 linearColor)\n{\n vec3 positiveColor = max(linearColor, vec3(0.0));\n return mix(\n positiveColor * 12.92,\n 1.055 * pow(positiveColor, vec3(1.0 / 2.4)) - 0.055,\n greaterThan(positiveColor, vec3(0.0031308))\n );\n}\n\nvec3 toneMapKhronosPBRNeutral(vec3 color)\n{\n const float startCompression = 0.76;\n float darkestChannel = min(color.r, min(color.g, color.b));\n float offset = darkestChannel < 0.08\n ? darkestChannel - 6.25 * darkestChannel * darkestChannel\n : 0.04;\n color -= vec3(offset);\n\n float peak = maxComponent(color);\n if (peak < startCompression) {\n return color;\n }\n\n float compressionRange = 1.0 - startCompression;\n float compressedPeak = 1.0 - compressionRange * compressionRange /\n (peak + compressionRange - startCompression);\n color *= compressedPeak / max(peak, 0.0001);\n float desaturation = 1.0 - 1.0 / (0.15 * (peak - compressedPeak) + 1.0);\n return mix(color, vec3(compressedPeak), desaturation);\n}\n\nvec3 applySceneColorManagement(vec3 sceneColor)\n{\n#ifdef USE_SCENE_COLOR_MANAGEMENT\n vec3 color = max(sceneColor, vec3(0.0)) * max(pbrScene.exposure, 0.0);\n if (pbrScene.toneMapMode == 1) {\n color /= vec3(1.0) + color;\n } else if (pbrScene.toneMapMode == 2) {\n color = toneMapKhronosPBRNeutral(color);\n } else if (pbrScene.toneMapMode == 3) {\n color = clamp(\n (color * (2.51 * color + 0.03)) / (color * (2.43 * color + 0.59) + 0.14),\n vec3(0.0),\n vec3(1.0)\n );\n }\n return pbrScene.outputEncoding == 0 ? color : encodeLinearSRGB(color);\n#else\n return pow(max(sceneColor, vec3(0.0)), vec3(1.0 / 2.2));\n#endif\n}\n\nfloat dielectricSchlick(float reflectance, float cosine)\n{\n return reflectance + (1.0 - reflectance) * pow(clamp(1.0 - cosine, 0.0, 1.0), 5.0);\n}\n\nvec3 evaluateIridescenceSensitivity(float opticalPathDifference, vec3 phaseShift)\n{\n float phase = 2.0 * M_PI * opticalPathDifference * 1.0e-9;\n vec3 sensitivity = vec3(5.4856e-13, 4.4201e-13, 5.2481e-13);\n vec3 position = vec3(1.6810e6, 1.7953e6, 2.2084e6);\n vec3 variance = vec3(4.3278e9, 9.3046e9, 6.6121e9);\n vec3 xyz = sensitivity * sqrt(2.0 * M_PI * variance) *\n cos(position * phase + phaseShift) * exp(-phase * phase * variance);\n xyz.x += 9.7470e-14 * sqrt(2.0 * M_PI * 4.5282e9) *\n cos(2.2399e6 * phase + phaseShift.x) * exp(-4.5282e9 * phase * phase);\n xyz /= 1.0685e-7;\n return mat3(\n 3.2404542, -0.9692660, 0.0556434,\n -1.5371385, 1.8760108, -0.2040259,\n -0.4985314, 0.0415560, 1.0572252\n ) * xyz;\n}\n\nvec3 getIridescenceTint(float iridescence, float thickness, float NdotV, vec3 baseReflectance)\n{\n if (iridescence <= 0.0 || thickness <= 0.0) {\n return baseReflectance;\n }\n\n float filmIor = max(pbrMaterial.iridescenceIor, 1.0);\n float sineSquared = (1.0 - NdotV * NdotV) / (filmIor * filmIor);\n float cosineSquared = 1.0 - sineSquared;\n if (cosineSquared <= 0.0) {\n return mix(baseReflectance, vec3(1.0), iridescence);\n }\n float filmCosine = sqrt(cosineSquared);\n float firstInterfaceReflectance = dielectricSchlick(getDielectricF0(filmIor), NdotV);\n float transmittedEnergy = 1.0 - firstInterfaceReflectance;\n\n vec3 baseIor = (vec3(1.0) + sqrt(clamp(baseReflectance, vec3(0.0), vec3(0.9999)))) /\n (vec3(1.0) - sqrt(clamp(baseReflectance, vec3(0.0), vec3(0.9999))));\n vec3 secondInterfaceF0 = (baseIor - vec3(filmIor)) / (baseIor + vec3(filmIor));\n secondInterfaceF0 *= secondInterfaceF0;\n vec3 secondInterfaceReflectance = secondInterfaceF0 +\n (vec3(1.0) - secondInterfaceF0) * pow(1.0 - filmCosine, 5.0);\n vec3 phaseShift = vec3(M_PI);\n phaseShift += mix(vec3(0.0), vec3(M_PI), lessThan(baseIor, vec3(filmIor)));\n float opticalPathDifference = 2.0 * filmIor * thickness * filmCosine;\n vec3 combinedReflectance = clamp(\n firstInterfaceReflectance * secondInterfaceReflectance,\n vec3(0.00001),\n vec3(0.9999)\n );\n vec3 recurringAmplitude = sqrt(combinedReflectance);\n vec3 interfaceResponse = transmittedEnergy * transmittedEnergy * secondInterfaceReflectance /\n (vec3(1.0) - combinedReflectance);\n vec3 reflectedSpectrum = vec3(firstInterfaceReflectance) + interfaceResponse;\n vec3 harmonicAmplitude = interfaceResponse - vec3(transmittedEnergy);\n for (int harmonic = 1; harmonic <= 2; harmonic++) {\n harmonicAmplitude *= recurringAmplitude;\n reflectedSpectrum += harmonicAmplitude * 2.0 * evaluateIridescenceSensitivity(\n float(harmonic) * opticalPathDifference,\n float(harmonic) * phaseShift\n );\n }\n return mix(baseReflectance, clamp(reflectedSpectrum, vec3(0.0), vec3(1.0)), 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\n// KHR_materials_volume_scatter is an active draft. This evaluates a local,\n// thickness-aware single-scattering approximation rather than random walk.\nvec3 getDiffuseTransmissionAttenuation(\n PBRInfo pbrInfo,\n vec3 multiscatterColor,\n float thickness\n)\n{\n vec3 volumeAttenuation = getVolumeAttenuation(thickness);\n float scatteringStrength = maxComponent(multiscatterColor);\n if (thickness <= 0.0 || scatteringStrength <= 0.0001) {\n return volumeAttenuation;\n }\n\n float anisotropy = clamp(pbrMaterial.scatterAnisotropy, -0.95, 0.95);\n float scatteringCosine = clamp(dot(-pbrInfo.v, pbrInfo.l), -1.0, 1.0);\n float phaseDenominator = max(\n 1.0 + anisotropy * anisotropy - 2.0 * anisotropy * scatteringCosine,\n 0.0001\n );\n float phaseWeight = clamp(\n (1.0 - anisotropy * anisotropy) / pow(phaseDenominator, 1.5),\n 0.0,\n 4.0\n );\n float scatteringDepth = thickness / max(pbrMaterial.attenuationDistance, 0.0001);\n float scatteringProbability = 1.0 - exp(-scatteringDepth);\n vec3 scatteringColor = clamp(multiscatterColor, vec3(0.0), vec3(1.0));\n return mix(\n volumeAttenuation,\n volumeAttenuation * mix(vec3(1.0), scatteringColor * phaseWeight, scatteringColor),\n scatteringProbability\n );\n}\n\nvec3 calculateDiffuseTransmissionLight(\n PBRInfo pbrInfo,\n vec3 lightColor,\n vec3 diffuseTransmissionColor,\n float diffuseTransmission,\n vec3 multiscatterColor,\n float thickness\n)\n{\n float oppositeHemisphere = max(dot(-pbrInfo.n, pbrInfo.l), 0.0);\n if (oppositeHemisphere <= 0.0 || diffuseTransmission <= 0.0) {\n return vec3(0.0);\n }\n\n vec3 nonReflectedEnergy = vec3(1.0) - clamp(pbrInfo.reflectance0, vec3(0.0), vec3(1.0));\n vec3 attenuatedColor = getDiffuseTransmissionAttenuation(\n pbrInfo,\n multiscatterColor,\n thickness\n );\n return lightColor * diffuseTransmissionColor * nonReflectedEnergy *\n attenuatedColor * (diffuseTransmission * oppositeHemisphere / M_PI);\n}\n\n#ifdef USE_IBL\nvec3 calculateDiffuseTransmissionIBL(\n PBRInfo pbrInfo,\n vec3 diffuseTransmissionColor,\n float diffuseTransmission,\n vec3 multiscatterColor,\n float thickness\n)\n{\n if (diffuseTransmission <= 0.0) {\n return vec3(0.0);\n }\n\n#ifdef USE_SCENE_ENVIRONMENT\n float rotationSine = sin(pbrScene.environmentRotation);\n float rotationCosine = cos(pbrScene.environmentRotation);\n mat2 environmentRotation = mat2(rotationCosine, rotationSine, -rotationSine, rotationCosine);\n vec3 oppositeNormal = vec3(environmentRotation * -pbrInfo.n.xz, -pbrInfo.n.y).xzy;\n vec3 environmentColor = texture(pbr_diffuseEnvSampler, oppositeNormal).rgb *\n max(pbrScene.environmentIntensity, 0.0);\n#else\n vec3 environmentColor = SRGBtoLINEAR(texture(pbr_diffuseEnvSampler, -pbrInfo.n)).rgb;\n#endif\n vec3 nonReflectedEnergy = vec3(1.0) - clamp(pbrInfo.reflectance0, vec3(0.0), vec3(1.0));\n return environmentColor * diffuseTransmissionColor * nonReflectedEnergy *\n getDiffuseTransmissionAttenuation(pbrInfo, multiscatterColor, thickness) *\n diffuseTransmission * pbrMaterial.scaleIBLAmbient.x;\n}\n#endif\n\n#ifdef USE_TRANSMISSION_FRAMEBUFFER\nvec3 sampleTransmittedSceneColor(\n vec3 position,\n vec3 normal,\n vec3 viewDirection,\n float thickness,\n float perceptualRoughness,\n float indexOfRefraction\n)\n{\n vec3 refractionDirection = refract(\n -viewDirection,\n normal,\n 1.0 / max(indexOfRefraction, 1.0)\n );\n vec3 refractedPosition = position + refractionDirection * thickness;\n vec4 clipPosition = pbrScene.projectionMatrix *\n pbrScene.viewMatrix * vec4(refractedPosition, 1.0);\n vec2 textureCoordinate = clipPosition.xy / max(clipPosition.w, 0.0001) * 0.5 + 0.5;\n textureCoordinate = clamp(textureCoordinate, vec2(0.001), vec2(0.999));\n\n vec2 blurRadius = perceptualRoughness * perceptualRoughness * 8.0 /\n max(pbrScene.framebufferSize, vec2(1.0));\n vec3 sceneColor = texture(pbr_transmissionFramebufferSampler, textureCoordinate).rgb * 0.4;\n sceneColor += texture(\n pbr_transmissionFramebufferSampler,\n textureCoordinate + vec2(blurRadius.x, 0.0)\n ).rgb * 0.15;\n sceneColor += texture(\n pbr_transmissionFramebufferSampler,\n textureCoordinate - vec2(blurRadius.x, 0.0)\n ).rgb * 0.15;\n sceneColor += texture(\n pbr_transmissionFramebufferSampler,\n textureCoordinate + vec2(0.0, blurRadius.y)\n ).rgb * 0.15;\n sceneColor += texture(\n pbr_transmissionFramebufferSampler,\n textureCoordinate - vec2(0.0, blurRadius.y)\n ).rgb * 0.15;\n return max(sceneColor, vec3(0.0));\n}\n\nvec3 getTransmittedSceneColor(\n vec3 position,\n vec3 normal,\n vec3 viewDirection,\n float thickness,\n float perceptualRoughness\n)\n{\n if (pbrMaterial.dispersion <= 0.0) {\n return sampleTransmittedSceneColor(\n position,\n normal,\n viewDirection,\n thickness,\n perceptualRoughness,\n pbrMaterial.ior\n );\n }\n\n float halfSpread = (max(pbrMaterial.ior, 1.0) - 1.0) * 0.025 * pbrMaterial.dispersion;\n vec3 indicesOfRefraction = max(\n vec3(pbrMaterial.ior - halfSpread, pbrMaterial.ior, pbrMaterial.ior + halfSpread),\n vec3(1.0)\n );\n return vec3(\n sampleTransmittedSceneColor(\n position, normal, viewDirection, thickness, perceptualRoughness, indicesOfRefraction.r\n ).r,\n sampleTransmittedSceneColor(\n position, normal, viewDirection, thickness, perceptualRoughness, indicesOfRefraction.g\n ).g,\n sampleTransmittedSceneColor(\n position, normal, viewDirection, thickness, perceptualRoughness, indicesOfRefraction.b\n ).b\n );\n}\n#endif\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 basePBRInfo.l,\n basePBRInfo.h\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 alpha = max(sheenRoughness * sheenRoughness, 0.0001);\n float inverseAlpha = 1.0 / alpha;\n float sineSquared = max(1.0 - pbrInfo.NdotH * pbrInfo.NdotH, 0.0);\n float distribution = (2.0 + inverseAlpha) * pow(sineSquared, inverseAlpha * 0.5) /\n (2.0 * M_PI);\n float visibility = 1.0 / max(\n 4.0 * (pbrInfo.NdotL + pbrInfo.NdotV - pbrInfo.NdotL * pbrInfo.NdotV),\n 0.0001\n );\n return pbrInfo.NdotL * lightColor * sheenColor * distribution * visibility *\n (1.0 - pbrInfo.metalness);\n}\n\nvec3 calculateAnisotropicLightColor(\n PBRInfo pbrInfo,\n vec3 lightColor,\n vec3 anisotropyTangent,\n float anisotropyStrength\n) {\n if (anisotropyStrength <= 0.0) {\n return calculateFinalColor(pbrInfo, lightColor);\n }\n\n vec3 anisotropyBitangent = normalize(cross(pbrInfo.n, anisotropyTangent));\n float tangentRoughness = mix(\n pbrInfo.alphaRoughness,\n 1.0,\n anisotropyStrength * anisotropyStrength\n );\n float bitangentRoughness = clamp(pbrInfo.alphaRoughness, 0.001, 1.0);\n float roughnessProduct = tangentRoughness * bitangentRoughness;\n vec3 distributionVector = vec3(\n bitangentRoughness * dot(anisotropyTangent, pbrInfo.h),\n tangentRoughness * dot(anisotropyBitangent, pbrInfo.h),\n roughnessProduct * pbrInfo.NdotH\n );\n float distributionFactor = roughnessProduct /\n max(dot(distributionVector, distributionVector), 0.000001);\n float distribution = roughnessProduct * distributionFactor * distributionFactor / M_PI;\n float viewMask = pbrInfo.NdotL * length(vec3(\n tangentRoughness * dot(anisotropyTangent, pbrInfo.v),\n bitangentRoughness * dot(anisotropyBitangent, pbrInfo.v),\n pbrInfo.NdotV\n ));\n float lightMask = pbrInfo.NdotV * length(vec3(\n tangentRoughness * dot(anisotropyTangent, pbrInfo.l),\n bitangentRoughness * dot(anisotropyBitangent, pbrInfo.l),\n pbrInfo.NdotL\n ));\n float visibility = clamp(0.5 / max(viewMask + lightMask, 0.000001), 0.0, 1.0);\n vec3 fresnel = specularReflection(pbrInfo);\n vec3 diffuseContribution = (vec3(1.0) - fresnel) * diffuse(pbrInfo);\n return pbrInfo.NdotL * lightColor *\n (diffuseContribution + fresnel * distribution * visibility);\n}\n\nvec3 getAnisotropicReflection(PBRInfo pbrInfo, vec3 anisotropyTangent, float anisotropyStrength)\n{\n if (anisotropyStrength <= 0.0) {\n return -normalize(reflect(pbrInfo.v, pbrInfo.n));\n }\n vec3 anisotropyBitangent = normalize(cross(pbrInfo.n, anisotropyTangent));\n vec3 anisotropicNormal = normalize(cross(anisotropyBitangent, pbrInfo.v));\n anisotropicNormal = normalize(cross(anisotropicNormal, anisotropyBitangent));\n float bend = anisotropyStrength * (1.0 - pbrInfo.perceptualRoughness);\n return -normalize(reflect(pbrInfo.v, normalize(mix(pbrInfo.n, anisotropicNormal, bend))));\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 vec3 color = calculateAnisotropicLightColor(\n pbrInfo,\n lightColor,\n anisotropyTangent,\n anisotropyStrength\n );\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 pbrInfo.l = pbrInfo.n;\n pbrInfo.h = pbrInfo.n;\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 pbrInfo.l = l;\n pbrInfo.h = h;\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 vertexColor)\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 vec2 diffuseTransmissionUV = getMaterialUV(\n pbrMaterial.diffuseTransmissionUVSet,\n pbrMaterial.diffuseTransmissionUVTransform\n );\n vec2 diffuseTransmissionColorUV = getMaterialUV(\n pbrMaterial.diffuseTransmissionColorUVSet,\n pbrMaterial.diffuseTransmissionColorUVTransform\n );\n vec2 multiscatterColorUV = getMaterialUV(\n pbrMaterial.multiscatterColorUVSet,\n pbrMaterial.multiscatterColorUVTransform\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)) *\n pbrMaterial.baseColorFactor * vertexColor;\n#else\n vec4 baseColor = pbrMaterial.baseColorFactor * vertexColor;\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 perceptualRoughness = widenSpecularRoughness(perceptualRoughness, n);\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.dispersion > 0.0001 ||\n pbrMaterial.transmissionMapEnabled ||\n pbrMaterial.transmissionFactor > 0.0001 ||\n pbrMaterial.diffuseTransmissionMapEnabled ||\n pbrMaterial.diffuseTransmissionColorMapEnabled ||\n pbrMaterial.diffuseTransmissionFactor > 0.0001 ||\n pbrMaterial.multiscatterColorMapEnabled ||\n maxComponent(pbrMaterial.multiscatterColorFactor) > 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 n\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(applySceneColorManagement(color), 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 diffuseTransmission = clamp(pbrMaterial.diffuseTransmissionFactor, 0.0, 1.0);\n#ifdef HAS_DIFFUSETRANSMISSIONMAP\n if (pbrMaterial.diffuseTransmissionMapEnabled) {\n diffuseTransmission *= texture(pbr_diffuseTransmissionSampler, diffuseTransmissionUV).a;\n }\n#endif\n diffuseTransmission *= (1.0 - metallic) * (1.0 - transmission);\n vec3 diffuseTransmissionColor = pbrMaterial.diffuseTransmissionColorFactor;\n#ifdef HAS_DIFFUSETRANSMISSIONCOLORMAP\n if (pbrMaterial.diffuseTransmissionColorMapEnabled) {\n diffuseTransmissionColor *= SRGBtoLINEAR(\n texture(pbr_diffuseTransmissionColorSampler, diffuseTransmissionColorUV)\n ).rgb;\n }\n#endif\n vec3 multiscatterColor = pbrMaterial.multiscatterColorFactor;\n#ifdef HAS_MULTISCATTERCOLORMAP\n if (pbrMaterial.multiscatterColorMapEnabled) {\n multiscatterColor *= SRGBtoLINEAR(\n texture(pbr_multiscatterColorSampler, multiscatterColorUV)\n ).rgb;\n }\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 clearcoatRoughness = widenSpecularRoughness(clearcoatRoughness, clearcoatNormal);\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 // 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 dielectricSpecularF0 = getIridescenceTint(\n iridescence,\n iridescenceThickness,\n NdotV,\n dielectricSpecularF0\n );\n vec3 diffuseColor = baseColor.rgb * (vec3(1.0) - dielectricSpecularF0);\n diffuseColor *= (1.0 - metallic) * (1.0 - transmission) * (1.0 - diffuseTransmission);\n vec3 specularColor = mix(dielectricSpecularF0, baseColor.rgb, metallic);\n\n float clearcoatViewFresnel = dielectricSchlick(\n 0.04,\n clamp(abs(dot(clearcoatNormal, v)), 0.0, 1.0)\n );\n float sheenDirectionalAlbedo = maxComponent(sheenColor) *\n (0.157 + 0.343 * (1.0 - NdotV)) * (1.0 - sheenRoughness * 0.5);\n float baseLayerEnergy = (1.0 - clearcoatFactor * clearcoatViewFresnel) *\n (1.0 - clamp(sheenDirectionalAlbedo, 0.0, 1.0));\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\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 color += calculateDiffuseTransmissionLight(\n pbrInfo,\n lighting_getDirectionalLight(i).color,\n diffuseTransmissionColor,\n diffuseTransmission,\n multiscatterColor,\n thickness\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 color += calculateDiffuseTransmissionLight(\n pbrInfo,\n lighting_getPointLight(i).color / attenuation,\n diffuseTransmissionColor,\n diffuseTransmission,\n multiscatterColor,\n thickness\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 color += calculateDiffuseTransmissionLight(\n pbrInfo,\n lighting_getSpotLight(i).color / attenuation,\n diffuseTransmissionColor,\n diffuseTransmission,\n multiscatterColor,\n thickness\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(\n pbrInfo,\n n,\n getAnisotropicReflection(pbrInfo, anisotropyTangent, anisotropyStrength)\n );\n color += calculateClearcoatIBLContribution(\n pbrInfo,\n clearcoatNormal,\n -normalize(reflect(v, clearcoatNormal)),\n clearcoatFactor,\n clearcoatRoughness\n );\n color += calculateDiffuseTransmissionIBL(\n pbrInfo,\n diffuseTransmissionColor,\n diffuseTransmission,\n multiscatterColor,\n thickness\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#ifdef USE_TRANSMISSION_FRAMEBUFFER\n float dielectricFresnel = getDielectricF0(pbrMaterial.ior);\n float transmissionFresnel = dielectricFresnel +\n (1.0 - dielectricFresnel) * pow(1.0 - NdotV, 5.0);\n vec3 transmittedColor = getTransmittedSceneColor(\n pbr_vPosition,\n n,\n v,\n thickness,\n perceptualRoughness\n );\n color += transmittedColor * getVolumeAttenuation(thickness) *\n transmission * (1.0 - transmissionFresnel);\n#else\n color = mix(color, color * getVolumeAttenuation(thickness), transmission);\n#endif\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#ifdef USE_TRANSMISSION_FRAMEBUFFER\n float alpha = clamp(baseColor.a, 0.0, 1.0);\n#else\n float alpha = clamp(baseColor.a * (1.0 - transmission), 0.0, 1.0);\n#endif\n return vec4(applySceneColorManagement(color), 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,HAS_BUMPMAP:!1,HAS_DIFFUSETRANSMISSIONMAP:!1,HAS_DIFFUSETRANSMISSIONCOLORMAP:!1,HAS_MULTISCATTERCOLORMAP:!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",dispersion:"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>",bumpFactor:"f32",bumpMapEnabled:"i32",diffuseTransmissionFactor:"f32",diffuseTransmissionMapEnabled:"i32",diffuseTransmissionColorFactor:"vec3<f32>",diffuseTransmissionColorMapEnabled:"i32",multiscatterColorFactor:"vec3<f32>",multiscatterColorMapEnabled:"i32",scatterAnisotropy:"f32",bumpUVSet:"i32",bumpUVTransform:"mat3x3<f32>",diffuseTransmissionUVSet:"i32",diffuseTransmissionUVTransform:"mat3x3<f32>",diffuseTransmissionColorUVSet:"i32",diffuseTransmissionColorUVTransform:"mat3x3<f32>",multiscatterColorUVSet:"i32",multiscatterColorUVTransform:"mat3x3<f32>"}},H=class{name;playing=!0;speed=1;startTime=0;constructor(e={}){this.name=e.name||"unnamed",Object.assign(this,e)}setTime(e){if(!this.playing)return;const t=(e/1e3-this.startTime)*this.speed;this.applyTime(t)}},q=class{clips;animations;constructor(e){this.clips=e,this.animations=e}animate(e){a.log.warn(`${this.constructor.name}#animate is deprecated. Use ${this.constructor.name}#setTime instead`)(),this.setTime(e)}setTime(e){this.clips.forEach(t=>t.setTime(e))}getAnimations(){return this.clips}};function Q(e,t,n){const r=W(e),i=W(t);let a=r.reduce((e,t,n)=>e+t*i[n],0);const o=a<0?-1:1;if(a=Math.min(Math.abs(a),1),a>.9995)return W(r.map((e,t)=>e+n*(i[t]*o-e)));const s=Math.acos(a),A=Math.sin(s),l=Math.sin((1-n)*s)/A,c=Math.sin(n*s)/A*o;return W(r.map((e,t)=>e*l+i[t]*c))}function K(e,t,n,r){const i=e["CUBICSPLINE"===t?3*n+1:n];return i?"quaternion"===r?W(i):[...i]:null}function W(e){const t=Math.hypot(...e);return t>0?e.map(e=>e/t):[0,0,0,1]}var $=class{name;times;values;interpolation;valueType;binding;constructor(e){this.name=e.name||e.binding.id||"unnamed",this.times=e.times,this.values=e.values,this.interpolation=e.interpolation||"LINEAR",this.valueType=e.valueType||"vector",this.binding=e.binding}get duration(){return this.times[this.times.length-1]||0}get sampler(){return{input:this.times,output:this.values,interpolation:this.interpolation}}evaluate(e){return function(e,t,n="vector"){const{input:r,output:i,interpolation:a="LINEAR"}=t;if(!r.length||!i.length||!Number.isFinite(e))return null;const o=r.length-1;if(e<=r[0]||0===o)return K(i,a,0,n);if(e>=r[o])return K(i,a,o,n);let s=0,A=o;for(;A-s>1;){const t=Math.floor((s+A)/2);r[t]<=e?s=t:A=t}const l=r[s],c=r[A]-l;if(c<=0||"STEP"===a)return K(i,a,s,n);const u=(e-l)/c;switch(a){case"LINEAR":{const e=i[s],t=i[A];return e&&t?"quaternion"===n?Q(e,t,u):function(e,t,n){return e.map((e,r)=>(1-n)*e+n*t[r])}(e,t,u):null}case"CUBICSPLINE":{const e=i[3*s+1],t=i[3*s+2],r=i[3*A],a=i[3*A+1];if(!(e&&t&&r&&a))return null;const o=function(e,t,n,r,i,a){const o=a*a,s=o*a;return e.map((e,A)=>(2*s-3*o+1)*e+(s-2*o+a)*t[A]*i+(-2*s+3*o)*r[A]+(s-o)*n[A]*i)}(e,t,r,a,c,u);return"quaternion"===n?W(o):o}default:return null}}(e,this.sampler,this.valueType)}},J=class{name;tracks;duration;constructor(e){this.name=e.name||"unnamed",this.tracks=e.tracks,this.duration=e.duration??Math.max(0,...e.tracks.map(e=>e.duration))}},Y=class{clip;mixer;time=0;timeScale;weight;loop;repetitions;paused=!1;playing=!1;elapsedTime=0;fade=null;constructor(e,t,n={}){this.mixer=e,this.clip=t,this.loop=n.loop||"repeat",this.repetitions=n.repetitions??Number.POSITIVE_INFINITY,this.timeScale=n.timeScale??1,this.weight=n.weight??1}play(){return this.playing=!0,this.paused=!1,this}pause(){return this.paused=!0,this}resume(){return this.playing=!0,this.paused=!1,this}stop(){return this.playing=!1,this.paused=!1,this.fade=null,this.reset()}reset(){return this.elapsedTime=0,this.time=0,this}setTime(e){return this.elapsedTime=e,this.time=this.resolveLocalTime(e),this}setLoop(e,t=Number.POSITIVE_INFINITY){return this.loop=e,this.repetitions=t,this.time=this.resolveLocalTime(this.elapsedTime),this}setEffectiveWeight(e){return this.weight=Math.max(0,e),this.fade=null,this}setEffectiveTimeScale(e){return this.timeScale=e,this}fadeIn(e){return this.scheduleFade(1,e)}fadeOut(e){return this.scheduleFade(0,e)}crossFadeTo(e,t){return e.weight=0,e.play().fadeIn(t),this.fadeOut(t)}crossFadeFrom(e,t){return e.crossFadeTo(this,t),this}advance(e){this.playing&&!this.paused&&(this.advanceFade(Math.abs(e)),this.elapsedTime+=e*this.timeScale,this.time=this.resolveLocalTime(this.elapsedTime),this.hasFinished()&&(this.playing=!1))}get shouldApply(){return(this.playing||this.hasFinished())&&this.weight>0}scheduleFade(e,t){return t<=0?(this.weight=e,this.fade=null,this):(this.fade={duration:t,elapsedTime:0,startWeight:this.weight,endWeight:e},this)}advanceFade(e){if(!this.fade)return;this.fade.elapsedTime+=e;const t=Math.min(this.fade.elapsedTime/this.fade.duration,1);this.weight=this.fade.startWeight+(this.fade.endWeight-this.fade.startWeight)*t,1===t&&(this.fade=null)}hasFinished(){const e=this.clip.duration;return e<=0?"once"===this.loop:"once"===this.loop?this.elapsedTime>=e||this.elapsedTime<0:Number.isFinite(this.repetitions)&&Math.abs(this.elapsedTime)>=e*this.repetitions}resolveLocalTime(e){const t=this.clip.duration;if(t<=0)return 0;if("once"===this.loop)return Math.min(Math.max(e,0),t);if(Number.isFinite(this.repetitions)&&Math.abs(e)>=t*this.repetitions)return"ping-pong"===this.loop&&this.repetitions%2==0||e<0?0:t;const n=e>=0&&e<t?e:(e%t+t)%t;if("repeat"===this.loop)return n;const r=Math.floor(e/t);return 0===Math.abs(r%2)?n:t-n}},X=class{time=0;timeScale=1;clips=new Map;actions=new Map;initialValues=new Map;constructor(e=[]){e.forEach(e=>this.addClip(e))}addClip(e){return this.clips.set(e.name,e),this}clipAction(e,t){const n="string"==typeof e?this.clips.get(e):e;if(!n)throw new Error(`Unknown animation clip: ${e}`);this.addClip(n);let r=this.actions.get(n);return r||(r=new Y(this,n,t),this.actions.set(n,r)),r}getAction(e){const t=this.clips.get(e);return t?this.actions.get(t):void 0}update(e){return this.advance(e),this.applyValues(),this}advance(e){const t=e*this.timeScale;return this.time+=t,this.actions.forEach(e=>e.advance(t)),this}setTime(e){return this.time=e,this.actions.forEach(t=>{t.paused||t.setTime(e*t.timeScale)}),this.applyValues(),this}stopAllAction(){return this.actions.forEach(e=>e.stop()),this}applyValues(){const e=new Map;this.actions.forEach(t=>{(t.shouldApply||t.playing&&0===t.weight)&&t.clip.tracks.forEach(n=>{const r=n.evaluate(t.time);if(!r)return;const i=n.binding.id||n.binding;if(!this.initialValues.has(i)){const e=n.binding.getValue?.();e&&this.initialValues.set(i,[...e])}if(0===t.weight&&!this.initialValues.has(i))return;const a=e.get(i);if(!a)return void e.set(i,{binding:n.binding,value:[...r],valueType:n.valueType,weight:t.weight});if(0===t.weight)return;const o=a.weight+t.weight,s=t.weight/o;a.value="quaternion"===n.valueType?Q(a.value,r,s):a.value.map((e,t)=>e+(r[t]-e)*s),a.weight=o})}),e.forEach(({binding:e,value:t,valueType:n,weight:r},i)=>{const a=r<1?this.initialValues.get(i):void 0;a&&a.length===t.length&&(t="quaternion"===n?Q(a,t,r):t.map((e,t)=>a[t]+(e-a[t])*r)),e.setValue(t)})}};function Z(e){const t=e.value;if(t instanceof Float32Array)return t;const n=new Float32Array(t.length),r=ne(t),i=t instanceof Int8Array||t instanceof Int16Array||t instanceof Int32Array;for(let a=0;a<t.length;a++){const o=Number(t[a]);n[a]=e.normalized&&r?i?Math.max(o/r,-1):o/r:o}return n}function ee(e,n,r,i){const a={};for(const t of["POSITION","NORMAL","TANGENT"]){const e=n.attributes[t];e&&(a[t]=Z(e))}const o=function(e,t,n){const r={};for(const i of["POSITION","NORMAL","TANGENT"]){const a=e[i];if(!a)continue;const o=new Float32Array(a),s="TANGENT"===i?4:3,A=Math.floor(a.length/s);for(let e=0;e<Math.min(t.length,n.length);e++){const r=n[e],a=t[e][i];if(!r||!a)continue;const l="TANGENT"===i&&a.length===4*A?4:3;for(let e=0;e<A;e++){const t=e*s,n=e*l;for(let e=0;e<3;e++)o[t+e]+=(a[n+e]||0)*r}}"POSITION"!==i&&re(o,s),r[i]=o}return r}(a,r,i),s={};for(const[t,u]of Object.entries(n.attributes))u&&(s[t]=u);for(const t of["POSITION","NORMAL","TANGENT"]){const e=o[t],n=s[t];e&&n&&(s[t]={...n,value:te(n,e)})}const A=new t.Geometry({id:n.id,topology:n.topology||"triangle-list",vertexCount:n.vertexCount,indices:n.indices,attributes:s,bufferLayout:n.bufferLayout}),l=t.makeInterleavedGeometry(A).attributes.geometry?.value,c=e._gpuGeometry?.attributes.geometry||e.bufferAttributes.geometry;if(l&&c)c.write(l);else for(const t of["POSITION","NORMAL","TANGENT"]){const n=o[t];if(n){const r="POSITION"===t?"positions":"NORMAL"===t?"normals":"TANGENT";e.bufferAttributes[r]?.write(n)}}}function te(e,t){if(e.value instanceof Float32Array)return t;const n=e.value.slice(),r=ne(n),i=n instanceof Int8Array||n instanceof Int16Array||n instanceof Int32Array;for(let a=0;a<t.length;a++){const o=t[a];n[a]=e.normalized&&r?Math.round(Math.max(i?-1:0,Math.min(1,o))*r):o}return n}function ne(e){return e instanceof Int8Array?127:e instanceof Uint8Array||e instanceof Uint8ClampedArray?255:e instanceof Int16Array?32767:e instanceof Uint16Array?65535:e instanceof Int32Array?2147483647:e instanceof Uint32Array?4294967295:0}function re(e,t){for(let n=0;n<e.length;n+=t){const t=Math.hypot(e[n],e[n+1],e[n+2]);t>0&&(e[n]/=t,e[n+1]/=t,e[n+2]/=t)}}function ie(e){const{joints:t,meshNode:r,worldMatrices:i,inverseBindMatrices:a,target:o}=e,s=t.length,A=o&&o.length===16*s?o:new Float32Array(16*s),l=r?i.get(r)||r.matrix:void 0,c=l?new n.Matrix4(l).invert():null;for(let u=0;u<s;u++){const e=t[u],r=i.get(e)||e.matrix,o=c?new n.Matrix4(c).multiplyRight(r):new n.Matrix4(r),s=16*u;if(a&&a.length>=s+16){const e=new n.Matrix4;for(let t=0;t<16;t++)e[t]=a[s+t];o.multiplyRight(e)}A.set(o,s)}return A}var ae=class{device;modules;_materialBindingNames;_materialModuleNames;constructor(e,t={}){this.device=e,this.modules=t.modules||[];const n=new i.ShaderInputs(Object.fromEntries(this.modules.map(e=>[e.name,e])));this._materialBindingNames=function(e){const t=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=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 se(this.device,{...e,factory:this})}getBindingNames(){return Array.from(this._materialBindingNames)}ownsBinding(e){if(this._materialBindingNames.has(e))return!0;const t=oe(e);return!!t&&this._materialModuleNames.has(t)}ownsModule(e){return this._materialModuleNames.has(e)}getBindingsByGroup(e){return Object.keys(e).length>0?{3:e}:{}}};function oe(e){return e.endsWith("Uniforms")?e.slice(0,-8):null}var se=class{id;device;factory;shaderInputs;bindings={};_uniformStore;_bindGroupCacheToken={};_dynamicResourceGenerations={};constructor(e,t={}){this.id=t.id||i.uid("material"),this.device=e,this.factory=t.factory||new ae(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 i.ShaderInputs(n),this._uniformStore=new i.UniformStore(this.device,this.shaderInputs.modules);for(const[r,a]of Object.entries(this.shaderInputs.modules))if(this.ownsModule(r)&&i.shaderModuleHasUniforms(a)){const e=this._uniformStore.getManagedUniformBuffer(r);this.bindings[`${r}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.updateShaderInputs(),t}ownsBinding(e){return this.factory.ownsBinding(e)}ownsModule(e){return this.factory.ownsModule(e)}setProps(e){this.shaderInputs.setProps(e)}updateShaderInputs(e){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues(),e),this._setOwnedBindings(this.shaderInputs.getBindingValues())&&(this._bindGroupCacheToken={})}getResourceBindings(){const e={};for(const[t,n]of Object.entries(this.bindings))oe(t)||(e[t]=n);return e}getBindings(e={bindings:[]}){this._syncDynamicResourceGenerations();const n={},r=n;for(const[a,o]of Object.entries(this.bindings))if(t.isTextureBindingSource(o)){const n=t.getTextureBindingLayout(e,a,{fallbackGroup:3}),i=n?o.resolveTextureBinding(n):null;i&&(r[a]=i)}else o instanceof i.DynamicBuffer?r[a]=o.buffer:i.isBufferRangeBinding(o)?r[a]=i.resolveBufferRangeBinding(o):r[a]=o;return this._syncDynamicResourceGenerations(),n}getBindingsByGroup(e={bindings:[]}){return this.factory.getBindingsByGroup(this.getBindings(e))}getBindGroupCacheKey(e){return this._syncDynamicResourceGenerations(),3===e?this._bindGroupCacheToken:null}getBindingsUpdateTimestamp(){let e=0;for(const r of Object.values(this.bindings))r instanceof o.TextureView?e=Math.max(e,r.texture.updateTimestamp):r instanceof a.Buffer||r instanceof n.Texture||r instanceof t.ExternalTexture||r instanceof i.DynamicBuffer?e=Math.max(e,r.updateTimestamp):t.isTextureBindingSource(r)?e=r.isReady?Math.max(e,r.updateTimestamp):1/0:i.isBufferRangeBinding(r)&&(e=Math.max(e,(r.buffer,i.DynamicBuffer,r.buffer.updateTimestamp)));return e}_replaceOwnedBindings(e){this._setOwnedBindings(e)&&(this._bindGroupCacheToken={})}_setOwnedBindings(e){let t=!1;for(const[n,r]of Object.entries(e))void 0!==r&&this.ownsBinding(n)&&this.bindings[n]!==r&&(this.bindings[n]=r,t=!0);return t}_syncDynamicResourceGenerations(){const e={};let t=!1;for(const[n,r]of Object.entries(this.bindings)){const i=Ae(r);null!==i&&(e[n]=i,this._dynamicResourceGenerations[n]!==i&&(t=!0))}Object.keys(e).length!==Object.keys(this._dynamicResourceGenerations).length&&(t=!0),this._dynamicResourceGenerations=e,t&&(this._bindGroupCacheToken={})}};function Ae(e){return t.isTextureBindingSource(e)?e.generation:i.getDynamicBufferFromBinding(e)?.generation??null}var le={"+X":0,"-X":1,"+Y":2,"-Y":3,"+Z":4,"-Z":5};function ce(e){return e?Array.isArray(e)?e[0]??null:e:null}function ue(e){if(n.isExternalImage(e))return n.getExternalImageSize(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 fe(e){return"object"==typeof e&&null!==e&&"data"in e&&"width"in e&&"height"in e}function de(e){return ArrayBuffer.isView(e)}function he(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 pe(e){const t=le[e];if(void 0===t)throw new Error(`Invalid cube face: ${e}`);return t}function me(e,t){return 6*e+pe(t)}function ge(e){throw new Error("setTexture1DData not supported in WebGL.")}function be(e,t,r,i){const a=(o=t,Array.isArray(o)?o:[o]);var o;const s=e,A=[];for(let l=0;l<a.length;l++){const e=a[l];if(n.isExternalImage(e))A.push({type:"external-image",image:e,z:s,mipLevel:l});else if(fe(e))A.push({type:"texture-data",data:e,textureFormat:he(e),z:s,mipLevel:l});else{if(!de(e)||!r)throw new Error("Unsupported 2D mip-level payload");A.push({type:"texture-data",data:{data:e,width:Math.max(1,r.width>>l),height:Math.max(1,r.height>>l),...i?{format:i}:{}},textureFormat:i,z:s,mipLevel:l})}}return A}function ve(e){const t=[];for(let n=0;n<e.length;n++)t.push(...be(n,e[n]));return t}function ye(e){const t=[];for(let n=0;n<e.length;n++)t.push(...be(n,e[n]));return t}function xe(e){const t=[];for(const[n,r]of Object.entries(e)){const e=pe(n);t.push(...be(e,r))}return t}function _e(e){const t=[];return e.forEach((e,n)=>{for(const[r,i]of Object.entries(e)){const e=me(n,r);t.push(...be(e,i))}}),t}var we=class e{device;id;props;_texture=null;_sampler=null;_view=null;ready;isReady=!1;destroyed=!1;generation=0;updateTimestamp;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..."})`}resolveTextureBinding(e){return this.isReady?this.texture:null}constructor(t,n){this.device=t;const r=i.uid("dynamic-texture"),a=n;this.props={...e.defaultProps,id:r,...n,data:null},this.id=this.props.id,this.ready=new Promise((e,t)=>{this.resolveReady=e,this.rejectReady=t}),this.updateTimestamp=this.device.incrementTimestamp(),this.initAsync(a)}async initAsync(e){try{const t=await this._loadAllData(e);this._checkNotDestroyed();const r=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 ge(e.data);case"2d":return be(0,e.data,t,n);case"3d":return ve(e.data);case"2d-array":return ye(e.data);case"cube":return xe(e.data);case"cube-array":return _e(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,o="usage"in e&&void 0!==e.usage,s=()=>{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=ce(n);if(!e)return null;const{width:t}=ue(e);return{width:t,height:1}}case"2d":{if(ArrayBuffer.isView(n))return null;const e=ce(n);return e?ue(e):null}case"3d":case"2d-array":{if(!Array.isArray(n)||0===n.length)return null;const e=ce(n[0]);return e?ue(e):null}case"cube":{const e=Object.keys(n)[0]??null;if(!e)return null;const t=ce(n[e]);return t?ue(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 r=ce(e[t]);return r?ue(r):null}default:return null}}(t);return e||{width:this.props.width||1,height:this.props.height||1}},A=s();if(!A||A.width<=0||A.height<=0)throw new Error(`${this} size could not be determined or was zero`);const l=function(e,t,n,r){if(0===t.length)return{subresources:t,mipLevels:1,format:r.format,hasExplicitMipChain:!1};const i=new Map;for(const c of t){const e=i.get(c.z)??[];e.push(c),i.set(c.z,e)}const a=t.some(e=>e.mipLevel>0);let o=r.format,s=Number.POSITIVE_INFINITY;const A=[];for(const[c,u]of i){const t=[...u].sort((e,t)=>e.mipLevel-t.mipLevel),r=t[0];if(!r||0!==r.mipLevel)throw new Error(`DynamicTexture: slice ${c} is missing mip level 0`);const i=Se(e,r);if(i.width!==n.width||i.height!==n.height)throw new Error(`DynamicTexture: slice ${c} base level dimensions ${i.width}x${i.height} do not match expected ${n.width}x${n.height}`);const a=Te(r);if(a){if(o&&o!==a)throw new Error(`DynamicTexture: slice ${c} base level format "${a}" does not match texture format "${o}"`);o=a}const l=o&&e.isTextureFormatCompressed(o)?Me(e,i.width,i.height,o):e.getMipLevelCount(i.width,i.height);let f=0;for(let n=0;n<t.length;n++){const r=t[n];if(!r||r.mipLevel!==n)break;if(n>=l)break;const a=Se(e,r),s=Math.max(1,i.width>>n),c=Math.max(1,i.height>>n);if(a.width!==s||a.height!==c)break;const u=Te(r);if(u&&(o||(o=u),u!==o))break;f++,A.push(r)}s=Math.min(s,f)}const l=Number.isFinite(s)?Math.max(1,s):1;return{subresources:A.filter(e=>e.mipLevel<l),mipLevels:l,format:o,hasExplicitMipChain:a}}(this.device,r,A,{format:i?e.format:void 0}),c=l.format??this.props.format,u={...this.props,...A,format:c,mipLevels:1,data:void 0};this.device.isTextureFormatCompressed(c)&&!o&&(u.usage=n.Texture.SAMPLE|n.Texture.COPY_DST);const f=this.props.mipmaps&&!l.hasExplicitMipChain&&!this.device.isTextureFormatCompressed(c);if("webgpu"===this.device.type&&f){const e="3d"===this.props.dimension?n.Texture.SAMPLE|n.Texture.STORAGE|n.Texture.COPY_DST|n.Texture.COPY_SRC:n.Texture.SAMPLE|n.Texture.RENDER|n.Texture.COPY_DST|n.Texture.COPY_SRC;u.usage|=e}const d=this.device.getMipLevelCount(u.width,u.height),h=l.hasExplicitMipChain?l.mipLevels:"auto"===this.props.mipLevels?d:Math.max(1,Math.min(d,this.props.mipLevels??1)),p={...u,mipLevels:h};this._texture=this.device.createTexture(p),this._sampler=this.texture.sampler,this._view=this.texture.view,this._touchGeneration(),l.subresources.length&&this._setTextureSubresources(l.subresources),!this.props.mipmaps||l.hasExplicitMipChain||f||a.log.warn(`${this} skipping auto-generated mipmaps for compressed texture format`)(),f&&this.generateMipmaps(),this.isReady=!0,this.resolveReady(this.texture),a.log.info(1,`${this} created`)()}catch(Gt){const t=Gt instanceof Error?Gt:new Error(String(Gt));this.rejectReady(t)}}destroy(){this._texture&&(this._texture.destroy(),this._texture=null,this._sampler=null,this._view=null),this.isReady=!1,this.destroyed=!0}generateMipmaps(){"webgl"===this.device.type?(this.texture.generateMipmapsWebGL(),this._touch()):"webgpu"===this.device.type?(this.device.generateMipmapsWebGPU(this.texture),this._touch()):a.log.warn(`${this} mipmaps not supported on ${this.device.type}`)}setSampler(e={}){this._checkReady();const t=e instanceof n.Sampler?e:this.device.createSampler(e);this.texture.setSampler(t),this._sampler=t,this._touchGeneration()}async readBuffer(e={}){this.isReady||await this.ready;const t=e.width??this.texture.width,n=e.height??this.texture.height,r=e.depthOrArrayLayers??this.texture.depth,i=this.texture.computeMemoryLayout({width:t,height:n,depthOrArrayLayers:r}),o=this.device.createBuffer({byteLength:i.byteLength,usage:a.Buffer.COPY_DST|a.Buffer.MAP_READ});this.texture.readBuffer({...e,width:t,height:n,depthOrArrayLayers:r},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,r=e.depthOrArrayLayers??this.texture.depth,i=this.texture.computeMemoryLayout({width:t,height:n,depthOrArrayLayers:r}),a=await this.readBuffer(e),o=await a.readAsync(0,i.byteLength);return a.destroy(),o.buffer instanceof ArrayBuffer?o.buffer:o.slice().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(),this._touchGeneration(),a.log.info(`${this} resized`),!0}getCubeFaceIndex(e){const t=le[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=ge();this._setTextureSubresources(t)}setTexture2DData(e,t=0){if(this._checkReady(),"2d"!==this.texture.props.dimension)throw new Error(`${this} is not 2d`);const n=be(t,e);this._setTextureSubresources(n)}setTexture3DData(e){if("3d"!==this.texture.props.dimension)throw new Error(`${this} is not 3d`);const t=ve(e);this._setTextureSubresources(t)}setTextureArrayData(e){if("2d-array"!==this.texture.props.dimension)throw new Error(`${this} is not 2d-array`);const t=ye(e);this._setTextureSubresources(t)}setTextureCubeData(e){if("cube"!==this.texture.props.dimension)throw new Error(`${this} is not cube`);const t=xe(e);this._setTextureSubresources(t)}setTextureCubeArrayData(e){if("cube-array"!==this.texture.props.dimension)throw new Error(`${this} is not cube-array`);const t=_e(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:r,flipY:i}=t;this.texture.copyExternalImage({image:r,z:e,mipLevel:n,flipY:i});break;case"texture-data":const{data:a,textureFormat:o}=t;if(o&&o!==this.texture.format)throw new Error(`${this} mip level ${n} uses format "${o}" but texture format is "${this.texture.format}"`);this.texture.writeData(a.data,{x:0,y:0,z:e,width:a.width,height:a.height,depthOrArrayLayers:1,mipLevel:n});break;default:throw new Error("Unsupported 2D mip-level payload")}}e.length>0&&this._touch()}async _loadAllData(e){const t=await Ee(e.data);return{dimension:e.dimension??"2d",data:t??null}}_checkNotDestroyed(){this.destroyed&&a.log.warn(`${this} already destroyed`)}_checkReady(){this.isReady||a.log.warn(`${this} Cannot perform this operation before ready`)}_touch(){this.updateTimestamp=this.device.incrementTimestamp()}_touchGeneration(){this.generation++,this._touch()}static defaultProps={...n.Texture.defaultProps,dimension:"2d",data:null,mipmaps:!1}};function Te(e){if("texture-data"===e.type)return e.textureFormat??he(e.data)}function Se(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 Me(e,t,n,r){const{blockWidth:i=1,blockHeight:a=1}=e.getTextureFormatInfo(r);let o=1;for(let s=1;;s++){const e=Math.max(1,t>>s),r=Math.max(1,n>>s);if(e<i||r<a)break;o++}return o}async function Ee(e){if(e=await e,Array.isArray(e))return await Promise.all(e.map(Ee));if(e&&"object"==typeof e&&e.constructor===Object){const t=e,n=await Promise.all(Object.values(t).map(Ee)),r=Object.keys(t),i={};for(let e=0;e<r.length;e++)i[r[e]]=n[e];return i}return e}function Ce(e,t){if(!e)throw new Error(t)}var Ie=class{id;matrix=new n.Matrix4;display=!0;position=new n.Vector3;rotation=new n.Vector3;scale=new n.Vector3(1,1,1);userData={};props={};constructor(e={}){const{id:t}=e;this.id=t||i.uid(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 Ce(3===e.length,"setPosition requires vector argument"),this.position=e,this}setRotation(e){return Ce(3===e.length||4===e.length,"setRotation requires vector argument"),this.rotation=e,this}setScale(e){return Ce(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:r,update:i=!0}=e;return t&&this.setPosition(t),n&&this.setRotation(n),r&&this.setScale(r),i&&this.updateMatrix(),this}updateMatrix(){if(this.matrix.identity(),this.matrix.translate(this.position),4===this.rotation.length){const e=(new n.Matrix4).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 r=new n.Matrix4(e).multiplyRight(t),i=r.invert(),a=i.transpose();return{viewMatrix:e,modelMatrix:t,objectMatrix:t,worldMatrix:r,worldInverseMatrix:i,worldInverseTransposeMatrix:a}}_setScenegraphNodeProps(e){void 0!==e.display&&(this.display=e.display),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)}};function Re(e,t,r){const i=new n.Matrix4(r);for(let a=0;a<8;a++){const r=new n.Vector3(t[1&a?1:0][0],t[2&a?1:0][1],t[4&a?1:0][2]);i.transformAsPoint(r,r);for(let t=0;t<3;t++)e[0][t]=Math.min(e[0][t],r[t]),e[1][t]=Math.max(e[1][t],r[t])}}function Pe(e){return Number.isFinite(e[0][0])}var Ne=class e extends Ie{children;constructor(e={}){e=Array.isArray(e)?{children:e}:e;const{children:t=[]}=e;a.log.assert(t.every(e=>e instanceof Ie),"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:r})=>{const i=t.getBounds();if(!i)return;const a=new n.Matrix4(r).multiplyRight(t.matrix);Re(e,i,a)}),Pe(e)?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(t,{worldMatrix:r=new n.Matrix4}={}){if(!this.display)return;const i=new n.Matrix4(r).multiplyRight(this.matrix);for(const n of this.children)n.display&&(n instanceof e?n.traverse(t,{worldMatrix:i}):t(n,{worldMatrix:i}))}traverseDepthSorted(e,{viewMatrix:t,worldMatrix:r=new n.Matrix4,order:i="back-to-front"}){const a=new n.Matrix4(t),o=[];this.traverse((e,t)=>{const r=e.getBounds(),i=r?new n.Vector3(r[0]).add(r[1]).divide([2,2,2]):new n.Vector3,s=new n.Matrix4(t.worldMatrix).multiplyRight(e.matrix);s.transformAsPoint(i,i),a.transformAsPoint(i,i),o.push({node:e,context:{worldMatrix:s,bounds:r,depth:-i[2]},index:o.length})},{worldMatrix:new n.Matrix4(r)});const s="back-to-front"===i?-1:1;o.sort((e,t)=>s*(e.context.depth-t.context.depth)||e.index-t.index);for(const{node:n,context:A}of o)e(n,A)}preorderTraversal(t,{worldMatrix:r=new n.Matrix4}={}){const i=new n.Matrix4(r).multiplyRight(this.matrix);t(this,{worldMatrix:i});for(const n of this.children)n instanceof e?n.preorderTraversal(t,{worldMatrix:i}):t(n,{worldMatrix:i})}},ke=class extends Ie{model;instanceMatrices;bounds=null;managedResources;constructor(e){super(e),this.model=e.model,this.managedResources=e.managedResources||[],this.instanceMatrices=e.instanceMatrices||null,this.bounds=e.bounds?this.instanceMatrices?function(e,t){const n=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]];for(const r of t)Re(n,e,r);return Pe(n)?n:null}(e.bounds,this.instanceMatrices):e.bounds:null,this.setProps(e)}destroy(){this.model&&(this.model.destroy(),this.model=null),this.managedResources.forEach(e=>e.destroy()),this.managedResources=[]}getBounds(){return this.bounds}draw(e){return this.model.draw(e)}};var Le=class{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&&n.deepEqual(this.opts,e.opts,1)}getShaders(e){return null}getSubLayerProps(e){const{defaultProps:t}=e.constructor,n={updateTriggers:{}};for(const r in t)if(r in this.props){const e=t[r],i=this.props[r];n[r]=i,e&&"accessor"===e.type&&(n.updateTriggers[r]=this.props.updateTriggers[r],"function"==typeof i&&(n[r]=this.getSubLayerAccessor(i)))}return n}initializeState(e,t){}updateState(e,t){}onNeedsRedraw(e){}getNeedsPickingBuffer(e){return!1}draw(e,t){}finalizeState(e,t){}};function Be(e,t,n=2,r,i="xy"){const a=t&&t.length,o=a?t[0]*n:e.length;let s=Oe(e,0,o,n,!0,r&&r[0],i);const A=[];if(!s||s.next===s.prev)return A;let l,c,u,f,d,h,p;if(a&&(s=function(e,t,n,r,i,a){const o=[];let s,A,l,c,u;for(s=0,A=t.length;s<A;s++)l=t[s]*r,c=s<A-1?t[s+1]*r:e.length,u=Oe(e,l,c,r,!1,i&&i[s+1],a),u===u.next&&(u.steiner=!0),o.push(Ke(u));for(o.sort(Ge),s=0;s<o.length;s++)n=He(o[s],n);return n}(e,t,s,n,r,i)),e.length>80*n){f=c=e[0],d=u=e[1];for(let t=n;t<o;t+=n)h=e[t],p=e[t+1],h<f&&(f=h),p<d&&(d=p),h>c&&(c=h),p>u&&(u=p);l=Math.max(c-f,u-d),l=0!==l?32767/l:0}return De(s,A,n,f,d,l,0),A}function Oe(e,n,r,i,a,o,s){let A,l;void 0===o&&(o=t.getPolygonSignedArea(e,{start:n,end:r,size:i,plane:s}));let c=t.DimIndex[s[0]],u=t.DimIndex[s[1]];if(a===o<0)for(A=n;A<r;A+=i)l=rt(A,e[A+c],e[A+u],l);else for(A=r-i;A>=n;A-=i)l=rt(A,e[A+c],e[A+u],l);return l&&Ye(l,l.next)&&(it(l),l=l.next),l}function Fe(e,t){if(!e)return e;t||(t=e);let n,r=e;do{if(n=!1,r.steiner||!Ye(r,r.next)&&0!==Je(r.prev,r,r.next))r=r.next;else{if(it(r),r=t=r.prev,r===r.next)break;n=!0}}while(n||r!==t);return t}function De(e,t,n,r,i,a,o){if(!e)return;!o&&a&&function(e,t,n,r){let i=e;do{0===i.z&&(i.z=Qe(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){let t,n,r,i,a,o,s,A,l=1;do{for(i=e,e=null,A=null,r=0;i;){for(r++,o=i,a=0,n=0;n<l&&(a++,o=o.nextZ,o);n++);for(s=l;a>0||s>0&&o;)0!==a&&(0===s||!o||i.z<=o.z)?(t=i,i=i.nextZ,a--):(t=o,o=o.nextZ,s--),A?A.nextZ=t:e=t,t.prevZ=A,A=t;i=o}A.nextZ=null,l*=2}while(r>1)}(i)}(e,r,i,a);let s,A,l=e;for(;e.prev!==e.next;)if(s=e.prev,A=e.next,a?Ve(e,r,i,a):Ue(e))t.push(s.i/n|0),t.push(e.i/n|0),t.push(A.i/n|0),it(e),e=A.next,l=A.next;else if((e=A)===l){o?1===o?De(e=je(Fe(e),t,n),t,n,r,i,a,2):2===o&&ze(e,t,n,r,i,a):De(Fe(e),t,n,r,i,a,1);break}}function Ue(e){const t=e.prev,n=e,r=e.next;if(Je(t,n,r)>=0)return!1;const i=t.x,a=n.x,o=r.x,s=t.y,A=n.y,l=r.y,c=i<a?i<o?i:o:a<o?a:o,u=s<A?s<l?s:l:A<l?A:l,f=i>a?i>o?i:o:a>o?a:o,d=s>A?s>l?s:l:A>l?A:l;let h=r.next;for(;h!==t;){if(h.x>=c&&h.x<=f&&h.y>=u&&h.y<=d&&We(i,s,a,A,o,l,h.x,h.y)&&Je(h.prev,h,h.next)>=0)return!1;h=h.next}return!0}function Ve(e,t,n,r){const i=e.prev,a=e,o=e.next;if(Je(i,a,o)>=0)return!1;const s=i.x,A=a.x,l=o.x,c=i.y,u=a.y,f=o.y,d=s<A?s<l?s:l:A<l?A:l,h=c<u?c<f?c:f:u<f?u:f,p=s>A?s>l?s:l:A>l?A:l,m=c>u?c>f?c:f:u>f?u:f,g=Qe(d,h,t,n,r),b=Qe(p,m,t,n,r);let v=e.prevZ,y=e.nextZ;for(;v&&v.z>=g&&y&&y.z<=b;){if(v.x>=d&&v.x<=p&&v.y>=h&&v.y<=m&&v!==i&&v!==o&&We(s,c,A,u,l,f,v.x,v.y)&&Je(v.prev,v,v.next)>=0)return!1;if(v=v.prevZ,y.x>=d&&y.x<=p&&y.y>=h&&y.y<=m&&y!==i&&y!==o&&We(s,c,A,u,l,f,y.x,y.y)&&Je(y.prev,y,y.next)>=0)return!1;y=y.nextZ}for(;v&&v.z>=g;){if(v.x>=d&&v.x<=p&&v.y>=h&&v.y<=m&&v!==i&&v!==o&&We(s,c,A,u,l,f,v.x,v.y)&&Je(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;y&&y.z<=b;){if(y.x>=d&&y.x<=p&&y.y>=h&&y.y<=m&&y!==i&&y!==o&&We(s,c,A,u,l,f,y.x,y.y)&&Je(y.prev,y,y.next)>=0)return!1;y=y.nextZ}return!0}function je(e,t,n){let r=e;do{const i=r.prev,a=r.next.next;!Ye(i,a)&&Xe(i,r,r.next,a)&&tt(i,a)&&tt(a,i)&&(t.push(i.i/n|0),t.push(r.i/n|0),t.push(a.i/n|0),it(r),it(r.next),r=e=a),r=r.next}while(r!==e);return Fe(r)}function ze(e,t,n,r,i,a){let o=e;do{let e=o.next.next;for(;e!==o.prev;){if(o.i!==e.i&&$e(o,e)){let s=nt(o,e);return o=Fe(o,o.next),s=Fe(s,s.next),De(o,t,n,r,i,a,0),void De(s,t,n,r,i,a,0)}e=e.next}o=o.next}while(o!==e)}function Ge(e,t){return e.x-t.x}function He(e,t){const n=function(e,t){let n=t;const r=e.x,i=e.y;let a,o=-1/0;do{if(i<=n.y&&i>=n.next.y&&n.next.y!==n.y){const e=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=r&&e>o&&(o=e,a=n.x<n.next.x?n:n.next,e===r))return a}n=n.next}while(n!==t);if(!a)return null;const s=a,A=a.x,l=a.y;let c,u=1/0;n=a;do{r>=n.x&&n.x>=A&&r!==n.x&&We(i<l?r:o,i,A,l,i<l?o:r,i,n.x,n.y)&&(c=Math.abs(i-n.y)/(r-n.x),tt(n,e)&&(c<u||c===u&&(n.x>a.x||n.x===a.x&&qe(a,n)))&&(a=n,u=c)),n=n.next}while(n!==s);return a}(e,t);if(!n)return t;const r=nt(n,e);return Fe(r,r.next),Fe(n,n.next)}function qe(e,t){return Je(e.prev,e,t.prev)<0&&Je(t.next,e,e.next)<0}function Qe(e,t,n,r,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Ke(e){let 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 We(e,t,n,r,i,a,o,s){return(i-o)*(t-s)>=(e-o)*(a-s)&&(e-o)*(r-s)>=(n-o)*(t-s)&&(n-o)*(a-s)>=(i-o)*(r-s)}function $e(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&Xe(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(tt(e,t)&&tt(t,e)&&function(e,t){let n=e,r=!1;const i=(e.x+t.x)/2,a=(e.y+t.y)/2;do{n.y>a!=n.next.y>a&&n.next.y!==n.y&&i<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==e);return r}(e,t)&&(Je(e.prev,e,t.prev)||Je(e,t.prev,t))||Ye(e,t)&&Je(e.prev,e,e.next)>0&&Je(t.prev,t,t.next)>0)}function Je(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function Ye(e,t){return e.x===t.x&&e.y===t.y}function Xe(e,t,n,r){const i=et(Je(e,t,n)),a=et(Je(e,t,r)),o=et(Je(n,r,e)),s=et(Je(n,r,t));return i!==a&&o!==s||(!(0!==i||!Ze(e,n,t))||(!(0!==a||!Ze(e,r,t))||(!(0!==o||!Ze(n,e,r))||!(0!==s||!Ze(n,t,r)))))}function Ze(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 et(e){return e>0?1:e<0?-1:0}function tt(e,t){return Je(e.prev,e,e.next)<0?Je(e,t,e.next)>=0&&Je(e,e.prev,t)>=0:Je(e,t,e.prev)<0||Je(e,e.next,t)<0}function nt(e,t){const n=new at(e.i,e.x,e.y),r=new at(t.i,t.x,t.y),i=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function rt(e,t,n,r){const i=new at(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function it(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)}Le.defaultProps={},Le.extensionName="LayerExtension";var at=class{constructor(e,t,n){this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1,this.i=e,this.x=t,this.y=n}},ot={...t.PolygonLayer.defaultProps},st=class extends t.CompositeLayer{indexToBounds(){return null}renderLayers(){const{elevationScale:e,extruded:n,wireframe:r,filled:i,stroked:a,lineWidthUnits:o,lineWidthScale:s,lineWidthMinPixels:A,lineWidthMaxPixels:l,lineAntialiasing:c,lineJointRounded:u,lineMiterLimit:f,lineDashJustified:d,getElevation:h,getFillColor:p,getLineColor:m,getLineWidth:g}=this.props,{updateTriggers:b,material:v,transitions:y}=this.props,x=this.getSubLayerClass("cell",t.PolygonLayer),{updateTriggers:_,...w}=this.indexToBounds()||{};return new x({filled:i,wireframe:r,extruded:n,elevationScale:e,stroked:a,lineWidthUnits:o,lineWidthScale:s,lineWidthMinPixels:A,lineWidthMaxPixels:l,lineAntialiasing:c,lineJointRounded:u,lineMiterLimit:f,lineDashJustified:d,material:v,transitions:y,getElevation:h,getFillColor:p,getLineColor:m,getLineWidth:g},this.getSubLayerProps({id:"cell",updateTriggers:b&&{..._,getElevation:b.getElevation,getFillColor:b.getFillColor,getLineColor:b.getLineColor,getLineWidth:b.getLineWidth}}),w)}};function At(){const e=new Float64Array(4);return e[0]=1,e[3]=1,e}function lt(){return new Float64Array(2)}function ct(e){const t=new Float64Array(2);return t[0]=e[0],t[1]=e[1],t}function ut(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e}function ft(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e}function dt(e,t){return e[0]=-t[0],e[1]=-t[1],e}function ht(e){return Math.hypot(e[0],e[1])}function pt(e,t,n,r){const i=t[0],a=t[1];return e[0]=i+r*(n[0]-i),e[1]=a+r*(n[1]-a),e}function mt(e,t,n){const r=t[0],i=t[1];return e[0]=n[0]*r+n[2]*i,e[1]=n[1]*r+n[3]*i,e}function gt(e,t,n){const r=t[0],i=t[1];return e[0]=n[0]*r+n[2]*i+n[4],e[1]=n[1]*r+n[3]*i+n[5],e}function bt(){return new Float64Array(3)}function vt(e,t,n){const r=new Float64Array(3);return r[0]=e,r[1]=t,r[2]=n,r}function yt(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e}function xt(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e}function _t(e,t,n,r){return e[0]=t[0]+n[0]*r,e[1]=t[1]+n[1]*r,e[2]=t[2]+n[2]*r,e}function wt(e,t){return Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2])}function Tt(e,t){const n=t[0],r=t[1],i=t[2];let a=n*n+r*r+i*i;return a>0&&(a=1/Math.sqrt(a)),e[0]=t[0]*a,e[1]=t[1]*a,e[2]=t[2]*a,e}function St(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function Mt(e,t,n){const r=t[0],i=t[1],a=t[2],o=n[0],s=n[1],A=n[2];return e[0]=i*A-a*s,e[1]=a*o-r*A,e[2]=r*s-i*o,e}function Et(e,t,n){const r=n[0],i=n[1],a=n[2],o=n[3],s=t[0],A=t[1],l=t[2];let c=i*l-a*A,u=a*s-r*l,f=r*A-i*s,d=i*f-a*u,h=a*c-r*f,p=r*u-i*c;const m=2*o;return c*=m,u*=m,f*=m,d*=2,h*=2,p*=2,e[0]=s+c+d,e[1]=A+u+h,e[2]=l+f+p,e}st.layerName="GeoCellLayer",st.defaultProps=ot;var Ct=(1+Math.sqrt(5))/2,It=2*Math.PI/5,Rt=Math.PI/5,Pt=Math.PI/10,Nt=2*Math.atan(Ct),kt=Math.PI-Nt;Math.PI,Math.acos(-1/Math.sqrt(3-Ct));var Lt=(Math.sqrt(5)-1)/2,Bt=3-Math.sqrt(5);Math.sqrt(3-Ct);Math.sqrt(3);var Ot=6371007.2;Math.PI;function Ft(e,t,n,r){const i=t[0]-e[0],a=t[1]-e[1],o=r[0]-n[0],s=r[1]-n[1],A=i*s-a*o;if(Math.abs(A)<1e-12)return!1;const l=n[0]-e[0],c=n[1]-e[1],u=(l*s-c*o)/A,f=(l*a-c*i)/A;return u>=0&&u<=1&&f>=0&&f<=1}var Dt=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 r=(n+1)%t;e+=(this.vertices[r][0]-this.vertices[n][0])*(this.vertices[r][1]+this.vertices[n][1])}return e}isWindingCorrect(){return this.getArea()>=0}getVertices(){return this.vertices}scale(e){for(const t of this.vertices)ft(t,t,e);return this}rotate180(){for(const e of this.vertices)dt(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)ut(t,t,e);return this}transform(e){for(const t of this.vertices)mt(t,t,e);return this}transform2d(e){for(const t of this.vertices)gt(t,t,e);return this}clone(){return new e(this.vertices.map(e=>ct(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 r=0;r<t;r++){const i=this.vertices[r],a=this.vertices[(r+1)%t],o=i[0]-a[0],s=i[1]-a[1],A=e[0]-i[0],l=e[1]-i[1],c=o*l-s*A;if(c<0){const e=Math.sqrt(A*A+l*l);n=Math.min(n,c/e)}}return n}intersectsSegment(e,t){if(this.containsPoint(e)>0||this.containsPoint(t)>0)return!0;const n=this.vertices.length;for(let r=0;r<n;r++){if(Ft(e,t,this.vertices[r],this.vertices[(r+1)%n]))return!0}return!1}splitEdges(t){if(t<=1)return this;const n=[],r=this.vertices.length;for(let e=0;e<r;e++){const i=this.vertices[e],a=this.vertices[(e+1)%r];n.push(ct(i));for(let e=1;e<t;e++){const r=e/t,o=lt();pt(o,i,a,r),n.push(o)}}return new e(n)}},Ut=[0,0],Vt=[0,1],jt=[.7885966681787006,1.6149108024237764],zt=[1.6171013659387945,1.054928690397459],Gt=[Math.cos(Pt),Math.sin(Pt)],Ht=2*ht(jt)*Math.cos(Rt),qt=Rt-Math.atan2(jt[1],jt[0]),Qt=2*Lt/Ht;[Ut,Vt,jt,zt,Gt].forEach(e=>{ft(e,e,Qt),function(e,t,n,r){const i=t[0]-n[0],a=t[1]-n[1],o=Math.sin(r),s=Math.cos(r);e[0]=i*s-a*o+n[0],e[1]=i*o+a*s+n[1]}(e,e,[0,0],qt)});var Kt=new Dt([Ut,Vt,jt,zt,Gt]),Wt=Math.atan2(jt[1],jt[0])-Rt,$t=Lt/Math.cos(Rt),Jt=Wt+Rt,Yt=[$t*Math.cos(Jt),$t*Math.sin(Jt)],Xt=Wt-Rt,Zt=[$t*Math.cos(Xt),$t*Math.sin(Xt)],en=new Dt([[0,0],Yt,Zt]),tn=[Yt[0],Yt[1],Zt[0],Zt[1]],nn=new Float64Array([-.0022392098386786394,21308606513250217e-22,-2.559257686421274e-9,33701965267802837e-28,-4667545312611249e-30,667492870384816e-32]),rn=new Float64Array([.0022392089963541657,28831978048607556e-22,5.08622073997266e-9,102018123778161e-25,21912872306767718e-30,49284235482523806e-33]),an=new class{applyCoefficients(e,t){const n=Math.sin(e),r=Math.cos(e),i=2*(r-n)*(r+n);let a,o;return a=i*t[5]+t[4],o=i*a+t[3],a=i*o-a+t[2],o=i*a-o+t[1],a=i*o-a+t[0],e+2*n*r*a}forward(e){return this.applyCoefficients(e,nn)}inverse(e){return this.applyCoefficients(e,rn)}};function on(e){return e*(Math.PI/180)}function sn(e){return e*(180/Math.PI)}function An(e){return[ht(e),Math.atan2(e[1],e[0])]}function ln(e){const t=Math.atan2(e[1],e[0]),n=Math.sqrt(e[0]*e[0]+e[1]*e[1]);return[t,Math.atan2(n,e[2])]}function cn([e,t]){const n=Math.sin(t);return[n*Math.cos(e),n*Math.sin(e),Math.cos(t)]}function un([e,t]){const n=on(e+93),r=on(t),i=an.forward(r);return[n,Math.PI/2-i]}function fn(e){return((e+180)%360+360)%360-180}function dn([e,t]){const n=fn(sn(e)-93),r=Math.PI/2-t;return[n,sn(an.inverse(r))]}bt(),vt(1,0,0),vt(0,1,0);var hn=Math.sqrt(5),pn=Math.sqrt(.2),mn=Math.sqrt((1-pn)/2),gn=Math.sqrt((1+pn)/2),bn=.5,vn=Math.sqrt((2.5-hn)/10),yn=Math.sqrt((2.5+hn)/10),xn=Math.sqrt((1+pn)/8),_n=Math.sqrt((1-pn)/8),wn=Math.sqrt((3-hn)/8),Tn=Math.sqrt((3+hn)/8),Sn=[[0,0],[mn,0],[vn,bn],[-xn,wn],[-xn,-wn],[vn,-bn],[-gn,0],[-_n,-Tn],[yn,-bn],[yn,bn],[-_n,Tn],[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?gn:mn]),Mn=["vu","uw","vw","vw","vw"],En=["wu","uw","vw","vu","uw"],Cn=["wu","uv","wv","wu","uw"],In=["vu","uv","wv","wu","uw"],Rn=[Mn,In,Cn,En,Cn,In,Cn,En,En,En,In,In],Pn=[4,2,3,2,0,4,3,2,2,0,3,0],Nn=[0,1,2,4,3,5,7,8,6,11,10,9],kn=[];var Ln=0;function Bn(e,t,n){if(Ln>11)throw new Error(`Too many origins: ${Ln}`);const r=function(){const e=new Float64Array(4);return e[3]=1,e}();var i,a;a=n,(i=r)[0]=-a[0],i[1]=-a[1],i[2]=-a[2],i[3]=a[3];const o={id:Ln,axis:e,axisCartesian:cn(e),quat:n,inverseQuat:r,angle:t,orientation:Rn[Ln],firstQuintant:Pn[Ln]};kn.push(o),Ln++}!function(){Bn([0,0],0,Sn[0]);for(let e=0;e<5;e++){const t=e*It,n=t+Rt;Bn([t,kt],Rt,Sn[e+1]),Bn([n,Math.PI-kt],Rt,Sn[(e+3)%5+6])}Bn([0,Math.PI],0,Sn[11])}(),kn.sort((e,t)=>Nn.indexOf(e.id)-Nn.indexOf(t.id)),kn.forEach((e,t)=>e.id=t);var On=class{forward([e,t]){return[Math.tan(t),e]}inverse([e,t]){return[t,Math.atan(e)]}};bt();function Fn(e,t,n){const r=e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+1+(t[0]*n[0]+t[1]*n[1]+t[2]*n[2])+(n[0]*e[0]+n[1]*e[1]+n[2]*e[2]);return 2*Math.atan2((a=t,o=n,(i=e)[0]*(a[1]*o[2]-a[2]*o[1])+i[1]*(a[2]*o[0]-a[0]*o[2])+i[2]*(a[0]*o[1]-a[1]*o[0])),r);var i,a,o}var Dn=bt(),Un=bt(),Vn=lt(),jn=lt(),zn=class e{constructor(t){this.constants=e.computeConstants(t)}static computeConstants(e){const[t,n,r]=e,i=bt();Mt(i,n,r);const a=St(t,n),o=St(t,r),s=St(n,r),A=St(t,i),l=o+s,c=a+1,u=l*l-c*c,f=2*c*(a*s-o),d=function(e,t,n,r,i,a){const o=new Float64Array(6);return o[0]=e,o[1]=t,o[2]=n,o[3]=r,o[4]=i,o[5]=a,o}(A*A-u,-f,-2*A*l,2*A*c,A*A+u,f);return{volumeABC:A,areaABC:Fn(t,n,r),AdotB:a,AdotC:o,alphaTransform:d}}forward(e,t,n){const[r,i,a]=t,{areaABC:o,volumeABC:s}=this.constants;Mt(Dn,i,a);const A=St(e,Dn);xt(Un,e,s),_t(Un,Un,r,-A);const l=(c=Un,Math.hypot(c[0],c[1],c[2]));var c;xt(Un,Un,l>0?1/l:1);const u=Math.max(0,Fn(r,i,Un))/o,f=l/s*Math.sqrt((1+St(r,Un))/(1+St(r,e)));return function(e,[t,n,r]){return[e[0]*t[0]+e[1]*n[0]+e[2]*r[0],e[0]*t[1]+e[1]*n[1]+e[2]*r[1]]}([1-f,f*(1-u),f*u],n)}inverse(e,t,n){const[r,i,a]=n,o=function(e,[t,n,r]){const i=[t[0]-r[0],t[1]-r[1]],a=[r[0]-n[0],r[1]-n[1]],o=[e[0]-r[0],e[1]-r[1]],s=a[0]*i[1]-a[1]*i[0],A=(a[0]*o[1]-a[1]*o[0])/s,l=(i[0]*o[1]-i[1]*o[0])/s;return[A,l,1-(A+l)]}(e,t),s=1-1e-14;if(o[0]>s)return r;if(o[1]>s)return i;if(o[2]>s)return a;const{AdotB:A,AdotC:l,alphaTransform:c,areaABC:u}=this.constants,f=St(r,i),d=Math.abs(f-A)>Math.abs(f-l),h=d?a:i,p=d?i:a,m=d?o[1]:o[2],g=1-o[0],b=m/g*u;Vn[0]=Math.cos(b),Vn[1]=Math.sin(b),gt(jn,Vn,c),xt(Un,h,jn[0]),_t(Un,Un,p,jn[1]),Tt(Un,Un);const v=St(r,Un),y=1+g*g*(v-1),x=g*Math.sqrt((1+y)/(1+v)),_=y-v*x,w=bt();return xt(w,r,_),_t(w,w,Un,x),w}},Gn=[0,1,2,3,4].map(e=>{const t=At();return function(e,t){const n=Math.sin(t),r=Math.cos(t);e[0]=r,e[1]=n,e[2]=-n,e[3]=r}(t,It*e),t}),Hn=lt(),qn=lt();[0,1,2,3].map(e=>{const t=Kt.clone();return 1&e&&t.rotate180(),2&e&&t.reflectY(),t.getCenter()});function Qn(e){const t=en.clone();return t.transform(Gn[e]),t}var Kn=new class{constructor(){if(this.vertices=[],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)}getCanonicalTriangle(){return[this.vertices[0],this.vertices[32],this.vertices[12]]}getVertex(e){for(const t of this.vertices)if(wt(e,t)<1e-5)return t;throw new Error("Failed to find vertex in CRS")}addFaceCenters(){kn.forEach(e=>this.add(cn(e.axis)))}addVertices(){const e=Math.atan(Bt);for(const t of kn)for(let n=0;n<5;n++){const r=cn([(2*n+1)*Math.PI/5+t.angle,e]);Et(r,r,t.quat),this.add(r)}}addMidpoints(){const e=Math.atan(Lt);for(const t of kn)for(let n=0;n<5;n++){const r=cn([2*n*Math.PI/5+t.angle,e]);Et(r,r,t.quat),this.add(r)}}add(e){const t=Tt(bt(),e);return!this.vertices.find(e=>wt(t,e)<1e-5)&&(this.vertices.push(t),!0)}},Wn={A:"PQAB",B:"B+++PQ---A",C:"P---RMb+++",M:"qQ+++C---b",P:"PpB---B+++",Q:"PQ---Cb+++",R:"b+++a---qQ"},$n=Object.keys(Wn);$n.map(e=>e.toLowerCase());var Jn=e=>[...e].reverse().map(e=>"+"===e?"-":"-"===e?"+":(e=>e>="a"&&e<="z"?e.toUpperCase():e.toLowerCase())(e)).join("");function Yn(e,t){let n="";for(const r of e){const e=r.toUpperCase();void 0!==t[r]?n+=t[r]:r!==e&&void 0!==t[e]?n+=Jn(t[e]):n+=r}return n}var Xn=(e,t)=>({a:e.a+t.a,b:e.b+t.b}),Zn=e=>({a:-e.b,b:e.a+e.b}),er=(e,t)=>{let n=e;const r=(t%6+6)%6;for(let i=0;i<r;i++)n=Zn(n);return n},tr={E:{a:4,b:0},e:{a:4,b:0},S:{a:4,b:-2},s:{a:4,b:-2},U:{a:0,b:2},u:{a:0,b:2},D:{a:0,b:-2},d:{a:0,b:-2},T:{a:-4,b:0},t:{a:-4,b:0}},nr=new Set(Object.keys(tr)),rr={E:[{a:0,b:0},{a:4,b:0},{a:4,b:-4}],e:[{a:0,b:0},{a:4,b:0},{a:0,b:4}],S:[{a:0,b:0},{a:4,b:0},{a:4,b:-4}],s:[{a:4,b:-2},{a:0,b:2},{a:0,b:-2}],U:[{a:0,b:2},{a:0,b:-2},{a:4,b:-2}],u:[{a:0,b:0},{a:0,b:4},{a:-4,b:4}],D:[{a:0,b:2},{a:0,b:-2},{a:4,b:-2}],d:[{a:0,b:0},{a:0,b:-4},{a:-4,b:0}],T:[{a:0,b:-4},{a:-4,b:0},{a:-4,b:-4}],t:[{a:-4,b:4},{a:0,b:0},{a:0,b:4}]};function ir(e,t,n){return rr[e].map(e=>Xn(t,er(e,n)))}function ar(e,t,n){const[r,i,a]=ir(e,t,n);return{a:r.a+i.a+a.a,b:r.b+i.b+a.b}}function or(e,t,n,r){let i={...t},a=(n%6+6)%6;for(const o of e)"+"!==o?"-"!==o?nr.has(o)&&(r?.(o,i,a),i=Xn(i,er(tr[o],a))):a=(a+5)%6:a=(a+1)%6;return{pos:i,heading:a}}var sr=1e-6;function Ar(e,t,n){const r=n?-1:1,i=[];for(let a=0;a<4;a++){const o=4*t+a,s=e.childToken[o],A=e.childFlip[o],l=e.childOffA[o],c=e.childOffB[o],u=e.fpEdges[2*s+(n^A)],f=[];for(let e=0;e<u.length;e+=4)f.push([3*l*r+u[e],3*c*r+u[e+1]]);i.push([a,f])}return i}function lr(e){if(1===e.length)return{leaf:e[0][0]};for(const[,t]of e){const n=t.length;for(let r=0;r<n;r++){const[i,a]=t[r],[o,s]=t[(r+1)%n],A=s-a,l=-(o-i),c=-(A*i+l*a),u=[],f=[];let d=!0;for(const[t,n]of e){let e=1/0,r=-1/0;for(const[t,i]of n){const n=A*t+l*i+c;n<e&&(e=n),n>r&&(r=n)}if(e>=-sr)u.push([t,n]);else{if(!(r<=sr)){d=!1;break}f.push([t,n])}}if(d&&u.length&&f.length)return{nx:A,ny:l,c:c,pos:lr(u),neg:lr(f)}}}throw new Error("lsystem: no clean BSP split for child set")}function cr(e,t){if("leaf"in e)return;const n=[e.nx,e.ny,e.c];t.some(e=>e[0]===n[0]&&e[1]===n[1]&&e[2]===n[2])||t.push(n),cr(e.pos,t),cr(e.neg,t)}function ur(e,t,n){return"leaf"in e?e.leaf:ur(t>>n.findIndex(t=>t[0]===e.nx&&t[1]===e.ny&&t[2]===e.c)&1?e.pos:e.neg,t,n)}var fr={S:0,D:1,E:2,T:3};function dr(e,t){const n=Object.keys(e),r=[...n,...n.map(e=>e.toLowerCase())],i=r.length,a={};function o(n,r){let i=n;for(let t=0;t<r;t++)i=Yn(i,e);return Yn(i,t)}r.forEach((e,t)=>a[e]=t);const s=e=>function(e){const t=or(e,{a:0,b:0},0);return{disp:t.pos,dHeading:t.heading}}(o(e,1)).disp;function A(t){let n={a:0,b:0},r=0;const i=[];for(const a of t){if("+"===a){r=(r+1)%6;continue}if("-"===a){r=(r+5)%6;continue}if(void 0===e[a.toUpperCase()])continue;if(0!==r&&3!==r)throw new Error(`lsystem: non-180° turn (${60*r}°) before a child in rule "${t}"`);const o=3===r;i.push({token:a,offUnit:{...n},flip:o});const A=s(a);n=o?{a:n.a-A.a,b:n.b-A.b}:{a:n.a+A.a,b:n.b+A.b}}if(4!==i.length)throw new Error(`lsystem: rule "${t}" must have 4 children`);return i}const l={};for(const y of n)l[y]=A(e[y]);for(const y of n)l[y.toLowerCase()]=A(Jn(e[y]));const c=new Int32Array(4*i),u=new Uint8Array(4*i),f=new Float64Array(4*i),d=new Float64Array(4*i);for(const y of r){const e=l[y];for(let t=0;t<4;t++){const n=4*a[y]+t;c[n]=a[e[t].token],u[n]=e[t].flip?1:0,f[n]=e[t].offUnit.a,d[n]=e[t].offUnit.b}}function h(e){const t=[...new Map(e.map(e=>[`${e.a},${e.b}`,e])).values()].sort((e,t)=>e.a-t.a||e.b-t.b);if(t.length<3)return t;const n=(e,t,n)=>(t.a-e.a)*(n.b-e.b)-(t.b-e.b)*(n.a-e.a),r=[];for(const a of t){for(;r.length>=2&&n(r[r.length-2],r[r.length-1],a)<=0;)r.pop();r.push(a)}const i=[];for(let a=t.length-1;a>=0;a--){const e=t[a];for(;i.length>=2&&n(i[i.length-2],i[i.length-1],e)<=0;)i.pop();i.push(e)}return r.slice(0,-1).concat(i.slice(0,-1))}const p=new Array(2*i);for(const y of r){const e=[];or(o(y,1),{a:0,b:0},0,(t,n,r)=>e.push(...ir(t,n,r)));const t=h(e);for(let n=0;n<2;n++){const e=n?-1:1,r=new Float64Array(4*t.length);for(let n=0;n<t.length;n++){const i=t[n],a=t[(n+1)%t.length];r[4*n]=3*e*i.a,r[4*n+1]=3*e*i.b,r[4*n+2]=e*(a.a-i.a),r[4*n+3]=e*(a.b-i.b)}p[2*a[y]+n]=r}}const m=new Float64Array(2*i*8),g=new Float64Array(2*i*48),b=new Uint8Array(2*i*4);for(const y of r){const e=o(y,1);for(let t=0;t<2;t++){const n=2*a[y]+t;let r=0;or(e,{a:0,b:0},t?3:0,(e,t,i)=>{const a=ar(e,t,i);m[8*n+2*r]=a.a,m[8*n+2*r+1]=a.b;const o=e.toUpperCase();if(void 0===fr[o])throw new Error(`lsystem: no pentagon flavor for draw symbol ${e}`);b[4*n+r]=fr[o]^(e===o?0:1)^1&i;let s=ir(e,t,i);(s[1].a-s[0].a)*(s[2].b-s[0].b)-(s[1].b-s[0].b)*(s[2].a-s[0].a)<0&&(s=[s[0],s[2],s[1]]);for(let A=0;A<3;A++){const e=s[A],t=s[(A+1)%3],i=48*n+12*r+4*A;g[i]=3*e.a,g[i+1]=3*e.b,g[i+2]=t.a-e.a,g[i+3]=t.b-e.b}r++})}}const v={motifIdx:a,childToken:c,childFlip:u,childOffA:f,childOffB:d,fpEdges:p,leafSum:m,leafTri:g,leafFlavor:b,classSep:new Float64Array(2*i*9),classLut:new Uint8Array(2*i*8)};for(let y=0;y<i;y++)for(let e=0;e<2;e++){const t=2*y+e,n=lr(Ar(v,y,e)),r=[];cr(n,r);for(let e=0;e<r.length;e++)v.classSep[9*t+3*e]=r[e][0],v.classSep[9*t+3*e+1]=r[e][1],v.classSep[9*t+3*e+2]=r[e][2];for(let e=0;e<8;e++)v.classLut[8*t+e]=ur(n,e,r)}return v}var hr=new Float64Array(32);for(let ev=0;ev<32;ev++)hr[ev]=2**ev;var pr=new Float64Array(20);for(let ev=0;ev<20;ev++)pr[ev]=4**ev;var mr=dr(Wn,{A:"E",B:"+e-",C:"-e+",M:"T",P:"S",Q:"D",R:"+++D---"});mr.motifIdx.A,mr.motifIdx.A,mr.motifIdx.C,mr.motifIdx.C,mr.motifIdx.B,mr.motifIdx.B;var gr=dr({W:"W+++Z---WZ",Z:"Z+++W---ZW"},{W:"E",Z:"+e-"}),br=gr.motifIdx.W;function vr(e){return Array.from({length:e.length},(t,n)=>e.indexOf(n))}var yr=[0,1,3,4,5,6,7,2],xr=[0,1,2,7,3,4,5,6];vr(yr),vr(xr);function _r(e,t,n,r,i){if(t<=0)return;const a=e[t]||0,o=e[t-1];let s=!0,A=!0;if(r!==(0===n[0]+n[1])?(s=1===a||2===a,A=1===a):(s=a<2,A=0===a),!s)return;const l=A?o:o+4,c=i[l];e[t-1]=c%4,e[t]=(a+4+Math.floor(c/4)-Math.floor(l/4))%4}function wr(e,t){1===t?e[1]=-e[1]:3===t&&(e[0]=-e[0])}var Tr={uv:{reverse:!1,invertJ:!1,flipIJ:!1},vu:{reverse:!0,invertJ:!1,flipIJ:!1},uw:{reverse:!1,invertJ:!1,flipIJ:!0},wu:{reverse:!0,invertJ:!1,flipIJ:!0},vw:{reverse:!0,invertJ:!0,flipIJ:!1},wv:{reverse:!1,invertJ:!0,flipIJ:!1}};function Sr(e,t){return(-1===e[1]?1:0)|((e[0]+e[1]===0?0===t||3===t:2===t||3===t)?1:0)<<1}function Mr(e,t,n){const r=1n<<BigInt(2*t),i=function(e,t){const n=[];let r=e;for(;r>0n||n.length<t;)n.push(Number(3n&r)),r>>=2n;return n}(n.reverse?r-1n-e:e,t),a=function(e,t,n){const r=n?xr:yr,i=[1,1];for(let a=e.length-1;a>=0;a--)_r(e,a,i,t,r),wr(i,e[a]);return i}(i,n.invertJ,n.flipIJ),o=function(e,t,n,r){const{childToken:i,childFlip:a,childOffA:o,childOffB:s,leafSum:A,leafFlavor:l}=e,c=Number(67108863n&t),u=Number(t>>26n);let f=r,d=0,h=0,p=0;for(let b=n;b>=2;b--){const e=b-1,t=4*f+(e<13?c>>>(e<<1)&3:Math.floor(u/pr[e-13])%4),n=d?-hr[b-2]:hr[b-2];h+=o[t]*n,p+=s[t]*n,d^=a[t],f=i[t]}const m=n>=1?3&c:0,g=2*f+d;return{a:3*h+A[8*g+2*m],b:3*p+A[8*g+2*m+1],flavor:l[4*g+m]}}(gr,function(e){let t=0n;for(let n=e.length-1;n>=0;n--)t=t<<2n|BigInt(e[n]);return t}(i),t,br);let s=function(e,t){if((2*e+t)%12!=0||t%4!=0)throw new Error(`abToTriple: off-lattice corner sum (${e},${t})`);const n=(2*e+t-12)/12,r=(t+4)/4;for(const i of[0,1]){if((r+i)%3!=0)continue;const e=(r+i)/3,t=i-e;if((t+n)%2==0)return{x:e,y:(t+n)/2,z:(t-n)/2}}throw new Error(`abToTriple: no integer triple for (${e},${t})`)}(o.a,o.b);if(n.flipIJ&&(s={x:s.z,y:s.y,z:s.x}),n.invertJ){const e=hr[t]-1;s={x:s.y-e,y:s.x+e,z:s.z}}return{triple:s,flips:a,q:i.length>0?i[0]:0}}function Er(e){const t=function(e){if(0n===e)return-1;if(1n&e||4n==(7n&e)||16n==(31n&e))return 30;let t=29,n=e>>1n;if(0n===n)return-1;let r,i=Number(4294967295n&n);for(0===i?(n>>=32n,t-=16,r=Number(n)):r=i,65535&r||(r>>=16,t-=8),t>=6&&!(255&r)&&(r>>=8,t-=4),t>=4&&!(15&r)&&(r>>=4,t-=2);t>-1&&!(1&r);)t-=1,r>>=t<2?1:2;return t}(e);if(-1===t)return{origin:kn[0],segment:0,S:0n,resolution:t};let n=58n,r=0;if(30===t){const t=1n&e?1n:4n&e?3n:5n;n=58n+t,r=1n===t?0:3n===t?32:40}const i=Number(e>>n)+r;let a,o;if(0===t?(a=kn[i],o=0):(a=kn[Math.floor(i/5)],o=(i+a.firstQuintant)%5),!a)throw new Error(`Could not parse origin: ${i}`);if(t<2)return{origin:a,segment:o,S:0n,resolution:t};return{origin:a,segment:o,S:(e&(1n<<n)-1n)>>n-BigInt(2*(t-2+1)),resolution:t}}var Cr=(e,t,n)=>({x:e,y:t,z:n}),Ir=(Cr(0,0,1),Cr(0,1,-1),Cr(0,1,0),Cr(1,-1,0),Cr(1,0,0),Cr(1,-1,1),Cr(1,1,-1),Cr(0,0,1),Cr(0,1,-1),Cr(0,1,0),Cr(1,-1,0),Cr(1,0,0),Cr(1,-1,1),Cr(1,1,-1),Cr(0,0,-1),Cr(0,-1,1),Cr(0,-1,0),Cr(-1,1,0),Cr(-1,0,0),Cr(-1,1,-1),Cr(-1,-1,1),Cr(0,0,-1),Cr(0,-1,1),Cr(0,-1,0),Cr(-1,1,0),Cr(-1,0,0),Cr(-1,1,-1),Cr(-1,-1,1),Cr(-1,1,0),Cr(0,-1,1),Cr(0,0,1),Cr(0,1,0),Cr(1,0,0),Cr(-1,1,1),Cr(1,-1,1),Cr(-1,1,0),Cr(0,-1,1),Cr(0,0,1),Cr(0,1,0),Cr(1,0,0),Cr(-1,1,1),Cr(1,-1,1),Cr(1,-1,0),Cr(0,1,-1),Cr(0,0,-1),Cr(0,-1,0),Cr(-1,0,0),Cr(1,-1,-1),Cr(-1,1,-1),Cr(1,-1,0),Cr(0,1,-1),Cr(0,0,-1),Cr(0,-1,0),Cr(-1,0,0),Cr(1,-1,-1),Cr(-1,1,-1),vt(0,0,1),(()=>{const e=[];for(let t=0;t<24;t++){const n=1.4*(t+1);e.push(vt(Math.cos(n),Math.sin(n),0))}})(),At(),new class{constructor(){this.faceTriangles=[],this.sphericalTriangles=[],this.equalArea=new zn(Kn.getCanonicalTriangle()),this.gnomonic=new On}forward(e,t){return this.forwardCartesian(cn(e),t)}forwardCartesian(e,t){const n=kn[t],r=bt();Et(r,e,n.inverseQuat);const i=ln(r),a=this.gnomonic.forward(i);a[1]=a[1]-n.angle;const o=this.getFaceTriangleIndex(a),s=this.shouldReflect(a);let A=this.getFaceTriangle(o,s,!1),l=this.getSphericalTriangle(o,t,s);return this.equalArea.forward(e,l,A)}inverse(e,t){const n=An(e),r=this.getFaceTriangleIndex(n),i=this.shouldReflect(n),a=this.getFaceTriangle(r,i,!1),o=this.getSphericalTriangle(r,t,i);return ln(this.equalArea.inverse(e,a,o))}shouldReflect(e){const[t,n]=e;return function([e,t]){return[e*Math.cos(t),e*Math.sin(t)]}([t,this.normalizeGamma(n)])[0]>Lt}getFaceTriangleIndex([e,t]){return(Math.floor(t/Rt)+10)%10}getFaceTriangle(e,t=!1,n=!1){let r=e;return t&&(r+=n?20:10),this.faceTriangles[r]||(this.faceTriangles[r]=t?this._getReflectedFaceTriangle(e,n):this._getFaceTriangle(e),Object.freeze(this.faceTriangles[r])),this.faceTriangles[r]}_getFaceTriangle(e){const[t,n,r]=Qn(Math.floor((e+1)/2)%5).getVertices(),i=lt();return pt(i,n,r,.5),e%2==0?[t,i,n]:[t,r,i]}_getReflectedFaceTriangle(e,t=!1){let[n,r,i]=this._getFaceTriangle(e).map(e=>ct(e));const a=e%2==0;var o,s,A,l;return dt(n,n),o=n,s=n,A=a?r:i,l=t?1+1/Math.cos(kt):2,o[0]=s[0]+A[0]*l,o[1]=s[1]+A[1]*l,[n,i,r]}getSphericalTriangle(e,t,n=!1){let r=10*t+e;return n&&(r+=120),this.sphericalTriangles[r]||(this.sphericalTriangles[r]=this._getSphericalTriangle(e,t,n),Object.freeze(this.sphericalTriangles[r])),this.sphericalTriangles[r]}_getSphericalTriangle(e,t,n=!1){const r=kn[t];return this.getFaceTriangle(e,n,!0).map(e=>{const[t,n]=An(e),i=[t,n+r.angle],a=cn(this.gnomonic.inverse(i));return Et(a,a,r.quat),Kn.getVertex(a)})}normalizeGamma(e){const t=e/It;return(t-Math.round(t))*It}});bt();function Rr({S:e,segment:t,origin:n,resolution:r}){const{quintant:i,orientation:a}=function(e,t){const n=t.orientation,r=n===Mn||n===En?-1:1,i=(e-t.firstQuintant+5)%5,a=n[i];return{quintant:(t.firstQuintant+r*i+5)%5,orientation:a}}(t,n);if(1===r)return Qn(i);if(0===r)return function(){const e=[];for(const t of Gn)e.push(mt(lt(),Yt,t));return e.reverse(),new Dt(e)}();const o=r-2+1,{triple:s,flavor:A}=function(e,t,n="uv"){const r=Tr[n],{triple:i,flips:a,q:o}=Mr(e,t,r);return r.invertJ&&(a[0]=-a[0]),{triple:i,flavor:Sr(a,o)}}(e,o,a);return function(e,t,n,r,i=!1){const a=(i?en:Kt).clone();var o,s,A;return 1&r&&a.rotate180(),2&r&&a.reflectY(),o=qn,s=n.x+n.y,A=-n.x+(1&r),o[0]=s,o[1]=A,mt(Hn,qn,tn),a.translate(Hn),a.scale(1/2**e),a.transform(Gn[t]),a}(o,i,s,A)}function Pr(e,{closedRing:t=!0,segments:n="auto"}={closedRing:!0,segments:"auto"}){if(0n===e)return[];const{S:r,segment:i,origin:a,resolution:o}=Er(e);"auto"===n&&(n=Math.max(1,Math.pow(2,6-o)));const s=Rr({S:r,segment:i,origin:a,resolution:o}).splitEdges(n).getVertices(),A=new Array(s.length);for(let c=0;c<s.length;c++)A[c]=dn(Ir.inverse(s[c],a.id));const l=function(e){const t=bt();for(let a=0;a<e.length;a++)yt(t,t,cn(un(e[a])));Tt(t,t);let[n,r]=dn(ln(t));(r>89.99||r<-89.99)&&(n=e[0][0]),n=fn(n);const i=new Array(e.length);for(let a=0;a<e.length;a++){let t=e[a][0];const r=e[a][1];for(;t-n>180;)t-=360;for(;t-n<-180;)t+=360;i[a]=[t,r]}return i}(A);return t&&l.push(l[0]),l.reverse(),l}var Nr=12742014.4/Math.sqrt(15),kr=new Array(31);kr[0]=12742014.4/Math.sqrt(3);for(let ev=1;ev<=30;ev++)kr[ev]=Nr/(1<<ev-1);(()=>{const e=[];for(let t=-1;t<=1;t++)for(let n=-1;n<=1;n++)for(let r=-1;r<=1;r++)0===t&&0===n&&0===r||e.push([t,n,r])})(),vt(0,0,1),vt(1,0,0),bt();var Lr=function(e){var t,n=void 0!==(e=e||{})?e:{},r={};for(t in n)n.hasOwnProperty(t)&&(r[t]=n[t]);var i,a=[],o="";"undefined"!=typeof document&&document.currentScript&&(o=document.currentScript.src),o=0!==o.indexOf("blob:")?o.substr(0,o.lastIndexOf("/")+1):"",i=function(e,t,n){var r=new XMLHttpRequest;r.open("GET",e,!0),r.responseType="arraybuffer",r.onload=function(){if(200==r.status||0==r.status&&r.response)t(r.response);else{var i=J(e);i?t(i.buffer):n()}},r.onerror=n,r.send(null)};var s=n.print||console.log.bind(console),A=n.printErr||console.warn.bind(console);for(t in r)r.hasOwnProperty(t)&&(n[t]=r[t]);r=null,n.arguments&&(a=n.arguments);var l=0;var c=!1;function u(e){var t,r=n["_"+e];return t="Cannot call unknown function "+e+", make sure it is exported",r||le("Assertion failed: "+t),r}function f(e,t,n,r,i){var a={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,r){if(!(r>0))return 0;for(var i=n,a=n+r-1,o=0;o<e.length;++o){var s=e.charCodeAt(o);if(s>=55296&&s<=57343)s=65536+((1023&s)<<10)|1023&e.charCodeAt(++o);if(s<=127){if(n>=a)break;t[n++]=s}else if(s<=2047){if(n+1>=a)break;t[n++]=192|s>>6,t[n++]=128|63&s}else if(s<=65535){if(n+2>=a)break;t[n++]=224|s>>12,t[n++]=128|s>>6&63,t[n++]=128|63&s}else{if(n+3>=a)break;t[n++]=240|s>>18,t[n++]=128|s>>12&63,t[n++]=128|s>>6&63,t[n++]=128|63&s}}t[n]=0})(e,p,t,n)})(e,t=te(n),n)}return t},array:function(e){var t=te(e.length);return function(e,t){h.set(e,t)}(e,t),t}};var o=u(e),s=[],A=0;if(r)for(var l=0;l<r.length;l++){var c=a[n[l]];c?(0===A&&(A=re()),s[l]=c(r[l])):s[l]=r[l]}var f=o.apply(null,s);return f=function(e){return"string"===t?x(e):"boolean"===t?Boolean(e):e}(f),0!==A&&ne(A),f}var d,h,p,m,g,b,v,y="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function x(e,t){return e?function(e,t,n){for(var r=t+n,i=t;e[i]&&!(i>=r);)++i;if(i-t>16&&e.subarray&&y)return y.decode(e.subarray(t,i));for(var a="";t<i;){var o=e[t++];if(128&o){var s=63&e[t++];if(192!=(224&o)){var A=63&e[t++];if((o=224==(240&o)?(15&o)<<12|s<<6|A:(7&o)<<18|s<<12|A<<6|63&e[t++])<65536)a+=String.fromCharCode(o);else{var l=o-65536;a+=String.fromCharCode(55296|l>>10,56320|1023&l)}}else a+=String.fromCharCode((31&o)<<6|s)}else a+=String.fromCharCode(o)}return a}(p,e,t):""}function _(e,t){return e%t>0&&(e+=t-e%t),e}function w(e){d=e,n.HEAP8=h=new Int8Array(e),n.HEAP16=m=new Int16Array(e),n.HEAP32=g=new Int32Array(e),n.HEAPU8=p=new Uint8Array(e),n.HEAPU16=new Uint16Array(e),n.HEAPU32=new Uint32Array(e),n.HEAPF32=b=new Float32Array(e),n.HEAPF64=v=new Float64Array(e)}"undefined"!=typeof TextDecoder&&new TextDecoder("utf-16le");var T=n.TOTAL_MEMORY||33554432;function S(e){for(;e.length>0;){var t=e.shift();if("function"!=typeof t){var r=t.func;"number"==typeof r?void 0===t.arg?n.dynCall_v(r):n.dynCall_vi(r,t.arg):r(void 0===t.arg?null:t.arg)}else t()}}T=(d=n.buffer?n.buffer:new ArrayBuffer(T)).byteLength,w(d),g[7096]=5271296;var M=[],E=[],C=[],I=[];function R(e){M.unshift(e)}function P(e){I.unshift(e)}var N=Math.abs,k=Math.ceil,L=Math.floor,B=Math.min,O=0,F=null,D=null;n.preloadedImages={},n.preloadedAudios={};var U,V,j=null,z="data:application/octet-stream;base64,";function G(e){return String.prototype.startsWith?e.startsWith(z):0===e.indexOf(z)}j="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+AAAAAAAAACsAAAADAAAAYQAAAAAAAABZAAAAAwAAAEcAAAADAAAAYgAAAAMAAABUAAAAAAAAAEUAAAAAAAAAYAAAAAMAAABSAAAAAwAAAEAAAAAAAAAASwAAAAAAAABBAAAAAAAAADoAAAADAAAAPQAAAAAAAAA1AAAAAwAAACwAAAADAAAAMQAAAAMAAAApAAAAAwAAAB8AAAADAAAAXgAAAAAAAABWAAAAAAAAAEwAAAADAAAAUQAAAAMAAABLAAAAAAAAAEEAAAAAAAAAQgAAAAMAAAA9AAAAAAAAADUAAAADAAAAawAAAAAAAABoAAAAAwAAAGAAAAADAAAAZQAAAAMAAABeAAAAAAAAAFYAAAAAAAAAVQAAAAMAAABRAAAAAwAAAEsAAAAAAAAAOQAAAAAAAAA7AAAAAAAAAD8AAAADAAAASgAAAAAAAABOAAAAAwAAAE8AAAADAAAAUwAAAAMAAABcAAAAAwAAAF8AAAADAAAAJQAAAAAAAAAnAAAAAwAAAC0AAAADAAAANAAAAAAAAAA5AAAAAAAAADsAAAAAAAAARgAAAAMAAABKAAAAAAAAAE4AAAADAAAAGAAAAAAAAAAXAAAAAwAAABkAAAADAAAAIAAAAAMAAAAlAAAAAAAAACcAAAADAAAAMgAAAAMAAAA0AAAAAAAAADkAAAAAAAAALgAAAAAAAAA8AAAAAAAAAEgAAAADAAAAOAAAAAAAAABEAAAAAwAAAFAAAAADAAAAPwAAAAMAAABNAAAAAwAAAFoAAAADAAAAGwAAAAAAAAAoAAAAAwAAADcAAAADAAAAIwAAAAAAAAAuAAAAAAAAADwAAAAAAAAALQAAAAMAAAA4AAAAAAAAAEQAAAADAAAADgAAAAAAAAAUAAAAAwAAACQAAAADAAAAEQAAAAMAAAAbAAAAAAAAACgAAAADAAAAGQAAAAMAAAAjAAAAAAAAAC4AAAAAAAAARwAAAAAAAABZAAAAAAAAAGEAAAADAAAASQAAAAAAAABbAAAAAwAAAGcAAAADAAAASAAAAAMAAABYAAAAAwAAAGkAAAADAAAAMwAAAAAAAABFAAAAAwAAAFQAAAADAAAANgAAAAAAAABHAAAAAAAAAFkAAAAAAAAANwAAAAMAAABJAAAAAAAAAFsAAAADAAAAJgAAAAAAAAAvAAAAAwAAAEAAAAADAAAAIgAAAAMAAAAzAAAAAAAAAEUAAAADAAAAJAAAAAMAAAA2AAAAAAAAAEcAAAAAAAAAYAAAAAAAAABoAAAAAAAAAGsAAAADAAAAYgAAAAAAAABuAAAAAwAAAHMAAAADAAAAYQAAAAMAAABvAAAAAwAAAHcAAAADAAAATAAAAAAAAABWAAAAAwAAAF4AAAADAAAAUgAAAAAAAABgAAAAAAAAAGgAAAAAAAAAVAAAAAMAAABiAAAAAAAAAG4AAAADAAAAOgAAAAAAAABBAAAAAwAAAEsAAAADAAAAPgAAAAMAAABMAAAAAAAAAFYAAAADAAAAQAAAAAMAAABSAAAAAAAAAGAAAAAAAAAAVQAAAAAAAABXAAAAAAAAAFMAAAADAAAAZQAAAAAAAABmAAAAAwAAAGQAAAADAAAAawAAAAMAAABwAAAAAwAAAHIAAAADAAAAQgAAAAAAAABDAAAAAwAAAEYAAAADAAAAUQAAAAAAAABVAAAAAAAAAFcAAAAAAAAAXgAAAAMAAABlAAAAAAAAAGYAAAADAAAAMQAAAAAAAAAwAAAAAwAAADIAAAADAAAAPQAAAAMAAABCAAAAAAAAAEMAAAADAAAASwAAAAMAAABRAAAAAAAAAFUAAAAAAAAAXwAAAAAAAABcAAAAAAAAAFMAAAAAAAAATwAAAAAAAABOAAAAAAAAAEoAAAADAAAAPwAAAAEAAAA7AAAAAwAAADkAAAADAAAAbQAAAAAAAABsAAAAAAAAAGQAAAAFAAAAXQAAAAEAAABfAAAAAAAAAFwAAAAAAAAATQAAAAEAAABPAAAAAAAAAE4AAAAAAAAAdQAAAAQAAAB2AAAABQAAAHIAAAAFAAAAagAAAAEAAABtAAAAAAAAAGwAAAAAAAAAWgAAAAEAAABdAAAAAQAAAF8AAAAAAAAAWgAAAAAAAABNAAAAAAAAAD8AAAAAAAAAUAAAAAAAAABEAAAAAAAAADgAAAADAAAASAAAAAEAAAA8AAAAAwAAAC4AAAADAAAAagAAAAAAAABdAAAAAAAAAE8AAAAFAAAAYwAAAAEAAABaAAAAAAAAAE0AAAAAAAAAWAAAAAEAAABQAAAAAAAAAEQAAAAAAAAAdQAAAAMAAABtAAAABQAAAF8AAAAFAAAAcQAAAAEAAABqAAAAAAAAAF0AAAAAAAAAaQAAAAEAAABjAAAAAQAAAFoAAAAAAAAAaQAAAAAAAABYAAAAAAAAAEgAAAAAAAAAZwAAAAAAAABbAAAAAAAAAEkAAAADAAAAYQAAAAEAAABZAAAAAwAAAEcAAAADAAAAcQAAAAAAAABjAAAAAAAAAFAAAAAFAAAAdAAAAAEAAABpAAAAAAAAAFgAAAAAAAAAbwAAAAEAAABnAAAAAAAAAFsAAAAAAAAAdQAAAAIAAABqAAAABQAAAFoAAAAFAAAAeQAAAAEAAABxAAAAAAAAAGMAAAAAAAAAdwAAAAEAAAB0AAAAAQAAAGkAAAAAAAAAdwAAAAAAAABvAAAAAAAAAGEAAAAAAAAAcwAAAAAAAABuAAAAAAAAAGIAAAADAAAAawAAAAEAAABoAAAAAwAAAGAAAAADAAAAeQAAAAAAAAB0AAAAAAAAAGcAAAAFAAAAeAAAAAEAAAB3AAAAAAAAAG8AAAAAAAAAcAAAAAEAAABzAAAAAAAAAG4AAAAAAAAAdQAAAAEAAABxAAAABQAAAGkAAAAFAAAAdgAAAAEAAAB5AAAAAAAAAHQAAAAAAAAAcgAAAAEAAAB4AAAAAQAAAHcAAAAAAAAAcgAAAAAAAABwAAAAAAAAAGsAAAAAAAAAZAAAAAAAAABmAAAAAAAAAGUAAAADAAAAUwAAAAEAAABXAAAAAwAAAFUAAAADAAAAdgAAAAAAAAB4AAAAAAAAAHMAAAAFAAAAbAAAAAEAAAByAAAAAAAAAHAAAAAAAAAAXAAAAAEAAABkAAAAAAAAAGYAAAAAAAAAdQAAAAAAAAB5AAAABQAAAHcAAAAFAAAAbQAAAAEAAAB2AAAAAAAAAHgAAAAAAAAAXwAAAAEAAABsAAAAAQAAAHIAAAAAAAAAGC1EVPsh+T8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABgtRFT7Ifk/GC1EVPsh+T8AAAAAAAAAAAAAAAAAAAAAGC1EVPsh+T8AAAAAAAAAABgtRFT7IQlAGC1EVPsh+T8AAAAAAAAAAAAAAAAAAAAAGC1EVPshCUAAAAAAAAAAABgtRFT7Ifm/GC1EVPsh+T8AAAAAAAAAAAAAAAAAAAAAGC1EVPsh+b8AAAAAAAAAAAAAAAAAAAAAGC1EVPsh+b8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABgtRFT7Ifm/GC1EVPsh+b8AAAAAAAAAAAAAAAAAAAAAGC1EVPsh+b8AAAAAAAAAABgtRFT7IQnAGC1EVPsh+b8AAAAAAAAAAAAAAAAAAAAAGC1EVPshCcAAAAAAAAAAABgtRFT7Ifk/GC1EVPsh+b8AAAAAAAAAAAAAAAAAAAAAGC1EVPsh+T8AAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAGAAAAAgAAAAUAAAABAAAABAAAAAAAAAAAAAAABQAAAAMAAAABAAAABgAAAAQAAAACAAAAAAAAAMpi5RexJsw/BlIKPVwR5T95Wyu0/QjnP5PjoT7YYcu/mBhKZ6zrwj8wRYS7NebuP3qW6geh+Ls/SLrixebL3r+pcyymN9XrPwmkNHp7xec/GWNMZVAA17+82s+x2BLiPwn2ytbJ9ek/LgEH1sMS1j8yp/2LhTfeP+SnWwtQBbu/d38gkp5X7z8ytsuHaADGPzUYObdf1+m/7IauECWhwz+cjSACjzniP76Z+wUhN9K/1+GEKzup67+/GYr/04baPw6idWOvsuc/ZedTWsRa5b/EJQOuRzi0v/OncYhHPes/h49PixY53j+i8wWfC03Nvw2idWOvsue/ZedTWsRa5T/EJQOuRzi0P/KncYhHPeu/iY9PixY53r+i8wWfC03NP9anWwtQBbs/d38gkp5X778ytsuHaADGvzUYObdf1+k/74auECWhw7+cjSACjzniv8CZ+wUhN9I/1uGEKzup6z+/GYr/04bavwmkNHp7xee/F2NMZVAA1z+82s+x2BLivwr2ytbJ9em/KwEH1sMS1r8yp/2LhTfev81i5RexJsy/BlIKPVwR5b95Wyu0/Qjnv5DjoT7YYcs/nBhKZ6zrwr8wRYS7Nebuv3OW6geh+Lu/SLrixebL3j+pcyymN9Xrv8rHIFfWehZAMBwUdlo0DECTUc17EOb2PxpVB1SWChdAzjbhb9pTDUDQhmdvECX5P9FlMKCC9+g/IIAzjELgE0DajDngMv8GQFhWDmDPjNs/y1guLh96EkAxPi8k7DIEQJCc4URlhRhA3eLKKLwkEECqpNAyTBD/P6xpjXcDiwVAFtl//cQm4z+Ibt3XKiYTQM7mCLUb3QdAoM1t8yVv7D8aLZv2Nk8UQEAJPV5nQwxAtSsfTCoE9z9TPjXLXIIWQBVanC5W9AtAYM3d7Adm9j++5mQz1FoWQBUThyaVBghAwH5muQsV7T89Q1qv82MUQJoWGOfNuBdAzrkClkmwDkDQjKq77t37Py+g0dtitsE/ZwAMTwVPEUBojepluNwBQGYbtuW+t9w/HNWIJs6MEkDTNuQUSlgEQKxktPP5TcQ/ixbLB8JjEUCwuWjXMQYCQAS/R09FkRdAowpiZjhhDkB7LmlczD/7P01iQmhhsAVAnrtTwDy84z/Z6jfQ2TgTQChOCXMnWwpAhrW3daoz8z/HYJvVPI4VQLT3ik5FcA5Angi7LOZd+z+NNVzDy5gXQBXdvVTFUA1AYNMgOeYe+T8+qHXGCwkXQKQTOKwa5AJA8gFVoEMW0T+FwzJyttIRQAEAAAD/////BwAAAP////8xAAAA/////1cBAAD/////YQkAAP////+nQQAA/////5HLAQD/////95AMAP/////B9lcAAAAAAAAAAAAAAAAAAgAAAP////8OAAAA/////2IAAAD/////rgIAAP/////CEgAA/////06DAAD/////IpcDAP/////uIRkA/////4LtrwAAAAAAAAAAAAAAAAAAAAAAAgAAAP//////////AQAAAAMAAAD//////////////////////////////////////////////////////////////////////////wEAAAAAAAAAAgAAAP///////////////wMAAAD//////////////////////////////////////////////////////////////////////////wEAAAAAAAAAAgAAAP///////////////wMAAAD//////////////////////////////////////////////////////////////////////////wEAAAAAAAAAAgAAAP///////////////wMAAAD//////////////////////////////////////////////////////////wIAAAD//////////wEAAAAAAAAA/////////////////////wMAAAD/////////////////////////////////////////////////////AwAAAP////////////////////8AAAAA/////////////////////wEAAAD///////////////8CAAAA////////////////////////////////AwAAAP////////////////////8AAAAA////////////////AgAAAAEAAAD/////////////////////////////////////////////////////AwAAAP////////////////////8AAAAA////////////////AgAAAAEAAAD/////////////////////////////////////////////////////AwAAAP////////////////////8AAAAA////////////////AgAAAAEAAAD/////////////////////////////////////////////////////AwAAAP////////////////////8AAAAA////////////////AgAAAAEAAAD/////////////////////////////////////////////////////AQAAAAIAAAD///////////////8AAAAA/////////////////////wMAAAD/////////////////////////////////////////////////////AQAAAAIAAAD///////////////8AAAAA/////////////////////wMAAAD/////////////////////////////////////////////////////AQAAAAIAAAD///////////////8AAAAA/////////////////////wMAAAD/////////////////////////////////////////////////////AQAAAAIAAAD///////////////8AAAAA/////////////////////wMAAAD///////////////////////////////8CAAAA////////////////AQAAAP////////////////////8AAAAA/////////////////////wMAAAD/////////////////////////////////////////////////////AwAAAP////////////////////8AAAAAAQAAAP//////////AgAAAP//////////////////////////////////////////////////////////AwAAAP///////////////wIAAAAAAAAAAQAAAP//////////////////////////////////////////////////////////////////////////AwAAAP///////////////wIAAAAAAAAAAQAAAP//////////////////////////////////////////////////////////////////////////AwAAAP///////////////wIAAAAAAAAAAQAAAP//////////////////////////////////////////////////////////////////////////AwAAAAEAAAD//////////wIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAgAAAAAAAAACAAAAAQAAAAEAAAACAAAAAgAAAAAAAAAFAAAABQAAAAAAAAACAAAAAgAAAAMAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAIAAAABAAAAAgAAAAIAAAACAAAAAAAAAAUAAAAGAAAAAAAAAAIAAAACAAAAAwAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAIAAAAAAAAAAgAAAAEAAAADAAAAAgAAAAIAAAAAAAAABQAAAAcAAAAAAAAAAgAAAAIAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAgAAAAAAAAACAAAAAQAAAAQAAAACAAAAAgAAAAAAAAAFAAAACAAAAAAAAAACAAAAAgAAAAMAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAACAAAAAAAAAAIAAAABAAAAAAAAAAIAAAACAAAAAAAAAAUAAAAJAAAAAAAAAAIAAAACAAAAAwAAAAUAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAIAAAACAAAAAAAAAAMAAAAOAAAAAgAAAAAAAAACAAAAAwAAAAAAAAAAAAAAAgAAAAIAAAADAAAABgAAAAAAAAAAAAAAAAAAAAAAAAALAAAAAgAAAAIAAAAAAAAAAwAAAAoAAAACAAAAAAAAAAIAAAADAAAAAQAAAAAAAAACAAAAAgAAAAMAAAAHAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAACAAAAAgAAAAAAAAADAAAACwAAAAIAAAAAAAAAAgAAAAMAAAACAAAAAAAAAAIAAAACAAAAAwAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAIAAAACAAAAAAAAAAMAAAAMAAAAAgAAAAAAAAACAAAAAwAAAAMAAAAAAAAAAgAAAAIAAAADAAAACQAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAgAAAAIAAAAAAAAAAwAAAA0AAAACAAAAAAAAAAIAAAADAAAABAAAAAAAAAACAAAAAgAAAAMAAAAKAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAACAAAAAgAAAAAAAAADAAAABgAAAAIAAAAAAAAAAgAAAAMAAAAPAAAAAAAAAAIAAAACAAAAAwAAAAsAAAAAAAAAAAAAAAAAAAAAAAAABgAAAAIAAAACAAAAAAAAAAMAAAAHAAAAAgAAAAAAAAACAAAAAwAAABAAAAAAAAAAAgAAAAIAAAADAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAgAAAAIAAAAAAAAAAwAAAAgAAAACAAAAAAAAAAIAAAADAAAAEQAAAAAAAAACAAAAAgAAAAMAAAANAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAACAAAAAgAAAAAAAAADAAAACQAAAAIAAAAAAAAAAgAAAAMAAAASAAAAAAAAAAIAAAACAAAAAwAAAA4AAAAAAAAAAAAAAAAAAAAAAAAACQAAAAIAAAACAAAAAAAAAAMAAAAFAAAAAgAAAAAAAAACAAAAAwAAABMAAAAAAAAAAgAAAAIAAAADAAAADwAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAgAAAAAAAAACAAAAAQAAABMAAAACAAAAAgAAAAAAAAAFAAAACgAAAAAAAAACAAAAAgAAAAMAAAAQAAAAAAAAAAAAAAAAAAAAAAAAABEAAAACAAAAAAAAAAIAAAABAAAADwAAAAIAAAACAAAAAAAAAAUAAAALAAAAAAAAAAIAAAACAAAAAwAAABEAAAAAAAAAAAAAAAAAAAAAAAAAEgAAAAIAAAAAAAAAAgAAAAEAAAAQAAAAAgAAAAIAAAAAAAAABQAAAAwAAAAAAAAAAgAAAAIAAAADAAAAEgAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAgAAAAAAAAACAAAAAQAAABEAAAACAAAAAgAAAAAAAAAFAAAADQAAAAAAAAACAAAAAgAAAAMAAAATAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAACAAAAAAAAAAIAAAABAAAAEgAAAAIAAAACAAAAAAAAAAUAAAAOAAAAAAAAAAIAAAACAAAAAwAAAAIAAAABAAAAAAAAAAEAAAACAAAAAAAAAAAAAAACAAAAAQAAAAAAAAABAAAAAgAAAAEAAAAAAAAAAgAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAAAAAAAAAAABQAAAAQAAAAAAAAAAQAAAAUAAAAEAAAAAAAAAAUAAAAAAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAAAAAAAAAAAAAIAAAABAAAAAAAAAAEAAAACAAAAAQAAAAAAAAACAAAAAgAAAAAAAAABAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAAAAAAAAAAABQAAAAQAAAAAAAAAAQAAAAUAAAAEAAAAAAAAAAUAAAAFAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAQAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAABAAAAAAAAAAABAAAAAAEAAAAAAAAAAAEAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAQAAAAAAAAAAAAEAAAAAAAAAAAAAOgehWlKfUEEz1zLi+JsiQa2og3wcMfVAWCbHorc0yEDi+Yn/Y6mbQJ11/mfsnG9At6bnG4UQQkBvMCQWKqUUQJVmwwswmOc/3hVgVBL3uj//qqOEOdGOPw/WDN4gnGE/H3ANkCUgND+AA8btKgAHPwTXBqJVSdo+XfRQAqsKrj4fc+zLYbSPQklEmCZHv2FCUP+uDso1NEKYtPhwphUHQptxnyFXYdpB7CddZAMmrkGAt1AxSTqBQUibBVdTsFNBSuX3MV+AJkFocv82SLf5QAqmgj7AY81A23VDSEnLoEDGEJVSeDFzQDYrqvBk70VA8U157pcRGUBWfEF+ZKbsP6phvycGBZRAJbod0OgwfkCp+L8jatBmQCjl3pGrPlFAfMWm114SOkButwtqS7UjQHQwbcjXyw1A8jnLuuyA9j9KwjL0VwHhPyotk0lcs8k/Q5PvEs9rsz+SfsOQEVqdPzUAKDojLoY/WJz/kcjCcD8YFu070FRZPyoLC2BdJEM/YOXQAuiMM0HIBz1bw3sdQdV46aaHRwZByatzjDPX8EDb3Jie8HXZQCJxj6ULP8NAUaG6uRAZrUCWdmou5/mVQLb9huRPm4BAhvoCHygZaUCuX/I3SPdSQC9/bC/1qTxAfKxsYQ6pJUCuslH+N14QQMS/cv7SvPg/Ol8maYKx4j8AAAAA/////wAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////////////////////////////wAAAAD/////AAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAA/////wAAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAP////8AAAAABQAAAAAAAAAAAAAAAAAAAAAAAAD/////BQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAA/////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////////////////////////////8AAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////AAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAABQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////////////////////////////wAAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAQAAAAAAAAABAAAAAAAAAAUAAAABAAAAAQAAAAAAAAAAAAAAAQAAAAEAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQEAAAAAAAEAAQAAAQEAAAAAAAEAAAABAAAAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAKriWFiWZfg/Y2nmTbY/8z8MHSPSqmnjv6hnn18HR3c/quJYWJZl+D/jq5TzDdzyPwwdI9KqaeO/u0kC1eFSBECq4lhYlmX4P69pJmt7c/E/NnkJi6jSBsDESFlzKkr6P33ArMz7sfY/o2q2uqM08D+oZ59fB0d3PzEqCi3qrvK/kmm4ANp49D+4wS2wzhzvP9WJvyAnx+E/upcY75RVx7+95t+9y0T1P9L18g1caO0/k6CkRyVzAEBf99+e/GjxP6QMsuuLQ/U/PlP4Qr8q7j8Mb/GO2GMCwLl2K/DQIghAePiwytEp9D9UHrsuI/nqPzjMedJ+yuy/k6xgf58n/L+XoQtn22DzP2lzCnsYk+s/JhUSDI4P8z+8lFcBhgTcPxOqKRxEX/M/89MEdoPQ6j8OKQaXDob7vzWwNvblgAPAzGkxMcl88j9Nm4okPkbpP0vI89vxSgRAdac2Z6W2/T+6UFOMC3zyP/+2XEF3hug/QqhELwGKCMAwdlQerEoEQFcr/B+VnvE/hB1hfFzT5j8wdsE/Da64P0hIvnF/sOC/KH/hrXUg8T9bI5OQHaLlP+mYzla7td6/CtKG6iOm8b8FW3TV8oXwP8ORhtNuJ+c/q8JrTMz/AcC8PaUl+PUFwAXv9rkMT/A/m+sAswr15D+7hk/O3yvkP6c/yVsOHKI/qqAX9idJ8D/8hNz1KNPiP7xSXh3Ggvg/epbkiKr57T/23/LB1GLvP4GTTeNZi+M/W4TqlTheBcDupZgIdYUIQGwlcW3YZO8/tQvDXQ3H4j8Bt+sf9DkAQMdFie+nNvg/Z5Uh1wDX7j9h5X2d4KjhPxMJ1ZVT4Pa/evqB8xB//7+W183U9QLsPwzNxsC7AOA/af/LqCnK/r/lPceQ0FQDwHoY0nYIW+w/bHNSHrTg4D/DFcMAdabuv2sz5Ojhnve/FvLf01HN6z/tEDL2Hz/gP0bBv0KUhPA/pd7sEnMc4D8EGon4Lo7sP5NVbYtSON8/DAMC50odBkB+Z2J8MGYCQIhlM1gubOo/FssiPwWy4D8OIlGqRnkCQAd1vopp6f4/QS1keLLK6T9rfoBuT7LZP3KQbH5ugwjAjqVPXTmbBUBL/JxcqR3qP3oSeovuktg/Y6pRhJmqy7+0kwuU0Yjmv2wvsfFmQ+g/R98lJFqQ2T/IGb5gjLkCwK3mNff3kQbAqDznPFM86T+iiP0FfsvYP7fzKG6Mls0/h7+at2btzL8tsUTgk+LmP/YEIrTDINU/WmwKoVjA5L9aC02r6FHxvzzFCT/Qg+Y/nx0V97en0j8+1toJOm77P1kZ7h8KjfQ/GBbbqxgk5j9RGXM79G/SP+beHsWmweQ/9REi4eX0xD/V9s+kmMHkP+pb9yNs09A/c5ERjVDTAECqEr3OBCH7P14ILfMECOU/piRx4P8P0j+JYU//bfL0Pw62fw28B+w/l5YW2Ga45D9+CyKRbenOP5cH6fHy1/S/o/egk03++r91nTYRL/bjP3fHN6OJVdA/7xXQh1XLBcAB3g6tBdUIQKW2KnGYjeQ/SqIpagclyz8F9P3YgNL6v9H6NBsZ8QDAW2k5L5Qs4z/0axa1l6zLP1GE65Mu4wNAwfX+BYmWAEBBgJP90M3hP6/03qhPLdA/zqo5bJz2778/ESlPCTn1v7JkhGyvzuE/DM7sj5twwz/6xbXLavYGQH29RFRGkgNA7bOXVSJ54T9fEhTHO/TDP+8t+HMOiwDAxa0SbGTtA8Atii7y0mLgP4cecHFB3sM/uPUpyv+K7j8nktD1/WvhP2cWmi772d8/Fj7uU9kEvD8oKOESLzKmvwSdCqrHdNu/XCluGsvI3T929OW5md+uP9dP6rXcZNq/gXM+ggzL6b+eKjsPgJncP6i1e9aVu7E/2CnPNJyD1D/DnyGgSe+xvy8k7g9bp9s/nYmLvHn1sz9cFOwApH8IwGa6Mjy9cgZAJr95SiSW2z8rCkhOFvqdP3SIKmO/UwPAEy0zkN7bBsCds8Hg/13YP1zv413hVGi/FVtqixSn6L9XAPQGul3yv7SGu2BoCNk/n94bv7Maj79p13T6X9z3P45MPCW3WvI/rU/8/LRj1T9cgR6SXd+ZPymL2DstbPI/8s/pAkIz6z/fmoB+8efYPz2XyfWgYaa/6wys72AW/j8LZImhgrf3P729Zla/n9U/ySB8B3PBqL8O2nhevvbxv17+5A+n6fe/YrGIqEGB1T+wCEGbkhaxv989QHVE5wFAzd12PTu3/T9AHUPZY2DUP3SQDST0zq2/JCxAlIoj5T+Mhe1IJkrQP/cRpl8QhtU/amc4seFts79khiUSVaz3vxYfWtjPwf2/CHscxQqD0j/ctUBQ9my3v0POnFiyXv2/pjjn2Ju/AcDk45DwBhPRP/GjwlCrv7m/aT2ciwolBsAQOzHr/wUJQCzpq5UYvtI/gDCf3SlCwb+4i7S+mukEQBDA1f8mowFA2utnRN3KyT9T+9EYAVG6v9/IVZ0enrE/7NbRtdGfzr/8y8GpRz7LP3U0vTSk18e/JzHEcwiBB0AGm8Q7AJkEQNLciyt4Esk/gLou5zoQxr+RrOfM91oBwEzd36KybgTAgLou5zoQxj/S3IsreBLJv1gCch0OHO8/FD+RxSLN4j91NL00pNfHP/zLwalHPsu/nL7/By4Pyr8tSP5h7CPiv1P70RgBUbo/2utnRN3Kyb/KfllfCpUIwLkP5zj+NwdAgDCf3SlCwT8s6auVGL7Sv2aFPlaC4eC/XrS5UVH77b/xo8JQq7+5P+TjkPAGE9G/Q30/RYbn1z8FF/ISafuLv9y1QFD2bLc/CHscxQqD0r/fi+tPROX0P6vRc+19ie0/amc4seFtsz/3EaZfEIbVv77TYpahl/o/DDsu0CaC9D90kA0k9M6tP0AdQ9ljYNS/CCI0rxjZA8BgfCaLthgHwLAIQZuSFrE/YrGIqEGB1b8kvQ982+rsv4J8EWu7jPS/ySB8B3PBqD+9vWZWv5/VvwrAByWcJgBAxFujmE9a+j89l8n1oGGmP9+agH7x59i/N03cuJUt9L8X9v4GdIz6v1yBHpJd35m/rU/8/LRj1b8mz69sydf/vyu5idMqVQLAn94bv7Majz8AhrtgaAjZv+aCE66WZ/q/lA1Mgz/p/79c7+Nd4VRoP52zweD/Xdi/TJZpMTb4AkDLWZShPOb/PysKSE4W+p2/Jr95SiSW27/PkmbE7zjnP6UAiCDmMNI/nYmLvHn1s78vJO4PW6fbv5MWA2vqSrQ/V5WLwPB51b+otXvWlbuxv54qOw+Amdy/1keqzYeRBsApIEMHgZIIQHb05bmZ366/XCluGsvI3b8W44a9X9UFQEeQtDM4rwJAFj7uU9kEvL9nFpou+9nfv3Co+JcyyQhAcdkCX2KzBUCHHnBxQd7Dvy2KLvLSYuC/o6+5YTt/AcCHCNDW+8YEwF8SFMc79MO/7bOXVSJ54b9E/pfA2S3xPzD9xaBb0uQ/DM7sj5tww7+yZIRsr87hv7c4c0SEXNG/Tr79/9M+5r+v9N6oTy3Qv5uAk/3QzeG/XcI1OVQkAUAQSV9Z7Qr9P/RrFrWXrMu/W2k5L5Qs479Zo2IBM/vkv6FuipzkFvG/SqIpagcly7+ltipxmI3kv0pmis91cfc/gWQecsRh8D93xzejiVXQv3WdNhEv9uO/D7mgYy612j+PyVPNaT2jv34LIpFt6c6/l5YW2Ga45L+LUp+2A2z9P39i5xSpRfc/piRx4P8P0r9eCC3zBAjlv5n4OKmIUf2/jj/kUAwgAsDqW/cjbNPQv9X2z6SYweS/aTdljlWd8L94R8vZ8SL3v1EZczv0b9K/GBbbqxgk5r9XdfyikfEDwPILMvas0gfAnx0V97en0r88xQk/0IPmvxGErZ681fa/9kCaiOy2/b/2BCK0wyDVvy2xROCT4ua/+5EBLOXxA0B7p53+BnkAQKKI/QV+y9i/qDznPFM86b/snWGNkkgHwC+ByugkUwdAR98lJFqQ2b9sL7HxZkPovyJNGM67oek/HzNy6BqA1D96EnqL7pLYv0v8nFypHeq/axL/u1FnB0AkSEHvxn8DQGt+gG5Pstm/QS1keLLK6b/Sk/O6mtGzPxU8pLcPNty/FssiPwWy4L+IZTNYLmzqvw4szKfSouq/G+XJHY1a87+TVW2LUjjfvwQaifgujuy/3VARaoMl2L9NFodfK+/qv+0QMvYfP+C/FvLf01HN67+ETOQysd8AwH71iI/eGgXAbHNSHrTg4L96GNJ2CFvsv6BnExReeAFA5CakvxSl+j8MzcbAuwDgv5bXzdT1Auy/uVq8/8x58z+uvPMNqzTnP2HlfZ3gqOG/Z5Uh1wDX7r8PUbMSo2P7P9VfBrXlxPI/tQvDXQ3H4r9sJXFt2GTvvyDssGgO0PG/WxT/uE4N+r+Bk03jWYvjv/bf8sHUYu+/rUXN8hUe3j9m5HB1yZCzv/yE3PUo0+K/qqAX9idJ8L9mByqLMMH5v4kHC7KQowHAm+sAswr15L8F7/a5DE/wv2JLsGADFwTAKQjVGovZCMDDkYbTbifnvwVbdNXyhfC/malhH7yI7D+oevd0GWDZP1sjk5AdouW/KH/hrXUg8b8KWmrpQ0sFQAzEAF/pTgBAhB1hfFzT5r9XK/wflZ7xv18hRuqKXAjA/5rUd9v1BED/tlxBd4bov7pQU4wLfPK/4pnwn0T/sj/c277XPF3jv02biiQ+Rum/zGkxMcl88r8Yk0HhJVzjv62yUUFRjfS/89MEdoPQ6r8TqikcRF/zvxQxghHovfY/cfM1eFWE5j9pcwp7GJPrv5ehC2fbYPO/KUV2nGg0/795OhmUaqEFwFQeuy4j+eq/ePiwytEp9L8DuqWfW+8BQLytJylXHPY/PlP4Qr8q7r+kDLLri0P1vxT4ShWL+Oo/DMsWg0zlv7/S9fINXGjtv73m373LRPW/+xg/Gaxd8b94MdQEfW0AwLjBLbDOHO+/kmm4ANp49L+cShSMMbAEwKyjUgWirAdAo2q2uqM08L99wKzM+7H2v3RdlNBXFgnA8S9+ewyV/z+vaSZre3Pxv6riWFiWZfi/2J7VSZZ60j+LES81zPn3v+OrlPMN3PK/quJYWJZl+L/OZbufkEcEQLCNB/1lPOO/Y2nmTbY/87+q4lhYlmX4v7CNB/1lPOO/zmW7n5BHBEBwKD1Aa57LP/XsSsw7RbU/PMDPJGsfoD/TqningGKIPzFtCLYmb3I/qYfrJr7eWz9pQmleXRFFP0rWlJkA2i8/pCvcttgTGD9Dt8IWbjMCPyCG4GRlhOs+1JI2GhDN1D7ns8cGvXK/Pi8m8UTJxac+hNTfA2z4kT7GI8kjLyt7Pv//////HwAI//////8zEAj/////fzIgCP////9vMjAI/////2MyQAj///8/YjJQCP///zdiMmAI////M2IycAj//78zYjKACP//qzNiMpAI/3+rM2IyoAj/D6szYjKwCP8DqzNiMsAIvwOrM2Iy0AifA6szYjLgCJkDqzNiMvAI//////8/Dwj//////ysfCP////9/KS8I/////z8pPwj/////OSlPCP///z84KV8I////Dzgpbwj///8OOCl/CP//Hw44KY8I//8PDjgpnwj/fw0OOCmvCP8PDQ44Kb8I/w0NDjgpzwj/DA0OOCnfCMcMDQ44Ke8IxAwNDjgp/wgHAAAABwAAAAEAAAACAAAABAAAAAMAAAAAAAAAAAAAAAcAAAADAAAAAQAAAAIAAAAFAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAAAgAAAAEAAAADAAAADgAAAAYAAAALAAAAAgAAAAcAAAABAAAAGAAAAAUAAAAKAAAAAQAAAAYAAAAAAAAAJgAAAAcAAAAMAAAAAwAAAAgAAAACAAAAMQAAAAkAAAAOAAAAAAAAAAUAAAAEAAAAOgAAAAgAAAANAAAABAAAAAkAAAADAAAAPwAAAAsAAAAGAAAADwAAAAoAAAAQAAAASAAAAAwAAAAHAAAAEAAAAAsAAAARAAAAUwAAAAoAAAAFAAAAEwAAAA4AAAAPAAAAYQAAAA0AAAAIAAAAEQAAAAwAAAASAAAAawAAAA4AAAAJAAAAEgAAAA0AAAATAAAAdQAAAA8AAAATAAAAEQAAABIAAAAQAAAABgAAAAIAAAADAAAABQAAAAQAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAMAAAABAAAABQAAAAQAAAAAAAAAAAAAAAcAAAAFAAAAAwAAAAQAAAABAAAAAAAAAAIAAAAAAAAAAgAAAAMAAAABAAAABQAAAAQAAAAGAAAAAAAAAAAAAAAYLURU+yH5PxgtRFT7Ifm/GC1EVPshCUAYLURU+yEJwGFsZ29zLmMAaDNOZWlnaGJvclJvdGF0aW9ucwBjZWxsc1RvTXVsdGlQb2x5LmMAY2VsbFRvRWRnZUFyY3MAAAEDAgQABAMFAQJjYW5jZWxBcmNQYWlycwBjcmVhdGVTb3J0YWJsZUxvb3AAZGlyZWN0ZWRFZGdlLmMAZGlyZWN0ZWRFZGdlVG9Cb3VuZGFyeQBhZGphY2VudEZhY2VEaXJbdG1wRmlqay5mYWNlXVtmaWprLmZhY2VdID09IEtJAGZhY2VpamsuYwBfZmFjZUlqa1BlbnRUb0NlbGxCb3VuZGFyeQBhZGphY2VudEZhY2VEaXJbY2VudGVySUpLLmZhY2VdW2ZhY2UyXSA9PSBLSQBfZmFjZUlqa1RvQ2VsbEJvdW5kYXJ5AGgzSW5kZXguYwBjb21wYWN0Q2VsbHMAdmVjM1RvQ2VsbABjZWxsVG9DaGlsZFBvcwB2YWxpZGF0ZUNoaWxkUG9zAHJldkRpciAhPSBJTlZBTElEX0RJR0lUAGxvY2FsaWouYwBjZWxsVG9Mb2NhbElqawBiYXNlQ2VsbCAhPSBvcmlnaW5CYXNlQ2VsbAAhKG9yaWdpbk9uUGVudCAmJiBpbmRleE9uUGVudCkAYmFzZUNlbGwgPT0gb3JpZ2luQmFzZUNlbGwALi4vaW5jbHVkZS9jb29yZGlqay5oAF91cEFwN0NoZWNrZWQAX3VwQXA3ckNoZWNrZWQAYmFzZUNlbGwgIT0gSU5WQUxJRF9CQVNFX0NFTEwAbG9jYWxJamtUb0NlbGwAIV9pc0Jhc2VDZWxsUGVudGFnb24oYmFzZUNlbGwpAGJhc2VDZWxsUm90YXRpb25zID49IDAAZ3JpZFBhdGhDZWxsc0ludGVycG9sYXRlAHBvbHlmaWxsLmMAaXRlclN0ZXBQb2x5Z29uQ29tcGFjdAAwAHZlcnRleC5jAHZlcnRleFJvdGF0aW9ucwBjZWxsVG9WZXJ0ZXg=";function H(e){return e}function q(e){return e.replace(/\b__Z[\w\d_]+/g,function(e){return e===e?e:e+" ["+e+"]"})}function Q(){var e=new Error;if(!e.stack){try{throw new Error(0)}catch(Gt){e=Gt}if(!e.stack)return"(no stack trace available)"}return e.stack.toString()}function K(){return h.length}function W(e){try{var t=new ArrayBuffer(e);if(t.byteLength!=e)return;return new Int8Array(t).set(h),X(t),w(t),1}catch(Gt){}}var $="function"==typeof atob?atob:function(e){var t,n,r,i,a,o,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",A="",l=0;e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{t=s.indexOf(e.charAt(l++))<<2|(i=s.indexOf(e.charAt(l++)))>>4,n=(15&i)<<4|(a=s.indexOf(e.charAt(l++)))>>2,r=(3&a)<<6|(o=s.indexOf(e.charAt(l++))),A+=String.fromCharCode(t),64!==a&&(A+=String.fromCharCode(n)),64!==o&&(A+=String.fromCharCode(r))}while(l<e.length);return A};function J(e){if(G(e))return function(e){try{for(var t=$(e),n=new Uint8Array(t.length),r=0;r<t.length;++r)n[r]=t.charCodeAt(r);return n}catch(i){throw new Error("Converting base64 string to bytes failed.")}}(e.slice(z.length))}var Y=function(e,t,n){var r=new e.Int8Array(n),i=new e.Int32Array(n);new e.Uint8Array(n),new e.Float32Array(n);var a=new e.Float64Array(n),o=0|t.o,s=0|t.p,A=e.Math.floor,l=e.Math.abs,c=e.Math.sqrt,u=e.Math.cos,f=e.Math.sin,d=e.Math.tan,h=e.Math.acos,p=e.Math.asin,m=e.Math.atan,g=e.Math.atan2,b=e.Math.ceil,v=e.Math.imul,y=e.Math.min,x=e.Math.max,_=e.Math.clz32,w=t.a,T=t.b,S=t.c,M=t.d,E=t.e,C=t.f,I=t.g,R=t.h,P=t.i,N=28416;function k(e,t,n,r){return 0|L(e|=0,t|=0,n|=0,r|=0,0)}function L(e,t,n,r,a){var o,s=0,A=0,l=0,c=0;if(o=N,N=N+16|0,A=o,!(0|B(e|=0,t|=0,n|=0,r|=0,a|=0)))return N=o,0|(r=0);do{if((0|n)>=0){if((0|n)>13780509){if(0|(s=0|We(15,A)))break;A=0|i[(l=A)>>2],l=0|i[l+4>>2]}else c=0|Ot(0|n,0|(s=((0|n)<0)<<31>>31),3,0),l=0|S(),s=0|Pt(0|n,0|s,1,0),s=0|Pt(0|(s=0|Ot(0|c,0|l,0|s,0|S())),0|S(),1,0),l=0|S(),i[A>>2]=s,i[A+4>>2]=l,A=s;if(Wt(0|r,0,A<<3),0|a){Wt(0|a,0,A<<2),s=0|O(e,t,n,r,a,A,l,0);break}(s=0|Ct(A,4))?(c=0|O(e,t,n,r,s,A,l,0),Et(s),s=c):s=13}else s=2}while(0);return N=o,0|(c=s)}function B(e,t,n,r,a){e|=0,t|=0,n|=0,r|=0,a|=0;var o,s,A=0,l=0,c=0,u=0,f=0,d=0,h=0,p=0,m=0;if(s=N,N=N+16|0,m=s+8|0,i[(p=o=s)>>2]=e,i[p+4>>2]=t,(0|n)<0)return N=s,0|(m=2);if(i[(A=r)>>2]=e,i[A+4>>2]=t,(A=!!(0|a))&&(i[a>>2]=0),0|Se(e,t))return N=s,0|(m=9);i[m>>2]=0;e:do{if((0|n)>=1)if(A)for(d=1,f=0,h=0,p=1,A=e;;){if(!(f|h)){if(0|(A=0|F(A,t,4,m,o)))break e;if(0|Se(A=0|i[(t=o)>>2],t=0|i[t+4>>2])){A=9;break e}}if(0|(A=0|F(A,t,0|i[26864+(h<<2)>>2],m,o)))break e;if(A=0|i[(t=o)>>2],t=0|i[t+4>>2],i[(e=r+(d<<3)|0)>>2]=A,i[e+4>>2]=t,i[a+(d<<2)>>2]=p,l=(0|(e=f+1|0))==(0|p),u=6==(0|(c=h+1|0)),0|Se(A,t)){A=9;break e}if((0|(p=p+(u&l&1)|0))>(0|n)){A=0;break}d=d+1|0,f=l?0:e,h=l?u?0:c:h}else for(d=1,f=0,h=0,p=1,A=e;;){if(!(f|h)){if(0|(A=0|F(A,t,4,m,o)))break e;if(0|Se(A=0|i[(t=o)>>2],t=0|i[t+4>>2])){A=9;break e}}if(0|(A=0|F(A,t,0|i[26864+(h<<2)>>2],m,o)))break e;if(A=0|i[(t=o)>>2],t=0|i[t+4>>2],i[(e=r+(d<<3)|0)>>2]=A,i[e+4>>2]=t,l=(0|(e=f+1|0))==(0|p),u=6==(0|(c=h+1|0)),0|Se(A,t)){A=9;break e}if((0|(p=p+(u&l&1)|0))>(0|n)){A=0;break}d=d+1|0,f=l?0:e,h=l?u?0:c:h}else A=0}while(0);return N=s,0|(m=A)}function O(e,t,n,r,a,o,s,A){n|=0,r|=0,a|=0,A|=0;var l,c,u,f=0,d=0,h=0,p=0,m=0,g=0,b=0;if(u=N,N=N+16|0,l=u+8|0,c=u,f=0|Dt(0|(e|=0),0|(t|=0),0|(o|=0),0|(s|=0)),h=0|S(),!(!(0|(b=0|i[(g=p=r+(f<<3)|0)>>2]))&!(0|(g=0|i[g+4>>2]))|(d=(0|b)==(0|e)&(0|g)==(0|t))))do{f=0|Ft(0|(f=0|Pt(0|f,0|h,1,0)),0|S(),0|o,0|s),h=0|S(),d=(0|(g=0|i[(b=p=r+(f<<3)|0)>>2]))==(0|e)&(0|(b=0|i[b+4>>2]))==(0|t)}while(!(!(0|g)&!(0|b)|d));if(f=a+(f<<2)|0,d&&(0|i[f>>2])<=(0|A))return N=u,0|(b=0);if(i[(b=p)>>2]=e,i[b+4>>2]=t,i[f>>2]=A,(0|A)>=(0|n))return N=u,0|(b=0);switch(d=A+1|0,i[l>>2]=0,0|(f=0|F(e,t,2,l,c))){case 9:m=9;break;case 0:(f=0|O(0|i[(f=c)>>2],0|i[f+4>>2],n,r,a,o,s,d))||(m=9)}e:do{if(9==(0|m)){switch(i[l>>2]=0,0|(f=0|F(e,t,3,l,c))){case 9:break;case 0:if(0|(f=0|O(0|i[(f=c)>>2],0|i[f+4>>2],n,r,a,o,s,d)))break e;break;default:break e}switch(i[l>>2]=0,0|(f=0|F(e,t,1,l,c))){case 9:break;case 0:if(0|(f=0|O(0|i[(f=c)>>2],0|i[f+4>>2],n,r,a,o,s,d)))break e;break;default:break e}switch(i[l>>2]=0,0|(f=0|F(e,t,5,l,c))){case 9:break;case 0:if(0|(f=0|O(0|i[(f=c)>>2],0|i[f+4>>2],n,r,a,o,s,d)))break e;break;default:break e}switch(i[l>>2]=0,0|(f=0|F(e,t,4,l,c))){case 9:break;case 0:if(0|(f=0|O(0|i[(f=c)>>2],0|i[f+4>>2],n,r,a,o,s,d)))break e;break;default:break e}switch(i[l>>2]=0,0|(f=0|F(e,t,6,l,c))){case 9:break;case 0:if(0|(f=0|O(0|i[(f=c)>>2],0|i[f+4>>2],n,r,a,o,s,d)))break e;break;default:break e}return N=u,0|(b=0)}}while(0);return N=u,0|(b=f)}function F(e,t,n,r,a){e|=0,t|=0,a|=0;var o,s,A,l=0,c=0,u=0,f=0,d=0,h=0;if((n|=0)>>>0>6)return 0|(a=1);c=(0|i[(r|=0)>>2])%6|0,i[r>>2]=c;e:do{if((0|c)>0)for(l=0;;){switch(0|n){case 1:n=5;break;case 5:n=4;break;case 4:n=6;break;case 6:n=2;break;case 2:n=3;break;case 3:n=1}if((0|(l=l+1|0))==(0|c))break e}}while(0);if(A=0|Vt(0|e,0|t,45),S(),(s=127&A)>>>0>121)return 0|(a=5);o=0|Ce(e,t),l=0|Vt(0|e,0|t,52),S(),l&=15;e:do{if(l){for(;;){if(u=0|Vt(0|e,0|t,0|(c=3*(15-l|0)|0)),S(),7==(0|(u&=7))){t=5;break}if(h=!(0|Le(l)),l=l+-1|0,d=0|jt(7,0,0|c),t&=~S(),e=0|jt(0|i[(h?432:16)+(28*u|0)+(n<<2)>>2],0,0|c)|e&~d,t|=c=0|S(),!(n=0|i[(h?640:224)+(28*u|0)+(n<<2)>>2])){n=0;break e}if(!l){f=15;break e}}return 0|t}f=15}while(0);15==(0|f)&&(e|=0|jt(0|(h=0|i[848+(28*s|0)+(n<<2)>>2]),0,45),t=S()|-1040385&t,n=0|i[4272+(28*s|0)+(n<<2)>>2],127&~h||(h=0|jt(0|i[848+(28*s|0)+20>>2],0,45),t=S()|-1040385&t,n=0|i[4272+(28*s|0)+20>>2],e=0|Re(h|e,t),t=0|S(),i[r>>2]=1+(0|i[r>>2]))),u=0|Vt(0|e,0|t,45),S(),u&=127;e:do{if(0|G(u)){t:do{if(1==(0|Ce(e,t))){if((0|s)!=(0|u)){if(0|K(u,0|i[7696+(28*s|0)>>2])){e=0|Ne(e,t),c=1,t=0|S();break}M(27634,26928,533,26936)}switch(0|o){case 3:e=0|Re(e,t),t=0|S(),i[r>>2]=1+(0|i[r>>2]),c=0;break t;case 5:e=0|Ne(e,t),t=0|S(),i[r>>2]=5+(0|i[r>>2]),c=0;break t;case 0:return 0|(h=9);default:return 0|(h=1)}}else c=0}while(0);if((0|n)>0){l=0;do{e=0|Ie(e,t),t=0|S(),l=l+1|0}while((0|l)!=(0|n))}if((0|s)!=(0|u)){if(!(0|H(u))){if(!!(0|c)|5!=(0|Ce(e,t)))break;i[r>>2]=1+(0|i[r>>2]);break}switch(127&A){case 8:case 118:break e}3!=(0|Ce(e,t))&&(i[r>>2]=1+(0|i[r>>2]))}}else if((0|n)>0){l=0;do{e=0|Re(e,t),t=0|S(),l=l+1|0}while((0|l)!=(0|n))}}while(0);return i[r>>2]=((0|i[r>>2])+n|0)%6|0,i[(h=a)>>2]=e,i[h+4>>2]=t,0|(h=0)}function D(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a,o,s=0,A=0,l=0,c=0,u=0,f=0,d=0,h=0,p=0;if(o=N,N=N+16|0,p=o+8|0,i[(h=a=o)>>2]=e,i[h+4>>2]=t,(0|n)<0)return N=o,0|(p=2);if(!n)return i[(p=r)>>2]=e,i[p+4>>2]=t,N=o,0|(p=0);i[p>>2]=0;e:do{if(0|Se(e,t))e=9;else{s=0,h=e;do{if(0|(e=0|F(h,t,4,p,a)))break e;if(s=s+1|0,0|Se(h=0|i[(t=a)>>2],t=0|i[t+4>>2])){e=9;break e}}while((0|s)<(0|n));i[(d=r)>>2]=h,i[d+4>>2]=t,d=n+-1|0,f=0,e=1;do{if(s=26864+(f<<2)|0,5==(0|f))for(l=0|i[s>>2],A=0,s=e;;){if(0|(e=0|F(0|i[(e=a)>>2],0|i[e+4>>2],l,p,a)))break e;if((0|A)!=(0|d)){if(c=0|i[(u=a)>>2],u=0|i[u+4>>2],i[(e=r+(s<<3)|0)>>2]=c,i[e+4>>2]=u,0|Se(c,u)){e=9;break e}e=s+1|0}else e=s;if((0|(A=A+1|0))>=(0|n))break;s=e}else for(l=a,u=0|i[s>>2],c=0,s=e,A=0|i[l>>2],l=0|i[l+4>>2];;){if(0|(e=0|F(A,l,u,p,a)))break e;if(A=0|i[(l=a)>>2],l=0|i[l+4>>2],i[(e=r+(s<<3)|0)>>2]=A,i[e+4>>2]=l,e=s+1|0,0|Se(A,l)){e=9;break e}if((0|(c=c+1|0))>=(0|n))break;s=e}f=f+1|0}while(f>>>0<6);e=(0|h)==(0|i[(e=a)>>2])&&(0|t)==(0|i[e+4>>2])?0:9}}while(0);return N=o,0|(p=e)}function U(e,t,n,r){e|=0,t|=0,r|=0;var a,o=0,s=0,A=0,l=0,c=0,u=0,f=0,d=0;if(a=N,N=N+16|0,A=a,!(n|=0))return i[r>>2]=e,i[r+4>>2]=t,N=a,0|(r=0);do{if((0|n)>=0){if((0|n)>13780509){if(0|(o=0|We(15,A)))break;o=0|i[(s=A)>>2],s=0|i[s+4>>2]}else f=0|Ot(0|n,0|(o=((0|n)<0)<<31>>31),3,0),s=0|S(),o=0|Pt(0|n,0|o,1,0),o=0|Pt(0|(o=0|Ot(0|f,0|s,0|o,0|S())),0|S(),1,0),s=0|S(),i[(f=A)>>2]=o,i[f+4>>2]=s;if(u=0|Ct(o,8)){if(!(f=0|Ct(o,4))){Et(u),o=13;break}if(0|(o=0|O(e,t,n,u,f,o,s,0))){Et(u),Et(f);break}if(t=0|i[A>>2],(0|(A=0|i[A+4>>2]))>0|!(0|A)&t>>>0>0){o=0,l=0,c=0;do{!(0|(s=0|i[(e=u+(l<<3)|0)>>2]))&!(0|(e=0|i[e+4>>2]))||(0|i[f+(l<<2)>>2])!=(0|n)||(i[(d=r+(o<<3)|0)>>2]=s,i[d+4>>2]=e,o=o+1|0),l=0|Pt(0|l,0|c,1,0),c=0|S()}while((0|c)<(0|A)|(0|c)==(0|A)&l>>>0<t>>>0)}Et(u),Et(f),o=0}else o=13}else o=2}while(0);return N=a,0|(d=o)}function V(e,t,n,r){n|=0,r|=0;var a,o,s,A=0,l=0;for(s=N,N=N+16|0,a=s,o=s+8|0,A=(A=!(0|Se(e|=0,t|=0)))?1:2;;){if(i[o>>2]=0,!(0|F(e,t,A,o,a))&((0|i[(l=a)>>2])==(0|n)?(0|i[l+4>>2])==(0|r):0)){e=4;break}if((A=A+1|0)>>>0>=7){A=7,e=4;break}}return 4==(0|e)?(N=s,0|A):0}function j(e,t,n,r,o,s,A){t|=0,n|=0,r|=0,o|=0,s|=0,A|=0;var l,c,u,f,d,h,p,m,g,b,v=0,y=0,x=0,_=0,w=0,T=0,M=0,E=0,C=0,I=0,R=0,P=0,k=0,L=0,B=0,O=0,F=0,D=0,U=0;if(b=N,N=N+64|0,p=b+48|0,m=b+32|0,g=b+24|0,l=b+8|0,c=b,(0|(y=0|i[(e|=0)>>2]))<=0)return N=b,0|(B=0);for(u=e+4|0,f=p+8|0,d=m+8|0,h=l+8|0,v=0,k=0;;){P=(x=0|i[u>>2])+(k<<4)|0,i[p>>2]=i[P>>2],i[p+4>>2]=i[P+4>>2],i[p+8>>2]=i[P+8>>2],i[p+12>>2]=i[P+12>>2],(0|k)==(y+-1|0)?(i[m>>2]=i[x>>2],i[m+4>>2]=i[x+4>>2],i[m+8>>2]=i[x+8>>2],i[m+12>>2]=i[x+12>>2]):(P=x+(k+1<<4)|0,i[m>>2]=i[P>>2],i[m+4>>2]=i[P+4>>2],i[m+8>>2]=i[P+8>>2],i[m+12>>2]=i[P+12>>2]),y=0|re(p,m,r,g);e:do{if(y)x=0,v=y;else if(x=0|i[(y=g)>>2],(0|(y=0|i[y+4>>2]))>0|!(0|y)&x>>>0>0){R=0,P=0;t:for(;;){if(F=1/(+(x>>>0)+4294967296*+(0|y)),U=+a[p>>3],D=+((y=0|Nt(0|x,0|y,0|R,0|P))>>>0)+4294967296*+(0|S()),O=+(R>>>0)+4294967296*+(0|P),a[l>>3]=F*(U*D)+F*(+a[m>>3]*O),a[h>>3]=F*(+a[f>>3]*D)+F*(+a[d>>3]*O),0|(y=0|Be(l,r,c))){v=y;break}T=0|Dt(0|(C=0|i[(I=c)>>2]),0|(I=0|i[I+4>>2]),0|t,0|n),_=0|S(),x=0|i[(w=y=A+(T<<3)|0)>>2],w=0|i[w+4>>2];n:do{if(!(0|x)&!(0|w))L=y,B=16;else for(M=0,E=0;;){if((0|M)>(0|n)|(0|M)==(0|n)&E>>>0>t>>>0){v=1;break t}if((0|x)==(0|C)&(0|w)==(0|I))break n;if(T=0|Ft(0|(y=0|Pt(0|T,0|_,1,0)),0|S(),0|t,0|n),_=0|S(),E=0|Pt(0|E,0|M,1,0),M=0|S(),!(0|(x=0|i[(w=y=A+(T<<3)|0)>>2]))&!(0|(w=0|i[w+4>>2]))){L=y,B=16;break}}}while(0);if(16!=(0|B)||(B=0,!(0|C)&!(0|I))||(i[(E=L)>>2]=C,i[E+4>>2]=I,E=s+(i[o>>2]<<3)|0,i[E>>2]=C,i[E+4>>2]=I,E=0|Pt(0|i[(E=o)>>2],0|i[E+4>>2],1,0),C=0|S(),i[(I=o)>>2]=E,i[I+4>>2]=C),R=0|Pt(0|R,0|P,1,0),P=0|S(),x=0|i[(y=g)>>2],!((0|(y=0|i[y+4>>2]))>(0|P)|(0|y)==(0|P)&x>>>0>R>>>0)){x=1;break e}}x=0}else x=1}while(0);if(k=k+1|0,!x){B=21;break}if((0|k)>=(0|(y=0|i[e>>2]))){v=0,B=21;break}}return 21==(0|B)?(N=b,0|v):0}function z(e,t){t|=0;var n,r=0,o=0,s=0,A=0,l=0,c=0,d=0,h=0,p=0;if((0|(A=0|i[(e|=0)>>2]))<=0)return o=(s=0)+(o=12.566370614359172-(o=0)),s=(A=s<0)?o:s,a[t>>3]=s,0;if(n=0|i[e+4>>2],e=1!=(0|A)&1,l=.5*+a[n>>3]+.7853981633974483,s=.5*+a[n+(e<<4)>>3]+.7853981633974483,r=+f(+l)*+f(+s),o=+a[n+(e<<4)+8>>3]-+a[n+8>>3],r=(o=(r=-2*+g(+ +f(+o)*r,+(+u(+l)*+u(+s)+ +u(+o)*r)))+0)-r,1==(0|A))return s=(l=o)+(s=12.566370614359172-(s=r)),l=(A=l<0)?s:l,a[t>>3]=l,0;for(e=1,s=o;h=e,p=(0|(e=e+1|0))%(0|A)|0,d=.5*+a[n+(h<<4)>>3]+.7853981633974483,c=.5*+a[n+(p<<4)>>3]+.7853981633974483,o=+f(+d)*+f(+c),l=+a[n+(p<<4)+8>>3]-+a[n+(h<<4)+8>>3],r=(o=s+(r=-2*+g(+ +f(+l)*o,+(+u(+d)*+u(+c)+ +u(+l)*o))-r))-s-r,!((0|e)>=(0|A));)s=o;return d=o+(d=12.566370614359172-r),d=(p=o<0)?d:o,a[t>>3]=d,0}function G(e){return(e|=0)>>>0>121?0|(e=0):0|(e=0|i[7696+(28*e|0)+16>>2])}function H(e){return 4==(0|(e|=0))|117==(0|e)|0}function q(e){return 0|i[11120+(216*(0|i[(e|=0)>>2])|0)+(72*(0|i[e+4>>2])|0)+(24*(0|i[e+8>>2])|0)+(i[e+12>>2]<<3)>>2]}function Q(e){return 0|i[11120+(216*(0|i[(e|=0)>>2])|0)+(72*(0|i[e+4>>2])|0)+(24*(0|i[e+8>>2])|0)+(i[e+12>>2]<<3)+4>>2]}function K(e,t){return t|=0,(0|i[7696+(28*(e|=0)|0)+20>>2])==(0|t)?0|(t=1):0|(t=(0|i[7696+(28*e|0)+24>>2])==(0|t))}function W(e,t){return 0|i[848+(28*(e|=0)|0)+((t|=0)<<2)>>2]}function $(e,t){return t|=0,(0|i[848+(28*(e|=0)|0)>>2])==(0|t)?0|(t=0):(0|i[848+(28*e|0)+4>>2])==(0|t)?0|(t=1):(0|i[848+(28*e|0)+8>>2])==(0|t)?0|(t=2):(0|i[848+(28*e|0)+12>>2])==(0|t)?0|(t=3):(0|i[848+(28*e|0)+16>>2])==(0|t)?0|(t=4):(0|i[848+(28*e|0)+20>>2])==(0|t)?0|(t=5):0|((0|i[848+(28*e|0)+24>>2])==(0|t)?6:7)}function J(e){var t,n,r;return t=(r=+a[(e|=0)+16>>3])-(n=+a[e+24>>3]),+(r<n?t+6.283185307179586:t)}function Y(e){return+(+a[(e|=0)>>3]-+a[e+8>>3])}function X(e,t){e|=0;var n,r,i=0;return(i=+a[(t|=0)>>3])>=+a[e+8>>3]&&i<=+a[e>>3]?(n=+a[e+16>>3],i=+a[e+24>>3],t=(r=+a[t+8>>3])>=i,e=r<=n&1,n<i?t&&(e=1):t||(e=0),0|(t=!!(0|e))):0|(t=0)}function Z(e,t){t|=0;var n,r,i,o,s,A=0,l=0,c=0,u=0;return+a[(e|=0)>>3]<+a[t+8>>3]||+a[e+8>>3]>+a[t>>3]?0|(A=0):(i=(l=+a[e+16>>3])<(u=+a[(n=e+24|0)>>3]),c=(s=+a[(A=t+16|0)>>3])<(o=+a[(r=t+24|0)>>3]),t=u-s<o-l,e=i?c|t?1:2:0,t=c?i?1:t?2:1:0,(l=+qe(l,e))<+qe(+a[r>>3],t)||(u=+qe(+a[n>>3],e))>+qe(+a[A>>3],t)?0|(c=0):0|(c=1))}function ee(e,t){t|=0;var n,r,i,o,s,A=0,l=0,c=0,u=0;return+a[(e|=0)>>3]<+a[t>>3]||+a[e+8>>3]>+a[t+8>>3]?0|(A=0):(i=(o=+a[(A=e+16|0)>>3])<(l=+a[e+24>>3]),c=(u=+a[(n=t+16|0)>>3])<(s=+a[(r=t+24|0)>>3]),t=l-u<s-o,e=i?c|t?1:2:0,t=c?i?1:t?2:1:0,(l=+qe(l,e))<=+qe(+a[r>>3],t)?0|(c=(u=+qe(+a[A>>3],e))>=+qe(+a[n>>3],t)):0|(c=0))}function te(e,t){e|=0,t|=0;var n,r,o,s,A,l=0;o=N,N=N+176|0,i[(r=o)>>2]=4,l=+a[t>>3],a[r+8>>3]=l,s=+a[t+16>>3],a[r+16>>3]=s,a[r+24>>3]=l,l=+a[t+24>>3],a[r+32>>3]=l,A=+a[t+8>>3],a[r+40>>3]=A,a[r+48>>3]=l,a[r+56>>3]=A,a[r+64>>3]=s,n=(t=r+72|0)+96|0;do{i[t>>2]=0,t=t+4|0}while((0|t)<(0|n));Qt(0|e,0|r,168),N=o}function ne(e,t,n){e|=0,t|=0,n|=0;var r,s,c,u,f,d,h,p=0,m=0,g=0,v=0,x=0,_=0,w=0;d=N,N=N+288|0,f=d+264|0,v=d+96|0,m=(p=g=d)+96|0;do{i[p>>2]=0,p=p+4|0}while((0|p)<(0|m));return 0|(t=0|Ve(t,g))?(N=d,0|(_=t)):(De(g=0|i[(m=g)>>2],m=0|i[m+4>>2],f),Ue(g,m,v),u=+Qe(f,v+8|0),a[f>>3]=+a[e>>3],a[(m=f+8|0)>>3]=+a[e+16>>3],a[v>>3]=+a[e+8>>3],a[(g=v+8|0)>>3]=+a[e+24>>3],s=+Qe(f,v),w=+a[m>>3]-+a[g>>3],c=+l(+w),h=+a[f>>3]-+a[v>>3],r=+l(+h),!(0==w|0==h)&&(w=+Gt(+c,+r),w=+b(+s*s/+Ht(+w/+Ht(+c,+r),3)/(u*(2.59807621135*u)*.8)),a[o>>3]=w,x=~~w>>>0,_=+l(w)>=1?w>0?~~+y(+A(w/4294967296),4294967295)>>>0:~~+b((w-+(~~w>>>0))/4294967296)>>>0:0,2146435072&~i[o+4>>2])?(v=!(0|x)&!(0|_),i[(t=n)>>2]=v?1:x,i[t+4>>2]=v?0:_,t=0):t=1,N=d,0|(_=t))}function re(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var s,c,u,f,d=0,h=0,p=0;f=N,N=N+288|0,c=f+264|0,u=f+96|0,s=(d=h=f)+96|0;do{i[d>>2]=0,d=d+4|0}while((0|d)<(0|s));return 0|(n=0|Ve(n,h))?(N=f,0|(r=n)):(De(d=0|i[(n=h)>>2],n=0|i[n+4>>2],c),Ue(d,n,u),p=+Qe(c,u+8|0),p=+b(+ +Qe(e,t)/(2*p)),a[o>>3]=p,n=~~p>>>0,d=+l(p)>=1?p>0?~~+y(+A(p/4294967296),4294967295)>>>0:~~+b((p-+(~~p>>>0))/4294967296)>>>0:0,2146435072&~i[o+4>>2]?(h=!(0|n)&!(0|d),i[r>>2]=h?1:n,i[r+4>>2]=h?0:d,N=f,0|(r=0)):(N=f,0|(r=1)))}function ie(e,t,n,o){e|=0,o|=0;var s,A=0,l=0,c=0,u=0,f=0,d=0,h=0,p=0,m=0,g=0,b=0,v=0,y=0,x=0,_=0,w=0,T=0,E=0,C=0,I=0,R=0,P=0,k=0,L=0,B=0;if(s=N,N=N+224|0,P=s,E=s+48|0,(f=(0|(n|=0))>0|!(0|n)&(t|=0)>>>0>0)&(n>>>0>0|!(0|n)&t>>>0>17895697))return N=s,0|(B=14);if((0|n)<0)return N=s,0|(B=2);if(!(0|t)&!(0|n))return i[o>>2]=0,i[o+4>>2]=0,N=s,0|(B=0);for(A=0|ve(0|i[(A=e)>>2],0|i[A+4>>2]),c=0,u=0;;){if(!(0|xe(0|i[(B=l=e+(c<<3)|0)>>2],0|i[B+4>>2]))){A=5,k=159;break}if(B=(0|ve(0|i[(B=l)>>2],0|i[B+4>>2]))==(0|A),c=0|Pt(0|c,0|u,1,0),u=0|S(),!B){A=12,k=159;break}if(!((0|u)<(0|n)|(0|u)==(0|n)&c>>>0<t>>>0)){k=8;break}}if(8==(0|k)){do{if((0|n)>0|!(0|n)&t>>>0>1){if(!(c=0|Mt(A=t<<3)))return N=s,0|(B=13);for(Qt(0|c,0|e,0|A),gt(c,t,8,1),A=1,l=0;B=c+(A+-1<<3)|0,B=(0|i[(L=c+(A<<3)|0)>>2])==(0|i[B>>2])?(0|i[L+4>>2])==(0|i[B+4>>2]):0,A=0|Pt(0|A,0|l,1,0),l=0|S(),!B;)if(!((0|l)<(0|n)|(0|l)==(0|n)&A>>>0<t>>>0)){k=14;break}if(14==(0|k)){Et(c);break}return Et(c),N=s,0|(B=10)}}while(0);if(A=0|Ot(0|t,0|n,6,0),l=0|S(),f){c=0,u=0;do{A=0|Pt(0|A,0|l,0|(B=!!(0|Se(0|i[(B=e+(u<<3)|0)>>2],0|i[B+4>>2]))<<31>>31),((0|B)<0)<<31>>31),l=0|S(),u=0|Pt(0|u,0|c,1,0),c=0|S()}while((0|c)<(0|n)|(0|c)==(0|n)&u>>>0<t>>>0);T=A,w=l}else T=A,w=l;if(x=0|Ot(0|T,0|w,10,0),_=0|S(),!(L=0|Mt(T<<5)))return N=s,0|(B=13);if(!(B=0|Ct(x,4)))return Et(L),N=s,0|(B=13);e:do{if(f){for(se(0|i[(R=e)>>2],0|i[R+4>>2],P),g=L,b=0,v=0,A=0,y=0;;){l=(f=!(0|i[(f=P)>>2])&!(0|i[f+4>>2]))?26990:26995,c=f?5:6,f=P+((1&f)<<3)|0,d=0|Pt(0|c,0|(u=0),-1,-1),h=0|S(),p=0,m=0;do{C=0|i[(I=f+(p<<3)|0)+4>>2],i[(R=g+(p<<5)|0)>>2]=i[I>>2],i[R+4>>2]=C,r[g+(p<<5)+9|0]=0,r[g+(p<<5)+8|0]=0,i[g+(p<<5)+20>>2]=g,i[(R=g+(p<<5)+24|0)>>2]=1,i[R+4>>2]=0,R=0|r[l+p|0],C=0|Dt(0|(C=0|Pt(0|d,0|h,0|p,0|m)),0|S(),0|c,0|u),S(),C=0|r[l+C|0],p=0|Pt(0|p,0|m,1,0),m=0|S(),I=0|r[l+((0|p)==(0|c)&(0|m)==(0|u)?0:p)|0],i[g+((R&=255)<<5)+16>>2]=g+((255&C)<<5),i[g+(R<<5)+12>>2]=g+((255&I)<<5)}while(m>>>0<u>>>0|(0|m)==(0|u)&p>>>0<c>>>0);if(b=0|Pt(0|b,0|v,1,0),v=0|S(),A=0|Pt(0|c,0|u,0|A,0|y),y=0|S(),!((0|v)<(0|n)|(0|v)==(0|n)&b>>>0<t>>>0))break e;0|se(0|i[(R=e+(b<<3)|0)>>2],0|i[R+4>>2],P)||(g=L+(A<<5)|0)}M(27634,26956,108,26975)}}while(0);if((0|w)>0|!(0|w)&T>>>0>0){u=0,f=0;do{if(A=0|Vt(0|(c=0|i[(l=L+(u<<5)|0)>>2]),0|(l=0|i[l+4>>2]),30),A=0|Vt(0|(l=0|Ot(A^c|0,(0|S())^l,484763065,-1084733587)),0|(c=0|S()),27),l=0|Dt((A=0|Vt(0|(c=0|Ot(A^l|0,(0|S())^c,321982955,-1798288965)),0|(l=0|S()),31))^c|0,(0|S())^l,0|x,0|_),c=0|S(),0|i[(A=B+(l<<2)|0)>>2])do{l=0|Ft(0|(A=0|Pt(0|l,0|c,1,0)),0|S(),0|x,0|_),c=0|S(),A=B+(l<<2)|0}while(0|i[A>>2]);i[A>>2]=L+(u<<5),u=0|Pt(0|u,0|f,1,0),f=0|S()}while((0|f)<(0|w)|(0|f)==(0|w)&u>>>0<T>>>0);p=0,m=0;do{if(u=L+(p<<5)|0,!(0|r[(f=L+(p<<5)+9|0)|0])){if(0|le(0|i[(R=u)>>2],0|i[R+4>>2],P)){k=39;break}l=0|Vt(0|(d=0|i[(h=P)>>2]),0|(h=0|i[h+4>>2]),30),A=0|Vt(0|(l=0|Ot(l^d|0,(0|S())^h,484763065,-1084733587)),0|(c=0|S()),27),l=0|Dt((A=0|Vt(0|(c=0|Ot(A^l|0,(0|S())^c,321982955,-1798288965)),0|(l=0|S()),31))^c|0,(0|S())^l,0|x,0|_),c=0|S(),A=0|i[B+(l<<2)>>2];e:do{if(0|A){for(;(0|i[(R=A)>>2])!=(0|d)||(0|i[R+4>>2])!=(0|h);)if(l=0|Ft(0|(A=0|Pt(0|l,0|c,1,0)),0|S(),0|x,0|_),c=0|S(),!(A=0|i[B+(l<<2)>>2]))break e;r[f|0]=1,r[A+9|0]=1,l=A+16|0,i[16+(0|i[(R=L+(p<<5)+12|0)>>2])>>2]=i[l>>2],n=A+12|0,I=0|i[L+(p<<5)+16>>2],i[I+12>>2]=i[n>>2],i[16+(0|i[n>>2])>>2]=I,i[12+(0|i[l>>2])>>2]=i[R>>2],l=0|ae(u),R=0|ae(A),A=(I=(0|(n=0|i[(A=l+24|0)+4>>2]))<(0|(C=0|i[(I=R+24|0)+4>>2]))|((0|n)==(0|C)?(0|i[A>>2])>>>0<(0|i[I>>2])>>>0:0))?l:R,(0|(l=I?R:l))!=(0|A)&&(C=A+24|0,C=0|Pt(0|i[(I=R=l+24|0)>>2],0|i[I+4>>2],0|i[C>>2],0|i[C+4>>2]),I=0|S(),i[R>>2]=C,i[R+4>>2]=I,i[A+20>>2]=l)}}while(0)}p=0|Pt(0|p,0|m,1,0),m=0|S()}while((0|m)<(0|w)|(0|m)==(0|w)&p>>>0<T>>>0);39==(0|k)&&M(27634,26956,258,27001),A=0,l=0;do{r[L+(A<<5)+8|0]=0,A=0|Pt(0|A,0|l,1,0),l=0|S()}while((0|l)<(0|w)|(0|l)==(0|w)&A>>>0<T>>>0);for(d=0,c=0,f=0,h=0;;){if(A=L+(d<<5)|0,0|r[L+(d<<5)+8|0]||0|r[L+(d<<5)+9|0])u=f;else{l=0|i[(u=A)>>2],u=0|i[u+4>>2];do{r[A+8|0]=1,R=A=0|i[A+12>>2]}while((0|i[R>>2])!=(0|l)||(0|i[R+4>>2])!=(0|u));c=0|Pt(0|c,0|f,1,0),u=0|S()}if(d=0|Pt(0|d,0|h,1,0),!((0|(h=0|S()))<(0|w)|(0|h)==(0|w)&d>>>0<T>>>0))break;f=u}A=0,l=0;do{r[L+(A<<5)+8|0]=0,A=0|Pt(0|A,0|l,1,0),l=0|S()}while((0|l)<(0|w)|(0|l)==(0|w)&A>>>0<T>>>0);I=c,C=u,A=1}else I=0,C=0,A=0;R=0|Mt(24*I|0);e:do{if(0|R){t:do{if(A){e=0,x=0,n=0,t=0;n:for(;;){if(A=L+(e<<5)|0,0|r[L+(e<<5)+8|0]||0|r[L+(e<<5)+9|0])l=n,A=x;else{v=0|i[(y=A)>>2],y=0|i[y+4>>2],l=0,c=0;do{l=0|Pt(0|l,0|c,2,0),c=0|S(),_=A=0|i[A+12>>2]}while((0|i[_>>2])!=(0|v)||(0|i[_+4>>2])!=(0|y));if(!(b=0|Mt(l<<4)))break;l=v,c=y,g=0,m=0,u=0,f=0;do{if(0|Ae(l,c,E)){k=69;break n}if(p=((0|(h=(_=0|i[E>>2])+-1|0))<0)<<31>>31,(0|_)>1){c=u,d=0,l=f,u=0;do{f=E+8+(d<<4)|0,i[(_=b+(c<<4)|0)>>2]=i[f>>2],i[_+4>>2]=i[f+4>>2],i[_+8>>2]=i[f+8>>2],i[_+12>>2]=i[f+12>>2],c=0|Pt(0|c,0|l,1,0),l=0|S(),d=0|Pt(0|d,0|u,1,0),u=0|S()}while((0|u)<(0|p)|(0|u)==(0|p)&d>>>0<h>>>0);u=c,f=l}g=0|Pt(0|g,0|m,0|h,0|p),m=0|S(),r[A+8|0]=1,A=0|i[A+12>>2],l=0|i[(c=A)>>2],c=0|i[c+4>>2]}while(!((0|l)==(0|v)&(0|c)==(0|y)));if(!(l=0|It(b,g<<4))){k=75;break}y=0|ae(A),_=0|i[y+4>>2],i[(A=R+(24*n|0)|0)>>2]=i[y>>2],i[A+4>>2]=_,i[(A=R+(24*n|0)+16|0)>>2]=g,i[R+(24*n|0)+20>>2]=l,i[P>>2]=i[A>>2],i[P+4>>2]=i[A+4>>2],z(P,R+(24*n|0)+8|0),l=0|Pt(0|n,0|x,1,0),A=0|S()}if(e=0|Pt(0|e,0|t,1,0),!((0|(t=0|S()))<(0|w)|(0|t)==(0|w)&e>>>0<T>>>0))break t;x=A,n=l}if(69==(0|k)?M(27634,26956,351,27016):75==(0|k)&&Et(b),(0|x)>0|!(0|x)&n>>>0>0)for(u=0,f=0,A=n,c=x;(l=0|i[R+(24*u|0)+20>>2])?(Et(l),l=x,A=n):l=c,u=0|Pt(0|u,0|f,1,0),(0|(f=0|S()))<(0|l)|(0|f)==(0|l)&u>>>0<A>>>0;)c=l;Et(R);break e}}while(0);gt(R,I,24,2);t:do{if(!(0|I)&!(0|C)){if(0|(_=0|Mt(192))){if(i[_+16>>2]=0,i[_+20>>2]=0,i[(m=_+8|0)>>2]=3,A=0|Mt(48),i[(g=_+12|0)>>2]=A,0|A){i[A>>2]=i[3860],i[A+4>>2]=i[3861],i[A+8>>2]=i[3862],i[A+12>>2]=i[3863],i[(p=A+16|0)>>2]=i[3864],i[p+4>>2]=i[3865],i[p+8>>2]=i[3866],i[p+12>>2]=i[3867],i[(p=A+32|0)>>2]=i[3868],i[p+4>>2]=i[3869],i[p+8>>2]=i[3870],i[p+12>>2]=i[3871],i[P>>2]=i[m>>2],i[P+4>>2]=i[m+4>>2],z(P,_),i[_+40>>2]=0,i[_+44>>2]=0,i[(p=_+32|0)>>2]=3,A=0|Mt(48),i[(b=_+36|0)>>2]=A;do{if(A){if(i[A>>2]=i[3872],i[A+4>>2]=i[3873],i[A+8>>2]=i[3874],i[A+12>>2]=i[3875],i[(h=A+16|0)>>2]=i[3876],i[h+4>>2]=i[3877],i[h+8>>2]=i[3878],i[h+12>>2]=i[3879],i[(h=A+32|0)>>2]=i[3880],i[h+4>>2]=i[3881],i[h+8>>2]=i[3882],i[h+12>>2]=i[3883],i[P>>2]=i[p>>2],i[P+4>>2]=i[p+4>>2],z(P,_+24|0),i[_+64>>2]=0,i[_+68>>2]=0,i[(h=_+56|0)>>2]=3,A=0|Mt(48),i[(v=_+60|0)>>2]=A,!A){u=0,f=2;break}if(i[A>>2]=i[3884],i[A+4>>2]=i[3885],i[A+8>>2]=i[3886],i[A+12>>2]=i[3887],i[(d=A+16|0)>>2]=i[3888],i[d+4>>2]=i[3889],i[d+8>>2]=i[3890],i[d+12>>2]=i[3891],i[(d=A+32|0)>>2]=i[3892],i[d+4>>2]=i[3893],i[d+8>>2]=i[3894],i[d+12>>2]=i[3895],i[P>>2]=i[h>>2],i[P+4>>2]=i[h+4>>2],z(P,_+48|0),i[_+88>>2]=0,i[_+92>>2]=0,i[(d=_+80|0)>>2]=3,A=0|Mt(48),i[(y=_+84|0)>>2]=A,!A){u=0,f=3;break}if(i[A>>2]=i[3896],i[A+4>>2]=i[3897],i[A+8>>2]=i[3898],i[A+12>>2]=i[3899],i[(f=A+16|0)>>2]=i[3900],i[f+4>>2]=i[3901],i[f+8>>2]=i[3902],i[f+12>>2]=i[3903],i[(f=A+32|0)>>2]=i[3904],i[f+4>>2]=i[3905],i[f+8>>2]=i[3906],i[f+12>>2]=i[3907],i[P>>2]=i[d>>2],i[P+4>>2]=i[d+4>>2],z(P,_+72|0),i[_+112>>2]=0,i[_+116>>2]=0,i[(f=_+104|0)>>2]=3,A=0|Mt(48),i[(e=_+108|0)>>2]=A,!A){u=0,f=4;break}if(i[A>>2]=i[3908],i[A+4>>2]=i[3909],i[A+8>>2]=i[3910],i[A+12>>2]=i[3911],i[(u=A+16|0)>>2]=i[3912],i[u+4>>2]=i[3913],i[u+8>>2]=i[3914],i[u+12>>2]=i[3915],i[(u=A+32|0)>>2]=i[3916],i[u+4>>2]=i[3917],i[u+8>>2]=i[3918],i[u+12>>2]=i[3919],i[P>>2]=i[f>>2],i[P+4>>2]=i[f+4>>2],z(P,_+96|0),i[_+136>>2]=0,i[_+140>>2]=0,i[(u=_+128|0)>>2]=3,A=0|Mt(48),i[(t=_+132|0)>>2]=A,!A){u=0,f=5;break}if(i[A>>2]=i[3920],i[A+4>>2]=i[3921],i[A+8>>2]=i[3922],i[A+12>>2]=i[3923],i[(c=A+16|0)>>2]=i[3924],i[c+4>>2]=i[3925],i[c+8>>2]=i[3926],i[c+12>>2]=i[3927],i[(c=A+32|0)>>2]=i[3928],i[c+4>>2]=i[3929],i[c+8>>2]=i[3930],i[c+12>>2]=i[3931],i[P>>2]=i[u>>2],i[P+4>>2]=i[u+4>>2],z(P,_+120|0),i[_+160>>2]=0,i[_+164>>2]=0,i[(c=_+152|0)>>2]=3,A=0|Mt(48),i[(n=_+156|0)>>2]=A,!A){u=0,f=6;break}if(i[A>>2]=i[3932],i[A+4>>2]=i[3933],i[A+8>>2]=i[3934],i[A+12>>2]=i[3935],i[(l=A+16|0)>>2]=i[3936],i[l+4>>2]=i[3937],i[l+8>>2]=i[3938],i[l+12>>2]=i[3939],i[(l=A+32|0)>>2]=i[3940],i[l+4>>2]=i[3941],i[l+8>>2]=i[3942],i[l+12>>2]=i[3943],i[P>>2]=i[c>>2],i[P+4>>2]=i[c+4>>2],z(P,_+144|0),i[_+184>>2]=0,i[_+188>>2]=0,i[(l=_+176|0)>>2]=3,A=0|Mt(48),i[(x=_+180|0)>>2]=A,!A){u=0,f=7;break}if(i[A>>2]=i[3944],i[A+4>>2]=i[3945],i[A+8>>2]=i[3946],i[A+12>>2]=i[3947],i[(E=A+16|0)>>2]=i[3948],i[E+4>>2]=i[3949],i[E+8>>2]=i[3950],i[E+12>>2]=i[3951],i[(A=A+32|0)>>2]=i[3952],i[A+4>>2]=i[3953],i[A+8>>2]=i[3954],i[A+12>>2]=i[3955],i[P>>2]=i[l>>2],i[P+4>>2]=i[l+4>>2],z(P,_+168|0),gt(_,8,24,3),A=0|Mt(128),i[o+4>>2]=A,0|A){i[o>>2]=8,i[A>>2]=i[m>>2],i[A+4>>2]=i[m+4>>2],i[A+8>>2]=i[m+8>>2],i[A+12>>2]=i[m+12>>2],i[(k=A+16|0)>>2]=i[p>>2],i[k+4>>2]=i[p+4>>2],i[k+8>>2]=i[p+8>>2],i[k+12>>2]=i[p+12>>2],i[(k=A+32|0)>>2]=i[h>>2],i[k+4>>2]=i[h+4>>2],i[k+8>>2]=i[h+8>>2],i[k+12>>2]=i[h+12>>2],i[(k=A+48|0)>>2]=i[d>>2],i[k+4>>2]=i[d+4>>2],i[k+8>>2]=i[d+8>>2],i[k+12>>2]=i[d+12>>2],i[(k=A+64|0)>>2]=i[f>>2],i[k+4>>2]=i[f+4>>2],i[k+8>>2]=i[f+8>>2],i[k+12>>2]=i[f+12>>2],i[(k=A+80|0)>>2]=i[u>>2],i[k+4>>2]=i[u+4>>2],i[k+8>>2]=i[u+8>>2],i[k+12>>2]=i[u+12>>2],i[(k=A+96|0)>>2]=i[c>>2],i[k+4>>2]=i[c+4>>2],i[k+8>>2]=i[c+8>>2],i[k+12>>2]=i[c+12>>2],i[(k=A+112|0)>>2]=i[l>>2],i[k+4>>2]=i[l+4>>2],i[k+8>>2]=i[l+8>>2],i[k+12>>2]=i[l+12>>2],Et(_),k=158;break t}0|(A=0|i[g>>2])&&Et(A),0|(A=0|i[b>>2])&&Et(A),0|(A=0|i[v>>2])&&Et(A),0|(A=0|i[y>>2])&&Et(A),0|(A=0|i[e>>2])&&Et(A),0|(A=0|i[t>>2])&&Et(A),0|(A=0|i[n>>2])&&Et(A),0|(A=0|i[x>>2])&&Et(A),Et(_);break t}u=0,f=1}while(0);A=0,c=0;do{0|(l=0|i[_+(24*A|0)+12>>2])&&Et(l),A=0|Pt(0|A,0|c,1,0),c=0|S()}while(c>>>0<u>>>0|(0|c)==(0|u)&A>>>0<f>>>0)}Et(_),k=152}}else{if((0|C)>0|!(0|C)&I>>>0>0){c=0,u=0,f=0,l=0,A=0,d=0;do{P=u,k=f,l=0|Pt(0|l,0|A,1&((0|(u=0|i[(E=R+(24*c|0)|0)>>2]))!=(0|P)|(0|(f=0|i[E+4>>2]))!=(0|k)),0),A=0|S(),c=0|Pt(0|c,0|d,1,0),d=0|S()}while((0|d)<(0|C)|(0|d)==(0|C)&c>>>0<I>>>0);y=l,v=A}else y=0,v=0;if(e=0|Mt(24*y|0)){n:do{if((0|C)>=0){for(m=0,g=0,l=0,c=0,b=0,u=0;;){if((0|m)==(0|I)&(0|g)==(0|C)||(k=R+(24*m|0)|0,(0|i[(P=R+(24*l|0)|0)>>2])!=(0|i[k>>2])||(0|i[P+4>>2])!=(0|i[k+4>>2]))){if(h=R+(24*l|0)|0,p=0|Pt(0|(k=0|Nt(0|m,0|g,0|l,0|c)),0|(P=0|S()),-1,-1),c=0|S(),(0|P)>0|!(0|P)&k>>>0>1){if(!(A=0|Mt(p<<3)))break;f=0,d=0;do{k=f,f=0|Pt(0|f,0|d,1,0),d=0|S(),P=0|i[(E=h+(24*f|0)+16|0)+4>>2],i[(k=A+(k<<3)|0)>>2]=i[E>>2],i[k+4>>2]=P}while((0|d)<(0|c)|(0|d)==(0|c)&f>>>0<p>>>0)}else A=0;k=0|i[(P=R+(24*l|0)+16|0)+4>>2],i[(c=e+(24*u|0)+8|0)>>2]=i[P>>2],i[c+4>>2]=k,i[e+(24*u|0)+16>>2]=p,i[e+(24*u|0)+20>>2]=A,a[e+(24*u|0)>>3]=+a[R+(24*l|0)+8>>3],u=0|Pt(0|u,0|b,1,0),l=m,c=g,A=0|S()}else A=b;if(k=m,m=0|Pt(0|m,0|g,1,0),P=g,g=0|S(),!((0|P)<(0|C)|(0|P)==(0|C)&k>>>0<I>>>0))break n;b=A}if((0|b)>0|!(0|b)&u>>>0>0){A=0,c=0;do{0|(l=0|i[e+(24*A|0)+20>>2])&&Et(l),A=0|Pt(0|A,0|c,1,0),c=0|S()}while((0|c)<(0|b)|(0|c)==(0|b)&A>>>0<u>>>0)}Et(e),k=152;break t}}while(0);if(gt(e,y,24,3),A=0|Mt(y<<4),i[(c=o+4|0)>>2]=A,A){i[o>>2]=y;do{if((0|v)>0|!(0|v)&y>>>0>0){if(o=e+8|0,i[A>>2]=i[o>>2],i[A+4>>2]=i[o+4>>2],i[A+8>>2]=i[o+8>>2],i[A+12>>2]=i[o+12>>2],1==(0|y)&!(0|v))break;if(k=e+32|0,i[(o=A+16|0)>>2]=i[k>>2],i[o+4>>2]=i[k+4>>2],i[o+8>>2]=i[k+8>>2],i[o+12>>2]=i[k+12>>2],!((0|v)>0|!(0|v)&y>>>0>2))break;A=2,l=0;do{o=(0|i[c>>2])+(A<<4)|0,k=e+(24*A|0)+8|0,i[o>>2]=i[k>>2],i[o+4>>2]=i[k+4>>2],i[o+8>>2]=i[k+8>>2],i[o+12>>2]=i[k+12>>2],A=0|Pt(0|A,0|l,1,0),l=0|S()}while((0|l)<(0|v)|(0|l)==(0|v)&A>>>0<y>>>0)}}while(0);Et(e),k=158;break}if((0|v)>0|!(0|v)&y>>>0>0){A=0,c=0;do{0|(l=0|i[e+(24*A|0)+20>>2])&&Et(l),A=0|Pt(0|A,0|c,1,0),c=0|S()}while((0|c)<(0|v)|(0|c)==(0|v)&A>>>0<y>>>0)}Et(e),k=152;break}k=152}}while(0);if(158==(0|k))return Et(L),Et(B),Et(R),N=s,0|(B=0);if(152==(0|k)&&(0|C)>0|!(0|C)&I>>>0>0)for(u=0,f=0,A=I,c=C;(l=0|i[R+(24*u|0)+20>>2])?(Et(l),l=C,A=I):l=c,u=0|Pt(0|u,0|f,1,0),(0|(f=0|S()))<(0|l)|(0|f)==(0|l)&u>>>0<A>>>0;)c=l;return Et(R),Et(L),Et(B),N=s,0|(B=13)}}while(0);return Et(L),Et(B),N=s,0|(B=13)}return 159==(0|k)?(N=s,0|A):0}function ae(e){var t,n=0;return(0|(n=0|i[(t=(e|=0)+20|0)>>2]))==(0|e)?0|e:(n=0|ae(n),i[t>>2]=n,0|n)}function oe(e,t){var n=0;switch(n=0|Vt(0|(e|=0),0|(t|=0),56),S(),7&n){case 0:case 7:return 0|(n=0)}return n=-2130706433&t|134217728,!0&268435456==(2013265920&t)?!0&16777216==(117440512&t)&!!(0|Se(e,n))?0|(n=0):0|(n=0|xe(e,n)):0|(n=0)}function se(e,t,n){n|=0;var r,a=0;return r=!(0|Se(e|=0,t|=0)),t&=-2130706433,i[(a=n)>>2]=r?e:0,i[a+4>>2]=r?285212672|t:0,i[(a=n+8|0)>>2]=e,i[a+4>>2]=301989888|t,i[(a=n+16|0)>>2]=e,i[a+4>>2]=318767104|t,i[(a=n+24|0)>>2]=e,i[a+4>>2]=335544320|t,i[(a=n+32|0)>>2]=e,i[a+4>>2]=352321536|t,i[(n=n+40|0)>>2]=e,i[n+4>>2]=369098752|t,0}function Ae(e,t,n){n|=0;var r,a,o=0,s=0;return a=N,N=N+16|0,r=a,s=-2130706433&(t|=0)|134217728,!0&268435456==(2013265920&t)?(o=0|Vt(0|(e|=0),0|t,56),S(),o=0|function(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0;if(o=N,N=N+16|0,a=o,r=0|Se(e,t),(n+-1|0)>>>0>5)return N=o,0|(a=-1);if(r=!!(0|r),1==(0|n)&r)return N=o,0|(a=-1);do{if(!(0|ht(e,t,a))){if(r){r=(5+(0|i[26416+(n<<2)>>2])-(0|i[a>>2])|0)%5|0;break}r=(6+(0|i[26448+(n<<2)>>2])-(0|i[a>>2])|0)%6|0;break}r=-1}while(0);return a=r,N=o,0|a}(e,s,7&o),-1==(0|o)?(i[n>>2]=0,N=a,0|(s=6)):(0|Fe(e,s,r)&&M(27634,27035,282,27050),t=0|Vt(0|e,0|t,52),S(),t&=15,0|Se(e,s)?de(r,t,o,2,n):ge(r,t,o,2,n),N=a,0|(s=0))):(N=a,0|(s=6))}function le(e,t,n){e|=0,n|=0;var r,a=0,o=0,s=0;return r=N,N=N+16|0,o=r,s=-2130706433&(t|=0)|134217728,!0&268435456==(2013265920&t)?(i[(a=r+8|0)>>2]=0,t=0|Vt(0|e,0|t,56),S(),0|(t=0|F(e,s,7&t,a,o))?(N=r,0|(n=t)):7==(0|(t=0|V(a=0|i[o>>2],o=0|i[o+4>>2],e,s)))?(N=r,0|(n=11)):(e=0|jt(0|t,0,56),s=-2130706433&o|S()|268435456,i[n>>2]=a|e,i[n+4>>2]=s,N=r,0|(n=0))):(N=r,0|(n=6))}function ce(e,t,n){e|=0,t|=0;var r,o,s=0,A=0,p=0,m=0,b=0,v=0,y=0,x=0,_=0,w=0,T=0,M=0,E=0,C=0,I=0,R=0,P=0;i[(n|=0)>>2]=0,y=+a[e>>3],x=+a[e+8>>3],v=+a[e+16>>3],A=0,p=5,s=5,e=0;do{(m=(T=+a[15888+(24*A|0)>>3]-y)*T+(w=+a[15888+(24*A|0)+8>>3]-x)*w+(m=+a[15888+(24*A|0)+16>>3]-v)*m)<s&&(i[n>>2]=A,p=m,e=A,s=m),A=A+1|0}while(20!=(0|A));if((p=+h(+(1-.5*p)))<1e-16)v=0,m=0;else{if(R=+a[16368+(24*e|0)>>3],C=+a[15888+(24*e|0)>>3],I=+a[15888+(24*e|0)+8>>3],m=C*(P=-((E=+a[15888+(24*e|0)+16>>3])+(0*C+0*I)))+0,T=I*P+0,m*=M=(M=+c(+((P=E*P+1)*P+(m*m+T*T))))>0?1/M:0,T*=M,M*=P,w=y+C*(P=-(y*C+x*I+v*E)),w*=x=(x=+c(+((y=v+E*P)*y+(w*w+(s=x+I*P)*s))))>0?1/x:0,s*=x,s=+He(R-+He(+g(+((x*=y)*(I*m-C*T)+(w*(E*T-I*M)+s*(C*M-E*m))),+(M*x+(m*w+T*s))))),m=0|Le(t)?+He(s+-.3334731722518321):s,s=2.618033988749896*+d(+p),(0|t)>0){e=0;do{s*=2.6457513110645907,e=e+1|0}while((0|e)!=(0|t))}v=+u(+m)*s,m=+f(+m)*s}t=n+4|0,i[(o=n+12|0)>>2]=0,p=1.1547005383792515*+l(+m),s=+l(+v)+.5*p,s-=+(0|(e=~~s)),p-=+(0|(A=~~p));do{if(s<.5){if(s<.3333333333333333){if(i[t>>2]=e,p<.5*(s+1)){i[n+8>>2]=A;break}A=A+1|0,i[n+8>>2]=A;break}if(A=(1&!(p<(P=1-s)))+A|0,i[n+8>>2]=A,P<=p&p<2*s){e=e+1|0,i[t>>2]=e;break}i[t>>2]=e;break}if(!(s<.6666666666666666)){if(e=e+1|0,i[t>>2]=e,p<.5*s){i[n+8>>2]=A;break}A=A+1|0,i[n+8>>2]=A;break}if(p<1-s){if(i[n+8>>2]=A,2*s-1<p){i[t>>2]=e;break}}else A=A+1|0,i[n+8>>2]=A;e=e+1|0,i[t>>2]=e}while(0);do{if(v<0){if(1&A){e=~~(+(0|e)-(2*(+((_=0|Nt(0|e,((0|e)<0)<<31>>31,0|(_=(A+1|0)/2|0),((0|_)<0)<<31>>31))>>>0)+4294967296*+(0|S()))+1)),i[t>>2]=e,_=t;break}e=~~(+(0|e)-2*(+((_=0|Nt(0|e,((0|e)<0)<<31>>31,0|(_=(0|A)/2|0),((0|_)<0)<<31>>31))>>>0)+4294967296*+(0|S()))),i[t>>2]=e,_=t;break}_=t}while(0);r=n+8|0,t=0-A|0,m<0?(n=e-((A<<1|1)/2|0)|0,i[_>>2]=n,i[r>>2]=t,A=t):n=e,e=A-n|0,t=0-n|0,(0|n)<0?(i[r>>2]=e,i[o>>2]=t,i[_>>2]=0,b=0):(e=A,b=n,t=0),n=b-e|0,A=t-e|0,(0|e)<0?(i[_>>2]=n,i[o>>2]=A,i[r>>2]=0,b=n,e=0):A=t,n=b-A|0,t=e-A|0,(0|A)<0?(i[_>>2]=n,i[r>>2]=t,i[o>>2]=0,A=0):(t=e,n=b),(0|(e=(0|A)<(0|(e=(0|t)<(0|n)?t:n))?A:e))<=0||(i[_>>2]=n-e,i[r>>2]=t-e,i[o>>2]=A-e)}function ue(e,t,n){t|=0,n|=0;var r,o,s,A;r=N,N=N+16|0,o=r,A=0|i[(e|=0)+12>>2],s=+((0|i[e+8>>2])-A|0),a[o>>3]=+((0|i[e+4>>2])-A|0)-.5*s,a[o+8>>3]=.8660254037844386*s,fe(o,0|i[e>>2],t,0,n),N=r}function fe(e,t,n,r,o){t|=0,n|=0,r|=0,o|=0;var s,A,l,d,h,p=0,b=0,v=0,y=0,x=0,_=0,w=0;if(p=+function(e){e|=0;var t=0,n=0;return n=+a[e>>3],t=+a[e+8>>3],+ +c(+(n*n+t*t))}(e|=0),p<1e-16)return t=15888+(24*t|0)|0,i[o>>2]=i[t>>2],i[o+4>>2]=i[t+4>>2],i[o+8>>2]=i[t+8>>2],i[o+12>>2]=i[t+12>>2],i[o+16>>2]=i[t+16>>2],void(i[o+20>>2]=i[t+20>>2]);if(b=+g(+ +a[e+8>>3],+ +a[e>>3]),(0|n)>0){e=0;do{p*=.37796447300922725,e=e+1|0}while((0|e)!=(0|n))}v=.3333333333333333*p,r?(n=!(0|Le(n)),p=+m(.381966011250105*(n?v:.37796447300922725*v))):(p=+m(.381966011250105*p),0|Le(n)&&(b=+He(b+.3334731722518321))),x=+He(+a[16368+(24*t|0)>>3]-b),v=+a[15888+(24*t|0)>>3],A=+a[15888+(24*t|0)+8>>3],y=v*(w=-((d=+a[15888+(24*t|0)+16>>3])+(0*v+0*A)))+0,b=A*w+0,y*=_=(_=+c(+((w=d*w+1)*w+(y*y+b*b))))>0?1/_:0,b*=_,_*=w,w=+u(+x),x=+f(+x),s=(h=+u(+p))*v+(l=+f(+p))*(w*y+x*(d*b-A*_)),p=h*A+l*(w*b+x*(v*_-d*y)),v=(v=+c(+((b=h*d+l*(w*_+x*(A*y-v*b)))*b+(s*s+p*p))))>0?1/v:0,a[o>>3]=s*v,a[o+8>>3]=p*v,a[o+16>>3]=b*v}function de(e,t,n,r,o){e|=0,t|=0,n|=0,r|=0,o|=0;var s,A,l,c,u,f,d,h,m,b,y,x,_,w,T,S,E,C,I,R,P,k,L,B,O,F,D,U=0,V=0,j=0,z=0,G=0,H=0,q=0,Q=0,K=0,W=0,$=0,J=0,Y=0,X=0,Z=0;if(D=N,N=N+256|0,K=D+224|0,B=D,O=D+208|0,F=D+192|0,C=D+168|0,I=D+152|0,R=D+136|0,P=D+120|0,k=D+104|0,L=D+80|0,i[(U=D+240|0)>>2]=t,i[K>>2]=i[e>>2],i[K+4>>2]=i[e+4>>2],i[K+8>>2]=i[e+8>>2],i[K+12>>2]=i[e+12>>2],he(K,U,B),i[o>>2]=0,(0|(K=r+n+(5==(0|r)&1)|0))<=(0|n))N=D;else{d=O+4|0,u=O+8|0,f=O+12|0,m=F+8|0,b=n+5|0,y=16848+((h=0|i[U>>2])<<2)|0,x=C+8|0,_=16928+(h<<2)|0,w=I+8|0,T=R+8|0,S=P+8|0,E=F+8|0,s=C+8|0,l=C+16|0,A=L+8|0,c=L+16|0,Q=n,r=0,V=0,j=0,z=0;e:for(;;){q=B+((0|Q)%5<<4)|0,i[O>>2]=i[q>>2],i[O+4>>2]=i[q+4>>2],i[O+8>>2]=i[q+8>>2],i[O+12>>2]=i[q+12>>2];do{}while(2==(0|pe(O,h,0,1)));if((0|Q)>(0|n)&!!(0|Le(t))){if(q=0|i[O>>2],e=0|i[d>>2],G=0|i[u>>2],U=0|i[f>>2],W=+(j-z|0),a[F>>3]=+(V-z|0)-.5*W,a[m>>3]=.8660254037844386*W,z=0|i[17008+(80*q|0)+(r<<2)>>2],H=0|i[18608+(80*q|0)+(20*z|0)>>2],(0|(j=0|i[18608+(80*q|0)+(20*z|0)+16>>2]))>0){V=0,r=G;do{r=((J=(0|(G=r+e-((X=(0|(Y=U+e|0))<0)?Y:0)|0))<0)?0:G)-((U=(0|($=U+r-(X?Y:0)-(J?G:0)|0))<0)?$:0)|0,e=(e=(X?0:Y)-(J?G:0)-(U?$:0)|0)-((G=(0|(U=(0|($=U?0:$))<(0|(U=(0|r)<(0|e)?r:e))?$:U))>0)?U:0)|0,r=r-(G?U:0)|0,U=$-(G?U:0)|0,V=V+1|0}while((0|V)<(0|j))}else r=G;switch(X=3*(0|i[y>>2])|0,$=(0|v(X,0|i[18608+(80*q|0)+(20*z|0)+4>>2]))+e|0,G=(0|v(X,0|i[18608+(80*q|0)+(20*z|0)+8>>2]))+r|0,X=(0|v(X,0|i[18608+(80*q|0)+(20*z|0)+12>>2]))+U|0,$=((z=(0|$)<0)?0:$)-((J=(0|(G=G-(z?$:0)|0))<0)?G:0)-((Y=(0|(X=X+(z?0-$|0:0)+(J?0-G|0:0)|0))<0)?X:0)|0,W=+((G=(J?0:G)-(Y?X:0)|0)-((J=(0|(Y=(0|(X=Y?0:X))<(0|(Y=(0|G)<(0|$)?G:$))?X:Y))>0)?Y:0)-(X=X-(J?Y:0)|0)|0),a[C>>3]=+($-(J?Y:0)-X|0)-.5*W,a[x>>3]=.8660254037844386*W,W=+(0|i[_>>2]),a[I>>3]=3*W,a[w>>3]=0,Z=-1.5*W,a[R>>3]=Z,a[T>>3]=2.598076211353316*W,a[P>>3]=Z,a[S>>3]=-2.598076211353316*W,0|i[17008+(80*H|0)+(q<<2)>>2]){case 1:e=R,r=I;break;case 3:e=P,r=R;break;case 2:e=I,r=P;break;default:e=12;break e}ft(F,C,r,e,k),fe(k,H,h,1,L),X=0|i[o>>2],W=+p(+ +a[c>>3]),Z=+g(+ +a[A>>3],+ +a[L>>3]),a[o+8+(X<<4)>>3]=W,a[o+8+(X<<4)+8>>3]=Z,i[o>>2]=1+(0|i[o>>2])}if((0|Q)<(0|b)&&(X=0|i[f>>2],W=+((0|i[u>>2])-X|0),a[F>>3]=+((0|i[d>>2])-X|0)-.5*W,a[E>>3]=.8660254037844386*W,fe(F,0|i[O>>2],h,1,C),X=0|i[o>>2],W=+p(+ +a[l>>3]),Z=+g(+ +a[s>>3],+ +a[C>>3]),a[o+8+(X<<4)>>3]=W,a[o+8+(X<<4)+8>>3]=Z,i[o>>2]=1+(0|i[o>>2])),(0|(Q=Q+1|0))>=(0|K)){e=3;break}r=0|i[O>>2],V=0|i[d>>2],j=0|i[u>>2],z=0|i[f>>2]}3!=(0|e)?12==(0|e)&&M(27073,27120,599,27130):N=D}}function he(e,t,n){e|=0,t|=0,n|=0;var r,a,o,s,A=0,l=0,c=0,u=0,f=0,d=0,h=0,p=0;s=N,N=N+128|0,l=s,u=20208,f=(c=A=s+64|0)+60|0;do{i[c>>2]=i[u>>2],c=c+4|0,u=u+4|0}while((0|c)<(0|f));u=20272,f=(c=l)+60|0;do{i[c>>2]=i[u>>2],c=c+4|0,u=u+4|0}while((0|c)<(0|f));p=(p=!(0|Le(0|i[t>>2])))?A:l,c=0|i[(o=e+4|0)>>2],A=0|i[(r=e+8|0)>>2],l=0|i[(a=e+12|0)>>2],u=A+(c<<1)|0,i[o>>2]=u,A=l+(A<<1)|0,i[r>>2]=A,c=(l<<1)+c|0,i[a>>2]=c,l=A-u|0,f=c-u|0,(0|u)<0&&(i[r>>2]=l,i[a>>2]=f,i[o>>2]=0,A=l,u=0,c=f),f=u-A|0,l=c-A|0,(0|A)<0?(i[o>>2]=f,i[a>>2]=l,i[r>>2]=0,A=0):(l=c,f=u),u=f-l|0,c=A-l|0,(0|l)<0?(i[o>>2]=u,i[r>>2]=c,i[a>>2]=0,l=0):(c=A,u=f),(0|(A=(0|l)<(0|(A=(0|c)<(0|u)?c:u))?l:A))>0&&(l=l-A|0,c=c-A|0,u=u-A|0,i[o>>2]=u,i[r>>2]=c,i[a>>2]=l),d=(c<<1)+u|0,f=l+(u<<1)|0,i[o>>2]=f,i[r>>2]=d,c=(l<<1)+c|0,i[a>>2]=c,A=d-f|0,l=c-f|0,(0|f)<0?(i[r>>2]=A,i[a>>2]=l,i[o>>2]=0,f=0,c=l):A=d,u=f-A|0,l=c-A|0,(0|A)<0?(i[o>>2]=u,i[a>>2]=l,i[r>>2]=0,f=u,A=0):l=c,u=f-l|0,c=A-l|0,(0|l)<0?(i[o>>2]=u,i[r>>2]=c,i[a>>2]=0,l=0):(c=A,u=f),(0|(A=(0|l)<(0|(A=(0|c)<(0|u)?c:u))?l:A))>0&&(i[o>>2]=u-A,i[r>>2]=c-A,i[a>>2]=l-A),0|Le(0|i[t>>2])&&(c=0|i[o>>2],A=(3*(u=0|i[r>>2])|0)+c|0,c=(l=0|i[a>>2])+(3*c|0)|0,i[o>>2]=c,i[r>>2]=A,u=(3*l|0)+u|0,i[a>>2]=u,l=A-c|0,f=u-c|0,(0|c)<0?(i[r>>2]=l,i[a>>2]=f,i[o>>2]=0,A=l,d=0):(d=c,f=u),c=d-A|0,l=f-A|0,(0|A)<0?(i[o>>2]=c,i[a>>2]=l,i[r>>2]=0,d=c,u=0):(u=A,l=f),c=d-l|0,A=u-l|0,(0|l)<0?(i[o>>2]=c,i[r>>2]=A,i[a>>2]=0,u=A,l=0):c=d,(0|(A=(0|l)<(0|(A=(0|u)<(0|c)?u:c))?l:A))>0&&(i[o>>2]=c-A,i[r>>2]=u-A,i[a>>2]=l-A),i[t>>2]=1+(0|i[t>>2])),i[n>>2]=i[e>>2],l=0|i[r>>2],A=0|i[a>>2],t=0|i[p+4>>2],h=0|i[p+8>>2],u=(0|i[p>>2])+(0|i[o>>2])|0,i[(d=n+4|0)>>2]=u,l=t+l|0,i[(t=n+8|0)>>2]=l,A=h+A|0,i[(h=n+12|0)>>2]=A,c=l-u|0,(0|u)<0&&(A=A-u|0,i[t>>2]=c,i[h>>2]=A,i[d>>2]=0,l=c,u=0),(0|l)<0&&(u=u-l|0,i[d>>2]=u,A=A-l|0,i[h>>2]=A,i[t>>2]=0,l=0),f=u-A|0,c=l-A|0,(0|A)<0?(i[d>>2]=f,i[t>>2]=c,i[h>>2]=0,u=f,A=0):c=l,(0|(l=(0|A)<(0|(l=(0|c)<(0|u)?c:u))?A:l))>0&&(i[d>>2]=u-l,i[t>>2]=c-l,i[h>>2]=A-l),i[n+16>>2]=i[e>>2],l=0|i[r>>2],A=0|i[a>>2],t=0|i[p+16>>2],h=0|i[p+20>>2],u=(0|i[p+12>>2])+(0|i[o>>2])|0,i[(d=n+20|0)>>2]=u,l=t+l|0,i[(t=n+24|0)>>2]=l,A=h+A|0,i[(h=n+28|0)>>2]=A,c=l-u|0,(0|u)<0&&(A=A-u|0,i[t>>2]=c,i[h>>2]=A,i[d>>2]=0,l=c,u=0),(0|l)<0&&(u=u-l|0,i[d>>2]=u,A=A-l|0,i[h>>2]=A,i[t>>2]=0,l=0),f=u-A|0,c=l-A|0,(0|A)<0?(i[d>>2]=f,i[t>>2]=c,i[h>>2]=0,u=f,A=0):c=l,(0|(l=(0|A)<(0|(l=(0|c)<(0|u)?c:u))?A:l))>0&&(i[d>>2]=u-l,i[t>>2]=c-l,i[h>>2]=A-l),i[n+32>>2]=i[e>>2],l=0|i[r>>2],A=0|i[a>>2],t=0|i[p+28>>2],h=0|i[p+32>>2],u=(0|i[p+24>>2])+(0|i[o>>2])|0,i[(d=n+36|0)>>2]=u,l=t+l|0,i[(t=n+40|0)>>2]=l,A=h+A|0,i[(h=n+44|0)>>2]=A,c=l-u|0,(0|u)<0&&(A=A-u|0,i[t>>2]=c,i[h>>2]=A,i[d>>2]=0,l=c,u=0),(0|l)<0&&(u=u-l|0,i[d>>2]=u,A=A-l|0,i[h>>2]=A,i[t>>2]=0,l=0),f=u-A|0,c=l-A|0,(0|A)<0?(i[d>>2]=f,i[t>>2]=c,i[h>>2]=0,u=f,A=0):c=l,(0|(l=(0|A)<(0|(l=(0|c)<(0|u)?c:u))?A:l))>0&&(i[d>>2]=u-l,i[t>>2]=c-l,i[h>>2]=A-l),i[n+48>>2]=i[e>>2],l=0|i[r>>2],A=0|i[a>>2],t=0|i[p+40>>2],h=0|i[p+44>>2],u=(0|i[p+36>>2])+(0|i[o>>2])|0,i[(d=n+52|0)>>2]=u,l=t+l|0,i[(t=n+56|0)>>2]=l,A=h+A|0,i[(h=n+60|0)>>2]=A,c=l-u|0,(0|u)<0&&(A=A-u|0,i[t>>2]=c,i[h>>2]=A,i[d>>2]=0,l=c,u=0),(0|l)<0&&(u=u-l|0,i[d>>2]=u,A=A-l|0,i[h>>2]=A,i[t>>2]=0,l=0),f=u-A|0,c=l-A|0,(0|A)<0?(i[d>>2]=f,i[t>>2]=c,i[h>>2]=0,u=f,A=0):c=l,(0|(l=(0|A)<(0|(l=(0|c)<(0|u)?c:u))?A:l))>0&&(i[d>>2]=u-l,i[t>>2]=c-l,i[h>>2]=A-l),i[n+64>>2]=i[e>>2],c=0|i[r>>2],A=0|i[a>>2],h=0|i[p+52>>2],d=0|i[p+56>>2],u=(0|i[p+48>>2])+(0|i[o>>2])|0,i[(t=n+68|0)>>2]=u,c=h+c|0,i[(h=n+72|0)>>2]=c,A=d+A|0,i[(d=n+76|0)>>2]=A,l=c-u|0,(0|u)<0?(A=A-u|0,i[h>>2]=l,i[d>>2]=A,i[t>>2]=0,c=0):(l=c,c=u),(0|l)<0&&(c=c-l|0,i[t>>2]=c,A=A-l|0,i[d>>2]=A,i[h>>2]=0,l=0),f=c-A|0,u=l-A|0,(0|A)<0?(i[t>>2]=f,i[h>>2]=u,i[d>>2]=0,c=f,A=0):u=l,(0|(l=(0|A)<(0|(l=(0|u)<(0|c)?u:c))?A:l))<=0||(i[t>>2]=c-l,i[h>>2]=u-l,i[d>>2]=A-l),N=s}function pe(e,t,n,r){e|=0,n|=0,r|=0;var a,o,s,A=0,l=0,c=0,u=0,f=0,d=0,h=0,p=0,m=0,g=0,b=0;if(d=0|i[16928+((t|=0)<<2)>>2],d=(s=!!(0|r))?3*d|0:d,u=0|i[(o=e+4|0)>>2],l=0|i[(a=e+8|0)>>2],s){if((0|(A=l+u+(r=0|i[(c=e+12|0)>>2])|0))==(0|d))return 0|(d=1);f=c}else r=A=0|i[(f=e+12|0)>>2],A=l+u+A|0;if((0|A)<=(0|d))return 0|(d=0);do{if((0|r)>0){if(A=0|i[e>>2],(0|l)>0){A=18608+(80*A|0)+60|0,c=u;break}A=18608+(80*A|0)+40|0,n?(n=((h=(0|(n=l+(c=u-d|0)|0))<0)?0:n)-((u=(0|(l=r+l-(h?n:0)|0))<0)?l:0)-((c=(0|(r=r+c-(h?n:0)-(u?l:0)|0))<0)?r:0)|0,l=(l=(u?0:l)-(c?r:0)|0)-((u=(0|(c=(0|(r=c?0:r))<(0|(c=(0|l)<(0|n)?l:n))?r:c))>0)?c:0)|0,r=r-(u?c:0)|0,c=n-(u?c:0)+d|0,i[o>>2]=c,i[a>>2]=l,i[f>>2]=r):c=u}else A=18608+(80*(0|i[e>>2])|0)+20|0,c=u}while(0);if(i[e>>2]=i[A>>2],(0|(u=0|i[A+16>>2]))>0){n=0;do{(0|(e=(0|(r=(l=(0|(c=r+l-(b=(p=(0|(h=r+c|0))<0)?h:0)-(e=(g=(0|(m=l+c-b|0))<0)?m:0)|0))<0)?0:c))<(0|(e=(0|(l=(g?0:m)-(c=l?c:0)|0))<(0|(c=(p?0:h)-e-c|0))?l:c))?r:e))>0&&(c=c-e|0,l=l-e|0,r=r-e|0),n=n+1|0}while((0|n)<(0|u));i[o>>2]=c,i[a>>2]=l,i[f>>2]=r}return m=0|i[16848+(t<<2)>>2],g=0|v(m=s?3*m|0:m,0|i[A+8>>2]),b=0|v(m,0|i[A+12>>2]),c=(0|v(m,0|i[A+4>>2]))+c|0,i[o>>2]=c,l=g+l|0,i[a>>2]=l,r=b+r|0,i[f>>2]=r,A=l-c|0,(0|c)<0?(r=r-c|0,i[a>>2]=A,i[f>>2]=r,i[o>>2]=0,l=0):(A=l,l=c),(0|A)<0?(e=l-A|0,i[o>>2]=e,r=r-A|0,i[f>>2]=r,i[a>>2]=0,c=0):(e=l,c=A),l=e-r|0,A=c-r|0,(0|r)<0?(i[o>>2]=l,i[a>>2]=A,i[f>>2]=0,r=0):(A=c,l=e),(0|(c=(0|r)<(0|(c=(0|A)<(0|l)?A:l))?r:c))>0&&(l=l-c|0,A=A-c|0,r=r-c|0,i[o>>2]=l,i[a>>2]=A,i[f>>2]=r),s?0|(b=(A+l+r|0)==(0|d)?1:2):0|(b=2)}function me(e,t){e|=0,t|=0;var n=0;do{n=0|pe(e,t,0,1)}while(2==(0|n));return 0|n}function ge(e,t,n,r,o){e|=0,t|=0,n|=0,r|=0,o|=0;var s,A,l,c,u,f,d,h,m,b,v,y,x,_,w,T,S,E,C,I,R,P,k,L,B,O,F,D,U=0,V=0,j=0,z=0,G=0,H=0,q=0;if(D=N,N=N+272|0,V=D+240|0,B=D,O=D+224|0,F=D+208|0,C=D+184|0,I=D+168|0,R=D+152|0,P=D+136|0,k=D+120|0,L=D+96|0,i[(U=D+256|0)>>2]=t,i[V>>2]=i[e>>2],i[V+4>>2]=i[e+4>>2],i[V+8>>2]=i[e+8>>2],i[V+12>>2]=i[e+12>>2],be(V,U,B),i[o>>2]=0,(0|(E=r+n+(6==(0|r)&1)|0))<=(0|n))N=D;else{v=n+6|0,y=F+8|0,x=C+8|0,_=16928+((b=0|i[U>>2])<<2)|0,w=I+8|0,T=R+8|0,S=P+8|0,h=0|i[V>>2],u=O+4|0,f=O+8|0,d=O+12|0,m=F+8|0,s=C+8|0,l=C+16|0,A=L+8|0,c=L+16|0,V=0,j=n,r=-1;e:for(;;){if(e=B+((U=(0|j)%6|0)<<4)|0,i[O>>2]=i[e>>2],i[O+4>>2]=i[e+4>>2],i[O+8>>2]=i[e+8>>2],i[O+12>>2]=i[e+12>>2],e=V,V=0|pe(O,b,0,1),(0|j)>(0|n)&!!(0|Le(t))&&1!=(0|e)&(0|(z=0|i[O>>2]))!=(0|r)){switch(e=0|i[B+((q=(U+5|0)%6|0)<<4)+12>>2],G=+((0|i[B+(q<<4)+8>>2])-e|0),a[F>>3]=+((0|i[B+(q<<4)+4>>2])-e|0)-.5*G,a[y>>3]=.8660254037844386*G,e=0|i[B+(U<<4)+12>>2],G=+((0|i[B+(U<<4)+8>>2])-e|0),a[C>>3]=+((0|i[B+(U<<4)+4>>2])-e|0)-.5*G,a[x>>3]=.8660254037844386*G,G=+(0|i[_>>2]),a[I>>3]=3*G,a[w>>3]=0,H=-1.5*G,a[R>>3]=H,a[T>>3]=2.598076211353316*G,a[P>>3]=H,a[S>>3]=-2.598076211353316*G,0|i[17008+(80*h|0)+(((0|r)==(0|h)?z:r)<<2)>>2]){case 1:e=R,r=I;break;case 3:e=P,r=R;break;case 2:e=I,r=P;break;default:e=8;break e}ft(F,C,r,e,k),0|dt(F,k)||0|dt(C,k)||(fe(k,h,b,1,L),q=0|i[o>>2],G=+p(+ +a[c>>3]),H=+g(+ +a[A>>3],+ +a[L>>3]),a[o+8+(q<<4)>>3]=G,a[o+8+(q<<4)+8>>3]=H,i[o>>2]=1+(0|i[o>>2]))}if((0|j)<(0|v)&&(q=0|i[d>>2],G=+((0|i[f>>2])-q|0),a[F>>3]=+((0|i[u>>2])-q|0)-.5*G,a[m>>3]=.8660254037844386*G,fe(F,0|i[O>>2],b,1,C),q=0|i[o>>2],G=+p(+ +a[l>>3]),H=+g(+ +a[s>>3],+ +a[C>>3]),a[o+8+(q<<4)>>3]=G,a[o+8+(q<<4)+8>>3]=H,i[o>>2]=1+(0|i[o>>2])),(0|(j=j+1|0))>=(0|E)){e=3;break}r=0|i[O>>2]}3!=(0|e)?8==(0|e)&&M(27157,27120,766,27202):N=D}}function be(e,t,n){e|=0,t|=0,n|=0;var r,a,o,s,A=0,l=0,c=0,u=0,f=0,d=0,h=0,p=0,m=0;s=N,N=N+160|0,l=s,u=20336,f=(c=A=s+80|0)+72|0;do{i[c>>2]=i[u>>2],c=c+4|0,u=u+4|0}while((0|c)<(0|f));u=20416,f=(c=l)+72|0;do{i[c>>2]=i[u>>2],c=c+4|0,u=u+4|0}while((0|c)<(0|f));m=(m=!(0|Le(0|i[t>>2])))?A:l,c=0|i[(o=e+4|0)>>2],A=0|i[(r=e+8|0)>>2],l=0|i[(a=e+12|0)>>2],u=A+(c<<1)|0,i[o>>2]=u,A=l+(A<<1)|0,i[r>>2]=A,c=(l<<1)+c|0,i[a>>2]=c,l=A-u|0,f=c-u|0,(0|u)<0&&(i[r>>2]=l,i[a>>2]=f,i[o>>2]=0,A=l,u=0,c=f),f=u-A|0,l=c-A|0,(0|A)<0?(i[o>>2]=f,i[a>>2]=l,i[r>>2]=0,A=0):(l=c,f=u),u=f-l|0,c=A-l|0,(0|l)<0?(i[o>>2]=u,i[r>>2]=c,i[a>>2]=0,l=0):(c=A,u=f),(0|(A=(0|l)<(0|(A=(0|c)<(0|u)?c:u))?l:A))>0&&(l=l-A|0,c=c-A|0,u=u-A|0,i[o>>2]=u,i[r>>2]=c,i[a>>2]=l),d=(c<<1)+u|0,f=l+(u<<1)|0,i[o>>2]=f,i[r>>2]=d,c=(l<<1)+c|0,i[a>>2]=c,A=d-f|0,l=c-f|0,(0|f)<0?(i[r>>2]=A,i[a>>2]=l,i[o>>2]=0,f=0,c=l):A=d,u=f-A|0,l=c-A|0,(0|A)<0?(i[o>>2]=u,i[a>>2]=l,i[r>>2]=0,f=u,A=0):l=c,u=f-l|0,c=A-l|0,(0|l)<0?(i[o>>2]=u,i[r>>2]=c,i[a>>2]=0,l=0):(c=A,u=f),(0|(A=(0|l)<(0|(A=(0|c)<(0|u)?c:u))?l:A))>0&&(i[o>>2]=u-A,i[r>>2]=c-A,i[a>>2]=l-A),0|Le(0|i[t>>2])&&(c=0|i[o>>2],A=(3*(u=0|i[r>>2])|0)+c|0,c=(l=0|i[a>>2])+(3*c|0)|0,i[o>>2]=c,i[r>>2]=A,u=(3*l|0)+u|0,i[a>>2]=u,l=A-c|0,f=u-c|0,(0|c)<0?(i[r>>2]=l,i[a>>2]=f,i[o>>2]=0,A=l,d=0):(d=c,f=u),c=d-A|0,l=f-A|0,(0|A)<0?(i[o>>2]=c,i[a>>2]=l,i[r>>2]=0,d=c,u=0):(u=A,l=f),c=d-l|0,A=u-l|0,(0|l)<0?(i[o>>2]=c,i[r>>2]=A,i[a>>2]=0,u=A,l=0):c=d,(0|(A=(0|l)<(0|(A=(0|u)<(0|c)?u:c))?l:A))>0&&(i[o>>2]=c-A,i[r>>2]=u-A,i[a>>2]=l-A),i[t>>2]=1+(0|i[t>>2])),d=0;do{i[n+(d<<4)>>2]=i[e>>2],l=0|i[r>>2],A=0|i[a>>2],h=0|i[m+(12*d|0)+4>>2],p=0|i[m+(12*d|0)+8>>2],u=(0|i[m+(12*d|0)>>2])+(0|i[o>>2])|0,i[(t=n+(d<<4)+4|0)>>2]=u,l=h+l|0,i[(h=n+(d<<4)+8|0)>>2]=l,A=p+A|0,i[(p=n+(d<<4)+12|0)>>2]=A,c=l-u|0,(0|u)<0&&(A=A-u|0,i[h>>2]=c,i[p>>2]=A,i[t>>2]=0,l=c,u=0),(0|l)<0&&(u=u-l|0,i[t>>2]=u,A=A-l|0,i[p>>2]=A,i[h>>2]=0,l=0),f=u-A|0,c=l-A|0,(0|A)<0?(i[t>>2]=f,i[h>>2]=c,i[p>>2]=0,u=f,A=0):c=l,(0|(l=(0|A)<(0|(l=(0|c)<(0|u)?c:u))?A:l))>0&&(i[t>>2]=u-l,i[h>>2]=c-l,i[p>>2]=A-l),d=d+1|0}while(6!=(0|d));N=s}function ve(e,t){return t=0|Vt(0|(e|=0),0|(t|=0),52),S(),15&t}function ye(e,t){return t=0|Vt(0|(e|=0),0|(t|=0),45),S(),127&t}function xe(e,t){e|=0;var n=0,i=0,a=0,o=0;return!0&134217728==(-16777216&(t|=0))?(i=0|Vt(0|e,0|t,52),S(),i&=15,n=0|Vt(0|e,0|t,45),S(),(n&=127)>>>0>121?0|(e=0):!(613566756&(o=0|jt(0|(a=0|Vt(0|e,0|t,0|(o=3*(15^i)|0))),0|S(),0|o))&(0|Nt(-1227133514,-1171,0|o,0|(a=0|S()))))&!(4681&a&S())&&15==(0|i)|!(0|(o=0|Vt(0|(0|jt(0|~e,0|~t,0|(o=19+(3*i|0)|0))),0|S(),0|o)))&!(0|S())?0|r[20496+n|0]?!(0|e)&!(0|(t&=8191))?0|(o=1):(o=0|zt(0|e,0|t,0),S(),0|!!((63-o|0)%3|0)):0|(o=1):0|(o=0)):0|(e=0)}function _e(e,t,n,r){e|=0,n|=0,r|=0;var a=0,o=0,s=0,A=0;if(a=0|jt(0|(t|=0),0,52),o=0|S(),n=0|jt(0|n,0,45),n=0|o|S()|134225919,(0|t)<1)return o=-1,r=n,i[(t=e)>>2]=o,void(i[(e=e+4|0)>>2]=r);for(o=1,a=-1;A=0|jt(7,0,0|(s=3*(15-o|0)|0)),n&=~S(),a=a&~A|(s=0|jt(0|r,0,0|s)),n=0|n|S(),(0|o)!=(0|t);)o=o+1|0;i[(s=A=e)>>2]=a,i[(A=A+4|0)>>2]=n}function we(e,t,n,r){n|=0,r|=0;var a=0,o=0;if(o=0|Vt(0|(e|=0),0|(t|=0),52),S(),n>>>0>15)return 0|(r=4);if((0|(o&=15))<(0|n))return 0|(r=12);if((0|o)==(0|n))return i[r>>2]=e,i[r+4>>2]=t,0|(r=0);if(a=0|jt(0|n,0,52),a|=e,e=S()|-15728641&t,(0|o)>(0|n))do{t=0|jt(7,0,3*(14-n|0)|0),n=n+1|0,a|=t,e=0|S()|e}while((0|n)<(0|o));return i[r>>2]=a,i[r+4>>2]=e,0|(r=0)}function Te(e,t,n,r){n|=0,r|=0;var a=0,o=0,s=0;if(o=0|Vt(0|(e|=0),0|(t|=0),52),S(),!((0|n)<16&(0|(o&=15))<=(0|n)))return 0|(r=4);a=n-o|0,n=0|Vt(0|e,0|t,45),S();e:do{if(0|G(127&n)){t:do{if(0|o){for(n=1;!((s=0|jt(7,0,3*(15-n|0)|0))&e|0)&!((0|S())&t);){if(!(n>>>0<o>>>0))break t;n=n+1|0}n=0|Ze(7,0,a,((0|a)<0)<<31>>31),a=0|S();break e}}while(0);n=0|Pt(0|(n=0|Ot(0|(n=0|Ze(7,0,a,((0|a)<0)<<31>>31)),0|S(),5,0)),0|S(),-5,-1),n=0|Pt(0|(n=0|Bt(0|n,0|S(),6,0)),0|S(),1,0),a=0|S()}else n=0|Ze(7,0,a,((0|a)<0)<<31>>31),a=0|S()}while(0);return i[(s=r)>>2]=n,i[s+4>>2]=a,0|(s=0)}function Se(e,t){var n=0,r=0,i=0;if(i=0|Vt(0|(e|=0),0|(t|=0),45),S(),!(0|G(127&i)))return 0|(i=0);i=0|Vt(0|e,0|t,52),S(),i&=15;e:do{if(i)for(r=1;;){if(n=0|Vt(0|e,0|t,3*(15-r|0)|0),S(),0|(n&=7))break e;if(!(r>>>0<i>>>0)){n=0;break}r=r+1|0}else n=0}while(0);return 0|(i=1&!(0|n))}function Me(e,t,n,r){return e|=0,t|=0,(0|(r|=0))<(0|(n|=0))?(r=e,T(0|(n=t)),0|r):(n=0|jt(-1,-1,3+(3*(r-n|0)|0)|0),r=0|jt(0|~n,0|~S(),3*(15-r|0)|0),n=~S()&t,r=~r&e,T(0|n),0|r)}function Ee(e,t,n,r){n|=0,r|=0;var a=0;return a=0|Vt(0|(e|=0),0|(t|=0),52),S(),(0|n)<16&(0|(a&=15))<=(0|n)?((0|a)<(0|n)&&(a=0|jt(-1,-1,3+(3*(n+-1-a|0)|0)|0),a=0|jt(0|~a,0|~S(),3*(15-n|0)|0),t=~S()&t,e&=~a),a=0|jt(0|n,0,52),n=-15728641&t|S(),i[r>>2]=e|a,i[r+4>>2]=n,0|(r=0)):0|(r=4)}function Ce(e,t){var n=0,r=0,i=0;if(i=0|Vt(0|(e|=0),0|(t|=0),52),S(),!(i&=15))return 0|(i=0);for(r=1;;){if(n=0|Vt(0|e,0|t,3*(15-r|0)|0),S(),0|(n&=7)){r=5;break}if(!(r>>>0<i>>>0)){n=0,r=5;break}r=r+1|0}return 5==(0|r)?0|n:0}function Ie(e,t){var n=0,r=0,i=0,a=0,o=0,s=0,A=0,l=0,c=0;if(c=0|Vt(0|(e|=0),0|(t|=0),52),S(),!(c&=15))return c=e,T(0|(l=t)),0|c;for(l=1,n=0;;){switch(a=e&~(s=0|jt(7,0,0|(r=3*(15-l|0)|0))),o=t&~(A=0|S()),e=0|Vt(0|e,0|t,0|r),S(),7&e){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;break;default:e&=7}e=(r=0|jt(0|e,0,0|r))|a,t=(i=0|S())|o;e:do{if(!n)if(!(r&s|0)&!(i&A|0))n=0;else if(o=0|Vt(0|e,0|t,52),S(),o&=15){n=1;t:for(;;){switch(A=0|Vt(0|e,0|t,3*(15-n|0)|0),S(),7&A){case 1:break t;case 0:break;default:n=1;break e}if(!(n>>>0<o>>>0)){n=1;break e}n=n+1|0}for(a=1;;){switch(n=0|Vt(0|e,0|t,0|(i=3*(15-a|0)|0)),S(),r=e&~(r=0|jt(7,0,0|i)),t&=~S(),7&n){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;break;default:e=7&n}if(e=0|jt(0|e,0,0|i),e|=r,t=0|S()|t,!(a>>>0<o>>>0)){n=1;break e}a=a+1|0}}else n=1}while(0);if(!(l>>>0<c>>>0))break;l=l+1|0}return T(0|t),0|e}function Re(e,t){var n=0,r=0,i=0,a=0,o=0;if(o=0|Vt(0|(e|=0),0|(t|=0),52),S(),!(o&=15))return o=e,T(0|(a=t)),0|o;for(a=1;;){switch(n=0|Vt(0|e,0|t,0|(i=3*(15-a|0)|0)),S(),r=e&~(r=0|jt(7,0,0|i)),t&=~S(),7&n){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;break;default:e=7&n}if(e=0|jt(0|e,0,0|i),e|=r,t=0|S()|t,!(a>>>0<o>>>0))break;a=a+1|0}return T(0|t),0|e}function Pe(e,t){var n=0,r=0,i=0,a=0,o=0,s=0,A=0,l=0,c=0;if(c=0|Vt(0|(e|=0),0|(t|=0),52),S(),!(c&=15))return c=e,T(0|(l=t)),0|c;for(l=1,n=0;;){switch(a=e&~(s=0|jt(7,0,0|(r=3*(15-l|0)|0))),o=t&~(A=0|S()),e=0|Vt(0|e,0|t,0|r),S(),7&e){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;break;default:e&=7}e=(r=0|jt(0|e,0,0|r))|a,t=(i=0|S())|o;e:do{if(!n)if(!(r&s|0)&!(i&A|0))n=0;else if(o=0|Vt(0|e,0|t,52),S(),o&=15){n=1;t:for(;;){switch(A=0|Vt(0|e,0|t,3*(15-n|0)|0),S(),7&A){case 1:break t;case 0:break;default:n=1;break e}if(!(n>>>0<o>>>0)){n=1;break e}n=n+1|0}for(a=1;;){switch(r=e&~(r=0|jt(7,0,0|(n=3*(15-a|0)|0))),i=t&~S(),e=0|Vt(0|e,0|t,0|n),S(),7&e){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;break;default:e&=7}if(e=0|jt(0|e,0,0|n),e|=r,t=0|S()|i,!(a>>>0<o>>>0)){n=1;break e}a=a+1|0}}else n=1}while(0);if(!(l>>>0<c>>>0))break;l=l+1|0}return T(0|t),0|e}function Ne(e,t){var n=0,r=0,i=0,a=0,o=0;if(o=0|Vt(0|(e|=0),0|(t|=0),52),S(),!(o&=15))return o=e,T(0|(a=t)),0|o;for(a=1;;){switch(n=e&~(n=0|jt(7,0,0|(r=3*(15-a|0)|0))),i=t&~S(),e=0|Vt(0|e,0|t,0|r),S(),7&e){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;break;default:e&=7}if(e=0|jt(0|e,0,0|r),e|=n,t=0|S()|i,!(a>>>0<o>>>0))break;a=a+1|0}return T(0|t),0|e}function ke(e,t){e|=0;var n,r=0,a=0,o=0,s=0,A=0,l=0,c=0,u=0,f=0,d=0,h=0,p=0,m=0,g=0,b=0,v=0,y=0,x=0,_=0,w=0,M=0;if(n=N,N=N+16|0,x=n,jt(0|(t|=0),0,52),r=134225919|S(),!t)return(0|i[e+4>>2])>2||(0|i[e+8>>2])>2||(0|i[e+12>>2])>2?(x=0,T(0|(y=0)),N=n,0|x):(jt(0|q(e),0,45),y=0|S()|r,x=-1,T(0|y),N=n,0|x);i[x>>2]=i[e>>2],i[x+4>>2]=i[e+4>>2],i[x+8>>2]=i[e+8>>2],i[x+12>>2]=i[e+12>>2],y=x+4|0;e:do{if((0|t)>0)for(b=x+12|0,m=t,d=0|i[(g=x+8|0)>>2],h=0|i[b>>2],t=-1,f=0|i[x+4>>2];;){p=m,m=m+-1|0,e=f-h|0,a=d-h|0,1&p?(s=0|St(.14285714285714285*+((3*e|0)-a|0)),i[y>>2]=s,e=0|St(.14285714285714285*+((a<<1)+e|0)),i[g>>2]=e,i[b>>2]=0,a=e-s|0,o=0-s|0,(0|s)<0?(i[g>>2]=a,i[b>>2]=o,i[y>>2]=0,e=a,A=0):(A=s,o=0),s=A-e|0,a=o-e|0,(0|e)<0?(i[y>>2]=s,i[b>>2]=a,i[g>>2]=0,A=s,s=0):(a=o,s=e),e=A-a|0,o=s-a|0,(0|a)<0?(i[y>>2]=e,i[g>>2]=o,i[b>>2]=0,s=0):(o=s,e=A,s=a),(0|(a=(0|s)<(0|(a=(0|o)<(0|e)?o:e))?s:a))>0&&(s=s-a|0,o=o-a|0,e=e-a|0,i[y>>2]=e,i[g>>2]=o,i[b>>2]=s),c=(u=(0|(l=(0|(M=(l=(0|(a=(3*s|0)+e-((_=(0|(w=o+(3*e|0)|0))<0)?w:0)-((c=(0|(u=s+(3*o|0)-(_?w:0)|0))<0)?u:0)|0))<0)?0:a))<(0|(l=(0|(A=(c?0:u)-(l?a:0)|0))<(0|(a=(_?0:w)-(c?u:0)-(l?a:0)|0))?A:a))?M:l))>0)?l:0,A=A-(u?l:0)|0,l=M-(u?l:0)|0,u=s):(l=0|St(.14285714285714285*+((e<<1)+a|0)),i[y>>2]=l,o=0|St(.14285714285714285*+((3*a|0)-e|0)),i[g>>2]=o,i[b>>2]=0,a=o-l|0,e=0-l|0,(0|l)<0?(i[g>>2]=a,i[b>>2]=e,i[y>>2]=0,o=a,l=0):e=0,A=l-o|0,a=e-o|0,(0|o)<0?(i[y>>2]=A,i[b>>2]=a,i[g>>2]=0,s=a,o=0):(s=e,A=l),e=A-s|0,a=o-s|0,(0|s)<0?(i[y>>2]=e,i[g>>2]=a,i[b>>2]=0,o=a,s=0):e=A,(0|(a=(0|s)<(0|(a=(0|o)<(0|e)?o:e))?s:a))>0&&(s=s-a|0,o=o-a|0,e=e-a|0,i[y>>2]=e,i[g>>2]=o,i[b>>2]=s),c=(u=(0|(l=(0|(_=(l=(0|(a=(3*s|0)+o-((M=(0|(w=s+(3*e|0)|0))<0)?w:0)-((c=(0|(u=(3*o|0)+e-(M?w:0)|0))<0)?u:0)|0))<0)?0:a))<(0|(l=(0|(A=(c?0:u)-(l?a:0)|0))<(0|(a=(M?0:w)-(c?u:0)-(l?a:0)|0))?A:a))?_:l))>0)?l:0,A=A-(u?l:0)|0,l=_-(u?l:0)|0,u=s),l=(f=(0|(h=h-l+((s=(0|(a=f+(c-a)|0))<0)?0-a|0:0)+((A=(0|(c=d-A-(s?a:0)|0))<0)?0-c|0:0)|0))<0)?0:h,M=(A?0:c)-(f?h:0)|0,h=(h=(s?0:a)-(A?c:0)-(f?h:0)|0)-((c=(0|(f=(0|l)<(0|(f=(0|M)<(0|h)?M:h))?l:f))>0)?f:0)|0,a=t&~(a=0|jt(7,0,0|(A=3*(15-p|0)|0))),s=r&~S(),t=(t=(r=(0|(w=l-(c?f:0)-(w=(d=(0|h)<0)?h:0)+((_=(0|(M=M-(c?f:0)-w|0))<0)?0-M|0:0)|0))<0)?0:w)-(M=(0|(M=(0|t)<(0|(M=(0|(r=(_?0:M)-(w=r?w:0)|0))<(0|(w=(d?0:h)-(_?M:0)-w|0))?r:w))?t:M))>0?M:0)|0,r=r-M|0;t:do{switch(w-M|0){case 0:switch(0|r){case 0:t=0|t?1==(0|t)?1:7:0;break t;case 1:t=0|t?1==(0|t)?3:7:2;break t;default:v=36;break t}case 1:switch(0|r){case 0:t=0|t?1==(0|t)?5:7:4;break t;case 1:if(t){v=36;break t}t=6;break t;default:v=36;break t}default:v=36}}while(0);if(36==(0|v)&&(v=0,t=7),t=0|jt(0|t,0,0|A),t|=a,r=0|S()|s,(0|p)<=1)break e;d=o,h=u,f=e}else t=-1,e=0|i[y>>2]}while(0);e:do{if((0|e)<=2&&(0|i[x+8>>2])<=2&&(0|i[x+12>>2])<=2){if(t|=e=0|jt(0|(a=0|q(x)),0,45),e=S()|-1040385&r,c=0|Q(x),!(0|G(a))){if((0|c)<=0)break;for(l=0;;){A=0|Vt(0|t,0|e,52),S(),A&=15;t:do{if(A)for(s=1;;){switch(r=0|Vt(0|t,0|e,0|(o=3*(15-s|0)|0)),S(),t&=~(a=0|jt(7,0,0|o)),a=e&~S(),7&r){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;break;default:e=7&r}if(t|=e=0|jt(0|e,0,0|o),e=0|S()|a,!(s>>>0<A>>>0))break t;s=s+1|0}}while(0);if((0|(l=l+1|0))==(0|c))break e}}A=0|Vt(0|t,0|e,52),S(),A&=15;t:do{if(A){r=1;n:for(;;){switch(M=0|Vt(0|t,0|e,3*(15-r|0)|0),S(),7&M){case 1:break n;case 0:break;default:break t}if(!(r>>>0<A>>>0))break t;r=r+1|0}if(0|K(a,0|i[x>>2]))for(s=1;;){switch(a=t&~(a=0|jt(7,0,0|(r=3*(15-s|0)|0))),o=e&~S(),e=0|Vt(0|t,0|e,0|r),S(),7&e){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;break;default:e&=7}if(t=0|jt(0|e,0,0|r),t|=a,e=0|S()|o,!(s>>>0<A>>>0))break t;s=s+1|0}else for(s=1;;){switch(r=0|Vt(0|t,0|e,0|(o=3*(15-s|0)|0)),S(),t&=~(a=0|jt(7,0,0|o)),a=e&~S(),7&r){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;break;default:e=7&r}if(t|=e=0|jt(0|e,0,0|o),e=0|S()|a,!(s>>>0<A>>>0))break t;s=s+1|0}}}while(0);if((0|c)>0){r=0;do{t=0|Ie(t,e),e=0|S(),r=r+1|0}while((0|r)!=(0|c))}}else t=0,e=0}while(0);return M=t,T(0|(w=e)),N=n,0|M}function Le(e){return(0|(e|=0))%2|0}function Be(e,t,n){n|=0;var r,s,A,l,c=0,d=0,h=0,p=0,m=0;if(A=N,N=N+64|0,s=A+24|0,p=A+48|0,m=A,(t|=0)>>>0>15)return N=A,0|(m=4);if(r=+a[(e|=0)>>3],a[o>>3]=r,!(2146435072&~i[o+4>>2]))return N=A,0|(m=3);if(c=+a[e+8>>3],a[o>>3]=c,!(2146435072&~i[o+4>>2]))return N=A,0|(m=3);l=(d=+u(+r))*+u(+c),d*=+f(+c),c=+f(+r),a[m>>3]=l,a[m+8>>3]=d,a[m+16>>3]=c,a[o>>3]=l;do{if(2146435072&~i[o+4>>2]&&(a[o>>3]=c,e=0|i[o+4>>2],a[o>>3]=d,!(!(2146435072&~i[o+4>>2])|!0&!(2146435072&~e)))){if(i[s>>2]=i[m>>2],i[s+4>>2]=i[m+4>>2],i[s+8>>2]=i[m+8>>2],i[s+12>>2]=i[m+12>>2],i[s+16>>2]=i[m+16>>2],i[s+20>>2]=i[m+20>>2],ce(s,t,p),p=0|ke(p,t),m=0|S(),i[n>>2]=p,i[n+4>>2]=m,!(!(0|p)&!(0|m))){h=0;break}M(27634,27225,1073,27248)}else h=2}while(0);return N=A,0|(m=h)}function Oe(e,t,n){var r,a,o=0,s=0,A=0,l=0,c=0,u=0,f=0,d=0,h=0,p=0;if(a=(n|=0)+4|0,p=0|Vt(0|(e|=0),0|(t|=0),52),S(),p&=15,h=0|Vt(0|e,0|t,45),S(),o=!(0|p),0|G(127&h)){if(o)return 0|(p=1);o=1}else{if(o)return 0|(p=0);o=0|i[a>>2]||0|i[n+8>>2]?1:1&!!(0|i[n+12>>2])}for(h=n+8|0,r=n+12|0,d=1,n=0|i[a>>2],l=0|i[h>>2],A=0|i[r>>2];s=3*n|0,c=3*l|0,f=3*A|0,1&d?(u=l+s|0,i[a>>2]=u,A=A+c|0,i[h>>2]=A,s=f+n|0,i[r>>2]=s,n=A-u|0,l=s-u|0,(0|u)<0?(i[h>>2]=n,i[r>>2]=l,i[a>>2]=0,c=0,s=l):(n=A,c=u),l=c-n|0,A=s-n|0,(0|n)<0?(i[a>>2]=l,i[r>>2]=A,i[h>>2]=0,c=l,s=0):(A=s,s=n),n=c-A|0,l=s-A|0,(0|A)<0?(i[a>>2]=n,i[h>>2]=l,i[r>>2]=0,A=0):(l=s,n=c),(0|(s=(0|A)<(0|(s=(0|l)<(0|n)?l:n))?A:s))>0&&(A=A-s|0,l=l-s|0,n=n-s|0,i[a>>2]=n,i[h>>2]=l,i[r>>2]=A)):(u=c+n|0,c=A+s|0,i[a>>2]=c,i[h>>2]=u,s=f+l|0,i[r>>2]=s,n=u-c|0,A=s-c|0,(0|c)<0?(i[h>>2]=n,i[r>>2]=A,i[a>>2]=0,c=0,s=A):n=u,l=c-n|0,A=s-n|0,(0|n)<0?(i[a>>2]=l,i[r>>2]=A,i[h>>2]=0,c=l,s=0):(A=s,s=n),n=c-A|0,l=s-A|0,(0|A)<0?(i[a>>2]=n,i[h>>2]=l,i[r>>2]=0,A=0):(l=s,n=c),(0|(s=(0|A)<(0|(s=(0|l)<(0|n)?l:n))?A:s))>0&&(A=A-s|0,l=l-s|0,n=n-s|0,i[a>>2]=n,i[h>>2]=l,i[r>>2]=A)),s=0|Vt(0|e,0|t,3*(15-d|0)|0),S(),((s&=7)+-1|0)>>>0<6&&(u=0|i[22032+(12*s|0)+4>>2],f=0|i[22032+(12*s|0)+8>>2],c=(0|i[22032+(12*s|0)>>2])+n|0,i[a>>2]=c,l=u+l|0,i[h>>2]=l,n=f+A|0,i[r>>2]=n,A=l-c|0,s=n-c|0,(0|c)<0&&(i[h>>2]=A,i[r>>2]=s,i[a>>2]=0,c=0,n=s,l=A),s=c-l|0,A=n-l|0,(0|l)<0?(i[a>>2]=s,i[r>>2]=A,i[h>>2]=0,c=s,l=0):A=n,n=c-A|0,s=l-A|0,(0|A)<0?(i[a>>2]=n,i[h>>2]=s,i[r>>2]=0,l=s,A=0):n=c,(0|(s=(0|A)<(0|(s=(0|l)<(0|n)?l:n))?A:s))>0&&(A=A-s|0,l=l-s|0,n=n-s|0,i[a>>2]=n,i[h>>2]=l,i[r>>2]=A)),d>>>0<p>>>0;)d=d+1|0;return 0|o}function Fe(e,t,n){n|=0;var r,a,o,s=0,A=0,l=0,c=0,u=0,f=0,d=0,h=0,p=0;if(o=N,N=N+16|0,a=o,h=0|Vt(0|(e|=0),0|(t|=0),45),S(),(h&=127)>>>0>121)return i[n>>2]=0,i[n+4>>2]=0,i[n+8>>2]=0,i[n+12>>2]=0,N=o,0|(p=5);e:do{if(0|G(h)&&(u=0|Vt(0|e,0|t,52),S(),u&=15,0|u)){s=1;t:for(;;){switch(p=0|Vt(0|e,0|t,3*(15-s|0)|0),S(),7&p){case 5:break t;case 0:break;default:d=t;break e}if(!(s>>>0<u>>>0)){d=t;break e}s=s+1|0}for(c=1,s=t;;){switch(A=e&~(A=0|jt(7,0,0|(t=3*(15-c|0)|0))),l=s&~S(),s=0|Vt(0|e,0|s,0|t),S(),7&s){case 1:s=3;break;case 3:s=2;break;case 2:s=6;break;case 6:s=4;break;case 4:s=5;break;case 5:s=1;break;default:s&=7}if(e=0|jt(0|s,0,0|t),e|=A,s=0|S()|l,!(c>>>0<u>>>0)){d=s;break e}c=c+1|0}}else d=t}while(0);if(p=7696+(28*h|0)|0,i[n>>2]=i[p>>2],i[n+4>>2]=i[p+4>>2],i[n+8>>2]=i[p+8>>2],i[n+12>>2]=i[p+12>>2],!(0|Oe(e,d,n)))return N=o,0|(p=0);if(p=n+4|0,i[a>>2]=i[p>>2],i[a+4>>2]=i[p+4>>2],i[a+8>>2]=i[p+8>>2],f=0|Vt(0|e,0|d,52),S(),r=15&f,1&f?(l=0|i[p>>2],s=(3*(A=0|i[(u=n+8|0)>>2])|0)+l|0,l=(t=0|i[(f=n+12|0)>>2])+(3*l|0)|0,i[p>>2]=l,i[u>>2]=s,A=(3*t|0)+A|0,i[f>>2]=A,t=s-l|0,c=A-l|0,(0|l)<0&&(i[u>>2]=t,i[f>>2]=c,i[p>>2]=0,s=t,l=0,A=c),c=l-s|0,t=A-s|0,(0|s)<0?(i[p>>2]=c,i[f>>2]=t,i[u>>2]=0,s=0):(t=A,c=l),l=c-t|0,A=s-t|0,(0|t)<0?(i[p>>2]=l,i[u>>2]=A,i[f>>2]=0,t=0):(A=s,l=c),(0|(s=(0|t)<(0|(s=(0|A)<(0|l)?A:l))?t:s))>0&&(i[p>>2]=l-s,i[u>>2]=A-s,i[f>>2]=t-s),A=r+1|0):A=r,0|G(h)){e:do{if(r)for(t=1;;){if(s=0|Vt(0|e,0|d,3*(15-t|0)|0),S(),0|(s&=7))break e;if(!(t>>>0<r>>>0)){s=0;break}t=t+1|0}else s=0}while(0);s=4==(0|s)&1}else s=0;if(0|pe(n,A,s,0)){if(0|G(h))do{}while(0|pe(n,A,0,0));(0|A)!=(0|r)&&(e=0|i[(u=n+12|0)>>2],t=0|St(.14285714285714285*+(((s=(0|i[p>>2])-e|0)<<1)+(e=(0|i[(c=n+8|0)>>2])-e|0)|0)),i[p>>2]=t,s=0|St(.14285714285714285*+((3*e|0)-s|0)),i[c>>2]=s,i[u>>2]=0,e=s-t|0,A=0-t|0,(0|t)<0?(i[c>>2]=e,i[u>>2]=A,i[p>>2]=0,s=e,t=0):A=0,l=t-s|0,e=A-s|0,(0|s)<0?(i[p>>2]=l,i[u>>2]=e,i[c>>2]=0,t=l,s=0):e=A,l=t-e|0,A=s-e|0,(0|e)<0?(i[p>>2]=l,i[c>>2]=A,i[u>>2]=0,t=l,e=0):A=s,(0|(s=(0|e)<(0|(s=(0|A)<(0|t)?A:t))?e:s))>0&&(i[p>>2]=t-s,i[c>>2]=A-s,i[u>>2]=e-s))}else(0|A)!=(0|r)&&(i[p>>2]=i[a>>2],i[p+4>>2]=i[a+4>>2],i[p+8>>2]=i[a+8>>2]);return N=o,0|(p=0)}function De(e,t,n){n|=0;var r,i,o,s=0,A=0,l=0;return o=N,N=N+48|0,i=o,(s=0|Fe(e|=0,t|=0,r=o+24|0))?(N=o,0|s):(s=0|Vt(0|e,0|t,52),S(),ue(r,15&s,i),l=+p(+ +a[i+16>>3]),A=+g(+ +a[i+8>>3],+ +a[i>>3]),a[n>>3]=l,a[n+8>>3]=A,N=o,0|(s=0))}function Ue(e,t,n){n|=0;var r,i=0,a=0,o=0;if(r=N,N=N+16|0,0|(i=0|Fe(e|=0,t|=0,o=r)))return N=r,0|(o=i);i=0|Vt(0|e,0|t,45),S(),i=!(0|G(127&i)),a=0|Vt(0|e,0|t,52),S(),a&=15;e:do{if(!i){if(0|a)for(i=1;;){if(!(!((0|jt(7,0,3*(15-i|0)|0))&e|0)&!((0|S())&t)))break e;if(!(i>>>0<a>>>0))break;i=i+1|0}return de(o,a,0,5,n),N=r,0|0}}while(0);return ge(o,a,0,6,n),N=r,0|0}function Ve(e,t){t|=0;var n=0,r=0,a=0,o=0,s=0,A=0,l=0;if((e|=0)>>>0>15)return 0|(A=4);if(jt(0|e,0,52),A=134225919|S(),!e){n=0,r=0;do{0|G(r)&&(jt(0|r,0,45),s=0|A|S(),i[(e=t+(n<<3)|0)>>2]=-1,i[e+4>>2]=s,n=n+1|0),r=r+1|0}while(122!=(0|r));return 0|(n=0)}n=0,s=0;do{if(0|G(s)){for(jt(0|s,0,45),r=1,a=-1,o=0|A|S();a&=~(l=0|jt(7,0,3*(15-r|0)|0)),o&=~S(),(0|r)!=(0|e);)r=r+1|0;i[(l=t+(n<<3)|0)>>2]=a,i[l+4>>2]=o,n=n+1|0}s=s+1|0}while(122!=(0|s));return 0|(n=0)}function je(e,t,n,r){e|=0,r|=0;var a=0,o=0,s=0;a=0|Vt(0|(t|=0),0|(n|=0),52),S(),!(0|t)&!(0|n)|(0|r)>15|(0|(a&=15))>(0|r)?(o=-1,t=-1,n=0,a=0):(t=0|Me(t,n,a+1|0,r),s=-15728641&S(),n=0|jt(0|r,0,52),o=a,t=(t=!(0|Se(n|=t,s=0|s|S())))?-1:r,a=s),i[(s=e)>>2]=n,i[s+4>>2]=a,i[e+8>>2]=o,i[e+12>>2]=t}function ze(e,t,n,r){n|=0,r|=0;var a=0,o=0;return a=0|Vt(0|(e|=0),0|(t|=0),52),S(),a&=15,i[(o=r+8|0)>>2]=a,!(0|e)&!(0|t)|(0|n)>15|(0|a)>(0|n)?(i[(n=r)>>2]=0,i[n+4>>2]=0,i[o>>2]=-1,void(i[r+12>>2]=-1)):(e=0|Me(e,t,a+1|0,n),o=-15728641&S(),a=0|jt(0|n,0,52),a|=e,o=0|o|S(),i[(e=r)>>2]=a,i[e+4>>2]=o,e=r+12|0,0|Se(a,o)?void(i[e>>2]=n):void(i[e>>2]=-1))}function Ge(e){var t,n=0,r=0,a=0,o=0,s=0,A=0,l=0,c=0;if(!(!(0|(n=0|i[(r=e|=0)>>2]))&!(0|(r=0|i[r+4>>2]))||(a=0|Vt(0|n,0|r,52),S(),n=0|Pt(0|(l=0|jt(1,0,3*(15^(a&=15))|0)),0|S(),0|n,0|r),r=0|S(),i[(l=e)>>2]=n,i[l+4>>2]=r,(0|a)<(0|(A=0|i[(l=e+8|0)>>2]))))){for(t=e+12|0,s=a;;){if((0|s)==(0|A)){a=5;break}if(c=(0|s)==(0|i[t>>2]),a=0|Vt(0|n,0|r,0|(o=3*(15-s|0)|0)),S(),c&1==(0|(a&=7))&!0){a=7;break}if(!(7==(0|a)&!0)){a=10;break}if(n=0|Pt(0|n,0|r,0|(c=0|jt(1,0,0|o)),0|S()),r=0|S(),i[(c=e)>>2]=n,i[c+4>>2]=r,!((0|s)>(0|A))){a=10;break}s=s+-1|0}if(5==(0|a))return i[(c=e)>>2]=0,i[c+4>>2]=0,i[l>>2]=-1,void(i[t>>2]=-1);if(7==(0|a))return A=0|Pt(0|n,0|r,0|(A=0|jt(1,0,0|o)),0|S()),l=0|S(),i[(c=e)>>2]=A,i[c+4>>2]=l,void(i[t>>2]=s+-1)}}function He(e){var t;return t=(e=+e)<0?e+6.283185307179586:e,+(e>=6.283185307179586?t+-6.283185307179586:t)}function qe(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 Qe(e,t){e|=0;var n,r,i,o=0;return r=+a[(t|=0)>>3],n=+a[e>>3],o=(i=+f(.5*(r-n)))*i+(o=+f(.5*(+a[t+8>>3]-+a[e+8>>3])))*(+u(+r)*+u(+n)*o),2*+g(+ +c(+o),+ +c(+(1-o)))*6371.007180918475}function Ke(e,t){return t|=0,(e|=0)>>>0>15?0|(t=4):(a[t>>3]=+a[20624+(e<<3)>>3],0|(t=0))}function We(e,t){t|=0;var n=0;return(e|=0)>>>0>15?0|(t=4):(n=0|Ot(0|(n=0|Ze(7,0,e,((0|e)<0)<<31>>31)),0|S(),120,0),e=0|S(),i[t>>2]=2|n,i[t+4>>2]=e,0|(t=0))}function $e(e,t,n,a,o){n|=0,a|=0,o|=0;var s,A=0,l=0,c=0,u=0,f=0,d=0,h=0,p=0,m=0,g=0,b=0,v=0,y=0;if(s=N,N=N+16|0,v=s,d=0|Vt(0|(e|=0),0|(t|=0),52),S(),d&=15,m=0|Vt(0|n,0|a,52),S(),(0|d)!=(15&m))return N=s,0|(v=12);if(u=0|Vt(0|e,0|t,45),S(),u&=127,f=0|Vt(0|n,0|a,45),S(),u>>>0>121|(f&=127)>>>0>121)return N=s,0|(v=5);if(m=(0|u)!=(0|f)){if(7==(0|(l=0|$(u,f))))return N=s,0|(v=1);7==(0|(c=0|$(f,u)))?M(27291,27315,164,27325):(b=l,A=c)}else b=0,A=0;h=0|G(u),p=0|G(f),i[v>>2]=0,i[v+4>>2]=0,i[v+8>>2]=0,i[v+12>>2]=0;do{if(b){l=(0|(f=0|i[4272+(28*u|0)+(b<<2)>>2]))>0;e:do{if(p)if(l)for(u=0,c=n,l=a;;){switch(c=0|Pe(c,l),l=0|S(),0|A){case 5:case 1:A=3;break;case 3:A=2;break;case 2:A=6;break;case 6:A=4;break;case 4:A=5}if((0|(u=u+1|0))==(0|f)){f=A,u=c,c=l;break e}}else f=A,u=n,c=a;else if(l)for(u=0,c=n,l=a;;){switch(c=0|Ne(c,l),l=0|S(),0|A){case 1:A=3;break;case 3:A=2;break;case 2:A=6;break;case 6:A=4;break;case 4:A=5;break;case 5:A=1}if((0|(u=u+1|0))==(0|f)){f=A,u=c,c=l;break e}}else f=A,u=n,c=a}while(0);if(Oe(u,c,v),m||M(27340,27315,194,27325),(l=!!(0|h))&(A=!!(0|p))&&M(27367,27315,195,27325),l){if(7==(0|(A=0|Ce(e,t)))){A=5;break}if(0|r[21968+(7*A|0)+b|0]){A=1;break}m=p=0|i[21136+(28*A|0)+(b<<2)>>2]}else if(A){if(7==(0|(A=0|Ce(u,c)))){A=5;break}if(0|r[21968+(7*A|0)+f|0]){A=1;break}m=0,p=0|i[21136+(28*f|0)+(A<<2)>>2]}else m=0,p=0;if((m|p|0)>=0){if((0|p)>0){a=v+8|0,h=v+12|0,f=0,c=0|i[(n=v+4|0)>>2],l=0|i[a>>2],A=0|i[h>>2];do{(0|(u=(0|(A=(y=(0|(c=A+c-(y=(t=(0|(g=l+c|0))<0)?g:0)-(u=(e=(0|(l=A+l-y|0))<0)?l:0)|0))<0)?0:c))<(0|(u=(0|(l=(e?0:l)-(c=y?c:0)|0))<(0|(c=(t?0:g)-u-c|0))?l:c))?A:u))>0&&(c=c-u|0,l=l-u|0,A=A-u|0),f=f+1|0}while((0|f)!=(0|p));i[n>>2]=c,i[a>>2]=l,i[h>>2]=A}if((b+-1|0)>>>0<6?(A=0|i[22032+(12*b|0)>>2],c=0|i[22032+(12*b|0)+4>>2],A=A-(l=(0|(l=(0|(y=0|i[22032+(12*b|0)+8>>2]))<(0|(l=(0|c)<(0|A)?c:A))?y:l))>0?l:0)|0,c=c-l|0,l=y-l|0):(A=0,c=0,l=0),d)for(;;){if(u=3*A|0,f=3*c|0,n=3*l|0,0|Le(d)?(A=(y=(0|(l=(0|(b=(l=(0|(c=A+n-((e=(0|(t=u+c|0))<0)?t:0)-((g=(0|(y=f+l-(e?t:0)|0))<0)?y:0)|0))<0)?0:c))<(0|(l=(0|(u=(g?0:y)-(l?c:0)|0))<(0|(c=(e?0:t)-(g?y:0)-(l?c:0)|0))?u:c))?b:l))>0)?l:0,u=u-(y?l:0)|0,l=b-(y?l:0)|0):(A=(y=(0|(l=(0|(b=(l=(0|(c=n+c-((t=(0|(g=u+l|0))<0)?g:0)-((A=(0|(y=f+A-(t?g:0)|0))<0)?y:0)|0))<0)?0:c))<(0|(l=(0|(u=(A?0:y)-(l?c:0)|0))<(0|(c=(t?0:g)-(A?y:0)-(l?c:0)|0))?u:c))?b:l))>0)?l:0,u=u-(y?l:0)|0,l=b-(y?l:0)|0),A=c-A|0,!((0|d)>1)){c=u;break}d=d+-1|0,c=u}if((0|m)>0){u=0;do{l=(l=(A=(0|(b=A+l-((e=(0|(t=A+c|0))<0)?t:0)-((g=(0|(y=c+l-(e?t:0)|0))<0)?y:0)|0))<0)?0:b)-((y=(0|(A=(0|l)<(0|(A=(0|(c=(g?0:y)-(A?b:0)|0))<(0|(b=(e?0:t)-(g?y:0)-(A?b:0)|0))?c:b))?l:A))>0)?A:0)|0,c=c-(y?A:0)|0,A=b-(y?A:0)|0,u=u+1|0}while((0|u)!=(0|m))}n=v+4|0,b=0|i[(d=v+8|0)>>2],y=0|i[(a=v+12|0)>>2],u=(0|i[n>>2])+A|0,i[n>>2]=u,c=b+c|0,i[d>>2]=c,A=y+l|0,i[a>>2]=A,l=c-u|0,(0|u)<0?(A=A-u|0,i[d>>2]=l,i[a>>2]=A,i[n>>2]=0,c=0):(l=c,c=u),(0|l)<0&&(c=c-l|0,i[n>>2]=c,A=A-l|0,i[a>>2]=A,i[d>>2]=0,l=0),f=c-A|0,u=l-A|0,(0|A)<0?(i[n>>2]=f,i[d>>2]=u,i[a>>2]=0,c=f,A=0):u=l,(0|(l=(0|A)<(0|(l=(0|u)<(0|c)?u:c))?A:l))>0?(i[n>>2]=c-l,i[d>>2]=u-l,i[a>>2]=A-l,g=77):g=77}else A=5}else if(Oe(n,a,v),!!(0|h)&!!(0|p))if((0|f)!=(0|u)&&M(27398,27315,264,27325),7==(0|(l=0|Ce(e,t)))|7==(0|(A=0|Ce(n,a))))A=5;else if(0|r[21968+(7*l|0)+A|0])A=1;else if((0|(n=0|i[21136+(28*l|0)+(A<<2)>>2]))>0){a=v+8|0,h=v+12|0,f=0,c=0|i[(d=v+4|0)>>2],l=0|i[a>>2],A=0|i[h>>2];do{(0|(u=(0|(A=(e=(0|(c=A+c-(e=(g=(0|(b=l+c|0))<0)?b:0)-(u=(t=(0|(l=A+l-e|0))<0)?l:0)|0))<0)?0:c))<(0|(u=(0|(l=(t?0:l)-(c=e?c:0)|0))<(0|(c=(g?0:b)-u-c|0))?l:c))?A:u))>0&&(c=c-u|0,l=l-u|0,A=A-u|0),f=f+1|0}while((0|f)!=(0|n));i[d>>2]=c,i[a>>2]=l,i[h>>2]=A,g=77}else g=77;else g=77}while(0);return 77==(0|g)&&(A=v+4|0,i[o>>2]=i[A>>2],i[o+4>>2]=i[A+4>>2],i[o+8>>2]=i[A+8>>2],A=0),N=s,0|(y=A)}function Je(e,t,n,r){n|=0,r|=0;var a=0,o=0,s=0,A=0,l=0,c=0,u=0,f=0,d=0,h=0,p=0,m=0,g=0,b=0,v=0,y=0,x=0,_=0,w=0,T=0,E=0;if(o=0|Vt(0|(e|=0),0|(t|=0),52),S(),o&=15,x=0|Vt(0|e,0|t,45),S(),(x&=127)>>>0>121)return 0|(r=5);if(g=0|G(x),jt(0|o,0,52),A=134225919|S(),i[(s=r)>>2]=-1,i[s+4>>2]=A,s=0|i[n>>2],A=0|i[n+4>>2],n=0|i[n+8>>2],!o){a=(a=(n=(0|(b=n-(b=(t=(0|s)<0)?s:0)+((g=(0|(y=A-b|0))<0)?0-y|0:0)|0))<0)?0:b)-(y=(0|(y=(0|a)<(0|(y=(0|(n=(g?0:y)-(b=n?b:0)|0))<(0|(b=(t?0:s)-(g?y:0)-b|0))?n:b))?a:y))>0?y:0)|0,n=n-y|0;e:do{switch(b-y|0){case 0:switch(0|n){case 0:if(a){a=1==(0|a)?1:7,v=11;break e}a=0;break e;case 1:if(a){a=1==(0|a)?3:7,v=11;break e}a=2;break e;default:return 0|(r=1)}case 1:switch(0|n){case 0:if(a){a=1==(0|a)?5:7,v=11;break e}a=4;break e;case 1:if(!a){a=6;break e}return 0|(a=1);default:return 0|(r=1)}default:return 0|(r=1)}}while(0);return 11==(0|v)&&7==(0|a)||127==(0|(a=0|W(x,a)))?0|(r=1):(y=0|jt(0|a,0,45),x=0|S(),x=-1040385&i[(v=r)+4>>2]|x,i[r>>2]=i[v>>2]|y,i[r+4>>2]=x,0|(r=0))}for(;;){if(m=o,o=o+-1|0,l=(p=s-n|0)>>>0>715827881|(h=A-n|0)>>>0>715827881,0|Le(m)){if(l){if(f=2147483647-p|0,d=-2147483648-p|0,(u=(0|p)>0)?(0|f)<(0|p):(0|d)>(0|p)){a=1,v=107;break}if(E=p<<1,u?(2147483647-E|0)<(0|p):(-2147483648-E|0)>(0|p)){a=1,v=107;break}if((0|h)>0?(2147483647-h|0)<(0|h):(-2147483648-h|0)>(0|h)){a=1,v=107;break}if(l=3*p|0,c=h<<1,(u?(0|f)<(0|c):(0|d)>(0|c))||((0|p)>-1?(-2147483648|l)>=(0|h):(-2147483648^l)<(0|h))){a=1,v=107;break}}else l=3*p|0,c=h<<1;if(f=0|St(.14285714285714285*+(l-h|0)),l=(c=(0|(u=0|St(.14285714285714285*+(c+p|0))))<(0|f))?f:u,(0|(c=c?u:f))<0){if(-2147483648==(0|c)||((0|l)>0?(2147483647-l|0)<(0|c):(-2147483648-l|0)>(0|c))){v=24;break}if((0|l)>-1?(-2147483648|l)>=(0|c):(-2147483648^l)<(0|c)){v=24;break}}d=((d=(0|f)<0)?0:f)-((w=(0|(h=u-(d?f:0)|0))<0)?h:0)-((p=(0|(_=(d?0-f|0:0)-(w?h:0)|0))<0)?_:0)|0,h=(w?0:h)-(p?_:0)|0,d=d-((w=(0|(p=(0|(_=p?0:_))<(0|(p=(0|h)<(0|d)?h:d))?_:p))>0)?p:0)|0,h=h-(w?p:0)|0,l=(E=(0|(u=(0|(T=(u=(0|(f=(3*(p=_-(w?p:0)|0)|0)+d-((_=(0|(w=(3*d|0)+h|0))<0)?w:0)-((l=(0|(E=(3*h|0)+p-(_?w:0)|0))<0)?E:0)|0))<0)?0:f))<(0|(u=(0|(c=(l?0:E)-(u?f:0)|0))<(0|(f=(_?0:w)-(l?E:0)-(u?f:0)|0))?c:f))?T:u))>0)?u:0,c=c-(E?u:0)|0,u=T-(E?u:0)|0}else{if(l){if((c=(0|p)>0)?(2147483647-p|0)<(0|p):(-2147483648-p|0)>(0|p)){a=1,v=107;break}if(l=p<<1,(u=(0|h)>0)?(2147483647-h|0)<(0|h):(-2147483648-h|0)>(0|h)){a=1,v=107;break}if(d=h<<1,u?(2147483647-d|0)<(0|h):(-2147483648-d|0)>(0|h)){a=1,v=107;break}if(c?(2147483647-l|0)<(0|h):(-2147483648-l|0)>(0|h)){a=1,v=107;break}if(c=3*h|0,(0|h)>-1?(-2147483648|c)>=(0|p):(-2147483648^c)<(0|p)){a=1,v=107;break}}else l=p<<1,c=3*h|0;if(f=0|St(.14285714285714285*+(l+h|0)),l=(c=(0|(u=0|St(.14285714285714285*+(c-p|0))))<(0|f))?f:u,(0|(c=c?u:f))<0){if(-2147483648==(0|c)||((0|l)>0?(2147483647-l|0)<(0|c):(-2147483648-l|0)>(0|c))){v=36;break}if((0|l)>-1?(-2147483648|l)>=(0|c):(-2147483648^l)<(0|c)){v=36;break}}d=((d=(0|f)<0)?0:f)-((T=(0|(h=u-(d?f:0)|0))<0)?h:0)-((p=(0|(E=(d?0-f|0:0)-(T?h:0)|0))<0)?E:0)|0,h=(T?0:h)-(p?E:0)|0,d=d-((T=(0|(p=(0|(E=p?0:E))<(0|(p=(0|h)<(0|d)?h:d))?E:p))>0)?p:0)|0,h=h-(T?p:0)|0,l=(_=(0|(u=(0|(w=(u=(0|(f=(3*(p=E-(T?p:0)|0)|0)+h-((E=(0|(T=(3*d|0)+p|0))<0)?T:0)-((l=(0|(_=(3*h|0)+d-(E?T:0)|0))<0)?_:0)|0))<0)?0:f))<(0|(u=(0|(c=(l?0:_)-(u?f:0)|0))<(0|(f=(E?0:T)-(l?_:0)-(u?f:0)|0))?c:f))?w:u))>0)?u:0,c=c-(_?u:0)|0,u=w-(_?u:0)|0}u=(s=(0|(_=n-u+((T=(0|(l=s+(l-f)|0))<0)?0-l|0:0)+((f=(0|(c=A-c-(T?l:0)|0))<0)?0-c|0:0)|0))<0)?0:_,E=(f?0:c)-(s?_:0)|0,_=(_=(T?0:l)-(f?c:0)-(s?_:0)|0)-((n=(0|(s=(0|u)<(0|(s=(0|E)<(0|_)?E:_))?u:s))>0)?s:0)|0,f=0|i[(c=r)>>2],c=0|i[c+4>>2],l=f&~(l=0|jt(7,0,0|(A=3*(15-m|0)|0))),c&=~S(),n=(n=(s=(0|(T=u-(n?s:0)-(T=(f=(0|_)<0)?_:0)+((w=(0|(E=E-(n?s:0)-T|0))<0)?0-E|0:0)|0))<0)?0:T)-(E=(0|(E=(0|n)<(0|(E=(0|(s=(w?0:E)-(T=s?T:0)|0))<(0|(T=(f?0:_)-(w?E:0)-T|0))?s:T))?n:E))>0?E:0)|0,s=s-E|0;e:do{switch(T-E|0){case 0:switch(0|s){case 0:n=0|n?1==(0|n)?1:7:0;break e;case 1:n=0|n?1==(0|n)?3:7:2;break e;default:v=45;break e}case 1:switch(0|s){case 0:n=0|n?1==(0|n)?5:7:4;break e;case 1:if(n){v=45;break e}n=6;break e;default:v=45;break e}default:v=45}}while(0);if(45==(0|v)&&(v=0,n=7),w=0|jt(0|n,0,0|A),T=0|S()|c,i[(E=r)>>2]=w|l,i[E+4>>2]=T,(0|m)<=1){v=47;break}s=d,A=h,n=p}if(24==(0|v))M(27634,27425,416,27447);else if(36==(0|v))M(27634,27425,464,27461);else{if(47==(0|v)){if((0|d)>1|(0|h)>1|(0|p)>1)return 0|(E=1);n=(n=(o=(0|(T=p-(T=(_=(0|d)<0)?d:0)+((w=(0|(E=h-T|0))<0)?0-E|0:0)|0))<0)?0:T)-(E=(0|(E=(0|n)<(0|(E=(0|(o=(w?0:E)-(T=o?T:0)|0))<(0|(T=(_?0:d)-(w?E:0)-T|0))?o:T))?n:E))>0?E:0)|0,o=o-E|0;e:do{switch(T-E|0){case 0:switch(0|o){case 0:o=0|n?1==(0|n)?1:7:0;break e;case 1:o=0|n?1==(0|n)?3:7:2;break e;default:v=55;break e}case 1:switch(0|o){case 0:o=0|n?1==(0|n)?5:7:4;break e;case 1:if(n){v=55;break e}o=6;break e;default:v=55;break e}default:v=55}}while(0);55==(0|v)&&(o=7),c=127==(0|(A=0|W(x,o)))?0:0|G(A);e:do{if(o){if(g){if(7==(0|(n=0|Ce(e,t))))return 0|(E=5);s=0|i[21344+(28*n|0)+(o<<2)>>2];t:do{if((0|s)>0)for(n=o,o=0;;){switch(0|n){case 1:n=5;break;case 5:n=4;break;case 4:n=6;break;case 6:n=2;break;case 2:n=3;break;case 3:n=1}if((0|(o=o+1|0))==(0|s))break t}else n=o}while(0);if(1==(0|n))return 0|(E=9);127==(0|(o=0|W(x,n)))&&M(27476,27315,415,27506),0|G(o)?M(27521,27315,416,27506):(a=o,y=s,b=n)}else a=A,y=0,b=o;if((0|(l=0|i[4272+(28*x|0)+(b<<2)>>2]))<=-1&&M(27552,27315,423,27506),!c){if((0|y)<0)return 0|(E=5);if(0|y){n=0,o=0|i[(s=r)>>2],s=0|i[s+4>>2];do{o=0|Re(o,s),s=0|S(),i[(E=r)>>2]=o,i[E+4>>2]=s,n=n+1|0}while((0|n)<(0|y))}if((0|l)<=0){v=104;break}for(n=0,o=0|i[(s=r)>>2],s=0|i[s+4>>2];;)if(o=0|Re(o,s),s=0|S(),i[(E=r)>>2]=o,i[E+4>>2]=s,(0|(n=n+1|0))==(0|l)){v=104;break e}}if(7==(0|(A=0|$(a,x)))&&M(27291,27315,432,27506),o=0|i[(n=r)>>2],n=0|i[n+4>>2],(0|l)>0){s=0;do{o=0|Re(o,n),n=0|S(),i[(E=r)>>2]=o,i[E+4>>2]=n,s=s+1|0}while((0|s)!=(0|l))}if(7==(0|(n=0|Ce(o,n)))&&M(27634,27315,444,27506),o=0|H(a),(0|(o=0|i[(o?21760:21552)+(28*A|0)+(n<<2)>>2]))<0&&M(27634,27315,458,27506),o){n=0,s=0|i[(A=r)>>2],A=0|i[A+4>>2];do{s=0|Ie(s,A),A=0|S(),i[(E=r)>>2]=s,i[E+4>>2]=A,n=n+1|0}while((0|n)<(0|o));v=104}else v=104}else if(!!(0|g)&!!(0|c)){if(7==(0|(a=0|Ce(e,t)))|7==(0|(n=0|Ce(0|i[(n=r)>>2],0|i[n+4>>2]))))return 0|(E=5);if((0|(n=0|i[21344+(28*a|0)+(n<<2)>>2]))<0)return 0|(E=5);if(n){a=0,o=0|i[(s=r)>>2],s=0|i[s+4>>2];do{o=0|Re(o,s),s=0|S(),i[(E=r)>>2]=o,i[E+4>>2]=s,a=a+1|0}while((0|a)<(0|n));a=A,v=104}else a=A,v=105}else a=A,v=104}while(0);return 104==(0|v)&&c&&(v=105),105==(0|v)&&1==(0|Ce(0|i[(E=r)>>2],0|i[E+4>>2]))?0|(E=9):(_=0|i[(T=r)>>2],T=-1040385&i[T+4>>2],w=0|jt(0|a,0,45),T=0|T|S(),i[(E=r)>>2]=_|w,i[E+4>>2]=T,0|(E=0))}if(107==(0|v))return 0|a}return 0}function Ye(e,t,n,r,a){n|=0,r|=0,a|=0;var o,s,A=0,l=0,c=0;return o=N,N=N+32|0,c=o,0|(A=0|$e(e|=0,t|=0,e,t,l=o+12|0))?(N=o,0|(c=A)):0|(e=0|$e(e,t,n,r,c))?(N=o,0|(c=e)):(t=(0|(n=(r=(s=(0|(e=(0|i[l>>2])-(0|i[c>>2])|0))<0)?0-e|0:0)+((0|i[l+4>>2])-(0|i[c+4>>2]))|0))<0,l=(l=(A=(0|(r=(0|i[l+8>>2])-(0|i[c+8>>2])+r+(t?0-n|0:0)|0))<0)?0:r)-(c=(0|(c=(0|l)<(0|(c=(0|(A=(t?0:n)-(r=A?r:0)|0))<(0|(r=(s?0:e)-(t?n:0)-r|0))?A:r))?l:c))>0?c:0)|0,A=A-c|0,l=(0|(c=(0|(c=r-c|0))>-1?c:0-c|0))>(0|(l=(0|(A=(0|A)>-1?A:0-A|0))>(0|(l=(0|l)>-1?l:0-l|0))?A:l))?c:l,i[(c=a)>>2]=l,i[c+4>>2]=((0|l)<0)<<31>>31,N=o,0|(c=0))}function Xe(e,t,n,r,a,o,s,A,c,u,f){e|=0,t|=0,n|=0,r|=0,a|=0,o|=0,s|=0,A|=0,c|=0,u|=0,f|=0;var d,h,p,m,g,b,v,y=0,x=0,_=0,w=0,T=0,E=0,C=0,I=0,R=0,P=0,k=0;if(v=N,N=N+48|0,x=v+12|0,b=v,i[(y=v+24|0)>>2]=0,i[y+4>>2]=0,i[y+8>>2]=0,i[x>>2]=0,i[x+4>>2]=0,i[x+8>>2]=0,0|$e(e,t,e,t,y)&&M(27634,27315,696,27575),0|$e(e,t,n,r,x)&&M(27634,27315,701,27575),n=(r=0|i[(T=y+8|0)>>2])-(0|i[y>>2])|0,i[y>>2]=n,r=(0|i[(P=y+4|0)>>2])-r|0,i[P>>2]=r,y=0-(P=r+n|0)|0,i[T>>2]=y,E=(C=0|i[(T=x+8|0)>>2])-(0|i[x>>2])|0,i[x>>2]=E,C=(0|i[(R=x+4|0)>>2])-C|0,i[R>>2]=C,R=C+E|0,i[T>>2]=0-R,m=(I=1/(+(a>>>0)+4294967296*+(0|o)))*+(E-n|0),g=I*+(C-r|0),I*=+(P-R|0),i[b>>2]=n,i[(R=b+4|0)>>2]=r,i[(P=b+8|0)>>2]=y,(0|o)<0)return N=v,0|(u=0);for(p=+(0|n),h=+(0|r),d=+(0|y),E=0,C=0;;){if(k=m*(w=+(E>>>0)+4294967296*+(0|C))+p,_=g*w+h,w=I*w+d,r=~~+qt(+k),y=~~+qt(+_),n=~~+qt(+w),(k=+l(+(+(0|r)-k)))>(_=+l(+(+(0|y)-_)))&k>(w=+l(+(+(0|n)-w)))?r=0-(x=n+y|0)|0:(x=0-r|0,_>w&&(y=x-n|0)),i[R>>2]=y,i[b>>2]=x,i[P>>2]=0,n=r+y|0,(0|r)>0?(i[R>>2]=n,i[P>>2]=r,i[b>>2]=0,x=0):(n=y,r=0),(0|n)<0?(y=x-n|0,i[b>>2]=y,r=r-n|0,i[P>>2]=r,i[R>>2]=0,x=y-r|0,n=0-r|0,(0|r)<0?(i[b>>2]=x,i[R>>2]=n,i[P>>2]=0,T=n,r=0):(T=0,x=y)):T=n,(0|(n=(0|r)<(0|(n=(0|T)<(0|x)?T:x))?r:n))>0&&(i[b>>2]=x-n,i[R>>2]=T-n,i[P>>2]=r-n),n=0|Pt(0|(n=0|Ot(0|E,0|C,0|u,0|f)),0|S(),0|A,0|c),S(),0|(n=0|Je(e,t,b,s+(n<<3)|0))){r=20;break}if(T=E,E=0|Pt(0|E,0|C,1,0),x=C,C=0|S(),!((0|x)<(0|o)|(0|x)==(0|o)&T>>>0<a>>>0)){n=0,r=20;break}}return 20==(0|r)?(N=v,0|n):0}function Ze(e,t,n,r){e|=0,t|=0;var i=0,a=0,o=0;if(!(0|(n|=0))&!(0|(r|=0)))return a=1,T(0|(i=0)),0|a;a=e,i=t,e=1,t=0;do{e=0|Ot(0|((o=!0&!(1&n))?1:a),0|(o?0:i),0|e,0|t),t=0|S(),n=0|Ut(0|n,0|r,1),r=0|S(),a=0|Ot(0|a,0|i,0|a,0|i),i=0|S()}while(!(!(0|n)&!(0|r)));return T(0|t),0|e}function et(e,t,n,r){n|=0,r|=0;var o,s=0,A=0,l=0,c=0,f=0,d=0;o=N,N=N+16|0,A=o,l=0|Vt(0|(e|=0),0|(t|=0),52),S(),l&=15;do{if(l){if(!(s=0|De(e,t,A))){f=+a[A>>3],c=1/+u(+f),d=+a[26032+(l<<3)>>3],a[n>>3]=f+d,a[n+8>>3]=f-d,f=+a[A+8>>3],c*=d,a[n+16>>3]=c+f,a[n+24>>3]=f-c;break}return N=o,0|(l=s)}if(s=0|Vt(0|e,0|t,45),S(),(s&=127)>>>0>121)return N=o,0|(l=5);A=22128+(s<<5)|0,i[n>>2]=i[A>>2],i[n+4>>2]=i[A+4>>2],i[n+8>>2]=i[A+8>>2],i[n+12>>2]=i[A+12>>2],i[n+16>>2]=i[A+16>>2],i[n+20>>2]=i[A+20>>2],i[n+24>>2]=i[A+24>>2],i[n+28>>2]=i[A+28>>2];break}while(0);return function(e,t){t=+t;var n,r,i,o,s,A,l,c=0,u=0;c=(o=+a[(i=16+(e|=0)|0)>>3])-(r=+a[(n=e+24|0)>>3]),c=o<r?c+6.283185307179586:c,u=+a[e>>3],c=.5*(c*t-c),u+=t=.5*((l=u-(A=+a[(s=e+8|0)>>3]))*t-l),a[e>>3]=u>1.5707963267948966?1.5707963267948966:u,t=A-t,a[s>>3]=t<-1.5707963267948966?-1.5707963267948966:t,t=(t=o+c)>3.141592653589793?t+-6.283185307179586:t,a[i>>3]=t<-3.141592653589793?t+6.283185307179586:t,t=(t=r-c)>3.141592653589793?t+-6.283185307179586:t,a[n>>3]=t<-3.141592653589793?t+6.283185307179586:t}(n,r?1.4:1.1),(0|i[(r=26160+(l<<3)|0)>>2])==(0|e)&&(0|i[r+4>>2])==(0|t)&&(a[n>>3]=1.5707963267948966),(0|i[(l=26288+(l<<3)|0)>>2])==(0|e)&&(0|i[l+4>>2])==(0|t)&&(a[n+8>>3]=-1.5707963267948966),1.5707963267948966!=+a[n>>3]&&-1.5707963267948966!=+a[n+8>>3]?(N=o,0|(l=0)):(a[n+16>>3]=3.141592653589793,a[n+24>>3]=-3.141592653589793,N=o,0|(l=0))}function tt(e,t,n,a){e|=0,t|=0,n|=0,a|=0;var o,s,A,l=0,c=0,u=0,f=0;A=N,N=N+48|0,o=A+40|0,s=A,_e(c=A+32|0,0,0,0),u=0|i[c>>2],c=0|i[c+4>>2];do{if(n>>>0<=15){if(0|(l=0|ot(a))){i[(a=s)>>2]=0,i[a+4>>2]=0,i[s+8>>2]=l,i[s+12>>2]=-1,u=s+29|0,i[(a=s+16|0)>>2]=0,i[a+4>>2]=0,i[a+8>>2]=0,r[a+12|0]=0,r[u|0]=0|r[o|0],r[u+1|0]=0|r[o+1|0],r[u+2|0]=0|r[o+2|0];break}if(l=0|Ct(1+(0|i[t+8>>2])|0,32)){st(t,l),i[(f=s)>>2]=u,i[f+4>>2]=c,i[s+8>>2]=0,i[s+12>>2]=n,i[s+16>>2]=a,i[s+20>>2]=t,i[s+24>>2]=l,r[s+28|0]=0,r[(u=s+29|0)|0]=0|r[o|0],r[u+1|0]=0|r[o+1|0],r[u+2|0]=0|r[o+2|0];break}i[(a=s)>>2]=0,i[a+4>>2]=0,i[s+8>>2]=13,i[s+12>>2]=-1,u=s+29|0,i[(a=s+16|0)>>2]=0,i[a+4>>2]=0,i[a+8>>2]=0,r[a+12|0]=0,r[u|0]=0|r[o|0],r[u+1|0]=0|r[o+1|0],r[u+2|0]=0|r[o+2|0];break}i[(u=s)>>2]=0,i[u+4>>2]=0,i[s+8>>2]=4,i[s+12>>2]=-1,f=s+29|0,i[(u=s+16|0)>>2]=0,i[u+4>>2]=0,i[u+8>>2]=0,r[u+12|0]=0,r[f|0]=0|r[o|0],r[f+1|0]=0|r[o+1|0],r[f+2|0]=0|r[o+2|0]}while(0);nt(s),i[e>>2]=i[s>>2],i[e+4>>2]=i[s+4>>2],i[e+8>>2]=i[s+8>>2],i[e+12>>2]=i[s+12>>2],i[e+16>>2]=i[s+16>>2],i[e+20>>2]=i[s+20>>2],i[e+24>>2]=i[s+24>>2],i[e+28>>2]=i[s+28>>2],N=A}function nt(e){var t,n,a,o,s=0,A=0,l=0,c=0,u=0,f=0,d=0,h=0,p=0,m=0,g=0,b=0,v=0,y=0,x=0,_=0;if(o=N,N=N+336|0,t=o+168|0,n=o,!(0|(A=0|i[(l=e|=0)>>2]))&!(0|(l=0|i[l+4>>2])))N=o;else{if(0|r[(s=e+28|0)|0]?(A=0|rt(A,l),l=0|S()):r[s|0]=1,!(0|i[i[(a=e+20|0)>>2]>>2]))return 0|(A=0|i[(s=e+24|0)>>2])&&Et(A),i[(_=e)>>2]=0,i[_+4>>2]=0,i[e+8>>2]=0,i[a>>2]=0,i[e+12>>2]=-1,i[e+16>>2]=0,i[s>>2]=0,void(N=o);c=15&(s=0|i[(_=e+16|0)>>2]);e:do{if(!(0|A)&!(0|l))x=e+24|0;else{v=e+12|0,g=3==(0|c),m=255&s,h=3==(1|c),b=e+24|0,p=(c+-1|0)>>>0<3,f=3==(2|c),d=n+8|0;t:for(;;){if(u=0|Vt(0|A,0|l,52),S(),(0|(u&=15))==(0|i[v>>2])){switch(15&m){case 0:case 2:case 3:if(0|(c=0|De(A,l,t))){y=15;break t}if(0|At(0|i[a>>2],0|i[b>>2],t)){y=19;break t}}if(h&&(c=0|i[4+(0|i[a>>2])>>2],i[t>>2]=i[c>>2],i[t+4>>2]=i[c+4>>2],i[t+8>>2]=i[c+8>>2],i[t+12>>2]=i[c+12>>2],0|X(26896,t))){if(0|Be(0|i[4+(0|i[a>>2])>>2],u,n)){y=25;break}if((0|i[(c=n)>>2])==(0|A)&&(0|i[c+4>>2])==(0|l)){y=29;break}}if(p){if(0|(c=0|Ue(A,l,t))){y=32;break}if(0|et(A,l,n,0)){y=36;break}if(f&&0|lt(0|i[a>>2],0|i[b>>2],t,n)){y=42;break}if(h&&0|ut(0|i[a>>2],0|i[b>>2],t,n)){y=42;break}}if(g){if(s=0|et(A,l,t,1),c=0|i[b>>2],0|s){y=45;break}if(0|Z(c,t)){if(te(n,t),0|ee(t,0|i[b>>2])){y=53;break}if(0|At(0|i[a>>2],0|i[b>>2],d)){y=53;break}if(0|ut(0|i[a>>2],0|i[b>>2],n,t)){y=53;break}}}}do{if((0|u)<(0|i[v>>2])){if(s=0|et(A,l,t,1),c=0|i[b>>2],0|s){y=58;break t}if(!(0|Z(c,t))){y=73;break}if(0|ee(0|i[b>>2],t)&&(te(n,t),0|lt(0|i[a>>2],0|i[b>>2],n,t))){y=65;break t}if(0|(A=0|Ee(A,l,u+1|0,n))){y=67;break t}A=0|i[(l=n)>>2],l=0|i[l+4>>2]}else y=73}while(0);if(73==(0|y)&&(y=0,A=0|rt(A,l),l=0|S()),!(0|A)&!(0|l)){x=b;break e}}switch(0|y){case 15:0|(s=0|i[b>>2])&&Et(s),i[(y=e)>>2]=0,i[y+4>>2]=0,i[a>>2]=0,i[v>>2]=-1,i[_>>2]=0,i[b>>2]=0,i[e+8>>2]=c,y=20;break;case 19:i[e>>2]=A,i[e+4>>2]=l,y=20;break;case 25:M(27634,27600,470,27611);break;case 29:case 42:return i[e>>2]=A,i[e+4>>2]=l,void(N=o);case 32:return 0|(s=0|i[b>>2])&&Et(s),i[(x=e)>>2]=0,i[x+4>>2]=0,i[a>>2]=0,i[v>>2]=-1,i[_>>2]=0,i[b>>2]=0,i[e+8>>2]=c,void(N=o);case 36:M(27634,27600,493,27611);break;case 45:0|c&&Et(c),i[(y=e)>>2]=0,i[y+4>>2]=0,i[a>>2]=0,i[v>>2]=-1,i[_>>2]=0,i[b>>2]=0,i[e+8>>2]=s,y=55;break;case 53:i[e>>2]=A,i[e+4>>2]=l,y=55;break;case 58:0|c&&Et(c),i[(y=e)>>2]=0,i[y+4>>2]=0,i[a>>2]=0,i[v>>2]=-1,i[_>>2]=0,i[b>>2]=0,i[e+8>>2]=s,y=71;break;case 65:i[e>>2]=A,i[e+4>>2]=l,y=71;break;case 67:return 0|(s=0|i[b>>2])&&Et(s),i[(x=e)>>2]=0,i[x+4>>2]=0,i[a>>2]=0,i[v>>2]=-1,i[_>>2]=0,i[b>>2]=0,i[e+8>>2]=A,void(N=o)}if(20==(0|y))return void(N=o);if(55==(0|y))return void(N=o);if(71==(0|y))return void(N=o)}}while(0);0|(s=0|i[x>>2])&&Et(s),i[(y=e)>>2]=0,i[y+4>>2]=0,i[e+8>>2]=0,i[a>>2]=0,i[e+12>>2]=-1,i[_>>2]=0,i[x>>2]=0,N=o}}function rt(e,t){var n,r=0,a=0,o=0,s=0,A=0,l=0,c=0,u=0,f=0;n=N,N=N+16|0,f=n,a=0|Vt(0|(e|=0),0|(t|=0),52),S(),a&=15,r=0|Vt(0|e,0|t,45),S();do{if(a){for(;r=0|jt(a+4095|0,0,52),o=S()|-15728641&t,r=r|e|(A=0|jt(7,0,0|(s=3*(15-a|0)|0))),o|=l=0|S(),c=0|Vt(0|e,0|t,0|s),S(),a=a+-1|0,!((c&=7)>>>0<6);){if(!a){u=4;break}t=o,e=r}if(4==(0|u)){r=0|Vt(0|r,0|o,45),S();break}return f=0|jt(((f=!(0|c)&!!(0|Se(r,o)))?2:1)+c|0,0,0|s),u=0|S()|t&~l,f|=e&~A,T(0|u),N=n,0|f}}while(0);return(r&=127)>>>0>120?(f=0,T(0|(u=0)),N=n,0|f):(_e(f,0,r+1|0,0),u=0|i[f+4>>2],f=0|i[f>>2],T(0|u),N=n,0|f)}function it(e,t,n){e|=0;var r,o=0,s=0,A=0,l=0,c=0,u=0,f=0,d=0,h=0;if(!(0|X(t|=0,n|=0)))return 0|(h=0);if(t=0|function(e){return+a[16+(e|=0)>>3]<+a[e+24>>3]|0}(t),o=+a[n>>3],s=t&(s=+a[n+8>>3])<0?s+6.283185307179586:s,(0|(h=0|i[e>>2]))<=0)return 0|(h=0);if(r=0|i[e+4>>2],t){t=0,d=s,n=-1,e=0;e:for(;;){for(f=e;l=+a[r+(f<<4)>>3],s=+a[r+(f<<4)+8>>3],A=+a[r+((e=(n+2|0)%(0|h)|0)<<4)>>3],c=+a[r+(e<<4)+8>>3],l>A?(u=l,l=c):(u=A,A=l,l=s,s=c),(o=o==A|o==u?o+2220446049250313e-31:o)<A|o>u;){if((0|(n=f+1|0))>=(0|h)){n=22;break e}e=f,f=n,n=e}if(((u=(c=l<0?l+6.283185307179586:l)+(o-A)/(u-A)*((l=s<0?s+6.283185307179586:s)-c))<0?u+6.283185307179586:u)>(d=c==d|l==d?d+-2220446049250313e-31:d)&&(t^=1),(0|(e=f+1|0))>=(0|h)){n=22;break}n=f}if(22==(0|n))return 0|t}else{t=0,d=s,n=-1,e=0;e:for(;;){for(f=e;l=+a[r+(f<<4)>>3],s=+a[r+(f<<4)+8>>3],A=+a[r+((e=(n+2|0)%(0|h)|0)<<4)>>3],c=+a[r+(e<<4)+8>>3],l>A?(u=l,l=c):(u=A,A=l,l=s,s=c),(o=o==A|o==u?o+2220446049250313e-31:o)<A|o>u;){if((0|(n=f+1|0))>=(0|h)){n=22;break e}e=f,f=n,n=e}if(l+(o-A)/(u-A)*(s-l)>(d=l==d|s==d?d+-2220446049250313e-31:d)&&(t^=1),(0|(e=f+1|0))>=(0|h)){n=22;break}n=f}if(22==(0|n))return 0|t}return 0}function at(e,t){t|=0;var n,r,o,s,A,c=0,u=0,f=0,d=0,h=0,p=0,m=0,g=0,b=0,v=0,y=0,x=0;if(!(r=0|i[(e|=0)>>2]))return i[t>>2]=0,i[t+4>>2]=0,i[t+8>>2]=0,i[t+12>>2]=0,i[t+16>>2]=0,i[t+20>>2]=0,i[t+24>>2]=0,void(i[t+28>>2]=0);if(a[(o=t+8|0)>>3]=17976931348623157e292,a[(s=t+24|0)>>3]=17976931348623157e292,a[t>>3]=-17976931348623157e292,a[(A=t+16|0)>>3]=-17976931348623157e292,!((0|r)<=0)){for(n=0|i[e+4>>2],g=17976931348623157e292,b=-17976931348623157e292,v=0,e=-1,d=17976931348623157e292,h=17976931348623157e292,m=-17976931348623157e292,u=-17976931348623157e292,y=0;c=+a[n+(y<<4)>>3],p=+a[n+(y<<4)+8>>3],f=+a[n+(((0|(e=e+2|0))==(0|r)?0:e)<<4)+8>>3],c<d&&(a[o>>3]=c,d=c),p<h&&(a[s>>3]=p,h=p),c>m?a[t>>3]=c:c=m,p>u&&(a[A>>3]=p,u=p),g=p>0&p<g?p:g,b=p<0&p>b?p:b,v|=+l(+(p-f))>3.141592653589793,(0|(e=y+1|0))!=(0|r);)x=y,m=c,y=e,e=x;v&&(a[A>>3]=b,a[s>>3]=g)}}function ot(e){return 0|((e|=0)>>>0<4?0:15)}function st(e,t){t|=0;var n,r=0,o=0,s=0,A=0,c=0,u=0,f=0,d=0,h=0,p=0,m=0,g=0,b=0,v=0,y=0,x=0,_=0,w=0,T=0,S=0,M=0;if(b=0|i[(e|=0)>>2]){if(a[(v=t+8|0)>>3]=17976931348623157e292,a[(y=t+24|0)>>3]=17976931348623157e292,a[t>>3]=-17976931348623157e292,a[(x=t+16|0)>>3]=-17976931348623157e292,(0|b)>0){for(s=0|i[e+4>>2],m=17976931348623157e292,g=-17976931348623157e292,o=0,r=-1,f=17976931348623157e292,d=17976931348623157e292,p=-17976931348623157e292,c=-17976931348623157e292,_=0;A=+a[s+(_<<4)>>3],h=+a[s+(_<<4)+8>>3],u=+a[s+(((0|(S=r+2|0))==(0|b)?0:S)<<4)+8>>3],A<f&&(a[v>>3]=A,f=A),h<d&&(a[y>>3]=h,d=h),A>p?a[t>>3]=A:A=p,h>c&&(a[x>>3]=h,c=h),m=h>0&h<m?h:m,g=h<0&h>g?h:g,o|=+l(+(h-u))>3.141592653589793,(0|(r=_+1|0))!=(0|b);)S=_,p=A,_=r,r=S;o&&(a[x>>3]=g,a[y>>3]=m)}}else i[t>>2]=0,i[t+4>>2]=0,i[t+8>>2]=0,i[t+12>>2]=0,i[t+16>>2]=0,i[t+20>>2]=0,i[t+24>>2]=0,i[t+28>>2]=0;if(!((0|(r=0|i[(S=e+8|0)>>2]))<=0)){n=e+12|0,T=0;do{if(s=0|i[n>>2],o=T,y=t+((T=T+1|0)<<5)|0,x=0|i[s+(o<<3)>>2]){if(a[(_=t+(T<<5)+8|0)>>3]=17976931348623157e292,a[(e=t+(T<<5)+24|0)>>3]=17976931348623157e292,a[y>>3]=-17976931348623157e292,a[(w=t+(T<<5)+16|0)>>3]=-17976931348623157e292,(0|x)>0){for(b=0|i[s+(o<<3)+4>>2],m=17976931348623157e292,g=-17976931348623157e292,s=0,o=-1,v=0,f=17976931348623157e292,d=17976931348623157e292,h=-17976931348623157e292,c=-17976931348623157e292;A=+a[b+(v<<4)>>3],p=+a[b+(v<<4)+8>>3],u=+a[b+(((0|(o=o+2|0))==(0|x)?0:o)<<4)+8>>3],A<f&&(a[_>>3]=A,f=A),p<d&&(a[e>>3]=p,d=p),A>h?a[y>>3]=A:A=h,p>c&&(a[w>>3]=p,c=p),m=p>0&p<m?p:m,g=p<0&p>g?p:g,s|=+l(+(p-u))>3.141592653589793,(0|(o=v+1|0))!=(0|x);)M=v,v=o,h=A,o=M;s&&(a[w>>3]=g,a[e>>3]=m)}}else i[y>>2]=0,i[y+4>>2]=0,i[y+8>>2]=0,i[y+12>>2]=0,i[y+16>>2]=0,i[y+20>>2]=0,i[y+24>>2]=0,i[y+28>>2]=0,r=0|i[S>>2]}while((0|T)<(0|r))}}function At(e,t,n){var r=0,a=0,o=0;if(!(0|it(e|=0,t|=0,n|=0)))return 0|(a=0);if((0|i[(a=e+8|0)>>2])<=0)return 0|(a=1);for(r=e+12|0,e=0;;){if(o=e,e=e+1|0,0|it((0|i[r>>2])+(o<<3)|0,t+(e<<5)|0,n)){e=0,r=6;break}if((0|e)>=(0|i[a>>2])){e=1,r=6;break}}return 6==(0|r)?0|e:0}function lt(e,t,n,r){r|=0;var a,o,s=0,A=0,l=0,c=0,u=0;if(o=N,N=N+16|0,a=o,!(0|it(e|=0,t|=0,l=(n|=0)+8|0)))return N=o,0|(c=0);c=e+8|0;e:do{if((0|i[c>>2])>0){for(A=e+12|0,s=0;;){if(u=s,s=s+1|0,0|it((0|i[A>>2])+(u<<3)|0,t+(s<<5)|0,l)){s=0;break}if((0|s)>=(0|i[c>>2]))break e}return N=o,0|s}}while(0);if(0|ct(e,t,n,r))return N=o,0|(u=0);i[a>>2]=i[n>>2],i[a+4>>2]=l,s=0|i[c>>2];e:do{if((0|s)>0)for(e=e+12|0,l=0,A=s;;){if(s=0|i[e>>2],(0|i[s+(l<<3)>>2])>0){if(0|it(a,r,0|i[s+(l<<3)+4>>2])){s=0;break e}if(s=l+1|0,0|ct((0|i[e>>2])+(l<<3)|0,t+(s<<5)|0,n,r)){s=0;break e}A=0|i[c>>2]}else s=l+1|0;if(!((0|s)<(0|A))){s=1;break}l=s}else s=1}while(0);return N=o,0|(u=s)}function ct(e,t,n,r){e|=0,n|=0;var o,s,A,l,c,u,f=0,d=0,h=0,p=0,m=0,g=0,b=0,v=0,y=0,x=0,_=0,w=0,T=0,S=0,M=0;if(u=N,N=N+176|0,l=u+172|0,f=u+168|0,c=u,!(0|Z(t|=0,r|=0)))return N=u,0|(e=0);if(function(e,t,n,r){var o,s,A,l,c;t|=0,n|=0,r|=0,e=(s=+a[16+(e|=0)>>3])<(c=+a[e+24>>3]),o=(l=+a[t+16>>3])<(A=+a[t+24>>3]),t=c-l<A-s,i[n>>2]=e?o|t?1:2:0,i[r>>2]=o?e?1:t?2:1:0}(t,r,l,f),Qt(0|c,0|n,168),(0|i[n>>2])>0){t=0;do{_=+qe(+a[(S=c+8+(t<<4)+8|0)>>3],0|i[f>>2]),a[S>>3]=_,t=t+1|0}while((0|t)<(0|i[n>>2]))}s=+a[r>>3],A=+a[r+8>>3],_=+qe(+a[r+16>>3],0|i[f>>2]),o=+qe(+a[r+24>>3],0|i[f>>2]);e:do{if((0|i[e>>2])>0){if(r=e+4|0,(0|(f=0|i[c>>2]))<=0)for(t=0;;)if((0|(t=t+1|0))>=(0|i[e>>2])){t=0;break e}for(n=0;;){if(t=0|i[r>>2],y=+a[t+(n<<4)>>3],x=+qe(+a[t+(n<<4)+8>>3],0|i[l>>2]),t=0|i[r>>2],S=(0|(n=n+1|0))%(0|i[e>>2])|0,d=+a[t+(S<<4)>>3],h=+qe(+a[t+(S<<4)+8>>3],0|i[l>>2]),!(y>=s)|!(d>=s)&&!(y<=A)|!(d<=A)&&!(x<=o)|!(h<=o)&&!(x>=_)|!(h>=_)){v=d-y,g=h-x,t=0;do{if(M=t,S=(0|(t=t+1|0))==(0|f)?0:t,d=+a[c+8+(M<<4)+8>>3],h=+a[c+8+(S<<4)+8>>3]-d,p=+a[c+8+(M<<4)>>3],!(0==(b=v*h-g*(m=+a[c+8+(S<<4)>>3]-p))||(w=x-d,T=y-p,m=(w*m-h*T)/b,m<0|m>1))&&(b=(v*w-g*T)/b)>=0&b<=1){t=1;break e}}while((0|t)<(0|f))}if((0|n)>=(0|i[e>>2])){t=0;break}}}else t=0}while(0);return N=u,0|(M=t)}function ut(e,t,n,r){var a=0,o=0,s=0;if(0|ct(e|=0,t|=0,n|=0,r|=0))return 0|(o=1);if((0|i[(o=e+8|0)>>2])<=0)return 0|(o=0);for(a=e+12|0,e=0;;){if(s=e,e=e+1|0,0|ct((0|i[a>>2])+(s<<3)|0,t+(e<<5)|0,n,r)){e=1,a=6;break}if((0|e)>=(0|i[o>>2])){e=0,a=6;break}}return 6==(0|a)?0|e:0}function ft(e,t,n,r,i){t|=0,n|=0,r|=0,i|=0;var o,s,A,l,c,u,f,d=0;l=+a[(e|=0)>>3],A=+a[t>>3]-l,s=+a[e+8>>3],o=+a[t+8>>3]-s,u=+a[n>>3],d=((d=+a[r>>3]-u)*(s-(f=+a[n+8>>3]))-(l-u)*(c=+a[r+8>>3]-f))/(A*c-o*d),a[i>>3]=l+A*d,a[i+8>>3]=s+o*d}function dt(e,t){return t|=0,+l(+(+a[(e|=0)>>3]-+a[t>>3]))<1.1920928955078125e-7?0|(t=+l(+(+a[e+8>>3]-+a[t+8>>3]))<1.1920928955078125e-7):0|(t=0)}function ht(e,t,n){n|=0;var r,a,o,s,A=0,l=0,c=0,u=0;if(s=N,N=N+32|0,u=s,0|(A=0|Fe(e|=0,t|=0,a=s+16|0)))return N=s,0|(n=A);r=0|ye(e,t),o=0|Ce(e,t),function(e,t){e=7696+(28*(e|=0)|0)|0,i[(t|=0)>>2]=i[e>>2],i[t+4>>2]=i[e+4>>2],i[t+8>>2]=i[e+8>>2],i[t+12>>2]=i[e+12>>2]}(r,u),A=0|function(e,t){e|=0;var n=0,r=0;if((t|=0)>>>0>20)return-1;do{if((0|i[11120+(216*t|0)>>2])!=(0|e))if((0|i[11120+(216*t|0)+8>>2])!=(0|e))if((0|i[11120+(216*t|0)+16>>2])!=(0|e))if((0|i[11120+(216*t|0)+24>>2])!=(0|e))if((0|i[11120+(216*t|0)+32>>2])!=(0|e))if((0|i[11120+(216*t|0)+40>>2])!=(0|e))if((0|i[11120+(216*t|0)+48>>2])!=(0|e))if((0|i[11120+(216*t|0)+56>>2])!=(0|e))if((0|i[11120+(216*t|0)+64>>2])!=(0|e))if((0|i[11120+(216*t|0)+72>>2])!=(0|e))if((0|i[11120+(216*t|0)+80>>2])!=(0|e))if((0|i[11120+(216*t|0)+88>>2])!=(0|e))if((0|i[11120+(216*t|0)+96>>2])!=(0|e))if((0|i[11120+(216*t|0)+104>>2])!=(0|e))if((0|i[11120+(216*t|0)+112>>2])!=(0|e))if((0|i[11120+(216*t|0)+120>>2])!=(0|e))if((0|i[11120+(216*t|0)+128>>2])!=(0|e)){if((0|i[11120+(216*t|0)+136>>2])!=(0|e)){if((0|i[11120+(216*t|0)+144>>2])==(0|e)){e=0,n=2,r=0;break}if((0|i[11120+(216*t|0)+152>>2])==(0|e)){e=0,n=2,r=1;break}if((0|i[11120+(216*t|0)+160>>2])==(0|e)){e=0,n=2,r=2;break}if((0|i[11120+(216*t|0)+168>>2])==(0|e)){e=1,n=2,r=0;break}if((0|i[11120+(216*t|0)+176>>2])==(0|e)){e=1,n=2,r=1;break}if((0|i[11120+(216*t|0)+184>>2])==(0|e)){e=1,n=2,r=2;break}if((0|i[11120+(216*t|0)+192>>2])==(0|e)){e=2,n=2,r=0;break}if((0|i[11120+(216*t|0)+200>>2])==(0|e)){e=2,n=2,r=1;break}if((0|i[11120+(216*t|0)+208>>2])==(0|e)){e=2,n=2,r=2;break}return-1}e=2,n=1,r=2}else e=2,n=1,r=1;else e=2,n=1,r=0;else e=1,n=1,r=2;else e=1,n=1,r=1;else e=1,n=1,r=0;else e=0,n=1,r=2;else e=0,n=1,r=1;else e=0,n=1,r=0;else e=2,n=0,r=2;else e=2,n=0,r=1;else e=2,n=0,r=0;else e=1,n=0,r=2;else e=1,n=0,r=1;else e=1,n=0,r=0;else e=0,n=0,r=2;else e=0,n=0,r=1;else e=0,n=0,r=0}while(0);return 0|i[11120+(216*t|0)+(72*n|0)+(24*e|0)+(r<<3)+4>>2]}(r,0|i[a>>2]);do{if(0|G(r)){switch(0|r){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(27634,27636,75,27645)}if(c=0|i[26480+(24*l|0)+8>>2],t=0|i[26480+(24*l|0)+16>>2],(0|(e=0|i[a>>2]))!=(0|i[u>>2])&&(u=0|H(r))|(0|(e=0|i[a>>2]))==(0|t)&&(A=(A+1|0)%6|0),3==(0|o)&(0|e)==(0|t)){A=(A+5|0)%6|0;break}5==(0|o)&(0|e)==(0|c)&&(A=(A+1|0)%6|0)}}while(0);return i[n>>2]=A,N=s,0|(n=0)}function pt(e,t,n,r){n|=0,r|=0;var a,o,s,A,l,c=0,u=0,f=0,d=0,h=0,p=0,m=0,g=0,b=0,v=0,y=0;if(l=N,N=N+32|0,y=l+24|0,A=l+20|0,s=l+8|0,o=l+16|0,a=l,h=(h=!(0|Se(e|=0,t|=0)))?6:5,m=0|Vt(0|e,0|t,52),S(),h>>>0<=n>>>0)return N=l,0|(r=2);!(g=!(0|(m&=15)))&&!((b=0|jt(7,0,3*(15^m)|0))&e|0)&!((0|S())&t)?c=n:u=4;e:do{if(4==(0|u)){if((0|((c=!!(0|Se(e,t)))?4:5))<(0|n))return N=l,0|(r=1);if(0|ht(e,t,y))return N=l,0|(r=1);if(u=(0|i[y>>2])+n|0,7==(0|(b=0|i[(c=c?26768+((0|u)%5<<2)|0:26800+((0|u)%6<<2)|0)>>2])))return N=l,0|(r=1);i[A>>2]=0,c=0|F(e,t,b,A,s);do{if(!c){if(p=0|i[(d=s)>>2],u=(f=(d=0|i[d+4>>2])>>>0<t>>>0|(0|d)==(0|t)&p>>>0<e>>>0)?p:e,f=f?d:t,!g&&!(p&(g=0|jt(7,0,3*(15^m)|0))|0)&!(d&(0|S())))c=n;else{if(d=(n+-1+h|0)%(0|h)|0,c=0|Se(e,t),(0|d)<0&&M(27634,27636,248,27661),(0|((h=!!(0|c))?4:5))<(0|d)&&M(27634,27636,248,27661),0|ht(e,t,y)&&M(27634,27636,248,27661),c=(0|i[y>>2])+d|0,7==(0|(d=0|i[(c=h?26768+((0|c)%5<<2)|0:26800+((0|c)%6<<2)|0)>>2]))&&M(27634,27636,248,27661),i[o>>2]=0,0|(c=0|F(e,t,d,o,a)))break;h=0|i[(p=a)>>2],p=0|i[p+4>>2];do{if(p>>>0<f>>>0|(0|p)==(0|f)&h>>>0<u>>>0){if(u=0|Se(h,p)?0|V(h,p,e,t):0|i[26864+(((0|i[o>>2])+(0|i[26832+(d<<2)>>2])|0)%6<<2)>>2],c=0|Se(h,p),(u+-1|0)>>>0>5){c=-1,u=h,f=p;break}if(1==(0|u)&(c=!!(0|c))){c=-1,u=h,f=p;break}do{if(!(0|ht(h,p,y))){if(c){c=(5+(0|i[26416+(u<<2)>>2])-(0|i[y>>2])|0)%5|0;break}c=(6+(0|i[26448+(u<<2)>>2])-(0|i[y>>2])|0)%6|0;break}c=-1}while(0);u=h,f=p}else c=n}while(0);p=0|i[(d=s)>>2],d=0|i[d+4>>2]}if((0|u)==(0|p)&(0|f)==(0|d)){if(e=(h=!!(0|Se(p,d)))?0|V(p,d,e,t):0|i[26864+(((0|i[A>>2])+(0|i[26832+(b<<2)>>2])|0)%6<<2)>>2],c=0|Se(p,d),(e+-1|0)>>>0<=5&&!(1==(0|e)&(v=!!(0|c))))do{if(!(0|ht(p,d,y))){if(v){c=(5+(0|i[26416+(e<<2)>>2])-(0|i[y>>2])|0)%5|0;break}c=(6+(0|i[26448+(e<<2)>>2])-(0|i[y>>2])|0)%6|0;break}c=-1}while(0);else c=-1;c=6==(0|(c=c+1|0))|h&5==(0|c)?0:c}t=f,e=u;break e}}while(0);return N=l,0|(r=c)}}while(0);return v=0|jt(0|c,0,56),y=S()|-2130706433&t|536870912,i[r>>2]=v|e,i[r+4>>2]=y,N=l,0|(r=0)}function mt(e,t){e|=0;var n,r,a=0,o=0;return r=N,N=N+16|0,n=r,!0&536870912==(2013265920&(t|=0))&&0|xe(e,a=-2130706433&t|134217728)?(o=0|Vt(0|e,0|t,56),S(),a=(o=!(0|pt(e,a,7&o,n)))&((0|i[(a=n)>>2])==(0|e)?(0|i[a+4>>2])==(0|t):0)&1,N=r,0|a):(N=r,0|(a=0))}function gt(e,t,n,r){e|=0,r|=0;var a,o,s,A=0,l=0,c=0,u=0,f=0,d=0;s=N,N=N+208|0,a=s,o=s+192|0,c=0|v(n|=0,t|=0),i[(u=o)>>2]=1,i[u+4>>2]=0;e:do{if(0|c){for(u=0-n|0,i[a+4>>2]=n,i[a>>2]=n,A=2,t=n,l=n;t=t+n+l|0,i[a+(A<<2)>>2]=t,t>>>0<c>>>0;)d=l,A=A+1|0,l=t,t=d;if((l=e+c+u|0)>>>0>e>>>0){c=l,A=1,t=1;do{do{if(3&~t){if((0|i[a+((t=A+-1|0)<<2)>>2])>>>0<(c-e|0)>>>0?bt(e,n,r,A,a):yt(e,n,r,o,A,0,a),1==(0|A)){xt(o,1),A=0;break}xt(o,t),A=1;break}bt(e,n,r,A,a),vt(o,2),A=A+2|0}while(0);t=1|i[o>>2],i[o>>2]=t,e=e+n|0}while(e>>>0<l>>>0)}else A=1,t=1;for(yt(e,n,r,o,A,0,a),l=o+4|0;;){if(1==(0|A)&1==(0|t)){if(!(0|i[l>>2]))break e;f=19}else(0|A)<2?f=19:(xt(o,2),d=A+-2|0,i[o>>2]=7^i[o>>2],vt(o,1),yt(e+(0-(0|i[a+(d<<2)>>2]))+u|0,n,r,o,A+-1|0,1,a),xt(o,1),t=1|i[o>>2],i[o>>2]=t,yt(e=e+u|0,n,r,o,d,1,a),A=d);19==(0|f)&&(f=0,vt(o,t=0|_t(o)),e=e+u|0,A=t+A|0,t=0|i[o>>2])}}}while(0);N=s}function bt(e,t,n,r,a){e|=0,t|=0,n|=0,r|=0,a|=0;var o,s,A=0,l=0,c=0,u=0,f=0;s=N,N=N+240|0,i[(o=s)>>2]=e;e:do{if((0|r)>1)for(f=0-t|0,c=e,A=r,r=1,l=e;;){if(e=(c=c+f|0)+(0-(0|i[a+((u=A+-2|0)<<2)>>2]))|0,(0|Yt[3&n](l,e))>-1&&(0|Yt[3&n](l,c))>-1)break e;if(l=o+(r<<2)|0,(0|Yt[3&n](e,c))>-1?(i[l>>2]=e,A=A+-1|0):(i[l>>2]=c,e=c,A=u),r=r+1|0,(0|A)<=1)break e;c=e,l=0|i[o>>2]}else r=1}while(0);Tt(t,o,r),N=s}function vt(e,t){var n,r=0,a=0;n=(e|=0)+4|0,(t|=0)>>>0>31?(a=0|i[n>>2],i[e>>2]=a,i[n>>2]=0,t=t+-32|0,r=0):(r=0|i[n>>2],a=0|i[e>>2]),i[e>>2]=r<<32-t|a>>>t,i[n>>2]=r>>>t}function yt(e,t,n,r,a,o,s){e|=0,t|=0,n|=0,a|=0,o|=0,s|=0;var A,l,c,u,f=0,d=0,h=0,p=0;u=N,N=N+240|0,l=u+232|0,c=u,p=0|i[(r|=0)>>2],i[l>>2]=p,d=0|i[r+4>>2],i[(A=l+4|0)>>2]=d,i[c>>2]=e;e:do{if(1!=(0|p)|!!(0|d)&&(h=0-t|0,f=e+(0-(0|i[s+(a<<2)>>2]))|0,(0|Yt[3&n](f,e))>=1))for(r=1,o=!(0|o),d=f;;){if(o&(0|a)>1){if(o=e+h|0,f=0|i[s+(a+-2<<2)>>2],(0|Yt[3&n](o,d))>-1){f=10;break e}if((0|Yt[3&n](o+(0-f)|0,d))>-1){f=10;break e}}if(o=r+1|0,i[c+(r<<2)>>2]=d,vt(l,p=0|_t(l)),a=p+a|0,!(1!=(0|i[l>>2])|!!(0|i[A>>2]))){r=o,e=d,f=10;break e}if(e=d+(0-(0|i[s+(a<<2)>>2]))|0,(0|Yt[3&n](e,0|i[c>>2]))<1){e=d,r=o,o=0,f=9;break}p=d,r=o,o=1,d=e,e=p}else r=1,f=9}while(0);9!=(0|f)||0|o||(f=10),10==(0|f)&&(Tt(t,c,r),bt(e,t,n,a,s)),N=u}function xt(e,t){var n,r=0,a=0;n=(e|=0)+4|0,(t|=0)>>>0>31?(a=0|i[e>>2],i[n>>2]=a,i[e>>2]=0,t=t+-32|0,r=0):(r=0|i[e>>2],a=0|i[n>>2]),i[n>>2]=r>>>(32-t|0)|a<<t,i[e>>2]=r<<t}function _t(e){var t=0;return(t=0|wt((0|i[(e|=0)>>2])-1|0))?0|t:0|(0|(t=0|wt(0|i[e+4>>2]))?t+32:0)}function wt(e){var t=0;if(e|=0)if(1&e)e=0;else for(t=e,e=0;e=e+1|0,!(2&t);)t>>>=1;else e=32;return 0|e}function Tt(e,t,n){e|=0,t|=0,n|=0;var r,a=0,o=0,s=0,A=0;r=N,N=N+256|0,a=r;e:do{if((0|n)>=2&&(s=t+(n<<2)|0,i[s>>2]=a,0|e))for(;;){o=e>>>0<256?e:256,Qt(0|a,0|i[t>>2],0|o),a=0;do{A=t+(a<<2)|0,a=a+1|0,Qt(0|i[A>>2],0|i[t+(a<<2)>>2],0|o),i[A>>2]=(0|i[A>>2])+o}while((0|a)!=(0|n));if(!(e=e-o|0))break e;a=0|i[s>>2]}}while(0);N=r}function St(e){return 0|+$t(+(e=+e))}function Mt(e){e|=0;var t,n=0,r=0,a=0,o=0,s=0,A=0,l=0,c=0,u=0,f=0,d=0,h=0,p=0,m=0,g=0,b=0,v=0,y=0,x=0,_=0;t=N,N=N+16|0,h=t;do{if(e>>>0<245){if(e=(u=e>>>0<11?16:e+11&-8)>>>3,3&(r=(d=0|i[6921])>>>e))return a=0|i[(r=(e=27724+((n=(1&r^1)+e|0)<<1<<2)|0)+8|0)>>2],(0|(s=0|i[(o=a+8|0)>>2]))==(0|e)?i[6921]=d&~(1<<n):(i[s+12>>2]=e,i[r>>2]=s),_=n<<3,i[a+4>>2]=3|_,i[(_=a+_+4|0)>>2]=1|i[_>>2],N=t,0|(_=o);if(u>>>0>(f=0|i[6923])>>>0){if(0|r)return n=((n=r<<e&((n=2<<e)|0-n))&0-n)-1|0,s=0|i[(e=(n=27724+((a=((r=(n>>>=l=n>>>12&16)>>>5&8)|l|(s=(n>>>=r)>>>2&4)|(e=(n>>>=s)>>>1&2)|(a=(n>>>=e)>>>1&1))+(n>>>a)|0)<<1<<2)|0)+8|0)>>2],(0|(r=0|i[(l=s+8|0)>>2]))==(0|n)?(e=d&~(1<<a),i[6921]=e):(i[r+12>>2]=n,i[e>>2]=r,e=d),A=(_=a<<3)-u|0,i[s+4>>2]=3|u,i[(o=s+u|0)+4>>2]=1|A,i[s+_>>2]=A,0|f&&(a=0|i[6926],r=27724+((n=f>>>3)<<1<<2)|0,e&(n=1<<n)?n=0|i[(e=r+8|0)>>2]:(i[6921]=e|n,n=r,e=r+8|0),i[e>>2]=a,i[n+12>>2]=a,i[a+8>>2]=n,i[a+12>>2]=r),i[6923]=A,i[6926]=o,N=t,0|(_=l);if(s=0|i[6922]){for(r=(s&0-s)-1|0,r=c=0|i[27988+(((a=(r>>>=o=r>>>12&16)>>>5&8)|o|(A=(r>>>=a)>>>2&4)|(l=(r>>>=A)>>>1&2)|(c=(r>>>=l)>>>1&1))+(r>>>c)<<2)>>2],l=c,c=(-8&i[c+4>>2])-u|0;(e=0|i[r+16>>2])||(e=0|i[r+20>>2]);)r=e,l=(o=(A=(-8&i[e+4>>2])-u|0)>>>0<c>>>0)?e:l,c=o?A:c;if((A=l+u|0)>>>0>l>>>0){o=0|i[l+24>>2],n=0|i[l+12>>2];do{if((0|n)==(0|l)){if(!(n=0|i[(e=l+20|0)>>2])&&!(n=0|i[(e=l+16|0)>>2])){r=0;break}for(;;)if(r=0|i[(a=n+20|0)>>2])n=r,e=a;else{if(!(r=0|i[(a=n+16|0)>>2]))break;n=r,e=a}i[e>>2]=0,r=n}else r=0|i[l+8>>2],i[r+12>>2]=n,i[n+8>>2]=r,r=n}while(0);do{if(0|o){if(n=0|i[l+28>>2],(0|l)==(0|i[(e=27988+(n<<2)|0)>>2])){if(i[e>>2]=r,!r){i[6922]=s&~(1<<n);break}}else if(i[((0|i[(_=o+16|0)>>2])==(0|l)?_:o+20)>>2]=r,!r)break;i[r+24>>2]=o,0|(n=0|i[l+16>>2])&&(i[r+16>>2]=n,i[n+24>>2]=r),0|(n=0|i[l+20>>2])&&(i[r+20>>2]=n,i[n+24>>2]=r)}}while(0);return c>>>0<16?(_=c+u|0,i[l+4>>2]=3|_,i[(_=l+_+4|0)>>2]=1|i[_>>2]):(i[l+4>>2]=3|u,i[A+4>>2]=1|c,i[A+c>>2]=c,0|f&&(a=0|i[6926],r=27724+((n=f>>>3)<<1<<2)|0,(n=1<<n)&d?n=0|i[(e=r+8|0)>>2]:(i[6921]=n|d,n=r,e=r+8|0),i[e>>2]=a,i[n+12>>2]=a,i[a+8>>2]=n,i[a+12>>2]=r),i[6923]=c,i[6926]=A),N=t,0|(_=l+8|0)}d=u}else d=u}else d=u}else if(e>>>0<=4294967231)if(u=-8&(e=e+11|0),a=0|i[6922]){o=0-u|0,c=(e>>>=8)?u>>>0>16777215?31:u>>>((c=14-((l=((g=e<<(d=(e+1048320|0)>>>16&8))+520192|0)>>>16&4)|d|(c=((g<<=l)+245760|0)>>>16&2))+(g<<c>>>15)|0)+7|0)&1|c<<1:0,r=0|i[27988+(c<<2)>>2];e:do{if(r)for(e=0,l=u<<(31==(0|c)?0:25-(c>>>1)|0),s=0;;){if((A=(-8&i[r+4>>2])-u|0)>>>0<o>>>0){if(!A){e=r,o=0,g=65;break e}e=r,o=A}if(s=!(0|(g=0|i[r+20>>2]))|(0|g)==(0|(r=0|i[r+16+(l>>>31<<2)>>2]))?s:g,!r){r=s,g=61;break}l<<=1}else r=0,e=0,g=61}while(0);if(61==(0|g)){if(!(0|r)&!(0|e)){if(!(e=((e=2<<c)|0-e)&a)){d=u;break}d=(e&0-e)-1|0,e=0,r=0|i[27988+(((s=(d>>>=A=d>>>12&16)>>>5&8)|A|(l=(d>>>=s)>>>2&4)|(c=(d>>>=l)>>>1&2)|(r=(d>>>=c)>>>1&1))+(d>>>r)<<2)>>2]}r?g=65:(l=e,A=o)}if(65==(0|g))for(s=r;;){if(o=(r=(d=(-8&i[s+4>>2])-u|0)>>>0<o>>>0)?d:o,e=r?s:e,(r=0|i[s+16>>2])||(r=0|i[s+20>>2]),!r){l=e,A=o;break}s=r}if(0|l&&A>>>0<((0|i[6923])-u|0)>>>0&&(f=l+u|0)>>>0>l>>>0){s=0|i[l+24>>2],n=0|i[l+12>>2];do{if((0|n)==(0|l)){if(!(n=0|i[(e=l+20|0)>>2])&&!(n=0|i[(e=l+16|0)>>2])){n=0;break}for(;;)if(r=0|i[(o=n+20|0)>>2])n=r,e=o;else{if(!(r=0|i[(o=n+16|0)>>2]))break;n=r,e=o}i[e>>2]=0}else _=0|i[l+8>>2],i[_+12>>2]=n,i[n+8>>2]=_}while(0);do{if(s){if(e=0|i[l+28>>2],(0|l)==(0|i[(r=27988+(e<<2)|0)>>2])){if(i[r>>2]=n,!n){a&=~(1<<e),i[6922]=a;break}}else if(i[((0|i[(_=s+16|0)>>2])==(0|l)?_:s+20)>>2]=n,!n)break;i[n+24>>2]=s,0|(e=0|i[l+16>>2])&&(i[n+16>>2]=e,i[e+24>>2]=n),(e=0|i[l+20>>2])&&(i[n+20>>2]=e,i[e+24>>2]=n)}}while(0);e:do{if(A>>>0<16)_=A+u|0,i[l+4>>2]=3|_,i[(_=l+_+4|0)>>2]=1|i[_>>2];else{if(i[l+4>>2]=3|u,i[f+4>>2]=1|A,i[f+A>>2]=A,n=A>>>3,A>>>0<256){r=27724+(n<<1<<2)|0,(e=0|i[6921])&(n=1<<n)?n=0|i[(e=r+8|0)>>2]:(i[6921]=e|n,n=r,e=r+8|0),i[e>>2]=f,i[n+12>>2]=f,i[f+8>>2]=n,i[f+12>>2]=r;break}if(n=27988+((r=(n=A>>>8)?A>>>0>16777215?31:A>>>((r=14-((y=((_=n<<(x=(n+1048320|0)>>>16&8))+520192|0)>>>16&4)|x|(r=((_<<=y)+245760|0)>>>16&2))+(_<<r>>>15)|0)+7|0)&1|r<<1:0)<<2)|0,i[f+28>>2]=r,i[(e=f+16|0)+4>>2]=0,i[e>>2]=0,!(a&(e=1<<r))){i[6922]=a|e,i[n>>2]=f,i[f+24>>2]=n,i[f+12>>2]=f,i[f+8>>2]=f;break}n=0|i[n>>2];t:do{if((-8&i[n+4>>2])!=(0|A)){for(a=A<<(31==(0|r)?0:25-(r>>>1)|0);e=0|i[(r=n+16+(a>>>31<<2)|0)>>2];){if((-8&i[e+4>>2])==(0|A)){n=e;break t}a<<=1,n=e}i[r>>2]=f,i[f+24>>2]=n,i[f+12>>2]=f,i[f+8>>2]=f;break e}}while(0);_=0|i[(x=n+8|0)>>2],i[_+12>>2]=f,i[x>>2]=f,i[f+8>>2]=_,i[f+12>>2]=n,i[f+24>>2]=0}}while(0);return N=t,0|(_=l+8|0)}d=u}else d=u;else d=-1}while(0);if((r=0|i[6923])>>>0>=d>>>0)return n=r-d|0,e=0|i[6926],n>>>0>15?(_=e+d|0,i[6926]=_,i[6923]=n,i[_+4>>2]=1|n,i[e+r>>2]=n,i[e+4>>2]=3|d):(i[6923]=0,i[6926]=0,i[e+4>>2]=3|r,i[(_=e+r+4|0)>>2]=1|i[_>>2]),N=t,0|(_=e+8|0);if((A=0|i[6924])>>>0>d>>>0)return y=A-d|0,i[6924]=y,x=(_=0|i[6927])+d|0,i[6927]=x,i[x+4>>2]=1|y,i[_+4>>2]=3|d,N=t,0|(_=_+8|0);if(0|i[7039]?e=0|i[7041]:(i[7041]=4096,i[7040]=4096,i[7042]=-1,i[7043]=-1,i[7044]=0,i[7032]=0,i[7039]=-16&h^1431655768,e=4096),l=d+48|0,(u=(s=e+(c=d+47|0)|0)&(o=0-e|0))>>>0<=d>>>0)return N=t,0|(_=0);if(0|(e=0|i[7031])&&(h=(f=0|i[7029])+u|0)>>>0<=f>>>0|h>>>0>e>>>0)return N=t,0|(_=0);e:do{if(4&i[7032])n=0,g=143;else{r=0|i[6927];t:do{if(r){for(a=28132;!((h=0|i[a>>2])>>>0<=r>>>0&&(h+(0|i[a+4>>2])|0)>>>0>r>>>0);){if(!(e=0|i[a+8>>2])){g=128;break t}a=e}if((n=s-A&o)>>>0<2147483647)if((0|(e=0|Jt(0|n)))==((0|i[a>>2])+(0|i[a+4>>2])|0)){if(-1!=(0|e)){A=n,s=e,g=145;break e}}else a=e,g=136;else n=0}else g=128}while(0);do{if(128==(0|g))if(-1!=(0|(r=0|Jt(0)))&&(n=r,m=(n=((m=(p=0|i[7040])+-1|0)&n|0?(m+n&0-p)-n|0:0)+u|0)+(p=0|i[7029])|0,n>>>0>d>>>0&n>>>0<2147483647)){if(0|(h=0|i[7031])&&m>>>0<=p>>>0|m>>>0>h>>>0){n=0;break}if((0|(e=0|Jt(0|n)))==(0|r)){A=n,s=r,g=145;break e}a=e,g=136}else n=0}while(0);do{if(136==(0|g)){if(r=0-n|0,!(l>>>0>n>>>0&n>>>0<2147483647&-1!=(0|a))){if(-1==(0|a)){n=0;break}A=n,s=a,g=145;break e}if((e=c-n+(e=0|i[7041])&0-e)>>>0>=2147483647){A=n,s=a,g=145;break e}if(-1==(0|Jt(0|e))){Jt(0|r),n=0;break}A=e+n|0,s=a,g=145;break e}}while(0);i[7032]=4|i[7032],g=143}}while(0);if(143==(0|g)&&u>>>0<2147483647&&!(-1==(0|(y=0|Jt(0|u)))|1^(v=(b=(m=0|Jt(0))-y|0)>>>0>(d+40|0)>>>0)|y>>>0<m>>>0&-1!=(0|y)&-1!=(0|m)^1)&&(A=v?b:n,s=y,g=145),145==(0|g)){n=(0|i[7029])+A|0,i[7029]=n,n>>>0>(0|i[7030])>>>0&&(i[7030]=n),c=0|i[6927];e:do{if(c){for(n=28132;;){if((0|s)==((e=0|i[n>>2])+(r=0|i[n+4>>2])|0)){g=154;break}if(!(a=0|i[n+8>>2]))break;n=a}if(!(154!=(0|g)||(x=n+4|0,8&i[n+12>>2]))&&s>>>0>c>>>0&e>>>0<=c>>>0){i[x>>2]=r+A,x=c+(y=7&(y=c+8|0)?0-y&7:0)|0,y=(_=(0|i[6924])+A|0)-y|0,i[6927]=x,i[6924]=y,i[x+4>>2]=1|y,i[c+_+4>>2]=40,i[6928]=i[7043];break}for(s>>>0<(0|i[6925])>>>0&&(i[6925]=s),r=s+A|0,n=28132;;){if((0|i[n>>2])==(0|r)){g=162;break}if(!(e=0|i[n+8>>2]))break;n=e}if(162==(0|g)&&!(8&i[n+12>>2])){i[n>>2]=s,i[(f=n+4|0)>>2]=(0|i[f>>2])+A,u=(f=s+(7&(f=s+8|0)?0-f&7:0)|0)+d|0,l=(n=r+(7&(n=r+8|0)?0-n&7:0)|0)-f-d|0,i[f+4>>2]=3|d;t:do{if((0|c)==(0|n))_=(0|i[6924])+l|0,i[6924]=_,i[6927]=u,i[u+4>>2]=1|_;else{if((0|i[6926])==(0|n)){_=(0|i[6923])+l|0,i[6923]=_,i[6926]=u,i[u+4>>2]=1|_,i[u+_>>2]=_;break}if(1==(3&(e=0|i[n+4>>2]))){A=-8&e,a=e>>>3;n:do{if(e>>>0<256){if(e=0|i[n+8>>2],(0|(r=0|i[n+12>>2]))==(0|e)){i[6921]=i[6921]&~(1<<a);break}i[e+12>>2]=r,i[r+8>>2]=e;break}s=0|i[n+24>>2],e=0|i[n+12>>2];do{if((0|e)==(0|n)){if(e=0|i[(a=(r=n+16|0)+4|0)>>2])r=a;else if(!(e=0|i[r>>2])){e=0;break}for(;;)if(a=0|i[(o=e+20|0)>>2])e=a,r=o;else{if(!(a=0|i[(o=e+16|0)>>2]))break;e=a,r=o}i[r>>2]=0}else _=0|i[n+8>>2],i[_+12>>2]=e,i[e+8>>2]=_}while(0);if(!s)break;a=27988+((r=0|i[n+28>>2])<<2)|0;do{if((0|i[a>>2])==(0|n)){if(i[a>>2]=e,0|e)break;i[6922]=i[6922]&~(1<<r);break n}if(i[((0|i[(_=s+16|0)>>2])==(0|n)?_:s+20)>>2]=e,!e)break n}while(0);if(i[e+24>>2]=s,0|(a=0|i[(r=n+16|0)>>2])&&(i[e+16>>2]=a,i[a+24>>2]=e),!(r=0|i[r+4>>2]))break;i[e+20>>2]=r,i[r+24>>2]=e}while(0);n=n+A|0,o=A+l|0}else o=l;if(i[(n=n+4|0)>>2]=-2&i[n>>2],i[u+4>>2]=1|o,i[u+o>>2]=o,n=o>>>3,o>>>0<256){r=27724+(n<<1<<2)|0,(e=0|i[6921])&(n=1<<n)?n=0|i[(e=r+8|0)>>2]:(i[6921]=e|n,n=r,e=r+8|0),i[e>>2]=u,i[n+12>>2]=u,i[u+8>>2]=n,i[u+12>>2]=r;break}n=o>>>8;do{if(n){if(o>>>0>16777215){a=31;break}a=o>>>((a=14-((y=((_=n<<(x=(n+1048320|0)>>>16&8))+520192|0)>>>16&4)|x|(a=((_<<=y)+245760|0)>>>16&2))+(_<<a>>>15)|0)+7|0)&1|a<<1}else a=0}while(0);if(n=27988+(a<<2)|0,i[u+28>>2]=a,i[(e=u+16|0)+4>>2]=0,i[e>>2]=0,!((e=0|i[6922])&(r=1<<a))){i[6922]=e|r,i[n>>2]=u,i[u+24>>2]=n,i[u+12>>2]=u,i[u+8>>2]=u;break}n=0|i[n>>2];n:do{if((-8&i[n+4>>2])!=(0|o)){for(a=o<<(31==(0|a)?0:25-(a>>>1)|0);e=0|i[(r=n+16+(a>>>31<<2)|0)>>2];){if((-8&i[e+4>>2])==(0|o)){n=e;break n}a<<=1,n=e}i[r>>2]=u,i[u+24>>2]=n,i[u+12>>2]=u,i[u+8>>2]=u;break t}}while(0);_=0|i[(x=n+8|0)>>2],i[_+12>>2]=u,i[x>>2]=u,i[u+8>>2]=_,i[u+12>>2]=n,i[u+24>>2]=0}}while(0);return N=t,0|(_=f+8|0)}for(n=28132;!((e=0|i[n>>2])>>>0<=c>>>0&&(_=e+(0|i[n+4>>2])|0)>>>0>c>>>0);)n=0|i[n+8>>2];n=(e=(e=(o=_+-47|0)+(7&(e=o+8|0)?0-e&7:0)|0)>>>0<(o=c+16|0)>>>0?c:e)+8|0,x=s+(y=7&(y=s+8|0)?0-y&7:0)|0,y=(r=A+-40|0)-y|0,i[6927]=x,i[6924]=y,i[x+4>>2]=1|y,i[s+r+4>>2]=40,i[6928]=i[7043],i[(r=e+4|0)>>2]=27,i[n>>2]=i[7033],i[n+4>>2]=i[7034],i[n+8>>2]=i[7035],i[n+12>>2]=i[7036],i[7033]=s,i[7034]=A,i[7036]=0,i[7035]=n,n=e+24|0;do{x=n,i[(n=n+4|0)>>2]=7}while((x+8|0)>>>0<_>>>0);if((0|e)!=(0|c)){if(s=e-c|0,i[r>>2]=-2&i[r>>2],i[c+4>>2]=1|s,i[e>>2]=s,n=s>>>3,s>>>0<256){r=27724+(n<<1<<2)|0,(e=0|i[6921])&(n=1<<n)?n=0|i[(e=r+8|0)>>2]:(i[6921]=e|n,n=r,e=r+8|0),i[e>>2]=c,i[n+12>>2]=c,i[c+8>>2]=n,i[c+12>>2]=r;break}if(r=27988+((a=(n=s>>>8)?s>>>0>16777215?31:s>>>((a=14-((y=((_=n<<(x=(n+1048320|0)>>>16&8))+520192|0)>>>16&4)|x|(a=((_<<=y)+245760|0)>>>16&2))+(_<<a>>>15)|0)+7|0)&1|a<<1:0)<<2)|0,i[c+28>>2]=a,i[c+20>>2]=0,i[o>>2]=0,!((n=0|i[6922])&(e=1<<a))){i[6922]=n|e,i[r>>2]=c,i[c+24>>2]=r,i[c+12>>2]=c,i[c+8>>2]=c;break}n=0|i[r>>2];t:do{if((-8&i[n+4>>2])!=(0|s)){for(a=s<<(31==(0|a)?0:25-(a>>>1)|0);e=0|i[(r=n+16+(a>>>31<<2)|0)>>2];){if((-8&i[e+4>>2])==(0|s)){n=e;break t}a<<=1,n=e}i[r>>2]=c,i[c+24>>2]=n,i[c+12>>2]=c,i[c+8>>2]=c;break e}}while(0);_=0|i[(x=n+8|0)>>2],i[_+12>>2]=c,i[x>>2]=c,i[c+8>>2]=_,i[c+12>>2]=n,i[c+24>>2]=0}}else!(0|(_=0|i[6925]))|s>>>0<_>>>0&&(i[6925]=s),i[7033]=s,i[7034]=A,i[7036]=0,i[6930]=i[7039],i[6929]=-1,i[6934]=27724,i[6933]=27724,i[6936]=27732,i[6935]=27732,i[6938]=27740,i[6937]=27740,i[6940]=27748,i[6939]=27748,i[6942]=27756,i[6941]=27756,i[6944]=27764,i[6943]=27764,i[6946]=27772,i[6945]=27772,i[6948]=27780,i[6947]=27780,i[6950]=27788,i[6949]=27788,i[6952]=27796,i[6951]=27796,i[6954]=27804,i[6953]=27804,i[6956]=27812,i[6955]=27812,i[6958]=27820,i[6957]=27820,i[6960]=27828,i[6959]=27828,i[6962]=27836,i[6961]=27836,i[6964]=27844,i[6963]=27844,i[6966]=27852,i[6965]=27852,i[6968]=27860,i[6967]=27860,i[6970]=27868,i[6969]=27868,i[6972]=27876,i[6971]=27876,i[6974]=27884,i[6973]=27884,i[6976]=27892,i[6975]=27892,i[6978]=27900,i[6977]=27900,i[6980]=27908,i[6979]=27908,i[6982]=27916,i[6981]=27916,i[6984]=27924,i[6983]=27924,i[6986]=27932,i[6985]=27932,i[6988]=27940,i[6987]=27940,i[6990]=27948,i[6989]=27948,i[6992]=27956,i[6991]=27956,i[6994]=27964,i[6993]=27964,i[6996]=27972,i[6995]=27972,x=s+(y=7&(y=s+8|0)?0-y&7:0)|0,y=(_=A+-40|0)-y|0,i[6927]=x,i[6924]=y,i[x+4>>2]=1|y,i[s+_+4>>2]=40,i[6928]=i[7043]}while(0);if((n=0|i[6924])>>>0>d>>>0)return y=n-d|0,i[6924]=y,x=(_=0|i[6927])+d|0,i[6927]=x,i[x+4>>2]=1|y,i[_+4>>2]=3|d,N=t,0|(_=_+8|0)}return i[(_=27680)>>2]=12,N=t,0|(_=0)}function Et(e){var t=0,n=0,r=0,a=0,o=0,s=0,A=0,l=0;if(e|=0){n=e+-8|0,a=0|i[6925],l=n+(t=-8&(e=0|i[e+-4>>2]))|0;do{if(1&e)A=n,s=n;else{if(r=0|i[n>>2],!(3&e))return;if(o=r+t|0,(s=n+(0-r)|0)>>>0<a>>>0)return;if((0|i[6926])==(0|s)){if(3&~(t=0|i[(e=l+4|0)>>2])){A=s,t=o;break}return i[6923]=o,i[e>>2]=-2&t,i[s+4>>2]=1|o,void(i[s+o>>2]=o)}if(n=r>>>3,r>>>0<256){if(e=0|i[s+8>>2],(0|(t=0|i[s+12>>2]))==(0|e)){i[6921]=i[6921]&~(1<<n),A=s,t=o;break}i[e+12>>2]=t,i[t+8>>2]=e,A=s,t=o;break}a=0|i[s+24>>2],e=0|i[s+12>>2];do{if((0|e)==(0|s)){if(e=0|i[(n=(t=s+16|0)+4|0)>>2])t=n;else if(!(e=0|i[t>>2])){e=0;break}for(;;)if(n=0|i[(r=e+20|0)>>2])e=n,t=r;else{if(!(n=0|i[(r=e+16|0)>>2]))break;e=n,t=r}i[t>>2]=0}else A=0|i[s+8>>2],i[A+12>>2]=e,i[e+8>>2]=A}while(0);if(a){if(t=0|i[s+28>>2],(0|i[(n=27988+(t<<2)|0)>>2])==(0|s)){if(i[n>>2]=e,!e){i[6922]=i[6922]&~(1<<t),A=s,t=o;break}}else if(i[((0|i[(A=a+16|0)>>2])==(0|s)?A:a+20)>>2]=e,!e){A=s,t=o;break}i[e+24>>2]=a,0|(n=0|i[(t=s+16|0)>>2])&&(i[e+16>>2]=n,i[n+24>>2]=e),(t=0|i[t+4>>2])?(i[e+20>>2]=t,i[t+24>>2]=e,A=s,t=o):(A=s,t=o)}else A=s,t=o}}while(0);if(!(s>>>0>=l>>>0)&&1&(r=0|i[(e=l+4|0)>>2])){if(2&r)i[e>>2]=-2&r,i[A+4>>2]=1|t,i[s+t>>2]=t,a=t;else{if((0|i[6927])==(0|l)){if(l=(0|i[6924])+t|0,i[6924]=l,i[6927]=A,i[A+4>>2]=1|l,(0|A)!=(0|i[6926]))return;return i[6926]=0,void(i[6923]=0)}if((0|i[6926])==(0|l))return l=(0|i[6923])+t|0,i[6923]=l,i[6926]=s,i[A+4>>2]=1|l,void(i[s+l>>2]=l);a=(-8&r)+t|0,n=r>>>3;do{if(r>>>0<256){if(t=0|i[l+8>>2],(0|(e=0|i[l+12>>2]))==(0|t)){i[6921]=i[6921]&~(1<<n);break}i[t+12>>2]=e,i[e+8>>2]=t;break}o=0|i[l+24>>2],e=0|i[l+12>>2];do{if((0|e)==(0|l)){if(e=0|i[(n=(t=l+16|0)+4|0)>>2])t=n;else if(!(e=0|i[t>>2])){n=0;break}for(;;)if(n=0|i[(r=e+20|0)>>2])e=n,t=r;else{if(!(n=0|i[(r=e+16|0)>>2]))break;e=n,t=r}i[t>>2]=0,n=e}else n=0|i[l+8>>2],i[n+12>>2]=e,i[e+8>>2]=n,n=e}while(0);if(0|o){if(e=0|i[l+28>>2],(0|i[(t=27988+(e<<2)|0)>>2])==(0|l)){if(i[t>>2]=n,!n){i[6922]=i[6922]&~(1<<e);break}}else if(i[((0|i[(r=o+16|0)>>2])==(0|l)?r:o+20)>>2]=n,!n)break;i[n+24>>2]=o,0|(t=0|i[(e=l+16|0)>>2])&&(i[n+16>>2]=t,i[t+24>>2]=n),0|(e=0|i[e+4>>2])&&(i[n+20>>2]=e,i[e+24>>2]=n)}}while(0);if(i[A+4>>2]=1|a,i[s+a>>2]=a,(0|A)==(0|i[6926]))return void(i[6923]=a)}if(e=a>>>3,a>>>0<256)return n=27724+(e<<1<<2)|0,(t=0|i[6921])&(e=1<<e)?e=0|i[(t=n+8|0)>>2]:(i[6921]=t|e,e=n,t=n+8|0),i[t>>2]=A,i[e+12>>2]=A,i[A+8>>2]=e,void(i[A+12>>2]=n);e=27988+((r=(e=a>>>8)?a>>>0>16777215?31:a>>>((r=14-((o=((l=e<<(s=(e+1048320|0)>>>16&8))+520192|0)>>>16&4)|s|(r=((l<<=o)+245760|0)>>>16&2))+(l<<r>>>15)|0)+7|0)&1|r<<1:0)<<2)|0,i[A+28>>2]=r,i[A+20>>2]=0,i[A+16>>2]=0,t=0|i[6922],n=1<<r;e:do{if(t&n){e=0|i[e>>2];t:do{if((-8&i[e+4>>2])!=(0|a)){for(r=a<<(31==(0|r)?0:25-(r>>>1)|0);t=0|i[(n=e+16+(r>>>31<<2)|0)>>2];){if((-8&i[t+4>>2])==(0|a)){e=t;break t}r<<=1,e=t}i[n>>2]=A,i[A+24>>2]=e,i[A+12>>2]=A,i[A+8>>2]=A;break e}}while(0);l=0|i[(s=e+8|0)>>2],i[l+12>>2]=A,i[s>>2]=A,i[A+8>>2]=l,i[A+12>>2]=e,i[A+24>>2]=0}else i[6922]=t|n,i[e>>2]=A,i[A+24>>2]=e,i[A+12>>2]=A,i[A+8>>2]=A}while(0);if(l=(0|i[6929])-1|0,i[6929]=l,!(0|l)){for(e=28140;e=0|i[e>>2];)e=e+8|0;i[6929]=-1}}}}function Ct(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|Mt(n))&&3&i[e+-4>>2]?(Wt(0|e,0,0|n),0|e):0|e}function It(e,t){t|=0;var n=0,r=0;return(e|=0)?t>>>0>4294967231?(i[(t=27680)>>2]=12,0|(t=0)):(n=0|function(e,t){e|=0,t|=0;var n=0,r=0,a=0,o=0,s=0,A=0,l=0,c=0,u=0,f=0;if(u=e+4|0,f=0|i[u>>2],n=-8&f,A=e+n|0,!(3&f))return t>>>0<256?0|(e=0):n>>>0>=(t+4|0)>>>0&&(n-t|0)>>>0<=i[7041]<<1>>>0?0|e:0|(e=0);if(n>>>0>=t>>>0)return(n=n-t|0)>>>0<=15||(c=e+t|0,i[u>>2]=1&f|t|2,i[c+4>>2]=3|n,i[(f=A+4|0)>>2]=1|i[f>>2],Rt(c,n)),0|e;if((0|i[6927])==(0|A))return n=(c=(0|i[6924])+n|0)-t|0,r=e+t|0,c>>>0<=t>>>0?0|(e=0):(i[u>>2]=1&f|t|2,i[r+4>>2]=1|n,i[6927]=r,i[6924]=n,0|e);if((0|i[6926])==(0|A))return(r=(0|i[6923])+n|0)>>>0<t>>>0?0|(e=0):((n=r-t|0)>>>0>15?(c=e+t|0,r=e+r|0,i[u>>2]=1&f|t|2,i[c+4>>2]=1|n,i[r>>2]=n,i[(r=r+4|0)>>2]=-2&i[r>>2],r=c):(i[u>>2]=1&f|r|2,i[(r=e+r+4|0)>>2]=1|i[r>>2],r=0,n=0),i[6923]=n,i[6926]=r,0|e);if(r=0|i[A+4>>2],2&r)return 0|(e=0);if(l=(-8&r)+n|0,l>>>0<t>>>0)return 0|(e=0);c=l-t|0,a=r>>>3;do{if(r>>>0<256){if(r=0|i[A+8>>2],(0|(n=0|i[A+12>>2]))==(0|r)){i[6921]=i[6921]&~(1<<a);break}i[r+12>>2]=n,i[n+8>>2]=r;break}s=0|i[A+24>>2],n=0|i[A+12>>2];do{if((0|n)==(0|A)){if(n=0|i[(a=(r=A+16|0)+4|0)>>2])r=a;else if(!(n=0|i[r>>2])){a=0;break}for(;;)if(a=0|i[(o=n+20|0)>>2])n=a,r=o;else{if(!(a=0|i[(o=n+16|0)>>2]))break;n=a,r=o}i[r>>2]=0,a=n}else a=0|i[A+8>>2],i[a+12>>2]=n,i[n+8>>2]=a,a=n}while(0);if(0|s){if(n=0|i[A+28>>2],(0|i[(r=27988+(n<<2)|0)>>2])==(0|A)){if(i[r>>2]=a,!a){i[6922]=i[6922]&~(1<<n);break}}else if(i[((0|i[(o=s+16|0)>>2])==(0|A)?o:s+20)>>2]=a,!a)break;i[a+24>>2]=s,0|(r=0|i[(n=A+16|0)>>2])&&(i[a+16>>2]=r,i[r+24>>2]=a),0|(n=0|i[n+4>>2])&&(i[a+20>>2]=n,i[n+24>>2]=a)}}while(0);return c>>>0<16?(i[u>>2]=1&f|l|2,i[(f=e+l+4|0)>>2]=1|i[f>>2],0|e):(A=e+t|0,i[u>>2]=1&f|t|2,i[A+4>>2]=3|c,i[(f=e+l+4|0)>>2]=1|i[f>>2],Rt(A,c),0|e)}(e+-8|0,t>>>0<11?16:t+11&-8),0|n?0|(t=n+8|0):(n=0|Mt(t))?(Qt(0|n,0|e,0|((r=(-8&(r=0|i[e+-4>>2]))-(3&r?4:8)|0)>>>0<t>>>0?r:t)),Et(e),0|(t=n)):0|(t=0)):0|(t=0|Mt(t))}function Rt(e,t){var n=0,r=0,a=0,o=0,s=0,A=0;A=(e|=0)+(t|=0)|0,n=0|i[e+4>>2];do{if(1&n)s=e;else{if(a=0|i[e>>2],!(3&n))return;if(s=e+(0-a)|0,t=a+t|0,(0|i[6926])==(0|s)){if(3&~(n=0|i[(e=A+4|0)>>2]))break;return i[6923]=t,i[e>>2]=-2&n,i[s+4>>2]=1|t,void(i[A>>2]=t)}if(r=a>>>3,a>>>0<256){if(e=0|i[s+8>>2],(0|(n=0|i[s+12>>2]))==(0|e)){i[6921]=i[6921]&~(1<<r);break}i[e+12>>2]=n,i[n+8>>2]=e;break}o=0|i[s+24>>2],e=0|i[s+12>>2];do{if((0|e)==(0|s)){if(e=0|i[(r=(n=s+16|0)+4|0)>>2])n=r;else if(!(e=0|i[n>>2])){e=0;break}for(;;)if(r=0|i[(a=e+20|0)>>2])e=r,n=a;else{if(!(r=0|i[(a=e+16|0)>>2]))break;e=r,n=a}i[n>>2]=0}else a=0|i[s+8>>2],i[a+12>>2]=e,i[e+8>>2]=a}while(0);if(o){if(n=0|i[s+28>>2],(0|i[(r=27988+(n<<2)|0)>>2])==(0|s)){if(i[r>>2]=e,!e){i[6922]=i[6922]&~(1<<n);break}}else if(i[((0|i[(a=o+16|0)>>2])==(0|s)?a:o+20)>>2]=e,!e)break;i[e+24>>2]=o,0|(r=0|i[(n=s+16|0)>>2])&&(i[e+16>>2]=r,i[r+24>>2]=e),(n=0|i[n+4>>2])&&(i[e+20>>2]=n,i[n+24>>2]=e)}}}while(0);if(2&(r=0|i[(e=A+4|0)>>2]))i[e>>2]=-2&r,i[s+4>>2]=1|t,i[s+t>>2]=t,a=t;else{if((0|i[6927])==(0|A)){if(A=(0|i[6924])+t|0,i[6924]=A,i[6927]=s,i[s+4>>2]=1|A,(0|s)!=(0|i[6926]))return;return i[6926]=0,void(i[6923]=0)}if((0|i[6926])==(0|A))return A=(0|i[6923])+t|0,i[6923]=A,i[6926]=s,i[s+4>>2]=1|A,void(i[s+A>>2]=A);a=(-8&r)+t|0,n=r>>>3;do{if(r>>>0<256){if(e=0|i[A+8>>2],(0|(t=0|i[A+12>>2]))==(0|e)){i[6921]=i[6921]&~(1<<n);break}i[e+12>>2]=t,i[t+8>>2]=e;break}o=0|i[A+24>>2],t=0|i[A+12>>2];do{if((0|t)==(0|A)){if(t=0|i[(n=(e=A+16|0)+4|0)>>2])e=n;else if(!(t=0|i[e>>2])){n=0;break}for(;;)if(n=0|i[(r=t+20|0)>>2])t=n,e=r;else{if(!(n=0|i[(r=t+16|0)>>2]))break;t=n,e=r}i[e>>2]=0,n=t}else n=0|i[A+8>>2],i[n+12>>2]=t,i[t+8>>2]=n,n=t}while(0);if(0|o){if(t=0|i[A+28>>2],(0|i[(e=27988+(t<<2)|0)>>2])==(0|A)){if(i[e>>2]=n,!n){i[6922]=i[6922]&~(1<<t);break}}else if(i[((0|i[(r=o+16|0)>>2])==(0|A)?r:o+20)>>2]=n,!n)break;i[n+24>>2]=o,0|(e=0|i[(t=A+16|0)>>2])&&(i[n+16>>2]=e,i[e+24>>2]=n),0|(t=0|i[t+4>>2])&&(i[n+20>>2]=t,i[t+24>>2]=n)}}while(0);if(i[s+4>>2]=1|a,i[s+a>>2]=a,(0|s)==(0|i[6926]))return void(i[6923]=a)}if(t=a>>>3,a>>>0<256)return n=27724+(t<<1<<2)|0,(e=0|i[6921])&(t=1<<t)?t=0|i[(e=n+8|0)>>2]:(i[6921]=e|t,t=n,e=n+8|0),i[e>>2]=s,i[t+12>>2]=s,i[s+8>>2]=t,void(i[s+12>>2]=n);if(t=27988+((r=(t=a>>>8)?a>>>0>16777215?31:a>>>((r=14-((n=((A=t<<(o=(t+1048320|0)>>>16&8))+520192|0)>>>16&4)|o|(r=((A<<=n)+245760|0)>>>16&2))+(A<<r>>>15)|0)+7|0)&1|r<<1:0)<<2)|0,i[s+28>>2]=r,i[s+20>>2]=0,i[s+16>>2]=0,!((e=0|i[6922])&(n=1<<r)))return i[6922]=e|n,i[t>>2]=s,i[s+24>>2]=t,i[s+12>>2]=s,void(i[s+8>>2]=s);t=0|i[t>>2];e:do{if((-8&i[t+4>>2])!=(0|a)){for(r=a<<(31==(0|r)?0:25-(r>>>1)|0);e=0|i[(n=t+16+(r>>>31<<2)|0)>>2];){if((-8&i[e+4>>2])==(0|a)){t=e;break e}r<<=1,t=e}return i[n>>2]=s,i[s+24>>2]=t,i[s+12>>2]=s,void(i[s+8>>2]=s)}}while(0);A=0|i[(o=t+8|0)>>2],i[A+12>>2]=s,i[o>>2]=s,i[s+8>>2]=A,i[s+12>>2]=t,i[s+24>>2]=0}function Pt(e,t,n,r){return 0|(T((t|=0)+(r|=0)+((n=(e|=0)+(n|=0)>>>0)>>>0<e>>>0|0)>>>0|0),n)}function Nt(e,t,n,r){return 0|(T(0|(r=(t|=0)-(r|=0)-((n|=0)>>>0>(e|=0)>>>0|0)>>>0)),e-n>>>0)}function kt(e){return 0|((e|=0)?31-(0|_(e^e-1)):32)}function Lt(e,t,n,r,a){a|=0;var o=0,s=0,A=0,l=0,c=0,u=0,f=0,d=0,h=0,p=0;if(u=e|=0,s=n|=0,A=d=r|=0,!(c=l=t|=0))return o=!!(0|a),A?o?(i[a>>2]=0|e,i[a+4>>2]=0&t,a=0,0|(T(0|(d=0)),a)):(a=0,0|(T(0|(d=0)),a)):(o&&(i[a>>2]=(u>>>0)%(s>>>0),i[a+4>>2]=0),a=(u>>>0)/(s>>>0)>>>0,0|(T(0|(d=0)),a));o=!(0|A);do{if(s){if(!o){if((o=(0|_(0|A))-(0|_(0|c))|0)>>>0<=31){s=f=o+1|0,e=u>>>(f>>>0)&(t=o-31>>31)|c<<(A=31-o|0),t&=c>>>(f>>>0),o=0,A=u<<A;break}return a?(i[a>>2]=0|e,i[a+4>>2]=l|0&t,a=0,0|(T(0|(d=0)),a)):(a=0,0|(T(0|(d=0)),a))}if((o=s-1|0)&s|0){s=A=33+(0|_(0|s))-(0|_(0|c))|0,e=(f=32-A|0)-1>>31&c>>>((h=A-32|0)>>>0)|(c<<f|u>>>(A>>>0))&(t=h>>31),t&=c>>>(A>>>0),o=u<<(p=64-A|0)&(l=f>>31),A=(c<<p|u>>>(h>>>0))&l|u<<f&A-33>>31;break}return 0|a&&(i[a>>2]=o&u,i[a+4>>2]=0),1==(0|s)?(p=0|e,0|(T(0|(h=l|0&t)),p)):(h=c>>>((p=0|kt(0|s))>>>0)|0,p=c<<32-p|u>>>(p>>>0),0|(T(0|h),p))}if(o)return 0|a&&(i[a>>2]=(c>>>0)%(s>>>0),i[a+4>>2]=0),p=(c>>>0)/(s>>>0)>>>0,0|(T(0|(h=0)),p);if(!u)return 0|a&&(i[a>>2]=0,i[a+4>>2]=(c>>>0)%(A>>>0)),p=(c>>>0)/(A>>>0)>>>0,0|(T(0|(h=0)),p);if(!((o=A-1|0)&A))return 0|a&&(i[a>>2]=0|e,i[a+4>>2]=o&c|0&t),h=0,p=c>>>((0|kt(0|A))>>>0),0|(T(0|h),p);if((o=(0|_(0|A))-(0|_(0|c))|0)>>>0<=30){s=t=o+1|0,e=c<<(A=31-o|0)|u>>>(t>>>0),t=c>>>(t>>>0),o=0,A=u<<A;break}return a?(i[a>>2]=0|e,i[a+4>>2]=l|0&t,p=0,0|(T(0|(h=0)),p)):(p=0,0|(T(0|(h=0)),p))}while(0);if(s){c=0|Pt(0|(f=0|n),0|(u=d|0&r),-1,-1),n=0|S(),l=A,A=0;do{r=l,l=o>>>31|l<<1,o=A|o<<1,Nt(0|c,0|n,0|(r=e<<1|r>>>31),0|(d=e>>>31|t<<1)),A=1&(h=(p=0|S())>>31|((0|p)<0?-1:0)<<1),e=0|Nt(0|r,0|d,h&f|0,(((0|p)<0?-1:0)>>31|((0|p)<0?-1:0)<<1)&u),t=0|S(),s=s-1|0}while(0|s);c=l,l=0}else c=A,l=0,A=0;return s=0,0|a&&(i[a>>2]=e,i[a+4>>2]=t),p=o<<1&-2|A,0|(T(0|(h=(0|o)>>>31|(c|s)<<1|l)),p)}function Bt(e,t,n,r){n|=0;var i,a,o,s,A;return a=(r|=0)>>31|((0|r)<0?-1:0)<<1,i=((0|r)<0?-1:0)>>31|((0|r)<0?-1:0)<<1,o=0|Nt((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),e=a^A,t=i^s,0|Nt((0|Lt(o,0|S(),0|Nt(a^n|0,i^r|0,0|a,0|i),0|S(),0))^e,(0|S())^t,0|e,0|t)}function Ot(e,t,n,r){t|=0,r|=0;var i,a;return n=0|function(e,t){var n,r,i,a=0;return e=((n=0|v(a=65535&(t|=0),i=65535&(e|=0)))>>>16)+(0|v(a,r=e>>>16))|0,t=0|v(a=t>>>16,i),0|(T((e>>>16)+(0|v(a,r))+(((65535&e)+t|0)>>>16)|0),e+t<<16|65535&n)}(i=e|=0,a=n|=0),e=0|S(),0|(T((0|v(t,a))+(0|v(r,i))+e|0&e),n)}function Ft(e,t,n,r){n|=0;var a,o,s,A,l,c;return a=N,N=N+16|0,A=0|a,c=(r|=0)>>31|((0|r)<0?-1:0)<<1,l=((0|r)<0?-1:0)>>31|((0|r)<0?-1:0)<<1,Lt(e=0|Nt((s=(t|=0)>>31|((0|t)<0?-1:0)<<1)^(e|=0)|0,(o=((0|t)<0?-1:0)>>31|((0|t)<0?-1:0)<<1)^t|0,0|s,0|o),t=0|S(),0|Nt(c^n|0,l^r|0,0|c,0|l),0|S(),A),r=0|Nt(i[A>>2]^s|0,i[A+4>>2]^o|0,0|s,0|o),n=0|S(),N=a,0|(T(0|n),r)}function Dt(e,t,n,r){var a,o;return o=N,N=N+16|0,Lt(e|=0,t|=0,n|=0,r|=0,a=0|o),N=o,0|(T(0|i[a+4>>2]),i[a>>2])}function Ut(e,t,n){return e|=0,t|=0,(0|(n|=0))<32?(T(t>>n|0),e>>>n|(t&(1<<n)-1)<<32-n):(T(0|((0|t)<0?-1:0)),t>>n-32)}function Vt(e,t,n){return e|=0,t|=0,(0|(n|=0))<32?(T(t>>>n|0),e>>>n|(t&(1<<n)-1)<<32-n):(T(0),t>>>n-32|0)}function jt(e,t,n){return e|=0,t|=0,(0|(n|=0))<32?(T(t<<n|(e&(1<<n)-1<<32-n)>>>32-n),e<<n):(T(e<<n-32),0)}function zt(e,t,n){return e|=0,32==(0|(t=0|_(t|=0)))&&(t=t+(0|_(e))|0),T(0),0|t}function Gt(e,t){return t=+t,(e=+e)!=e?+t:t!=t?+e:+x(+e,+t)}function Ht(e,t){return t=+t,(e=+e)!=e?+t:t!=t?+e:+y(+e,+t)}function qt(e){return(e=+e)>=0?+A(e+.5):+b(e-.5)}function Qt(e,t,n){e|=0,t|=0;var a,o,s=0;if((0|(n|=0))>=8192)return I(0|e,0|t,0|n),0|e;if(o=0|e,a=e+n|0,(3&e)==(3&t)){for(;3&e;){if(!n)return 0|o;r[e|0]=0|r[t|0],e=e+1|0,t=t+1|0,n=n-1|0}for(s=(n=-4&a)-64|0;(0|e)<=(0|s);)i[e>>2]=i[t>>2],i[e+4>>2]=i[t+4>>2],i[e+8>>2]=i[t+8>>2],i[e+12>>2]=i[t+12>>2],i[e+16>>2]=i[t+16>>2],i[e+20>>2]=i[t+20>>2],i[e+24>>2]=i[t+24>>2],i[e+28>>2]=i[t+28>>2],i[e+32>>2]=i[t+32>>2],i[e+36>>2]=i[t+36>>2],i[e+40>>2]=i[t+40>>2],i[e+44>>2]=i[t+44>>2],i[e+48>>2]=i[t+48>>2],i[e+52>>2]=i[t+52>>2],i[e+56>>2]=i[t+56>>2],i[e+60>>2]=i[t+60>>2],e=e+64|0,t=t+64|0;for(;(0|e)<(0|n);)i[e>>2]=i[t>>2],e=e+4|0,t=t+4|0}else for(n=a-4|0;(0|e)<(0|n);)r[e|0]=0|r[t|0],r[e+1|0]=0|r[t+1|0],r[e+2|0]=0|r[t+2|0],r[e+3|0]=0|r[t+3|0],e=e+4|0,t=t+4|0;for(;(0|e)<(0|a);)r[e|0]=0|r[t|0],e=e+1|0,t=t+1|0;return 0|o}function Kt(e,t,n){var i=0;if((0|(t|=0))<(0|(e|=0))&(0|e)<(t+(n|=0)|0)){for(i=e,t=t+n|0,e=e+n|0;(0|n)>0;)t=t-1|0,n=n-1|0,r[(e=e-1|0)|0]=0|r[t|0];e=i}else Qt(e,t,n);return 0|e}function Wt(e,t,n){t|=0;var a,o=0,s=0,A=0;if(a=(e|=0)+(n|=0)|0,t&=255,(0|n)>=67){for(;3&e;)r[e|0]=t,e=e+1|0;for(A=t|t<<8|t<<16|t<<24,s=(o=-4&a)-64|0;(0|e)<=(0|s);)i[e>>2]=A,i[e+4>>2]=A,i[e+8>>2]=A,i[e+12>>2]=A,i[e+16>>2]=A,i[e+20>>2]=A,i[e+24>>2]=A,i[e+28>>2]=A,i[e+32>>2]=A,i[e+36>>2]=A,i[e+40>>2]=A,i[e+44>>2]=A,i[e+48>>2]=A,i[e+52>>2]=A,i[e+56>>2]=A,i[e+60>>2]=A,e=e+64|0;for(;(0|e)<(0|o);)i[e>>2]=A,e=e+4|0}for(;(0|e)<(0|a);)r[e|0]=t,e=e+1|0;return a-n|0}function $t(e){return(e=+e)>=0?+A(e+.5):+b(e-.5)}function Jt(e){e|=0;var t,n,r;return r=0|C(),(0|e)>0&(0|(t=(n=0|i[s>>2])+e|0))<(0|n)|(0|t)<0?(P(0|t),E(12),-1):(0|t)>(0|r)&&!(0|R(0|t))?(E(12),-1):(i[s>>2]=t,0|n)}var Yt=[function(e,t){return w(0),0},function(e,t){t|=0;var n=0,r=0;return e=0|i[(r=e|=0)>>2],r=0|i[r+4>>2],t=0|i[(n=t)>>2],0|(r>>>0<(n=0|i[n+4>>2])>>>0|(0|r)==(0|n)&e>>>0<t>>>0?-1:1&(r>>>0>n>>>0|(0|r)==(0|n)&e>>>0>t>>>0))},function(e,t){t|=0;var n,r,o,s,A=0,l=0;return s=0|i[(l=e|=0)>>2],l=0|i[l+4>>2],o=0|i[(A=t)>>2],l>>>0<(A=0|i[A+4>>2])>>>0|(0|l)==(0|A)&s>>>0<o>>>0?0|(t=-1):l>>>0>A>>>0|(0|l)==(0|A)&s>>>0>o>>>0?0|(t=1):(r=+a[e+8>>3])<(n=+a[t+8>>3])?0|(t=-1):0|(t=r>n&1)},function(e,t){var n,r;return t|=0,0|((r=+a[(e|=0)>>3])>(n=+a[t>>3])?-1:r<n&1)}];return{___divdi3:Bt,___muldi3:Ot,___remdi3:Ft,___uremdi3:Dt,_areNeighborCells:function(e,t,n,r,a){a|=0;var o,s,A,l=0,c=0,u=0,f=0;if(A=N,N=N+64|0,s=A,o=A+56|0,!(!0&134217728==(2013265920&(t|=0))&!0&134217728==(2013265920&(r|=0))))return N=A,0|(a=5);if((0|(e|=0))==(0|(n|=0))&(0|t)==(0|r))return i[a>>2]=0,N=A,0|(a=0);if(c=0|Vt(0|e,0|t,52),S(),c&=15,f=0|Vt(0|n,0|r,52),S(),(0|c)!=(15&f))return N=A,0|(a=12);if(l=c+-1|0,c>>>0>1){we(e,t,l,s),we(n,r,l,o),u=0|i[(f=s)>>2],f=0|i[f+4>>2];e:do{if((0|u)==(0|i[o>>2])&&(0|f)==(0|i[o+4>>2])){l=0|Vt(0|e,0|t,0|(c=3*(15^c)|0)),S(),l&=7,c=0|Vt(0|n,0|r,0|c),S(),c&=7;do{if(!(0|l)|!(0|c))i[a>>2]=1,l=0;else if(7==(0|l))l=5;else{if(1==(0|l)|1==(0|c)&&0|Se(u,f)){l=5;break}if((0|i[15824+(l<<2)>>2])!=(0|c)&&(0|i[15856+(l<<2)>>2])!=(0|c))break e;i[a>>2]=1,l=0}}while(0);return N=A,0|(a=l)}}while(0)}c=(l=s)+56|0;do{i[l>>2]=0,l=l+4|0}while((0|l)<(0|c));return k(e,t,1,s),l=(0|i[(t=s)>>2])==(0|n)&&(0|i[t+4>>2])==(0|r)||(0|i[(t=s+8|0)>>2])==(0|n)&&(0|i[t+4>>2])==(0|r)||(0|i[(t=s+16|0)>>2])==(0|n)&&(0|i[t+4>>2])==(0|r)||(0|i[(t=s+24|0)>>2])==(0|n)&&(0|i[t+4>>2])==(0|r)||(0|i[(t=s+32|0)>>2])==(0|n)&&(0|i[t+4>>2])==(0|r)||(0|i[(t=s+40|0)>>2])==(0|n)&&(0|i[t+4>>2])==(0|r)?1:1&((0|i[(l=s+48|0)>>2])==(0|n)?(0|i[l+4>>2])==(0|r):0),i[a>>2]=l,N=A,0|(a=0)},_bitshift64Ashr:Ut,_bitshift64Lshr:Vt,_bitshift64Shl:jt,_calloc:Ct,_cellAreaKm2:function(e,t,n){n|=0;var r,o,s,A=0;return s=N,N=N+192|0,r=s+176|0,A=s+168|0,(e=0|Ue(e|=0,t|=0,o=s))?(N=s,0|(A=e)):(i[A>>2]=i[o>>2],i[A+4>>2]=o+8,i[r>>2]=i[A>>2],i[r+4>>2]=i[A+4>>2],z(r,n),a[n>>3]=40589732.49931477*+a[n>>3],N=s,0|(A=0))},_cellAreaM2:function(e,t,n){n|=0;var r,o,s,A=0;return s=N,N=N+192|0,r=s+176|0,A=s+168|0,(e=0|Ue(e|=0,t|=0,o=s))?(N=s,0|(A=e)):(i[A>>2]=i[o>>2],i[A+4>>2]=o+8,i[r>>2]=i[A>>2],i[r+4>>2]=i[A+4>>2],z(r,n),a[n>>3]=40589732.49931477*+a[n>>3]*1e6,N=s,0|(A=0))},_cellAreaRads2:function(e,t,n){n|=0;var r,a,o,s=0;return o=N,N=N+192|0,r=o+176|0,s=o+168|0,0|(e=0|Ue(e|=0,t|=0,a=o))?(N=o,0|(s=e)):(i[s>>2]=i[a>>2],i[s+4>>2]=a+8,i[r>>2]=i[s>>2],i[r+4>>2]=i[s+4>>2],z(r,n),N=o,0|(s=0))},_cellToBoundary:Ue,_cellToCenterChild:Ee,_cellToChildPos:function(e,t,n,r){n|=0,r|=0;var a,o=0,s=0,A=0,l=0,c=0,u=0,f=0,d=0,h=0,p=0,m=0,g=0,b=0,v=0;if(a=N,N=N+16|0,b=a,v=0|Vt(0|(e|=0),0|(t|=0),52),S(),v&=15,n>>>0>15)return N=a,0|(v=4);if((0|v)<(0|n))return N=a,0|(v=12);if((0|v)!=(0|n))if(s=0|jt(0|n,0,52),s|=e,l=S()|-15728641&t,(0|v)>(0|n)){c=n;do{g=0|jt(7,0,3*(14-c|0)|0),c=c+1|0,s|=g,l=0|S()|l}while((0|c)<(0|v));g=s}else g=s;else g=e,l=t;m=0|Vt(0|g,0|l,45),S();e:do{if(0|G(127&m)){if(c=0|Vt(0|g,0|l,52),S(),0|(c&=15))for(s=1;;){if(!(!((m=0|jt(7,0,3*(15-s|0)|0))&g|0)&!((0|S())&l))){u=33;break e}if(!(s>>>0<c>>>0))break;s=s+1|0}if(i[(m=r)>>2]=0,i[m+4>>2]=0,(0|v)>(0|n)){for(m=-15728641&t,p=v;;){if(h=p,(p=p+-1|0)>>>0>15|(0|v)<(0|p)){u=19;break}if((0|v)!=(0|p))if(s=0|jt(0|p,0,52),s|=e,c=0|S()|m,(0|v)<(0|h))d=s;else{u=p;do{d=0|jt(7,0,3*(14-u|0)|0),u=u+1|0,s|=d,c=0|S()|c}while((0|u)<(0|v));d=s}else d=e,c=t;if(f=0|Vt(0|d,0|c,45),S(),0|G(127&f)){f=0|Vt(0|d,0|c,52),S(),f&=15;t:do{if(f)for(u=1;;){if(s=0|Vt(0|d,0|c,3*(15-u|0)|0),S(),0|(s&=7))break t;if(!(u>>>0<f>>>0)){s=0;break}u=u+1|0}else s=0}while(0);s=1&!(0|s)}else s=0;if(c=0|Vt(0|e,0|t,3*(15-h|0)|0),S(),7==(0|(c&=7))){o=5,u=42;break}if(1==(0|c)&(s=!!(0|s))){o=5,u=42;break}if(0|(d=c+((!!(0|c)&s)<<31>>31)|0)&&(u=0|Ze(7,0,u=v-h|0,((0|u)<0)<<31>>31),f=0|S(),s?(s=0|Pt(0|(s=0|Ot(0|u,0|f,5,0)),0|S(),-5,-1),s=0|Pt(0|(s=0|Bt(0|s,0|S(),6,0)),0|S(),1,0),c=0|S()):(s=u,c=f),h=0|Pt(0|s,0|c,0|(h=0|Ot(0|u,0|f,0|(h=d+-1|0),((0|h)<0)<<31>>31)),0|S()),f=0|Pt(0|h,0|(d=0|S()),0|i[(f=r)>>2],0|i[f+4>>2]),d=0|S(),i[(h=r)>>2]=f,i[h+4>>2]=d),(0|p)<=(0|n)){u=37;break}}if(19==(0|u))M(27634,27225,1407,27259);else{if(37==(0|u)){o=0|i[(A=r)+4>>2],A=0|i[A>>2];break}if(42==(0|u))return N=a,0|o}}else o=0,A=0}else u=33}while(0);e:do{if(33==(0|u)){if(i[(m=r)>>2]=0,i[m+4>>2]=0,(0|v)>(0|n)){for(s=v;;){if(o=0|Vt(0|e,0|t,3*(15-s|0)|0),S(),7==(0|(o&=7))){o=5;break}if(o=0|Ot(0|(A=0|Ze(7,0,A=v-s|0,((0|A)<0)<<31>>31)),0|S(),0|o,0),A=0|S(),A=0|Pt(0|i[(m=r)>>2],0|i[m+4>>2],0|o,0|A),o=0|S(),i[(m=r)>>2]=A,i[m+4>>2]=o,(0|(s=s+-1|0))<=(0|n))break e}return N=a,0|o}o=0,A=0}}while(0);return 0|Te(g,l,v,b)&&M(27634,27225,1367,27274),((0|o)>-1|-1==(0|o)&A>>>0>4294967295)&((0|(b=0|i[(v=b)+4>>2]))>(0|o)|((0|b)==(0|o)?(0|i[v>>2])>>>0>A>>>0:0))?(N=a,0|(v=0)):(M(27634,27225,1447,27259),0)},_cellToChildren:function(e,t,n,r){r|=0;var a,o,s=0,A=0;if(o=N,N=N+16|0,je(a=o,e|=0,t|=0,n|=0),!(0|(e=0|i[(t=a)>>2]))&!(0|(t=0|i[t+4>>2])))return N=o,0;s=0,n=0;do{i[(A=r+(s<<3)|0)>>2]=e,i[A+4>>2]=t,s=0|Pt(0|s,0|n,1,0),n=0|S(),Ge(a),e=0|i[(A=a)>>2],t=0|i[A+4>>2]}while(!(!(0|e)&!(0|t)));return N=o,0},_cellToChildrenSize:Te,_cellToLatLng:De,_cellToLocalIj:function(e,t,n,r,a,o){o|=0;var s,A=0;return s=N,N=N+16|0,A=s,0|(a|=0)?(N=s,0|(A=15)):((e=0|$e(e|=0,t|=0,n|=0,r|=0,A))||(a=0|i[A+4>>2],e=0|i[A+8>>2],i[o>>2]=(0|i[A>>2])-e,i[o+4>>2]=a-e,e=0),N=s,0|(A=e))},_cellToParent:we,_cellToVertex:pt,_cellToVertexes:function(e,t,n){n|=0;var r,a=0,o=0;return o=!(0|Se(e|=0,t|=0)),r=!(0|(a=0|pt(e,t,0,n))),o?r?0|(a=0|pt(e,t,1,n+8|0))||0|(a=0|pt(e,t,2,n+16|0))||0|(a=0|pt(e,t,3,n+24|0))||(a=0|pt(e,t,4,n+32|0))?0|(o=a):0|pt(e,t,5,n+40|0):0|(o=a):r?0|(a=0|pt(e,t,1,n+8|0))||0|(a=0|pt(e,t,2,n+16|0))||0|(a=0|pt(e,t,3,n+24|0))||0|(a=0|pt(e,t,4,n+32|0))?0|(o=a):(i[(o=n+40|0)>>2]=0,i[o+4>>2]=0,0|(o=0)):0|(o=a)},_cellsToDirectedEdge:function(e,t,n,r,a){return a|=0,7==(0|(n=0|V(e|=0,t|=0,n|=0,r|=0)))?0|(a=11):(r=0|jt(0|n,0,56),t=-2130706433&t|S()|268435456,i[a>>2]=e|r,i[a+4>>2]=t,0|(a=0))},_cellsToLinkedMultiPolygon:function(e,t,n){n|=0;var r,a,o=0,s=0,A=0,l=0,c=0;if(a=N,N=N+16|0,0|(e=0|ie(e|=0,t|=0,((0|t)<0)<<31>>31,A=a)))return N=a,0|(A=e);if(r=0|function(e,t){e|=0,t|=0;var n=0,r=0,a=0,o=0,s=0,A=0,l=0,c=0,u=0,f=0,d=0,h=0,p=0,m=0,g=0,b=0;if(i[t>>2]=0,g=t+4|0,i[g>>2]=0,b=t+8|0,i[b>>2]=0,m=0|i[e>>2],(0|m)<=0)return 0|(t=0);p=e+4|0,e=t,h=0;e:for(;;){if(h){if(!(n=0|Ct(1,12))){n=5;break}i[e+8>>2]=n,e=n}if(l=0|i[p>>2],!(c=0|Ct(1,12))){e=13,n=37;break}if(r=0|i[(d=e+4|0)>>2],i[(0|r?r+8:e)>>2]=c,i[d>>2]=c,(0|(r=0|i[l+(h<<4)>>2]))<3){e=1,n=37;break}a=l+(h<<4)+4|0,o=c+4|0,n=0,s=0;do{if(A=s,!(s=0|Mt(24))){e=13,n=37;break e}Kt(0|s,(0|i[a>>2])+(n<<4)|0,16),i[s+16>>2]=0,A?i[A+16>>2]=s:i[c>>2]=s,i[o>>2]=s,n=n+1|0}while((0|n)<(0|r));if((0|(f=0|i[l+(h<<4)+8>>2]))>0){u=l+(h<<4)+12|0,l=0;do{if(r=0|i[u>>2],n=c,!(c=0|Ct(1,12))){e=13,n=37;break e}if(i[n+8>>2]=c,i[d>>2]=c,(0|(A=0|i[r+(l<<3)>>2]))<3){e=1,n=37;break e}r=r+(l<<3)+4|0,a=c+4|0,n=0,o=0;do{if(s=o,!(o=0|Mt(24))){e=13,n=37;break e}Kt(0|o,(0|i[r>>2])+(n<<4)|0,16),i[o+16>>2]=0,s?i[s+16>>2]=o:i[c>>2]=o,i[a>>2]=o,n=n+1|0}while((0|n)<(0|A));l=l+1|0}while((0|l)<(0|f))}if((0|(h=h+1|0))>=(0|m)){e=0,n=50;break}}if(5==(0|n)){if(!t)return 0|(t=13);for(r=1,a=t;;){if(0|(e=0|i[a>>2]))do{if(0|(n=0|i[e>>2]))do{m=n,n=0|i[n+16>>2],Et(m)}while(0|n);m=e,e=0|i[e+8>>2],Et(m)}while(0|e);if(e=a,a=0|i[a+8>>2],r?(i[t>>2]=0,i[g>>2]=0,i[b>>2]=0):Et(e),!a){e=13;break}r=0}return 0|e}if(37==(0|n)){if(!t)return 0|(t=e);for(a=1,o=t;;){if(0|(n=0|i[o>>2]))do{if(0|(r=0|i[n>>2]))do{m=r,r=0|i[r+16>>2],Et(m)}while(0|r);m=n,n=0|i[n+8>>2],Et(m)}while(0|n);if(n=o,o=0|i[o+8>>2],a?(i[t>>2]=0,i[g>>2]=0,i[b>>2]=0):Et(n),!o)break;a=0}return 0|e}if(50==(0|n))return 0|e;return 0}(A,n),n=A+4|0,(0|i[A>>2])>0){t=0;do{if(s=0|i[n>>2],Et(0|i[(o=s+(t<<4)+4|0)>>2]),i[o>>2]=0,i[s+(t<<4)>>2]=0,o=s+(t<<4)+8|0,s=s+(t<<4)+12|0,(0|i[o>>2])>0){e=0;do{l=0|i[s>>2],Et(0|i[(c=l+(e<<3)+4|0)>>2]),i[c>>2]=0,i[l+(e<<3)>>2]=0,e=e+1|0}while((0|e)<(0|i[o>>2]))}Et(0|i[s>>2]),i[s>>2]=0,i[o>>2]=0,t=t+1|0}while((0|t)<(0|i[A>>2]))}return Et(0|i[n>>2]),i[n>>2]=0,i[A>>2]=0,N=a,0|(c=r)},_childPosToCell:function(e,t,n,r,a,o){e|=0,t|=0,o|=0;var s,A=0,l=0,c=0,u=0,f=0,d=0,h=0,p=0,m=0;if(s=N,N=N+16|0,A=s,(a|=0)>>>0>15)return N=s,0|(o=4);if(l=0|Vt(0|(n|=0),0|(r|=0),52),S(),(0|(l&=15))>(0|a))return N=s,0|(o=12);if(0|Te(n,r,a,A)&&M(27634,27225,1367,27274),!(((0|t)>-1|-1==(0|t)&e>>>0>4294967295)&((0|(u=0|i[(f=A)+4>>2]))>(0|t)|((0|u)==(0|t)?(0|i[f>>2])>>>0>e>>>0:0))))return N=s,0|(o=2);f=a-l|0,a=0|jt(0|a,0,52),c=S()|-15728641&r,i[(u=o)>>2]=a|n,i[u+4>>2]=c,u=0|Vt(0|n,0|r,45),S();e:do{if(0|G(127&u)){if(0|l)for(A=1;;){if(!(!((u=0|jt(7,0,3*(15-A|0)|0))&n|0)&!((0|S())&r)))break e;if(!(A>>>0<l>>>0))break;A=A+1|0}if((0|f)<1)return N=s,0|(o=0);for(u=15^l,r=-1,c=1,A=1;;){l=0|Ze(7,0,l=f-c|0,((0|l)<0)<<31>>31),n=0|S();do{if(A){if(A=0|Bt(0|(A=0|Pt(0|(A=0|Ot(0|l,0|n,5,0)),0|S(),-5,-1)),0|S(),6,0),(0|t)>(0|(a=0|S()))|(0|t)==(0|a)&e>>>0>A>>>0){t=0|Nt(0|(t=0|Pt(0|e,0|t,-1,-1)),0|S(),0|A,0|a),A=0|S(),p=0|i[(d=o)>>2],d=0|i[d+4>>2],h=0|jt(7,0,0|(m=3*(u+r|0)|0)),d&=~S(),m=0|jt(0|(a=0|Pt(0|(r=0|Bt(0|t,0|A,0|l,0|n)),0|(e=0|S()),2,0)),0|S(),0|m),d=0|S()|d,i[(a=o)>>2]=m|p&~h,i[a+4>>2]=d,e=0|Nt(0|t,0|A,0|(e=0|Ot(0|r,0|e,0|l,0|n)),0|S()),A=0,t=0|S();break}h=0|i[(m=o)>>2],m=0|i[m+4>>2],p=0|jt(7,0,3*(u+r|0)|0),m&=~S(),i[(A=o)>>2]=h&~p,i[A+4>>2]=m,A=1;break}a=0|i[(h=o)>>2],h=0|i[h+4>>2],d=0|jt(7,0,0|(r=3*(u+r|0)|0)),h&=~S(),r=0|jt(0|(m=0|Bt(0|e,0|t,0|l,0|n)),0|(A=0|S()),0|r),h=0|S()|h,i[(p=o)>>2]=r|a&~d,i[p+4>>2]=h,e=0|Nt(0|e,0|t,0|(A=0|Ot(0|m,0|A,0|l,0|n)),0|S()),A=0,t=0|S()}while(0);if(!((0|f)>(0|c))){t=0;break}r=~c,c=c+1|0}return N=s,0|t}}while(0);if((0|f)<1)return N=s,0|(m=0);for(a=15^l,A=1;;){if(p=0|Ze(7,0,p=f-A|0,((0|p)<0)<<31>>31),m=0|S(),n=0|i[(c=o)>>2],c=0|i[c+4>>2],r=0|jt(7,0,0|(l=3*(a-A|0)|0)),c&=~S(),l=0|jt(0|(d=0|Bt(0|e,0|t,0|p,0|m)),0|(h=0|S()),0|l),c=0|S()|c,i[(u=o)>>2]=l|n&~r,i[u+4>>2]=c,e=0|Nt(0|e,0|t,0|(m=0|Ot(0|d,0|h,0|p,0|m)),0|S()),t=0|S(),(0|f)<=(0|A)){t=0;break}A=A+1|0}return N=s,0|t},_compactCells:function(e,t,n,r){t|=0;var a,o=0,s=0,A=0,l=0,c=0,u=0,f=0,d=0,h=0,p=0,m=0,g=0,b=0,v=0,y=0,x=0,_=0,w=0,T=0,E=0,C=0,I=0,R=0,P=0,N=0;if(!(0|(n|=0))&!(0|(r|=0)))return 0|(N=0);if(s=0|i[(o=e|=0)>>2],!0&!(15728640&(o=0|i[o+4>>2]))){if(!((0|r)>0|!(0|r)&n>>>0>0))return 0|(N=0);if(i[(N=t)>>2]=s,i[N+4>>2]=o,1==(0|n)&!(0|r))return 0|(N=0);o=1,s=0;do{P=0|i[(R=e+(o<<3)|0)+4>>2],i[(N=t+(o<<3)|0)>>2]=i[R>>2],i[N+4>>2]=P,o=0|Pt(0|o,0|s,1,0),s=0|S()}while((0|s)<(0|r)|(0|s)==(0|r)&o>>>0<n>>>0);return 0|(o=0)}if(!(P=0|Mt(a=n<<3)))return 0|(N=13);if(Qt(0|P,0|e,0|a),!(R=0|Ct(n,8)))return Et(P),0|(N=13);e:for(;;){C=0|Vt(0|(u=0|i[(o=P)>>2]),0|(o=0|i[o+4>>2]),52),S(),I=(C&=15)+-1|0,E=!!(0|C),T=(0|r)>0|!(0|r)&n>>>0>0;t:do{if(E&T){if(y=0|jt(0|I,0,52),x=0|S(),I>>>0>15){if(!(!(0|u)&!(0|o))){N=16;break e}for(s=0,e=0;;){if(s=0|Pt(0|s,0|e,1,0),!((0|(e=0|S()))<(0|r)|(0|e)==(0|r)&s>>>0<n>>>0))break t;if(!(!(0|(w=0|i[(A=P+(s<<3)|0)>>2]))&!(0|(A=0|i[A+4>>2])))){o=A,N=16;break e}}}for(l=u,e=o,s=0,A=0;;){if(!(!(0|l)&!(0|e))){if(!(!0&!(117440512&e))){N=21;break e}if(f=0|Vt(0|l,0|e,52),S(),(0|(f&=15))<(0|I)){o=12,N=27;break e}if((0|f)!=(0|I)&&(l|=y,e=-15728641&e|x,f>>>0>=C>>>0)){c=I;do{w=0|jt(7,0,3*(14-c|0)|0),c=c+1|0,l|=w,e=0|S()|e}while(c>>>0<f>>>0)}if(h=0|Dt(0|l,0|e,0|n,0|r),p=0|S(),!(!(0|(d=0|i[(f=c=R+(h<<3)|0)>>2]))&!(0|(f=0|i[f+4>>2])))){b=0,v=0;do{if((0|b)>(0|r)|(0|b)==(0|r)&v>>>0>n>>>0){N=31;break e}if((0|d)==(0|l)&(-117440513&f)==(0|e)){m=0|Vt(0|d,0|f,56),S(),g=(m&=7)+1|0,w=0|Vt(0|d,0|f,45),S();n:do{if(0|G(127&w)){if(d=0|Vt(0|d,0|f,52),S(),!(d&=15)){f=6;break}for(f=1;;){if(!(!((w=0|jt(7,0,3*(15-f|0)|0))&l|0)&!((0|S())&e))){f=7;break n}if(!(f>>>0<d>>>0)){f=6;break}f=f+1|0}}else f=7}while(0);if((m+2|0)>>>0>f>>>0){N=41;break e}w=0|jt(0|g,0,56),e=S()|-117440513&e,i[(_=c)>>2]=0,i[_+4>>2]=0,l|=w}else h=0|Ft(0|(h=0|Pt(0|h,0|p,1,0)),0|S(),0|n,0|r),p=0|S();v=0|Pt(0|v,0|b,1,0),b=0|S(),d=0|i[(f=c=R+(h<<3)|0)>>2],f=0|i[f+4>>2]}while(!(!(0|d)&!(0|f)))}i[(w=c)>>2]=l,i[w+4>>2]=e}if(s=0|Pt(0|s,0|A,1,0),!((0|(A=0|S()))<(0|r)|(0|A)==(0|r)&s>>>0<n>>>0))break t;l=0|i[(e=P+(s<<3)|0)>>2],e=0|i[e+4>>2]}}}while(0);if(w=0|Pt(0|n,0|r,5,0),(_=0|S())>>>0<0|!(0|_)&w>>>0<11){N=85;break}if(w=0|Bt(0|n,0|r,6,0),S(),!(w=0|Ct(w,8))){N=48;break}do{if(T){for(g=0,e=0,m=0,b=0;;){if(!(0|(s=0|i[(A=f=R+(g<<3)|0)>>2]))&!(0|(A=0|i[A+4>>2])))_=m;else{d=0|Vt(0|s,0|A,56),S(),l=(d&=7)+1|0,h=-117440513&A,_=0|Vt(0|s,0|A,45),S();t:do{if(0|G(127&_)){if(p=0|Vt(0|s,0|A,52),S(),0|(p&=15))for(c=1;;){if(!(!(s&(_=0|jt(7,0,3*(15-c|0)|0))|0)&!(h&(0|S()))))break t;if(!(c>>>0<p>>>0))break;c=c+1|0}s|=A=0|jt(0|l,0,56),A=0|S()|h,i[(l=f)>>2]=s,i[l+4>>2]=A,l=d+2|0}}while(0);7==(0|l)?(i[(_=w+(e<<3)|0)>>2]=s,i[_+4>>2]=-117440513&A,e=0|Pt(0|e,0|m,1,0),_=0|S()):_=m}if(g=0|Pt(0|g,0|b,1,0),!((0|(b=0|S()))<(0|r)|(0|b)==(0|r)&g>>>0<n>>>0))break;m=_}if(T){if(v=I>>>0>15,y=0|jt(0|I,0,52),x=0|S(),!E){for(s=0,c=0,l=0,A=0;!(0|u)&!(0|o)||(i[(I=t+(s<<3)|0)>>2]=u,i[I+4>>2]=o,s=0|Pt(0|s,0|c,1,0),c=0|S()),l=0|Pt(0|l,0|A,1,0),(0|(A=0|S()))<(0|r)|(0|A)==(0|r)&l>>>0<n>>>0;)u=0|i[(o=P+(l<<3)|0)>>2],o=0|i[o+4>>2];o=_;break}for(s=0,c=0,A=0,l=0;;){do{if(!(!(0|u)&!(0|o))){if(p=0|Vt(0|u,0|o,52),S(),v|(0|(p&=15))<(0|I)){N=80;break e}if((0|p)!=(0|I)){if(f=u|y,d=-15728641&o|x,p>>>0>=C>>>0){h=I;do{E=0|jt(7,0,3*(14-h|0)|0),h=h+1|0,f|=E,d=0|S()|d}while(h>>>0<p>>>0)}}else f=u,d=o;m=0|Dt(0|f,0|d,0|n,0|r),h=0,p=0,b=0|S();do{if((0|h)>(0|r)|(0|h)==(0|r)&p>>>0>n>>>0){N=81;break e}if((-117440513&(g=0|i[(E=R+(m<<3)|0)+4>>2]))==(0|d)&&(0|i[E>>2])==(0|f)){N=65;break}m=0|Ft(0|(E=0|Pt(0|m,0|b,1,0)),0|S(),0|n,0|r),b=0|S(),p=0|Pt(0|p,0|h,1,0),h=0|S(),E=R+(m<<3)|0}while((0|i[E>>2])!=(0|f)||(0|i[E+4>>2])!=(0|d));if(65==(0|N)&&(N=0,!0&100663296==(117440512&g)))break;i[(E=t+(s<<3)|0)>>2]=u,i[E+4>>2]=o,s=0|Pt(0|s,0|c,1,0),c=0|S()}}while(0);if(A=0|Pt(0|A,0|l,1,0),!((0|(l=0|S()))<(0|r)|(0|l)==(0|r)&A>>>0<n>>>0))break;u=0|i[(o=P+(A<<3)|0)>>2],o=0|i[o+4>>2]}o=_}else s=0,o=_}else s=0,e=0,o=0}while(0);if(Wt(0|R,0,0|a),Qt(0|P,0|w,e<<3),Et(w),!(0|e)&!(0|o)){N=89;break}t=t+(s<<3)|0,r=o,n=e}if(16==(0|N))!0&!(117440512&o)?(o=4,N=27):N=21;else if(31==(0|N))M(27634,27225,620,27235);else{if(41==(0|N))return Et(P),Et(R),0|(N=10);if(48==(0|N))return Et(P),Et(R),0|(N=13);80==(0|N)?M(27634,27225,711,27235):81==(0|N)?M(27634,27225,723,27235):85==(0|N)&&(Qt(0|t,0|P,n<<3),N=89)}return 21==(0|N)?(Et(P),Et(R),0|(N=5)):27==(0|N)?(Et(P),Et(R),0|(N=o)):89==(0|N)?(Et(P),Et(R),0|(N=0)):0},_constructCell:function(e,t,n,a){n|=0,a|=0;var o=0,s=0,A=0,l=0,c=0,u=0;if((e|=0)>>>0>15)return 0|(a=4);if((t|=0)>>>0>121)return 0|(a=17);A=0|jt(0|e,0,52),o=0|S(),l=0|jt(0|t,0,45),o=0|o|S()|134225919;e:do{if((0|e)>=1){for(l=1,A=!!(0|r[20496+t|0]),s=-1;;){if((t=0|i[n+(l+-1<<2)>>2])>>>0>6){o=18,t=10;break}if(!(!(0|t)|1^A)){if(1==(0|t)){o=19,t=10;break}A=0}if(c=0|jt(7,0,0|(u=3*(15-l|0)|0)),o&=~S(),s=(t=0|jt(0|t,((0|t)<0)<<31>>31,0|u))|s&~c,o=0|S()|o,!((0|l)<(0|e)))break e;l=l+1|0}if(10==(0|t))return 0|o}else s=-1}while(0);return i[(u=a)>>2]=s,i[u+4>>2]=o,0|(u=0)},_destroyLinkedMultiPolygon:function(e){var t,n,r=0,a=0,o=0,s=0,A=0;if(e|=0)for(t=e+4|0,n=e+8|0,o=1,s=e;;){if(0|(r=0|i[s>>2]))do{if(0|(a=0|i[r>>2]))do{A=a,a=0|i[a+16>>2],Et(A)}while(0|a);A=r,r=0|i[r+8>>2],Et(A)}while(0|r);if(r=s,s=0|i[s+8>>2],o?(i[e>>2]=0,i[t>>2]=0,i[n>>2]=0):Et(r),!s)break;o=0}},_directedEdgeToBoundary:Ae,_directedEdgeToCells:function(e,t,n){e|=0;var r,a,o,s=0;return r=N,N=N+16|0,s=r,!0&268435456==(2013265920&(t|=0))?(a=-2130706433&t|134217728,i[(o=n|=0)>>2]=e,i[o+4>>2]=a,i[s>>2]=0,t=0|Vt(0|e,0|t,56),S(),s=0|F(e,a,7&t,s,n+8|0),N=r,0|s):(N=r,0|(s=6))},_edgeLengthKm:function(e,t,n){n|=0;var r,o=0,s=0,A=0,l=0,d=0,h=0,p=0;if(r=N,N=N+176|0,0|(e=0|Ae(e|=0,t|=0,l=r)))return l=e,A=+a[n>>3],A*=6371.007180918475,a[n>>3]=A,N=r,0|l;if(a[n>>3]=0,(0|(e=0|i[l>>2]))<=1)return l=0,A=0,A*=6371.007180918475,a[n>>3]=A,N=r,0|l;t=e+-1|0,e=0,o=+a[l+8>>3],s=+a[l+16>>3],A=0;do{h=o,o=+a[l+8+((e=e+1|0)<<4)>>3],p=+f(.5*(o-h)),d=s,s=+a[l+8+(e<<4)+8>>3],d=p*p+(d=+f(.5*(s-d)))*(+u(+h)*+u(+o)*d),A+=2*+g(+ +c(+d),+ +c(+(1-d)))}while((0|e)!=(0|t));return a[n>>3]=A,l=0,p=A,p*=6371.007180918475,a[n>>3]=p,N=r,0|l},_edgeLengthM:function(e,t,n){n|=0;var r,o=0,s=0,A=0,l=0,d=0,h=0,p=0;if(r=N,N=N+176|0,0|(e=0|Ae(e|=0,t|=0,l=r)))return l=e,A=+a[n>>3],A*=6371.007180918475,A*=1e3,a[n>>3]=A,N=r,0|l;if(a[n>>3]=0,(0|(e=0|i[l>>2]))<=1)return l=0,A=0,A*=6371.007180918475,A*=1e3,a[n>>3]=A,N=r,0|l;t=e+-1|0,e=0,o=+a[l+8>>3],s=+a[l+16>>3],A=0;do{h=o,o=+a[l+8+((e=e+1|0)<<4)>>3],p=+f(.5*(o-h)),d=s,s=+a[l+8+(e<<4)+8>>3],d=p*p+(d=+f(.5*(s-d)))*(+u(+h)*+u(+o)*d),A+=2*+g(+ +c(+d),+ +c(+(1-d)))}while((0|e)!=(0|t));return a[n>>3]=A,l=0,p=A,p*=6371.007180918475,p*=1e3,a[n>>3]=p,N=r,0|l},_edgeLengthRads:function(e,t,n){n|=0;var r,o=0,s=0,A=0,l=0,d=0,h=0,p=0;if(r=N,N=N+176|0,0|(e=0|Ae(e|=0,t|=0,l=r)))return N=r,0|(l=e);if(a[n>>3]=0,(0|(e=0|i[l>>2]))<=1)return N=r,0|(l=0);t=e+-1|0,e=0,o=+a[l+8>>3],s=+a[l+16>>3],A=0;do{h=o,o=+a[l+8+((e=e+1|0)<<4)>>3],p=+f(.5*(o-h)),d=s,s=+a[l+8+(e<<4)+8>>3],d=p*p+(d=+f(.5*(s-d)))*(+u(+o)*+u(+h)*d),A+=2*+g(+ +c(+d),+ +c(+(1-d)))}while((0|e)<(0|t));return a[n>>3]=A,N=r,0|(l=0)},_emscripten_replace_memory:function(e){return r=new Int8Array(e),new Uint8Array(e),i=new Int32Array(e),new Float32Array(e),a=new Float64Array(e),n=e,!0},_free:Et,_getBaseCellNumber:ye,_getDirectedEdgeDestination:function(e,t,n){e|=0,t|=0,n|=0;var r,a,o=0;return r=N,N=N+16|0,i[(o=r)>>2]=0,!0&268435456==(2013265920&t)?(a=0|Vt(0|e,0|t,56),S(),o=0|F(e,-2130706433&t|134217728,7&a,o,n),N=r,0|o):(N=r,0|(o=6))},_getDirectedEdgeOrigin:function(e,t,n){return e|=0,n|=0,!0&268435456==(2013265920&(t|=0))?(i[n>>2]=e,i[n+4>>2]=-2130706433&t|134217728,0|(n=0)):0|(n=6)},_getHexagonAreaAvgKm2:Ke,_getHexagonAreaAvgM2:function(e,t){return t|=0,(e|=0)>>>0>15?0|(t=4):(a[t>>3]=+a[20752+(e<<3)>>3],0|(t=0))},_getHexagonEdgeLengthAvgKm:function(e,t){return t|=0,(e|=0)>>>0>15?0|(t=4):(a[t>>3]=+a[20880+(e<<3)>>3],0|(t=0))},_getHexagonEdgeLengthAvgM:function(e,t){return t|=0,(e|=0)>>>0>15?0|(t=4):(a[t>>3]=+a[21008+(e<<3)>>3],0|(t=0))},_getIcosahedronFaces:function e(t,n,r){r|=0;var a,o=0,s=0,A=0,l=0,c=0,u=0,f=0,d=0;a=N,N=N+128|0,f=a+112|0,A=a+96|0,d=a,s=0|Vt(0|(t|=0),0|(n|=0),52),S(),c=15&s,i[f>>2]=c,l=0|Vt(0|t,0|n,45),S(),l&=127;e:do{if(0|G(l)){if(0|c)for(o=1;;){if(!(!((u=0|jt(7,0,3*(15-o|0)|0))&t|0)&!((0|S())&n))){s=0;break e}if(!(o>>>0<c>>>0))break;o=o+1|0}if(!(1&s))return u=0|jt(c+1|0,0,52),d=S()|-15728641&n,d=0|e((u|t)&~(f=0|jt(7,0,3*(14-c|0)|0)),d&~S(),r),N=a,0|d;s=1}else s=0}while(0);if(!(o=0|Fe(t,n,A))){s?(he(A,f,d),u=5):(be(A,f,d),u=6);e:do{if(0|G(l))if(c)for(o=1;;){if(!(!((l=0|jt(7,0,3*(15-o|0)|0))&t|0)&!((0|S())&n))){t=2;break e}if(!(o>>>0<c>>>0)){t=5;break}o=o+1|0}else t=5;else t=2}while(0);Wt(0|r,-1,t<<2);e:do{if(s)for(A=0;;){if(me(l=d+(A<<4)|0,0|i[f>>2]),l=0|i[l>>2],-1==(0|(c=0|i[r>>2]))|(0|c)==(0|l))o=r;else{s=0;do{if((s=s+1|0)>>>0>=t>>>0){o=1;break e}c=0|i[(o=r+(s<<2)|0)>>2]}while(!(-1==(0|c)|(0|c)==(0|l)))}if(i[o>>2]=l,(A=A+1|0)>>>0>=u>>>0){o=0;break}}else for(A=0;;){if(pe(l=d+(A<<4)|0,0|i[f>>2],0,1),l=0|i[l>>2],-1==(0|(c=0|i[r>>2]))|(0|c)==(0|l))o=r;else{s=0;do{if((s=s+1|0)>>>0>=t>>>0){o=1;break e}c=0|i[(o=r+(s<<2)|0)>>2]}while(!(-1==(0|c)|(0|c)==(0|l)))}if(i[o>>2]=l,(A=A+1|0)>>>0>=u>>>0){o=0;break}}}while(0)}return N=a,0|(d=o)},_getIndexDigit:function(e,t,n,r){return r|=0,((n|=0)+-1|0)>>>0>14?0|(r=4):(n=0|Vt(0|(e|=0),0|(t|=0),3*(15-n|0)|0),S(),i[r>>2]=7&n,0|(r=0))},_getNumCells:We,_getPentagons:Ve,_getRes0Cells:function(e){e|=0;var t=0,n=0,r=0;t=0;do{jt(0|t,0,45),r=134225919|S(),i[(n=e+(t<<3)|0)>>2]=-1,i[n+4>>2]=r,t=t+1|0}while(122!=(0|t));return 0},_getResolution:ve,_greatCircleDistanceKm:Qe,_greatCircleDistanceM:function(e,t){e|=0;var n,r,i,o=0;return r=+a[(t|=0)>>3],n=+a[e>>3],o=(i=+f(.5*(r-n)))*i+(o=+f(.5*(+a[t+8>>3]-+a[e+8>>3])))*(+u(+r)*+u(+n)*o),2*+g(+ +c(+o),+ +c(+(1-o)))*6371.007180918475*1e3},_greatCircleDistanceRads:function(e,t){e|=0;var n,r,i,o=0;return r=+a[(t|=0)>>3],n=+a[e>>3],o=(i=+f(.5*(r-n)))*i+(o=+f(.5*(+a[t+8>>3]-+a[e+8>>3])))*(+u(+r)*+u(+n)*o),2*+g(+ +c(+o),+ +c(+(1-o)))},_gridDisk:k,_gridDiskDistances:L,_gridDistance:Ye,_gridPathCells:function(e,t,n,r,a){a|=0;var o,s,A=0,l=0;return s=N,N=N+16|0,0|(l=0|Ye(e|=0,t|=0,n|=0,r|=0,A=s))?(N=s,0|(a=l)):!(0|(A=0|i[(l=A)>>2]))&!(0|(l=0|i[l+4>>2]))?(i[a>>2]=e,i[a+4>>2]=t,N=s,0|(a=0)):(o=0|Xe(e,t,n,r,A,l,a,0,0,1,0))?(a=!(0|Xe(n,r,e,t,A,l,a,A,l,-1,-1)),N=s,0|(a=a?0:o)):(N=s,0|(a=0))},_gridPathCellsSize:function(e,t,n,r,a){a|=0;var o,s=0;return o=N,N=N+16|0,0|(e=0|Ye(e|=0,t|=0,n|=0,r|=0,s=o))?(N=o,0|(s=e)):(n=0|Pt(0|i[(n=s)>>2],0|i[n+4>>2],1,0),r=0|S(),i[(s=a)>>2]=n,i[s+4>>2]=r,N=o,0|(s=0))},_gridRing:function(e,t,n,r){return 0|D(e|=0,t|=0,n|=0,r|=0)?(Wt(0|r,0,48*n|0),0|(r=0|U(e,t,n,r))):0|(r=0)},_gridRingUnsafe:D,_i64Add:Pt,_i64Subtract:Nt,_isPentagon:Se,_isResClassIII:function(e,t){return t=0|Vt(0|(e|=0),0|(t|=0),52),S(),1&t},_isValidCell:xe,_isValidDirectedEdge:oe,_isValidIndex:function(e,t){e|=0;var n=0,i=0,a=0,o=0;if(!0&134217728==(-16777216&(t|=0))&&(i=0|Vt(0|e,0|t,52),S(),i&=15,n=0|Vt(0|e,0|t,45),S(),(n&=127)>>>0<=121)&&!(613566756&(o=0|jt(0|(a=0|Vt(0|e,0|t,0|(o=3*(15^i)|0))),0|S(),0|o))&(0|Nt(-1227133514,-1171,0|o,0|(a=0|S()))))&!(4681&a&S())&&15==(0|i)|!(0|(o=0|Vt(0|(0|jt(0|~e,0|~t,0|(o=19+(3*i|0)|0))),0|S(),0|o)))&!(0|S())){if(!(0|r[20496+n|0]))return 0|(o=1);if(!(0|e)&!(0|(n=8191&t)))return 0|(o=1);if(o=0|zt(0|e,0|n,0),S(),(63-o|0)%3|0)return 0|(o=1)}return 0|oe(e,t)?0|(o=1):0|(o=1&!!(0|mt(e,t)))},_isValidVertex:mt,_latLngToCell:Be,_llvm_ctlz_i64:zt,_llvm_maxnum_f64:Gt,_llvm_minnum_f64:Ht,_llvm_round_f64:qt,_localIjToCell:function(e,t,n,r,a){e|=0,t|=0,a|=0;var o,s,A,l=0,c=0,u=0,f=0;return A=N,N=N+16|0,f=A,0|(r|=0)?(N=A,0|(f=15)):(u=0|i[(n|=0)>>2],c=0|i[n+4>>2],i[f>>2]=u,i[(o=f+4|0)>>2]=c,i[(s=f+8|0)>>2]=0,r=(n=(0|c)<(0|u))?u:c,(0|(n=n?c:u))<0&&(-2147483648==(0|n)||((0|r)>0?(2147483647-r|0)<(0|n):(-2147483648-r|0)>(0|n))||((0|r)>-1?(-2147483648|r)>=(0|n):(-2147483648^r)<(0|n)))?r=1:l=5,5==(0|l)&&(r=c-u|0,l=0-u|0,(0|u)<0?(i[o>>2]=r,i[s>>2]=l,i[f>>2]=0,u=0):(r=c,l=0),c=u-r|0,n=l-r|0,(0|r)<0?(i[f>>2]=c,i[s>>2]=n,i[o>>2]=0,u=c,r=0):n=l,c=u-n|0,l=r-n|0,(0|n)<0?(i[f>>2]=c,i[o>>2]=l,i[s>>2]=0,n=0):(l=r,c=u),(0|(r=(0|n)<(0|(r=(0|l)<(0|c)?l:c))?n:r))>0&&(i[f>>2]=c-r,i[o>>2]=l-r,i[s>>2]=n-r),r=0|Je(e,t,f,a)),N=A,0|(f=r))},_malloc:Mt,_maxFaceCount:function(e,t,n){n|=0;var r=0,a=0;if(a=0|Vt(0|(e|=0),0|(t|=0),45),S(),!(0|G(127&a)))return a=2,i[n>>2]=a,0;if(a=0|Vt(0|e,0|t,52),S(),!(a&=15))return a=5,i[n>>2]=a,0;for(r=1;;){if(!(!((0|jt(7,0,3*(15-r|0)|0))&e|0)&!((0|S())&t))){r=2,e=6;break}if(!(r>>>0<a>>>0)){r=5,e=6;break}r=r+1|0}return 6==(0|e)?(i[n>>2]=r,0):0},_maxGridDiskSize:function(e,t){t|=0;var n=0,r=0,a=0;return(0|(e|=0))<0?0|(t=2):(0|e)>13780509?0|(t=0|We(15,t)):(a=0|Ot(0|e,0|(n=((0|e)<0)<<31>>31),3,0),r=0|S(),n=0|Pt(0|e,0|n,1,0),n=0|Pt(0|(n=0|Ot(0|a,0|r,0|n,0|S())),0|S(),1,0),e=0|S(),i[t>>2]=n,i[t+4>>2]=e,0|(t=0))},_maxPolygonToCellsSize:function(e,t,n,r){e|=0,t|=0,r|=0;var a,o=0,s=0,A=0,l=0,c=0;if(a=N,N=N+48|0,o=a+16|0,s=a+8|0,A=a,0|(n=0|ot(n|=0)))return N=a,0|(A=n);if(l=0|i[(c=e)+4>>2],i[(n=s)>>2]=i[c>>2],i[n+4>>2]=l,at(s,o),!(n=0|ne(o,t,A))){if(t=0|i[s>>2],(0|(s=0|i[e+8>>2]))>0){o=0|i[e+12>>2],n=0;do{t=(0|i[o+(n<<3)>>2])+t|0,n=n+1|0}while((0|n)<(0|s))}o=0|i[(n=A)>>2],(0|(n=0|i[n+4>>2]))<(0|(s=((0|t)<0)<<31>>31))|(0|n)==(0|s)&o>>>0<t>>>0?(i[(n=A)>>2]=t,i[n+4>>2]=s,n=s):t=o,l=0|Pt(0|t,0|n,12,0),c=0|S(),i[(n=A)>>2]=l,i[n+4>>2]=c,i[(n=r)>>2]=l,i[n+4>>2]=c,n=0}return N=a,0|(c=n)},_maxPolygonToCellsSizeExperimental:function(e,t,n,o){t|=0,n|=0,o|=0;var s,A,c=0,f=0,d=0,h=0,p=0,m=0,g=0,b=0;if(A=N,N=N+48|0,p=A+32|0,h=A+40|0,s=A,!(0|i[(e|=0)>>2]))return i[(m=o)>>2]=0,i[m+4>>2]=0,N=A,0|(m=0);_e(p,0,0,0),c=0|i[(d=p)>>2],d=0|i[d+4>>2];do{if(t>>>0>15)i[(m=s)>>2]=0,i[m+4>>2]=0,i[s+8>>2]=4,i[s+12>>2]=-1,n=s+29|0,i[(m=s+16|0)>>2]=0,i[m+4>>2]=0,i[m+8>>2]=0,r[m+12|0]=0,r[n|0]=0|r[h|0],r[n+1|0]=0|r[h+1|0],r[n+2|0]=0|r[h+2|0],n=4,m=9;else{if(0|(n=0|ot(n))){i[(p=s)>>2]=0,i[p+4>>2]=0,i[s+8>>2]=n,i[s+12>>2]=-1,m=s+29|0,i[(p=s+16|0)>>2]=0,i[p+4>>2]=0,i[p+8>>2]=0,r[p+12|0]=0,r[m|0]=0|r[h|0],r[m+1|0]=0|r[h+1|0],r[m+2|0]=0|r[h+2|0],m=9;break}if(!(n=0|Ct(1+(0|i[e+8>>2])|0,32))){i[(m=s)>>2]=0,i[m+4>>2]=0,i[s+8>>2]=13,i[s+12>>2]=-1,n=s+29|0,i[(m=s+16|0)>>2]=0,i[m+4>>2]=0,i[m+8>>2]=0,r[m+12|0]=0,r[n|0]=0|r[h|0],r[n+1|0]=0|r[h+1|0],r[n+2|0]=0|r[h+2|0],n=13,m=9;break}st(e,n),i[(b=s)>>2]=c,i[b+4>>2]=d,i[(d=s+8|0)>>2]=0,i[s+12>>2]=t,i[s+20>>2]=e,i[s+24>>2]=n,r[s+28|0]=0,r[(c=s+29|0)|0]=0|r[h|0],r[c+1|0]=0|r[h+1|0],r[c+2|0]=0|r[h+2|0],i[s+16>>2]=3,g=+Y(n),g*=+J(n),f=+l(+ +a[n>>3]),f=g/+u(+ +Ht(+f,+ +l(+ +a[n+8>>3])))*6371.007180918475*6371.007180918475,n=0|i[(c=s+12|0)>>2];e:do{if((0|n)>0)do{if(Ke(n+-1|0,p),!(f/+a[p>>3]>10))break e;n=(b=0|i[c>>2])+-1|0,i[c>>2]=n}while((0|b)>1)}while(0);if(nt(s),i[(c=o)>>2]=0,i[c+4>>2]=0,!(!(0|(n=0|i[(c=s)>>2]))&!(0|(c=0|i[c+4>>2]))))do{Te(n,c,t,p),h=p,h=0|Pt(0|i[(e=o)>>2],0|i[e+4>>2],0|i[h>>2],0|i[h+4>>2]),e=0|S(),i[(b=o)>>2]=h,i[b+4>>2]=e,nt(s),n=0|i[(b=s)>>2],c=0|i[b+4>>2]}while(!(!(0|n)&!(0|c)));n=0|i[d>>2]}}while(0);return N=A,0|(b=n)},_memcpy:Qt,_memmove:Kt,_memset:Wt,_originToDirectedEdges:se,_pentagonCount:function(){return 12},_polygonToCells:function(e,t,n,r){e|=0,t|=0,r|=0;var a,o,s,A,l=0,c=0,u=0,f=0,d=0,h=0,p=0,m=0,g=0,b=0,v=0,y=0,x=0,_=0,w=0,T=0,M=0,E=0,C=0,I=0,R=0,P=0,k=0,L=0,F=0,D=0,U=0;if(A=N,N=N+112|0,a=A+80|0,d=A+72|0,o=A,s=A+56|0,0|(l=0|ot(n|=0)))return N=A,0|(U=l);if(!(U=0|Mt(32+(i[(h=e+8|0)>>2]<<5)|0)))return N=A,0|(U=13);if(st(e,U),!(l=0|ot(n))){if(D=0|i[(F=e)+4>>2],i[(l=d)>>2]=i[F>>2],i[l+4>>2]=D,at(d,a),l=0|ne(a,t,o))F=0,D=0;else{if(l=0|i[d>>2],(0|(c=0|i[h>>2]))>0){u=0|i[e+12>>2],n=0;do{l=(0|i[u+(n<<3)>>2])+l|0,n=n+1|0}while((0|n)!=(0|c));n=l}else n=l;c=0|i[(l=o)>>2],(0|(l=0|i[l+4>>2]))<(0|(u=((0|n)<0)<<31>>31))|(0|l)==(0|u)&c>>>0<n>>>0?(i[(l=o)>>2]=n,i[l+4>>2]=u,l=u):n=c,F=0|Pt(0|n,0|l,12,0),D=0|S(),i[(l=o)>>2]=F,i[l+4>>2]=D,l=0}if(!l){if(!(n=0|Ct(F,8)))return Et(U),N=A,0|(U=13);if(!(f=0|Ct(F,8)))return Et(U),Et(n),N=A,0|(U=13);i[(k=a)>>2]=0,i[k+4>>2]=0,L=0|i[(k=e)+4>>2],i[(l=d)>>2]=i[k>>2],i[l+4>>2]=L,l=0|j(d,F,D,t,a,n,f);e:do{if(l)Et(n),Et(f),Et(U);else{t:do{if((0|i[h>>2])>0){for(u=e+12|0,c=0;l=0|j((0|i[u>>2])+(c<<3)|0,F,D,t,a,n,f),c=c+1|0,!(0|l);)if((0|c)>=(0|i[h>>2]))break t;Et(n),Et(f),Et(U);break e}}while(0);(0|D)>0|!(0|D)&F>>>0>0&&Wt(0|f,0,F<<3),k=0|i[(L=a)+4>>2];t:do{if((0|k)>0|!(0|k)&(0|i[L>>2])>>>0>0){I=n,R=f,P=n,k=f,L=n,l=n,M=n,E=f,C=f,n=f;n:for(;;){for(x=0,_=0,w=0,T=0,c=0,u=0;;){d=(f=o)+56|0;do{i[f>>2]=0,f=f+4|0}while((0|f)<(0|d));if(0|B(h=0|i[(t=I+(x<<3)|0)>>2],t=0|i[t+4>>2],1,o,0)){d=(f=o)+56|0;do{i[f>>2]=0,f=f+4|0}while((0|f)<(0|d));0|(f=0|Ct(7,4))&&(O(h,t,1,o,f,7,0,0),Et(f))}for(y=0;;){b=0|i[(v=o+(y<<3)|0)>>2],v=0|i[v+4>>2];r:do{if(!(0|b)&!(0|v))f=c,d=u;else{if(p=0|Dt(0|b,0|v,0|F,0|D),h=0|S(),!(!(0|(d=0|i[(t=f=r+(p<<3)|0)>>2]))&!(0|(t=0|i[t+4>>2])))){m=0,g=0;do{if((0|m)>(0|D)|(0|m)==(0|D)&g>>>0>F>>>0)break n;if((0|d)==(0|b)&(0|t)==(0|v)){f=c,d=u;break r}p=0|Ft(0|(f=0|Pt(0|p,0|h,1,0)),0|S(),0|F,0|D),h=0|S(),g=0|Pt(0|g,0|m,1,0),m=0|S(),d=0|i[(t=f=r+(p<<3)|0)>>2],t=0|i[t+4>>2]}while(!(!(0|d)&!(0|t)))}if(!(0|b)&!(0|v)){f=c,d=u;break}De(b,v,s),0|At(e,U,s)&&(g=0|Pt(0|c,0|u,1,0),u=0|S(),i[(m=f)>>2]=b,i[m+4>>2]=v,i[(c=R+(c<<3)|0)>>2]=b,i[c+4>>2]=v,c=g),f=c,d=u}}while(0);if((y=y+1|0)>>>0>=7)break;c=f,u=d}if(x=0|Pt(0|x,0|_,1,0),_=0|S(),w=0|Pt(0|w,0|T,1,0),T=0|S(),c=0|i[(u=a)>>2],!((0|T)<(0|(u=0|i[u+4>>2]))|(0|T)==(0|u)&w>>>0<c>>>0))break;c=f,u=d}if((0|u)>0|!(0|u)&c>>>0>0){c=0,u=0;do{i[(T=I+(c<<3)|0)>>2]=0,i[T+4>>2]=0,c=0|Pt(0|c,0|u,1,0),u=0|S(),w=0|i[(T=a)+4>>2]}while((0|u)<(0|w)|((0|u)==(0|w)?c>>>0<(0|i[T>>2])>>>0:0))}if(i[(T=a)>>2]=f,i[T+4>>2]=d,!((0|d)>0|!(0|d)&f>>>0>0))break t;y=n,x=C,_=L,w=E,T=R,n=M,C=l,E=P,M=y,l=x,L=k,k=_,P=w,R=I,I=T}Et(P),Et(k),Et(U),l=1;break e}l=f}while(0);Et(U),Et(n),Et(l),l=0}}while(0);return N=A,0|(U=l)}}return Et(U),N=A,0|(U=l)},_polygonToCellsExperimental:function(e,t,n,r,a,o){r|=0,a|=0,o|=0;var s,A,l,c=0,u=0,f=0,d=0,h=0,p=0,m=0,g=0;l=N,N=N+160|0,u=l+64|0,h=l+112|0,g=l,tt(d=l+80|0,e|=0,t|=0,n|=0),je(u,0|i[(f=d)>>2],0|i[f+4>>2],t),s=0|i[(f=u)>>2],f=0|i[f+4>>2],c=0|i[d+8>>2],i[(p=h+4|0)>>2]=i[d>>2],i[p+4>>2]=i[d+4>>2],i[p+8>>2]=i[d+8>>2],i[p+12>>2]=i[d+12>>2],i[p+16>>2]=i[d+16>>2],i[p+20>>2]=i[d+20>>2],i[p+24>>2]=i[d+24>>2],i[p+28>>2]=i[d+28>>2],i[(p=g)>>2]=s,i[p+4>>2]=f,i[(p=g+8|0)>>2]=c,t=h,n=(e=g+12|0)+36|0;do{i[e>>2]=i[t>>2],e=e+4|0,t=t+4|0}while((0|e)<(0|n));if(i[(h=g+48|0)>>2]=i[u>>2],i[h+4>>2]=i[u+4>>2],i[h+8>>2]=i[u+8>>2],i[h+12>>2]=i[u+12>>2],!(0|s)&!(0|f))return N=l,0|(g=c);n=g+16|0,A=g+24|0,d=g+28|0,c=0,u=0,t=s,e=f;do{if(!((0|c)<(0|a)|(0|c)==(0|a)&u>>>0<r>>>0)){m=4;break}if(f=u,u=0|Pt(0|u,0|c,1,0),c=0|S(),i[(f=o+(f<<3)|0)>>2]=t,i[f+4>>2]=e,Ge(h),!(0|(t=0|i[(e=h)>>2]))&!(0|(e=0|i[e+4>>2]))){if(nt(n),!(0|(e=0|i[(t=n)>>2]))&!(0|(t=0|i[t+4>>2]))){m=10;break}ze(e,t,0|i[d>>2],h),t=0|i[(e=h)>>2],e=0|i[e+4>>2]}i[(f=g)>>2]=t,i[f+4>>2]=e}while(!(!(0|t)&!(0|e)));return 4==(0|m)?(0|(t=0|i[(e=g+40|0)>>2])&&Et(t),i[(m=g+16|0)>>2]=0,i[m+4>>2]=0,i[A>>2]=0,i[g+36>>2]=0,i[d>>2]=-1,i[g+32>>2]=0,i[e>>2]=0,ze(0,0,0,h),i[g>>2]=0,i[g+4>>2]=0,i[p>>2]=0,N=l,0|(g=14)):(10==(0|m)&&(i[g>>2]=0,i[g+4>>2]=0,i[p>>2]=i[A>>2]),g=0|i[p>>2],N=l,0|g)},_readInt64AsDoubleFromPointer:function(e){return+(+((0|i[(e|=0)>>2])>>>0)+4294967296*+(0|i[e+4>>2]))},_res0CellCount:function(){return 122},_reverseDirectedEdge:le,_round:$t,_sbrk:Jt,_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,r,a,o,s){e|=0,r|=0,a|=0,o|=0;var A,l=0,c=0,u=0,f=0,d=0,h=0,p=0,m=0;if(A=N,N=N+16|0,m=A,!((0|(n|=0))>0|!(0|n)&(t|=0)>>>0>0))return N=A,0|(m=0);if((0|(s|=0))>=16)return N=A,0|(m=12);h=0,p=0,d=0,l=0;e:for(;;){if(f=0|Vt(0|(c=0|i[(u=e+(h<<3)|0)>>2]),0|(u=0|i[u+4>>2]),52),S(),(15&f)>(0|s)){l=12,c=11;break}if(je(m,c,u,s),!(0|(u=0|i[(f=m)>>2]))&!(0|(f=0|i[f+4>>2])))c=d;else{c=d;do{if(!((0|l)<(0|o)|(0|l)==(0|o)&c>>>0<a>>>0)){c=10;break e}i[(d=r+(c<<3)|0)>>2]=u,i[d+4>>2]=f,c=0|Pt(0|c,0|l,1,0),l=0|S(),Ge(m),u=0|i[(d=m)>>2],f=0|i[d+4>>2]}while(!(!(0|u)&!(0|f)))}if(h=0|Pt(0|h,0|p,1,0),!((0|(p=0|S()))<(0|n)|(0|p)==(0|n)&h>>>0<t>>>0)){l=0,c=11;break}d=c}return 10==(0|c)?(N=A,0|(m=14)):11==(0|c)?(N=A,0|l):0},_uncompactCellsSize:function(e,t,n,r,a){e|=0,t|=0,n|=0,r|=0,a|=0;var o,s,A=0,l=0,c=0,u=0,f=0,d=0;s=N,N=N+16|0,o=s;e:do{if((0|n)>0|!(0|n)&t>>>0>0){for(f=0,l=0,A=0,d=0;;){if(!(!(0|(c=0|i[(u=e+(f<<3)|0)>>2]))&!(0|(u=0|i[u+4>>2]))||(u=!(0|Te(c,u,r,o)),l=0|Pt(0|i[(c=o)>>2],0|i[c+4>>2],0|l,0|A),A=0|S(),u))){A=12;break}if(f=0|Pt(0|f,0|d,1,0),!((0|(d=0|S()))<(0|n)|(0|d)==(0|n)&f>>>0<t>>>0))break e}return N=s,0|A}l=0,A=0}while(0);return i[a>>2]=l,i[a+4>>2]=A,N=s,0|(a=0)},_vertexToLatLng:function(e,t,n){n|=0;var r,a,o,s,A=0,l=0;return s=N,N=N+192|0,a=s,o=s+168|0,A=0|Vt(0|(e|=0),0|(t|=0),56),S(),A&=7,0|(r=0|Fe(e,l=-2130706433&t|134217728,o))?(N=s,0|(l=r)):(t=0|Vt(0|e,0|t,52),S(),t&=15,0|Se(e,l)?de(o,t,A,1,a):ge(o,t,A,1,a),l=a+8|0,i[n>>2]=i[l>>2],i[n+4>>2]=i[l+4>>2],i[n+8>>2]=i[l+8>>2],i[n+12>>2]=i[l+12>>2],N=s,0|(l=0))},dynCall_iii:function(e,t,n){return t|=0,n|=0,0|Yt[3&(e|=0)](0|t,0|n)},establishStackSpace:function(e,t){N=e|=0},stackAlloc:function(e){var t;return t=N,N=(N=N+(e|=0)|0)+15&-16,0|t},stackRestore:function(e){N=e|=0},stackSave:function(){return 0|N}}}({Math:Math,Int8Array:Int8Array,Int32Array:Int32Array,Uint8Array:Uint8Array,Float32Array:Float32Array,Float64Array:Float64Array},{a:le,b:function(e){l=e},c:function(){return l},d:function(e,t,n,r){le("Assertion failed: "+x(e)+", at: "+[t?x(t):"unknown filename",n,r?x(r):"unknown function"])},e:function(e){return n.___errno_location&&(g[n.___errno_location()>>2]=e),e},f:K,g:function(e,t,n){p.set(p.subarray(t,t+n),e)},h:function(e){var t=K(),n=16777216,r=2130706432;if(e>r)return!1;for(var i=Math.max(t,16777216);i<e;)i=i<=536870912?_(2*i,n):Math.min(_((3*i+2147483648)/4,n),r);return!!W(i)},i:function(e){le("OOM")},j:H,k:q,l:W,m:Q,n:function(){var e=Q();return n.extraStackTrace&&(e+="\n"+n.extraStackTrace()),q(e)},o:28400,p:28384},d);n.___divdi3=Y.___divdi3,n.___muldi3=Y.___muldi3,n.___remdi3=Y.___remdi3,n.___uremdi3=Y.___uremdi3,n._areNeighborCells=Y._areNeighborCells,n._bitshift64Ashr=Y._bitshift64Ashr,n._bitshift64Lshr=Y._bitshift64Lshr,n._bitshift64Shl=Y._bitshift64Shl,n._calloc=Y._calloc,n._cellAreaKm2=Y._cellAreaKm2,n._cellAreaM2=Y._cellAreaM2,n._cellAreaRads2=Y._cellAreaRads2,n._cellToBoundary=Y._cellToBoundary,n._cellToCenterChild=Y._cellToCenterChild,n._cellToChildPos=Y._cellToChildPos,n._cellToChildren=Y._cellToChildren,n._cellToChildrenSize=Y._cellToChildrenSize,n._cellToLatLng=Y._cellToLatLng,n._cellToLocalIj=Y._cellToLocalIj,n._cellToParent=Y._cellToParent,n._cellToVertex=Y._cellToVertex,n._cellToVertexes=Y._cellToVertexes,n._cellsToDirectedEdge=Y._cellsToDirectedEdge,n._cellsToLinkedMultiPolygon=Y._cellsToLinkedMultiPolygon,n._childPosToCell=Y._childPosToCell,n._compactCells=Y._compactCells,n._constructCell=Y._constructCell,n._destroyLinkedMultiPolygon=Y._destroyLinkedMultiPolygon,n._directedEdgeToBoundary=Y._directedEdgeToBoundary,n._directedEdgeToCells=Y._directedEdgeToCells,n._edgeLengthKm=Y._edgeLengthKm,n._edgeLengthM=Y._edgeLengthM,n._edgeLengthRads=Y._edgeLengthRads;var X=n._emscripten_replace_memory=Y._emscripten_replace_memory;n._free=Y._free,n._getBaseCellNumber=Y._getBaseCellNumber,n._getDirectedEdgeDestination=Y._getDirectedEdgeDestination,n._getDirectedEdgeOrigin=Y._getDirectedEdgeOrigin,n._getHexagonAreaAvgKm2=Y._getHexagonAreaAvgKm2,n._getHexagonAreaAvgM2=Y._getHexagonAreaAvgM2,n._getHexagonEdgeLengthAvgKm=Y._getHexagonEdgeLengthAvgKm,n._getHexagonEdgeLengthAvgM=Y._getHexagonEdgeLengthAvgM,n._getIcosahedronFaces=Y._getIcosahedronFaces,n._getIndexDigit=Y._getIndexDigit,n._getNumCells=Y._getNumCells,n._getPentagons=Y._getPentagons,n._getRes0Cells=Y._getRes0Cells,n._getResolution=Y._getResolution,n._greatCircleDistanceKm=Y._greatCircleDistanceKm,n._greatCircleDistanceM=Y._greatCircleDistanceM,n._greatCircleDistanceRads=Y._greatCircleDistanceRads,n._gridDisk=Y._gridDisk,n._gridDiskDistances=Y._gridDiskDistances,n._gridDistance=Y._gridDistance,n._gridPathCells=Y._gridPathCells,n._gridPathCellsSize=Y._gridPathCellsSize,n._gridRing=Y._gridRing,n._gridRingUnsafe=Y._gridRingUnsafe,n._i64Add=Y._i64Add,n._i64Subtract=Y._i64Subtract,n._isPentagon=Y._isPentagon,n._isResClassIII=Y._isResClassIII,n._isValidCell=Y._isValidCell,n._isValidDirectedEdge=Y._isValidDirectedEdge,n._isValidIndex=Y._isValidIndex,n._isValidVertex=Y._isValidVertex,n._latLngToCell=Y._latLngToCell,n._llvm_ctlz_i64=Y._llvm_ctlz_i64,n._llvm_maxnum_f64=Y._llvm_maxnum_f64,n._llvm_minnum_f64=Y._llvm_minnum_f64,n._llvm_round_f64=Y._llvm_round_f64,n._localIjToCell=Y._localIjToCell,n._malloc=Y._malloc,n._maxFaceCount=Y._maxFaceCount,n._maxGridDiskSize=Y._maxGridDiskSize,n._maxPolygonToCellsSize=Y._maxPolygonToCellsSize,n._maxPolygonToCellsSizeExperimental=Y._maxPolygonToCellsSizeExperimental,n._memcpy=Y._memcpy,n._memmove=Y._memmove,n._memset=Y._memset,n._originToDirectedEdges=Y._originToDirectedEdges,n._pentagonCount=Y._pentagonCount,n._polygonToCells=Y._polygonToCells,n._polygonToCellsExperimental=Y._polygonToCellsExperimental,n._readInt64AsDoubleFromPointer=Y._readInt64AsDoubleFromPointer,n._res0CellCount=Y._res0CellCount,n._reverseDirectedEdge=Y._reverseDirectedEdge,n._round=Y._round,n._sbrk=Y._sbrk,n._sizeOfCellBoundary=Y._sizeOfCellBoundary,n._sizeOfCoordIJ=Y._sizeOfCoordIJ,n._sizeOfGeoLoop=Y._sizeOfGeoLoop,n._sizeOfGeoPolygon=Y._sizeOfGeoPolygon,n._sizeOfH3Index=Y._sizeOfH3Index,n._sizeOfLatLng=Y._sizeOfLatLng,n._sizeOfLinkedGeoPolygon=Y._sizeOfLinkedGeoPolygon,n._uncompactCells=Y._uncompactCells,n._uncompactCellsSize=Y._uncompactCellsSize,n._vertexToLatLng=Y._vertexToLatLng,n.establishStackSpace=Y.establishStackSpace;var Z,ee,te=n.stackAlloc=Y.stackAlloc,ne=n.stackRestore=Y.stackRestore,re=n.stackSave=Y.stackSave;if(n.dynCall_iii=Y.dynCall_iii,n.asm=Y,n.cwrap=function(e,t,n,r){var i=(n=n||[]).every(function(e){return"number"===e});return"string"!==t&&i&&!r?u(e):function(){return f(e,t,n,arguments)}},n.setValue=function(e,t,n,r){switch("*"===(n=n||"i8").charAt(n.length-1)&&(n="i32"),n){case"i1":case"i8":h[e|0]=t;break;case"i16":m[e>>1]=t;break;case"i32":g[e>>2]=t;break;case"i64":V=[t>>>0,(U=t,+N(U)>=1?U>0?(0|B(+L(U/4294967296),4294967295))>>>0:~~+k((U-+(~~U>>>0))/4294967296)>>>0:0)],g[e>>2]=V[0],g[e+4>>2]=V[1];break;case"float":b[e>>2]=t;break;case"double":v[e>>3]=t;break;default:le("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 m[e>>1];case"i32":case"i64":return g[e>>2];case"float":return b[e>>2];case"double":return v[e>>3];default:le("invalid type for getValue: "+t)}return null},j){G(j)||(Z=j,j=n.locateFile?n.locateFile(Z,o):o+Z),O++,n.monitorRunDependencies&&n.monitorRunDependencies(O);var ie=function(e){e.byteLength&&(e=new Uint8Array(e)),p.set(e,8),n.memoryInitializerRequest&&delete n.memoryInitializerRequest.response,function(){if(O--,n.monitorRunDependencies&&n.monitorRunDependencies(O),0==O&&(null!==F&&(clearInterval(F),F=null),D)){var e=D;D=null,e()}}()},ae=function(){i(j,ie,function(){throw"could not load memory initializer "+j})},oe=J(j);if(oe)ie(oe.buffer);else if(n.memoryInitializerRequest){var se=function(){var e=n.memoryInitializerRequest,t=e.response;if(200!==e.status&&0!==e.status){var r=J(n.memoryInitializerRequestURL);if(!r)return console.warn("a problem seems to have happened with Module.memoryInitializerRequest, status: "+e.status+", retrying "+j),void ae();t=r.buffer}ie(t)};n.memoryInitializerRequest.response?setTimeout(se,0):n.memoryInitializerRequest.addEventListener("load",se)}else ae()}function Ae(e){function t(){ee||(ee=!0,c||(S(E),S(C),n.onRuntimeInitialized&&n.onRuntimeInitialized(),function(){if(n.postRun)for("function"==typeof n.postRun&&(n.postRun=[n.postRun]);n.postRun.length;)P(n.postRun.shift());S(I)}()))}e=e||a,O>0||(!function(){if(n.preRun)for("function"==typeof n.preRun&&(n.preRun=[n.preRun]);n.preRun.length;)R(n.preRun.shift());S(M)}(),O>0||(n.setStatus?(n.setStatus("Running..."),setTimeout(function(){setTimeout(function(){n.setStatus("")},1),t()},1)):t()))}function le(e){throw n.onAbort&&n.onAbort(e),s(e+=""),A(e),c=!0,"abort("+e+"). Build with -s ASSERTIONS=1 for more info."}if(D=function e(){ee||Ae(),ee||(D=e)},n.run=Ae,n.abort=le,n.preInit)for("function"==typeof n.preInit&&(n.preInit=[n.preInit]);n.preInit.length>0;)n.preInit.pop()();return Ae(),e}("object"==typeof Lr?Lr:{}),Br="number",Or={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"},Fr={1e3:"Unknown unit",1001:"Array length out of bounds",1002:"Got unexpected null value for H3 index"};function Dr(e,t,n){var r=n&&"value"in n,i=new Error((e[t]||"Unknown error")+" (code: "+t+(r?", value: "+n.value:"")+")");return i.code=t,i}function Ur(e,t){return Dr(Or,e,2===arguments.length?{value:t}:{})}function Vr(e,t){return Dr(Fr,e,2===arguments.length?{value:t}:{})}function jr(e){if(0!==e)throw Ur(e)}var zr={};[["sizeOfH3Index",Br],["sizeOfLatLng",Br],["sizeOfCellBoundary",Br],["sizeOfGeoLoop",Br],["sizeOfGeoPolygon",Br],["sizeOfLinkedGeoPolygon",Br],["sizeOfCoordIJ",Br],["readInt64AsDoubleFromPointer",Br],["isValidCell",Br,[Br,Br]],["isValidIndex",Br,[Br,Br]],["latLngToCell",Br,[Br,Br,Br,Br]],["cellToLatLng",Br,[Br,Br,Br]],["cellToBoundary",Br,[Br,Br,Br]],["maxGridDiskSize",Br,[Br,Br]],["gridDisk",Br,[Br,Br,Br,Br]],["gridDiskDistances",Br,[Br,Br,Br,Br,Br]],["gridRing",Br,[Br,Br,Br,Br]],["gridRingUnsafe",Br,[Br,Br,Br,Br]],["maxPolygonToCellsSize",Br,[Br,Br,Br,Br]],["polygonToCells",Br,[Br,Br,Br,Br]],["maxPolygonToCellsSizeExperimental",Br,[Br,Br,Br,Br]],["polygonToCellsExperimental",Br,[Br,Br,Br,Br,Br,Br]],["cellsToLinkedMultiPolygon",Br,[Br,Br,Br]],["destroyLinkedMultiPolygon",null,[Br]],["compactCells",Br,[Br,Br,Br,Br]],["uncompactCells",Br,[Br,Br,Br,Br,Br,Br]],["uncompactCellsSize",Br,[Br,Br,Br,Br,Br]],["isPentagon",Br,[Br,Br]],["isResClassIII",Br,[Br,Br]],["getBaseCellNumber",Br,[Br,Br]],["getResolution",Br,[Br,Br]],["getIndexDigit",Br,[Br,Br,Br]],["constructCell",Br,[Br,Br,Br,Br]],["maxFaceCount",Br,[Br,Br,Br]],["getIcosahedronFaces",Br,[Br,Br,Br]],["cellToParent",Br,[Br,Br,Br,Br]],["cellToChildren",Br,[Br,Br,Br,Br]],["cellToCenterChild",Br,[Br,Br,Br,Br]],["cellToChildrenSize",Br,[Br,Br,Br,Br]],["cellToChildPos",Br,[Br,Br,Br,Br]],["childPosToCell",Br,[Br,Br,Br,Br,Br,Br]],["areNeighborCells",Br,[Br,Br,Br,Br,Br]],["cellsToDirectedEdge",Br,[Br,Br,Br,Br,Br]],["getDirectedEdgeOrigin",Br,[Br,Br,Br]],["getDirectedEdgeDestination",Br,[Br,Br,Br]],["isValidDirectedEdge",Br,[Br,Br]],["directedEdgeToCells",Br,[Br,Br,Br]],["originToDirectedEdges",Br,[Br,Br,Br]],["directedEdgeToBoundary",Br,[Br,Br,Br]],["reverseDirectedEdge",Br,[Br,Br,Br]],["gridDistance",Br,[Br,Br,Br,Br,Br]],["gridPathCells",Br,[Br,Br,Br,Br,Br]],["gridPathCellsSize",Br,[Br,Br,Br,Br,Br]],["cellToLocalIj",Br,[Br,Br,Br,Br,Br,Br]],["localIjToCell",Br,[Br,Br,Br,Br,Br]],["getHexagonAreaAvgM2",Br,[Br,Br]],["getHexagonAreaAvgKm2",Br,[Br,Br]],["getHexagonEdgeLengthAvgM",Br,[Br,Br]],["getHexagonEdgeLengthAvgKm",Br,[Br,Br]],["greatCircleDistanceM",Br,[Br,Br]],["greatCircleDistanceKm",Br,[Br,Br]],["greatCircleDistanceRads",Br,[Br,Br]],["cellAreaM2",Br,[Br,Br,Br]],["cellAreaKm2",Br,[Br,Br,Br]],["cellAreaRads2",Br,[Br,Br,Br]],["edgeLengthM",Br,[Br,Br,Br]],["edgeLengthKm",Br,[Br,Br,Br]],["edgeLengthRads",Br,[Br,Br,Br]],["getNumCells",Br,[Br,Br]],["getRes0Cells",Br,[Br]],["res0CellCount",Br],["getPentagons",Br,[Br,Br]],["pentagonCount",Br],["cellToVertex",Br,[Br,Br,Br,Br]],["cellToVertexes",Br,[Br,Br,Br]],["vertexToLatLng",Br,[Br,Br,Br]],["isValidVertex",Br,[Br,Br]]].forEach(function(e){zr[e[0]]=Lr.cwrap.apply(Lr,e)});var Gr=16,Hr=zr.sizeOfH3Index(),qr=zr.sizeOfLatLng(),Qr=zr.sizeOfCellBoundary(),Kr=(zr.sizeOfGeoPolygon(),zr.sizeOfGeoLoop(),zr.sizeOfLinkedGeoPolygon()),Wr=(zr.sizeOfCoordIJ(),"m"),$r="km";Math.pow(2,32),Math.pow(2,31);var Jr=/[^0-9a-fA-F]/;function Yr(e){if(Array.isArray(e)&&2===e.length&&Number.isInteger(e[0])&&Number.isInteger(e[1]))return e;if("string"!=typeof e||Jr.test(e))return[0,0];var t=parseInt(e.substring(0,e.length-8),Gr);return[parseInt(e.substring(e.length-8),Gr),t]}function Xr(e){if(e>=0)return e.toString(Gr);var t=Zr(8,(e&=2147483647).toString(Gr));return t=(parseInt(t[0],Gr)+8).toString(Gr)+t.substring(1)}function Zr(e,t){for(var n=e-t.length,r="",i=0;i<n;i++)r+="0";return r+=t}function ei(e,t){void 0===t&&(t=0);var n=Lr.getValue(e+Hr*t,"i32"),r=Lr.getValue(e+Hr*t+4,"i32");return r?function(e,t){return Xr(t)+Zr(8,Xr(e))}(n,r):null}function ti(e,t,n){Lr.HEAPU32.set(Yr(e),t/4+2*n)}function ni(e){return 180*Lr.getValue(e,"double")/Math.PI}function ri(e){return[ni(e),ni(e+8)]}function ii(e){return[ni(e+8),ni(e)]}function ai(e){var t=Yr(e),n=t[0],r=t[1];return Boolean(zr.isPentagon(n,r))}function oi(e){var t=Yr(e),n=t[0],r=t[1];return zr.isValidCell(n,r)?zr.getResolution(n,r):-1}function si(e,t,n){var r=Lr._malloc(qr);Lr.HEAPF64.set([e,t].map(di),r/8);var i=Lr._malloc(Hr);try{return jr(zr.latLngToCell(r,n,i)),function(e){if(!e)throw Vr(1002);return e}(ei(i))}finally{Lr._free(i),Lr._free(r)}}function Ai(e){var t=Lr._malloc(qr),n=Yr(e),r=n[0],i=n[1];try{return jr(zr.cellToLatLng(r,i,t)),ri(t)}finally{Lr._free(t)}}function li(e,t){var n=Lr._malloc(Qr),r=Yr(e),i=r[0],a=r[1];try{return jr(zr.cellToBoundary(i,a,n)),function(e,t,n){for(var r=Lr.getValue(e,"i32"),i=e+8,a=[],o=t?ii:ri,s=0;s<2*r;s+=2)a.push(o(i+8*s));return n&&a.push(a[0]),a}(n,t,t)}finally{Lr._free(n)}}function ci(e,t){if(!e||!e.length)return[];var n=e.length,r=Lr._calloc(n,Hr);!function(e,t){for(var n=t.length,r=0;r<n;r++)ti(t[r],e,r)}(r,e);var i=Lr._calloc(Kr);try{return jr(zr.cellsToLinkedMultiPolygon(r,n,i)),function(e,t){for(var n,r,i,a,o=[],s=t?ii:ri;e;){for(o.push(n=[]),r=Lr.getValue(e,"i8*");r;){for(n.push(i=[]),a=Lr.getValue(r,"i8*");a;)i.push(s(a)),a=Lr.getValue(a+16,"i8*");t&&i.push(i[0]),r=Lr.getValue(r+8,"i8*")}e=Lr.getValue(e+8,"i8*")}return o}(i,t)}finally{zr.destroyLinkedMultiPolygon(i),Lr._free(i),Lr._free(r)}}function ui(e,t){var n,r=Yr(e),i=r[0],a=r[1],o=Yr(t),s=o[0],A=o[1],l=Lr._malloc(8);try{return jr(zr.gridDistance(i,a,s,A,l)),n=l,zr.readInt64AsDoubleFromPointer(n)}finally{Lr._free(l)}}function fi(e,t){!function(e){if("number"!=typeof e||e<0||e>15||Math.floor(e)!==e)throw Ur(4,e)}(e);var n,r,i=Lr._malloc(8);try{switch(t){case Wr:jr(zr.getHexagonEdgeLengthAvgM(e,i));break;case $r:jr(zr.getHexagonEdgeLengthAvgKm(e,i));break;default:throw Vr(1e3,t)}return n=i,void 0===r&&(r=0),Lr.getValue(n+8*r,"double")}finally{Lr._free(i)}}function di(e){return e*Math.PI/180}function hi(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 pi(e,t,n){const r=e(t,n),[i,a]=Ai(r);return[a,i]}function mi(e,t=1){const r=li(e,!0);return 1!==t?function(e,t,r){const[i,a]=Ai(e),o=t.length;hi(t,a);const s=t[0]===t[o-1]?o-1:o;for(let A=0;A<s;A++)t[A][0]=n.lerp$2(a,t[A][0],r),t[A][1]=n.lerp$2(i,t[A][1],r)}(e,r,t):hi(r),r}function gi(e){const t=new Float64Array(2*e.length);let n=0;for(const r of e)t[n++]=r[0],t[n++]=r[1];return t}var bi=class extends st{indexToBounds(){const{data:e,getPentagon:t}=this.props;return{data:e,_normalize:!1,_windingOrder:"CCW",positionFormat:"XY",getPolygon:(e,n)=>{const r=t(e,n);return gi(Pr("string"==typeof r?BigInt(`0x${r}`):r,{closedRing:!0,segments:"auto"}))}}}};function vi(e){return"string"==typeof e?e.charAt(0).toLowerCase()+e.slice(1):e}function yi(e){if(Array.isArray(e))return e.map(e=>yi(e));if(e&&"object"==typeof e){const t={};for(const[n,r]of Object.entries(e))t[vi(n)]=yi(r);return t}return e}bi.layerName="A5Layer",bi.defaultProps={getPentagon:{type:"accessor",value:e=>e.pentagon}};var xi=new RegExp("^[: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][: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\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$");var _i=function(e){const t=xi.exec(e);return!(null==t)};var wi=["hasOwnProperty","toString","valueOf","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"],Ti=["__proto__","constructor","prototype"],Si={allowBooleanAttributes:!1,unpairedTags:[]};function Mi(e){return" "===e||"\t"===e||"\n"===e||"\r"===e}function Ei(e,t){const n=t;for(;t<e.length;t++)if("?"==e[t]||" "==e[t]){const r=e.substr(n,t-n);if(t>5&&"xml"===r)return Li("InvalidXml","XML declaration allowed only at the start of the document.",Fi(e,t));if("?"==e[t]&&">"==e[t+1]){t++;break}continue}return t}function Ci(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}var Ii='"',Ri="'";function Pi(e,t){let n="",r="",i=!1;for(;t<e.length;t++){if(e[t]===Ii||e[t]===Ri)""===r?r=e[t]:r!==e[t]||(r="");else if(">"===e[t]&&""===r){i=!0;break}n+=e[t]}return""===r&&{value:n,index:t,tagClosed:i}}function Ni(e,t){const n=function(e){const t=[],n=e.length;let r=0;for(;r<n;){const i=r;for(;r<n&&Mi(e[r]);)r++;if(r>=n)break;if("="===e[r]){r=i+1;continue}const a=e.slice(i,r),o=r;for(;r<n&&!Mi(e[r])&&"="!==e[r];)r++;const s=e.slice(o,r);let A,l,c,u=r;for(;u<n&&Mi(e[u]);)u++;u<n&&"="===e[u]&&(A=e.slice(r,u+1),r=u+1);let f=r;for(;f<n&&Mi(e[f]);)f++;if(f<n&&('"'===e[f]||"'"===e[f])){const t=f+1,n=e.indexOf(e[f],t);-1!==n&&(l=e[f],c=e.slice(t,n),r=n+1)}const d={startIndex:i};d[1]=a,d[2]=s,d[3]=A,d[4]=void 0!==l||void 0,d[5]=l,d[6]=c,t.push(d)}return t}(e),r={};for(let i=0;i<n.length;i++){if(0===n[i][1].length)return Li("InvalidAttr","Attribute '"+n[i][2]+"' has no space in starting.",Di(n[i]));if(void 0!==n[i][3]&&void 0===n[i][4])return Li("InvalidAttr","Attribute '"+n[i][2]+"' is without value.",Di(n[i]));if(void 0===n[i][3]&&!t.allowBooleanAttributes)return Li("InvalidAttr","boolean attribute '"+n[i][2]+"' is not allowed.",Di(n[i]));const e=n[i][2];if(!Bi(e))return Li("InvalidAttr","Attribute '"+e+"' is an invalid name.",Di(n[i]));if(Object.prototype.hasOwnProperty.call(r,e))return Li("InvalidAttr","Attribute '"+e+"' is repeated.",Di(n[i]));r[e]=1}return!0}function ki(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 Li(e,t,n){return{err:{code:e,msg:t,line:n.line||n,col:n.col}}}function Bi(e){return _i(e)}function Oi(e){return _i(e)}function Fi(e,t){const n=e.substring(0,t).split(/\r?\n/);return{line:n.length,col:n[n.length-1].length+1}}function Di(e){return e.startIndex+e[1].length}var Ui={cent:"¢",pound:"£",curren:"¤",yen:"¥",euro:"€",dollar:"$",fnof:"ƒ",inr:"₹",af:"؋",birr:"ብር",peso:"₱",rub:"₽",won:"₩",yuan:"¥",cedil:"¸"},Vi={amp:"&",apos:"'",gt:">",lt:"<",quot:'"'},ji={nbsp:" ",copy:"©",reg:"®",trade:"™",mdash:"—",ndash:"–",hellip:"…",laquo:"«",raquo:"»",lsquo:"‘",rsquo:"’",ldquo:"“",rdquo:"”",bull:"•",para:"¶",sect:"§",deg:"°",frac12:"½",frac14:"¼",frac34:"¾"},zi=Object.freeze({ALLOW:"allow",BLOCK:"block",THROW:"throw"}),Gi=new Set("!?\\\\/[]$%{}^&*()<>|+");function Hi(e){if("#"===e[0])throw new Error(`[EntityReplacer] Invalid character '#' in entity name: "${e}"`);for(const t of e)if(Gi.has(t))throw new Error(`[EntityReplacer] Invalid character '${t}' in entity name: "${e}"`);return e}function qi(...e){const t=Object.create(null);for(const n of e)if(n)for(const e of Object.keys(n)){const r=n[e];if("string"==typeof r)t[e]=r;else if(r&&"object"==typeof r&&void 0!==r.val){const n=r.val;"string"==typeof n&&(t[e]=n)}}return t}var Qi="external",Ki="base",Wi="all";var $i=Object.freeze({allow:0,leave:1,remove:2,throw:3}),Ji=new Set([9,10,13]);var Yi=class{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??Qi)&&t!==Qi?t===Wi?new Set([Wi]):t===Ki?new Set([Ki]):Array.isArray(t)?new Set(t):new Set([Qi]):new Set([Qi]),this._numericAllowed=e.numericAllowed??!0,this._baseMap=qi(Vi,e.namedEntities||null),this._externalMap=Object.create(null),this._inputMap=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:$i.allow,nullLevel:$i.remove};const t=1.1===e.xmlVersion?1.1:1,n=$i[e.onNCR]??$i.allow,r=$i[e.nullNCR]??$i.remove;return{xmlVersion:t,onLevel:n,nullLevel:Math.max(r,$i.remove)}}(e.ncr);this._ncrXmlVersion=n.xmlVersion,this._ncrOnLevel=n.onLevel,this._ncrNullLevel=n.nullLevel,this._onExternalEntity="function"==typeof e.onExternalEntity?e.onExternalEntity:null,this._onInputEntity="function"==typeof e.onInputEntity?e.onInputEntity:null}_applyRegistrationHook(e,t,n,r){if(!e)return!0;const i=e(t,n);if(i===zi.BLOCK)return!1;if(i===zi.THROW)throw new Error(`[EntityDecoder] Registration of ${r} entity "&${t};" was rejected by hook`);return!0}setExternalEntities(e){if(e)for(const r of Object.keys(e))Hi(r);if(!this._onExternalEntity)return void(this._externalMap=qi(e));const t=qi(e),n=Object.create(null);for(const[r,i]of Object.entries(t))this._applyRegistrationHook(this._onExternalEntity,r,i,"external")&&(n[r]=i);this._externalMap=n}addExternalEntity(e,t){Hi(e),"string"==typeof t&&-1===t.indexOf("&")&&this._applyRegistrationHook(this._onExternalEntity,e,t,"external")&&(this._externalMap[e]=t)}addInputEntities(e){if(this._totalExpansions=0,this._expandedLength=0,!this._onInputEntity)return void(this._inputMap=qi(e));const t=qi(e),n=Object.create(null);for(const[r,i]of Object.entries(t))this._applyRegistrationHook(this._onInputEntity,r,i,"input")&&(n[r]=i);this._inputMap=n}reset(){return this._inputMap=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;if(-1===e.indexOf("&"))return e;const t=e,n=[],r=e.length;let i=0,a=0;const o=this._maxTotalExpansions>0,s=this._maxExpandedLength>0,A=o||s;for(;a<r;){if(38!==e.charCodeAt(a)){a++;continue}let t=a+1;for(;t<r&&59!==e.charCodeAt(t)&&t-a<=32;)t++;if(t>=r||59!==e.charCodeAt(t)){a++;continue}const l=e.slice(a+1,t);if(0===l.length){a++;continue}let c,u;if(this._removeSet.has(l))c="",void 0===u&&(u=Qi);else{if(this._leaveSet.has(l)){a++;continue}if(35===l.charCodeAt(0)){const e=this._resolveNCR(l);if(void 0===e){a++;continue}c=e,u=Ki}else{const e=this._resolveName(l);c=e?.value,u=e?.tier}}if(void 0!==c){if(a>i&&n.push(e.slice(i,a)),n.push(c),i=t+1,a=i,A&&this._tierCounts(u)){if(o&&(this._totalExpansions++,this._totalExpansions>this._maxTotalExpansions))throw new Error(`[EntityReplacer] Entity expansion count limit exceeded: ${this._totalExpansions} > ${this._maxTotalExpansions}`);if(s){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 a++}i<r&&n.push(e.slice(i));const l=0===n.length?e:n.join("");return this._postCheck(l,t)}_tierCounts(e){return!!this._limitTiers.has(Wi)||this._limitTiers.has(e)}_resolveName(e){return e in this._inputMap?{value:this._inputMap[e],tier:Qi}:e in this._externalMap?{value:this._externalMap[e],tier:Qi}:e in this._baseMap?{value:this._baseMap[e],tier:Ki}:void 0}_classifyNCR(e){return 0===e?this._ncrNullLevel:e>=55296&&e<=57343||1===this._ncrXmlVersion&&e>=1&&e<=31&&!Ji.has(e)?$i.remove:-1}_applyNCRAction(e,t,n){switch(e){case $i.allow:return String.fromCodePoint(n);case $i.remove:return"";case $i.leave:return;case $i.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 r=this._classifyNCR(n);if(!this._numericAllowed&&r<$i.remove)return;const i=-1===r?this._ncrOnLevel:Math.max(this._ncrOnLevel,r);return this._applyNCRAction(i,e,n)}},Xi=e=>wi.includes(e)?"__"+e:e,Zi={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,unicode:!1},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:Xi};function ea(e,t){if("string"!=typeof e)return;const n=e.toLowerCase();if(wi.some(e=>n===e.toLowerCase()))throw new Error(`[SECURITY] Invalid ${t}: "${e}" is a reserved JavaScript keyword that could cause prototype pollution`);if(Ti.some(e=>n===e.toLowerCase()))throw new Error(`[SECURITY] Invalid ${t}: "${e}" is a reserved JavaScript keyword that could cause prototype pollution`)}function ta(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"}:ta(!0)}var na,ra=function(e){const t=Object.assign({},Zi,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:r,name:i}of n)r&&ea(r,i);return null===t.onDangerousProperty&&(t.onDangerousProperty=Xi),t.processEntities=ta(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};na="function"!=typeof Symbol?"@@xmlMetadata":Symbol("XML Node Metadata");var ia=class{constructor(e){this.tagname=e,this.child=[],this[":@"]=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}),this.addStartIndex(t)}addStartIndex(e){void 0!==e&&(this.child[this.child.length-1][na]={startIndex:e})}addEndIndex(e){const t=this.child[this.child.length-1];void 0!==t&&void 0!==t[na]&&void 0===t[na].endIndex&&(t[na].endIndex=e)}static getMetaDataSymbol(){return na}},aa=":A-Za-z_À-ÖØ-öø-˿Ͱ-ͽͿ-҆҈-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�",oa=":A-Za-z_À-˿Ͱ-ͽͿ-҆҈-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�𐀀-󯿿",sa=oa+"\\-\\.\\d·̀-ͯ҇‿-⁀",Aa=(e,t,n="")=>{const r=`[${e.replace(":","")}][${t.replace(":","")}]*`;return{name:new RegExp(`^[${e}][${t}]*$`,n),ncName:new RegExp(`^${r}$`,n),qName:new RegExp(`^${r}(?::${r})?$`,n),nmToken:new RegExp(`^[${t}]+$`,n),nmTokens:new RegExp(`^[${t}]+(?:\\s+[${t}]+)*$`,n)}},la=Aa(aa,aa+"\\-\\.\\d·̀-ͯ‿-⁀"),ca=Aa(oa,sa,"u"),ua=Aa(":A-Za-z_",":A-Za-z_\\-\\.\\d"),fa=(e,{xmlVersion:t="1.0",asciiOnly:n=!1}={})=>((e="1.0",t=!1)=>t?ua:"1.1"===e?ca:la)(t,n).qName.test(e),da=class{constructor(e,t){this.suppressValidationErr=!e,this.options=e,this.xmlVersion=t||1}setXmlVersion(e=1){this.xmlVersion=e}readDocType(e,t){const n=Object.create(null);let r=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 i=1,a=!1,o=!1,s=null,A="";for(;t<e.length;t++)if(null===s)if(a||o||'"'!==e[t]&&"'"!==e[t])if("<"!==e[t]||o)if(">"===e[t]){if(o?"-"===e[t-1]&&"-"===e[t-2]&&(o=!1,i--):i--,0===i)break}else"["===e[t]?a=!0:A+=e[t];else{if(a&&pa(e,"!ENTITY",t)){let i,a;if(t+=7,[i,a,t]=this.readEntityExp(e,t+1,this.suppressValidationErr),-1===a.indexOf("&")){if(!1!==this.options.enabled&&null!=this.options.maxEntityCount&&r>=this.options.maxEntityCount)throw new Error(`Entity count (${r+1}) exceeds maximum allowed (${this.options.maxEntityCount})`);n[i]=a,r++}}else if(a&&pa(e,"!ELEMENT",t)){t+=8;const{index:n}=this.readElementExp(e,t+1);t=n}else if(a&&pa(e,"!ATTLIST",t))t+=8;else if(a&&pa(e,"!NOTATION",t)){t+=9;const{index:n}=this.readNotationExp(e,t+1,this.suppressValidationErr);t=n}else{if(!pa(e,"!--",t))throw new Error("Invalid DOCTYPE");o=!0}i++,A=""}else s=e[t],A+=e[t];else e[t]===s&&(s=null),A+=e[t];if(null!==s||0!==i)throw new Error("Unclosed DOCTYPE")}return{entities:n,i:t}}readEntityExp(e,t){const n=t=ha(e,t);for(;t<e.length&&!/\s/.test(e[t])&&'"'!==e[t]&&"'"!==e[t];)t++;let r=e.substring(n,t);if(ma(r,{xmlVersion:this.xmlVersion}),t=ha(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 i="";if([t,i]=this.readIdentifierVal(e,t,"entity"),!1!==this.options.enabled&&null!=this.options.maxEntitySize&&i.length>this.options.maxEntitySize)throw new Error(`Entity "${r}" size (${i.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`);return[r,i,--t]}readNotationExp(e,t){const n=t=ha(e,t);for(;t<e.length&&!/\s/.test(e[t]);)t++;let r=e.substring(n,t);!this.suppressValidationErr&&ma(r,{xmlVersion:this.xmlVersion}),t=ha(e,t);const i=e.substring(t,t+6).toUpperCase();if(!this.suppressValidationErr&&"SYSTEM"!==i&&"PUBLIC"!==i)throw new Error(`Expected SYSTEM or PUBLIC, found "${i}"`);t+=i.length,t=ha(e,t);let a=null,o=null;if("PUBLIC"===i)[t,a]=this.readIdentifierVal(e,t,"publicIdentifier"),'"'!==e[t=ha(e,t)]&&"'"!==e[t]||([t,o]=this.readIdentifierVal(e,t,"systemIdentifier"));else if("SYSTEM"===i&&([t,o]=this.readIdentifierVal(e,t,"systemIdentifier"),!this.suppressValidationErr&&!o))throw new Error("Missing mandatory system identifier for SYSTEM notation");return{notationName:r,publicIdentifier:a,systemIdentifier:o,index:--t}}readIdentifierVal(e,t,n){let r="";const i=e[t];if('"'!==i&&"'"!==i)throw new Error(`Expected quoted string, found "${i}"`);const a=++t;for(;t<e.length&&e[t]!==i;)t++;if(r=e.substring(a,t),e[t]!==i)throw new Error(`Unterminated ${n} value`);return[++t,r]}readElementExp(e,t){const n=t=ha(e,t);for(;t<e.length&&!/\s/.test(e[t]);)t++;let r=e.substring(n,t);if(!this.suppressValidationErr&&!fa(r,{xmlVersion:this.xmlVersion}))throw new Error(`Invalid element name: "${r}"`);let i="";if("E"===e[t=ha(e,t)]&&pa(e,"MPTY",t))t+=4;else if("A"===e[t]&&pa(e,"NY",t))t+=2;else if("("===e[t]){const n=++t;for(;t<e.length&&")"!==e[t];)t++;if(i=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:r,contentModel:i.trim(),index:t}}readAttlistExp(e,t){let n=t=ha(e,t);for(;t<e.length&&!/\s/.test(e[t]);)t++;let r=e.substring(n,t);for(ma(r,{xmlVersion:this.xmlVersion}),n=t=ha(e,t);t<e.length&&!/\s/.test(e[t]);)t++;let i=e.substring(n,t);if(!ma(i,{xmlVersion:this.xmlVersion}))throw new Error(`Invalid attribute name: "${i}"`);t=ha(e,t);let a="";if("NOTATION"===e.substring(t,t+8).toUpperCase()){if(a="NOTATION","("!==e[t=ha(e,t+=8)])throw new Error(`Expected '(', found "${e[t]}"`);t++;let n=[];for(;t<e.length&&")"!==e[t];){const r=t;for(;t<e.length&&"|"!==e[t]&&")"!==e[t];)t++;let i=e.substring(r,t);if(i=i.trim(),!ma(i,{xmlVersion:this.xmlVersion}))throw new Error(`Invalid notation name: "${i}"`);n.push(i),"|"===e[t]&&(t++,t=ha(e,t))}if(")"!==e[t])throw new Error("Unterminated list of notations");t++,a+=" ("+n.join("|")+")"}else{const n=t;for(;t<e.length&&!/\s/.test(e[t]);)t++;if(a+=e.substring(n,t),!this.suppressValidationErr&&!["CDATA","ID","IDREF","IDREFS","ENTITY","ENTITIES","NMTOKEN","NMTOKENS"].includes(a.toUpperCase()))throw new Error(`Invalid attribute type: "${a}"`)}t=ha(e,t);let o="";return"#REQUIRED"===e.substring(t,t+8).toUpperCase()?(o="#REQUIRED",t+=8):"#IMPLIED"===e.substring(t,t+7).toUpperCase()?(o="#IMPLIED",t+=7):[t,o]=this.readIdentifierVal(e,t,"ATTLIST"),{elementName:r,attributeName:i,attributeType:a,defaultValue:o,index:t}}},ha=(e,t)=>{for(;t<e.length&&/\s/.test(e[t]);)t++;return t};function pa(e,t,n){for(let r=0;r<t.length;r++)if(t[r]!==e[n+r+1])return!1;return!0}function ma(e,t){if(fa(e,{xmlVersion:t}))return e;throw new Error(`Invalid entity name ${e}`)}var ga=new Map,ba=new Uint8Array(63904).fill(255);for(const ev of[48,1632,1776,2406,2534,2662,2790,2918,3046,3174,3302,3430,3558,3664,3792,3872,4160,4240,6112,6160,6470,6608,6784,6800,6992,7088,7232,7248,65296,120782,120792,120802,120812,120822,66720,68912,69734,69872,69942,70096,70384,70736,70864,71248,71360,71472,71904,72016,72688,72784,73040,73120,73552,92768,92864,93008,123200,123632,124144,125264,130032])for(let e=0;e<10;e++){const t=ev+e;t<=65535?ba[t-1632]=e:ga.set(t,e)}var va=new Set([8722,65293,65123]);var ya=/^[-+]?0x[a-fA-F0-9]+$/,xa=/^0b[01]+$/,_a=/^0o[0-7]+$/,wa=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,Ta={hex:!0,binary:!1,octal:!1,leadingZeros:!0,decimalPoint:".",eNotation:!0,infinity:"original",unicode:!1};function Sa(e,t={}){if(t=Object.assign({},Ta,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.unicode&&(n=function(e){if("string"!=typeof e)return e;const t=e.length;if(0===t)return e;let n=-1;for(let i=0;i<t;i++){const r=e.charCodeAt(i);if(!(r>=48&&r<=57||45===r))if(r<1632){if(va.has(r)){n=i;break}}else if(r>=55296&&r<=56319){if(i+1<t){const t=e.charCodeAt(i+1);if(t>=56320&&t<=57343){const e=65536+(r-55296<<10)+(t-56320);if(ga.has(e)){n=i;break}}}}else if(255!==ba[r-1632]||va.has(r)){n=i;break}}if(-1===n)return e;const r=[];n>0&&r.push(e.slice(0,n));for(let i=n;i<t;i++){const n=e.charCodeAt(i);if(n>=48&&n<=57||45===n){r.push(e[i]);continue}if(n<1632){r.push(va.has(n)?"-":e[i]);continue}if(n>=55296&&n<=56319){if(i+1<t){const t=e.charCodeAt(i+1);if(t>=56320&&t<=57343){const e=65536+(n-55296<<10)+(t-56320),a=ga.get(e);if(void 0!==a){r.push(String.fromCharCode(a+48)),i++;continue}}}r.push(e[i]);continue}if(va.has(n)){r.push("-");continue}const a=ba[n-1632];r.push(255!==a?String.fromCharCode(a+48):e[i])}return r.join("")}(n),"0"===n))return 0;if(t.hex&&ya.test(n))return Ea(n,16);if(t.binary&&xa.test(n))return Ea(n,2);if(t.octal&&_a.test(n))return Ea(n,8);if(isFinite(n)){if(n.includes("e")||n.includes("E"))return function(e,t,n){if(!n.eNotation)return e;const r=t.match(Ma);if(r){let i=r[1]||"";const a=-1===r[3].indexOf("e")?"E":"e",o=r[2],s=i?t[o.length+1]===a:t[o.length]===a;return o.length>1&&s?e:(1!==o.length||!r[3].startsWith(`.${a}`)&&r[3][0]!==a)&&o.length>0?n.leadingZeros&&!s?Number(t):e:Number(t)}return e}(e,n,t);{const r=wa.exec(n);if(r){const i=r[1]||"",a=r[2];let o=function(e){if(e&&-1!==e.indexOf(".")){let t=e.length;for(;t>0&&48===e.charCodeAt(t-1);)t--;return"."===(e=e.slice(0,t))?e="0":"."===e[0]?e="0"+e:"."===e[e.length-1]&&(e=e.substring(0,e.length-1)),e}return e}(r[3]);const s=i?"."===n[a.length+1]:"."===n[a.length];if(!t.leadingZeros&&(a.length>1||1===a.length&&!s))return e;{const r=Number(n),s=String(r);if(0===r)return r;if(-1!==s.search(/[eE]/))return t.eNotation?r:e;if(-1!==n.indexOf("."))return"0"===s||s===o||s===`${i}${o}`?r:e;let A=a?o:n;return a?A===s||i+A===s?r:e:A===s||A===i+s?r:e}}return e}}{const r=Number(n);return Number.isNaN(r)?e:function(e,t,n){const r=t===1/0;switch(n.infinity.toLowerCase()){case"null":return null;case"infinity":return t;case"string":return r?"Infinity":"-Infinity";default:return e}}(e,r,t)}}var Ma=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;function Ea(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")}var Ca=class{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,r="";for(;n<e.length;)e[n]===this.separator?n+1<e.length&&e[n+1]===this.separator?(r.trim()&&(t.push(this._parseSegment(r.trim())),r=""),t.push({type:"deep-wildcard"}),n+=2):(r.trim()&&t.push(this._parseSegment(r.trim())),r="",n++):(r+=e[n],n++);return r.trim()&&t.push(this._parseSegment(r.trim())),t}_parseSegment(e){const t={type:"tag"};let n=null,r=e;const i=e.match(/^([^\[]+)(\[[^\]]*\])(.*)$/);if(i&&(r=i[1]+i[3],i[2])){const e=i[2].slice(1,-1);e&&(n=e)}let a,o,s=r;if(r.includes("::")){const t=r.indexOf("::");if(a=r.substring(0,t).trim(),s=r.substring(t+2).trim(),!a)throw new Error(`Invalid namespace in pattern: ${e}`)}let A=null;if(s.includes(":")){const e=s.lastIndexOf(":"),t=s.substring(0,e).trim(),n=s.substring(e+1).trim();["first","last","odd","even"].includes(n)||/^nth\(\d+\)$/.test(n)?(o=t,A=n):o=s}else o=s;if(!o)throw new Error(`Invalid segment pattern: ${e}`);if(t.tag=o,a&&(t.namespace=a),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}},Ia=class{constructor(){this._byDepthAndTag=new Map,this._wildcardByDepth=new Map,this._deepWildcards=[],this._deepByTerminalTag=new Map,this._patterns=new Set,this._sealed=!1}add(e){if(this._sealed)throw new TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions.");if(this._patterns.has(e.pattern))return this;if(this._patterns.add(e.pattern),e.hasDeepWildcard()){const t=e.segments[e.segments.length-1];if(t&&"deep-wildcard"!==t.type&&"*"!==t.tag){const n=t.tag;this._deepByTerminalTag.has(n)||this._deepByTerminalTag.set(n,[]),this._deepByTerminalTag.get(n).push(e)}else this._deepWildcards.push(e);return this}const t=e.length,n=e.segments[e.segments.length-1]?.tag;if(n&&"*"!==n){const r=`${t}:${n}`;this._byDepthAndTag.has(r)||this._byDepthAndTag.set(r,[]),this._byDepthAndTag.get(r).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=e.getCurrentTag(),r=`${t}:${n}`,i=this._byDepthAndTag.get(r);if(i)for(let s=0;s<i.length;s++)if(e.matches(i[s]))return i[s];const a=this._wildcardByDepth.get(t);if(a)for(let s=0;s<a.length;s++)if(e.matches(a[s]))return a[s];const o=this._deepByTerminalTag.get(n);if(o)for(let s=0;s<o.length;s++)if(e.matches(o[s]))return o[s];for(let s=0;s<this._deepWildcards.length;s++)if(e.matches(this._deepWildcards[s]))return this._deepWildcards[s];return null}},Ra=class{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}getAnyParentAttr(e){return this._matcher.getAnyParentAttr(e)}hasAnyParentAttr(e){return this._matcher.hasAnyParentAttr(e)}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)}},Pa=class{constructor(e={}){this.separator=e.separator||".",this.path=[],this.siblingStacks=[],this._pathStringCache=null,this._view=new Ra(this),this._keptAttrs=[]}push(e,t=null,n=null,r=null){this._pathStringCache=null,this.path.length>0&&(this.path[this.path.length-1].values=void 0);const i=this.path.length;let a=this.siblingStacks[i];a||(a={counts:new Map,total:0},this.siblingStacks[i]=a);const o=n?`${n}:${e}`:e,s=a.counts.get(o)||0,A=a.total;a.counts.set(o,s+1),a.total++;const l={tag:e,position:A,counter:s};null!=n&&(l.namespace=n),null!=t&&(l.values=t),this.path.push(l);const c=this.path.length,u=null!==r?r.keep:null;if(null!=u&&u.length>0&&t)for(let f=0;f<u.length;f++){const e=u[f];void 0!==t[e]&&this._keptAttrs.push({depth:c,name:e,value:t[e]})}}pop(){if(0===this.path.length)return;this._pathStringCache=null;const e=this.path.pop();this.siblingStacks.length>this.path.length+1&&(this.siblingStacks.length=this.path.length+1);const t=this.path.length+1;for(;this._keptAttrs.length>0&&this._keptAttrs[this._keptAttrs.length-1].depth>=t;)this._keptAttrs.pop();return 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}getAnyParentAttr(e){const t=this._keptAttrs;for(let n=t.length-1;n>=0;n--)if(t[n].name===e)return t[n].value}hasAnyParentAttr(e){const t=this._keptAttrs;for(let n=t.length-1;n>=0;n--)if(t[n].name===e)return!0;return!1}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=[],this._keptAttrs=[]}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 r=e[n];if("deep-wildcard"===r.type){if(n--,n<0)return!0;const r=e[n];let i=!1;for(let e=t;e>=0;e--)if(this._matchSegment(r,this.path[e],e===this.path.length-1)){t=e-1,n--,i=!0;break}if(!i)return!1}else{if(!this._matchSegment(r,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 r=t.counter??0;if("first"===e.position&&0!==r)return!1;if("odd"===e.position&&r%2!=1)return!1;if("even"===e.position&&r%2!=0)return!1;if("nth"===e.position&&r!==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=>e?{counts:new Map(e.counts),total:e.total}:e),keptAttrs:this._keptAttrs.map(e=>({...e}))}}restore(e){this._pathStringCache=null,this.path=e.path.map(e=>({...e})),this.siblingStacks=e.siblingStacks.map(e=>e?{counts:new Map(e.counts),total:e.total}:e),this._keptAttrs=(e.keptAttrs||[]).map(e=>({...e}))}readOnly(){return this._view}},Na=[{id:"html-script-open",description:"<script opening tag",pattern:/<script[\s>/]/i},{id:"html-script-close",description:"<\/script closing tag",pattern:/<\/script[\s>]/i},{id:"html-javascript-protocol",description:"javascript: URI scheme (with optional whitespace/encoding)",pattern:/j[\t\n\r ]*a[\t\n\r ]*v[\t\n\r ]*a[\t\n\r ]*s[\t\n\r ]*c[\t\n\r ]*r[\t\n\r ]*i[\t\n\r ]*p[\t\n\r ]*t[\t\n\r ]*:/i},{id:"html-vbscript-protocol",description:"vbscript: URI scheme",pattern:/vbscript[\t\n\r ]*:/i},{id:"html-data-html",description:"data:text/html URI — can execute scripts in browsers",pattern:/data[\t\n\r ]*:[\t\n\r ]*text\/html/i},{id:"html-data-xhtml",description:"data:application/xhtml+xml URI",pattern:/data[\t\n\r ]*:[\t\n\r ]*application\/xhtml/i},{id:"html-data-svg",description:"data:image/svg+xml URI — can execute scripts",pattern:/data[\t\n\r ]*:[\t\n\r ]*image\/svg\+xml/i},{id:"html-inline-event-handler",description:"Inline event handler attributes: onclick=, onerror=, onload=, etc.",pattern:/\bon\w{1,30}\s*=/i},{id:"html-entity-obfuscated-script",description:"HTML-entity-encoded <script (e.g. &#x3C;script or &lt;script)",pattern:/(?:&#x0*3[Cc];?|&#0*60;?|&lt;)\s*script/i},{id:"html-entity-obfuscated-javascript",description:'HTML-entity-encoded javascript: (partial — catches common &#106; or &#x6a; for "j")',pattern:/(?:&#x0*6[Aa];?|&#0*106;?)\s*(?:&#x0*61;?|a)[\s\S]{0,80}script\s*:/i},{id:"html-style-expression",description:"CSS expression() — IE-era code execution in style attributes",pattern:/style[\s\S]{0,20}expression\s*\(/i},{id:"html-object-embed",description:"<object or <embed tags that can load active content",pattern:/<(?:object|embed)[\s>/]/i},{id:"html-base-tag",description:"<base href= — can hijack all relative URLs on a page",pattern:/<base[\s>]/i},{id:"html-meta-refresh",description:'<meta http-equiv="refresh" — can redirect users',pattern:/<meta[\s\S]{0,40}http-equiv[\s\S]{0,20}refresh/i},{id:"html-srcdoc",description:"srcdoc= attribute on iframes — embeds HTML that can run scripts",pattern:/srcdoc\s*=/i},{id:"html-iframe",description:"<iframe tag",pattern:/<iframe[\s>/]/i},{id:"html-form",description:"<form tag — can be used for phishing / credential harvesting injection",pattern:/<form[\s>/]/i}],ka=[{id:"xml-cdata-injection",description:"CDATA section injection: <![CDATA[ breaks out of text node context",pattern:/<!\[CDATA\[/i},{id:"xml-cdata-close",description:"CDATA close sequence: ]]> can terminate an enclosing CDATA section",pattern:/\]\]>/},{id:"xml-processing-instruction",description:"XML processing instruction: <?xml-stylesheet or <?php etc.",pattern:/<\?(?:xml[\- ]|php|asp)/i},{id:"xml-doctype-injection",description:"DOCTYPE declaration embedded in content — can define entities",pattern:/<!DOCTYPE(?:[\s[]|$)/i},{id:"xml-entity-system",description:"SYSTEM keyword — used in external entity declarations (XXE)",pattern:/\bSYSTEM\s+["']/i},{id:"xml-entity-public",description:"PUBLIC keyword — used in external entity declarations (XXE)",pattern:/\bPUBLIC\s+["']/i},{id:"xml-entity-declaration",description:"<!ENTITY declaration — defines entities, potential XXE or entity expansion",pattern:/<!ENTITY[\s%]/i},{id:"xml-billion-laughs",description:"Entity reference chaining / billion laughs: repeated &eX; style references",pattern:/(?:&\w{1,20};){3,}/},{id:"xml-namespace-confusion",description:"xmlns: attribute injection — can redefine namespaces to confuse parsers",pattern:/\bxmlns(?::\w{1,40})?\s*=/i},{id:"xml-comment-injection",description:"\x3c!-- comment injection — can hide content from some parsers",pattern:/<!--/},{id:"xml-comment-close",description:"--\x3e closes an enclosing XML comment",pattern:/-->/},{id:"xml-pi-close",description:"?> closes an enclosing processing instruction",pattern:/\?>/}],La=[{id:"svg-script-element",description:"<script element inside SVG executes JavaScript",pattern:/<script[\s>/]/i},{id:"svg-xlink-href-javascript",description:"xlink:href with javascript: — classic SVG XSS via <a> or <use>",pattern:/xlink\s*:\s*href\s*=\s*["']?\s*javascript\s*:/i},{id:"svg-href-javascript",description:"href= with javascript: in SVG context (<a>, <animate>, etc.)",pattern:/href\s*=\s*["']?\s*javascript\s*:/i},{id:"svg-foreignobject",description:"<foreignObject embeds HTML inside SVG — can execute scripts",pattern:/<foreignObject[\s>/]/i},{id:"svg-use-external",description:"<use xlink:href or href pointing to external resource (non-fragment URL)",pattern:/<use[\s\S]{0,60}(?:xlink\s*:\s*)?href\s*=\s*(?:["'][^#]|[^"'#\s>])/i},{id:"svg-animate-href",description:'<animate attributeName="href" — can dynamically change href to javascript:',pattern:/<animate[\s\S]{0,80}attributeName\s*=\s*["'][\s]*href["']/i},{id:"svg-animate-xlinkhref",description:'<animate attributeName="xlink:href"',pattern:/<animate[\s\S]{0,80}attributeName\s*=\s*["'][\s]*xlink\s*:\s*href["']/i},{id:"svg-set-javascript",description:'<set to="javascript:..." — sets an attribute to a javascript: URI',pattern:/<set[\s\S]{0,80}to\s*=\s*["']?\s*javascript\s*:/i},{id:"svg-event-handler",description:"SVG-specific event handler attributes: onload=, onerror=, onactivate=, etc.",pattern:/\bon(?:load|error|activate|begin|end|repeat|focus|blur|click|mouse\w{1,20}|key\w{1,20})\s*=/i},{id:"svg-handler-generic",description:"Generic on* handler catch-all for SVG attributes",pattern:/\bon\w{1,30}\s*=/i},{id:"svg-filter-feimage",description:"<feImage href= — filter primitive that can load external resources",pattern:/<feImage[\s\S]{0,80}(?:xlink\s*:\s*)?href\s*=/i},{id:"svg-image-external",description:"<image xlink:href with http/https or javascript protocol",pattern:/<image[\s\S]{0,80}(?:xlink\s*:\s*)?href\s*=\s*["']?\s*(?:https?|javascript)\s*:/i},{id:"svg-style-javascript",description:"style= attribute containing javascript: (e.g. background:url(javascript:...))",pattern:/style\s*=[\s\S]{0,60}javascript\s*:/i}],Ba=[{id:"sql-block-comment-open",description:"SQL block comment open: /* ... */ — unusual in legitimate user text",pattern:/\/\*/},{id:"sql-union-select",description:"UNION SELECT — most common SQL injection aggregation attack",pattern:/\bUNION\s{1,20}(?:ALL\s{1,20})?SELECT\b/i},{id:"sql-drop-table",description:"DROP TABLE — destructive DDL injection",pattern:/\bDROP\s{1,20}TABLE\b/i},{id:"sql-drop-database",description:"DROP DATABASE — destructive DDL injection",pattern:/\bDROP\s{1,20}DATABASE\b/i},{id:"sql-insert-into",description:"INSERT INTO — data injection",pattern:/\bINSERT\s{1,20}INTO\b/i},{id:"sql-delete-from",description:"DELETE FROM — data deletion injection",pattern:/\bDELETE\s{1,20}FROM\b/i},{id:"sql-update-set",description:"UPDATE ... SET — data modification injection",pattern:/\bUPDATE\b[\s\S]{1,60}\bSET\b/i},{id:"sql-exec-xp",description:"EXEC xp_ — MSSQL extended stored procedure execution",pattern:/\bEXEC(?:UTE)?\s{1,20}xp_/i},{id:"sql-tautology-string",description:'Classic string tautology: \' OR \'1\'=\'1 or " OR "1"="1"',pattern:/'\s{0,10}OR\s{0,10}'[^']{0,20}'\s*=\s*'[^']{0,20}/i},{id:"sql-tautology-numeric",description:"Numeric tautology: OR 1=1",pattern:/\bOR\s{1,10}1\s*=\s*1\b/i},{id:"sql-always-true-zero",description:"Numeric tautology: OR 0=0",pattern:/\bOR\s{1,10}0\s*=\s*0\b/i},{id:"sql-sleep-benchmark",description:"Time-based blind injection: SLEEP() or BENCHMARK()",pattern:/\b(?:SLEEP|BENCHMARK)\s*\(/i},{id:"sql-waitfor-delay",description:"MSSQL time-based blind injection: WAITFOR DELAY",pattern:/\bWAITFOR\s{1,20}DELAY\b/i},{id:"sql-char-function",description:"CHAR() function — used to obfuscate injected strings",pattern:/\bCHAR\s*\(\s*\d{1,3}/i},{id:"sql-information-schema",description:"INFORMATION_SCHEMA — reconnaissance query for table/column enumeration",pattern:/\bINFORMATION_SCHEMA\b/i}],Oa=[{id:"shell-path-traversal-unix",description:"Unix path traversal: ../ — climbing the directory tree",pattern:/\.\.\//},{id:"shell-path-traversal-windows",description:"Windows path traversal: ..\\ — climbing the directory tree",pattern:/\.\.\\/},{id:"shell-path-traversal-encoded",description:"URL-encoded path traversal: %2e%2e or %2f variants",pattern:/%2e%2e|%2f\.\.|\.\.%2f/i},{id:"shell-null-byte",description:"Null byte injection: \\x00 or %00 — truncates strings in C-backed functions",pattern:/\x00|%00/},{id:"shell-semicolon",description:"Semicolon command separator: cmd1; cmd2",pattern:/;/},{id:"shell-pipe",description:"Pipe operator: cmd1 | cmd2",pattern:/\|/},{id:"shell-and-operator",description:"AND operator: cmd1 && cmd2",pattern:/&&/},{id:"shell-or-operator",description:"OR operator: cmd1 || cmd2",pattern:/\|\|/},{id:"shell-backtick",description:"Backtick command substitution: `cmd`",pattern:/`/},{id:"shell-dollar-paren",description:"Dollar-paren command substitution: $(cmd)",pattern:/\$\(/},{id:"shell-dollar-brace",description:"Dollar-brace variable expansion: ${var} — can be abused for injection",pattern:/\$\{/},{id:"shell-redirect-out",description:"Output redirection: cmd > file or cmd >> file",pattern:/>{1,2}/},{id:"shell-redirect-in",description:"Input redirection: cmd < file",pattern:/</},{id:"shell-newline-injection",description:"Newline injection: \\n or \\r — can inject new shell commands",pattern:/[\n\r]/},{id:"shell-glob-star",description:"Glob expansion: * or ? — can expand to unintended files",pattern:/[/\\][*?]/},{id:"shell-absolute-root",description:"Absolute root path injection: string starting with / or \\ (Windows UNC)",pattern:/^(?:\/|\\\\)/},{id:"shell-windows-drive",description:"Windows drive letter path injection: C:\\ or D:/",pattern:/^[a-zA-Z]:[/\\]/},{id:"shell-curl-wget",description:"curl/wget with URL or flags — can exfiltrate data or download payloads",pattern:/\b(?:curl|wget)\s+(?:https?:\/\/|ftp:\/\/|-)/i}],Fa=[{id:"redos-nested-quantifier-plus",description:"Nested + quantifier inside a group with outer quantifier: (a+)+, (.+b)*, etc.",pattern:/\([^)]*\+[^)]*\)[+*]/},{id:"redos-nested-quantifier-star",description:"Nested * quantifier: (a*)* or (a*)+ — catastrophic backtracking",pattern:/\([^)]*\*[^)]*\)[*+]/},{id:"redos-nested-groups",description:"Doubly nested quantified groups: ((a+)+) — guaranteed catastrophic",pattern:/\(\([^)]{0,40}\)[+*]\)[+*]/},{id:"redos-alternation-overlap",description:"Overlapping alternation under quantifier: (a|a)+ — ambiguous NFA paths",pattern:/\(([^|()]{1,20})\|(?:\1)(?:\|[^|()]{1,20}){0,5}\)[+*?]{1,2}/},{id:"redos-star-plus-concat",description:"(x*x)+ pattern — triggers super-linear backtracking",pattern:/\([^)]{0,10}\*[^)]{0,10}\)[+*]/},{id:"redos-dot-star-greedy",description:"(.*){n,} or (.+){n,} — repeated greedy dot quantifiers",pattern:/\(\.[*+]\)\{?\d/},{id:"redos-large-repetition",description:"Very large fixed or range repetition count {1000,} or {1000,n} — denial of service via backtracking",pattern:/\{\d{4,}(?:,\d*)?\}/},{id:"redos-catastrophic-alternation",description:"Long alternation with many similar branches — polynomial backtracking risk",pattern:/\([^)]{0,200}(?:\|[^|)]{0,50}){9,}\)/}],Da="[\"'\\s]*:",Ua=[{id:"nosql-where-operator",description:"$where — executes arbitrary JavaScript server-side in MongoDB",pattern:new RegExp(`\\$where${Da}`,"i")},{id:"nosql-ne-operator",description:'$ne — "not equal" operator used to bypass equality checks',pattern:new RegExp(`\\$ne${Da}`,"i")},{id:"nosql-gt-operator",description:'$gt — "greater than" used to bypass password/value checks',pattern:new RegExp(`\\$gte?${Da}`,"i")},{id:"nosql-lt-operator",description:'$lt / $lte — "less than" bypass variants',pattern:new RegExp(`\\$lte?${Da}`,"i")},{id:"nosql-regex-operator",description:"$regex — can be used to extract data character by character (blind injection)",pattern:new RegExp(`\\$regex${Da}`,"i")},{id:"nosql-or-operator",description:"$or — logical OR; used to create always-true conditions",pattern:new RegExp(`\\$or${Da}\\s*\\[`,"i")},{id:"nosql-and-operator",description:"$and — logical AND operator injection",pattern:new RegExp(`\\$and${Da}\\s*\\[`,"i")},{id:"nosql-nor-operator",description:"$nor — logical NOR operator injection",pattern:new RegExp(`\\$nor${Da}\\s*\\[`,"i")},{id:"nosql-exists-operator",description:"$exists — can enumerate fields to determine schema",pattern:new RegExp(`\\$exists${Da}`,"i")},{id:"nosql-in-operator",description:"$in — matches any value in a list; can enumerate values",pattern:new RegExp(`\\$in${Da}\\s*\\[`,"i")},{id:"nosql-expr-operator",description:"$expr — allows aggregation expressions in queries (MongoDB 3.6+)",pattern:new RegExp(`\\$expr${Da}`,"i")},{id:"nosql-function-operator",description:"$function — executes arbitrary JavaScript in MongoDB 4.4+",pattern:new RegExp(`\\$function${Da}`,"i")},{id:"nosql-accumulator-operator",description:"$accumulator — custom aggregation with arbitrary JS execution",pattern:new RegExp(`\\$accumulator${Da}`,"i")},{id:"nosql-proto-pollution",description:"__proto__ — prototype pollution via object key injection",pattern:/__proto__/},{id:"nosql-constructor-prototype",description:"constructor.prototype — alternative prototype pollution vector (dot notation or JSON key)",pattern:/constructor[\s"':.,{\[]*prototype/i},{id:"nosql-proto-bracket",description:'["__proto__"] — bracket-notation prototype pollution',pattern:/\[["']__proto__["']\]/}],Va=[{id:"log-crlf-injection",description:"CRLF injection: literal \\r or \\n embeds fake log lines",pattern:/[\r\n]/},{id:"log-url-encoded-crlf",description:"URL-encoded CRLF: %0d, %0a, %0D, %0A — decoded by some log parsers",pattern:/%0[dDaA]/},{id:"log-unicode-newline",description:"Unicode newline variants: U+2028 (line separator), U+2029 (paragraph separator)",pattern:/[\u2028\u2029]/},{id:"log-log4shell-jndi",description:"Log4Shell: ${jndi:...} triggers remote code execution in Apache Log4j",pattern:/\$\{jndi\s*:/i},{id:"log-log4shell-obfuscated",description:"Obfuscated Log4Shell: ${::-j}... lookup-bypass prefix used to evade WAF detection",pattern:/\$\{::-/},{id:"log-log4j-lookup",description:"Log4j lookup syntax: ${env:...}, ${sys:...}, ${ctx:...} — data exfiltration",pattern:/\$\{(?:env|sys|ctx|main|map|sd|web|docker|k8s|spring)\s*:/i},{id:"log-ssti-double-brace",description:"SSTI double-brace: {{expression}} — Jinja2, Twig, Handlebars, etc.",pattern:/\{\{[\s\S]{0,80}\}\}/},{id:"log-ssti-hash-brace",description:"SSTI hash-brace: #{expression} — Thymeleaf, Velocity, Ruby ERB",pattern:/#\{[\s\S]{0,80}\}/},{id:"log-ssti-dollar-brace",description:"SSTI/EL injection: ${expression with operators or method calls} — JSP EL, Freemarker, SpEL",pattern:/\$\{[^}]*(?:\.|\(|\*|\+|\bclass\b|\bruntime\b|\bprocess\b|\bexec\b)[^}]{0,80}\}/i},{id:"log-ssti-percent-tag",description:"SSTI ERB/ASP tag: <%= expression %> — Ruby ERB, ASP",pattern:/<%=[\s\S]{0,80}%>/},{id:"log-null-byte",description:"Null byte: \\x00 or %00 — can truncate log entries in C-backed loggers",pattern:/\x00|%00/},{id:"log-ansi-escape",description:"ANSI escape sequence: ESC[ — can manipulate terminal output when logs are tailed",pattern:/\x1b\[/}],ja=[...Ba,{id:"sql-line-comment",description:"SQL line comment: -- followed by whitespace or end of string",pattern:/--(?:\s|$)/},{id:"sql-stacked-query",description:"Stacked queries: semicolon immediately followed by a SQL keyword",pattern:/;\s{0,10}(?:SELECT|INSERT|UPDATE|DELETE|DROP|CREATE|ALTER|EXEC)\b/i},{id:"sql-hex-encoding",description:"Hex-encoded string injection: 0x41414141 style (MySQL)",pattern:/\b0x[0-9a-f]{4,}/i}],za=Object.freeze({colon:":",Tab:"\t",NewLine:"\n"}),Ga=/&(?:#[xX]0*([0-9a-fA-F]{1,6});?|#0*([0-9]{1,7});?|([a-zA-Z][a-zA-Z0-9]{1,15});)/g;Na.label="HTML",ka.label="XML",La.label="SVG",Na.decodeEntities=!0,ka.decodeEntities=!0,La.decodeEntities=!0,Ba.label="SQL",ja.label="SQL-STRICT",Oa.label="SHELL",Fa.label="REDOS",Ua.label="NOSQL",Va.label="LOG";Object.freeze({HTML:Na,XML:ka,SVG:La,SQL:Ba,"SQL-STRICT":ja,SHELL:Oa,REDOS:Fa,NOSQL:Ua,LOG:Va});function Ha(e,t){if(!t.decodeEntities)return null;const n=-1===(r=e).indexOf("&")?r:r.replace(Ga,(e,t,n,r)=>{if(void 0!==r)return Object.prototype.hasOwnProperty.call(za,r)?za[r]:e;const i=void 0!==t?parseInt(t,16):parseInt(n,10);return!Number.isFinite(i)||i>1114111?e:String.fromCodePoint(i)});var r;return n===e?null:n}function qa(e,t){const n=t.label??"CUSTOM",r=Ha(e,t);for(const i of t)if(i.pattern.test(e)||null!==r&&i.pattern.test(r))return{context:n,id:i.id,description:i.description,pattern:i.pattern};return null}function Qa(e,t){!function(e){if("string"!=typeof e)throw new TypeError("is-unsafe: first argument must be a string, got "+typeof e)}(e),function(e){if(!(e instanceof RegExp)){if(!Array.isArray(e))throw new TypeError("is-unsafe: second argument must be a PatternList (e.g. HTML), an array of PatternLists (e.g. [HTML, XML]), or a RegExp. Got: "+typeof e);if(0===e.length)throw new TypeError("is-unsafe: context must not be an empty array");if(Array.isArray(e[0]))for(const t of e)if(!Array.isArray(t)||0===t.length)throw new TypeError("is-unsafe: each context in the array must be a non-empty pattern array (PatternList)")}}(t);const{lists:n,regex:r}=function(e){return e instanceof RegExp?{lists:null,regex:e}:Array.isArray(e[0])?{lists:e,regex:null}:{lists:[e],regex:null}}(t);if(r)return r.test(e);for(const i of n)if(null!==qa(e,i))return!0;return!1}function Ka(e,t){if(!e)return{};const n=t.attributesGroupName?e[t.attributesGroupName]:e;if(!n)return{};const r={};for(const i in n)if(i.startsWith(t.attributeNamePrefix)){r[i.substring(t.attributeNamePrefix.length)]=n[i]}else r[i]=n[i];return r}function Wa(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}}var $a=class{constructor(e,t){var n;this.options=e,this.currentNode=null,this.tagsNodeStack=[],this.parseXml=eo,this.parseTextData=Ja,this.resolveNameSpace=Ya,this.buildAttributesMap=Za,this.isItStopNode=ao,this.replaceEntitiesValue=ro,this.readStopNodeData=lo,this.saveTextToParentTag=io,this.addChild=no,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,this.doctypefound=!1;let r={...Vi};this.options.entityDecoder?this.entityDecoder=this.options.entityDecoder:("object"==typeof this.options.htmlEntities?r=this.options.htmlEntities:!0===this.options.htmlEntities&&(r={...ji,...Ui}),this.entityDecoder=new Yi({namedEntities:{...r,...t},numericAllowed:this.options.htmlEntities,limit:{maxTotalExpansions:this.options.processEntities.maxTotalExpansions,maxExpandedLength:this.options.processEntities.maxExpandedLength,applyLimitsTo:this.options.processEntities.appliesTo},onInputEntity:(e,t)=>Qa(t,[Na,ka])?zi.BLOCK:zi.ALLOW})),this.matcher=new Pa,this.readonlyMatcher=this.matcher.readOnly(),this.isCurrentNodeStopNode=!1,this.stopNodeExpressionsSet=new Ia;const i=this.options.stopNodes;if(i&&i.length>0){for(let e=0;e<i.length;e++){const t=i[e];"string"==typeof t?this.stopNodeExpressionsSet.add(new Ca(t)):t instanceof Ca&&this.stopNodeExpressionsSet.add(t)}this.stopNodeExpressionsSet.seal()}}};function Ja(e,t,n,r,i,a,o){const s=this.options;if(void 0!==e&&(s.trimValues&&!r&&(e=e.trim()),e.length>0)){o||(e=this.replaceEntitiesValue(e,t,n));const r=s.jPath?n.toString():n,A=s.tagValueProcessor(t,e,r,i,a);return null==A?e:typeof A!=typeof e||A!==e?A:s.trimValues||e.trim()===e?co(e,s.parseTagValue,s.numberParseOptions):e}}function Ya(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}var Xa=new RegExp("([^\\s=]+)\\s*(=\\s*(['\"])([\\s\\S]*?)\\3)?","gm");function Za(e,t,n,r=!1){const i=this.options;if(!0===r||!0!==i.ignoreAttributes&&"string"==typeof e){const r=function(e,t){const n=[];let r=t.exec(e);for(;r;){const i=[];i.startIndex=t.lastIndex-r[0].length;const a=r.length;for(let e=0;e<a;e++)i.push(r[e]);n.push(i),r=t.exec(e)}return n}(e,Xa),a=r.length,o={},s=new Array(a);let A=!1;const l={};for(let e=0;e<a;e++){const t=this.resolveNameSpace(r[e][1]),a=r[e][4];if(t.length&&void 0!==a){let r=a;i.trimValues&&(r=r.trim()),r=this.replaceEntitiesValue(r,n,this.readonlyMatcher),s[e]=r,l[t]=r,A=!0}}A&&"object"==typeof t&&t.updateCurrent&&t.updateCurrent(l);const c=i.jPath?t.toString():this.readonlyMatcher;let u=!1;for(let e=0;e<a;e++){const t=this.resolveNameSpace(r[e][1]);if(this.ignoreAttributesFn(t,c))continue;let n=i.attributeNamePrefix+t;if(t.length)if(i.transformAttributeName&&(n=i.transformAttributeName(n)),n=fo(n,i),void 0!==r[e][4]){const r=s[e],a=i.attributeValueProcessor(t,r,c);o[n]=null==a?r:typeof a!=typeof r||a!==r?a:co(r,i.parseAttributeValue,i.numberParseOptions),u=!0}else i.allowBooleanAttributes&&(o[n]=!0,u=!0)}if(!u)return;if(i.attributesGroupName&&!i.preserveOrder){const e={};return e[i.attributesGroupName]=o,e}return o}}var eo=function(e){const t=this.options,n=t.captureMetaData?[]:void 0;e=e.replace(/\r\n?/g,t.captureMetaData?(e,t)=>(2===e.length&&n.push(t-n.length),"\n"):"\n");const r=new ia("!xml");let i=r,a="";this.matcher.reset(),this.entityDecoder.reset(),this.entityExpansionCount=0,this.currentExpandedLength=0,this.doctypefound=!1;const o=new da(t.processEntities),s=e.length;for(let A=0;A<s;A++)if("<"===e[A]){const l=e.charCodeAt(A+1);if(47===l){const o=oo(e,">",A,"Closing Tag is not closed.");let s=e.substring(A+2,o).trim();if(t.removeNSPrefix){const e=s.indexOf(":");-1!==e&&(s=s.substr(e+1))}s=uo(t.transformTagName,s,"",t).tagName,i&&(a=this.saveTextToParentTag(a,i,this.readonlyMatcher));const l=this.matcher.getCurrentTag();if(s&&t.unpairedTagsSet.has(s))throw new Error(`Unpaired tag can not be used as closing tag: </${s}>`);l&&t.unpairedTagsSet.has(l)&&(this.matcher.pop(),this.tagsNodeStack.pop()),this.matcher.pop(),this.isCurrentNodeStopNode=!1,i=this.tagsNodeStack.pop()||r,t.captureMetaData&&i&&i.addEndIndex(to(o+1,n)),a="",A=o}else if(63===l){let r=Ao(e,A,!1,"?>");if(!r)throw new Error("Pi Tag is not closed.");a=this.saveTextToParentTag(a,i,this.readonlyMatcher);const s=this.buildAttributesMap(r.tagExp,this.matcher,r.tagName,!0);if(s){const e=s[this.options.attributeNamePrefix+"version"];this.entityDecoder.setXmlVersion(Number(e)||1),o.setXmlVersion(Number(e)||1)}if(t.ignoreDeclaration&&"?xml"===r.tagName||t.ignorePiTags);else{const e=new ia(r.tagName);e.add(t.textNodeName,""),r.tagName!==r.tagExp&&r.attrExpPresent&&!0!==t.ignoreAttributes&&(e[":@"]=s);const a=t.captureMetaData?to(A,n):A;this.addChild(i,e,this.readonlyMatcher,a),t.captureMetaData&&i.addEndIndex(to(r.closeIndex+2,n))}A=r.closeIndex+1}else if(33===l&&45===e.charCodeAt(A+2)&&45===e.charCodeAt(A+3)){const n=oo(e,"--\x3e",A+4,"Comment is not closed.");if(t.commentPropName){const r=e.substring(A+4,n-2);a=this.saveTextToParentTag(a,i,this.readonlyMatcher),i.add(t.commentPropName,[{[t.textNodeName]:r}])}A=n}else if(33===l&&68===e.charCodeAt(A+2)){if(this.doctypefound)throw new Error("Multiple DOCTYPE declarations found.");this.doctypefound=!0;const t=o.readDocType(e,A);this.entityDecoder.addInputEntities(t.entities),A=t.i}else if(33===l&&91===e.charCodeAt(A+2)){const n=oo(e,"]]>",A,"CDATA is not closed.")-2,r=e.substring(A+9,n);a=this.saveTextToParentTag(a,i,this.readonlyMatcher);let o=this.parseTextData(r,i.tagname,this.readonlyMatcher,!0,!1,!0,!0);null==o&&(o=""),t.cdataPropName?i.add(t.cdataPropName,[{[t.textNodeName]:r}]):i.add(t.textNodeName,o),A=n+2}else{let o=Ao(e,A,t.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 l=o.tagName;const c=o.rawTagName;let u=o.tagExp,f=o.attrExpPresent,d=o.closeIndex;if(({tagName:l,tagExp:u}=uo(t.transformTagName,l,u,t)),t.strictReservedNames&&(l===t.commentPropName||l===t.cdataPropName||l===t.textNodeName||l===t.attributesGroupName))throw new Error(`Invalid tag name: ${l}`);i&&a&&"!xml"!==i.tagname&&(a=this.saveTextToParentTag(a,i,this.readonlyMatcher,!1));const h=i;h&&t.unpairedTagsSet.has(h.tagname)&&(i=this.tagsNodeStack.pop(),this.matcher.pop());let p=!1;u.length>0&&u.lastIndexOf("/")===u.length-1&&(p=!0,"/"===l[l.length-1]?(l=l.substr(0,l.length-1),u=l):u=u.substr(0,u.length-1),f=l!==u);let m,g=null;m=Wa(c),l!==r.tagname&&this.matcher.push(l,{},m),l!==u&&f&&(g=this.buildAttributesMap(u,this.matcher,l),g&&Ka(g,t)),l!==r.tagname&&(this.isCurrentNodeStopNode=this.isItStopNode());const b=t.captureMetaData?to(A,n):A;if(this.isCurrentNodeStopNode){let r="";if(p)A=o.closeIndex;else if(t.unpairedTagsSet.has(l))A=o.closeIndex;else{const t=this.readStopNodeData(e,c,d+1);if(!t)throw new Error(`Unexpected end of ${c}`);A=t.i,r=t.tagContent}const a=new ia(l);g&&(a[":@"]=g),a.add(t.textNodeName,r),this.matcher.pop(),this.isCurrentNodeStopNode=!1,this.addChild(i,a,this.readonlyMatcher,b),t.captureMetaData&&i.addEndIndex(to(A+1,n))}else{if(p){({tagName:l,tagExp:u}=uo(t.transformTagName,l,u,t));const e=new ia(l);g&&(e[":@"]=g),this.addChild(i,e,this.readonlyMatcher,b),t.captureMetaData&&i.addEndIndex(to(d+1,n)),this.matcher.pop(),this.isCurrentNodeStopNode=!1}else{if(t.unpairedTagsSet.has(l)){const e=new ia(l);g&&(e[":@"]=g),this.addChild(i,e,this.readonlyMatcher,b),t.captureMetaData&&i.addEndIndex(to(o.closeIndex+1,n)),this.matcher.pop(),this.isCurrentNodeStopNode=!1,A=o.closeIndex;continue}{const e=new ia(l);if(this.tagsNodeStack.length>t.maxNestedTags)throw new Error("Maximum nested tags exceeded");this.tagsNodeStack.push(i),g&&(e[":@"]=g),this.addChild(i,e,this.readonlyMatcher,b),i=e}}a="",A=d}}}else a+=e[A];return r.child};function to(e,t){let n=0,r=t.length;for(;n<r;){const i=Math.floor((n+r)/2);t[i]<e?n=i+1:r=i}return e+n}function no(e,t,n,r){this.options.captureMetaData||(r=void 0);const i=this.options.jPath?n.toString():n,a=this.options.updateTag(t.tagname,i,t[":@"]);!1===a||("string"==typeof a?(t.tagname=a,e.addChild(t,r)):e.addChild(t,r))}function ro(e,t,n){const r=this.options.processEntities;if(!r||!r.enabled)return e;if(r.allowedTags){const i=this.options.jPath?n.toString():n;if(!(Array.isArray(r.allowedTags)?r.allowedTags.includes(t):r.allowedTags(t,i)))return e}if(r.tagFilter){const i=this.options.jPath?n.toString():n;if(!r.tagFilter(t,i))return e}return this.entityDecoder.decode(e)}function io(e,t,n,r){return e&&(void 0===r&&(r=0===t.child.length),void 0!==(e=this.parseTextData(e,t.tagname,n,!1,!!t[":@"]&&0!==Object.keys(t[":@"]).length,r))&&""!==e&&t.add(this.options.textNodeName,e),e=""),e}function ao(){return 0!==this.stopNodeExpressionsSet.size&&this.matcher.matchesAny(this.stopNodeExpressionsSet)}function oo(e,t,n,r){const i=e.indexOf(t,n);if(-1===i)throw new Error(r);return i+t.length-1}function so(e,t,n,r){const i=e.indexOf(t,n);if(-1===i)throw new Error(r);return i}function Ao(e,t,n,r=">"){const i=function(e,t,n=">"){let r=0;const i=e.length,a=n.charCodeAt(0),o=n.length>1?n.charCodeAt(1):-1;let s="",A=t;for(let l=t;l<i;l++){const t=e.charCodeAt(l);if(r)t===r&&(r=0);else if(34===t||39===t)r=t;else if(t===a){if(-1===o)return s+=e.substring(A,l),{data:s,index:l};if(e.charCodeAt(l+1)===o)return s+=e.substring(A,l),{data:s,index:l}}else 9!==t||r||(s+=e.substring(A,l)+" ",A=l+1)}}(e,t+1,r);if(!i)return;let a=i.data;const o=i.index,s=a.search(/\s/);let A=a,l=!0;-1!==s&&(A=a.substring(0,s),a=a.substring(s+1).trimStart());const c=A;if(n){const e=A.indexOf(":");-1!==e&&(A=A.substr(e+1),l=A!==i.data.substr(e+1))}return{tagName:A,tagExp:a,closeIndex:o,attrExpPresent:l,rawTagName:c}}function lo(e,t,n){const r=n;let i=1,a=!1,o=-1;const s=e.length;for(;n<s;n++)if("<"===e[n]){const s=e.charCodeAt(n+1);if(47===s){const a=so(e,">",n,`${t} is not closed`);if(e.substring(n+2,a).trim()===t&&(i--,0===i))return{tagContent:e.substring(r,n),i:a};n=a}else if(63===s)n=oo(e,"?>",n+1,"StopNode is not closed.");else if(33===s&&45===e.charCodeAt(n+2)&&45===e.charCodeAt(n+3))n=oo(e,"--\x3e",n+3,"StopNode is not closed.");else if(33===s&&91===e.charCodeAt(n+2))n=oo(e,"]]>",n,"StopNode is not closed.")-2;else{const r=a?void 0:Ao(e,n,!1);if(r)r.tagName===t&&"/"!==r.tagExp[r.tagExp.length-1]&&i++,n=r.closeIndex;else{if(a=!0,o<n&&(o=e.indexOf(">",n),-1===o))return;const r=e.indexOf("<",n+1);if(-1===r||r>o){const r=e.substring(n+1,o),a=r.search(/\s/);(-1===a?r:r.substring(0,a))===t&&"/"!==r[r.length-1]&&i++,n=o}}}}}function co(e,t,n){if(t&&"string"==typeof e){const t=e.trim();return"true"===t||"false"!==t&&Sa(e,n)}return function(e){return void 0!==e}(e)?e:""}function uo(e,t,n,r){if(e){const r=e(t);n===t&&(n=r),t=r}return{tagName:t=fo(t,r),tagExp:n}}function fo(e,t){if(Ti.includes(e))throw new Error(`[SECURITY] Invalid name: "${e}" is a reserved JavaScript keyword that could cause prototype pollution`);return wi.includes(e)?t.onDangerousProperty(e):e}var ho=ia.getMetaDataSymbol();function po(e,t){if(!e||"object"!=typeof e)return{};if(!t)return e;const n={};for(const r in e)if(r.startsWith(t)){n[r.substring(t.length)]=e[r]}else n[r]=e[r];return n}function mo(e,t,n,r){return go(e,t,n,r)}function go(e,t,n,r){let i;const a={};for(let o=0;o<e.length;o++){const s=e[o],A=bo(s);if(void 0!==A&&A!==t.textNodeName){const e=po(s[":@"]||{},t.attributeNamePrefix);n.push(A,e)}if(A===t.textNodeName)void 0===i?i=s[A]:i+=""+s[A];else{if(void 0===A)continue;if(s[A]){let e=go(s[A],t,n,r);const i=yo(e,t);if(0===Object.keys(e).length&&t.alwaysCreateTextNode&&(e[t.textNodeName]=""),s[":@"]?vo(e,s[":@"],r,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!==s[ho]&&"object"==typeof e&&null!==e&&(e[ho]=s[ho]),void 0!==a[A]&&Object.prototype.hasOwnProperty.call(a,A))Array.isArray(a[A])||(a[A]=[a[A]]),a[A].push(e);else{const n=t.jPath?r.toString():r;t.isArray(A,n,i)?a[A]=[e]:a[A]=e}void 0!==A&&A!==t.textNodeName&&n.pop()}}}return"string"==typeof i?i.length>0&&(a[t.textNodeName]=i):void 0!==i&&(a[t.textNodeName]=i),a}function bo(e){const t=Object.keys(e);for(let n=0;n<t.length;n++){const e=t[n];if(":@"!==e)return e}}function vo(e,t,n,r){if(t){const i=Object.keys(t),a=i.length;for(let o=0;o<a;o++){const a=i[o],s=a.startsWith(r.attributeNamePrefix)?a.substring(r.attributeNamePrefix.length):a,A=r.jPath?n.toString()+"."+s:n;r.isArray(a,A,!0,!0)?e[a]=[t[a]]:e[a]=t[a]}}}function yo(e,t){const{textNodeName:n}=t,r=Object.keys(e).length;return 0===r||!(1!==r||!e[n]&&"boolean"!=typeof e[n]&&0!==e[n])}var xo=class{constructor(e){this.externalEntities={},this.options=ra(e)}parse(e,t){if("string"!=typeof e&&e.toString)e=e instanceof Uint8Array&&("undefined"==typeof Buffer||!Buffer.isBuffer(e))?new TextDecoder("utf-8",{ignoreBOM:!0}).decode(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({},Si,t);const n=[];let r=!1,i=!1;"\ufeff"===e[0]&&(e=e.substr(1));for(let a=0;a<e.length;a++)if("<"===e[a]&&"?"===e[a+1]){if(a+=2,a=Ei(e,a),a.err)return a}else{if("<"!==e[a]){if(Mi(e[a]))continue;return Li("InvalidChar","char '"+e[a]+"' is not expected.",Fi(e,a))}{let o=a;if(a++,"!"===e[a]){a=Ci(e,a);continue}{let s=!1;"/"===e[a]&&(s=!0,a++);let A="";for(;a<e.length&&">"!==e[a]&&" "!==e[a]&&"\t"!==e[a]&&"\n"!==e[a]&&"\r"!==e[a];a++)A+=e[a];if(A=A.trim(),"/"===A[A.length-1]&&(A=A.substring(0,A.length-1),a--),!Oi(A)){let t;return t=0===A.trim().length?"Invalid space after '<'.":"Tag '"+A+"' is an invalid name.",Li("InvalidTag",t,Fi(e,a))}const l=Pi(e,a);if(!1===l)return Li("InvalidAttr","Attributes for '"+A+"' have open quote.",Fi(e,a));let c=l.value;if(a=l.index,"/"===c[c.length-1]){const n=a-c.length;c=c.substring(0,c.length-1);const i=Ni(c,t);if(!0!==i)return Li(i.err.code,i.err.msg,Fi(e,n+i.err.line));r=!0}else if(s){if(!l.tagClosed)return Li("InvalidTag","Closing tag '"+A+"' doesn't have proper closing.",Fi(e,a));if(c.trim().length>0)return Li("InvalidTag","Closing tag '"+A+"' can't have attributes or invalid starting.",Fi(e,o));if(0===n.length)return Li("InvalidTag","Closing tag '"+A+"' has not been opened.",Fi(e,o));{const t=n.pop();if(A!==t.tagName){let n=Fi(e,t.tagStartPos);return Li("InvalidTag","Expected closing tag '"+t.tagName+"' (opened in line "+n.line+", col "+n.col+") instead of closing tag '"+A+"'.",Fi(e,o))}0==n.length&&(i=!0)}}else{const s=Ni(c,t);if(!0!==s)return Li(s.err.code,s.err.msg,Fi(e,a-c.length+s.err.line));if(!0===i)return Li("InvalidXml","Multiple possible root nodes found.",Fi(e,a));-1!==t.unpairedTags.indexOf(A)||n.push({tagName:A,tagStartPos:o}),r=!0}for(a++;a<e.length;a++)if("<"===e[a]){if("!"===e[a+1]){a++,a=Ci(e,a);continue}if("?"!==e[a+1])break;if(a=Ei(e,++a),a.err)return a}else if("&"===e[a]){const t=ki(e,a);if(-1==t)return Li("InvalidChar","char '&' is not expected.",Fi(e,a));a=t}else if(!0===i&&!Mi(e[a]))return Li("InvalidXml","Extra text at the end",Fi(e,a));"<"===e[a]&&a--}}}return r?1==n.length?Li("InvalidTag","Unclosed tag '"+n[0].tagName+"'.",Fi(e,n[0].tagStartPos)):!(n.length>0)||Li("InvalidXml","Invalid '"+JSON.stringify(n.map(e=>e.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1}):Li("InvalidXml","Start tag expected.",1)}(e,t);if(!0!==n)throw Error(`${n.err.msg}:${n.err.line}:${n.err.col}`)}const n=new $a(this.options,this.externalEntities),r=n.parseXml(e);return this.options.preserveOrder||void 0===r?r:mo(r,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 ia.getMetaDataSymbol()}};function _o(e,t){if(t?._parser&&"fast-xml-parser"!==t._parser)throw new Error(t?._parser);const n=function(e,t){return new xo({ignoreAttributes:!1,attributeNamePrefix:"",...t}).parse(e)}(e,{allowBooleanAttributes:!0,ignoreDeclaration:!0,removeNSPrefix:t?.removeNSPrefix,textNodeName:t?.textNodeName,isArray:(e,n,r,i)=>Boolean(t?.arrayPaths?.some(e=>n===e)),...t?._fastXML});return t?.uncapitalizeKeys?yi(n):n}var wo={dataType:null,batchType:null,name:"XML",id:"xml",module:"xml",version:"4.5.4",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)=>_o((new TextDecoder).decode(e),{...wo.options.xml,...t?.xml}),parseTextSync:(e,t)=>_o(e,{...wo.options.xml,...t?.xml})};var To={dataType:null,batchType:null,id:"wms-error",name:"WMS Error",module:"wms",version:"4.5.4",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)=>So((new TextDecoder).decode(e),t),parseSync:(e,t)=>So((new TextDecoder).decode(e),t),parseTextSync:(e,t)=>So(e,t)};function So(e,t){const n={...To.options.wms,...t?.wms},r=function(e,t){const n=wo.parseTextSync?.(e,t),r=n?.ServiceExceptionReport?.ServiceException||n?.["ogc:ServiceExceptionReport"]?.["ogc:ServiceException"];return"string"==typeof r?r:r.value||r.code||"Unknown error"}(e,n),i=n.minimalErrors?r:`WMS Service error: ${r}`;if(n.throwOnError)throw new Error(i);return i}function Mo(e){return Array.isArray(e)?e:e?[e]:[]}function Eo(e){const t=Mo(e);return t.length>0&&t.every(e=>"string"==typeof e)?t:[]}function Co(e,t=void 0){switch(typeof e){case"number":return e;case"string":return parseFloat(e);default:return}}function Io(e,t=void 0){switch(typeof e){case"number":return e;case"string":return parseInt(e,10);default:return}}function Ro(e){switch(e){case"true":case"1":return!0;default:return!1}}function Po(e,t){const n=wo.parseTextSync?.(e,t),r=n.WMT_MS_Capabilities||n.WMS_Capabilities||n,i=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:Eo(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:Io(e.Service?.LayerLimit),maxWidth:Io(e.Service?.maxWidth),maxHeight:Io(e.Service?.maxHeight),layers:[],requests:No(e.Capability?.Request),exceptions:ko(e.Exception)},n=Mo(e.Capability?.Layer);for(const r of n)t.layers.push(Lo(r));for(const[r,i]of Object.entries(t))void 0===i&&delete t[r];return t}(r);if(t?.inheritedLayerProps)for(const a of i.layers)Bo(a,null);return t?.includeRawJSON&&(i.json=r),t?.includeXMLText&&(i.xml=e),i}function No(e){const t={};for(const[n,r]of Object.entries(e||{}))t[n]={mimeTypes:Eo(r?.Format)};return t}function ko(e){if(Mo(e?.Format).length>0)return{mimeTypes:Eo(e)}}function Lo(e){const t={title:String(e?.Title||""),name:e?.Name&&String(e?.Name),abstract:e?.Name&&String(e?.Abstract),keywords:Eo(e.KeywordList?.Keyword)},n=e?.CRS||e?.SRS;n&&Array.isArray(n)&&n.every(e=>"string"==typeof e)&&(t.crs=n);let r=e?.EX_GeographicBoundingBox&&function(e){const{westBoundLongitude:t,northBoundLatitude:n,eastBoundLongitude:r,southBoundLatitude:i}=e;return[[t,i],[r,n]]}(e?.EX_GeographicBoundingBox);r&&(t.geographicBoundingBox=r),r=e?.LatLonBoundingBox&&function(e){const{minx:t,miny:n,maxx:r,maxy:i}=e;return[[t,n],[r,i]]}(e?.LatLonBoundingBox),r&&(t.geographicBoundingBox=r);const i=e?.BoundingBox&&(a=e?.BoundingBox,Mo(a).map(e=>function(e){const{CRS:t,SRS:n,minx:r,miny:i,maxx:a,maxy:o,resx:s,resy:A}=e,l={crs:t||n,boundingBox:[[Co(r),Co(i)],[Co(a),Co(o)]]};return s&&(l.xResolution=s),A&&(l.yResolution=A),l}(e)));var a;i&&i.length>0&&(t.boundingBoxes=i);const o=Mo(e?.Dimension).map(e=>function(e){const{name:t,units:n,value:r}=e,i={name:t,units:n,extent:r};e.unitSymbol&&(i.unitSymbol=e.unitSymbol);e.default&&(i.defaultValue=e.default);e.multipleValues&&(i.multipleValues=Ro(e.multipleValues));e.nearestValue&&(i.nearestValue=Ro(e.nearestValue));e.current&&(i.current=Ro(e.current));return i}(e));o.length&&(t.dimensions=o),e?.opaque&&(t.opaque=Ro(e?.opaque)),e?.cascaded&&(t.cascaded=Ro(e?.cascaded)),e?.queryable&&(t.queryable=Ro(e?.queryable));const s=Mo(e?.Layer),A=[];for(const l of s)A.push(Lo(l));A.length>0&&(t.layers=A);for(const[l,c]of Object.entries(t))void 0===c&&delete t[l];return t}function Bo(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||[])Bo(n,e)}var Oo={dataType:null,batchType:null,id:"wms-capabilities",name:"WMS Capabilities",module:"wms",version:"4.5.4",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)=>Po((new TextDecoder).decode(e),t?.wms),parseTextSync:(e,t)=>Po(e,t?.wms)};function Fo(e,t){const n=(wo.parseTextSync?.(e,t)).FeatureInfoResponse?.FIELDS||[];return{features:(Array.isArray(n)?n:[n]).map(e=>function(e){return{attributes:e||{},type:"",bounds:{bottom:0,top:0,left:0,right:0}}}(e))}}var Do={...Oo,dataType:null,id:"wms-feature-info",name:"WMS FeatureInfo",parse:async(e,t)=>Fo((new TextDecoder).decode(e),t),parseTextSync:(e,t)=>Fo(e,t)};function Uo(e,t){return wo.parseTextSync?.(e,t)}var Vo={...Oo,dataType:null,id:"wms-layer-description",name:"WMS DescribeLayer",parse:async(e,t)=>Uo((new TextDecoder).decode(e),t),parseTextSync:(e,t)=>Uo(e,t)},jo={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 zo(e,t)},zo=class extends b{substituteCRS84;flipCRS;wmsParameters;vendorParameters;capabilities=null;constructor(e,t){super(e,t,jo.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,...r}=e,i={bbox:t?[...t[0],...t[1]]:n,...r};return await this.getMap(i)}normalizeMetadata(e){return e}async getCapabilities(e,t){const n=this.getCapabilitiesURL(e,t),r=await this.fetch(n),i=await r.arrayBuffer();this._checkResponse(r,i);const a=await Oo.parse(i,this.loadOptions);return this.capabilities=a,a}async getMap(e,t){const n=this.getMapURL(e,t),i=await this.fetch(n),a=await i.arrayBuffer();this._checkResponse(i,a);try{return await r.ImageLoader.parse(a,this.loadOptions)}catch{throw this._parseError(a)}}async getFeatureInfo(e,t){const n=this.getFeatureInfoURL(e,t),r=await this.fetch(n),i=await r.arrayBuffer();return this._checkResponse(r,i),await Do.parse(i,this.loadOptions)}async getFeatureInfoText(e,t){const n=this.getFeatureInfoURL(e,t),r=await this.fetch(n),i=await r.arrayBuffer();return this._checkResponse(r,i),(new TextDecoder).decode(i)}async describeLayer(e,t){const n=this.describeLayerURL(e,t),r=await this.fetch(n),i=await r.arrayBuffer();return this._checkResponse(r,i),await Vo.parse(i,this.loadOptions)}async getLegendGraphic(e,t){const n=this.getLegendGraphicURL(e,t),i=await this.fetch(n),a=await i.arrayBuffer();this._checkResponse(i,a);try{return await r.ImageLoader.parse(a,this.loadOptions)}catch{throw this._parseError(a)}}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:r}=e;e.bbox=n?[...n[0],...n[1]]:r;const i={version:this.wmsParameters.version,info_format:this.wmsParameters.info_format,layers:this.wmsParameters.layers,query_layers:this.wmsParameters.query_layers,styles:this.wmsParameters.styles,crs:this.wmsParameters.crs,...e};return this._getWMSUrl("GetFeatureInfo",i,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("?"),r=n.split("&"),i={};for(const a of r){const[e,t]=a.split("=");i[e]=t}return{url:t,parameters:i}}_getWMSUrl(e,t,n){let r=this.url,i=!0;const a={service:"WMS",version:t.version,request:e,...t,...this.vendorParameters,...n},o=["transparent","time","elevation"];for(const[s,A]of Object.entries(a))o.includes(s)&&!A||(r+=i?"?":"&",i=!1,r+=this._getURLParameter(s,A,t));return encodeURI(r)}_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 r=this._flipBoundingBox(t,n);r&&(t=r);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 r=e.headers["content-type"];if(!e.ok||To.mimeTypes.includes(r)){const e=n.mergeOptions(this.loadOptions,{wms:{throwOnError:!0}}),r=To.parseSync?.(t,e);throw new Error(r)}}_parseError(e){const t=To.parseSync?.(e,this.options.core?.loadOptions);return new Error(t)}},Go=6378137*Math.PI;function Ho(e){const t=n.lngLatToWorld(e);return t[0]=(t[0]/256-1)*Go,t[1]=(t[1]/256-1)*Go,t}var qo={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)=>console.error(t,e)}},Qo=class extends t.CompositeLayer{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:r}){const{viewport:i}=this.context;e.dataChanged||t.serviceType!==r.serviceType?(this.state.imageSource=this._createImageSource(t),this._loadMetadata(),this.debounce(()=>this.loadImage(i,"image source changed"),0)):n.deepEqual(t.layers,r.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:r,lastRequestParameters:i}=this.state;return r&&new t.BitmapLayer({...this.getSubLayerProps({id:"bitmap"}),_imageCoordinateSystem:"EPSG:4326"===i.srs?n.COORDINATE_SYSTEM.LNGLAT:n.COORDINATE_SYSTEM.CARTESIAN,bounds:e,image:r})}async getFeatureInfoText(e,t){const{lastRequestParameters:n}=this.state;return n?await(this.state.imageSource.getFeatureInfoText?.({...n,query_layers:n.layers,x:e,y:t,info_format:"application/vnd.ogc.gml"})):""}_createImageSource(e){if(e.data instanceof v)return e.data;if("string"==typeof e.data)return function(e,t,n){const r=n?.core?.type||n.type||"auto",i="auto"===r?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}(r,t);if(!i)throw new Error("Not a valid source type");return i.createDataSource(e,n)}(e.data,[jo],{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:r}=this.props;if("wms"===r&&0===n.length)return;const i=e.getBounds(),{width:a,height:o}=e,s=this.getRequestId();let{srs:A}=this.props;"auto"===A&&(A=e.resolution?"EPSG:4326":"EPSG:3857");const l={width:a,height:o,boundingBox:[[i[0],i[1]],[i[2],i[3]]],layers:n,crs:A};"EPSG:3857"===A&&(l.boundingBox=[Ho([i[0],i[1]]),Ho([i[2],i[3]])]);try{this.state.loadCounter++,this.props.onImageLoadStart(s);const e=await this.state.imageSource.getImage(l);this.state.lastRequestId<s&&(this.getCurrentLayer()?.props.onImageLoad(s),this.setState({image:e,bounds:i,lastRequestParameters:l,lastRequestId:s}))}catch(c){this.raiseError(c,"Load image"),this.getCurrentLayer()?.props.onImageLoadError(s,c)}finally{this.state.loadCounter--}}getRequestId(){return this.state._nextRequestId++}debounce(e,t=500){clearTimeout(this.state._timeoutId),this.state._timeoutId=setTimeout(()=>e(),t)}};Qo.layerName="WMSLayer",Qo.defaultProps=qo;var Ko=class extends t.ArcLayer{};Ko.layerName="GreatCircleLayer",Ko.defaultProps={getHeight:{type:"accessor",value:0},greatCircle:!0};var Wo=e.__commonJSMin((e,t,n)=>{!function(e,n){"function"==typeof define&&define.amd?define([],n):"function"==typeof require&&"object"==typeof t&&t&&t.exports?t.exports=n():(e.dcodeIO=e.dcodeIO||{}).Long=n()}(n,function(){"use strict";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={},r={};function i(e,t){var i,a,s;return t?(s=0<=(e>>>=0)&&e<256)&&(a=r[e])?a:(i=o(e,(0|e)<0?-1:0,!0),s&&(r[e]=i),i):(s=-128<=(e|=0)&&e<128)&&(a=n[e])?a:(i=o(e,e<0?-1:0,!1),s&&(n[e]=i),i)}function a(e,t){if(isNaN(e)||!isFinite(e))return t?p:h;if(t){if(e<0)return p;if(e>=u)return y}else{if(e<=-f)return x;if(e+1>=f)return v}return e<0?a(-e,t).neg():o(e%c|0,e/c|0,t)}function o(t,n,r){return new e(t,n,r)}e.fromInt=i,e.fromNumber=a,e.fromBits=o;var s=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 h;if("number"==typeof t?(n=t,t=!1):t=!!t,(n=n||10)<2||36<n)throw RangeError("radix");var r;if((r=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===r)return A(e.substring(1),t,n).neg();for(var i=a(s(n,8)),o=h,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=a(s(n,c));o=o.mul(f).add(a(u))}else o=(o=o.mul(i)).add(a(u))}return o.unsigned=t,o}function l(t){return t instanceof e?t:"number"==typeof t?a(t):"string"==typeof t?A(t):o(t.low,t.high,t.unsigned)}e.fromString=A,e.fromValue=l;var c=4294967296,u=c*c,f=u/2,d=i(1<<24),h=i(0);e.ZERO=h;var p=i(0,!0);e.UZERO=p;var m=i(1);e.ONE=m;var g=i(1,!0);e.UONE=g;var b=i(-1);e.NEG_ONE=b;var v=o(-1,2147483647,!1);e.MAX_VALUE=v;var y=o(-1,-1,!0);e.MAX_UNSIGNED_VALUE=y;var x=o(0,-2147483648,!1);e.MIN_VALUE=x;var _=e.prototype;return _.toInt=function(){return this.unsigned?this.low>>>0:this.low},_.toNumber=function(){return this.unsigned?(this.high>>>0)*c+(this.low>>>0):this.high*c+(this.low>>>0)},_.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(x)){var t=a(e),n=this.div(t),r=n.mul(t).sub(this);return n.toString(e)+r.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var i=a(s(e,6),this.unsigned),o=this,A="";;){var l=o.div(i),c=(o.sub(l.mul(i)).toInt()>>>0).toString(e);if((o=l).isZero())return c+A;for(;c.length<6;)c="0"+c;A=""+c+A}},_.getHighBits=function(){return this.high},_.getHighBitsUnsigned=function(){return this.high>>>0},_.getLowBits=function(){return this.low},_.getLowBitsUnsigned=function(){return this.low>>>0},_.getNumBitsAbs=function(){if(this.isNegative())return this.eq(x)?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},_.isZero=function(){return 0===this.high&&0===this.low},_.isNegative=function(){return!this.unsigned&&this.high<0},_.isPositive=function(){return this.unsigned||this.high>=0},_.isOdd=function(){return!(1&~this.low)},_.isEven=function(){return!(1&this.low)},_.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)},_.eq=_.equals,_.notEquals=function(e){return!this.eq(e)},_.neq=_.notEquals,_.lessThan=function(e){return this.comp(e)<0},_.lt=_.lessThan,_.lessThanOrEqual=function(e){return this.comp(e)<=0},_.lte=_.lessThanOrEqual,_.greaterThan=function(e){return this.comp(e)>0},_.gt=_.greaterThan,_.greaterThanOrEqual=function(e){return this.comp(e)>=0},_.gte=_.greaterThanOrEqual,_.compare=function(e){if(t(e)||(e=l(e)),this.eq(e))return 0;var n=this.isNegative(),r=e.isNegative();return n&&!r?-1:!n&&r?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},_.comp=_.compare,_.negate=function(){return!this.unsigned&&this.eq(x)?x:this.not().add(m)},_.neg=_.negate,_.add=function(e){t(e)||(e=l(e));var n=this.high>>>16,r=65535&this.high,i=this.low>>>16,a=65535&this.low,s=e.high>>>16,A=65535&e.high,c=e.low>>>16,u=0,f=0,d=0,h=0;return d+=(h+=a+(65535&e.low))>>>16,f+=(d+=i+c)>>>16,u+=(f+=r+A)>>>16,u+=n+s,o((d&=65535)<<16|(h&=65535),(u&=65535)<<16|(f&=65535),this.unsigned)},_.subtract=function(e){return t(e)||(e=l(e)),this.add(e.neg())},_.sub=_.subtract,_.multiply=function(e){if(this.isZero())return h;if(t(e)||(e=l(e)),e.isZero())return h;if(this.eq(x))return e.isOdd()?x:h;if(e.eq(x))return this.isOdd()?x:h;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(d)&&e.lt(d))return a(this.toNumber()*e.toNumber(),this.unsigned);var n=this.high>>>16,r=65535&this.high,i=this.low>>>16,s=65535&this.low,A=e.high>>>16,c=65535&e.high,u=e.low>>>16,f=65535&e.low,p=0,m=0,g=0,b=0;return g+=(b+=s*f)>>>16,m+=(g+=i*f)>>>16,g&=65535,m+=(g+=s*u)>>>16,p+=(m+=r*f)>>>16,m&=65535,p+=(m+=i*u)>>>16,m&=65535,p+=(m+=s*c)>>>16,p+=n*f+r*u+i*c+s*A,o((g&=65535)<<16|(b&=65535),(p&=65535)<<16|(m&=65535),this.unsigned)},_.mul=_.multiply,_.divide=function(e){if(t(e)||(e=l(e)),e.isZero())throw Error("division by zero");if(this.isZero())return this.unsigned?p:h;var n,r,i;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return p;if(e.gt(this.shru(1)))return g;i=p}else{if(this.eq(x))return e.eq(m)||e.eq(b)?x:e.eq(x)?m:(n=this.shr(1).div(e).shl(1)).eq(h)?e.isNegative()?m:b:(r=this.sub(e.mul(n)),i=n.add(r.div(e)));if(e.eq(x))return this.unsigned?p:h;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=h}for(r=this;r.gte(e);){n=Math.max(1,Math.floor(r.toNumber()/e.toNumber()));for(var o=Math.ceil(Math.log(n)/Math.LN2),A=o<=48?1:s(2,o-48),c=a(n),u=c.mul(e);u.isNegative()||u.gt(r);)u=(c=a(n-=A,this.unsigned)).mul(e);c.isZero()&&(c=m),i=i.add(c),r=r.sub(u)}return i},_.div=_.divide,_.modulo=function(e){return t(e)||(e=l(e)),this.sub(this.div(e).mul(e))},_.mod=_.modulo,_.not=function(){return o(~this.low,~this.high,this.unsigned)},_.and=function(e){return t(e)||(e=l(e)),o(this.low&e.low,this.high&e.high,this.unsigned)},_.or=function(e){return t(e)||(e=l(e)),o(this.low|e.low,this.high|e.high,this.unsigned)},_.xor=function(e){return t(e)||(e=l(e)),o(this.low^e.low,this.high^e.high,this.unsigned)},_.shiftLeft=function(e){return t(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?o(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):o(0,this.low<<e-32,this.unsigned)},_.shl=_.shiftLeft,_.shiftRight=function(e){return t(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?o(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):o(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},_.shr=_.shiftRight,_.shiftRightUnsigned=function(e){if(t(e)&&(e=e.toInt()),0===(e&=63))return this;var n=this.high;return e<32?o(this.low>>>e|n<<32-e,n>>>e,this.unsigned):o(32===e?n:n>>>e-32,0,this.unsigned)},_.shru=_.shiftRightUnsigned,_.toSigned=function(){return this.unsigned?o(this.low,this.high,!1):this},_.toUnsigned=function(){return this.unsigned?this:o(this.low,this.high,!0)},_.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},_.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]},_.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})}),$o=e.__toESM(Wo(),1),Jo=180/Math.PI;function Yo(e,t,n){const r=1<<t;return[(e[0]+n[0])/r,(e[1]+n[1])/r]}function Xo(e){return e>=.5?1/3*(4*e*e-1):1/3*(1-4*(1-e)*(1-e))}function Zo(e){return[Xo(e[0]),Xo(e[1])]}function es(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 ts([e,t,n]){const r=Math.atan2(n,Math.sqrt(e*e+t*t));return[Math.atan2(t,e)*Jo,r*Jo]}function ns(e,t,n,r){if(0===r){1===n&&(t[0]=e-1-t[0],t[1]=e-1-t[1]);const r=t[0];t[0]=t[1],t[1]=r}}function rs(e){if("string"==typeof e){if(e.indexOf("/")>0)return e;e=function(e){const t=e.padEnd(16,"0");return $o.default.fromString(t,16)}(e)}return function(e){let t=$o.default.fromString(e,!0,10).toString(2);for(;t.length<64;)t="0"+t;const n=t.lastIndexOf("1"),r=t.substring(0,3),i=t.substring(3,n),a=i.length/2,o=$o.default.fromString(r,!0,2).toString(10);let s=$o.default.fromString(i,!0,2).toString(4);for(;s.length<a;)s="0"+s;return`${o}/${s}`}(e.toString())}function is(e){return function({face:e,ij:t,level:n}){const r=[[0,0],[0,1],[1,1],[1,0],[0,0]],i=Math.max(1,Math.ceil(100*Math.pow(2,-n))),a=new Float64Array(4*i*2+2);let o=0,s=0;for(let A=0;A<4;A++){const l=r[A].slice(0),c=r[A+1],u=(c[0]-l[0])/i,f=(c[1]-l[1])/i;for(let r=0;r<i;r++){l[0]+=u,l[1]+=f;const r=ts(es(e,Zo(Yo(t,n,l))));Math.abs(r[1])>89.999&&(r[0]=s);const i=r[0]-s;r[0]+=i>180?-360:i<-180?360:0,a[o++]=r[0],a[o++]=r[1],s=r[0]}}return a[o++]=a[0],a[o++]=a[1],a}(function(e){const t=e.split("/"),n=parseInt(t[0],10),r=t[1],i=r.length,a=[0,0];let o;for(let s=i-1;s>=0;s--){o=i-s;const e=r[s];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);ns(A,a,t,n),a[0]+=A*t,a[1]+=A*n}if(n%2==1){const e=a[0];a[0]=a[1],a[1]=e}return{face:n,ij:a,level:o}}(rs(e)))}var as=class extends st{indexToBounds(){const{data:e,getS2Token:t}=this.props;return{data:e,_normalize:!1,positionFormat:"XY",getPolygon:(e,n)=>is(t(e,n))}}};as.layerName="S2Layer",as.defaultProps={getS2Token:{type:"accessor",value:e=>e.token}};function os(e,t=1){const[r,i]=function(e,t){let n=0,r=0,i=1<<e.length;const a=i/512;for(let o=0;o<e.length;o++){i>>=1;const t=parseInt(e[o]);t%2&&(n|=i),t>1&&(r|=i)}return[[n/a,512-r/a],[(n+t)/a,512-(r+t)/a]]}(e,t),[a,o]=n.worldToLngLat(r),[s,A]=n.worldToLngLat(i);return[s,o,s,A,a,A,a,o,s,o]}var ss=class extends st{indexToBounds(){const{data:e,extruded:t,getQuadkey:n}=this.props,r=t?.99:1;return{data:e,_normalize:!1,positionFormat:"XY",getPolygon:(e,t)=>os(n(e,t),r),updateTriggers:{getPolygon:r}}}};ss.layerName="QuadkeyLayer",ss.defaultProps={getQuadkey:{type:"accessor",value:e=>e.quadkey}};var As=class{constructor(e){this.index=e,this.isVisible=!1,this.isSelected=!1,this.parent=null,this.children=[],this.content=null,this._loader=void 0,this._abortController=null,this._loaderId=0,this._isLoaded=!1,this._isCancelled=!1,this._needsReload=!1}get bbox(){return this._bbox}set bbox(e){this._bbox||(this._bbox=e,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)||console.error("byteLength not defined in tile data"),e}async _loadData({getData:e,getRequestPriority:t,requestScheduler:n,onLoad:r,onError:i}){const{index:a,id:o,bbox:s,userData:A,zoom:l}=this,c=this._loaderId;this._abortController=new AbortController;const{signal:u}=this._abortController,f=await n.scheduleRequest(this,t);if(!f)return void(this._isCancelled=!0);if(this._isCancelled)return void f.done();let d,h=null;try{h=await e({index:a,id:o,bbox:s,userData:A,zoom:l,signal:u})}catch(p){d=p||!0}finally{f.done()}c===this._loaderId&&(this._loader=void 0,this.content=h,!this._isCancelled||h?(this._isLoaded=!0,this._isCancelled=!1,d?i(d,this):r(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())}},ls=-1,cs=0,us=1,fs=new n.Vector3,ds=new n.Vector3,hs=class e{constructor(e=[0,0,0],t=[0,0,0],r){r=r||fs.copy(e).add(t).scale(.5),this.center=new n.Vector3(r),this.halfDiagonal=new n.Vector3(t).subtract(this.center),this.minimum=new n.Vector3(e),this.maximum=new n.Vector3(t)}clone(){return new e(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=ds.from(e.normal),r=t.x*Math.abs(n.x)+t.y*Math.abs(n.y)+t.z*Math.abs(n.z),i=this.center.dot(n)+e.distance;return i-r>0?us:i+r<0?ls:cs}distanceTo(e){return Math.sqrt(this.distanceSquaredTo(e))}distanceSquaredTo(e){const t=fs.from(e).subtract(this.center),{halfDiagonal:n}=this;let r,i=0;return r=Math.abs(t.x)-n.x,r>0&&(i+=r*r),r=Math.abs(t.y)-n.y,r>0&&(i+=r*r),r=Math.abs(t.z)-n.z,r>0&&(i+=r*r),i}},ps=new n.Vector3,ms=new n.Vector3,gs=class e{constructor(e=[0,0,0],t=0){this.radius=-0,this.center=new n.Vector3,this.fromCenterRadius(e,t)}fromCenterRadius(e,t){return this.center.from(e),this.radius=t,this}fromCornerPoints(e,t){return t=ps.from(t),this.center=(new n.Vector3).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 e(this.center,this.radius)}union(e){const t=this.center,n=this.radius,r=e.center,i=e.radius,a=ps.copy(r).subtract(t),o=a.magnitude();if(n>=o+i)return this.clone();if(i>=o+n)return e.clone();const s=.5*(n+o+i);return ms.copy(a).scale((-n+s)/o).add(t),this.center.copy(ms),this.radius=s,this}expand(e){const t=ps.from(e).subtract(this.center).magnitude();return t>this.radius&&(this.radius=t),this}transform(e){this.center.transform(e);const t=n.getScaling(ps,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=ps.from(e).subtract(this.center);return Math.max(0,t.len()-this.radius)}intersectPlane(e){const t=this.center,n=this.radius,r=e.normal.dot(t)+e.distance;return r<-n?ls:r<n?cs:us}},bs=new n.Vector3,vs=new n.Vector3,ys=new n.Vector3,xs=new n.Vector3,_s=new n.Vector3,ws=new n.Vector3,Ts=new n.Vector3,Ss=0,Ms=1,Es=2,Cs=3,Is=4,Rs=5,Ps=6,Ns=7,ks=8,Ls=class e{constructor(e=[0,0,0],t=[0,0,0,0,0,0,0,0,0]){this.center=(new n.Vector3).from(e),this.halfAxes=new L(t)}get halfSize(){const e=this.halfAxes.getColumn(0),t=this.halfAxes.getColumn(1),r=this.halfAxes.getColumn(2);return[new n.Vector3(e).len(),new n.Vector3(t).len(),new n.Vector3(r).len()]}get quaternion(){const e=this.halfAxes.getColumn(0),t=this.halfAxes.getColumn(1),i=this.halfAxes.getColumn(2),a=new n.Vector3(e).normalize(),o=new n.Vector3(t).normalize(),s=new n.Vector3(i).normalize();return(new r.Quaternion).fromMatrix3(new L([...a,...o,...s]))}fromCenterHalfSizeQuaternion(e,t,i){const a=new r.Quaternion(i),o=(new L).fromQuaternion(a);return o[0]=o[0]*t[0],o[1]=o[1]*t[0],o[2]=o[2]*t[0],o[3]=o[3]*t[1],o[4]=o[4]*t[1],o[5]=o[5]*t[1],o[6]=o[6]*t[2],o[7]=o[7]*t[2],o[8]=o[8]*t[2],this.center=(new n.Vector3).from(e),this.halfAxes=o,this}clone(){return new e(this.center,this.halfAxes)}equals(e){return this===e||Boolean(e)&&this.center.equals(e.center)&&this.halfAxes.equals(e.halfAxes)}getBoundingSphere(e=new gs){const t=this.halfAxes,n=t.getColumn(0,ys),r=t.getColumn(1,xs),i=t.getColumn(2,_s),a=bs.copy(n).add(r).add(i);return e.center.copy(this.center),e.radius=a.magnitude(),e}intersectPlane(e){const t=this.center,n=e.normal,r=this.halfAxes,i=n.x,a=n.y,o=n.z,s=Math.abs(i*r[Ss]+a*r[Ms]+o*r[Es])+Math.abs(i*r[Cs]+a*r[Is]+o*r[Rs])+Math.abs(i*r[Ps]+a*r[Ns]+o*r[ks]),A=n.dot(t)+e.distance;return A<=-s?ls:A>=s?us:cs}distanceTo(e){return Math.sqrt(this.distanceSquaredTo(e))}distanceSquaredTo(e){const t=vs.from(e).subtract(this.center),n=this.halfAxes,r=n.getColumn(0,ys),i=n.getColumn(1,xs),a=n.getColumn(2,_s),o=r.magnitude(),s=i.magnitude(),A=a.magnitude();r.normalize(),i.normalize(),a.normalize();let l,c=0;return l=Math.abs(t.dot(r))-o,l>0&&(c+=l*l),l=Math.abs(t.dot(i))-s,l>0&&(c+=l*l),l=Math.abs(t.dot(a))-A,l>0&&(c+=l*l),c}computePlaneDistances(e,t,n=[-0,-0]){let r=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY;const a=this.center,o=this.halfAxes,s=o.getColumn(0,ys),A=o.getColumn(1,xs),l=o.getColumn(2,_s),c=ws.copy(s).add(A).add(l).add(a),u=Ts.copy(c).subtract(e);let f=t.dot(u);return r=Math.min(f,r),i=Math.max(f,i),c.copy(a).add(s).add(A).subtract(l),u.copy(c).subtract(e),f=t.dot(u),r=Math.min(f,r),i=Math.max(f,i),c.copy(a).add(s).subtract(A).add(l),u.copy(c).subtract(e),f=t.dot(u),r=Math.min(f,r),i=Math.max(f,i),c.copy(a).add(s).subtract(A).subtract(l),u.copy(c).subtract(e),f=t.dot(u),r=Math.min(f,r),i=Math.max(f,i),a.copy(c).subtract(s).add(A).add(l),u.copy(c).subtract(e),f=t.dot(u),r=Math.min(f,r),i=Math.max(f,i),a.copy(c).subtract(s).add(A).subtract(l),u.copy(c).subtract(e),f=t.dot(u),r=Math.min(f,r),i=Math.max(f,i),a.copy(c).subtract(s).subtract(A).add(l),u.copy(c).subtract(e),f=t.dot(u),r=Math.min(f,r),i=Math.max(f,i),a.copy(c).subtract(s).subtract(A).subtract(l),u.copy(c).subtract(e),f=t.dot(u),r=Math.min(f,r),i=Math.max(f,i),n[0]=r,n[1]=i,n}transform(e){this.center.transformAsPoint(e);const t=this.halfAxes.getColumn(0,ys);t.transformAsPoint(e);const n=this.halfAxes.getColumn(1,xs);n.transformAsPoint(e);const r=this.halfAxes.getColumn(2,_s);return r.transformAsPoint(e),this.halfAxes=new L([...t,...n,...r]),this}getTransform(){throw new Error("not implemented")}},Bs=new n.Vector3,Os=new n.Vector3,Fs=class e{constructor(e=[0,0,1],t=0){this.normal=new n.Vector3,this.distance=-0,this.fromNormalDistance(e,t)}fromNormalDistance(e,t){return n.assert$1(Number.isFinite(t)),this.normal.from(e).normalize(),this.distance=t,this}fromPointNormal(e,t){e=Bs.from(e),this.normal.from(t).normalize();const n=-this.normal.dot(e);return this.distance=n,this}fromCoefficients(e,t,r,i){return this.normal.set(e,t,r),n.assert$1(n.equals(this.normal.len(),1)),this.distance=i,this}clone(){return new e(this.normal,this.distance)}equals(e){return n.equals(this.distance,e.distance)&&n.equals(this.normal,e.normal)}getPointDistance(e){return this.normal.dot(e)+this.distance}transform(e){const t=Os.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=Bs.from(e),r=this.getPointDistance(n),i=Os.copy(this.normal).scale(r);return n.subtract(i).to(t)}},Ds=[new n.Vector3([1,0,0]),new n.Vector3([0,1,0]),new n.Vector3([0,0,1])],Us=new n.Vector3,Vs=new n.Vector3,js=class e{constructor(e=[]){this.planes=e}fromBoundingSphere(e){this.planes.length=2*Ds.length;const t=e.center,n=e.radius;let r=0;for(const i of Ds){let e=this.planes[r],a=this.planes[r+1];e||(e=this.planes[r]=new Fs),a||(a=this.planes[r+1]=new Fs);const o=Us.copy(i).scale(-n).add(t);e.fromPointNormal(o,i);const s=Us.copy(i).scale(n).add(t),A=Vs.copy(i).negate();a.fromPointNormal(s,A),r+=2}return this}computeVisibility(e){let t=us;for(const n of this.planes)switch(e.intersectPlane(n)){case ls:return ls;case cs:t=cs}return t}computeVisibilityWithPlaneMask(t,r){if(n.assert$1(Number.isFinite(r),"parentPlaneMask is required."),r===e.MASK_OUTSIDE||r===e.MASK_INSIDE)return r;let i=e.MASK_INSIDE;const a=this.planes;for(let n=0;n<this.planes.length;++n){const o=n<31?1<<n:0;if(n<31&&0===(r&o))continue;const s=a[n],A=t.intersectPlane(s);if(A===ls)return e.MASK_OUTSIDE;A===cs&&(i|=o)}return i}};js.MASK_OUTSIDE=4294967295,js.MASK_INSIDE=0,js.MASK_INDETERMINATE=2147483647;new n.Vector3,new n.Vector3,new n.Vector3,new n.Vector3,new n.Vector3,new n.Vector3,new n.Vector3,new n.Vector3,new n.Vector3,new n.Vector3,new n.Vector3,new n.Vector3,new n.Vector3,new n.Vector3,new n.Vector3,new n.Vector3,new n.Vector3;var zs=new L,Gs=new L,Hs=new L,qs=new L,Qs=new L;function Ks(e,t={}){let n=0,r=0;const i=Gs,a=Hs;i.identity(),a.copy(e);const o=1e-20*function(e){let t=0;for(let n=0;n<9;++n){const r=e[n];t+=r*r}return Math.sqrt(t)}(a);for(;r<10&&Js(a)>o;)Ys(a,qs),Qs.copy(qs).transpose(),a.multiplyRight(qs),a.multiplyLeft(Qs),i.multiplyRight(qs),++n>2&&(++r,n=0);return t.unitary=i.toTarget(t.unitary),t.diagonal=a.toTarget(t.diagonal),t}var Ws=[1,0,0],$s=[2,2,1];function Js(e){let t=0;for(let n=0;n<3;++n){const r=e[zs.getElementIndex($s[n],Ws[n])];t+=2*r*r}return Math.sqrt(t)}function Ys(e,t){let n=0,r=1;for(let A=0;A<3;++A){const t=Math.abs(e[zs.getElementIndex($s[A],Ws[A])]);t>n&&(r=A,n=t)}const i=Ws[r],a=$s[r];let o=1,s=0;if(Math.abs(e[zs.getElementIndex(a,i)])>1e-15){const t=(e[zs.getElementIndex(a,a)]-e[zs.getElementIndex(i,i)])/2/e[zs.getElementIndex(a,i)];let n;n=t<0?-1/(-t+Math.sqrt(1+t*t)):1/(t+Math.sqrt(1+t*t)),o=1/Math.sqrt(1+n*n),s=n*o}return L.IDENTITY.to(t),t[zs.getElementIndex(i,i)]=t[zs.getElementIndex(a,a)]=o,t[zs.getElementIndex(a,i)]=s,t[zs.getElementIndex(i,a)]=-s,t}var Xs=new n.Vector3,Zs=new n.Vector3,eA=new n.Vector3,tA=new n.Vector3,nA=new n.Vector3,rA=new L,iA={diagonal:new L,unitary:new L};function aA(e,t=new Ls){if(!e||0===e.length)return t.halfAxes=new L([0,0,0,0,0,0,0,0,0]),t.center=new n.Vector3,t;const r=e.length,i=new n.Vector3(0,0,0);for(const n of e)i.add(n);const a=1/r;i.multiplyByScalar(a);let o=0,s=0,A=0,l=0,c=0,u=0;for(const n of e){const e=Xs.copy(n).subtract(i);o+=e.x*e.x,s+=e.x*e.y,A+=e.x*e.z,l+=e.y*e.y,c+=e.y*e.z,u+=e.z*e.z}o*=a,s*=a,A*=a,l*=a,c*=a,u*=a;const f=rA;f[0]=o,f[1]=s,f[2]=A,f[3]=s,f[4]=l,f[5]=c,f[6]=A,f[7]=c,f[8]=u;const{unitary:d}=Ks(f,iA),h=t.halfAxes.copy(d);let p=h.getColumn(0,eA),m=h.getColumn(1,tA),g=h.getColumn(2,nA),b=-Number.MAX_VALUE,v=-Number.MAX_VALUE,y=-Number.MAX_VALUE,x=Number.MAX_VALUE,_=Number.MAX_VALUE,w=Number.MAX_VALUE;for(const n of e)Xs.copy(n),b=Math.max(Xs.dot(p),b),v=Math.max(Xs.dot(m),v),y=Math.max(Xs.dot(g),y),x=Math.min(Xs.dot(p),x),_=Math.min(Xs.dot(m),_),w=Math.min(Xs.dot(g),w);p=p.multiplyByScalar(.5*(x+b)),m=m.multiplyByScalar(.5*(_+v)),g=g.multiplyByScalar(.5*(w+y)),t.center.copy(p).add(m).add(g);const T=Zs.set(b-x,v-_,y-w).multiplyByScalar(.5),S=new L([T[0],0,0,0,T[1],0,0,0,T[2]]);return t.halfAxes.multiplyRight(S),t}var oA=512,sA=[[.5,.5],[0,0],[0,1],[1,0],[1,1]],AA=sA.concat([[0,.5],[.5,0],[1,.5],[.5,1]]),lA=AA.concat([[.25,.5],[.75,.5]]),cA=class e{constructor(e,t,n){this.x=e,this.y=t,this.z=n}get children(){if(!this._children){const t=2*this.x,n=2*this.y,r=this.z+1;this._children=[new e(t,n,r),new e(t,n+1,r),new e(t+1,n,r),new e(t+1,n+1,r)]}return this._children}update(e){const{viewport:t,cullingVolume:n,elevationBounds:r,minZ:i,maxZ:a,bounds:o,offset:s,project:A}=e,l=this.getBoundingVolume(r,s,A);if(o&&!this.insideBounds(o))return!1;if(n.computeVisibility(l)<0)return!1;if(A&&this.beyondHorizon(t.cameraPosition,A,r[1]))return!1;if(!this.childVisible){let{z:e}=this;if(e<a&&e>=i){const n=l.distanceTo(t.cameraPosition)*t.scale/t.height;e+=Math.floor(Math.log2(n))}if(e>=a)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}beyondHorizon(e,t,n){const r=e[0],i=e[1],a=e[2],o=Math.sqrt(r*r+i*i+a*a),s=180*Math.atan2(r,-i)/Math.PI,A=180*Math.asin(a/o)/Math.PI,[l,c]=vA(this.x,this.y,this.z),[u,f]=vA(this.x+1,this.y+1,this.z),d=(l+u)/2,h=d+((s-d+540)%360-180),p=t([Math.max(l,Math.min(h,u)),Math.max(f,Math.min(A,c)),n]);return p[0]*r+p[1]*i+p[2]*a<=p[0]*p[0]+p[1]*p[1]+p[2]*p[2]}insideBounds([e,t,n,r]){const i=Math.pow(2,this.z),a=oA/i;return this.x*a<n&&this.y*a<r&&(this.x+1)*a>e&&(this.y+1)*a>t}getBoundingVolume(e,t,n){if(n){const t=this.z<1?lA:this.z<2?AA:sA,r=[];for(const i of t){const t=vA(this.x+i[0],this.y+i[1],this.z);t[2]=e[0],r.push(n(t)),e[0]!==e[1]&&(t[2]=e[1],r.push(n(t)))}return aA(r)}const r=Math.pow(2,this.z),i=oA/r,a=this.x*i+t*oA,o=oA-(this.y+1)*i;return new hs([a,o,e[0]],[a+i,o+i,e[1]])}};var uA=512,fA=[-1/0,-1/0,1/0,1/0],dA={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 r=0;r<n;r++)if(e[r]!==t[r])return!1;return!0}};function hA(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 pA(e,t){if(!e||!e.length)return null;const{index:n,id:r}=t;if(Array.isArray(e)){const t=(i=r,Math.abs(i.split("").reduce((e,t)=>(e<<5)-e+t.charCodeAt(0)|0,0))%e.length);e=e[t]}var i;let a=e;for(const o of Object.keys(n)){const e=new RegExp(`{${o}}`,"g");a=a.replace(e,String(n[o]))}return Number.isInteger(n.y)&&Number.isInteger(n.z)&&(a=a.replace(/\{-y\}/g,String(Math.pow(2,n.z)-n.y-1))),a}function mA({viewport:e,z:t,cullRect:n}){return(e.subViewports||[e]).map(e=>gA(e,t||0,n))}function gA(e,t,n){if(!Array.isArray(t)){const r=n.x-e.x,i=n.y-e.y,{width:a,height:o}=n,s={targetZ:t},A=e.unproject([r,i],s),l=e.unproject([r+a,i],s),c=e.unproject([r,i+o],s),u=e.unproject([r+a,i+o],s);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 r=gA(e,t[0],n),i=gA(e,t[1],n);return[Math.min(r[0],i[0]),Math.min(r[1],i[1]),Math.max(r[2],i[2]),Math.max(r[3],i[3])]}function bA(e,t){return Math.pow(2,e)*uA/t}function vA(e,t,n){const r=bA(n,uA),i=e/r*360-180,a=Math.PI-2*Math.PI*t/r;return[i,180/Math.PI*Math.atan(.5*(Math.exp(a)-Math.exp(-a)))]}function yA(e,t,n,r){const i=bA(n,r);return[e/i*uA,t/i*uA]}function xA(e,t,n,r,i=uA){if(e.isGeospatial){const[e,i]=vA(t,n,r),[a,o]=vA(t+1,n+1,r);return{west:e,north:i,east:a,south:o}}const[a,o]=yA(t,n,r,i),[s,A]=yA(t+1,n+1,r,i);return{left:a,top:o,right:s,bottom:A}}function _A(e,t,n,r,i){const[a,o,s,A]=function(e,t,n){return n?hA(e,n).map(e=>e*t/uA):e.map(e=>e*t/uA)}(function(e,t,n){let r;if(t&&2===t.length){const[n,i]=t,a=e.getBounds({z:n}),o=e.getBounds({z:i});r=[Math.min(a[0],o[0]),Math.min(a[1],o[1]),Math.max(a[2],o[2]),Math.max(a[3],o[3])]}else r=e.getBounds();return e.isGeospatial?[Math.max(r[0],n[0]),Math.max(r[1],n[1]),Math.min(r[2],n[2]),Math.min(r[3],n[3])]:[Math.max(Math.min(r[0],n[2]),n[0]),Math.max(Math.min(r[1],n[3]),n[1]),Math.min(Math.max(r[2],n[0]),n[2]),Math.min(Math.max(r[3],n[1]),n[3])]}(e,null,r),bA(t,n),i),l=[];for(let c=Math.floor(a);c<s;c++)for(let e=Math.floor(o);e<A;e++)l.push({x:c,y:e,z:t});return l}function wA({viewport:e,maxZoom:t,minZoom:i,zRange:a,extent:o,tileSize:s=uA,modelMatrix:A,modelMatrixInverse:l,zoomOffset:c=0,visibleMinZoom:u,visibleMaxZoom:f}){let d=e.isGeospatial?Math.round(e.zoom+Math.log2(uA/s)+c):Math.ceil(e.zoom+c);if("number"==typeof i&&Number.isFinite(i)&&d<i){if(!o)return[];d=i}if("number"==typeof t&&Number.isFinite(t)&&d>t&&(d=t),null!=u&&e.zoom<u)return[];if(null!=f&&e.zoom>f)return[];let h=o;return A&&l&&o&&!e.isGeospatial&&(h=hA(o,A)),e.isGeospatial?function(e,t,i,a){const o=e instanceof r.GlobeViewport?e.projectPosition:null,s=Object.values(e.getFrustumPlanes()).map(({normal:e,distance:t})=>new Fs(e.clone().negate(),t)),A=new js(s),l=e.distanceScales.unitsPerMeter[2],c=i&&i[0]*l||0,u=i&&i[1]*l||0,f=e instanceof n.WebMercatorViewport&&e.pitch<=60?t:0;if(a){const[e,t,r,i]=a,o=n.lngLatToWorld([e,i]),s=n.lngLatToWorld([r,t]);a=[o[0],oA-o[1],s[0],oA-s[1]]}const d=new cA(0,0,0),h={viewport:e,project:o,cullingVolume:A,elevationBounds:[c,u],minZ:f,maxZ:t,bounds:a,offset:0};if(d.update(h),e instanceof n.WebMercatorViewport&&e.subViewports&&e.subViewports.length>1){for(h.offset=-1;d.update(h)&&!(--h.offset<-3););for(h.offset=1;d.update(h)&&!(++h.offset>3););}return d.getSelected()}(e,d,a,o):_A(e,d,s,h||fA,l)}function TA(e,t){if(e===t)return!0;if(Array.isArray(e)){const n=e.length;if(!t||t.length!==n)return!1;for(let r=0;r<n;r++)if(e[r]!==t[r])return!1;return!0}return!1}var SA="never",MA="no-overlap",EA="best-available",CA=99999999,IA={[EA]:function(e){for(const t of e)t.state=0;for(const t of e)t.isSelected&&!NA(t)&&kA(t);for(const t of e)t.isVisible=Boolean(2&t.state)},[MA]:function(e){for(const n of e)n.state=0;for(const n of e)n.isSelected&&NA(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&&kA(n)},[SA]:()=>{}},RA={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:()=>{}},PA=class{constructor(e){this._getCullBounds=function(e){let t,n={};return r=>{for(const i in r)if(!TA(r[i],n[i])){t=e(r),n=r;break}return t}}(mA),this.opts={...RA,...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 g({throttleRequests:this.opts.maxRequests>0||this.opts.debounceTime>0,maxRequests:this.opts.maxRequests,debounceTime:this.opts.debounceTime}),this._cache=new Map,this._tiles=[],this._dirty=!1,this._cacheByteSize=0,this._viewport=null,this._zRange=null,this._selectedTiles=null,this._frameNumber=0,this._modelMatrix=new n.Matrix4,this._modelMatrixInverse=new n.Matrix4}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:r}={zRange:null,modelMatrix:null}){const i=r?new n.Matrix4(r):new n.Matrix4,a=!i.equals(this._modelMatrix);if(this._viewport&&e.equals(this._viewport)&&n.equals(this._zRange,t)&&!a)this.needsReload&&(this._selectedTiles=this._selectedTiles.map(e=>this._getTile(e.index,!0)));else{a&&(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,r){if(!e.isVisible)return!1;if(t&&this._viewport){const i=this._getCullBounds({viewport:this._viewport,z:this._zRange,cullRect:t});let{bbox:a}=e;for(const[e,t,o,s]of i){let i;if("west"in a)i=a.west<o&&a.east>e&&a.south<s&&a.north>t;else{if(r&&!n.Matrix4.IDENTITY.equals(r)){const[e,t,n,i]=hA([a.left,a.top,a.right,a.bottom],r);a={left:e,top:t,right:n,bottom:i}}const A=Math.min(a.top,a.bottom),l=Math.max(a.top,a.bottom);i=a.left<o&&a.right>e&&A<s&&l>t}if(i)return!0}return!1}return!0}getTileIndices({viewport:e,maxZoom:t,minZoom:n,zRange:r,modelMatrix:i,modelMatrixInverse:a}){const{tileSize:o,extent:s,zoomOffset:A,visibleMinZoom:l,visibleMaxZoom:c}=this.opts;return wA({viewport:e,maxZoom:t,minZoom:n,zRange:r,tileSize:o,extent:s,modelMatrix:i,modelMatrixInverse:a,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:xA(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||"best-available",t=new Array(this._cache.size);let n=0;for(const r of this._cache.values())t[n++]=r.isVisible,r.isSelected=!1,r.isVisible=!1;for(const r of this._selectedTiles)r.isSelected=!0,r.isVisible=!0;("function"==typeof e?e:IA[e])(Array.from(this._cache.values())),n=0;for(const r of this._cache.values())if(t[n++]!==r.isVisible)return!0;return!1}_getRequestPriority(e){if(!e.isSelected&&!e.isVisible)return-1;const t=this._getTileDistancePriority(e);return e.isSelected?0+t:1e8+t}_getTileDistancePriority(e){const{width:t,height:n}=this._viewport||{};if(!this._viewport||!t||!n)return 0;try{const r=this._getTileScreenCorners(e.bbox),i=[t/2,n/2];if(4===r.length){if(this._isPointInPolygon(i,r))return 0;const e=r.reduce((e,t,n)=>{const a=r[(n+1)%r.length];return Math.min(e,this._getPointToSegmentDistanceSquared(i,t,a))},Number.MAX_SAFE_INTEGER);return Math.min(e,CA)}}catch{}return CA}_getTileScreenCorners(e){return("west"in e?[[e.west,e.south],[e.east,e.south],[e.east,e.north],[e.west,e.north]]:[[e.left,e.top],[e.right,e.top],[e.right,e.bottom],[e.left,e.bottom]]).map(e=>this._viewport.project(e)).filter(([e,t])=>Number.isFinite(e)&&Number.isFinite(t))}_isPointInPolygon(e,t){let n=!1;const[r,i]=e;for(let a=0,o=t.length-1;a<t.length;o=a++){const[e,s]=t[a],[A,l]=t[o];s>i!=l>i&&r<(A-e)*(i-s)/(l-s)+e&&(n=!n)}return n}_getPointToSegmentDistanceSquared(e,t,n){const[r,i]=e,[a,o]=t,[s,A]=n,l=s-a,c=A-o,u=l*l+c*c,f=u?Math.max(0,Math.min(1,((r-a)*l+(i-o)*c)/u)):0,d=r-(a+f*l),h=i-(o+f*c);return d*d+h*h}_pruneRequests(){const{maxRequests:e=0}=this.opts,t=[];let n=0;for(const r of this._cache.values())r.isLoading&&(n++,r.isSelected||r.isVisible||t.push(r));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),r=t.maxCacheByteSize??1/0;if(e.size>n||this._cacheByteSize>r){for(const[i,a]of e)if(a.isVisible||a.isSelected||(this._cacheByteSize-=null!==t.maxCacheByteSize?a.byteLength:0,e.delete(i),this.opts.onTileUnload?.(a)),e.size<=n&&this._cacheByteSize<=r)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 r=this._cache.get(n),i=!1;return!r&&t?(r=new As(e),Object.assign(r,this.getTileMetadata(r.index)),Object.assign(r,{id:n,zoom:this.getTileZoom(r.index)}),i=!0,this._cache.set(n,r),this._dirty=!0):r&&r.needsReload&&(i=!0),r&&i&&r.loadData({getData:this.opts.getTileData,getRequestPriority:this._getRequestPriority.bind(this),requestScheduler:this._requestScheduler,onLoad:this.onTileLoad,onError:this.opts.onTileError}),r}_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 NA(e){let t=e;for(;t;){if(t.isLoaded||t.content)return t.state|=2,!0;t=t.parent}return!1}function kA(e){for(const t of e.children)t.isLoaded||t.content?t.state|=2:kA(t)}var LA={TilesetClass:PA,data:{type:"data",value:[]},dataComparator:dA.equal,renderSubLayers:{type:"function",value:e=>new t.GeoJsonLayer(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=>console.error(e)},extent:{type:"array",optional:!0,value:null,compare:!0},tileSize:512,maxZoom:null,minZoom:0,maxCacheSize:null,maxCacheByteSize:null,refinementStrategy:EA,zRange:null,maxRequests:6,debounceTime:0,zoomOffset:0,visibleMinZoom:null,visibleMaxZoom:null},BA=class extends t.CompositeLayer{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,r=e.dataChanged||e.updateTriggersChanged&&(e.updateTriggersChanged.all||e.updateTriggersChanged.getTileData);t?n&&(t.setOptions(this._getTilesetOptions()),r?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:r,extent:i,maxZoom:a,minZoom:o,maxRequests:s,debounceTime:A,zoomOffset:l,visibleMinZoom:c,visibleMaxZoom:u}=this.props;return{maxCacheSize:t,maxCacheByteSize:n,maxZoom:a,minZoom:o,tileSize:e,refinementStrategy:r,extent:i,maxRequests:s,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,r=e.update(this.context.viewport,{zRange:t,modelMatrix:n}),{isLoaded:i}=e,a=this.state.isLoaded!==i,o=this.state.frameNumber!==r;i&&(a||o)&&this._onViewportLoad(),o&&this.setState({frameNumber:r}),this.state.isLoaded=i}_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:r}=this.props,{signal:i}=e;return e.url="string"==typeof t||Array.isArray(t)?pA(t,e):null,n?n(e):r&&e.url?r(e.url,{propName:"data",layer:this,signal:i}):null}renderSubLayers(e){return this.props.renderSubLayers(e)}getSubLayerPropsByTile(e){return null}getPickingInfo(e){const t=e.sourceLayer,n=t.props.tile,r=e.info;return r.picked&&(r.tile=n),r.sourceTile=n,r.sourceTileSubLayer=t,r}_updateAutoHighlight(e){e.sourceTileSubLayer.updateAutoHighlight(e)}renderLayers(){const{visibleMinZoom:e,visibleMaxZoom:t,minZoom:r,extent:i}=this.props,a=this.context.viewport.zoom;if(null!=e&&a<e||null!=t&&a>t||null!=r&&!i&&a<r){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 r=this.renderSubLayers({...this.props,...this.getSubLayerProps({id:e.id,updateTriggers:this.props.updateTriggers}),data:e.content,_offset:0,tile:e});e.layers=n.flatten(r,Boolean).map(n=>n.clone({tile:e,...t}))}else;return e.layers})}filterSubLayer({layer:e,cullRect:t}){const{tile:r}=e.props,{modelMatrix:i}=this.props;return this.state.tileset.isTileVisible(r,t,i?new n.Matrix4(i):null)}};BA.defaultProps=LA,BA.layerName="TileLayer";var OA="layout(std140) uniform tripsUniforms {\n bool fadeTrail;\n float trailLength;\n float currentTime;\n} trips;\n",FA={name:"trips",source:"struct TripsUniforms {\n fadeTrail: f32,\n trailLength: f32,\n currentTime: f32,\n};\n\n@group(0) @binding(auto)\nvar<uniform> trips: TripsUniforms;\n",vs:OA,fs:OA,uniformTypes:{fadeTrail:"f32",trailLength:"f32",currentTime:"f32"}};function DA(e,t=e.length,n=!1){const r=new Float32Array(2*t);if(0===e.length)return r;const i=t>e.length,a=n?e.length:Math.max(e.length-1,1);for(let o=0;o<t;o++){const t=i?o%a:Math.min(o,e.length-1),n=i?(t+1)%a:Math.min(t+1,e.length-1);r[2*o]=e[t],r[2*o+1]=e[n]}return r}var UA={" @location(12) rowIndexes: u32,":"\n @location(13) instanceTimestamps: vec2<f32>,"," @location(5) vJointType: f32,":"\n @location(6) vTime: f32,"," attributes.instanceColors.a * layer.opacity\n );":"\n\n varyings.vTime = mix(\n attributes.instanceTimestamps.x,\n attributes.instanceTimestamps.y,\n varyings.vPathPosition.y / varyings.vPathLength\n );\n\n if (trips.fadeTrail > 0.5) {\n varyings.vColor.a *=\n 1.0 - (trips.currentTime - varyings.vTime) / trips.trailLength;\n }"," // DECKGL_FILTER_COLOR":"\n if (\n varyings.vTime > trips.currentTime ||\n (trips.fadeTrail > 0.5 && varyings.vTime < trips.currentTime - trips.trailLength)\n ) {\n discard;\n }"},VA={"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:DECKGL_FILTER_COLOR":"if(vTime > trips.currentTime || (trips.fadeTrail && (vTime < trips.currentTime - trips.trailLength))) {\n discard;\n}\nif(trips.fadeTrail) {\n color.a *= 1.0 - (trips.currentTime - vTime) / trips.trailLength;\n}\n"},jA=class extends t.PathLayer{getShaders(){const e=super.getShaders();return e.inject="webgpu"===this.context.device.type?UA:VA,e.modules=[...e.modules,FA],e}initializeState(){super.initializeState(),this.getAttributeManager().addInstanced({..."webgpu"===this.context.device.type?{instanceTimestamps:{size:2,accessor:"getTimestamps",update:this.calculateWebGPUTimestamps,bufferGroup:"path-instance-data"}}:{timestamps:{size:1,accessor:"getTimestamps",shaderAttributes:{instanceTimestamps:{vertexOffset:0},instanceNextTimestamps:{vertexOffset:1}}}}})}calculateWebGPUTimestamps(e,{data:n,props:r}){const{pathTesselator:i}=this.state,{instanceCount:a,vertexStarts:o}=i,s=new Float32Array(2*a),{iterable:A,objectInfo:l}=t.createIterable(n);for(const t of A){l.index++;const e=o[l.index],n=o[l.index+1]??a;if(n<=e)continue;const i=r.getTimestamps?.(t,l)??[];s.set(DA(i,n-e,"loop"===r._pathType),2*e)}e.startIndices=o,e.value=s}draw(e){const{fadeTrail:t,trailLength:n,currentTime:r}=this.props,i={fadeTrail:t,trailLength:n,currentTime:r};this.state.model.shaderInputs.setProps({trips:i}),super.draw(e)}};jA.layerName="TripsLayer",jA.defaultProps={fadeTrail:!0,trailLength:{type:"number",value:120,min:0},currentTime:{type:"number",value:0,min:0},getTimestamps:{type:"accessor",value:e=>e.timestamps}};var zA={...t.PolygonLayer.defaultProps,highPrecision:"auto",coverage:{type:"number",min:0,max:1,value:1},centerHexagon:null,getHexagon:{type:"accessor",value:e=>e.hexagon},extruded:!0},GA=class e extends t.CompositeLayer{initializeState(){e._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,n=!1,r=!1;const{iterable:i,objectInfo:a}=t.createIterable(this.props.data);for(const t of i){a.index++;const i=this.props.getHexagon(t,a),o=oi(i);if(e<0){if(e=o,!this.props.highPrecision)break}else if(e!==o){r=!0;break}if(ai(i)){n=!0;break}}return{resolution:e,edgeLengthKM:e>=0?fi(e,"km"):0,hasMultipleRes:r,hasPentagon:n}}_shouldUseHighPrecision(){if("auto"===this.props.highPrecision){const{resolution:e,hasPentagon:t,hasMultipleRes:n}=this.state,{viewport:r}=this.context;return Boolean(r?.resolution)||n||t||e>=0&&e<=5}return this.props.highPrecision}_updateVertices(e){if(this._shouldUseHighPrecision())return;const{resolution:t,edgeLengthKM:n,centerHex:r}=this.state;if(t<0)return;const i=this.props.centerHexagon||si(e.latitude,e.longitude,t);if(r===i)return;if(r)try{if(ui(r,i)*n<10)return}catch{}const{unitsPerMeter:a}=e.distanceScales;let o=mi(i);const[s,A]=Ai(i),[l,c]=e.projectFlat([A,s]);o=o.map(t=>{const n=e.projectFlat(t);return[(n[0]-l)/a[0],(n[1]-c)/a[1]]}),this.setState({centerHex:i,vertices:o})}renderLayers(){return this._shouldUseHighPrecision()?this._renderPolygonLayer():this._renderColumnLayer()}_getForwardProps(){const{elevationScale:e,material:t,coverage:n,extruded:r,wireframe:i,stroked:a,filled:o,lineWidthUnits:s,lineWidthScale:A,lineWidthMinPixels:l,lineWidthMaxPixels:c,getFillColor:u,getElevation:f,getLineColor:d,getLineWidth:h,transitions:p,updateTriggers:m}=this.props;return{elevationScale:e,extruded:r,coverage:n,wireframe:i,stroked:a,filled:o,lineWidthUnits:s,lineWidthScale:A,lineWidthMinPixels:l,lineWidthMaxPixels:c,material:t,getElevation:f,getFillColor:u,getLineColor:d,getLineWidth:h,transitions:p,updateTriggers:{getFillColor:m.getFillColor,getElevation:m.getElevation,getLineColor:m.getLineColor,getLineWidth:m.getLineWidth}}}_renderPolygonLayer(){const{data:e,getHexagon:n,updateTriggers:r,coverage:i}=this.props,a=this.getSubLayerClass("hexagon-cell-hifi",t.PolygonLayer),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}(r.getHexagon,i),new a(o,this.getSubLayerProps({id:"hexagon-cell-hifi",updateTriggers:o.updateTriggers}),{data:e,_normalize:!1,_windingOrder:"CCW",positionFormat:"XY",getPolygon:(e,t)=>gi(mi(n(e,t),i))})}_renderColumnLayer(){const{data:e,getHexagon:n,updateTriggers:r}=this.props,i=this.getSubLayerClass("hexagon-cell",t.ColumnLayer),a=this._getForwardProps();return a.updateTriggers.getPosition=r.getHexagon,new i(a,this.getSubLayerProps({id:"hexagon-cell",flatShading:!0,updateTriggers:a.updateTriggers}),{data:e,diskResolution:6,radius:1,vertices:this.state.vertices,getPosition:pi.bind(null,n)})}};GA.defaultProps=zA,GA.layerName="H3HexagonLayer",GA._checkH3Lib=()=>{};var HA=class extends st{initializeState(){GA._checkH3Lib()}updateState({props:e,changeFlags:n}){if(n.dataChanged||n.updateTriggersChanged&&n.updateTriggersChanged.getHexagons){const{data:n,getHexagons:r}=e,i=[],{iterable:a,objectInfo:o}=t.createIterable(n);for(const e of a){o.index++;const t=ci(r(e,o),!0);for(const n of t){for(const e of n)hi(e);i.push(this.getSubLayerRow({polygon:n},e,o.index))}}this.setState({polygons:i})}}indexToBounds(){const{getElevation:e,getFillColor:t,getLineColor:n,getLineWidth:r}=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(r)}}};HA.layerName="H3ClusterLayer",HA.defaultProps={getHexagons:{type:"accessor",value:e=>e.hexagons}};var qA=Math.PI/180,QA=new Float32Array(16),KA=new Float32Array(12);function WA(e,t,n){const r=t[0]*qA,i=t[1]*qA,a=t[2]*qA,o=Math.sin(a),s=Math.sin(r),A=Math.sin(i),l=Math.cos(a),c=Math.cos(r),u=Math.cos(i),f=n[0],d=n[1],h=n[2];e[0]=f*u*c,e[1]=f*A*c,e[2]=f*-s,e[3]=d*(-A*l+u*s*o),e[4]=d*(u*l+A*s*o),e[5]=d*c*o,e[6]=h*(A*o+u*s*l),e[7]=h*(-u*o+A*s*l),e[8]=h*c*l}function $A(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)}var JA={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:n,endRow:r}){const{data:i,getOrientation:a,getScale:o,getTranslation:s,getTransformMatrix:A}=this.props,l=Array.isArray(A),c=l&&16===A.length,u=Array.isArray(o),f=Array.isArray(a),d=Array.isArray(s),h=c||!l&&Boolean(A(i[0]));e.constant=h?c:f&&u&&d;const p=e.value;if(e.constant){let t;h?(QA.set(A),t=$A(QA)):(t=KA,WA(t,a,o),t.set(s,9)),e.value=new Float32Array(t)}else{let l=n*e.size;const{iterable:m,objectInfo:g}=t.createIterable(i,n,r);for(const e of m){let t;if(g.index++,h)QA.set(c?A:A(e,g)),t=$A(QA);else{t=KA;WA(t,f?a:a(e,g),u?o:o(e,g)),t.set(d?s:s(e,g),9)}p[l++]=t[0],p[l++]=t[1],p[l++]=t[2],p[l++]=t[3],p[l++]=t[4],p[l++]=t[5],p[l++]=t[6],p[l++]=t[7],p[l++]=t[8],p[l++]=t[9],p[l++]=t[10],p[l++]=t[11]}}}};function YA(e,t){return"cartesian"===t||"meter-offsets"===t||"default"===t&&!e.isGeospatial}var XA="layout(std140) uniform simpleMeshUniforms {\n float sizeScale;\n bool composeModelMatrix;\n bool hasTexture;\n bool flatShading;\n} simpleMesh;\n",ZA={name:"simpleMesh",source:"struct SimpleMeshUniforms {\n sizeScale: f32,\n composeModelMatrix: f32,\n hasTexture: f32,\n flatShading: f32,\n};\n\n@group(0) @binding(auto) var<uniform> simpleMesh: SimpleMeshUniforms;\n@group(0) @binding(auto) var simpleMeshTexture: texture_2d<f32>;\n@group(0) @binding(auto) var simpleMeshTextureSampler: sampler;\n",vs:XA,fs:XA,uniformTypes:{sizeScale:"f32",composeModelMatrix:"f32",hasTexture:"f32",flatShading:"f32"}};function el(e){const t=e.positions||e.POSITION;n.defaultLogger.assert(t,'no "postions" or "POSITION" attribute in mesh');const r=t.value.length/t.size;let i=e.COLOR_0||e.colors;i||(i={size:3,value:new Float32Array(3*r).fill(1)});let a=e.NORMAL||e.normals;a||(a={size:3,value:new Float32Array(3*r).fill(0)});let o=e.TEXCOORD_0||e.texCoords;return o||(o={size:2,value:new Float32Array(2*r).fill(0)}),{positions:t,colors:i,normals:a,texCoords:o}}function tl(e){return e instanceof t.Geometry?(e.attributes=el(e.attributes),e):e.attributes?new t.Geometry({...e,topology:"triangle-list",attributes:el(e.attributes)}):new t.Geometry({topology:"triangle-list",attributes:el(e)})}var nl=class extends t.Layer{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 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 = picking_getPickingColorFromInstanceID();\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",source:"struct Attributes {\n @builtin(instance_index) instanceIndex: u32,\n @location(0) positions: vec3<f32>,\n @location(1) normals: vec3<f32>,\n @location(2) colors: vec3<f32>,\n @location(3) texCoords: vec2<f32>,\n @location(4) instancePositions: vec3<f32>,\n @location(5) instancePositions64Low: vec3<f32>,\n @location(6) instanceColors: vec4<f32>,\n @location(7) instanceModelMatrixCol0: vec3<f32>,\n @location(8) instanceModelMatrixCol1: vec3<f32>,\n @location(9) instanceModelMatrixCol2: vec3<f32>,\n @location(10) instanceTranslation: vec3<f32>,\n};\n\nstruct Varyings {\n @builtin(position) position: vec4<f32>,\n @location(0) color: vec4<f32>,\n @location(1) texCoords: vec2<f32>,\n @location(2) normal: vec3<f32>,\n @location(3) positionCommon: vec3<f32>,\n @location(4) pickingColor: vec3<f32>,\n};\n\n@vertex\nfn vertexMain(attributes: Attributes) -> Varyings {\n var varyings: Varyings;\n\n geometry.worldPosition = attributes.instancePositions;\n geometry.uv = attributes.texCoords;\n geometry.pickingColor = picking_getPickingColorFromIndex(attributes.instanceIndex);\n\n let instanceModelMatrix = mat3x3<f32>(\n attributes.instanceModelMatrixCol0,\n attributes.instanceModelMatrixCol1,\n attributes.instanceModelMatrixCol2\n );\n let meshPosition =\n (instanceModelMatrix * attributes.positions) * simpleMesh.sizeScale +\n attributes.instanceTranslation;\n\n if (simpleMesh.composeModelMatrix > 0.5) {\n geometry.normal = project_normal(instanceModelMatrix * attributes.normals);\n geometry.worldPosition += meshPosition;\n let projected = project_position_to_clipspace_and_commonspace(\n attributes.instancePositions + meshPosition,\n attributes.instancePositions64Low,\n vec3<f32>(0.0)\n );\n geometry.position = projected.commonPosition;\n varyings.position = projected.clipPosition;\n } else {\n let projected = project_position_to_clipspace_and_commonspace(\n attributes.instancePositions,\n attributes.instancePositions64Low,\n project_size_vec3(meshPosition)\n );\n geometry.position = projected.commonPosition;\n geometry.normal = project_normal(instanceModelMatrix * attributes.normals);\n varyings.position = projected.clipPosition;\n }\n\n varyings.color = vec4<f32>(\n attributes.colors * attributes.instanceColors.rgb,\n attributes.instanceColors.a\n );\n varyings.texCoords = attributes.texCoords;\n varyings.normal = geometry.normal;\n varyings.positionCommon = geometry.position.xyz;\n varyings.pickingColor = geometry.pickingColor;\n return varyings;\n}\n\n@fragment\nfn fragmentMain(varyings: Varyings) -> @location(0) vec4<f32> {\n geometry.uv = varyings.texCoords;\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 var color = varyings.color;\n if (simpleMesh.hasTexture > 0.5) {\n color = textureSample(simpleMeshTexture, simpleMeshTextureSampler, varyings.texCoords);\n }\n\n var normal = varyings.normal;\n if (simpleMesh.flatShading > 0.5) {\n // WebGPU's screen-space Y axis reverses the derivative orientation used by GLSL flat shading.\n normal = normalize(cross(dpdy(varyings.positionCommon), dpdx(varyings.positionCommon)));\n }\n\n color = vec4<f32>(\n lighting_getLightColor2(color.rgb, project.cameraPosition, varyings.positionCommon, normal),\n color.a * layer.opacity\n );\n\n if (picking.isHighlightActive > 0.5) {\n let highlightedColor = picking_normalizeColor(picking.highlightedObjectColor);\n if (picking_isColorZero(abs(varyings.pickingColor - highlightedColor))) {\n let blendedAlpha = picking.highlightColor.a + color.a * (1.0 - picking.highlightColor.a);\n if (blendedAlpha > 0.0) {\n color = vec4<f32>(\n mix(color.rgb, picking.highlightColor.rgb, picking.highlightColor.a / blendedAlpha),\n blendedAlpha\n );\n }\n }\n }\n\n return deckgl_premultiplied_alpha(color);\n}\n",modules:[t.project32_default,t.color_default,t.phongMaterial,t.picking_default,ZA]})}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}=tl(t);n.POSITION=n.POSITION||n.positions,e=function(e){let t=1/0,n=1/0,r=1/0,i=-1/0,a=-1/0,o=-1/0;const s=e.POSITION?e.POSITION.value:[],A=s&&s.length;for(let l=0;l<A;l+=3){const e=s[l],A=s[l+1],c=s[l+2];t=e<t?e:t,n=A<n?A:n,r=c<r?c:r,i=e>i?e:i,a=A>a?A:a,o=c>o?c:o}return[[t,n,r],[i,a,o]]}(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:JA}),this.setState({emptyTexture:this.context.device.createTexture({data:new Uint8Array(4),width:1,height:1})})}updateState(e){super.updateState(e);const{props:t,oldProps:r,changeFlags:i}=e;if(t.mesh!==r.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!==r.texture&&t.texture instanceof n.Texture&&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:r}=this.context,{sizeScale:i,coordinateSystem:a,_instanced:o}=this.props,s={sizeScale:i,composeModelMatrix:!o||YA(n,a),flatShading:!this.state.hasNormals};t.shaderInputs.setProps({simpleMesh:s}),t.draw(r)}get isLoaded(){return Boolean(this.state?.model&&super.isLoaded)}getModel(e){const n=new t.Model(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:tl(e),isInstanced:!0});return n.shaderInputs.setProps({simpleMesh:this.getTextureProps(this.props.texture)}),n}setTexture(e){const{model:t}=this.state;t&&t.shaderInputs.setProps({simpleMesh:this.getTextureProps(e)})}getTextureProps(e){const t=e||this.state.emptyTexture;return{..."webgpu"===this.context.device.type?{simpleMeshTexture:t}:{sampler:t},hasTexture:Boolean(e)}}};nl.defaultProps={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}},nl.layerName="SimpleMeshLayer";var rl;function il(e,t){const r=t.materialFactory||new ae(e,{modules:[G]}),i={...t.parsedPPBRMaterial.uniforms};delete i.camera;const s=Object.fromEntries(Object.entries({...i,...t.parsedPPBRMaterial.bindings}).filter(([e,t])=>r.ownsBinding(e)&&function(e){return e instanceof a.Buffer||e instanceof we||e instanceof n.Sampler||e instanceof n.Texture||e instanceof o.TextureView}(t))),A=r.createMaterial({id:t.id,bindings:s});return A.setProps({pbrMaterial:i}),A}function al(e,r){const{id:i,geometry:o,parsedPPBRMaterial:s,vertexCount:A,modelOptions:l={},instanceMatrices:c,morphTargets:u=[]}=r,f=l.userData?.gltfAnimatedCrowd;if(f&&c)throw new Error("Nested glTF crowd instancing is unsupported");a.log.info(4,"createGLTFModel defines: ",s.defines)();const d=[],h={},p=[],m=[],g=[],b=Boolean(f?.gpuAnimation);if(c||f)for(let t=0;t<4;t++){const n=new Float32Array(4*(f?.capacity||c?.length||0));c?.forEach((e,r)=>{for(let i=0;i<4;i++)n[4*r+i]=e[4*t+i]});const r=`instanceModelMatrixCol${t}`,o=e.createBuffer({id:`${i||"gltf"}-${r}`,data:n,usage:a.Buffer.VERTEX|a.Buffer.COPY_DST});h[r]=o,p.push({name:r,format:"float32x4",stepMode:"instance"}),d.push(o),m.push(o),g.push(n)}let v,y,x,_;if(f&&b){v=new Float32Array(4*f.capacity),x=new Float32Array(4*f.capacity);for(const[t,n]of[["instanceAnimationFrames",v],["instanceAnimationBlend",x]]){const r=e.createBuffer({id:`${i||"gltf"}-${t}`,data:n,usage:a.Buffer.VERTEX|a.Buffer.COPY_DST});h[t]=r,p.push({name:t,format:"float32x4",stepMode:"instance"}),d.push(r),"instanceAnimationFrames"===t?y=r:_=r}}const w=Boolean(s.defines.HAS_SKIN),T=Boolean(f&&w&&!b);let S,M;f&&T&&(M=new Float32Array(f.capacity*f.jointsPerInstance*16),S="webgpu"===e.type?e.createBuffer({id:`${i||"gltf"}-crowd-joint-matrices`,byteLength:M.byteLength,usage:a.Buffer.STORAGE|a.Buffer.COPY_DST}):e.createTexture({id:`${i||"gltf"}-crowd-joint-matrices`,format:"rgba32float",width:4*f.jointsPerInstance,height:f.capacity,usage:n.Texture.SAMPLE|n.Texture.COPY_DST,sampler:{minFilter:"nearest",magFilter:"nearest",mipmapFilter:"nearest"}}),d.push(S));const E=f?u.length:0,C=Math.floor((o.attributes.POSITION?.value.length||0)/3);let I,R,P;if(f&&E>0&&C>0){const t=new Float32Array(3*E*C*4);for(const[e,n]of u.entries())for(const[r,i]of["POSITION","NORMAL","TANGENT"].entries()){const a=n[i];if(!a)continue;const o="TANGENT"===i&&a.length===4*C?4:3;for(let n=0;n<C;n++){const i=4*((3*e+r)*C+n),s=n*o;t[i]=a[s]||0,t[i+1]=a[s+1]||0,t[i+2]=a[s+2]||0}}if(I=ol(e,`${i||"gltf"}-crowd-morph-targets`,t,C,3*E),d.push(I),!b){const t=Math.ceil(E/4);R=new Float32Array(f.capacity*t*4),P=ol(e,`${i||"gltf"}-crowd-morph-weights`,R,t,f.capacity),d.push(P)}}const N=w&&f?f.jointsPerInstance:0,k=4+4*N+E;let L,B;f?.gpuAnimation&&(B=new Float32Array(f.gpuAnimation.frameCount*k*4),L=ol(e,`${i||"gltf"}-crowd-animation-frames`,B,k,f.gpuAnimation.frameCount),d.push(L));let F="\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#ifdef HAS_GLTF_INSTANCING\n @location(8) instanceModelMatrixCol0: vec4f,\n @location(9) instanceModelMatrixCol1: vec4f,\n @location(10) instanceModelMatrixCol2: vec4f,\n @location(11) instanceModelMatrixCol3: vec4f,\n @builtin(instance_index) instanceIndex: u32,\n#endif\n#ifdef HAS_GPU_CROWD_ANIMATION\n @location(12) instanceAnimationFrames: vec4f,\n @location(13) instanceAnimationBlend: vec4f,\n#endif\n#ifdef HAS_INSTANCED_MORPH\n @builtin(vertex_index) vertexIndex: u32,\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#ifdef HAS_GLTF_INSTANCING\nfn getGLTFInstanceNormalMatrix(matrix: mat3x3f) -> mat3x3f {\n let firstCofactor = cross(matrix[1], matrix[2]);\n let inverseDeterminant = 1.0 / dot(matrix[0], firstCofactor);\n return mat3x3f(\n firstCofactor,\n cross(matrix[2], matrix[0]),\n cross(matrix[0], matrix[1])\n ) * inverseDeterminant;\n}\n#endif\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\n#ifdef HAS_INSTANCED_MORPH\n var animationFrames = vec4f(0.0);\n var animationBlend = vec4f(0.0);\n#ifdef HAS_GPU_CROWD_ANIMATION\n animationFrames = inputs.instanceAnimationFrames;\n animationBlend = inputs.instanceAnimationBlend;\n#endif\n position = vec4f(\n position.xyz + getGPUCrowdMorphDelta(\n inputs.instanceIndex,\n inputs.vertexIndex,\n 0u,\n u32(CROWD_MORPH_VERTEX_COUNT),\n u32(CROWD_MORPH_TARGET_COUNT),\n u32(CROWD_ANIMATION_JOINT_COUNT),\n animationFrames,\n animationBlend,\n u32(CROWD_ANIMATION_FRAME_STRIDE)\n ),\n 1.0\n );\n#ifdef HAS_NORMALS\n normal = normalize(normal + getGPUCrowdMorphDelta(\n inputs.instanceIndex,\n inputs.vertexIndex,\n 1u,\n u32(CROWD_MORPH_VERTEX_COUNT),\n u32(CROWD_MORPH_TARGET_COUNT),\n u32(CROWD_ANIMATION_JOINT_COUNT),\n animationFrames,\n animationBlend,\n u32(CROWD_ANIMATION_FRAME_STRIDE)\n ));\n#endif\n#ifdef HAS_TANGENTS\n tangent = vec4f(normalize(tangent.xyz + getGPUCrowdMorphDelta(\n inputs.instanceIndex,\n inputs.vertexIndex,\n 2u,\n u32(CROWD_MORPH_VERTEX_COUNT),\n u32(CROWD_MORPH_TARGET_COUNT),\n u32(CROWD_ANIMATION_JOINT_COUNT),\n animationFrames,\n animationBlend,\n u32(CROWD_ANIMATION_FRAME_STRIDE)\n )), tangent.w);\n#endif\n#endif\n\n#ifdef HAS_SKIN\n#ifdef HAS_GPU_CROWD_ANIMATION\n let skinMatrix = getGPUAnimatedSkinMatrix(\n inputs.WEIGHTS_0,\n inputs.JOINTS_0,\n inputs.instanceAnimationFrames,\n inputs.instanceAnimationBlend,\n u32(CROWD_ANIMATION_FRAME_STRIDE)\n );\n#else\n#ifdef HAS_INSTANCED_SKIN\n let skinMatrix = getInstancedSkinMatrix(\n inputs.WEIGHTS_0,\n inputs.JOINTS_0,\n inputs.instanceIndex,\n u32(CROWD_JOINTS_PER_INSTANCE)\n );\n#else\n let skinMatrix = getSkinMatrix(inputs.WEIGHTS_0, inputs.JOINTS_0);\n#endif\n#endif\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#ifdef HAS_GLTF_INSTANCING\n var instanceMatrix = mat4x4f(\n inputs.instanceModelMatrixCol0,\n inputs.instanceModelMatrixCol1,\n inputs.instanceModelMatrixCol2,\n inputs.instanceModelMatrixCol3\n );\n#ifdef HAS_GPU_CROWD_ANIMATION\n instanceMatrix *= sampleGPUAnimationMatrix(\n inputs.instanceAnimationFrames,\n inputs.instanceAnimationBlend,\n 0u,\n u32(CROWD_ANIMATION_FRAME_STRIDE)\n );\n#endif\n position = instanceMatrix * position;\n normal = normalize(getGLTFInstanceNormalMatrix(mat3x3f(\n instanceMatrix[0].xyz,\n instanceMatrix[1].xyz,\n instanceMatrix[2].xyz\n )) * normal);\n#ifdef HAS_TANGENTS\n tangent = vec4f(normalize((instanceMatrix * 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";for(const[t,n]of[["CROWD_JOINTS_PER_INSTANCE",f?.jointsPerInstance||0],["CROWD_MORPH_VERTEX_COUNT",C],["CROWD_MORPH_TARGET_COUNT",E],["CROWD_ANIMATION_JOINT_COUNT",N],["CROWD_ANIMATION_FRAME_STRIDE",k]])F=F.replaceAll(`u32(${t})`,`u32(${n})`);const U={id:i,source:F,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 #ifdef HAS_GLTF_INSTANCING\n in vec4 instanceModelMatrixCol0;\n in vec4 instanceModelMatrixCol1;\n in vec4 instanceModelMatrixCol2;\n in vec4 instanceModelMatrixCol3;\n #endif\n\n #ifdef HAS_GPU_CROWD_ANIMATION\n in vec4 instanceAnimationFrames;\n in vec4 instanceAnimationBlend;\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_INSTANCED_MORPH\n vec4 animationFrames = vec4(0.0);\n vec4 animationBlend = vec4(0.0);\n #ifdef HAS_GPU_CROWD_ANIMATION\n animationFrames = instanceAnimationFrames;\n animationBlend = instanceAnimationBlend;\n #endif\n pos.xyz += getGPUCrowdMorphDelta(\n uint(gl_InstanceID),\n uint(gl_VertexID),\n 0u,\n uint(CROWD_MORPH_TARGET_COUNT),\n uint(CROWD_ANIMATION_JOINT_COUNT),\n animationFrames,\n animationBlend\n );\n #ifdef HAS_NORMALS\n _NORMAL.xyz = normalize(_NORMAL.xyz + getGPUCrowdMorphDelta(\n uint(gl_InstanceID),\n uint(gl_VertexID),\n 1u,\n uint(CROWD_MORPH_TARGET_COUNT),\n uint(CROWD_ANIMATION_JOINT_COUNT),\n animationFrames,\n animationBlend\n ));\n #endif\n #ifdef HAS_TANGENTS\n _TANGENT.xyz = normalize(_TANGENT.xyz + getGPUCrowdMorphDelta(\n uint(gl_InstanceID),\n uint(gl_VertexID),\n 2u,\n uint(CROWD_MORPH_TARGET_COUNT),\n uint(CROWD_ANIMATION_JOINT_COUNT),\n animationFrames,\n animationBlend\n ));\n #endif\n #endif\n\n #ifdef HAS_SKIN\n #ifdef HAS_GPU_CROWD_ANIMATION\n mat4 skinMat = getGPUAnimatedSkinMatrix(\n WEIGHTS_0,\n JOINTS_0,\n instanceAnimationFrames,\n instanceAnimationBlend\n );\n #else\n #ifdef HAS_INSTANCED_SKIN\n mat4 skinMat = getInstancedSkinMatrix(\n WEIGHTS_0,\n JOINTS_0,\n uint(gl_InstanceID),\n uint(CROWD_JOINTS_PER_INSTANCE)\n );\n #else\n mat4 skinMat = getSkinMatrix(WEIGHTS_0, JOINTS_0);\n #endif\n #endif\n pos = skinMat * pos;\n _NORMAL = skinMat * _NORMAL;\n _TANGENT = vec4((skinMat * vec4(_TANGENT.xyz, 0.)).xyz, _TANGENT.w);\n #endif\n\n #ifdef HAS_GLTF_INSTANCING\n mat4 instanceMatrix = mat4(\n instanceModelMatrixCol0,\n instanceModelMatrixCol1,\n instanceModelMatrixCol2,\n instanceModelMatrixCol3\n );\n #ifdef HAS_GPU_CROWD_ANIMATION\n instanceMatrix *= sampleGPUAnimationMatrix(\n instanceAnimationFrames,\n instanceAnimationBlend,\n 0\n );\n #endif\n pos = instanceMatrix * pos;\n _NORMAL = vec4(normalize(transpose(inverse(mat3(instanceMatrix))) * _NORMAL.xyz), 0.0);\n _TANGENT = vec4(normalize(mat3(instanceMatrix) * _TANGENT.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:o,topology:o.topology,vertexCount:A,modules:[G,O,...f?[D]:[]],...l,...c||f?{attributes:{...l.attributes,...h},bufferLayout:[...l.bufferLayout||[],...p],instanceCount:c?.length||0,isInstanced:!0}:{},defines:{...s.defines,...l.defines,...c||f?{HAS_GLTF_INSTANCING:!0}:{},...T?{HAS_INSTANCED_SKIN:!0,CROWD_JOINTS_PER_INSTANCE:f.jointsPerInstance}:{},...b?{HAS_GPU_CROWD_ANIMATION:!0,CROWD_ANIMATION_FRAME_STRIDE:k}:{},...I?{HAS_INSTANCED_MORPH:!0,CROWD_MORPH_TARGET_COUNT:E}:{},...f?{CROWD_ANIMATION_JOINT_COUNT:N}:{}},parameters:{depthWriteEnabled:!0,depthCompare:"less",depthFormat:"depth24plus",cullMode:"back",...s.parameters,...l.parameters}},V=r.material||il(e,{id:i?`${i}-material`:void 0,parsedPPBRMaterial:s});U.material=V;const j=new t.Model(e,U),z={...s.uniforms,...l.uniforms,...s.bindings,...l.bindings},H=function(e,t,n){const r=new Map;for(const a of e){for(const e of Object.keys(a.uniformTypes||{}))r.set(e,a.name);for(const e of a.bindingLayout||[])r.set(e.name,a.name)}const i={};for(const[a,o]of Object.entries(n)){if(void 0===o)continue;const e=r.get(a);e&&!t.ownsModule(e)&&(i[e]||={},i[e][a]=o)}return i}(j.shaderInputs.getModules(),V,z);j.shaderInputs.setProps(H),S&&j.shaderInputs.setProps({skin:{jointMatrices:[],skinJointMatrices:S}}),(L||I||P)&&j.shaderInputs.setProps({gpuAnimation:{...L?{gpuAnimationFrames:L}:{},...I?{gpuMorphTargets:I}:{},...P?{gpuMorphWeights:P}:{}}});const q=new ke({managedResources:d,model:j,bounds:r.bounds,instanceMatrices:c});return f&&(q.userData.gltfAnimatedCrowd={transformBuffers:m,transformColumns:g,skinJointMatrices:S,jointMatrices:M,jointsPerInstance:f.jointsPerInstance,morphTargetCount:E,morphTargetData:I,morphWeights:R,morphWeightData:P,animationFrames:L,animationFrameValues:B,animationFrameStride:k,animationJointCount:N,animationParameters:v,animationParameterBuffer:y,animationBlend:x,animationBlendBuffer:_}),q}function ol(e,t,r,i,o){if("webgpu"===e.type)return e.createBuffer({id:t,data:r,usage:a.Buffer.STORAGE|a.Buffer.COPY_DST});const s=e.createTexture({id:t,format:"rgba32float",width:i,height:o,usage:n.Texture.SAMPLE|n.Texture.COPY_DST,sampler:{minFilter:"nearest",magFilter:"nearest",mipmapFilter:"nearest"}});return s.writeData(r,{width:i,height:o}),s}function sl(e,t,n){if(!e)return[...n];const r=e.value;return n.map((n,i)=>{const a=r[t*e.size+i];return void 0===a?n:e.normalized?e.value instanceof Int8Array?Math.max(a/127,-1):e.value instanceof Int16Array?Math.max(a/32767,-1):e.value instanceof Uint8Array?a/255:e.value instanceof Uint16Array?a/65535:a:a})}function Al(e){switch(e){case"VEC2":return 2;case"VEC3":return 3;case"VEC4":return 4;default:return 1}}function ll(e,t){e.userData.morphWeights=[...t];const n=e.userData.morphMeshes||[];for(const r of n)r.preorderTraversal(e=>{if(!(e instanceof ke))return;const n=e.userData.morphTargets;n&&(ee(e.model,n.geometry,n.targets,t),e.userData.morphWeights=[...t])})}function cl(e){switch(e){case rl.POINTS:return"point-list";case rl.LINES:return"line-list";case rl.LINE_STRIP:return"line-strip";case rl.TRIANGLES:return"triangle-list";case rl.TRIANGLE_STRIP:return"triangle-strip";default:throw new Error(String(e))}}!function(e){e[e.POINTS=0]="POINTS",e[e.LINES=1]="LINES",e[e.LINE_LOOP=2]="LINE_LOOP",e[e.LINE_STRIP=3]="LINE_STRIP",e[e.TRIANGLES=4]="TRIANGLES",e[e.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",e[e.TRIANGLE_FAN=6]="TRIANGLE_FAN",e[e.ONE=1]="ONE",e[e.SRC_ALPHA=770]="SRC_ALPHA",e[e.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",e[e.FUNC_ADD=32774]="FUNC_ADD",e[e.LINEAR=9729]="LINEAR",e[e.NEAREST=9728]="NEAREST",e[e.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",e[e.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",e[e.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",e[e.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",e[e.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",e[e.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",e[e.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",e[e.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",e[e.REPEAT=10497]="REPEAT",e[e.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",e[e.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL"}(rl||(rl={}));var ul=[dl("baseColor","pbr_baseColorSampler","baseColorTexture",["pbrMetallicRoughness","baseColorTexture"]),dl("metallicRoughness","pbr_metallicRoughnessSampler","metallicRoughnessTexture",["pbrMetallicRoughness","metallicRoughnessTexture"]),dl("normal","pbr_normalSampler","normalTexture",["normalTexture"]),dl("occlusion","pbr_occlusionSampler","occlusionTexture",["occlusionTexture"]),dl("emissive","pbr_emissiveSampler","emissiveTexture",["emissiveTexture"]),dl("specularColor","pbr_specularColorSampler","KHR_materials_specular.specularColorTexture",["extensions","KHR_materials_specular","specularColorTexture"]),dl("specularIntensity","pbr_specularIntensitySampler","KHR_materials_specular.specularTexture",["extensions","KHR_materials_specular","specularTexture"]),dl("transmission","pbr_transmissionSampler","KHR_materials_transmission.transmissionTexture",["extensions","KHR_materials_transmission","transmissionTexture"]),dl("thickness","pbr_thicknessSampler","KHR_materials_volume.thicknessTexture",["extensions","KHR_materials_volume","thicknessTexture"]),dl("clearcoat","pbr_clearcoatSampler","KHR_materials_clearcoat.clearcoatTexture",["extensions","KHR_materials_clearcoat","clearcoatTexture"]),dl("clearcoatRoughness","pbr_clearcoatRoughnessSampler","KHR_materials_clearcoat.clearcoatRoughnessTexture",["extensions","KHR_materials_clearcoat","clearcoatRoughnessTexture"]),dl("clearcoatNormal","pbr_clearcoatNormalSampler","KHR_materials_clearcoat.clearcoatNormalTexture",["extensions","KHR_materials_clearcoat","clearcoatNormalTexture"]),dl("sheenColor","pbr_sheenColorSampler","KHR_materials_sheen.sheenColorTexture",["extensions","KHR_materials_sheen","sheenColorTexture"]),dl("sheenRoughness","pbr_sheenRoughnessSampler","KHR_materials_sheen.sheenRoughnessTexture",["extensions","KHR_materials_sheen","sheenRoughnessTexture"]),dl("iridescence","pbr_iridescenceSampler","KHR_materials_iridescence.iridescenceTexture",["extensions","KHR_materials_iridescence","iridescenceTexture"]),dl("iridescenceThickness","pbr_iridescenceThicknessSampler","KHR_materials_iridescence.iridescenceThicknessTexture",["extensions","KHR_materials_iridescence","iridescenceThicknessTexture"]),dl("anisotropy","pbr_anisotropySampler","KHR_materials_anisotropy.anisotropyTexture",["extensions","KHR_materials_anisotropy","anisotropyTexture"]),dl("bump","pbr_bumpSampler","EXT_materials_bump.bumpTexture",["extensions","EXT_materials_bump","bumpTexture"]),dl("diffuseTransmission","pbr_diffuseTransmissionSampler","KHR_materials_diffuse_transmission.diffuseTransmissionTexture",["extensions","KHR_materials_diffuse_transmission","diffuseTransmissionTexture"]),dl("diffuseTransmissionColor","pbr_diffuseTransmissionColorSampler","KHR_materials_diffuse_transmission.diffuseTransmissionColorTexture",["extensions","KHR_materials_diffuse_transmission","diffuseTransmissionColorTexture"]),dl("multiscatterColor","pbr_multiscatterColorSampler","KHR_materials_volume_scatter.multiscatterColorTexture",["extensions","KHR_materials_volume_scatter","multiscatterColorTexture"])],fl=new Map(ul.map(e=>[e.slot,e]));function dl(e,t,n,r){return{slot:e,binding:t,displayName:n,pathSegments:r,colorSpace:"baseColor"===e||"emissive"===e||"specularColor"===e||"sheenColor"===e||"diffuseTransmissionColor"===e||"multiscatterColor"===e?"srgb":"linear",uvSetUniform:`${e}UVSet`,uvTransformUniform:`${e}UVTransform`}}function hl(e){const t=fl.get(e);if(!t)throw new Error(`Unknown PBR texture transform slot ${e}`);return t}function pl(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 ml(e){return(e?.extensions?.KHR_texture_transform)?.texCoord??e?.texCoord??0}function gl(e){const t=(new L).set(1,0,0,0,1,0,e.offset[0],e.offset[1],1),n=(new L).set(Math.cos(e.rotation),Math.sin(e.rotation),0,-Math.sin(e.rotation),Math.cos(e.rotation),0,0,0,1),r=(new L).set(e.scale[0],0,0,0,e.scale[1],0,0,0,1);return Array.from(t.multiplyRight(n).multiplyRight(r))}function bl(e,t){const n=new L(gl(e)),r=new L(gl(t)),i=new L(n).invert();return Array.from(r.multiplyRight(i))}function vl(e={}){const t=e.wrapS??e.parameters?.[rl.TEXTURE_WRAP_S],n=e.wrapT??e.parameters?.[rl.TEXTURE_WRAP_T],r=e.magFilter??e.parameters?.[rl.TEXTURE_MAG_FILTER],i=e.minFilter??e.parameters?.[rl.TEXTURE_MIN_FILTER],a=yl(t),o=yl(n),s=function(e){switch(e){case rl.NEAREST:return"nearest";case rl.LINEAR:return"linear";default:return}}(r);return{...a?{addressModeU:a}:{},...o?{addressModeV:o}:{},...s?{magFilter:s}:{},...xl(i)}}function yl(e){switch(e){case rl.CLAMP_TO_EDGE:return"clamp-to-edge";case rl.REPEAT:return"repeat";case rl.MIRRORED_REPEAT:return"mirror-repeat";default:return}}function xl(e){switch(e){case rl.NEAREST:return{minFilter:"nearest"};case rl.LINEAR:return{minFilter:"linear"};case rl.NEAREST_MIPMAP_NEAREST:return{minFilter:"nearest",mipmapFilter:"nearest"};case rl.LINEAR_MIPMAP_NEAREST:return{minFilter:"linear",mipmapFilter:"nearest"};case rl.NEAREST_MIPMAP_LINEAR:return{minFilter:"nearest",mipmapFilter:"linear"};case rl.LINEAR_MIPMAP_LINEAR:return{minFilter:"linear",mipmapFilter:"linear"};default:return{}}}var _l={NORMAL:["NORMAL","normals"],TANGENT:["TANGENT"],TEXCOORD_0:["TEXCOORD_0","texCoords"],TEXCOORD_1:["TEXCOORD_1","texCoords1"],JOINTS_0:["JOINTS_0"],WEIGHTS_0:["WEIGHTS_0"],COLOR_0:["COLOR_0","colors"]};function wl(e,t,n,r){const i={defines:{MANUAL_SRGB:!0},bindings:{},uniforms:{camera:[0,0,0],metallicRoughnessValues:[1,1]},parameters:{},glParameters:{},generatedTextures:[]};i.defines.USE_TEX_LOD=!0;const{imageBasedLightingEnvironment:o}=r;return o&&(i.bindings.pbr_diffuseEnvSampler=o.diffuseEnvSampler.texture,i.bindings.pbr_specularEnvSampler=o.specularEnvSampler.texture,i.bindings.pbr_brdfLUT=o.brdfLutTexture.texture,i.uniforms.IBLenabled=!0,i.uniforms.scaleIBLAmbient=[1,1]),r?.pbrDebug&&(i.defines.PBR_DEBUG=!0,i.uniforms.scaleDiffBaseMR=[0,0,0,0],i.uniforms.scaleFGDSpec=[0,0,0,0]),Sl(n,"NORMAL")&&(i.defines.HAS_NORMALS=!0),Sl(n,"TANGENT")&&r?.useTangents&&(i.defines.HAS_TANGENTS=!0),Sl(n,"TEXCOORD_0")&&(i.defines.HAS_UV=!0),Sl(n,"TEXCOORD_1")&&(i.defines.HAS_UV_1=!0),Sl(n,"JOINTS_0")&&Sl(n,"WEIGHTS_0")&&(i.defines.HAS_SKIN=!0),Sl(n,"COLOR_0")&&(i.defines.HAS_COLORS=!0),r?.imageBasedLightingEnvironment&&(i.defines.USE_IBL=!0),r?.lights&&(i.defines.USE_LIGHTS=!0),t&&(!1!==r.validateAttributes&&function(e,t){const n=Tl(e,0);n.length>0&&!Sl(t,"TEXCOORD_0")&&a.log.warn(`glTF material uses ${n.join(", ")} but primitive is missing TEXCOORD_0; textured shading will sample the default UV coordinates`)();const r=Tl(e,1);r.length>0&&!Sl(t,"TEXCOORD_1")&&a.log.warn(`glTF material uses ${r.join(", ")} with TEXCOORD_1 but primitive is missing TEXCOORD_1; those textures will be skipped`)();if(Boolean(e.unlit||e.extensions?.KHR_materials_unlit)||Sl(t,"NORMAL"))return;const i=e.normalTexture?"lit PBR shading with normalTexture":"lit PBR shading";a.log.warn(`glTF primitive is missing NORMAL while using ${i}; shading will fall back to geometric normals`)()}(t,n),function(e,t,n,r,i){n.uniforms.unlit=Boolean(t.unlit||t.extensions?.KHR_materials_unlit),t.pbrMetallicRoughness&&function(e,t,n,r,i){t.baseColorTexture&&El(e,t.baseColorTexture,"pbr_baseColorSampler",n,{featureOptions:{define:"HAS_BASECOLORMAP",enabledUniformName:"baseColorMapEnabled"},gltf:i,attributes:r,textureTransformSlot:"baseColor"});n.uniforms.baseColorFactor=t.baseColorFactor||[1,1,1,1],t.metallicRoughnessTexture&&El(e,t.metallicRoughnessTexture,"pbr_metallicRoughnessSampler",n,{featureOptions:{define:"HAS_METALROUGHNESSMAP",enabledUniformName:"metallicRoughnessMapEnabled"},gltf:i,attributes:r,textureTransformSlot:"metallicRoughness"});const{metallicFactor:a=1,roughnessFactor:o=1}=t;n.uniforms.metallicRoughnessValues=[a,o]}(e,t.pbrMetallicRoughness,n,r,i);if(t.normalTexture){El(e,t.normalTexture,"pbr_normalSampler",n,{featureOptions:{define:"HAS_NORMALMAP",enabledUniformName:"normalMapEnabled"},gltf:i,attributes:r,textureTransformSlot:"normal"});const{scale:a=1}=t.normalTexture;n.uniforms.normalScale=a}if(t.occlusionTexture){El(e,t.occlusionTexture,"pbr_occlusionSampler",n,{featureOptions:{define:"HAS_OCCLUSIONMAP",enabledUniformName:"occlusionMapEnabled"},gltf:i,attributes:r,textureTransformSlot:"occlusion"});const{strength:a=1}=t.occlusionTexture;n.uniforms.occlusionStrength=a}n.uniforms.emissiveFactor=t.emissiveFactor||[0,0,0],t.emissiveTexture&&El(e,t.emissiveTexture,"pbr_emissiveSampler",n,{featureOptions:{define:"HAS_EMISSIVEMAP",enabledUniformName:"emissiveMapEnabled"},gltf:i,attributes:r,textureTransformSlot:"emissive"});switch(function(e,t,n,r,i={}){if(!t)return;(function(e){return Boolean(e.KHR_materials_specular||e.KHR_materials_ior||e.EXT_materials_bump||e.KHR_materials_transmission||e.KHR_materials_diffuse_transmission||e.KHR_materials_volume||e.KHR_materials_volume_scatter||e.KHR_materials_dispersion||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,r,i={}){if(!t)return;t.specularColorFactor&&(n.uniforms.specularColorFactor=t.specularColorFactor);void 0!==t.specularFactor&&(n.uniforms.specularIntensityFactor=t.specularFactor);t.specularColorTexture&&El(e,t.specularColorTexture,"pbr_specularColorSampler",n,{featureOptions:{define:"HAS_SPECULARCOLORMAP",enabledUniformName:"specularColorMapEnabled"},gltf:r,attributes:i,textureTransformSlot:"specularColor"});t.specularTexture&&El(e,t.specularTexture,"pbr_specularIntensitySampler",n,{featureOptions:{define:"HAS_SPECULARINTENSITYMAP",enabledUniformName:"specularIntensityMapEnabled"},gltf:r,attributes:i,textureTransformSlot:"specularIntensity"})})(e,t.KHR_materials_specular,n,r,i),function(e,t){void 0!==e?.ior&&(t.uniforms.ior=e.ior)}(t.KHR_materials_ior,n),function(e,t,n,r,i={}){if(!t)return;n.uniforms.bumpFactor=Math.max(t.bumpFactor??1,0),t.bumpTexture&&El(e,t.bumpTexture,"pbr_bumpSampler",n,{featureOptions:{define:"HAS_BUMPMAP",enabledUniformName:"bumpMapEnabled"},gltf:r,attributes:i,textureTransformSlot:"bump"})}(e,t.EXT_materials_bump,n,r,i),function(e,t,n,r,i={}){if(!t)return;void 0!==t.transmissionFactor&&(n.uniforms.transmissionFactor=t.transmissionFactor);t.transmissionTexture&&El(e,t.transmissionTexture,"pbr_transmissionSampler",n,{featureOptions:{define:"HAS_TRANSMISSIONMAP",enabledUniformName:"transmissionMapEnabled"},gltf:r,attributes:i,textureTransformSlot:"transmission"});((t.transmissionFactor??0)>0||t.transmissionTexture)&&(a.log.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=rl.FUNC_ADD,e.glParameters.blendFunc=[rl.ONE,rl.ONE_MINUS_SRC_ALPHA,rl.ONE,rl.ONE_MINUS_SRC_ALPHA]}(n))}(e,t.KHR_materials_transmission,n,r,i),function(e,t,n,r,i={}){if(!t)return;n.uniforms.diffuseTransmissionFactor=Math.min(Math.max(t.diffuseTransmissionFactor??0,0),1),n.uniforms.diffuseTransmissionColorFactor=t.diffuseTransmissionColorFactor||[1,1,1],t.diffuseTransmissionTexture&&El(e,t.diffuseTransmissionTexture,"pbr_diffuseTransmissionSampler",n,{featureOptions:{define:"HAS_DIFFUSETRANSMISSIONMAP",enabledUniformName:"diffuseTransmissionMapEnabled"},gltf:r,attributes:i,textureTransformSlot:"diffuseTransmission"});t.diffuseTransmissionColorTexture&&El(e,t.diffuseTransmissionColorTexture,"pbr_diffuseTransmissionColorSampler",n,{featureOptions:{define:"HAS_DIFFUSETRANSMISSIONCOLORMAP",enabledUniformName:"diffuseTransmissionColorMapEnabled"},gltf:r,attributes:i,textureTransformSlot:"diffuseTransmissionColor"})}(e,t.KHR_materials_diffuse_transmission,n,r,i),function(e,t,n,r,i={}){if(!t)return;void 0!==t.thicknessFactor&&(n.uniforms.thicknessFactor=t.thicknessFactor);t.thicknessTexture&&El(e,t.thicknessTexture,"pbr_thicknessSampler",n,{featureOptions:{define:"HAS_THICKNESSMAP"},gltf:r,attributes:i,textureTransformSlot:"thickness"});void 0!==t.attenuationDistance&&(n.uniforms.attenuationDistance=t.attenuationDistance);t.attenuationColor&&(n.uniforms.attenuationColor=t.attenuationColor)}(e,t.KHR_materials_volume,n,r,i),function(e,t,n,r,i,a={}){if(!t||!n)return;r.uniforms.multiscatterColorFactor=t.multiscatterColorFactor||t.multiscatterColor||[0,0,0],r.uniforms.scatterAnisotropy=Math.min(Math.max(t.scatterAnisotropy??0,-.999),.999),t.multiscatterColorTexture&&El(e,t.multiscatterColorTexture,"pbr_multiscatterColorSampler",r,{featureOptions:{define:"HAS_MULTISCATTERCOLORMAP",enabledUniformName:"multiscatterColorMapEnabled"},gltf:i,attributes:a,textureTransformSlot:"multiscatterColor"})}(e,t.KHR_materials_volume_scatter,t.KHR_materials_volume,n,r,i),function(e,t){void 0!==e?.dispersion&&(t.uniforms.dispersion=Math.max(e.dispersion,0))}(t.KHR_materials_dispersion,n),function(e,t,n,r,i={}){if(!t)return;void 0!==t.clearcoatFactor&&(n.uniforms.clearcoatFactor=t.clearcoatFactor);void 0!==t.clearcoatRoughnessFactor&&(n.uniforms.clearcoatRoughnessFactor=t.clearcoatRoughnessFactor);t.clearcoatTexture&&El(e,t.clearcoatTexture,"pbr_clearcoatSampler",n,{featureOptions:{define:"HAS_CLEARCOATMAP",enabledUniformName:"clearcoatMapEnabled"},gltf:r,attributes:i,textureTransformSlot:"clearcoat"});t.clearcoatRoughnessTexture&&El(e,t.clearcoatRoughnessTexture,"pbr_clearcoatRoughnessSampler",n,{featureOptions:{define:"HAS_CLEARCOATROUGHNESSMAP",enabledUniformName:"clearcoatRoughnessMapEnabled"},gltf:r,attributes:i,textureTransformSlot:"clearcoatRoughness"});t.clearcoatNormalTexture&&El(e,t.clearcoatNormalTexture,"pbr_clearcoatNormalSampler",n,{featureOptions:{define:"HAS_CLEARCOATNORMALMAP"},gltf:r,attributes:i,textureTransformSlot:"clearcoatNormal"})}(e,t.KHR_materials_clearcoat,n,r,i),function(e,t,n,r,i={}){if(!t)return;t.sheenColorFactor&&(n.uniforms.sheenColorFactor=t.sheenColorFactor);void 0!==t.sheenRoughnessFactor&&(n.uniforms.sheenRoughnessFactor=t.sheenRoughnessFactor);t.sheenColorTexture&&El(e,t.sheenColorTexture,"pbr_sheenColorSampler",n,{featureOptions:{define:"HAS_SHEENCOLORMAP",enabledUniformName:"sheenColorMapEnabled"},gltf:r,attributes:i,textureTransformSlot:"sheenColor"});t.sheenRoughnessTexture&&El(e,t.sheenRoughnessTexture,"pbr_sheenRoughnessSampler",n,{featureOptions:{define:"HAS_SHEENROUGHNESSMAP",enabledUniformName:"sheenRoughnessMapEnabled"},gltf:r,attributes:i,textureTransformSlot:"sheenRoughness"})}(e,t.KHR_materials_sheen,n,r,i),function(e,t,n,r,i={}){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&&El(e,t.iridescenceTexture,"pbr_iridescenceSampler",n,{featureOptions:{define:"HAS_IRIDESCENCEMAP",enabledUniformName:"iridescenceMapEnabled"},gltf:r,attributes:i,textureTransformSlot:"iridescence"});t.iridescenceThicknessTexture&&El(e,t.iridescenceThicknessTexture,"pbr_iridescenceThicknessSampler",n,{featureOptions:{define:"HAS_IRIDESCENCETHICKNESSMAP"},gltf:r,attributes:i,textureTransformSlot:"iridescenceThickness"})}(e,t.KHR_materials_iridescence,n,r,i),function(e,t,n,r,i={}){if(!t)return;void 0!==t.anisotropyStrength&&(n.uniforms.anisotropyStrength=t.anisotropyStrength);void 0!==t.anisotropyRotation&&(n.uniforms.anisotropyRotation=t.anisotropyRotation);t.anisotropyTexture&&El(e,t.anisotropyTexture,"pbr_anisotropySampler",n,{featureOptions:{define:"HAS_ANISOTROPYMAP",enabledUniformName:"anisotropyMapEnabled"},gltf:r,attributes:i,textureTransformSlot:"anisotropy"})}(e,t.KHR_materials_anisotropy,n,r,i),function(e,t){void 0!==e?.emissiveStrength&&(t.uniforms.emissiveStrength=e.emissiveStrength)}(t.KHR_materials_emissive_strength,n)}(e,t.extensions,n,i,r),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":a.log.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=rl.FUNC_ADD,e.glParameters.blendFunc=[rl.SRC_ALPHA,rl.ONE_MINUS_SRC_ALPHA,rl.ONE,rl.ONE_MINUS_SRC_ALPHA]}(n)}}(e,t,i,n,r.gltf)),i}function Tl(e,t){const n=[];for(const r of ul){const i=Ml(e,r.pathSegments);i&&(ml(i)===t&&n.push(r.displayName))}return n}function Sl(e,t){return _l[t].some(t=>Boolean(e[t]))}function Ml(e,t){let n=e;for(const r of t)if(n=n?.[r],!n)return null;return n}function El(e,t,r,i,o={}){const{featureOptions:s={},gltf:A,attributes:l={},textureTransformSlot:c}=o,{define:u,enabledUniformName:f}=s,d=ml(t);if(d>1)return void a.log.warn(`Skipping ${String(r)} because ${d} is not supported; only TEXCOORD_0 and TEXCOORD_1 are currently available`)();if(1===d&&!Sl(l,"TEXCOORD_1"))return void a.log.warn(`Skipping ${String(r)} because it requires TEXCOORD_1 but the primitive does not provide TEXCOORD_1`)();const h=function(e,t){if(e.texture||void 0===e.index||!t?.textures)return e;const n=t.textures[e.index];return n?"texture"in n&&n.texture?{...n,...e,texture:n.texture}:"source"in n?{...e,texture:n}:e:e}(t,A),p=h.texture?.source?.image;if(!p)return void a.log.warn(`Skipping unresolved glTF texture for ${String(r)}`)();const m=function(e,t,r){if("compressed"in t)return function(e,t,r){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 a.log.warn("createCompressedTexture: compressed image has no valid mip levels, creating fallback")(),Cl(e,r);const o=i[0],s=o.width??t.width??0,A=o.height??t.height??0;if(s<=0||A<=0)return a.log.warn("createCompressedTexture: base level has invalid dimensions, creating fallback")(),Cl(e,r);const l=Il(o);if(!l)return a.log.warn("createCompressedTexture: compressed image has no textureFormat, creating fallback")(),Cl(e,r);if(!e.isTextureFormatSupported(l))return a.log.warn(`createCompressedTexture: ${e.type} device does not support '${l}', creating fallback`)(),Cl(e,r);const c=function(e,t,r){const{blockWidth:i=1,blockHeight:a=1}=n.textureFormatDecoder.getInfo(r);let o=1;for(let n=1;;n++){const r=Math.max(1,e>>n),s=Math.max(1,t>>n);if(r<i||s<a)break;o++}return o}(s,A,l),u=Math.min(i.length,c);let f=1;for(let n=1;n<u;n++){const e=i[n];if(!e.data||e.width<=0||e.height<=0){a.log.warn(`createCompressedTexture: mip level ${n} has invalid data/dimensions, truncating`)();break}const t=Il(e);if(t&&t!==l){a.log.warn(`createCompressedTexture: mip level ${n} format '${t}' differs from base '${l}', truncating`)();break}const r=Math.max(1,s>>n),o=Math.max(1,A>>n);if(e.width!==r||e.height!==o){a.log.warn(`createCompressedTexture: mip level ${n} dimensions ${e.width}x${e.height} don't match expected ${r}x${o}, truncating`)();break}f++}const d=e.createTexture({...r,format:l,usage:n.Texture.TEXTURE|n.Texture.COPY_DST,width:s,height:A,mipLevels:f,data:o.data});for(let n=1;n<f;n++)d.writeData(i[n].data,{width:i[n].width,height:i[n].height,mipLevel:n});return d}(e,t,{id:r.id,sampler:r.sampler});const i=void 0!==r.width&&void 0!==r.height?{width:r.width,height:r.height}:e.getExternalImageSize(t),o="nearest"===r.sampler.mipmapFilter||"linear"===r.sampler.mipmapFilter,s=o?e.getMipLevelCount(i.width,i.height):1,A=e.createTexture({id:r.id,sampler:r.sampler,width:i.width,height:i.height,mipLevels:s,...o?{usage:n.Texture.SAMPLE|n.Texture.RENDER|n.Texture.COPY_DST|n.Texture.COPY_SRC}:{},...r.colorSpace?{format:"srgb"===r.colorSpace?"rgba8unorm-srgb":"rgba8unorm"}:{},data:t});s>1&&("webgl"===e.type?A.generateMipmapsWebGL():"webgpu"===e.type&&e.generateMipmapsWebGPU(A));return A}(e,p,{id:h.uniformName||h.id,sampler:{addressModeU:"repeat",addressModeV:"repeat",minFilter:"linear",magFilter:"linear",...vl(h.texture.sampler)}});if(i.bindings[r]=m,u&&(i.defines[u]=!0),f&&(i.uniforms[f]=!0),c){const e=hl(c);i.uniforms[e.uvSetUniform]=d,i.uniforms[e.uvTransformUniform]=gl(pl(t))}i.generatedTextures.push(m)}function Cl(e,t){return e.createTexture({...t,format:"rgba8unorm",width:1,height:1,mipLevels:1})}function Il(e){return e.textureFormat}var Rl={modelOptions:{},pbrDebug:!1,imageBasedLightingEnvironment:void 0,lights:!0,useTangents:!1,useByteColors:!0,strictExtensions:!1};function Pl(e,t,r={}){const i=new Set,a={...Rl,...r,generatedTextures:i},o=new ae(e,{modules:[G]}),s=(t.materials||[]).map((n,r)=>il(e,{id:Ll(n,r),parsedPPBRMaterial:Nl(e,n,{},{...a,gltf:t,validateAttributes:!1}),materialFactory:o})),A=new Map;(t.materials||[]).forEach((e,t)=>{A.set(e.id,s[t])});const l=new Map;t.meshes.forEach((n,r)=>{const i=kl(e,n,t,A,a);l.set(n.id,i)});const c=new Map,u=new Map,f=new Set,d=new Set,h=new Set;return t.nodes.forEach((e,t)=>{const n=function(e,t){return new Ne({id:t.name||t.id,children:[],matrix:t.matrix,display:!1!==t.extensions?.KHR_node_visibility?.visible,position:t.translation,rotation:t.rotation,scale:t.scale})}(0,e);c.set(t,n),u.set(e.id,n)}),t.nodes.forEach((r,i)=>{if(c.get(i).add((r.children??[]).map(({id:e})=>{const t=u.get(e);if(!t)throw new Error(`Cannot find child ${e} of node ${i}`);return t})),r.mesh){const o=r.mesh,s=function(e,t){const r=t.extensions?.EXT_mesh_gpu_instancing?.attributes;if(!r||"object"!=typeof r)return null;const i={};let a;for(const[n,s]of Object.entries(r)){const t="number"==typeof s?e.accessors[s]:s;if(!t||!ArrayBuffer.isView(t.value))throw new Error(`Invalid glTF instance accessor for ${n}`);if(void 0!==a&&t.count!==a)throw new Error("glTF instance attributes must have matching accessor counts");a=t.count,i[n]={value:t.value,size:t.components||Al(t.type),count:t.count,normalized:Boolean(t.normalized)}}const o=[];for(let s=0;s<(a||0);s++){const e=sl(i.TRANSLATION,s,[0,0,0]),t=sl(i.ROTATION,s,[0,0,0,1]),r=sl(i.SCALE,s,[1,1,1]),a=Math.hypot(...t);if(a>0)for(let n=0;n<t.length;n++)t[n]/=a;o.push((new n.Matrix4).translate(e).multiplyRight((new n.Matrix4).fromQuaternion(t)).scale(r))}return{matrices:o,attributes:i}}(t,r),u=o.primitives.some(e=>Boolean(e.targets?.length)),p=s||u&&f.has(o.id)?kl(e,o,t,A,a,s||void 0):l.get(o.id);if(!p)throw new Error(`Cannot find mesh child ${r.mesh.id} of node ${i}`);const m=c.get(i),g=l.get(o.id),b=d.has(o.id)&&(void 0!==r.skin||h.has(o.id))&&p===g?kl(e,o,t,A,a):p;if(m.add(b),m.userData.gltfMesh=b,d.add(o.id),void 0!==r.skin&&h.add(o.id),u){f.add(o.id);const e=o.primitives.find(e=>e.targets?.length)?.targets?.length||0,t=r.weights||o.weights||new Array(e).fill(0);m.userData.morphMeshes=[b],a.modelOptions?.userData?.gltfAnimatedCrowd?m.userData.morphWeights=[...t]:ll(m,t)}}}),{scenes:t.scenes.map(e=>{const t=(e.nodes||[]).map(({id:t})=>{const n=u.get(t);if(!n)throw new Error(`Cannot find child ${t} of scene ${e.name||e.id}`);return n});return new Ne({id:e.name||e.id,children:t})}),materials:s,gltfMeshIdToNodeMap:l,gltfNodeIdToNodeMap:u,gltfNodeIndexToNodeMap:c,generatedTextures:i}}function Nl(e,t,n,r){const i=wl(e,t,n,r);for(const a of i.generatedTextures)r.generatedTextures.add(a);return i}function kl(e,n,r,i,a,o){const s=(n.primitives||[]).map((s,A)=>function({device:e,gltfPrimitive:n,primitiveIndex:r,gltfMesh:i,gltf:a,gltfMaterialIdToMaterialMap:o,options:s,instancing:A}){const l=n.name||`${i.name||i.id}-primitive-${r}`,c=function(e){let t=1/0;for(const n of Object.values(e))if(n){const{value:e,size:r,components:i}=n,a=r??i;void 0!==e?.length&&a>=1&&(t=Math.min(t,e.length/a))}if(!Number.isFinite(t))throw new Error("Could not determine vertex count from attributes");return t}(n.attributes),u=function(e,n,r){const i={};for(const[t,a]of Object.entries(n.attributes)){const{components:e,size:r,value:o,normalized:s}=a,A="POSITION"===t||"NORMAL"===t||"TANGENT"===t,l=Boolean(n.targets?.length&&A);i[t]={size:r??e,value:l?Z({value:o,normalized:s}):o,normalized:!l&&s}}return new t.Geometry({id:e,topology:r.topology,indices:r.indices??n.indices?.value,attributes:i})}(l,n,function(e,t,n){if(e!==rl.LINE_LOOP&&e!==rl.TRIANGLE_FAN)return{topology:cl(e)};const r=t?.length??n,i=e===rl.LINE_LOOP?r>=2?2*r:0:r>=3?3*(r-2):0,a=new(t instanceof Uint32Array||!t&&n>65536?Uint32Array:Uint16Array)(i),o=e=>t?.[e]??e;if(e===rl.LINE_LOOP){for(let e=0;e<r;e++)a[2*e]=o(e),a[2*e+1]=o((e+1)%r);return{topology:"line-list",indices:a}}for(let s=0;s<r-2;s++)a[3*s]=o(0),a[3*s+1]=o(s+1),a[3*s+2]=o(s+2);return{topology:"triangle-list",indices:a}}(n.mode??4,n.indices?.value,c)),f=u.vertexCount,d=function(e,t,n){if(!e.targets?.length)return;const r={};for(const i of["POSITION","NORMAL","TANGENT"]){const e=n.attributes[i]?.value;e instanceof Float32Array&&(r[i]=new Float32Array(e))}return{geometry:n,baseAttributes:r,targets:e.targets.map(e=>{const n={};for(const r of["POSITION","NORMAL","TANGENT"]){const i=e[r],a="number"==typeof i?t.accessors[i]:i;a?.value&&ArrayBuffer.isView(a.value)&&(n[r]=Z(a))}return n})}}(n,a,u),h=Nl(e,n.material,u.attributes,{...s,gltf:a}),p=al(e,{id:l,geometry:u,material:n.material&&o.get(n.material.id)||null,parsedPPBRMaterial:h,modelOptions:s.modelOptions,vertexCount:f,bounds:[n.attributes.POSITION.min,n.attributes.POSITION.max],instanceMatrices:A?.matrices,morphTargets:d?.targets});A&&(p.userData.gltfInstancing=A);const m=n.extensions?.KHR_materials_variants?.mappings||[];if(m.length){const t=new Map;for(const n of m){const r="number"==typeof n.material?a.materials[n.material]:n.material,i=r&&o.get(r.id);if(!i)continue;const A=Nl(e,r,u.attributes,{...s,gltf:a});for(const e of n.variants||[])t.set(e,{material:i,parameters:{...p.model.parameters,...A.parameters,depthWriteEnabled:"BLEND"!==r.alphaMode,cullMode:r.doubleSided?"none":"back"}})}p.userData.gltfMaterialVariants={defaultMaterial:p.model.material,defaultParameters:{...p.model.parameters},mappings:t}}d&&(p.userData.morphTargets=d);return p}({device:e,gltfPrimitive:s,primitiveIndex:A,gltfMesh:n,gltf:r,gltfMaterialIdToMaterialMap:i,options:a,instancing:o}));return new Ne({id:n.name||n.id,children:s})}function Ll(e,t){return e.name||e.id||`material-${t}`}function Bl(e,t={}){const n=t.lightDefinitions||e.lights||e.extensions?.KHR_lights_punctual?.lights;if(!n||!Array.isArray(n)||0===n.length)return[];const r=[],i=function(e){const t=new Map;for(const n of e)for(const e of n.children||[])t.set(e.id,n);return t}(e.nodes||[]),a=new Map;for(const o of e.nodes||[]){if(!Ol(o,i,t.nodeVisibility))continue;const e=o.light??o.extensions?.KHR_lights_punctual?.light;if("number"!=typeof e||t.nodeIdentifiers&&!t.nodeIdentifiers.has(o.id))continue;const s=n[e];if(!s)continue;const A=Fl(s.color||[1,1,1],t.useByteColors??!0),l=s.intensity??1,c=s.range,u=jl(o,i,a);switch(s.type){case"directional":r.push(Ul(u,A,l));break;case"point":r.push(Dl(u,A,l,c));break;case"spot":r.push(Vl(u,A,l,c,s.spot))}}return r}function Ol(e,t,n){let r=e;for(;r;){const e=n?.get(r.id);if(e?!e.display:!1===r.extensions?.KHR_node_visibility?.visible)return!1;r=t.get(r.id)}return!0}function Fl(e,n){return n?e.map(e=>255*e):t.normalizeByteColor3(e,!1)}function Dl(e,t,n,r){let i=[1,0,0];return void 0!==r&&r>0&&(i=[1,0,1/(r*r)]),{type:"point",position:zl(e),color:t,intensity:n,attenuation:i}}function Ul(e,t,n){return{type:"directional",direction:Gl(e),color:t,intensity:n}}function Vl(e,t,n,r,i={}){let a=[1,0,0];return void 0!==r&&r>0&&(a=[1,0,1/(r*r)]),{type:"spot",position:zl(e),direction:Gl(e),color:t,intensity:n,attenuation:a,innerConeAngle:i.innerConeAngle??0,outerConeAngle:i.outerConeAngle??Math.PI/4}}function jl(e,t,r){const i=r.get(e.id);if(i)return i;const a=function(e){if(e.matrix)return new n.Matrix4(e.matrix);const t=new n.Matrix4;e.translation&&t.translate(e.translation);e.rotation&&t.multiplyRight((new n.Matrix4).fromQuaternion(e.rotation));e.scale&&t.scale(e.scale);return t}(e),o=t.get(e.id),s=o?new n.Matrix4(jl(o,t,r)).multiplyRight(a):a;return r.set(e.id,s),s}function zl(e){return e.transformAsPoint([0,0,0])}function Gl(e){return e.transformDirection([0,0,-1])}var Hl=class extends H{animation;gltfNodeIdToNodeMap;onVisibilityChange;cameras;lightDefinitions;onLightChange;materials;clip;mixer;action;materialTextureTransformState=new Map;constructor(e){if(super({name:e.animation.name||"unnamed"}),this.animation=e.animation,this.gltfNodeIdToNodeMap=e.gltfNodeIdToNodeMap,this.onVisibilityChange=e.onVisibilityChange,this.cameras=e.cameras||[],this.lightDefinitions=e.lightDefinitions||[],this.onLightChange=e.onLightChange,this.materials=e.materials||[],this.animation.name||="unnamed",this.name=this.animation.name,this.animation.channels.some(e=>"material"===e.type||"textureTransform"===e.type)&&!this.materials.length)throw new Error(`Animation ${this.animation.name} targets materials, but GLTFAnimator was created without a materials array`);this.mixer=e.mixer||new X,this.clip=new J({name:this.name,tracks:this.animation.channels.map(e=>this.createAnimationTrack(e))}),this.action=this.mixer.clipAction(this.clip).play()}applyTime(e){this.action.setTime(e),this.mixer.update(0)}createAnimationTrack(e){const t=function(e){switch(e){case"STEP":case"LINEAR":case"CUBICSPLINE":return e;default:throw new Error(`Unsupported animation interpolation: ${e}`)}}(e.sampler.interpolation);if("node"===e.type)return new $({name:`${e.targetNodeId}.${e.path}`,times:e.sampler.input,values:e.sampler.output,interpolation:t,valueType:"rotation"===e.path?"quaternion":"vector",binding:{id:`node:${e.targetNodeId}:${e.path}`,getValue:()=>this.getNodeAnimationValue(e.targetNodeId,e.path),setValue:t=>this.applyNodeAnimationValue(e.targetNodeId,e.path,t)}});if("camera"===e.type||"light"===e.type)return new $({name:e.pointer,times:e.sampler.input,values:e.sampler.output,interpolation:t,binding:{id:e.pointer,getValue:()=>this.getSceneAnimationValue(e),setValue:t=>this.applySceneAnimationValue(e,t)}});const n=this.materials[e.targetMaterialIndex];if(!n)throw new Error(`Cannot find animation target material ${e.targetMaterialIndex} for ${e.pointer}`);return new $({name:e.pointer,times:e.sampler.input,values:e.sampler.output,interpolation:t,binding:{id:e.pointer,getValue:"material"===e.type?()=>function(e,t){const n=e.shaderInputs.getUniformValues().pbrMaterial?.[t.property];return Array.isArray(n)?void 0===t.component?[...n]:[n[t.component]]:"number"==typeof n?[n]:[]}(n,e):void 0,setValue:t=>{"material"===e.type?function(e,t,n){const r=void 0!==t.component?{[t.property]:Kl(Ql(e,t.property),t.component,n[0])}:{[t.property]:1===n.length?n[0]:n};e.setProps({pbrMaterial:r})}(n,e,t):function(e,t,n,r){const i=hl(t.textureSlot),a=function(e,t,n){const r=e.get(t)||{};let i=r[n.textureSlot];i||(i={offset:[...n.baseTransform.offset],rotation:n.baseTransform.rotation,scale:[...n.baseTransform.scale]},r[n.textureSlot]=i,e.set(t,r));return i}(r,e,t);switch(t.path){case"offset":void 0!==t.component?a.offset[t.component]=n[0]:a.offset=[n[0],n[1]];break;case"rotation":a.rotation=n[0];break;case"scale":void 0!==t.component?a.scale[t.component]=n[0]:a.scale=[n[0],n[1]]}e.setProps({pbrMaterial:{[i.uvTransformUniform]:bl(t.baseTransform,a)}})}(n,e,t,this.materialTextureTransformState)}}})}getNodeAnimationValue(e,t){const n=this.getTargetNode(e);switch(t){case"translation":return Array.from(n.position);case"rotation":return Array.from(n.rotation);case"scale":return Array.from(n.scale);case"weights":return Array.from(n.userData.morphWeights||[]);case"visibility":return[n.display?1:0];default:return[]}}applyNodeAnimationValue(e,t,n){const r=this.getTargetNode(e);switch(t){case"translation":r.setPosition(n).updateMatrix();break;case"rotation":r.setRotation(n).updateMatrix();break;case"scale":r.setScale(n).updateMatrix();break;case"weights":ll(r,n);break;case"visibility":r.setProps({display:0!==n[0]}),this.onVisibilityChange?.();break;default:a.log.warn(`Bad animation path ${t}`)()}}getTargetNode(e){const t=this.gltfNodeIdToNodeMap.get(e);if(!t)throw new Error(`Cannot find animation target node ${e}`);return t}getSceneAnimationValue(e){if("camera"===e.type){const t=this.cameras[e.targetCameraIndex]?.[e.projection]?.[e.property];return"number"==typeof t?[t]:[]}const t=this.lightDefinitions[e.targetLightIndex],n="innerConeAngle"===e.property||"outerConeAngle"===e.property?t?.spot?.[e.property]:t?.[e.property];return Array.isArray(n)?void 0===e.component?[...n]:[n[e.component]]:"number"==typeof n?[n]:[]}applySceneAnimationValue(e,t){if("camera"===e.type){const n=this.cameras[e.targetCameraIndex];return void(n?.[e.projection]&&(n[e.projection][e.property]=t[0]))}const n=this.lightDefinitions[e.targetLightIndex];if(n){if("innerConeAngle"===e.property||"outerConeAngle"===e.property)n.spot||={},n.spot[e.property]=t[0];else if(void 0!==e.component){const r=[...n[e.property]||[1,1,1]];r[e.component]=t[0],n[e.property]=r}else n[e.property]=1===t.length?t[0]:[...t];this.onLightChange?.()}}},ql=class extends q{mixer;activeClip;onUpdate;previousTimeSeconds;constructor(e){const t=new X;super(e.animations.map((n,r)=>{const i=n.name||`Animation-${r}`;return new Hl({gltfNodeIdToNodeMap:e.gltfNodeIdToNodeMap,onVisibilityChange:e.onVisibilityChange,cameras:e.cameras,lightDefinitions:e.lightDefinitions,onLightChange:e.onLightChange,materials:e.materials,mixer:t,animation:{name:i,channels:n.channels}})})),this.mixer=t,this.onUpdate=e.onUpdate,this.activeClip=this.clips[0]?.name,!1===e.autoplay?this.clips.forEach(e=>{e.playing=!1,e.action.stop()}):"first"===e.autoplay&&this.activeClip&&this.selectClip(this.activeClip)}setUpdateHandler(e){return this.onUpdate=e,this}setTime(e){const t=e/1e3,n=void 0===this.previousTimeSeconds?0:t-this.previousTimeSeconds;this.previousTimeSeconds=t;const r=n*this.mixer.timeScale;this.clips.forEach(e=>{if(!e.playing)return void e.action.stop();if(e.action.paused)return;e.action.resume();const n=Math.max(0,t-e.startTime)*e.speed;e.action.setTime(n-r*e.action.timeScale)}),this.mixer.update(n),this.onUpdate?.()}update(e){this.mixer.update(e),this.onUpdate?.()}selectClip(e,t={}){const n=this.clips.find(t=>t.name===e);if(!n)throw new Error(`Unknown animation clip: ${e}`);const r=this.clips.find(e=>e.name===this.activeClip),i=t.crossFadeDuration||0;for(const a of this.clips)a===n||i>0&&a===r||(a.playing=!1,a.action.stop());return n.playing=!0,i>0&&r&&r!==n?(r.playing=!0,r.action.crossFadeTo(n.action,i)):n.action.reset().setEffectiveWeight(1).play(),this.activeClip=e,n}};function Ql(e,t){const n=e.shaderInputs.getUniformValues().pbrMaterial?.[t];return Array.isArray(n)?[...n]:[]}function Kl(e,t,n){const r=[...e];return r[t]=n,r}var Wl=class{bindings;scenes;constructor(e){this.scenes=e.scenes,this.bindings=function(e){const{gltf:t,gltfNodeIndexToNodeMap:n}=e,r=[],i=t.skins||[],a=new Set;for(const o of e.scenes)o.preorderTraversal(e=>{e instanceof Ne&&a.add(e)});for(const[o,s]of t.nodes.entries()){const e=s.skin;if(void 0===e||!s.mesh)continue;const A=$l(t,e),l=i[A],c=n.get(o);if(!l||!c||!a.has(c))continue;const u=l.joints.flatMap(e=>{const t=n.get(e);return t?[t]:[]});if(u.length!==l.joints.length)continue;const f=s.mesh,d=c.userData.gltfMesh,h=d instanceof Ne?d:c.children.find(e=>e instanceof Ne&&e.id===(f.name||f.id));if(!(h instanceof Ne))continue;const p=h.children.flatMap(e=>e instanceof ke?[e]:[]),m=l.inverseBindMatrices?.value;r.push({nodeIndex:o,skinIndex:A,node:c,joints:u,...m instanceof Float32Array?{inverseBindMatrices:m}:{},jointMatrices:new Float32Array(16*u.length),models:p})}return r}(e),this.update()}update(){if(0===this.bindings.length)return;const e=new Map;for(const t of this.scenes)t.preorderTraversal((t,{worldMatrix:r})=>{t instanceof Ne&&e.set(t,new n.Matrix4(r))});for(const t of this.bindings){ie({joints:t.joints,meshNode:t.node,worldMatrices:e,inverseBindMatrices:t.inverseBindMatrices,target:t.jointMatrices});for(const e of t.models)e.model.shaderInputs.setProps({skin:{jointMatrices:t.jointMatrices}})}}getBinding(e){return this.bindings.find(t=>"number"==typeof e?t.nodeIndex===e:t.node===e)}};function $l(e,t){return"number"==typeof t?t:(e.skins||[]).findIndex(n=>{if(n===t||t.id&&n.id===t.id)return!0;if(n.joints.length!==t.joints?.length||!n.joints.every((e,n)=>e===t.joints?.[n]))return!1;if("number"==typeof t.inverseBindMatrices){const r=e.accessors[t.inverseBindMatrices];return!n.inverseBindMatrices||n.inverseBindMatrices===r}return!0})}var Jl={supportLevel:"none",standardStatus:"unknown",comment:"Not currently listed in the luma.gl glTF extension support registry."},Yl={KHR_draco_mesh_compression:{supportLevel:"built-in",standardStatus:"ratified",comment:"Decoded by loaders.gl before luma.gl builds the scenegraph."},EXT_meshopt_compression:{supportLevel:"built-in",standardStatus:"ratified",comment:"EXT meshopt-compressed buffer views are decoded by loaders.gl before rendering."},KHR_meshopt_compression:{supportLevel:"none",standardStatus:"release-candidate",comment:"The installed loaders.gl GLTFLoader supports EXT_meshopt_compression, not the KHR release candidate."},KHR_mesh_quantization:{supportLevel:"built-in",standardStatus:"ratified",comment:"Loader-materialized quantized accessors retain their typed values and normalization."},EXT_mesh_features:{supportLevel:"loader-only",standardStatus:"ratified",comment:"Feature identifiers are decoded by loaders.gl; automatic rendering and picking are application-owned."},EXT_structural_metadata:{supportLevel:"loader-only",standardStatus:"ratified",comment:"Structural metadata is decoded by loaders.gl; automatic rendering and querying are application-owned."},KHR_lights_punctual:{supportLevel:"built-in",standardStatus:"ratified",comment:"Parsed into luma.gl Light objects."},KHR_materials_unlit:{supportLevel:"built-in",standardStatus:"ratified",comment:"Unlit materials bypass the default lighting path."},KHR_materials_emissive_strength:{supportLevel:"built-in",standardStatus:"ratified",comment:"Applied by the stock PBR shader."},KHR_texture_basisu:{supportLevel:"built-in",standardStatus:"ratified",comment:"BasisU / KTX2 textures pass through when the device supports them."},KHR_texture_transform:{supportLevel:"built-in",standardStatus:"ratified",comment:"Per-slot UV transforms and animated pointers are applied at runtime; avoid duplicate legacy loader-side baking."},EXT_texture_webp:{supportLevel:"loader-only",standardStatus:"ratified",comment:"Texture source is resolved during load; final support depends on browser and device decode support."},EXT_texture_avif:{supportLevel:"none",standardStatus:"ratified",comment:"The image loader can decode supported AVIF images, but GLTFLoader does not select EXT_texture_avif sources."},KHR_materials_specular:{supportLevel:"built-in",standardStatus:"ratified",comment:"The stock shader now applies specular factors and textures to the dielectric F0 term."},KHR_materials_ior:{supportLevel:"built-in",standardStatus:"ratified",comment:"The stock shader now drives dielectric reflectance from the glTF IOR value."},KHR_materials_transmission:{supportLevel:"built-in",standardStatus:"ratified",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",standardStatus:"ratified",comment:"Thickness and attenuation now tint transmitted light in the stock shader."},KHR_materials_clearcoat:{supportLevel:"built-in",standardStatus:"ratified",comment:"The stock shader now adds a secondary clearcoat specular lobe."},KHR_materials_sheen:{supportLevel:"built-in",standardStatus:"ratified",comment:"The stock shader now adds a sheen lobe for cloth-like materials."},KHR_materials_iridescence:{supportLevel:"built-in",standardStatus:"ratified",comment:"The stock shader now tints specular response with a view-dependent thin-film iridescence approximation."},KHR_materials_anisotropy:{supportLevel:"built-in",standardStatus:"ratified",comment:"The stock shader now shapes highlights and IBL response with an anisotropy-direction approximation."},KHR_materials_pbrSpecularGlossiness:{supportLevel:"loader-only",standardStatus:"archived",comment:"Extension data can be loaded, but it is not translated into the default metallic-roughness material path."},KHR_materials_variants:{supportLevel:"parsed-and-wired",standardStatus:"ratified",comment:"Primitive material variants can be selected and restored on the generated scenegraph."},EXT_mesh_gpu_instancing:{supportLevel:"built-in",standardStatus:"ratified",comment:"Accessor-backed instance transforms use one instanced draw per source primitive."},KHR_node_visibility:{supportLevel:"parsed-and-wired",standardStatus:"ratified",comment:"Recursive node visibility controls rendered geometry, punctual lights, and animation."},KHR_animation_pointer:{supportLevel:"parsed-and-wired",standardStatus:"ratified",comment:"Node transforms, morph weights and visibility, material factors, texture transforms, camera projections, and punctual lights are wired to runtime updates."},EXT_materials_bump:{supportLevel:"built-in",standardStatus:"draft",comment:"The experimental bump-map draft perturbs the canonical surface normal from a linear height texture."},KHR_materials_diffuse_transmission:{supportLevel:"built-in",standardStatus:"release-candidate",comment:"The Khronos release candidate adds energy-conserving back-lit diffuse transmission and independent color/factor textures."},KHR_materials_dispersion:{supportLevel:"parsed-and-wired",standardStatus:"ratified",comment:"The canonical PBR shader separates red, green, and blue transmission using wavelength-dependent refraction."},KHR_materials_volume_scatter:{supportLevel:"parsed-and-wired",standardStatus:"draft",comment:"The unratified volume-scattering draft is approximated per surface; random-walk and screen-space diffusion are not implemented."},KHR_xmp:{supportLevel:"none",standardStatus:"archived",comment:"Metadata payloads remain in the loaded glTF, but luma.gl does not interpret them."},KHR_xmp_json_ld:{supportLevel:"none",standardStatus:"ratified",comment:"Metadata is preserved in the glTF, but luma.gl does not interpret it."},EXT_lights_image_based:{supportLevel:"none",standardStatus:"multi-vendor",comment:"Use loadPBREnvironment() or custom environment setup instead."},EXT_texture_video:{supportLevel:"none",standardStatus:"multi-vendor",comment:"Video textures are not created automatically by the stock pipeline."},MSFT_lod:{supportLevel:"parsed-and-wired",standardStatus:"vendor",comment:"Node levels are parsed and selected by opt-in animated crowds; material LOD and GPU-driven selection are not implemented."}};function Xl(e,t){const n=Array.from(function(e){const t=e,n=new Set;tc(n,e.extensionsUsed),tc(n,e.extensionsRequired),tc(n,t.extensionsRemoved),tc(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(),r=new Set(e.extensionsRequired||[]),i=n.map(n=>{const i=Yl[n]||Jl,a=function(e,t,n,r){if("KHR_texture_basisu"!==e||!r)return t;const i=function(e){const t=[];for(const n of e.textures||[]){const e=n?.source?.image;if(!e?.compressed)continue;const r=Array.isArray(e.data)?e.data[0]:Array.isArray(e.mipmaps)?e.mipmaps[0]:void 0;t.push(r?.textureFormat??null)}return t}(n).find(e=>null===e||!r.isTextureFormatSupported(e));return void 0===i?t:{supportLevel:"none",comment:null===i?`The ${r.type} device cannot use a BasisU texture whose transcoded GPU format is missing.`:`The ${r.type} device does not support the transcoded BasisU texture format '${i}'.`}}(n,i,e,t);return[n,{extensionName:n,required:r.has(n),supported:(o=a.supportLevel,"built-in"===o||"parsed-and-wired"===o),supportLevel:a.supportLevel,standardStatus:i.standardStatus,comment:a.comment}];var o});return new Map(i)}function Zl(e,t){const n=function(e,t){return Array.from(Xl(e,t).values()).filter(e=>e.required&&!e.supported)}(e,t);if(n.length)throw new Error(`Unsupported required glTF extensions: ${n.map(e=>e.extensionName).join(", ")}`)}function ec(e){return Yl[e]||null}function tc(e,t=[]){for(const n of t)e.add(n)}function nc(e){const t=e.animations||[],n=new Map,r=new Map;return t.flatMap((t,i)=>{const o=t.name||`Animation-${i}`,s=new Map,A=t.channels.flatMap(({sampler:i,target:o})=>{const A=function(e,t){let n;if("weights"===t.path)n=t.node;else{if("pointer"!==t.path)return;{const e=t.extensions?.KHR_animation_pointer?.pointer,r="string"==typeof e?/^\/nodes\/(\d+)\/weights$/.exec(e):null;if(!r)return;n=Number(r[1])}}const r=e.nodes[n??0],i="number"==typeof r?.mesh?e.meshes[r.mesh]:r?.mesh;return r?.weights?.length||i?.weights?.length||i?.primitives?.[0]?.targets?.length||1}(e,o),l=`${i}:${A??0}`;let c=s.get(l);if(!c){const a=t.samplers[i];if(!a)throw new Error(`Cannot find animation sampler ${i}`);const{input:o,interpolation:u="LINEAR",output:f}=a,d=function(e,t){if(t.has(e))return t.get(e);const{value:n,components:r}=lc(e);cc(1===r,"accessorToJsArray1D must have exactly 1 component");const i=Array.from(n);return t.set(e,i),i}(e.accessors[o],n),h=function(e,t){if(t.has(e))return t.get(e);const{value:n,components:r}=lc(e);cc(r>=1,"accessorToJsArray2D must have at least 1 component");const i=[];for(let a=0;a<n.length;a+=r)i.push(Array.from(n.slice(a,a+r)));return t.set(e,i),i}(e.accessors[f],r);c={input:d,interpolation:u,output:void 0!==A?rc(h,d.length,u,A):h},s.set(l,c)}const u=function(e,t,n){if("pointer"===t.path)return function(e,t,n){const r=t.extensions?.KHR_animation_pointer?.pointer;if("string"!=typeof r||!r.startsWith("/"))return a.log.warn("KHR_animation_pointer channel is missing a valid JSON pointer and will be skipped")(),null;const i=function(e){return e.slice(1).split("/").map(e=>e.replace(/~1/g,"/").replace(/~0/g,"~"))}(r);switch(i[0]){case"nodes":return function(e,t,n,r){const i=5===t.length&&"extensions"===t[2]&&"KHR_node_visibility"===t[3]&&"visible"===t[4];if(3!==t.length&&!i)return Ac(r,"node pointers must target transforms, morph weights, or KHR_node_visibility.visible"),null;const o=Number(t[1]),s=e.nodes[o];if(!Number.isInteger(o)||!s)return a.log.warn(`KHR_animation_pointer target ${r} references a missing node and will be skipped`)(),null;if(i&&"STEP"!==n.interpolation)return Ac(r,"boolean visibility animation requires STEP interpolation"),null;const A=i?"visibility":ic(t[2]);if(!A)return Ac(r,`node property "${t[2]}" has no runtime animation mapping`),null;return{type:"node",sampler:n,targetNodeId:s.id,path:A}}(e,i,n,r);case"materials":return function(e,t,n,r){if(t.length<3)return Ac(r,"material pointers must include a material index and target property path"),null;const i=Number(t[1]),o=e.materials[i];if(!Number.isInteger(i)||!o)return a.log.warn(`KHR_animation_pointer target ${r} 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 r=function(e){return ul.find(t=>t.pathSegments.length===e.length&&t.pathSegments.every((t,n)=>e[n]===t))||null}(t.slice(0,n));if(!r)return{reason:oc(t.slice(0,n))};const i=function(e,t){let n=e;for(const r of t)if(n=n?.[r],!n)return null;return n}(e,r.pathSegments);if(!i)return{reason:`texture-transform target "${t.slice(0,n).join("/")}" does not exist on the referenced material`};const a=t[n+2];if("texCoord"===a)return{reason:"animated KHR_texture_transform.texCoord is unsupported because texCoord selection is structural, not a runtime float/vector update"};if("offset"!==a&&"rotation"!==a&&"scale"!==a)return{reason:`KHR_texture_transform property "${a}" is not animatable; supported properties are offset, rotation, and scale`};const o=t[n+3];if(t.length>n+4)return{reason:`KHR_texture_transform.${a} does not support nested property paths`};let s;if(void 0!==o){if(s=Number(o),"rotation"===a)return{reason:"KHR_texture_transform.rotation does not support component indices"};if(!Number.isInteger(s)||s<0||s>1)return{reason:`KHR_texture_transform.${a} component index "${o}" is invalid; only 0 and 1 are supported`}}return{type:"textureTransform",textureSlot:r.slot,path:a,component:s,baseTransform:pl(i)}}(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:ac(t)};case"pbrMetallicRoughness/metallicFactor":return e.pbrMetallicRoughness?{type:"material",property:"metallicRoughnessValues",component:0}:{reason:ac(t)};case"pbrMetallicRoughness/roughnessFactor":return e.pbrMetallicRoughness?{type:"material",property:"metallicRoughnessValues",component:1}:{reason:ac(t)};case"normalTexture/scale":return e.normalTexture?{type:"material",property:"normalScale"}:{reason:ac(t)};case"occlusionTexture/strength":return e.occlusionTexture?{type:"material",property:"occlusionStrength"}:{reason:ac(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:ac(t)};case"extensions/KHR_materials_specular/specularColorFactor":return e.extensions?.KHR_materials_specular?{type:"material",property:"specularColorFactor"}:{reason:ac(t)};case"extensions/KHR_materials_ior/ior":return e.extensions?.KHR_materials_ior?{type:"material",property:"ior"}:{reason:ac(t)};case"extensions/EXT_materials_bump/bumpFactor":return e.extensions?.EXT_materials_bump?{type:"material",property:"bumpFactor"}:{reason:ac(t)};case"extensions/KHR_materials_diffuse_transmission/diffuseTransmissionFactor":return e.extensions?.KHR_materials_diffuse_transmission?{type:"material",property:"diffuseTransmissionFactor"}:{reason:ac(t)};case"extensions/KHR_materials_diffuse_transmission/diffuseTransmissionColorFactor":return e.extensions?.KHR_materials_diffuse_transmission?{type:"material",property:"diffuseTransmissionColorFactor"}:{reason:ac(t)};case"extensions/KHR_materials_volume_scatter/multiscatterColorFactor":case"extensions/KHR_materials_volume_scatter/multiscatterColor":return e.extensions?.KHR_materials_volume_scatter?{type:"material",property:"multiscatterColorFactor"}:{reason:ac(t)};case"extensions/KHR_materials_volume_scatter/scatterAnisotropy":return e.extensions?.KHR_materials_volume_scatter?{type:"material",property:"scatterAnisotropy"}:{reason:ac(t)};case"extensions/KHR_materials_dispersion/dispersion":return e.extensions?.KHR_materials_dispersion?{type:"material",property:"dispersion"}:{reason:ac(t)};case"extensions/KHR_materials_transmission/transmissionFactor":return e.extensions?.KHR_materials_transmission?{type:"material",property:"transmissionFactor"}:{reason:ac(t)};case"extensions/KHR_materials_volume/thicknessFactor":return e.extensions?.KHR_materials_volume?{type:"material",property:"thicknessFactor"}:{reason:ac(t)};case"extensions/KHR_materials_volume/attenuationDistance":return e.extensions?.KHR_materials_volume?{type:"material",property:"attenuationDistance"}:{reason:ac(t)};case"extensions/KHR_materials_volume/attenuationColor":return e.extensions?.KHR_materials_volume?{type:"material",property:"attenuationColor"}:{reason:ac(t)};case"extensions/KHR_materials_clearcoat/clearcoatFactor":return e.extensions?.KHR_materials_clearcoat?{type:"material",property:"clearcoatFactor"}:{reason:ac(t)};case"extensions/KHR_materials_clearcoat/clearcoatRoughnessFactor":return e.extensions?.KHR_materials_clearcoat?{type:"material",property:"clearcoatRoughnessFactor"}:{reason:ac(t)};case"extensions/KHR_materials_sheen/sheenColorFactor":return e.extensions?.KHR_materials_sheen?{type:"material",property:"sheenColorFactor"}:{reason:ac(t)};case"extensions/KHR_materials_sheen/sheenRoughnessFactor":return e.extensions?.KHR_materials_sheen?{type:"material",property:"sheenRoughnessFactor"}:{reason:ac(t)};case"extensions/KHR_materials_iridescence/iridescenceFactor":return e.extensions?.KHR_materials_iridescence?{type:"material",property:"iridescenceFactor"}:{reason:ac(t)};case"extensions/KHR_materials_iridescence/iridescenceIor":return e.extensions?.KHR_materials_iridescence?{type:"material",property:"iridescenceIor"}:{reason:ac(t)};case"extensions/KHR_materials_iridescence/iridescenceThicknessMinimum":return e.extensions?.KHR_materials_iridescence?{type:"material",property:"iridescenceThicknessRange",component:0}:{reason:ac(t)};case"extensions/KHR_materials_iridescence/iridescenceThicknessMaximum":return e.extensions?.KHR_materials_iridescence?{type:"material",property:"iridescenceThicknessRange",component:1}:{reason:ac(t)};case"extensions/KHR_materials_anisotropy/anisotropyStrength":return e.extensions?.KHR_materials_anisotropy?{type:"material",property:"anisotropyStrength"}:{reason:ac(t)};case"extensions/KHR_materials_anisotropy/anisotropyRotation":return e.extensions?.KHR_materials_anisotropy?{type:"material",property:"anisotropyRotation"}:{reason:ac(t)};case"extensions/KHR_materials_emissive_strength/emissiveStrength":return e.extensions?.KHR_materials_emissive_strength?{type:"material",property:"emissiveStrength"}:{reason:ac(t)};default:return{reason:ac(t)}}}(o,t.slice(2));if("reason"in s)return Ac(r,s.reason),null;return{sampler:n,pointer:r,targetMaterialIndex:i,...s}}(e,i,n,r);case"cameras":return function(e,t,n,r){const i=Number(t[1]),a=e.cameras?.[i],o=t[2],s=t[3];if(4!==t.length||!Number.isInteger(i)||!a||"perspective"!==o&&"orthographic"!==o||a.type!==o||!("perspective"===o?["aspectRatio","yfov","znear","zfar"]:["xmag","ymag","znear","zfar"]).includes(s))return Ac(r,"camera pointers must target a supported projection property"),null;return{type:"camera",sampler:n,pointer:r,targetCameraIndex:i,projection:o,property:s}}(e,i,n,r);case"extensions":if("KHR_lights_punctual"===i[1])return function(e,t,n,r){const i=Number(t[3]),a=e.lights||e.extensions?.KHR_lights_punctual?.lights,o="spot"===t[4],s=o?t[5]:t[4],A=o||"color"!==s?void 0:t[5],l=["color","intensity","range","innerConeAngle","outerConeAngle"],c=o||void 0!==A?6:5;if("lights"!==t[2]||t.length!==c||!Number.isInteger(i)||!Array.isArray(a)||!a[i]||!l.includes(s)||o&&"innerConeAngle"!==s&&"outerConeAngle"!==s||void 0!==A&&(!/^[0-2]$/.test(A)||"color"!==s))return Ac(r,"punctual-light pointers must target supported typed light properties"),null;return{type:"light",sampler:n,pointer:r,targetLightIndex:i,property:s,...void 0===A?{}:{component:Number(A)}}}(e,i,n,r)}return Ac(r,`top-level target "${i[0]}" has no runtime animation mapping`),null}(e,t,n);const r=ic(t.path);if(!r)return null;const i=e.nodes[t.node??0];if(!i)throw new Error(`Cannot find animation target ${t.node}`);return{type:"node",sampler:n,targetNodeId:i.id,path:r}}(e,o,c);return u?[u]:[]});return A.length?[{name:o,channels:A}]:[]})}function rc(e,t,n,r){const i="CUBICSPLINE"===n?3:1,a=e.length/(Math.max(t,1)*i),o=r>1?r:Number.isInteger(a)&&a>1?a:r;if(o<=1)return e;const s=e.flat(),A=[];for(let l=0;l<s.length;l+=o)A.push(s.slice(l,l+o));return A}function ic(e){switch(e){case"translation":case"rotation":case"scale":case"weights":return e;default:return null}}function ac(e){const t=sc(e);if(t){const e=ec(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 oc(e){const t=sc(e);if(t){const e=ec(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 sc(e){const t=e.indexOf("extensions"),n=e[t+1];return t>=0&&n?n:null}function Ac(e,t){a.log.warn(`KHR_animation_pointer target ${e} will be skipped because ${t}`)()}function lc(e){if(e.value)return{value:e.value,components:e.components};const t=e.bufferView?.data;cc(void 0!==t),cc(5126===e.componentType);const n="SCALAR"===e.type?1:Number(e.type.slice(3));return{value:new Float32Array(t.buffer,t.byteOffset+(e.byteOffset||0),e.count*n),components:n}}function cc(e,t){if(!e)throw new Error(t)}var uc=class{variants;names;activeVariant=null;modelNodes;constructor(e,t){const n=e.extensions?.KHR_materials_variants?.variants||[];this.variants=n.map((e,t)=>({name:e.name||`Variant-${t}`,index:t})),this.names=this.variants.map(e=>e.name);const r=new Set;for(const i of t)i.preorderTraversal(e=>{e instanceof ke&&e.userData.gltfMaterialVariants&&r.add(e)});this.modelNodes=Array.from(r)}selectVariant(e){const t=this.variants.find(t=>t.name===e);if(!t)throw new Error(`Unknown glTF material variant: ${e}`);for(const n of this.modelNodes){const e=n.userData.gltfMaterialVariants,r=e.mappings.get(t.index);n.model.setMaterial(r?.material||e.defaultMaterial),n.model.setParameters(r?.parameters||e.defaultParameters)}this.activeVariant=e}resetVariant(){for(const e of this.modelNodes){const t=e.userData.gltfMaterialVariants;e.model.setMaterial(t.defaultMaterial),e.model.setParameters(t.defaultParameters)}this.activeVariant=null}};function fc(e,t,n){n?.strictExtensions&&Zl(t,e);const{scenes:r,materials:i,gltfMeshIdToNodeMap:a,gltfNodeIdToNodeMap:o,gltfNodeIndexToNodeMap:s,generatedTextures:A}=Pl(e,t,n),l=nc(t),c=(t.lights||t.extensions?.KHR_lights_punctual?.lights||[]).map(e=>({...e,...Array.isArray(e.color)?{color:[...e.color]}:{},...e.spot?{spot:{...e.spot}}:{}})),u=(t.cameras||[]).map(e=>{const t={...e};return e.perspective&&(t.perspective={...e.perspective}),e.orthographic&&(t.orthographic={...e.orthographic}),t}),f={useByteColors:n?.useByteColors??!0,nodeVisibility:o,lightDefinitions:c},d=Bl(t,f),h=()=>{d.splice(0,d.length,...Bl(t,f))},p=new ql({onVisibilityChange:h,cameras:u,lightDefinitions:c,onLightChange:h,animations:l,gltfNodeIdToNodeMap:o,materials:i}),m=new uc(t,r),g=Xl(t,e),b=r.map(e=>dc(e.getBounds())),v=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 dc(t)}(b),y=new Wl({gltf:t,scenes:r,gltfNodeIndexToNodeMap:s});p.setUpdateHandler(()=>y.update());let x=!1;return{scenes:r,materials:i,variants:m,cameras:u,animator:p,animations:l,lights:d,extensionSupport:g,sceneBounds:b,modelBounds:v,gltfMeshIdToNodeMap:a,gltfNodeIdToNodeMap:o,gltfNodeIndexToNodeMap:s,skins:y,gltf:t,destroy:()=>{if(x)return;x=!0;const e=new Set([...r,...a.values(),...o.values()]),t=new Set,n=new Set(i);for(const r of e)r.preorderTraversal(e=>{e instanceof ke&&(t.add(e),e.model?.material&&n.add(e.model.material))});for(const r of t)r.destroy();for(const r of e)r.destroy();for(const r of n)r.destroy();for(const r of A)r.destroy();A.clear()}}}function dc(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]],r=[t[0][0]+.5*n[0],t[0][1]+.5*n[1],t[0][2]+.5*n[2]],i=.5*Math.max(n[0],n[1],n[2]),a=Math.max(.5*Math.hypot(n[0],n[1],n[2]),.001);return{bounds:t,center:r,size:n,radius:a,recommendedOrbitDistance:Math.max(Math.max(i,.001)/Math.tan(Math.PI/6)*1.15,1.1*a)}}var hc=function(){var e=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]),t=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if("object"!=typeof WebAssembly)return{supported:!1};var n,r=WebAssembly.validate(e)?a("b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuixkbbebeeddddilve9Weeeviebeoweuecj:Gdkr;Neqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949WbwY9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVJ9V29VVbDl79IV9Rbqq:I9Dklbzik94evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaeai86b:q:W:cjbaecitab8Piw83i:q:G:cjbaecefgecjd9hmbkk:SBlEud97dur978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnalTmbcuhoaiRbbgrc;WeGc:Ge9hmbarcsGgwce0mbc9:hoalcufadcd4cbawEgDadfgrcKcaawEgqaraq0Egk6mbaialfgxar9RhodnadTgmmbavaoad;8qbbkaicefhPcj;abad9Uc;WFbGcjdadca0EhsdndndnadTmbaoadfhzcbhHinaeaH9nmdaxaP9RaD6miabaHad2fgOavcjdfasaeaH9RaHasfae6EgAaAcsfgoc9WGgCSEhXaPaDfhQaocl4cifcd4hLavcj;cbfaCcetfhKavcj;cbfaCci2fhYavcj;cbfaCfh8AcbhEaoc;ab6h3incbh5dnawTmbaPaEcd4fRbbh5kcbh8Eavcj;cbfh8Findndndndna5a8Ecet4ciGgoc9:fPdebdkaxaQ9RaC6mwdnaCTmbavcj;cbfa8EaC2faQaC;8qbbkaQaAfhQxdkaCTmeavcj;cbfa8EaC2fcbaC;8kbxekaxaQ9RaL6moaoclVcbawEhraQaLfhocbhidna3mbaxao9Rc;Gb6mbcbhlina8FalfhidndndndndndnaQalco4fRbbgqciGarfPDbedibledibkaipxbbbbbbbbbbbbbbbbpklbxlkaiaopbblaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLgacdp:meaapmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9oghpxiiiiiiiiiiiiiiiip8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbagRb:q:W:cjbggpsaap5e9cjF;8;4;W;G;ab9:9cU1:Ng8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spklbagaoclffa8JRb:q:W:cjbfhoxikaiaopbbwaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLpxssssssssssssssssp9oghpxssssssssssssssssp8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbagRb:q:W:cjbggpsaap5e9cjF;8;4;W;G;ab9:9cU1:Ng8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spklbagaocwffa8JRb:q:W:cjbfhoxdkaiaopbbbpklbaoczfhoxekaiaopbbdaoRbbggcitpbi:q:G:cjbagRb:q:W:cjbggpsaoRbeg8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbagaocdffa8JRb:q:W:cjbfhokdndndndndndnaqcd4ciGarfPDbedibledibkaiczfpxbbbbbbbbbbbbbbbbpklbxlkaiczfaopbblaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLgacdp:meaapmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9oghpxiiiiiiiiiiiiiiiip8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbagRb:q:W:cjbggpsaap5e9cjF;8;4;W;G;ab9:9cU1:Ng8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spklbagaoclffa8JRb:q:W:cjbfhoxikaiczfaopbbwaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLpxssssssssssssssssp9oghpxssssssssssssssssp8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbagRb:q:W:cjbggpsaap5e9cjF;8;4;W;G;ab9:9cU1:Ng8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spklbagaocwffa8JRb:q:W:cjbfhoxdkaiczfaopbbbpklbaoczfhoxekaiczfaopbbdaoRbbggcitpbi:q:G:cjbagRb:q:W:cjbggpsaoRbeg8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbagaocdffa8JRb:q:W:cjbfhokdndndndndndnaqcl4ciGarfPDbedibledibkaicafpxbbbbbbbbbbbbbbbbpklbxlkaicafaopbblaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLgacdp:meaapmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9oghpxiiiiiiiiiiiiiiiip8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbagRb:q:W:cjbggpsaap5e9cjF;8;4;W;G;ab9:9cU1:Ng8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spklbagaoclffa8JRb:q:W:cjbfhoxikaicafaopbbwaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLpxssssssssssssssssp9oghpxssssssssssssssssp8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbagRb:q:W:cjbggpsaap5e9cjF;8;4;W;G;ab9:9cU1:Ng8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spklbagaocwffa8JRb:q:W:cjbfhoxdkaicafaopbbbpklbaoczfhoxekaicafaopbbdaoRbbggcitpbi:q:G:cjbagRb:q:W:cjbggpsaoRbeg8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbagaocdffa8JRb:q:W:cjbfhokdndndndndndnaqco4arfPDbedibledibkaic8Wfpxbbbbbbbbbbbbbbbbpklbxlkaic8Wfaopbblaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLgacdp:meaapmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9oghpxiiiiiiiiiiiiiiiip8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Ngicitpbi:q:G:cjbaiRb:q:W:cjbgipsaap5e9cjF;8;4;W;G;ab9:9cU1:Ngqcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spklbaiaoclffaqRb:q:W:cjbfhoxikaic8Wfaopbbwaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLpxssssssssssssssssp9oghpxssssssssssssssssp8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Ngicitpbi:q:G:cjbaiRb:q:W:cjbgipsaap5e9cjF;8;4;W;G;ab9:9cU1:Ngqcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spklbaiaocwffaqRb:q:W:cjbfhoxdkaic8Wfaopbbbpklbaoczfhoxekaic8WfaopbbdaoRbbgicitpbi:q:G:cjbaiRb:q:W:cjbgipsaoRbegqcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbaiaocdffaqRb:q:W:cjbfhokalc;abfhialcjefaC0meaihlaxao9Rc;Fb0mbkkdnaiaC9pmbaici4hlinaxao9RcK6mwa8FaifhqdndndndndndnaQaico4fRbbalcoG4ciGarfPDbedibledibkaqpxbbbbbbbbbbbbbbbbpkbbxlkaqaopbblaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLgacdp:meaapmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9oghpxiiiiiiiiiiiiiiiip8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbagRb:q:W:cjbggpsaap5e9cjF;8;4;W;G;ab9:9cU1:Ng8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spkbbagaoclffa8JRb:q:W:cjbfhoxikaqaopbbwaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLpxssssssssssssssssp9oghpxssssssssssssssssp8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbagRb:q:W:cjbggpsaap5e9cjF;8;4;W;G;ab9:9cU1:Ng8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spkbbagaocwffa8JRb:q:W:cjbfhoxdkaqaopbbbpkbbaoczfhoxekaqaopbbdaoRbbggcitpbi:q:G:cjbagRb:q:W:cjbggpsaoRbeg8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpkbbagaocdffa8JRb:q:W:cjbfhokalcdfhlaiczfgiaC6mbkkaohQaoTmoka8FaCfh8Fa8Ecefg8Ecl9hmbkdndndndnawTmbazaEcd4fRbbglciGPlbedwbkaCTmdaXaEfhlavaEfpbdbh8Kcbhoinalavcj;cbfaofpblbg8La8Aaofpblbg8MpmbzeHdOiAlCvXoQrLg8NaKaofpblbgyaYaofpblbg8PpmbzeHdOiAlCvXoQrLgIpmbezHdiOAlvCXorQLgacep9Taapxeeeeeeeeeeeeeeeeghp9op9Hp9rgaa8Kp9Ug8Kp9Abbbaladfgla8Kaaaapmlvorlvorlvorlvorp9Ug8Kp9Abbbaladfgla8KaaaapmwDqkwDqkwDqkwDqkp9Ug8Kp9Abbbaladfgla8KaaaapmxmPsxmPsxmPsxmPsp9Ug8Kp9Abbbaladfgla8Ka8NaIpmwDKYqk8AExm35Ps8E8Fgacep9Taaahp9op9Hp9rgap9Ug8Kp9Abbbaladfgla8Kaaaapmlvorlvorlvorlvorp9Ug8Kp9Abbbaladfgla8KaaaapmwDqkwDqkwDqkwDqkp9Ug8Kp9Abbbaladfgla8KaaaapmxmPsxmPsxmPsxmPsp9Ug8Kp9Abbbaladfgla8Ka8La8MpmwKDYq8AkEx3m5P8Es8Fg8Laya8PpmwKDYq8AkEx3m5P8Es8Fg8MpmbezHdiOAlvCXorQLgacep9Taaahp9op9Hp9rgap9Ug8Kp9Abbbaladfgla8Kaaaapmlvorlvorlvorlvorp9Ug8Kp9Abbbaladfgla8KaaaapmwDqkwDqkwDqkwDqkp9Ug8Kp9Abbbaladfgla8KaaaapmxmPsxmPsxmPsxmPsp9Ug8Kp9Abbbaladfgla8Ka8La8MpmwDKYqk8AExm35Ps8E8Fgacep9Taaahp9op9Hp9rgap9Ughp9Abbbaladfglahaaaapmlvorlvorlvorlvorp9Ughp9AbbbaladfglahaaaapmwDqkwDqkwDqkwDqkp9Ughp9AbbbaladfglahaaaapmxmPsxmPsxmPsxmPsp9Ug8Kp9AbbbaladfhlaoczfgoaC6mbxikkaCTmeaXaEfhlavaEfpbdbh8Kcbhoinalavcj;cbfaofpblbg8La8Aaofpblbg8MpmbzeHdOiAlCvXoQrLg8NaKaofpblbgyaYaofpblbg8PpmbzeHdOiAlCvXoQrLgIpmbezHdiOAlvCXorQLgacep:neaapxebebebebebebebebghp9op:bep9rgaa8Kp:oeg8Kp9Abbbaladfgla8Kaaaapmlvorlvorlvorlvorp:oeg8Kp9Abbbaladfgla8KaaaapmwDqkwDqkwDqkwDqkp:oeg8Kp9Abbbaladfgla8KaaaapmxmPsxmPsxmPsxmPsp:oeg8Kp9Abbbaladfgla8Ka8NaIpmwDKYqk8AExm35Ps8E8Fgacep:neaaahp9op:bep9rgap:oeg8Kp9Abbbaladfgla8Kaaaapmlvorlvorlvorlvorp:oeg8Kp9Abbbaladfgla8KaaaapmwDqkwDqkwDqkwDqkp:oeg8Kp9Abbbaladfgla8KaaaapmxmPsxmPsxmPsxmPsp:oeg8Kp9Abbbaladfgla8Ka8La8MpmwKDYq8AkEx3m5P8Es8Fg8Laya8PpmwKDYq8AkEx3m5P8Es8Fg8MpmbezHdiOAlvCXorQLgacep:neaaahp9op:bep9rgap:oeg8Kp9Abbbaladfgla8Kaaaapmlvorlvorlvorlvorp:oeg8Kp9Abbbaladfgla8KaaaapmwDqkwDqkwDqkwDqkp:oeg8Kp9Abbbaladfgla8KaaaapmxmPsxmPsxmPsxmPsp:oeg8Kp9Abbbaladfgla8Ka8La8MpmwDKYqk8AExm35Ps8E8Fgacep:neaaahp9op:bep9rgap:oeghp9Abbbaladfglahaaaapmlvorlvorlvorlvorp:oeghp9AbbbaladfglahaaaapmwDqkwDqkwDqkwDqkp:oeghp9AbbbaladfglahaaaapmxmPsxmPsxmPsxmPsp:oeg8Kp9AbbbaladfhlaoczfgoaC6mbxdkkaCTmbaXaEfhrcbhocbalcl4gl9Rc8FGhiavaEfpbdbhhinaravcj;cbfaofpblbg8Ka8Aaofpblbg8LpmbzeHdOiAlCvXoQrLg8MaKaofpblbg8NaYaofpblbgypmbzeHdOiAlCvXoQrLg8PpmbezHdiOAlvCXorQLgaaip:Reaaalp:Tep9qgaahp9rghp9Abbbaradfgrahaaaapmlvorlvorlvorlvorp9rghp9AbbbaradfgrahaaaapmwDqkwDqkwDqkwDqkp9rghp9AbbbaradfgrahaaaapmxmPsxmPsxmPsxmPsp9rghp9Abbbaradfgraha8Ma8PpmwDKYqk8AExm35Ps8E8Fgaaip:Reaaalp:Tep9qgap9rghp9Abbbaradfgrahaaaapmlvorlvorlvorlvorp9rghp9AbbbaradfgrahaaaapmwDqkwDqkwDqkwDqkp9rghp9AbbbaradfgrahaaaapmxmPsxmPsxmPsxmPsp9rghp9Abbbaradfgraha8Ka8LpmwKDYq8AkEx3m5P8Es8Fg8Ka8NaypmwKDYq8AkEx3m5P8Es8Fg8LpmbezHdiOAlvCXorQLgaaip:Reaaalp:Tep9qgap9rghp9Abbbaradfgrahaaaapmlvorlvorlvorlvorp9rghp9AbbbaradfgrahaaaapmwDqkwDqkwDqkwDqkp9rghp9AbbbaradfgrahaaaapmxmPsxmPsxmPsxmPsp9rghp9Abbbaradfgraha8Ka8LpmwDKYqk8AExm35Ps8E8Fgaaip:Reaaalp:Tep9qgap9rghp9Abbbaradfgrahaaaapmlvorlvorlvorlvorp9rghp9AbbbaradfgrahaaaapmwDqkwDqkwDqkwDqkp9rghp9AbbbaradfgrahaaaapmxmPsxmPsxmPsxmPsp9rghp9AbbbaradfhraoczfgoaC6mbkkaEclfgEad6mbkdnaXavcjdf9hmbaAad2goTmbaOavcjdfao;8qbbkdnammbavaXaAcufad2fad;8qbbkaAaHfhHc9:hoaQhPaQmbxlkkaeTmbaDalfhrcbhocuhlinaralaD9RglfaD6mdasaeao9Raoasfae6Eaofgoae6mbkaial9RhPkcbc99axaP9RakSEhoxekc9:hokavcj;kbf8Kjjjjbaokwbz:bjjjbkpPesu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnalaeci9UgrcHf6mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgwce0mbavc;abfcFecje;8kbav9cu83iUav9cu83i8Wav9cu83iyav9cu83iaav9cu83iKav9cu83izav9cu83iwav9cu83ibaialfc9WfhDaicefgiarfhqdndnaeci9pmbaqhexekcmcsawceSEhkcbhxcbhmaqhecbhlcbhoindndnaiRbbgrc;Ve0mbavc;abfaoarcu7gPcl4fcsGcitfgwydlhsawydbhzdndnarcsGgwak9pmbavalaPfcsGcdtfydbaxawEhraxawTgHfhxxekdnaeaD9nmbc9:hoxokdndnawcsSmbcehHamawcetfcWfhrxekaecefhrae8SbbgwcFeGhPdndnawcu9mmbarhexekaecvfheaPcFbGhPcrhwdninar8SbbgHcFbGawtaPVhPaHcu9kmearcefhrawcrfgwc8J9hmbxdkkarcefhekcehHaPce4cbaPceG9R7amfhrkarhmkavc;abfaocitfgwarBdbawasBdlavalcdtfarBdbavc;abfaocefcsGcitfgwazBdbawarBdlaocdfhoaHalfhldnadcd9hmbabar87elabas87edabaz87ebabcofhbxdkabarBdwabasBdlabazBdbabcxfhbxekdnarcpe0mbavalaDarcsGfRbbgwcl4gP9RcsGcdtfydbaxcefgsaPEhravalaw9RcsGcdtfydbasaPTgzfgsawcsGgPEhwaPThPdndnadcd9hmbabaw87elabar87edabax87ebcohHxekabawBdwabarBdlabaxBdbcxhHkavalcdtfaxBdbavc;abfaocitfgOarBdbaOaxBdlavalcefglcsGcdtfarBdbavc;abfaocefcsGcitfgOawBdbaOarBdlavalazfglcsGcdtfawBdbavc;abfaocdfcsGcitfgraxBdbarawBdlaocifhoabaHfhbalaPfhlasaPfhxxekdnaeaD9nmbc9:hoxlkaxcbaeRbbgwEgHarc;:eSgrfhsawcsGhOdndnawcl4gAmbascefhzxekashzavalaA9RcsGcdtfydbhskdndnaOmbazcefhxxekazhxavalaw9RcsGcdtfydbhzkdndnarTmbaecefhrxekaecdfhrae8SbegPcFeGhwdnaPcu9kmbaecofhHawcFbGhwcrhedninar8SbbgPcFbGaetawVhwaPcu9kmearcefhraecrfgec8J9hmbkaHhrxekarcefhrkawce4cbawceG9R7amfgmhHkdndnaAcsSmbarhwxekarcefhwar8SbbgecFeGhPdnaecu9kmbarcvfhsaPcFbGhPcrhedninaw8SbbgrcFbGaetaPVhParcu9kmeawcefhwaecrfgec8J9hmbkashwxekawcefhwkaPce4cbaPceG9R7amfgmhskdndnaOcsSmbawhexekawcefheaw8SbbgrcFeGhPdnarcu9kmbawcvfhzaPcFbGhPcrhrdninae8SbbgwcFbGartaPVhPawcu9kmeaecefhearcrfgrc8J9hmbkazhexekaecefhekaPce4cbaPceG9R7amfgmhzkdndnadcd9hmbabaz87elabas87edabaH87ebcohrxekabazBdwabasBdlabaHBdbcxhrkavc;abfaocitfgwasBdbawaHBdlavalcdtfaHBdbavc;abfaocefcsGcitfgwazBdbawasBdlavalcefglcsGcdtfasBdbavc;abfaocdfcsGcitfgwaHBdbawazBdlavalaATaAcsSVfglcsGcdtfazBdbalaOTaOcsSVfhlaocifhoabarfhbkaocsGhoalcsGhlaicefgiaq6mbkkcbc99aeaDSEhokavc;aef8Kjjjjbaok:clevu8Jjjjjbcz9Rhvdnalaecvf9pmbc9:skdnaiRbbc;:eGc;qeSmbcuskav9cb83iwaicefhoaialfc98fhrdnaeTmbdnadcdSmbcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcdtfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgiBdbalaiBdbawcefgwae9hmbxdkkcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcetfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgi87ebalaiBdbawcefgwae9hmbkkcbc99aoarSEk;Toio97eue97aec98Ghedndnadcl9hmbaeTmecbhdinababpbbbgicKp:RecKp:Sep;6eglaicwp:RecKp:Sep;6ealp;Geaiczp:RecKp:Sep;6egvp;Gep;Kep;Legopxbbbbbbbbbbbbbbbbp:2egralpxbbbjbbbjbbbjbbbjgwp9op9rp;Keglpxbb;:9cbb;:9cbb;:9cbb;:9calalp;Meaoaop;Meavaravawp9op9rp;Keglalp;Mep;Kep;Kep;Jep;Negvp;Mepxbbn0bbn0bbn0bbn0grp;KepxFbbbFbbbFbbbFbbbp9oaipxbbbFbbbFbbbFbbbFp9op9qalavp;Mearp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaoavp;Mearp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbabczfhbadclfgdae6mbxdkkaeTmbcbhdinabczfgDaDpbbbgipxbbbbbbFFbbbbbbFFgwp9oabpbbbgoaipmbediwDqkzHOAKY8AEgvczp:Reczp:Sep;6eglaoaipmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eavczp:Sep;6egvp;Gealp;Gep;Kep;Legipxbbbbbbbbbbbbbbbbp:2egralpxbbbjbbbjbbbjbbbjgqp9op9rp;Keglpxb;:FSb;:FSb;:FSb;:FSalalp;Meaiaip;Meavaravaqp9op9rp;Keglalp;Mep;Kep;Kep;Jep;Negvp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbp9oaiavp;Mearp;Keczp:Rep9qgialavp;Mearp;KepxFFbbFFbbFFbbFFbbp9oglpmwDKYqk8AExm35Ps8E8Fp9qpkbbabaoawp9oaialpmbezHdiOAlvCXorQLp9qpkbbabcafhbadclfgdae6mbkkk;2ileue97euo97dnaec98GgiTmbcbheinabcKfpx:ji:1S:ji:1S:ji:1S:ji:1SabpbbbglabczfgvpbbbgopmlvorxmPsCXQL358E8Fgrczp:Segwpxibbbibbbibbbibbbp9qp;6egDp;NegqaDaDp;MegDaDp;KealaopmbediwDqkzHOAKY8AEgDczp:Reczp:Sep;6eglalp;MeaDczp:Sep;6egoaop;Mearczp:Reczp:Sep;6egrarp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jep;Mepxbbn0bbn0bbn0bbn0gDp;KepxFFbbFFbbFFbbFFbbgkp9oaqaop;MeaDp;Keczp:Rep9qgoaqalp;MeaDp;Keakp9oaqarp;MeaDp;Keczp:Rep9qgDpmwDKYqk8AExm35Ps8E8Fglp5eawclp:RegqpEi:T:j83ibavalp5baqpEd:T:j83ibabcwfaoaDpmbezHdiOAlvCXorQLgDp5eaqpEe:T:j83ibabaDp5baqpEb:T:j83ibabcafhbaeclfgeai6mbkkkuee97dnadcd4ae2c98GgeTmbcbhdinababpbbbgicwp:Recwp:Sep;6eaicep:SepxbbjFbbjFbbjFbbjFp9opxbbjZbbjZbbjZbbjZp:Uep;Mepkbbabczfhbadclfgdae6mbkkk:Sodw97euaec98Ghedndnadcl9hmbaeTmecbhdinabpxbbuJbbuJbbuJbbuJabpbbbgicKp:TeglaicYp:Tep9qgvcdp:Teavp9qgvclp:Teavp9qgop;6ep;Negvaicwp:RecKp:SegraipxFbbbFbbbFbbbFbbbgwp9ogDp:Uep;6ep;Mepxbbn0bbn0bbn0bbn0gqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9oavaDarp:Xeaiczp:RecKp:Segip:Uep;6ep;Meaqp;Keawp9op9qavaDaraip:Uep:Xep;6ep;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qavaoalcep:Rep9oalpxebbbebbbebbbebbbp9op9qp;6ep;Meaqp;KecKp:Rep9qpkbbabczfhbadclfgdae6mbxdkkaeTmbcbhdinabczfgkpxbFu9hbFu9hbFu9hbFu9habpbbbglakpbbbgrpmlvorxmPsCXQL358E8Fgvczp:TegqavcHp:Tep9qgicdp:Teaip9qgiclp:Teaip9qgicwp:Teaip9qgop;6ep;NegialarpmbediwDqkzHOAKY8AEgDpxFFbbFFbbFFbbFFbbglp9ograDczp:Segwp:Ueavczp:Reczp:SegDp:Xep;6ep;Mepxbbn0bbn0bbn0bbn0gvp;Kealp9oaiarawaDp:Uep:Xep;6ep;Meavp;Keczp:Rep9qgwaiaoaqcep:Rep9oaqpxebbbebbbebbbebbbp9op9qp;6ep;Meavp;Keczp:ReaiaDarp:Uep;6ep;Meavp;Kealp9op9qgipmwDKYqk8AExm35Ps8E8FpkbbabawaipmbezHdiOAlvCXorQLpkbbabcafhbadclfgdae6mbkkk9teiucbcbydj:G:cjbgeabcifc98GfgbBdj:G:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkxebcj:Gdklz:zbb"):a("b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuixkbeeeddddillviebeoweuecj:Gdkr;Neqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949WboY9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVJ9V29VVbrl79IV9Rbwq;X8:kdbk:kYi5ud9:du8Jjjjjbcjq9Rgv8Kjjjjbc9:hodnalTmbcuhoaiRbbgrc;WeGc:Ge9hmbarcsGgwce0mbc9:hoalcufadcd4cbawEgDadfgrcKcaawEgqaraq0Egk6mbaicefhxcj;abad9Uc;WFbGcjdadca0EhmaialfgPar9Rgoadfhsavaoadz:jjjjbgzceVhHcbhOdndninaeaO9nmeaPax9RaD6mdamaeaO9RaOamfgoae6EgAcsfglc9WGhCaAcethXaxaDfhiaOaeaoaeao6E9RhQalcl4cifcd4hLazcjdfaAfhKcbhYabaOad2fg8AhEaHh3incbh5dnawTmbaxaYcd4fRbbh5kcbh8Eazcjdfhqinaih8Fdndndndna5a8Ecet4ciGgoc9:fPdebdkaPa8F9RaA6mrazcjdfa8EaA2fa8FaAz:jjjjb8Aa8FaAfhixdkazcjdfa8EaA2fcbaAz:kjjjb8Aa8FhixekaPa8F9RaL6mva8FaLfhidnaCTmbaPai9RcK6mbaocdtc:q:G:cjbfcj:G:cjbawEhaczhrcbhlinargoc9Wfghaqfhrdndndndndndnaaa8Fahco4fRbbalcoG4ciGcdtfydbPDbedvivvvlvkar9cb83bwar9cb83bbxlkarcbaiRbdai8Xbb9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:gg9cjjjjjz:dg8J9qE86bbaqaofgrcGfcbaicdfa8J9c8N1:NfghRbbag9cjjjjjw:dg8J9qE86bbarcVfcbaha8J9c8M1:NfghRbbag9cjjjjjl:dg8J9qE86bbarc7fcbaha8J9c8L1:NfghRbbag9cjjjjjd:dg8J9qE86bbarctfcbaha8J9c8K1:NfghRbbag9cjjjjje:dg8J9qE86bbarc91fcbaha8J9c8J1:NfghRbbag9cjjjj;ab:dg8J9qE86bbarc4fcbaha8J9cg1:NfghRbbag9cjjjja:dg8J9qE86bbarc93fcbaha8J9ch1:NfghRbbag9cjjjjz:dgg9qE86bbarc94fcbahag9ca1:NfghRbbai8Xbe9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:gg9cjjjjjz:dg8J9qE86bbarc95fcbaha8J9c8N1:NfgiRbbag9cjjjjjw:dg8J9qE86bbarc96fcbaia8J9c8M1:NfgiRbbag9cjjjjjl:dg8J9qE86bbarc97fcbaia8J9c8L1:NfgiRbbag9cjjjjjd:dg8J9qE86bbarc98fcbaia8J9c8K1:NfgiRbbag9cjjjjje:dg8J9qE86bbarc99fcbaia8J9c8J1:NfgiRbbag9cjjjj;ab:dg8J9qE86bbarc9:fcbaia8J9cg1:NfgiRbbag9cjjjja:dg8J9qE86bbarcufcbaia8J9ch1:NfgiRbbag9cjjjjz:dgg9qE86bbaiag9ca1:NfhixikaraiRblaiRbbghco4g8Ka8KciSg8KE86bbaqaofgrcGfaiclfa8Kfg8KRbbahcl4ciGg8La8LciSg8LE86bbarcVfa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc7fa8Ka8Lfg8KRbbahciGghahciSghE86bbarctfa8Kahfg8KRbbaiRbeghco4g8La8LciSg8LE86bbarc91fa8Ka8Lfg8KRbbahcl4ciGg8La8LciSg8LE86bbarc4fa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc93fa8Ka8Lfg8KRbbahciGghahciSghE86bbarc94fa8Kahfg8KRbbaiRbdghco4g8La8LciSg8LE86bbarc95fa8Ka8Lfg8KRbbahcl4ciGg8La8LciSg8LE86bbarc96fa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc97fa8Ka8Lfg8KRbbahciGghahciSghE86bbarc98fa8KahfghRbbaiRbigico4g8Ka8KciSg8KE86bbarc99faha8KfghRbbaicl4ciGg8Ka8KciSg8KE86bbarc9:faha8KfghRbbaicd4ciGg8Ka8KciSg8KE86bbarcufaha8KfgrRbbaiciGgiaiciSgiE86bbaraifhixdkaraiRbwaiRbbghcl4g8Ka8KcsSg8KE86bbaqaofgrcGfaicwfa8Kfg8KRbbahcsGghahcsSghE86bbarcVfa8KahfghRbbaiRbeg8Kcl4g8La8LcsSg8LE86bbarc7faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarctfaha8KfghRbbaiRbdg8Kcl4g8La8LcsSg8LE86bbarc91faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc4faha8KfghRbbaiRbig8Kcl4g8La8LcsSg8LE86bbarc93faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc94faha8KfghRbbaiRblg8Kcl4g8La8LcsSg8LE86bbarc95faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc96faha8KfghRbbaiRbvg8Kcl4g8La8LcsSg8LE86bbarc97faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc98faha8KfghRbbaiRbog8Kcl4g8La8LcsSg8LE86bbarc99faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc9:faha8KfghRbbaiRbrgicl4g8Ka8KcsSg8KE86bbarcufaha8KfgrRbbaicsGgiaicsSgiE86bbaraifhixekarai8Pbw83bwarai8Pbb83bbaiczfhikdnaoaC9pmbalcdfhlaoczfhraPai9RcL0mekkaoaC6moaimexokaCmva8FTmvkaqaAfhqa8Ecefg8Ecl9hmbkdndndndnawTmbasaYcd4fRbbgociGPlbedrbkaATmdazaYfh8Fazcjdfhhcbh8EaEhaina8FRbbhraahocbhlinaoahalfRbbgqce4cbaqceG9R7arfgr86bbaoadfhoaAalcefgl9hmbkaacefhaa8Fcefh8FahaAfhha8Ecefg8Ecl9hmbxikkaATmeazaYfhaazcjdfhhcbhoceh8EaKh8FinaEaofhlaa8Vbbhrcbhoinala8FaofRbbcwtahaofRbbgqVc;:FiGce4cbaqceG9R7arfgr87bbaladfhlaQaocefgofmbka8FaXfh8FcdhoaacdfhaahaXfhha8EceGhlcbh8EalmbxdkkaATmbaocl4h8EazaYfRbbhqcwhoa3hlinalRbbaotaqVhqalcefhlaocwfgoca9hmbkcbhhaEh8FaKhainazcjdfahfRbbhrcwhoaahlinalRbbaotarVhralaAfhlaocwfgoca9hmbkara8E94aq7hqcbhoa8Fhlinalaqao486bbalcefhlaocwfgoca9hmbka8Fadfh8FaacefhaahcefghaA9hmbkkaEclfhEa3clfh3aYclfgYad6mbkaza8AaAcufad2fadz:jjjjb8AaAaOfhOaihxaimbkc9:hoxdkcbc99aPax9RakSEhoxekc9:hokavcjqf8Kjjjjbaok:bsesu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnalaeci9UgrcHf6mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgwce0mbavc;abfcFecjez:kjjjb8Aav9cu83iUav9cu83i8Wav9cu83iyav9cu83iaav9cu83iKav9cu83izav9cu83iwav9cu83ibaialfc9WfhDaicefgiarfhqdndnaeci9pmbaqhexekcmcsawceSEhkcbhxcbhmaqhecbhlcbhoindndnaiRbbgrc;Ve0mbavc;abfaoarcu7gPcl4fcsGcitfgwydlhsawydbhzdndnarcsGgwak9pmbavalaPfcsGcdtfydbaxawEhraxawTgHfhxxekdnaeaD9nmbc9:hoxokdndnawcsSmbcehHamawcetfcWfhrxekaecefhrae8SbbgwcFeGhPdndnawcu9mmbarhexekaecvfheaPcFbGhPcrhwdninar8SbbgHcFbGawtaPVhPaHcu9kmearcefhrawcrfgwc8J9hmbxdkkarcefhekcehHaPce4cbaPceG9R7amfhrkarhmkavc;abfaocitfgwarBdbawasBdlavalcdtfarBdbavc;abfaocefcsGcitfgwazBdbawarBdlaocdfhoaHalfhldnadcd9hmbabar87elabas87edabaz87ebabcofhbxdkabarBdwabasBdlabazBdbabcxfhbxekdnarcpe0mbavalaDarcsGfRbbgwcl4gP9RcsGcdtfydbaxcefgsaPEhravalaw9RcsGcdtfydbasaPTgzfgsawcsGgPEhwaPThPdndnadcd9hmbabaw87elabar87edabax87ebcohHxekabawBdwabarBdlabaxBdbcxhHkavalcdtfaxBdbavc;abfaocitfgOarBdbaOaxBdlavalcefglcsGcdtfarBdbavc;abfaocefcsGcitfgOawBdbaOarBdlavalazfglcsGcdtfawBdbavc;abfaocdfcsGcitfgraxBdbarawBdlaocifhoabaHfhbalaPfhlasaPfhxxekdnaeaD9nmbc9:hoxlkaxcbaeRbbgwEgHarc;:eSgrfhsawcsGhOdndnawcl4gAmbascefhzxekashzavalaA9RcsGcdtfydbhskdndnaOmbazcefhxxekazhxavalaw9RcsGcdtfydbhzkdndnarTmbaecefhrxekaecdfhrae8SbegPcFeGhwdnaPcu9kmbaecofhHawcFbGhwcrhedninar8SbbgPcFbGaetawVhwaPcu9kmearcefhraecrfgec8J9hmbkaHhrxekarcefhrkawce4cbawceG9R7amfgmhHkdndnaAcsSmbarhwxekarcefhwar8SbbgecFeGhPdnaecu9kmbarcvfhsaPcFbGhPcrhedninaw8SbbgrcFbGaetaPVhParcu9kmeawcefhwaecrfgec8J9hmbkashwxekawcefhwkaPce4cbaPceG9R7amfgmhskdndnaOcsSmbawhexekawcefheaw8SbbgrcFeGhPdnarcu9kmbawcvfhzaPcFbGhPcrhrdninae8SbbgwcFbGartaPVhPawcu9kmeaecefhearcrfgrc8J9hmbkazhexekaecefhekaPce4cbaPceG9R7amfgmhzkdndnadcd9hmbabaz87elabas87edabaH87ebcohrxekabazBdwabasBdlabaHBdbcxhrkavc;abfaocitfgwasBdbawaHBdlavalcdtfaHBdbavc;abfaocefcsGcitfgwazBdbawasBdlavalcefglcsGcdtfasBdbavc;abfaocdfcsGcitfgwaHBdbawazBdlavalaATaAcsSVfglcsGcdtfazBdbalaOTaOcsSVfhlaocifhoabarfhbkaocsGhoalcsGhlaicefgiaq6mbkkcbc99aeaDSEhokavc;aef8Kjjjjbaok:clevu8Jjjjjbcz9Rhvdnalaecvf9pmbc9:skdnaiRbbc;:eGc;qeSmbcuskav9cb83iwaicefhoaialfc98fhrdnaeTmbdnadcdSmbcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcdtfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgiBdbalaiBdbawcefgwae9hmbxdkkcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcetfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgi87ebalaiBdbawcefgwae9hmbkkcbc99aoarSEk:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk:4ioiue99dud99dud99dnaeTmbcbhiabhlindndnal8Uebgv:YgoJ:ji:1Salcof8UebgrciVgw:Y:vgDNJbbbZJbbb:;avcu9kEMgq:lJbbb9p9DTmbaq:Ohkxekcjjjj94hkkalclf8Uebhvalcdf8UebhxalarcefciGcetfak87ebdndnax:YgqaDNJbbbZJbbb:;axcu9kEMgm:lJbbb9p9DTmbam:Ohxxekcjjjj94hxkabaiarciGgkfcd7cetfax87ebdndnav:YgmaDNJbbbZJbbb:;avcu9kEMgP:lJbbb9p9DTmbaP:Ohvxekcjjjj94hvkalarcufciGcetfav87ebdndnawaw2:ZgPaPMaoaoN:taqaqN:tamamN:tgoJbbbbaoJbbbb9GE:raDNJbbbZMgD:lJbbb9p9DTmbaD:Ohrxekcjjjj94hrkalakcetfar87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2gdTmbinababydbgecwtcw91:Yaece91cjjj98Gcjjj;8if::NUdbabclfhbadcufgdmbkkk:Tvirud99eudndnadcl9hmbaeTmeindndnabRbbgiabcefgl8Sbbgvabcdfgo8Sbbgrf9R:YJbbuJabcifgwRbbgdce4adVgDcd4aDVgDcl4aDVgD:Z:vgqNJbbbZMgk:lJbbb9p9DTmbak:Ohxxekcjjjj94hxkaoax86bbdndnaraif:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohoxekcjjjj94hokalao86bbdndnavaifar9R:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabai86bbdndnaDadcetGadceGV:ZaqNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkawad86bbabclfhbaecufgembxdkkaeTmbindndnab8Vebgiabcdfgl8Uebgvabclfgo8Uebgrf9R:YJbFu9habcofgw8Vebgdce4adVgDcd4aDVgDcl4aDVgDcw4aDVgD:Z:vgqNJbbbZMgk:lJbbb9p9DTmbak:Ohxxekcjjjj94hxkaoax87ebdndnaraif:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohoxekcjjjj94hokalao87ebdndnavaifar9R:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabai87ebdndnaDadcetGadceGV:ZaqNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkawad87ebabcwfhbaecufgembkkk9teiucbcbyd:K:G:cjbgeabcifc98GfgbBd:K:G:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaeczfheaiczfhiadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkk83dbcj:Gdk8Kbbbbdbbblbbbwbbbbbbbebbbdbbblbbbwbbbbc:K:Gdkl8W:qbb"),i=WebAssembly.instantiate(r,{}).then(function(e){(n=e.instance).exports.__wasm_call_ctors()});function a(e){for(var n=new Uint8Array(e.length),r=0;r<e.length;++r){var i=e.charCodeAt(r);n[r]=i>96?i-97:i>64?i-39:i+4}var a=0;for(r=0;r<e.length;++r)n[a++]=n[r]<60?t[n[r]]:64*(n[r]-60)+n[++r];return n.buffer.slice(0,a)}function o(e,t,n,r,i,a,o){var s=e.exports.sbrk,A=r+3&-4,l=s(A*i),c=s(a.length),u=new Uint8Array(e.exports.memory.buffer);u.set(a,c);var f=t(l,r,i,c,a.length);if(0==f&&o&&o(l,A,i),n.set(u.subarray(l,l+r*i)),s(l-s(0)),0!=f)throw new Error("Malformed buffer data: "+f)}var s={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp",COLOR:"meshopt_decodeFilterColor"},A={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"},l=[],c=0;function u(e){var t={object:new Worker(e),pending:0,requests:{}};return t.object.onmessage=function(e){var n=e.data;t.pending-=n.count,t.requests[n.id][n.action](n.value),delete t.requests[n.id]},t}function f(e){var t=e.data;self.ready.then(function(e){if(!t.id)return self.close();try{var n=new Uint8Array(t.count*t.size);o(e,e.exports[t.mode],n,t.count,t.size,t.source,e.exports[t.filter]),self.postMessage({id:t.id,count:t.count,action:"resolve",value:n},[n.buffer])}catch(r){self.postMessage({id:t.id,count:t.count,action:"reject",value:r})}})}return{ready:i,supported:!0,useWorkers:function(e){!function(e){for(var t="self.ready = WebAssembly.instantiate(new Uint8Array(["+new Uint8Array(r)+"]), {}).then(function(result) { result.instance.exports.__wasm_call_ctors(); return result.instance; });self.onmessage = "+f.name+";"+o.toString()+f.toString(),n=new Blob([t],{type:"text/javascript"}),i=URL.createObjectURL(n),a=l.length;a<e;++a)l[a]=u(i);for(a=e;a<l.length;++a)l[a].object.postMessage({});l.length=e,URL.revokeObjectURL(i)}(e)},decodeVertexBuffer:function(e,t,r,i,a){o(n,n.exports.meshopt_decodeVertexBuffer,e,t,r,i,n.exports[s[a]])},decodeIndexBuffer:function(e,t,r,i){o(n,n.exports.meshopt_decodeIndexBuffer,e,t,r,i)},decodeIndexSequence:function(e,t,r,i){o(n,n.exports.meshopt_decodeIndexSequence,e,t,r,i)},decodeGltfBuffer:function(e,t,r,i,a,l){o(n,n.exports[A[a]],e,t,r,i,n.exports[s[l]])},decodeGltfBufferAsync:function(e,t,r,a,u){return l.length>0?function(e,t,n,r,i){for(var a=l[0],o=1;o<l.length;++o)l[o].pending<a.pending&&(a=l[o]);return new Promise(function(o,s){var A=new Uint8Array(n),l=++c;a.pending+=e,a.requests[l]={resolve:o,reject:s},a.object.postMessage({id:l,count:e,size:t,source:A,mode:r,filter:i},[A.buffer])})}(e,t,r,A[a],s[u]):i.then(function(){var i=new Uint8Array(e*t);return o(n,n.exports[A[a]],i,e,t,r,n.exports[s[u]]),i})}}}();function pc(e,t){if(!e)throw new Error(t||"assert failed: gltf")}var mc={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},gc={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},bc=["SCALAR","VEC2","VEC3","VEC4"],vc=new Map([[Int8Array,5120],[Uint8Array,5121],[Int16Array,5122],[Uint16Array,5123],[Uint32Array,5125],[Float32Array,5126],[Float64Array,5130]]),yc={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},xc={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},_c={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function wc(e){return bc[e-1]||bc[0]}function Tc(e){const t=vc.get(e.constructor);if(!t)throw new Error("Illegal typed array");return t}function Sc(e,t){const n=_c[e.componentType],r=yc[e.type],i=xc[e.componentType],a=e.count*r,o=e.count*r*i;return pc(o>=0&&o<=t.byteLength),{ArrayType:n,length:a,byteLength:o,componentByteSize:gc[e.componentType],numberOfComponentsInElement:mc[e.type]}}function Mc(e){let{images:t,bufferViews:n}=e;t=t||[],n=n||[];const r=t.map(e=>e.bufferView);n=n.filter(e=>!r.includes(e));const i=n.reduce((e,t)=>e+t.byteLength,0),a=t.reduce((e,t)=>{const{width:n,height:r}=t.image;return e+n*r},0);return i+Math.ceil(4*a*1.33)}var Ec=class{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];pc(n);const r=(e.byteOffset||0)+n.byteOffset;return new Uint8Array(n.arrayBuffer,r,e.byteLength)}getTypedArrayForAccessor(e){const t=this.getAccessor(e);return function(e,t,n){const r="number"==typeof n?e.accessors?.[n]:n;if(!r)throw new Error(`No gltf accessor ${JSON.stringify(n)}`);const i=e.bufferViews?.[r.bufferView||0];if(!i)throw new Error(`No gltf buffer view for accessor ${i}`);const{arrayBuffer:a,byteOffset:o}=t[i.buffer],s=(o||0)+(r.byteOffset||0)+(i.byteOffset||0),{ArrayType:A,length:l,componentByteSize:c,numberOfComponentsInElement:u}=Sc(r,i),f=c*u,d=i.byteStride||f;if(void 0===i.byteStride||i.byteStride===f)return new A(a,s,l);const h=new A(l);for(let p=0;p<r.count;p++){const e=new A(a,s+p*d,u);h.set(e,p*u)}return h}(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,r=t.byteOffset||0;return new Uint8Array(n,r,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 pc(t),this.json.extensions=this.json.extensions||{},this.json.extensions[e]=t,this.registerUsedExtension(e),t}addRequiredExtension(e,t={}){return pc(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 r={mesh:t};return n&&(r.matrix=n),this.json.nodes.push(r),this.json.nodes.length-1}addMesh(e){const{attributes:t,indices:n,material:r,mode:i=4}=e,a={primitives:[{attributes:this._addAttributes(t),mode:i}]};if(n){const e=this._addIndices(n);a.primitives[0].indices=e}return Number.isFinite(r)&&(a.primitives[0].material=r),this.json.meshes=this.json.meshes||[],this.json.meshes.push(a),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=r.getBinaryImageMetadata(e),i=t||n?.mimeType,a={bufferView:this.addBufferView(e),mimeType:i};return this.json.images=this.json.images||[],this.json.images.push(a),this.json.images.length-1}addBufferView(e,t=0,n=this.byteLength){const r=e.byteLength;pc(Number.isFinite(r)),this.sourceBuffers=this.sourceBuffers||[],this.sourceBuffers.push(e);const i={buffer:t,byteOffset:n,byteLength:r};return this.byteLength+=h(r,4),this.json.bufferViews=this.json.bufferViews||[],this.json.bufferViews.push(i),this.json.bufferViews.length-1}addAccessor(e,t){const n={bufferView:e,type:wc(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 r={min:t.min,max:t.max};r.min&&r.max||(r=this._getAccessorMinMax(e,t.size));const i={size:t.size,componentType:Tc(e),count:Math.round(e.length/t.size),min:r.min,max:r.max};return this.addAccessor(n,Object.assign(i,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 r=0;for(const i of this.sourceBuffers||[])r=p(i,n,r);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 r=e.indexOf(t);r>-1?e.splice(r,1):n=!1}}_addAttributes(e={}){const t={};for(const n in e){const r=e[n];t[this._getGltfAttributeName(n)]=this.addBinaryBuffer(r.value,r)}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 r=e.subarray(0,t);for(const i of r)n.min.push(i),n.max.push(i);for(let i=t;i<e.length;i+=t)for(let r=0;r<t;r++)n.min[0+r]=Math.min(n.min[0+r],e[i+r]),n.max[0+r]=Math.max(n.max[0+r],e[i+r]);return n}};function Cc(e){return(e%1+1)%1}var Ic={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16,BOOLEAN:1,STRING:1,ENUM:1},Rc={INT8:Int8Array,UINT8:Uint8Array,INT16:Int16Array,UINT16:Uint16Array,INT32:Int32Array,UINT32:Uint32Array,INT64:BigInt64Array,UINT64:BigUint64Array,FLOAT32:Float32Array,FLOAT64:Float64Array},Pc={INT8:1,UINT8:1,INT16:2,UINT16:2,INT32:4,UINT32:4,INT64:8,UINT64:8,FLOAT32:4,FLOAT64:8};function Nc(e,t){return Pc[t]*Ic[e]}function kc(e,t,n,r){if("UINT8"!==n&&"UINT16"!==n&&"UINT32"!==n&&"UINT64"!==n)return null;const i=Lc(e.getTypedArrayForBufferView(t),"SCALAR",n,r+1);return i instanceof BigInt64Array||i instanceof BigUint64Array?null:i}function Lc(e,t,r,i=1){const a=Rc[r],o=Pc[r],s=i*Ic[t],A=s*o;let l=e.buffer,c=e.byteOffset;return c%o!==0&&(l=new Uint8Array(l).slice(c,c+A).buffer,c=0),new a(n.ensureArrayBuffer(l),c,s)}function Bc(e,t,n){const r=`TEXCOORD_${t.texCoord||0}`,i=n.attributes[r],a=e.getTypedArrayForAccessor(i),o=e.gltf.json,s=t.index,A=o.textures?.[s]?.source;if(void 0!==A){const n=o.images?.[A]?.mimeType,r=e.gltf.images?.[A];if(r&&void 0!==r.width){const e=[];for(let i=0;i<a.length;i+=2){const o=Fc(r,n,a,i,t.channels);e.push(o)}return e}}return[]}function Oc(e,t,n,r,i){if(!n?.length)return;const a=[];for(const c of n){let e=r.findIndex(e=>e===c);-1===e&&(e=r.push(c)-1),a.push(e)}const o=new Uint32Array(a),s=e.gltf.buffers.push({arrayBuffer:o.buffer,byteOffset:o.byteOffset,byteLength:o.byteLength})-1,A=e.addBufferView(o,s,0),l=e.addAccessor(A,{size:1,componentType:Tc(o),count:o.length});i.attributes[t]=l}function Fc(e,t,n,i,a=[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 l=1;!t||-1===t.indexOf("image/jpeg")&&-1===t.indexOf("image/png")||(l=4);const c=function(e,t,n,r=1){const i=n.width,a=Cc(e)*(i-1),o=Math.round(a),s=n.height,A=Cc(t)*(s-1),l=Math.round(A),c=n.components?n.components:r;return(l*i+o)*c}(s,A,e,l);let u=0;for(const f of a){const t="number"==typeof f?Object.values(o)[f]:o[f],n=c+t.offset,i=r.getImageData(e);if(i.data.length<=n)throw new Error(`${i.data.length} <= ${n}`);u|=i.data[n]<<t.shift}return u}function Dc(e,t,n,r,i){const a=[];for(let o=0;o<t;o++){const t=n[o],s=n[o+1]-n[o];if(s+t>r)break;const A=t/i,l=s/i;a.push(e.slice(A,A+l))}return a}function Uc(e,t,n){const r=[];for(let i=0;i<t;i++){const t=i*n;r.push(e.slice(t,t+n))}return r}function Vc(e,t,n,r){if(n)throw new Error("Not implemented - arrayOffsets for strings is specified");if(r){const n=[],i=new TextDecoder("utf8");let a=0;for(let o=0;o<e;o++){const e=r[o+1]-r[o];if(e+a<=t.length){const r=t.subarray(a,e+a),o=i.decode(r);n.push(o),a+=e}}return n}return[]}var jc=e.__exportAll({createExtMeshFeatures:()=>Kc,decode:()=>Hc,encode:()=>qc,name:()=>Gc}),zc="EXT_mesh_features",Gc=zc;async function Hc(e,t){!function(e,t){const n=e.gltf.json;if(!n.meshes)return;for(const r of n.meshes)for(const n of r.primitives)Qc(e,n,t)}(new Ec(e),t)}function qc(e,t){const n=new Ec(e);return function(e){const t=e.gltf.json.meshes;if(!t)return;for(const n of t)for(const t of n.primitives)Wc(e,t)}(n),n.createBinaryChunk(),n.gltf}function Qc(e,t,n){if(!n?.gltf?.loadBuffers)return;const r=(t.extensions?.[zc])?.featureIds;if(r)for(const i of r){let r;if(void 0!==i.attribute){const n=`_FEATURE_ID_${i.attribute}`,a=t.attributes[n];r=e.getTypedArrayForAccessor(a)}else r=void 0!==i.texture&&n?.gltf?.loadImages?Bc(e,i.texture,t):[];i.data=r}}function Kc(e,t,n,r){t.extensions||(t.extensions={});let i=t.extensions[zc];i||(i={featureIds:[]},t.extensions[zc]=i);const{featureIds:a}=i,o={featureCount:n.length,propertyTable:r,data:n};a.push(o),e.addObjectExtension(t,zc,i)}function Wc(e,t){const n=t.extensions?.[zc];if(!n)return;const r=n.featureIds;r.forEach((n,i)=>{if(n.data){const{accessorKey:a,index:o}=function(e){const t="_FEATURE_ID_",n=Object.keys(e).filter(e=>0===e.indexOf(t));let r=-1;for(const i of n){const e=Number(i.substring(12));e>r&&(r=e)}return r++,{accessorKey:`${t}${r}`,index:r}}(t.attributes),s=new Uint32Array(n.data);r[i]={featureCount:s.length,propertyTable:n.propertyTable,attribute:o},e.gltf.buffers.push({arrayBuffer:s.buffer,byteOffset:s.byteOffset,byteLength:s.byteLength});const A=e.addBufferView(s),l=e.addAccessor(A,{size:1,componentType:Tc(s),count:s.length});t.attributes[a]=l}})}var $c=e.__exportAll({createExtStructuralMetadata:()=>lu,decode:()=>Xc,encode:()=>Zc,name:()=>Yc}),Jc="EXT_structural_metadata",Yc=Jc;async function Xc(e,t){!function(e,t){if(!t.gltf?.loadBuffers)return;const n=e.getExtension(Jc);if(!n)return;t.gltf?.loadImages&&function(e,t){const n=t.propertyTextures,r=e.gltf.json;if(n&&r.meshes)for(const i of r.meshes)for(const r of i.primitives)tu(e,n,r,t)}(e,n);!function(e,t){const n=t.schema;if(!n)return;const r=n.classes,i=t.propertyTables;if(r&&i)for(const a in r){const t=eu(i,a);t&&ru(e,n,t)}}(e,n)}(new Ec(e),t)}function Zc(e,t){const n=new Ec(e);return function(e){const t=e.getExtension(Jc);if(!t)return;if(t.propertyTables)for(const n of t.propertyTables){const r=n.class,i=t.schema?.classes?.[r];n.properties&&i&&Au(n,i,e)}}(n),n.createBinaryChunk(),n.gltf}function eu(e,t){for(const n of e)if(n.class===t)return n;return null}function tu(e,t,n,r){if(!t)return;const i=(n.extensions?.[Jc])?.propertyTextures;if(i)for(const a of i){nu(e,t[a],n,r)}}function nu(e,t,n,r){if(!t.properties)return;r.dataAttributeNames||(r.dataAttributeNames=[]);const i=t.class;for(const a in t.properties){const o=`${i}_${a}`,s=t.properties?.[a];if(!s)continue;s.data||(s.data=[]);const A=s.data,l=Bc(e,s,n);null!==l&&(Oc(e,o,l,A,n),s.data=A,r.dataAttributeNames.push(o))}}function ru(e,t,n){const r=t.classes?.[n.class];if(!r)throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${n.class}`);const i=n.count;for(const a in r.properties){const o=r.properties[a],s=n.properties?.[a];s&&(s.data=iu(e,t,o,i,s))}}function iu(e,t,n,r,i){let a=[];const o=i.values,s=e.getTypedArrayForBufferView(o),A=function(e,t,n,r){return t.array&&void 0===t.count&&void 0!==n.arrayOffsets?kc(e,n.arrayOffsets,n.arrayOffsetType||"UINT32",r):null}(e,n,i,r),l=function(e,t,n){return void 0!==t.stringOffsets?kc(e,t.stringOffsets,t.stringOffsetType||"UINT32",n):null}(e,i,r);switch(n.type){case"SCALAR":case"VEC2":case"VEC3":case"VEC4":case"MAT2":case"MAT3":case"MAT4":a=function(e,t,n,r){const i=e.array,a=e.count,o=Nc(e.type,e.componentType),s=n.byteLength/o;let A;A=e.componentType?Lc(n,e.type,e.componentType,s):n;if(i)return r?Dc(A,t,r,n.length,o):a?Uc(A,t,a):[];return A}(n,r,s,A);break;case"BOOLEAN":throw new Error(`Not implemented - classProperty.type=${n.type}`);case"STRING":a=Vc(r,s,A,l);break;case"ENUM":a=function(e,t,n,r,i){const a=t.enumType;if(!a)throw new Error("Incorrect data in the EXT_structural_metadata extension: classProperty.enumType is not set for type ENUM");const o=e.enums?.[a];if(!o)throw new Error(`Incorrect data in the EXT_structural_metadata extension: schema.enums does't contain ${a}`);const s=o.valueType||"UINT16",A=Nc(t.type,s),l=r.byteLength/A;let c=Lc(r,t.type,s,l);c||(c=r);if(t.array){if(i)return function(e){const{valuesData:t,numberOfElements:n,arrayOffsets:r,valuesDataBytesLength:i,elementSize:a,enumEntry:o}=e,s=[];for(let A=0;A<n;A++){const e=r[A],n=r[A+1]-r[A];if(n+e>i)break;const l=au(t,e/a,n/a,o);s.push(l)}return s}({valuesData:c,numberOfElements:n,arrayOffsets:i,valuesDataBytesLength:r.length,elementSize:A,enumEntry:o});const e=t.count;return e?function(e,t,n,r){const i=[];for(let a=0;a<t;a++){const t=au(e,n*a,n,r);i.push(t)}return i}(c,n,e,o):[]}return au(c,0,n,o)}(t,n,r,s,A);break;default:throw new Error(`Unknown classProperty type ${n.type}`)}return a}function au(e,t,n,r){const i=[];for(let a=0;a<n;a++)if(e instanceof BigInt64Array||e instanceof BigUint64Array)i.push("");else{const n=ou(r,e[t+a]);n?i.push(n.name):i.push("")}return i}function ou(e,t){for(const n of e.values)if(n.value===t)return n;return null}var su="schemaClassId";function Au(e,t,n){for(const r in e.properties){const i=e.properties[r].data;if(i){const a=t.properties[r];if(a){const t=cu(i,a,n);e.properties[r]=t}}}}function lu(e,t,n=su){let r=e.getExtension(Jc);r||(r=e.addExtension(Jc)),r.schema=function(e,t,n){const r=n??{id:"schema_id"},i={properties:{}};for(const a of e){const e={type:a.elementType,componentType:a.componentType};i.properties[a.name]=e}return r.classes={},r.classes[t]=i,r}(t,n,r.schema);const i=function(e,t,n){const r={class:t,count:0};let i=0;const a=n.classes?.[t];for(const o of e){if(0===i&&(i=o.values.length),i!==o.values.length&&o.values.length)throw new Error("Illegal values in attributes");a?.properties[o.name]&&(r.properties||(r.properties={}),r.properties[o.name]={values:0,data:o.values})}return r.count=i,r}(t,n,r.schema);return r.propertyTables||(r.propertyTables=[]),r.propertyTables.push(i)-1}function cu(e,t,n){const r={values:0};if("STRING"===t.type){const{stringData:t,stringOffsets:i}=function(e){const t=new TextEncoder,n=[];let r=0;for(const s of e){const e=t.encode(s);r+=e.length,n.push(e)}const i=new Uint8Array(r),a=[];let o=0;for(const s of n)i.set(s,o),a.push(o),o+=s.length;return a.push(o),{stringData:i,stringOffsets:new Uint32Array(a)}}(e);r.stringOffsets=fu(i,n),r.values=fu(t,n)}else"SCALAR"===t.type&&t.componentType&&(r.values=fu(function(e,t){const n=[];for(const i of e)n.push(Number(i));const r=uu[t];if(!r)throw new Error("Illegal component type");return new r(n)}(e,t.componentType),n));return r}var uu={INT8:Int8Array,UINT8:Uint8Array,INT16:Int16Array,UINT16:Uint16Array,INT32:Int32Array,UINT32:Uint32Array,INT64:Int32Array,UINT64:Uint32Array,FLOAT32:Float32Array,FLOAT64:Float64Array};function fu(e,t){return t.gltf.buffers.push({arrayBuffer:n.ensureArrayBuffer(e.buffer),byteOffset:e.byteOffset,byteLength:e.byteLength}),t.addBufferView(e)}var du=e.__exportAll({decode:()=>mu,name:()=>pu}),hu="EXT_feature_metadata",pu=hu;async function mu(e,t){!function(e,t){if(!t.gltf?.loadBuffers)return;const n=e.getExtension(hu);if(!n)return;t.gltf?.loadImages&&function(e,t){const n=t.schema;if(!n)return;const r=n.classes,{featureTextures:i}=t;if(r&&i)for(const a in r){const t=r[a],n=bu(i,a);n&&yu(e,n,t)}}(e,n);!function(e,t){const n=t.schema;if(!n)return;const r=n.classes,i=t.featureTables;if(r&&i)for(const a in r){const t=gu(i,a);t&&vu(e,n,t)}}(e,n)}(new Ec(e),t)}function gu(e,t){for(const n in e){const r=e[n];if(r.class===t)return r}return null}function bu(e,t){for(const n in e){const r=e[n];if(r.class===t)return r}return null}function vu(e,t,n){if(!n.class)return;const r=t.classes?.[n.class];if(!r)throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${n.class}`);const i=n.count;for(const a in r.properties){const o=r.properties[a],s=n.properties?.[a];s&&(s.data=xu(e,t,o,i,s))}}function yu(e,t,n){const r=t.class;for(const i in n.properties){const n=t?.properties?.[i];n&&(n.data=_u(e,n,r))}}function xu(e,t,n,r,i){let a=[];const o=i.bufferView,s=e.getTypedArrayForBufferView(o),A=function(e,t,n,r){return"ARRAY"===t.type&&void 0===t.componentCount&&void 0!==n.arrayOffsetBufferView?kc(e,n.arrayOffsetBufferView,n.offsetType||"UINT32",r):null}(e,n,i,r),l=function(e,t,n,r){return void 0!==n.stringOffsetBufferView?kc(e,n.stringOffsetBufferView,n.offsetType||"UINT32",r):null}(e,0,i,r);return"STRING"===n.type||"STRING"===n.componentType?a=Vc(r,s,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)&&(a=function(e,t,n,r){const i="ARRAY"===e.type,a=e.componentCount,o="SCALAR",s=e.componentType||e.type,A=Nc(o,s),l=n.byteLength/A,c=Lc(n,o,s,l);if(i)return r?Dc(c,t,r,n.length,A):a?Uc(c,t,a):[];return c}(n,r,s,A)),a}function _u(e,t,n){const r=e.gltf.json;if(!r.meshes)return[];const i=[];for(const a of r.meshes)for(const r of a.primitives)wu(e,n,t,i,r);return i}function wu(e,t,n,r,i){const a=Bc(e,{channels:n.channels,...n.texture},i);a&&Oc(e,t,a,r,i)}var Tu,Su,Mu="basis_transcoder.js",Eu="basis_transcoder.wasm",Cu="basis_encoder.js",Iu="basis_encoder.wasm";async function Ru(e){var t;t=e.modules,globalThis.loaders||={},globalThis.loaders.modules||={},Object.assign(globalThis.loaders.modules,t);const n=function(e){return globalThis.loaders?.modules?.[e]||null}("basis");return n||(Tu||=async function(e){let t=null,n=null;return[t,n]=await Promise.all([await u(Mu,"textures",e),await u(Eu,"textures",e)]),t=t||globalThis.BASIS,await function(e,t){const n={};t&&(n.wasmBinary=t);return y(()=>e(n),e=>{const{BasisFile:t,initializeBasis:n}=e;return n(),{BasisFile:t}})}(t,n)}(e),await Tu)}async function Pu(e){const t=e.modules||{};return t.basisEncoder?t.basisEncoder:(Su=Su||async function(e){let t=null,n=null;return[t,n]=await Promise.all([await u(Cu,"textures",e),await u(Iu,"textures",e)]),t=t||globalThis.BASIS,await function(e,t){const n={};t&&(n.wasmBinary=t);return y(()=>e(n),e=>{const{BasisFile:t,KTX2File:n,BasisEncoder:r,initializeBasis:i}=e;return i(),{BasisFile:t,KTX2File:n,BasisEncoder:r}})}(t,n)}(e),await Su)}var Nu=["","WEBKIT_","MOZ_"],ku={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"]},Lu=null;function Bu(e){if(!Lu){e=e||function(){try{return document.createElement("canvas").getContext("webgl")}catch(e){return null}}()||void 0,Lu=new Set;for(const t of Nu)for(const n in ku)if(e&&e.getExtension(`${t}${n}`))for(const e of ku[n])Lu.add(e)}return Lu}var Ou=[171,75,84,88,32,50,48,187,13,10,26,10];var Fu=Promise.resolve(),Du={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:6,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"}};Object.freeze(Object.keys(Du));function Uu(e,t,n){const r=new e(new Uint8Array(t));try{if(!r.startTranscoding())throw new Error("Failed to start basis transcoding");const e=r.getNumImages(),t=[];for(let i=0;i<e;i++){const e=r.getNumLevels(i),a=[];for(let t=0;t<e;t++)a.push(Vu(r,i,t,n));t.push(a)}return t}finally{r.close(),r.delete()}}function Vu(e,t,n,r){const i=e.getImageWidth(t,n),a=e.getImageHeight(t,n),o=e.getHasAlpha(),{compressed:s,format:A,basisFormat:l,textureFormat:c}=Gu(r,o),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:i,height:a,data:f,compressed:s,...void 0!==A?{format:A}:{},...void 0!==c?{textureFormat:c}:{},hasAlpha:o}}function ju(e,t,n){const r=new e(new Uint8Array(t));try{if(!r.startTranscoding())throw new Error("failed to start KTX2 transcoding");const e=r.getLevels(),t=[];for(let i=0;i<e;i++)t.push(zu(r,i,n));return[t]}finally{r.close(),r.delete()}}function zu(e,t,n){const{alphaFlag:r,height:i,width:a}=e.getImageLevelInfo(t,0,0),{compressed:o,format:s,basisFormat:A,textureFormat:l}=Gu(n,r),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:a,height:i,data:u,compressed:o,...void 0!==s?{format:s}:{},...void 0!==l?{textureFormat:l}:{},levelSize:c,hasAlpha:r}}function Gu(e,t){let n=e.basis?.format||"auto";"auto"===n&&(n=e.basis?.supportedTextureFormats?Hu(e.basis.supportedTextureFormats):Hu()),"object"==typeof n&&(n=t?n.alpha:n.noAlpha);const r=n.toLowerCase(),i=Du[r];if(!i)throw new Error(`Unknown Basis format ${n}`);return i}function Hu(e=Bu()){const t=new Set(e);return qu(t,["astc-4x4-unorm","astc-4x4-unorm-srgb"])?"astc-4x4":qu(t,["bc7-rgba-unorm","bc7-rgba-unorm-srgb"])?{alpha:"bc7-m5",noAlpha:"bc7-m6-opaque-only"}:qu(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"}:qu(t,["pvrtc-rgb4unorm-webgl","pvrtc-rgba4unorm-webgl","pvrtc-rgb2unorm-webgl","pvrtc-rgba2unorm-webgl"])?{alpha:"pvrtc1-4-rgba",noAlpha:"pvrtc1-4-rgb"}:qu(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":qu(t,["atc-rgb-unorm-webgl","atc-rgba-unorm-webgl","atc-rgbai-unorm-webgl"])?{alpha:"atc-rgba-interpolated-alpha",noAlpha:"atc-rgb"}:"rgb565"}function qu(e,t){return t.some(t=>e.has(t))}var Qu={...{dataType:null,batchType:null,name:"Basis",id:"basis",module:"textures",version:"4.5.4",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=c(t);return await async function(e){const t=Fu;let n;Fu=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<Ou.length||t[0]!==Ou[0]||t[1]!==Ou[1]||t[2]!==Ou[2]||t[3]!==Ou[3]||t[4]!==Ou[4]||t[5]!==Ou[5]||t[6]!==Ou[6]||t[7]!==Ou[7]||t[8]!==Ou[8]||t[9]!==Ou[9]||t[10]!==Ou[10]||t[11]!==Ou[11])}(e))return ju((await Pu(n)).KTX2File,e,t);const{BasisFile:r}=await Ru(n);return Uu(r,e,t)}if("encoder"===t.basis.module){const r=await Pu(n);return"ktx2"===t.basis.containerFormat?ju(r.KTX2File,e,t):Uu(r.BasisFile,e,t)}{const{BasisFile:r}=await Ru(n);return Uu(r,e,t)}})}},Ku=!0,Wu=1735152710,$u=1313821514,Ju=5130562;function Yu(e,t,r=0,i={}){const a=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))}`}(a,r+0),s=a.getUint32(r+4,Ku),A=a.getUint32(r+8,Ku);switch(Object.assign(e,{header:{byteOffset:r,byteLength:A,hasBinChunk:!1},type:o,version:s,json:{},binChunks:[]}),r+=12,e.version){case 1:return function(e,t,r){n.assert$3(e.header.byteLength>20);const i=t.getUint32(r+0,Ku),a=t.getUint32(r+4,Ku);return r+=8,n.assert$3(0===a),Xu(e,t,r,i),r+=i,r+=Zu(e,t,r,e.header.byteLength),r}(e,a,r);case 2:return function(e,t,r,i){return n.assert$3(e.header.byteLength>20),function(e,t,n,r){for(;n+8<=e.header.byteLength;){const i=t.getUint32(n+0,Ku),a=t.getUint32(n+4,Ku);switch(n+=8,a){case $u:Xu(e,t,n,i);break;case Ju:Zu(e,t,n,i);break;case 0:r.strict||Xu(e,t,n,i);break;case 1:r.strict||Zu(e,t,n,i)}n+=h(i,4)}}(e,t,r,i),r+e.header.byteLength}(e,a,r,{});default:throw new Error(`Invalid GLB version ${e.version}. Only supports version 1 and 2.`)}}function Xu(e,t,n,r){const i=new Uint8Array(t.buffer,n,r),a=new TextDecoder("utf8").decode(i);return e.json=JSON.parse(a),h(r,4)}function Zu(e,t,n,r){return e.header.hasBinChunk=!0,e.binChunks.push({byteOffset:n,byteLength:r,arrayBuffer:t.buffer}),h(r,4)}function ef(e,t,n){if(e.startsWith("data:")||e.startsWith("http:")||e.startsWith("https:"))return e;const r=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(!r)throw new Error(`'baseUrl' must be provided to resolve relative url ${e}`);return r.endsWith("/")?`${r}${e}`:`${r}/${e}`}async function tf(e,t,n){if(!t.gltf?.decompressMeshes||!t.gltf.loadBuffers)return;!function(e){const t=e.bufferViews||[];for(let r=0;r<t.length;r++){const e=t[r].extensions;if(e?.KHR_meshopt_compression&&e.EXT_meshopt_compression)throw new Error(`glTF bufferView ${r} cannot use both KHR_meshopt_compression and EXT_meshopt_compression.`)}const n=e.buffers||[];for(let r=0;r<n.length;r++){const e=n[r].extensions;if(e?.KHR_meshopt_compression&&e.EXT_meshopt_compression)throw new Error(`glTF buffer ${r} cannot use both KHR_meshopt_compression and EXT_meshopt_compression.`)}}(e.json);const r=new Ec(e),i=e.json.bufferViews||[],a=i.map(e=>async function(e,t,n){const r=e.getObjectExtension(t,n);if(!r)return;const{byteOffset:i=0,byteLength:a,byteStride:o,count:s,mode:A,filter:l="NONE",buffer:c}=r,u=e.gltf.buffers[c],f=e.gltf.buffers[t.buffer],d=new Uint8Array(u.arrayBuffer,u.byteOffset+i,a),h=new Uint8Array(f.arrayBuffer,f.byteOffset+(t.byteOffset||0),t.byteLength);await async function(e,t,n,r,i,a="NONE"){await hc.ready,hc.decodeGltfBuffer(e,t,n,r,i,function(e){return"string"==typeof e?e:["NONE","OCTAHEDRAL","QUATERNION","EXPONENTIAL","COLOR"][e]}(a))}(h,s,o,d,A,l)}(r,e,n));await Promise.all(a);for(const o of i)r.removeObjectExtension(o,n);for(const o of e.json.buffers||[])r.removeObjectExtension(o,n);r.removeExtension(n)}var nf=e.__exportAll({decode:()=>af,name:()=>rf}),rf="EXT_meshopt_compression";async function af(e,t){await tf(e,t,rf)}var of=e.__exportAll({decode:()=>Af,name:()=>sf}),sf="KHR_meshopt_compression";async function Af(e,t){await tf(e,t,sf)}var lf=e.__exportAll({name:()=>uf,preprocess:()=>ff}),cf="EXT_texture_webp",uf=cf;function ff(e,t){const n=new Ec(e);if(!M("image/webp")){if(n.getRequiredExtensions().includes(cf))throw new Error(`gltf: Required extension ${cf} not supported by browser`);return}const{json:r}=n;for(const i of r.textures||[]){const e=n.getObjectExtension(i,cf);e&&(i.source=e.source),n.removeObjectExtension(i,cf)}n.removeExtension(cf)}var df=e.__exportAll({name:()=>pf,preprocess:()=>mf}),hf="EXT_texture_avif",pf=hf;async function mf(e,t){const n=new Ec(e);if(!(await T()).has("image/avif")){if(n.getRequiredExtensions().includes(hf))throw new Error(`gltf: Required extension ${hf} not supported by browser`);return}const{json:r}=n;for(const i of r.textures||[]){const e=n.getObjectExtension(i,hf);e&&(i.source=e.source),n.removeObjectExtension(i,hf)}n.removeExtension(hf)}var gf=e.__exportAll({name:()=>vf,preprocess:()=>yf}),bf="KHR_texture_basisu",vf=bf;function yf(e,t){const n=new Ec(e),{json:r}=n;for(const i of r.textures||[]){const e=n.getObjectExtension(i,bf);e&&(i.source=e.source,n.removeObjectExtension(i,bf))}n.removeExtension(bf)}var xf,_f="https://www.gstatic.com/draco/versioned/decoders/1.5.6",wf="draco_wasm_wrapper.js",Tf="draco_decoder.wasm",Sf="draco_decoder.js",Mf="draco_encoder.js",Ef={[wf]:`${_f}/${wf}`,[Tf]:`${_f}/${Tf}`,[Sf]:`${_f}/${Sf}`,[Mf]:`https://raw.githubusercontent.com/google/draco/1.4.1/javascript/${Mf}`};async function Cf(e={},t){const r=e.modules||{};return r.draco3d?xf||=y(()=>r.draco3d.createDecoderModule({}),e=>({draco:e})):xf||=async function(e,t){let r,i;if("js"===t)r=await u(Ef[Sf],"draco",e,Sf);else try{[r,i]=await Promise.all([await u(Ef[wf],"draco",e,wf),await u(Ef[Tf],"draco",e,Tf)])}catch{r=null,i=null}r=If(r,"DracoDecoderModule"),r=r||globalThis.DracoDecoderModule,r||n.isBrowser||([r,i]=await Promise.all([await u(Ef[wf],"draco",{...e,useLocalLibraries:!0},wf),await u(Ef[Tf],"draco",{...e,useLocalLibraries:!0},Tf)]),r=If(r,"DracoDecoderModule"),r=r||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 y(t=>e({...n,onModuleLoaded:t}),e=>({draco:e}))}(r,i)}(e,t),await xf}function If(e,t){if(e&&"object"==typeof e){if(e.default)return e.default;if(e[t])return e[t]}return e}function Rf(e,t,n){return x(e,t,n?Pf(n.metadata):void 0)}function Pf(e){Object.entries(e);const t={};for(const n in e)t[`${n}.string`]=JSON.stringify(e[n]);return t}var Nf={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},kf={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array},Lf=class{draco;decoder;metadataQuerier;constructor(e){this.draco=e,this.decoder=new this.draco.Decoder,this.metadataQuerier=new this.draco.MetadataQuerier}destroy(){this.draco.destroy(this.decoder),this.draco.destroy(this.metadataQuerier)}parseSync(e,t={}){const n=new this.draco.DecoderBuffer;n.Init(new Int8Array(e),e.byteLength),this._disableAttributeTransforms(t);const r=this.decoder.GetEncodedGeometryType(n),i=r===this.draco.TRIANGULAR_MESH?new this.draco.Mesh:new this.draco.PointCloud;try{let e;switch(r){case this.draco.TRIANGULAR_MESH:e=this.decoder.DecodeBufferToMesh(n,i);break;case this.draco.POINT_CLOUD:e=this.decoder.DecodeBufferToPointCloud(n,i);break;default:throw new Error("DRACO: Unknown geometry type.")}if(!e.ok()||!i.ptr){const t=`DRACO decompression failed: ${e.error_msg()}`;throw new Error(t)}const a=this._getDracoLoaderData(i,r,t),o=this._getMeshData(i,a,t),s=function(e){let t=1/0,n=1/0,r=1/0,i=-1/0,a=-1/0,o=-1/0;const s=e.POSITION?e.POSITION.value:[],A=s&&s.length;for(let l=0;l<A;l+=3){const e=s[l],A=s[l+1],c=s[l+2];t=e<t?e:t,n=A<n?A:n,r=c<r?c:r,i=e>i?e:i,a=A>a?A:a,o=c>o?c:o}return[[t,n,r],[i,a,o]]}(o.attributes),A=function(e,t,n){const r=Pf(t.metadata),i=[],a=function(e){const t={};for(const n in e){const r=e[n];t[r.name||"undefined"]=r}return t}(t.attributes);for(const o in e){const t=Rf(o,e[o],a[o]);i.push(t)}if(n){const e=Rf("indices",n);i.push(e)}return{fields:i,metadata:r}}(o.attributes,a,o.indices);return{loader:"draco",loaderData:a,header:{vertexCount:i.num_points(),boundingBox:s},...o,schema:A}}finally{this.draco.destroy(n),i&&this.draco.destroy(i)}}_getDracoLoaderData(e,t,n){const r=this._getTopLevelMetadata(e),i=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:r,attributes:i}}_getDracoAttributes(e,t){const n={};for(let r=0;r<e.num_attributes();r++){const i=this.decoder.GetAttribute(e,r),a=this._getAttributeMetadata(e,r);n[i.unique_id()]={unique_id:i.unique_id(),attribute_type:i.attribute_type(),data_type:i.data_type(),num_components:i.num_components(),byte_offset:i.byte_offset(),byte_stride:i.byte_stride(),normalized:i.normalized(),attribute_index:r,metadata:a};const o=this._getQuantizationTransform(i,t);o&&(n[i.unique_id()].quantization_transform=o);const s=this._getOctahedronTransform(i,t);s&&(n[i.unique_id()].octahedron_transform=s)}return n}_getMeshData(e,t,n){const r=this._getMeshAttributes(t,e,n);if(!r.POSITION)throw new Error("DRACO: No position attribute found.");if(e instanceof this.draco.Mesh){if("triangle-strip"===n.topology)return{topology:"triangle-strip",mode:4,attributes:r,indices:{value:this._getTriangleStripIndices(e),size:1}};return{topology:"triangle-list",mode:5,attributes:r,indices:{value:this._getTriangleListIndices(e),size:1}}}return{topology:"point-list",mode:0,attributes:r}}_getMeshAttributes(e,t,n){const r={};for(const i of Object.values(e.attributes)){const e=this._deduceAttributeName(i,n);i.name=e;const a=this._getAttributeValues(t,i);if(a){const{value:t,size:n}=a;r[e]={value:t,size:n,byteOffset:i.byte_offset,byteStride:i.byte_stride,normalized:i.normalized}}}return r}_getTriangleListIndices(e){const t=3*e.num_faces(),n=4*t,r=this.draco._malloc(n);try{return this.decoder.GetTrianglesUInt32Array(e,n,r),new Uint32Array(this.draco.HEAPF32.buffer,r,t).slice()}finally{this.draco._free(r)}}_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 r=0;r<t;r++)n[r]=e.GetValue(r);return n}(t)}finally{this.draco.destroy(t)}}_getAttributeValues(e,t){const n=kf[t.data_type];if(!n)return console.warn(`DRACO: Unsupported attribute type ${t.data_type}`),null;const r=t.num_components,i=e.num_points()*r,a=i*n.BYTES_PER_ELEMENT,o=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 s;const A=this.draco._malloc(a);try{const r=this.decoder.GetAttribute(e,t.attribute_index);this.decoder.GetAttributeDataArrayForAllPoints(e,r,o,a,A),s=new n(this.draco.HEAPF32.buffer,A,i).slice()}finally{this.draco._free(A)}return{value:s,size:r}}_deduceAttributeName(e,t){const n=e.unique_id;for(const[a,o]of Object.entries(t.extraAttributes||{}))if(o===n)return a;const r=e.attribute_type;for(const a in Nf)if(this.draco[a]===r)return Nf[a];const i=t.attributeNameEntry||"name";return e.metadata[i]?e.metadata[i].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 r=0;r<n;r++){const n=this.metadataQuerier.GetEntryName(e,r);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 r=function(e){const t=e.size(),n=new Int32Array(t);for(let r=0;r<t;r++)n[r]=e.GetValue(r);return n}(n);return{int:this.metadataQuerier.GetIntEntry(e,t),string:this.metadataQuerier.GetStringEntry(e,t),double:this.metadataQuerier.GetDoubleEntry(e,t),intArray:r}}finally{this.draco.destroy(n)}}_disableAttributeTransforms(e){const{quantizedAttributes:t=[],octahedronAttributes:n=[]}=e,r=[...t,...n];for(const i of r)this.decoder.SkipAttributeTransform(this.draco[i])}_getQuantizationTransform(e,t){const{quantizedAttributes:n=[]}=t,r=e.attribute_type();if(n.map(e=>this.decoder[e]).includes(r)){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,r=e.attribute_type();if(n.map(e=>this.decoder[e]).includes(r)){const t=new this.draco.AttributeQuantizationTransform;try{if(t.InitFromAttribute(e))return{quantization_bits:t.quantization_bits()}}finally{this.draco.destroy(t)}}return null}};var Bf={...{dataType:null,batchType:null,name:"Draco",id:"draco",module:"draco",version:"4.5.4",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 Cf(c(t),t?.draco?.decoderType||"wasm"),r=new Lf(n);try{return r.parseSync(e,t?.draco)}finally{r.destroy()}}};function Of(e){const{buffer:t,size:n,count:r}=function(e){let t=e,n=1,r=0;e&&e.value&&(t=e.value,n=e.size||1);t&&(ArrayBuffer.isView(t)||(t=function(e,t,n=!1){return e?Array.isArray(e)?new t(e):!n||e instanceof t?e:new t(e):null}(t,Float32Array)),r=t.length/n);return{buffer:t,size:n,count:r}}(e);return{value:t,size:n,byteOffset:0,count:r,type:wc(n),componentType:Tc(t)}}var Ff=e.__exportAll({decode:()=>jf,encode:()=>zf,name:()=>Uf,preprocess:()=>Vf}),Df="KHR_draco_mesh_compression",Uf=Df;function Vf(e,t,n){const r=new Ec(e);for(const i of qf(r))r.getObjectExtension(i,Df)}async function jf(e,t,n){if(!t?.gltf?.decompressMeshes)return;const r=new Ec(e),i=[];for(const a of qf(r))r.getObjectExtension(a,Df)&&i.push(Gf(r,a,t,n));await Promise.all(i),r.removeExtension(Df)}function zf(e,t={}){const n=new Ec(e);for(const r of n.json.meshes||[])Hf(r,t),n.addRequiredExtension(Df)}async function Gf(e,t,r,i){const a=e.getObjectExtension(t,Df);if(!a)return;const o=e.getTypedArrayForBufferView(a.bufferView),A=n.sliceArrayBuffer(o.buffer,o.byteOffset),l={...r};delete l["3d-tiles"];const c=await s(A,Bf,l,i),u=function(e){const t={};for(const n in e){const r=e[n];"indices"!==n&&(t[n]=Of(r))}return t}(c.attributes);for(const[n,s]of Object.entries(u))if(n in t.attributes){const r=t.attributes[n],i=e.getAccessor(r);i?.min&&i?.max&&(s.min=i.min,s.max=i.max)}t.attributes=u,c.indices&&(t.indices=Of(c.indices)),e.removeObjectExtension(t,Df),function(e){if(!e.attributes&&Object.keys(e.attributes).length>0)throw new Error("glTF: Empty primitive detected: Draco decompression failure?")}(t)}function Hf(e,t,n=4,r,i){if(!r.DracoWriter)throw new Error("options.gltf.DracoWriter not provided");const a=r.DracoWriter.encodeSync({attributes:e}),o=i?.parseSync?.({attributes:e}),s=r._addFauxAttributes(o.attributes),A=r.addBufferView(a);return{primitives:[{attributes:s,mode:n,extensions:{[Df]:{bufferView:A,attributes:s}}}]}}function*qf(e){for(const t of e.json.meshes||[])for(const e of t.primitives)yield e}var Qf=e.__exportAll({decode:()=>Xf,name:()=>Wf}),Kf="KHR_texture_transform",Wf=Kf,$f=new n.Vector3,Jf=new L,Yf=new L;async function Xf(e,t){const n=new Ec(e);if(!n.hasExtension(Kf)||!t.gltf?.loadBuffers)return;const r=e.json.materials||[];for(let i=0;i<r.length;i++)Zf(i,e,n);r.some(e=>ed(e).length>0)||n.removeExtension(Kf)}function Zf(e,t,n){const r=t.json.materials?.[e],i=ed(r),a=new Map;let o=function(e){let t=-1;for(const n of e.json.meshes||[])for(const e of n.primitives)for(const n of Object.keys(e.attributes)){const e=/^TEXCOORD_(\d+)$/.exec(n);e&&(t=Math.max(t,Number(e[1])))}return t+1}(t);for(const s of i){const r=s.extensions?.[Kf];if(r){const i=r.texCoord??s.texCoord??0,A=td(i,r);let l=a.get(A);if(!l){if(l={sourceTexCoord:i,texCoord:o,matrix:id(r)},!nd(t,e,l))continue;o++,a.set(A,l)}s.texCoord=l.texCoord,n.removeObjectExtension(s,Kf),s.extensions&&0===Object.keys(s.extensions).length&&delete s.extensions}}}function ed(e){if(!e||"object"!=typeof e)return[];const t=e,n=[],r=t.extensions;Number.isFinite(t.index)&&r?.[Kf]&&n.push(t);for(const[i,a]of Object.entries(t))"extras"!==i&&n.push(...ed(a));return n}function td(e,t){const{offset:n=[0,0],rotation:r=0,scale:i=[1,1]}=t;return JSON.stringify([e,n,r,i])}function nd(e,t,n){const r=[],i=e.json.meshes||[];for(const a of i)for(const e of a.primitives){const n=e.material;Number.isFinite(n)&&t===n&&r.push(e)}if(0===r.length||r.some(t=>!function(e,t,n){const r=t.attributes[`TEXCOORD_${n}`];if(!Number.isFinite(r))return!1;const i=e.json.accessors?.[r];if(!i||void 0===i.bufferView||i.sparse)return!1;const a=e.json.bufferViews?.[i.bufferView];return Boolean(a&&e.buffers[a.buffer])}(e,t,n.sourceTexCoord)))return!1;for(const a of r)rd(e,a,n);return!0}function rd(e,t,r){const{sourceTexCoord:i,texCoord:a,matrix:o}=r,s=t.attributes[`TEXCOORD_${i}`];if(Number.isFinite(s)){const r=e.json.accessors?.[s];if(r&&void 0!==r.bufferView){const i=e.json.bufferViews?.[r.bufferView];if(i){const{arrayBuffer:s,byteOffset:A}=e.buffers[i.buffer],l=(A||0)+(r.byteOffset||0)+(i.byteOffset||0),{ArrayType:c,length:u}=Sc(r,i),f=gc[r.componentType],d=mc[r.type],h=i.byteStride||f*d,p=new Float32Array(u);for(let e=0;e<r.count;e++){const t=new c(s,l+e*h,2);$f.set(t[0],t[1],1),$f.transformByMatrix3(o),p.set([$f[0],$f[1]],e*d)}!function(e,t,r,i,a){i.buffers.push({arrayBuffer:n.ensureArrayBuffer(a.buffer),byteOffset:0,byteLength:a.buffer.byteLength}),i.json.bufferViews=i.json.bufferViews||[];const o=i.json.bufferViews;o.push({buffer:i.buffers.length-1,byteLength:a.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"}),r.attributes[`TEXCOORD_${e}`]=s.length-1}(a,r,t,e,p)}}}}function id(e){const{offset:t=[0,0],rotation:n=0,scale:r=[1,1]}=e,i=(new L).set(1,0,0,0,1,0,t[0],t[1],1),a=Jf.set(Math.cos(n),Math.sin(n),0,-Math.sin(n),Math.cos(n),0,0,0,1),o=Yf.set(r[0],0,0,0,r[1],0,0,0,1);return i.multiplyRight(a).multiplyRight(o)}var ad=e.__exportAll({decode:()=>Ad,encode:()=>ld,name:()=>sd}),od="KHR_lights_punctual",sd=od;async function Ad(e){const t=new Ec(e),{json:n}=t,r=t.getExtension(od);r&&(t.json.lights=r.lights,t.removeExtension(od));for(const i of n.nodes||[]){const e=t.getObjectExtension(i,od);e&&(i.light=e.light),t.removeObjectExtension(i,od)}}async function ld(e){const t=new Ec(e),{json:n}=t;if(n.lights){const e=t.addExtension(od);pc(!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,od,e)}delete t.json.lights}}var cd=e.__exportAll({decode:()=>dd,encode:()=>hd,name:()=>fd}),ud="KHR_materials_unlit",fd=ud;async function dd(e){const t=new Ec(e),{json:n}=t;for(const r of n.materials||[])r.extensions&&r.extensions.KHR_materials_unlit&&(r.unlit=!0),t.removeObjectExtension(r,ud);t.removeExtension(ud)}function hd(e){const t=new Ec(e),{json:n}=t;if(t.materials)for(const r of n.materials||[])r.unlit&&(delete r.unlit,t.addObjectExtension(r,ud,{}),t.addExtension(ud))}var pd=e.__exportAll({decode:()=>bd,encode:()=>vd,name:()=>gd}),md="KHR_techniques_webgl",gd=md;async function bd(e){const t=new Ec(e),{json:n}=t,r=t.getExtension(md);if(r){const e=function(e,t){const{programs:n=[],shaders:r=[],techniques:i=[]}=e,a=new TextDecoder;return r.forEach(e=>{if(!Number.isFinite(e.bufferView))throw new Error("KHR_techniques_webgl: no shader code");e.code=a.decode(t.getTypedArrayForBufferView(e.bufferView))}),n.forEach(e=>{e.fragmentShader=r[e.fragmentShader],e.vertexShader=r[e.vertexShader]}),i.forEach(e=>{e.program=n[e.program]}),i}(r,t);for(const r of n.materials||[]){const n=t.getObjectExtension(r,md);n&&(r.technique=Object.assign({},n,e[n.technique]),r.technique.values=yd(r.technique,t)),t.removeObjectExtension(r,md)}t.removeExtension(md)}}async function vd(e,t){}function yd(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}var xd=[$c,jc,of,nf,df,lf,gf,Ff,ad,cd,pd,Qf,du];function _d(e,t){const n=t?.gltf?.excludeExtensions||{};return!(e in n&&!n[e])}var wd="KHR_binary_glTF";var Td={accessors:"accessor",animations:"animation",buffers:"buffer",bufferViews:"bufferView",images:"image",materials:"material",meshes:"mesh",nodes:"node",samplers:"sampler",scenes:"scene",skins:"skin",textures:"texture"},Sd={accessor:"accessors",animations:"animation",buffer:"buffers",bufferView:"bufferViews",image:"images",material:"materials",mesh:"meshes",node:"nodes",sampler:"samplers",scene:"scenes",skin:"skins",texture:"textures"},Md=class{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 void console.warn(`glTF: Unknown version ${n.asset.version}`)}if(!t.normalize)throw new Error("glTF v1 is not supported.");console.warn("Converting glTF v1 to glTF v2 format. This is experimental and may fail."),this._addAsset(n),this._convertTopLevelObjectsToArrays(n),function(e){const t=new Ec(e),{json:n}=t;for(const r of n.images||[]){const e=t.getObjectExtension(r,wd);e&&Object.assign(r,e),t.removeObjectExtension(r,wd)}n.buffers&&n.buffers[0]&&delete n.buffers[0].uri,t.removeExtension(wd)}(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 Td)this._convertTopLevelObjectToArray(e,t)}_convertTopLevelObjectToArray(e,t){const n=e[t];if(n&&!Array.isArray(n)){e[t]=[];for(const r in n){const i=n[r];i.id=i.id||r;const a=e[t].length;e[t].push(i),this.idToIndexMap[t][r]=a}}}_convertObjectIdsToArrayIndices(e){for(const t in Td)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:r}=t;for(const t in e)e[t]=this._convertIdToIndex(e[t],"accessor");n&&(t.indices=this._convertIdToIndex(n,"accessor")),r&&(t.material=this._convertIdToIndex(r,"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]||(console.warn(`gltf v1: json doesn't contain attribute ${t}`),e[t]=[]);for(const n of e[t])for(const e in n){const t=n[e];n[e]=this._convertIdToIndex(t,e)}}_convertIdToIndex(e,t){const n=Sd[t];if(n in this.idToIndexMap){const r=this.idToIndexMap[n][e];if(!Number.isFinite(r))throw new Error(`gltf v1: failed to resolve ${t} with id ${e}`);return r}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,r=e.textures.findIndex(e=>e.id===n);-1!==r&&(t.pbrMetallicRoughness.baseColorTexture={index:r})}}};async function Ed(e,t,n=0,r,i){return function(e,t,n,r){r.core?.baseUrl&&(e.baseUri=r.core?.baseUrl);t instanceof ArrayBuffer&&!function(e,t=0,n={}){const r=new DataView(e),{magic:i=Wu}=n,a=r.getUint32(t,!1);return a===i||a===Wu}(t,n,r.glb)&&(t=(new TextDecoder).decode(t));if("string"==typeof t)e.json=d(t);else if(t instanceof ArrayBuffer){const i={};n=Yu(i,t,n,r.glb),pc("glTF"===i.type,`Invalid GLB magic string ${i.type}`),e._glb=i,e.json=i.json}else pc(!1,"GLTF: must be ArrayBuffer or string");const i=e.json.buffers||[];if(e.buffers=new Array(i.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 a=e.json.images||[];e.images=new Array(a.length).fill({})}(e,t,n,r),function(e,t={}){(new Md).normalize(e,t)}(e,{normalize:r?.gltf?.normalize}),await async function(e,t={},n){const r=xd.filter(e=>_d(e.name,t));for(const i of r)await(i.preprocess?.(e,t,n))}(e,r,i),r?.gltf?.loadBuffers&&e.json.buffers&&await async function(e,t,n){const r=e.json.buffers||[];for(let i=0;i<r.length;++i){const a=r[i];if(a.uri){const{fetch:r}=n;pc(r);const o=ef(a.uri,t,n),s=await((await(n?.fetch?.(o)))?.arrayBuffer?.());e.buffers[i]={arrayBuffer:s,byteOffset:0,byteLength:s.byteLength},delete a.uri}else null===e.buffers[i]&&(e.buffers[i]={arrayBuffer:new ArrayBuffer(a.byteLength),byteOffset:0,byteLength:a.byteLength})}}(e,r,i),r?.gltf?.loadImages&&await async function(e,t,n){const r=function(e){const t=new Set,n=e.json.textures||[];for(const r of n)void 0!==r.source&&t.add(r.source);return Array.from(t).sort()}(e),i=e.json.images||[],a=[];for(const o of r)a.push(Cd(e,i[o],o,t,n));return await Promise.all(a)}(e,r,i),await async function(e,t={},n){const r=xd.filter(e=>_d(e.name,t));for(const i of r)await(i.decode?.(e,t,n))}(e,r,i),e}async function Cd(e,t,i,a,o){let A;if(t.uri&&!t.hasOwnProperty("bufferView")){const e=ef(t.uri,a,o),{fetch:n}=o;A=await(await n(e)).arrayBuffer(),t.bufferView={data:A}}if(Number.isFinite(t.bufferView)){const r=function(e,t,n){const r=e.bufferViews[n];pc(r);const i=t[r.buffer];pc(i);const a=(r.byteOffset||0)+i.byteOffset;return new Uint8Array(i.arrayBuffer,a,r.byteLength)}(e.json,e.buffers,t.bufferView);A=n.sliceArrayBuffer(r.buffer,r.byteOffset,r.byteLength)}pc(A,"glTF image has no data");const l=function(e,t){const n=e.basis,r=n?.format;return{...e,core:{...e.core,mimeType:t},basis:{...n,format:r&&"auto"!==r?r:Hu(n?.supportedTextureFormats)}}}(a,t.mimeType);let c=await s(A,[r.ImageLoader,Qu],l,o);c&&c[0]&&(c={compressed:!0,mipmaps:!1,width:c[0].width,height:c[0].height,data:c[0]}),e.images=e.images||[],e.images[i]=c}var Id={dataType:null,batchType:null,name:"glTF",id:"gltf",module:"gltf",version:"4.5.4",extensions:["gltf","glb"],mimeTypes:["model/gltf+json","model/gltf-binary"],text:!0,binary:!0,tests:["glTF"],parse:async function(e,t={},n){const r={...Id.options,...t};r.gltf={...Id.options.gltf,...r.gltf};const i=t?.glb?.byteOffset||0;return await Ed({},e,i,r,n)},options:{gltf:{normalize:!0,loadBuffers:!0,loadImages:!0,decompressMeshes:!0}}};var Rd={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Pd={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},Nd=10240,kd=10241,Ld=10242,Bd=10243,Od=10497,Fd=9729,Dd=9986,Ud={magFilter:Nd,minFilter:kd,wrapS:Ld,wrapT:Bd},Vd={[Nd]:Fd,[kd]:Dd,[Ld]:Od,[Bd]:Od};var jd=class{baseUri="";jsonUnprocessed;json;buffers=[];images=[];postProcess(e,t={}){const{json:n,buffers:r=[],images:i=[]}=e,{baseUri:a=""}=e;return pc(n),this.baseUri=a,this.buffers=r,this.images=i,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||console.warn(`glTF file error: Could not find ${e}[${t}]`),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,t)=>{const r={...e,attributes:{},indices:void 0,material:void 0},i=e.attributes;for(const n in i)r.attributes[n]=this.getAccessor(i[n]);return void 0!==e.indices&&(r.indices=this.getAccessor(e.indices)),void 0!==e.material&&(r.material=this.getMaterial(e.material)),function(e,t,n){if(2!==e.mode&&6!==e.mode)return e;const r=e.indices?.value,i=e.indices?.count??function(e){const t=Object.values(e.attributes)[0];return pc(t,"glTF primitive must define at least one attribute"),t.count}(e),a=function(e,t){if(!e)return Math.max(0,t-1);let n=0;for(let r=0;r<t;r++)n=Math.max(n,Number(e[r]));return n}(r,i),o=a<=65535?Uint16Array:Uint32Array,s=2===e.mode?function(e,t,n){if(t<2)return new n(0);const r=new n(2*t);for(let i=0;i<t;i++)r[2*i]=Gd(e,i),r[2*i+1]=Gd(e,(i+1)%t);return r}(r,i,o):function(e,t,n){const r=Math.max(0,t-2),i=new n(3*r);for(let a=0;a<r;a++)i[3*a]=Gd(e,0),i[3*a+1]=Gd(e,a+1),i[3*a+2]=Gd(e,a+2);return i}(r,i,o);return e.mode=2===e.mode?1:4,e.indices={id:`${t}-primitive-${n}-portable-indices`,components:1,bytesPerComponent:o.BYTES_PER_ELEMENT,bytesPerElement:o.BYTES_PER_ELEMENT,componentType:o===Uint16Array?5123:5125,normalized:!1,count:s.length,type:"SCALAR",min:s.length?[zd(s)]:void 0,max:s.length?[a]:void 0,value:s},e}(r,n.id,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 r=(i=e.componentType,Pd[i]);var i;const a=(o=e.type,Rd[o]);var o;const s=r*a,A={...e,id:e.id||`accessor-${t}`,bytesPerComponent:r,components:a,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:r}=Sc(A,A.bufferView),i=(A.bufferView.byteOffset||0)+(A.byteOffset||0)+e.byteOffset;let a=n.copyToArrayBuffer(e.arrayBuffer,i,r);A.bufferView.byteStride&&(a=this._getValueFromInterleavedBuffer(e,i,A.bufferView.byteStride,A.bytesPerElement,A.count)),A.value=new t(a)}else{const{ArrayType:e}=Sc(A,{byteLength:A.count*A.bytesPerElement});A.value=new e(A.count*A.components)}return e.sparse&&this._applySparseAccessor(A,e.sparse),A}_applySparseAccessor(e,t){const n=function(e){switch(e){case 5121:return Uint8Array;case 5123:return Uint16Array;case 5125:return Uint32Array;default:throw new Error(`Invalid glTF sparse index component type ${e}`)}}(t.indices.componentType),r=this._getTypedArrayFromBufferView(n,this.getBufferView(t.indices.bufferView),t.indices.byteOffset||0,t.count),i=e.value.constructor,a=this._getTypedArrayFromBufferView(i,this.getBufferView(t.values.bufferView),t.values.byteOffset||0,t.count*e.components);for(let o=0;o<t.count;o++){const t=Number(r[o]);pc(Number.isInteger(t)&&t>=0&&t<e.count,"glTF sparse accessor index is out of bounds");for(let n=0;n<e.components;n++){const r=t*e.components+n,i=o*e.components+n;Reflect.set(e.value,r,a[i])}}}_getTypedArrayFromBufferView(e,t,r,i){const a=i*e.BYTES_PER_ELEMENT;pc(r+a<=t.byteLength,"glTF sparse accessor data exceeds its buffer view");const o=t.buffer,s=o.byteOffset+(t.byteOffset||0)+r;return new e(n.copyToArrayBuffer(o.arrayBuffer,s,a))}_getValueFromInterleavedBuffer(e,t,n,r,i){const a=new Uint8Array(i*r);for(let o=0;o<i;o++){const i=t+o*n;a.set(new Uint8Array(e.arrayBuffer.slice(i,i+r)),o*r)}return a.buffer}_resolveTexture(e,t){return{...e,id:e.id||`texture-${t}`,sampler:"number"==typeof e.sampler?this.getSampler(e.sampler):{id:"default-sampler",parameters:Vd},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 r in n){const e=this._enumSamplerParameter(r);void 0!==e&&(n.parameters[e]=n[r])}return n}_enumSamplerParameter(e){return Ud[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},r=this.images[t];return r&&(n.image=r),n}_resolveBufferView(e,t){const n=e.buffer,r=this.buffers[n].arrayBuffer;let i=this.buffers[n].byteOffset||0;return e.byteOffset&&(i+=e.byteOffset),{id:`bufferView-${t}`,...e,buffer:this.buffers[n],data:new Uint8Array(r,i,e.byteLength)}}_resolveCamera(e,t){const n={...e,id:e.id||`camera-${t}`};return n.perspective,n.orthographic,n}};function zd(e){let t=1/0;for(const n of e)t=Math.min(t,n);return t}function Gd(e,t){return e?Number(e[t]):t}function Hd(e,t){return(new jd).postProcess(e,t)}async function qd(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))}var Qd="layout(std140) uniform scenegraphUniforms {\n float sizeScale;\n float sizeMinPixels;\n float sizeMaxPixels;\n mat4 sceneModelMatrix;\n float composeModelMatrix;\n} scenegraph;\n",Kd={name:"scenegraph",source:"struct ScenegraphUniforms {\n sizeScale: f32,\n sizeMinPixels: f32,\n sizeMaxPixels: f32,\n sceneModelMatrix: mat4x4<f32>,\n composeModelMatrix: f32,\n};\n\n@group(0) @binding(auto)\nvar<uniform> scenegraph: ScenegraphUniforms;\n",vs:Qd,fs:Qd,uniformTypes:{sizeScale:"f32",sizeMinPixels:"f32",sizeMaxPixels:"f32",sceneModelMatrix:"mat4x4<f32>",composeModelMatrix:"f32"}},Wd=G.source.replace(/fn pbr_setPositionNormalTangentUV\([\s\S]*?\n}\n/,"fn pbr_setPositionNormalTangentUV(position: vec4f, normal: vec4f, tangent: vec4f, uv: vec2f)\n{\n fragmentInputs.pbr_vPosition = position.xyz;\n fragmentInputs.pbr_vNormal = normal.xyz;\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 = uv;\n fragmentInputs.pbr_vUV1 = uv;\n}\n").replace(/pbrProjection\.camera/g,"project.cameraPosition"),$d={...G,dependencies:[t.lighting],source:Wd},Jd=[255,255,255,255],Yd={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:Jd},_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:[Id]},Xd=class extends t.Layer{getShaders(){const e={};let n;const r="webgpu"===this.context.device?.type;"pbr"===this.props._lighting?(n=r?$d:G,e.LIGHTING_PBR=1):n=r?$d:{name:"pbrMaterial"};const i=[t.project32_default,t.color_default,t.picking_default,Kd,n];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 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 = picking_getPickingColorFromInstanceID();\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);\nfloat sizeRatio = originalSize == 0.0 ? 0.0 : clampedSize / originalSize;\nvec3 pos = (instanceModelMatrix * (scenegraph.sceneModelMatrix * vec4(positions, 1.0)).xyz) * scenegraph.sizeScale * sizeRatio + instanceTranslation;\nif(scenegraph.composeModelMatrix > 0.5) {\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 = pbr_filterColor(vColor);\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",source:"struct VertexInputs {\n @location(0) positions: vec3<f32>,\n#ifdef HAS_NORMALS\n @location(1) normals: vec3<f32>,\n#endif\n#ifdef HAS_UV\n @location(3) texCoords: vec2<f32>,\n#endif\n @location(6) instancePositions: vec3<f32>,\n @location(7) instancePositions64Low: vec3<f32>,\n @location(8) instanceColors: vec4<f32>,\n @location(10) instanceModelMatrixCol0: vec3<f32>,\n @location(11) instanceModelMatrixCol1: vec3<f32>,\n @location(12) instanceModelMatrixCol2: vec3<f32>,\n @location(13) instanceTranslation: vec3<f32>,\n};\n\nstruct FragmentInputs {\n @builtin(position) position: vec4<f32>,\n @location(0) vColor: vec4<f32>,\n @location(1) vTexCoord: vec2<f32>,\n @location(2) pbrPosition: vec3<f32>,\n @location(3) pbrUV: vec2<f32>,\n @location(4) pbrNormal: vec3<f32>,\n @location(5) pickingColor: vec3<f32>,\n};\n\n@vertex\nfn vertexMain(\n inputs: VertexInputs,\n @builtin(instance_index) instanceIndex: u32\n) -> FragmentInputs {\n var outputs: FragmentInputs;\n\n geometry.worldPosition = inputs.instancePositions;\n geometry.pickingColor = picking_getPickingColorFromIndex(instanceIndex);\n\n var vertexPosition = inputs.positions;\n var texCoord = vec2<f32>(0.0, 0.0);\n var normal = vec3<f32>(0.0, 0.0, 1.0);\n\n#ifdef HAS_UV\n texCoord = inputs.texCoords;\n#endif\n#ifdef HAS_NORMALS\n normal = inputs.normals;\n#endif\n\n geometry.uv = texCoord;\n\n let instanceModelMatrix = mat3x3<f32>(\n inputs.instanceModelMatrixCol0,\n inputs.instanceModelMatrixCol1,\n inputs.instanceModelMatrixCol2\n );\n\n let scenePosition = (scenegraph.sceneModelMatrix * vec4<f32>(vertexPosition, 1.0)).xyz;\n let worldNormal = instanceModelMatrix * (scenegraph.sceneModelMatrix * vec4<f32>(normal, 0.0)).xyz;\n\n let originalSize = project_meter_size_to_pixel(scenegraph.sizeScale);\n let clampedSize = clamp(originalSize, scenegraph.sizeMinPixels, scenegraph.sizeMaxPixels);\n let sizeRatio = select(0.0, clampedSize / originalSize, originalSize > 0.0);\n\n let pos =\n (instanceModelMatrix * scenePosition) * scenegraph.sizeScale * sizeRatio +\n inputs.instanceTranslation;\n\n if (scenegraph.composeModelMatrix > 0.5) {\n geometry.normal = project_normal(worldNormal);\n geometry.worldPosition = inputs.instancePositions + pos;\n geometry.position = vec4<f32>(\n project_position_vec3_f64(inputs.instancePositions + pos, inputs.instancePositions64Low),\n 1.0\n );\n } else {\n let sizeAdjustedPos = project_size_vec3(pos);\n // Scenegraph offsets are east/north/up in globe mode. Use project32's helper so it can\n // rotate the offset onto the local tangent plane before producing the common position.\n let projectResult = project_position_to_clipspace_and_commonspace(\n inputs.instancePositions,\n inputs.instancePositions64Low,\n sizeAdjustedPos\n );\n geometry.position = projectResult.commonPosition;\n geometry.normal = project_normal(worldNormal);\n }\n\n outputs.position = project_common_position_to_clipspace(geometry.position);\n outputs.vColor = inputs.instanceColors;\n outputs.vTexCoord = texCoord;\n outputs.pbrPosition = geometry.position.xyz;\n outputs.pbrUV = texCoord;\n outputs.pbrNormal = geometry.normal;\n outputs.pickingColor = geometry.pickingColor;\n return outputs;\n}\n\n@fragment\nfn fragmentMain(inputs: FragmentInputs) -> @location(0) vec4<f32> {\n fragmentGeometry.uv = inputs.vTexCoord;\n\n if (picking.isActive > 0.5) {\n if (!picking_isColorValid(inputs.pickingColor)) {\n discard;\n }\n return vec4<f32>(inputs.pickingColor, 1.0);\n }\n\n var fragColor = inputs.vColor;\n\n#ifdef LIGHTING_PBR\n fragmentInputs.pbr_vPosition = inputs.pbrPosition;\n // scenegraphPbrMaterial uses the indexed UV fields from the current PBR module.\n fragmentInputs.pbr_vUV0 = inputs.pbrUV;\n fragmentInputs.pbr_vUV1 = vec2<f32>(0.0);\n fragmentInputs.pbr_vNormal = inputs.pbrNormal;\n // Vertex color is part of the material base color and must be applied before lighting.\n fragColor = pbr_filterColor(fragColor);\n#else\n#ifdef HAS_BASECOLORMAP\n fragColor =\n fragColor *\n textureSample(pbr_baseColorSampler, pbr_baseColorSamplerSampler, inputs.vTexCoord);\n#endif\n#endif\n\n fragColor.a *= layer.opacity;\n\n if (picking.isHighlightActive > 0.5) {\n let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);\n if (picking_isColorZero(abs(inputs.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 }\n }\n }\n\n return deckgl_premultiplied_alpha(fragColor);\n}\n",modules:i})}initializeState(){const e=this.getAttributeManager(),t="webgpu"!==this.context.device.type;e.addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),accessor:"getPosition",transition:t},instanceColors:{type:"unorm8",size:this.props.colorFormat.length,accessor:"getColor",defaultValue:Jd,transition:t},instanceModelMatrix:JA})}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 r=null;if(e.scenegraph instanceof Ie)r={scenes:[e.scenegraph]};else if(e.scenegraph&&"object"==typeof e.scenegraph){const n=e.scenegraph,i=fc(t,n.json?Hd(n):n,this._getModelOptions());r=i,qd(i).then(()=>this.setNeedsRedraw()).catch(e=>{this.raiseError(e,"loading glTF")})}const i={layer:this,device:this.context.device},a=e.getScene(r,i),o=e.getAnimator(r,i);if(a instanceof Ne){this._destroyScenegraphAssets(),this._applyAnimationsProp(o,e._animations);const t=[];a.traverse(e=>{e instanceof ke&&t.push(e.model)}),this.setState({scenegraph:a,animator:o,materials:r?.materials||null,models:t,firstDrawSignaled:!1}),this.getAttributeManager().invalidateAll()}else null!==a&&n.defaultLogger.warn("invalid scenegraph:",a)()}_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 r=e.getAnimations();Object.keys(t).sort().forEach(e=>{const i=t[e];if("*"===e)r.forEach(e=>{Object.assign(e,i)});else if(Number.isFinite(Number(e))){const t=Number(e);t>=0&&t<r.length?Object.assign(r[t],i):n.defaultLogger.warn(`animation ${e} not found`)()}else{const t=r.find(({animation:t})=>t.name===e);t?Object.assign(t,i):n.defaultLogger.warn(`animation ${e} not found`)()}})}_getModelOptions(){const{_imageBasedLightingEnvironment:e}=this.props;let t;e&&(t="function"==typeof e?e({device:this.context.device,gl:this.context.gl,layer:this}):e);const n="webgpu"===this.context.device.type?{depthWriteEnabled:!0,depthCompare:"less-equal"}:void 0;return{imageBasedLightingEnvironment:t,modelOptions:{id:this.props.id,isInstanced:!0,bufferLayout:this.getAttributeManager().getBufferLayouts(),parameters:n,...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:r,sizeMinPixels:i,sizeMaxPixels:a,coordinateSystem:o}=this.props,s={camera:t.cameraPosition},A=this.getNumInstances();this.state.scenegraph.traverse((e,{worldMatrix:l})=>{if(e instanceof ke){const{model:c}=e;c.setInstanceCount(A);const u={sizeScale:r,sizeMinPixels:i,sizeMaxPixels:a,composeModelMatrix:YA(t,o)?1:0,sceneModelMatrix:l};c.shaderInputs.setProps({pbrProjection:s,scenegraph:u}),c.draw(n)}}),this.state.firstDrawSignaled||(this.state.firstDrawSignaled=!0,this.props.onFirstDraw?.())}};Xd.defaultProps=Yd,Xd.layerName="ScenegraphLayer";var Zd="layout(std140) uniform meshUniforms {\n bool pickFeatureIds;\n} mesh;\n",eh={name:"mesh",vs:Zd,fs:Zd,source:"struct MeshUniforms {\n pickFeatureIds: f32,\n};\n\n@group(0) @binding(auto) var<uniform> mesh: MeshUniforms;\n",uniformTypes:{pickFeatureIds:"f32"}},th=G.source.replace(/fn pbr_setPositionNormalTangentUV\([\s\S]*?\n}\n/,"fn pbr_setPositionNormalTangentUV(position: vec4f, normal: vec4f, tangent: vec4f, uv: vec2f)\n{\n fragmentInputs.pbr_vPosition = position.xyz;\n fragmentInputs.pbr_vNormal = normal.xyz;\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 = uv;\n fragmentInputs.pbr_vUV1 = uv;\n}\n").replace(/pbrProjection\.camera/g,"project.cameraPosition"),nh={...G,source:th};var rh=class extends nl{getShaders(){const e=super.getShaders();return{...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 float rowIndexes;\nin vec4 instanceColors;\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 = picking_getPickingColorFromIndex(rowIndexes);\n} else {\ngeometry.pickingColor = picking_getPickingColorFromInstanceID();\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",source:"struct VertexInputs {\n @location(0) positions: vec3<f32>,\n#ifdef HAS_NORMALS\n @location(1) normals: vec3<f32>,\n#endif\n @location(2) colors: vec4<f32>,\n#ifdef HAS_UV\n @location(3) texCoords: vec2<f32>,\n#endif\n#ifdef HAS_UV_REGIONS\n @location(4) uvRegions: vec4<f32>,\n#endif\n#ifdef HAS_FEATURE_IDS\n @location(5) rowIndexes: u32,\n#endif\n @location(6) instanceColors: vec4<f32>,\n @location(7) instanceModelMatrixCol0: vec3<f32>,\n @location(8) instanceModelMatrixCol1: vec3<f32>,\n @location(9) instanceModelMatrixCol2: vec3<f32>,\n};\n\nstruct FragmentInputs {\n @builtin(position) position: vec4<f32>,\n @location(0) color: vec4<f32>,\n @location(1) texCoord: vec2<f32>,\n @location(2) pbrPosition: vec3<f32>,\n @location(3) pbrNormal: vec3<f32>,\n @location(4) pickingColor: vec3<f32>,\n};\n\nfn applyUVRegion(uv: vec2<f32>, uvRegion: vec4<f32>) -> vec2<f32> {\n#ifdef HAS_UV_REGIONS\n // https://github.com/Esri/i3s-spec/blob/master/docs/1.7/geometryUVRegion.cmn.md\n return fract(uv) * (uvRegion.zw - uvRegion.xy) + uvRegion.xy;\n#else\n return uv;\n#endif\n}\n\n@vertex\nfn vertexMain(\n inputs: VertexInputs,\n @builtin(instance_index) instanceIndex: u32\n) -> FragmentInputs {\n var outputs: FragmentInputs;\n var texCoord = vec2<f32>(0.0);\n var normal = vec3<f32>(0.0, 0.0, 1.0);\n var uvRegion = vec4<f32>(0.0);\n\n#ifdef HAS_UV\n texCoord = inputs.texCoords;\n#endif\n#ifdef HAS_NORMALS\n normal = inputs.normals;\n#endif\n#ifdef HAS_UV_REGIONS\n uvRegion = inputs.uvRegions;\n#endif\n\n texCoord = applyUVRegion(texCoord, uvRegion);\n geometry.uv = texCoord;\n#ifdef HAS_FEATURE_IDS\n geometry.pickingColor = picking_getPickingColorFromIndex(inputs.rowIndexes);\n#else\n geometry.pickingColor = picking_getPickingColorFromIndex(instanceIndex);\n#endif\n\n let instanceModelMatrix = mat3x3<f32>(\n inputs.instanceModelMatrixCol0,\n inputs.instanceModelMatrixCol1,\n inputs.instanceModelMatrixCol2\n );\n let commonPosition = vec4<f32>(project_position_vec3_f32(inputs.positions), 1.0);\n\n geometry.position = commonPosition;\n geometry.normal = project_normal(instanceModelMatrix * normal);\n\n outputs.position = project_common_position_to_clipspace(commonPosition);\n outputs.color = vec4<f32>(\n inputs.colors.rgb * inputs.instanceColors.rgb,\n inputs.instanceColors.a\n );\n outputs.texCoord = texCoord;\n outputs.pbrPosition = commonPosition.xyz;\n outputs.pbrNormal = geometry.normal;\n outputs.pickingColor = geometry.pickingColor;\n return outputs;\n}\n\n@fragment\nfn fragmentMain(inputs: FragmentInputs) -> @location(0) vec4<f32> {\n fragmentGeometry.uv = inputs.texCoord;\n\n if (picking.isActive > 0.5) {\n if (!picking_isColorValid(inputs.pickingColor)) {\n discard;\n }\n return vec4<f32>(inputs.pickingColor, 1.0);\n }\n\n fragmentInputs.pbr_vPosition = inputs.pbrPosition;\n fragmentInputs.pbr_vUV0 = inputs.texCoord;\n fragmentInputs.pbr_vUV1 = vec2<f32>(0.0);\n fragmentInputs.pbr_vNormal = inputs.pbrNormal;\n\n var color = inputs.color * pbr_filterColor(vec4<f32>(0.0));\n color.a *= layer.opacity;\n\n if (picking.isHighlightActive > 0.5) {\n let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);\n if (picking_isColorZero(abs(inputs.pickingColor - highlightedObjectColor))) {\n let highlightAlpha = picking.highlightColor.a;\n let blendedAlpha = highlightAlpha + color.a * (1.0 - highlightAlpha);\n if (blendedAlpha > 0.0) {\n color = vec4<f32>(\n mix(color.rgb, picking.highlightColor.rgb, highlightAlpha / blendedAlpha),\n blendedAlpha\n );\n }\n }\n }\n\n return deckgl_premultiplied_alpha(color);\n}\n",modules:[...e.modules,nh,eh]}}initializeState(){const{featureIds:e}=this.props;super.initializeState();const t=this.getAttributeManager();e&&t.add({rowIndexes:{type:"uint32",size:1,noAlloc:!0,update:this.calculateFeatureIdsPickingIndexes}})}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 r={pickFeatureIds:Boolean(t)},i={camera:this.context.viewport.cameraPosition};n.shaderInputs.setProps({pbrProjection:i,mesh:r}),super.draw(e)}getModel(e){const{id:n}=this.props,r=this.parseMaterial(this.props.pbrMaterial,e);this.setState({parsedPBRMaterial:r});const i=this.getShaders();return 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),new t.Model(this.context.device,{...this.getShaders(),id:n,geometry:e,bufferLayout:this.getAttributeManager().getBufferLayouts(),defines:{...i.defines,...r?.defines,HAS_UV_REGIONS:e.attributes.uvRegions?1:0,HAS_FEATURE_IDS:this.props.featureIds?1:0},parameters:r?.parameters,isInstanced:!0})}updatePbrMaterialUniforms(e){const{model:t}=this.state;if(t){const{mesh:n}=this.props,r=this.parseMaterial(e,n);this.setState({parsedPBRMaterial:r});const{pbr_baseColorSampler:i}=r.bindings,{emptyTexture:a}=this.state,o=i||a,s={..."webgpu"===this.context.device.type?{simpleMeshTexture:o}:{sampler:o},hasTexture:Boolean(i)},{camera:A,...l}={...r.bindings,...r.uniforms};t.shaderInputs.setProps({simpleMesh:s,pbrMaterial:l})}}parseMaterial(e,t){const n=Boolean(e.pbrMetallicRoughness&&e.pbrMetallicRoughness.baseColorTexture);return wl(this.context.device,{unlit:n,...e},{NORMAL:t.attributes.normals,TEXCOORD_0:t.attributes.texCoords},{pbrDebug:!1,lights:!0,useTangents:!1})}calculateFeatureIdsPickingIndexes(e){const t=this.props.featureIds;e.value=new Uint32Array(t)}finalizeState(e){super.finalizeState(e),this.state.parsedPBRMaterial?.generatedTextures.forEach(e=>e.destroy()),this.setState({parsedPBRMaterial:null})}};rh.layerName="MeshLayer",rh.defaultProps={pbrMaterial:{type:"object",value:null},featureIds:{type:"array",value:null,optional:!0}};var ih=6378137,ah=6378137,oh=6356752.314245179;Math.max(ih,ah,oh);function sh(e){return e}new n.Vector3;function Ah(e,t=[]){return function(e,t=[],n=sh){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,n.config._cartographicRadians?sh:n.toRadians)}function lh(e,t){return function(e,t,n=sh){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,n.config._cartographicRadians?sh:n.toDegrees)}var ch=new n.Vector3,uh={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"}},fh={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},dh={east:new n.Vector3,north:new n.Vector3,up:new n.Vector3,west:new n.Vector3,south:new n.Vector3,down:new n.Vector3},hh=new n.Vector3,ph=new n.Vector3,mh=new n.Vector3;function gh(e,t,r,i,a,o){const s=uh[t]&&uh[t][r];let A,l,c;n.assert$1(s&&(!i||i===s));const u=ch.copy(a);if(n.equals(u.x,0,1e-14)&&n.equals(u.y,0,1e-14)){const e=Math.sign(u.z);A=hh.fromArray(fh[t]),"east"!==t&&"west"!==t&&A.scale(e),l=ph.fromArray(fh[r]),"east"!==r&&"west"!==r&&l.scale(e),c=mh.fromArray(fh[i]),"east"!==i&&"west"!==i&&c.scale(e)}else{const{up:n,east:a,north:o}=dh;a.set(-u.y,u.x,0).normalize(),e.geodeticSurfaceNormal(u,n),o.copy(n).cross(a);const{down:s,west:f,south:d}=dh;s.copy(n).scale(-1),f.copy(a).scale(-1),d.copy(o).scale(-1),A=dh[t],l=dh[r],c=dh[i]}return o[0]=A.x,o[1]=A.y,o[2]=A.z,o[3]=0,o[4]=l.x,o[5]=l.y,o[6]=l.z,o[7]=0,o[8]=c.x,o[9]=c.y,o[10]=c.z,o[11]=0,o[12]=u.x,o[13]=u.y,o[14]=u.z,o[15]=1,o}var bh=new n.Vector3,vh=new n.Vector3,yh=new n.Vector3;var xh=new n.Vector3,_h=new n.Vector3,wh=new n.Vector3,Th=new n.Vector3,Sh=new n.Vector3,Mh=new n.Vector3,Eh=class{constructor(e=0,t=0,r=0){this.centerToleranceSquared=.1,n.assert$1(e>=0),n.assert$1(t>=0),n.assert$1(r>=0),this.radii=new n.Vector3(e,t,r),this.radiiSquared=new n.Vector3(e*e,t*t,r*r),this.radiiToTheFourth=new n.Vector3(e*e*e*e,t*t*t*t,r*r*r*r),this.oneOverRadii=new n.Vector3(0===e?0:1/e,0===t?0:1/t,0===r?0:1/r),this.oneOverRadiiSquared=new n.Vector3(0===e?0:1/(e*e),0===t?0:1/(t*t),0===r?0:1/(r*r)),this.minimumRadius=Math.min(e,t,r),this.maximumRadius=Math.max(e,t,r),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=_h,r=wh,[,,i]=e;this.geodeticSurfaceNormalCartographic(e,n),r.copy(this.radiiSquared).scale(n);const a=Math.sqrt(n.dot(r));return r.scale(1/a),n.scale(i),r.add(n),r.to(t)}cartesianToCartographic(e,t=[0,0,0]){Mh.from(e);const r=this.scaleToGeodeticSurface(Mh,Th);if(!r)return;const i=this.geodeticSurfaceNormal(r,_h),a=Sh;a.copy(Mh).subtract(r);return lh([Math.atan2(i.y,i.x),Math.asin(i.z),Math.sign(n.dot$1(a,Mh))*n.length$1(a)],t)}eastNorthUpToFixedFrame(e,t=new n.Matrix4){return gh(this,"east","north","up",e,t)}localFrameToFixedFrame(e,t,r,i,a=new n.Matrix4){return gh(this,e,t,r,i,a)}geocentricSurfaceNormal(e,t=[0,0,0]){return xh.from(e).normalize().to(t)}geodeticSurfaceNormalCartographic(e,t=[0,0,0]){const n=Ah(e),r=n[0],i=n[1],a=Math.cos(i);return xh.set(a*Math.cos(r),a*Math.sin(r),Math.sin(i)).normalize(),xh.to(t)}geodeticSurfaceNormal(e,t=[0,0,0]){return xh.from(e).scale(this.oneOverRadiiSquared).normalize().to(t)}scaleToGeodeticSurface(e,t){return function(e,t,n=[]){const{oneOverRadii:r,oneOverRadiiSquared:i,centerToleranceSquared:a}=t;bh.from(e);const o=bh.x,s=bh.y,A=bh.z,l=r.x,c=r.y,u=r.z,f=o*o*l*l,d=s*s*c*c,h=A*A*u*u,p=f+d+h,m=Math.sqrt(1/p);if(!Number.isFinite(m))return;const g=vh;if(g.copy(e).scale(m),p<a)return g.to(n);const b=i.x,v=i.y,y=i.z,x=yh;x.set(g.x*b*2,g.y*v*2,g.z*y*2);let _,w,T,S,M=(1-m)*bh.len()/(.5*x.len()),E=0;do{M-=E,_=1/(1+M*b),w=1/(1+M*v),T=1/(1+M*y);const e=_*_,t=w*w,n=T*T;S=f*e+d*t+h*n-1,E=S/(-2*(f*(e*_)*b+d*(t*w)*v+h*(n*T)*y))}while(Math.abs(S)>1e-12);return bh.scale([_,w,T]).to(n)}(e,this,t)}scaleToGeocentricSurface(e,t=[0,0,0]){Th.from(e);const n=Th.x,r=Th.y,i=Th.z,a=this.oneOverRadiiSquared,o=1/Math.sqrt(n*n*a.x+r*r*a.y+i*i*a.z);return Th.multiplyScalar(o).to(t)}transformPositionToScaledSpace(e,t=[0,0,0]){return Th.from(e).scale(this.oneOverRadii).to(t)}transformPositionFromScaledSpace(e,t=[0,0,0]){return Th.from(e).scale(this.radii).to(t)}getSurfaceNormalIntersectionWithZAxis(e,t=0,r=[0,0,0]){n.assert$1(n.equals(this.radii.x,this.radii.y,1e-15)),n.assert$1(this.radii.z>0),Th.from(e);const i=Th.z*(1-this.squaredXOverSquaredZ);if(!(Math.abs(i)>=this.radii.z-t))return Th.set(0,0,i).to(r)}};Eh.WGS84=new Eh(ih,ah,oh);var Ch=class{item;previous;next;constructor(e,t,n){this.item=e,this.previous=t,this.next=n}},Ih=class{head=null;tail=null;_length=0;get length(){return this._length}add(e){const t=new Ch(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}},Rh=class{_list;_sentinel;_trimTiles;constructor(){this._list=new Ih,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 r=t._cacheNode;r&&(this._list.remove(r),t._cacheNode=null,n&&n(e,t))}unloadTiles(e,t){const n=this._trimTiles;this._trimTiles=!1;const r=this._list,i=1024*e.maximumMemoryUsage*1024,a=this._sentinel;let o=r.head;for(;o!==a&&(e.gpuMemoryUsageInBytes>i||n);){const n=o.item;o=o.next,this.unloadTile(e,n,t)}}trim(){this._trimTiles=!0}};function Ph(e,t){n.assert$3(e),n.assert$3(t);const{rtcCenter:r,gltfUpAxis:i}=t,{computedTransform:a,boundingVolume:{center:o}}=e;let s=new n.Matrix4(a);switch(r&&s.translate(r),i){case"Z":break;case"Y":const e=(new n.Matrix4).rotateX(Math.PI/2);s=s.multiplyRight(e);break;case"X":const t=(new n.Matrix4).rotateY(-Math.PI/2);s=s.multiplyRight(t)}t.isQuantized&&s.translate(t.quantizedVolumeOffset).scale(t.quantizedVolumeScale);const A=new n.Vector3(o);t.cartesianModelMatrix=s,t.cartesianOrigin=A;const l=Eh.WGS84.cartesianToCartographic(A,new n.Vector3);t.cartographicModelMatrix=Eh.WGS84.eastNorthUpToFixedFrame(A).invert().multiplyRight(s),t.cartographicOrigin=l;const c=function(e){const t=e.gltf;if(!t)return null;const n="number"==typeof t.scene?t.scene:0,r=(t.scenes?.[n])?.nodes?.[0];if(!r?.matrix)return null;const i=r.matrix;return i[12]*i[12]+i[13]*i[13]+i[14]*i[14]<=Nh?null:r}(t);c&&(t.cartesianModelMatrix=new n.Matrix4(s).multiplyRight(c.matrix),t.cartographicModelMatrix.multiplyRight(c.matrix),c.matrix=n.Matrix4.IDENTITY),t.coordinateSystem||(t.modelMatrix=t.cartographicModelMatrix)}var Nh=1e6**2;var kh=new n.Vector3,Lh=new n.Vector3,Bh=new js([new Fs,new Fs,new Fs,new Fs,new Fs,new Fs]);function Oh(e,t){const{cameraDirection:r,cameraUp:i,height:a}=e,{metersPerUnit:o}=e.distanceScales,s=Dh(e,e.center),A=Eh.WGS84.eastNorthUpToFixedFrame(s),l=e.unprojectPosition(e.cameraPosition),c=Eh.WGS84.cartographicToCartesian(l,new n.Vector3),u=new n.Vector3(A.transformAsVector(new n.Vector3(r).scale(o))).normalize(),f=new n.Vector3(A.transformAsVector(new n.Vector3(i).scale(o))).normalize();!function(e){const t=e.getFrustumPlanes(),n=Fh(t.near,e.cameraPosition),r=Dh(e,n),i=Dh(e,e.cameraPosition,Lh);let a=0;Bh.planes[a++].fromPointNormal(r,kh.copy(r).subtract(i));for(const o in t){if("near"===o)continue;const i=Dh(e,Fh(t[o],n,Lh),Lh);Bh.planes[a++].fromPointNormal(i,kh.copy(r).subtract(i))}}(e);const d=e.constructor,{longitude:h,latitude:p,width:m,bearing:g,zoom:b}=e;return{camera:{position:c,direction:u,up:f},viewport:e,topDownViewport:new d({longitude:h,latitude:p,height:a,width:m,bearing:g,zoom:b,pitch:0}),height:a,cullingVolume:Bh,frameNumber:t,sseDenominator:1.15}}function Fh(e,t,r=new n.Vector3){const i=e.normal.dot(t);return r.copy(e.normal).scale(e.distance-i).add(t),r}function Dh(e,t,r=new n.Vector3){const i=e.unprojectPosition(t);return Eh.WGS84.cartographicToCartesian(i,r)}var Uh=6356752.314245179,Vh=new n.Vector3;function jh(e,t){if(e instanceof Ls){const{halfAxes:n}=e,r=function(e){e.getColumn(0,Vh);const t=e.getColumn(1),n=e.getColumn(2);return Vh.add(t).add(n).len()}(n);return Math.log2(Uh/(r+t[2]))}if(e instanceof gs){const{radius:n}=e;return Math.log2(Uh/(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 zh(e,t,n){Eh.WGS84.cartographicToCartesian([e.xmax,e.ymax,e.zmax],Vh);const r=Math.sqrt(Math.pow(Vh[0]-n[0],2)+Math.pow(Vh[1]-n[1],2)+Math.pow(Vh[2]-n[2],2));return Math.log2(Uh/(r+t[2]))}var Gh,Hh,qh,Qh,Kh=0,Wh=1,$h=3,Jh=4,Yh=5;!function(e){e[e.ADD=1]="ADD",e[e.REPLACE=2]="REPLACE"}(Gh||(Gh={})),function(e){e.EMPTY="empty",e.SCENEGRAPH="scenegraph",e.POINTCLOUD="pointcloud",e.MESH="mesh"}(Hh||(Hh={})),function(e){e.I3S="I3S",e.TILES3D="TILES3D"}(qh||(qh={})),function(e){e.GEOMETRIC_ERROR="geometricError",e.MAX_SCREEN_THRESHOLD="maxScreenThreshold"}(Qh||(Qh={}));var Xh=1;function Zh(e){return null!=e}var ep=new n.Vector3,tp=new n.Vector3,np=new n.Vector3,rp=new n.Vector3,ip=new n.Vector3,ap=new n.Vector3,op=new n.Vector3,sp=new n.Vector3;function Ap(e,t,r){if(n.assert$3(e,"3D Tile: boundingVolume must be defined"),e.box)return cp(e.box,t,r);if(e.region)return function(e){const[t,r,i,a,o,s]=e,A=Eh.WGS84.cartographicToCartesian([n.degrees(t),n.degrees(a),o],np),l=Eh.WGS84.cartographicToCartesian([n.degrees(i),n.degrees(r),s],rp),c=(new n.Vector3).addVectors(A,l).multiplyByScalar(.5);return Eh.WGS84.cartesianToCartographic(c,ip),Eh.WGS84.cartographicToCartesian([n.degrees(i),ip[1],ip[2]],ap),Eh.WGS84.cartographicToCartesian([ip[0],n.degrees(a),ip[2]],op),Eh.WGS84.cartographicToCartesian([ip[0],ip[1],s],sp),cp([...c,...ap.subtract(c),...op.subtract(c),...sp.subtract(c)],new n.Matrix4)}(e.region);if(e.sphere)return function(e,t,r){const i=new n.Vector3(e[0],e[1],e[2]);t.transform(i,i);const a=t.getScale(tp),o=Math.max(Math.max(a[0],a[1]),a[2]),s=e[3]*o;if(Zh(r))return r.center=i,r.radius=s,r;return new gs(i,s)}(e.sphere,t,r);throw new Error("3D Tile: boundingVolume must contain a sphere, region, or box")}function lp(e,t){if(e.box)return function(e){const t=up(),{halfAxes:r}=e,i=new n.Vector3(r.getColumn(0)),a=new n.Vector3(r.getColumn(1)),o=new n.Vector3(r.getColumn(2));for(let n=0;n<2;n++){for(let n=0;n<2;n++){for(let n=0;n<2;n++)ep.copy(e.center),ep.add(i),ep.add(a),ep.add(o),fp(t,ep),o.negate();a.negate()}i.negate()}return t}(t);if(e.region){const[t,r,i,a,o,s]=e.region;return[[n.degrees(t),n.degrees(r),o],[n.degrees(i),n.degrees(a),s]]}if(e.sphere)return function(e){const t=up(),{center:r,radius:i}=e,a=Eh.WGS84.scaleToGeodeticSurface(r,ep);let o;o=a?Eh.WGS84.geodeticSurfaceNormal(a):new n.Vector3(0,0,1);let s=new n.Vector3(o[2],-o[1],0);s.len()>0?s.normalize():s=new n.Vector3(0,1,0);const A=s.clone().cross(o);for(const n of[s,A,o]){tp.copy(n).scale(i);for(let e=0;e<2;e++)ep.copy(r),ep.add(tp),fp(t,ep),tp.negate()}return t}(t);throw new Error("Unkown boundingVolume type")}function cp(e,t,i){const a=new n.Vector3(e[0],e[1],e[2]);t.transform(a,a);let o=[];if(10===e.length){const t=e.slice(3,6),i=new r.Quaternion;i.fromArray(e,6);const a=new n.Vector3([1,0,0]),s=new n.Vector3([0,1,0]),A=new n.Vector3([0,0,1]);a.transformByQuaternion(i),a.scale(t[0]),s.transformByQuaternion(i),s.scale(t[1]),A.transformByQuaternion(i),A.scale(t[2]),o=[...a.toArray(),...s.toArray(),...A.toArray()]}else o=[...e.slice(3,6),...e.slice(6,9),...e.slice(9,12)];const s=t.transformAsVector(o.slice(0,3)),A=t.transformAsVector(o.slice(3,6)),l=t.transformAsVector(o.slice(6,9)),c=new L([s[0],s[1],s[2],A[0],A[1],A[2],l[0],l[1],l[2]]);return Zh(i)?(i.center=a,i.halfAxes=c,i):new Ls(a,c)}function up(){return[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]]}function fp(e,t){Eh.WGS84.cartesianToCartographic(t,ep),e[0][0]=Math.min(e[0][0],ep[0]),e[0][1]=Math.min(e[0][1],ep[1]),e[0][2]=Math.min(e[0][2],ep[2]),e[1][0]=Math.max(e[1][0],ep[0]),e[1][1]=Math.max(e[1][1],ep[1]),e[1][2]=Math.max(e[1][2],ep[2])}new n.Vector3,new n.Vector3,new n.Matrix4,new n.Vector3,new n.Vector3,new n.Vector3;function dp(e,t){if(e.dynamicScreenSpaceError&&e.dynamicScreenSpaceErrorComputedDensity){const n=e.dynamicScreenSpaceErrorComputedDensity,r=e.dynamicScreenSpaceErrorFactor;return function(e,t){const n=e*t;return 1-Math.exp(-n*n)}(t,n)*r}return 0}var hp=new n.Vector3,pp=new n.Vector3,mp=new n.Vector3,gp=new n.Vector3,bp=new n.Vector3,vp=new n.Matrix4,yp=new n.Matrix4;function xp(e,t){const{topDownViewport:n}=t,r=e.header.mbs[1],i=e.header.mbs[0],a=e.header.mbs[2],o=e.header.mbs[3],s=[...e.boundingVolume.center],A=n.unprojectPosition(n.cameraPosition);Eh.WGS84.cartographicToCartesian(A,hp),pp.copy(hp).subtract(s).normalize(),Eh.WGS84.eastNorthUpToFixedFrame(s,vp),yp.copy(vp).invert(),mp.copy(hp).transform(yp);const l=Math.sqrt(mp[0]*mp[0]+mp[1]*mp[1]),c=l*l/mp[2];gp.copy([mp[0],mp[1],c]);const u=gp.transform(vp).subtract(s).normalize(),f=pp.cross(u).normalize().scale(o).add(s),d=Eh.WGS84.cartesianToCartographic(f),h=n.project([i,r,a]),p=n.project(d);return bp.copy(h).subtract(p).magnitude()}var _p=class{_map=new Map;_array;_length;constructor(e=0){this._array=new Array(e),this._length=e}get length(){return this._length}set length(e){this._length=e,e>this._array.length&&(this._array.length=e)}get values(){return this._array}get(e){return n.assert$3(e<this._array.length),this._array[e]}set(e,t){n.assert$3(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){n.assert$3(e>=0),e>this._array.length&&(this._array.length=e)}resize(e){n.assert$3(e>=0),this.length=e}trim(e){null==e&&(e=this.length),this._array.length=e}reset(){this._array=[],this._map=new Map,this._length=0}find(e){return this._map.has(e)}},wp={loadSiblings:!1,skipLevelOfDetail:!1,updateTransforms:!0,onTraversalEnd:()=>{},viewportTraversersMap:{},basePath:""},Tp=class{options;root=null;selectedTiles={};requestedTiles={};emptyTiles={};lastUpdate=(new Date).getTime();updateDebounceTime=1e3;_traversalStack=new _p;_emptyTraversalStack=new _p;_frameNumber=null;traversalFinished(e){return!0}constructor(e){this.options={...wp,...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 r=!1;this.canTraverse(e,t)&&(this.updateChildTiles(e,t),r=this.updateAndPushChildren(e,t,n,e.hasRenderContent?e._selectionDepth+1:e._selectionDepth));const i=e.parent,a=Boolean(!i||i._shouldRefine),o=!r;e.hasRenderContent?e.refine===Gh.ADD?(this.loadTile(e,t),this.selectTile(e,t)):e.refine===Gh.REPLACE&&(this.loadTile(e,t),o&&this.selectTile(e,t)):(this.emptyTiles[e.id]=e,this.loadTile(e,t),o&&this.selectTile(e,t)),this.touchTile(e,t),e._shouldRefine=r&&a}const r=(new Date).getTime();(this.traversalFinished(t)||r-this.lastUpdate>this.updateDebounceTime)&&(this.lastUpdate=r,this.options.onTraversalEnd(t))}updateChildTiles(e,t){const n=e.children;for(const r of n)this.updateTile(r,t)}updateAndPushChildren(e,t,n,r){const{loadSiblings:i,skipLevelOfDetail:a}=this.options,o=e.children;o.sort(this.compareDistanceToCamera.bind(this));const s=e.refine===Gh.REPLACE&&e.hasRenderContent&&!a;let A=!1,l=!0;for(const c of o)if(c._selectionDepth=r,c.isVisibleAndInRequestVolume?(n.find(c)&&n.delete(c),n.push(c),A=!0):(s||i)&&(this.loadTile(c,t),this.touchTile(c,t)),s){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 r=e._screenSpaceError;return n&&(r=e.getScreenSpaceError(t,!0)),r>e.tileset.memoryAdjustedScreenSpaceError}updateTileVisibility(e,t){const n=[];if(this.options.viewportTraversersMap)for(const r in this.options.viewportTraversersMap)this.options.viewportTraversersMap[r]===t.viewport.id&&n.push(r);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 r of e.children)r.updateVisibility(t),n=n||r.isVisibleAndInRequestVolume;return n}executeEmptyTraversal(e,t){let n=!0;const r=this._emptyTraversalStack;for(r.push(e);r.length>0;){const e=r.pop(),i=!e.hasRenderContent&&this.canTraverse(e,t),a=!e.hasRenderContent&&0===e.children.length;if(i||e.contentAvailable||a||(n=!1),this.updateTile(e,t),e.isVisibleAndInRequestVolume||(this.loadTile(e,t),this.touchTile(e,t)),i){const t=e.children;for(const e of t)r.push(e)}}return e.hasEmptyContent||n}},Sp=new n.Vector3;var Mp=class{tileset;header;id;url;parent;refine;type;contentUrl;lodMetricType="geometricError";lodMetricValue=0;boundingVolume=null;content=null;contentState=Kh;gpuMemoryUsageInBytes=0;children=[];depth=0;viewportIds=[];transform=new n.Matrix4;extensions=null;implicitTiling=null;userData={};computedTransform;hasEmptyContent=!1;hasTilesetContent=!1;traverser=new Tp({});_cacheNode=null;_frameNumber=null;_expireDate=null;_expiredContent=null;_boundingBox=void 0;_distanceToCamera=0;_screenSpaceError=0;_visibilityPlaneMask;_visible=void 0;_contentBoundingVolume;_viewerRequestVolume;_initialTransform=new n.Matrix4;_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,r=""){this.header=t,this.tileset=e,this.id=r||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===$h||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===Kh}get contentExpired(){return this.contentState===Jh}get contentFailed(){return this.contentState===Yh}get distanceToCamera(){return this._distanceToCamera}get screenSpaceError(){return this._screenSpaceError}get boundingBox(){return this._boundingBox||(this._boundingBox=lp(this.header.boundingVolume,this.boundingVolume)),this._boundingBox}getScreenSpaceError(e,t){switch(this.tileset.type){case qh.I3S:return xp(this,e);case qh.TILES3D:return function(e,t,n){const r=e.tileset,i=e.parent&&e.parent.lodMetricValue||e.lodMetricValue,a=n?i:e.lodMetricValue;if(0===a)return 0;const o=Math.max(e._distanceToCamera,1e-7),{height:s,sseDenominator:A}=t,{viewDistanceScale:l}=r.options;let c=a*s*(l||1)/(o*A);return c-=dp(r,o),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===Gh.ADD||t;if(n&&!this.isVisible&&void 0!==this._visible)return-1;if(this.tileset._frameNumber-this._touchedFrame>=1)return-1;if(this.contentState===Kh)return-1;const r=this.parent,i=!r||n&&0!==this._screenSpaceError&&!r.hasTilesetContent?this._screenSpaceError:r._screenSpaceError,a=e.root?e.root._screenSpaceError:0;return Math.max(a-i,0)}async loadContent(){if(this.hasEmptyContent)return!1;if(this.content)return!0;this.contentExpired&&(this._expireDate=null),this.contentState=Wh;const e=await this.tileset._requestScheduler.scheduleRequest(this.id,this._getPriority.bind(this));if(!e)return this.contentState=Kh,!1;try{const e=this.tileset.getTileUrl(this.contentUrl),t=this.tileset.loader,r=this.tileset.loadOptions[t.id]||{},i={...this.tileset.loadOptions,[t.id]:{...r,isTileset:"json"===this.type,...this._getLoaderSpecificOptions(t.id)}};return this.content=await n.load(e,t,i),this.tileset.options.contentLoader&&await this.tileset.options.contentLoader(this),this._isTileset()&&this.tileset._initializeTileHeaders(this.content,this),this.contentState=$h,this._onContentLoaded(),!0}catch(t){throw this.contentState=Yh,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=Kh,this.tileDrawn=!0,!0}updateVisibility(e,t){if(this._frameNumber===e.frameNumber)return;const n=this.parent,r=n?n._visibilityPlaneMask:js.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,r),this._visible=this._visibilityPlaneMask!==js.MASK_OUTSIDE,this._inRequestVolume=this.insideViewerRequestVolume(e),this._frameNumber=e.frameNumber,this.viewportIds=t}visibility(e,t){const{cullingVolume:n}=e,{boundingVolume:r}=this;return n.computeVisibilityWithPlaneMask(r,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 Sp.subVectors(t.center,e.position),e.direction.dot(Sp)}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=Jh,this._expiredContent=this.content)}}get extras(){return this.header.extras}_initializeLodMetric(e){"lodMetricType"in e?this.lodMetricType=e.lodMetricType:(this.lodMetricType=this.parent&&this.parent.lodMetricType||this.tileset.lodMetricType,console.warn("3D Tile: Required prop lodMetricType is undefined. Using parent lodMetricType")),"lodMetricValue"in e?this.lodMetricValue=e.lodMetricValue:(this.lodMetricValue=this.parent&&this.parent.lodMetricValue||this.tileset.lodMetricValue,console.warn("3D Tile: Required prop lodMetricValue is undefined. Using parent lodMetricValue"))}_initializeTransforms(e){this.transform=e.transform?new n.Matrix4(e.transform):new n.Matrix4;const t=this.parent,r=this.tileset,i=t&&t.computedTransform?t.computedTransform.clone():r.modelMatrix.clone();this.computedTransform=new n.Matrix4(i).multiplyRight(this.transform);const a=t&&t._initialTransform?t._initialTransform.clone():new n.Matrix4;this._initialTransform=new n.Matrix4(a).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=Kh,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=js.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||Gh.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=Ap(e.boundingVolume,this.computedTransform,this.boundingVolume);const t=e.content;t&&(t.boundingVolume&&(this._contentBoundingVolume=Ap(t.boundingVolume,this.computedTransform,this._contentBoundingVolume)),e.viewerRequestVolume&&(this._viewerRequestVolume=Ap(e.viewerRequestVolume,this.computedTransform,this._viewerRequestVolume)))}_updateTransform(e=new n.Matrix4){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}},Ep=class extends Tp{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 r=e.refine===Gh.REPLACE,i=e._optimChildrenWithinParent===Xh;r&&i&&n&&!this.anyChildrenVisible(e,t)&&(e._visible=!1)}meetsScreenSpaceErrorEarly(e,t){const{parent:n}=e;return!(!n||n.hasTilesetContent||n.refine!==Gh.ADD)&&!this.shouldRefine(e,t,!0)}},Cp=class{frameNumberMap=new Map;register(e,t){const n=this.frameNumberMap.get(e)||new Map,r=n.get(t)||0;n.set(t,r+1),this.frameNumberMap.set(e,n)}deregister(e,t){const n=this.frameNumberMap.get(e);if(!n)return;const r=n.get(t)||1;n.set(t,r-1)}isZero(e,t){return 0===(this.frameNumberMap.get(e)?.get(t)||0)}},Ip="REQUESTED",Rp="COMPLETED",Pp="ERROR",Np=class{_statusMap;pendingTilesRegister=new Cp;constructor(){this._statusMap={}}add(e,t,n,r){if(!this._statusMap[t]){const{frameNumber:i,viewport:{id:a}}=r;this._statusMap[t]={request:e,callback:n,key:t,frameState:r,status:Ip},this.pendingTilesRegister.register(a,i),e().then(e=>{this._statusMap[t].status=Rp;const{frameNumber:n,viewport:{id:i}}=this._statusMap[t].frameState;this.pendingTilesRegister.deregister(i,n),this._statusMap[t].callback(e,r)}).catch(e=>{this._statusMap[t].status=Pp;const{frameNumber:r,viewport:{id:i}}=this._statusMap[t].frameState;this.pendingTilesRegister.deregister(i,r),n(e)})}}update(e,t){if(this._statusMap[e]){const{frameNumber:n,viewport:{id:r}}=this._statusMap[e].frameState;this.pendingTilesRegister.deregister(r,n);const{frameNumber:i,viewport:{id:a}}=t;this.pendingTilesRegister.register(a,i),this._statusMap[e].frameState=t}}find(e){return this._statusMap[e]}hasPendingTiles(e,t){return!this.pendingTilesRegister.isZero(e,t)}},kp=class extends Tp{_tileManager;constructor(e){super(e),this._tileManager=new Np}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*xp(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||[],r=e.children,i=e.tileset;for(const a of n){const n=`${a.id}-${t.viewport.id}`,o=r&&r.find(e=>e.id===n);if(o)o&&this.updateTile(o,t);else{let r=()=>this._loadTile(a.id,i);this._tileManager.find(n)?this._tileManager.update(n,t):(i.tileset.nodePages&&(r=()=>i.tileset.nodePagesTile.formTileFromNodePages(a.id)),this._tileManager.add(r,n,t=>this._onTileLoad(t,e,n),t))}}return!1}async _loadTile(e,t){const{loader:r}=t,i=t.getTileUrl(`${t.url}/nodes/${e}`),a={...t.loadOptions,i3s:{...t.loadOptions.i3s,isTileHeader:!0}};return await n.load(i,r,a)}_onTileLoad(e,t,n){const r=new Mp(t.tileset,e,t,n);t.children.push(r);const i=this._tileManager.find(r.id).frameState;this.updateTile(r,i),this._frameNumber===i.frameNumber&&(this.traversalFinished(i)||(new Date).getTime()-this.lastUpdate>this.updateDebounceTime)&&this.executeTraversal(r,i)}},Lp={description:"",ellipsoid:Eh.WGS84,modelMatrix:new n.Matrix4,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:{}},Bp="Tiles In Tileset(s)",Op="Tiles In Memory",Fp="Tiles In View",Dp="Tiles To Render",Up="Tiles Loaded",Vp="Tiles Loading",jp="Tiles Unloaded",zp="Failed Tile Loads",Gp="Points/Vertices",Hp="Tile Memory Use",qp="Maximum Screen Space Error",Qp=class{options;loadOptions;type;tileset;loader;url;basePath;modelMatrix;ellipsoid;lodMetricType;lodMetricValue;refine;root=null;roots={};asset={};description="";properties;extras=null;attributions={};credits={};stats;contentFormats={draco:!1,meshopt:!1,dds:!1,ktx2:!1};cartographicCenter=null;cartesianCenter=null;zoom=1;boundingVolume=null;dynamicScreenSpaceErrorComputedDensity=0;maximumMemoryUsage=32;gpuMemoryUsageInBytes=0;memoryAdjustedScreenSpaceError=0;_cacheBytes=0;_cacheOverflowBytes=0;_frameNumber=0;_queryParams={};_extensionsUsed=[];_tiles={};_pendingCount=0;selectedTiles=[];traverseCounter=0;geometricError=0;lastUpdatedVieports=null;_requestedTiles=[];_emptyTiles=[];frameStateData={};_traverser;_cache=new Rh;_requestScheduler;_heldTiles=new Set;updatePromise=null;tilesetInitializationPromise;constructor(e,t){this.options={...Lp,...t},this.tileset=e,this.loader=e.loader,this.type=e.type,this.url=e.url,this.basePath=e.basePath||n.dirname(this.url),this.modelMatrix=this.options.modelMatrix,this.ellipsoid=this.options.ellipsoid,this.lodMetricType=e.lodMetricType,this.lodMetricValue=e.lodMetricValue,this.refine=e.root.refine,this.loadOptions=this.options.loadOptions||{},this._traverser=this._initializeTraverser(),this._requestScheduler=new g({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 n.Stats({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 r of t){const e=r.id;this._needTraverse(e)?n.push(e):this.traverseCounter--}for(const r of t){const e=r.id;if(this.roots[e]||(this.roots[e]=this._initializeTileHeaders(this.tileset,null)),!n.includes(e))continue;const t=Oh(r,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],r=Object.values(this._traverser.selectedTiles),[i,a]=function(e,t,n){if(0===n||e.length<=n)return[e,[]];const r=[],{longitude:i,latitude:a}=t.viewport;for(const[l,c]of e.entries()){const[e,t]=c.header.mbs,n=Math.abs(i-e),o=Math.abs(a-t),s=Math.sqrt(o*o+n*n);r.push([l,s])}const o=r.sort((e,t)=>e[1]-t[1]),s=[];for(let l=0;l<n;l++)s.push(e[o[l][0]]);const A=[];for(let l=n;l<o.length;l++)A.push(e[o[l][0]]);return[s,A]}(r,e,this.options.maximumTilesSelected);n.selectedTiles=i;for(const o of a)o.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 r in this.frameStateData){const e=this.frameStateData[r];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 r=this._tiles[e];r&&r.contentAvailable?(r._selectedFrame=this._frameNumber,this.selectedTiles.push(r),n++):this._heldTiles.delete(e)}}else this._heldTiles=t;n>0&&setTimeout(()=>{this.selectTiles()},0);for(const r of this.selectedTiles)this._tiles[r.id]=r;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)),r=new Set(t.map(e=>e.id));let i=e.filter(e=>!r.has(e.id)).length>0;return i=i||t.filter(e=>!n.has(e.id)).length>0,i}_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(Fp).count=this.selectedTiles.length,this.stats.get(Dp).count=e,this.stats.get(Gp).count=t,this.stats.get(qp).count=this.memoryAdjustedScreenSpaceError}async _initializeTileSet(e){this.type===qh.I3S&&(this.calculateViewPropsI3S(),e.root=await e.root),this.root=this._initializeTileHeaders(e,null),this.type===qh.TILES3D&&(this._initializeTiles3DTileset(e),this.calculateViewPropsTiles3D()),this.type===qh.I3S&&this._initializeI3STileset()}calculateViewPropsI3S(){const e=this.tileset.fullExtent;if(e){const{xmin:t,xmax:r,ymin:i,ymax:a,zmin:o,zmax:s}=e;return this.cartographicCenter=new n.Vector3(t+(r-t)/2,i+(a-i)/2,o+(s-o)/2),this.cartesianCenter=new n.Vector3,Eh.WGS84.cartographicToCartesian(this.cartographicCenter,this.cartesianCenter),void(this.zoom=zh(e,this.cartographicCenter,this.cartesianCenter))}const t=this.tileset.store?.extent;if(t){const[e,r,i,a]=t;return this.cartographicCenter=new n.Vector3(e+(i-e)/2,r+(a-r)/2,0),this.cartesianCenter=new n.Vector3,Eh.WGS84.cartographicToCartesian(this.cartographicCenter,this.cartesianCenter),void(this.zoom=function(e,t,n){const[r,i,a,o]=e;return zh({xmin:r,xmax:a,ymin:i,ymax:o,zmin:0,zmax:0},t,n)}(t,this.cartographicCenter,this.cartesianCenter))}console.warn("Extent is not defined in the tileset header"),this.cartographicCenter=new n.Vector3,this.zoom=1}calculateViewPropsTiles3D(){const e=this.root,{center:t}=e.boundingVolume;if(!t)return console.warn("center was not pre-calculated for the root tile"),this.cartographicCenter=new n.Vector3,void(this.zoom=1);0!==t[0]||0!==t[1]||0!==t[2]?(this.cartographicCenter=new n.Vector3,Eh.WGS84.cartesianToCartographic(t,this.cartographicCenter)):this.cartographicCenter=new n.Vector3(0,0,-Eh.WGS84.radii[0]),this.cartesianCenter=t,this.zoom=jh(e.boundingVolume,this.cartographicCenter)}_initializeStats(){this.stats.get(Bp),this.stats.get(Vp),this.stats.get(Op),this.stats.get(Fp),this.stats.get(Dp),this.stats.get(Up),this.stats.get(jp),this.stats.get(zp),this.stats.get(Gp),this.stats.get(Hp,"memory"),this.stats.get(qp)}_initializeTileHeaders(e,t){const n=new Mp(this,e.root,t);if(t&&(t.children.push(n),n.depth=t.depth+1),this.type===qh.TILES3D){const e=[];for(e.push(n);e.length>0;){const t=e.pop();this.stats.get(Bp).incrementCount();const n=t.header.children||[];for(const r of n){const n=new Mp(this,r,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 qh.TILES3D:e=Ep;break;case qh.I3S:e=kp;break;default:e=Tp}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(zp).incrementCount();const n=t.message||t.toString(),r=e.url;console.error(`A 3D tile failed to load: ${e.url} ${n}`),this.options.onTileError(e,n,r)}_onTileLoad(e,t){if(t){if(this.type===qh.I3S){const e=this.tileset?.nodePagesTile?.nodesInNodePages||0;this.stats.get(Bp).reset(),this.stats.get(Bp).addCount(e)}e&&e.content&&Ph(e,e.content),this.updateContentTypes(e),this._addTileToCache(e),this.options.onTileLoad(e)}}updateContentTypes(e){if(this.type===qh.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===qh.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(Vp).incrementCount()}_onEndTileLoading(){this._pendingCount--,this.stats.get(Vp).decrementCount()}_addTileToCache(e){this._cache.add(this,e,t=>t._updateCacheStats(e))}_updateCacheStats(e){this.stats.get(Up).incrementCount(),this.stats.get(Op).incrementCount(),this.gpuMemoryUsageInBytes+=e.gpuMemoryUsageInBytes||0,this.stats.get(Hp).count=this.gpuMemoryUsageInBytes,this.options.memoryAdjustedScreenSpaceError&&this.adjustScreenSpaceError()}_unloadTile(e){this.gpuMemoryUsageInBytes-=e.gpuMemoryUsageInBytes||0,this.stats.get(Op).decrementCount(),this.stats.get(jp).incrementCount(),this.stats.get(Hp).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)}},Kp="4.5.4",Wp={COMPOSITE:"cmpt",POINT_CLOUD:"pnts",BATCHED_3D_MODEL:"b3dm",INSTANCED_3D_MODEL:"i3dm",GEOMETRY:"geom",VECTOR:"vect",GLTF:"glTF"};Object.keys(Wp);function $p(e,t,r){n.assert$3(e instanceof ArrayBuffer);const i=new TextDecoder("utf8"),a=new Uint8Array(e,t,r);return i.decode(a)}var Jp={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,DOUBLE:5130},Yp={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,...Jp},Xp={[Jp.DOUBLE]:Float64Array,[Jp.FLOAT]:Float32Array,[Jp.UNSIGNED_SHORT]:Uint16Array,[Jp.UNSIGNED_INT]:Uint32Array,[Jp.UNSIGNED_BYTE]:Uint8Array,[Jp.BYTE]:Int8Array,[Jp.SHORT]:Int16Array,[Jp.INT]:Int32Array},Zp={DOUBLE:Jp.DOUBLE,FLOAT:Jp.FLOAT,UNSIGNED_SHORT:Jp.UNSIGNED_SHORT,UNSIGNED_INT:Jp.UNSIGNED_INT,UNSIGNED_BYTE:Jp.UNSIGNED_BYTE,BYTE:Jp.BYTE,SHORT:Jp.SHORT,INT:Jp.INT},em="Failed to convert GL type",tm=class e{static fromTypedArray(e){e=ArrayBuffer.isView(e)?e.constructor:e;for(const t in Xp)if(Xp[t]===e)return t;throw new Error(em)}static fromName(e){const t=Zp[e];if(!t)throw new Error(em);return t}static getArrayType(e){switch(e){case Jp.UNSIGNED_SHORT_5_6_5:case Jp.UNSIGNED_SHORT_4_4_4_4:case Jp.UNSIGNED_SHORT_5_5_5_1:return Uint16Array;default:const t=Xp[e];if(!t)throw new Error(em);return t}}static getByteSize(t){return e.getArrayType(t).BYTES_PER_ELEMENT}static validate(t){return Boolean(e.getArrayType(t))}static createTypedArray(t,n,r=0,i){void 0===i&&(i=(n.byteLength-r)/e.getByteSize(t));const a=ArrayBuffer.isView(n)?n.buffer:n;return new(e.getArrayType(t))(a,r,i)}};function nm(e,t=[0,0,0]){const n=e>>11&31,r=e>>5&63,i=31&e;return t[0]=n<<3,t[1]=r<<2,t[2]=i<<3,t}new P,new n.Vector3,new P,new P;function rm(e,t=255){return n.clamp(e,0,t)/t*2-1}function im(e){return e<0?-1:1}function am(e,t,n,r){if(function(e,t){if(!e)throw new Error(`math.gl assertion failed. ${t}`)}(r),e<0||e>n||t<0||t>n)throw new Error(`x and y must be unsigned normalized integers between 0 and ${n}`);if(r.x=rm(e,n),r.y=rm(t,n),r.z=1-(Math.abs(r.x)+Math.abs(r.y)),r.z<0){const e=r.x;r.x=(1-Math.abs(r.y))*im(e),r.y=(1-Math.abs(e))*im(r.y)}return r.normalize()}function om(e,t,n){return am(e,t,255,n)}var sm=class{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=Yp.UNSIGNED_INT,n=1){const r=this.json[e];return r&&Number.isFinite(r.byteOffset)?this._getTypedArrayFromBinary(e,t,n,1,r.byteOffset):r}getPropertyArray(e,t,n){const r=this.json[e];return r&&Number.isFinite(r.byteOffset)?("componentType"in r&&(t=tm.fromName(r.componentType)),this._getTypedArrayFromBinary(e,t,n,this.featuresLength,r.byteOffset)):this._getTypedArrayFromArray(e,t,r)}getProperty(e,t,n,r,i){const a=this.json[e];if(!a)return a;const o=this.getPropertyArray(e,t,n);if(1===n)return o[r];for(let s=0;s<n;++s)i[s]=o[n*r+s];return i}_getTypedArrayFromBinary(e,t,n,r,i){const a=this._cachedTypedArrays;let o=a[e];return o||(o=tm.createTypedArray(t,this.buffer.buffer,this.buffer.byteOffset+i,r*n),a[e]=o),o}_getTypedArrayFromArray(e,t,n){const r=this._cachedTypedArrays;let i=r[e];if(!i){if(ArrayBuffer.isView(n)){const e=n.byteOffset,r=n.byteLength/tm.getByteSize(t);i=tm.createTypedArray(t,n.buffer,e,r)}else i=n instanceof ArrayBuffer?tm.createTypedArray(t,n):new(tm.getArrayType(t))(n);r[e]=i}return i}},Am={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},lm={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]]},cm={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]}};var um=e=>void 0!==e;function fm(e,t,n){if(!t)return null;let r=e.getExtension("3DTILES_batch_table_hierarchy");const i=t.HIERARCHY;return i&&(console.warn("3D Tile Parser: HIERARCHY is deprecated. Use 3DTILES_batch_table_hierarchy."),t.extensions=t.extensions||{},t.extensions["3DTILES_batch_table_hierarchy"]=i,r=i),r?function(e,t){let n,r,i;const a=e.instancesLength,o=e.classes;let s,A=e.classIds,l=e.parentCounts,c=e.parentIds,u=a;um(A.byteOffset)&&(A.componentType=defaultValue(A.componentType,GL.UNSIGNED_SHORT),A.type=AttributeType.SCALAR,i=getBinaryAccessor(A),A=i.createArrayBufferView(t.buffer,t.byteOffset+A.byteOffset,a));if(um(l))for(um(l.byteOffset)&&(l.componentType=defaultValue(l.componentType,GL.UNSIGNED_SHORT),l.type=AttributeType.SCALAR,i=getBinaryAccessor(l),l=i.createArrayBufferView(t.buffer,t.byteOffset+l.byteOffset,a)),s=new Uint16Array(a),u=0,n=0;n<a;++n)s[n]=u,u+=l[n];um(c)&&um(c.byteOffset)&&(c.componentType=defaultValue(c.componentType,GL.UNSIGNED_SHORT),c.type=AttributeType.SCALAR,i=getBinaryAccessor(c),c=i.createArrayBufferView(t.buffer,t.byteOffset+c.byteOffset,u));const f=o.length;for(n=0;n<f;++n){const e=o[n].length,r=o[n].instances,i=getBinaryProperties(e,r,t);o[n].instances=combine(i,r)}const d=new Array(f).fill(0),h=new Uint16Array(a);for(n=0;n<a;++n)r=A[n],h[n]=d[r],++d[r];const p={classes:o,classIds:A,classIndexes:h,parentCounts:l,parentIndexes:s,parentIds:c};return function(e){const t=e.classIds.length;for(let n=0;n<t;++n)hm(e,n,stack)}(p),p}(r,n):null}function dm(e,t,n){if(!e)return;const r=e.parentCounts;return e.parentIds?n(e,t):r>0?function(e,t,n){const r=e.classIds,i=e.parentCounts,a=e.parentIds,o=e.parentIndexes,s=r.length,A=scratchVisited;A.length=Math.max(A.length,s);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 r=n(e,t);if(um(r))return r;const s=i[t],u=o[t];for(let e=0;e<s;++e){const n=a[u+e];n!==t&&c.push(n)}}return null}(e,t,n):function(e,t,n){let r=!0;for(;r;){const i=n(e,t);if(um(i))return i;const a=e.parentIds[t];r=a!==t,t=a}throw new Error("traverseHierarchySingleParent")}(e,t,n)}function hm(e,t,n){const r=e.parentCounts,i=e.parentIds,a=e.parentIndexes,o=e.classIds.length;if(!um(i))return;assert(t<o,`Parent index ${t} exceeds the total number of instances: ${o}`),assert(-1===n.indexOf(t),"Circular dependency detected in the batch table hierarchy."),n.push(t);const s=um(r)?r[t]:1,A=um(r)?a[t]:t;for(let l=0;l<s;++l){const r=i[A+l];r!==t&&hm(e,r,n)}n.pop(t)}function pm(e){return null!=e}var mm=(e,t)=>e,gm={HIERARCHY:!0,extensions:!0,extras:!0},bm=class{json;binary;featureCount;_extensions;_properties;_binaryProperties;_hierarchy;constructor(e,t,r,i={}){n.assert$3(r>=0),this.json=e||{},this.binary=t,this.featureCount=r,this._extensions=this.json?.extensions||{},this._properties={};for(const n in this.json)gm[n]||(this._properties[n]=this.json[n]);this._binaryProperties=this._initializeBinaryProperties(),i["3DTILES_batch_table_hierarchy"]&&(this._hierarchy=fm(this,this.json,this.binary))}getExtension(e){return this.json&&this.json.extensions&&this.json.extensions[e]}memorySizeInBytes(){return 0}isClass(e,t){return this._checkBatchId(e),n.assert$3("string"==typeof t,t),!!this._hierarchy&&pm(dm(this._hierarchy,e,(e,n)=>{const r=e.classIds[n];return e.classes[r].name===t}))}isExactClass(e,t){return n.assert$3("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),n.assert$3("string"==typeof t,t),pm(this._properties[t])||this._hasPropertyInHierarchy(e,t)}getPropertyNames(e,t){this._checkBatchId(e),(t=pm(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),n.assert$3("string"==typeof t,t),this._binaryProperties){const n=this._binaryProperties[t];if(pm(n))return this._getBinaryProperty(n,e)}const r=this._properties[t];if(pm(r))return mm(r[e]);if(this._hierarchy){const n=this._getHierarchyProperty(e,t);if(pm(n))return n}}setProperty(e,t,r){const i=this.featureCount;if(this._checkBatchId(e),n.assert$3("string"==typeof t,t),this._binaryProperties){const n=this._binaryProperties[t];if(n)return void this._setBinaryProperty(n,e,r)}if(this._hierarchy&&this._setHierarchyProperty(this,e,t,r))return;let a=this._properties[t];pm(a)||(this._properties[t]=new Array(i),a=this._properties[t]),a[e]=mm(r)}_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],r=this._initializeBinaryProperty(t,n);r&&(e=e||{},e[t]=r)}return e}_initializeBinaryProperty(e,t){if("byteOffset"in t){const r=t;n.assert$3(this.binary,`Property ${e} requires a batch table binary.`),n.assert$3(r.type,`Property ${e} requires a type.`);const i=function(e,t,r,i){const{componentType:a}=e;n.assert$3(e.componentType);const o="string"==typeof a?tm.fromName(a):a,s=Am[e.type],A=lm[e.type],l=cm[e.type];return r+=e.byteOffset,{values:tm.createTypedArray(o,t,r,s*i),type:o,size:s,unpacker:A,packer:l}}(r,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){return!!this._hierarchy&&pm(dm(this._hierarchy,e,(e,n)=>{const r=e.classIds[n];return pm(e.classes[r].instances[t])}))}_getPropertyNamesInHierarchy(e,t){dm(this._hierarchy,e,(e,n)=>{const r=e.classIds[n],i=e.classes[r].instances;for(const a in i)i.hasOwnProperty(a)&&-1===t.indexOf(a)&&t.push(a)})}_getHierarchyProperty(e,t){return dm(this._hierarchy,e,(e,n)=>{const r=e.classIds[n],i=e.classes[r],a=e.classIndexes[n],o=i.instances[t];return pm(o)?pm(o.typedArray)?this._getBinaryProperty(o,a):mm(o[a]):null})}_setHierarchyProperty(e,t,r,i){return pm(dm(this._hierarchy,t,(e,a)=>{const o=e.classIds[a],s=e.classes[o],A=e.classIndexes[a],l=s.instances[r];return!!pm(l)&&(n.assert$3(a===t,`Inherited property "${r}" is read-only.`),pm(l.typedArray)?this._setBinaryProperty(l,A,i):l[A]=mm(i),!0)}))}};function vm(e,t,n=0){const r=new DataView(t);if(e.magic=r.getUint32(n,!0),n+=4,e.version=r.getUint32(n,!0),n+=4,e.byteLength=r.getUint32(n,!0),n+=4,1!==e.version)throw new Error(`3D Tile Version ${e.version} not supported`);return n}var ym="b3dm tile in legacy format.";function xm(e,t,n){const r=new DataView(t);let i;e.header=e.header||{};let a=r.getUint32(n,!0);n+=4;let o=r.getUint32(n,!0);n+=4;let s=r.getUint32(n,!0);n+=4;let A=r.getUint32(n,!0);return n+=4,s>=570425344?(n-=8,i=a,s=o,A=0,a=0,o=0,console.warn(ym)):A>=570425344&&(n-=4,i=s,s=a,A=o,a=0,o=0,console.warn(ym)),e.header.featureTableJsonByteLength=a,e.header.featureTableBinaryByteLength=o,e.header.batchTableJsonByteLength=s,e.header.batchTableBinaryByteLength=A,e.header.batchLength=i,n}function _m(e,t,n,r){return n=function(e,t,n){const{featureTableJsonByteLength:r,featureTableBinaryByteLength:i,batchLength:a}=e.header||{};if(e.featureTableJson={BATCH_LENGTH:a||0},r&&r>0){const i=$p(t,n,r);e.featureTableJson=JSON.parse(i)}return n+=r||0,e.featureTableBinary=new Uint8Array(t,n,i),n+=i||0,n}(e,t,n),n=function(e,t,n){const{batchTableJsonByteLength:r,batchTableBinaryByteLength:i}=e.header||{};if(r&&r>0){const a=$p(t,n,r);e.batchTableJson=JSON.parse(a),n+=r,i&&i>0&&(e.batchTableBinary=new Uint8Array(t,n,i),e.batchTableBinary=new Uint8Array(e.batchTableBinary),n+=i)}return n}(e,t,n),n}function wm(e,t,n){if(!(t||e&&e.batchIds&&n))return null;const{batchIds:r,isRGB565:i,pointCount:a=0}=e;if(r&&n){const e=new Uint8ClampedArray(3*a);for(let t=0;t<a;t++){const i=r[t],a=n.getProperty(i,"dimensions").map(e=>255*e);e[3*t]=a[0],e[3*t+1]=a[1],e[3*t+2]=a[2]}return{type:Yp.UNSIGNED_BYTE,value:e,size:3,normalized:!0}}if(t&&i){const e=new Uint8ClampedArray(3*a);for(let n=0;n<a;n++){const r=nm(t[n]);e[3*n]=r[0],e[3*n+1]=r[1],e[3*n+2]=r[2]}return{type:Yp.UNSIGNED_BYTE,value:e,size:3,normalized:!0}}return t&&t.length===3*a?{type:Yp.UNSIGNED_BYTE,value:t,size:3,normalized:!0}:{type:Yp.UNSIGNED_BYTE,value:t||new Uint8ClampedArray,size:4,normalized:!0}}var Tm=new n.Vector3;function Sm(e,t,r){return e.isQuantized?r["3d-tiles"]&&r["3d-tiles"].decodeQuantizedPositions?(e.isQuantized=!1,function(e,t){const r=new n.Vector3,i=new Float32Array(3*e.pointCount);for(let n=0;n<e.pointCount;n++)r.set(t[3*n],t[3*n+1],t[3*n+2]).scale(1/e.quantizedRange).multiply(e.quantizedVolumeScale).add(e.quantizedVolumeOffset).toArray(i,3*n);return i}(e,t)):{type:Yp.UNSIGNED_SHORT,value:t,size:3,normalized:!0}:t}async function Mm(e,t,r,i,a){r=_m(e,t,r=xm(e,t,r=vm(e,t,r))),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:A}=function(e){const t=new sm(e.featureTableJson,e.featureTableBinary),n=t.getGlobalProperty("POINTS_LENGTH");if(!Number.isFinite(n))throw new Error("POINTS_LENGTH must be defined");return t.featuresLength=n,e.featuresLength=n,e.pointsLength=n,e.pointCount=n,e.rtcCenter=t.getGlobalProperty("RTC_CENTER",Yp.FLOAT,3),{featureTable:t,batchTable:Em(e,t)}}(e);return await async function(e,t,r,i,a){let o,A,l;const c=e.batchTableJson&&e.batchTableJson.extensions&&e.batchTableJson.extensions["3DTILES_draco_point_compression"];c&&(l=c.properties);const u=t.getExtension("3DTILES_draco_point_compression");if(u){A=u.properties;const t=u.byteOffset,n=u.byteLength;if(!A||!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(A.POSITION),e.hasColors=Number.isFinite(A.RGB)||Number.isFinite(A.RGBA),e.hasNormals=Number.isFinite(A.NORMAL),e.hasBatchIds=Number.isFinite(A.BATCH_ID),e.isTranslucent=Number.isFinite(A.RGBA)}return!o||await async function(e,t,r,i){if(!i)return;const a={...r,draco:{...r?.draco,extraAttributes:t.batchTableProperties||{}}};delete a["3d-tiles"];const o=await s(t.buffer,Bf,a,i),A=o.attributes.POSITION&&o.attributes.POSITION.value,l=o.attributes.COLOR_0&&o.attributes.COLOR_0.value,c=o.attributes.NORMAL&&o.attributes.NORMAL.value,u=o.attributes.BATCH_ID&&o.attributes.BATCH_ID.value,f=A&&o.attributes.POSITION.value.quantization,d=c&&o.attributes.NORMAL.value.quantization;if(f){const t=o.POSITION.data.quantization,r=t.range;e.quantizedVolumeScale=new n.Vector3(r,r,r),e.quantizedVolumeOffset=new n.Vector3(t.minValues),e.quantizedRange=(1<<t.quantizationBits)-1,e.isQuantizedDraco=!0}d&&(e.octEncodedRange=(1<<o.NORMAL.data.quantization.quantizationBits)-1,e.isOctEncodedDraco=!0);const h={};if(t.batchTableProperties)for(const n of Object.keys(t.batchTableProperties))o.attributes[n]&&o.attributes[n].value&&(h[n.toLowerCase()]=o.attributes[n].value);e.attributes={positions:A,colors:wm(e,l,void 0),normals:c,batchIds:u,...h}}(e,{buffer:o,properties:{...A,...l},featureTableProperties:A,batchTableProperties:l,dequantizeInShader:!1},i,a)}(e,o,0,i,a),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",Yp.FLOAT,3);else if(t.hasProperty("POSITION_QUANTIZED")){const r=t.getPropertyArray("POSITION_QUANTIZED",Yp.UNSIGNED_SHORT,3);if(e.isQuantized=!0,e.quantizedRange=65535,e.quantizedVolumeScale=t.getGlobalProperty("QUANTIZED_VOLUME_SCALE",Yp.FLOAT,3),!e.quantizedVolumeScale)throw new Error("QUANTIZED_VOLUME_SCALE must be defined for quantized positions.");if(e.quantizedVolumeOffset=t.getGlobalProperty("QUANTIZED_VOLUME_OFFSET",Yp.FLOAT,3),!e.quantizedVolumeOffset)throw new Error("QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.");e.attributes.positions=Sm(e,r,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 r=null;t.hasProperty("RGBA")?(r=t.getPropertyArray("RGBA",Yp.UNSIGNED_BYTE,4),e.isTranslucent=!0):t.hasProperty("RGB")?r=t.getPropertyArray("RGB",Yp.UNSIGNED_BYTE,3):t.hasProperty("RGB565")&&(r=t.getPropertyArray("RGB565",Yp.UNSIGNED_SHORT,1),e.isRGB565=!0),e.attributes.colors=wm(e,r,n)}t.hasProperty("CONSTANT_RGBA")&&(e.constantRGBA=t.getGlobalProperty("CONSTANT_RGBA",Yp.UNSIGNED_BYTE,4))}(e,o,A),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",Yp.FLOAT,3):t.hasProperty("NORMAL_OCT16P")&&(n=t.getPropertyArray("NORMAL_OCT16P",Yp.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 r=0;r<(e.pointsLength||0);r++)om(t[2*r],t[2*r+1],Tm),Tm.toArray(n,3*r);return{type:Yp.FLOAT,size:2,value:n}}return{type:Yp.FLOAT,size:2,value:t}}(e,n)}}(e,o),r}function Em(e,t){let n=null;if(!e.batchIds&&t.hasProperty("BATCH_ID")&&(e.batchIds=t.getPropertyArray("BATCH_ID",Yp.UNSIGNED_SHORT,1),e.batchIds)){const r=t.getGlobalProperty("BATCH_LENGTH");if(!r)throw new Error("Global property: BATCH_LENGTH must be defined when BATCH_ID is defined.");const{batchTableJson:i,batchTableBinary:a}=e;n=new bm(i,a,r)}return n}var Cm=0,Im=1;function Rm(e,t,r,i){e.rotateYtoZ=!0;const a=(e.byteOffset||0)+(e.byteLength||0)-r;if(0===a)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=n.sliceArrayBuffer(t,r,a),e.gltfByteOffset=0,e.gltfByteLength=a,r%4==0||console.warn(`${e.type}: embedded glb is not aligned to a 4-byte boundary.`),(e.byteOffset||0)+(e.byteLength||0)}async function Pm(e,t,n,r){const i=n?.["3d-tiles"]||{};if(function(e,t){switch(t){case Cm:if(e.gltfArrayBuffer){const t=new Uint8Array(e.gltfArrayBuffer,e.gltfByteOffset);e.gltfUrl=(new TextDecoder).decode(t).replace(/[\s\0]+$/,"")}delete e.gltfArrayBuffer,delete e.gltfByteOffset,delete e.gltfByteLength;break;case Im:break;default:throw new Error("b3dm: Illegal glTF format field")}}(e,t),i.loadGLTF){if(!r)return;if(e.gltfUrl){const{fetch:t}=r;e.gltfArrayBuffer=await(await t(e.gltfUrl,n?.core)).arrayBuffer(),e.gltfByteOffset=0}if(e.gltfArrayBuffer){const t=await s(e.gltfArrayBuffer,Id,n,r);e.gltf=Hd(t),e.gpuMemoryUsageInBytes=Mc(e.gltf),delete e.gltfArrayBuffer,delete e.gltfByteOffset,delete e.gltfByteLength}}}async function Nm(e,t,n,r,i){n=function(e,t,n,r){return n=vm(e,t,n),n=xm(e,t,n),n=_m(e,t,n),n=Rm(e,t,n,r),e.rtcCenter=new sm(e.featureTableJson,e.featureTableBinary).getGlobalProperty("RTC_CENTER",Yp.FLOAT,3),n}(e,t,n,r),await Pm(e,Im,r,i);const a=e?.gltf?.extensions;return a&&a.CESIUM_RTC&&(e.rtcCenter=a.CESIUM_RTC.center),n}async function km(e,t,i,a,o){return i=function(e,t,i,a){if(i=vm(e,t,i),1!==e.version)throw new Error(`Instanced 3D Model version ${e.version} is not supported`);if(i=xm(e,t,i),e.gltfFormat=new DataView(t).getUint32(i,!0),i+=4,i=_m(e,t,i),i=Rm(e,t,i,a),!e?.header?.featureTableJsonByteLength||0===e.header.featureTableJsonByteLength)throw new Error("i3dm parser: featureTableJsonByteLength is zero.");const o=new sm(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");return e.eastNorthUp=o.getGlobalProperty("EAST_NORTH_UP"),e.rtcCenter=o.getGlobalProperty("RTC_CENTER",Yp.FLOAT,3),function(e,t,i,a){const o=new Array(a),s=new n.Vector3;new n.Vector3,new n.Vector3,new n.Vector3;const A=new L,l=new r.Quaternion,c=new n.Vector3,u={},f=new n.Matrix4,d=[],h=[],p=[],m=[];for(let r=0;r<a;r++){let i;if(t.hasProperty("POSITION"))i=t.getProperty("POSITION",Yp.FLOAT,3,r,s);else if(t.hasProperty("POSITION_QUANTIZED")){i=t.getProperty("POSITION_QUANTIZED",Yp.UNSIGNED_SHORT,3,r,s);const e=t.getGlobalProperty("QUANTIZED_VOLUME_OFFSET",Yp.FLOAT,3);if(!e)throw new Error("i3dm parser: QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.");const n=t.getGlobalProperty("QUANTIZED_VOLUME_SCALE",Yp.FLOAT,3);if(!n)throw new Error("i3dm parser: QUANTIZED_VOLUME_SCALE must be defined for quantized positions.");const a=65535;for(let t=0;t<3;t++)i[t]=i[t]/a*n[t]+e[t]}if(!i)throw new Error("i3dm: POSITION or POSITION_QUANTIZED must be defined for each instance.");if(s.copy(i),u.translation=s,e.normalUp=t.getProperty("NORMAL_UP",Yp.FLOAT,3,r,d),e.normalRight=t.getProperty("NORMAL_RIGHT",Yp.FLOAT,3,r,h),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",Yp.UNSIGNED_SHORT,2,r,d),e.octNormalRight=t.getProperty("NORMAL_RIGHT_OCT32P",Yp.UNSIGNED_SHORT,2,r,h),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?(Eh.WGS84.eastNorthUpToFixedFrame(s,f),f.getRotationMatrix3(A)):A.identity()}l.fromMatrix3(A),u.rotation=l,c.set(1,1,1);const a=t.getProperty("SCALE",Yp.FLOAT,1,r,p);Number.isFinite(a)&&c.multiplyByScalar(a);const g=t.getProperty("SCALE_NON_UNIFORM",Yp.FLOAT,3,r,d);g&&c.scale(g),u.scale=c;let b=t.getProperty("BATCH_ID",Yp.UNSIGNED_SHORT,1,r,m);void 0===b&&(b=r);const v=(new n.Matrix4).fromQuaternion(u.rotation);f.identity(),f.translate(u.translation),f.multiplyRight(v),f.scale(u.scale);const y=f.clone();o[r]={modelMatrix:y,batchId:b}}e.instances=o}(e,o,new bm(e.batchTableJson,e.batchTableBinary,s),s),i}(e,t,i,a),await Pm(e,e.gltfFormat||0,a,o),i}async function Lm(e,t=0,n,r,i={shape:"tile3d"}){switch(i.byteOffset=t,i.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),i.type){case Wp.COMPOSITE:return await async function(e,t,n,r,i,a){for(n=vm(e,t,n),e.tilesLength=new DataView(t).getUint32(n,!0),n+=4,e.tiles=[];e.tiles.length<e.tilesLength&&(e.byteLength||0)-n>12;){const o={shape:"tile3d"};e.tiles.push(o),n=await a(t,n,r,i,o)}return n}(i,e,t,n,r,Lm);case Wp.BATCHED_3D_MODEL:return await Nm(i,e,t,n,r);case Wp.GLTF:return await async function(e,t,n,r){if(e.rotateYtoZ=!0,e.gltfUpAxis=n?.["3d-tiles"]?.assetGltfUpAxis?n["3d-tiles"].assetGltfUpAxis:"Y",n?.["3d-tiles"]?.loadGLTF){if(!r)return t.byteLength;const i=await s(t,Id,n,r);e.gltf=Hd(i),e.gpuMemoryUsageInBytes=Mc(e.gltf)}else e.gltfArrayBuffer=t;return t.byteLength}(i,e,n,r);case Wp.INSTANCED_3D_MODEL:return await km(i,e,t,n,r);case Wp.POINT_CLOUD:return await Mm(i,e,t,n,r);default:throw new Error(`3DTileLoader: unknown type ${i.type}`)}}async function Bm(e,t,n,r){const i=Number.isFinite(t.bitstream)?t.bitstream:t.bufferView;if("number"!=typeof i)return;const a=e.bufferViews[i],o=e.buffers[a.buffer];if(!r?.baseUrl)throw new Error("Url is not provided");if(!r.fetch)throw new Error("fetch is not provided");if(o.uri){const e=`${r?.baseUrl||""}/${o.uri}`,n=await(await r.fetch(e)).arrayBuffer();return void(t.explicitBitstream=new Uint8Array(n,a.byteOffset,a.byteLength))}const s=e.buffers.slice(0,a.buffer).reduce((e,t)=>e+t.byteLength,0);t.explicitBitstream=new Uint8Array(n.slice(s,s+o.byteLength),a.byteOffset,a.byteLength)}function Om(e){const t=new DataView(e);return t.getUint32(0,!0)+2**32*t.getUint32(4,!0)}var Fm={dataType:null,batchType:null,id:"3d-tiles-subtree",name:"3D Tiles Subtree",module:"3d-tiles",version:Kp,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 r=Om(e.slice(8,16)),i=new Uint8Array(e,24,r),a=new TextDecoder("utf8").decode(i),o=JSON.parse(a),s=Om(e.slice(16,24));let A=new ArrayBuffer(0);if(s&&(A=e.slice(24+r)),await Bm(o,o.tileAvailability,A,n),Array.isArray(o.contentAvailability))for(const l of o.contentAvailability)await Bm(o,l,A,n);else await Bm(o,o.contentAvailability,A,n);return await Bm(o,o.childSubtreeAvailability,A,n),o},options:{}},Dm=null;try{Dm=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 Um(e,t,n){this.low=0|e,this.high=0|t,this.unsigned=!!n}function Vm(e){return!0===(e&&e.__isLong__)}function jm(e){var t=Math.clz32(e&-e);return e?31-t:t}Um.prototype.__isLong__,Object.defineProperty(Um.prototype,"__isLong__",{value:!0}),Um.isLong=Vm;var zm={},Gm={};function Hm(e,t){var n,r,i;return t?(i=0<=(e>>>=0)&&e<256)&&(r=Gm[e])?r:(n=Qm(e,0,!0),i&&(Gm[e]=n),n):(i=-128<=(e|=0)&&e<128)&&(r=zm[e])?r:(n=Qm(e,e<0?-1:0,!1),i&&(zm[e]=n),n)}function qm(e,t){if(isNaN(e))return t?tg:eg;if(t){if(e<0)return tg;if(e>=Ym)return og}else{if(e<=-Xm)return sg;if(e+1>=Xm)return ag}return e<0?qm(-e,t).neg():Qm(e%Jm|0,e/Jm|0,t)}function Qm(e,t,n){return new Um(e,t,n)}Um.fromInt=Hm,Um.fromNumber=qm,Um.fromBits=Qm;var Km=Math.pow;function Wm(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?tg:eg;if((n=n||10)<2||36<n)throw RangeError("radix");var r;if((r=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===r)return Wm(e.substring(1),t,n).neg();for(var i=qm(Km(n,8)),a=eg,o=0;o<e.length;o+=8){var s=Math.min(8,e.length-o),A=parseInt(e.substring(o,o+s),n);if(s<8){var l=qm(Km(n,s));a=a.mul(l).add(qm(A))}else a=(a=a.mul(i)).add(qm(A))}return a.unsigned=t,a}function $m(e,t){return"number"==typeof e?qm(e,t):"string"==typeof e?Wm(e,t):Qm(e.low,e.high,"boolean"==typeof t?t:e.unsigned)}Um.fromString=Wm,Um.fromValue=$m;var Jm=4294967296,Ym=Jm*Jm,Xm=Ym/2,Zm=Hm(1<<24),eg=Hm(0);Um.ZERO=eg;var tg=Hm(0,!0);Um.UZERO=tg;var ng=Hm(1);Um.ONE=ng;var rg=Hm(1,!0);Um.UONE=rg;var ig=Hm(-1);Um.NEG_ONE=ig;var ag=Qm(-1,2147483647,!1);Um.MAX_VALUE=ag;var og=Qm(-1,-1,!0);Um.MAX_UNSIGNED_VALUE=og;var sg=Qm(0,-2147483648,!1);Um.MIN_VALUE=sg;var Ag=Um.prototype;Ag.toInt=function(){return this.unsigned?this.low>>>0:this.low},Ag.toNumber=function(){return this.unsigned?(this.high>>>0)*Jm+(this.low>>>0):this.high*Jm+(this.low>>>0)},Ag.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(sg)){var t=qm(e),n=this.div(t),r=n.mul(t).sub(this);return n.toString(e)+r.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var i=qm(Km(e,6),this.unsigned),a=this,o="";;){var s=a.div(i),A=(a.sub(s.mul(i)).toInt()>>>0).toString(e);if((a=s).isZero())return A+o;for(;A.length<6;)A="0"+A;o=""+A+o}},Ag.getHighBits=function(){return this.high},Ag.getHighBitsUnsigned=function(){return this.high>>>0},Ag.getLowBits=function(){return this.low},Ag.getLowBitsUnsigned=function(){return this.low>>>0},Ag.getNumBitsAbs=function(){if(this.isNegative())return this.eq(sg)?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},Ag.isSafeInteger=function(){var e=this.high>>21;return!e||!this.unsigned&&(-1===e&&!(0===this.low&&-2097152===this.high))},Ag.isZero=function(){return 0===this.high&&0===this.low},Ag.eqz=Ag.isZero,Ag.isNegative=function(){return!this.unsigned&&this.high<0},Ag.isPositive=function(){return this.unsigned||this.high>=0},Ag.isOdd=function(){return!(1&~this.low)},Ag.isEven=function(){return!(1&this.low)},Ag.equals=function(e){return Vm(e)||(e=$m(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&(this.high===e.high&&this.low===e.low)},Ag.eq=Ag.equals,Ag.notEquals=function(e){return!this.eq(e)},Ag.neq=Ag.notEquals,Ag.ne=Ag.notEquals,Ag.lessThan=function(e){return this.comp(e)<0},Ag.lt=Ag.lessThan,Ag.lessThanOrEqual=function(e){return this.comp(e)<=0},Ag.lte=Ag.lessThanOrEqual,Ag.le=Ag.lessThanOrEqual,Ag.greaterThan=function(e){return this.comp(e)>0},Ag.gt=Ag.greaterThan,Ag.greaterThanOrEqual=function(e){return this.comp(e)>=0},Ag.gte=Ag.greaterThanOrEqual,Ag.ge=Ag.greaterThanOrEqual,Ag.compare=function(e){if(Vm(e)||(e=$m(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},Ag.comp=Ag.compare,Ag.negate=function(){return!this.unsigned&&this.eq(sg)?sg:this.not().add(ng)},Ag.neg=Ag.negate,Ag.add=function(e){Vm(e)||(e=$m(e));var t=this.high>>>16,n=65535&this.high,r=this.low>>>16,i=65535&this.low,a=e.high>>>16,o=65535&e.high,s=e.low>>>16,A=0,l=0,c=0,u=0;return c+=(u+=i+(65535&e.low))>>>16,l+=(c+=r+s)>>>16,A+=(l+=n+o)>>>16,A+=t+a,Qm((c&=65535)<<16|(u&=65535),(A&=65535)<<16|(l&=65535),this.unsigned)},Ag.subtract=function(e){return Vm(e)||(e=$m(e)),this.add(e.neg())},Ag.sub=Ag.subtract,Ag.multiply=function(e){if(this.isZero())return this;if(Vm(e)||(e=$m(e)),Dm)return Qm(Dm.mul(this.low,this.high,e.low,e.high),Dm.get_high(),this.unsigned);if(e.isZero())return this.unsigned?tg:eg;if(this.eq(sg))return e.isOdd()?sg:eg;if(e.eq(sg))return this.isOdd()?sg:eg;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(Zm)&&e.lt(Zm))return qm(this.toNumber()*e.toNumber(),this.unsigned);var t=this.high>>>16,n=65535&this.high,r=this.low>>>16,i=65535&this.low,a=e.high>>>16,o=65535&e.high,s=e.low>>>16,A=65535&e.low,l=0,c=0,u=0,f=0;return u+=(f+=i*A)>>>16,c+=(u+=r*A)>>>16,u&=65535,c+=(u+=i*s)>>>16,l+=(c+=n*A)>>>16,c&=65535,l+=(c+=r*s)>>>16,c&=65535,l+=(c+=i*o)>>>16,l+=t*A+n*s+r*o+i*a,Qm((u&=65535)<<16|(f&=65535),(l&=65535)<<16|(c&=65535),this.unsigned)},Ag.mul=Ag.multiply,Ag.divide=function(e){if(Vm(e)||(e=$m(e)),e.isZero())throw Error("division by zero");if(Dm)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?Qm((this.unsigned?Dm.div_u:Dm.div_s)(this.low,this.high,e.low,e.high),Dm.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?tg:eg;var t,n,r;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return tg;if(e.gt(this.shru(1)))return rg;r=tg}else{if(this.eq(sg))return e.eq(ng)||e.eq(ig)?sg:e.eq(sg)?ng:(t=this.shr(1).div(e).shl(1)).eq(eg)?e.isNegative()?ng:ig:(n=this.sub(e.mul(t)),r=t.add(n.div(e)));if(e.eq(sg))return this.unsigned?tg:eg;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=eg}for(n=this;n.gte(e);){t=Math.max(1,Math.floor(n.toNumber()/e.toNumber()));for(var i=Math.ceil(Math.log(t)/Math.LN2),a=i<=48?1:Km(2,i-48),o=qm(t),s=o.mul(e);s.isNegative()||s.gt(n);)s=(o=qm(t-=a,this.unsigned)).mul(e);o.isZero()&&(o=ng),r=r.add(o),n=n.sub(s)}return r},Ag.div=Ag.divide,Ag.modulo=function(e){return Vm(e)||(e=$m(e)),Dm?Qm((this.unsigned?Dm.rem_u:Dm.rem_s)(this.low,this.high,e.low,e.high),Dm.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},Ag.mod=Ag.modulo,Ag.rem=Ag.modulo,Ag.not=function(){return Qm(~this.low,~this.high,this.unsigned)},Ag.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},Ag.clz=Ag.countLeadingZeros,Ag.countTrailingZeros=function(){return this.low?jm(this.low):jm(this.high)+32},Ag.ctz=Ag.countTrailingZeros,Ag.and=function(e){return Vm(e)||(e=$m(e)),Qm(this.low&e.low,this.high&e.high,this.unsigned)},Ag.or=function(e){return Vm(e)||(e=$m(e)),Qm(this.low|e.low,this.high|e.high,this.unsigned)},Ag.xor=function(e){return Vm(e)||(e=$m(e)),Qm(this.low^e.low,this.high^e.high,this.unsigned)},Ag.shiftLeft=function(e){return Vm(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?Qm(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):Qm(0,this.low<<e-32,this.unsigned)},Ag.shl=Ag.shiftLeft,Ag.shiftRight=function(e){return Vm(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?Qm(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):Qm(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},Ag.shr=Ag.shiftRight,Ag.shiftRightUnsigned=function(e){return Vm(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?Qm(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):Qm(32===e?this.high:this.high>>>e-32,0,this.unsigned)},Ag.shru=Ag.shiftRightUnsigned,Ag.shr_u=Ag.shiftRightUnsigned,Ag.rotateLeft=function(e){var t;return Vm(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?Qm(this.high,this.low,this.unsigned):e<32?(t=32-e,Qm(this.low<<e|this.high>>>t,this.high<<e|this.low>>>t,this.unsigned)):(t=32-(e-=32),Qm(this.high<<e|this.low>>>t,this.low<<e|this.high>>>t,this.unsigned))},Ag.rotl=Ag.rotateLeft,Ag.rotateRight=function(e){var t;return Vm(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?Qm(this.high,this.low,this.unsigned):e<32?(t=32-e,Qm(this.high<<t|this.low>>>e,this.low<<t|this.high>>>e,this.unsigned)):(t=32-(e-=32),Qm(this.low<<t|this.high>>>e,this.high<<t|this.low>>>e,this.unsigned))},Ag.rotr=Ag.rotateRight,Ag.toSigned=function(){return this.unsigned?Qm(this.low,this.high,!1):this},Ag.toUnsigned=function(){return this.unsigned?this:Qm(this.low,this.high,!0)},Ag.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},Ag.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]},Ag.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]},Um.fromBytes=function(e,t,n){return n?Um.fromBytesLE(e,t):Um.fromBytesBE(e,t)},Um.fromBytesLE=function(e,t){return new Um(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},Um.fromBytesBE=function(e,t){return new Um(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&&(Um.fromBigInt=function(e,t){return Qm(Number(BigInt.asIntN(32,e)),Number(BigInt.asIntN(32,e>>BigInt(32))),t)},Um.fromValue=function(e,t){return"bigint"==typeof e?Um.fromBigInt(e,t):$m(e,t)},Ag.toBigInt=function(){var e=BigInt(this.low>>>0);return BigInt(this.unsigned?this.high>>>0:this.high)<<BigInt(32)|e});function lg(e){"X"===e&&(e="");const t=e.padEnd(16,"0");return Um.fromString(t,!0,16)}var cg=180/Math.PI;function ug(e,t,n){const r=1<<t;return[(e[0]+n[0])/r,(e[1]+n[1])/r]}function fg(e){return e>=.5?1/3*(4*e*e-1):1/3*(1-4*(1-e)*(1-e))}function dg(e){return[fg(e[0]),fg(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 pg([e,t,n]){const r=Math.atan2(n,Math.sqrt(e*e+t*t));return[Math.atan2(t,e)*cg,r*cg]}function mg(e,t,n,r){if(0===r){1===n&&(t[0]=e-1-t[0],t[1]=e-1-t[1]);const r=t[0];t[0]=t[1],t[1]=r}}function gg(e){const{face:t,ij:n,level:r}=e,i=[[0,0],[0,1],[1,1],[1,0],[0,0]],a=Math.max(1,Math.ceil(100*Math.pow(2,-r))),o=new Float64Array(4*a*2+2);let s=0,A=0;for(let l=0;l<4;l++){const e=i[l].slice(0),c=i[l+1],u=(c[0]-e[0])/a,f=(c[1]-e[1])/a;for(let i=0;i<a;i++){e[0]+=u,e[1]+=f;const i=pg(hg(t,dg(ug(n,r,e))));Math.abs(i[1])>89.999&&(i[0]=A);const a=i[0]-A;i[0]+=a>180?-360:a<-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 bg(e){const t=function(e){if(e.indexOf("/")>0)return e;const t=lg(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"),r=t.substring(0,3),i=t.substring(3,n),a=i.length/2,o=Um.fromString(r,!0,2).toString(10);let s="";if(0!==a)for(s=Um.fromString(i,!0,2).toString(4);s.length<a;)s="0"+s;return`${o}/${s}`}(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),r=t[1],i=r.length;let a=0;const o=[0,0];for(let s=i-1;s>=0;s--){a=i-s;const e=r[s];let t=0,n=0;"1"===e?n=1:"2"===e?(t=1,n=1):"3"===e&&(t=1);const A=Math.pow(2,a-1);mg(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:a}}(t)}function vg(e){return function(e){const t=dg(ug(e.ij,e.level,[.5,.5]));return pg(hg(e.face,t))}(bg(e))}function yg(e){if(e.length%2!=0)throw new Error("Invalid corners");const t=[],n=[];for(let r=0;r<e.length;r+=2)t.push(e[r]),n.push(e[r+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 xg(e,t){const r=t?.minimumHeight||0,i=t?.maximumHeight||0,a=function(e){let t;if(2===e.face||5===e.face){let n=null,r=0;for(let t=0;t<4;t++){const i=gg(bg(`${e.face}/${t}`));null==n&&(n=new Float64Array(4*i.length)),n.set(i,r),r+=i.length}t=yg(n)}else t=yg(gg(e));return t}(bg(e)),o=a.west,s=a.south,A=a.east,l=a.north,c=[];return c.push(new n.Vector3(o,l,r)),c.push(new n.Vector3(A,l,r)),c.push(new n.Vector3(A,s,r)),c.push(new n.Vector3(o,s,r)),c.push(new n.Vector3(o,l,i)),c.push(new n.Vector3(A,l,i)),c.push(new n.Vector3(A,s,i)),c.push(new n.Vector3(o,s,i)),c}function _g(e){const t=e.token,r={minimumHeight:e.minimumHeight,maximumHeight:e.maximumHeight},i=xg(t,r),a=vg(t),o=a[0],s=a[1],A=Eh.WGS84.cartographicToCartesian([o,s,r.maximumHeight]),l=new n.Vector3(A[0],A[1],A[2]);i.push(l);const c=aA(i);return[...c.center,...c.halfAxes]}var wg={QUADTREE:4,OCTREE:8};function Tg(e,t,n){if(e?.box){const r=function(e,t){const n=function(e){return e.and(e.not().add(1))}(e).shiftRightUnsigned(2);return e.add(Um.fromNumber(2*t+1-4).multiply(n))}(lg(e.s2VolumeInfo.token),t),i=function(e){if(e.isZero())return"X";let t=e.countTrailingZeros();t=(t-t%4)/4;const n=t;t*=4;const r=e.shiftRightUnsigned(t).toString(16).replace(/0+$/,"");return Array(17-n-r.length).join("0")+r}(r),a={...e.s2VolumeInfo};if(a.token=i,"OCTREE"===n){const t=e.s2VolumeInfo,n=t.maximumHeight-t.minimumHeight,r=n/2,i=t.minimumHeight+n/2;t.minimumHeight=i-r,t.maximumHeight=i+r}return{box:_g(a),s2VolumeInfo:a}}}async function Sg(e){const{subtree:t,subtreeData:r={level:0,x:0,y:0,z:0},parentData:i={mortonIndex:0,localLevel:-1,localX:0,localY:0,localZ:0},childIndex:a=0,implicitOptions:o,loaderOptions:s,s2VolumeBox:l}=e,{subdivisionScheme:c,subtreeLevels:u,maximumLevel:f,contentUrlTemplate:d,subtreesUriTemplate:h,basePath:p}=o,m={children:[],lodMetricValue:0,contentUrl:""};if("number"!=typeof f||!Number.isFinite(f))return A.once(`Missing 'maximumLevel' or 'availableLevels' property. The subtree ${d} won't be loaded...`),m;const g=i.localLevel+1,b=r.level+g;if(b>f)return m;const v=wg[c],y=Math.log2(v),x=1&a,_=a>>1&1,w=a>>2&1,T=Eg(i.localX,x,1),S=Eg(i.localY,_,1),M=Eg(i.localZ,w,1),E=Eg(r.x,T,g),C=Eg(r.y,S,g),I=Eg(r.z,M,g),R=Eg(i.mortonIndex,a,y);let P,N,k,L;if(g===u&&Mg(t.childSubtreeAvailability,R)){const e=Cg(`${p}/${h}`,b,E,C,I);P=await n.load(e,Fm,s),L=0,N={level:b,x:E,y:C,z:I},k={mortonIndex:0,localLevel:0,localX:0,localY:0,localZ:0}}else P=t,L=(v**g-1)/(v-1)+R,N=r,k={mortonIndex:R,localLevel:g,localX:T,localY:S,localZ:M};if(!Mg(P.tileAvailability,L))return m;Mg(P.contentAvailability,L)&&(m.contentUrl=Cg(d,b,E,C,I));for(let n=0;n<v;n++){const e=Tg(l,n,c),t=await Sg({subtree:P,subtreeData:N,parentData:k,childIndex:n,implicitOptions:o,loaderOptions:s,s2VolumeBox:e});(t.contentUrl||t.children.length)&&m.children.push(t)}return m.contentUrl||m.children.length?function(e,t,n,r){const{basePath:i,refine:a,getRefine:o,lodMetricType:s,getTileType:A,rootLodMetricValue:l,rootBoundingVolume:c}=n,u=e.contentUrl&&e.contentUrl.replace(`${i}/`,""),f=l/2**t.level,d=function(e,t,n){if(e.region){const{level:r,x:i,y:a,z:o}=t,[s,A,l,c,u,f]=e.region,d=2**r,h=(l-s)/d,[p,m]=[s+h*i,s+h*(i+1)],g=(c-A)/d,[b,v]=[A+g*a,A+g*(a+1)];let y,x;if("OCTREE"===n){const e=(f-u)/d;[y,x]=[u+e*o,u+e*(o+1)]}else[y,x]=[u,f];return{region:[p,b,m,v,y,x]}}if(e.box)return e;throw new Error(`Unsupported bounding volume type ${JSON.stringify(e)}`)}(r?.box?{box:r.box}:c,t,n.subdivisionScheme);return{children:e.children,contentUrl:e.contentUrl,content:{uri:u},id:e.contentUrl,refine:o(a),type:A(e),lodMetricType:s,lodMetricValue:f,geometricError:f,transform:e.transform,boundingVolume:d}}(m,{level:b,x:E,y:C,z:I},o,l):m}function Mg(e,t){let n;return Array.isArray(e)?(n=e[0],e.length>1&&A.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),r=e%8;return 1==(t[n]>>r&1)}(t,n.explicitBitstream)}function Eg(e,t,n){return(e<<n)+t}function Cg(e,t,n,r,i){const a=function(e){const t={};for(const n in e)t[`{${n}}`]=e[n];return t}({level:t,x:n,y:r,z:i});return e.replace(/{level}|{x}|{y}|{z}/gi,e=>a[e])}function Ig(e,t=""){if(!t)return Hh.EMPTY;const n=t.split("?")[0].split(".").pop();switch(n){case"pnts":return Hh.POINTCLOUD;case"i3dm":case"b3dm":case"glb":case"gltf":return Hh.SCENEGRAPH;default:return n||Hh.EMPTY}}function Rg(e){switch(e){case"REPLACE":case"replace":return Gh.REPLACE;case"ADD":case"add":return Gh.ADD;default:return e}}function Pg(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:n.resolve(t,e)}function Ng(e,t){if(!e)return null;let n;if(e.content){const r=e.content.uri||e.content?.url;void 0!==r&&(n=Pg(r,t))}return{...e,id:n,contentUrl:n,lodMetricType:Qh.GEOMETRIC_ERROR,lodMetricValue:e.geometricError,transformMatrix:e.transform,type:Ig(0,n),refine:Rg(e.refine)}}async function kg(e,t,r,i,a){const{subdivisionScheme:o,maximumLevel:s,availableLevels:A,subtreeLevels:l,subtrees:{uri:c}}=i,u=Pg(Cg(c,0,0,0,0),r),f=await n.load(u,Fm,a),d=e.content?.uri,h=d?Pg(d,r):"",p=t?.root?.refine,m=e.geometricError,g=e.boundingVolume.extensions?.["3DTILES_bounding_volume_S2"];g&&(e.boundingVolume={box:_g(g),s2VolumeInfo:g});const b=e.boundingVolume;return await async function(e,t,n,r,i){if(!e)return null;const{children:a,contentUrl:o}=await Sg({subtree:n,implicitOptions:r,loaderOptions:i});let s,A=null;o&&(s=o,A={uri:o.replace(`${t}/`,"")});return{...e,id:s,contentUrl:s,lodMetricType:Qh.GEOMETRIC_ERROR,lodMetricValue:e.geometricError,transformMatrix:e.transform,type:Ig(0,s),refine:Rg(e.refine),content:A||e.content,children:a}}(e,r,f,{contentUrlTemplate:h,subtreesUriTemplate:c,subdivisionScheme:o,subtreeLevels:l,maximumLevel:Number.isFinite(A)?A-1:s,refine:p,basePath:r,lodMetricType:Qh.GEOMETRIC_ERROR,rootLodMetricValue:m,rootBoundingVolume:b,getTileType:Ig,getRefine:Rg},a)}function Lg(e){return e?.extensions?.["3DTILES_implicit_tiling"]||e?.implicitTiling}var Bg={dataType:null,batchType:null,id:"3d-tiles",name:"3D Tiles",module:"3d-tiles",version:Kp,extensions:["cmpt","pnts","b3dm","i3dm"],mimeTypes:["application/octet-stream"],tests:["cmpt","pnts","b3dm","i3dm"],parse:async function(e,t={},r){const i=t["3d-tiles"]||{};let a;a="auto"===i.isTileset?r?.url&&-1!==r.url.indexOf(".json"):i.isTileset;return a?async function(e,t,r){const i=JSON.parse((new TextDecoder).decode(e)),a=r?.url||"",o=function(e){return n.dirname(e)}(a),s=await async function(e,t,n){let r=null;const i=Lg(e.root);r=i&&e.root?await kg(e.root,e,t,i,n):Ng(e.root,t);const a=[];for(a.push(r);a.length>0;){const r=a.pop()||{},i=r.children||[],o=[];for(const s of i){const r=Lg(s);let i;i=r?await kg(s,e,t,r,n):Ng(s,t),i&&(o.push(i),a.push(i))}r.children=o}return r}(i,o,t||{});return{...i,shape:"tileset3d",loader:Bg,url:a,queryString:r?.queryString||"",basePath:o,root:s||i.root,type:qh.TILES3D,lodMetricType:Qh.GEOMETRIC_ERROR,lodMetricValue:i.root?.geometricError||0}}(e,t,r):async function(e,t,n){const r={content:{shape:"tile3d",featureIds:null}};return await Lm(e,0,t,n,r.content),r.content}(e,t,r)},options:{"3d-tiles":{loadGLTF:!0,decodeQuantizedPositions:!1,isTileset:"auto",assetGltfUpAxis:null}}};var Og=[0],Fg={[-1]:n.COORDINATE_SYSTEM.DEFAULT,0:n.COORDINATE_SYSTEM.CARTESIAN,1:n.COORDINATE_SYSTEM.LNGLAT,2:n.COORDINATE_SYSTEM.METER_OFFSETS,3:n.COORDINATE_SYSTEM.LNGLAT_OFFSETS};function Dg(e){return"number"==typeof e?Fg[e]??e:e}var Ug={getPointColor:{type:"accessor",value:[0,0,0,255]},pointSize:1,data:"",loader:Bg,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]}},Vg=class extends t.CompositeLayer{initializeState(){"onTileLoadFail"in this.props&&n.defaultLogger.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 r=n?.[e.id];r&&e.equals(r)||(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:r}){const{tile:i}=e.props,{id:a}=t;if(!i.selected||!i.viewportIds.includes(a))return!1;if(r&&n&&i.content?.cartographicOrigin){const[e,r]=t.project(i.content.cartographicOrigin),a=n.x+n.width/2,o=n.y+n.height/2,s=Math.max(t.width,t.height)/4,A=e-a,l=r-o;if(A*A+l*l>s*s)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||{},r=this.props.loaders?.length?this.props.loaders:this.props.loader,i=Array.isArray(r)?r[0]:r,{tileset:a,...o}=t,s={loadOptions:{...o},...a};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 l=await n.load(A,i,s.loadOptions),c=new Qp(l,{onTileLoad:this._onTileLoad.bind(this),onTileUnload:this._onTileUnload.bind(this),onTileError:this.props.onTileError,onUpdate:()=>this.setNeedsUpdate(),...s});this.setState({tileset3d:c,layerMap:{}}),this._updateTileset(this.state.activeViewports),this.props.onTilesetLoad(c)}_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,r=Object.keys(e).length;n&&r&&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 Hh.POINTCLOUD:return this._makePointCloudLayer(e,t);case Hh.SCENEGRAPH:return this._make3DModelLayer(e);case Hh.MESH:return this._makeSimpleMeshLayer(e,t);default:throw new Error(`Tile3DLayer: Failed to render layer of type ${e.content.type}`)}}_makePointCloudLayer(e,r){const{attributes:i,pointCount:a,constantRGBA:o,cartographicOrigin:s,modelMatrix:A}=e.content,{positions:l,normals:c,colors:u}=i;if(!l)return null;const f=r&&r.props.data||{header:{vertexCount:a},attributes:{POSITION:l,NORMAL:c,COLOR_0:u}},{pointSize:d,getPointColor:h}=this.props;return new(this.getSubLayerClass("pointcloud",t.PointCloudLayer))({pointSize:d},this.getSubLayerProps({id:"pointcloud"}),{id:`${this.id}-pointcloud-${e.id}`,tile:e,data:f,coordinateSystem:n.COORDINATE_SYSTEM.METER_OFFSETS,coordinateOrigin:s,modelMatrix:A,getColor:o||h,_offset:0})}_make3DModelLayer(e){const{gltf:t,instances:r,cartographicOrigin:i,modelMatrix:a}=e.content;return new(this.getSubLayerClass("scenegraph",Xd))({_lighting:"pbr"},this.getSubLayerProps({id:"scenegraph"}),{id:`${this.id}-scenegraph-${e.id}`,tile:e,data:r||Og,scenegraph:t,coordinateSystem:n.COORDINATE_SYSTEM.METER_OFFSETS,coordinateOrigin:i,modelMatrix:a,getTransformMatrix:e=>e.modelMatrix,getPosition:[0,0,0],_offset:0,onFirstDraw:()=>{e.tileDrawn=!0}})}_makeSimpleMeshLayer(e,r){const{attributes:i,indices:a,modelMatrix:o,cartographicOrigin:s,coordinateSystem:A=n.COORDINATE_SYSTEM.METER_OFFSETS,material:l,featureIds:c}=e.content,{_getMeshColor:u}=this.props,f=r&&r.props.mesh||new t.Geometry({topology:"triangle-list",attributes:jg(i),indices:a});return new(this.getSubLayerClass("mesh",rh))(this.getSubLayerProps({id:"mesh"}),{id:`${this.id}-mesh-${e.id}`,tile:e,mesh:f,data:Og,getColor:u(e),pbrMaterial:l,modelMatrix:o,coordinateOrigin:s,coordinateSystem:Dg(A),featureIds:c,_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:r}=n;return e.selected&&(r?n.needsUpdate&&(r=this._getSubLayer(e,r),n.needsUpdate=!1):r=this._getSubLayer(e)),n.layer=r,r}).filter(Boolean):null}};function jg(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}Vg.defaultProps=Ug,Vg.layerName="Tile3DLayer";var zg={dataType:null,batchType:null,name:"Terrain",id:"terrain",module:"terrain",version:"4.5.4",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}}},Gg=[1],Hg={...BA.defaultProps,elevationData:dA,texture:{...dA,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:[zg]};function qg(e){return Array.isArray(e)?e.join(";"):e||""}var Qg=class extends t.CompositeLayer{updateState({props:e,oldProps:t}){const r=e.elevationData!==t.elevationData;if(r){const{elevationData:t}=e,n=t&&(Array.isArray(t)||Kg(t));this.setState({isTiled:n})}const i=r||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&&n.defaultLogger.removed("workerUrl","loadOptions.terrain.workerUrl")()}loadTerrain({elevationData:e,bounds:t,elevationDecoder:n,meshMaxError:r,signal:i}){if(!e)return null;const a=function(e){return!Number.isFinite(e)||e<=0?1:Math.max(e,1)}(r);let o=this.getLoadOptions();o={...o,terrain:{skirtHeight:this.state.isTiled?2*a:0,...o?.terrain,bounds:t,meshMaxError:a,elevationDecoder:n}};const{fetch:s}=this.props;return s(e,{propName:"elevationData",layer:this,loadOptions:o,signal:i})}getTiledTerrainData(e){const{elevationData:t,fetch:n,texture:i,elevationDecoder:a,meshMaxError:o}=this.props,{viewport:s}=this.context,A=pA(t,e),l=i&&pA(i,e),{signal:c}=e;let u=[0,0],f=[0,0];if(s.isGeospatial){const t=e.bbox;u=s.projectFlat([t.west,t.south]),f=s.projectFlat([t.east,t.north])}else{const t=e.bbox;u=[t.left,t.bottom],f=[t.right,t.top]}const d=function(e,t,n){const r=(e[2]-e[0])/t*1,i=(e[3]-e[1])/t*1,a=[e[0]-r,e[1]-i,e[2]+r,e[3]+i];return n?[Math.max(a[0],-180),Math.max(a[1],-90),Math.min(a[2],180),Math.min(a[3],90)]:a}([u[0],u[1],f[0],f[1]],this.props.tileSize,s instanceof r.GlobeViewport),h=this.loadTerrain({elevationData:A,bounds:d,elevationDecoder:a,meshMaxError:o,signal:c}),p=l?n(l,{propName:"texture",layer:this,loaders:[],signal:c}).catch(e=>null):Promise.resolve(null);return Promise.all([h,p])}renderSubLayers(e){const t=this.getSubLayerClass("mesh",nl),{color:i,wireframe:a,material:o}=this.props,{data:s}=e;if(!s)return null;const[A,l]=s,{viewport:c}=this.context,u=c instanceof r.GlobeViewport,f=A?.header?.boundingBox,d=f&&f.every(([e,t])=>e>=-180&&e<=180&&t>=-90&&t<=90),h=u&&d?n.COORDINATE_SYSTEM.LNGLAT:n.COORDINATE_SYSTEM.CARTESIAN;return new t(e,{data:Gg,mesh:A,texture:l,_instanced:!1,coordinateSystem:h,getPosition:e=>[0,0,0],getColor:i,wireframe:a,material:o})}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 r=Math.min(...n.map(e=>e[0])),i=Math.max(...n.map(e=>e[1]));(!t||r<t[0]||i>t[1])&&this.setState({zRange:[r,i]})}renderLayers(){const{color:e,material:t,elevationData:n,texture:r,wireframe:i,meshMaxError:a,elevationDecoder:o,tileSize:s,maxZoom:A,minZoom:l,extent:c,maxRequests:u,onTileLoad:f,onTileUnload:d,onTileError:h,maxCacheSize:p,maxCacheByteSize:m,refinementStrategy:g,zoomOffset:b}=this.props;return this.state.isTiled?new BA(this.getSubLayerProps({id:"tiles"}),{getTileData:this.getTiledTerrainData.bind(this),renderSubLayers:this.renderSubLayers.bind(this),updateTriggers:{getTileData:{elevationData:qg(n),texture:qg(r),meshMaxError:a,elevationDecoder:o,projectionMode:this.context.viewport.projectionMode,zoomOffset:b}},onViewportLoad:this.onViewportLoad.bind(this),zRange:this.state.zRange||null,tileSize:s,maxZoom:A,minZoom:l,extent:c,maxRequests:u,onTileLoad:f,onTileUnload:d,onTileError:h,maxCacheSize:p,maxCacheByteSize:m,refinementStrategy:g,zoomOffset:b}):n?new(this.getSubLayerClass("mesh",nl))(this.getSubLayerProps({id:"mesh"}),{data:Gg,mesh:this.state.terrain,texture:r,_instanced:!1,getPosition:e=>[0,0,0],getColor:e,material:t,wireframe:i}):null}};Qg.defaultProps=Hg,Qg.layerName="TerrainLayer";var Kg=e=>e.includes("{x}")&&(e.includes("{y}")||e.includes("{-y}")),Wg="\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",$g={name:"clip",vs:Wg,uniformTypes:{bounds:"vec4<f32>"}},Jg={"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"},Yg={name:"clip",fs:Wg,uniformTypes:{bounds:"vec4<f32>"}},Xg={"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"},Zg=class extends Le{getShaders(){let e="instancePositions"in this.getAttributeManager().attributes;return void 0!==this.props.clipByInstance&&(e=Boolean(this.props.clipByInstance)),this.state.clipByInstance=e,"webgpu"===this.context.device.type?{}:e?{modules:[$g],inject:Jg}:{modules:[Yg],inject:Xg}}draw(){const{clipBounds:e}=this.props,t={};if(this.state.clipByInstance)t.bounds=e;else{const n=this.projectPosition([e[0],e[1],0]),r=this.projectPosition([e[2],e[3],0]);t.bounds=[Math.min(n[0],r[0]),Math.min(n[1],r[1]),Math.max(n[0],r[0]),Math.max(n[1],r[1])]}"webgpu"===this.context.device.type&&(t.enabled=!0,t.mode=this.state.clipByInstance?"instance":"geometry"),this.setShaderModuleProps({clip:t})}};function eb(e,t,n){switch(e.type){case"Point":return function(e,t,n){const{positions:r}=e,i=nb(r,t,n);return i.length>1?{type:"MultiPoint",coordinates:i}:{type:"Point",coordinates:i[0]}}(e,t,n);case"LineString":return function(e,t=-1/0,n=1/0){const{positions:r}=e,i=e.pathIndices.value.filter(e=>e>=t&&e<=n);if(!(i.length>2))return{type:"LineString",coordinates:nb(r,i[0],i[1])};const a=[];for(let o=0;o<i.length-1;o++){const e=nb(r,i[o],i[o+1]);a.push(e)}return{type:"MultiLineString",coordinates:a}}(e,t,n);case"Polygon":return tb(e,t,n);default:throw new Error(`Unsupported geometry type: ${e?.type}`)}}function tb(e,t=-1/0,n=1/0){const{positions:r}=e,i=e.polygonIndices.value.filter(e=>e>=t&&e<=n),a=e.primitivePolygonIndices.value.filter(e=>e>=t&&e<=n);if(!(i.length>2)){const e=[];for(let t=0;t<a.length-1;t++){const n=nb(r,a[t],a[t+1]);e.push(n)}return{type:"Polygon",coordinates:e}}const o=[];for(let s=0;s<i.length-1;s++){const t=tb(e,i[s],i[s+1]).coordinates;o.push(t)}return{type:"MultiPolygon",coordinates:o}}function nb(e,t,n){t=t||0,n=n||e.value.length/e.size;const r=[];for(let i=t;i<n;i++){const t=Array();for(let n=i*e.size;n<(i+1)*e.size;n++)t.push(Number(e.value[n]));r.push(t)}return r}function rb(e,t,n){const r=function(e){const t={};for(const n of e)if(n.properties)for(const e in n.properties){const r=n.properties[e];t[e]=ub(r,t[e])}return t}(e),i=Object.keys(r).filter(e=>r[e]!==Array);return function(e,t,n){const{pointPositionsCount:r,pointFeaturesCount:i,linePositionsCount:a,linePathsCount:o,lineFeaturesCount:s,polygonPositionsCount:A,polygonObjectsCount:l,polygonRingsCount:c,polygonFeaturesCount:u,propArrayTypes:f,coordLength:d}=t,{numericPropKeys:h=[],PositionDataType:p=Float32Array,triangulate:m=!0}=n,g=e[0]&&"id"in e[0],b=e.length>65535?Uint32Array:Uint16Array,v={type:"Point",positions:new p(r*d),globalFeatureIds:new b(r),featureIds:i>65535?new Uint32Array(r):new Uint16Array(r),numericProps:{},properties:[],fields:[]},y={type:"LineString",pathIndices:a>65535?new Uint32Array(o+1):new Uint16Array(o+1),positions:new p(a*d),globalFeatureIds:new b(a),featureIds:s>65535?new Uint32Array(a):new Uint16Array(a),numericProps:{},properties:[],fields:[]},x={type:"Polygon",polygonIndices:A>65535?new Uint32Array(l+1):new Uint16Array(l+1),primitivePolygonIndices:A>65535?new Uint32Array(c+1):new Uint16Array(c+1),positions:new p(A*d),globalFeatureIds:new b(A),featureIds:u>65535?new Uint32Array(A):new Uint16Array(A),numericProps:{},properties:[],fields:[]};m&&(x.triangles=[]);for(const w of[v,y,x])for(const e of h){const t=f[e];w.numericProps[e]=new t(w.positions.length/d)}y.pathIndices[o]=a,x.polygonIndices[l]=A,x.primitivePolygonIndices[c]=A;const _={pointPosition:0,pointFeature:0,linePosition:0,linePath:0,lineFeature:0,polygonPosition:0,polygonObject:0,polygonRing:0,polygonFeature:0,feature:0};for(const w of e){const e=w.geometry,t=w.properties||{};switch(e.type){case"Point":ib(e,v,_,d,t),v.properties.push(cb(t,h)),g&&v.fields.push({id:w.id}),_.pointFeature++;break;case"LineString":ab(e,y,_,d,t),y.properties.push(cb(t,h)),g&&y.fields.push({id:w.id}),_.lineFeature++;break;case"Polygon":ob(e,x,_,d,t),x.properties.push(cb(t,h)),g&&x.fields.push({id:w.id}),_.polygonFeature++;break;default:throw new Error("Invalid geometry type")}_.feature++}return function(e,t,n,r){const i={shape:"binary-feature-collection",points:{...e,positions:{value:e.positions,size:r},globalFeatureIds:{value:e.globalFeatureIds,size:1},featureIds:{value:e.featureIds,size:1},numericProps:Ab(e.numericProps,1)},lines:{...t,positions:{value:t.positions,size:r},pathIndices:{value:t.pathIndices,size:1},globalFeatureIds:{value:t.globalFeatureIds,size:1},featureIds:{value:t.featureIds,size:1},numericProps:Ab(t.numericProps,1)},polygons:{...n,positions:{value:n.positions,size:r},polygonIndices:{value:n.polygonIndices,size:1},primitivePolygonIndices:{value:n.primitivePolygonIndices,size:1},globalFeatureIds:{value:n.globalFeatureIds,size:1},featureIds:{value:n.featureIds,size:1},numericProps:Ab(n.numericProps,1)}};i.polygons&&n.triangles&&(i.polygons.triangles={value:new Uint32Array(n.triangles),size:1});return i}(v,y,x,d)}(e,{propArrayTypes:r,...t},{numericPropKeys:n&&n.numericPropKeys||i,PositionDataType:n?n.PositionDataType:Float32Array,triangulate:!n||n.triangulate})}function ib(e,t,n,r,i){t.positions.set(e.data,n.pointPosition*r);const a=e.data.length/r;lb(t,i,n.pointPosition,a),t.globalFeatureIds.fill(n.feature,n.pointPosition,n.pointPosition+a),t.featureIds.fill(n.pointFeature,n.pointPosition,n.pointPosition+a),n.pointPosition+=a}function ab(e,t,n,r,i){t.positions.set(e.data,n.linePosition*r);const a=e.data.length/r;lb(t,i,n.linePosition,a),t.globalFeatureIds.fill(n.feature,n.linePosition,n.linePosition+a),t.featureIds.fill(n.lineFeature,n.linePosition,n.linePosition+a);for(let o=0,s=e.indices.length;o<s;++o){const i=e.indices[o],a=o===s-1?e.data.length:e.indices[o+1];t.pathIndices[n.linePath++]=n.linePosition,n.linePosition+=(a-i)/r}}function ob(e,t,n,r,i){t.positions.set(e.data,n.polygonPosition*r);const a=e.data.length/r;lb(t,i,n.polygonPosition,a),t.globalFeatureIds.fill(n.feature,n.polygonPosition,n.polygonPosition+a),t.featureIds.fill(n.polygonFeature,n.polygonPosition,n.polygonPosition+a);for(let o=0,s=e.indices.length;o<s;++o){const i=n.polygonPosition;t.polygonIndices[n.polygonObject++]=i;const a=e.areas[o],s=e.indices[o],A=e.indices[o+1];for(let o=0,l=s.length;o<l;++o){const i=s[o],a=o===l-1?void 0===A?e.data.length:A[0]:s[o+1];t.primitivePolygonIndices[n.polygonRing++]=n.polygonPosition,n.polygonPosition+=(a-i)/r}sb(t,a,s,{startPosition:i,endPosition:n.polygonPosition,coordLength:r})}}function sb(e,t,n,{startPosition:r,endPosition:i,coordLength:a}){if(!e.triangles)return;const o=r*a,s=i*a,A=e.positions.subarray(o,s),l=n[0],c=Be(A,n.slice(1).map(e=>(e-l)/a),a,t);for(let u=0,f=c.length;u<f;++u)e.triangles.push(r+c[u])}function Ab(e,t){const n={};for(const r in e)n[r]={value:e[r],size:t};return n}function lb(e,t,n,r){for(const i in e.numericProps)if(i in t){const a=t[i];e.numericProps[i].fill(a,n,n+r)}}function cb(e,t){const n={};for(const r in e)t.includes(r)||(n[r]=e[r]);return n}function ub(e,t){return t!==Array&&Number.isFinite(e)?t===Float64Array||Math.fround(e)!==e?Float64Array:Float32Array:Array}function fb(e,t){const n=t?.globalFeatureId;return void 0!==n?function(e,t){const n=db(e);for(const r of n){let e=0,n=r.featureIds.value[0];for(let i=0;i<r.featureIds.value.length;i++){const a=r.featureIds.value[i];if(a!==n){if(t===r.globalFeatureIds.value[e])return hb(r,e,i);e=i,n=a}}if(t===r.globalFeatureIds.value[e])return hb(r,e,r.featureIds.value.length)}throw new Error(`featureId:${t} not found`)}(e,n):function(e,t){return function(e){const t=[];for(const n of e){if(0===n.featureIds.value.length)continue;let e=0,r=n.featureIds.value[0];for(let i=0;i<n.featureIds.value.length;i++){const a=n.featureIds.value[i];a!==r&&(t.push(hb(n,e,i)),e=i,r=a)}t.push(hb(n,e,n.featureIds.value.length))}return t}(db(e,t))}(e,t?.type)}function db(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 hb(e,t,n){return{type:"Feature",geometry:eb(e,t,n),properties:mb(e,t,n),...pb(e,t,n)}}function pb(e,t=0,n){return e.fields&&e.fields[e.featureIds.value[t]]}function mb(e,t=0,n){const r=Object.assign({},e.properties[e.featureIds.value[t]]);for(const i in e.numericProps)r[i]=e.numericProps[i].value[t];return r}Zg.defaultProps={clipBounds:[0,0,1,1],clipByInstance:void 0},Zg.extensionName="ClipExtension";var gb=e.__commonJSMin(e=>{e.read=function(e,t,n,r,i){var a,o,s=8*i-r-1,A=(1<<s)-1,l=A>>1,c=-7,u=n?i-1:0,f=n?-1:1,d=e[t+u];for(u+=f,a=d&(1<<-c)-1,d>>=-c,c+=s;c>0;a=256*a+e[t+u],u+=f,c-=8);for(o=a&(1<<-c)-1,a>>=-c,c+=r;c>0;o=256*o+e[t+u],u+=f,c-=8);if(0===a)a=1-l;else{if(a===A)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,r),a-=l}return(d?-1:1)*o*Math.pow(2,a-r)},e.write=function(e,t,n,r,i,a){var o,s,A,l=8*a-i-1,c=(1<<l)-1,u=c>>1,f=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:a-1,h=r?1:-1,p=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,o=c):(o=Math.floor(Math.log(t)/Math.LN2),t*(A=Math.pow(2,-o))<1&&(o--,A*=2),(t+=o+u>=1?f/A:f*Math.pow(2,1-u))*A>=2&&(o++,A/=2),o+u>=c?(s=0,o=c):o+u>=1?(s=(t*A-1)*Math.pow(2,i),o+=u):(s=t*Math.pow(2,u-1)*Math.pow(2,i),o=0));i>=8;e[n+d]=255&s,d+=h,s/=256,i-=8);for(o=o<<i|s,l+=i;l>0;e[n+d]=255&o,d+=h,o/=256,l-=8);e[n+d-h]|=128*p}}),bb=e.__commonJSMin((e,t)=>{t.exports=r;var n=gb();function r(e){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(e)?e:new Uint8Array(e||0),this.pos=0,this.type=0,this.length=this.buf.length}r.Varint=0,r.Fixed64=1,r.Bytes=2,r.Fixed32=5;var i=4294967296,a=1/i,o="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");function s(e){return e.type===r.Bytes?e.readVarint()+e.pos:e.pos+1}function A(e,t,n){return n?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function l(e,t,n){var r=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));n.realloc(r);for(var i=n.pos-1;i>=e;i--)n.buf[i+r]=n.buf[i]}function c(e,t){for(var n=0;n<e.length;n++)t.writeVarint(e[n])}function u(e,t){for(var n=0;n<e.length;n++)t.writeSVarint(e[n])}function f(e,t){for(var n=0;n<e.length;n++)t.writeFloat(e[n])}function d(e,t){for(var n=0;n<e.length;n++)t.writeDouble(e[n])}function h(e,t){for(var n=0;n<e.length;n++)t.writeBoolean(e[n])}function p(e,t){for(var n=0;n<e.length;n++)t.writeFixed32(e[n])}function m(e,t){for(var n=0;n<e.length;n++)t.writeSFixed32(e[n])}function g(e,t){for(var n=0;n<e.length;n++)t.writeFixed64(e[n])}function b(e,t){for(var n=0;n<e.length;n++)t.writeSFixed64(e[n])}function v(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+16777216*e[t+3]}function y(e,t,n){e[n]=t,e[n+1]=t>>>8,e[n+2]=t>>>16,e[n+3]=t>>>24}function x(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+(e[t+3]<<24)}r.prototype={destroy:function(){this.buf=null},readFields:function(e,t,n){for(n=n||this.length;this.pos<n;){var r=this.readVarint(),i=r>>3,a=this.pos;this.type=7&r,e(i,t,this),this.pos===a&&this.skip(r)}return t},readMessage:function(e,t){return this.readFields(e,t,this.readVarint()+this.pos)},readFixed32:function(){var e=v(this.buf,this.pos);return this.pos+=4,e},readSFixed32:function(){var e=x(this.buf,this.pos);return this.pos+=4,e},readFixed64:function(){var e=v(this.buf,this.pos)+v(this.buf,this.pos+4)*i;return this.pos+=8,e},readSFixed64:function(){var e=v(this.buf,this.pos)+x(this.buf,this.pos+4)*i;return this.pos+=8,e},readFloat:function(){var e=n.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=n.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(e){var t,n=this.buf,r=n[this.pos++];return t=127&r,r<128?t:(t|=(127&(r=n[this.pos++]))<<7,r<128?t:(t|=(127&(r=n[this.pos++]))<<14,r<128?t:(t|=(127&(r=n[this.pos++]))<<21,r<128?t:function(e,t,n){var r,i=n.buf,a=i[n.pos++];if(r=(112&a)>>4,a<128)return A(e,r,t);if(a=i[n.pos++],r|=(127&a)<<3,a<128)return A(e,r,t);if(a=i[n.pos++],r|=(127&a)<<10,a<128)return A(e,r,t);if(a=i[n.pos++],r|=(127&a)<<17,a<128)return A(e,r,t);if(a=i[n.pos++],r|=(127&a)<<24,a<128)return A(e,r,t);if(a=i[n.pos++],r|=(1&a)<<31,a<128)return A(e,r,t);throw new Error("Expected varint not more than 10 bytes")}(t|=(15&(r=n[this.pos]))<<28,e,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var e=this.readVarint();return e%2==1?(e+1)/-2:e/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=12&&o?function(e,t,n){return o.decode(e.subarray(t,n))}(this.buf,t,e):function(e,t,n){var r="",i=t;for(;i<n;){var a,o,s,A=e[i],l=null,c=A>239?4:A>223?3:A>191?2:1;if(i+c>n)break;1===c?A<128&&(l=A):2===c?128==(192&(a=e[i+1]))&&(l=(31&A)<<6|63&a)<=127&&(l=null):3===c?(a=e[i+1],o=e[i+2],128==(192&a)&&128==(192&o)&&((l=(15&A)<<12|(63&a)<<6|63&o)<=2047||l>=55296&&l<=57343)&&(l=null)):4===c&&(a=e[i+1],o=e[i+2],s=e[i+3],128==(192&a)&&128==(192&o)&&128==(192&s)&&((l=(15&A)<<18|(63&a)<<12|(63&o)<<6|63&s)<=65535||l>=1114112)&&(l=null)),null===l?(l=65533,c=1):l>65535&&(l-=65536,r+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),r+=String.fromCharCode(l),i+=c}return r}(this.buf,t,e)},readBytes:function(){var e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t},readPackedVarint:function(e,t){if(this.type!==r.Bytes)return e.push(this.readVarint(t));var n=s(this);for(e=e||[];this.pos<n;)e.push(this.readVarint(t));return e},readPackedSVarint:function(e){if(this.type!==r.Bytes)return e.push(this.readSVarint());var t=s(this);for(e=e||[];this.pos<t;)e.push(this.readSVarint());return e},readPackedBoolean:function(e){if(this.type!==r.Bytes)return e.push(this.readBoolean());var t=s(this);for(e=e||[];this.pos<t;)e.push(this.readBoolean());return e},readPackedFloat:function(e){if(this.type!==r.Bytes)return e.push(this.readFloat());var t=s(this);for(e=e||[];this.pos<t;)e.push(this.readFloat());return e},readPackedDouble:function(e){if(this.type!==r.Bytes)return e.push(this.readDouble());var t=s(this);for(e=e||[];this.pos<t;)e.push(this.readDouble());return e},readPackedFixed32:function(e){if(this.type!==r.Bytes)return e.push(this.readFixed32());var t=s(this);for(e=e||[];this.pos<t;)e.push(this.readFixed32());return e},readPackedSFixed32:function(e){if(this.type!==r.Bytes)return e.push(this.readSFixed32());var t=s(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed32());return e},readPackedFixed64:function(e){if(this.type!==r.Bytes)return e.push(this.readFixed64());var t=s(this);for(e=e||[];this.pos<t;)e.push(this.readFixed64());return e},readPackedSFixed64:function(e){if(this.type!==r.Bytes)return e.push(this.readSFixed64());var t=s(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed64());return e},skip:function(e){var t=7&e;if(t===r.Varint)for(;this.buf[this.pos++]>127;);else if(t===r.Bytes)this.pos=this.readVarint()+this.pos;else if(t===r.Fixed32)this.pos+=4;else{if(t!==r.Fixed64)throw new Error("Unimplemented type: "+t);this.pos+=8}},writeTag:function(e,t){this.writeVarint(e<<3|t)},realloc:function(e){for(var t=this.length||16;t<this.pos+e;)t*=2;if(t!==this.length){var n=new Uint8Array(t);n.set(this.buf),this.buf=n,this.length=t}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(e){this.realloc(4),y(this.buf,e,this.pos),this.pos+=4},writeSFixed32:function(e){this.realloc(4),y(this.buf,e,this.pos),this.pos+=4},writeFixed64:function(e){this.realloc(8),y(this.buf,-1&e,this.pos),y(this.buf,Math.floor(e*a),this.pos+4),this.pos+=8},writeSFixed64:function(e){this.realloc(8),y(this.buf,-1&e,this.pos),y(this.buf,Math.floor(e*a),this.pos+4),this.pos+=8},writeVarint:function(e){(e=+e||0)>268435455||e<0?function(e,t){var n,r;e>=0?(n=e%4294967296|0,r=e/4294967296|0):(r=~(-e/4294967296),4294967295^(n=~(-e%4294967296))?n=n+1|0:(n=0,r=r+1|0));if(e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),function(e,t,n){n.buf[n.pos++]=127&e|128,e>>>=7,n.buf[n.pos++]=127&e|128,e>>>=7,n.buf[n.pos++]=127&e|128,e>>>=7,n.buf[n.pos++]=127&e|128,e>>>=7,n.buf[n.pos]=127&e}(n,0,t),function(e,t){var n=(7&e)<<4;if(t.buf[t.pos++]|=n|((e>>>=3)?128:0),!e)return;if(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),!e)return;if(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),!e)return;if(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),!e)return;if(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),!e)return;t.buf[t.pos++]=127&e}(r,t)}(e,this):(this.realloc(4),this.buf[this.pos++]=127&e|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=e>>>7&127))))},writeSVarint:function(e){this.writeVarint(e<0?2*-e-1:2*e)},writeBoolean:function(e){this.writeVarint(Boolean(e))},writeString:function(e){e=String(e),this.realloc(4*e.length),this.pos++;var t=this.pos;this.pos=function(e,t,n){for(var r,i,a=0;a<t.length;a++){if((r=t.charCodeAt(a))>55295&&r<57344){if(!i){r>56319||a+1===t.length?(e[n++]=239,e[n++]=191,e[n++]=189):i=r;continue}if(r<56320){e[n++]=239,e[n++]=191,e[n++]=189,i=r;continue}r=i-55296<<10|r-56320|65536,i=null}else i&&(e[n++]=239,e[n++]=191,e[n++]=189,i=null);r<128?e[n++]=r:(r<2048?e[n++]=r>>6|192:(r<65536?e[n++]=r>>12|224:(e[n++]=r>>18|240,e[n++]=r>>12&63|128),e[n++]=r>>6&63|128),e[n++]=63&r|128)}return n}(this.buf,e,this.pos);var n=this.pos-t;n>=128&&l(t,n,this),this.pos=t-1,this.writeVarint(n),this.pos+=n},writeFloat:function(e){this.realloc(4),n.write(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),n.write(this.buf,e,this.pos,!0,52,8),this.pos+=8},writeBytes:function(e){var t=e.length;this.writeVarint(t),this.realloc(t);for(var n=0;n<t;n++)this.buf[this.pos++]=e[n]},writeRawMessage:function(e,t){this.pos++;var n=this.pos;e(t,this);var r=this.pos-n;r>=128&&l(n,r,this),this.pos=n-1,this.writeVarint(r),this.pos+=r},writeMessage:function(e,t,n){this.writeTag(e,r.Bytes),this.writeRawMessage(t,n)},writePackedVarint:function(e,t){t.length&&this.writeMessage(e,c,t)},writePackedSVarint:function(e,t){t.length&&this.writeMessage(e,u,t)},writePackedBoolean:function(e,t){t.length&&this.writeMessage(e,h,t)},writePackedFloat:function(e,t){t.length&&this.writeMessage(e,f,t)},writePackedDouble:function(e,t){t.length&&this.writeMessage(e,d,t)},writePackedFixed32:function(e,t){t.length&&this.writeMessage(e,p,t)},writePackedSFixed32:function(e,t){t.length&&this.writeMessage(e,m,t)},writePackedFixed64:function(e,t){t.length&&this.writeMessage(e,g,t)},writePackedSFixed64:function(e,t){t.length&&this.writeMessage(e,b,t)},writeBytesField:function(e,t){this.writeTag(e,r.Bytes),this.writeBytes(t)},writeFixed32Field:function(e,t){this.writeTag(e,r.Fixed32),this.writeFixed32(t)},writeSFixed32Field:function(e,t){this.writeTag(e,r.Fixed32),this.writeSFixed32(t)},writeFixed64Field:function(e,t){this.writeTag(e,r.Fixed64),this.writeFixed64(t)},writeSFixed64Field:function(e,t){this.writeTag(e,r.Fixed64),this.writeSFixed64(t)},writeVarintField:function(e,t){this.writeTag(e,r.Varint),this.writeVarint(t)},writeSVarintField:function(e,t){this.writeTag(e,r.Varint),this.writeSVarint(t)},writeStringField:function(e,t){this.writeTag(e,r.Bytes),this.writeString(t)},writeFloatField:function(e,t){this.writeTag(e,r.Fixed32),this.writeFloat(t)},writeDoubleField:function(e,t){this.writeTag(e,r.Fixed64),this.writeDouble(t)},writeBooleanField:function(e,t){this.writeVarintField(e,Boolean(t))}}});function vb(e){let t=0;for(let n,r,i=0,a=e.length-1;i<e.length;a=i++)n=e[i],r=e[a],t+=(r[0]-n[0])*(n[1]+r[1]);return t}function yb(e,t){if(Array.isArray(e[0])){for(const n of e)yb(n,t);return}const n=e;n[0]/=t,n[1]/=t}function xb(e,t){for(let n=0;n<e.length;++n)e[n]/=t}function _b(e,t,n){if("number"!=typeof e[0][0]){for(const r of e)_b(r,t,n);return}const r=n*Math.pow(2,t.z),i=n*t.x,a=n*t.y;for(let o=0;o<e.length;o++){const t=e[o];t[0]=360*(t[0]+i)/r-180;const n=180-360*(t[1]+a)/r;t[1]=360/Math.PI*Math.atan(Math.exp(n*Math.PI/180))-90}}var wb=class{properties;extent;type;id;_pbf;_geometry;_keys;_values;_geometryInfo;static types=["Unknown","Point","LineString","Polygon"];constructor(e,t,n,r,i,a){this.properties={},this.extent=n,this.type=0,this.id=null,this._pbf=e,this._geometry=-1,this._keys=r,this._values=i,this._geometryInfo=a,e.readFields(Sb,this,t)}toGeoJSONFeature(e,t){const n=this.loadGeometry();return Tb(this,n,"wgs84"===e?e=>_b(e,t,this.extent):yb)}toBinaryFeature(e,t){const n=this.loadFlatGeometry();return"wgs84"===e?this._toBinaryCoordinates(n,e=>function(e,t,n){const{x:r,y:i,z:a}=t,o=n*Math.pow(2,a),s=n*r,A=n*i;for(let l=0,c=e.length;l<c;l+=2){e[l]=360*(e[l]+s)/o-180;const t=180-360*(e[l+1]+A)/o;e[l+1]=360/Math.PI*Math.atan(Math.exp(t*Math.PI/180))-90}}(e,t,this.extent)):this._toBinaryCoordinates(n,xb)}bbox(){const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos;let n=1,r=0,i=0,a=0,o=1/0,s=-1/0,A=1/0,l=-1/0;for(;e.pos<t;){if(r<=0){const t=e.readVarint();n=7&t,r=t>>3}if(r--,1===n||2===n)i+=e.readSVarint(),a+=e.readSVarint(),i<o&&(o=i),i>s&&(s=i),a<A&&(A=a),a>l&&(l=a);else if(7!==n)throw new Error(`unknown command ${n}`)}return[o,A,s,l]}_toBinaryCoordinates(e,n){let r;n(e.data,this.extent);switch(this.type){case 1:this._geometryInfo.pointFeaturesCount++,this._geometryInfo.pointPositionsCount+=e.indices.length,r={type:"Point",...e};break;case 2:this._geometryInfo.lineFeaturesCount++,this._geometryInfo.linePathsCount+=e.indices.length,this._geometryInfo.linePositionsCount+=e.data.length/2,r={type:"LineString",...e};break;case 3:r=function(e){const n=e.indices.length,r="Polygon";if(n<=1)return{type:r,data:e.data,areas:[[t.getPolygonSignedArea(e.data)]],indices:[e.indices]};const i=[],a=[];let o,s=[],A=[],l=0;for(let c,u,f=0;f<n;f++){u=e.indices[f]-l,c=e.indices[f+1]-l||e.data.length;const n=e.data.slice(u,c),r=t.getPolygonSignedArea(n);if(0===r){const t=e.data.slice(0,u),n=e.data.slice(c);e.data=t.concat(n),l+=c-u;continue}void 0===o&&(o=r<0),o===r<0?(A.length&&(i.push(s),a.push(A)),A=[u],s=[r]):(s.push(r),A.push(u))}return s&&i.push(s),A.length&&a.push(A),{type:r,areas:i,indices:a,data:e.data}}(e),this._geometryInfo.polygonFeaturesCount++,this._geometryInfo.polygonObjectsCount+=r.indices.length;for(const e of r.indices)this._geometryInfo.polygonRingsCount+=e.length;this._geometryInfo.polygonPositionsCount+=r.data.length/2;break;default:throw new Error(`Invalid geometry type: ${this.type}`)}const i={type:"Feature",geometry:r,properties:this.properties};return null!==this.id&&(i.id=this.id),i}loadGeometry(){const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos;let n=1,r=0,i=0,a=0;const o=[];let s;for(;e.pos<t;){if(r<=0){const t=e.readVarint();n=7&t,r=t>>3}switch(r--,n){case 1:case 2:i+=e.readSVarint(),a+=e.readSVarint(),1===n&&(s&&o.push(s),s=[]),s&&s.push([i,a]);break;case 7:s&&s.push(s[0].slice());break;default:throw new Error(`unknown command ${n}`)}}return s&&o.push(s),o}loadFlatGeometry(){const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos;let n,r=1,i=0,a=0,o=0,s=0;const A=[],l=[];for(;e.pos<t;)if(i<=0&&(n=e.readVarint(),r=7&n,i=n>>3),i--,1===r||2===r)a+=e.readSVarint(),o+=e.readSVarint(),1===r&&A.push(s),l.push(a,o),s+=2;else{if(7!==r)throw new Error(`unknown command ${r}`);if(s>0){const e=A[A.length-1];l.push(l[e],l[e+1]),s+=2}}return{data:l,indices:A}}};function Tb(e,t,n){let r,i,a,o=wb.types[e.type];switch(e.type){case 1:const o=[];for(r=0;r<t.length;r++)o[r]=t[r][0];a=o,n(a,e.extent);break;case 2:for(a=t,r=0;r<a.length;r++)n(a[r],e.extent);break;case 3:for(a=function(e){const t=e.length;if(t<=1)return[e];const n=[];let r,i;for(let a=0;a<t;a++){const t=vb(e[a]);0!==t&&(void 0===i&&(i=t<0),i===t<0?(r&&n.push(r),r=[e[a]]):r&&r.push(e[a]))}return r&&n.push(r),n}(t),r=0;r<a.length;r++)for(i=0;i<a[r].length;i++)n(a[r][i],e.extent);break;default:throw new Error("illegal vector tile type")}1===a.length?a=a[0]:o=`Multi${o}`;const s={type:"Feature",geometry:{type:o,coordinates:a},properties:e.properties};return null!==e.id&&(s.id=e.id),s}function Sb(e,t,n){t&&n&&(1===e?t.id=n.readVarint():2===e?function(e,t){const n=e.readVarint()+e.pos;for(;e.pos<n;){const n=t._keys[e.readVarint()],r=t._values[e.readVarint()];t.properties[n]=r}}(n,t):3===e?t.type=n.readVarint():4===e&&(t._geometry=n.pos))}var Mb=class{version;name;extent;length;_pbf;_keys;_values;_features;constructor(e,t){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=e,this._keys=[],this._values=[],this._features=[],e.readFields(Eb,this,t),this.length=this._features.length}getGeoJSONFeature(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];const t=this._pbf.readVarint()+this._pbf.pos;return new wb(this._pbf,t,this.extent,this._keys,this._values)}getBinaryFeature(e,t){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];const n=this._pbf.readVarint()+this._pbf.pos;return new wb(this._pbf,n,this.extent,this._keys,this._values,t)}};function Eb(e,t,n){t&&n&&(15===e?t.version=n.readVarint():1===e?t.name=n.readString():5===e?t.extent=n.readVarint():2===e?t._features.push(n.pos):3===e?t._keys.push(n.readString()):4===e&&t._values.push(function(e){let t=null;const n=e.readVarint()+e.pos;for(;e.pos<n;){const n=e.readVarint()>>3;t=1===n?e.readString():2===n?e.readFloat():3===n?e.readDouble():4===n?e.readVarint64():5===n?e.readVarint():6===n?e.readSVarint():7===n?e.readBoolean():null}return t}(n)))}var Cb=class{layers;constructor(e,t){this.layers=e.readFields(Ib,{},t)}};function Ib(e,t,n){if(3===e&&n){const e=new Mb(n,n.readVarint()+n.pos);e.length&&t&&(t[e.name]=e)}}var Rb=e.__toESM(bb(),1);function Pb(e,t){const r=function(e){if(!e?.mvt)throw new Error("mvt options required");if("wgs84"===e.mvt?.coordinates&&!e.mvt.tileIndex)throw new Error("MVT Loader: WGS84 coordinates need tileIndex property");e.gis&&n.log.warn('MVTLoader: "options.gis" is deprecated, use "options.mvt.shape" instead')();return e.mvt}(t),i=t?.gis?.format||t?.mvt?.shape||t?.shape;switch(i){case"columnar-table":return{shape:"columnar-table",data:Nb(e,r)};case"geojson-table":return{shape:"geojson-table",type:"FeatureCollection",features:kb(e,r)};case"geojson":return kb(e,r);case"binary-geometry":case"binary":return Nb(e,r);default:throw new Error(i||"undefined shape")}}function Nb(e,t){const[n,r]=function(e,t){const n=[],r={coordLength:2,pointPositionsCount:0,pointFeaturesCount:0,linePositionsCount:0,linePathsCount:0,lineFeaturesCount:0,polygonPositionsCount:0,polygonObjectsCount:0,polygonRingsCount:0,polygonFeaturesCount:0};if(e.byteLength<=0)return[n,r];const i=new Cb(new Rb.default(e));return(t&&Array.isArray(t.layers)?t.layers:Object.keys(i.layers)).forEach(e=>{const a=i.layers[e];if(a)for(let i=0;i<a.length;i++){const o=Bb(a.getBinaryFeature(i,r),t,e);n.push(o)}}),[n,r]}(e,t),i=rb(n,r);return i.byteLength=e.byteLength,i}function kb(e,t){if(e.byteLength<=0)return[];const n=[],r=new Cb(new Rb.default(e));return(Array.isArray(t.layers)?t.layers:Object.keys(r.layers)).forEach(e=>{const i=r.layers[e];if(i)for(let r=0;r<i.length;r++){const a=Lb(i.getGeoJSONFeature(r),t,e);n.push(a)}}),n}function Lb(e,t,n){const r=e.toGeoJSONFeature(t.coordinates||"local",t.tileIndex);return t.layerProperty&&(r.properties||={},r.properties[t.layerProperty]=n),r}function Bb(e,t,n){const r=e.toBinaryFeature(t.coordinates||"local",t.tileIndex);return t.layerProperty&&r.properties&&(r.properties[t.layerProperty]=n),r}var Ob={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.5.4",worker:!0,options:{mvt:{shape:"geojson",coordinates:"local",layerProperty:"layerName",layers:void 0,tileIndex:void 0}}},Fb={Point:Db,MultiPoint:function(e,t,n){return Ub(e,t,n)},LineString:Vb,MultiLineString:function(e,t,n){return e.map(e=>Vb(e,t,n))},Polygon:jb,MultiPolygon:function(e,t,n){return e.map(e=>jb(e,t,n))}};function Db([e,t],[r,i],a){const o=n.lerp$2(r[0],i[0],e),s=n.lerp$2(r[1],i[1],t);return a.unprojectFlat([o,s])}function Ub(e,t,n){return e.map(e=>Db(e,t,n))}function Vb(e,t,n){return Ub(e,t,n)}function jb(e,t,n){return e.map(e=>Ub(e,t,n))}var zb=["points","lines","polygons"];function Gb(e,t,n,r){const i=e.featureIds.value;if(!i.length)return-1;let a=0,o=i[i.length-1]+1;if(r){const t=function(e,t){if(!e.__layers){const t={},{properties:n}=e;for(let e=0;e<n.length;e++){const{layerName:r}=n[e];r&&(t[r]?t[r][1]=e:t[r]=[e,e])}e.__layers=t}return e.__layers[t]}(e,r);if(!t)return-1;a=t[0],o=t[1]+1}let s=-1;if(t in e.numericProps){const r=e.numericProps[t].value.findIndex((e,t)=>e===n&&i[t]>=a&&i[t]<o);return r>=0?e.globalFeatureIds.value[r]:-1}return t?s=Hb(e.properties,e=>e[t]===n,a,o):e.fields&&(s=Hb(e.fields,e=>e.id===n,a,o)),s>=0?function(e,t){if(!e.__ids){const t=[],n=e.featureIds.value,r=e.globalFeatureIds.value;for(let e=0;e<n.length;e++)t[n[e]]=r[e];e.__ids=t}return e.__ids[t]}(e,s):-1}function Hb(e,t,n,r){for(let i=n;i<r;i++)if(t(e[i],i))return i;return-1}var qb={...t.GeoJsonLayer.defaultProps,data:dA,onDataLoad:{type:"function",value:null,optional:!0,compare:!1},uniqueIdProperty:"",highlightedFeatureId:null,loaders:[Ob],binary:!0},Qb=class extends BA{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:r}){r.dataChanged&&this._updateTileData(),this.state?.data&&(super.updateState({props:e,oldProps:t,context:n,changeFlags:r}),this._setWGS84PropertyForTiles());const{highlightColor:i}=e;i!==t.highlightColor&&Array.isArray(i)&&this.setState({highlightColor:i})}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:r,fetch:i}=this.props;this.setState({data:null,tileJSON:null});try{t=await i(e,{propName:"data",layer:this,loaders:[]})}catch(n){this.raiseError(n,"loading TileJSON"),e=null}r&&r(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:r}=this.props;return t&&(Number.isFinite(t.minzoom)&&t.minzoom>n&&(e.minZoom=t.minzoom),Number.isFinite(t.maxzoom)&&(!Number.isFinite(r)||t.maxzoom<r)&&(e.maxZoom=t.maxzoom)),e}renderLayers(){return this.state?.data?super.renderLayers():null}getTileData(e){const{data:t,binary:n}=this.state,{index:r,signal:i}=e,a=pA(t,e);if(!a)return Promise.reject("Invalid URL");let o=this.getLoadOptions();const{fetch:s}=this.props;return o={...o,core:{...o?.core,mimeType:"application/x-protobuf"},mvt:{...o?.mvt,shape:n?"binary":"geojson",coordinates:this.context.viewport.resolution?"wgs84":"local",tileIndex:r}},s(a,{propName:"data",layer:this,loadOptions:o,signal:i})}renderSubLayers(e){const{x:r,y:i,z:a}=e.tile.index,o=Math.pow(2,a),s=512/o,A=-s,l=512*r/o,c=512*(1-i/o),u=(new n.Matrix4).scale([s,A,1]);e.autoHighlight=!1,this.context.viewport.resolution||(e.modelMatrix=u,e.coordinateOrigin=[l,c,0],e.coordinateSystem=n.COORDINATE_SYSTEM.CARTESIAN,e.extensions=[...e.extensions||[],new Zg]);const f=super.renderSubLayers(e);return!this.state.binary||f instanceof t.GeoJsonLayer||n.defaultLogger.warn("renderSubLayers() must return GeoJsonLayer when using binary:true")(),f}_updateAutoHighlight(e){const{uniqueIdProperty:t}=this.props,{hoveredFeatureId:n,hoveredFeatureLayerName:r}=this.state,i=e.object;let a=null,o=null;i&&(a=Kb(i,t),o=Wb(i));let{highlightColor:s}=this.props;"function"==typeof s&&(s=s(e)),n===a&&r===o||this.setState({highlightColor:s,hoveredFeatureId:a,hoveredFeatureLayerName:o})}_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=fb(n,{globalFeatureId:t.index})}return t.object&&!this._isWGS84()&&(t.object=Jb(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:r}=this.state,{uniqueIdProperty:i,highlightedFeatureId:a}=this.props,o=e.content,s=$b(a);if(!$b(t)&&!s)return-1;const A=s?a:t;return Array.isArray(o)?o.findIndex(e=>{const t=Kb(e,i)===A,r=s||Wb(e)===n;return t&&r}):o&&r?function(e,t,n,r){for(const i of zb){const a=e[i]&&Gb(e[i],t,n,r);if(a>=0)return a}return-1}(o,i,A,s?"":n):-1}_pickObjects(e){const{deck:t,viewport:n}=this.context,r=n.width,i=n.height,a=n.x,o=n.y,s=[this.id];return t.pickObjects({x:a,y:o,width:r,height:i,layerIds:s,maxObjects:e})}getRenderedFeatures(e=null){const t=this._pickObjects(e),n=new Set,r=[];for(const i of t){const e=Kb(i.object,this.props.uniqueIdProperty);void 0===e?r.push(i.object):n.has(e)||(n.add(e),r.push(i.object))}return r}_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;return void 0===t._contentWGS84&&function(e){return Number.isFinite(e.west)&&Number.isFinite(e.north)&&Number.isFinite(e.east)&&Number.isFinite(e.south)}(e)&&(t._contentWGS84=(this.state.binary?fb(t.content):t.content).map(t=>Jb(t,e,this.context.viewport))),t._contentWGS84}})})}};function Kb(e,t){return e.properties&&t?e.properties[t]:"id"in e?e.id:void 0}function Wb(e){return e.properties?.layerName||null}function $b(e){return null!=e&&""!==e}function Jb(e,t,n){const r={...e,geometry:{type:e.geometry.type}};return Object.defineProperty(r.geometry,"coordinates",{get:()=>function(e,t,n){const r=[n.projectFlat([t.west,t.north]),n.projectFlat([t.east,t.south])];return{...e,coordinates:Fb[e.type](e.coordinates,r,n)}}(e.geometry,t,n).coordinates}),r}Qb.layerName="MVTLayer",Qb.defaultProps=qb;var Yb={};for(let ev=0;ev<32;ev++)Yb["0123456789bcdefghjkmnpqrstuvwxyz".charAt(ev)]=ev;function Xb(e){const[t,n,r,i]=function(e){let t,n=!0,r=90,i=-90,a=180,o=-180,s=0;for(let A=0,l=e.length;A<l;A++){const l=e[A].toLowerCase();s=Yb[l];for(let e=4;e>=0;e--){const A=s>>e&1;n?(t=(a+o)/2,1===A?o=t:a=t):(t=(r+i)/2,1===A?i=t:r=t),n=!n}}return[i,o,r,a]}(e);return[i,r,i,t,n,t,n,r,i,r]}var Zb=class extends st{indexToBounds(){const{data:e,getGeohash:t}=this.props;return{data:e,_normalize:!1,positionFormat:"XY",getPolygon:(e,n)=>Xb(t(e,n))}}};Zb.layerName="GeohashLayer",Zb.defaultProps={getGeohash:{type:"accessor",value:e=>e.geohash}},exports.A5Layer=bi,exports.GeohashLayer=Zb,exports.GreatCircleLayer=Ko,exports.H3ClusterLayer=HA,exports.H3HexagonLayer=GA,exports.MVTLayer=Qb,exports.QuadkeyLayer=ss,exports.S2Layer=as,exports.TerrainLayer=Qg,exports.Tile3DLayer=Vg,exports.TileLayer=BA,exports.TripsLayer=jA,exports._GeoCellLayer=st,exports._Tile2DHeader=As,exports._Tileset2D=PA,exports._WMSLayer=Qo,exports._getURLFromTemplate=pA;