@instruktlabs/kiln 1.2.0 → 1.2.1

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.
@@ -1,8 +1,8 @@
1
- function to(e){let t=Object.values(e).filter((i)=>typeof i==="number");return Object.entries(e).filter(([i,r])=>t.indexOf(+i)===-1).map(([i,r])=>r)}function Tl(e,t="|"){return e.map((n)=>Cl(n)).join(t)}function no(e,t){if(typeof t==="bigint")return t.toString();return t}class Tf{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;if(e!==void 0)this._value=e(),this._getter=void 0;return this._value}}function io(e){return new Tf(e)}function Af(e){return e===null||e===void 0}function Ea(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Rf(e,t){let n=e/t,i=Math.round(n),r=4*Number.EPSILON*Math.max(Math.abs(n),1);if(Math.abs(n-i)<r)return 0;return n-i}function Dn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function ro(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function Li(e){return ro(e._zod.def)??e._zod.def.shape}function Cf(e,t,n){Object.defineProperty(e,t,{get(){let i=n();return Dn(this,t,i),i},enumerable:!0,configurable:!0})}function If(e,t,n){if(t in e)Dn(e,t,n);else e[t]=n}function Lr(e,t,n,i){let r=Li(t);for(let s of n){let o=Object.getOwnPropertyDescriptor(r,s);if(!o.enumerable)continue;if(o.get)Cf(e,s,()=>{let a=t._zod.def.shape[s];return i?i(a,s):a});else If(e,s,i?i(o.value,s):o.value)}}function Db(e,t){for(let n of Reflect.ownKeys(t)){let i=Object.getOwnPropertyDescriptor(t,n);if(!i.enumerable)continue;if(i.get)Cf(e,n,()=>t[n]);else If(e,n,i.value)}}function Sn(...e){let t={};for(let n of e){let i=Object.getOwnPropertyDescriptors(n);Object.assign(t,i)}return Object.defineProperties({},t)}function Pf(e){return JSON.stringify(e)}function Lf(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Al="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function os(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var Nf=io(()=>{if(xn.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function Nr(e){if(os(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;if(typeof t!=="function")return!0;let n=t.prototype;if(os(n)===!1)return!1;if(Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)return!1;return!0}function Rl(e){if(Nr(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}var Df=new Set(["string","number","symbol"]);function Ji(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ci(e,t,n){let i=new e._zod.constr(t??e._zod.def);if(!t||n?.parent)i._zod.parent=e;return i}function De(e){let t=e;if(!t)return{};if(typeof t==="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}if(delete t.message,typeof t.error==="string")return{...t,error:()=>t.error};return t}function Cl(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function Of(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var Ta=(()=>({safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]}))(),Il={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Ob(e,t){let n=e._zod.def,i=n.checks;if(i&&i.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let s={};return Lr(s,e,Aa(e,t)),ci(e,Sn(n,{shape:s,checks:[]}))}function Aa(e,t){let n=Li(e),i=[];for(let r of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,r)?.enumerable)throw Error(`Unrecognized key: "${String(r)}"`);if(t[r])i.push(r)}return i}function Ub(e,t){let n=e._zod.def,i=n.checks;if(i&&i.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let s=new Set(Aa(e,t)),o={};return Lr(o,e,Reflect.ownKeys(Li(e)).filter((a)=>!s.has(a))),ci(e,Sn(n,{shape:o,checks:[]}))}function Fb(e,t){if(!Nr(t))throw Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let r=Li(e);for(let s of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(r,s)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return ci(e,Sn(e._zod.def,{shape:Uf(e,t)}))}function Uf(e,t){let n={};return Lr(n,e,Reflect.ownKeys(Li(e))),Db(n,t),n}function zb(e,t){if(!Nr(t))throw Error("Invalid input to safeExtend: expected a plain object");return ci(e,Sn(e._zod.def,{shape:Uf(e,t)}))}function kb(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let n={};Lr(n,e,Reflect.ownKeys(Li(e))),Lr(n,t,Reflect.ownKeys(Li(t)));let i=Sn(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ci(e,i)}function Ff(e,t,n,i="partial"){let s=t._zod.def.checks;if(s&&s.length>0)throw Error(`.${i}() cannot be used on object schemas containing refinements`);let a=n?new Set(Aa(t,n)):void 0,c={};return Lr(c,t,Reflect.ownKeys(Li(t)),e&&((l,u)=>a&&!a.has(u)?l:new e({type:"optional",innerType:l}))),ci(t,Sn(t._zod.def,{shape:c,checks:[]}))}function Bb(e,t,n){let i=n?new Set(Aa(t,n)):void 0,r={};return Lr(r,t,Reflect.ownKeys(Li(t)),(s,o)=>i&&!i.has(o)?s:new e({type:"nonoptional",innerType:s})),ci(t,Sn(t._zod.def,{shape:r}))}function li(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function zf(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Qi(e,t){return t.map((n)=>{var i;return(i=n).path??(i.path=[]),n.path.unshift(e),n})}function eo(e){return typeof e==="string"?e:e?.message}function Pl(e,t,n){var i;for(let r=t;r<e.length;r++)(i=e[r]).schema??(i.schema=n)}function ui(e,t,n){var i;let r=e.inst?._zod?.traits;if(r?.has("$ZodType"))if(r.has("$ZodCheck"))(i=e).schema??(i.schema=e.inst);else e.schema=e.inst;let s=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,o=e.message?e.message:eo(e.inst?._zod.def?.error?.(e))??eo(s?.(e))??eo(t?.error?.(e))??eo(n.customError?.(e))??eo(n.localeError?.(e))??"Invalid input",a={};for(let c of Object.keys(e)){if(c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__")continue;a[c]=e[c]}if(a.path??(a.path=[]),a.message=o,t?.reportInput)a.input=e.input;return a}var Gb=/[\uD800-\uDBFF]/;function Ra(e){let t=e.length;if(!Gb.test(e))return t;let n=t;for(let i=0;i<t-1;i++)if((e.charCodeAt(i)&64512)===55296&&(e.charCodeAt(i+1)&64512)===56320)n--,i++;return n}function Ca(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function kf(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}function Dr(...e){let[t,n,i]=e;if(typeof t==="string")return{message:t,code:"custom",input:n,inst:i};return{...t}}function Bf(e,t){for(let n in t){let i=Object.getOwnPropertyDescriptor(t,n);if(i.get)Object.defineProperty(e,n,{...i,enumerable:!1});else Hb(e,n,i.value)}}function Ni(e,t,n,i=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:i,value:n}),n}function Ia(e,t,n){return Ni(e,t,n,!1)}function Gf(e,t){for(let n in e){let i=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Ni(this,n,i(this))},set(r){Ni(this,n,r)}})}return t}function Hb(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Ni(this,t,n.bind(this))},set(i){Ni(this,t,i)}})}function Vb(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var El,Ki=!1,$b={configurable:!0,get(){Ki=!0;return}};function at(e,t,n){let i=Object.getPrototypeOf(e._zod);if(t in i&&El!==e._zod){El=void 0;return}El=e._zod,Object.defineProperty(i,t,{configurable:!0,get(){Object.defineProperty(this,t,$b);let r=Ki;Ki=!1;try{let s=n(this);if(Ki)delete this[t];else Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s});return Ki=Ki||r,s}catch(s){throw delete this[t],Ki=Ki||r,s}},set(r){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r})}})}function Wb(e,t,n,i){let r=Vb(e,t);if(!r)return;Object.defineProperty(r,t,{configurable:!0,get(){let s={configurable:!0,writable:!0,enumerable:i,value:void 0};return Object.defineProperty(this,t,s),s.value=n(this),Object.defineProperty(this,t,s),s.value},set(s){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:i,value:s})}})}var Zb="~constantCatch";function Hf(e){let t=()=>e;return t[Zb]=!0,t}var Vf;var Ll={value:void 0,enumerable:!1},$f="captureStackTrace"in Error?Error:null;function Xb(e){let t=$f;if(t){let n=t.stackTraceLimit;if(typeof n==="number"){try{t.stackTraceLimit=0}catch{return $f=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function ie(e,t,n,i){let r={};function s(d){this.def=d,this.constr=h,this.traits=new Set}s.prototype=r;let o=n,a=o&&new WeakSet;function c(d,f){if(!d._zod){Ll.value=new s(f);try{Object.defineProperty(d,"_zod",Ll)}finally{Ll.value=void 0}}else if(d._zod.traits.has(e))return;if(d._zod.traits.add(e),t(d,f),a){let _=Object.getPrototypeOf(d),p=d._zod.constr.prototype,g=_;while(g&&g!==p)g=Object.getPrototypeOf(g);let M=g??_;if(!a.has(M))a.add(M),Bf(M,o)}let m=h.prototype;for(let _ in m){if(!Object.prototype.hasOwnProperty.call(m,_))continue;if(!(_ in d))d[_]=m[_].bind(d)}}let l=i?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function h(d){let f=i?.Parent?Xb(u):this;c(f,d);let m=f._zod.deferred;if(m){for(let p of m)p();f._zod.deferred=void 0}let _=globalThis.__zod_globalConfig?.postProcessor;if(_)_(f);return f}return Object.defineProperty(h,"init",{value:c}),Object.defineProperty(h,Symbol.hasInstance,{value:(d)=>{if(i?.Parent&&d instanceof i.Parent)return!0;return d?._zod?.traits?.has(e)}}),Object.defineProperty(h,"name",{value:e}),h}class hi extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class so extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(Vf=globalThis).__zod_globalConfig??(Vf.__zod_globalConfig={});var xn=globalThis.__zod_globalConfig;function wn(e){if(e)Object.assign(xn,e);return xn}function jb(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,no,2)),e.message}function qb(e){this._zod.message=e}var Yb={get:jb,set:qb,enumerable:!0,configurable:!0},Dl={value:void 0,enumerable:!1},Wf=new WeakSet([Object.prototype,Error.prototype]),Zf=(e,t)=>{e.name="$ZodError",Dl.value=t,Object.defineProperty(e,"issues",Dl),Dl.value=void 0,Object.defineProperty(e,"message",Yb);let n=Object.getPrototypeOf(e);if(!Wf.has(n))Wf.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let i=()=>this.message;return Object.defineProperty(this,"toString",{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,"toString",{value:i,configurable:!0,writable:!0})}})},Xf=ie("$ZodError",Zf),WC=ie("$ZodError",Zf,void 0,{Parent:Error});function Kb(e,t,n){if(!Object.prototype.hasOwnProperty.call(e,t))if(t==="__proto__")Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0});else e[t]=n();return e[t]}function jf(e,t=(n)=>n.message){let n={},i=[];for(let r of e.issues)if(r.path.length>0)Kb(n,r.path[0],()=>[]).push(t(r));else i.push(t(r));return{formErrors:i,fieldErrors:n}}function qf(e,t=(n)=>n.message){let n={_errors:[]},i=(r,s=[])=>{for(let o of r.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map((a)=>i({issues:a},[...s,...o.path]));else if(o.code==="invalid_key")i({issues:o.issues},[...s,...o.path]);else if(o.code==="invalid_element")i({issues:o.issues},[...s,...o.path]);else{let a=[...s,...o.path];if(a.length===0)n._errors.push(t(o));else{let c=n,l=0;while(l<a.length){let u=a[l],h=l===a.length-1;if(u==="_errors"){if(h)c._errors.push(t(o));l++;continue}if(!Object.prototype.hasOwnProperty.call(c,u))Object.defineProperty(c,u,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let d=c[u];if(h)d._errors.push(t(o));c=d,l++}}}};return i(e),n}function Pa(e,t){return{callee:t?.callee??e,Err:t?.Err}}var La=(e)=>{let t=(n,i,r,s)=>{let o=r?{...r,async:!1}:{async:!1},a=n._zod.run({value:i,issues:[]},o);if(a instanceof Promise)throw new hi;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map((l)=>ui(l,o,wn())));throw Al(c,s?.callee??t),c}return a.value};return t};var Na=(e)=>{let t=async(n,i,r,s)=>{let o=r?{...r,async:!0}:{async:!0},a=n._zod.run({value:i,issues:[]},o);if(a instanceof Promise)a=await a;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map((l)=>ui(l,o,wn())));throw Al(c,s?.callee??t),c}return a.value};return t};var Da=(e)=>(t,n,i)=>{let r=i?{...i,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise)throw new hi;return s.issues.length?Yf(e,s.issues,r):{success:!0,data:s.value}};function Yf(e,t,n){let i;return{success:!1,get error(){if(!i)i=new e(t.map((r)=>ui(r,n,wn()))),t=void 0,n=void 0;return i},set error(r){i=r,t=void 0,n=void 0}}}var Oa=(e)=>async(t,n,i)=>{let r=i?{...i,async:!0}:{async:!0},s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise)s=await s;return s.issues.length?Yf(e,s.issues,r):{success:!0,data:s.value}};var Jb=Symbol.for("zod.compile.invalid"),Qb=Symbol.for("zod.compile.fallback"),Ol=(e,t,n)=>{let i=e._zod.bag.validator;if(i!==void 0){if(i(t)!==Jb)return!0;if(i.definite===!0&&n===void 0)return!1}return eS(e,t,n)};function eS(e,t,n){let i=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},r=e._zod.bag.fallbackRun,s;if(r)i[Qb]=!0,s=r({value:t,issues:[]},i);else s=e._zod.run({value:t,issues:[]},i);if(s instanceof Promise)throw new hi;return s.issues.length===0}var Ul=async(e,t,n)=>{let i=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},r=e._zod.run({value:t,issues:[]},i);if(r instanceof Promise)r=await r;return r.issues.length===0},Kf=(e)=>{let t=La(e),n=(i,r,s,o)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return t(i,r,a,Pa(n,o))};return n};var Jf=(e)=>{let t=La(e),n=(i,r,s,o)=>t(i,r,s,Pa(n,o));return n};var Qf=(e)=>{let t=Na(e),n=async(i,r,s,o)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return await t(i,r,a,Pa(n,o))};return n};var ep=(e)=>{let t=Na(e),n=async(i,r,s,o)=>await t(i,r,s,Pa(n,o));return n};var tp=(e)=>(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return Da(e)(t,n,r)};var np=(e)=>(t,n,i)=>Da(e)(t,n,i);var ip=(e)=>async(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return Oa(e)(t,n,r)};var rp=(e)=>async(t,n,i)=>Oa(e)(t,n,i);var sp=/^[cC][0-9a-z]{6,}$/,op=/^[0-9a-z]+$/,ap=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,cp=/^[0-9a-vA-V]{20}$/,lp=/^[A-Za-z0-9]{27}$/,up=/^[a-zA-Z0-9_-]{21}$/;function hp(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var dp=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var fp=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,zl=(e)=>{if(!e)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var pp=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var tS="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function mp(){return new RegExp(tS,"u")}var gp=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,_p=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var xp=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,vp=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,yp=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,bp=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var Sp=/^https?$/,wp=/^\+[1-9]\d{6,14}$/;var Mp="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function nS(e){return new RegExp(`^${e}$`)}var Ep=nS(Mp);function Fl(e){return typeof e.precision==="number"?e.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":e.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?":"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function Tp(e){return new RegExp(`^${Fl(e)}$`)}function Ap(e){let t=["Z"];if(e.offset)t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${Fl({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,i=e.local?`${n}|${Fl({precision:e.precision})}`:n;return new RegExp(`^${Mp}T(?:${i})$`)}var Rp=/^[\s\S]{0,}$/;var kl=/^-?\d+$/,oo=/^-?\d+(?:\.\d+)?$/,Cp=/^(?:true|false)$/i;var Ip=/^[^A-Z]*$/,Pp=/^[^a-z]*$/;var nn=ie("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])});var Bl=(e)=>{let t=e.value;return!Af(t)&&t.length!==void 0},Ua={number:"number",bigint:"bigint",object:"date"},Gl=ie("$ZodCheckLessThan",(e,t)=>{nn.init(e,t);let n=Ua[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value<=t.value:i.value<t.value)return;i.issues.push({origin:Ua[typeof i.value]??n,code:"too_big",maximum:typeof t.value==="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Hl=ie("$ZodCheckGreaterThan",(e,t)=>{nn.init(e,t);let n=Ua[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value>=t.value:i.value>t.value)return;i.issues.push({origin:Ua[typeof i.value]??n,code:"too_small",minimum:typeof t.value==="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Lp=ie("$ZodCheckMultipleOf",(e,t)=>{nn.init(e,t),e._zod.check=(n)=>{if(typeof n.value!==typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof n.value==="bigint"?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):Rf(n.value,t.value)===0)return;n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Np=ie("$ZodCheckNumberFormat",(e,t)=>{nn.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),i=n?"int":"number",[r,s]=Ta[t.format];e._zod.check=(o)=>{let a=o.value;if(n){if(!Number.isInteger(a)){o.issues.push({expected:i,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){if(a>0)o.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort});else o.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort});return}}if(a<r)o.issues.push({origin:"number",input:a,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort});if(a>s)o.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var Dp=ie("$ZodCheckMaxLength",(e,t)=>{var n;nn.init(e,t),(n=e._zod.def).when??(n.when=Bl),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>t.maximum?Ra(r):s)<=t.maximum)return;let a=Ca(r);i.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Op=ie("$ZodCheckMinLength",(e,t)=>{var n;nn.init(e,t),(n=e._zod.def).when??(n.when=Bl),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>=t.minimum&&s<t.minimum*2?Ra(r):s)>=t.minimum)return;let a=Ca(r);i.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Up=ie("$ZodCheckLengthEquals",(e,t)=>{var n;nn.init(e,t),(n=e._zod.def).when??(n.when=Bl),e._zod.check=(i)=>{let r=i.value,s=r.length,o=typeof r==="string"&&s>=t.length&&s<=t.length*2?Ra(r):s;if(o===t.length)return;let a=Ca(r),c=o>t.length;i.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:i.value,inst:e,continue:!t.abort})}}),co=ie("$ZodCheckStringFormat",(e,t)=>{var n,i;if(nn.init(e,t),t.pattern)(n=e._zod).check??(n.check=(r)=>{if(t.pattern.lastIndex=0,t.pattern.test(r.value))return;r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(i=e._zod).check??(i.check=()=>{})}),Fp=ie("$ZodCheckRegex",(e,t)=>{co.init(e,t),e._zod.check=(n)=>{if(t.pattern.lastIndex=0,t.pattern.test(n.value))return;n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),zp=ie("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Ip),co.init(e,t)}),kp=ie("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Pp),co.init(e,t)}),Bp=ie("$ZodCheckIncludes",(e,t)=>{nn.init(e,t);let n=Ji(t.includes),i=new RegExp(typeof t.position==="number"?`^.{${t.position},}${n}`:n);t.pattern=i,e._zod.check=(r)=>{if(r.value.includes(t.includes,t.position))return;r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),Gp=ie("$ZodCheckStartsWith",(e,t)=>{nn.init(e,t);let n=new RegExp(`^${Ji(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.check=(i)=>{if(i.value.startsWith(t.prefix))return;i.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:i.value,inst:e,continue:!t.abort})}}),Hp=ie("$ZodCheckEndsWith",(e,t)=>{nn.init(e,t);let n=new RegExp(`.*${Ji(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.check=(i)=>{if(i.value.endsWith(t.suffix))return;i.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:i.value,inst:e,continue:!t.abort})}});var Vp=ie("$ZodCheckOverwrite",(e,t)=>{nn.init(e,t),e._zod.check=(n)=>{n.value=t.tx(n.value)}});class Vl{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let n=e.split(`
1
+ function ro(e){let t=Object.values(e).filter((i)=>typeof i==="number");return Object.entries(e).filter(([i,r])=>t.indexOf(+i)===-1).map(([i,r])=>r)}function Al(e,t="|"){return e.map((n)=>Il(n)).join(t)}function so(e,t){if(typeof t==="bigint")return t.toString();return t}class Af{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;if(e!==void 0)this._value=e(),this._getter=void 0;return this._value}}function oo(e){return new Af(e)}function Rf(e){return e===null||e===void 0}function Aa(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Cf(e,t){let n=e/t,i=Math.round(n),r=4*Number.EPSILON*Math.max(Math.abs(n),1);if(Math.abs(n-i)<r)return 0;return n-i}function Dn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function ao(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function Ni(e){return ao(e._zod.def)??e._zod.def.shape}function If(e,t,n){Object.defineProperty(e,t,{get(){let i=n();return Dn(this,t,i),i},enumerable:!0,configurable:!0})}function Pf(e,t,n){if(t in e)Dn(e,t,n);else e[t]=n}function Nr(e,t,n,i){let r=Ni(t);for(let s of n){let o=Object.getOwnPropertyDescriptor(r,s);if(!o.enumerable)continue;if(o.get)If(e,s,()=>{let a=t._zod.def.shape[s];return i?i(a,s):a});else Pf(e,s,i?i(o.value,s):o.value)}}function Ub(e,t){for(let n of Reflect.ownKeys(t)){let i=Object.getOwnPropertyDescriptor(t,n);if(!i.enumerable)continue;if(i.get)If(e,n,()=>t[n]);else Pf(e,n,i.value)}}function Sn(...e){let t={};for(let n of e){let i=Object.getOwnPropertyDescriptors(n);Object.assign(t,i)}return Object.defineProperties({},t)}function Lf(e){return JSON.stringify(e)}function Nf(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Rl="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function as(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var Df=oo(()=>{if(xn.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function Dr(e){if(as(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;if(typeof t!=="function")return!0;let n=t.prototype;if(as(n)===!1)return!1;if(Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)return!1;return!0}function Cl(e){if(Dr(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}var Of=new Set(["string","number","symbol"]);function Qi(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ci(e,t,n){let i=new e._zod.constr(t??e._zod.def);if(!t||n?.parent)i._zod.parent=e;return i}function De(e){let t=e;if(!t)return{};if(typeof t==="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}if(delete t.message,typeof t.error==="string")return{...t,error:()=>t.error};return t}function Il(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function Uf(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var Ra=(()=>({safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]}))(),Pl={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Fb(e,t){let n=e._zod.def,i=n.checks;if(i&&i.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let s={};return Nr(s,e,Ca(e,t)),ci(e,Sn(n,{shape:s,checks:[]}))}function Ca(e,t){let n=Ni(e),i=[];for(let r of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,r)?.enumerable)throw Error(`Unrecognized key: "${String(r)}"`);if(t[r])i.push(r)}return i}function zb(e,t){let n=e._zod.def,i=n.checks;if(i&&i.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let s=new Set(Ca(e,t)),o={};return Nr(o,e,Reflect.ownKeys(Ni(e)).filter((a)=>!s.has(a))),ci(e,Sn(n,{shape:o,checks:[]}))}function kb(e,t){if(!Dr(t))throw Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let r=Ni(e);for(let s of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(r,s)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return ci(e,Sn(e._zod.def,{shape:Ff(e,t)}))}function Ff(e,t){let n={};return Nr(n,e,Reflect.ownKeys(Ni(e))),Ub(n,t),n}function Bb(e,t){if(!Dr(t))throw Error("Invalid input to safeExtend: expected a plain object");return ci(e,Sn(e._zod.def,{shape:Ff(e,t)}))}function Gb(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let n={};Nr(n,e,Reflect.ownKeys(Ni(e))),Nr(n,t,Reflect.ownKeys(Ni(t)));let i=Sn(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ci(e,i)}function zf(e,t,n,i="partial"){let s=t._zod.def.checks;if(s&&s.length>0)throw Error(`.${i}() cannot be used on object schemas containing refinements`);let a=n?new Set(Ca(t,n)):void 0,c={};return Nr(c,t,Reflect.ownKeys(Ni(t)),e&&((l,u)=>a&&!a.has(u)?l:new e({type:"optional",innerType:l}))),ci(t,Sn(t._zod.def,{shape:c,checks:[]}))}function Hb(e,t,n){let i=n?new Set(Ca(t,n)):void 0,r={};return Nr(r,t,Reflect.ownKeys(Ni(t)),(s,o)=>i&&!i.has(o)?s:new e({type:"nonoptional",innerType:s})),ci(t,Sn(t._zod.def,{shape:r}))}function li(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function kf(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function er(e,t){return t.map((n)=>{var i;return(i=n).path??(i.path=[]),n.path.unshift(e),n})}function io(e){return typeof e==="string"?e:e?.message}function Ll(e,t,n){var i;for(let r=t;r<e.length;r++)(i=e[r]).schema??(i.schema=n)}function ui(e,t,n){var i;let r=e.inst?._zod?.traits;if(r?.has("$ZodType"))if(r.has("$ZodCheck"))(i=e).schema??(i.schema=e.inst);else e.schema=e.inst;let s=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,o=e.message?e.message:io(e.inst?._zod.def?.error?.(e))??io(s?.(e))??io(t?.error?.(e))??io(n.customError?.(e))??io(n.localeError?.(e))??"Invalid input",a={};for(let c of Object.keys(e)){if(c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__")continue;a[c]=e[c]}if(a.path??(a.path=[]),a.message=o,t?.reportInput)a.input=e.input;return a}var Vb=/[\uD800-\uDBFF]/;function Ia(e){let t=e.length;if(!Vb.test(e))return t;let n=t;for(let i=0;i<t-1;i++)if((e.charCodeAt(i)&64512)===55296&&(e.charCodeAt(i+1)&64512)===56320)n--,i++;return n}function Pa(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function Bf(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}function Or(...e){let[t,n,i]=e;if(typeof t==="string")return{message:t,code:"custom",input:n,inst:i};return{...t}}function Gf(e,t){for(let n in t){let i=Object.getOwnPropertyDescriptor(t,n);if(i.get)Object.defineProperty(e,n,{...i,enumerable:!1});else $b(e,n,i.value)}}function Di(e,t,n,i=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:i,value:n}),n}function La(e,t,n){return Di(e,t,n,!1)}function Hf(e,t){for(let n in e){let i=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Di(this,n,i(this))},set(r){Di(this,n,r)}})}return t}function $b(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Di(this,t,n.bind(this))},set(i){Di(this,t,i)}})}function Wb(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var Tl,Ji=!1,Zb={configurable:!0,get(){Ji=!0;return}};function at(e,t,n){let i=Object.getPrototypeOf(e._zod);if(t in i&&Tl!==e._zod){Tl=void 0;return}Tl=e._zod,Object.defineProperty(i,t,{configurable:!0,get(){Object.defineProperty(this,t,Zb);let r=Ji;Ji=!1;try{let s=n(this);if(Ji)delete this[t];else Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s});return Ji=Ji||r,s}catch(s){throw delete this[t],Ji=Ji||r,s}},set(r){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r})}})}function Xb(e,t,n,i){let r=Wb(e,t);if(!r)return;Object.defineProperty(r,t,{configurable:!0,get(){let s={configurable:!0,writable:!0,enumerable:i,value:void 0};return Object.defineProperty(this,t,s),s.value=n(this),Object.defineProperty(this,t,s),s.value},set(s){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:i,value:s})}})}var jb="~constantCatch";function Vf(e){let t=()=>e;return t[jb]=!0,t}var $f;var Nl={value:void 0,enumerable:!1},Wf="captureStackTrace"in Error?Error:null;function qb(e){let t=Wf;if(t){let n=t.stackTraceLimit;if(typeof n==="number"){try{t.stackTraceLimit=0}catch{return Wf=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function ie(e,t,n,i){let r={};function s(d){this.def=d,this.constr=h,this.traits=new Set}s.prototype=r;let o=n,a=o&&new WeakSet;function c(d,f){if(!d._zod){Nl.value=new s(f);try{Object.defineProperty(d,"_zod",Nl)}finally{Nl.value=void 0}}else if(d._zod.traits.has(e))return;if(d._zod.traits.add(e),t(d,f),a){let _=Object.getPrototypeOf(d),p=d._zod.constr.prototype,g=_;while(g&&g!==p)g=Object.getPrototypeOf(g);let M=g??_;if(!a.has(M))a.add(M),Gf(M,o)}let m=h.prototype;for(let _ in m){if(!Object.prototype.hasOwnProperty.call(m,_))continue;if(!(_ in d))d[_]=m[_].bind(d)}}let l=i?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function h(d){let f=i?.Parent?qb(u):this;c(f,d);let m=f._zod.deferred;if(m){for(let p of m)p();f._zod.deferred=void 0}let _=globalThis.__zod_globalConfig?.postProcessor;if(_)_(f);return f}return Object.defineProperty(h,"init",{value:c}),Object.defineProperty(h,Symbol.hasInstance,{value:(d)=>{if(i?.Parent&&d instanceof i.Parent)return!0;return d?._zod?.traits?.has(e)}}),Object.defineProperty(h,"name",{value:e}),h}class hi extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class co extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}($f=globalThis).__zod_globalConfig??($f.__zod_globalConfig={});var xn=globalThis.__zod_globalConfig;function wn(e){if(e)Object.assign(xn,e);return xn}function Yb(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,so,2)),e.message}function Kb(e){this._zod.message=e}var Jb={get:Yb,set:Kb,enumerable:!0,configurable:!0},Ol={value:void 0,enumerable:!1},Zf=new WeakSet([Object.prototype,Error.prototype]),Xf=(e,t)=>{e.name="$ZodError",Ol.value=t,Object.defineProperty(e,"issues",Ol),Ol.value=void 0,Object.defineProperty(e,"message",Jb);let n=Object.getPrototypeOf(e);if(!Zf.has(n))Zf.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let i=()=>this.message;return Object.defineProperty(this,"toString",{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,"toString",{value:i,configurable:!0,writable:!0})}})},jf=ie("$ZodError",Xf),XC=ie("$ZodError",Xf,void 0,{Parent:Error});function Qb(e,t,n){if(!Object.prototype.hasOwnProperty.call(e,t))if(t==="__proto__")Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0});else e[t]=n();return e[t]}function qf(e,t=(n)=>n.message){let n={},i=[];for(let r of e.issues)if(r.path.length>0)Qb(n,r.path[0],()=>[]).push(t(r));else i.push(t(r));return{formErrors:i,fieldErrors:n}}function Yf(e,t=(n)=>n.message){let n={_errors:[]},i=(r,s=[])=>{for(let o of r.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map((a)=>i({issues:a},[...s,...o.path]));else if(o.code==="invalid_key")i({issues:o.issues},[...s,...o.path]);else if(o.code==="invalid_element")i({issues:o.issues},[...s,...o.path]);else{let a=[...s,...o.path];if(a.length===0)n._errors.push(t(o));else{let c=n,l=0;while(l<a.length){let u=a[l],h=l===a.length-1;if(u==="_errors"){if(h)c._errors.push(t(o));l++;continue}if(!Object.prototype.hasOwnProperty.call(c,u))Object.defineProperty(c,u,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let d=c[u];if(h)d._errors.push(t(o));c=d,l++}}}};return i(e),n}function Na(e,t){return{callee:t?.callee??e,Err:t?.Err}}var Da=(e)=>{let t=(n,i,r,s)=>{let o=r?{...r,async:!1}:{async:!1},a=n._zod.run({value:i,issues:[]},o);if(a instanceof Promise)throw new hi;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map((l)=>ui(l,o,wn())));throw Rl(c,s?.callee??t),c}return a.value};return t};var Oa=(e)=>{let t=async(n,i,r,s)=>{let o=r?{...r,async:!0}:{async:!0},a=n._zod.run({value:i,issues:[]},o);if(a instanceof Promise)a=await a;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map((l)=>ui(l,o,wn())));throw Rl(c,s?.callee??t),c}return a.value};return t};var Ua=(e)=>(t,n,i)=>{let r=i?{...i,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise)throw new hi;return s.issues.length?Kf(e,s.issues,r):{success:!0,data:s.value}};function Kf(e,t,n){let i;return{success:!1,get error(){if(!i)i=new e(t.map((r)=>ui(r,n,wn()))),t=void 0,n=void 0;return i},set error(r){i=r,t=void 0,n=void 0}}}var Fa=(e)=>async(t,n,i)=>{let r=i?{...i,async:!0}:{async:!0},s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise)s=await s;return s.issues.length?Kf(e,s.issues,r):{success:!0,data:s.value}};var eS=Symbol.for("zod.compile.invalid"),tS=Symbol.for("zod.compile.fallback"),Ul=(e,t,n)=>{let i=e._zod.bag.validator;if(i!==void 0){if(i(t)!==eS)return!0;if(i.definite===!0&&n===void 0)return!1}return nS(e,t,n)};function nS(e,t,n){let i=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},r=e._zod.bag.fallbackRun,s;if(r)i[tS]=!0,s=r({value:t,issues:[]},i);else s=e._zod.run({value:t,issues:[]},i);if(s instanceof Promise)throw new hi;return s.issues.length===0}var Fl=async(e,t,n)=>{let i=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},r=e._zod.run({value:t,issues:[]},i);if(r instanceof Promise)r=await r;return r.issues.length===0},Jf=(e)=>{let t=Da(e),n=(i,r,s,o)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return t(i,r,a,Na(n,o))};return n};var Qf=(e)=>{let t=Da(e),n=(i,r,s,o)=>t(i,r,s,Na(n,o));return n};var ep=(e)=>{let t=Oa(e),n=async(i,r,s,o)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return await t(i,r,a,Na(n,o))};return n};var tp=(e)=>{let t=Oa(e),n=async(i,r,s,o)=>await t(i,r,s,Na(n,o));return n};var np=(e)=>(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return Ua(e)(t,n,r)};var ip=(e)=>(t,n,i)=>Ua(e)(t,n,i);var rp=(e)=>async(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return Fa(e)(t,n,r)};var sp=(e)=>async(t,n,i)=>Fa(e)(t,n,i);var op=/^[cC][0-9a-z]{6,}$/,ap=/^[0-9a-z]+$/,cp=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,lp=/^[0-9a-vA-V]{20}$/,up=/^[A-Za-z0-9]{27}$/,hp=/^[a-zA-Z0-9_-]{21}$/;function dp(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var fp=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var pp=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,kl=(e)=>{if(!e)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var mp=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var iS="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function gp(){return new RegExp(iS,"u")}var _p=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,xp=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var vp=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,yp=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,bp=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Sp=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var wp=/^https?$/,Mp=/^\+[1-9]\d{6,14}$/;var Ep="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function rS(e){return new RegExp(`^${e}$`)}var Tp=rS(Ep);function zl(e){return typeof e.precision==="number"?e.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":e.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?":"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function Ap(e){return new RegExp(`^${zl(e)}$`)}function Rp(e){let t=["Z"];if(e.offset)t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${zl({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,i=e.local?`${n}|${zl({precision:e.precision})}`:n;return new RegExp(`^${Ep}T(?:${i})$`)}var Cp=/^[\s\S]{0,}$/;var Bl=/^-?\d+$/,lo=/^-?\d+(?:\.\d+)?$/,Ip=/^(?:true|false)$/i;var Pp=/^[^A-Z]*$/,Lp=/^[^a-z]*$/;var nn=ie("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])});var Gl=(e)=>{let t=e.value;return!Rf(t)&&t.length!==void 0},za={number:"number",bigint:"bigint",object:"date"},Hl=ie("$ZodCheckLessThan",(e,t)=>{nn.init(e,t);let n=za[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value<=t.value:i.value<t.value)return;i.issues.push({origin:za[typeof i.value]??n,code:"too_big",maximum:typeof t.value==="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Vl=ie("$ZodCheckGreaterThan",(e,t)=>{nn.init(e,t);let n=za[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value>=t.value:i.value>t.value)return;i.issues.push({origin:za[typeof i.value]??n,code:"too_small",minimum:typeof t.value==="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Np=ie("$ZodCheckMultipleOf",(e,t)=>{nn.init(e,t),e._zod.check=(n)=>{if(typeof n.value!==typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof n.value==="bigint"?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):Cf(n.value,t.value)===0)return;n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Dp=ie("$ZodCheckNumberFormat",(e,t)=>{nn.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),i=n?"int":"number",[r,s]=Ra[t.format];e._zod.check=(o)=>{let a=o.value;if(n){if(!Number.isInteger(a)){o.issues.push({expected:i,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){if(a>0)o.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort});else o.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort});return}}if(a<r)o.issues.push({origin:"number",input:a,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort});if(a>s)o.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var Op=ie("$ZodCheckMaxLength",(e,t)=>{var n;nn.init(e,t),(n=e._zod.def).when??(n.when=Gl),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>t.maximum?Ia(r):s)<=t.maximum)return;let a=Pa(r);i.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Up=ie("$ZodCheckMinLength",(e,t)=>{var n;nn.init(e,t),(n=e._zod.def).when??(n.when=Gl),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>=t.minimum&&s<t.minimum*2?Ia(r):s)>=t.minimum)return;let a=Pa(r);i.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Fp=ie("$ZodCheckLengthEquals",(e,t)=>{var n;nn.init(e,t),(n=e._zod.def).when??(n.when=Gl),e._zod.check=(i)=>{let r=i.value,s=r.length,o=typeof r==="string"&&s>=t.length&&s<=t.length*2?Ia(r):s;if(o===t.length)return;let a=Pa(r),c=o>t.length;i.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:i.value,inst:e,continue:!t.abort})}}),ho=ie("$ZodCheckStringFormat",(e,t)=>{var n,i;if(nn.init(e,t),t.pattern)(n=e._zod).check??(n.check=(r)=>{if(t.pattern.lastIndex=0,t.pattern.test(r.value))return;r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(i=e._zod).check??(i.check=()=>{})}),zp=ie("$ZodCheckRegex",(e,t)=>{ho.init(e,t),e._zod.check=(n)=>{if(t.pattern.lastIndex=0,t.pattern.test(n.value))return;n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),kp=ie("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Pp),ho.init(e,t)}),Bp=ie("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Lp),ho.init(e,t)}),Gp=ie("$ZodCheckIncludes",(e,t)=>{nn.init(e,t);let n=Qi(t.includes),i=new RegExp(typeof t.position==="number"?`^.{${t.position},}${n}`:n);t.pattern=i,e._zod.check=(r)=>{if(r.value.includes(t.includes,t.position))return;r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),Hp=ie("$ZodCheckStartsWith",(e,t)=>{nn.init(e,t);let n=new RegExp(`^${Qi(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.check=(i)=>{if(i.value.startsWith(t.prefix))return;i.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:i.value,inst:e,continue:!t.abort})}}),Vp=ie("$ZodCheckEndsWith",(e,t)=>{nn.init(e,t);let n=new RegExp(`.*${Qi(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.check=(i)=>{if(i.value.endsWith(t.suffix))return;i.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:i.value,inst:e,continue:!t.abort})}});var $p=ie("$ZodCheckOverwrite",(e,t)=>{nn.init(e,t),e._zod.check=(n)=>{n.value=t.tx(n.value)}});class $l{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let n=e.split(`
2
2
  `).filter((s)=>s),i=Math.min(...n.map((s)=>s.length-s.trimStart().length)),r=n.map((s)=>s.slice(i)).map((s)=>" ".repeat(this.indent*2)+s);for(let s of r)this.content.push(s)}compile(){let e=Function,t=this?.content??[""];return new e(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
3
3
  ${t.join(`
4
4
  `)}
5
- };`)(...Object.values(this.closed))}}var Wp={major:4,minor:6,patch:5};var Ct=ie("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Wp;let i=e._zod.def.checks,r=e._zod.traits.has("$ZodCheck")?[e,...i??[]]:i?.length?[...i]:[];for(let s of r)for(let o of s._zod.onattach)o(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let s=(a,c,l)=>{if(a.memo)return a;let u=li(a),h;for(let d of c){if(d._zod.def.when){if(zf(a))continue;if(!d._zod.def.when(a))continue}else if(u)continue;let f=a.issues.length,m=d._zod.check(a);if(m instanceof Promise&&l?.async===!1)throw new hi;if(h||m instanceof Promise)h=(h??Promise.resolve()).then(async()=>{if(await m,a.issues.length===f)return;if(Pl(a.issues,f,e),!u)u=li(a,f)});else{if(a.issues.length===f)continue;if(Pl(a.issues,f,e),!u)u=li(a,f)}}if(h)return h.then(()=>a);return a},o=(a,c,l)=>{if(li(a))return a.aborted=!0,a;let u=s(c,r,l);if(u instanceof Promise){if(l.async===!1)throw new hi;return u.then((h)=>e._zod.parse(h,l))}return e._zod.parse(u,l)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let u=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});if(u instanceof Promise)return u.then((h)=>o(h,a,c));return o(u,a,c)}let l=e._zod.parse(a,c);if(l instanceof Promise){if(c.async===!1)throw new hi;return l.then((u)=>s(u,r,c))}return s(l,r,c)}}},{get "~standard"(){return Ia(this,"~standard",Wl(this))},set "~standard"(e){Ni(this,"~standard",e)}}),nm=(e,t)=>e.issues.length?{issues:e.issues.map((n)=>ui(n,t,wn()))}:{value:e.value};async function iS(e,t){let n={async:!0};return nm(await e._zod.run({value:t,issues:[]},n),n)}function Wl(e){return{validate:(t)=>{let n={async:!1};try{let i=e._zod.run({value:t,issues:[]},n);if(!(i instanceof Promise))return nm(i,n)}catch(i){}return iS(e,t)},vendor:"zod",version:1}}var Ba=ie("$ZodString",(e,t)=>{Ct.init(e,t),e._zod.pattern=t.pattern??Rp,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=String(n.value)}catch(r){}if(typeof n.value==="string")return n;return n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),Tt=ie("$ZodStringFormat",(e,t)=>{co.init(e,t),Ba.init(e,t)}),im=ie("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=fp),Tt.init(e,t)}),rm=ie("$ZodUUID",(e,t)=>{if(t.version){let i={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(i===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=zl(i))}else t.pattern??(t.pattern=zl());Tt.init(e,t)}),sm=ie("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=pp),Tt.init(e,t)}),om=1,za=2;function am(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function rS(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return am(e)||za;return sS(e,t)}function sS(e,t){if(!t.normalize&&t.protocol?.source===Sp.source&&!/^https?:\/\//i.test(e))return om;try{if(typeof URL<"u"){let n=URL;if(typeof n.parse==="function")return n.parse(e)??za}return new URL(e)}catch{return za}}var oS=/[\t\n\r]/g;function Zp(e){return e.replace(oS,"")}function aS(e,t){return t.lastIndex=0,t.test(e.hostname)}function cS(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var cm=ie("$ZodURL",(e,t)=>{Tt.init(e,t),e._zod.check=(n)=>{try{let i=n.value.trim(),r=rS(i,t);if(r===om){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(r===za){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(r===!0){n.value=Zp(i);return}if(t.hostname&&!aS(r,t.hostname))n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort});if(t.protocol&&!cS(r,t.protocol))n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort});n.value=t.normalize?r.href:Zp(i);return}catch(i){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),lm=ie("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=mp()),Tt.init(e,t)}),um=ie("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?up:hp(t.length)),Tt.init(e,t)}),hm=ie("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=sp),Tt.init(e,t)}),dm=ie("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=op),Tt.init(e,t)}),fm=ie("$ZodULID",(e,t)=>{t.pattern??(t.pattern=ap),Tt.init(e,t)}),pm=ie("$ZodXID",(e,t)=>{t.pattern??(t.pattern=cp),Tt.init(e,t)}),mm=ie("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=lp),Tt.init(e,t)}),gm=ie("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Ap(t)),Tt.init(e,t)}),_m=ie("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Ep),Tt.init(e,t)}),xm=ie("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Tp(t)),Tt.init(e,t)}),vm=ie("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=dp),Tt.init(e,t)}),ym=ie("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=gp),Tt.init(e,t)}),lS=/^[0-9a-fA-F:.]+$/;function bm(e){if(!lS.test(e))return!1;return am(`http://[${e}]`)}var Sm=ie("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=_p),Tt.init(e,t),e._zod.check=(n)=>{if(!bm(n.value))n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}});var wm=ie("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=xp),Tt.init(e,t)});function uS(e){let t=e.split("/");if(t.length!==2)return!1;let[n,i]=t;if(!i)return!1;let r=Number(i);if(`${r}`!==i)return!1;if(r<0||r>128)return!1;return bm(n)}var Mm=ie("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=vp),Tt.init(e,t),e._zod.check=(n)=>{if(!uS(n.value))n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function Em(e){if(e==="")return!0;if(/\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Zl=/^[0-9a-zA-Z+/]*={0,2}$/,Tm=ie("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Zl),Tt.init(e,t),e._zod.check=(n)=>{if(Em(n.value))return;n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),Ga=/^[A-Za-z0-9_-]*$/;function hS(e){if(!Ga.test(e))return!1;let t=e.replace(/[-_]/g,(i)=>i==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Em(n)}var Am=ie("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Ga),Tt.init(e,t),e._zod.check=(n)=>{if(hS(n.value))return;n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Rm=ie("$ZodE164",(e,t)=>{t.pattern??(t.pattern=wp),Tt.init(e,t)});function dS(e,t=null){try{let n=e.split(".");if(n.length!==3)return!1;let[i]=n;if(!i)return!1;let r=JSON.parse(atob(i));if("typ"in r&&r?.typ!=="JWT")return!1;if(!r.alg)return!1;if(t&&(!("alg"in r)||r.alg!==t))return!1;return!0}catch{return!1}}var Cm=ie("$ZodJWT",(e,t)=>{Tt.init(e,t),e._zod.check=(n)=>{if(dS(n.value,t.alg))return;n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}});var Xl=ie("$ZodNumber",(e,t)=>{Ct.init(e,t),e._zod.pattern=oo,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=Number(n.value)}catch(o){}let r=n.value;if(typeof r==="number"&&!Number.isNaN(r)&&Number.isFinite(r))return n;let s=typeof r==="number"?Number.isNaN(r)?"NaN":!Number.isFinite(r)?String(r):void 0:void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...s?{received:s}:{}}),n}}),Im=ie("$ZodNumberFormat",(e,t)=>{Np.init(e,t),Xl.init(e,t)}),Pm=ie("$ZodBoolean",(e,t)=>{Ct.init(e,t),e._zod.pattern=Cp,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(s){}let r=n.value;if(typeof r==="boolean")return n;return n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),n}});var Lm=ie("$ZodUnknown",(e,t)=>{Ct.init(e,t),e._zod.parse=(n)=>n}),Nm=ie("$ZodNever",(e,t)=>{Ct.init(e,t),e._zod.parse=(n,i)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Xp(e,t,n){if(e.issues.length)t.issues.push(...Qi(n,e.issues));t.value[n]=e.value}var Dm=ie("$ZodArray",(e,t)=>{Ct.init(e,t);let n=xn.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let s=i.value;if(!Array.isArray(s))return i.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),i;i.value=n?n.alloc(e,i,Array(s.length),r):Array(s.length);let o=[],a=r?.abortEarly;for(let c=0;c<s.length;c++){let l=s[c],u=t.element._zod.run({value:l,issues:[]},r);if(u instanceof Promise)o.push(u.then((h)=>Xp(h,i,c)));else if(Xp(u,i,c),a&&u.issues.length!==0&&li(u))break}if(o.length)return Promise.all(o).then(()=>i);return i}});function ka(e,t,n,i,r,s){let o=n in i,a=s==="optional";if(!o&&a&&r==="optional")return;if(e.issues.length){if(r!==void 0&&a&&!o)return;t.issues.push(...Qi(n,e.issues))}if(!o&&r===void 0){if(!e.issues.length)t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}if(e.value===void 0){if(o||r==="defaulted"&&!a)t.value[n]=void 0}else t.value[n]=e.value}var fS=[];function Om(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),i=n.length?n:fS,r=i.length?[...t,...i]:t;for(let o of r)if(!e.shape?.[o]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(o)}": expected a Zod schema`);let s=Of(e.shape);return{...e,allKeys:r,symbolKeys:i,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function Um(e,t,n,i,r,s,o){let a=[],c=r.keySet,l=r.catchall._zod,u=l.def.type,{optin:h,optout:d}=l,f=0;for(let m in t){if(o&&n.issues.length!==f){if(li(n,f))break;f=n.issues.length}if(c.has(m))continue;if(m==="__proto__"){if(u==="never")a.push(m);continue}if(u==="never"){a.push(m);continue}let _=l.run({value:t[m],issues:[]},i);if(_ instanceof Promise)e.push(_.then((p)=>ka(p,n,m,t,h,d)));else ka(_,n,m,t,h,d)}if(a.length)n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s,continue:!0});if(!e.length)return n;return Promise.all(e).then(()=>n)}var pS=ie("$ZodObject",(e,t)=>{Ct.init(e,t);let n=Object.getOwnPropertyDescriptor(t,"shape"),i=n?.get?n.get.raw:t.shape??{};if(i){let l=()=>{let u={...i};return Object.defineProperty(t,"shape",{value:u}),l.raw=u,u};l.raw=i,Object.defineProperty(t,"shape",{get:l})}let r=io(()=>Om(t));at(e,"propValues",(l)=>{let u=l.def.shape,h={};for(let d in u){let f=u[d]._zod;if(f.values){if(!Object.prototype.hasOwnProperty.call(h,d))Dn(h,d,new Set);for(let m of f.values)h[d].add(m);if(f.optin!==void 0)h[d].add(void 0)}}return h});let s=os,o=t.catchall,a,c=xn.memoizer;c?.attach(e),e._zod.parse=(l,u)=>{a??(a=r.value);let h=l.value;if(!s(h))return l.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),l;l.value=c?c.alloc(e,l,{},u):{};let d=[],f=a.shape,m=u?.abortEarly,_=l.issues.length;for(let p of a.allKeys){if(m&&l.issues.length!==_){if(li(l,_))break;_=l.issues.length}if(p==="__proto__")continue;let g=f[p],M=g._zod.optin,T=g._zod.optout,v=g._zod.run({value:h[p],issues:[]},u);if(v instanceof Promise)d.push(v.then((S)=>ka(S,l,p,h,M,T)));else ka(v,l,p,h,M,T)}if(!o)return d.length?Promise.all(d).then(()=>l):l;return Um(d,h,l,u,r.value,e,m===!0)}}),Fm=ie("$ZodObjectJIT",(e,t)=>{pS.init(e,t);let n=e._zod.parse,i=io(()=>Om(t)),r=xn.memoizer,s=(f)=>{let m=i.value,_=m.symbolKeys,p=new Vl(["payload","ctx"],{shape:f,inst:e,memo:r,syms:_}),g=(S)=>`shape[${S}]._zod.run({ value: input[${S}], issues: [] }, ctx)`,M=(S,E)=>`
5
+ };`)(...Object.values(this.closed))}}var Zp={major:4,minor:6,patch:5};var Ct=ie("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Zp;let i=e._zod.def.checks,r=e._zod.traits.has("$ZodCheck")?[e,...i??[]]:i?.length?[...i]:[];for(let s of r)for(let o of s._zod.onattach)o(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let s=(a,c,l)=>{if(a.memo)return a;let u=li(a),h;for(let d of c){if(d._zod.def.when){if(kf(a))continue;if(!d._zod.def.when(a))continue}else if(u)continue;let f=a.issues.length,m=d._zod.check(a);if(m instanceof Promise&&l?.async===!1)throw new hi;if(h||m instanceof Promise)h=(h??Promise.resolve()).then(async()=>{if(await m,a.issues.length===f)return;if(Ll(a.issues,f,e),!u)u=li(a,f)});else{if(a.issues.length===f)continue;if(Ll(a.issues,f,e),!u)u=li(a,f)}}if(h)return h.then(()=>a);return a},o=(a,c,l)=>{if(li(a))return a.aborted=!0,a;let u=s(c,r,l);if(u instanceof Promise){if(l.async===!1)throw new hi;return u.then((h)=>e._zod.parse(h,l))}return e._zod.parse(u,l)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let u=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});if(u instanceof Promise)return u.then((h)=>o(h,a,c));return o(u,a,c)}let l=e._zod.parse(a,c);if(l instanceof Promise){if(c.async===!1)throw new hi;return l.then((u)=>s(u,r,c))}return s(l,r,c)}}},{get "~standard"(){return La(this,"~standard",Zl(this))},set "~standard"(e){Di(this,"~standard",e)}}),im=(e,t)=>e.issues.length?{issues:e.issues.map((n)=>ui(n,t,wn()))}:{value:e.value};async function sS(e,t){let n={async:!0};return im(await e._zod.run({value:t,issues:[]},n),n)}function Zl(e){return{validate:(t)=>{let n={async:!1};try{let i=e._zod.run({value:t,issues:[]},n);if(!(i instanceof Promise))return im(i,n)}catch(i){}return sS(e,t)},vendor:"zod",version:1}}var Ha=ie("$ZodString",(e,t)=>{Ct.init(e,t),e._zod.pattern=t.pattern??Cp,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=String(n.value)}catch(r){}if(typeof n.value==="string")return n;return n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),Tt=ie("$ZodStringFormat",(e,t)=>{ho.init(e,t),Ha.init(e,t)}),rm=ie("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=pp),Tt.init(e,t)}),sm=ie("$ZodUUID",(e,t)=>{if(t.version){let i={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(i===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=kl(i))}else t.pattern??(t.pattern=kl());Tt.init(e,t)}),om=ie("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=mp),Tt.init(e,t)}),am=1,Ba=2;function cm(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function oS(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return cm(e)||Ba;return aS(e,t)}function aS(e,t){if(!t.normalize&&t.protocol?.source===wp.source&&!/^https?:\/\//i.test(e))return am;try{if(typeof URL<"u"){let n=URL;if(typeof n.parse==="function")return n.parse(e)??Ba}return new URL(e)}catch{return Ba}}var cS=/[\t\n\r]/g;function Xp(e){return e.replace(cS,"")}function lS(e,t){return t.lastIndex=0,t.test(e.hostname)}function uS(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var lm=ie("$ZodURL",(e,t)=>{Tt.init(e,t),e._zod.check=(n)=>{try{let i=n.value.trim(),r=oS(i,t);if(r===am){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(r===Ba){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(r===!0){n.value=Xp(i);return}if(t.hostname&&!lS(r,t.hostname))n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort});if(t.protocol&&!uS(r,t.protocol))n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort});n.value=t.normalize?r.href:Xp(i);return}catch(i){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),um=ie("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=gp()),Tt.init(e,t)}),hm=ie("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?hp:dp(t.length)),Tt.init(e,t)}),dm=ie("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=op),Tt.init(e,t)}),fm=ie("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=ap),Tt.init(e,t)}),pm=ie("$ZodULID",(e,t)=>{t.pattern??(t.pattern=cp),Tt.init(e,t)}),mm=ie("$ZodXID",(e,t)=>{t.pattern??(t.pattern=lp),Tt.init(e,t)}),gm=ie("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=up),Tt.init(e,t)}),_m=ie("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Rp(t)),Tt.init(e,t)}),xm=ie("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Tp),Tt.init(e,t)}),vm=ie("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Ap(t)),Tt.init(e,t)}),ym=ie("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=fp),Tt.init(e,t)}),bm=ie("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=_p),Tt.init(e,t)}),hS=/^[0-9a-fA-F:.]+$/;function Sm(e){if(!hS.test(e))return!1;return cm(`http://[${e}]`)}var wm=ie("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=xp),Tt.init(e,t),e._zod.check=(n)=>{if(!Sm(n.value))n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}});var Mm=ie("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=vp),Tt.init(e,t)});function dS(e){let t=e.split("/");if(t.length!==2)return!1;let[n,i]=t;if(!i)return!1;let r=Number(i);if(`${r}`!==i)return!1;if(r<0||r>128)return!1;return Sm(n)}var Em=ie("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=yp),Tt.init(e,t),e._zod.check=(n)=>{if(!dS(n.value))n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function Tm(e){if(e==="")return!0;if(/\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Xl=/^[0-9a-zA-Z+/]*={0,2}$/,Am=ie("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Xl),Tt.init(e,t),e._zod.check=(n)=>{if(Tm(n.value))return;n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),Va=/^[A-Za-z0-9_-]*$/;function fS(e){if(!Va.test(e))return!1;let t=e.replace(/[-_]/g,(i)=>i==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Tm(n)}var Rm=ie("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Va),Tt.init(e,t),e._zod.check=(n)=>{if(fS(n.value))return;n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Cm=ie("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Mp),Tt.init(e,t)});function pS(e,t=null){try{let n=e.split(".");if(n.length!==3)return!1;let[i]=n;if(!i)return!1;let r=JSON.parse(atob(i));if("typ"in r&&r?.typ!=="JWT")return!1;if(!r.alg)return!1;if(t&&(!("alg"in r)||r.alg!==t))return!1;return!0}catch{return!1}}var Im=ie("$ZodJWT",(e,t)=>{Tt.init(e,t),e._zod.check=(n)=>{if(pS(n.value,t.alg))return;n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}});var jl=ie("$ZodNumber",(e,t)=>{Ct.init(e,t),e._zod.pattern=lo,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=Number(n.value)}catch(o){}let r=n.value;if(typeof r==="number"&&!Number.isNaN(r)&&Number.isFinite(r))return n;let s=typeof r==="number"?Number.isNaN(r)?"NaN":!Number.isFinite(r)?String(r):void 0:void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...s?{received:s}:{}}),n}}),Pm=ie("$ZodNumberFormat",(e,t)=>{Dp.init(e,t),jl.init(e,t)}),Lm=ie("$ZodBoolean",(e,t)=>{Ct.init(e,t),e._zod.pattern=Ip,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(s){}let r=n.value;if(typeof r==="boolean")return n;return n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),n}});var Nm=ie("$ZodUnknown",(e,t)=>{Ct.init(e,t),e._zod.parse=(n)=>n}),Dm=ie("$ZodNever",(e,t)=>{Ct.init(e,t),e._zod.parse=(n,i)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function jp(e,t,n){if(e.issues.length)t.issues.push(...er(n,e.issues));t.value[n]=e.value}var Om=ie("$ZodArray",(e,t)=>{Ct.init(e,t);let n=xn.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let s=i.value;if(!Array.isArray(s))return i.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),i;i.value=n?n.alloc(e,i,Array(s.length),r):Array(s.length);let o=[],a=r?.abortEarly;for(let c=0;c<s.length;c++){let l=s[c],u=t.element._zod.run({value:l,issues:[]},r);if(u instanceof Promise)o.push(u.then((h)=>jp(h,i,c)));else if(jp(u,i,c),a&&u.issues.length!==0&&li(u))break}if(o.length)return Promise.all(o).then(()=>i);return i}});function Ga(e,t,n,i,r,s){let o=n in i,a=s==="optional";if(!o&&a&&r==="optional")return;if(e.issues.length){if(r!==void 0&&a&&!o)return;t.issues.push(...er(n,e.issues))}if(!o&&r===void 0){if(!e.issues.length)t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}if(e.value===void 0){if(o||r==="defaulted"&&!a)t.value[n]=void 0}else t.value[n]=e.value}var mS=[];function Um(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),i=n.length?n:mS,r=i.length?[...t,...i]:t;for(let o of r)if(!e.shape?.[o]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(o)}": expected a Zod schema`);let s=Uf(e.shape);return{...e,allKeys:r,symbolKeys:i,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function Fm(e,t,n,i,r,s,o){let a=[],c=r.keySet,l=r.catchall._zod,u=l.def.type,{optin:h,optout:d}=l,f=0;for(let m in t){if(o&&n.issues.length!==f){if(li(n,f))break;f=n.issues.length}if(c.has(m))continue;if(m==="__proto__"){if(u==="never")a.push(m);continue}if(u==="never"){a.push(m);continue}let _=l.run({value:t[m],issues:[]},i);if(_ instanceof Promise)e.push(_.then((p)=>Ga(p,n,m,t,h,d)));else Ga(_,n,m,t,h,d)}if(a.length)n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s,continue:!0});if(!e.length)return n;return Promise.all(e).then(()=>n)}var gS=ie("$ZodObject",(e,t)=>{Ct.init(e,t);let n=Object.getOwnPropertyDescriptor(t,"shape"),i=n?.get?n.get.raw:t.shape??{};if(i){let l=()=>{let u={...i};return Object.defineProperty(t,"shape",{value:u}),l.raw=u,u};l.raw=i,Object.defineProperty(t,"shape",{get:l})}let r=oo(()=>Um(t));at(e,"propValues",(l)=>{let u=l.def.shape,h={};for(let d in u){let f=u[d]._zod;if(f.values){if(!Object.prototype.hasOwnProperty.call(h,d))Dn(h,d,new Set);for(let m of f.values)h[d].add(m);if(f.optin!==void 0)h[d].add(void 0)}}return h});let s=as,o=t.catchall,a,c=xn.memoizer;c?.attach(e),e._zod.parse=(l,u)=>{a??(a=r.value);let h=l.value;if(!s(h))return l.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),l;l.value=c?c.alloc(e,l,{},u):{};let d=[],f=a.shape,m=u?.abortEarly,_=l.issues.length;for(let p of a.allKeys){if(m&&l.issues.length!==_){if(li(l,_))break;_=l.issues.length}if(p==="__proto__")continue;let g=f[p],M=g._zod.optin,T=g._zod.optout,v=g._zod.run({value:h[p],issues:[]},u);if(v instanceof Promise)d.push(v.then((S)=>Ga(S,l,p,h,M,T)));else Ga(v,l,p,h,M,T)}if(!o)return d.length?Promise.all(d).then(()=>l):l;return Fm(d,h,l,u,r.value,e,m===!0)}}),zm=ie("$ZodObjectJIT",(e,t)=>{gS.init(e,t);let n=e._zod.parse,i=oo(()=>Um(t)),r=xn.memoizer,s=(f)=>{let m=i.value,_=m.symbolKeys,p=new $l(["payload","ctx"],{shape:f,inst:e,memo:r,syms:_}),g=(S)=>`shape[${S}]._zod.run({ value: input[${S}], issues: [] }, ctx)`,M=(S,E)=>`
6
6
  let ${S}_ab = false;
7
7
  for (let i = 0; i < ${S}.issues.length; i++) {
8
8
  const iss = ${S}.issues[i];
@@ -13,7 +13,7 @@ ${t.join(`
13
13
  if (${S}_ab && ctx && ctx.abortEarly) {
14
14
  payload.value = newResult;
15
15
  return payload;
16
- }`;p.write("const input = payload.value;");let T=Object.create(null),v=0;for(let S of m.allKeys)T[S]=`key_${v++}`;p.write(r?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let S of m.allKeys){if(S==="__proto__")continue;let E=T[S],R=typeof S==="symbol"?`syms[${_.indexOf(S)}]`:Pf(S),x=`${R} in input`,w=f[S],H=w?._zod?.optin,C=H!==void 0,N=w?._zod?.optout==="optional";if(p.write(`const ${E} = ${g(R)};`),C&&N){let ee=H==="optional"?`${E}_present`:`${E}.value !== undefined || ${E}_present`;p.write(`
16
+ }`;p.write("const input = payload.value;");let T=Object.create(null),v=0;for(let S of m.allKeys)T[S]=`key_${v++}`;p.write(r?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let S of m.allKeys){if(S==="__proto__")continue;let E=T[S],R=typeof S==="symbol"?`syms[${_.indexOf(S)}]`:Lf(S),x=`${R} in input`,w=f[S],G=w?._zod?.optin,C=G!==void 0,D=w?._zod?.optout==="optional";if(p.write(`const ${E} = ${g(R)};`),C&&D){let ee=G==="optional"?`${E}_present`:`${E}.value !== undefined || ${E}_present`;p.write(`
17
17
  const ${E}_present = ${x};
18
18
  if (!${E}.issues.length || ${E}_present) {
19
19
  if (${E}.issues.length) {${M(E,R)}
@@ -48,24 +48,24 @@ ${t.join(`
48
48
  `);else if(p.write(`
49
49
  if (${E}.issues.length) {${M(E,R)}
50
50
  }
51
- `),H==="defaulted")p.write(`newResult[${R}] = ${E}.value;`);else p.write(`
51
+ `),G==="defaulted")p.write(`newResult[${R}] = ${E}.value;`);else p.write(`
52
52
  if (${E}.value !== undefined || ${x}) {
53
53
  newResult[${R}] = ${E}.value;
54
54
  }
55
- `)}return p.write("payload.value = newResult;"),p.write("return payload;"),p.compile()},o,a=os,c=!xn.jitless,u=c&&Nf.value,h=t.catchall,d;e._zod.parse=(f,m)=>{d??(d=i.value);let _=f.value;if(!a(_))return f.issues.push({expected:"object",code:"invalid_type",input:_,inst:e}),f;if(c&&u&&m?.async===!1&&m.jitless!==!0){if(!o)o=s(t.shape);if(f=o(f,m),!h)return f;return Um([],_,f,m,d,e,m?.abortEarly===!0)}return n(f,m)}});function jp(e,t,n,i){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let r=e.filter((s)=>!li(s));if(r.length===1)return t.value=r[0].value,r[0];return t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map((s)=>s.issues.map((o)=>ui(o,i,wn())))}),t}var jl=ie("$ZodUnion",(e,t)=>{Ct.init(e,t),at(e,"optin",(i)=>i.def.options.some((r)=>r._zod.optin==="defaulted")?"defaulted":i.def.options.some((r)=>r._zod.optin!==void 0)?"optional":void 0),at(e,"optout",(i)=>i.def.options.some((r)=>r._zod.optout==="optional")?"optional":void 0),at(e,"values",(i)=>{if(i.def.options.every((r)=>r._zod.values))return new Set(i.def.options.flatMap((r)=>Array.from(r._zod.values)));return}),at(e,"pattern",(i)=>{if(i.def.options.every((r)=>r._zod.pattern)){let r=i.def.options.map((s)=>s._zod.pattern);return new RegExp(`^(${r.map((s)=>Ea(s.source)).join("|")})$`)}return});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(i,r)=>{if(n)return n(i,r);let s=!1,o=[];for(let a of t.options){let c=a._zod.run({value:i.value,issues:[]},r);if(c instanceof Promise)o.push(c),s=!0;else{if(c.issues.length===0)return c;o.push(c)}}if(!s)return jp(o,i,e,r);return Promise.all(o).then((a)=>jp(a,i,e,r))}});function mS(e){let t=new Map;for(let n of e.options){let i=n._zod.propValues?.[e.discriminator];if(!i||i.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let r of i)if(t.has(r)){if(r!==void 0)throw Error(`Duplicate discriminator value "${String(r)}"`);t.set(r,null)}else t.set(r,n)}return t}var zm=ie("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,jl.init(e,t);let n=e._zod.parse;at(e,"propValues",(r)=>{let s={},o=0;for(let a of r.def.options){let c=a._zod.propValues;if(!c||Object.keys(c).length===0)throw Error(`Invalid discriminated union option at index "${r.def.options.indexOf(a)}"`);if(c[r.def.discriminator]?.has(void 0))o++;for(let[l,u]of Object.entries(c)){if(!Object.prototype.hasOwnProperty.call(s,l))Dn(s,l,new Set);for(let h of u)s[l].add(h)}}if(!r.def.unionFallback&&o>1)s[r.def.discriminator]?.delete(void 0);return s}),t.options.forEach((r,s)=>{let o=ro(r._zod.def);if(o&&!Object.prototype.hasOwnProperty.call(o,t.discriminator))throw Error(`Invalid discriminated union option at index "${s}"`)});let i=io(()=>mS(t));e._zod.parse=(r,s)=>{let o=r.value;if(!os(o))return r.issues.push({code:"invalid_type",expected:"object",input:o,inst:e}),r;let a=o?.[t.discriminator],c=i.value.get(a);if(c&&(a!==void 0||s.direction!=="backward"))return c._zod.run(r,s);if(t.unionFallback||s.direction==="backward")return n(r,s);return r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(i.value.keys()).filter((l)=>i.value.get(l)!==null),input:o,path:[t.discriminator],inst:e}),r}}),km=ie("$ZodIntersection",(e,t)=>{Ct.init(e,t),e._zod.parse=(n,i)=>{let r=n.value,s=t.left._zod.run({value:r,issues:[]},i),o=t.right._zod.run({value:r,issues:[]},i);if(s instanceof Promise||o instanceof Promise)return Promise.all([s,o]).then(([c,l])=>qp(n,c,l));return qp(n,s,o)}});function $l(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(Nr(e)&&Nr(t)){let n=Object.keys(t),i=Object.keys(e).filter((s)=>n.indexOf(s)!==-1),r={...e,...t};if(Object.prototype.hasOwnProperty.call(r,"__proto__"))delete r.__proto__;for(let s of i){if(s==="__proto__")continue;let o=$l(e[s],t[s]);if(!o.valid)return{valid:!1,mergeErrorPath:[s,...o.mergeErrorPath]};r[s]=o.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let i=0;i<e.length;i++){let r=e[i],s=t[i],o=$l(r,s);if(!o.valid)return{valid:!1,mergeErrorPath:[i,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function qp(e,t,n){let i=new Map,r,s=new Map,o=(l,u)=>{let h;if(l.code==="unrecognized_keys"&&!l.path?.length)r??(r=l),h=l.keys;else if(l.code==="invalid_key"&&l.origin==="record"&&l.path?.length===1){let d=String(l.path[0]);if(!s.has(d))s.set(d,l);h=[d]}else return!1;for(let d of h){if(!i.has(d))i.set(d,{});i.get(d)[u]=!0}return!0};for(let l of t.issues)if(!o(l,"l"))e.issues.push(l);for(let l of n.issues)if(!o(l,"r"))e.issues.push(l);let a=[...i].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(a.length){let l=r?a.filter((u)=>r.keys.includes(u)):[];if(l.length)e.issues.push({...r,keys:l});for(let u of a)if(!l.includes(u)&&s.has(u))e.issues.push(s.get(u))}let c=$l(t.value,n.value);if(!c.valid){if(li(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Bm=ie("$ZodRecord",(e,t)=>{Ct.init(e,t);let n=xn.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let s=i.value;if(!Nr(s))return i.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),i;let o=[],a=t.keyType._zod.values;if(a&&!t.partial){i.value=n?n.alloc(e,i,{},r):{};let c=new Set;for(let u of a)if(typeof u==="string"||typeof u==="number"||typeof u==="symbol"){if(c.add(typeof u==="number"?u.toString():u),u==="__proto__")continue;let h=t.keyType._zod.run({value:u,issues:[]},r);if(h instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(h.issues.length){i.issues.push({code:"invalid_key",origin:"record",issues:h.issues.map((m)=>ui(m,r,wn())),input:u,path:[u],inst:e});continue}let d=h.value;if(d==="__proto__")continue;let f=t.valueType._zod.run({value:s[u],issues:[]},r);if(f instanceof Promise)o.push(f.then((m)=>{if(m.issues.length)i.issues.push(...Qi(u,m.issues));i.value[d]=m.value}));else{if(f.issues.length)i.issues.push(...Qi(u,f.issues));i.value[d]=f.value}}let l;for(let u in s)if(!c.has(u))if(t.mode==="loose"){if(u==="__proto__")continue;i.value[u]=s[u]}else l=l??[],l.push(u);if(l&&l.length>0)i.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:l,continue:!0})}else{i.value=n?n.alloc(e,i,{},r):{};let c;for(let l of Reflect.ownKeys(s)){if(l==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(s,l))continue;let u=t.keyType._zod.run({value:l,issues:[]},r);if(u instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof l==="string"&&oo.test(l)&&u.issues.length){let m=t.keyType._zod.run({value:Number(l),issues:[]},r);if(m instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(m.issues.length===0)u=m}if(u.issues.length){if(t.mode==="loose")i.value[l]=s[l];else if(a)c=c??[],c.push(l);else i.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map((m)=>ui(m,r,wn())),input:l,path:[l],inst:e});continue}let d=u.value;if(d==="__proto__")continue;let f=t.valueType._zod.run({value:s[l],issues:[]},r);if(f instanceof Promise)o.push(f.then((m)=>{if(m.issues.length)i.issues.push(...Qi(l,m.issues));i.value[d]=m.value}));else{if(f.issues.length)i.issues.push(...Qi(l,f.issues));i.value[d]=f.value}}if(c&&c.length>0)i.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c,continue:!0})}if(o.length)return Promise.all(o).then(()=>i);return i}});var Gm=ie("$ZodEnum",(e,t)=>{Ct.init(e,t);let n=to(t.entries),i=new Set(n);e._zod.values=i,at(e,"pattern",(r)=>{let s=to(r.def.entries).filter((o)=>Df.has(typeof o));return new RegExp(s.length?`^(${s.map((o)=>Ji(o.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(r,s)=>{let o=r.value;if(i.has(o))return r;return r.issues.push({code:"invalid_value",values:n,input:o,inst:e}),r}}),Hm=ie("$ZodLiteral",(e,t)=>{Ct.init(e,t);let n=new Set(t.values);e._zod.values=n,at(e,"pattern",(i)=>{let r=i.def.values;return new RegExp(r.length?`^(${r.map((s)=>typeof s==="string"?Ji(s):s?Ji(s.toString()):String(s)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(i,r)=>{let s=i.value;if(n.has(s))return i;return i.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),i}});var Vm=ie("$ZodTransform",(e,t)=>{Ct.init(e,t),e._zod.optin="optional",xn.memoizer?.guard(e),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new so(e.constructor.name);let r=t.transform(n.value,n);if(i.async)return(r instanceof Promise?r:Promise.resolve(r)).then((o)=>(n.value=o,n));if(r instanceof Promise)throw new hi;return n.value=r,n}});function Yp(e,t){return e.value=t.issues.length?void 0:t.value,e}var ql=ie("$ZodOptional",(e,t)=>{Ct.init(e,t),at(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",at(e,"values",(n)=>{let i=n.def.innerType._zod.values;return i?new Set([...i,void 0]):void 0}),at(e,"pattern",(n)=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${Ea(i.source)})?$`):void 0}),e._zod.parse=(n,i)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;let r=t.innerType._zod.run({value:n.value,issues:[]},i);if(r instanceof Promise)return r.then((s)=>Yp(n,s));return Yp(n,r)}return t.innerType._zod.run(n,i)}}),$m=ie("$ZodExactOptional",(e,t)=>{ql.init(e,t),at(e,"values",(n)=>n.def.innerType._zod.values),at(e,"pattern",(n)=>n.def.innerType._zod.pattern),e._zod.parse=(n,i)=>t.innerType._zod.run(n,i)}),Wm=ie("$ZodNullable",(e,t)=>{Ct.init(e,t),at(e,"optin",(n)=>n.def.innerType._zod.optin),at(e,"optout",(n)=>n.def.innerType._zod.optout),at(e,"pattern",(n)=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${Ea(i.source)}|null)$`):void 0}),at(e,"values",(n)=>n.def.innerType._zod.values?new Set([...n.def.innerType._zod.values,null]):void 0),e._zod.parse=(n,i)=>{if(n.value===null)return n;return t.innerType._zod.run(n,i)}}),Zm=ie("$ZodDefault",(e,t)=>{Ct.init(e,t),e._zod.optin="defaulted",at(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);if(n.value===void 0)return n.value=t.defaultValue,n;let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>Kp(s,t));return Kp(r,t)}});function Kp(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var Xm=ie("$ZodPrefault",(e,t)=>{Ct.init(e,t),e._zod.optin="defaulted",at(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);if(n.value===void 0)n.value=t.defaultValue;return t.innerType._zod.run(n,i)}}),jm=ie("$ZodNonOptional",(e,t)=>{Ct.init(e,t),at(e,"values",(n)=>{let i=n.def.innerType._zod.values;return i?new Set([...i].filter((r)=>r!==void 0)):void 0}),e._zod.parse=(n,i)=>{let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>Jp(s,e));return Jp(r,e)}});function Jp(e,t){if(!e.issues.length&&e.value===void 0)e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t});return e}function Qp(e,t,n,i){if(!t.issues.length){if(e.value=t.value,t.memo)e.memo=!0;return e}return e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map((r)=>ui(r,i,wn()))},input:e.value}),e}var qm=ie("$ZodCatch",(e,t)=>{Ct.init(e,t),at(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),at(e,"optout",(n)=>n.def.innerType._zod.optout),at(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);let r=t.innerType._zod.run({value:n.value,issues:[]},i);if(r instanceof Promise)return r.then((s)=>Qp(n,s,t,i));return Qp(n,r,t,i)}});var Ym=ie("$ZodPipe",(e,t)=>{Ct.init(e,t),at(e,"values",(n)=>n.def.in._zod.values),at(e,"optin",(n)=>n.def.in._zod.optin),at(e,"optout",(n)=>n.def.out._zod.optout),at(e,"propValues",(n)=>n.def.in._zod.propValues),e._zod.parse=(n,i)=>{if(i.direction==="backward"){let s=t.out._zod.run(n,i);if(s instanceof Promise)return s.then((o)=>Fa(o,t.in,i));return Fa(s,t.in,i)}let r=t.in._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>Fa(s,t.out,i));return Fa(r,t.out,i)}});function Fa(e,t,n){if(e.issues.some((i)=>i.code!=="unrecognized_keys"))return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues},n)}var Km=ie("$ZodReadonly",(e,t)=>{Ct.init(e,t),at(e,"propValues",(n)=>n.def.innerType._zod.propValues),at(e,"values",(n)=>n.def.innerType._zod.values),at(e,"optin",(n)=>n.def.innerType?._zod?.optin),at(e,"optout",(n)=>n.def.innerType?._zod?.optout),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then(em);return em(r)}});function em(e){if(!e.memo)e.value=Object.freeze(e.value);return e}var Jm=ie("$ZodCustom",(e,t)=>{nn.init(e,t),Ct.init(e,t),e._zod.parse=(n,i)=>n,e._zod.check=(n)=>{let i=n.value,r=t.fn(i);if(r instanceof Promise)return r.then((s)=>tm(s,n,i,e));tm(r,n,i,e);return}});function tm(e,t,n,i){if(!e){let r={code:"custom",input:n,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};if(i._zod.def.params)r.params=i._zod.def.params;t.issues.push(Dr(r))}}class eg extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var Kl="~memo",Qm=[];function tg(e){return e!==null&&typeof e==="object"}function Yl(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var ng=new WeakMap,lo=0,$a=1,uo=2;function Wa(e,t,n){let i=ng.get(e);if(i!==void 0)return i?uo:lo;if(t.has(e))return uo;t.add(e);let r=lo,s=(u)=>{if(r!==uo&&u?._zod){let h=Wa(u,t,n);if(h>r)r=h}},o=(u,h)=>{let d=lo;for(let f of Reflect.ownKeys(u)){let m=Object.getOwnPropertyDescriptor(u,f);if(h&&!m.enumerable)continue;let _=m.get?$a:m.value?._zod?Wa(m.value,t,n):lo;if(_>d)d=_}return d},a=(u)=>{if(u>r)r=u},c=e._zod.def,l=c.type;switch(l){case"object":{let u=ro(c);a(u?o(u,!0):$a),s(c.catchall);break}case"array":s(c.element);break;case"tuple":for(let u of c.items)s(u);s(c.rest);break;case"record":case"map":s(c.keyType),s(c.valueType);break;case"set":s(c.valueType);break;case"union":for(let u of c.options)s(u);break;case"intersection":s(c.left),s(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":s(c.innerType);break;case"pipe":s(c.in),s(c.out);break;case"function":s(c.input),s(c.output);break;case"lazy":{let u=c._cachedInner??(n?e._zod.innerType:void 0);a(u?Wa(u,t,!1):$a);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let u in c){let h=Object.getOwnPropertyDescriptor(c,u);if(!h||h.get)continue;let d=h.value;if(!d||typeof d!=="object")continue;if(d._zod)s(d);else if(Array.isArray(d))for(let f of d)s(f)}}return t.delete(e),gS(e,r)}function gS(e,t){if(t!==$a)ng.set(e,t===uo);return t}function _S(e,t){let n=e.buckets.get(t);if(!n)n=new WeakMap,e.buckets.set(t,n);return n}var Ha,Va=[],xS={alloc(e,t,n){let i=Ha;if(!i)return n;Ha=void 0;let r={value:n,issues:null};return i.set(t.value,r),Va.push(r),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let n=e._zod.parse,i=(r,s)=>{if(s.direction!=="backward"&&vS(s,r.value))throw new eg;return n(r,s)};if(e._zod.parse=i,e._zod.run===n)e._zod.run=i})},attach(e){var t;let n,i=!1,r,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let o=e._zod.parse,a=(c,l)=>{if(n===void 0){let g=Wa(e,new Set,!1);if(g===lo){if(e._zod.parse=o,e._zod.run===a)e._zod.run=o;return o(c,l)}if(g===uo||i)n=!0;else i=!0}let u=c.value;if(!tg(u))return o(c,l);let h=l[Kl];if(!h)h={buckets:new WeakMap,backEdges:void 0},l[Kl]=h;let d;if(r===l)d=s;else d=_S(h,e),r=l,s=d;let f=d.get(u);if(f){if(c.value=f.value,f.issues){if(f.issues.length)c.issues.push(...Yl(f.issues))}else c.memo=!0,h.backEdges??(h.backEdges=new WeakSet),h.backEdges.add(f.value);return c}Ha=d;let m=Va.length,_=o(c,l);Ha=void 0;let p=Va.length>m?Va.pop():void 0;if(_ instanceof Promise)return _.then((g)=>{if(p)p.issues=g.issues.length?Yl(g.issues):Qm;return g});if(p)p.issues=_.issues.length?Yl(_.issues):Qm;return _};if(e._zod.parse=a,e._zod.run===o)e._zod.run=a})}};function ig(){return xS}function vS(e,t){let n=e[Kl]?.backEdges;return n!==void 0&&tg(t)&&n.has(t)}var yS=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(s){return e[s]??null}let n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};function r(s,o){if(s==="number"&&typeof o==="number"&&!Number.isFinite(o))return String(o);return i[s]??s}return(s)=>{switch(s.code){case"invalid_type":{let o=r(s.expected),a=kf(s.input),c=r(a,s.input);return`Invalid input: expected ${o}, received ${c}`}case"invalid_value":if(s.values.length===1)return`Invalid input: expected ${Cl(s.values[0])}`;return`Invalid option: expected one of ${Tl(s.values,"|")}`;case"too_big":{let o=s.exact?"exactly ":s.inclusive?"<=":"<",a=t(s.origin);if(a)return`Too big: expected ${s.origin??"value"} to have ${o}${s.maximum.toString()} ${a.unit??"elements"}`;return`Too big: expected ${s.origin??"value"} to be ${o}${s.maximum.toString()}`}case"too_small":{let o=s.exact?"exactly ":s.inclusive?">=":">",a=t(s.origin);if(a)return`Too small: expected ${s.origin} to have ${o}${s.minimum.toString()} ${a.unit}`;return`Too small: expected ${s.origin} to be ${o}${s.minimum.toString()}`}case"invalid_format":{let o=s;if(o.format==="starts_with")return`Invalid string: must start with "${o.prefix}"`;if(o.format==="ends_with")return`Invalid string: must end with "${o.suffix}"`;if(o.format==="includes")return`Invalid string: must include "${o.includes}"`;if(o.format==="regex")return`Invalid string: must match pattern ${o.pattern}`;return`Invalid ${n[o.format]??s.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${s.divisor}`;case"unrecognized_keys":return`Unrecognized key${s.keys.length>1?"s":""}: ${Tl(s.keys,", ")}`;case"invalid_key":return`Invalid key in ${s.origin}`;case"invalid_union":if(s.options&&Array.isArray(s.options)&&s.options.length>0)return`Invalid discriminator value. Expected ${s.options.map((a)=>`'${a}'`).join(" | ")}`;if(s.inclusive===!1)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${s.origin}`;default:return"Invalid input"}}};function Jl(){return{localeError:yS()}}var rg;class sg{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n==="object"&&"id"in n)this._idmap.set(n.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);if(t&&typeof t==="object"&&"id"in t)this._idmap.delete(t.id);return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let i={...n,...this._map.get(e)};return Object.keys(i).length?i:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function bS(){return new sg}(rg=globalThis).__zod_globalRegistry??(rg.__zod_globalRegistry=bS());var Or=globalThis.__zod_globalRegistry;function og(e){if(e.checks)e.checks=[...e.checks];return e}function ag(e,t){return new e(og({type:"string",...De(t)}))}function cg(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...De(t)})}function lg(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...De(t)})}function ug(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...De(t)})}function hg(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...De(t)})}function dg(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...De(t)})}function fg(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...De(t)})}function pg(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...De(t)})}function mg(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...De(t)})}function gg(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...De(t)})}function _g(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...De(t)})}function xg(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...De(t)})}function vg(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...De(t)})}function yg(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...De(t)})}function bg(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...De(t)})}function Sg(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...De(t)})}function wg(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...De(t)})}function Mg(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...De(t)})}function Eg(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...De(t)})}function Tg(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...De(t)})}function Ag(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...De(t)})}function Rg(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...De(t)})}function Cg(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...De(t)})}function Ig(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...De(t)})}function Pg(e,t){return new e({type:"string",format:"date",check:"string_format",...De(t)})}function Lg(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...De(t)})}function Ng(e,t){return new e({type:"string",format:"duration",check:"string_format",...De(t)})}function Dg(e,t){return new e(og({type:"number",checks:[],...De(t)}))}function Og(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...De(t)})}function Ug(e,t){return new e({type:"boolean",...De(t)})}function Fg(e){return new e({type:"unknown"})}function zg(e,t){return new e({type:"never",...De(t)})}function Za(e,t){return new Gl({check:"less_than",...De(t),value:e,inclusive:!1})}function ho(e,t){return new Gl({check:"less_than",...De(t),value:e,inclusive:!0})}function Xa(e,t){return new Hl({check:"greater_than",...De(t),value:e,inclusive:!1})}function fo(e,t){return new Hl({check:"greater_than",...De(t),value:e,inclusive:!0})}function ja(e,t){return new Lp({check:"multiple_of",...De(t),value:e})}function qa(e,t){return new Dp({check:"max_length",...De(t),maximum:e})}function as(e,t){return new Op({check:"min_length",...De(t),minimum:e})}function Ya(e,t){return new Up({check:"length_equals",...De(t),length:e})}function Ql(e,t){return new Fp({check:"string_format",format:"regex",...De(t),pattern:e})}function eu(e){return new zp({check:"string_format",format:"lowercase",...De(e)})}function tu(e){return new kp({check:"string_format",format:"uppercase",...De(e)})}function nu(e,t){return new Bp({check:"string_format",format:"includes",...De(t),includes:e})}function iu(e,t){return new Gp({check:"string_format",format:"starts_with",...De(t),prefix:e})}function ru(e,t){return new Hp({check:"string_format",format:"ends_with",...De(t),suffix:e})}function er(e){return new Vp({check:"overwrite",tx:e})}function su(e){return er((t)=>t.normalize(e))}function ou(){return er((e)=>e.trim())}function au(){return er((e)=>e.toLowerCase())}function cu(){return er((e)=>e.toUpperCase())}function lu(){return er((e)=>Lf(e))}function kg(e,t,n){return new e({type:"array",element:t,...De(n)})}function Bg(e,t,n){return new e({type:"custom",check:"custom",fn:t,...De(n)})}function Gg(e,t){let n=SS((i)=>(i.addIssue=(r)=>{if(typeof r==="string")i.issues.push(Dr(r,i.value,n._zod.def));else{let s=r;if(s.fatal)s.continue=!1;if(s.code??(s.code="custom"),!("input"in s))s.input=i.value;s.inst??(s.inst=n),s.continue??(s.continue=!n._zod.def.abort),i.issues.push(Dr(s))}},e(i.value,i)),t);return n}function SS(e,t){let n=new nn({check:"custom",...De(t)});return n._zod.check=e,n}function po(e,...t){for(let n of t)for(let i of Reflect.ownKeys(n))if(Object.prototype.propertyIsEnumerable.call(n,i))Dn(e,i,n[i]);return e}function hu(e){let t=e?.target??"draft-2020-12";if(t==="draft-4")t="draft-04";if(t==="draft-7")t="draft-07";return{processors:e.processors??{},metadataRegistry:e?.metadata??Or,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function Di(e,t,n,i,r){let s=typeof t.unrepresentable==="function"?t.unrepresentable({zodSchema:e,path:i.path,message:r}):t.unrepresentable;if(s==="any")return!1;if(s===void 0||s==="throw")throw Error(r);return Object.assign(n,s),!0}function zt(e,t,n={path:[],schemaPath:[]}){var i;let r=e._zod.def,s=t.seen.get(e);if(s){if(s.count++,n.schemaPath.includes(e))s.cycle=n.path;return s.schema}let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)o.schema=a;else{let u={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,u);else{let d=o.schema,f=t.processors[r.type];if(!f)throw Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);f(e,t,d,u)}let h=e._zod.parent;if(h){if(!o.ref)o.ref=h;zt(h,t,u),t.seen.get(h).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)po(o.schema,c);if(t.io==="input"&&fn(e))delete o.schema.examples,delete o.schema.default;if(t.io==="input"&&"_prefault"in o.schema)(i=o.schema).default??(i.default=o.schema._prefault);return delete o.schema._prefault,t.seen.get(e).schema}function Hg(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function du(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let i=new Map;for(let o of e.seen.entries()){let a=e.metadataRegistry.get(o[0])?.id;if(a){let c=i.get(a);if(c&&c!==o[0])throw Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(a,o[0])}}let r=(o)=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let h=e.external.registry.get(o[0])?.id,d=e.external.uri??((m)=>m);if(h)return{ref:d(h)};let f=o[1].defId??o[1].schema.id??`schema${e.counter++}`;return o[1].defId=f,{defId:f,ref:`${d("__shared")}#/${a}/${Hg(f)}`}}let c="#",l=`${c}/${a}/`;if(o[1]===n&&!o[1].schema.id)return{ref:c};let u=o[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:l+Hg(u)}},s=(o)=>{if(o[1].schema.$ref)return;let a=o[1],{ref:c,defId:l}=r(o);if(a.def={...a.schema},l)a.defId=l;let u=a.schema;for(let h in u)delete u[h];u.$ref=c};if(e.cycles==="throw")for(let o of e.seen.entries()){let a=o[1];if(a.cycle)throw Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
55
+ `)}return p.write("payload.value = newResult;"),p.write("return payload;"),p.compile()},o,a=as,c=!xn.jitless,u=c&&Df.value,h=t.catchall,d;e._zod.parse=(f,m)=>{d??(d=i.value);let _=f.value;if(!a(_))return f.issues.push({expected:"object",code:"invalid_type",input:_,inst:e}),f;if(c&&u&&m?.async===!1&&m.jitless!==!0){if(!o)o=s(t.shape);if(f=o(f,m),!h)return f;return Fm([],_,f,m,d,e,m?.abortEarly===!0)}return n(f,m)}});function qp(e,t,n,i){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let r=e.filter((s)=>!li(s));if(r.length===1)return t.value=r[0].value,r[0];return t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map((s)=>s.issues.map((o)=>ui(o,i,wn())))}),t}var ql=ie("$ZodUnion",(e,t)=>{Ct.init(e,t),at(e,"optin",(i)=>i.def.options.some((r)=>r._zod.optin==="defaulted")?"defaulted":i.def.options.some((r)=>r._zod.optin!==void 0)?"optional":void 0),at(e,"optout",(i)=>i.def.options.some((r)=>r._zod.optout==="optional")?"optional":void 0),at(e,"values",(i)=>{if(i.def.options.every((r)=>r._zod.values))return new Set(i.def.options.flatMap((r)=>Array.from(r._zod.values)));return}),at(e,"pattern",(i)=>{if(i.def.options.every((r)=>r._zod.pattern)){let r=i.def.options.map((s)=>s._zod.pattern);return new RegExp(`^(${r.map((s)=>Aa(s.source)).join("|")})$`)}return});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(i,r)=>{if(n)return n(i,r);let s=!1,o=[];for(let a of t.options){let c=a._zod.run({value:i.value,issues:[]},r);if(c instanceof Promise)o.push(c),s=!0;else{if(c.issues.length===0)return c;o.push(c)}}if(!s)return qp(o,i,e,r);return Promise.all(o).then((a)=>qp(a,i,e,r))}});function _S(e){let t=new Map;for(let n of e.options){let i=n._zod.propValues?.[e.discriminator];if(!i||i.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let r of i)if(t.has(r)){if(r!==void 0)throw Error(`Duplicate discriminator value "${String(r)}"`);t.set(r,null)}else t.set(r,n)}return t}var km=ie("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,ql.init(e,t);let n=e._zod.parse;at(e,"propValues",(r)=>{let s={},o=0;for(let a of r.def.options){let c=a._zod.propValues;if(!c||Object.keys(c).length===0)throw Error(`Invalid discriminated union option at index "${r.def.options.indexOf(a)}"`);if(c[r.def.discriminator]?.has(void 0))o++;for(let[l,u]of Object.entries(c)){if(!Object.prototype.hasOwnProperty.call(s,l))Dn(s,l,new Set);for(let h of u)s[l].add(h)}}if(!r.def.unionFallback&&o>1)s[r.def.discriminator]?.delete(void 0);return s}),t.options.forEach((r,s)=>{let o=ao(r._zod.def);if(o&&!Object.prototype.hasOwnProperty.call(o,t.discriminator))throw Error(`Invalid discriminated union option at index "${s}"`)});let i=oo(()=>_S(t));e._zod.parse=(r,s)=>{let o=r.value;if(!as(o))return r.issues.push({code:"invalid_type",expected:"object",input:o,inst:e}),r;let a=o?.[t.discriminator],c=i.value.get(a);if(c&&(a!==void 0||s.direction!=="backward"))return c._zod.run(r,s);if(t.unionFallback||s.direction==="backward")return n(r,s);return r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(i.value.keys()).filter((l)=>i.value.get(l)!==null),input:o,path:[t.discriminator],inst:e}),r}}),Bm=ie("$ZodIntersection",(e,t)=>{Ct.init(e,t),e._zod.parse=(n,i)=>{let r=n.value,s=t.left._zod.run({value:r,issues:[]},i),o=t.right._zod.run({value:r,issues:[]},i);if(s instanceof Promise||o instanceof Promise)return Promise.all([s,o]).then(([c,l])=>Yp(n,c,l));return Yp(n,s,o)}});function Wl(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(Dr(e)&&Dr(t)){let n=Object.keys(t),i=Object.keys(e).filter((s)=>n.indexOf(s)!==-1),r={...e,...t};if(Object.prototype.hasOwnProperty.call(r,"__proto__"))delete r.__proto__;for(let s of i){if(s==="__proto__")continue;let o=Wl(e[s],t[s]);if(!o.valid)return{valid:!1,mergeErrorPath:[s,...o.mergeErrorPath]};r[s]=o.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let i=0;i<e.length;i++){let r=e[i],s=t[i],o=Wl(r,s);if(!o.valid)return{valid:!1,mergeErrorPath:[i,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Yp(e,t,n){let i=new Map,r,s=new Map,o=(l,u)=>{let h;if(l.code==="unrecognized_keys"&&!l.path?.length)r??(r=l),h=l.keys;else if(l.code==="invalid_key"&&l.origin==="record"&&l.path?.length===1){let d=String(l.path[0]);if(!s.has(d))s.set(d,l);h=[d]}else return!1;for(let d of h){if(!i.has(d))i.set(d,{});i.get(d)[u]=!0}return!0};for(let l of t.issues)if(!o(l,"l"))e.issues.push(l);for(let l of n.issues)if(!o(l,"r"))e.issues.push(l);let a=[...i].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(a.length){let l=r?a.filter((u)=>r.keys.includes(u)):[];if(l.length)e.issues.push({...r,keys:l});for(let u of a)if(!l.includes(u)&&s.has(u))e.issues.push(s.get(u))}let c=Wl(t.value,n.value);if(!c.valid){if(li(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Gm=ie("$ZodRecord",(e,t)=>{Ct.init(e,t);let n=xn.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let s=i.value;if(!Dr(s))return i.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),i;let o=[],a=t.keyType._zod.values;if(a&&!t.partial){i.value=n?n.alloc(e,i,{},r):{};let c=new Set;for(let u of a)if(typeof u==="string"||typeof u==="number"||typeof u==="symbol"){if(c.add(typeof u==="number"?u.toString():u),u==="__proto__")continue;let h=t.keyType._zod.run({value:u,issues:[]},r);if(h instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(h.issues.length){i.issues.push({code:"invalid_key",origin:"record",issues:h.issues.map((m)=>ui(m,r,wn())),input:u,path:[u],inst:e});continue}let d=h.value;if(d==="__proto__")continue;let f=t.valueType._zod.run({value:s[u],issues:[]},r);if(f instanceof Promise)o.push(f.then((m)=>{if(m.issues.length)i.issues.push(...er(u,m.issues));i.value[d]=m.value}));else{if(f.issues.length)i.issues.push(...er(u,f.issues));i.value[d]=f.value}}let l;for(let u in s)if(!c.has(u))if(t.mode==="loose"){if(u==="__proto__")continue;i.value[u]=s[u]}else l=l??[],l.push(u);if(l&&l.length>0)i.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:l,continue:!0})}else{i.value=n?n.alloc(e,i,{},r):{};let c;for(let l of Reflect.ownKeys(s)){if(l==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(s,l))continue;let u=t.keyType._zod.run({value:l,issues:[]},r);if(u instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof l==="string"&&lo.test(l)&&u.issues.length){let m=t.keyType._zod.run({value:Number(l),issues:[]},r);if(m instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(m.issues.length===0)u=m}if(u.issues.length){if(t.mode==="loose")i.value[l]=s[l];else if(a)c=c??[],c.push(l);else i.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map((m)=>ui(m,r,wn())),input:l,path:[l],inst:e});continue}let d=u.value;if(d==="__proto__")continue;let f=t.valueType._zod.run({value:s[l],issues:[]},r);if(f instanceof Promise)o.push(f.then((m)=>{if(m.issues.length)i.issues.push(...er(l,m.issues));i.value[d]=m.value}));else{if(f.issues.length)i.issues.push(...er(l,f.issues));i.value[d]=f.value}}if(c&&c.length>0)i.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c,continue:!0})}if(o.length)return Promise.all(o).then(()=>i);return i}});var Hm=ie("$ZodEnum",(e,t)=>{Ct.init(e,t);let n=ro(t.entries),i=new Set(n);e._zod.values=i,at(e,"pattern",(r)=>{let s=ro(r.def.entries).filter((o)=>Of.has(typeof o));return new RegExp(s.length?`^(${s.map((o)=>Qi(o.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(r,s)=>{let o=r.value;if(i.has(o))return r;return r.issues.push({code:"invalid_value",values:n,input:o,inst:e}),r}}),Vm=ie("$ZodLiteral",(e,t)=>{Ct.init(e,t);let n=new Set(t.values);e._zod.values=n,at(e,"pattern",(i)=>{let r=i.def.values;return new RegExp(r.length?`^(${r.map((s)=>typeof s==="string"?Qi(s):s?Qi(s.toString()):String(s)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(i,r)=>{let s=i.value;if(n.has(s))return i;return i.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),i}});var $m=ie("$ZodTransform",(e,t)=>{Ct.init(e,t),e._zod.optin="optional",xn.memoizer?.guard(e),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new co(e.constructor.name);let r=t.transform(n.value,n);if(i.async)return(r instanceof Promise?r:Promise.resolve(r)).then((o)=>(n.value=o,n));if(r instanceof Promise)throw new hi;return n.value=r,n}});function Kp(e,t){return e.value=t.issues.length?void 0:t.value,e}var Yl=ie("$ZodOptional",(e,t)=>{Ct.init(e,t),at(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",at(e,"values",(n)=>{let i=n.def.innerType._zod.values;return i?new Set([...i,void 0]):void 0}),at(e,"pattern",(n)=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${Aa(i.source)})?$`):void 0}),e._zod.parse=(n,i)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;let r=t.innerType._zod.run({value:n.value,issues:[]},i);if(r instanceof Promise)return r.then((s)=>Kp(n,s));return Kp(n,r)}return t.innerType._zod.run(n,i)}}),Wm=ie("$ZodExactOptional",(e,t)=>{Yl.init(e,t),at(e,"values",(n)=>n.def.innerType._zod.values),at(e,"pattern",(n)=>n.def.innerType._zod.pattern),e._zod.parse=(n,i)=>t.innerType._zod.run(n,i)}),Zm=ie("$ZodNullable",(e,t)=>{Ct.init(e,t),at(e,"optin",(n)=>n.def.innerType._zod.optin),at(e,"optout",(n)=>n.def.innerType._zod.optout),at(e,"pattern",(n)=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${Aa(i.source)}|null)$`):void 0}),at(e,"values",(n)=>n.def.innerType._zod.values?new Set([...n.def.innerType._zod.values,null]):void 0),e._zod.parse=(n,i)=>{if(n.value===null)return n;return t.innerType._zod.run(n,i)}}),Xm=ie("$ZodDefault",(e,t)=>{Ct.init(e,t),e._zod.optin="defaulted",at(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);if(n.value===void 0)return n.value=t.defaultValue,n;let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>Jp(s,t));return Jp(r,t)}});function Jp(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var jm=ie("$ZodPrefault",(e,t)=>{Ct.init(e,t),e._zod.optin="defaulted",at(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);if(n.value===void 0)n.value=t.defaultValue;return t.innerType._zod.run(n,i)}}),qm=ie("$ZodNonOptional",(e,t)=>{Ct.init(e,t),at(e,"values",(n)=>{let i=n.def.innerType._zod.values;return i?new Set([...i].filter((r)=>r!==void 0)):void 0}),e._zod.parse=(n,i)=>{let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>Qp(s,e));return Qp(r,e)}});function Qp(e,t){if(!e.issues.length&&e.value===void 0)e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t});return e}function em(e,t,n,i){if(!t.issues.length){if(e.value=t.value,t.memo)e.memo=!0;return e}return e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map((r)=>ui(r,i,wn()))},input:e.value}),e}var Ym=ie("$ZodCatch",(e,t)=>{Ct.init(e,t),at(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),at(e,"optout",(n)=>n.def.innerType._zod.optout),at(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);let r=t.innerType._zod.run({value:n.value,issues:[]},i);if(r instanceof Promise)return r.then((s)=>em(n,s,t,i));return em(n,r,t,i)}});var Km=ie("$ZodPipe",(e,t)=>{Ct.init(e,t),at(e,"values",(n)=>n.def.in._zod.values),at(e,"optin",(n)=>n.def.in._zod.optin),at(e,"optout",(n)=>n.def.out._zod.optout),at(e,"propValues",(n)=>n.def.in._zod.propValues),e._zod.parse=(n,i)=>{if(i.direction==="backward"){let s=t.out._zod.run(n,i);if(s instanceof Promise)return s.then((o)=>ka(o,t.in,i));return ka(s,t.in,i)}let r=t.in._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>ka(s,t.out,i));return ka(r,t.out,i)}});function ka(e,t,n){if(e.issues.some((i)=>i.code!=="unrecognized_keys"))return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues},n)}var Jm=ie("$ZodReadonly",(e,t)=>{Ct.init(e,t),at(e,"propValues",(n)=>n.def.innerType._zod.propValues),at(e,"values",(n)=>n.def.innerType._zod.values),at(e,"optin",(n)=>n.def.innerType?._zod?.optin),at(e,"optout",(n)=>n.def.innerType?._zod?.optout),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then(tm);return tm(r)}});function tm(e){if(!e.memo)e.value=Object.freeze(e.value);return e}var Qm=ie("$ZodCustom",(e,t)=>{nn.init(e,t),Ct.init(e,t),e._zod.parse=(n,i)=>n,e._zod.check=(n)=>{let i=n.value,r=t.fn(i);if(r instanceof Promise)return r.then((s)=>nm(s,n,i,e));nm(r,n,i,e);return}});function nm(e,t,n,i){if(!e){let r={code:"custom",input:n,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};if(i._zod.def.params)r.params=i._zod.def.params;t.issues.push(Or(r))}}class tg extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var Jl="~memo",eg=[];function ng(e){return e!==null&&typeof e==="object"}function Kl(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var ig=new WeakMap,fo=0,Za=1,po=2;function Xa(e,t,n){let i=ig.get(e);if(i!==void 0)return i?po:fo;if(t.has(e))return po;t.add(e);let r=fo,s=(u)=>{if(r!==po&&u?._zod){let h=Xa(u,t,n);if(h>r)r=h}},o=(u,h)=>{let d=fo;for(let f of Reflect.ownKeys(u)){let m=Object.getOwnPropertyDescriptor(u,f);if(h&&!m.enumerable)continue;let _=m.get?Za:m.value?._zod?Xa(m.value,t,n):fo;if(_>d)d=_}return d},a=(u)=>{if(u>r)r=u},c=e._zod.def,l=c.type;switch(l){case"object":{let u=ao(c);a(u?o(u,!0):Za),s(c.catchall);break}case"array":s(c.element);break;case"tuple":for(let u of c.items)s(u);s(c.rest);break;case"record":case"map":s(c.keyType),s(c.valueType);break;case"set":s(c.valueType);break;case"union":for(let u of c.options)s(u);break;case"intersection":s(c.left),s(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":s(c.innerType);break;case"pipe":s(c.in),s(c.out);break;case"function":s(c.input),s(c.output);break;case"lazy":{let u=c._cachedInner??(n?e._zod.innerType:void 0);a(u?Xa(u,t,!1):Za);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let u in c){let h=Object.getOwnPropertyDescriptor(c,u);if(!h||h.get)continue;let d=h.value;if(!d||typeof d!=="object")continue;if(d._zod)s(d);else if(Array.isArray(d))for(let f of d)s(f)}}return t.delete(e),xS(e,r)}function xS(e,t){if(t!==Za)ig.set(e,t===po);return t}function vS(e,t){let n=e.buckets.get(t);if(!n)n=new WeakMap,e.buckets.set(t,n);return n}var $a,Wa=[],yS={alloc(e,t,n){let i=$a;if(!i)return n;$a=void 0;let r={value:n,issues:null};return i.set(t.value,r),Wa.push(r),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let n=e._zod.parse,i=(r,s)=>{if(s.direction!=="backward"&&bS(s,r.value))throw new tg;return n(r,s)};if(e._zod.parse=i,e._zod.run===n)e._zod.run=i})},attach(e){var t;let n,i=!1,r,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let o=e._zod.parse,a=(c,l)=>{if(n===void 0){let g=Xa(e,new Set,!1);if(g===fo){if(e._zod.parse=o,e._zod.run===a)e._zod.run=o;return o(c,l)}if(g===po||i)n=!0;else i=!0}let u=c.value;if(!ng(u))return o(c,l);let h=l[Jl];if(!h)h={buckets:new WeakMap,backEdges:void 0},l[Jl]=h;let d;if(r===l)d=s;else d=vS(h,e),r=l,s=d;let f=d.get(u);if(f){if(c.value=f.value,f.issues){if(f.issues.length)c.issues.push(...Kl(f.issues))}else c.memo=!0,h.backEdges??(h.backEdges=new WeakSet),h.backEdges.add(f.value);return c}$a=d;let m=Wa.length,_=o(c,l);$a=void 0;let p=Wa.length>m?Wa.pop():void 0;if(_ instanceof Promise)return _.then((g)=>{if(p)p.issues=g.issues.length?Kl(g.issues):eg;return g});if(p)p.issues=_.issues.length?Kl(_.issues):eg;return _};if(e._zod.parse=a,e._zod.run===o)e._zod.run=a})}};function rg(){return yS}function bS(e,t){let n=e[Jl]?.backEdges;return n!==void 0&&ng(t)&&n.has(t)}var SS=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(s){return e[s]??null}let n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};function r(s,o){if(s==="number"&&typeof o==="number"&&!Number.isFinite(o))return String(o);return i[s]??s}return(s)=>{switch(s.code){case"invalid_type":{let o=r(s.expected),a=Bf(s.input),c=r(a,s.input);return`Invalid input: expected ${o}, received ${c}`}case"invalid_value":if(s.values.length===1)return`Invalid input: expected ${Il(s.values[0])}`;return`Invalid option: expected one of ${Al(s.values,"|")}`;case"too_big":{let o=s.exact?"exactly ":s.inclusive?"<=":"<",a=t(s.origin);if(a)return`Too big: expected ${s.origin??"value"} to have ${o}${s.maximum.toString()} ${a.unit??"elements"}`;return`Too big: expected ${s.origin??"value"} to be ${o}${s.maximum.toString()}`}case"too_small":{let o=s.exact?"exactly ":s.inclusive?">=":">",a=t(s.origin);if(a)return`Too small: expected ${s.origin} to have ${o}${s.minimum.toString()} ${a.unit}`;return`Too small: expected ${s.origin} to be ${o}${s.minimum.toString()}`}case"invalid_format":{let o=s;if(o.format==="starts_with")return`Invalid string: must start with "${o.prefix}"`;if(o.format==="ends_with")return`Invalid string: must end with "${o.suffix}"`;if(o.format==="includes")return`Invalid string: must include "${o.includes}"`;if(o.format==="regex")return`Invalid string: must match pattern ${o.pattern}`;return`Invalid ${n[o.format]??s.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${s.divisor}`;case"unrecognized_keys":return`Unrecognized key${s.keys.length>1?"s":""}: ${Al(s.keys,", ")}`;case"invalid_key":return`Invalid key in ${s.origin}`;case"invalid_union":if(s.options&&Array.isArray(s.options)&&s.options.length>0)return`Invalid discriminator value. Expected ${s.options.map((a)=>`'${a}'`).join(" | ")}`;if(s.inclusive===!1)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${s.origin}`;default:return"Invalid input"}}};function Ql(){return{localeError:SS()}}var sg;class og{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n==="object"&&"id"in n)this._idmap.set(n.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);if(t&&typeof t==="object"&&"id"in t)this._idmap.delete(t.id);return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let i={...n,...this._map.get(e)};return Object.keys(i).length?i:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function wS(){return new og}(sg=globalThis).__zod_globalRegistry??(sg.__zod_globalRegistry=wS());var Ur=globalThis.__zod_globalRegistry;function ag(e){if(e.checks)e.checks=[...e.checks];return e}function cg(e,t){return new e(ag({type:"string",...De(t)}))}function lg(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...De(t)})}function ug(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...De(t)})}function hg(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...De(t)})}function dg(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...De(t)})}function fg(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...De(t)})}function pg(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...De(t)})}function mg(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...De(t)})}function gg(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...De(t)})}function _g(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...De(t)})}function xg(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...De(t)})}function vg(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...De(t)})}function yg(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...De(t)})}function bg(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...De(t)})}function Sg(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...De(t)})}function wg(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...De(t)})}function Mg(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...De(t)})}function Eg(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...De(t)})}function Tg(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...De(t)})}function Ag(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...De(t)})}function Rg(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...De(t)})}function Cg(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...De(t)})}function Ig(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...De(t)})}function Pg(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...De(t)})}function Lg(e,t){return new e({type:"string",format:"date",check:"string_format",...De(t)})}function Ng(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...De(t)})}function Dg(e,t){return new e({type:"string",format:"duration",check:"string_format",...De(t)})}function Og(e,t){return new e(ag({type:"number",checks:[],...De(t)}))}function Ug(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...De(t)})}function Fg(e,t){return new e({type:"boolean",...De(t)})}function zg(e){return new e({type:"unknown"})}function kg(e,t){return new e({type:"never",...De(t)})}function ja(e,t){return new Hl({check:"less_than",...De(t),value:e,inclusive:!1})}function mo(e,t){return new Hl({check:"less_than",...De(t),value:e,inclusive:!0})}function qa(e,t){return new Vl({check:"greater_than",...De(t),value:e,inclusive:!1})}function go(e,t){return new Vl({check:"greater_than",...De(t),value:e,inclusive:!0})}function Ya(e,t){return new Np({check:"multiple_of",...De(t),value:e})}function Ka(e,t){return new Op({check:"max_length",...De(t),maximum:e})}function cs(e,t){return new Up({check:"min_length",...De(t),minimum:e})}function Ja(e,t){return new Fp({check:"length_equals",...De(t),length:e})}function eu(e,t){return new zp({check:"string_format",format:"regex",...De(t),pattern:e})}function tu(e){return new kp({check:"string_format",format:"lowercase",...De(e)})}function nu(e){return new Bp({check:"string_format",format:"uppercase",...De(e)})}function iu(e,t){return new Gp({check:"string_format",format:"includes",...De(t),includes:e})}function ru(e,t){return new Hp({check:"string_format",format:"starts_with",...De(t),prefix:e})}function su(e,t){return new Vp({check:"string_format",format:"ends_with",...De(t),suffix:e})}function tr(e){return new $p({check:"overwrite",tx:e})}function ou(e){return tr((t)=>t.normalize(e))}function au(){return tr((e)=>e.trim())}function cu(){return tr((e)=>e.toLowerCase())}function lu(){return tr((e)=>e.toUpperCase())}function uu(){return tr((e)=>Nf(e))}function Bg(e,t,n){return new e({type:"array",element:t,...De(n)})}function Gg(e,t,n){return new e({type:"custom",check:"custom",fn:t,...De(n)})}function Hg(e,t){let n=MS((i)=>(i.addIssue=(r)=>{if(typeof r==="string")i.issues.push(Or(r,i.value,n._zod.def));else{let s=r;if(s.fatal)s.continue=!1;if(s.code??(s.code="custom"),!("input"in s))s.input=i.value;s.inst??(s.inst=n),s.continue??(s.continue=!n._zod.def.abort),i.issues.push(Or(s))}},e(i.value,i)),t);return n}function MS(e,t){let n=new nn({check:"custom",...De(t)});return n._zod.check=e,n}function _o(e,...t){for(let n of t)for(let i of Reflect.ownKeys(n))if(Object.prototype.propertyIsEnumerable.call(n,i))Dn(e,i,n[i]);return e}function du(e){let t=e?.target??"draft-2020-12";if(t==="draft-4")t="draft-04";if(t==="draft-7")t="draft-07";return{processors:e.processors??{},metadataRegistry:e?.metadata??Ur,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function Oi(e,t,n,i,r){let s=typeof t.unrepresentable==="function"?t.unrepresentable({zodSchema:e,path:i.path,message:r}):t.unrepresentable;if(s==="any")return!1;if(s===void 0||s==="throw")throw Error(r);return Object.assign(n,s),!0}function zt(e,t,n={path:[],schemaPath:[]}){var i;let r=e._zod.def,s=t.seen.get(e);if(s){if(s.count++,n.schemaPath.includes(e))s.cycle=n.path;return s.schema}let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)o.schema=a;else{let u={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,u);else{let d=o.schema,f=t.processors[r.type];if(!f)throw Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);f(e,t,d,u)}let h=e._zod.parent;if(h){if(!o.ref)o.ref=h;zt(h,t,u),t.seen.get(h).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)_o(o.schema,c);if(t.io==="input"&&fn(e))delete o.schema.examples,delete o.schema.default;if(t.io==="input"&&"_prefault"in o.schema)(i=o.schema).default??(i.default=o.schema._prefault);return delete o.schema._prefault,t.seen.get(e).schema}function Vg(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function fu(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let i=new Map;for(let o of e.seen.entries()){let a=e.metadataRegistry.get(o[0])?.id;if(a){let c=i.get(a);if(c&&c!==o[0])throw Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(a,o[0])}}let r=(o)=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let h=e.external.registry.get(o[0])?.id,d=e.external.uri??((m)=>m);if(h)return{ref:d(h)};let f=o[1].defId??o[1].schema.id??`schema${e.counter++}`;return o[1].defId=f,{defId:f,ref:`${d("__shared")}#/${a}/${Vg(f)}`}}let c="#",l=`${c}/${a}/`;if(o[1]===n&&!o[1].schema.id)return{ref:c};let u=o[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:l+Vg(u)}},s=(o)=>{if(o[1].schema.$ref)return;let a=o[1],{ref:c,defId:l}=r(o);if(a.def={...a.schema},l)a.defId=l;let u=a.schema;for(let h in u)delete u[h];u.$ref=c};if(e.cycles==="throw")for(let o of e.seen.entries()){let a=o[1];if(a.cycle)throw Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
56
56
 
57
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let o of e.seen.entries()){let a=o[1];if(t===o[0]){s(o);continue}if(e.external){let l=e.external.registry.get(o[0])?.id;if(t!==o[0]&&l){s(o);continue}}if(e.metadataRegistry.get(o[0])?.id){s(o);continue}if(a.cycle){s(o);continue}if(a.count>1){if(e.reused==="ref")s(o)}}if(e.external)e.sharedDefsExtractedFor=e.external}function Wg(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let i of t){if(!i||typeof i!=="object")return;Wg(i);let r=Object.keys(i);if(r.length!==1||r[0]!=="type")return;let s=i.type;for(let o of Array.isArray(s)?s:[s]){if(typeof o!=="string")return;if(!n.includes(o))n.push(o)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var Zg=new Set(["type","properties","required","additionalProperties"]),Vg=["oneOf","anyOf"];function $g(e){let t=e.additionalProperties;if(t===void 0||t===!1||typeof t!=="object"||t===null)return null;return Object.keys(t).length?t:null}function uu(e){let t=[];for(let s of e){if(typeof s!=="object"||s.type!=="object")return null;for(let o in s)if(!Zg.has(o))return null;t.push(s)}let n={},i=new Set;for(let s of t){for(let o in s.properties){if(Object.prototype.hasOwnProperty.call(n,o))continue;let a=[];for(let l of t){let u=l.properties?.[o]??$g(l);if(u===null||u===void 0)continue;if(!a.some((h)=>JSON.stringify(h)===JSON.stringify(u)))a.push(u)}let c=a.length===1?a[0]:uu(a)??{allOf:a};Dn(n,o,c)}for(let o of s.required??[])i.add(o)}let r={type:"object",properties:n};if(i.size)r.required=[...i];if(t.every((s)=>s.additionalProperties===!1))r.additionalProperties=!1;else{let s=[];for(let o of t){let a=$g(o);if(a&&!s.some((c)=>JSON.stringify(c)===JSON.stringify(a)))s.push(a)}if(s.length===1)r.additionalProperties=s[0];else if(s.length>1)r.additionalProperties={allOf:s}}return r}function wS(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let r of Zg)if(r in e)return;let n=t.filter((r)=>Vg.some((s)=>Array.isArray(r[s]))),i=null;if(!n.length)i=uu(t);else{let r=n[0],s=Vg.find((c)=>Array.isArray(r[c]));if(Object.keys(r).length!==1)return;let o=t.filter((c)=>c!==r),a=r[s].map((c)=>uu([...o,c]));if(a.some((c)=>!c))return;i={[s]:a}}if(!i)return;delete e.allOf,po(e,i)}function fu(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");let i=(a)=>{let c=e.seen.get(a);if(c.ref===null)return;let l=c.def??c.schema,u={...l},h=c.ref;if(c.ref=null,h){i(h);let f=e.seen.get(h),m=f.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))l.allOf=l.allOf??[],l.allOf.push(m);else po(l,m);if(po(l,u),a._zod.parent===h)for(let p in l){if(p==="$ref"||p==="allOf")continue;if(!(p in u))delete l[p]}if(m.$ref&&f.def)for(let p in l){if(p==="$ref"||p==="allOf")continue;if(p in f.def&&JSON.stringify(l[p])===JSON.stringify(f.def[p]))delete l[p]}}let d=a._zod.parent;if(d&&d!==h){i(d);let f=e.seen.get(d);if(f?.schema.$ref){if(l.$ref=f.schema.$ref,f.def)for(let m in l){if(m==="$ref"||m==="allOf")continue;if(m in f.def&&JSON.stringify(l[m])===JSON.stringify(f.def[m]))delete l[m]}}}e.override({zodSchema:a,jsonSchema:l,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())i(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())Wg(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let l of[c.schema,c.def]){let u=l?.allOf;if(!Array.isArray(u))continue;let h=a.get(u);if(h)h.push(l);else a.set(u,[l])}for(let c of e.intersections)for(let l of a.get(c)??[])wS(l)}}let r={};if(e.target==="draft-2020-12")r.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")r.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")r.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw Error("Schema is missing an `id` property");r.$id=e.external.uri(a)}po(r,n.defId?n.schema:n.def??n.schema);let s=e.metadataRegistry.get(t)?.id;if(s!==void 0&&r.id===s)delete r.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let a of e.seen.entries()){let c=a[1];if(c.def&&c.defId){if(c.def.id===c.defId)delete c.def.id;Dn(o,c.defId,c.def)}}if(e.external)e.sharedEmitDoneFor=e.external;if(e.external);else if(Object.keys(o).length>0)if(e.target==="draft-2020-12")r.$defs=o;else r.definitions=o;try{let a=JSON.parse(JSON.stringify(r));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:mo(t,"input",e.processors),output:mo(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function fn(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let i=e._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return fn(i.element,n);if(i.type==="set")return fn(i.valueType,n);if(i.type==="lazy")return fn(i.getter(),n);if(i.type==="promise"||i.type==="optional"||i.type==="nonoptional"||i.type==="nullable"||i.type==="readonly"||i.type==="default"||i.type==="prefault"||i.type==="catch")return fn(i.innerType,n);if(i.type==="intersection")return fn(i.left,n)||fn(i.right,n);if(i.type==="record"||i.type==="map")return fn(i.keyType,n)||fn(i.valueType,n);if(i.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return fn(i.in,n)||fn(i.out,n)}if(i.type==="object"){for(let r in i.shape)if(fn(i.shape[r],n))return!0;return!1}if(i.type==="union"){for(let r of i.options)if(fn(r,n))return!0;return!1}if(i.type==="tuple"){for(let r of i.items)if(fn(r,n))return!0;if(i.rest&&fn(i.rest,n))return!0;return!1}return!1}var Xg=(e,t={})=>(n)=>{let i=hu({...n,processors:t});return zt(e,i),du(i,e),fu(i,e)},mo=(e,t,n={})=>(i)=>{let{libraryOptions:r,target:s}=i??{},o=hu({...r??{},target:s,io:t,processors:n});return zt(e,o),du(o,e),fu(o,e)};var cs=(e,t,n)=>{if(e[t]===void 0||n>e[t])e[t]=n},ls=(e,t,n)=>{if(e[t]===void 0||n<e[t])e[t]=n},jg=(e,t)=>{cs(e,"minimum",t),ls(e,"maximum",t)},Jg=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},Qg=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},e_=(e,t)=>{e.mime=e.mime?e.mime.filter((n)=>t.includes(n)):[...t]},t_=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},qg=(e,t)=>cs(e,"minimum",t.minimum),Yg=(e,t)=>ls(e,"maximum",t.maximum),Kg=(e)=>(t,n)=>{t_(t,n.format);let[i,r]=e[n.format];cs(t,"minimum",i),ls(t,"maximum",r)},MS={greater_than:(e,t)=>cs(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>ls(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>Jg(e,t.value),number_format:Kg(Ta),bigint_format:Kg(Il),min_length:qg,max_length:Yg,length_equals:(e,t)=>jg(e,t.length),min_size:qg,max_size:Yg,size_equals:(e,t)=>jg(e,t.size),string_format:(e,t)=>{if(t_(e,t.format),t.pattern)Qg(e,t.pattern);if(t.format==="base64"||t.format==="base64url")e.contentEncoding=t.format;if(t.local||t.precision===-1)e.laxFormat=!0},mime_type:(e,t)=>e_(e,t.mime)};function On(e){let t={},n=e._zod.def,i=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(let s of i)MS[s._zod.def.check]?.(t,s._zod.def);let r=e._zod.bag;if(r.minimum!==void 0)cs(t,"minimum",r.minimum);if(r.exclusiveMinimum!==void 0)cs(t,"exclusiveMinimum",r.exclusiveMinimum);if(r.maximum!==void 0)ls(t,"maximum",r.maximum);if(r.exclusiveMaximum!==void 0)ls(t,"exclusiveMaximum",r.exclusiveMaximum);if(r.multipleOf!==void 0)Jg(t,r.multipleOf);if(r.format!==void 0){if(t.format??(t.format=r.format),r.format.includes("int"))t.isInt=!0}if(r.mime)e_(t,r.mime);for(let s of r.patterns??[])Qg(t,s);return t}var ES={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},TS=new Map([[Zl,yp],[Ga,bp]]),n_=(e)=>TS.get(e)??e,i_=(e,t,n,i)=>{let r=n;r.type="string";let{minimum:s,maximum:o,format:a,patterns:c,contentEncoding:l,laxFormat:u}=On(e);if(typeof s==="number")r.minLength=s;if(typeof o==="number")r.maxLength=o;if(a){if(r.format=ES[a]??a,r.format==="")delete r.format;if(a==="time"||u)delete r.format}if(l)r.contentEncoding=l;if(c&&c.size>0){let h=[...c].map(n_);if(h.length===1)r.pattern=h[0].source;else if(h.length>1)r.allOf=[...h.map((d)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))]}},r_=(e,t,n,i)=>{let r=n,{minimum:s,maximum:o,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=On(e);r.type=u?"integer":"number";let h=typeof l==="number"&&l>=(s??Number.NEGATIVE_INFINITY),d=typeof c==="number"&&c<=(o??Number.POSITIVE_INFINITY),f=t.target==="draft-04"||t.target==="openapi-3.0";if(h)if(f)r.minimum=l,r.exclusiveMinimum=!0;else r.exclusiveMinimum=l;else if(typeof s==="number")r.minimum=s;if(d)if(f)r.maximum=c,r.exclusiveMaximum=!0;else r.exclusiveMaximum=c;else if(typeof o==="number")r.maximum=o;if(a){let m=new Set;for(let g of a)if(Number.isFinite(g)&&g!==0)m.add(Math.abs(g));else Di(e,t,r,i,`A multipleOf divisor of ${g} cannot be represented in JSON Schema`);let[_,...p]=m;if(_!==void 0)r.multipleOf=_;if(p.length)r.allOf=[...r.allOf??[],...p.map((g)=>({multipleOf:g}))]}},s_=(e,t,n,i)=>{n.type="boolean"};var o_=(e,t,n,i)=>{n.not={}};var a_=(e,t,n,i)=>{};var c_=(e,t,n,i)=>{let r=e._zod.def,s=to(r.entries);if(s.length===0){n.not={};return}if(s.every((o)=>typeof o==="number"))n.type="number";if(s.every((o)=>typeof o==="string"))n.type="string";n.enum=s},l_=(e,t,n,i)=>{let r=e._zod.def;if(r.values.length===0){n.not={};return}let s=[];for(let o of r.values)if(o===void 0){if(Di(e,t,n,i,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==="bigint"){if(Di(e,t,n,i,"BigInt literals cannot be represented in JSON Schema"))return;s.push(Number(o))}else s.push(o);if(s.length===0);else if(s.length===1){let o=s[0];if(n.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0")n.enum=[o];else n.const=o}else{if(s.every((o)=>typeof o==="number"))n.type="number";if(s.every((o)=>typeof o==="string"))n.type="string";if(s.every((o)=>typeof o==="boolean"))n.type="boolean";if(s.every((o)=>o===null))n.type="null";n.enum=s}};var u_=(e,t,n,i)=>{Di(e,t,n,i,"Custom types cannot be represented in JSON Schema")};var h_=(e,t,n,i)=>{Di(e,t,n,i,"Transforms cannot be represented in JSON Schema")};var d_=(e,t,n,i)=>{let r=n,s=e._zod.def,{minimum:o,maximum:a}=On(e);if(typeof o==="number")r.minItems=o;if(typeof a==="number")r.maxItems=a;r.type="array",r.items=zt(s.element,t,{...i,path:[...i.path,"items"]})};function Ka(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return Ka(t.out);if(t.type==="catch")return Ka(t.innerType);return e._zod.optin}var f_=(e,t,n,i)=>{let r=n,s=e._zod.def,o=s.shape;if(Object.getOwnPropertySymbols(o).length&&Di(e,t,r,i,"Symbol keys cannot be represented in JSON Schema"))return;r.type="object",r.properties={};for(let l in o)Dn(r.properties,l,zt(o[l],t,{...i,path:[...i.path,"properties",l]}));let c=[];for(let l of Object.keys(o)){let u=s.shape[l];if(t.io==="input"?Ka(u)===void 0:u._zod.optout===void 0)c.push(l)}if(c.length>0)r.required=c;if(s.catchall?._zod.def.type==="never")r.additionalProperties=!1;else if(!s.catchall){if(t.io==="output")r.additionalProperties=!1}else if(s.catchall)r.additionalProperties=zt(s.catchall,t,{...i,path:[...i.path,"additionalProperties"]})},p_=(e,t,n,i)=>{let r=e._zod.def,s=r.inclusive===!1,o=r.options.map((a,c)=>zt(a,t,{...i,path:[...i.path,s?"oneOf":"anyOf",c]}));if(s)n.oneOf=o;else n.anyOf=o},m_=(e,t,n,i)=>{let r=e._zod.def,s=zt(r.left,t,{...i,path:[...i.path,"allOf",0]}),o=zt(r.right,t,{...i,path:[...i.path,"allOf",1]}),a=(l)=>("allOf"in l)&&Object.keys(l).length===1,c=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)};function pu(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let m=e.get(t)?.def;if(!m)return t;let _=pu(e,m,n);return _===m?t:_}for(let m of["anyOf","oneOf"]){let _=t[m];if(!Array.isArray(_))continue;let p=_.map((g)=>pu(e,g,n));if(p.some((g,M)=>g!==_[M]))t={...t,[m]:p}}let i=Array.isArray(t.type)?t.type:[t.type],r=!i.includes("string")&&i.some((m)=>m==="number"||m==="integer"),s=t.enum??(t.const!==void 0?[t.const]:void 0);if(!r&&!s?.some((m)=>typeof m==="number"))return t;let{minimum:o,maximum:a,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:h,id:d,...f}=t;if(f.enum)f.enum=f.enum.map((m)=>typeof m==="number"?String(m):m);else if(typeof f.const==="number")f.const=String(f.const);if(!r)return f;if(f.type="string",!s)f.pattern=(i.includes("number")?oo:kl).source;return f}var mu=new WeakMap;function AS(e){let t=new Map;for(let i of e.seen.values())if(i.def&&!t.has(i.schema))t.set(i.schema,i);let n=new Map;for(let i of mu.get(e)??[]){let r=e.seen.get(i),s=(r?.def??r?.schema)?.propertyNames;if(!s||s===!0||n.has(s))continue;let o=pu(t,s,new Set);if(o!==s)n.set(s,o)}if(!n.size)return;for(let i of e.seen.values())for(let r of[i.schema,i.def]){let s=r&&n.get(r.propertyNames);if(s)r.propertyNames=s}}var g_=(e,t,n,i)=>{let r=n,s=e._zod.def;r.type="object";let o=s.keyType,a=On(o).patterns;if(s.mode==="loose"&&a&&a.size>0){let u=zt(s.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});r.patternProperties={};for(let h of a)Dn(r.patternProperties,n_(h).source,u)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){r.propertyNames=zt(s.keyType,t,{...i,path:[...i.path,"propertyNames"]});let u=mu.get(t);if(!u)u=[],mu.set(t,u),t.deferred.push(()=>AS(t));u.push(e)}r.additionalProperties=zt(s.valueType,t,{...i,path:[...i.path,"additionalProperties"]})}let c=o._zod.values,l=t.io==="input"&&Ka(s.valueType)!==void 0;if(c&&!s.partial&&!l){let u=[...c].filter((h)=>typeof h==="string"||typeof h==="number");if(u.length>0)r.required=u.map(String)}},__=(e,t,n,i)=>{let r=e._zod.def,s=zt(r.innerType,t,i),o=t.seen.get(e);if(t.target==="openapi-3.0")o.ref=r.innerType,n.nullable=!0;else n.anyOf=[s,{type:"null"}]},x_=(e,t,n,i)=>{let r=e._zod.def;zt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType},gu=Symbol();function v_(e,t,n,i,r){let s=!1,o=JSON.stringify(e,(a,c)=>{if(typeof c!=="bigint")return c;return s=!0,null});if(!s)return JSON.parse(o);return Di(t,n,i,r,"BigInt defaults cannot be represented in JSON Schema"),gu}var y_=(e,t,n,i)=>{let r=e._zod.def;zt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType;let o=v_(r.defaultValue,e,t,n,i);if(o!==gu)n.default=o},b_=(e,t,n,i)=>{let r=e._zod.def;zt(r.innerType,t,i);let s=t.seen.get(e);if(s.ref=r.innerType,t.io!=="input")return;let o=v_(r.defaultValue,e,t,n,i);if(o!==gu)n._prefault=o},S_=(e,t,n,i)=>{let r=e._zod.def;zt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType;let o;try{o=r.catchValue(void 0)}catch{Di(e,t,n,i,"Dynamic catch values are not supported in JSON Schema");return}n.default=o},w_=(e,t,n,i)=>{let r=e._zod.def,s=r.in._zod.traits.has("$ZodTransform"),o=t.io==="input"?s?r.out:r.in:r.out;zt(o,t,i);let a=t.seen.get(e);a.ref=o},M_=(e,t,n,i)=>{let r=e._zod.def;zt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType,n.readOnly=!0};var _u=(e,t,n,i)=>{let r=e._zod.def;zt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType};var E_=new WeakSet([Object.prototype,Error.prototype]);function Ja(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let i=n(this);return Object.defineProperty(this,t,{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,t,{value:i,configurable:!0,writable:!0})}})}var OS=(e,t)=>{Xf.init(e,t),e.name="ZodError";let n=Object.getPrototypeOf(e);if(E_.has(n))return;E_.add(n),Ja(n,"format",(i)=>(r)=>qf(i,r)),Ja(n,"flatten",(i)=>(r)=>jf(i,r)),Ja(n,"addIssue",(i)=>(r)=>{i.issues.push(r),i.message=JSON.stringify(i.issues,no,2)}),Ja(n,"addIssues",(i)=>(r)=>{i.issues.push(...r),i.message=JSON.stringify(i.issues,no,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var Mn=ie("ZodError",OS,void 0,{Parent:Error});var T_=La(Mn),A_=Na(Mn),R_=Da(Mn),C_=Oa(Mn),I_=Kf(Mn),P_=Jf(Mn),L_=Qf(Mn),N_=ep(Mn),D_=tp(Mn),O_=np(Mn),U_=ip(Mn),F_=rp(Mn);function FS(){if(!xn.localeError)wn(Jl())}function ec(){if(!xn.memoizer)wn({memoizer:ig()})}var Lt=ie("ZodType",(e,t)=>(FS(),Ct.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(Sn(t,{checks:[...t.checks??[],...e.map((n)=>typeof n==="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return ci(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Dw(e,t))},superRefine(e,t){return this.check(Ow(e,t))},overwrite(e){return this.check(er(e))},optional(){return B_(this)},exactOptional(){return bw(this)},nullable(){return G_(this)},nullish(){return B_(G_(this))},nonoptional(e){return Aw(this,e)},array(){return wt(this)},or(e){return Z_([this,e])},and(e){return _w(this,e)},transform(e){return H_(this,yw(e))},default(e){return Mw(this,e)},prefault(e){return Tw(this,e)},catch(e){return Cw(this,e)},pipe(e){return H_(this,e)},readonly(){return Lw(this)},describe(e){let t=this.clone();return Or.add(t,{description:e}),t},meta(...e){if(e.length===0)return Or.get(this);let t=this.clone();return Or.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get "~standard"(){return Ia(this,"~standard",{...Wl(this),jsonSchema:{input:mo(this,"input"),output:mo(this,"output")}})},set "~standard"(e){Ni(this,"~standard",e)},parse:function e(t,n){return T_(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await A_(this,t,n,{callee:e})},safeParse(e,t){return R_(this,e,t)},async safeParseAsync(e,t){return C_(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Ni(this,"spa",e)},validate(e,t){return Ol(this,e,t)},validateAsync(e,t){return Ul(this,e,t)},encode:function e(t,n){return I_(this,t,n,{callee:e})},decode:function e(t,n){return P_(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await L_(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await N_(this,t,n,{callee:e})},safeEncode(e,t){return D_(this,e,t)},safeDecode(e,t){return O_(this,e,t)},async safeEncodeAsync(e,t){return U_(this,e,t)},async safeDecodeAsync(e,t){return F_(this,e,t)},toJSONSchema(e){return Xg(this,{})(e)},get description(){return Or.get(this)?.description},get _def(){return this._zod.def}}),V_=ie("_ZodString",(e,t)=>{Ba.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>i_(e,n,i,r)},Gf({format:(e)=>On(e).format??null,minLength:(e)=>On(e).minimum??null,maxLength:(e)=>On(e).maximum??null},{regex(...e){return this.check(Ql(...e))},includes(...e){return this.check(nu(...e))},startsWith(...e){return this.check(iu(...e))},endsWith(...e){return this.check(ru(...e))},min(...e){return this.check(as(...e))},max(...e){return this.check(qa(...e))},length(...e){return this.check(Ya(...e))},nonempty(...e){return this.check(as(1,...e))},lowercase(e){return this.check(eu(e))},uppercase(e){return this.check(tu(e))},trim(){return this.check(ou())},normalize(...e){return this.check(su(...e))},toLowerCase(){return this.check(au())},toUpperCase(){return this.check(cu())},slugify(){return this.check(lu())}})),zS=ie("ZodString",(e,t)=>{Ba.init(e,t),V_.init(e,t)},{email(e){return this.check(cg(VS,e))},url(e){return this.check(pg(WS,e))},jwt(e){return this.check(Cg(ow,e))},emoji(e){return this.check(mg(ZS,e))},guid(e){return this.check(lg($S,e))},uuid(e){return this.check(ug(Qa,e))},uuidv4(e){return this.check(hg(Qa,e))},uuidv6(e){return this.check(dg(Qa,e))},uuidv7(e){return this.check(fg(Qa,e))},nanoid(e){return this.check(gg(XS,e))},cuid(e){return this.check(_g(jS,e))},cuid2(e){return this.check(xg(qS,e))},ulid(e){return this.check(vg(YS,e))},base64(e){return this.check(Tg(iw,e))},base64url(e){return this.check(Ag(rw,e))},xid(e){return this.check(yg(KS,e))},ksuid(e){return this.check(bg(JS,e))},ipv4(e){return this.check(Sg(QS,e))},ipv6(e){return this.check(wg(ew,e))},cidrv4(e){return this.check(Mg(tw,e))},cidrv6(e){return this.check(Eg(nw,e))},e164(e){return this.check(Rg(sw,e))},datetime(e){return this.check(Ig(kS,e))},date(e){return this.check(Pg(BS,e))},time(e){return this.check(Lg(GS,e))},duration(e){return this.check(Ng(HS,e))}});function Fe(e){return ag(zS,e)}var Nt=ie("ZodStringFormat",(e,t)=>{Tt.init(e,t),V_.init(e,t)}),kS=ie("ZodISODateTime",(e,t)=>{gm.init(e,t),Nt.init(e,t)}),BS=ie("ZodISODate",(e,t)=>{_m.init(e,t),Nt.init(e,t)}),GS=ie("ZodISOTime",(e,t)=>{xm.init(e,t),Nt.init(e,t)}),HS=ie("ZodISODuration",(e,t)=>{vm.init(e,t),Nt.init(e,t)}),VS=ie("ZodEmail",(e,t)=>{sm.init(e,t),Nt.init(e,t)});var $S=ie("ZodGUID",(e,t)=>{im.init(e,t),Nt.init(e,t)});var Qa=ie("ZodUUID",(e,t)=>{rm.init(e,t),Nt.init(e,t)});var WS=ie("ZodURL",(e,t)=>{cm.init(e,t),Nt.init(e,t)});var ZS=ie("ZodEmoji",(e,t)=>{lm.init(e,t),Nt.init(e,t)});var XS=ie("ZodNanoID",(e,t)=>{um.init(e,t),Nt.init(e,t)});var jS=ie("ZodCUID",(e,t)=>{hm.init(e,t),Nt.init(e,t)});var qS=ie("ZodCUID2",(e,t)=>{dm.init(e,t),Nt.init(e,t)});var YS=ie("ZodULID",(e,t)=>{fm.init(e,t),Nt.init(e,t)});var KS=ie("ZodXID",(e,t)=>{pm.init(e,t),Nt.init(e,t)});var JS=ie("ZodKSUID",(e,t)=>{mm.init(e,t),Nt.init(e,t)});var QS=ie("ZodIPv4",(e,t)=>{ym.init(e,t),Nt.init(e,t)});var ew=ie("ZodIPv6",(e,t)=>{Sm.init(e,t),Nt.init(e,t)});var tw=ie("ZodCIDRv4",(e,t)=>{wm.init(e,t),Nt.init(e,t)});var nw=ie("ZodCIDRv6",(e,t)=>{Mm.init(e,t),Nt.init(e,t)});var iw=ie("ZodBase64",(e,t)=>{Tm.init(e,t),Nt.init(e,t)});var rw=ie("ZodBase64URL",(e,t)=>{Am.init(e,t),Nt.init(e,t)});var sw=ie("ZodE164",(e,t)=>{Rm.init(e,t),Nt.init(e,t)});var ow=ie("ZodJWT",(e,t)=>{Cm.init(e,t),Nt.init(e,t)});var $_=ie("ZodNumber",(e,t)=>{Xl.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>r_(e,n,i,r),e.isFinite=!0},Gf({minValue:(e)=>{let{minimum:t,exclusiveMinimum:n}=On(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:n}=On(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:n}=On(e);return!!t||!!n?.some(Number.isSafeInteger)},format:(e)=>On(e).format??null},{gt(e,t){return this.check(Xa(e,t))},gte(e,t){return this.check(fo(e,t))},min(e,t){return this.check(fo(e,t))},lt(e,t){return this.check(Za(e,t))},lte(e,t){return this.check(ho(e,t))},max(e,t){return this.check(ho(e,t))},int(e){return this.check(z_(e))},safe(e){return this.check(z_(e))},positive(e){return this.check(Xa(0,e))},nonnegative(e){return this.check(fo(0,e))},negative(e){return this.check(Za(0,e))},nonpositive(e){return this.check(ho(0,e))},multipleOf(e,t){return this.check(ja(e,t))},step(e,t){return this.check(ja(e,t))},finite(){return this}}));function vt(e){return Dg($_,e)}var aw=ie("ZodNumberFormat",(e,t)=>{Im.init(e,t),$_.init(e,t)});function z_(e){return Og(aw,e)}var cw=ie("ZodBoolean",(e,t)=>{Pm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>s_(e,n,i,r)});function go(e){return Ug(cw,e)}var lw=ie("ZodUnknown",(e,t)=>{Lm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>a_(e,n,i,r)});function Ur(){return Fg(lw)}var uw=ie("ZodNever",(e,t)=>{Nm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>o_(e,n,i,r)});function hw(e){return zg(uw,e)}var dw=ie("ZodArray",(e,t)=>{ec(),Dm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>d_(e,n,i,r),e.element=t.element},{min(e,t){return this.check(as(e,t))},nonempty(e){return this.check(as(1,e))},max(e,t){return this.check(qa(e,t))},length(e,t){return this.check(Ya(e,t))},unwrap(){return this.element}});function wt(e,t){return kg(dw,e,t)}var fw=ie("ZodObject",(e,t)=>{ec(),Fm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>f_(e,n,i,r),Wb(e,"shape",(n)=>n._zod.def.shape,!1)},{keyof(){return pn(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(Sn(this._zod.def,{catchall:e}))},passthrough(){return this.clone(Sn(this._zod.def,{catchall:Ur()}))},loose(){return this.clone(Sn(this._zod.def,{catchall:Ur()}))},strict(){return this.clone(Sn(this._zod.def,{catchall:hw()}))},strip(){return this.clone(Sn(this._zod.def,{catchall:void 0}))},extend(e){return Fb(this,e)},safeExtend(e){return zb(this,e)},merge(e){return kb(this,e)},pick(e){return Ob(this,e)},omit(e){return Ub(this,e)},partial(...e){return Ff(X_,this,e[0])},exactPartial(...e){return Ff(j_,this,e[0],"exactPartial")},required(...e){return Bb(q_,this,e[0])}});function qe(e,t){let n={type:"object",shape:e??{},...De(t)};return new fw(n)}var W_=ie("ZodUnion",(e,t)=>{jl.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>p_(e,n,i,r),e.options=t.options});function Z_(e,t){return new W_({type:"union",options:e,...De(t)})}var pw=ie("ZodDiscriminatedUnion",(e,t)=>{W_.init(e,t),zm.init(e,t)});function mw(e,t,n){return new pw({type:"union",options:t,discriminator:e,...De(n)})}var gw=ie("ZodIntersection",(e,t)=>{km.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>m_(e,n,i,r)});function _w(e,t){return new gw({type:"intersection",left:e,right:t})}var k_=ie("ZodRecord",(e,t)=>{ec(),Bm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>g_(e,n,i,r),e.keyType=t.keyType,e.valueType=t.valueType});function tc(e,t,n){if(!t||!t._zod)return new k_({type:"record",keyType:Fe(),valueType:e,...De(t)});return new k_({type:"record",keyType:e,valueType:t,...De(n)})}var vu=ie("ZodEnum",(e,t)=>{Gm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(i,r,s)=>c_(e,i,r,s),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(i,r)=>{let s={};for(let o of i)if(n.has(o))s[o]=t.entries[o];else throw Error(`Key ${o} not found in enum`);return new vu({...t,checks:[],...De(r),entries:s})},e.exclude=(i,r)=>{let s={...t.entries};for(let o of i)if(n.has(o))delete s[o];else throw Error(`Key ${o} not found in enum`);return new vu({...t,checks:[],...De(r),entries:s})}});function pn(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map((i)=>[i,i])):e;return new vu({type:"enum",entries:n,...De(t)})}var xw=ie("ZodLiteral",(e,t)=>{Hm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>l_(e,n,i,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function jt(e,t){return new xw({type:"literal",values:Array.isArray(e)?e:[e],...De(t)})}var vw=ie("ZodTransform",(e,t)=>{ec(),Vm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>h_(e,n,i,r),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new so(e.constructor.name);n.addIssue=(s)=>{if(typeof s==="string")n.issues.push(Dr(s,n.value,t));else{let o=s;if(o.fatal)o.continue=!1;if(o.code??(o.code="custom"),!("input"in o))o.input=n.value;o.inst??(o.inst=e),n.issues.push(Dr(o))}};let r=t.transform(n.value,n);if(r instanceof Promise)return r.then((s)=>(n.value=s,n));return n.value=r,n}});function yw(e){return new vw({type:"transform",transform:e})}var X_=ie("ZodOptional",(e,t)=>{ql.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>_u(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function B_(e){return new X_({type:"optional",innerType:e})}var j_=ie("ZodExactOptional",(e,t)=>{$m.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>_u(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function bw(e){return new j_({type:"optional",innerType:e})}var Sw=ie("ZodNullable",(e,t)=>{Wm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>__(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function G_(e){return new Sw({type:"nullable",innerType:e})}var ww=ie("ZodDefault",(e,t)=>{Zm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>y_(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Mw(e,t){return new ww({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():Rl(t)}})}var Ew=ie("ZodPrefault",(e,t)=>{Xm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>b_(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function Tw(e,t){return new Ew({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():Rl(t)}})}var q_=ie("ZodNonOptional",(e,t)=>{jm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>x_(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function Aw(e,t){return new q_({type:"nonoptional",innerType:e,...De(t)})}var Rw=ie("ZodCatch",(e,t)=>{qm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>S_(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Cw(e,t){return new Rw({type:"catch",innerType:e,catchValue:typeof t==="function"?t:Hf(t)})}var Iw=ie("ZodPipe",(e,t)=>{Ym.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>w_(e,n,i,r),e.in=t.in,e.out=t.out});function H_(e,t){return new Iw({type:"pipe",in:e,out:t})}var Pw=ie("ZodReadonly",(e,t)=>{Km.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>M_(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function Lw(e){return new Pw({type:"readonly",innerType:e})}var Nw=ie("ZodCustom",(e,t)=>{Jm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>u_(e,n,i,r)});function Dw(e,t={}){return Bg(Nw,e,t)}function Ow(e,t){return Gg(e,t)}var nc={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};var Y_;(function(e){})(Y_||(Y_={}));var K_=["neutral","dark","light"];var bu=(e,t)=>Object.freeze({id:e,rgb:Object.freeze([...t]),hex:`#${t.map((n)=>n.toString(16).padStart(2,"0")).join("")}`}),J_=Object.freeze({neutral:bu("neutral",[170,177,188]),dark:bu("dark",[26,26,26]),light:bu("light",[223,227,232])});var mL=J_.neutral.rgb,gL=J_.neutral.hex;/*!
57
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let o of e.seen.entries()){let a=o[1];if(t===o[0]){s(o);continue}if(e.external){let l=e.external.registry.get(o[0])?.id;if(t!==o[0]&&l){s(o);continue}}if(e.metadataRegistry.get(o[0])?.id){s(o);continue}if(a.cycle){s(o);continue}if(a.count>1){if(e.reused==="ref")s(o)}}if(e.external)e.sharedDefsExtractedFor=e.external}function Zg(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let i of t){if(!i||typeof i!=="object")return;Zg(i);let r=Object.keys(i);if(r.length!==1||r[0]!=="type")return;let s=i.type;for(let o of Array.isArray(s)?s:[s]){if(typeof o!=="string")return;if(!n.includes(o))n.push(o)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var Xg=new Set(["type","properties","required","additionalProperties"]),$g=["oneOf","anyOf"];function Wg(e){let t=e.additionalProperties;if(t===void 0||t===!1||typeof t!=="object"||t===null)return null;return Object.keys(t).length?t:null}function hu(e){let t=[];for(let s of e){if(typeof s!=="object"||s.type!=="object")return null;for(let o in s)if(!Xg.has(o))return null;t.push(s)}let n={},i=new Set;for(let s of t){for(let o in s.properties){if(Object.prototype.hasOwnProperty.call(n,o))continue;let a=[];for(let l of t){let u=l.properties?.[o]??Wg(l);if(u===null||u===void 0)continue;if(!a.some((h)=>JSON.stringify(h)===JSON.stringify(u)))a.push(u)}let c=a.length===1?a[0]:hu(a)??{allOf:a};Dn(n,o,c)}for(let o of s.required??[])i.add(o)}let r={type:"object",properties:n};if(i.size)r.required=[...i];if(t.every((s)=>s.additionalProperties===!1))r.additionalProperties=!1;else{let s=[];for(let o of t){let a=Wg(o);if(a&&!s.some((c)=>JSON.stringify(c)===JSON.stringify(a)))s.push(a)}if(s.length===1)r.additionalProperties=s[0];else if(s.length>1)r.additionalProperties={allOf:s}}return r}function ES(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let r of Xg)if(r in e)return;let n=t.filter((r)=>$g.some((s)=>Array.isArray(r[s]))),i=null;if(!n.length)i=hu(t);else{let r=n[0],s=$g.find((c)=>Array.isArray(r[c]));if(Object.keys(r).length!==1)return;let o=t.filter((c)=>c!==r),a=r[s].map((c)=>hu([...o,c]));if(a.some((c)=>!c))return;i={[s]:a}}if(!i)return;delete e.allOf,_o(e,i)}function pu(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");let i=(a)=>{let c=e.seen.get(a);if(c.ref===null)return;let l=c.def??c.schema,u={...l},h=c.ref;if(c.ref=null,h){i(h);let f=e.seen.get(h),m=f.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))l.allOf=l.allOf??[],l.allOf.push(m);else _o(l,m);if(_o(l,u),a._zod.parent===h)for(let p in l){if(p==="$ref"||p==="allOf")continue;if(!(p in u))delete l[p]}if(m.$ref&&f.def)for(let p in l){if(p==="$ref"||p==="allOf")continue;if(p in f.def&&JSON.stringify(l[p])===JSON.stringify(f.def[p]))delete l[p]}}let d=a._zod.parent;if(d&&d!==h){i(d);let f=e.seen.get(d);if(f?.schema.$ref){if(l.$ref=f.schema.$ref,f.def)for(let m in l){if(m==="$ref"||m==="allOf")continue;if(m in f.def&&JSON.stringify(l[m])===JSON.stringify(f.def[m]))delete l[m]}}}e.override({zodSchema:a,jsonSchema:l,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())i(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())Zg(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let l of[c.schema,c.def]){let u=l?.allOf;if(!Array.isArray(u))continue;let h=a.get(u);if(h)h.push(l);else a.set(u,[l])}for(let c of e.intersections)for(let l of a.get(c)??[])ES(l)}}let r={};if(e.target==="draft-2020-12")r.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")r.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")r.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw Error("Schema is missing an `id` property");r.$id=e.external.uri(a)}_o(r,n.defId?n.schema:n.def??n.schema);let s=e.metadataRegistry.get(t)?.id;if(s!==void 0&&r.id===s)delete r.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let a of e.seen.entries()){let c=a[1];if(c.def&&c.defId){if(c.def.id===c.defId)delete c.def.id;Dn(o,c.defId,c.def)}}if(e.external)e.sharedEmitDoneFor=e.external;if(e.external);else if(Object.keys(o).length>0)if(e.target==="draft-2020-12")r.$defs=o;else r.definitions=o;try{let a=JSON.parse(JSON.stringify(r));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:xo(t,"input",e.processors),output:xo(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function fn(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let i=e._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return fn(i.element,n);if(i.type==="set")return fn(i.valueType,n);if(i.type==="lazy")return fn(i.getter(),n);if(i.type==="promise"||i.type==="optional"||i.type==="nonoptional"||i.type==="nullable"||i.type==="readonly"||i.type==="default"||i.type==="prefault"||i.type==="catch")return fn(i.innerType,n);if(i.type==="intersection")return fn(i.left,n)||fn(i.right,n);if(i.type==="record"||i.type==="map")return fn(i.keyType,n)||fn(i.valueType,n);if(i.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return fn(i.in,n)||fn(i.out,n)}if(i.type==="object"){for(let r in i.shape)if(fn(i.shape[r],n))return!0;return!1}if(i.type==="union"){for(let r of i.options)if(fn(r,n))return!0;return!1}if(i.type==="tuple"){for(let r of i.items)if(fn(r,n))return!0;if(i.rest&&fn(i.rest,n))return!0;return!1}return!1}var jg=(e,t={})=>(n)=>{let i=du({...n,processors:t});return zt(e,i),fu(i,e),pu(i,e)},xo=(e,t,n={})=>(i)=>{let{libraryOptions:r,target:s}=i??{},o=du({...r??{},target:s,io:t,processors:n});return zt(e,o),fu(o,e),pu(o,e)};var ls=(e,t,n)=>{if(e[t]===void 0||n>e[t])e[t]=n},us=(e,t,n)=>{if(e[t]===void 0||n<e[t])e[t]=n},qg=(e,t)=>{ls(e,"minimum",t),us(e,"maximum",t)},Qg=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},e_=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},t_=(e,t)=>{e.mime=e.mime?e.mime.filter((n)=>t.includes(n)):[...t]},n_=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},Yg=(e,t)=>ls(e,"minimum",t.minimum),Kg=(e,t)=>us(e,"maximum",t.maximum),Jg=(e)=>(t,n)=>{n_(t,n.format);let[i,r]=e[n.format];ls(t,"minimum",i),us(t,"maximum",r)},TS={greater_than:(e,t)=>ls(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>us(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>Qg(e,t.value),number_format:Jg(Ra),bigint_format:Jg(Pl),min_length:Yg,max_length:Kg,length_equals:(e,t)=>qg(e,t.length),min_size:Yg,max_size:Kg,size_equals:(e,t)=>qg(e,t.size),string_format:(e,t)=>{if(n_(e,t.format),t.pattern)e_(e,t.pattern);if(t.format==="base64"||t.format==="base64url")e.contentEncoding=t.format;if(t.local||t.precision===-1)e.laxFormat=!0},mime_type:(e,t)=>t_(e,t.mime)};function On(e){let t={},n=e._zod.def,i=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(let s of i)TS[s._zod.def.check]?.(t,s._zod.def);let r=e._zod.bag;if(r.minimum!==void 0)ls(t,"minimum",r.minimum);if(r.exclusiveMinimum!==void 0)ls(t,"exclusiveMinimum",r.exclusiveMinimum);if(r.maximum!==void 0)us(t,"maximum",r.maximum);if(r.exclusiveMaximum!==void 0)us(t,"exclusiveMaximum",r.exclusiveMaximum);if(r.multipleOf!==void 0)Qg(t,r.multipleOf);if(r.format!==void 0){if(t.format??(t.format=r.format),r.format.includes("int"))t.isInt=!0}if(r.mime)t_(t,r.mime);for(let s of r.patterns??[])e_(t,s);return t}var AS={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},RS=new Map([[Xl,bp],[Va,Sp]]),i_=(e)=>RS.get(e)??e,r_=(e,t,n,i)=>{let r=n;r.type="string";let{minimum:s,maximum:o,format:a,patterns:c,contentEncoding:l,laxFormat:u}=On(e);if(typeof s==="number")r.minLength=s;if(typeof o==="number")r.maxLength=o;if(a){if(r.format=AS[a]??a,r.format==="")delete r.format;if(a==="time"||u)delete r.format}if(l)r.contentEncoding=l;if(c&&c.size>0){let h=[...c].map(i_);if(h.length===1)r.pattern=h[0].source;else if(h.length>1)r.allOf=[...h.map((d)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))]}},s_=(e,t,n,i)=>{let r=n,{minimum:s,maximum:o,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=On(e);r.type=u?"integer":"number";let h=typeof l==="number"&&l>=(s??Number.NEGATIVE_INFINITY),d=typeof c==="number"&&c<=(o??Number.POSITIVE_INFINITY),f=t.target==="draft-04"||t.target==="openapi-3.0";if(h)if(f)r.minimum=l,r.exclusiveMinimum=!0;else r.exclusiveMinimum=l;else if(typeof s==="number")r.minimum=s;if(d)if(f)r.maximum=c,r.exclusiveMaximum=!0;else r.exclusiveMaximum=c;else if(typeof o==="number")r.maximum=o;if(a){let m=new Set;for(let g of a)if(Number.isFinite(g)&&g!==0)m.add(Math.abs(g));else Oi(e,t,r,i,`A multipleOf divisor of ${g} cannot be represented in JSON Schema`);let[_,...p]=m;if(_!==void 0)r.multipleOf=_;if(p.length)r.allOf=[...r.allOf??[],...p.map((g)=>({multipleOf:g}))]}},o_=(e,t,n,i)=>{n.type="boolean"};var a_=(e,t,n,i)=>{n.not={}};var c_=(e,t,n,i)=>{};var l_=(e,t,n,i)=>{let r=e._zod.def,s=ro(r.entries);if(s.length===0){n.not={};return}if(s.every((o)=>typeof o==="number"))n.type="number";if(s.every((o)=>typeof o==="string"))n.type="string";n.enum=s},u_=(e,t,n,i)=>{let r=e._zod.def;if(r.values.length===0){n.not={};return}let s=[];for(let o of r.values)if(o===void 0){if(Oi(e,t,n,i,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==="bigint"){if(Oi(e,t,n,i,"BigInt literals cannot be represented in JSON Schema"))return;s.push(Number(o))}else s.push(o);if(s.length===0);else if(s.length===1){let o=s[0];if(n.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0")n.enum=[o];else n.const=o}else{if(s.every((o)=>typeof o==="number"))n.type="number";if(s.every((o)=>typeof o==="string"))n.type="string";if(s.every((o)=>typeof o==="boolean"))n.type="boolean";if(s.every((o)=>o===null))n.type="null";n.enum=s}};var h_=(e,t,n,i)=>{Oi(e,t,n,i,"Custom types cannot be represented in JSON Schema")};var d_=(e,t,n,i)=>{Oi(e,t,n,i,"Transforms cannot be represented in JSON Schema")};var f_=(e,t,n,i)=>{let r=n,s=e._zod.def,{minimum:o,maximum:a}=On(e);if(typeof o==="number")r.minItems=o;if(typeof a==="number")r.maxItems=a;r.type="array",r.items=zt(s.element,t,{...i,path:[...i.path,"items"]})};function Qa(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return Qa(t.out);if(t.type==="catch")return Qa(t.innerType);return e._zod.optin}var p_=(e,t,n,i)=>{let r=n,s=e._zod.def,o=s.shape;if(Object.getOwnPropertySymbols(o).length&&Oi(e,t,r,i,"Symbol keys cannot be represented in JSON Schema"))return;r.type="object",r.properties={};for(let l in o)Dn(r.properties,l,zt(o[l],t,{...i,path:[...i.path,"properties",l]}));let c=[];for(let l of Object.keys(o)){let u=s.shape[l];if(t.io==="input"?Qa(u)===void 0:u._zod.optout===void 0)c.push(l)}if(c.length>0)r.required=c;if(s.catchall?._zod.def.type==="never")r.additionalProperties=!1;else if(!s.catchall){if(t.io==="output")r.additionalProperties=!1}else if(s.catchall)r.additionalProperties=zt(s.catchall,t,{...i,path:[...i.path,"additionalProperties"]})},m_=(e,t,n,i)=>{let r=e._zod.def,s=r.inclusive===!1,o=r.options.map((a,c)=>zt(a,t,{...i,path:[...i.path,s?"oneOf":"anyOf",c]}));if(s)n.oneOf=o;else n.anyOf=o},g_=(e,t,n,i)=>{let r=e._zod.def,s=zt(r.left,t,{...i,path:[...i.path,"allOf",0]}),o=zt(r.right,t,{...i,path:[...i.path,"allOf",1]}),a=(l)=>("allOf"in l)&&Object.keys(l).length===1,c=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)};function mu(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let m=e.get(t)?.def;if(!m)return t;let _=mu(e,m,n);return _===m?t:_}for(let m of["anyOf","oneOf"]){let _=t[m];if(!Array.isArray(_))continue;let p=_.map((g)=>mu(e,g,n));if(p.some((g,M)=>g!==_[M]))t={...t,[m]:p}}let i=Array.isArray(t.type)?t.type:[t.type],r=!i.includes("string")&&i.some((m)=>m==="number"||m==="integer"),s=t.enum??(t.const!==void 0?[t.const]:void 0);if(!r&&!s?.some((m)=>typeof m==="number"))return t;let{minimum:o,maximum:a,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:h,id:d,...f}=t;if(f.enum)f.enum=f.enum.map((m)=>typeof m==="number"?String(m):m);else if(typeof f.const==="number")f.const=String(f.const);if(!r)return f;if(f.type="string",!s)f.pattern=(i.includes("number")?lo:Bl).source;return f}var gu=new WeakMap;function CS(e){let t=new Map;for(let i of e.seen.values())if(i.def&&!t.has(i.schema))t.set(i.schema,i);let n=new Map;for(let i of gu.get(e)??[]){let r=e.seen.get(i),s=(r?.def??r?.schema)?.propertyNames;if(!s||s===!0||n.has(s))continue;let o=mu(t,s,new Set);if(o!==s)n.set(s,o)}if(!n.size)return;for(let i of e.seen.values())for(let r of[i.schema,i.def]){let s=r&&n.get(r.propertyNames);if(s)r.propertyNames=s}}var __=(e,t,n,i)=>{let r=n,s=e._zod.def;r.type="object";let o=s.keyType,a=On(o).patterns;if(s.mode==="loose"&&a&&a.size>0){let u=zt(s.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});r.patternProperties={};for(let h of a)Dn(r.patternProperties,i_(h).source,u)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){r.propertyNames=zt(s.keyType,t,{...i,path:[...i.path,"propertyNames"]});let u=gu.get(t);if(!u)u=[],gu.set(t,u),t.deferred.push(()=>CS(t));u.push(e)}r.additionalProperties=zt(s.valueType,t,{...i,path:[...i.path,"additionalProperties"]})}let c=o._zod.values,l=t.io==="input"&&Qa(s.valueType)!==void 0;if(c&&!s.partial&&!l){let u=[...c].filter((h)=>typeof h==="string"||typeof h==="number");if(u.length>0)r.required=u.map(String)}},x_=(e,t,n,i)=>{let r=e._zod.def,s=zt(r.innerType,t,i),o=t.seen.get(e);if(t.target==="openapi-3.0")o.ref=r.innerType,n.nullable=!0;else n.anyOf=[s,{type:"null"}]},v_=(e,t,n,i)=>{let r=e._zod.def;zt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType},_u=Symbol();function y_(e,t,n,i,r){let s=!1,o=JSON.stringify(e,(a,c)=>{if(typeof c!=="bigint")return c;return s=!0,null});if(!s)return JSON.parse(o);return Oi(t,n,i,r,"BigInt defaults cannot be represented in JSON Schema"),_u}var b_=(e,t,n,i)=>{let r=e._zod.def;zt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType;let o=y_(r.defaultValue,e,t,n,i);if(o!==_u)n.default=o},S_=(e,t,n,i)=>{let r=e._zod.def;zt(r.innerType,t,i);let s=t.seen.get(e);if(s.ref=r.innerType,t.io!=="input")return;let o=y_(r.defaultValue,e,t,n,i);if(o!==_u)n._prefault=o},w_=(e,t,n,i)=>{let r=e._zod.def;zt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType;let o;try{o=r.catchValue(void 0)}catch{Oi(e,t,n,i,"Dynamic catch values are not supported in JSON Schema");return}n.default=o},M_=(e,t,n,i)=>{let r=e._zod.def,s=r.in._zod.traits.has("$ZodTransform"),o=t.io==="input"?s?r.out:r.in:r.out;zt(o,t,i);let a=t.seen.get(e);a.ref=o},E_=(e,t,n,i)=>{let r=e._zod.def;zt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType,n.readOnly=!0};var xu=(e,t,n,i)=>{let r=e._zod.def;zt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType};var T_=new WeakSet([Object.prototype,Error.prototype]);function ec(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let i=n(this);return Object.defineProperty(this,t,{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,t,{value:i,configurable:!0,writable:!0})}})}var FS=(e,t)=>{jf.init(e,t),e.name="ZodError";let n=Object.getPrototypeOf(e);if(T_.has(n))return;T_.add(n),ec(n,"format",(i)=>(r)=>Yf(i,r)),ec(n,"flatten",(i)=>(r)=>qf(i,r)),ec(n,"addIssue",(i)=>(r)=>{i.issues.push(r),i.message=JSON.stringify(i.issues,so,2)}),ec(n,"addIssues",(i)=>(r)=>{i.issues.push(...r),i.message=JSON.stringify(i.issues,so,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var Mn=ie("ZodError",FS,void 0,{Parent:Error});var A_=Da(Mn),R_=Oa(Mn),C_=Ua(Mn),I_=Fa(Mn),P_=Jf(Mn),L_=Qf(Mn),N_=ep(Mn),D_=tp(Mn),O_=np(Mn),U_=ip(Mn),F_=rp(Mn),z_=sp(Mn);function kS(){if(!xn.localeError)wn(Ql())}function nc(){if(!xn.memoizer)wn({memoizer:rg()})}var Lt=ie("ZodType",(e,t)=>(kS(),Ct.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(Sn(t,{checks:[...t.checks??[],...e.map((n)=>typeof n==="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return ci(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Uw(e,t))},superRefine(e,t){return this.check(Fw(e,t))},overwrite(e){return this.check(tr(e))},optional(){return G_(this)},exactOptional(){return ww(this)},nullable(){return H_(this)},nullish(){return G_(H_(this))},nonoptional(e){return Cw(this,e)},array(){return wt(this)},or(e){return X_([this,e])},and(e){return vw(this,e)},transform(e){return V_(this,Sw(e))},default(e){return Tw(this,e)},prefault(e){return Rw(this,e)},catch(e){return Pw(this,e)},pipe(e){return V_(this,e)},readonly(){return Dw(this)},describe(e){let t=this.clone();return Ur.add(t,{description:e}),t},meta(...e){if(e.length===0)return Ur.get(this);let t=this.clone();return Ur.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get "~standard"(){return La(this,"~standard",{...Zl(this),jsonSchema:{input:xo(this,"input"),output:xo(this,"output")}})},set "~standard"(e){Di(this,"~standard",e)},parse:function e(t,n){return A_(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await R_(this,t,n,{callee:e})},safeParse(e,t){return C_(this,e,t)},async safeParseAsync(e,t){return I_(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Di(this,"spa",e)},validate(e,t){return Ul(this,e,t)},validateAsync(e,t){return Fl(this,e,t)},encode:function e(t,n){return P_(this,t,n,{callee:e})},decode:function e(t,n){return L_(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await N_(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await D_(this,t,n,{callee:e})},safeEncode(e,t){return O_(this,e,t)},safeDecode(e,t){return U_(this,e,t)},async safeEncodeAsync(e,t){return F_(this,e,t)},async safeDecodeAsync(e,t){return z_(this,e,t)},toJSONSchema(e){return jg(this,{})(e)},get description(){return Ur.get(this)?.description},get _def(){return this._zod.def}}),$_=ie("_ZodString",(e,t)=>{Ha.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>r_(e,n,i,r)},Hf({format:(e)=>On(e).format??null,minLength:(e)=>On(e).minimum??null,maxLength:(e)=>On(e).maximum??null},{regex(...e){return this.check(eu(...e))},includes(...e){return this.check(iu(...e))},startsWith(...e){return this.check(ru(...e))},endsWith(...e){return this.check(su(...e))},min(...e){return this.check(cs(...e))},max(...e){return this.check(Ka(...e))},length(...e){return this.check(Ja(...e))},nonempty(...e){return this.check(cs(1,...e))},lowercase(e){return this.check(tu(e))},uppercase(e){return this.check(nu(e))},trim(){return this.check(au())},normalize(...e){return this.check(ou(...e))},toLowerCase(){return this.check(cu())},toUpperCase(){return this.check(lu())},slugify(){return this.check(uu())}})),BS=ie("ZodString",(e,t)=>{Ha.init(e,t),$_.init(e,t)},{email(e){return this.check(lg(WS,e))},url(e){return this.check(mg(XS,e))},jwt(e){return this.check(Ig(cw,e))},emoji(e){return this.check(gg(jS,e))},guid(e){return this.check(ug(ZS,e))},uuid(e){return this.check(hg(tc,e))},uuidv4(e){return this.check(dg(tc,e))},uuidv6(e){return this.check(fg(tc,e))},uuidv7(e){return this.check(pg(tc,e))},nanoid(e){return this.check(_g(qS,e))},cuid(e){return this.check(xg(YS,e))},cuid2(e){return this.check(vg(KS,e))},ulid(e){return this.check(yg(JS,e))},base64(e){return this.check(Ag(sw,e))},base64url(e){return this.check(Rg(ow,e))},xid(e){return this.check(bg(QS,e))},ksuid(e){return this.check(Sg(ew,e))},ipv4(e){return this.check(wg(tw,e))},ipv6(e){return this.check(Mg(nw,e))},cidrv4(e){return this.check(Eg(iw,e))},cidrv6(e){return this.check(Tg(rw,e))},e164(e){return this.check(Cg(aw,e))},datetime(e){return this.check(Pg(GS,e))},date(e){return this.check(Lg(HS,e))},time(e){return this.check(Ng(VS,e))},duration(e){return this.check(Dg($S,e))}});function Fe(e){return cg(BS,e)}var Nt=ie("ZodStringFormat",(e,t)=>{Tt.init(e,t),$_.init(e,t)}),GS=ie("ZodISODateTime",(e,t)=>{_m.init(e,t),Nt.init(e,t)}),HS=ie("ZodISODate",(e,t)=>{xm.init(e,t),Nt.init(e,t)}),VS=ie("ZodISOTime",(e,t)=>{vm.init(e,t),Nt.init(e,t)}),$S=ie("ZodISODuration",(e,t)=>{ym.init(e,t),Nt.init(e,t)}),WS=ie("ZodEmail",(e,t)=>{om.init(e,t),Nt.init(e,t)});var ZS=ie("ZodGUID",(e,t)=>{rm.init(e,t),Nt.init(e,t)});var tc=ie("ZodUUID",(e,t)=>{sm.init(e,t),Nt.init(e,t)});var XS=ie("ZodURL",(e,t)=>{lm.init(e,t),Nt.init(e,t)});var jS=ie("ZodEmoji",(e,t)=>{um.init(e,t),Nt.init(e,t)});var qS=ie("ZodNanoID",(e,t)=>{hm.init(e,t),Nt.init(e,t)});var YS=ie("ZodCUID",(e,t)=>{dm.init(e,t),Nt.init(e,t)});var KS=ie("ZodCUID2",(e,t)=>{fm.init(e,t),Nt.init(e,t)});var JS=ie("ZodULID",(e,t)=>{pm.init(e,t),Nt.init(e,t)});var QS=ie("ZodXID",(e,t)=>{mm.init(e,t),Nt.init(e,t)});var ew=ie("ZodKSUID",(e,t)=>{gm.init(e,t),Nt.init(e,t)});var tw=ie("ZodIPv4",(e,t)=>{bm.init(e,t),Nt.init(e,t)});var nw=ie("ZodIPv6",(e,t)=>{wm.init(e,t),Nt.init(e,t)});var iw=ie("ZodCIDRv4",(e,t)=>{Mm.init(e,t),Nt.init(e,t)});var rw=ie("ZodCIDRv6",(e,t)=>{Em.init(e,t),Nt.init(e,t)});var sw=ie("ZodBase64",(e,t)=>{Am.init(e,t),Nt.init(e,t)});var ow=ie("ZodBase64URL",(e,t)=>{Rm.init(e,t),Nt.init(e,t)});var aw=ie("ZodE164",(e,t)=>{Cm.init(e,t),Nt.init(e,t)});var cw=ie("ZodJWT",(e,t)=>{Im.init(e,t),Nt.init(e,t)});var W_=ie("ZodNumber",(e,t)=>{jl.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>s_(e,n,i,r),e.isFinite=!0},Hf({minValue:(e)=>{let{minimum:t,exclusiveMinimum:n}=On(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:n}=On(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:n}=On(e);return!!t||!!n?.some(Number.isSafeInteger)},format:(e)=>On(e).format??null},{gt(e,t){return this.check(qa(e,t))},gte(e,t){return this.check(go(e,t))},min(e,t){return this.check(go(e,t))},lt(e,t){return this.check(ja(e,t))},lte(e,t){return this.check(mo(e,t))},max(e,t){return this.check(mo(e,t))},int(e){return this.check(k_(e))},safe(e){return this.check(k_(e))},positive(e){return this.check(qa(0,e))},nonnegative(e){return this.check(go(0,e))},negative(e){return this.check(ja(0,e))},nonpositive(e){return this.check(mo(0,e))},multipleOf(e,t){return this.check(Ya(e,t))},step(e,t){return this.check(Ya(e,t))},finite(){return this}}));function vt(e){return Og(W_,e)}var lw=ie("ZodNumberFormat",(e,t)=>{Pm.init(e,t),W_.init(e,t)});function k_(e){return Ug(lw,e)}var uw=ie("ZodBoolean",(e,t)=>{Lm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>o_(e,n,i,r)});function vo(e){return Fg(uw,e)}var hw=ie("ZodUnknown",(e,t)=>{Nm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>c_(e,n,i,r)});function Fr(){return zg(hw)}var dw=ie("ZodNever",(e,t)=>{Dm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>a_(e,n,i,r)});function fw(e){return kg(dw,e)}var pw=ie("ZodArray",(e,t)=>{nc(),Om.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>f_(e,n,i,r),e.element=t.element},{min(e,t){return this.check(cs(e,t))},nonempty(e){return this.check(cs(1,e))},max(e,t){return this.check(Ka(e,t))},length(e,t){return this.check(Ja(e,t))},unwrap(){return this.element}});function wt(e,t){return Bg(pw,e,t)}var mw=ie("ZodObject",(e,t)=>{nc(),zm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>p_(e,n,i,r),Xb(e,"shape",(n)=>n._zod.def.shape,!1)},{keyof(){return pn(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(Sn(this._zod.def,{catchall:e}))},passthrough(){return this.clone(Sn(this._zod.def,{catchall:Fr()}))},loose(){return this.clone(Sn(this._zod.def,{catchall:Fr()}))},strict(){return this.clone(Sn(this._zod.def,{catchall:fw()}))},strip(){return this.clone(Sn(this._zod.def,{catchall:void 0}))},extend(e){return kb(this,e)},safeExtend(e){return Bb(this,e)},merge(e){return Gb(this,e)},pick(e){return Fb(this,e)},omit(e){return zb(this,e)},partial(...e){return zf(j_,this,e[0])},exactPartial(...e){return zf(q_,this,e[0],"exactPartial")},required(...e){return Hb(Y_,this,e[0])}});function qe(e,t){let n={type:"object",shape:e??{},...De(t)};return new mw(n)}var Z_=ie("ZodUnion",(e,t)=>{ql.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>m_(e,n,i,r),e.options=t.options});function X_(e,t){return new Z_({type:"union",options:e,...De(t)})}var gw=ie("ZodDiscriminatedUnion",(e,t)=>{Z_.init(e,t),km.init(e,t)});function _w(e,t,n){return new gw({type:"union",options:t,discriminator:e,...De(n)})}var xw=ie("ZodIntersection",(e,t)=>{Bm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>g_(e,n,i,r)});function vw(e,t){return new xw({type:"intersection",left:e,right:t})}var B_=ie("ZodRecord",(e,t)=>{nc(),Gm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>__(e,n,i,r),e.keyType=t.keyType,e.valueType=t.valueType});function ic(e,t,n){if(!t||!t._zod)return new B_({type:"record",keyType:Fe(),valueType:e,...De(t)});return new B_({type:"record",keyType:e,valueType:t,...De(n)})}var yu=ie("ZodEnum",(e,t)=>{Hm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(i,r,s)=>l_(e,i,r,s),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(i,r)=>{let s={};for(let o of i)if(n.has(o))s[o]=t.entries[o];else throw Error(`Key ${o} not found in enum`);return new yu({...t,checks:[],...De(r),entries:s})},e.exclude=(i,r)=>{let s={...t.entries};for(let o of i)if(n.has(o))delete s[o];else throw Error(`Key ${o} not found in enum`);return new yu({...t,checks:[],...De(r),entries:s})}});function pn(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map((i)=>[i,i])):e;return new yu({type:"enum",entries:n,...De(t)})}var yw=ie("ZodLiteral",(e,t)=>{Vm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>u_(e,n,i,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function jt(e,t){return new yw({type:"literal",values:Array.isArray(e)?e:[e],...De(t)})}var bw=ie("ZodTransform",(e,t)=>{nc(),$m.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>d_(e,n,i,r),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new co(e.constructor.name);n.addIssue=(s)=>{if(typeof s==="string")n.issues.push(Or(s,n.value,t));else{let o=s;if(o.fatal)o.continue=!1;if(o.code??(o.code="custom"),!("input"in o))o.input=n.value;o.inst??(o.inst=e),n.issues.push(Or(o))}};let r=t.transform(n.value,n);if(r instanceof Promise)return r.then((s)=>(n.value=s,n));return n.value=r,n}});function Sw(e){return new bw({type:"transform",transform:e})}var j_=ie("ZodOptional",(e,t)=>{Yl.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>xu(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function G_(e){return new j_({type:"optional",innerType:e})}var q_=ie("ZodExactOptional",(e,t)=>{Wm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>xu(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function ww(e){return new q_({type:"optional",innerType:e})}var Mw=ie("ZodNullable",(e,t)=>{Zm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>x_(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function H_(e){return new Mw({type:"nullable",innerType:e})}var Ew=ie("ZodDefault",(e,t)=>{Xm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>b_(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Tw(e,t){return new Ew({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():Cl(t)}})}var Aw=ie("ZodPrefault",(e,t)=>{jm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>S_(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function Rw(e,t){return new Aw({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():Cl(t)}})}var Y_=ie("ZodNonOptional",(e,t)=>{qm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>v_(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function Cw(e,t){return new Y_({type:"nonoptional",innerType:e,...De(t)})}var Iw=ie("ZodCatch",(e,t)=>{Ym.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>w_(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Pw(e,t){return new Iw({type:"catch",innerType:e,catchValue:typeof t==="function"?t:Vf(t)})}var Lw=ie("ZodPipe",(e,t)=>{Km.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>M_(e,n,i,r),e.in=t.in,e.out=t.out});function V_(e,t){return new Lw({type:"pipe",in:e,out:t})}var Nw=ie("ZodReadonly",(e,t)=>{Jm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>E_(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function Dw(e){return new Nw({type:"readonly",innerType:e})}var Ow=ie("ZodCustom",(e,t)=>{Qm.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>h_(e,n,i,r)});function Uw(e,t={}){return Gg(Ow,e,t)}function Fw(e,t){return Hg(e,t)}var rc={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};var K_;(function(e){})(K_||(K_={}));var J_=["neutral","dark","light"];var Su=(e,t)=>Object.freeze({id:e,rgb:Object.freeze([...t]),hex:`#${t.map((n)=>n.toString(16).padStart(2,"0")).join("")}`}),Q_=Object.freeze({neutral:Su("neutral",[170,177,188]),dark:Su("dark",[26,26,26]),light:Su("light",[223,227,232])});var _L=Q_.neutral.rgb,xL=Q_.neutral.hex;/*!
58
58
  fflate - fast JavaScript compression/decompression
59
59
  <https://101arrowz.github.io/fflate>
60
60
  Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE
61
61
  version 0.8.2
62
- */var Dt=Uint8Array,En=Uint16Array,Lu=Int32Array,ic=new Dt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),rc=new Dt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Tu=new Dt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),s0=function(e,t){var n=new En(31);for(var i=0;i<31;++i)n[i]=t+=1<<e[i-1];var r=new Lu(n[30]);for(var i=1;i<30;++i)for(var s=n[i];s<n[i+1];++s)r[s]=s-n[i]<<5|i;return{b:n,r}},o0=s0(ic,2),{b:a0,r:Au}=o0;a0[28]=258,Au[258]=28;var c0=s0(rc,0),{b:Uw,r:Q_}=c0,Ru=new En(32768);for(tt=0;tt<32768;++tt)di=(tt&43690)>>1|(tt&21845)<<1,di=(di&52428)>>2|(di&13107)<<2,di=(di&61680)>>4|(di&3855)<<4,Ru[tt]=((di&65280)>>8|(di&255)<<8)>>1;var di,tt,pi=function(e,t,n){var i=e.length,r=0,s=new En(t);for(;r<i;++r)if(e[r])++s[e[r]-1];var o=new En(t);for(r=1;r<t;++r)o[r]=o[r-1]+s[r-1]<<1;var a;if(n){a=new En(1<<t);var c=15-t;for(r=0;r<i;++r)if(e[r]){var l=r<<4|e[r],u=t-e[r],h=o[e[r]-1]++<<u;for(var d=h|(1<<u)-1;h<=d;++h)a[Ru[h]>>c]=l}}else{a=new En(i);for(r=0;r<i;++r)if(e[r])a[r]=Ru[o[e[r]-1]++]>>15-e[r]}return a},tr=new Dt(288);for(tt=0;tt<144;++tt)tr[tt]=8;var tt;for(tt=144;tt<256;++tt)tr[tt]=9;var tt;for(tt=256;tt<280;++tt)tr[tt]=7;var tt;for(tt=280;tt<288;++tt)tr[tt]=8;var tt,vo=new Dt(32);for(tt=0;tt<32;++tt)vo[tt]=5;var tt,Fw=pi(tr,9,0),zw=pi(tr,9,1),kw=pi(vo,5,0),Bw=pi(vo,5,1),Su=function(e){var t=e[0];for(var n=1;n<e.length;++n)if(e[n]>t)t=e[n];return t},$n=function(e,t,n){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(t&7)&n},wu=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},Nu=function(e){return(e+7)/8|0},yo=function(e,t,n){if(t==null||t<0)t=0;if(n==null||n>e.length)n=e.length;return new Dt(e.subarray(t,n))};var Gw=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],mn=function(e,t,n){var i=Error(t||Gw[e]);if(i.code=e,Error.captureStackTrace)Error.captureStackTrace(i,mn);if(!n)throw i;return i},Hw=function(e,t,n,i){var r=e.length,s=i?i.length:0;if(!r||t.f&&!t.l)return n||new Dt(0);var o=!n,a=o||t.i!=2,c=t.i;if(o)n=new Dt(r*3);var l=function(ae){var ke=n.length;if(ae>ke){var Ce=new Dt(Math.max(ke*2,ae));Ce.set(n),n=Ce}},u=t.f||0,h=t.p||0,d=t.b||0,{l:f,d:m,m:_,n:p}=t,g=r*8;do{if(!f){u=$n(e,h,1);var M=$n(e,h+1,3);if(h+=3,!M){var T=Nu(h)+4,v=e[T-4]|e[T-3]<<8,S=T+v;if(S>r){if(c)mn(0);break}if(a)l(d+v);n.set(e.subarray(T,S),d),t.b=d+=v,t.p=h=S*8,t.f=u;continue}else if(M==1)f=zw,m=Bw,_=9,p=5;else if(M==2){var E=$n(e,h,31)+257,R=$n(e,h+10,15)+4,x=E+$n(e,h+5,31)+1;h+=14;var w=new Dt(x),H=new Dt(19);for(var C=0;C<R;++C)H[Tu[C]]=$n(e,h+C*3,7);h+=R*3;var N=Su(H),ee=(1<<N)-1,P=pi(H,N,1);for(var C=0;C<x;){var Z=P[$n(e,h,ee)];h+=Z&15;var T=Z>>4;if(T<16)w[C++]=T;else{var G=0,k=0;if(T==16)k=3+$n(e,h,3),h+=2,G=w[C-1];else if(T==17)k=3+$n(e,h,7),h+=3;else if(T==18)k=11+$n(e,h,127),h+=7;while(k--)w[C++]=G}}var W=w.subarray(0,E),B=w.subarray(E);_=Su(W),p=Su(B),f=pi(W,_,1),m=pi(B,p,1)}else mn(1);if(h>g){if(c)mn(0);break}}if(a)l(d+131072);var Y=(1<<_)-1,K=(1<<p)-1,ge=h;for(;;ge=h){var G=f[wu(e,h)&Y],de=G>>4;if(h+=G&15,h>g){if(c)mn(0);break}if(!G)mn(2);if(de<256)n[d++]=de;else if(de==256){ge=h,f=null;break}else{var fe=de-254;if(de>264){var C=de-257,he=ic[C];fe=$n(e,h,(1<<he)-1)+a0[C],h+=he}var I=m[wu(e,h)&K],V=I>>4;if(!I)mn(3);h+=I&15;var B=Uw[V];if(V>3){var he=rc[V];B+=wu(e,h)&(1<<he)-1,h+=he}if(h>g){if(c)mn(0);break}if(a)l(d+131072);var q=d+fe;if(d<B){var se=s-B,ce=Math.min(B,q);if(se+d<0)mn(3);for(;d<ce;++d)n[d]=i[se+d]}for(;d<q;++d)n[d]=n[d-B]}}if(t.l=f,t.p=ge,t.b=d,t.f=u,f)u=1,t.m=_,t.d=m,t.n=p}while(!u);return d!=n.length&&o?yo(n,0,d):n.subarray(0,d)},Oi=function(e,t,n){n<<=t&7;var i=t/8|0;e[i]|=n,e[i+1]|=n>>8},_o=function(e,t,n){n<<=t&7;var i=t/8|0;e[i]|=n,e[i+1]|=n>>8,e[i+2]|=n>>16},Mu=function(e,t){var n=[];for(var i=0;i<e.length;++i)if(e[i])n.push({s:i,f:e[i]});var r=n.length,s=n.slice();if(!r)return{t:u0,l:0};if(r==1){var o=new Dt(n[0].s+1);return o[n[0].s]=1,{t:o,l:1}}n.sort(function(S,E){return S.f-E.f}),n.push({s:-1,f:25001});var a=n[0],c=n[1],l=0,u=1,h=2;n[0]={s:-1,f:a.f+c.f,l:a,r:c};while(u!=r-1)a=n[n[l].f<n[h].f?l++:h++],c=n[l!=u&&n[l].f<n[h].f?l++:h++],n[u++]={s:-1,f:a.f+c.f,l:a,r:c};var d=s[0].s;for(var i=1;i<r;++i)if(s[i].s>d)d=s[i].s;var f=new En(d+1),m=Cu(n[u-1],f,0);if(m>t){var i=0,_=0,p=m-t,g=1<<p;s.sort(function(E,R){return f[R.s]-f[E.s]||E.f-R.f});for(;i<r;++i){var M=s[i].s;if(f[M]>t)_+=g-(1<<m-f[M]),f[M]=t;else break}_>>=p;while(_>0){var T=s[i].s;if(f[T]<t)_-=1<<t-f[T]++-1;else++i}for(;i>=0&&_;--i){var v=s[i].s;if(f[v]==t)--f[v],++_}m=t}return{t:new Dt(f),l:m}},Cu=function(e,t,n){return e.s==-1?Math.max(Cu(e.l,t,n+1),Cu(e.r,t,n+1)):t[e.s]=n},e0=function(e){var t=e.length;while(t&&!e[--t]);var n=new En(++t),i=0,r=e[0],s=1,o=function(c){n[i++]=c};for(var a=1;a<=t;++a)if(e[a]==r&&a!=t)++s;else{if(!r&&s>2){for(;s>138;s-=138)o(32754);if(s>2)o(s>10?s-11<<5|28690:s-3<<5|12305),s=0}else if(s>3){o(r),--s;for(;s>6;s-=6)o(8304);if(s>2)o(s-3<<5|8208),s=0}while(s--)o(r);s=1,r=e[a]}return{c:n.subarray(0,i),n:t}},xo=function(e,t){var n=0;for(var i=0;i<t.length;++i)n+=e[i]*t[i];return n},l0=function(e,t,n){var i=n.length,r=Nu(t+2);e[r]=i&255,e[r+1]=i>>8,e[r+2]=e[r]^255,e[r+3]=e[r+1]^255;for(var s=0;s<i;++s)e[r+s+4]=n[s];return(r+4+i)*8},t0=function(e,t,n,i,r,s,o,a,c,l,u){Oi(t,u++,n),++r[256];var h=Mu(r,15),{t:d,l:f}=h,m=Mu(s,15),{t:_,l:p}=m,g=e0(d),{c:M,n:T}=g,v=e0(_),{c:S,n:E}=v,R=new En(19);for(var x=0;x<M.length;++x)++R[M[x]&31];for(var x=0;x<S.length;++x)++R[S[x]&31];var w=Mu(R,7),{t:H,l:C}=w,N=19;for(;N>4&&!H[Tu[N-1]];--N);var ee=l+5<<3,P=xo(r,tr)+xo(s,vo)+o,Z=xo(r,d)+xo(s,_)+o+14+3*N+xo(R,H)+2*R[16]+3*R[17]+7*R[18];if(c>=0&&ee<=P&&ee<=Z)return l0(t,u,e.subarray(c,c+l));var G,k,W,B;if(Oi(t,u,1+(Z<P)),u+=2,Z<P){G=pi(d,f,0),k=d,W=pi(_,p,0),B=_;var Y=pi(H,C,0);Oi(t,u,T-257),Oi(t,u+5,E-1),Oi(t,u+10,N-4),u+=14;for(var x=0;x<N;++x)Oi(t,u+3*x,H[Tu[x]]);u+=3*N;var K=[M,S];for(var ge=0;ge<2;++ge){var de=K[ge];for(var x=0;x<de.length;++x){var fe=de[x]&31;if(Oi(t,u,Y[fe]),u+=H[fe],fe>15)Oi(t,u,de[x]>>5&127),u+=de[x]>>12}}}else G=Fw,k=tr,W=kw,B=vo;for(var x=0;x<a;++x){var he=i[x];if(he>255){var fe=he>>18&31;if(_o(t,u,G[fe+257]),u+=k[fe+257],fe>7)Oi(t,u,he>>23&31),u+=ic[fe];var I=he&31;if(_o(t,u,W[I]),u+=B[I],I>3)_o(t,u,he>>5&8191),u+=rc[I]}else _o(t,u,G[he]),u+=k[he]}return _o(t,u,G[256]),u+k[256]},Vw=new Lu([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),u0=new Dt(0),$w=function(e,t,n,i,r,s){var o=s.z||e.length,a=new Dt(i+o+5*(1+Math.ceil(o/7000))+r),c=a.subarray(i,a.length-r),l=s.l,u=(s.r||0)&7;if(t){if(u)c[0]=s.r>>3;var h=Vw[t-1],d=h>>13,f=h&8191,m=(1<<n)-1,_=s.p||new En(32768),p=s.h||new En(m+1),g=Math.ceil(n/3),M=2*g,T=function(Ve){return(e[Ve]^e[Ve+1]<<g^e[Ve+2]<<M)&m},v=new Lu(25000),S=new En(288),E=new En(32),R=0,x=0,w=s.i||0,H=0,C=s.w||0,N=0;for(;w+2<o;++w){var ee=T(w),P=w&32767,Z=p[ee];if(_[P]=Z,p[ee]=P,C<=w){var G=o-w;if((R>7000||H>24576)&&(G>423||!l)){u=t0(e,c,0,v,S,E,x,H,N,w-N,u),H=R=x=0,N=w;for(var k=0;k<286;++k)S[k]=0;for(var k=0;k<30;++k)E[k]=0}var W=2,B=0,Y=f,K=P-Z&32767;if(G>2&&ee==T(w-K)){var ge=Math.min(d,G)-1,de=Math.min(32767,w),fe=Math.min(258,G);while(K<=de&&--Y&&P!=Z){if(e[w+W]==e[w+W-K]){var he=0;for(;he<fe&&e[w+he]==e[w+he-K];++he);if(he>W){if(W=he,B=K,he>ge)break;var I=Math.min(K,he-2),V=0;for(var k=0;k<I;++k){var q=w-K+k&32767,se=_[q],ce=q-se&32767;if(ce>V)V=ce,Z=q}}}P=Z,Z=_[P],K+=P-Z&32767}}if(B){v[H++]=268435456|Au[W]<<18|Q_[B];var ae=Au[W]&31,ke=Q_[B]&31;x+=ic[ae]+rc[ke],++S[257+ae],++E[ke],C=w+W,++R}else v[H++]=e[w],++S[e[w]]}}for(w=Math.max(w,C);w<o;++w)v[H++]=e[w],++S[e[w]];if(u=t0(e,c,l,v,S,E,x,H,N,w-N,u),!l)s.r=u&7|c[u/8|0]<<3,u-=7,s.h=p,s.p=_,s.i=w,s.w=C}else{for(var w=s.w||0;w<o+l;w+=65535){var Ce=w+65535;if(Ce>=o)c[u/8|0]=l,Ce=o;u=l0(c,u+1,e.subarray(w,Ce))}s.i=o}return yo(a,0,i+Nu(u)+r)},Ww=function(){var e=new Int32Array(256);for(var t=0;t<256;++t){var n=t,i=9;while(--i)n=(n&1&&-306674912)^n>>>1;e[t]=n}return e}(),Zw=function(){var e=-1;return{p:function(t){var n=e;for(var i=0;i<t.length;++i)n=Ww[n&255^t[i]]^n>>>8;e=n},d:function(){return~e}}};var Xw=function(e,t,n,i,r){if(!r){if(r={l:1},t.dictionary){var s=t.dictionary.subarray(-32768),o=new Dt(s.length+e.length);o.set(s),o.set(e,s.length),e=o,r.w=s.length}}return $w(e,t.level==null?6:t.level,t.mem==null?r.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,n,i,r)},h0=function(e,t){var n={};for(var i in e)n[i]=e[i];for(var i in t)n[i]=t[i];return n};var fi=function(e,t){return e[t]|e[t+1]<<8},Wn=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},Eu=function(e,t){return Wn(e,t)+Wn(e,t+4)*4294967296},rn=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function jw(e,t){return Xw(e,t||{},0,0)}function qw(e,t){return Hw(e,{i:2},t&&t.out,t&&t.dictionary)}var d0=function(e,t,n,i){for(var r in e){var s=e[r],o=t+r,a=i;if(Array.isArray(s))a=h0(i,s[1]),s=s[0];if(s instanceof Dt)n[o]=[s,a];else n[o+="/"]=[new Dt(0),a],d0(s,o,n,i)}},n0=typeof TextEncoder<"u"&&new TextEncoder,Iu=typeof TextDecoder<"u"&&new TextDecoder,Yw=0;try{Iu.decode(u0,{stream:!0}),Yw=1}catch(e){}var Kw=function(e){for(var t="",n=0;;){var i=e[n++],r=(i>127)+(i>223)+(i>239);if(n+r>e.length)return{s:t,r:yo(e,n-1)};if(!r)t+=String.fromCharCode(i);else if(r==3)i=((i&15)<<18|(e[n++]&63)<<12|(e[n++]&63)<<6|e[n++]&63)-65536,t+=String.fromCharCode(55296|i>>10,56320|i&1023);else if(r&1)t+=String.fromCharCode((i&31)<<6|e[n++]&63);else t+=String.fromCharCode((i&15)<<12|(e[n++]&63)<<6|e[n++]&63)}};function i0(e,t){if(t){var n=new Dt(e.length);for(var i=0;i<e.length;++i)n[i]=e.charCodeAt(i);return n}if(n0)return n0.encode(e);var r=e.length,s=new Dt(e.length+(e.length>>1)),o=0,a=function(u){s[o++]=u};for(var i=0;i<r;++i){if(o+5>s.length){var c=new Dt(o+8+(r-i<<1));c.set(s),s=c}var l=e.charCodeAt(i);if(l<128||t)a(l);else if(l<2048)a(192|l>>6),a(128|l&63);else if(l>55295&&l<57344)l=65536+(l&1047552)|e.charCodeAt(++i)&1023,a(240|l>>18),a(128|l>>12&63),a(128|l>>6&63),a(128|l&63);else a(224|l>>12),a(128|l>>6&63),a(128|l&63)}return yo(s,0,o)}function Jw(e,t){if(t){var n="";for(var i=0;i<e.length;i+=16384)n+=String.fromCharCode.apply(null,e.subarray(i,i+16384));return n}else if(Iu)return Iu.decode(e);else{var r=Kw(e),{s,r:n}=r;if(n.length)mn(8);return s}}var Qw=function(e,t){return t+30+fi(e,t+26)+fi(e,t+28)},eM=function(e,t,n){var i=fi(e,t+28),r=Jw(e.subarray(t+46,t+46+i),!(fi(e,t+8)&2048)),s=t+46+i,o=Wn(e,t+20),a=n&&o==4294967295?tM(e,s):[o,Wn(e,t+24),Wn(e,t+42)],c=a[0],l=a[1],u=a[2];return[fi(e,t+10),c,l,r,s+fi(e,t+30)+fi(e,t+32),u]},tM=function(e,t){for(;fi(e,t)!=1;t+=4+fi(e,t+2));return[Eu(e,t+12),Eu(e,t+4),Eu(e,t+20)]},Pu=function(e){var t=0;if(e)for(var n in e){var i=e[n].length;if(i>65535)mn(9);t+=i+4}return t},r0=function(e,t,n,i,r,s,o,a){var c=i.length,l=n.extra,u=a&&a.length,h=Pu(l);if(rn(e,t,o!=null?33639248:67324752),t+=4,o!=null)e[t++]=20,e[t++]=n.os;e[t]=20,t+=2,e[t++]=n.flag<<1|(s<0&&8),e[t++]=r&&8,e[t++]=n.compression&255,e[t++]=n.compression>>8;var d=new Date(n.mtime==null?Date.now():n.mtime),f=d.getFullYear()-1980;if(f<0||f>119)mn(10);if(rn(e,t,f<<25|d.getMonth()+1<<21|d.getDate()<<16|d.getHours()<<11|d.getMinutes()<<5|d.getSeconds()>>1),t+=4,s!=-1)rn(e,t,n.crc),rn(e,t+4,s<0?-s-2:s),rn(e,t+8,n.size);if(rn(e,t+12,c),rn(e,t+14,h),t+=16,o!=null)rn(e,t,u),rn(e,t+6,n.attrs),rn(e,t+10,o),t+=14;if(e.set(i,t),t+=c,h)for(var m in l){var _=l[m],p=_.length;rn(e,t,+m),rn(e,t+2,p),e.set(_,t+4),t+=4+p}if(u)e.set(a,t),t+=u;return t},nM=function(e,t,n,i,r){rn(e,t,101010256),rn(e,t+8,n),rn(e,t+10,n),rn(e,t+12,i),rn(e,t+16,r)};function f0(e,t){if(!t)t={};var n={},i=[];d0(e,"",n,t);var r=0,s=0;for(var o in n){var a=n[o],c=a[0],l=a[1],u=l.level==0?0:8,h=i0(o),d=h.length,f=l.comment,m=f&&i0(f),_=m&&m.length,p=Pu(l.extra);if(d>65535)mn(11);var g=u?jw(c,l):c,M=g.length,T=Zw();T.p(c),i.push(h0(l,{size:c.length,crc:T.d(),c:g,f:h,m,u:d!=o.length||m&&f.length!=_,o:r,compression:u})),r+=30+d+p+M,s+=76+2*(d+p)+(_||0)+M}var v=new Dt(s+22),S=r,E=s-r;for(var R=0;R<i.length;++R){var h=i[R];r0(v,h.o,h,h.f,h.u,h.c.length);var x=30+h.f.length+Pu(h.extra);v.set(h.c,h.o+x),r0(v,r,h,h.f,h.u,h.c.length,h.o,h.m),r+=16+x+(h.m?h.m.length:0)}return nM(v,r,i.length,E,S),v}function p0(e,t){var n={},i=e.length-22;for(;Wn(e,i)!=101010256;--i)if(!i||e.length-i>65558)mn(13);var r=fi(e,i+8);if(!r)return{};var s=Wn(e,i+16),o=s==4294967295||r==65535;if(o){var a=Wn(e,i-12);if(o=Wn(e,a)==101075792,o)r=Wn(e,a+32),s=Wn(e,a+48)}var c=t&&t.filter;for(var l=0;l<r;++l){var u=eM(e,s,o),h=u[0],d=u[1],f=u[2],m=u[3],_=u[4],p=u[5],g=Qw(e,p);if(s=_,!c||c({name:m,size:d,originalSize:f,compression:h}))if(!h)n[m]=yo(e,g,g+d);else if(h==8)n[m]=qw(e.subarray(g,g+d),{out:new Dt(f)});else mn(14,"unknown compression type "+h)}return n}var Du=["albedo","emissive","normal","roughness","metalness","metallicRoughness","occlusion"];function iM(e){if(e==="UNINITIALIZED_BINDING")return"A const, let or class binding was read before its declaration ran (temporal dead zone). Move the declaration above the first code that reads it; top-level constants must be declared before other top-level code uses them. kiln_validate names the binding and line when the read runs immediately.";if(e==="LOD_SET")return'Levels of detail: sibling nodes whose names share a stem and carry LOD0, LOD1, ... tokens (Body_LOD0, Body_LOD1) form one set. A set needs LOD0 and consecutive levels under one parent, outside any other tier, and one defineLod([lod0, lod1, ...], { screenCoverage: [...] }) call listing its tiers in level order with one value per level, each from 0 to 1 and strictly decreasing; the last may be 0, which never culls. Build one tier without LOD tokens unless the brief asks for levels. Call kiln_discover with ids ["defineLod"].';if(e==="OPEN_SHELL")return'markOpenShell(part, reason) marks a part as intentionally open: part is the mesh createPart returned or a group whose meshes it covers, and reason is a non-empty string of at most 200 characters saying why, for example markOpenShell(rail, "C-channel closed by the end plates"). The engine owns the kilnOpenShell userData key; set it only through markOpenShell. Call kiln_discover with ids ["markOpenShell"].';if(e==="BUILD_RESULT")return'Define a top-level function build() (it may be async) that returns the root Object3D, for example const root = createRoot("Name"); ...; return root;. A build() that returns nothing, or returns a geometry or material, is rejected.';if(e==="MATERIAL_RECIPE_OVERRIDE")return'materialRecipe takes a listed kiln.material.*.v1 ID and only the overrides that recipe allows; the allowed overrides differ by recipe (the emissive recipe has no metalness). Call kiln_discover with ids ["materialRecipe"] to see what each recipe allows; kiln_validate names the recipe and key when both are literals.';if(e==="PROGRAM_TYPE_ERROR")return"The program or a helper it called threw a TypeError: a value had the wrong type. Usually something is undefined (a function without a return, an un-awaited async helper such as roundedBoxGeo, extrudeProfile or materialRecipe, or a misspelt property) or a non-function was called. Run kiln_validate, then check the helper contract with kiln_discover.";if(e==="PROGRAM_RANGE_ERROR")return"The program or a helper it called threw a RangeError: a number was outside its allowed range, for example a non-positive size, an invalid array length or segment count, or unbounded recursion. Check the helper arguments against kiln_discover.";if(e==="MESH_DATA_NONFINITE")return"meshGeo positions, normals, UVs and tangents must contain finite numbers representable in Float32. Check missing XYZ components, undefined values, division by zero and overflowing calculations before constructing the arrays. Do not replace invalid values blindly with zero; correct the source calculation. Call kiln_discover for the exact meshGeo data contract.";if(e==="PORTABLE_COLOR_ARGUMENT")return"compilePortableMaterialSpecV2 baseColor and emissive must be numeric color integers from 0x000000 to 0xffffff, for example baseColor: 0x8a867c. CSS strings and materialRecipe hex-string overrides use different contracts. Omit these fields for their defaults, or call kiln_discover for the exact helper contract.";if(e==="MATERIAL_RECIPE_TEXTURE_BINDING")return"materialRecipe textureResources maps portable slots to approved resource ID strings. Slots are baseColor, normal, metallicRoughness, emissive and occlusion. albedo is a pbrMaterial field, not a recipe slot. Use kiln_discover to check each resource allowedSlots and recipeIds before binding it; no slot or resource substitution is applied.";if(e==="PORTABLE_TEXTURE_REFERENCE")return'compilePortableMaterialSpecV2 textures require typed references: { kind: "resource", resourceId: "kiln.texture..." } for an approved resource, or { kind: "procedural", spec: { schemaVersion: 2, ... } } for a procedural texture. Bare resource ID strings are invalid here. Use portable slots such as baseColor and check the exact helper/resource contracts with kiln_discover.';if(e==="TAPER_CONE_AXIS")return'taperConeGeo(radiusBottom, radiusTop, height, axis, segments): the fourth argument is axis, "x", "y" or "z" (default "y"). Segment count is the fifth argument, for example taperConeGeo(0.03, 0.02, 0.01, "x", 12). Call kiln_discover for the full contract.';if(e==="PROCEDURAL_TEXTURE_BLEND")return'proceduralTexture layer blend must be normal, multiply, screen, or overlay. Omit blend for normal compositing. Call kiln_discover with ids ["proceduralTexture"] for the supported layer fields.';if(e==="PART_NAME_ARGUMENT")return"createPart(name, geometry, material, options?): the first argument is a string name. Put the parent Object3D in the fourth argument as { parent: root }.";if(e==="PART_GEOMETRY_ARGUMENT")return"createPart(name, geometry, material, options?): the second argument must be a BufferGeometry. Call geometry helpers, for example boxGeo(1, 1, 1), instead of passing the function. For async helpers such as roundedBoxGeo, extrudeProfile and revolveProfile, await the result inside async build() before passing it to createPart. Call kiln_discover for the exact return contract.";if(e==="PART_MATERIAL_ARGUMENT")return"createPart(name, geometry, material, options?): the third argument must be a Three.js material. Wrap a color with gameMaterial(0x808080); a number or settings object alone is not a material. Call kiln_discover for the chosen material helper contract.";if(e==="SOLID_FLOAT32_COLLAPSE")return"Solid output cannot retain valid faces at Float32 precision. Simplify subprecision features or recenter local geometry; review coincident cut boundaries. Smoothing or replacing normals does not repair collapsed triangles. Kiln did not export a partially repaired solid.";if(e==="PROFILE_BEVEL_COLLAPSE")return"extrudeProfile or revolveProfile: bevel is too large for this profile; erosion leaves nothing. Reduce bevel below half the narrowest section width, set bevel to 0, or widen the profile. Dimensions and bevel use the same asset units.";if(e==="TUBE_RADIUS")return"curveToMesh and pipeAlongPath require an explicit positive finite radius representable in Float32, in asset units. A missing or undefined radius is invalid; check the referenced dimension. Radius is half the tube diameter.";if(e==="MATERIAL_ALPHA_MODE")return'pbrMaterial and portable material specs require lowercase alphaMode: "opaque", "mask", or "blend". Omit it for opaque. Exported glTF uses uppercase mode names; those are not authoring input values.';if(e==="MATERIAL_COLOR_ARGUMENT")return"gameMaterial, basicMaterial, glassMaterial and lambertMaterial take a color first: a hex number or CSS string. Settings belong in the second argument, for example gameMaterial(0x9a9a96, { roughness: 0.4, metalness: 0.8 }). pbrMaterial uses a different object-form contract; call kiln_discover for its texture and material fields.";if(e==="MATERIAL_PACKED_CHANNELS")return'pbrMaterial requires one packed texture with G=roughness and B=metalness. Generate or load it for usage "metallicRoughness" and pass metallicRoughness, or pass the same packed texture in both roughness and metalness. Do not combine those forms or pass a texture in only one scalar slot. Plain roughness and metalness values are 0..1 numbers. Call kiln_discover for the exact texture contract.';if(e==="REMOVED_HELPER")return"Generated source references a retired Kiln global. Call kiln_validate for name-specific migration guidance, then kiln_discover for the replacement contract. No compatibility aliases are provided.";if(e==="UNBOUND_VARIABLE")return"Check variable spelling and scope: generated code used an undeclared variable. Read the current source and check declarations before retrying. If it was meant to be a Kiln helper, call kiln_discover to confirm the exact name and signature; the sandbox exposes only those globals.";if(e==="ROUNDED_BOX_RADIUS")return"roundedBoxGeo: radius must be less than half the smallest dimension. Reduce radius or increase the smallest dimension; equality is invalid.";if(e==="GEAR_RADII_ORDER")return"gearGeo requires boreRadius < rootRadius < tipRadius; specify rootRadius when changing tipRadius. Omitted radii keep their absolute defaults.";if(e==="PROCEDURAL_TEXTURE_UNKNOWN_KEY")return'Remove unsupported proceduralTexture fields. Call kiln_discover with ids ["proceduralTexture"] and use only the documented fields for the selected layer op.';if(e==="MATERIAL_FRACTION_RANGE")return"Material fractions must be finite numbers between 0 and 1, inclusive. In proceduralTexture, mortarWidth and stagger are fractions, not pixels; opacity uses the same range. materialRecipe roughness, metalness, opacity, alphaCutoff and emissiveIntensity use 0..1. portableMaterial roughness, metalness and alphaCutoff also use 0..1; its emissiveIntensity has a separate 0..64 range. Call kiln_discover for the exact field contracts.";if(e==="PROFILE_HOLES_UNSUPPORTED")return"loftProfiles and sweepProfile: holes are unsupported in options or sections. Use extrudeProfile for a holed cross-section with optional twist/taper; independently varying contours need explicit geometry or solid subtraction. cap:false does not create inner walls or thickness.";if(e==="PROFILE_CORRESPONDENCE_COLLAPSE")return"loftProfiles or sweepProfile: corresponding profile edges collapse between stations. Check matching start vertices and vertex order; for an intended twist, add intermediate sections or path stations. No automatic correspondence repair is applied. Other self-intersections remain unchecked.";return e==="PARAMETRIC_PERIODIC_ENDPOINT"?"Periodic parametricSurface endpoints must return matching positions. For periodicU, sample(uMin, v) and sample(uMax, v) must match; for periodicV, sample(u, vMin) and sample(u, vMax) must match.":""}class Ou extends Error{diagnostic;constructor(e,t=iM(e)){super(t);this.diagnostic=e;this.name="AuthoringDiagnosticError"}}var m0=1024,g0=4,_0=8,rM=6,x0=80,bo=256;class At extends Ou{constructor(e,t){super(t,e);this.name="ProceduralTextureError"}}var v0=["solid","checker","stripes","gradient","bricks","noise"],y0=["normal","multiply","screen","overlay"],sM=new Set(["__proto__","prototype","constructor"]);function sc(e,t){if(!e||typeof e!=="object"||Array.isArray(e))throw new At(`${t} must be a plain JSON object.`);let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)throw new At(`${t} must be a plain JSON object with no custom prototype.`);for(let i of Reflect.ownKeys(e)){if(typeof i!=="string")throw new At(`${t} must not contain symbol keys.`);if(sM.has(i))throw new At(`${t} contains forbidden key ${JSON.stringify(i)}.`);if(!Object.prototype.propertyIsEnumerable.call(e,i))throw new At(`${t}.${i} must be an enumerable JSON field.`);let r=Object.getOwnPropertyDescriptor(e,i);if(!r||!("value"in r))throw new At(`${t}.${i} must be a plain JSON data field.`)}return e}function oM(e,t){if(!Array.isArray(e)||Object.getPrototypeOf(e)!==Array.prototype)throw new At(`${t} must be a plain JSON array.`);for(let n of Reflect.ownKeys(e)){if(typeof n!=="string")throw new At(`${t} must not contain symbol keys.`);if(n==="length")continue;if(!/^(0|[1-9][0-9]*)$/.test(n)||Number(n)>=e.length)throw new At(`${t} has non-index JSON array key ${JSON.stringify(n)}.`)}for(let n=0;n<e.length;n++)if(!Object.hasOwn(e,n))throw new At(`${t} must be a dense JSON array (missing index ${n}).`);return e}function nr(e,t,n){let i=new Set(t);for(let r of Object.keys(e))if(!i.has(r))throw new At(`${n} has unknown key ${JSON.stringify(r)}.`,"PROCEDURAL_TEXTURE_UNKNOWN_KEY")}function Zn(e,t,n){if(typeof e!=="number"||!Number.isInteger(e)||e<0||e>16777215)throw new At(`${t} must be a color integer between 0x000000 and 0xffffff, got ${JSON.stringify(e)}.`,n);return e}function Fr(e,t,n,i,r){if(e===void 0)return n;if(typeof e!=="number"||!Number.isInteger(e)||e<i||e>r)throw new At(`${t} must be a whole number between ${i} and ${r}, got ${JSON.stringify(e)}.`);return e}function S0(e,t,n,i,r,s){if(e===void 0)return n;if(typeof e!=="number"||!Number.isFinite(e)||e<i||e>r)throw new At(`${t} must be a finite number between ${i} and ${r}, got ${JSON.stringify(e)}.`,s);return e}function Uu(e,t,n){return S0(e,t,n,0,1,"MATERIAL_FRACTION_RANGE")}function aM(e,t){if(e===void 0)return;let n=typeof e==="string"&&[...e].some((i)=>{let r=i.charCodeAt(0);return r<32||r===127});if(typeof e!=="string"||e.length===0||e.length>x0||n)throw new At(`${t} must be 1..${x0} visible characters.`);return e}function cM(e,t,n){if(e===void 0)return n;if(!Du.includes(e))throw new At(`${t} must be one of ${Du.join(", ")}, got ${JSON.stringify(e)}.`);return e}function b0(e,t){let i=(S0(e,t,0,-36000,36000)%360+360)%360;return Object.is(i,-0)?0:i}function lM(e,t){let n=e.blend??"normal";if(!y0.includes(n))throw new At(`${t}.blend ${JSON.stringify(n)} is not one of ${y0.join(", ")}.`,"PROCEDURAL_TEXTURE_BLEND");return n}function uM(e,t){let n=`proceduralTexture.layers[${t}]`,i=sc(e,n),r=i.op;if(!v0.includes(r))throw new At(`${n}.op ${JSON.stringify(r)} is not one of ${v0.join(", ")}.`);let s=lM(i,n),o=Uu(i.opacity,`${n}.opacity`,1),a={blend:t===0?"normal":s,opacity:t===0?1:o};switch(r){case"solid":return nr(i,["op","color","blend","opacity"],n),{op:r,color:Zn(i.color,`${n}.color`),...a};case"checker":return nr(i,["op","colorA","colorB","squares","blend","opacity"],n),{op:r,colorA:Zn(i.colorA,`${n}.colorA`),colorB:Zn(i.colorB,`${n}.colorB`),squares:Fr(i.squares,`${n}.squares`,8,1,bo),...a};case"stripes":return nr(i,["op","colorA","colorB","count","angleDeg","blend","opacity"],n),{op:r,colorA:Zn(i.colorA,`${n}.colorA`),colorB:Zn(i.colorB,`${n}.colorB`),count:Fr(i.count,`${n}.count`,8,1,bo),angleDeg:b0(i.angleDeg,`${n}.angleDeg`),...a};case"gradient":return nr(i,["op","from","to","angleDeg","blend","opacity"],n),{op:r,from:Zn(i.from,`${n}.from`),to:Zn(i.to,`${n}.to`),angleDeg:b0(i.angleDeg,`${n}.angleDeg`),...a};case"bricks":return nr(i,["op","brick","mortar","rows","cols","mortarWidth","stagger","blend","opacity"],n),{op:r,brick:Zn(i.brick,`${n}.brick`),mortar:Zn(i.mortar,`${n}.mortar`),rows:Fr(i.rows,`${n}.rows`,8,1,bo),cols:Fr(i.cols,`${n}.cols`,4,1,bo),mortarWidth:Uu(i.mortarWidth,`${n}.mortarWidth`,0.06),stagger:Uu(i.stagger,`${n}.stagger`,0.5),...a};case"noise":return nr(i,["op","colorA","colorB","scale","octaves","seed","blend","opacity"],n),{op:r,colorA:Zn(i.colorA,`${n}.colorA`),colorB:Zn(i.colorB,`${n}.colorB`),scale:Fr(i.scale,`${n}.scale`,8,1,bo),octaves:Fr(i.octaves,`${n}.octaves`,3,1,rM),seed:Fr(i.seed,`${n}.seed`,0,-2147483648,2147483647),...a};default:throw new At(`${n}.op is unsupported.`)}}function hM(e){let t=sc(e,"proceduralTexture");if(nr(t,["schemaVersion","size","usage","name","layers"],"proceduralTexture"),t.schemaVersion!==void 0&&t.schemaVersion!==1)throw new At(`proceduralTexture.schemaVersion must be 1 or absent for V1 migration, got ${JSON.stringify(t.schemaVersion)}.`);return{schemaVersion:2,...t.size!==void 0?{size:t.size}:{},...t.usage!==void 0?{usage:t.usage}:{},...t.name!==void 0?{name:t.name}:{},layers:t.layers}}function w0(e){let t=sc(e,"proceduralTexture"),n=t.schemaVersion===void 0||t.schemaVersion===1?sc(hM(t),"proceduralTexture"):t;if(nr(n,["schemaVersion","size","usage","name","layers"],"proceduralTexture"),n.schemaVersion!==2)throw new At(`proceduralTexture.schemaVersion must be 2, got ${JSON.stringify(n.schemaVersion)}.`);let i=n.size??256;if(typeof i!=="number"||!Number.isInteger(i)||i<g0||i>m0||(i&i-1)!==0)throw new At(`proceduralTexture.size must be a power of two between ${g0} and ${m0}, got ${JSON.stringify(n.size)}.`);let r=n.layers;if(!Array.isArray(r)||r.length===0)throw new At("proceduralTexture.layers must be a non-empty array — the bottom layer is the base pattern.");let s=oM(r,"proceduralTexture.layers");if(s.length>_0)throw new At(`proceduralTexture: ${s.length} layers exceeds the maximum of ${_0}.`);let o=aM(n.name,"proceduralTexture.name");return{schemaVersion:2,size:i,usage:cM(n.usage,"proceduralTexture.usage","albedo"),...o!==void 0?{name:o}:{},layers:s.map(uM)}}var wL=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);var jn=Object.freeze({maxMapBytes:8388608,maxRecordBytes:33554432,maxManifestBytes:262144,maxMapEdge:4096,maxRecordPixels:8388608,maxPayloadBytes:16777216,maxPayloadPixels:16777216,maxPayloadRecords:16}),E0=["baseColor","normal","metallicRoughness","emissive","occlusion"],dM={baseColor:"albedo",normal:"normal",metallicRoughness:"metallicRoughness",emissive:"emissive",occlusion:"occlusion"};var wo=Fe().regex(/^[a-z][a-z0-9_-]{0,79}$/),Mo=Fe().regex(/^sha256:[a-f0-9]{64}$/),ir=Fe().min(1).max(1000),M0=Fe().max(2000).url().refine((e)=>/^https?:\/\//.test(e),"Provenance URL must be HTTP(S)"),T0=qe({id:wo,kind:pn(["external","procedural"]),provider:ir,creator:ir,assetId:ir.optional(),assetUrl:M0.optional(),accessedAt:Fe().datetime().optional(),license:qe({spdx:ir,url:M0,attribution:Fe().max(4000)}).strict(),originalFiles:wt(qe({name:Fe().min(1).max(200),sha256:Mo,bytes:vt().int().positive().max(1073741824)}).strict()).max(20)}).strict().superRefine((e,t)=>{if(e.kind==="external"&&(!e.assetUrl||!e.originalFiles.length))t.addIssue({code:"custom",message:"External materials require a source URL and original file hashes"});if(new Set(e.originalFiles.map((n)=>n.name)).size!==e.originalFiles.length)t.addIssue({code:"custom",message:"Duplicate original filename"})}),A0=qe({operation:ir,tool:ir,version:ir,parameters:tc(Fe().max(100),Z_([Fe().max(2000),vt().finite(),go()])).optional()}).strict(),Xn=vt().int().min(0).max(16777215),So=vt().int().min(1).max(256),us={blend:pn(["normal","multiply","screen","overlay"]).default("normal"),opacity:vt().min(0).max(1).default(1)},R0=qe({schemaVersion:jt(2),size:vt().int().min(4).max(1024).default(256),usage:pn(["albedo","normal","roughness","metalness","metallicRoughness","emissive","occlusion"]).default("albedo"),name:Fe().min(1).max(80).optional(),layers:wt(mw("op",[qe({op:jt("solid"),color:Xn,...us}).strict(),qe({op:jt("checker"),colorA:Xn,colorB:Xn,squares:So.default(8),...us}).strict(),qe({op:jt("stripes"),colorA:Xn,colorB:Xn,count:So.default(8),angleDeg:vt().min(-36000).max(36000).default(0),...us}).strict(),qe({op:jt("gradient"),from:Xn,to:Xn,angleDeg:vt().min(-36000).max(36000).default(0),...us}).strict(),qe({op:jt("bricks"),brick:Xn,mortar:Xn,rows:So.default(8),cols:So.default(4),mortarWidth:vt().min(0).max(1).default(0.06),stagger:vt().min(0).max(1).default(0.5),...us}).strict(),qe({op:jt("noise"),colorA:Xn,colorB:Xn,scale:So.default(8),octaves:vt().int().min(1).max(6).default(3),seed:vt().int().min(-2147483648).max(2147483647).default(0),...us}).strict()])).min(1).max(8)}).strict(),C0=qe({kind:jt("normal-from-height"),strength:vt().finite().positive().max(64)}).strict(),fM=qe({compiler:jt("kiln.procedural-texture.v2"),spec:R0,derive:C0.optional(),recipeHash:Mo,pixelHash:Mo,encoder:qe({name:jt("sharp"),version:ir}).strict()}).strict(),I0=qe({baseColor:vt().int().min(0).max(16777215).optional(),roughness:vt().min(0).max(1).default(1),metalness:vt().min(0).max(1).default(0),emissive:vt().int().min(0).max(16777215).optional(),emissiveIntensity:vt().min(0).max(64).default(1),alphaMode:pn(["opaque","mask","blend"]).default("opaque"),alphaCutoff:vt().min(0).max(1).default(0.5),doubleSided:go().default(!1)}).strict(),P0=qe({schemaVersion:jt(1),materialId:wo,revisionId:Mo,name:Fe().min(1).max(200),tags:wt(Fe().min(1).max(80)).max(30),tileable:go(),physicalSizeMeters:qe({width:vt().finite().positive().max(1e5),height:vt().finite().positive().max(1e5)}).strict().optional(),parameters:I0,sources:wt(T0).min(1).max(20),maps:wt(qe({slot:pn(E0),file:pn(["baseColor.png","normal.png","metallicRoughness.png","emissive.png","occlusion.png"]),sha256:Mo,bytes:vt().int().positive().max(jn.maxMapBytes),width:vt().int().positive().max(jn.maxMapEdge),height:vt().int().positive().max(jn.maxMapEdge),usage:pn(["albedo","normal","metallicRoughness","emissive","occlusion"]),colorSpace:pn(["srgb","linear"]),normalConvention:jt("opengl").optional(),channelPacking:jt("r-occlusion-g-roughness-b-metallic").optional(),sourceId:wo,originalFile:Fe().min(1).max(200).optional(),transforms:wt(A0).max(30),procedural:fM.optional()}).strict()).min(1).max(5)}).strict(),AL=qe({materialId:wo,name:Fe().min(1).max(200),tags:wt(Fe().min(1).max(80)).max(30).optional(),tileable:go(),physicalSizeMeters:qe({width:vt().finite().positive().max(1e5),height:vt().finite().positive().max(1e5)}).strict().optional(),parameters:I0.partial().optional(),sources:wt(T0).min(1).max(20),maps:wt(qe({slot:pn(E0),sourceId:wo,transforms:wt(A0).max(30),normalConvention:jt("opengl").optional(),channelPacking:jt("r-occlusion-g-roughness-b-metallic").optional(),procedural:R0,derive:C0.optional()}).strict()).min(1).max(5)}).strict(),L0=qe({schemaVersion:jt(1),records:wt(qe({manifest:P0,files:tc(Fe().regex(/^(baseColor|normal|metallicRoughness|emissive|occlusion)\.png$/),Fe().max(Math.ceil(jn.maxMapBytes/3)*4))}).strict()).max(jn.maxPayloadRecords)}).strict();function To(e,t=!1,n=0){if(n>30)throw Error("Material JSON exceeds nesting limit");if(e===null||typeof e==="string"||typeof e==="boolean")return;if(typeof e==="number"&&Number.isFinite(e))return;if(t&&e instanceof Uint8Array)return;if(!e||typeof e!=="object")throw Error("Material values must be plain JSON data");let i=Array.isArray(e),r=Object.getPrototypeOf(e);if(i?r!==Array.prototype:r!==Object.prototype&&r!==null)throw Error("Material values must have plain JSON prototypes");if(i&&e.length>1e4)throw Error("Material JSON array exceeds limit");for(let s of Reflect.ownKeys(e)){if(i&&s==="length")continue;if(typeof s!=="string"||["__proto__","prototype","constructor"].includes(s))throw Error("Material JSON contains a forbidden key");if(i&&(!/^(0|[1-9][0-9]*)$/.test(s)||Number(s)>=e.length))throw Error("Material arrays must contain only indexed data");let o=Object.getOwnPropertyDescriptor(e,s);if(!("value"in o)||!o.enumerable)throw Error("Material JSON accessors or hidden fields are not allowed");To(o.value,t,n+1)}if(i&&Object.keys(e).length!==e.length)throw Error("Material JSON arrays must be dense")}function Eo(e){To(e);let t=(n)=>Array.isArray(n)?n.map(t):n!==null&&typeof n==="object"?Object.fromEntries(Object.entries(n).sort(([i],[r])=>i<r?-1:i>r?1:0).map(([i,r])=>[i,t(r)])):n;return JSON.stringify(t(e))}function N0(e){if(To(e),new TextEncoder().encode(JSON.stringify(e)).length>jn.maxManifestBytes)throw Error("Material manifest exceeds size limit");let t=P0.parse(e);if(new Set(t.sources.map((r)=>r.id)).size!==t.sources.length)throw Error("Duplicate material source identity");if(new Set(t.maps.map((r)=>r.slot)).size!==t.maps.length)throw Error("Duplicate material map slot");let n=0,i=0;for(let r of t.maps){let s=r.slot==="baseColor"||r.slot==="emissive";if(r.file!==`${r.slot}.png`||r.usage!==dM[r.slot]||r.colorSpace!==(s?"srgb":"linear"))throw Error("Material map filename, usage or color convention mismatch");if(r.slot==="normal"!==(r.normalConvention==="opengl")||r.slot==="metallicRoughness"!==(r.channelPacking==="r-occlusion-g-roughness-b-metallic"))throw Error("Material map convention is missing or invalid");let o=t.sources.find((a)=>a.id===r.sourceId);if(!o)throw Error("Material map source is missing");if(r.procedural){if(r.procedural.derive&&r.slot!=="normal")throw Error("Height derivation requires a normal map slot");if(Eo(r.procedural.spec)!==Eo(w0(r.procedural.spec)))throw Error("Stored procedural material recipe must be canonical");if(o.kind!=="procedural"||r.originalFile||r.procedural.spec.usage!==r.usage||r.procedural.spec.size!==r.width||r.width!==r.height)throw Error("Procedural material source or map convention mismatch")}else if(o.kind!=="external"||!o.originalFiles.some((a)=>a.name===r.originalFile))throw Error("Material map must reference an original source file");n+=r.bytes,i+=r.width*r.height}if(n>jn.maxRecordBytes||i>jn.maxRecordPixels)throw Error("Material record exceeds byte or pixel budget");return t}var Un=67108864,Fu=Fe().regex(/^[a-z][a-z0-9_-]{0,79}$/),pM=Fe().regex(/^sha256:[a-f0-9]{64}$/),D0=qe({version:jt("kiln.asset.v1"),assetId:Fu,revisionId:Fu,parentRevision:Fu.optional(),name:Fe().min(1).max(200),tags:wt(Fe().max(80)).max(30),createdAt:Fe().datetime(),description:Fe().max(4000).optional(),brief:Fe().max(8000).optional(),attribution:qe({model:Fe().max(200).optional(),harness:Fe().max(200).optional(),author:Fe().max(200).optional()}).optional(),editable:go(),files:tc(Fe(),qe({sha256:pM,bytes:vt().int().nonnegative().max(Un)})),build:qe({engine:Fe(),options:tc(Fe(),Ur()),warnings:wt(Fe()),integration:Ur().optional(),qa:Ur().optional(),dependencies:wt(Ur()).optional(),rebuild:pn(["engine-required","external-dependencies-required"])}).optional(),preview:qe({fidelity:Ur().optional(),error:Fe().optional(),backdrop:pn(K_).optional()}).optional()}),Ao="materials.kiln.json",O0=25165824;function U0(e,t=!1){let n=(e.manifest.build?.dependencies??[]).filter((c)=>c&&typeof c==="object"&&c.kind==="kiln.material.v1"),i=new Map(n.map((c)=>{if(c.delivery!=="runtime")throw Error("Invalid saved material dependency");let l=N0(c.manifest);return[`${l.materialId}/${l.revisionId}`,Eo(l)]}));if(!e.materialResources){if(t&&i.size)throw Error("Editable asset material closure unavailable");return}To(e.materialResources);let r=L0.parse(e.materialResources),s=0,o=0,a=new Set;for(let c of r.records){let l=`${c.manifest.materialId}/${c.manifest.revisionId}`;if(a.has(l)||i.get(l)!==Eo(c.manifest))throw Error("Asset material closure mismatch");if(a.add(l),Object.keys(c.files).length!==c.manifest.maps.length)throw Error("Asset material map inventory mismatch");for(let u of c.manifest.maps){if(c.files[u.file]?.length!==Math.ceil(u.bytes/3)*4)throw Error("Asset material map size mismatch");s+=u.bytes,o+=u.width*u.height}}if(a.size!==i.size)throw Error("Asset material closure incomplete");if(s>jn.maxPayloadBytes||o>jn.maxPayloadPixels)throw Error("Asset material closure exceeds allocation limits")}var mM=new Set(["asset.glb","source.kiln.js","preview.png"]);function oc(e){let t=D0.parse(e.manifest),n=Object.keys(e.files);if(n.length!==Object.keys(t.files).length||!n.includes("asset.glb"))throw Error("Asset file inventory mismatch");let i=0;for(let r of n){if(!mM.has(r)||!t.files[r]||t.files[r].bytes!==e.files[r].length)throw Error("Invalid asset file inventory");i+=e.files[r].length}if(i>Un||t.editable!==n.includes("source.kiln.js"))throw Error("Invalid asset size or source inventory");if((e.files["source.kiln.js"]?.length??0)>1048576)throw Error("Source exceeds 1 MiB");zu(e.files["asset.glb"]),U0(e)}function zu(e){if(e.length<20||e.length>Un)throw Error("Invalid GLB size");let t=new DataView(e.buffer,e.byteOffset,e.byteLength);if(t.getUint32(0,!0)!==1179937895||t.getUint32(4,!0)!==2||t.getUint32(8,!0)!==e.length||t.getUint32(16,!0)!==1313821514)throw Error("Invalid GLB header");let n=20+t.getUint32(12,!0);if(n>e.length)throw Error("Invalid GLB JSON length");let i=JSON.parse(new TextDecoder().decode(e.subarray(20,n)));for(let r of[...i.buffers??[],...i.images??[]])if(r.uri&&!String(r.uri).startsWith("data:"))throw Error("GLB must embed its resources")}function ku(e){if(!e.length||e.length>100)throw Error("Bundle requires 1..100 revisions");let t={},n=0;for(let i of e){oc(i),U0(i,!0);let r=`${i.manifest.assetId}/${i.manifest.revisionId}/`;if(t[`${r}manifest.json`])throw Error("Duplicate bundle revision");t[`${r}manifest.json`]=new TextEncoder().encode(JSON.stringify(i.manifest,null,2));for(let[s,o]of Object.entries(i.files))t[r+s]=o;if(i.materialResources){let s=new TextEncoder().encode(JSON.stringify(i.materialResources));if(s.length>O0)throw Error("Asset material payload exceeds byte limit");t[r+Ao]=s}}for(let i of Object.values(t))n+=i.length;if(n>Un)throw Error("Bundle exceeds 64 MiB");return f0(t,{level:0})}function F0(e){if(e.length>Un+1048576)throw Error("Bundle exceeds 64 MiB");let t=0,n=0,i=p0(e,{filter:(o)=>{if(t+=o.originalSize,n++,t>Un||n>500||o.name.endsWith(`/${Ao}`)&&o.originalSize>O0||!/^[a-z][a-z0-9_-]{0,79}\/[a-z][a-z0-9_-]{0,79}\/(manifest\.json|asset\.glb|source\.kiln\.js|preview\.png|materials\.kiln\.json)$/.test(o.name))throw Error("Unsafe or oversized asset bundle");return!0}}),r=[],s=new Set;for(let[o,a]of Object.entries(i)){if(!o.endsWith("/manifest.json"))continue;if(a.length>1048576)throw Error("Manifest exceeds 1 MiB");let c=D0.parse(JSON.parse(new TextDecoder().decode(a))),l=`${c.assetId}/${c.revisionId}/`;if(o!==`${l}manifest.json`)throw Error("Bundle identity mismatch");let u={manifest:c,files:{}};s.add(o);for(let h of Object.keys(c.files)){if(!i[l+h])throw Error("Bundle file missing");u.files[h]=i[l+h],s.add(l+h)}if(i[l+Ao])u.materialResources=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(i[l+Ao])),s.add(l+Ao);oc(u),r.push(u)}if(!r.length||s.size!==Object.keys(i).length)throw Error("Incomplete asset bundle");return r}function z0(e){let t=e.attribution;if(!t)return[];return[t.model?{label:"Model",value:t.model}:null,t.harness?{label:"Harness",value:t.harness}:null,t.author?{label:"Author",value:t.author}:null].filter((n)=>n!==null)}var Sx="186",hr={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},dr={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},wx=0,hh=1,Mx=2;var ko=1,Ex=2,Cs=3,fr=0,cn=1,Bn=2,vi=0,Bo=1,dh=2,fh=3,ph=4,Tx=5;var Is=100,Ax=101,Rx=102,Cx=103,Ix=104,Px=200,Lx=201,Nx=202,Dx=203,Ox=204,Ux=205,Fx=206,zx=207,kx=208,Bx=209,Gx=210,Hx=211,Vx=212,$x=213,Wx=214,Zx=0,Xx=1,jx=2,mh=3,qx=4,Yx=5,Kx=6,Jx=7,Qx=0,ev=1,tv=2,ei=0,gh=1,_h=2,xh=3,Go=4,vh=5,yh=6,bh=7;var Ps=301,$r=302,Oc=303,Uc=304,Ho=306,Ls=1000,Ns=1001,Fc=1002,ti=1003,zc=1004;var Wr=1005;var Jt=1006,Ds=1007;var yi=1008;var ni=1009,nv=1010,iv=1011,Vo=1012,Sh=1013,pr=1014,Vi=1015,bi=1016,wh=1017,Mh=1018,Os=1020,rv=35902,sv=35899,ov=1021,av=1022,Si=1023,Zr=1026,Xr=1027,cv=1028,Eh=1029,jr=1030,Th=1031;var Ah=1033,kc=33776,Bc=33777,Gc=33778,Hc=33779,Rh=35840,Ch=35841,Ih=35842,Ph=35843,Lh=36196,Nh=37492,Dh=37496,Oh=37488,Uh=37489,Vc=37490,Fh=37491,zh=37808,kh=37809,Bh=37810,Gh=37811,Hh=37812,Vh=37813,$h=37814,Wh=37815,Zh=37816,Xh=37817,jh=37818,qh=37819,Yh=37820,Kh=37821,Jh=36492,Qh=36494,ed=36495,td=36283,nd=36284,$c=36285,id=36286;var rd=2300,Wc=2301;var sd=0,$o=1,Us=2;var od=0,lv=1,qr="",mr="srgb",Rn="srgb-linear",ad="linear",yt="srgb";var uv=512,hv=513,dv=514,Zc=515,fv=516,pv=517,Xc=518,mv=519;var cd="300 es",ld=2000;function gM(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function _M(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Ts(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function gv(){let e=Ts("canvas");return e.style.display="block",e}var k0={},As=null;function zo(...e){let t="THREE."+e.shift();if(As)As("log",t,...e);else console.log(t,...e)}function _v(e){let t=e[0];if(typeof t==="string"&&t.startsWith("TSL:")){let n=e[1];if(n&&n.isStackTrace)e[0]+=" "+n.getLocation();else e[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return e}function Ue(...e){e=_v(e);let t="THREE."+e.shift();if(As)As("warn",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.warn(n.getError(t));else console.warn(t,...e)}}function $e(...e){e=_v(e);let t="THREE."+e.shift();if(As)As("error",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.error(n.getError(t));else console.error(t,...e)}}function Hr(...e){let t=e.join(" ");if(t in k0)return;k0[t]=!0,Ue(...e)}function xv(e,t,n){return new Promise(function(i,r){function s(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:r();break;case e.TIMEOUT_EXPIRED:setTimeout(s,n);break;default:i()}}setTimeout(s,n)})}var vv={[0]:1,[2]:6,[4]:7,[3]:5,[1]:0,[6]:2,[7]:4,[5]:3};class ii{addEventListener(e,t){if(this._listeners===void 0)this._listeners={};let n=this._listeners;if(n[e]===void 0)n[e]=[];if(n[e].indexOf(t)===-1)n[e].push(t)}hasEventListener(e,t){let n=this._listeners;if(n===void 0)return!1;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let i=n[e];if(i!==void 0){let r=i.indexOf(t);if(r!==-1)i.splice(r,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let i=n.slice(0);for(let r=0,s=i.length;r<s;r++)i[r].call(this,e);e.target=null}}}var on=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],B0=1234567,Uo=Math.PI/180,Vr=180/Math.PI;function Qn(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(on[e&255]+on[e>>8&255]+on[e>>16&255]+on[e>>24&255]+"-"+on[t&255]+on[t>>8&255]+"-"+on[t>>16&15|64]+on[t>>24&255]+"-"+on[n&63|128]+on[n>>8&255]+"-"+on[n>>16&255]+on[n>>24&255]+on[i&255]+on[i>>8&255]+on[i>>16&255]+on[i>>24&255]).toLowerCase()}function Je(e,t,n){return Math.max(t,Math.min(n,e))}function ud(e,t){return(e%t+t)%t}function xM(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)}function vM(e,t,n){if(e!==t)return(n-e)/(t-e);else return 0}function Fo(e,t,n){return(1-n)*e+n*t}function yM(e,t,n,i){return Fo(e,t,1-Math.exp(-n*i))}function bM(e,t=1){return t-Math.abs(ud(e,t*2)-t)}function SM(e,t,n){if(e<=t)return 0;if(e>=n)return 1;return e=(e-t)/(n-t),e*e*(3-2*e)}function wM(e,t,n){if(e<=t)return 0;if(e>=n)return 1;return e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10)}function MM(e,t){return e+Math.floor(Math.random()*(t-e+1))}function EM(e,t){return e+Math.random()*(t-e)}function TM(e){return e*(0.5-Math.random())}function AM(e){if(e!==void 0)B0=e;let t=B0+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function RM(e){return e*Uo}function CM(e){return e*Vr}function IM(e){return e>0&&Number.isInteger(e)&&2**Math.round(Math.log2(e))===e}function PM(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function LM(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function NM(e,t,n,i,r){let{cos:s,sin:o}=Math,a=s(n/2),c=o(n/2),l=s((t+i)/2),u=o((t+i)/2),h=s((t-i)/2),d=o((t-i)/2),f=s((i-t)/2),m=o((i-t)/2);switch(r){case"XYX":e.set(a*u,c*h,c*d,a*l);break;case"YZY":e.set(c*d,a*u,c*h,a*l);break;case"ZXZ":e.set(c*h,c*d,a*u,a*l);break;case"XZX":e.set(a*u,c*m,c*f,a*l);break;case"YXY":e.set(c*f,a*u,c*m,a*l);break;case"ZYZ":e.set(c*m,c*f,a*u,a*l);break;default:Ue("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function Jn(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:case Uint8ClampedArray:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error("THREE.MathUtils: Invalid component type.")}}function ft(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:case Uint8ClampedArray:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error("THREE.MathUtils: Invalid component type.")}}var Wo={DEG2RAD:Uo,RAD2DEG:Vr,generateUUID:Qn,clamp:Je,euclideanModulo:ud,mapLinear:xM,inverseLerp:vM,lerp:Fo,damp:yM,pingpong:bM,smoothstep:SM,smootherstep:wM,randInt:MM,randFloat:EM,randFloatSpread:TM,seededRandom:AM,degToRad:RM,radToDeg:CM,isPowerOfTwo:IM,ceilPowerOfTwo:PM,floorPowerOfTwo:LM,setQuaternionFromProperEuler:NM,normalize:ft,denormalize:Jn};class Be{static{Be.prototype.isVector2=!0}constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Je(this.x,e.x,t.x),this.y=Je(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Je(this.x,e,t),this.y=Je(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Je(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(Je(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,s=this.y-e.y;return this.x=r*n-s*i+e.x,this.y=r*i+s*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Yt{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,r,s,o){let a=n[i+0],c=n[i+1],l=n[i+2],u=n[i+3],h=r[s+0],d=r[s+1],f=r[s+2],m=r[s+3];if(u!==m||a!==h||c!==d||l!==f){let _=a*h+c*d+l*f+u*m;if(_<0)h=-h,d=-d,f=-f,m=-m,_=-_;let p=1-o;if(_<0.9995){let g=Math.acos(_),M=Math.sin(g);p=Math.sin(p*g)/M,o=Math.sin(o*g)/M,a=a*p+h*o,c=c*p+d*o,l=l*p+f*o,u=u*p+m*o}else{a=a*p+h*o,c=c*p+d*o,l=l*p+f*o,u=u*p+m*o;let g=1/Math.sqrt(a*a+c*c+l*l+u*u);a*=g,c*=g,l*=g,u*=g}}e[t]=a,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,i,r,s){let o=n[i],a=n[i+1],c=n[i+2],l=n[i+3],u=r[s],h=r[s+1],d=r[s+2],f=r[s+3];return e[t]=o*f+l*u+a*d-c*h,e[t+1]=a*f+l*h+c*u-o*d,e[t+2]=c*f+l*d+o*h-a*u,e[t+3]=l*f-o*u-a*h-c*d,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let{_x:n,_y:i,_z:r,_order:s}=e,{cos:o,sin:a}=Math,c=o(n/2),l=o(i/2),u=o(r/2),h=a(n/2),d=a(i/2),f=a(r/2);switch(s){case"XYZ":this._x=h*l*u+c*d*f,this._y=c*d*u-h*l*f,this._z=c*l*f+h*d*u,this._w=c*l*u-h*d*f;break;case"YXZ":this._x=h*l*u+c*d*f,this._y=c*d*u-h*l*f,this._z=c*l*f-h*d*u,this._w=c*l*u+h*d*f;break;case"ZXY":this._x=h*l*u-c*d*f,this._y=c*d*u+h*l*f,this._z=c*l*f+h*d*u,this._w=c*l*u-h*d*f;break;case"ZYX":this._x=h*l*u-c*d*f,this._y=c*d*u+h*l*f,this._z=c*l*f-h*d*u,this._w=c*l*u+h*d*f;break;case"YZX":this._x=h*l*u+c*d*f,this._y=c*d*u+h*l*f,this._z=c*l*f-h*d*u,this._w=c*l*u-h*d*f;break;case"XZY":this._x=h*l*u-c*d*f,this._y=c*d*u-h*l*f,this._z=c*l*f+h*d*u,this._w=c*l*u+h*d*f;break;default:Ue("Quaternion: .setFromEuler() encountered an unknown order: "+s)}if(t===!0)this._onChangeCallback();return this}setFromAxisAngle(e,t){let n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],i=t[4],r=t[8],s=t[1],o=t[5],a=t[9],c=t[2],l=t[6],u=t[10],h=n+o+u;if(h>0){let d=0.5/Math.sqrt(h+1);this._w=0.25/d,this._x=(l-a)*d,this._y=(r-c)*d,this._z=(s-i)*d}else if(n>o&&n>u){let d=2*Math.sqrt(1+n-o-u);this._w=(l-a)/d,this._x=0.25*d,this._y=(i+s)/d,this._z=(r+c)/d}else if(o>u){let d=2*Math.sqrt(1+o-n-u);this._w=(r-c)/d,this._x=(i+s)/d,this._y=0.25*d,this._z=(a+l)/d}else{let d=2*Math.sqrt(1+u-n-o);this._w=(s-i)/d,this._x=(r+c)/d,this._y=(a+l)/d,this._z=0.25*d}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;if(n<0.00000001)if(n=0,Math.abs(e.x)>Math.abs(e.z))this._x=-e.y,this._y=e.x,this._z=0,this._w=n;else this._x=0,this._y=-e.z,this._z=e.y,this._w=n;else this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n;return this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Je(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();if(e===0)this._x=0,this._y=0,this._z=0,this._w=1;else e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e;return this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let{_x:n,_y:i,_z:r,_w:s}=e,{_x:o,_y:a,_z:c,_w:l}=t;return this._x=n*l+s*o+i*c-r*a,this._y=i*l+s*a+r*o-n*c,this._z=r*l+s*c+n*a-i*o,this._w=s*l-n*o-i*a-r*c,this._onChangeCallback(),this}slerp(e,t){let{_x:n,_y:i,_z:r,_w:s}=e,o=this.dot(e);if(o<0)n=-n,i=-i,r=-r,s=-s,o=-o;let a=1-t;if(o<0.9995){let c=Math.acos(o),l=Math.sin(c);a=Math.sin(a*c)/l,t=Math.sin(t*c)/l,this._x=this._x*a+n*t,this._y=this._y*a+i*t,this._z=this._z*a+r*t,this._w=this._w*a+s*t,this._onChangeCallback()}else this._x=this._x*a+n*t,this._y=this._y*a+i*t,this._z=this._z*a+r*t,this._w=this._w*a+s*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class F{static{F.prototype.isVector3=!0}constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){if(n===void 0)n=this.z;return this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(G0.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(G0.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,r=e.elements,s=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*s,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*s,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*s,this}applyQuaternion(e){let t=this.x,n=this.y,i=this.z,{x:r,y:s,z:o,w:a}=e,c=2*(s*i-o*n),l=2*(o*t-r*i),u=2*(r*n-s*t);return this.x=t+a*c+s*u-o*l,this.y=n+a*l+o*c-r*u,this.z=i+a*u+r*l-s*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Je(this.x,e.x,t.x),this.y=Je(this.y,e.y,t.y),this.z=Je(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Je(this.x,e,t),this.y=Je(this.y,e,t),this.z=Je(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Je(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let{x:n,y:i,z:r}=e,{x:s,y:o,z:a}=t;return this.x=i*a-r*o,this.y=r*s-n*a,this.z=n*o-i*s,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Bu.copy(this).projectOnVector(e),this.sub(Bu)}reflect(e){return this.sub(Bu.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(Je(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}var Bu=new F,G0=new Yt;class We{static{We.prototype.isMatrix3=!0}constructor(e,t,n,i,r,s,o,a,c){if(this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0)this.set(e,t,n,i,r,s,o,a,c)}set(e,t,n,i,r,s,o,a,c){let l=this.elements;return l[0]=e,l[1]=i,l[2]=o,l[3]=t,l[4]=r,l[5]=a,l[6]=n,l[7]=s,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,s=n[0],o=n[3],a=n[6],c=n[1],l=n[4],u=n[7],h=n[2],d=n[5],f=n[8],m=i[0],_=i[3],p=i[6],g=i[1],M=i[4],T=i[7],v=i[2],S=i[5],E=i[8];return r[0]=s*m+o*g+a*v,r[3]=s*_+o*M+a*S,r[6]=s*p+o*T+a*E,r[1]=c*m+l*g+u*v,r[4]=c*_+l*M+u*S,r[7]=c*p+l*T+u*E,r[2]=h*m+d*g+f*v,r[5]=h*_+d*M+f*S,r[8]=h*p+d*T+f*E,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8];return t*s*l-t*o*c-n*r*l+n*o*a+i*r*c-i*s*a}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=l*s-o*c,h=o*a-l*r,d=c*r-s*a,f=t*u+n*h+i*d;if(f===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/f;return e[0]=u*m,e[1]=(i*c-l*n)*m,e[2]=(o*n-i*s)*m,e[3]=h*m,e[4]=(l*t-i*a)*m,e[5]=(i*r-o*t)*m,e[6]=d*m,e[7]=(n*a-c*t)*m,e[8]=(s*t-n*r)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,r,s,o){let a=Math.cos(r),c=Math.sin(r);return this.set(n*a,n*c,-n*(a*s+c*o)+s+e,-i*c,i*a,-i*(-c*s+a*o)+o+t,0,0,1),this}scale(e,t){return Hr("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Gu.makeScale(e,t)),this}rotate(e){return Hr("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Gu.makeRotation(-e)),this}translate(e,t){return Hr("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Gu.makeTranslation(e,t)),this}makeTranslation(e,t){if(e.isVector2)this.set(1,0,e.x,0,1,e.y,0,0,1);else this.set(1,0,e,0,1,t,0,0,1);return this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}var Gu=new We,H0=new We().set(0.4123908,0.3575843,0.1804808,0.212639,0.7151687,0.0721923,0.0193308,0.1191948,0.9505322),V0=new We().set(3.2409699,-1.5373832,-0.4986108,-0.9692436,1.8759675,0.0415551,0.0556301,-0.203977,1.0569715);function DM(){let e={enabled:!0,workingColorSpace:"srgb-linear",spaces:{},convert:function(r,s,o){if(this.enabled===!1||s===o||!s||!o)return r;if(this.spaces[s].transfer==="srgb")r.r=Hi(r.r),r.g=Hi(r.g),r.b=Hi(r.b);if(this.spaces[s].primaries!==this.spaces[o].primaries)r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[o].fromXYZ);if(this.spaces[o].transfer==="srgb")r.r=Es(r.r),r.g=Es(r.g),r.b=Es(r.b);return r},workingToColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},colorSpaceToWorking:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){if(r==="")return"linear";return this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,o){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,s){return Hr("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),e.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return Hr("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),e.colorSpaceToWorking(r,s)}},t=[0.64,0.33,0.3,0.6,0.15,0.06],n=[0.2126,0.7152,0.0722],i=[0.3127,0.329];return e.define({["srgb-linear"]:{primaries:t,whitePoint:i,transfer:"linear",toXYZ:H0,fromXYZ:V0,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:"srgb"},outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}},["srgb"]:{primaries:t,whitePoint:i,transfer:"srgb",toXYZ:H0,fromXYZ:V0,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}}}),e}var Ke=DM();function Hi(e){return e<0.04045?e*0.0773993808:Math.pow(e*0.9478672986+0.0521327014,2.4)}function Es(e){return e<0.0031308?e*12.92:1.055*Math.pow(e,0.41666)-0.055}var hs;class hd{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src))return e.src;if(typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{if(hs===void 0)hs=Ts("canvas");hs.width=e.width,hs.height=e.height;let i=hs.getContext("2d");if(e instanceof ImageData)i.putImageData(e,0,0);else i.drawImage(e,0,0,e.width,e.height);n=hs}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=Ts("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let s=0;s<r.length;s++)r[s]=Hi(r[s]/255)*255;return n.putImageData(i,0,0),t}else if(e.data){let t=e.data.slice(0);for(let n=0;n<t.length;n++)if(t instanceof Uint8Array||t instanceof Uint8ClampedArray)t[n]=Math.floor(Hi(t[n]/255)*255);else t[n]=Hi(t[n]);return{data:t,width:e.width,height:e.height}}else return Ue("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}var OM=0;class Zo{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:OM++}),this.uuid=Qn(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;if(typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement)e.set(t.videoWidth,t.videoHeight,0);else if(typeof VideoFrame<"u"&&t instanceof VideoFrame)e.set(t.displayWidth,t.displayHeight,0);else if(t!==null)e.set(t.width,t.height,t.depth||0);else e.set(0,0,0);return e}set needsUpdate(e){if(e===!0)this.version++}toJSON(e){let t=e===void 0||typeof e==="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let r;if(Array.isArray(i)){r=[];for(let s=0,o=i.length;s<o;s++)if(i[s].isDataTexture)r.push(Hu(i[s].image));else r.push(Hu(i[s]))}else r=Hu(i);n.url=r}if(!t)e.images[this.uuid]=n;return n}}function Hu(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap)return hd.getDataURL(e);else if(e.data)return{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name};else return Ue("Texture: Unable to serialize Texture."),{}}var UM=0,Vu=new F;class Ot extends ii{constructor(e=Ot.DEFAULT_IMAGE,t=Ot.DEFAULT_MAPPING,n=1001,i=1001,r=1006,s=1008,o=1023,a=1009,c=Ot.DEFAULT_ANISOTROPY,l=""){super();this.isTexture=!0,Object.defineProperty(this,"id",{value:UM++}),this.uuid=Qn(),this.name="",this.source=new Zo(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=s,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=a,this.offset=new Be(0,0),this.repeat=new Be(1,1),this.center=new Be(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new We,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=l,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=e&&e.depth&&e.depth>1?!0:!1,this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(Vu).x}get height(){return this.source.getSize(Vu).y}get depth(){return this.source.getSize(Vu).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){Ue(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){Ue(`Texture.setValues(): property '${t}' does not exist.`);continue}if(i&&n&&(i.isVector2&&n.isVector2))i.copy(n);else if(i&&n&&(i.isVector3&&n.isVector3))i.copy(n);else if(i&&n&&(i.isMatrix3&&n.isMatrix3))i.copy(n);else this[t]=n}}toJSON(e){let t=e===void 0||typeof e==="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(Object.keys(this.userData).length>0)n.userData=this.userData;if(!t)e.textures[this.uuid]=n;return n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case 1000:e.x=e.x-Math.floor(e.x);break;case 1001:e.x=e.x<0?0:1;break;case 1002:if(Math.abs(Math.floor(e.x)%2)===1)e.x=Math.ceil(e.x)-e.x;else e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case 1000:e.y=e.y-Math.floor(e.y);break;case 1001:e.y=e.y<0?0:1;break;case 1002:if(Math.abs(Math.floor(e.y)%2)===1)e.y=Math.ceil(e.y)-e.y;else e.y=e.y-Math.floor(e.y);break}if(this.flipY)e.y=1-e.y;return e}set needsUpdate(e){if(e===!0)this.version++,this.source.needsUpdate=!0}set needsPMREMUpdate(e){if(e===!0)this.pmremVersion++}}Ot.DEFAULT_IMAGE=null;Ot.DEFAULT_MAPPING=300;Ot.DEFAULT_ANISOTROPY=1;class pt{static{pt.prototype.isVector4=!0}constructor(e=0,t=0,n=0,i=1){this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,r=this.w,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i+s[12]*r,this.y=s[1]*t+s[5]*n+s[9]*i+s[13]*r,this.z=s[2]*t+s[6]*n+s[10]*i+s[14]*r,this.w=s[3]*t+s[7]*n+s[11]*i+s[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);if(t<0.0001)this.x=1,this.y=0,this.z=0;else this.x=e.x/t,this.y=e.y/t,this.z=e.z/t;return this}setAxisAngleFromRotationMatrix(e){let t,n,i,r,s=0.01,o=0.1,a=e.elements,c=a[0],l=a[4],u=a[8],h=a[1],d=a[5],f=a[9],m=a[2],_=a[6],p=a[10];if(Math.abs(l-h)<0.01&&Math.abs(u-m)<0.01&&Math.abs(f-_)<0.01){if(Math.abs(l+h)<0.1&&Math.abs(u+m)<0.1&&Math.abs(f+_)<0.1&&Math.abs(c+d+p-3)<0.1)return this.set(1,0,0,0),this;t=Math.PI;let M=(c+1)/2,T=(d+1)/2,v=(p+1)/2,S=(l+h)/4,E=(u+m)/4,R=(f+_)/4;if(M>T&&M>v)if(M<0.01)n=0,i=0.707106781,r=0.707106781;else n=Math.sqrt(M),i=S/n,r=E/n;else if(T>v)if(T<0.01)n=0.707106781,i=0,r=0.707106781;else i=Math.sqrt(T),n=S/i,r=R/i;else if(v<0.01)n=0.707106781,i=0.707106781,r=0;else r=Math.sqrt(v),n=E/r,i=R/r;return this.set(n,i,r,t),this}let g=Math.sqrt((_-f)*(_-f)+(u-m)*(u-m)+(h-l)*(h-l));if(Math.abs(g)<0.001)g=1;return this.x=(_-f)/g,this.y=(u-m)/g,this.z=(h-l)/g,this.w=Math.acos((c+d+p-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Je(this.x,e.x,t.x),this.y=Je(this.y,e.y,t.y),this.z=Je(this.z,e.z,t.z),this.w=Je(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Je(this.x,e,t),this.y=Je(this.y,e,t),this.z=Je(this.z,e,t),this.w=Je(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Je(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class dd extends ii{constructor(e=1,t=1,n={}){super();n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:1006,depthBuffer:!0,stencilBuffer:!1,resolveColorBuffer:!0,resolveDepthBuffer:!0,resolveStencilBuffer:!0,storeMultisampledColorBuffer:!0,storeMultisampledDepthBuffer:!0,storeMultisampledStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new pt(0,0,e,t),this.scissorTest=!1,this.viewport=new pt(0,0,e,t),this.textures=[];let i={width:e,height:t,depth:n.depth},r=new Ot(i),s=n.count;for(let o=0;o<s;o++)this.textures[o]=r.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveColorBuffer=n.resolveColorBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.storeMultisampledColorBuffer=n.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=n.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=n.storeMultisampledStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(e={}){let t={minFilter:1006,generateMipmaps:!1,flipY:!1,internalFormat:null};if(e.mapping!==void 0)t.mapping=e.mapping;if(e.wrapS!==void 0)t.wrapS=e.wrapS;if(e.wrapT!==void 0)t.wrapT=e.wrapT;if(e.wrapR!==void 0)t.wrapR=e.wrapR;if(e.magFilter!==void 0)t.magFilter=e.magFilter;if(e.minFilter!==void 0)t.minFilter=e.minFilter;if(e.format!==void 0)t.format=e.format;if(e.type!==void 0)t.type=e.type;if(e.anisotropy!==void 0)t.anisotropy=e.anisotropy;if(e.colorSpace!==void 0)t.colorSpace=e.colorSpace;if(e.flipY!==void 0)t.flipY=e.flipY;if(e.generateMipmaps!==void 0)t.generateMipmaps=e.generateMipmaps;if(e.internalFormat!==void 0)t.internalFormat=e.internalFormat;for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){if(this._depthTexture!==null&&this._depthTexture.renderTarget===this)this._depthTexture.renderTarget=null;if(e!==null&&e.renderTarget===null)e.renderTarget=this;this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let i=0,r=this.textures.length;i<r;i++)if(this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=n,this.textures[i].isData3DTexture!==!0)this.textures[i].isArrayTexture=this.textures[i].image.depth>1;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let i=Object.assign({},e.textures[t].image);this.textures[t].source=new Zo(i)}if(this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveColorBuffer=e.resolveColorBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,this.storeMultisampledColorBuffer=e.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=e.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=e.storeMultisampledStencilBuffer,e.depthTexture!==null)if(e.depthTexture.renderTarget===e){let t=e.depthTexture.clone();t.renderTarget=null,this.depthTexture=t}else this.depthTexture=e.depthTexture;return this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Cn extends dd{constructor(e=1,t=1,n={}){super(e,t,n);this.isWebGLRenderTarget=!0}}class jc extends Ot{constructor(e=null,t=1,n=1,i=1){super(null);this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class fd extends Ot{constructor(e=null,t=1,n=1,i=1){super(null);this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}}class Xe{static{Xe.prototype.isMatrix4=!0}constructor(e,t,n,i,r,s,o,a,c,l,u,h,d,f,m,_){if(this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0)this.set(e,t,n,i,r,s,o,a,c,l,u,h,d,f,m,_)}set(e,t,n,i,r,s,o,a,c,l,u,h,d,f,m,_){let p=this.elements;return p[0]=e,p[4]=t,p[8]=n,p[12]=i,p[1]=r,p[5]=s,p[9]=o,p[13]=a,p[2]=c,p[6]=l,p[10]=u,p[14]=h,p[3]=d,p[7]=f,p[11]=m,p[15]=_,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Xe().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){if(this.determinantAffine()===0)return e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this;return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();let t=this.elements,n=e.elements,i=1/ds.setFromMatrixColumn(e,0).length(),r=1/ds.setFromMatrixColumn(e,1).length(),s=1/ds.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*s,t[9]=n[9]*s,t[10]=n[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,{x:n,y:i,z:r}=e,s=Math.cos(n),o=Math.sin(n),a=Math.cos(i),c=Math.sin(i),l=Math.cos(r),u=Math.sin(r);if(e.order==="XYZ"){let h=s*l,d=s*u,f=o*l,m=o*u;t[0]=a*l,t[4]=-a*u,t[8]=c,t[1]=d+f*c,t[5]=h-m*c,t[9]=-o*a,t[2]=m-h*c,t[6]=f+d*c,t[10]=s*a}else if(e.order==="YXZ"){let h=a*l,d=a*u,f=c*l,m=c*u;t[0]=h+m*o,t[4]=f*o-d,t[8]=s*c,t[1]=s*u,t[5]=s*l,t[9]=-o,t[2]=d*o-f,t[6]=m+h*o,t[10]=s*a}else if(e.order==="ZXY"){let h=a*l,d=a*u,f=c*l,m=c*u;t[0]=h-m*o,t[4]=-s*u,t[8]=f+d*o,t[1]=d+f*o,t[5]=s*l,t[9]=m-h*o,t[2]=-s*c,t[6]=o,t[10]=s*a}else if(e.order==="ZYX"){let h=s*l,d=s*u,f=o*l,m=o*u;t[0]=a*l,t[4]=f*c-d,t[8]=h*c+m,t[1]=a*u,t[5]=m*c+h,t[9]=d*c-f,t[2]=-c,t[6]=o*a,t[10]=s*a}else if(e.order==="YZX"){let h=s*a,d=s*c,f=o*a,m=o*c;t[0]=a*l,t[4]=m-h*u,t[8]=f*u+d,t[1]=u,t[5]=s*l,t[9]=-o*l,t[2]=-c*l,t[6]=d*u+f,t[10]=h-m*u}else if(e.order==="XZY"){let h=s*a,d=s*c,f=o*a,m=o*c;t[0]=a*l,t[4]=-u,t[8]=c*l,t[1]=h*u+m,t[5]=s*l,t[9]=d*u-f,t[2]=f*u-d,t[6]=o*l,t[10]=m*u+h}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(FM,e,zM)}lookAt(e,t,n){let i=this.elements;if(Tn.subVectors(e,t),Tn.lengthSq()===0)Tn.z=1;if(Tn.normalize(),rr.crossVectors(n,Tn),rr.lengthSq()===0){if(Math.abs(n.z)===1)Tn.x+=0.0001;else Tn.z+=0.0001;Tn.normalize(),rr.crossVectors(n,Tn)}return rr.normalize(),ac.crossVectors(Tn,rr),i[0]=rr.x,i[4]=ac.x,i[8]=Tn.x,i[1]=rr.y,i[5]=ac.y,i[9]=Tn.y,i[2]=rr.z,i[6]=ac.z,i[10]=Tn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,s=n[0],o=n[4],a=n[8],c=n[12],l=n[1],u=n[5],h=n[9],d=n[13],f=n[2],m=n[6],_=n[10],p=n[14],g=n[3],M=n[7],T=n[11],v=n[15],S=i[0],E=i[4],R=i[8],x=i[12],w=i[1],H=i[5],C=i[9],N=i[13],ee=i[2],P=i[6],Z=i[10],G=i[14],k=i[3],W=i[7],B=i[11],Y=i[15];return r[0]=s*S+o*w+a*ee+c*k,r[4]=s*E+o*H+a*P+c*W,r[8]=s*R+o*C+a*Z+c*B,r[12]=s*x+o*N+a*G+c*Y,r[1]=l*S+u*w+h*ee+d*k,r[5]=l*E+u*H+h*P+d*W,r[9]=l*R+u*C+h*Z+d*B,r[13]=l*x+u*N+h*G+d*Y,r[2]=f*S+m*w+_*ee+p*k,r[6]=f*E+m*H+_*P+p*W,r[10]=f*R+m*C+_*Z+p*B,r[14]=f*x+m*N+_*G+p*Y,r[3]=g*S+M*w+T*ee+v*k,r[7]=g*E+M*H+T*P+v*W,r[11]=g*R+M*C+T*Z+v*B,r[15]=g*x+M*N+T*G+v*Y,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],s=e[1],o=e[5],a=e[9],c=e[13],l=e[2],u=e[6],h=e[10],d=e[14],f=e[3],m=e[7],_=e[11],p=e[15],g=a*d-c*h,M=o*d-c*u,T=o*h-a*u,v=s*d-c*l,S=s*h-a*l,E=s*u-o*l;return t*(m*g-_*M+p*T)-n*(f*g-_*v+p*S)+i*(f*M-m*v+p*E)-r*(f*T-m*S+_*E)}determinantAffine(){let e=this.elements,t=e[0],n=e[4],i=e[8],r=e[1],s=e[5],o=e[9],a=e[2],c=e[6],l=e[10];return t*(s*l-o*c)-n*(r*l-o*a)+i*(r*c-s*a)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let i=this.elements;if(e.isVector3)i[12]=e.x,i[13]=e.y,i[14]=e.z;else i[12]=e,i[13]=t,i[14]=n;return this}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=e[9],h=e[10],d=e[11],f=e[12],m=e[13],_=e[14],p=e[15],g=t*o-n*s,M=t*a-i*s,T=t*c-r*s,v=n*a-i*o,S=n*c-r*o,E=i*c-r*a,R=l*m-u*f,x=l*_-h*f,w=l*p-d*f,H=u*_-h*m,C=u*p-d*m,N=h*p-d*_,ee=g*N-M*C+T*H+v*w-S*x+E*R;if(ee===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let P=1/ee;return e[0]=(o*N-a*C+c*H)*P,e[1]=(i*C-n*N-r*H)*P,e[2]=(m*E-_*S+p*v)*P,e[3]=(h*S-u*E-d*v)*P,e[4]=(a*w-s*N-c*x)*P,e[5]=(t*N-i*w+r*x)*P,e[6]=(_*T-f*E-p*M)*P,e[7]=(l*E-h*T+d*M)*P,e[8]=(s*C-o*w+c*R)*P,e[9]=(n*w-t*C-r*R)*P,e[10]=(f*S-m*T+p*g)*P,e[11]=(u*T-l*S-d*g)*P,e[12]=(o*x-s*H-a*R)*P,e[13]=(t*H-n*x+i*R)*P,e[14]=(m*M-f*v-_*g)*P,e[15]=(l*v-u*M+h*g)*P,this}scale(e){let t=this.elements,{x:n,y:i,z:r}=e;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){if(e.isVector3)this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1);else this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1);return this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),i=Math.sin(t),r=1-n,{x:s,y:o,z:a}=e,c=r*s,l=r*o;return this.set(c*s+n,c*o-i*a,c*a+i*o,0,c*o+i*a,l*o+n,l*a-i*s,0,c*a-i*o,l*a+i*s,r*a*a+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,r,s){return this.set(1,n,r,0,e,1,s,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){let i=this.elements,{_x:r,_y:s,_z:o,_w:a}=t,c=r+r,l=s+s,u=o+o,h=r*c,d=r*l,f=r*u,m=s*l,_=s*u,p=o*u,g=a*c,M=a*l,T=a*u,{x:v,y:S,z:E}=n;return i[0]=(1-(m+p))*v,i[1]=(d+T)*v,i[2]=(f-M)*v,i[3]=0,i[4]=(d-T)*S,i[5]=(1-(h+p))*S,i[6]=(_+g)*S,i[7]=0,i[8]=(f+M)*E,i[9]=(_-g)*E,i[10]=(1-(h+m))*E,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){let i=this.elements;e.x=i[12],e.y=i[13],e.z=i[14];let r=this.determinantAffine();if(r===0)return n.set(1,1,1),t.identity(),this;let s=ds.set(i[0],i[1],i[2]).length(),o=ds.set(i[4],i[5],i[6]).length(),a=ds.set(i[8],i[9],i[10]).length();if(r<0)s=-s;qn.copy(this);let c=1/s,l=1/o,u=1/a;return qn.elements[0]*=c,qn.elements[1]*=c,qn.elements[2]*=c,qn.elements[4]*=l,qn.elements[5]*=l,qn.elements[6]*=l,qn.elements[8]*=u,qn.elements[9]*=u,qn.elements[10]*=u,t.setFromRotationMatrix(qn),n.x=s,n.y=o,n.z=a,this}makePerspective(e,t,n,i,r,s,o=2000,a=!1){let c=this.elements,l=2*r/(t-e),u=2*r/(n-i),h=(t+e)/(t-e),d=(n+i)/(n-i),f,m;if(a)f=r/(s-r),m=s*r/(s-r);else if(o===2000)f=-(s+r)/(s-r),m=-2*s*r/(s-r);else if(o===2001)f=-s/(s-r),m=-s*r/(s-r);else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=h,c[12]=0,c[1]=0,c[5]=u,c[9]=d,c[13]=0,c[2]=0,c[6]=0,c[10]=f,c[14]=m,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,i,r,s,o=2000,a=!1){let c=this.elements,l=2/(t-e),u=2/(n-i),h=-(t+e)/(t-e),d=-(n+i)/(n-i),f,m;if(a)f=1/(s-r),m=s/(s-r);else if(o===2000)f=-2/(s-r),m=-(s+r)/(s-r);else if(o===2001)f=-1/(s-r),m=-r/(s-r);else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=0,c[12]=h,c[1]=0,c[5]=u,c[9]=0,c[13]=d,c[2]=0,c[6]=0,c[10]=f,c[14]=m,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}var ds=new F,qn=new Xe,FM=new F(0,0,0),zM=new F(1,1,1),rr=new F,ac=new F,Tn=new F,$0=new Xe,W0=new Yt;class xi{constructor(e=0,t=0,n=0,i=xi.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let i=e.elements,r=i[0],s=i[4],o=i[8],a=i[1],c=i[5],l=i[9],u=i[2],h=i[6],d=i[10];switch(t){case"XYZ":if(this._y=Math.asin(Je(o,-1,1)),Math.abs(o)<0.9999999)this._x=Math.atan2(-l,d),this._z=Math.atan2(-s,r);else this._x=Math.atan2(h,c),this._z=0;break;case"YXZ":if(this._x=Math.asin(-Je(l,-1,1)),Math.abs(l)<0.9999999)this._y=Math.atan2(o,d),this._z=Math.atan2(a,c);else this._y=Math.atan2(-u,r),this._z=0;break;case"ZXY":if(this._x=Math.asin(Je(h,-1,1)),Math.abs(h)<0.9999999)this._y=Math.atan2(-u,d),this._z=Math.atan2(-s,c);else this._y=0,this._z=Math.atan2(a,r);break;case"ZYX":if(this._y=Math.asin(-Je(u,-1,1)),Math.abs(u)<0.9999999)this._x=Math.atan2(h,d),this._z=Math.atan2(a,r);else this._x=0,this._z=Math.atan2(-s,c);break;case"YZX":if(this._z=Math.asin(Je(a,-1,1)),Math.abs(a)<0.9999999)this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,r);else this._x=0,this._y=Math.atan2(o,d);break;case"XZY":if(this._z=Math.asin(-Je(s,-1,1)),Math.abs(s)<0.9999999)this._x=Math.atan2(h,c),this._y=Math.atan2(o,r);else this._x=Math.atan2(-l,d),this._y=0;break;default:Ue("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}if(this._order=t,n===!0)this._onChangeCallback();return this}setFromQuaternion(e,t,n){return $0.makeRotationFromQuaternion(e),this.setFromRotationMatrix($0,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return W0.setFromEuler(this),this.setFromQuaternion(W0,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){if(this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0)this._order=e[3];return this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}xi.DEFAULT_ORDER="XYZ";class qc{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}var kM=0,Z0=new F,fs=new Yt,Ui=new Xe,cc=new F,Ro=new F,BM=new F,GM=new Yt,X0=new F(1,0,0),j0=new F(0,1,0),q0=new F(0,0,1),Y0={type:"added"},HM={type:"removed"},ps={type:"childadded",child:null},$u={type:"childremoved",child:null};class _t extends ii{constructor(){super();this.isObject3D=!0,Object.defineProperty(this,"id",{value:kM++}),this.uuid=Qn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=_t.DEFAULT_UP.clone();let e=new F,t=new xi,n=new Yt,i=new F(1,1,1);function r(){n.setFromEuler(t,!1)}function s(){t.setFromQuaternion(n,void 0,!1)}t._onChange(r),n._onChange(s),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Xe},normalMatrix:{value:new We}}),this.matrix=new Xe,this.matrixWorld=new Xe,this.matrixAutoUpdate=_t.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=_t.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new qc,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){if(this.matrixAutoUpdate)this.updateMatrix();this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return fs.setFromAxisAngle(e,t),this.quaternion.multiply(fs),this}rotateOnWorldAxis(e,t){return fs.setFromAxisAngle(e,t),this.quaternion.premultiply(fs),this}rotateX(e){return this.rotateOnAxis(X0,e)}rotateY(e){return this.rotateOnAxis(j0,e)}rotateZ(e){return this.rotateOnAxis(q0,e)}translateOnAxis(e,t){return Z0.copy(e).applyQuaternion(this.quaternion),this.position.add(Z0.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(X0,e)}translateY(e){return this.translateOnAxis(j0,e)}translateZ(e){return this.translateOnAxis(q0,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Ui.copy(this.matrixWorld).invert())}lookAt(e,t,n){if(e.isVector3)cc.copy(e);else cc.set(e,t,n);let i=this.parent;if(this.updateWorldMatrix(!0,!1),Ro.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight)Ui.lookAt(Ro,cc,this.up);else Ui.lookAt(cc,Ro,this.up);if(this.quaternion.setFromRotationMatrix(Ui),i)Ui.extractRotation(i.matrixWorld),fs.setFromRotationMatrix(Ui),this.quaternion.premultiply(fs.invert())}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}if(e===this)return $e("Object3D.add: object can't be added as a child of itself.",e),this;if(e&&e.isObject3D)e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Y0),ps.child=e,this.dispatchEvent(ps),ps.child=null;else $e("Object3D.add: object not an instance of THREE.Object3D.",e);return this}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let t=this.children.indexOf(e);if(t!==-1)e.parent=null,this.children.splice(t,1),e.dispatchEvent(HM),$u.child=e,this.dispatchEvent($u),$u.child=null;return this}removeFromParent(){let e=this.parent;if(e!==null)e.remove(this);return this}clear(){return this.remove(...this.children)}attach(e){if(this.updateWorldMatrix(!0,!1),Ui.copy(this.matrixWorld).invert(),e.parent!==null)e.parent.updateWorldMatrix(!0,!1),Ui.multiply(e.parent.matrixWorld);return e.applyMatrix4(Ui),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Y0),ps.child=e,this.dispatchEvent(ps),ps.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,i=this.children.length;n<i;n++){let s=this.children[n].getObjectByProperty(e,t);if(s!==void 0)return s}return}getObjectsByProperty(e,t,n=[]){if(this[e]===t)n.push(this);let i=this.children;for(let r=0,s=i.length;r<s;r++)i[r].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ro,e,BM),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ro,GM,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}intersectsFrustum(){}traverse(e){e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;if(t!==null)e(t),t.traverseAncestors(e)}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let{x:t,y:n,z:i}=e,r=this.matrix.elements;r[12]+=t-r[0]*t-r[4]*n-r[8]*i,r[13]+=n-r[1]*t-r[5]*n-r[9]*i,r[14]+=i-r[2]*t-r[6]*n-r[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||e){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,e=!0}let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){let i=this.parent;if(e===!0&&i!==null)i.updateWorldMatrix(!0,!1);if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||n){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,n=!0}if(t===!0){let r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].updateWorldMatrix(!1,!0,n)}}toJSON(e){let t=e===void 0||typeof e==="string",n={};if(t)e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"};let i={};if(i.uuid=this.uuid,i.type=this.type,i.name=this.name,i.castShadow=this.castShadow,i.receiveShadow=this.receiveShadow,i.visible=this.visible,i.frustumCulled=this.frustumCulled,i.renderOrder=this.renderOrder,i.static=this.static,i.matrixAutoUpdate=this.matrixAutoUpdate,Object.keys(this.userData).length>0)i.userData=this.userData;if(i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null)i.pivot=this.pivot.toArray();if(this.morphTargetDictionary!==void 0)i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary);if(this.morphTargetInfluences!==void 0)i.morphTargetInfluences=this.morphTargetInfluences.slice();if(this.isInstancedMesh){if(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null)i.instanceColor=this.instanceColor.toJSON()}if(this.isBatchedMesh){if(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map((o)=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map((o)=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null)i.colorsTexture=this._colorsTexture.toJSON(e);if(this.boundingSphere!==null)i.boundingSphere=this.boundingSphere.toJSON();if(this.boundingBox!==null)i.boundingBox=this.boundingBox.toJSON()}function r(o,a){if(o[a.uuid]===void 0)o[a.uuid]=a.toJSON(e);return a.uuid}if(this.isScene){if(this.background){if(this.background.isColor)i.background=this.background.toJSON();else if(this.background.isTexture)i.background=this.background.toJSON(e).uuid}if(this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0)i.environment=this.environment.toJSON(e).uuid}else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);let o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){let a=o.shapes;if(Array.isArray(a))for(let c=0,l=a.length;c<l;c++){let u=a[c];r(e.shapes,u)}else r(e.shapes,a)}}if(this.isSkinnedMesh){if(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0)r(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid}if(this.material!==void 0)if(Array.isArray(this.material)){let o=[];for(let a=0,c=this.material.length;a<c;a++)o.push(r(e.materials,this.material[a]));i.material=o}else i.material=r(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){let a=this.animations[o];i.animations.push(r(e.animations,a))}}if(t){let o=s(e.geometries),a=s(e.materials),c=s(e.textures),l=s(e.images),u=s(e.shapes),h=s(e.skeletons),d=s(e.animations),f=s(e.nodes);if(o.length>0)n.geometries=o;if(a.length>0)n.materials=a;if(c.length>0)n.textures=c;if(l.length>0)n.images=l;if(u.length>0)n.shapes=u;if(h.length>0)n.skeletons=h;if(d.length>0)n.animations=d;if(f.length>0)n.nodes=f}return n.object=i,n;function s(o){let a=[];for(let c in o){let l=o[c];delete l.metadata,a.push(l)}return a}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){let i=e.children[n];this.add(i.clone())}return this}dispose(){this.dispatchEvent({type:"dispose"})}}_t.DEFAULT_UP=new F(0,1,0);_t.DEFAULT_MATRIX_AUTO_UPDATE=!0;_t.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class gi extends _t{constructor(){super();this.isGroup=!0,this.type="Group"}}var VM={type:"move"};class Xo{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){if(this._hand===null)this._hand=new gi,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1};return this._hand}getTargetRaySpace(){if(this._targetRay===null)this._targetRay=new gi,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new F,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new F;return this._targetRay}getGripSpace(){if(this._grip===null)this._grip=new gi,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new F,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new F,this._grip.eventsEnabled=!1;return this._grip}dispatchEvent(e){if(this._targetRay!==null)this._targetRay.dispatchEvent(e);if(this._grip!==null)this._grip.dispatchEvent(e);if(this._hand!==null)this._hand.dispatchEvent(e);return this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){if(this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null)this._targetRay.visible=!1;if(this._grip!==null)this._grip.visible=!1;if(this._hand!==null)this._hand.visible=!1;return this}update(e,t,n){let i=null,r=null,s=null,o=this._targetRay,a=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){s=!0;for(let m of e.hand.values()){let _=t.getJointPose(m,n),p=this._getHandJoint(c,m);if(_!==null)p.matrix.fromArray(_.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=_.radius;p.visible=_!==null}let l=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],h=l.position.distanceTo(u.position),d=0.02,f=0.005;if(c.inputState.pinching&&h>d+f)c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this});else if(!c.inputState.pinching&&h<=d-f)c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this})}else if(a!==null&&e.gripSpace){if(r=t.getPose(e.gripSpace,n),r!==null){if(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,r.linearVelocity)a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity);else a.hasLinearVelocity=!1;if(r.angularVelocity)a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity);else a.hasAngularVelocity=!1;if(a.eventsEnabled)a.dispatchEvent({type:"gripUpdated",data:e,target:this})}}if(o!==null){if(i=t.getPose(e.targetRaySpace,n),i===null&&r!==null)i=r;if(i!==null){if(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity)o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity);else o.hasLinearVelocity=!1;if(i.angularVelocity)o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity);else o.hasAngularVelocity=!1;this.dispatchEvent(VM)}}}if(o!==null)o.visible=i!==null;if(a!==null)a.visible=r!==null;if(c!==null)c.visible=s!==null;return this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new gi;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}var yv={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},sr={h:0,s:0,l:0},lc={h:0,s:0,l:0};function Wu(e,t,n){if(n<0)n+=1;if(n>1)n-=1;if(n<0.16666666666666666)return e+(t-e)*6*n;if(n<0.5)return t;if(n<0.6666666666666666)return e+(t-e)*6*(0.6666666666666666-n);return e}class He{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let i=e;if(i&&i.isColor)this.copy(i);else if(typeof i==="number")this.setHex(i);else if(typeof i==="string")this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t="srgb"){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Ke.colorSpaceToWorking(this,t),this}setRGB(e,t,n,i=Ke.workingColorSpace){return this.r=e,this.g=t,this.b=n,Ke.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=Ke.workingColorSpace){if(e=ud(e,1),t=Je(t,0,1),n=Je(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=0.5?n*(1+t):n+t-n*t,s=2*n-r;this.r=Wu(s,r,e+0.3333333333333333),this.g=Wu(s,r,e),this.b=Wu(s,r,e-0.3333333333333333)}return Ke.colorSpaceToWorking(this,i),this}setStyle(e,t="srgb"){function n(r){if(r===void 0)return;if(parseFloat(r)<1)Ue("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r,s=i[1],o=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:Ue("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){let r=i[1],s=r.length;if(s===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);else if(s===6)return this.setHex(parseInt(r,16),t);else Ue("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t="srgb"){let n=yv[e.toLowerCase()];if(n!==void 0)this.setHex(n,t);else Ue("Color: Unknown color "+e);return this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Hi(e.r),this.g=Hi(e.g),this.b=Hi(e.b),this}copyLinearToSRGB(e){return this.r=Es(e.r),this.g=Es(e.g),this.b=Es(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e="srgb"){return Ke.workingToColorSpace(an.copy(this),e),Math.round(Je(an.r*255,0,255))*65536+Math.round(Je(an.g*255,0,255))*256+Math.round(Je(an.b*255,0,255))}getHexString(e="srgb"){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Ke.workingColorSpace){Ke.workingToColorSpace(an.copy(this),t);let{r:n,g:i,b:r}=an,s=Math.max(n,i,r),o=Math.min(n,i,r),a,c,l=(o+s)/2;if(o===s)a=0,c=0;else{let u=s-o;switch(c=l<=0.5?u/(s+o):u/(2-s-o),s){case n:a=(i-r)/u+(i<r?6:0);break;case i:a=(r-n)/u+2;break;case r:a=(n-i)/u+4;break}a/=6}return e.h=a,e.s=c,e.l=l,e}getRGB(e,t=Ke.workingColorSpace){return Ke.workingToColorSpace(an.copy(this),t),e.r=an.r,e.g=an.g,e.b=an.b,e}getStyle(e="srgb"){Ke.workingToColorSpace(an.copy(this),e);let{r:t,g:n,b:i}=an;if(e!=="srgb")return`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`;return`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(e,t,n){return this.getHSL(sr),this.setHSL(sr.h+e,sr.s+t,sr.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(sr),e.getHSL(lc);let n=Fo(sr.h,lc.h,t),i=Fo(sr.s,lc.s,t),r=Fo(sr.l,lc.l,t);return this.setHSL(n,i,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,i=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*i,this.g=r[1]*t+r[4]*n+r[7]*i,this.b=r[2]*t+r[5]*n+r[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}var an=new He;He.NAMES=yv;class Fs extends _t{constructor(){super();if(this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new xi,this.environmentIntensity=1,this.environmentRotation=new xi,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){if(super.copy(e,t),e.background!==null)this.background=e.background.clone();if(e.environment!==null)this.environment=e.environment.clone();if(e.fog!==null)this.fog=e.fog.clone();if(this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null)this.overrideMaterial=e.overrideMaterial.clone();return this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);if(this.fog!==null)t.object.fog=this.fog.toJSON();return t.object.backgroundBlurriness=this.backgroundBlurriness,t.object.backgroundIntensity=this.backgroundIntensity,t.object.backgroundRotation=this.backgroundRotation.toArray(),t.object.environmentIntensity=this.environmentIntensity,t.object.environmentRotation=this.environmentRotation.toArray(),t}}var Yn=new F,Fi=new F,Zu=new F,zi=new F,ms=new F,gs=new F,K0=new F,Xu=new F,ju=new F,qu=new F,Yu=new pt,Ku=new pt,Ju=new pt;class kn{constructor(e=new F,t=new F,n=new F){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),Yn.subVectors(e,t),i.cross(Yn);let r=i.lengthSq();if(r>0)return i.multiplyScalar(1/Math.sqrt(r));return i.set(0,0,0)}static getBarycoord(e,t,n,i,r){Yn.subVectors(i,t),Fi.subVectors(n,t),Zu.subVectors(e,t);let s=Yn.dot(Yn),o=Yn.dot(Fi),a=Yn.dot(Zu),c=Fi.dot(Fi),l=Fi.dot(Zu),u=s*c-o*o;if(u===0)return r.set(0,0,0),null;let h=1/u,d=(c*a-o*l)*h,f=(s*l-o*a)*h;return r.set(1-d-f,f,d)}static containsPoint(e,t,n,i){if(this.getBarycoord(e,t,n,i,zi)===null)return!1;return zi.x>=0&&zi.y>=0&&zi.x+zi.y<=1}static getInterpolation(e,t,n,i,r,s,o,a){if(this.getBarycoord(e,t,n,i,zi)===null){if(a.x=0,a.y=0,"z"in a)a.z=0;if("w"in a)a.w=0;return null}return a.setScalar(0),a.addScaledVector(r,zi.x),a.addScaledVector(s,zi.y),a.addScaledVector(o,zi.z),a}static getInterpolatedAttribute(e,t,n,i,r,s){return Yu.setScalar(0),Ku.setScalar(0),Ju.setScalar(0),Yu.fromBufferAttribute(e,t),Ku.fromBufferAttribute(e,n),Ju.fromBufferAttribute(e,i),s.setScalar(0),s.addScaledVector(Yu,r.x),s.addScaledVector(Ku,r.y),s.addScaledVector(Ju,r.z),s}static isFrontFacing(e,t,n,i){return Yn.subVectors(n,t),Fi.subVectors(e,t),Yn.cross(Fi).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Yn.subVectors(this.c,this.b),Fi.subVectors(this.a,this.b),Yn.cross(Fi).length()*0.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(0.3333333333333333)}getNormal(e){return kn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return kn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,r){return kn.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return kn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return kn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,i=this.b,r=this.c,s,o;ms.subVectors(i,n),gs.subVectors(r,n),Xu.subVectors(e,n);let a=ms.dot(Xu),c=gs.dot(Xu);if(a<=0&&c<=0)return t.copy(n);ju.subVectors(e,i);let l=ms.dot(ju),u=gs.dot(ju);if(l>=0&&u<=l)return t.copy(i);let h=a*u-l*c;if(h<=0&&a>=0&&l<=0)return s=a/(a-l),t.copy(n).addScaledVector(ms,s);qu.subVectors(e,r);let d=ms.dot(qu),f=gs.dot(qu);if(f>=0&&d<=f)return t.copy(r);let m=d*c-a*f;if(m<=0&&c>=0&&f<=0)return o=c/(c-f),t.copy(n).addScaledVector(gs,o);let _=l*f-d*u;if(_<=0&&u-l>=0&&d-f>=0)return K0.subVectors(r,i),o=(u-l)/(u-l+(d-f)),t.copy(i).addScaledVector(K0,o);let p=1/(_+m+h);return s=m*p,o=h*p,t.copy(n).addScaledVector(ms,s).addScaledVector(gs,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class Vt{constructor(e=new F(1/0,1/0,1/0),t=new F(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(Kn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Kn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=Kn.copy(t).multiplyScalar(0.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(0.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0){let r=n.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let s=0,o=r.count;s<o;s++){if(e.isMesh===!0)e.getVertexPosition(s,Kn);else Kn.fromBufferAttribute(r,s);Kn.applyMatrix4(e.matrixWorld),this.expandByPoint(Kn)}else{if(e.boundingBox!==void 0){if(e.boundingBox===null)e.computeBoundingBox();uc.copy(e.boundingBox)}else{if(n.boundingBox===null)n.computeBoundingBox();uc.copy(n.boundingBox)}uc.applyMatrix4(e.matrixWorld),this.union(uc)}}let i=e.children;for(let r=0,s=i.length;r<s;r++)this.expandByObject(i[r],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Kn),Kn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;if(e.normal.x>0)t=e.normal.x*this.min.x,n=e.normal.x*this.max.x;else t=e.normal.x*this.max.x,n=e.normal.x*this.min.x;if(e.normal.y>0)t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y;else t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y;if(e.normal.z>0)t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z;else t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z;return t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Co),hc.subVectors(this.max,Co),_s.subVectors(e.a,Co),xs.subVectors(e.b,Co),vs.subVectors(e.c,Co),or.subVectors(xs,_s),ar.subVectors(vs,xs),zr.subVectors(_s,vs);let t=[0,-or.z,or.y,0,-ar.z,ar.y,0,-zr.z,zr.y,or.z,0,-or.x,ar.z,0,-ar.x,zr.z,0,-zr.x,-or.y,or.x,0,-ar.y,ar.x,0,-zr.y,zr.x,0];if(!Qu(t,_s,xs,vs,hc))return!1;if(t=[1,0,0,0,1,0,0,0,1],!Qu(t,_s,xs,vs,hc))return!1;return dc.crossVectors(or,ar),t=[dc.x,dc.y,dc.z],Qu(t,_s,xs,vs,hc)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Kn).distanceTo(e)}getBoundingSphere(e){if(this.isEmpty())e.makeEmpty();else this.getCenter(e.center),e.radius=this.getSize(Kn).length()*0.5;return e}intersect(e){if(this.min.max(e.min),this.max.min(e.max),this.isEmpty())this.makeEmpty();return this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){if(this.isEmpty())return this;return ki[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),ki[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),ki[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),ki[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),ki[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),ki[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),ki[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),ki[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(ki),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}var ki=[new F,new F,new F,new F,new F,new F,new F,new F],Kn=new F,uc=new Vt,_s=new F,xs=new F,vs=new F,or=new F,ar=new F,zr=new F,Co=new F,hc=new F,dc=new F,kr=new F;function Qu(e,t,n,i,r){for(let s=0,o=e.length-3;s<=o;s+=3){kr.fromArray(e,s);let a=r.x*Math.abs(kr.x)+r.y*Math.abs(kr.y)+r.z*Math.abs(kr.z),c=t.dot(kr),l=n.dot(kr),u=i.dot(kr);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>a)return!1}return!0}var Gt=new F,fc=new Be,$M=0;class Kt extends ii{constructor(e,t,n=!1){super();if(Array.isArray(e))throw TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:$M++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=35044,this.updateRanges=[],this.gpuType=1015,this.version=0}onUploadCallback(){}set needsUpdate(e){if(e===!0)this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[e+i]=t.array[n+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)fc.fromBufferAttribute(this,t),fc.applyMatrix3(e),this.setXY(t,fc.x,fc.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)Gt.fromBufferAttribute(this,t),Gt.applyMatrix3(e),this.setXYZ(t,Gt.x,Gt.y,Gt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Gt.fromBufferAttribute(this,t),Gt.applyMatrix4(e),this.setXYZ(t,Gt.x,Gt.y,Gt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Gt.fromBufferAttribute(this,t),Gt.applyNormalMatrix(e),this.setXYZ(t,Gt.x,Gt.y,Gt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Gt.fromBufferAttribute(this,t),Gt.transformDirection(e),this.setXYZ(t,Gt.x,Gt.y,Gt.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];if(this.normalized)n=Jn(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=ft(n,this.array);return this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];if(this.normalized)t=Jn(t,this.array);return t}setX(e,t){if(this.normalized)t=ft(t,this.array);return this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];if(this.normalized)t=Jn(t,this.array);return t}setY(e,t){if(this.normalized)t=ft(t,this.array);return this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];if(this.normalized)t=Jn(t,this.array);return t}setZ(e,t){if(this.normalized)t=ft(t,this.array);return this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];if(this.normalized)t=Jn(t,this.array);return t}setW(e,t){if(this.normalized)t=ft(t,this.array);return this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){if(e*=this.itemSize,this.normalized)t=ft(t,this.array),n=ft(n,this.array);return this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){if(e*=this.itemSize,this.normalized)t=ft(t,this.array),n=ft(n,this.array),i=ft(i,this.array);return this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,r){if(e*=this.itemSize,this.normalized)t=ft(t,this.array),n=ft(n,this.array),i=ft(i,this.array),r=ft(r,this.array);return this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return e.name=this.name,e.usage=this.usage,e.gpuType=this.gpuType,e}dispose(){this.dispatchEvent({type:"dispose"})}}class Yc extends Kt{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class Kc extends Kt{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class vn extends Kt{constructor(e,t,n){super(new Float32Array(e),t,n)}}var WM=new Vt,Io=new F,eh=new F;class In{constructor(e=new F,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;if(t!==void 0)n.copy(t);else WM.setFromPoints(e).getCenter(n);let i=0;for(let r=0,s=e.length;r<s;r++)i=Math.max(i,n.distanceToSquared(e[r]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let n=this.center.distanceToSquared(e);if(t.copy(e),n>this.radius*this.radius)t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center);return t}getBoundingBox(e){if(this.isEmpty())return e.makeEmpty(),e;return e.set(this.center,this.center),e.expandByScalar(this.radius),e}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Io.subVectors(e,this.center);let t=Io.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),i=(n-this.radius)*0.5;this.center.addScaledVector(Io,i/n),this.radius+=i}return this}union(e){if(e.isEmpty())return this;if(this.isEmpty())return this.copy(e),this;if(this.center.equals(e.center)===!0)this.radius=Math.max(this.radius,e.radius);else eh.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Io.copy(e.center).add(eh)),this.expandByPoint(Io.copy(e.center).sub(eh));return this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}var ZM=0,Fn=new Xe,th=new _t,ys=new F,An=new Vt,Po=new Vt,qt=new F;class ln extends ii{constructor(){super();this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:ZM++}),this.uuid=Qn(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){if(Array.isArray(e))this.index=new((gM(e))?Kc:Yc)(e,1);else this.index=e;return this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;if(t!==void 0)t.applyMatrix4(e),t.needsUpdate=!0;let n=this.attributes.normal;if(n!==void 0){let r=new We().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}let i=this.attributes.tangent;if(i!==void 0)i.transformDirection(e),i.needsUpdate=!0;if(this.boundingBox!==null)this.computeBoundingBox();if(this.boundingSphere!==null)this.computeBoundingSphere();return this._transformed=!0,this}applyQuaternion(e){return Fn.makeRotationFromQuaternion(e),this.applyMatrix4(Fn),this}rotateX(e){return Fn.makeRotationX(e),this.applyMatrix4(Fn),this}rotateY(e){return Fn.makeRotationY(e),this.applyMatrix4(Fn),this}rotateZ(e){return Fn.makeRotationZ(e),this.applyMatrix4(Fn),this}translate(e,t,n){return Fn.makeTranslation(e,t,n),this.applyMatrix4(Fn),this}scale(e,t,n){return Fn.makeScale(e,t,n),this.applyMatrix4(Fn),this}lookAt(e){return th.lookAt(e),th.updateMatrix(),this.applyMatrix4(th.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ys).negate(),this.translate(ys.x,ys.y,ys.z),this}setFromPoints(e){let t=this.getAttribute("position");if(t===void 0){let n=[];for(let i=0,r=e.length;i<r;i++){let s=e[i];n.push(s.x,s.y,s.z||0)}this.setAttribute("position",new vn(n,3))}else{let n=Math.min(e.length,t.count);for(let i=0;i<n;i++){let r=e[i];t.setXYZ(i,r.x,r.y,r.z||0)}if(e.length>t.count)Ue("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.");t.needsUpdate=!0}return this}computeBoundingBox(){if(this.boundingBox===null)this.boundingBox=new Vt;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){$e("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new F(-1/0,-1/0,-1/0),new F(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){let r=t[n];if(An.setFromBufferAttribute(r),this.morphTargetsRelative)qt.addVectors(this.boundingBox.min,An.min),this.boundingBox.expandByPoint(qt),qt.addVectors(this.boundingBox.max,An.max),this.boundingBox.expandByPoint(qt);else this.boundingBox.expandByPoint(An.min),this.boundingBox.expandByPoint(An.max)}}else this.boundingBox.makeEmpty();if(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))$e('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){if(this.boundingSphere===null)this.boundingSphere=new In;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){$e("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new F,1/0);return}if(e){let n=this.boundingSphere.center;if(An.setFromBufferAttribute(e),t)for(let r=0,s=t.length;r<s;r++){let o=t[r];if(Po.setFromBufferAttribute(o),this.morphTargetsRelative)qt.addVectors(An.min,Po.min),An.expandByPoint(qt),qt.addVectors(An.max,Po.max),An.expandByPoint(qt);else An.expandByPoint(Po.min),An.expandByPoint(Po.max)}An.getCenter(n);let i=0;for(let r=0,s=e.count;r<s;r++)qt.fromBufferAttribute(e,r),i=Math.max(i,n.distanceToSquared(qt));if(t)for(let r=0,s=t.length;r<s;r++){let o=t[r],a=this.morphTargetsRelative;for(let c=0,l=o.count;c<l;c++){if(qt.fromBufferAttribute(o,c),a)ys.fromBufferAttribute(e,c),qt.add(ys);i=Math.max(i,n.distanceToSquared(qt))}}if(this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius))$e('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){$e("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let{position:n,normal:i,uv:r}=t,s=this.getAttribute("tangent");if(s===void 0||s.count!==n.count)s=new Kt(new Float32Array(4*n.count),4),this.setAttribute("tangent",s);let o=[],a=[];for(let R=0;R<n.count;R++)o[R]=new F,a[R]=new F;let c=new F,l=new F,u=new F,h=new Be,d=new Be,f=new Be,m=new F,_=new F;function p(R,x,w){c.fromBufferAttribute(n,R),l.fromBufferAttribute(n,x),u.fromBufferAttribute(n,w),h.fromBufferAttribute(r,R),d.fromBufferAttribute(r,x),f.fromBufferAttribute(r,w),l.sub(c),u.sub(c),d.sub(h),f.sub(h);let H=1/(d.x*f.y-f.x*d.y);if(!isFinite(H))return;m.copy(l).multiplyScalar(f.y).addScaledVector(u,-d.y).multiplyScalar(H),_.copy(u).multiplyScalar(d.x).addScaledVector(l,-f.x).multiplyScalar(H),o[R].add(m),o[x].add(m),o[w].add(m),a[R].add(_),a[x].add(_),a[w].add(_)}let g=this.groups;if(g.length===0)g=[{start:0,count:e.count}];for(let R=0,x=g.length;R<x;++R){let w=g[R],{start:H,count:C}=w;for(let N=H,ee=H+C;N<ee;N+=3)p(e.getX(N+0),e.getX(N+1),e.getX(N+2))}let M=new F,T=new F,v=new F,S=new F;function E(R){v.fromBufferAttribute(i,R),S.copy(v);let x=o[R];M.copy(x),M.sub(v.multiplyScalar(v.dot(x))).normalize(),T.crossVectors(S,x);let H=T.dot(a[R])<0?-1:1;s.setXYZW(R,M.x,M.y,M.z,H)}for(let R=0,x=g.length;R<x;++R){let w=g[R],{start:H,count:C}=w;for(let N=H,ee=H+C;N<ee;N+=3)E(e.getX(N+0)),E(e.getX(N+1)),E(e.getX(N+2))}this._transformed=!0}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0||n.count!==t.count)n=new Kt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let h=0,d=n.count;h<d;h++)n.setXYZ(h,0,0,0);let i=new F,r=new F,s=new F,o=new F,a=new F,c=new F,l=new F,u=new F;if(e)for(let h=0,d=e.count;h<d;h+=3){let f=e.getX(h+0),m=e.getX(h+1),_=e.getX(h+2);i.fromBufferAttribute(t,f),r.fromBufferAttribute(t,m),s.fromBufferAttribute(t,_),l.subVectors(s,r),u.subVectors(i,r),l.cross(u),o.fromBufferAttribute(n,f),a.fromBufferAttribute(n,m),c.fromBufferAttribute(n,_),o.add(l),a.add(l),c.add(l),n.setXYZ(f,o.x,o.y,o.z),n.setXYZ(m,a.x,a.y,a.z),n.setXYZ(_,c.x,c.y,c.z)}else for(let h=0,d=t.count;h<d;h+=3)i.fromBufferAttribute(t,h+0),r.fromBufferAttribute(t,h+1),s.fromBufferAttribute(t,h+2),l.subVectors(s,r),u.subVectors(i,r),l.cross(u),n.setXYZ(h+0,l.x,l.y,l.z),n.setXYZ(h+1,l.x,l.y,l.z),n.setXYZ(h+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)qt.fromBufferAttribute(e,t),qt.normalize(),e.setXYZ(t,qt.x,qt.y,qt.z)}toNonIndexed(){function e(o,a){let{array:c,itemSize:l,normalized:u}=o,h=new c.constructor(a.length*l),d=0,f=0;for(let m=0,_=a.length;m<_;m++){if(o.isInterleavedBufferAttribute)d=a[m]*o.data.stride+o.offset;else d=a[m]*l;for(let p=0;p<l;p++)h[f++]=c[d++]}return new Kt(h,l,u)}if(this.index===null)return Ue("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new ln,n=this.index.array,i=this.attributes;for(let o in i){let a=i[o],c=e(a,n);t.setAttribute(o,c)}let r=this.morphAttributes;for(let o in r){let a=[],c=r[o];for(let l=0,u=c.length;l<u;l++){let h=c[l],d=e(h,n);a.push(d)}t.morphAttributes[o]=a}t.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;for(let o=0,a=s.length;o<a;o++){let c=s[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){let e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,e.name=this.name,Object.keys(this.userData).length>0)e.userData=this.userData;if(this.parameters!==void 0&&this._transformed!==!0){let a=this.parameters;for(let c in a)if(a[c]!==void 0)e[c]=a[c];return e}e.data={attributes:{}};let t=this.index;if(t!==null)e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)};let n=this.attributes;for(let a in n){let c=n[a];e.data.attributes[a]=c.toJSON(e.data)}let i={},r=!1;for(let a in this.morphAttributes){let c=this.morphAttributes[a],l=[];for(let u=0,h=c.length;u<h;u++){let d=c[u];l.push(d.toJSON(e.data))}if(l.length>0)i[a]=l,r=!0}if(r)e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;if(s.length>0)e.data.groups=JSON.parse(JSON.stringify(s));let o=this.boundingSphere;if(o!==null)e.data.boundingSphere=o.toJSON();return e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;if(n!==null)this.setIndex(n.clone());let i=e.attributes;for(let c in i){let l=i[c];this.setAttribute(c,l.clone(t))}let r=e.morphAttributes;for(let c in r){let l=[],u=r[c];for(let h=0,d=u.length;h<d;h++)l.push(u[h].clone(t));this.morphAttributes[c]=l}this.morphTargetsRelative=e.morphTargetsRelative;let s=e.groups;for(let c=0,l=s.length;c<l;c++){let u=s[c];this.addGroup(u.start,u.count,u.materialIndex)}let o=e.boundingBox;if(o!==null)this.boundingBox=o.clone();let a=e.boundingSphere;if(a!==null)this.boundingSphere=a.clone();return this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class jo{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=35044,this.updateRanges=[],this.version=0,this.uuid=Qn()}onUploadCallback(){}set needsUpdate(e){if(e===!0)this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,r=this.stride;i<r;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){if(e.arrayBuffers===void 0)e.arrayBuffers={};if(this.array.buffer._uuid===void 0)this.array.buffer._uuid=Qn();if(e.arrayBuffers[this.array.buffer._uuid]===void 0)e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer;let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){if(e.arrayBuffers===void 0)e.arrayBuffers={};if(this.array.buffer._uuid===void 0)this.array.buffer._uuid=Qn();if(e.arrayBuffers[this.array.buffer._uuid]===void 0)e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer));let t={uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride};return t.usage=this.usage,t}}var gn=new F;class zs{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)gn.fromBufferAttribute(this,t),gn.applyMatrix4(e),this.setXYZ(t,gn.x,gn.y,gn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)gn.fromBufferAttribute(this,t),gn.applyNormalMatrix(e),this.setXYZ(t,gn.x,gn.y,gn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)gn.fromBufferAttribute(this,t),gn.transformDirection(e),this.setXYZ(t,gn.x,gn.y,gn.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];if(this.normalized)n=Jn(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=ft(n,this.array);return this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){if(this.normalized)t=ft(t,this.array);return this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){if(this.normalized)t=ft(t,this.array);return this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){if(this.normalized)t=ft(t,this.array);return this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){if(this.normalized)t=ft(t,this.array);return this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];if(this.normalized)t=Jn(t,this.array);return t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];if(this.normalized)t=Jn(t,this.array);return t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];if(this.normalized)t=Jn(t,this.array);return t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];if(this.normalized)t=Jn(t,this.array);return t}setXY(e,t,n){if(e=e*this.data.stride+this.offset,this.normalized)t=ft(t,this.array),n=ft(n,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){if(e=e*this.data.stride+this.offset,this.normalized)t=ft(t,this.array),n=ft(n,this.array),i=ft(i,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,r){if(e=e*this.data.stride+this.offset,this.normalized)t=ft(t,this.array),n=ft(n,this.array),i=ft(i,this.array),r=ft(r,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=r,this}clone(e){if(e===void 0){zo("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return new Kt(new this.array.constructor(t),this.itemSize,this.normalized)}else{if(e.interleavedBuffers===void 0)e.interleavedBuffers={};if(e.interleavedBuffers[this.data.uuid]===void 0)e.interleavedBuffers[this.data.uuid]=this.data.clone(e);return new zs(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}}toJSON(e){if(e===void 0){zo("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else{if(e.interleavedBuffers===void 0)e.interleavedBuffers={};if(e.interleavedBuffers[this.data.uuid]===void 0)e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e);return{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}}var nh=new F,XM=new F,jM=new We;class zn{constructor(e=new F(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let i=nh.subVectors(n,t).cross(XM.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,n=!0){let i=e.delta(nh),r=this.normal.dot(i);if(r===0){if(this.distanceToPoint(e.start)===0)return t.copy(e.start);return null}let s=-(e.start.dot(this.normal)+this.constant)/r;if(n===!0&&(s<0||s>1))return null;return t.copy(e.start).addScaledVector(i,s)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||jM.getNormalMatrix(e),i=this.coplanarPoint(nh).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}toJSON(){return{normal:this.normal.toArray(),constant:this.constant}}fromJSON(e){return this.normal.fromArray(e.normal),this.constant=e.constant,this}}var qM=0;class yn extends ii{constructor(){super();this.isMaterial=!0,Object.defineProperty(this,"id",{value:qM++}),this.uuid=Qn(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new He(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=7680,this.stencilZFail=7680,this.stencilZPass=7680,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){if(this._alphaTest>0!==e>0)this.version++;this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e===void 0)return;for(let t in e){let n=e[t];if(n===void 0){Ue(`Material: parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){Ue(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}if(i&&i.isColor)i.set(n);else if(i&&i.isVector2&&(n&&n.isVector2)||i&&i.isEuler&&(n&&n.isEuler)||i&&i.isVector3&&(n&&n.isVector3))i.copy(n);else this[t]=n}}toJSON(e){let t=e===void 0||typeof e==="string";if(t)e={textures:{},images:{}};let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};if(n.uuid=this.uuid,n.type=this.type,n.blending=this.blending,n.side=this.side,n.shadowSide=this.shadowSide,n.vertexColors=this.vertexColors,n.opacity=this.opacity,n.transparent=this.transparent,n.blendSrc=this.blendSrc,n.blendDst=this.blendDst,n.blendEquation=this.blendEquation,n.blendSrcAlpha=this.blendSrcAlpha,n.blendDstAlpha=this.blendDstAlpha,n.blendEquationAlpha=this.blendEquationAlpha,n.blendColor=this.blendColor.getHex(),n.blendAlpha=this.blendAlpha,n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.clipIntersection=this.clipIntersection,n.clipShadows=this.clipShadows,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,n.stencilWrite=this.stencilWrite,n.polygonOffset=this.polygonOffset,n.polygonOffsetFactor=this.polygonOffsetFactor,n.polygonOffsetUnits=this.polygonOffsetUnits,n.dithering=this.dithering,n.alphaTest=this.alphaTest,n.alphaHash=this.alphaHash,n.alphaToCoverage=this.alphaToCoverage,n.premultipliedAlpha=this.premultipliedAlpha,n.forceSinglePass=this.forceSinglePass,n.allowOverride=this.allowOverride,n.visible=this.visible,n.toneMapped=this.toneMapped,n.name=this.name,this.color&&this.color.isColor)n.color=this.color.getHex();if(this.roughness!==void 0)n.roughness=this.roughness;if(this.metalness!==void 0)n.metalness=this.metalness;if(this.sheen!==void 0)n.sheen=this.sheen;if(this.sheenColor&&this.sheenColor.isColor)n.sheenColor=this.sheenColor.getHex();if(this.sheenRoughness!==void 0)n.sheenRoughness=this.sheenRoughness;if(this.emissive&&this.emissive.isColor)n.emissive=this.emissive.getHex();if(this.emissiveIntensity!==void 0)n.emissiveIntensity=this.emissiveIntensity;if(this.specular&&this.specular.isColor)n.specular=this.specular.getHex();if(this.specularIntensity!==void 0)n.specularIntensity=this.specularIntensity;if(this.specularColor&&this.specularColor.isColor)n.specularColor=this.specularColor.getHex();if(this.shininess!==void 0)n.shininess=this.shininess;if(this.clearcoat!==void 0)n.clearcoat=this.clearcoat;if(this.clearcoatRoughness!==void 0)n.clearcoatRoughness=this.clearcoatRoughness;if(this.clearcoatMap&&this.clearcoatMap.isTexture)n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid;if(this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture)n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid;if(this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture)n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray();if(this.sheenColorMap&&this.sheenColorMap.isTexture)n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid;if(this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture)n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid;if(this.dispersion!==void 0)n.dispersion=this.dispersion;if(this.retroreflectivity!==void 0)n.retroreflectivity=this.retroreflectivity;if(this.iridescence!==void 0)n.iridescence=this.iridescence;if(this.iridescenceIOR!==void 0)n.iridescenceIOR=this.iridescenceIOR;if(this.iridescenceThicknessRange!==void 0)n.iridescenceThicknessRange=this.iridescenceThicknessRange;if(this.iridescenceMap&&this.iridescenceMap.isTexture)n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid;if(this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture)n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid;if(this.anisotropy!==void 0)n.anisotropy=this.anisotropy;if(this.anisotropyRotation!==void 0)n.anisotropyRotation=this.anisotropyRotation;if(this.anisotropyMap&&this.anisotropyMap.isTexture)n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid;if(this.map&&this.map.isTexture)n.map=this.map.toJSON(e).uuid;if(this.matcap&&this.matcap.isTexture)n.matcap=this.matcap.toJSON(e).uuid;if(this.alphaMap&&this.alphaMap.isTexture)n.alphaMap=this.alphaMap.toJSON(e).uuid;if(this.lightMap&&this.lightMap.isTexture)n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity;if(this.aoMap&&this.aoMap.isTexture)n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity;if(this.bumpMap&&this.bumpMap.isTexture)n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale;if(this.normalMap&&this.normalMap.isTexture)n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray();if(this.displacementMap&&this.displacementMap.isTexture)n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias;if(this.roughnessMap&&this.roughnessMap.isTexture)n.roughnessMap=this.roughnessMap.toJSON(e).uuid;if(this.metalnessMap&&this.metalnessMap.isTexture)n.metalnessMap=this.metalnessMap.toJSON(e).uuid;if(this.emissiveMap&&this.emissiveMap.isTexture)n.emissiveMap=this.emissiveMap.toJSON(e).uuid;if(this.specularMap&&this.specularMap.isTexture)n.specularMap=this.specularMap.toJSON(e).uuid;if(this.specularIntensityMap&&this.specularIntensityMap.isTexture)n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid;if(this.specularColorMap&&this.specularColorMap.isTexture)n.specularColorMap=this.specularColorMap.toJSON(e).uuid;if(this.envMap&&this.envMap.isTexture){if(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0)n.combine=this.combine}if(this.envMapRotation!==void 0)n.envMapRotation=this.envMapRotation.toArray();if(this.envMapIntensity!==void 0)n.envMapIntensity=this.envMapIntensity;if(this.reflectivity!==void 0)n.reflectivity=this.reflectivity;if(this.refractionRatio!==void 0)n.refractionRatio=this.refractionRatio;if(this.gradientMap&&this.gradientMap.isTexture)n.gradientMap=this.gradientMap.toJSON(e).uuid;if(this.transmission!==void 0)n.transmission=this.transmission;if(this.transmissionMap&&this.transmissionMap.isTexture)n.transmissionMap=this.transmissionMap.toJSON(e).uuid;if(this.thickness!==void 0)n.thickness=this.thickness;if(this.thicknessMap&&this.thicknessMap.isTexture)n.thicknessMap=this.thicknessMap.toJSON(e).uuid;if(this.attenuationDistance!==void 0)n.attenuationDistance=this.attenuationDistance;if(this.attenuationColor!==void 0)n.attenuationColor=this.attenuationColor.getHex();if(this.size!==void 0)n.size=this.size;if(this.sizeAttenuation!==void 0)n.sizeAttenuation=this.sizeAttenuation;if(Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0)n.clippingPlanes=this.clippingPlanes.map((r)=>r.toJSON());if(this.rotation!==void 0)n.rotation=this.rotation;if(this.depthPacking!==void 0)n.depthPacking=this.depthPacking;if(this.linewidth!==void 0)n.linewidth=this.linewidth;if(this.linecap!==void 0)n.linecap=this.linecap;if(this.linejoin!==void 0)n.linejoin=this.linejoin;if(this.dashSize!==void 0)n.dashSize=this.dashSize;if(this.gapSize!==void 0)n.gapSize=this.gapSize;if(this.scale!==void 0)n.scale=this.scale;if(this.wireframe!==void 0)n.wireframe=this.wireframe;if(this.wireframeLinewidth!==void 0)n.wireframeLinewidth=this.wireframeLinewidth;if(this.wireframeLinecap!==void 0)n.wireframeLinecap=this.wireframeLinecap;if(this.wireframeLinejoin!==void 0)n.wireframeLinejoin=this.wireframeLinejoin;if(this.flatShading!==void 0)n.flatShading=this.flatShading;if(this.fog!==void 0)n.fog=this.fog;if(Object.keys(this.userData).length>0)n.userData=this.userData;function i(r){let s=[];for(let o in r){let a=r[o];delete a.metadata,s.push(a)}return s}if(t){let r=i(e.textures),s=i(e.images);if(r.length>0)n.textures=r;if(s.length>0)n.images=s}return n}fromJSON(e,t){if(e.uuid!==void 0)this.uuid=e.uuid;if(e.name!==void 0)this.name=e.name;if(e.color!==void 0&&this.color!==void 0)this.color.setHex(e.color);if(e.roughness!==void 0)this.roughness=e.roughness;if(e.metalness!==void 0)this.metalness=e.metalness;if(e.sheen!==void 0)this.sheen=e.sheen;if(e.sheenColor!==void 0)this.sheenColor=new He().setHex(e.sheenColor);if(e.sheenRoughness!==void 0)this.sheenRoughness=e.sheenRoughness;if(e.emissive!==void 0&&this.emissive!==void 0)this.emissive.setHex(e.emissive);if(e.specular!==void 0&&this.specular!==void 0)this.specular.setHex(e.specular);if(e.specularIntensity!==void 0)this.specularIntensity=e.specularIntensity;if(e.specularColor!==void 0&&this.specularColor!==void 0)this.specularColor.setHex(e.specularColor);if(e.shininess!==void 0)this.shininess=e.shininess;if(e.clearcoat!==void 0)this.clearcoat=e.clearcoat;if(e.clearcoatRoughness!==void 0)this.clearcoatRoughness=e.clearcoatRoughness;if(e.dispersion!==void 0)this.dispersion=e.dispersion;if(e.retroreflectivity!==void 0)this.retroreflectivity=e.retroreflectivity;if(e.iridescence!==void 0)this.iridescence=e.iridescence;if(e.iridescenceIOR!==void 0)this.iridescenceIOR=e.iridescenceIOR;if(e.iridescenceThicknessRange!==void 0)this.iridescenceThicknessRange=e.iridescenceThicknessRange;if(e.transmission!==void 0)this.transmission=e.transmission;if(e.thickness!==void 0)this.thickness=e.thickness;if(e.attenuationDistance!==void 0)this.attenuationDistance=e.attenuationDistance;if(e.attenuationColor!==void 0&&this.attenuationColor!==void 0)this.attenuationColor.setHex(e.attenuationColor);if(e.anisotropy!==void 0)this.anisotropy=e.anisotropy;if(e.anisotropyRotation!==void 0)this.anisotropyRotation=e.anisotropyRotation;if(e.fog!==void 0)this.fog=e.fog;if(e.flatShading!==void 0)this.flatShading=e.flatShading;if(e.blending!==void 0)this.blending=e.blending;if(e.combine!==void 0)this.combine=e.combine;if(e.side!==void 0)this.side=e.side;if(e.shadowSide!==void 0)this.shadowSide=e.shadowSide;if(e.opacity!==void 0)this.opacity=e.opacity;if(e.transparent!==void 0)this.transparent=e.transparent;if(e.alphaTest!==void 0)this.alphaTest=e.alphaTest;if(e.alphaHash!==void 0)this.alphaHash=e.alphaHash;if(e.depthFunc!==void 0)this.depthFunc=e.depthFunc;if(e.depthTest!==void 0)this.depthTest=e.depthTest;if(e.depthWrite!==void 0)this.depthWrite=e.depthWrite;if(e.colorWrite!==void 0)this.colorWrite=e.colorWrite;if(e.clippingPlanes!==void 0)this.clippingPlanes=e.clippingPlanes.map((n)=>new zn().fromJSON(n));if(e.clipIntersection!==void 0)this.clipIntersection=e.clipIntersection;if(e.clipShadows!==void 0)this.clipShadows=e.clipShadows;if(e.depthPacking!==void 0)this.depthPacking=e.depthPacking;if(e.blendSrc!==void 0)this.blendSrc=e.blendSrc;if(e.blendDst!==void 0)this.blendDst=e.blendDst;if(e.blendEquation!==void 0)this.blendEquation=e.blendEquation;if(e.blendSrcAlpha!==void 0)this.blendSrcAlpha=e.blendSrcAlpha;if(e.blendDstAlpha!==void 0)this.blendDstAlpha=e.blendDstAlpha;if(e.blendEquationAlpha!==void 0)this.blendEquationAlpha=e.blendEquationAlpha;if(e.blendColor!==void 0&&this.blendColor!==void 0)this.blendColor.setHex(e.blendColor);if(e.blendAlpha!==void 0)this.blendAlpha=e.blendAlpha;if(e.stencilWriteMask!==void 0)this.stencilWriteMask=e.stencilWriteMask;if(e.stencilFunc!==void 0)this.stencilFunc=e.stencilFunc;if(e.stencilRef!==void 0)this.stencilRef=e.stencilRef;if(e.stencilFuncMask!==void 0)this.stencilFuncMask=e.stencilFuncMask;if(e.stencilFail!==void 0)this.stencilFail=e.stencilFail;if(e.stencilZFail!==void 0)this.stencilZFail=e.stencilZFail;if(e.stencilZPass!==void 0)this.stencilZPass=e.stencilZPass;if(e.stencilWrite!==void 0)this.stencilWrite=e.stencilWrite;if(e.wireframe!==void 0)this.wireframe=e.wireframe;if(e.wireframeLinewidth!==void 0)this.wireframeLinewidth=e.wireframeLinewidth;if(e.wireframeLinecap!==void 0)this.wireframeLinecap=e.wireframeLinecap;if(e.wireframeLinejoin!==void 0)this.wireframeLinejoin=e.wireframeLinejoin;if(e.rotation!==void 0)this.rotation=e.rotation;if(e.linewidth!==void 0)this.linewidth=e.linewidth;if(e.linecap!==void 0)this.linecap=e.linecap;if(e.linejoin!==void 0)this.linejoin=e.linejoin;if(e.dashSize!==void 0)this.dashSize=e.dashSize;if(e.gapSize!==void 0)this.gapSize=e.gapSize;if(e.scale!==void 0)this.scale=e.scale;if(e.polygonOffset!==void 0)this.polygonOffset=e.polygonOffset;if(e.polygonOffsetFactor!==void 0)this.polygonOffsetFactor=e.polygonOffsetFactor;if(e.polygonOffsetUnits!==void 0)this.polygonOffsetUnits=e.polygonOffsetUnits;if(e.dithering!==void 0)this.dithering=e.dithering;if(e.alphaToCoverage!==void 0)this.alphaToCoverage=e.alphaToCoverage;if(e.premultipliedAlpha!==void 0)this.premultipliedAlpha=e.premultipliedAlpha;if(e.forceSinglePass!==void 0)this.forceSinglePass=e.forceSinglePass;if(e.allowOverride!==void 0)this.allowOverride=e.allowOverride;if(e.visible!==void 0)this.visible=e.visible;if(e.toneMapped!==void 0)this.toneMapped=e.toneMapped;if(e.userData!==void 0)this.userData=e.userData;if(e.vertexColors!==void 0)if(typeof e.vertexColors==="number")this.vertexColors=e.vertexColors>0;else this.vertexColors=e.vertexColors;if(e.size!==void 0)this.size=e.size;if(e.sizeAttenuation!==void 0)this.sizeAttenuation=e.sizeAttenuation;if(e.map!==void 0)this.map=t[e.map]||null;if(e.matcap!==void 0)this.matcap=t[e.matcap]||null;if(e.alphaMap!==void 0)this.alphaMap=t[e.alphaMap]||null;if(e.bumpMap!==void 0)this.bumpMap=t[e.bumpMap]||null;if(e.bumpScale!==void 0)this.bumpScale=e.bumpScale;if(e.normalMap!==void 0)this.normalMap=t[e.normalMap]||null;if(e.normalMapType!==void 0)this.normalMapType=e.normalMapType;if(e.normalScale!==void 0){let n=e.normalScale;if(Array.isArray(n)===!1)n=[n,n];this.normalScale=new Be().fromArray(n)}if(e.displacementMap!==void 0)this.displacementMap=t[e.displacementMap]||null;if(e.displacementScale!==void 0)this.displacementScale=e.displacementScale;if(e.displacementBias!==void 0)this.displacementBias=e.displacementBias;if(e.roughnessMap!==void 0)this.roughnessMap=t[e.roughnessMap]||null;if(e.metalnessMap!==void 0)this.metalnessMap=t[e.metalnessMap]||null;if(e.emissiveMap!==void 0)this.emissiveMap=t[e.emissiveMap]||null;if(e.emissiveIntensity!==void 0)this.emissiveIntensity=e.emissiveIntensity;if(e.specularMap!==void 0)this.specularMap=t[e.specularMap]||null;if(e.specularIntensityMap!==void 0)this.specularIntensityMap=t[e.specularIntensityMap]||null;if(e.specularColorMap!==void 0)this.specularColorMap=t[e.specularColorMap]||null;if(e.envMap!==void 0)this.envMap=t[e.envMap]||null;if(e.envMapRotation!==void 0)this.envMapRotation.fromArray(e.envMapRotation);if(e.envMapIntensity!==void 0)this.envMapIntensity=e.envMapIntensity;if(e.reflectivity!==void 0)this.reflectivity=e.reflectivity;if(e.refractionRatio!==void 0)this.refractionRatio=e.refractionRatio;if(e.lightMap!==void 0)this.lightMap=t[e.lightMap]||null;if(e.lightMapIntensity!==void 0)this.lightMapIntensity=e.lightMapIntensity;if(e.aoMap!==void 0)this.aoMap=t[e.aoMap]||null;if(e.aoMapIntensity!==void 0)this.aoMapIntensity=e.aoMapIntensity;if(e.gradientMap!==void 0)this.gradientMap=t[e.gradientMap]||null;if(e.clearcoatMap!==void 0)this.clearcoatMap=t[e.clearcoatMap]||null;if(e.clearcoatRoughnessMap!==void 0)this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null;if(e.clearcoatNormalMap!==void 0)this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null;if(e.clearcoatNormalScale!==void 0)this.clearcoatNormalScale=new Be().fromArray(e.clearcoatNormalScale);if(e.iridescenceMap!==void 0)this.iridescenceMap=t[e.iridescenceMap]||null;if(e.iridescenceThicknessMap!==void 0)this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null;if(e.transmissionMap!==void 0)this.transmissionMap=t[e.transmissionMap]||null;if(e.thicknessMap!==void 0)this.thicknessMap=t[e.thicknessMap]||null;if(e.anisotropyMap!==void 0)this.anisotropyMap=t[e.anisotropyMap]||null;if(e.sheenColorMap!==void 0)this.sheenColorMap=t[e.sheenColorMap]||null;if(e.sheenRoughnessMap!==void 0)this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null;return this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let i=t.length;n=Array(i);for(let r=0;r!==i;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){if(e===!0)this.version++}}var Bi=new F,ih=new F,pc=new F,mc=new F;class gr{constructor(e=new F,t=new F(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Bi)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);if(n<0)return t.copy(this.origin);return t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=Bi.subVectors(e,this.origin).dot(this.direction);if(t<0)return this.origin.distanceToSquared(e);return Bi.copy(this.origin).addScaledVector(this.direction,t),Bi.distanceToSquared(e)}distanceSqToSegment(e,t,n,i){ih.copy(e).add(t).multiplyScalar(0.5),pc.copy(t).sub(e).normalize(),mc.copy(this.origin).sub(ih);let r=e.distanceTo(t)*0.5,s=-this.direction.dot(pc),o=mc.dot(this.direction),a=-mc.dot(pc),c=mc.lengthSq(),l=Math.abs(1-s*s),u,h,d,f;if(l>0)if(u=s*a-o,h=s*o-a,f=r*l,u>=0)if(h>=-f)if(h<=f){let m=1/l;u*=m,h*=m,d=u*(u+s*h+2*o)+h*(s*u+h+2*a)+c}else h=r,u=Math.max(0,-(s*h+o)),d=-u*u+h*(h+2*a)+c;else h=-r,u=Math.max(0,-(s*h+o)),d=-u*u+h*(h+2*a)+c;else if(h<=-f)u=Math.max(0,-(-s*r+o)),h=u>0?-r:Math.min(Math.max(-r,-a),r),d=-u*u+h*(h+2*a)+c;else if(h<=f)u=0,h=Math.min(Math.max(-r,-a),r),d=h*(h+2*a)+c;else u=Math.max(0,-(s*r+o)),h=u>0?r:Math.min(Math.max(-r,-a),r),d=-u*u+h*(h+2*a)+c;else h=s>0?-r:r,u=Math.max(0,-(s*h+o)),d=-u*u+h*(h+2*a)+c;if(n)n.copy(this.origin).addScaledVector(this.direction,u);if(i)i.copy(ih).addScaledVector(pc,h);return d}intersectSphere(e,t){if(e.radius<0)return null;Bi.subVectors(e.center,this.origin);let n=Bi.dot(this.direction),i=Bi.dot(Bi)-n*n,r=e.radius*e.radius;if(i>r)return null;let s=Math.sqrt(r-i),o=n-s,a=n+s;if(a<0)return null;if(o<0)return this.at(a,t);return this.at(o,t)}intersectsSphere(e){if(e.radius<0)return!1;return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0){if(e.distanceToPoint(this.origin)===0)return 0;return null}let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);if(n===null)return null;return this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);if(t===0)return!0;if(e.normal.dot(this.direction)*t<0)return!0;return!1}intersectBox(e,t){let n,i,r,s,o,a,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,h=this.origin;if(c>=0)n=(e.min.x-h.x)*c,i=(e.max.x-h.x)*c;else n=(e.max.x-h.x)*c,i=(e.min.x-h.x)*c;if(l>=0)r=(e.min.y-h.y)*l,s=(e.max.y-h.y)*l;else r=(e.max.y-h.y)*l,s=(e.min.y-h.y)*l;if(n>s||r>i)return null;if(r>n||isNaN(n))n=r;if(s<i||isNaN(i))i=s;if(u>=0)o=(e.min.z-h.z)*u,a=(e.max.z-h.z)*u;else o=(e.max.z-h.z)*u,a=(e.min.z-h.z)*u;if(n>a||o>i)return null;if(o>n||n!==n)n=o;if(a<i||i!==i)i=a;if(i<0)return null;return this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,Bi)!==null}intersectTriangle(e,t,n,i,r){let s=this.origin,o=this.direction,{x:a,y:c,z:l}=o,u=e.x-s.x,h=e.y-s.y,d=e.z-s.z,f=t.x-s.x,m=t.y-s.y,_=t.z-s.z,p=n.x-s.x,g=n.y-s.y,M=n.z-s.z,T=Math.abs(a),v=Math.abs(c),S=Math.abs(l),E,R,x,w,H,C,N,ee,P,Z,G,k;if(T>=v&&T>=S)if(x=a,C=u,P=f,k=p,a>=0)E=c,R=l,w=h,H=d,N=m,ee=_,Z=g,G=M;else E=l,R=c,w=d,H=h,N=_,ee=m,Z=M,G=g;else if(v>=S)if(x=c,C=h,P=m,k=g,c>=0)E=l,R=a,w=d,H=u,N=_,ee=f,Z=M,G=p;else E=a,R=l,w=u,H=d,N=f,ee=_,Z=p,G=M;else if(x=l,C=d,P=_,k=M,l>=0)E=a,R=c,w=u,H=h,N=f,ee=m,Z=p,G=g;else E=c,R=a,w=h,H=u,N=m,ee=f,Z=g,G=p;if(x===0)return null;let W=E/x,B=R/x,Y=1/x,K=w-W*C,ge=H-B*C,de=N-W*P,fe=ee-B*P,he=Z-W*k,I=G-B*k,V=he*fe-I*de,q=K*I-ge*he,se=de*ge-fe*K;if(i){if(V<0||q<0||se<0)return null}else if((V<0||q<0||se<0)&&(V>0||q>0||se>0))return null;let ce=V+q+se;if(ce===0)return null;let ae=Y*(V*C+q*P+se*k);if(ce>0?ae<0:ae>0)return null;return this.at(ae/ce,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class wi extends yn{constructor(e){super();this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new He(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new xi,this.combine=0,this.reflectivity=1,this.refractionRatio=0.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}var J0=new Xe,Br=new gr,gc=new In,Q0=new F,_c=new F,xc=new F,vc=new F,rh=new F,yc=new F,ex=new F,bc=new F;class Mt extends _t{constructor(e=new ln,t=new wi){super();this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){if(super.copy(e,t),e.morphTargetInfluences!==void 0)this.morphTargetInfluences=e.morphTargetInfluences.slice();if(e.morphTargetDictionary!==void 0)this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary);return this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(e,t){let n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,s=n.morphTargetsRelative;t.fromBufferAttribute(i,e);let o=this.morphTargetInfluences;if(r&&o){yc.set(0,0,0);for(let a=0,c=r.length;a<c;a++){let l=o[a],u=r[a];if(l===0)continue;if(rh.fromBufferAttribute(u,e),s)yc.addScaledVector(rh,l);else yc.addScaledVector(rh.sub(t),l)}t.add(yc)}return t}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.material,r=this.matrixWorld;if(i===void 0)return;if(n.boundingSphere===null)n.computeBoundingSphere();if(gc.copy(n.boundingSphere),gc.applyMatrix4(r),Br.copy(e.ray).recast(e.near),gc.containsPoint(Br.origin)===!1){if(Br.intersectSphere(gc,Q0)===null)return;if(Br.origin.distanceToSquared(Q0)>(e.far-e.near)**2)return}if(J0.copy(r).invert(),Br.copy(e.ray).applyMatrix4(J0),n.boundingBox!==null){if(Br.intersectsBox(n.boundingBox)===!1)return}this._computeIntersections(e,t,Br)}_computeIntersections(e,t,n){let i,r=this.geometry,s=this.material,o=r.index,a=r.attributes.position,c=r.attributes.uv,l=r.attributes.uv1,u=r.attributes.normal,{groups:h,drawRange:d}=r;if(o!==null)if(Array.isArray(s))for(let f=0,m=h.length;f<m;f++){let _=h[f],p=s[_.materialIndex],g=Math.max(_.start,d.start),M=Math.min(o.count,Math.min(_.start+_.count,d.start+d.count));for(let T=g,v=M;T<v;T+=3){let S=o.getX(T),E=o.getX(T+1),R=o.getX(T+2);if(i=Sc(this,p,e,n,c,l,u,S,E,R),i)i.faceIndex=Math.floor(T/3),i.face.materialIndex=_.materialIndex,t.push(i)}}else{let f=Math.max(0,d.start),m=Math.min(o.count,d.start+d.count);for(let _=f,p=m;_<p;_+=3){let g=o.getX(_),M=o.getX(_+1),T=o.getX(_+2);if(i=Sc(this,s,e,n,c,l,u,g,M,T),i)i.faceIndex=Math.floor(_/3),t.push(i)}}else if(a!==void 0)if(Array.isArray(s))for(let f=0,m=h.length;f<m;f++){let _=h[f],p=s[_.materialIndex],g=Math.max(_.start,d.start),M=Math.min(a.count,Math.min(_.start+_.count,d.start+d.count));for(let T=g,v=M;T<v;T+=3){let S=T,E=T+1,R=T+2;if(i=Sc(this,p,e,n,c,l,u,S,E,R),i)i.faceIndex=Math.floor(T/3),i.face.materialIndex=_.materialIndex,t.push(i)}}else{let f=Math.max(0,d.start),m=Math.min(a.count,d.start+d.count);for(let _=f,p=m;_<p;_+=3){let g=_,M=_+1,T=_+2;if(i=Sc(this,s,e,n,c,l,u,g,M,T),i)i.faceIndex=Math.floor(_/3),t.push(i)}}}}function YM(e,t,n,i,r,s,o,a){let c;if(t.side===1)c=i.intersectTriangle(o,s,r,!0,a);else c=i.intersectTriangle(r,s,o,t.side===0,a);if(c===null)return null;bc.copy(a),bc.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(bc);if(l<n.near||l>n.far)return null;return{distance:l,point:bc.clone(),object:e}}function Sc(e,t,n,i,r,s,o,a,c,l){e.getVertexPosition(a,_c),e.getVertexPosition(c,xc),e.getVertexPosition(l,vc);let u=YM(e,t,n,i,_c,xc,vc,ex);if(u){let h=new F;if(kn.getBarycoord(ex,_c,xc,vc,h),r)u.uv=kn.getInterpolatedAttribute(r,a,c,l,h,new Be);if(s)u.uv1=kn.getInterpolatedAttribute(s,a,c,l,h,new Be);if(o){if(u.normal=kn.getInterpolatedAttribute(o,a,c,l,h,new F),u.normal.dot(i.direction)>0)u.normal.multiplyScalar(-1)}let d={a,b:c,c:l,normal:new F,materialIndex:0};kn.getNormal(_c,xc,vc,d.normal),u.face=d,u.barycoord=h}return u}var Lo=new pt,tx=new pt,nx=new pt,KM=new pt,ix=new Xe,wc=new F,sh=new In,rx=new Xe,oh=new gr;class Jc extends Mt{constructor(e,t){super(e,t);this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new Xe,this.bindMatrixInverse=new Xe,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;if(this.boundingBox===null)this.boundingBox=new Vt;this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,wc),this.boundingBox.expandByPoint(wc)}computeBoundingSphere(){let e=this.geometry;if(this.boundingSphere===null)this.boundingSphere=new In;this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,wc),this.boundingSphere.expandByPoint(wc)}copy(e,t){if(super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null)this.boundingBox=e.boundingBox.clone();if(e.boundingSphere!==null)this.boundingSphere=e.boundingSphere.clone();return this}raycast(e,t){let n=this.material,i=this.matrixWorld;if(n===void 0)return;if(this.boundingSphere===null)this.computeBoundingSphere();if(sh.copy(this.boundingSphere),sh.applyMatrix4(i),e.ray.intersectsSphere(sh)===!1)return;if(rx.copy(i).invert(),oh.copy(e.ray).applyMatrix4(rx),this.boundingBox!==null){if(oh.intersectsBox(this.boundingBox)===!1)return}this._computeIntersections(e,t,oh)}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){if(this.skeleton=e,t===void 0)this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld;this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let e=new pt,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);let r=1/e.manhattanLength();if(r!==1/0)e.multiplyScalar(r);else e.set(1,0,0,0);t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.bindMode==="attached")this.bindMatrixInverse.copy(this.matrixWorld).invert();else if(this.bindMode==="detached")this.bindMatrixInverse.copy(this.bindMatrix).invert();else Ue("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let n=this.skeleton,i=this.geometry;if(tx.fromBufferAttribute(i.attributes.skinIndex,e),nx.fromBufferAttribute(i.attributes.skinWeight,e),t.isVector4)Lo.copy(t),t.set(0,0,0,0);else Lo.set(...t,1),t.set(0,0,0);Lo.applyMatrix4(this.bindMatrix);for(let r=0;r<4;r++){let s=nx.getComponent(r);if(s!==0){let o=tx.getComponent(r);ix.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(KM.copy(Lo).applyMatrix4(ix),s)}}if(t.isVector4)t.w=Lo.w;return t.applyMatrix4(this.bindMatrixInverse)}}class qo extends _t{constructor(){super();this.isBone=!0,this.type="Bone"}}class Yo extends Ot{constructor(e=null,t=1,n=1,i,r,s,o,a,c=1003,l=1003,u,h){super(null,s,o,a,c,l,i,r,u,h);this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}var sx=new Xe,JM=new Xe;class Ko{constructor(e=[],t=[]){this.uuid=Qn(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){Ue("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new Xe)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let n=new Xe;if(this.bones[e])n.copy(this.bones[e].matrixWorld).invert();this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];if(n)n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];if(n){if(n.parent&&n.parent.isBone)n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld);else n.matrix.copy(n.matrixWorld);n.matrix.decompose(n.position,n.quaternion,n.scale)}}}update(){let e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let r=0,s=e.length;r<s;r++){let o=e[r]?e[r].matrixWorld:JM;sx.multiplyMatrices(o,t[r]),sx.toArray(n,r*16)}if(i!==null)i.needsUpdate=!0}clone(){return new Ko(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let n=new Yo(t,e,e,1023,1015);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){let i=this.bones[t];if(i.name===e)return i}return}dispose(){if(this.boneTexture!==null)this.boneTexture.dispose(),this.boneTexture=null}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){let r=e.bones[n],s=t[r];if(s===void 0)Ue("Skeleton: No bone found with UUID:",r),s=new qo;this.bones.push(s),this.boneInverses.push(new Xe().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){let e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,n=this.boneInverses;for(let i=0,r=t.length;i<r;i++){let s=t[i];e.bones.push(s.uuid);let o=n[i];e.boneInverses.push(o.toArray())}return e}}class ur extends Kt{constructor(e,t,n,i=1){super(e,t,n);this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}var bs=new Xe,ox=new Xe,Mc=[],ax=new Vt,QM=new Xe,No=new Mt,Do=new In;class ks extends Mt{constructor(e,t,n){super(e,t);this.isInstancedMesh=!0,this.instanceMatrix=new ur(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,QM)}computeBoundingBox(){let e=this.geometry,t=this.count;if(this.boundingBox===null)this.boundingBox=new Vt;if(e.boundingBox===null)e.computeBoundingBox();this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,bs),ax.copy(e.boundingBox).applyMatrix4(bs),this.boundingBox.union(ax)}computeBoundingSphere(){let e=this.geometry,t=this.count;if(this.boundingSphere===null)this.boundingSphere=new In;if(e.boundingSphere===null)e.computeBoundingSphere();this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,bs),Do.copy(e.boundingSphere).applyMatrix4(bs),this.boundingSphere.union(Do)}copy(e,t){if(super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null)this.morphTexture=e.morphTexture.clone();if(e.instanceColor!==null)this.instanceColor=e.instanceColor.clone();if(this.count=e.count,e.boundingBox!==null)this.boundingBox=e.boundingBox.clone();if(e.boundingSphere!==null)this.boundingSphere=e.boundingSphere.clone();return this}getColorAt(e,t){if(this.instanceColor===null)return t.setRGB(1,1,1);else return t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){return t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){let n=t.morphTargetInfluences,i=this.morphTexture.source.data.data,r=n.length+1,s=e*r+1;for(let o=0;o<n.length;o++)n[o]=i[s+o]}raycast(e,t){let n=this.matrixWorld,i=this.count;if(No.geometry=this.geometry,No.material=this.material,No.material===void 0)return;if(this.boundingSphere===null)this.computeBoundingSphere();if(Do.copy(this.boundingSphere),Do.applyMatrix4(n),e.ray.intersectsSphere(Do)===!1)return;for(let r=0;r<i;r++){this.getMatrixAt(r,bs),ox.multiplyMatrices(n,bs),No.matrixWorld=ox,No.raycast(e,Mc);for(let s=0,o=Mc.length;s<o;s++){let a=Mc[s];a.instanceId=r,a.object=this,t.push(a)}Mc.length=0}}setColorAt(e,t){if(this.instanceColor===null)this.instanceColor=new ur(new Float32Array(this.instanceMatrix.count*3).fill(1),3);return t.toArray(this.instanceColor.array,e*3),this}setMatrixAt(e,t){return t.toArray(this.instanceMatrix.array,e*16),this}setMorphAt(e,t){let n=t.morphTargetInfluences,i=n.length+1;if(this.morphTexture===null)this.morphTexture=new Yo(new Float32Array(i*this.count),i,this.count,1028,1015);let r=this.morphTexture.source.data.data,s=0;for(let c=0;c<n.length;c++)s+=n[c];let o=this.geometry.morphTargetsRelative?1:1-s,a=i*e;return r[a]=o,r.set(n,a+1),this}updateMorphTargets(){}dispose(){if(super.dispose(),this.morphTexture!==null)this.morphTexture.dispose(),this.morphTexture=null}}var Gr=new In,eE=new Be(0.5,0.5),Ec=new F;class Jo{constructor(e=new zn,t=new zn,n=new zn,i=new zn,r=new zn,s=new zn){this.planes=[e,t,n,i,r,s]}set(e,t,n,i,r,s){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(s),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=2000,n=!1){let i=this.planes,r=e.elements,s=r[0],o=r[1],a=r[2],c=r[3],l=r[4],u=r[5],h=r[6],d=r[7],f=r[8],m=r[9],_=r[10],p=r[11],g=r[12],M=r[13],T=r[14],v=r[15];if(i[0].setComponents(c-s,d-l,p-f,v-g).normalize(),i[1].setComponents(c+s,d+l,p+f,v+g).normalize(),i[2].setComponents(c+o,d+u,p+m,v+M).normalize(),i[3].setComponents(c-o,d-u,p-m,v-M).normalize(),n)i[4].setComponents(a,h,_,T).normalize(),i[5].setComponents(c-a,d-h,p-_,v-T).normalize();else if(i[4].setComponents(c-a,d-h,p-_,v-T).normalize(),t===2000)i[5].setComponents(c+a,d+h,p+_,v+T).normalize();else if(t===2001)i[5].setComponents(a,h,_,T).normalize();else throw Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0){if(e.boundingSphere===null)e.computeBoundingSphere();Gr.copy(e.boundingSphere).applyMatrix4(e.matrixWorld)}else{let t=e.geometry;if(t.boundingSphere===null)t.computeBoundingSphere();Gr.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Gr)}intersectsSprite(e){Gr.center.set(0,0,0);let t=eE.distanceTo(e.center);return Gr.radius=0.7071067811865476+t,Gr.applyMatrix4(e.matrixWorld),this.intersectsSphere(Gr)}intersectsSphere(e){let t=this.planes,n=e.center,i=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let i=t[n];if(Ec.x=i.normal.x>0?e.max.x:e.min.x,Ec.y=i.normal.y>0?e.max.y:e.min.y,Ec.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Ec)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Qo extends yn{constructor(e){super();this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new He(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}var Nc=new F,Dc=new F,cx=new Xe,Oo=new gr,Tc=new In,ah=new F,lx=new F;class _r extends _t{constructor(e=new ln,t=new Qo){super();this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let i=1,r=t.count;i<r;i++)Nc.fromBufferAttribute(t,i-1),Dc.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=Nc.distanceTo(Dc);e.setAttribute("lineDistance",new vn(n,1))}else Ue("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.matrixWorld,r=e.params.Line.threshold,s=n.drawRange;if(n.boundingSphere===null)n.computeBoundingSphere();if(Tc.copy(n.boundingSphere),Tc.applyMatrix4(i),Tc.radius+=r,e.ray.intersectsSphere(Tc)===!1)return;cx.copy(i).invert(),Oo.copy(e.ray).applyMatrix4(cx);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=o*o,c=this.isLineSegments?2:1,l=n.index,h=n.attributes.position;if(l!==null){let d=Math.max(0,s.start),f=Math.min(l.count,s.start+s.count);for(let m=d,_=f-1;m<_;m+=c){let p=l.getX(m),g=l.getX(m+1),M=Ac(this,e,Oo,a,p,g,m);if(M)t.push(M)}if(this.isLineLoop){let m=l.getX(f-1),_=l.getX(d),p=Ac(this,e,Oo,a,m,_,f-1);if(p)t.push(p)}}else{let d=Math.max(0,s.start),f=Math.min(h.count,s.start+s.count);for(let m=d,_=f-1;m<_;m+=c){let p=Ac(this,e,Oo,a,m,m+1,m);if(p)t.push(p)}if(this.isLineLoop){let m=Ac(this,e,Oo,a,f-1,d,f-1);if(m)t.push(m)}}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function Ac(e,t,n,i,r,s,o){let a=e.geometry.attributes.position;if(Nc.fromBufferAttribute(a,r),Dc.fromBufferAttribute(a,s),n.distanceSqToSegment(Nc,Dc,ah,lx)>i)return;ah.applyMatrix4(e.matrixWorld);let l=t.ray.origin.distanceTo(ah);if(l<t.near||l>t.far)return;return{distance:l,point:lx.clone().applyMatrix4(e.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:e}}var ux=new F,hx=new F;class Qc extends _r{constructor(e,t){super(e,t);this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let i=0,r=t.count;i<r;i+=2)ux.fromBufferAttribute(t,i),hx.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+ux.distanceTo(hx);e.setAttribute("lineDistance",new vn(n,1))}else Ue("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class el extends _r{constructor(e,t){super(e,t);this.isLineLoop=!0,this.type="LineLoop"}}class ea extends yn{constructor(e){super();this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new He(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}var dx=new Xe,uh=new gr,Rc=new In,Cc=new F;class Bs extends _t{constructor(e=new ln,t=new ea){super();this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.matrixWorld,r=e.params.Points.threshold,s=n.drawRange;if(n.boundingSphere===null)n.computeBoundingSphere();if(Rc.copy(n.boundingSphere),Rc.applyMatrix4(i),Rc.radius+=r,e.ray.intersectsSphere(Rc)===!1)return;dx.copy(i).invert(),uh.copy(e.ray).applyMatrix4(dx);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=o*o,c=n.index,u=n.attributes.position;if(c!==null){let h=Math.max(0,s.start),d=Math.min(c.count,s.start+s.count);for(let f=h,m=d;f<m;f++){let _=c.getX(f);Cc.fromBufferAttribute(u,_),fx(Cc,_,a,i,e,t,this)}}else{let h=Math.max(0,s.start),d=Math.min(u.count,s.start+s.count);for(let f=h,m=d;f<m;f++)Cc.fromBufferAttribute(u,f),fx(Cc,f,a,i,e,t,this)}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function fx(e,t,n,i,r,s,o){let a=uh.distanceSqToPoint(e);if(a<n){let c=new F;uh.closestPointToPoint(e,c),c.applyMatrix4(i);let l=r.ray.origin.distanceTo(c);if(l<r.near||l>r.far)return;s.push({distance:l,distanceToRay:Math.sqrt(a),point:c,index:t,face:null,faceIndex:null,barycoord:null,object:o})}}class tl extends Ot{constructor(e=[],t=301,n,i,r,s,o,a,c,l){super(e,t,n,i,r,s,o,a,c,l);this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Yr extends Ot{constructor(e,t,n=1014,i,r,s,o=1003,a=1003,c,l=1026,u=1){if(l!==1026&&l!==1027)throw Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let h={width:e,height:t,depth:u};super(h,i,r,s,o,a,l,n,c);this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Zo(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}}class pd extends Yr{constructor(e,t=1014,n=301,i,r,s=1003,o=1003,a,c=1026){let l={width:e,height:e,depth:1},u=[l,l,l,l,l,l];super(e,e,t,n,i,r,s,o,a,c);this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class nl extends Ot{constructor(e=null){super();this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class xr extends ln{constructor(e=1,t=1,n=1,i=1,r=1,s=1){super();this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:s};let o=this;i=Math.floor(i),r=Math.floor(r),s=Math.floor(s);let a=[],c=[],l=[],u=[],h=0,d=0;f("z","y","x",-1,-1,n,t,e,s,r,0),f("z","y","x",1,-1,n,t,-e,s,r,1),f("x","z","y",1,1,e,n,t,i,s,2),f("x","z","y",1,-1,e,n,-t,i,s,3),f("x","y","z",1,-1,e,t,n,i,r,4),f("x","y","z",-1,-1,e,t,-n,i,r,5),this.setIndex(a),this.setAttribute("position",new vn(c,3)),this.setAttribute("normal",new vn(l,3)),this.setAttribute("uv",new vn(u,2));function f(m,_,p,g,M,T,v,S,E,R,x){let w=T/E,H=v/R,C=T/2,N=v/2,ee=S/2,P=E+1,Z=R+1,G=0,k=0,W=new F;for(let B=0;B<Z;B++){let Y=B*H-N;for(let K=0;K<P;K++){let ge=K*w-C;W[m]=ge*g,W[_]=Y*M,W[p]=ee,c.push(W.x,W.y,W.z),W[m]=0,W[_]=0,W[p]=S>0?1:-1,l.push(W.x,W.y,W.z),u.push(K/E),u.push(1-B/R),G+=1}}for(let B=0;B<R;B++)for(let Y=0;Y<E;Y++){let K=h+Y+P*B,ge=h+Y+P*(B+1),de=h+(Y+1)+P*(B+1),fe=h+(Y+1)+P*B;a.push(K,ge,fe),a.push(ge,de,fe),k+=6}o.addGroup(d,k,x),d+=k,h+=G}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new xr(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class ta extends ln{constructor(e=1,t=1,n=1,i=1){super();this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};let r=e/2,s=t/2,o=Math.floor(n),a=Math.floor(i),c=o+1,l=a+1,u=e/o,h=t/a,d=[],f=[],m=[],_=[];for(let p=0;p<l;p++){let g=p*h-s;for(let M=0;M<c;M++){let T=M*u-r;f.push(T,-g,0),m.push(0,0,1),_.push(M/o),_.push(1-p/a)}}for(let p=0;p<a;p++)for(let g=0;g<o;g++){let M=g+c*p,T=g+c*(p+1),v=g+1+c*(p+1),S=g+1+c*p;d.push(M,T,S),d.push(T,v,S)}this.setIndex(d),this.setAttribute("position",new vn(f,3)),this.setAttribute("normal",new vn(m,3)),this.setAttribute("uv",new vn(_,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ta(e.width,e.height,e.widthSegments,e.heightSegments)}}function Kr(e){let t={};for(let n in e){t[n]={};for(let i in e[n]){let r=e[n][i];if(px(r))if(r.isRenderTargetTexture)Ue("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[n][i]=null;else t[n][i]=r.clone();else if(Array.isArray(r))if(px(r[0])){let s=[];for(let o=0,a=r.length;o<a;o++)s[o]=r[o].clone();t[n][i]=s}else t[n][i]=r.slice();else t[n][i]=r}}return t}function un(e){let t={};for(let n=0;n<e.length;n++){let i=Kr(e[n]);for(let r in i)t[r]=i[r]}return t}function px(e){return e&&(e.isColor||e.isMatrix3||e.isMatrix4||e.isVector2||e.isVector3||e.isVector4||e.isTexture||e.isQuaternion)}function tE(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}function md(e){let t=e.getRenderTarget();if(t===null)return e.outputColorSpace;if(t.isXRRenderTarget===!0)return t.texture.colorSpace;return Ke.workingColorSpace}var bv={clone:Kr,merge:un},nE=`void main() {
62
+ */var Dt=Uint8Array,En=Uint16Array,Nu=Int32Array,sc=new Dt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),oc=new Dt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Au=new Dt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),o0=function(e,t){var n=new En(31);for(var i=0;i<31;++i)n[i]=t+=1<<e[i-1];var r=new Nu(n[30]);for(var i=1;i<30;++i)for(var s=n[i];s<n[i+1];++s)r[s]=s-n[i]<<5|i;return{b:n,r}},a0=o0(sc,2),{b:c0,r:Ru}=a0;c0[28]=258,Ru[258]=28;var l0=o0(oc,0),{b:zw,r:e0}=l0,Cu=new En(32768);for(tt=0;tt<32768;++tt)di=(tt&43690)>>1|(tt&21845)<<1,di=(di&52428)>>2|(di&13107)<<2,di=(di&61680)>>4|(di&3855)<<4,Cu[tt]=((di&65280)>>8|(di&255)<<8)>>1;var di,tt,pi=function(e,t,n){var i=e.length,r=0,s=new En(t);for(;r<i;++r)if(e[r])++s[e[r]-1];var o=new En(t);for(r=1;r<t;++r)o[r]=o[r-1]+s[r-1]<<1;var a;if(n){a=new En(1<<t);var c=15-t;for(r=0;r<i;++r)if(e[r]){var l=r<<4|e[r],u=t-e[r],h=o[e[r]-1]++<<u;for(var d=h|(1<<u)-1;h<=d;++h)a[Cu[h]>>c]=l}}else{a=new En(i);for(r=0;r<i;++r)if(e[r])a[r]=Cu[o[e[r]-1]++]>>15-e[r]}return a},nr=new Dt(288);for(tt=0;tt<144;++tt)nr[tt]=8;var tt;for(tt=144;tt<256;++tt)nr[tt]=9;var tt;for(tt=256;tt<280;++tt)nr[tt]=7;var tt;for(tt=280;tt<288;++tt)nr[tt]=8;var tt,So=new Dt(32);for(tt=0;tt<32;++tt)So[tt]=5;var tt,kw=pi(nr,9,0),Bw=pi(nr,9,1),Gw=pi(So,5,0),Hw=pi(So,5,1),wu=function(e){var t=e[0];for(var n=1;n<e.length;++n)if(e[n]>t)t=e[n];return t},$n=function(e,t,n){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(t&7)&n},Mu=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},Du=function(e){return(e+7)/8|0},wo=function(e,t,n){if(t==null||t<0)t=0;if(n==null||n>e.length)n=e.length;return new Dt(e.subarray(t,n))};var Vw=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],mn=function(e,t,n){var i=Error(t||Vw[e]);if(i.code=e,Error.captureStackTrace)Error.captureStackTrace(i,mn);if(!n)throw i;return i},$w=function(e,t,n,i){var r=e.length,s=i?i.length:0;if(!r||t.f&&!t.l)return n||new Dt(0);var o=!n,a=o||t.i!=2,c=t.i;if(o)n=new Dt(r*3);var l=function(ue){var $e=n.length;if(ue>$e){var Ce=new Dt(Math.max($e*2,ue));Ce.set(n),n=Ce}},u=t.f||0,h=t.p||0,d=t.b||0,{l:f,d:m,m:_,n:p}=t,g=r*8;do{if(!f){u=$n(e,h,1);var M=$n(e,h+1,3);if(h+=3,!M){var T=Du(h)+4,v=e[T-4]|e[T-3]<<8,S=T+v;if(S>r){if(c)mn(0);break}if(a)l(d+v);n.set(e.subarray(T,S),d),t.b=d+=v,t.p=h=S*8,t.f=u;continue}else if(M==1)f=Bw,m=Hw,_=9,p=5;else if(M==2){var E=$n(e,h,31)+257,R=$n(e,h+10,15)+4,x=E+$n(e,h+5,31)+1;h+=14;var w=new Dt(x),G=new Dt(19);for(var C=0;C<R;++C)G[Au[C]]=$n(e,h+C*3,7);h+=R*3;var D=wu(G),ee=(1<<D)-1,L=pi(G,D,1);for(var C=0;C<x;){var W=L[$n(e,h,ee)];h+=W&15;var T=W>>4;if(T<16)w[C++]=T;else{var B=0,P=0;if(T==16)P=3+$n(e,h,3),h+=2,B=w[C-1];else if(T==17)P=3+$n(e,h,7),h+=3;else if(T==18)P=11+$n(e,h,127),h+=7;while(P--)w[C++]=B}}var J=w.subarray(0,E),H=w.subarray(E);_=wu(J),p=wu(H),f=pi(J,_,1),m=pi(H,p,1)}else mn(1);if(h>g){if(c)mn(0);break}}if(a)l(d+131072);var q=(1<<_)-1,Q=(1<<p)-1,ge=h;for(;;ge=h){var B=f[Mu(e,h)&q],he=B>>4;if(h+=B&15,h>g){if(c)mn(0);break}if(!B)mn(2);if(he<256)n[d++]=he;else if(he==256){ge=h,f=null;break}else{var de=he-254;if(he>264){var C=he-257,fe=sc[C];de=$n(e,h,(1<<fe)-1)+c0[C],h+=fe}var I=m[Mu(e,h)&Q],V=I>>4;if(!I)mn(3);h+=I&15;var H=zw[V];if(V>3){var fe=oc[V];H+=Mu(e,h)&(1<<fe)-1,h+=fe}if(h>g){if(c)mn(0);break}if(a)l(d+131072);var j=d+de;if(d<H){var re=s-H,oe=Math.min(H,j);if(re+d<0)mn(3);for(;d<oe;++d)n[d]=i[re+d]}for(;d<j;++d)n[d]=n[d-H]}}if(t.l=f,t.p=ge,t.b=d,t.f=u,f)u=1,t.m=_,t.d=m,t.n=p}while(!u);return d!=n.length&&o?wo(n,0,d):n.subarray(0,d)},Ui=function(e,t,n){n<<=t&7;var i=t/8|0;e[i]|=n,e[i+1]|=n>>8},yo=function(e,t,n){n<<=t&7;var i=t/8|0;e[i]|=n,e[i+1]|=n>>8,e[i+2]|=n>>16},Eu=function(e,t){var n=[];for(var i=0;i<e.length;++i)if(e[i])n.push({s:i,f:e[i]});var r=n.length,s=n.slice();if(!r)return{t:h0,l:0};if(r==1){var o=new Dt(n[0].s+1);return o[n[0].s]=1,{t:o,l:1}}n.sort(function(S,E){return S.f-E.f}),n.push({s:-1,f:25001});var a=n[0],c=n[1],l=0,u=1,h=2;n[0]={s:-1,f:a.f+c.f,l:a,r:c};while(u!=r-1)a=n[n[l].f<n[h].f?l++:h++],c=n[l!=u&&n[l].f<n[h].f?l++:h++],n[u++]={s:-1,f:a.f+c.f,l:a,r:c};var d=s[0].s;for(var i=1;i<r;++i)if(s[i].s>d)d=s[i].s;var f=new En(d+1),m=Iu(n[u-1],f,0);if(m>t){var i=0,_=0,p=m-t,g=1<<p;s.sort(function(E,R){return f[R.s]-f[E.s]||E.f-R.f});for(;i<r;++i){var M=s[i].s;if(f[M]>t)_+=g-(1<<m-f[M]),f[M]=t;else break}_>>=p;while(_>0){var T=s[i].s;if(f[T]<t)_-=1<<t-f[T]++-1;else++i}for(;i>=0&&_;--i){var v=s[i].s;if(f[v]==t)--f[v],++_}m=t}return{t:new Dt(f),l:m}},Iu=function(e,t,n){return e.s==-1?Math.max(Iu(e.l,t,n+1),Iu(e.r,t,n+1)):t[e.s]=n},t0=function(e){var t=e.length;while(t&&!e[--t]);var n=new En(++t),i=0,r=e[0],s=1,o=function(c){n[i++]=c};for(var a=1;a<=t;++a)if(e[a]==r&&a!=t)++s;else{if(!r&&s>2){for(;s>138;s-=138)o(32754);if(s>2)o(s>10?s-11<<5|28690:s-3<<5|12305),s=0}else if(s>3){o(r),--s;for(;s>6;s-=6)o(8304);if(s>2)o(s-3<<5|8208),s=0}while(s--)o(r);s=1,r=e[a]}return{c:n.subarray(0,i),n:t}},bo=function(e,t){var n=0;for(var i=0;i<t.length;++i)n+=e[i]*t[i];return n},u0=function(e,t,n){var i=n.length,r=Du(t+2);e[r]=i&255,e[r+1]=i>>8,e[r+2]=e[r]^255,e[r+3]=e[r+1]^255;for(var s=0;s<i;++s)e[r+s+4]=n[s];return(r+4+i)*8},n0=function(e,t,n,i,r,s,o,a,c,l,u){Ui(t,u++,n),++r[256];var h=Eu(r,15),{t:d,l:f}=h,m=Eu(s,15),{t:_,l:p}=m,g=t0(d),{c:M,n:T}=g,v=t0(_),{c:S,n:E}=v,R=new En(19);for(var x=0;x<M.length;++x)++R[M[x]&31];for(var x=0;x<S.length;++x)++R[S[x]&31];var w=Eu(R,7),{t:G,l:C}=w,D=19;for(;D>4&&!G[Au[D-1]];--D);var ee=l+5<<3,L=bo(r,nr)+bo(s,So)+o,W=bo(r,d)+bo(s,_)+o+14+3*D+bo(R,G)+2*R[16]+3*R[17]+7*R[18];if(c>=0&&ee<=L&&ee<=W)return u0(t,u,e.subarray(c,c+l));var B,P,J,H;if(Ui(t,u,1+(W<L)),u+=2,W<L){B=pi(d,f,0),P=d,J=pi(_,p,0),H=_;var q=pi(G,C,0);Ui(t,u,T-257),Ui(t,u+5,E-1),Ui(t,u+10,D-4),u+=14;for(var x=0;x<D;++x)Ui(t,u+3*x,G[Au[x]]);u+=3*D;var Q=[M,S];for(var ge=0;ge<2;++ge){var he=Q[ge];for(var x=0;x<he.length;++x){var de=he[x]&31;if(Ui(t,u,q[de]),u+=G[de],de>15)Ui(t,u,he[x]>>5&127),u+=he[x]>>12}}}else B=kw,P=nr,J=Gw,H=So;for(var x=0;x<a;++x){var fe=i[x];if(fe>255){var de=fe>>18&31;if(yo(t,u,B[de+257]),u+=P[de+257],de>7)Ui(t,u,fe>>23&31),u+=sc[de];var I=fe&31;if(yo(t,u,J[I]),u+=H[I],I>3)yo(t,u,fe>>5&8191),u+=oc[I]}else yo(t,u,B[fe]),u+=P[fe]}return yo(t,u,B[256]),u+P[256]},Ww=new Nu([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),h0=new Dt(0),Zw=function(e,t,n,i,r,s){var o=s.z||e.length,a=new Dt(i+o+5*(1+Math.ceil(o/7000))+r),c=a.subarray(i,a.length-r),l=s.l,u=(s.r||0)&7;if(t){if(u)c[0]=s.r>>3;var h=Ww[t-1],d=h>>13,f=h&8191,m=(1<<n)-1,_=s.p||new En(32768),p=s.h||new En(m+1),g=Math.ceil(n/3),M=2*g,T=function(He){return(e[He]^e[He+1]<<g^e[He+2]<<M)&m},v=new Nu(25000),S=new En(288),E=new En(32),R=0,x=0,w=s.i||0,G=0,C=s.w||0,D=0;for(;w+2<o;++w){var ee=T(w),L=w&32767,W=p[ee];if(_[L]=W,p[ee]=L,C<=w){var B=o-w;if((R>7000||G>24576)&&(B>423||!l)){u=n0(e,c,0,v,S,E,x,G,D,w-D,u),G=R=x=0,D=w;for(var P=0;P<286;++P)S[P]=0;for(var P=0;P<30;++P)E[P]=0}var J=2,H=0,q=f,Q=L-W&32767;if(B>2&&ee==T(w-Q)){var ge=Math.min(d,B)-1,he=Math.min(32767,w),de=Math.min(258,B);while(Q<=he&&--q&&L!=W){if(e[w+J]==e[w+J-Q]){var fe=0;for(;fe<de&&e[w+fe]==e[w+fe-Q];++fe);if(fe>J){if(J=fe,H=Q,fe>ge)break;var I=Math.min(Q,fe-2),V=0;for(var P=0;P<I;++P){var j=w-Q+P&32767,re=_[j],oe=j-re&32767;if(oe>V)V=oe,W=j}}}L=W,W=_[L],Q+=L-W&32767}}if(H){v[G++]=268435456|Ru[J]<<18|e0[H];var ue=Ru[J]&31,$e=e0[H]&31;x+=sc[ue]+oc[$e],++S[257+ue],++E[$e],C=w+J,++R}else v[G++]=e[w],++S[e[w]]}}for(w=Math.max(w,C);w<o;++w)v[G++]=e[w],++S[e[w]];if(u=n0(e,c,l,v,S,E,x,G,D,w-D,u),!l)s.r=u&7|c[u/8|0]<<3,u-=7,s.h=p,s.p=_,s.i=w,s.w=C}else{for(var w=s.w||0;w<o+l;w+=65535){var Ce=w+65535;if(Ce>=o)c[u/8|0]=l,Ce=o;u=u0(c,u+1,e.subarray(w,Ce))}s.i=o}return wo(a,0,i+Du(u)+r)},Xw=function(){var e=new Int32Array(256);for(var t=0;t<256;++t){var n=t,i=9;while(--i)n=(n&1&&-306674912)^n>>>1;e[t]=n}return e}(),jw=function(){var e=-1;return{p:function(t){var n=e;for(var i=0;i<t.length;++i)n=Xw[n&255^t[i]]^n>>>8;e=n},d:function(){return~e}}};var qw=function(e,t,n,i,r){if(!r){if(r={l:1},t.dictionary){var s=t.dictionary.subarray(-32768),o=new Dt(s.length+e.length);o.set(s),o.set(e,s.length),e=o,r.w=s.length}}return Zw(e,t.level==null?6:t.level,t.mem==null?r.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,n,i,r)},d0=function(e,t){var n={};for(var i in e)n[i]=e[i];for(var i in t)n[i]=t[i];return n};var fi=function(e,t){return e[t]|e[t+1]<<8},Wn=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},Tu=function(e,t){return Wn(e,t)+Wn(e,t+4)*4294967296},rn=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function Yw(e,t){return qw(e,t||{},0,0)}function Kw(e,t){return $w(e,{i:2},t&&t.out,t&&t.dictionary)}var f0=function(e,t,n,i){for(var r in e){var s=e[r],o=t+r,a=i;if(Array.isArray(s))a=d0(i,s[1]),s=s[0];if(s instanceof Dt)n[o]=[s,a];else n[o+="/"]=[new Dt(0),a],f0(s,o,n,i)}},i0=typeof TextEncoder<"u"&&new TextEncoder,Pu=typeof TextDecoder<"u"&&new TextDecoder,Jw=0;try{Pu.decode(h0,{stream:!0}),Jw=1}catch(e){}var Qw=function(e){for(var t="",n=0;;){var i=e[n++],r=(i>127)+(i>223)+(i>239);if(n+r>e.length)return{s:t,r:wo(e,n-1)};if(!r)t+=String.fromCharCode(i);else if(r==3)i=((i&15)<<18|(e[n++]&63)<<12|(e[n++]&63)<<6|e[n++]&63)-65536,t+=String.fromCharCode(55296|i>>10,56320|i&1023);else if(r&1)t+=String.fromCharCode((i&31)<<6|e[n++]&63);else t+=String.fromCharCode((i&15)<<12|(e[n++]&63)<<6|e[n++]&63)}};function r0(e,t){if(t){var n=new Dt(e.length);for(var i=0;i<e.length;++i)n[i]=e.charCodeAt(i);return n}if(i0)return i0.encode(e);var r=e.length,s=new Dt(e.length+(e.length>>1)),o=0,a=function(u){s[o++]=u};for(var i=0;i<r;++i){if(o+5>s.length){var c=new Dt(o+8+(r-i<<1));c.set(s),s=c}var l=e.charCodeAt(i);if(l<128||t)a(l);else if(l<2048)a(192|l>>6),a(128|l&63);else if(l>55295&&l<57344)l=65536+(l&1047552)|e.charCodeAt(++i)&1023,a(240|l>>18),a(128|l>>12&63),a(128|l>>6&63),a(128|l&63);else a(224|l>>12),a(128|l>>6&63),a(128|l&63)}return wo(s,0,o)}function eM(e,t){if(t){var n="";for(var i=0;i<e.length;i+=16384)n+=String.fromCharCode.apply(null,e.subarray(i,i+16384));return n}else if(Pu)return Pu.decode(e);else{var r=Qw(e),{s,r:n}=r;if(n.length)mn(8);return s}}var tM=function(e,t){return t+30+fi(e,t+26)+fi(e,t+28)},nM=function(e,t,n){var i=fi(e,t+28),r=eM(e.subarray(t+46,t+46+i),!(fi(e,t+8)&2048)),s=t+46+i,o=Wn(e,t+20),a=n&&o==4294967295?iM(e,s):[o,Wn(e,t+24),Wn(e,t+42)],c=a[0],l=a[1],u=a[2];return[fi(e,t+10),c,l,r,s+fi(e,t+30)+fi(e,t+32),u]},iM=function(e,t){for(;fi(e,t)!=1;t+=4+fi(e,t+2));return[Tu(e,t+12),Tu(e,t+4),Tu(e,t+20)]},Lu=function(e){var t=0;if(e)for(var n in e){var i=e[n].length;if(i>65535)mn(9);t+=i+4}return t},s0=function(e,t,n,i,r,s,o,a){var c=i.length,l=n.extra,u=a&&a.length,h=Lu(l);if(rn(e,t,o!=null?33639248:67324752),t+=4,o!=null)e[t++]=20,e[t++]=n.os;e[t]=20,t+=2,e[t++]=n.flag<<1|(s<0&&8),e[t++]=r&&8,e[t++]=n.compression&255,e[t++]=n.compression>>8;var d=new Date(n.mtime==null?Date.now():n.mtime),f=d.getFullYear()-1980;if(f<0||f>119)mn(10);if(rn(e,t,f<<25|d.getMonth()+1<<21|d.getDate()<<16|d.getHours()<<11|d.getMinutes()<<5|d.getSeconds()>>1),t+=4,s!=-1)rn(e,t,n.crc),rn(e,t+4,s<0?-s-2:s),rn(e,t+8,n.size);if(rn(e,t+12,c),rn(e,t+14,h),t+=16,o!=null)rn(e,t,u),rn(e,t+6,n.attrs),rn(e,t+10,o),t+=14;if(e.set(i,t),t+=c,h)for(var m in l){var _=l[m],p=_.length;rn(e,t,+m),rn(e,t+2,p),e.set(_,t+4),t+=4+p}if(u)e.set(a,t),t+=u;return t},rM=function(e,t,n,i,r){rn(e,t,101010256),rn(e,t+8,n),rn(e,t+10,n),rn(e,t+12,i),rn(e,t+16,r)};function p0(e,t){if(!t)t={};var n={},i=[];f0(e,"",n,t);var r=0,s=0;for(var o in n){var a=n[o],c=a[0],l=a[1],u=l.level==0?0:8,h=r0(o),d=h.length,f=l.comment,m=f&&r0(f),_=m&&m.length,p=Lu(l.extra);if(d>65535)mn(11);var g=u?Yw(c,l):c,M=g.length,T=jw();T.p(c),i.push(d0(l,{size:c.length,crc:T.d(),c:g,f:h,m,u:d!=o.length||m&&f.length!=_,o:r,compression:u})),r+=30+d+p+M,s+=76+2*(d+p)+(_||0)+M}var v=new Dt(s+22),S=r,E=s-r;for(var R=0;R<i.length;++R){var h=i[R];s0(v,h.o,h,h.f,h.u,h.c.length);var x=30+h.f.length+Lu(h.extra);v.set(h.c,h.o+x),s0(v,r,h,h.f,h.u,h.c.length,h.o,h.m),r+=16+x+(h.m?h.m.length:0)}return rM(v,r,i.length,E,S),v}function m0(e,t){var n={},i=e.length-22;for(;Wn(e,i)!=101010256;--i)if(!i||e.length-i>65558)mn(13);var r=fi(e,i+8);if(!r)return{};var s=Wn(e,i+16),o=s==4294967295||r==65535;if(o){var a=Wn(e,i-12);if(o=Wn(e,a)==101075792,o)r=Wn(e,a+32),s=Wn(e,a+48)}var c=t&&t.filter;for(var l=0;l<r;++l){var u=nM(e,s,o),h=u[0],d=u[1],f=u[2],m=u[3],_=u[4],p=u[5],g=tM(e,p);if(s=_,!c||c({name:m,size:d,originalSize:f,compression:h}))if(!h)n[m]=wo(e,g,g+d);else if(h==8)n[m]=Kw(e.subarray(g,g+d),{out:new Dt(f)});else mn(14,"unknown compression type "+h)}return n}var Ou=["albedo","emissive","normal","roughness","metalness","metallicRoughness","occlusion"];function sM(e){if(e==="UNINITIALIZED_BINDING")return"A const, let or class binding was read before its declaration ran (temporal dead zone). Move the declaration above the first code that reads it; top-level constants must be declared before other top-level code uses them. kiln_validate names the binding and line when the read runs immediately.";if(e==="LOD_SET")return'Levels of detail: sibling nodes whose names share a stem and carry LOD0, LOD1, ... tokens (Body_LOD0, Body_LOD1) form one set. A set needs LOD0 and consecutive levels under one parent, outside any other tier, and one defineLod([lod0, lod1, ...], { screenCoverage: [...] }) call listing its tiers in level order with one value per level, each from 0 to 1 and strictly decreasing; the last may be 0, which never culls. Build one tier without LOD tokens unless the brief asks for levels. Call kiln_discover with ids ["defineLod"].';if(e==="OPEN_SHELL")return'markOpenShell(part, reason) marks a part as intentionally open: part is the mesh createPart returned or a group whose meshes it covers, and reason is a non-empty string of at most 200 characters saying why, for example markOpenShell(rail, "C-channel closed by the end plates"). The engine owns the kilnOpenShell userData key; set it only through markOpenShell. Call kiln_discover with ids ["markOpenShell"].';if(e==="BUILD_RESULT")return'Define a top-level function build() (it may be async) that returns the root Object3D, for example const root = createRoot("Name"); ...; return root;. A build() that returns nothing, or returns a geometry or material, is rejected.';if(e==="MATERIAL_RECIPE_OVERRIDE")return'materialRecipe takes a listed kiln.material.*.v1 ID and only the overrides that recipe allows; the allowed overrides differ by recipe (the emissive recipe has no metalness). Call kiln_discover with ids ["materialRecipe"] to see what each recipe allows; kiln_validate names the recipe and key when both are literals.';if(e==="PROGRAM_TYPE_ERROR")return"The program or a helper it called threw a TypeError: a value had the wrong type. Usually something is undefined (a function without a return, an un-awaited async helper such as roundedBoxGeo, extrudeProfile or materialRecipe, or a misspelt property) or a non-function was called. Run kiln_validate, then check the helper contract with kiln_discover.";if(e==="PROGRAM_RANGE_ERROR")return"The program or a helper it called threw a RangeError: a number was outside its allowed range, for example a non-positive size, an invalid array length or segment count, or unbounded recursion. Check the helper arguments against kiln_discover.";if(e==="MESH_DATA_NONFINITE")return"meshGeo positions, normals, UVs and tangents must contain finite numbers representable in Float32. Check missing XYZ components, undefined values, division by zero and overflowing calculations before constructing the arrays. Do not replace invalid values blindly with zero; correct the source calculation. Call kiln_discover for the exact meshGeo data contract.";if(e==="PORTABLE_COLOR_ARGUMENT")return"compilePortableMaterialSpecV2 baseColor and emissive must be numeric color integers from 0x000000 to 0xffffff, for example baseColor: 0x8a867c. CSS strings and materialRecipe hex-string overrides use different contracts. Omit these fields for their defaults, or call kiln_discover for the exact helper contract.";if(e==="MATERIAL_RECIPE_TEXTURE_BINDING")return"materialRecipe textureResources maps portable slots to approved resource ID strings. Slots are baseColor, normal, metallicRoughness, emissive and occlusion. albedo is a pbrMaterial field, not a recipe slot. Use kiln_discover to check each resource allowedSlots and recipeIds before binding it; no slot or resource substitution is applied.";if(e==="PORTABLE_TEXTURE_REFERENCE")return'compilePortableMaterialSpecV2 textures require typed references: { kind: "resource", resourceId: "kiln.texture..." } for an approved resource, or { kind: "procedural", spec: { schemaVersion: 2, ... } } for a procedural texture. Bare resource ID strings are invalid here. Use portable slots such as baseColor and check the exact helper/resource contracts with kiln_discover.';if(e==="TAPER_CONE_AXIS")return'taperConeGeo(radiusBottom, radiusTop, height, axis, segments): the fourth argument is axis, "x", "y" or "z" (default "y"). Segment count is the fifth argument, for example taperConeGeo(0.03, 0.02, 0.01, "x", 12). Call kiln_discover for the full contract.';if(e==="PROCEDURAL_TEXTURE_BLEND")return'proceduralTexture layer blend must be normal, multiply, screen, or overlay. Omit blend for normal compositing. Call kiln_discover with ids ["proceduralTexture"] for the supported layer fields.';if(e==="PART_NAME_ARGUMENT")return"createPart(name, geometry, material, options?): the first argument is a string name. Put the parent Object3D in the fourth argument as { parent: root }.";if(e==="PART_GEOMETRY_ARGUMENT")return"createPart(name, geometry, material, options?): the second argument must be a BufferGeometry. Call geometry helpers, for example boxGeo(1, 1, 1), instead of passing the function. For async helpers such as roundedBoxGeo, extrudeProfile and revolveProfile, await the result inside async build() before passing it to createPart. Call kiln_discover for the exact return contract.";if(e==="PART_MATERIAL_ARGUMENT")return"createPart(name, geometry, material, options?): the third argument must be a Three.js material. Wrap a color with gameMaterial(0x808080); a number or settings object alone is not a material. Call kiln_discover for the chosen material helper contract.";if(e==="SOLID_FLOAT32_COLLAPSE")return"Solid output cannot retain valid faces at Float32 precision. Simplify subprecision features or recenter local geometry; review coincident cut boundaries. Smoothing or replacing normals does not repair collapsed triangles. Kiln did not export a partially repaired solid.";if(e==="PROFILE_BEVEL_COLLAPSE")return"extrudeProfile or revolveProfile: bevel is too large for this profile; erosion leaves nothing. Reduce bevel below half the narrowest section width, set bevel to 0, or widen the profile. Dimensions and bevel use the same asset units.";if(e==="TUBE_RADIUS")return"curveToMesh and pipeAlongPath require an explicit positive finite radius representable in Float32, in asset units. A missing or undefined radius is invalid; check the referenced dimension. Radius is half the tube diameter.";if(e==="MATERIAL_ALPHA_MODE")return'pbrMaterial and portable material specs require lowercase alphaMode: "opaque", "mask", or "blend". Omit it for opaque. Exported glTF uses uppercase mode names; those are not authoring input values.';if(e==="MATERIAL_COLOR_ARGUMENT")return"gameMaterial, basicMaterial, glassMaterial and lambertMaterial take a color first: a hex number or CSS string. Settings belong in the second argument, for example gameMaterial(0x9a9a96, { roughness: 0.4, metalness: 0.8 }). pbrMaterial uses a different object-form contract; call kiln_discover for its texture and material fields.";if(e==="MATERIAL_PACKED_CHANNELS")return'pbrMaterial requires one packed texture with G=roughness and B=metalness. Generate or load it for usage "metallicRoughness" and pass metallicRoughness, or pass the same packed texture in both roughness and metalness. Do not combine those forms or pass a texture in only one scalar slot. Plain roughness and metalness values are 0..1 numbers. Call kiln_discover for the exact texture contract.';if(e==="REMOVED_HELPER")return"Generated source references a retired Kiln global. Call kiln_validate for name-specific migration guidance, then kiln_discover for the replacement contract. No compatibility aliases are provided.";if(e==="UNBOUND_VARIABLE")return"Check variable spelling and scope: generated code used an undeclared variable. Read the current source and check declarations before retrying. If it was meant to be a Kiln helper, call kiln_discover to confirm the exact name and signature; the sandbox exposes only those globals.";if(e==="ROUNDED_BOX_RADIUS")return"roundedBoxGeo: radius must be less than half the smallest dimension. Reduce radius or increase the smallest dimension; equality is invalid.";if(e==="GEAR_RADII_ORDER")return"gearGeo requires boreRadius < rootRadius < tipRadius; specify rootRadius when changing tipRadius. Omitted radii keep their absolute defaults.";if(e==="PROCEDURAL_TEXTURE_UNKNOWN_KEY")return'Remove unsupported proceduralTexture fields. Call kiln_discover with ids ["proceduralTexture"] and use only the documented fields for the selected layer op.';if(e==="MATERIAL_FRACTION_RANGE")return"Material fractions must be finite numbers between 0 and 1, inclusive. In proceduralTexture, mortarWidth and stagger are fractions, not pixels; opacity uses the same range. materialRecipe roughness, metalness, opacity, alphaCutoff and emissiveIntensity use 0..1. portableMaterial roughness, metalness and alphaCutoff also use 0..1; its emissiveIntensity has a separate 0..64 range. Call kiln_discover for the exact field contracts.";if(e==="PROFILE_HOLES_UNSUPPORTED")return"loftProfiles and sweepProfile: holes are unsupported in options or sections. Use extrudeProfile for a holed cross-section with optional twist/taper; independently varying contours need explicit geometry or solid subtraction. cap:false does not create inner walls or thickness.";if(e==="PROFILE_CORRESPONDENCE_COLLAPSE")return"loftProfiles or sweepProfile: corresponding profile edges collapse between stations. Check matching start vertices and vertex order; for an intended twist, add intermediate sections or path stations. No automatic correspondence repair is applied. Other self-intersections remain unchecked.";return e==="PARAMETRIC_PERIODIC_ENDPOINT"?"Periodic parametricSurface endpoints must return matching positions. For periodicU, sample(uMin, v) and sample(uMax, v) must match; for periodicV, sample(u, vMin) and sample(u, vMax) must match.":""}class Uu extends Error{diagnostic;constructor(e,t=sM(e)){super(t);this.diagnostic=e;this.name="AuthoringDiagnosticError"}}var g0=1024,_0=4,x0=8,oM=6,v0=80,Mo=256;class At extends Uu{constructor(e,t){super(t,e);this.name="ProceduralTextureError"}}var y0=["solid","checker","stripes","gradient","bricks","noise"],b0=["normal","multiply","screen","overlay"],aM=new Set(["__proto__","prototype","constructor"]);function ac(e,t){if(!e||typeof e!=="object"||Array.isArray(e))throw new At(`${t} must be a plain JSON object.`);let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)throw new At(`${t} must be a plain JSON object with no custom prototype.`);for(let i of Reflect.ownKeys(e)){if(typeof i!=="string")throw new At(`${t} must not contain symbol keys.`);if(aM.has(i))throw new At(`${t} contains forbidden key ${JSON.stringify(i)}.`);if(!Object.prototype.propertyIsEnumerable.call(e,i))throw new At(`${t}.${i} must be an enumerable JSON field.`);let r=Object.getOwnPropertyDescriptor(e,i);if(!r||!("value"in r))throw new At(`${t}.${i} must be a plain JSON data field.`)}return e}function cM(e,t){if(!Array.isArray(e)||Object.getPrototypeOf(e)!==Array.prototype)throw new At(`${t} must be a plain JSON array.`);for(let n of Reflect.ownKeys(e)){if(typeof n!=="string")throw new At(`${t} must not contain symbol keys.`);if(n==="length")continue;if(!/^(0|[1-9][0-9]*)$/.test(n)||Number(n)>=e.length)throw new At(`${t} has non-index JSON array key ${JSON.stringify(n)}.`)}for(let n=0;n<e.length;n++)if(!Object.hasOwn(e,n))throw new At(`${t} must be a dense JSON array (missing index ${n}).`);return e}function ir(e,t,n){let i=new Set(t);for(let r of Object.keys(e))if(!i.has(r))throw new At(`${n} has unknown key ${JSON.stringify(r)}.`,"PROCEDURAL_TEXTURE_UNKNOWN_KEY")}function Zn(e,t,n){if(typeof e!=="number"||!Number.isInteger(e)||e<0||e>16777215)throw new At(`${t} must be a color integer between 0x000000 and 0xffffff, got ${JSON.stringify(e)}.`,n);return e}function zr(e,t,n,i,r){if(e===void 0)return n;if(typeof e!=="number"||!Number.isInteger(e)||e<i||e>r)throw new At(`${t} must be a whole number between ${i} and ${r}, got ${JSON.stringify(e)}.`);return e}function w0(e,t,n,i,r,s){if(e===void 0)return n;if(typeof e!=="number"||!Number.isFinite(e)||e<i||e>r)throw new At(`${t} must be a finite number between ${i} and ${r}, got ${JSON.stringify(e)}.`,s);return e}function Fu(e,t,n){return w0(e,t,n,0,1,"MATERIAL_FRACTION_RANGE")}function lM(e,t){if(e===void 0)return;let n=typeof e==="string"&&[...e].some((i)=>{let r=i.charCodeAt(0);return r<32||r===127});if(typeof e!=="string"||e.length===0||e.length>v0||n)throw new At(`${t} must be 1..${v0} visible characters.`);return e}function uM(e,t,n){if(e===void 0)return n;if(!Ou.includes(e))throw new At(`${t} must be one of ${Ou.join(", ")}, got ${JSON.stringify(e)}.`);return e}function S0(e,t){let i=(w0(e,t,0,-36000,36000)%360+360)%360;return Object.is(i,-0)?0:i}function hM(e,t){let n=e.blend??"normal";if(!b0.includes(n))throw new At(`${t}.blend ${JSON.stringify(n)} is not one of ${b0.join(", ")}.`,"PROCEDURAL_TEXTURE_BLEND");return n}function dM(e,t){let n=`proceduralTexture.layers[${t}]`,i=ac(e,n),r=i.op;if(!y0.includes(r))throw new At(`${n}.op ${JSON.stringify(r)} is not one of ${y0.join(", ")}.`);let s=hM(i,n),o=Fu(i.opacity,`${n}.opacity`,1),a={blend:t===0?"normal":s,opacity:t===0?1:o};switch(r){case"solid":return ir(i,["op","color","blend","opacity"],n),{op:r,color:Zn(i.color,`${n}.color`),...a};case"checker":return ir(i,["op","colorA","colorB","squares","blend","opacity"],n),{op:r,colorA:Zn(i.colorA,`${n}.colorA`),colorB:Zn(i.colorB,`${n}.colorB`),squares:zr(i.squares,`${n}.squares`,8,1,Mo),...a};case"stripes":return ir(i,["op","colorA","colorB","count","angleDeg","blend","opacity"],n),{op:r,colorA:Zn(i.colorA,`${n}.colorA`),colorB:Zn(i.colorB,`${n}.colorB`),count:zr(i.count,`${n}.count`,8,1,Mo),angleDeg:S0(i.angleDeg,`${n}.angleDeg`),...a};case"gradient":return ir(i,["op","from","to","angleDeg","blend","opacity"],n),{op:r,from:Zn(i.from,`${n}.from`),to:Zn(i.to,`${n}.to`),angleDeg:S0(i.angleDeg,`${n}.angleDeg`),...a};case"bricks":return ir(i,["op","brick","mortar","rows","cols","mortarWidth","stagger","blend","opacity"],n),{op:r,brick:Zn(i.brick,`${n}.brick`),mortar:Zn(i.mortar,`${n}.mortar`),rows:zr(i.rows,`${n}.rows`,8,1,Mo),cols:zr(i.cols,`${n}.cols`,4,1,Mo),mortarWidth:Fu(i.mortarWidth,`${n}.mortarWidth`,0.06),stagger:Fu(i.stagger,`${n}.stagger`,0.5),...a};case"noise":return ir(i,["op","colorA","colorB","scale","octaves","seed","blend","opacity"],n),{op:r,colorA:Zn(i.colorA,`${n}.colorA`),colorB:Zn(i.colorB,`${n}.colorB`),scale:zr(i.scale,`${n}.scale`,8,1,Mo),octaves:zr(i.octaves,`${n}.octaves`,3,1,oM),seed:zr(i.seed,`${n}.seed`,0,-2147483648,2147483647),...a};default:throw new At(`${n}.op is unsupported.`)}}function fM(e){let t=ac(e,"proceduralTexture");if(ir(t,["schemaVersion","size","usage","name","layers"],"proceduralTexture"),t.schemaVersion!==void 0&&t.schemaVersion!==1)throw new At(`proceduralTexture.schemaVersion must be 1 or absent for V1 migration, got ${JSON.stringify(t.schemaVersion)}.`);return{schemaVersion:2,...t.size!==void 0?{size:t.size}:{},...t.usage!==void 0?{usage:t.usage}:{},...t.name!==void 0?{name:t.name}:{},layers:t.layers}}function M0(e){let t=ac(e,"proceduralTexture"),n=t.schemaVersion===void 0||t.schemaVersion===1?ac(fM(t),"proceduralTexture"):t;if(ir(n,["schemaVersion","size","usage","name","layers"],"proceduralTexture"),n.schemaVersion!==2)throw new At(`proceduralTexture.schemaVersion must be 2, got ${JSON.stringify(n.schemaVersion)}.`);let i=n.size??256;if(typeof i!=="number"||!Number.isInteger(i)||i<_0||i>g0||(i&i-1)!==0)throw new At(`proceduralTexture.size must be a power of two between ${_0} and ${g0}, got ${JSON.stringify(n.size)}.`);let r=n.layers;if(!Array.isArray(r)||r.length===0)throw new At("proceduralTexture.layers must be a non-empty array — the bottom layer is the base pattern.");let s=cM(r,"proceduralTexture.layers");if(s.length>x0)throw new At(`proceduralTexture: ${s.length} layers exceeds the maximum of ${x0}.`);let o=lM(n.name,"proceduralTexture.name");return{schemaVersion:2,size:i,usage:uM(n.usage,"proceduralTexture.usage","albedo"),...o!==void 0?{name:o}:{},layers:s.map(dM)}}var EL=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);var jn=Object.freeze({maxMapBytes:8388608,maxRecordBytes:33554432,maxManifestBytes:262144,maxMapEdge:4096,maxRecordPixels:8388608,maxPayloadBytes:16777216,maxPayloadPixels:16777216,maxPayloadRecords:16}),T0=["baseColor","normal","metallicRoughness","emissive","occlusion"],pM={baseColor:"albedo",normal:"normal",metallicRoughness:"metallicRoughness",emissive:"emissive",occlusion:"occlusion"};var To=Fe().regex(/^[a-z][a-z0-9_-]{0,79}$/),Ao=Fe().regex(/^sha256:[a-f0-9]{64}$/),rr=Fe().min(1).max(1000),E0=Fe().max(2000).url().refine((e)=>/^https?:\/\//.test(e),"Provenance URL must be HTTP(S)"),A0=qe({id:To,kind:pn(["external","procedural"]),provider:rr,creator:rr,assetId:rr.optional(),assetUrl:E0.optional(),accessedAt:Fe().datetime().optional(),license:qe({spdx:rr,url:E0,attribution:Fe().max(4000)}).strict(),originalFiles:wt(qe({name:Fe().min(1).max(200),sha256:Ao,bytes:vt().int().positive().max(1073741824)}).strict()).max(20)}).strict().superRefine((e,t)=>{if(e.kind==="external"&&(!e.assetUrl||!e.originalFiles.length))t.addIssue({code:"custom",message:"External materials require a source URL and original file hashes"});if(new Set(e.originalFiles.map((n)=>n.name)).size!==e.originalFiles.length)t.addIssue({code:"custom",message:"Duplicate original filename"})}),R0=qe({operation:rr,tool:rr,version:rr,parameters:ic(Fe().max(100),X_([Fe().max(2000),vt().finite(),vo()])).optional()}).strict(),Xn=vt().int().min(0).max(16777215),Eo=vt().int().min(1).max(256),hs={blend:pn(["normal","multiply","screen","overlay"]).default("normal"),opacity:vt().min(0).max(1).default(1)},C0=qe({schemaVersion:jt(2),size:vt().int().min(4).max(1024).default(256),usage:pn(["albedo","normal","roughness","metalness","metallicRoughness","emissive","occlusion"]).default("albedo"),name:Fe().min(1).max(80).optional(),layers:wt(_w("op",[qe({op:jt("solid"),color:Xn,...hs}).strict(),qe({op:jt("checker"),colorA:Xn,colorB:Xn,squares:Eo.default(8),...hs}).strict(),qe({op:jt("stripes"),colorA:Xn,colorB:Xn,count:Eo.default(8),angleDeg:vt().min(-36000).max(36000).default(0),...hs}).strict(),qe({op:jt("gradient"),from:Xn,to:Xn,angleDeg:vt().min(-36000).max(36000).default(0),...hs}).strict(),qe({op:jt("bricks"),brick:Xn,mortar:Xn,rows:Eo.default(8),cols:Eo.default(4),mortarWidth:vt().min(0).max(1).default(0.06),stagger:vt().min(0).max(1).default(0.5),...hs}).strict(),qe({op:jt("noise"),colorA:Xn,colorB:Xn,scale:Eo.default(8),octaves:vt().int().min(1).max(6).default(3),seed:vt().int().min(-2147483648).max(2147483647).default(0),...hs}).strict()])).min(1).max(8)}).strict(),I0=qe({kind:jt("normal-from-height"),strength:vt().finite().positive().max(64)}).strict(),mM=qe({compiler:jt("kiln.procedural-texture.v2"),spec:C0,derive:I0.optional(),recipeHash:Ao,pixelHash:Ao,encoder:qe({name:jt("sharp"),version:rr}).strict()}).strict(),P0=qe({baseColor:vt().int().min(0).max(16777215).optional(),roughness:vt().min(0).max(1).default(1),metalness:vt().min(0).max(1).default(0),emissive:vt().int().min(0).max(16777215).optional(),emissiveIntensity:vt().min(0).max(64).default(1),alphaMode:pn(["opaque","mask","blend"]).default("opaque"),alphaCutoff:vt().min(0).max(1).default(0.5),doubleSided:vo().default(!1)}).strict(),L0=qe({schemaVersion:jt(1),materialId:To,revisionId:Ao,name:Fe().min(1).max(200),tags:wt(Fe().min(1).max(80)).max(30),tileable:vo(),physicalSizeMeters:qe({width:vt().finite().positive().max(1e5),height:vt().finite().positive().max(1e5)}).strict().optional(),parameters:P0,sources:wt(A0).min(1).max(20),maps:wt(qe({slot:pn(T0),file:pn(["baseColor.png","normal.png","metallicRoughness.png","emissive.png","occlusion.png"]),sha256:Ao,bytes:vt().int().positive().max(jn.maxMapBytes),width:vt().int().positive().max(jn.maxMapEdge),height:vt().int().positive().max(jn.maxMapEdge),usage:pn(["albedo","normal","metallicRoughness","emissive","occlusion"]),colorSpace:pn(["srgb","linear"]),normalConvention:jt("opengl").optional(),channelPacking:jt("r-occlusion-g-roughness-b-metallic").optional(),sourceId:To,originalFile:Fe().min(1).max(200).optional(),transforms:wt(R0).max(30),procedural:mM.optional()}).strict()).min(1).max(5)}).strict(),CL=qe({materialId:To,name:Fe().min(1).max(200),tags:wt(Fe().min(1).max(80)).max(30).optional(),tileable:vo(),physicalSizeMeters:qe({width:vt().finite().positive().max(1e5),height:vt().finite().positive().max(1e5)}).strict().optional(),parameters:P0.partial().optional(),sources:wt(A0).min(1).max(20),maps:wt(qe({slot:pn(T0),sourceId:To,transforms:wt(R0).max(30),normalConvention:jt("opengl").optional(),channelPacking:jt("r-occlusion-g-roughness-b-metallic").optional(),procedural:C0,derive:I0.optional()}).strict()).min(1).max(5)}).strict(),N0=qe({schemaVersion:jt(1),records:wt(qe({manifest:L0,files:ic(Fe().regex(/^(baseColor|normal|metallicRoughness|emissive|occlusion)\.png$/),Fe().max(Math.ceil(jn.maxMapBytes/3)*4))}).strict()).max(jn.maxPayloadRecords)}).strict();function Co(e,t=!1,n=0){if(n>30)throw Error("Material JSON exceeds nesting limit");if(e===null||typeof e==="string"||typeof e==="boolean")return;if(typeof e==="number"&&Number.isFinite(e))return;if(t&&e instanceof Uint8Array)return;if(!e||typeof e!=="object")throw Error("Material values must be plain JSON data");let i=Array.isArray(e),r=Object.getPrototypeOf(e);if(i?r!==Array.prototype:r!==Object.prototype&&r!==null)throw Error("Material values must have plain JSON prototypes");if(i&&e.length>1e4)throw Error("Material JSON array exceeds limit");for(let s of Reflect.ownKeys(e)){if(i&&s==="length")continue;if(typeof s!=="string"||["__proto__","prototype","constructor"].includes(s))throw Error("Material JSON contains a forbidden key");if(i&&(!/^(0|[1-9][0-9]*)$/.test(s)||Number(s)>=e.length))throw Error("Material arrays must contain only indexed data");let o=Object.getOwnPropertyDescriptor(e,s);if(!("value"in o)||!o.enumerable)throw Error("Material JSON accessors or hidden fields are not allowed");Co(o.value,t,n+1)}if(i&&Object.keys(e).length!==e.length)throw Error("Material JSON arrays must be dense")}function Ro(e){Co(e);let t=(n)=>Array.isArray(n)?n.map(t):n!==null&&typeof n==="object"?Object.fromEntries(Object.entries(n).sort(([i],[r])=>i<r?-1:i>r?1:0).map(([i,r])=>[i,t(r)])):n;return JSON.stringify(t(e))}function D0(e){if(Co(e),new TextEncoder().encode(JSON.stringify(e)).length>jn.maxManifestBytes)throw Error("Material manifest exceeds size limit");let t=L0.parse(e);if(new Set(t.sources.map((r)=>r.id)).size!==t.sources.length)throw Error("Duplicate material source identity");if(new Set(t.maps.map((r)=>r.slot)).size!==t.maps.length)throw Error("Duplicate material map slot");let n=0,i=0;for(let r of t.maps){let s=r.slot==="baseColor"||r.slot==="emissive";if(r.file!==`${r.slot}.png`||r.usage!==pM[r.slot]||r.colorSpace!==(s?"srgb":"linear"))throw Error("Material map filename, usage or color convention mismatch");if(r.slot==="normal"!==(r.normalConvention==="opengl")||r.slot==="metallicRoughness"!==(r.channelPacking==="r-occlusion-g-roughness-b-metallic"))throw Error("Material map convention is missing or invalid");let o=t.sources.find((a)=>a.id===r.sourceId);if(!o)throw Error("Material map source is missing");if(r.procedural){if(r.procedural.derive&&r.slot!=="normal")throw Error("Height derivation requires a normal map slot");if(Ro(r.procedural.spec)!==Ro(M0(r.procedural.spec)))throw Error("Stored procedural material recipe must be canonical");if(o.kind!=="procedural"||r.originalFile||r.procedural.spec.usage!==r.usage||r.procedural.spec.size!==r.width||r.width!==r.height)throw Error("Procedural material source or map convention mismatch")}else if(o.kind!=="external"||!o.originalFiles.some((a)=>a.name===r.originalFile))throw Error("Material map must reference an original source file");n+=r.bytes,i+=r.width*r.height}if(n>jn.maxRecordBytes||i>jn.maxRecordPixels)throw Error("Material record exceeds byte or pixel budget");return t}var Un=67108864,zu=Fe().regex(/^[a-z][a-z0-9_-]{0,79}$/),gM=Fe().regex(/^sha256:[a-f0-9]{64}$/),O0=qe({version:jt("kiln.asset.v1"),assetId:zu,revisionId:zu,parentRevision:zu.optional(),name:Fe().min(1).max(200),tags:wt(Fe().max(80)).max(30),createdAt:Fe().datetime(),description:Fe().max(4000).optional(),brief:Fe().max(8000).optional(),attribution:qe({model:Fe().max(200).optional(),harness:Fe().max(200).optional(),author:Fe().max(200).optional()}).optional(),editable:vo(),files:ic(Fe(),qe({sha256:gM,bytes:vt().int().nonnegative().max(Un)})),build:qe({engine:Fe(),options:ic(Fe(),Fr()),warnings:wt(Fe()),integration:Fr().optional(),qa:Fr().optional(),dependencies:wt(Fr()).optional(),rebuild:pn(["engine-required","external-dependencies-required"])}).optional(),preview:qe({fidelity:Fr().optional(),error:Fe().optional(),backdrop:pn(J_).optional()}).optional()}),Io="materials.kiln.json",U0=25165824;function F0(e,t=!1){let n=(e.manifest.build?.dependencies??[]).filter((c)=>c&&typeof c==="object"&&c.kind==="kiln.material.v1"),i=new Map(n.map((c)=>{if(c.delivery!=="runtime")throw Error("Invalid saved material dependency");let l=D0(c.manifest);return[`${l.materialId}/${l.revisionId}`,Ro(l)]}));if(!e.materialResources){if(t&&i.size)throw Error("Editable asset material closure unavailable");return}Co(e.materialResources);let r=N0.parse(e.materialResources),s=0,o=0,a=new Set;for(let c of r.records){let l=`${c.manifest.materialId}/${c.manifest.revisionId}`;if(a.has(l)||i.get(l)!==Ro(c.manifest))throw Error("Asset material closure mismatch");if(a.add(l),Object.keys(c.files).length!==c.manifest.maps.length)throw Error("Asset material map inventory mismatch");for(let u of c.manifest.maps){if(c.files[u.file]?.length!==Math.ceil(u.bytes/3)*4)throw Error("Asset material map size mismatch");s+=u.bytes,o+=u.width*u.height}}if(a.size!==i.size)throw Error("Asset material closure incomplete");if(s>jn.maxPayloadBytes||o>jn.maxPayloadPixels)throw Error("Asset material closure exceeds allocation limits")}var _M=new Set(["asset.glb","source.kiln.js","preview.png"]);function cc(e){let t=O0.parse(e.manifest),n=Object.keys(e.files);if(n.length!==Object.keys(t.files).length||!n.includes("asset.glb"))throw Error("Asset file inventory mismatch");let i=0;for(let r of n){if(!_M.has(r)||!t.files[r]||t.files[r].bytes!==e.files[r].length)throw Error("Invalid asset file inventory");i+=e.files[r].length}if(i>Un||t.editable!==n.includes("source.kiln.js"))throw Error("Invalid asset size or source inventory");if((e.files["source.kiln.js"]?.length??0)>1048576)throw Error("Source exceeds 1 MiB");ku(e.files["asset.glb"]),F0(e)}function ku(e){if(e.length<20||e.length>Un)throw Error("Invalid GLB size");let t=new DataView(e.buffer,e.byteOffset,e.byteLength);if(t.getUint32(0,!0)!==1179937895||t.getUint32(4,!0)!==2||t.getUint32(8,!0)!==e.length||t.getUint32(16,!0)!==1313821514)throw Error("Invalid GLB header");let n=20+t.getUint32(12,!0);if(n>e.length)throw Error("Invalid GLB JSON length");let i=JSON.parse(new TextDecoder().decode(e.subarray(20,n)));for(let r of[...i.buffers??[],...i.images??[]])if(r.uri&&!String(r.uri).startsWith("data:"))throw Error("GLB must embed its resources")}function Bu(e){if(!e.length||e.length>100)throw Error("Bundle requires 1..100 revisions");let t={},n=0;for(let i of e){cc(i),F0(i,!0);let r=`${i.manifest.assetId}/${i.manifest.revisionId}/`;if(t[`${r}manifest.json`])throw Error("Duplicate bundle revision");t[`${r}manifest.json`]=new TextEncoder().encode(JSON.stringify(i.manifest,null,2));for(let[s,o]of Object.entries(i.files))t[r+s]=o;if(i.materialResources){let s=new TextEncoder().encode(JSON.stringify(i.materialResources));if(s.length>U0)throw Error("Asset material payload exceeds byte limit");t[r+Io]=s}}for(let i of Object.values(t))n+=i.length;if(n>Un)throw Error("Bundle exceeds 64 MiB");return p0(t,{level:0})}function z0(e){if(e.length>Un+1048576)throw Error("Bundle exceeds 64 MiB");let t=0,n=0,i=m0(e,{filter:(o)=>{if(t+=o.originalSize,n++,t>Un||n>500||o.name.endsWith(`/${Io}`)&&o.originalSize>U0||!/^[a-z][a-z0-9_-]{0,79}\/[a-z][a-z0-9_-]{0,79}\/(manifest\.json|asset\.glb|source\.kiln\.js|preview\.png|materials\.kiln\.json)$/.test(o.name))throw Error("Unsafe or oversized asset bundle");return!0}}),r=[],s=new Set;for(let[o,a]of Object.entries(i)){if(!o.endsWith("/manifest.json"))continue;if(a.length>1048576)throw Error("Manifest exceeds 1 MiB");let c=O0.parse(JSON.parse(new TextDecoder().decode(a))),l=`${c.assetId}/${c.revisionId}/`;if(o!==`${l}manifest.json`)throw Error("Bundle identity mismatch");let u={manifest:c,files:{}};s.add(o);for(let h of Object.keys(c.files)){if(!i[l+h])throw Error("Bundle file missing");u.files[h]=i[l+h],s.add(l+h)}if(i[l+Io])u.materialResources=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(i[l+Io])),s.add(l+Io);cc(u),r.push(u)}if(!r.length||s.size!==Object.keys(i).length)throw Error("Incomplete asset bundle");return r}function k0(e){let t=e.attribution;if(!t)return[];return[t.model?{label:"Model",value:t.model}:null,t.harness?{label:"Harness",value:t.harness}:null,t.author?{label:"Author",value:t.author}:null].filter((n)=>n!==null)}var wx="186",dr={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},fr={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Mx=0,dh=1,Ex=2;var Ho=1,Tx=2,Is=3,pr=0,cn=1,Bn=2,vi=0,Vo=1,fh=2,ph=3,mh=4,Ax=5;var Ps=100,Rx=101,Cx=102,Ix=103,Px=104,Lx=200,Nx=201,Dx=202,Ox=203,Ux=204,Fx=205,zx=206,kx=207,Bx=208,Gx=209,Hx=210,Vx=211,$x=212,Wx=213,Zx=214,Xx=0,jx=1,qx=2,gh=3,Yx=4,Kx=5,Jx=6,Qx=7,ev=0,tv=1,nv=2,ei=0,_h=1,xh=2,vh=3,$o=4,yh=5,bh=6,Sh=7;var Ls=301,Wr=302,Fc=303,zc=304,Wo=306,Ns=1000,Ds=1001,kc=1002,ti=1003,Bc=1004;var Zr=1005;var Jt=1006,Os=1007;var yi=1008;var ni=1009,iv=1010,rv=1011,Zo=1012,wh=1013,mr=1014,$i=1015,bi=1016,Mh=1017,Eh=1018,Us=1020,sv=35902,ov=35899,av=1021,cv=1022,Si=1023,Xr=1026,jr=1027,lv=1028,Th=1029,qr=1030,Ah=1031;var Rh=1033,Gc=33776,Hc=33777,Vc=33778,$c=33779,Ch=35840,Ih=35841,Ph=35842,Lh=35843,Nh=36196,Dh=37492,Oh=37496,Uh=37488,Fh=37489,Wc=37490,zh=37491,kh=37808,Bh=37809,Gh=37810,Hh=37811,Vh=37812,$h=37813,Wh=37814,Zh=37815,Xh=37816,jh=37817,qh=37818,Yh=37819,Kh=37820,Jh=37821,Qh=36492,ed=36494,td=36495,nd=36283,id=36284,Zc=36285,rd=36286;var sd=2300,Xc=2301;var od=0,Xo=1,Fs=2;var ad=0,uv=1,Yr="",gr="srgb",Rn="srgb-linear",cd="linear",yt="srgb";var hv=512,dv=513,fv=514,jc=515,pv=516,mv=517,qc=518,gv=519;var ld="300 es",ud=2000;function xM(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function vM(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function As(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function _v(){let e=As("canvas");return e.style.display="block",e}var B0={},Rs=null;function Go(...e){let t="THREE."+e.shift();if(Rs)Rs("log",t,...e);else console.log(t,...e)}function xv(e){let t=e[0];if(typeof t==="string"&&t.startsWith("TSL:")){let n=e[1];if(n&&n.isStackTrace)e[0]+=" "+n.getLocation();else e[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return e}function Ue(...e){e=xv(e);let t="THREE."+e.shift();if(Rs)Rs("warn",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.warn(n.getError(t));else console.warn(t,...e)}}function Ve(...e){e=xv(e);let t="THREE."+e.shift();if(Rs)Rs("error",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.error(n.getError(t));else console.error(t,...e)}}function Vr(...e){let t=e.join(" ");if(t in B0)return;B0[t]=!0,Ue(...e)}function vv(e,t,n){return new Promise(function(i,r){function s(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:r();break;case e.TIMEOUT_EXPIRED:setTimeout(s,n);break;default:i()}}setTimeout(s,n)})}var yv={[0]:1,[2]:6,[4]:7,[3]:5,[1]:0,[6]:2,[7]:4,[5]:3};class ii{addEventListener(e,t){if(this._listeners===void 0)this._listeners={};let n=this._listeners;if(n[e]===void 0)n[e]=[];if(n[e].indexOf(t)===-1)n[e].push(t)}hasEventListener(e,t){let n=this._listeners;if(n===void 0)return!1;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let i=n[e];if(i!==void 0){let r=i.indexOf(t);if(r!==-1)i.splice(r,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let i=n.slice(0);for(let r=0,s=i.length;r<s;r++)i[r].call(this,e);e.target=null}}}var on=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],G0=1234567,ko=Math.PI/180,$r=180/Math.PI;function Qn(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(on[e&255]+on[e>>8&255]+on[e>>16&255]+on[e>>24&255]+"-"+on[t&255]+on[t>>8&255]+"-"+on[t>>16&15|64]+on[t>>24&255]+"-"+on[n&63|128]+on[n>>8&255]+"-"+on[n>>16&255]+on[n>>24&255]+on[i&255]+on[i>>8&255]+on[i>>16&255]+on[i>>24&255]).toLowerCase()}function Je(e,t,n){return Math.max(t,Math.min(n,e))}function hd(e,t){return(e%t+t)%t}function yM(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)}function bM(e,t,n){if(e!==t)return(n-e)/(t-e);else return 0}function Bo(e,t,n){return(1-n)*e+n*t}function SM(e,t,n,i){return Bo(e,t,1-Math.exp(-n*i))}function wM(e,t=1){return t-Math.abs(hd(e,t*2)-t)}function MM(e,t,n){if(e<=t)return 0;if(e>=n)return 1;return e=(e-t)/(n-t),e*e*(3-2*e)}function EM(e,t,n){if(e<=t)return 0;if(e>=n)return 1;return e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10)}function TM(e,t){return e+Math.floor(Math.random()*(t-e+1))}function AM(e,t){return e+Math.random()*(t-e)}function RM(e){return e*(0.5-Math.random())}function CM(e){if(e!==void 0)G0=e;let t=G0+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function IM(e){return e*ko}function PM(e){return e*$r}function LM(e){return e>0&&Number.isInteger(e)&&2**Math.round(Math.log2(e))===e}function NM(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function DM(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function OM(e,t,n,i,r){let{cos:s,sin:o}=Math,a=s(n/2),c=o(n/2),l=s((t+i)/2),u=o((t+i)/2),h=s((t-i)/2),d=o((t-i)/2),f=s((i-t)/2),m=o((i-t)/2);switch(r){case"XYX":e.set(a*u,c*h,c*d,a*l);break;case"YZY":e.set(c*d,a*u,c*h,a*l);break;case"ZXZ":e.set(c*h,c*d,a*u,a*l);break;case"XZX":e.set(a*u,c*m,c*f,a*l);break;case"YXY":e.set(c*f,a*u,c*m,a*l);break;case"ZYZ":e.set(c*m,c*f,a*u,a*l);break;default:Ue("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function Jn(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:case Uint8ClampedArray:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error("THREE.MathUtils: Invalid component type.")}}function ft(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:case Uint8ClampedArray:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error("THREE.MathUtils: Invalid component type.")}}var jo={DEG2RAD:ko,RAD2DEG:$r,generateUUID:Qn,clamp:Je,euclideanModulo:hd,mapLinear:yM,inverseLerp:bM,lerp:Bo,damp:SM,pingpong:wM,smoothstep:MM,smootherstep:EM,randInt:TM,randFloat:AM,randFloatSpread:RM,seededRandom:CM,degToRad:IM,radToDeg:PM,isPowerOfTwo:LM,ceilPowerOfTwo:NM,floorPowerOfTwo:DM,setQuaternionFromProperEuler:OM,normalize:ft,denormalize:Jn};class ke{static{ke.prototype.isVector2=!0}constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Je(this.x,e.x,t.x),this.y=Je(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Je(this.x,e,t),this.y=Je(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Je(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(Je(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,s=this.y-e.y;return this.x=r*n-s*i+e.x,this.y=r*i+s*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Yt{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,r,s,o){let a=n[i+0],c=n[i+1],l=n[i+2],u=n[i+3],h=r[s+0],d=r[s+1],f=r[s+2],m=r[s+3];if(u!==m||a!==h||c!==d||l!==f){let _=a*h+c*d+l*f+u*m;if(_<0)h=-h,d=-d,f=-f,m=-m,_=-_;let p=1-o;if(_<0.9995){let g=Math.acos(_),M=Math.sin(g);p=Math.sin(p*g)/M,o=Math.sin(o*g)/M,a=a*p+h*o,c=c*p+d*o,l=l*p+f*o,u=u*p+m*o}else{a=a*p+h*o,c=c*p+d*o,l=l*p+f*o,u=u*p+m*o;let g=1/Math.sqrt(a*a+c*c+l*l+u*u);a*=g,c*=g,l*=g,u*=g}}e[t]=a,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,i,r,s){let o=n[i],a=n[i+1],c=n[i+2],l=n[i+3],u=r[s],h=r[s+1],d=r[s+2],f=r[s+3];return e[t]=o*f+l*u+a*d-c*h,e[t+1]=a*f+l*h+c*u-o*d,e[t+2]=c*f+l*d+o*h-a*u,e[t+3]=l*f-o*u-a*h-c*d,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let{_x:n,_y:i,_z:r,_order:s}=e,{cos:o,sin:a}=Math,c=o(n/2),l=o(i/2),u=o(r/2),h=a(n/2),d=a(i/2),f=a(r/2);switch(s){case"XYZ":this._x=h*l*u+c*d*f,this._y=c*d*u-h*l*f,this._z=c*l*f+h*d*u,this._w=c*l*u-h*d*f;break;case"YXZ":this._x=h*l*u+c*d*f,this._y=c*d*u-h*l*f,this._z=c*l*f-h*d*u,this._w=c*l*u+h*d*f;break;case"ZXY":this._x=h*l*u-c*d*f,this._y=c*d*u+h*l*f,this._z=c*l*f+h*d*u,this._w=c*l*u-h*d*f;break;case"ZYX":this._x=h*l*u-c*d*f,this._y=c*d*u+h*l*f,this._z=c*l*f-h*d*u,this._w=c*l*u+h*d*f;break;case"YZX":this._x=h*l*u+c*d*f,this._y=c*d*u+h*l*f,this._z=c*l*f-h*d*u,this._w=c*l*u-h*d*f;break;case"XZY":this._x=h*l*u-c*d*f,this._y=c*d*u-h*l*f,this._z=c*l*f+h*d*u,this._w=c*l*u+h*d*f;break;default:Ue("Quaternion: .setFromEuler() encountered an unknown order: "+s)}if(t===!0)this._onChangeCallback();return this}setFromAxisAngle(e,t){let n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],i=t[4],r=t[8],s=t[1],o=t[5],a=t[9],c=t[2],l=t[6],u=t[10],h=n+o+u;if(h>0){let d=0.5/Math.sqrt(h+1);this._w=0.25/d,this._x=(l-a)*d,this._y=(r-c)*d,this._z=(s-i)*d}else if(n>o&&n>u){let d=2*Math.sqrt(1+n-o-u);this._w=(l-a)/d,this._x=0.25*d,this._y=(i+s)/d,this._z=(r+c)/d}else if(o>u){let d=2*Math.sqrt(1+o-n-u);this._w=(r-c)/d,this._x=(i+s)/d,this._y=0.25*d,this._z=(a+l)/d}else{let d=2*Math.sqrt(1+u-n-o);this._w=(s-i)/d,this._x=(r+c)/d,this._y=(a+l)/d,this._z=0.25*d}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;if(n<0.00000001)if(n=0,Math.abs(e.x)>Math.abs(e.z))this._x=-e.y,this._y=e.x,this._z=0,this._w=n;else this._x=0,this._y=-e.z,this._z=e.y,this._w=n;else this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n;return this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Je(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();if(e===0)this._x=0,this._y=0,this._z=0,this._w=1;else e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e;return this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let{_x:n,_y:i,_z:r,_w:s}=e,{_x:o,_y:a,_z:c,_w:l}=t;return this._x=n*l+s*o+i*c-r*a,this._y=i*l+s*a+r*o-n*c,this._z=r*l+s*c+n*a-i*o,this._w=s*l-n*o-i*a-r*c,this._onChangeCallback(),this}slerp(e,t){let{_x:n,_y:i,_z:r,_w:s}=e,o=this.dot(e);if(o<0)n=-n,i=-i,r=-r,s=-s,o=-o;let a=1-t;if(o<0.9995){let c=Math.acos(o),l=Math.sin(c);a=Math.sin(a*c)/l,t=Math.sin(t*c)/l,this._x=this._x*a+n*t,this._y=this._y*a+i*t,this._z=this._z*a+r*t,this._w=this._w*a+s*t,this._onChangeCallback()}else this._x=this._x*a+n*t,this._y=this._y*a+i*t,this._z=this._z*a+r*t,this._w=this._w*a+s*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class z{static{z.prototype.isVector3=!0}constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){if(n===void 0)n=this.z;return this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(H0.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(H0.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,r=e.elements,s=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*s,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*s,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*s,this}applyQuaternion(e){let t=this.x,n=this.y,i=this.z,{x:r,y:s,z:o,w:a}=e,c=2*(s*i-o*n),l=2*(o*t-r*i),u=2*(r*n-s*t);return this.x=t+a*c+s*u-o*l,this.y=n+a*l+o*c-r*u,this.z=i+a*u+r*l-s*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Je(this.x,e.x,t.x),this.y=Je(this.y,e.y,t.y),this.z=Je(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Je(this.x,e,t),this.y=Je(this.y,e,t),this.z=Je(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Je(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let{x:n,y:i,z:r}=e,{x:s,y:o,z:a}=t;return this.x=i*a-r*o,this.y=r*s-n*a,this.z=n*o-i*s,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Gu.copy(this).projectOnVector(e),this.sub(Gu)}reflect(e){return this.sub(Gu.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(Je(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}var Gu=new z,H0=new Yt;class We{static{We.prototype.isMatrix3=!0}constructor(e,t,n,i,r,s,o,a,c){if(this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0)this.set(e,t,n,i,r,s,o,a,c)}set(e,t,n,i,r,s,o,a,c){let l=this.elements;return l[0]=e,l[1]=i,l[2]=o,l[3]=t,l[4]=r,l[5]=a,l[6]=n,l[7]=s,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,s=n[0],o=n[3],a=n[6],c=n[1],l=n[4],u=n[7],h=n[2],d=n[5],f=n[8],m=i[0],_=i[3],p=i[6],g=i[1],M=i[4],T=i[7],v=i[2],S=i[5],E=i[8];return r[0]=s*m+o*g+a*v,r[3]=s*_+o*M+a*S,r[6]=s*p+o*T+a*E,r[1]=c*m+l*g+u*v,r[4]=c*_+l*M+u*S,r[7]=c*p+l*T+u*E,r[2]=h*m+d*g+f*v,r[5]=h*_+d*M+f*S,r[8]=h*p+d*T+f*E,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8];return t*s*l-t*o*c-n*r*l+n*o*a+i*r*c-i*s*a}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=l*s-o*c,h=o*a-l*r,d=c*r-s*a,f=t*u+n*h+i*d;if(f===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/f;return e[0]=u*m,e[1]=(i*c-l*n)*m,e[2]=(o*n-i*s)*m,e[3]=h*m,e[4]=(l*t-i*a)*m,e[5]=(i*r-o*t)*m,e[6]=d*m,e[7]=(n*a-c*t)*m,e[8]=(s*t-n*r)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,r,s,o){let a=Math.cos(r),c=Math.sin(r);return this.set(n*a,n*c,-n*(a*s+c*o)+s+e,-i*c,i*a,-i*(-c*s+a*o)+o+t,0,0,1),this}scale(e,t){return Vr("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Hu.makeScale(e,t)),this}rotate(e){return Vr("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Hu.makeRotation(-e)),this}translate(e,t){return Vr("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Hu.makeTranslation(e,t)),this}makeTranslation(e,t){if(e.isVector2)this.set(1,0,e.x,0,1,e.y,0,0,1);else this.set(1,0,e,0,1,t,0,0,1);return this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}var Hu=new We,V0=new We().set(0.4123908,0.3575843,0.1804808,0.212639,0.7151687,0.0721923,0.0193308,0.1191948,0.9505322),$0=new We().set(3.2409699,-1.5373832,-0.4986108,-0.9692436,1.8759675,0.0415551,0.0556301,-0.203977,1.0569715);function UM(){let e={enabled:!0,workingColorSpace:"srgb-linear",spaces:{},convert:function(r,s,o){if(this.enabled===!1||s===o||!s||!o)return r;if(this.spaces[s].transfer==="srgb")r.r=Vi(r.r),r.g=Vi(r.g),r.b=Vi(r.b);if(this.spaces[s].primaries!==this.spaces[o].primaries)r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[o].fromXYZ);if(this.spaces[o].transfer==="srgb")r.r=Ts(r.r),r.g=Ts(r.g),r.b=Ts(r.b);return r},workingToColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},colorSpaceToWorking:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){if(r==="")return"linear";return this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,o){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,s){return Vr("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),e.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return Vr("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),e.colorSpaceToWorking(r,s)}},t=[0.64,0.33,0.3,0.6,0.15,0.06],n=[0.2126,0.7152,0.0722],i=[0.3127,0.329];return e.define({["srgb-linear"]:{primaries:t,whitePoint:i,transfer:"linear",toXYZ:V0,fromXYZ:$0,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:"srgb"},outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}},["srgb"]:{primaries:t,whitePoint:i,transfer:"srgb",toXYZ:V0,fromXYZ:$0,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}}}),e}var Ke=UM();function Vi(e){return e<0.04045?e*0.0773993808:Math.pow(e*0.9478672986+0.0521327014,2.4)}function Ts(e){return e<0.0031308?e*12.92:1.055*Math.pow(e,0.41666)-0.055}var ds;class dd{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src))return e.src;if(typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{if(ds===void 0)ds=As("canvas");ds.width=e.width,ds.height=e.height;let i=ds.getContext("2d");if(e instanceof ImageData)i.putImageData(e,0,0);else i.drawImage(e,0,0,e.width,e.height);n=ds}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=As("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let s=0;s<r.length;s++)r[s]=Vi(r[s]/255)*255;return n.putImageData(i,0,0),t}else if(e.data){let t=e.data.slice(0);for(let n=0;n<t.length;n++)if(t instanceof Uint8Array||t instanceof Uint8ClampedArray)t[n]=Math.floor(Vi(t[n]/255)*255);else t[n]=Vi(t[n]);return{data:t,width:e.width,height:e.height}}else return Ue("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}var FM=0;class qo{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:FM++}),this.uuid=Qn(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;if(typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement)e.set(t.videoWidth,t.videoHeight,0);else if(typeof VideoFrame<"u"&&t instanceof VideoFrame)e.set(t.displayWidth,t.displayHeight,0);else if(t!==null)e.set(t.width,t.height,t.depth||0);else e.set(0,0,0);return e}set needsUpdate(e){if(e===!0)this.version++}toJSON(e){let t=e===void 0||typeof e==="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let r;if(Array.isArray(i)){r=[];for(let s=0,o=i.length;s<o;s++)if(i[s].isDataTexture)r.push(Vu(i[s].image));else r.push(Vu(i[s]))}else r=Vu(i);n.url=r}if(!t)e.images[this.uuid]=n;return n}}function Vu(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap)return dd.getDataURL(e);else if(e.data)return{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name};else return Ue("Texture: Unable to serialize Texture."),{}}var zM=0,$u=new z;class Ot extends ii{constructor(e=Ot.DEFAULT_IMAGE,t=Ot.DEFAULT_MAPPING,n=1001,i=1001,r=1006,s=1008,o=1023,a=1009,c=Ot.DEFAULT_ANISOTROPY,l=""){super();this.isTexture=!0,Object.defineProperty(this,"id",{value:zM++}),this.uuid=Qn(),this.name="",this.source=new qo(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=s,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=a,this.offset=new ke(0,0),this.repeat=new ke(1,1),this.center=new ke(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new We,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=l,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=e&&e.depth&&e.depth>1?!0:!1,this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize($u).x}get height(){return this.source.getSize($u).y}get depth(){return this.source.getSize($u).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){Ue(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){Ue(`Texture.setValues(): property '${t}' does not exist.`);continue}if(i&&n&&(i.isVector2&&n.isVector2))i.copy(n);else if(i&&n&&(i.isVector3&&n.isVector3))i.copy(n);else if(i&&n&&(i.isMatrix3&&n.isMatrix3))i.copy(n);else this[t]=n}}toJSON(e){let t=e===void 0||typeof e==="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(Object.keys(this.userData).length>0)n.userData=this.userData;if(!t)e.textures[this.uuid]=n;return n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case 1000:e.x=e.x-Math.floor(e.x);break;case 1001:e.x=e.x<0?0:1;break;case 1002:if(Math.abs(Math.floor(e.x)%2)===1)e.x=Math.ceil(e.x)-e.x;else e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case 1000:e.y=e.y-Math.floor(e.y);break;case 1001:e.y=e.y<0?0:1;break;case 1002:if(Math.abs(Math.floor(e.y)%2)===1)e.y=Math.ceil(e.y)-e.y;else e.y=e.y-Math.floor(e.y);break}if(this.flipY)e.y=1-e.y;return e}set needsUpdate(e){if(e===!0)this.version++,this.source.needsUpdate=!0}set needsPMREMUpdate(e){if(e===!0)this.pmremVersion++}}Ot.DEFAULT_IMAGE=null;Ot.DEFAULT_MAPPING=300;Ot.DEFAULT_ANISOTROPY=1;class pt{static{pt.prototype.isVector4=!0}constructor(e=0,t=0,n=0,i=1){this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,r=this.w,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i+s[12]*r,this.y=s[1]*t+s[5]*n+s[9]*i+s[13]*r,this.z=s[2]*t+s[6]*n+s[10]*i+s[14]*r,this.w=s[3]*t+s[7]*n+s[11]*i+s[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);if(t<0.0001)this.x=1,this.y=0,this.z=0;else this.x=e.x/t,this.y=e.y/t,this.z=e.z/t;return this}setAxisAngleFromRotationMatrix(e){let t,n,i,r,s=0.01,o=0.1,a=e.elements,c=a[0],l=a[4],u=a[8],h=a[1],d=a[5],f=a[9],m=a[2],_=a[6],p=a[10];if(Math.abs(l-h)<0.01&&Math.abs(u-m)<0.01&&Math.abs(f-_)<0.01){if(Math.abs(l+h)<0.1&&Math.abs(u+m)<0.1&&Math.abs(f+_)<0.1&&Math.abs(c+d+p-3)<0.1)return this.set(1,0,0,0),this;t=Math.PI;let M=(c+1)/2,T=(d+1)/2,v=(p+1)/2,S=(l+h)/4,E=(u+m)/4,R=(f+_)/4;if(M>T&&M>v)if(M<0.01)n=0,i=0.707106781,r=0.707106781;else n=Math.sqrt(M),i=S/n,r=E/n;else if(T>v)if(T<0.01)n=0.707106781,i=0,r=0.707106781;else i=Math.sqrt(T),n=S/i,r=R/i;else if(v<0.01)n=0.707106781,i=0.707106781,r=0;else r=Math.sqrt(v),n=E/r,i=R/r;return this.set(n,i,r,t),this}let g=Math.sqrt((_-f)*(_-f)+(u-m)*(u-m)+(h-l)*(h-l));if(Math.abs(g)<0.001)g=1;return this.x=(_-f)/g,this.y=(u-m)/g,this.z=(h-l)/g,this.w=Math.acos((c+d+p-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Je(this.x,e.x,t.x),this.y=Je(this.y,e.y,t.y),this.z=Je(this.z,e.z,t.z),this.w=Je(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Je(this.x,e,t),this.y=Je(this.y,e,t),this.z=Je(this.z,e,t),this.w=Je(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Je(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class fd extends ii{constructor(e=1,t=1,n={}){super();n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:1006,depthBuffer:!0,stencilBuffer:!1,resolveColorBuffer:!0,resolveDepthBuffer:!0,resolveStencilBuffer:!0,storeMultisampledColorBuffer:!0,storeMultisampledDepthBuffer:!0,storeMultisampledStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new pt(0,0,e,t),this.scissorTest=!1,this.viewport=new pt(0,0,e,t),this.textures=[];let i={width:e,height:t,depth:n.depth},r=new Ot(i),s=n.count;for(let o=0;o<s;o++)this.textures[o]=r.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveColorBuffer=n.resolveColorBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.storeMultisampledColorBuffer=n.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=n.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=n.storeMultisampledStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(e={}){let t={minFilter:1006,generateMipmaps:!1,flipY:!1,internalFormat:null};if(e.mapping!==void 0)t.mapping=e.mapping;if(e.wrapS!==void 0)t.wrapS=e.wrapS;if(e.wrapT!==void 0)t.wrapT=e.wrapT;if(e.wrapR!==void 0)t.wrapR=e.wrapR;if(e.magFilter!==void 0)t.magFilter=e.magFilter;if(e.minFilter!==void 0)t.minFilter=e.minFilter;if(e.format!==void 0)t.format=e.format;if(e.type!==void 0)t.type=e.type;if(e.anisotropy!==void 0)t.anisotropy=e.anisotropy;if(e.colorSpace!==void 0)t.colorSpace=e.colorSpace;if(e.flipY!==void 0)t.flipY=e.flipY;if(e.generateMipmaps!==void 0)t.generateMipmaps=e.generateMipmaps;if(e.internalFormat!==void 0)t.internalFormat=e.internalFormat;for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){if(this._depthTexture!==null&&this._depthTexture.renderTarget===this)this._depthTexture.renderTarget=null;if(e!==null&&e.renderTarget===null)e.renderTarget=this;this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let i=0,r=this.textures.length;i<r;i++)if(this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=n,this.textures[i].isData3DTexture!==!0)this.textures[i].isArrayTexture=this.textures[i].image.depth>1;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let i=Object.assign({},e.textures[t].image);this.textures[t].source=new qo(i)}if(this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveColorBuffer=e.resolveColorBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,this.storeMultisampledColorBuffer=e.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=e.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=e.storeMultisampledStencilBuffer,e.depthTexture!==null)if(e.depthTexture.renderTarget===e){let t=e.depthTexture.clone();t.renderTarget=null,this.depthTexture=t}else this.depthTexture=e.depthTexture;return this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Cn extends fd{constructor(e=1,t=1,n={}){super(e,t,n);this.isWebGLRenderTarget=!0}}class Yc extends Ot{constructor(e=null,t=1,n=1,i=1){super(null);this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class pd extends Ot{constructor(e=null,t=1,n=1,i=1){super(null);this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}}class Xe{static{Xe.prototype.isMatrix4=!0}constructor(e,t,n,i,r,s,o,a,c,l,u,h,d,f,m,_){if(this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0)this.set(e,t,n,i,r,s,o,a,c,l,u,h,d,f,m,_)}set(e,t,n,i,r,s,o,a,c,l,u,h,d,f,m,_){let p=this.elements;return p[0]=e,p[4]=t,p[8]=n,p[12]=i,p[1]=r,p[5]=s,p[9]=o,p[13]=a,p[2]=c,p[6]=l,p[10]=u,p[14]=h,p[3]=d,p[7]=f,p[11]=m,p[15]=_,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Xe().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){if(this.determinantAffine()===0)return e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this;return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();let t=this.elements,n=e.elements,i=1/fs.setFromMatrixColumn(e,0).length(),r=1/fs.setFromMatrixColumn(e,1).length(),s=1/fs.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*s,t[9]=n[9]*s,t[10]=n[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,{x:n,y:i,z:r}=e,s=Math.cos(n),o=Math.sin(n),a=Math.cos(i),c=Math.sin(i),l=Math.cos(r),u=Math.sin(r);if(e.order==="XYZ"){let h=s*l,d=s*u,f=o*l,m=o*u;t[0]=a*l,t[4]=-a*u,t[8]=c,t[1]=d+f*c,t[5]=h-m*c,t[9]=-o*a,t[2]=m-h*c,t[6]=f+d*c,t[10]=s*a}else if(e.order==="YXZ"){let h=a*l,d=a*u,f=c*l,m=c*u;t[0]=h+m*o,t[4]=f*o-d,t[8]=s*c,t[1]=s*u,t[5]=s*l,t[9]=-o,t[2]=d*o-f,t[6]=m+h*o,t[10]=s*a}else if(e.order==="ZXY"){let h=a*l,d=a*u,f=c*l,m=c*u;t[0]=h-m*o,t[4]=-s*u,t[8]=f+d*o,t[1]=d+f*o,t[5]=s*l,t[9]=m-h*o,t[2]=-s*c,t[6]=o,t[10]=s*a}else if(e.order==="ZYX"){let h=s*l,d=s*u,f=o*l,m=o*u;t[0]=a*l,t[4]=f*c-d,t[8]=h*c+m,t[1]=a*u,t[5]=m*c+h,t[9]=d*c-f,t[2]=-c,t[6]=o*a,t[10]=s*a}else if(e.order==="YZX"){let h=s*a,d=s*c,f=o*a,m=o*c;t[0]=a*l,t[4]=m-h*u,t[8]=f*u+d,t[1]=u,t[5]=s*l,t[9]=-o*l,t[2]=-c*l,t[6]=d*u+f,t[10]=h-m*u}else if(e.order==="XZY"){let h=s*a,d=s*c,f=o*a,m=o*c;t[0]=a*l,t[4]=-u,t[8]=c*l,t[1]=h*u+m,t[5]=s*l,t[9]=d*u-f,t[2]=f*u-d,t[6]=o*l,t[10]=m*u+h}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(kM,e,BM)}lookAt(e,t,n){let i=this.elements;if(Tn.subVectors(e,t),Tn.lengthSq()===0)Tn.z=1;if(Tn.normalize(),sr.crossVectors(n,Tn),sr.lengthSq()===0){if(Math.abs(n.z)===1)Tn.x+=0.0001;else Tn.z+=0.0001;Tn.normalize(),sr.crossVectors(n,Tn)}return sr.normalize(),lc.crossVectors(Tn,sr),i[0]=sr.x,i[4]=lc.x,i[8]=Tn.x,i[1]=sr.y,i[5]=lc.y,i[9]=Tn.y,i[2]=sr.z,i[6]=lc.z,i[10]=Tn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,s=n[0],o=n[4],a=n[8],c=n[12],l=n[1],u=n[5],h=n[9],d=n[13],f=n[2],m=n[6],_=n[10],p=n[14],g=n[3],M=n[7],T=n[11],v=n[15],S=i[0],E=i[4],R=i[8],x=i[12],w=i[1],G=i[5],C=i[9],D=i[13],ee=i[2],L=i[6],W=i[10],B=i[14],P=i[3],J=i[7],H=i[11],q=i[15];return r[0]=s*S+o*w+a*ee+c*P,r[4]=s*E+o*G+a*L+c*J,r[8]=s*R+o*C+a*W+c*H,r[12]=s*x+o*D+a*B+c*q,r[1]=l*S+u*w+h*ee+d*P,r[5]=l*E+u*G+h*L+d*J,r[9]=l*R+u*C+h*W+d*H,r[13]=l*x+u*D+h*B+d*q,r[2]=f*S+m*w+_*ee+p*P,r[6]=f*E+m*G+_*L+p*J,r[10]=f*R+m*C+_*W+p*H,r[14]=f*x+m*D+_*B+p*q,r[3]=g*S+M*w+T*ee+v*P,r[7]=g*E+M*G+T*L+v*J,r[11]=g*R+M*C+T*W+v*H,r[15]=g*x+M*D+T*B+v*q,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],s=e[1],o=e[5],a=e[9],c=e[13],l=e[2],u=e[6],h=e[10],d=e[14],f=e[3],m=e[7],_=e[11],p=e[15],g=a*d-c*h,M=o*d-c*u,T=o*h-a*u,v=s*d-c*l,S=s*h-a*l,E=s*u-o*l;return t*(m*g-_*M+p*T)-n*(f*g-_*v+p*S)+i*(f*M-m*v+p*E)-r*(f*T-m*S+_*E)}determinantAffine(){let e=this.elements,t=e[0],n=e[4],i=e[8],r=e[1],s=e[5],o=e[9],a=e[2],c=e[6],l=e[10];return t*(s*l-o*c)-n*(r*l-o*a)+i*(r*c-s*a)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let i=this.elements;if(e.isVector3)i[12]=e.x,i[13]=e.y,i[14]=e.z;else i[12]=e,i[13]=t,i[14]=n;return this}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=e[9],h=e[10],d=e[11],f=e[12],m=e[13],_=e[14],p=e[15],g=t*o-n*s,M=t*a-i*s,T=t*c-r*s,v=n*a-i*o,S=n*c-r*o,E=i*c-r*a,R=l*m-u*f,x=l*_-h*f,w=l*p-d*f,G=u*_-h*m,C=u*p-d*m,D=h*p-d*_,ee=g*D-M*C+T*G+v*w-S*x+E*R;if(ee===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let L=1/ee;return e[0]=(o*D-a*C+c*G)*L,e[1]=(i*C-n*D-r*G)*L,e[2]=(m*E-_*S+p*v)*L,e[3]=(h*S-u*E-d*v)*L,e[4]=(a*w-s*D-c*x)*L,e[5]=(t*D-i*w+r*x)*L,e[6]=(_*T-f*E-p*M)*L,e[7]=(l*E-h*T+d*M)*L,e[8]=(s*C-o*w+c*R)*L,e[9]=(n*w-t*C-r*R)*L,e[10]=(f*S-m*T+p*g)*L,e[11]=(u*T-l*S-d*g)*L,e[12]=(o*x-s*G-a*R)*L,e[13]=(t*G-n*x+i*R)*L,e[14]=(m*M-f*v-_*g)*L,e[15]=(l*v-u*M+h*g)*L,this}scale(e){let t=this.elements,{x:n,y:i,z:r}=e;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){if(e.isVector3)this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1);else this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1);return this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),i=Math.sin(t),r=1-n,{x:s,y:o,z:a}=e,c=r*s,l=r*o;return this.set(c*s+n,c*o-i*a,c*a+i*o,0,c*o+i*a,l*o+n,l*a-i*s,0,c*a-i*o,l*a+i*s,r*a*a+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,r,s){return this.set(1,n,r,0,e,1,s,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){let i=this.elements,{_x:r,_y:s,_z:o,_w:a}=t,c=r+r,l=s+s,u=o+o,h=r*c,d=r*l,f=r*u,m=s*l,_=s*u,p=o*u,g=a*c,M=a*l,T=a*u,{x:v,y:S,z:E}=n;return i[0]=(1-(m+p))*v,i[1]=(d+T)*v,i[2]=(f-M)*v,i[3]=0,i[4]=(d-T)*S,i[5]=(1-(h+p))*S,i[6]=(_+g)*S,i[7]=0,i[8]=(f+M)*E,i[9]=(_-g)*E,i[10]=(1-(h+m))*E,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){let i=this.elements;e.x=i[12],e.y=i[13],e.z=i[14];let r=this.determinantAffine();if(r===0)return n.set(1,1,1),t.identity(),this;let s=fs.set(i[0],i[1],i[2]).length(),o=fs.set(i[4],i[5],i[6]).length(),a=fs.set(i[8],i[9],i[10]).length();if(r<0)s=-s;qn.copy(this);let c=1/s,l=1/o,u=1/a;return qn.elements[0]*=c,qn.elements[1]*=c,qn.elements[2]*=c,qn.elements[4]*=l,qn.elements[5]*=l,qn.elements[6]*=l,qn.elements[8]*=u,qn.elements[9]*=u,qn.elements[10]*=u,t.setFromRotationMatrix(qn),n.x=s,n.y=o,n.z=a,this}makePerspective(e,t,n,i,r,s,o=2000,a=!1){let c=this.elements,l=2*r/(t-e),u=2*r/(n-i),h=(t+e)/(t-e),d=(n+i)/(n-i),f,m;if(a)f=r/(s-r),m=s*r/(s-r);else if(o===2000)f=-(s+r)/(s-r),m=-2*s*r/(s-r);else if(o===2001)f=-s/(s-r),m=-s*r/(s-r);else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=h,c[12]=0,c[1]=0,c[5]=u,c[9]=d,c[13]=0,c[2]=0,c[6]=0,c[10]=f,c[14]=m,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,i,r,s,o=2000,a=!1){let c=this.elements,l=2/(t-e),u=2/(n-i),h=-(t+e)/(t-e),d=-(n+i)/(n-i),f,m;if(a)f=1/(s-r),m=s/(s-r);else if(o===2000)f=-2/(s-r),m=-(s+r)/(s-r);else if(o===2001)f=-1/(s-r),m=-r/(s-r);else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=0,c[12]=h,c[1]=0,c[5]=u,c[9]=0,c[13]=d,c[2]=0,c[6]=0,c[10]=f,c[14]=m,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}var fs=new z,qn=new Xe,kM=new z(0,0,0),BM=new z(1,1,1),sr=new z,lc=new z,Tn=new z,W0=new Xe,Z0=new Yt;class xi{constructor(e=0,t=0,n=0,i=xi.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let i=e.elements,r=i[0],s=i[4],o=i[8],a=i[1],c=i[5],l=i[9],u=i[2],h=i[6],d=i[10];switch(t){case"XYZ":if(this._y=Math.asin(Je(o,-1,1)),Math.abs(o)<0.9999999)this._x=Math.atan2(-l,d),this._z=Math.atan2(-s,r);else this._x=Math.atan2(h,c),this._z=0;break;case"YXZ":if(this._x=Math.asin(-Je(l,-1,1)),Math.abs(l)<0.9999999)this._y=Math.atan2(o,d),this._z=Math.atan2(a,c);else this._y=Math.atan2(-u,r),this._z=0;break;case"ZXY":if(this._x=Math.asin(Je(h,-1,1)),Math.abs(h)<0.9999999)this._y=Math.atan2(-u,d),this._z=Math.atan2(-s,c);else this._y=0,this._z=Math.atan2(a,r);break;case"ZYX":if(this._y=Math.asin(-Je(u,-1,1)),Math.abs(u)<0.9999999)this._x=Math.atan2(h,d),this._z=Math.atan2(a,r);else this._x=0,this._z=Math.atan2(-s,c);break;case"YZX":if(this._z=Math.asin(Je(a,-1,1)),Math.abs(a)<0.9999999)this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,r);else this._x=0,this._y=Math.atan2(o,d);break;case"XZY":if(this._z=Math.asin(-Je(s,-1,1)),Math.abs(s)<0.9999999)this._x=Math.atan2(h,c),this._y=Math.atan2(o,r);else this._x=Math.atan2(-l,d),this._y=0;break;default:Ue("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}if(this._order=t,n===!0)this._onChangeCallback();return this}setFromQuaternion(e,t,n){return W0.makeRotationFromQuaternion(e),this.setFromRotationMatrix(W0,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Z0.setFromEuler(this),this.setFromQuaternion(Z0,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){if(this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0)this._order=e[3];return this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}xi.DEFAULT_ORDER="XYZ";class Kc{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}var GM=0,X0=new z,ps=new Yt,Fi=new Xe,uc=new z,Po=new z,HM=new z,VM=new Yt,j0=new z(1,0,0),q0=new z(0,1,0),Y0=new z(0,0,1),K0={type:"added"},$M={type:"removed"},ms={type:"childadded",child:null},Wu={type:"childremoved",child:null};class _t extends ii{constructor(){super();this.isObject3D=!0,Object.defineProperty(this,"id",{value:GM++}),this.uuid=Qn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=_t.DEFAULT_UP.clone();let e=new z,t=new xi,n=new Yt,i=new z(1,1,1);function r(){n.setFromEuler(t,!1)}function s(){t.setFromQuaternion(n,void 0,!1)}t._onChange(r),n._onChange(s),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Xe},normalMatrix:{value:new We}}),this.matrix=new Xe,this.matrixWorld=new Xe,this.matrixAutoUpdate=_t.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=_t.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Kc,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){if(this.matrixAutoUpdate)this.updateMatrix();this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return ps.setFromAxisAngle(e,t),this.quaternion.multiply(ps),this}rotateOnWorldAxis(e,t){return ps.setFromAxisAngle(e,t),this.quaternion.premultiply(ps),this}rotateX(e){return this.rotateOnAxis(j0,e)}rotateY(e){return this.rotateOnAxis(q0,e)}rotateZ(e){return this.rotateOnAxis(Y0,e)}translateOnAxis(e,t){return X0.copy(e).applyQuaternion(this.quaternion),this.position.add(X0.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(j0,e)}translateY(e){return this.translateOnAxis(q0,e)}translateZ(e){return this.translateOnAxis(Y0,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Fi.copy(this.matrixWorld).invert())}lookAt(e,t,n){if(e.isVector3)uc.copy(e);else uc.set(e,t,n);let i=this.parent;if(this.updateWorldMatrix(!0,!1),Po.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight)Fi.lookAt(Po,uc,this.up);else Fi.lookAt(uc,Po,this.up);if(this.quaternion.setFromRotationMatrix(Fi),i)Fi.extractRotation(i.matrixWorld),ps.setFromRotationMatrix(Fi),this.quaternion.premultiply(ps.invert())}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}if(e===this)return Ve("Object3D.add: object can't be added as a child of itself.",e),this;if(e&&e.isObject3D)e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(K0),ms.child=e,this.dispatchEvent(ms),ms.child=null;else Ve("Object3D.add: object not an instance of THREE.Object3D.",e);return this}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let t=this.children.indexOf(e);if(t!==-1)e.parent=null,this.children.splice(t,1),e.dispatchEvent($M),Wu.child=e,this.dispatchEvent(Wu),Wu.child=null;return this}removeFromParent(){let e=this.parent;if(e!==null)e.remove(this);return this}clear(){return this.remove(...this.children)}attach(e){if(this.updateWorldMatrix(!0,!1),Fi.copy(this.matrixWorld).invert(),e.parent!==null)e.parent.updateWorldMatrix(!0,!1),Fi.multiply(e.parent.matrixWorld);return e.applyMatrix4(Fi),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(K0),ms.child=e,this.dispatchEvent(ms),ms.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,i=this.children.length;n<i;n++){let s=this.children[n].getObjectByProperty(e,t);if(s!==void 0)return s}return}getObjectsByProperty(e,t,n=[]){if(this[e]===t)n.push(this);let i=this.children;for(let r=0,s=i.length;r<s;r++)i[r].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Po,e,HM),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Po,VM,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}intersectsFrustum(){}traverse(e){e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;if(t!==null)e(t),t.traverseAncestors(e)}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let{x:t,y:n,z:i}=e,r=this.matrix.elements;r[12]+=t-r[0]*t-r[4]*n-r[8]*i,r[13]+=n-r[1]*t-r[5]*n-r[9]*i,r[14]+=i-r[2]*t-r[6]*n-r[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||e){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,e=!0}let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){let i=this.parent;if(e===!0&&i!==null)i.updateWorldMatrix(!0,!1);if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||n){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,n=!0}if(t===!0){let r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].updateWorldMatrix(!1,!0,n)}}toJSON(e){let t=e===void 0||typeof e==="string",n={};if(t)e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"};let i={};if(i.uuid=this.uuid,i.type=this.type,i.name=this.name,i.castShadow=this.castShadow,i.receiveShadow=this.receiveShadow,i.visible=this.visible,i.frustumCulled=this.frustumCulled,i.renderOrder=this.renderOrder,i.static=this.static,i.matrixAutoUpdate=this.matrixAutoUpdate,Object.keys(this.userData).length>0)i.userData=this.userData;if(i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null)i.pivot=this.pivot.toArray();if(this.morphTargetDictionary!==void 0)i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary);if(this.morphTargetInfluences!==void 0)i.morphTargetInfluences=this.morphTargetInfluences.slice();if(this.isInstancedMesh){if(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null)i.instanceColor=this.instanceColor.toJSON()}if(this.isBatchedMesh){if(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map((o)=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map((o)=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null)i.colorsTexture=this._colorsTexture.toJSON(e);if(this.boundingSphere!==null)i.boundingSphere=this.boundingSphere.toJSON();if(this.boundingBox!==null)i.boundingBox=this.boundingBox.toJSON()}function r(o,a){if(o[a.uuid]===void 0)o[a.uuid]=a.toJSON(e);return a.uuid}if(this.isScene){if(this.background){if(this.background.isColor)i.background=this.background.toJSON();else if(this.background.isTexture)i.background=this.background.toJSON(e).uuid}if(this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0)i.environment=this.environment.toJSON(e).uuid}else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);let o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){let a=o.shapes;if(Array.isArray(a))for(let c=0,l=a.length;c<l;c++){let u=a[c];r(e.shapes,u)}else r(e.shapes,a)}}if(this.isSkinnedMesh){if(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0)r(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid}if(this.material!==void 0)if(Array.isArray(this.material)){let o=[];for(let a=0,c=this.material.length;a<c;a++)o.push(r(e.materials,this.material[a]));i.material=o}else i.material=r(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){let a=this.animations[o];i.animations.push(r(e.animations,a))}}if(t){let o=s(e.geometries),a=s(e.materials),c=s(e.textures),l=s(e.images),u=s(e.shapes),h=s(e.skeletons),d=s(e.animations),f=s(e.nodes);if(o.length>0)n.geometries=o;if(a.length>0)n.materials=a;if(c.length>0)n.textures=c;if(l.length>0)n.images=l;if(u.length>0)n.shapes=u;if(h.length>0)n.skeletons=h;if(d.length>0)n.animations=d;if(f.length>0)n.nodes=f}return n.object=i,n;function s(o){let a=[];for(let c in o){let l=o[c];delete l.metadata,a.push(l)}return a}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){let i=e.children[n];this.add(i.clone())}return this}dispose(){this.dispatchEvent({type:"dispose"})}}_t.DEFAULT_UP=new z(0,1,0);_t.DEFAULT_MATRIX_AUTO_UPDATE=!0;_t.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class gi extends _t{constructor(){super();this.isGroup=!0,this.type="Group"}}var WM={type:"move"};class Yo{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){if(this._hand===null)this._hand=new gi,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1};return this._hand}getTargetRaySpace(){if(this._targetRay===null)this._targetRay=new gi,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new z,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new z;return this._targetRay}getGripSpace(){if(this._grip===null)this._grip=new gi,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new z,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new z,this._grip.eventsEnabled=!1;return this._grip}dispatchEvent(e){if(this._targetRay!==null)this._targetRay.dispatchEvent(e);if(this._grip!==null)this._grip.dispatchEvent(e);if(this._hand!==null)this._hand.dispatchEvent(e);return this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){if(this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null)this._targetRay.visible=!1;if(this._grip!==null)this._grip.visible=!1;if(this._hand!==null)this._hand.visible=!1;return this}update(e,t,n){let i=null,r=null,s=null,o=this._targetRay,a=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){s=!0;for(let m of e.hand.values()){let _=t.getJointPose(m,n),p=this._getHandJoint(c,m);if(_!==null)p.matrix.fromArray(_.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=_.radius;p.visible=_!==null}let l=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],h=l.position.distanceTo(u.position),d=0.02,f=0.005;if(c.inputState.pinching&&h>d+f)c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this});else if(!c.inputState.pinching&&h<=d-f)c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this})}else if(a!==null&&e.gripSpace){if(r=t.getPose(e.gripSpace,n),r!==null){if(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,r.linearVelocity)a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity);else a.hasLinearVelocity=!1;if(r.angularVelocity)a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity);else a.hasAngularVelocity=!1;if(a.eventsEnabled)a.dispatchEvent({type:"gripUpdated",data:e,target:this})}}if(o!==null){if(i=t.getPose(e.targetRaySpace,n),i===null&&r!==null)i=r;if(i!==null){if(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity)o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity);else o.hasLinearVelocity=!1;if(i.angularVelocity)o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity);else o.hasAngularVelocity=!1;this.dispatchEvent(WM)}}}if(o!==null)o.visible=i!==null;if(a!==null)a.visible=r!==null;if(c!==null)c.visible=s!==null;return this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new gi;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}var bv={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},or={h:0,s:0,l:0},hc={h:0,s:0,l:0};function Zu(e,t,n){if(n<0)n+=1;if(n>1)n-=1;if(n<0.16666666666666666)return e+(t-e)*6*n;if(n<0.5)return t;if(n<0.6666666666666666)return e+(t-e)*6*(0.6666666666666666-n);return e}class Ge{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let i=e;if(i&&i.isColor)this.copy(i);else if(typeof i==="number")this.setHex(i);else if(typeof i==="string")this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t="srgb"){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Ke.colorSpaceToWorking(this,t),this}setRGB(e,t,n,i=Ke.workingColorSpace){return this.r=e,this.g=t,this.b=n,Ke.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=Ke.workingColorSpace){if(e=hd(e,1),t=Je(t,0,1),n=Je(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=0.5?n*(1+t):n+t-n*t,s=2*n-r;this.r=Zu(s,r,e+0.3333333333333333),this.g=Zu(s,r,e),this.b=Zu(s,r,e-0.3333333333333333)}return Ke.colorSpaceToWorking(this,i),this}setStyle(e,t="srgb"){function n(r){if(r===void 0)return;if(parseFloat(r)<1)Ue("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r,s=i[1],o=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:Ue("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){let r=i[1],s=r.length;if(s===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);else if(s===6)return this.setHex(parseInt(r,16),t);else Ue("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t="srgb"){let n=bv[e.toLowerCase()];if(n!==void 0)this.setHex(n,t);else Ue("Color: Unknown color "+e);return this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Vi(e.r),this.g=Vi(e.g),this.b=Vi(e.b),this}copyLinearToSRGB(e){return this.r=Ts(e.r),this.g=Ts(e.g),this.b=Ts(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e="srgb"){return Ke.workingToColorSpace(an.copy(this),e),Math.round(Je(an.r*255,0,255))*65536+Math.round(Je(an.g*255,0,255))*256+Math.round(Je(an.b*255,0,255))}getHexString(e="srgb"){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Ke.workingColorSpace){Ke.workingToColorSpace(an.copy(this),t);let{r:n,g:i,b:r}=an,s=Math.max(n,i,r),o=Math.min(n,i,r),a,c,l=(o+s)/2;if(o===s)a=0,c=0;else{let u=s-o;switch(c=l<=0.5?u/(s+o):u/(2-s-o),s){case n:a=(i-r)/u+(i<r?6:0);break;case i:a=(r-n)/u+2;break;case r:a=(n-i)/u+4;break}a/=6}return e.h=a,e.s=c,e.l=l,e}getRGB(e,t=Ke.workingColorSpace){return Ke.workingToColorSpace(an.copy(this),t),e.r=an.r,e.g=an.g,e.b=an.b,e}getStyle(e="srgb"){Ke.workingToColorSpace(an.copy(this),e);let{r:t,g:n,b:i}=an;if(e!=="srgb")return`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`;return`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(e,t,n){return this.getHSL(or),this.setHSL(or.h+e,or.s+t,or.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(or),e.getHSL(hc);let n=Bo(or.h,hc.h,t),i=Bo(or.s,hc.s,t),r=Bo(or.l,hc.l,t);return this.setHSL(n,i,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,i=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*i,this.g=r[1]*t+r[4]*n+r[7]*i,this.b=r[2]*t+r[5]*n+r[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}var an=new Ge;Ge.NAMES=bv;class zs extends _t{constructor(){super();if(this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new xi,this.environmentIntensity=1,this.environmentRotation=new xi,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){if(super.copy(e,t),e.background!==null)this.background=e.background.clone();if(e.environment!==null)this.environment=e.environment.clone();if(e.fog!==null)this.fog=e.fog.clone();if(this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null)this.overrideMaterial=e.overrideMaterial.clone();return this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);if(this.fog!==null)t.object.fog=this.fog.toJSON();return t.object.backgroundBlurriness=this.backgroundBlurriness,t.object.backgroundIntensity=this.backgroundIntensity,t.object.backgroundRotation=this.backgroundRotation.toArray(),t.object.environmentIntensity=this.environmentIntensity,t.object.environmentRotation=this.environmentRotation.toArray(),t}}var Yn=new z,zi=new z,Xu=new z,ki=new z,gs=new z,_s=new z,J0=new z,ju=new z,qu=new z,Yu=new z,Ku=new pt,Ju=new pt,Qu=new pt;class kn{constructor(e=new z,t=new z,n=new z){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),Yn.subVectors(e,t),i.cross(Yn);let r=i.lengthSq();if(r>0)return i.multiplyScalar(1/Math.sqrt(r));return i.set(0,0,0)}static getBarycoord(e,t,n,i,r){Yn.subVectors(i,t),zi.subVectors(n,t),Xu.subVectors(e,t);let s=Yn.dot(Yn),o=Yn.dot(zi),a=Yn.dot(Xu),c=zi.dot(zi),l=zi.dot(Xu),u=s*c-o*o;if(u===0)return r.set(0,0,0),null;let h=1/u,d=(c*a-o*l)*h,f=(s*l-o*a)*h;return r.set(1-d-f,f,d)}static containsPoint(e,t,n,i){if(this.getBarycoord(e,t,n,i,ki)===null)return!1;return ki.x>=0&&ki.y>=0&&ki.x+ki.y<=1}static getInterpolation(e,t,n,i,r,s,o,a){if(this.getBarycoord(e,t,n,i,ki)===null){if(a.x=0,a.y=0,"z"in a)a.z=0;if("w"in a)a.w=0;return null}return a.setScalar(0),a.addScaledVector(r,ki.x),a.addScaledVector(s,ki.y),a.addScaledVector(o,ki.z),a}static getInterpolatedAttribute(e,t,n,i,r,s){return Ku.setScalar(0),Ju.setScalar(0),Qu.setScalar(0),Ku.fromBufferAttribute(e,t),Ju.fromBufferAttribute(e,n),Qu.fromBufferAttribute(e,i),s.setScalar(0),s.addScaledVector(Ku,r.x),s.addScaledVector(Ju,r.y),s.addScaledVector(Qu,r.z),s}static isFrontFacing(e,t,n,i){return Yn.subVectors(n,t),zi.subVectors(e,t),Yn.cross(zi).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Yn.subVectors(this.c,this.b),zi.subVectors(this.a,this.b),Yn.cross(zi).length()*0.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(0.3333333333333333)}getNormal(e){return kn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return kn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,r){return kn.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return kn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return kn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,i=this.b,r=this.c,s,o;gs.subVectors(i,n),_s.subVectors(r,n),ju.subVectors(e,n);let a=gs.dot(ju),c=_s.dot(ju);if(a<=0&&c<=0)return t.copy(n);qu.subVectors(e,i);let l=gs.dot(qu),u=_s.dot(qu);if(l>=0&&u<=l)return t.copy(i);let h=a*u-l*c;if(h<=0&&a>=0&&l<=0)return s=a/(a-l),t.copy(n).addScaledVector(gs,s);Yu.subVectors(e,r);let d=gs.dot(Yu),f=_s.dot(Yu);if(f>=0&&d<=f)return t.copy(r);let m=d*c-a*f;if(m<=0&&c>=0&&f<=0)return o=c/(c-f),t.copy(n).addScaledVector(_s,o);let _=l*f-d*u;if(_<=0&&u-l>=0&&d-f>=0)return J0.subVectors(r,i),o=(u-l)/(u-l+(d-f)),t.copy(i).addScaledVector(J0,o);let p=1/(_+m+h);return s=m*p,o=h*p,t.copy(n).addScaledVector(gs,s).addScaledVector(_s,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class Vt{constructor(e=new z(1/0,1/0,1/0),t=new z(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(Kn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Kn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=Kn.copy(t).multiplyScalar(0.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(0.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0){let r=n.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let s=0,o=r.count;s<o;s++){if(e.isMesh===!0)e.getVertexPosition(s,Kn);else Kn.fromBufferAttribute(r,s);Kn.applyMatrix4(e.matrixWorld),this.expandByPoint(Kn)}else{if(e.boundingBox!==void 0){if(e.boundingBox===null)e.computeBoundingBox();dc.copy(e.boundingBox)}else{if(n.boundingBox===null)n.computeBoundingBox();dc.copy(n.boundingBox)}dc.applyMatrix4(e.matrixWorld),this.union(dc)}}let i=e.children;for(let r=0,s=i.length;r<s;r++)this.expandByObject(i[r],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Kn),Kn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;if(e.normal.x>0)t=e.normal.x*this.min.x,n=e.normal.x*this.max.x;else t=e.normal.x*this.max.x,n=e.normal.x*this.min.x;if(e.normal.y>0)t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y;else t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y;if(e.normal.z>0)t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z;else t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z;return t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Lo),fc.subVectors(this.max,Lo),xs.subVectors(e.a,Lo),vs.subVectors(e.b,Lo),ys.subVectors(e.c,Lo),ar.subVectors(vs,xs),cr.subVectors(ys,vs),kr.subVectors(xs,ys);let t=[0,-ar.z,ar.y,0,-cr.z,cr.y,0,-kr.z,kr.y,ar.z,0,-ar.x,cr.z,0,-cr.x,kr.z,0,-kr.x,-ar.y,ar.x,0,-cr.y,cr.x,0,-kr.y,kr.x,0];if(!eh(t,xs,vs,ys,fc))return!1;if(t=[1,0,0,0,1,0,0,0,1],!eh(t,xs,vs,ys,fc))return!1;return pc.crossVectors(ar,cr),t=[pc.x,pc.y,pc.z],eh(t,xs,vs,ys,fc)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Kn).distanceTo(e)}getBoundingSphere(e){if(this.isEmpty())e.makeEmpty();else this.getCenter(e.center),e.radius=this.getSize(Kn).length()*0.5;return e}intersect(e){if(this.min.max(e.min),this.max.min(e.max),this.isEmpty())this.makeEmpty();return this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){if(this.isEmpty())return this;return Bi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Bi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Bi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Bi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Bi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Bi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Bi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Bi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Bi),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}var Bi=[new z,new z,new z,new z,new z,new z,new z,new z],Kn=new z,dc=new Vt,xs=new z,vs=new z,ys=new z,ar=new z,cr=new z,kr=new z,Lo=new z,fc=new z,pc=new z,Br=new z;function eh(e,t,n,i,r){for(let s=0,o=e.length-3;s<=o;s+=3){Br.fromArray(e,s);let a=r.x*Math.abs(Br.x)+r.y*Math.abs(Br.y)+r.z*Math.abs(Br.z),c=t.dot(Br),l=n.dot(Br),u=i.dot(Br);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>a)return!1}return!0}var Gt=new z,mc=new ke,ZM=0;class Kt extends ii{constructor(e,t,n=!1){super();if(Array.isArray(e))throw TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:ZM++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=35044,this.updateRanges=[],this.gpuType=1015,this.version=0}onUploadCallback(){}set needsUpdate(e){if(e===!0)this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[e+i]=t.array[n+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)mc.fromBufferAttribute(this,t),mc.applyMatrix3(e),this.setXY(t,mc.x,mc.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)Gt.fromBufferAttribute(this,t),Gt.applyMatrix3(e),this.setXYZ(t,Gt.x,Gt.y,Gt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Gt.fromBufferAttribute(this,t),Gt.applyMatrix4(e),this.setXYZ(t,Gt.x,Gt.y,Gt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Gt.fromBufferAttribute(this,t),Gt.applyNormalMatrix(e),this.setXYZ(t,Gt.x,Gt.y,Gt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Gt.fromBufferAttribute(this,t),Gt.transformDirection(e),this.setXYZ(t,Gt.x,Gt.y,Gt.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];if(this.normalized)n=Jn(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=ft(n,this.array);return this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];if(this.normalized)t=Jn(t,this.array);return t}setX(e,t){if(this.normalized)t=ft(t,this.array);return this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];if(this.normalized)t=Jn(t,this.array);return t}setY(e,t){if(this.normalized)t=ft(t,this.array);return this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];if(this.normalized)t=Jn(t,this.array);return t}setZ(e,t){if(this.normalized)t=ft(t,this.array);return this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];if(this.normalized)t=Jn(t,this.array);return t}setW(e,t){if(this.normalized)t=ft(t,this.array);return this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){if(e*=this.itemSize,this.normalized)t=ft(t,this.array),n=ft(n,this.array);return this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){if(e*=this.itemSize,this.normalized)t=ft(t,this.array),n=ft(n,this.array),i=ft(i,this.array);return this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,r){if(e*=this.itemSize,this.normalized)t=ft(t,this.array),n=ft(n,this.array),i=ft(i,this.array),r=ft(r,this.array);return this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return e.name=this.name,e.usage=this.usage,e.gpuType=this.gpuType,e}dispose(){this.dispatchEvent({type:"dispose"})}}class Jc extends Kt{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class Qc extends Kt{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class vn extends Kt{constructor(e,t,n){super(new Float32Array(e),t,n)}}var XM=new Vt,No=new z,th=new z;class In{constructor(e=new z,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;if(t!==void 0)n.copy(t);else XM.setFromPoints(e).getCenter(n);let i=0;for(let r=0,s=e.length;r<s;r++)i=Math.max(i,n.distanceToSquared(e[r]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let n=this.center.distanceToSquared(e);if(t.copy(e),n>this.radius*this.radius)t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center);return t}getBoundingBox(e){if(this.isEmpty())return e.makeEmpty(),e;return e.set(this.center,this.center),e.expandByScalar(this.radius),e}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;No.subVectors(e,this.center);let t=No.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),i=(n-this.radius)*0.5;this.center.addScaledVector(No,i/n),this.radius+=i}return this}union(e){if(e.isEmpty())return this;if(this.isEmpty())return this.copy(e),this;if(this.center.equals(e.center)===!0)this.radius=Math.max(this.radius,e.radius);else th.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(No.copy(e.center).add(th)),this.expandByPoint(No.copy(e.center).sub(th));return this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}var jM=0,Fn=new Xe,nh=new _t,bs=new z,An=new Vt,Do=new Vt,qt=new z;class ln extends ii{constructor(){super();this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:jM++}),this.uuid=Qn(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){if(Array.isArray(e))this.index=new((xM(e))?Qc:Jc)(e,1);else this.index=e;return this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;if(t!==void 0)t.applyMatrix4(e),t.needsUpdate=!0;let n=this.attributes.normal;if(n!==void 0){let r=new We().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}let i=this.attributes.tangent;if(i!==void 0)i.transformDirection(e),i.needsUpdate=!0;if(this.boundingBox!==null)this.computeBoundingBox();if(this.boundingSphere!==null)this.computeBoundingSphere();return this._transformed=!0,this}applyQuaternion(e){return Fn.makeRotationFromQuaternion(e),this.applyMatrix4(Fn),this}rotateX(e){return Fn.makeRotationX(e),this.applyMatrix4(Fn),this}rotateY(e){return Fn.makeRotationY(e),this.applyMatrix4(Fn),this}rotateZ(e){return Fn.makeRotationZ(e),this.applyMatrix4(Fn),this}translate(e,t,n){return Fn.makeTranslation(e,t,n),this.applyMatrix4(Fn),this}scale(e,t,n){return Fn.makeScale(e,t,n),this.applyMatrix4(Fn),this}lookAt(e){return nh.lookAt(e),nh.updateMatrix(),this.applyMatrix4(nh.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(bs).negate(),this.translate(bs.x,bs.y,bs.z),this}setFromPoints(e){let t=this.getAttribute("position");if(t===void 0){let n=[];for(let i=0,r=e.length;i<r;i++){let s=e[i];n.push(s.x,s.y,s.z||0)}this.setAttribute("position",new vn(n,3))}else{let n=Math.min(e.length,t.count);for(let i=0;i<n;i++){let r=e[i];t.setXYZ(i,r.x,r.y,r.z||0)}if(e.length>t.count)Ue("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.");t.needsUpdate=!0}return this}computeBoundingBox(){if(this.boundingBox===null)this.boundingBox=new Vt;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ve("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new z(-1/0,-1/0,-1/0),new z(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){let r=t[n];if(An.setFromBufferAttribute(r),this.morphTargetsRelative)qt.addVectors(this.boundingBox.min,An.min),this.boundingBox.expandByPoint(qt),qt.addVectors(this.boundingBox.max,An.max),this.boundingBox.expandByPoint(qt);else this.boundingBox.expandByPoint(An.min),this.boundingBox.expandByPoint(An.max)}}else this.boundingBox.makeEmpty();if(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))Ve('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){if(this.boundingSphere===null)this.boundingSphere=new In;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ve("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new z,1/0);return}if(e){let n=this.boundingSphere.center;if(An.setFromBufferAttribute(e),t)for(let r=0,s=t.length;r<s;r++){let o=t[r];if(Do.setFromBufferAttribute(o),this.morphTargetsRelative)qt.addVectors(An.min,Do.min),An.expandByPoint(qt),qt.addVectors(An.max,Do.max),An.expandByPoint(qt);else An.expandByPoint(Do.min),An.expandByPoint(Do.max)}An.getCenter(n);let i=0;for(let r=0,s=e.count;r<s;r++)qt.fromBufferAttribute(e,r),i=Math.max(i,n.distanceToSquared(qt));if(t)for(let r=0,s=t.length;r<s;r++){let o=t[r],a=this.morphTargetsRelative;for(let c=0,l=o.count;c<l;c++){if(qt.fromBufferAttribute(o,c),a)bs.fromBufferAttribute(e,c),qt.add(bs);i=Math.max(i,n.distanceToSquared(qt))}}if(this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius))Ve('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){Ve("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let{position:n,normal:i,uv:r}=t,s=this.getAttribute("tangent");if(s===void 0||s.count!==n.count)s=new Kt(new Float32Array(4*n.count),4),this.setAttribute("tangent",s);let o=[],a=[];for(let R=0;R<n.count;R++)o[R]=new z,a[R]=new z;let c=new z,l=new z,u=new z,h=new ke,d=new ke,f=new ke,m=new z,_=new z;function p(R,x,w){c.fromBufferAttribute(n,R),l.fromBufferAttribute(n,x),u.fromBufferAttribute(n,w),h.fromBufferAttribute(r,R),d.fromBufferAttribute(r,x),f.fromBufferAttribute(r,w),l.sub(c),u.sub(c),d.sub(h),f.sub(h);let G=1/(d.x*f.y-f.x*d.y);if(!isFinite(G))return;m.copy(l).multiplyScalar(f.y).addScaledVector(u,-d.y).multiplyScalar(G),_.copy(u).multiplyScalar(d.x).addScaledVector(l,-f.x).multiplyScalar(G),o[R].add(m),o[x].add(m),o[w].add(m),a[R].add(_),a[x].add(_),a[w].add(_)}let g=this.groups;if(g.length===0)g=[{start:0,count:e.count}];for(let R=0,x=g.length;R<x;++R){let w=g[R],{start:G,count:C}=w;for(let D=G,ee=G+C;D<ee;D+=3)p(e.getX(D+0),e.getX(D+1),e.getX(D+2))}let M=new z,T=new z,v=new z,S=new z;function E(R){v.fromBufferAttribute(i,R),S.copy(v);let x=o[R];M.copy(x),M.sub(v.multiplyScalar(v.dot(x))).normalize(),T.crossVectors(S,x);let G=T.dot(a[R])<0?-1:1;s.setXYZW(R,M.x,M.y,M.z,G)}for(let R=0,x=g.length;R<x;++R){let w=g[R],{start:G,count:C}=w;for(let D=G,ee=G+C;D<ee;D+=3)E(e.getX(D+0)),E(e.getX(D+1)),E(e.getX(D+2))}this._transformed=!0}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0||n.count!==t.count)n=new Kt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let h=0,d=n.count;h<d;h++)n.setXYZ(h,0,0,0);let i=new z,r=new z,s=new z,o=new z,a=new z,c=new z,l=new z,u=new z;if(e)for(let h=0,d=e.count;h<d;h+=3){let f=e.getX(h+0),m=e.getX(h+1),_=e.getX(h+2);i.fromBufferAttribute(t,f),r.fromBufferAttribute(t,m),s.fromBufferAttribute(t,_),l.subVectors(s,r),u.subVectors(i,r),l.cross(u),o.fromBufferAttribute(n,f),a.fromBufferAttribute(n,m),c.fromBufferAttribute(n,_),o.add(l),a.add(l),c.add(l),n.setXYZ(f,o.x,o.y,o.z),n.setXYZ(m,a.x,a.y,a.z),n.setXYZ(_,c.x,c.y,c.z)}else for(let h=0,d=t.count;h<d;h+=3)i.fromBufferAttribute(t,h+0),r.fromBufferAttribute(t,h+1),s.fromBufferAttribute(t,h+2),l.subVectors(s,r),u.subVectors(i,r),l.cross(u),n.setXYZ(h+0,l.x,l.y,l.z),n.setXYZ(h+1,l.x,l.y,l.z),n.setXYZ(h+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)qt.fromBufferAttribute(e,t),qt.normalize(),e.setXYZ(t,qt.x,qt.y,qt.z)}toNonIndexed(){function e(o,a){let{array:c,itemSize:l,normalized:u}=o,h=new c.constructor(a.length*l),d=0,f=0;for(let m=0,_=a.length;m<_;m++){if(o.isInterleavedBufferAttribute)d=a[m]*o.data.stride+o.offset;else d=a[m]*l;for(let p=0;p<l;p++)h[f++]=c[d++]}return new Kt(h,l,u)}if(this.index===null)return Ue("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new ln,n=this.index.array,i=this.attributes;for(let o in i){let a=i[o],c=e(a,n);t.setAttribute(o,c)}let r=this.morphAttributes;for(let o in r){let a=[],c=r[o];for(let l=0,u=c.length;l<u;l++){let h=c[l],d=e(h,n);a.push(d)}t.morphAttributes[o]=a}t.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;for(let o=0,a=s.length;o<a;o++){let c=s[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){let e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,e.name=this.name,Object.keys(this.userData).length>0)e.userData=this.userData;if(this.parameters!==void 0&&this._transformed!==!0){let a=this.parameters;for(let c in a)if(a[c]!==void 0)e[c]=a[c];return e}e.data={attributes:{}};let t=this.index;if(t!==null)e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)};let n=this.attributes;for(let a in n){let c=n[a];e.data.attributes[a]=c.toJSON(e.data)}let i={},r=!1;for(let a in this.morphAttributes){let c=this.morphAttributes[a],l=[];for(let u=0,h=c.length;u<h;u++){let d=c[u];l.push(d.toJSON(e.data))}if(l.length>0)i[a]=l,r=!0}if(r)e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;if(s.length>0)e.data.groups=JSON.parse(JSON.stringify(s));let o=this.boundingSphere;if(o!==null)e.data.boundingSphere=o.toJSON();return e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;if(n!==null)this.setIndex(n.clone());let i=e.attributes;for(let c in i){let l=i[c];this.setAttribute(c,l.clone(t))}let r=e.morphAttributes;for(let c in r){let l=[],u=r[c];for(let h=0,d=u.length;h<d;h++)l.push(u[h].clone(t));this.morphAttributes[c]=l}this.morphTargetsRelative=e.morphTargetsRelative;let s=e.groups;for(let c=0,l=s.length;c<l;c++){let u=s[c];this.addGroup(u.start,u.count,u.materialIndex)}let o=e.boundingBox;if(o!==null)this.boundingBox=o.clone();let a=e.boundingSphere;if(a!==null)this.boundingSphere=a.clone();return this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Ko{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=35044,this.updateRanges=[],this.version=0,this.uuid=Qn()}onUploadCallback(){}set needsUpdate(e){if(e===!0)this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,r=this.stride;i<r;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){if(e.arrayBuffers===void 0)e.arrayBuffers={};if(this.array.buffer._uuid===void 0)this.array.buffer._uuid=Qn();if(e.arrayBuffers[this.array.buffer._uuid]===void 0)e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer;let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){if(e.arrayBuffers===void 0)e.arrayBuffers={};if(this.array.buffer._uuid===void 0)this.array.buffer._uuid=Qn();if(e.arrayBuffers[this.array.buffer._uuid]===void 0)e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer));let t={uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride};return t.usage=this.usage,t}}var gn=new z;class ks{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)gn.fromBufferAttribute(this,t),gn.applyMatrix4(e),this.setXYZ(t,gn.x,gn.y,gn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)gn.fromBufferAttribute(this,t),gn.applyNormalMatrix(e),this.setXYZ(t,gn.x,gn.y,gn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)gn.fromBufferAttribute(this,t),gn.transformDirection(e),this.setXYZ(t,gn.x,gn.y,gn.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];if(this.normalized)n=Jn(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=ft(n,this.array);return this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){if(this.normalized)t=ft(t,this.array);return this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){if(this.normalized)t=ft(t,this.array);return this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){if(this.normalized)t=ft(t,this.array);return this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){if(this.normalized)t=ft(t,this.array);return this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];if(this.normalized)t=Jn(t,this.array);return t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];if(this.normalized)t=Jn(t,this.array);return t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];if(this.normalized)t=Jn(t,this.array);return t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];if(this.normalized)t=Jn(t,this.array);return t}setXY(e,t,n){if(e=e*this.data.stride+this.offset,this.normalized)t=ft(t,this.array),n=ft(n,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){if(e=e*this.data.stride+this.offset,this.normalized)t=ft(t,this.array),n=ft(n,this.array),i=ft(i,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,r){if(e=e*this.data.stride+this.offset,this.normalized)t=ft(t,this.array),n=ft(n,this.array),i=ft(i,this.array),r=ft(r,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=r,this}clone(e){if(e===void 0){Go("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return new Kt(new this.array.constructor(t),this.itemSize,this.normalized)}else{if(e.interleavedBuffers===void 0)e.interleavedBuffers={};if(e.interleavedBuffers[this.data.uuid]===void 0)e.interleavedBuffers[this.data.uuid]=this.data.clone(e);return new ks(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}}toJSON(e){if(e===void 0){Go("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else{if(e.interleavedBuffers===void 0)e.interleavedBuffers={};if(e.interleavedBuffers[this.data.uuid]===void 0)e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e);return{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}}var ih=new z,qM=new z,YM=new We;class zn{constructor(e=new z(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let i=ih.subVectors(n,t).cross(qM.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,n=!0){let i=e.delta(ih),r=this.normal.dot(i);if(r===0){if(this.distanceToPoint(e.start)===0)return t.copy(e.start);return null}let s=-(e.start.dot(this.normal)+this.constant)/r;if(n===!0&&(s<0||s>1))return null;return t.copy(e.start).addScaledVector(i,s)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||YM.getNormalMatrix(e),i=this.coplanarPoint(ih).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}toJSON(){return{normal:this.normal.toArray(),constant:this.constant}}fromJSON(e){return this.normal.fromArray(e.normal),this.constant=e.constant,this}}var KM=0;class yn extends ii{constructor(){super();this.isMaterial=!0,Object.defineProperty(this,"id",{value:KM++}),this.uuid=Qn(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ge(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=7680,this.stencilZFail=7680,this.stencilZPass=7680,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){if(this._alphaTest>0!==e>0)this.version++;this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e===void 0)return;for(let t in e){let n=e[t];if(n===void 0){Ue(`Material: parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){Ue(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}if(i&&i.isColor)i.set(n);else if(i&&i.isVector2&&(n&&n.isVector2)||i&&i.isEuler&&(n&&n.isEuler)||i&&i.isVector3&&(n&&n.isVector3))i.copy(n);else this[t]=n}}toJSON(e){let t=e===void 0||typeof e==="string";if(t)e={textures:{},images:{}};let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};if(n.uuid=this.uuid,n.type=this.type,n.blending=this.blending,n.side=this.side,n.shadowSide=this.shadowSide,n.vertexColors=this.vertexColors,n.opacity=this.opacity,n.transparent=this.transparent,n.blendSrc=this.blendSrc,n.blendDst=this.blendDst,n.blendEquation=this.blendEquation,n.blendSrcAlpha=this.blendSrcAlpha,n.blendDstAlpha=this.blendDstAlpha,n.blendEquationAlpha=this.blendEquationAlpha,n.blendColor=this.blendColor.getHex(),n.blendAlpha=this.blendAlpha,n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.clipIntersection=this.clipIntersection,n.clipShadows=this.clipShadows,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,n.stencilWrite=this.stencilWrite,n.polygonOffset=this.polygonOffset,n.polygonOffsetFactor=this.polygonOffsetFactor,n.polygonOffsetUnits=this.polygonOffsetUnits,n.dithering=this.dithering,n.alphaTest=this.alphaTest,n.alphaHash=this.alphaHash,n.alphaToCoverage=this.alphaToCoverage,n.premultipliedAlpha=this.premultipliedAlpha,n.forceSinglePass=this.forceSinglePass,n.allowOverride=this.allowOverride,n.visible=this.visible,n.toneMapped=this.toneMapped,n.name=this.name,this.color&&this.color.isColor)n.color=this.color.getHex();if(this.roughness!==void 0)n.roughness=this.roughness;if(this.metalness!==void 0)n.metalness=this.metalness;if(this.sheen!==void 0)n.sheen=this.sheen;if(this.sheenColor&&this.sheenColor.isColor)n.sheenColor=this.sheenColor.getHex();if(this.sheenRoughness!==void 0)n.sheenRoughness=this.sheenRoughness;if(this.emissive&&this.emissive.isColor)n.emissive=this.emissive.getHex();if(this.emissiveIntensity!==void 0)n.emissiveIntensity=this.emissiveIntensity;if(this.specular&&this.specular.isColor)n.specular=this.specular.getHex();if(this.specularIntensity!==void 0)n.specularIntensity=this.specularIntensity;if(this.specularColor&&this.specularColor.isColor)n.specularColor=this.specularColor.getHex();if(this.shininess!==void 0)n.shininess=this.shininess;if(this.clearcoat!==void 0)n.clearcoat=this.clearcoat;if(this.clearcoatRoughness!==void 0)n.clearcoatRoughness=this.clearcoatRoughness;if(this.clearcoatMap&&this.clearcoatMap.isTexture)n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid;if(this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture)n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid;if(this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture)n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray();if(this.sheenColorMap&&this.sheenColorMap.isTexture)n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid;if(this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture)n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid;if(this.dispersion!==void 0)n.dispersion=this.dispersion;if(this.retroreflectivity!==void 0)n.retroreflectivity=this.retroreflectivity;if(this.iridescence!==void 0)n.iridescence=this.iridescence;if(this.iridescenceIOR!==void 0)n.iridescenceIOR=this.iridescenceIOR;if(this.iridescenceThicknessRange!==void 0)n.iridescenceThicknessRange=this.iridescenceThicknessRange;if(this.iridescenceMap&&this.iridescenceMap.isTexture)n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid;if(this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture)n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid;if(this.anisotropy!==void 0)n.anisotropy=this.anisotropy;if(this.anisotropyRotation!==void 0)n.anisotropyRotation=this.anisotropyRotation;if(this.anisotropyMap&&this.anisotropyMap.isTexture)n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid;if(this.map&&this.map.isTexture)n.map=this.map.toJSON(e).uuid;if(this.matcap&&this.matcap.isTexture)n.matcap=this.matcap.toJSON(e).uuid;if(this.alphaMap&&this.alphaMap.isTexture)n.alphaMap=this.alphaMap.toJSON(e).uuid;if(this.lightMap&&this.lightMap.isTexture)n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity;if(this.aoMap&&this.aoMap.isTexture)n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity;if(this.bumpMap&&this.bumpMap.isTexture)n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale;if(this.normalMap&&this.normalMap.isTexture)n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray();if(this.displacementMap&&this.displacementMap.isTexture)n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias;if(this.roughnessMap&&this.roughnessMap.isTexture)n.roughnessMap=this.roughnessMap.toJSON(e).uuid;if(this.metalnessMap&&this.metalnessMap.isTexture)n.metalnessMap=this.metalnessMap.toJSON(e).uuid;if(this.emissiveMap&&this.emissiveMap.isTexture)n.emissiveMap=this.emissiveMap.toJSON(e).uuid;if(this.specularMap&&this.specularMap.isTexture)n.specularMap=this.specularMap.toJSON(e).uuid;if(this.specularIntensityMap&&this.specularIntensityMap.isTexture)n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid;if(this.specularColorMap&&this.specularColorMap.isTexture)n.specularColorMap=this.specularColorMap.toJSON(e).uuid;if(this.envMap&&this.envMap.isTexture){if(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0)n.combine=this.combine}if(this.envMapRotation!==void 0)n.envMapRotation=this.envMapRotation.toArray();if(this.envMapIntensity!==void 0)n.envMapIntensity=this.envMapIntensity;if(this.reflectivity!==void 0)n.reflectivity=this.reflectivity;if(this.refractionRatio!==void 0)n.refractionRatio=this.refractionRatio;if(this.gradientMap&&this.gradientMap.isTexture)n.gradientMap=this.gradientMap.toJSON(e).uuid;if(this.transmission!==void 0)n.transmission=this.transmission;if(this.transmissionMap&&this.transmissionMap.isTexture)n.transmissionMap=this.transmissionMap.toJSON(e).uuid;if(this.thickness!==void 0)n.thickness=this.thickness;if(this.thicknessMap&&this.thicknessMap.isTexture)n.thicknessMap=this.thicknessMap.toJSON(e).uuid;if(this.attenuationDistance!==void 0)n.attenuationDistance=this.attenuationDistance;if(this.attenuationColor!==void 0)n.attenuationColor=this.attenuationColor.getHex();if(this.size!==void 0)n.size=this.size;if(this.sizeAttenuation!==void 0)n.sizeAttenuation=this.sizeAttenuation;if(Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0)n.clippingPlanes=this.clippingPlanes.map((r)=>r.toJSON());if(this.rotation!==void 0)n.rotation=this.rotation;if(this.depthPacking!==void 0)n.depthPacking=this.depthPacking;if(this.linewidth!==void 0)n.linewidth=this.linewidth;if(this.linecap!==void 0)n.linecap=this.linecap;if(this.linejoin!==void 0)n.linejoin=this.linejoin;if(this.dashSize!==void 0)n.dashSize=this.dashSize;if(this.gapSize!==void 0)n.gapSize=this.gapSize;if(this.scale!==void 0)n.scale=this.scale;if(this.wireframe!==void 0)n.wireframe=this.wireframe;if(this.wireframeLinewidth!==void 0)n.wireframeLinewidth=this.wireframeLinewidth;if(this.wireframeLinecap!==void 0)n.wireframeLinecap=this.wireframeLinecap;if(this.wireframeLinejoin!==void 0)n.wireframeLinejoin=this.wireframeLinejoin;if(this.flatShading!==void 0)n.flatShading=this.flatShading;if(this.fog!==void 0)n.fog=this.fog;if(Object.keys(this.userData).length>0)n.userData=this.userData;function i(r){let s=[];for(let o in r){let a=r[o];delete a.metadata,s.push(a)}return s}if(t){let r=i(e.textures),s=i(e.images);if(r.length>0)n.textures=r;if(s.length>0)n.images=s}return n}fromJSON(e,t){if(e.uuid!==void 0)this.uuid=e.uuid;if(e.name!==void 0)this.name=e.name;if(e.color!==void 0&&this.color!==void 0)this.color.setHex(e.color);if(e.roughness!==void 0)this.roughness=e.roughness;if(e.metalness!==void 0)this.metalness=e.metalness;if(e.sheen!==void 0)this.sheen=e.sheen;if(e.sheenColor!==void 0)this.sheenColor=new Ge().setHex(e.sheenColor);if(e.sheenRoughness!==void 0)this.sheenRoughness=e.sheenRoughness;if(e.emissive!==void 0&&this.emissive!==void 0)this.emissive.setHex(e.emissive);if(e.specular!==void 0&&this.specular!==void 0)this.specular.setHex(e.specular);if(e.specularIntensity!==void 0)this.specularIntensity=e.specularIntensity;if(e.specularColor!==void 0&&this.specularColor!==void 0)this.specularColor.setHex(e.specularColor);if(e.shininess!==void 0)this.shininess=e.shininess;if(e.clearcoat!==void 0)this.clearcoat=e.clearcoat;if(e.clearcoatRoughness!==void 0)this.clearcoatRoughness=e.clearcoatRoughness;if(e.dispersion!==void 0)this.dispersion=e.dispersion;if(e.retroreflectivity!==void 0)this.retroreflectivity=e.retroreflectivity;if(e.iridescence!==void 0)this.iridescence=e.iridescence;if(e.iridescenceIOR!==void 0)this.iridescenceIOR=e.iridescenceIOR;if(e.iridescenceThicknessRange!==void 0)this.iridescenceThicknessRange=e.iridescenceThicknessRange;if(e.transmission!==void 0)this.transmission=e.transmission;if(e.thickness!==void 0)this.thickness=e.thickness;if(e.attenuationDistance!==void 0)this.attenuationDistance=e.attenuationDistance;if(e.attenuationColor!==void 0&&this.attenuationColor!==void 0)this.attenuationColor.setHex(e.attenuationColor);if(e.anisotropy!==void 0)this.anisotropy=e.anisotropy;if(e.anisotropyRotation!==void 0)this.anisotropyRotation=e.anisotropyRotation;if(e.fog!==void 0)this.fog=e.fog;if(e.flatShading!==void 0)this.flatShading=e.flatShading;if(e.blending!==void 0)this.blending=e.blending;if(e.combine!==void 0)this.combine=e.combine;if(e.side!==void 0)this.side=e.side;if(e.shadowSide!==void 0)this.shadowSide=e.shadowSide;if(e.opacity!==void 0)this.opacity=e.opacity;if(e.transparent!==void 0)this.transparent=e.transparent;if(e.alphaTest!==void 0)this.alphaTest=e.alphaTest;if(e.alphaHash!==void 0)this.alphaHash=e.alphaHash;if(e.depthFunc!==void 0)this.depthFunc=e.depthFunc;if(e.depthTest!==void 0)this.depthTest=e.depthTest;if(e.depthWrite!==void 0)this.depthWrite=e.depthWrite;if(e.colorWrite!==void 0)this.colorWrite=e.colorWrite;if(e.clippingPlanes!==void 0)this.clippingPlanes=e.clippingPlanes.map((n)=>new zn().fromJSON(n));if(e.clipIntersection!==void 0)this.clipIntersection=e.clipIntersection;if(e.clipShadows!==void 0)this.clipShadows=e.clipShadows;if(e.depthPacking!==void 0)this.depthPacking=e.depthPacking;if(e.blendSrc!==void 0)this.blendSrc=e.blendSrc;if(e.blendDst!==void 0)this.blendDst=e.blendDst;if(e.blendEquation!==void 0)this.blendEquation=e.blendEquation;if(e.blendSrcAlpha!==void 0)this.blendSrcAlpha=e.blendSrcAlpha;if(e.blendDstAlpha!==void 0)this.blendDstAlpha=e.blendDstAlpha;if(e.blendEquationAlpha!==void 0)this.blendEquationAlpha=e.blendEquationAlpha;if(e.blendColor!==void 0&&this.blendColor!==void 0)this.blendColor.setHex(e.blendColor);if(e.blendAlpha!==void 0)this.blendAlpha=e.blendAlpha;if(e.stencilWriteMask!==void 0)this.stencilWriteMask=e.stencilWriteMask;if(e.stencilFunc!==void 0)this.stencilFunc=e.stencilFunc;if(e.stencilRef!==void 0)this.stencilRef=e.stencilRef;if(e.stencilFuncMask!==void 0)this.stencilFuncMask=e.stencilFuncMask;if(e.stencilFail!==void 0)this.stencilFail=e.stencilFail;if(e.stencilZFail!==void 0)this.stencilZFail=e.stencilZFail;if(e.stencilZPass!==void 0)this.stencilZPass=e.stencilZPass;if(e.stencilWrite!==void 0)this.stencilWrite=e.stencilWrite;if(e.wireframe!==void 0)this.wireframe=e.wireframe;if(e.wireframeLinewidth!==void 0)this.wireframeLinewidth=e.wireframeLinewidth;if(e.wireframeLinecap!==void 0)this.wireframeLinecap=e.wireframeLinecap;if(e.wireframeLinejoin!==void 0)this.wireframeLinejoin=e.wireframeLinejoin;if(e.rotation!==void 0)this.rotation=e.rotation;if(e.linewidth!==void 0)this.linewidth=e.linewidth;if(e.linecap!==void 0)this.linecap=e.linecap;if(e.linejoin!==void 0)this.linejoin=e.linejoin;if(e.dashSize!==void 0)this.dashSize=e.dashSize;if(e.gapSize!==void 0)this.gapSize=e.gapSize;if(e.scale!==void 0)this.scale=e.scale;if(e.polygonOffset!==void 0)this.polygonOffset=e.polygonOffset;if(e.polygonOffsetFactor!==void 0)this.polygonOffsetFactor=e.polygonOffsetFactor;if(e.polygonOffsetUnits!==void 0)this.polygonOffsetUnits=e.polygonOffsetUnits;if(e.dithering!==void 0)this.dithering=e.dithering;if(e.alphaToCoverage!==void 0)this.alphaToCoverage=e.alphaToCoverage;if(e.premultipliedAlpha!==void 0)this.premultipliedAlpha=e.premultipliedAlpha;if(e.forceSinglePass!==void 0)this.forceSinglePass=e.forceSinglePass;if(e.allowOverride!==void 0)this.allowOverride=e.allowOverride;if(e.visible!==void 0)this.visible=e.visible;if(e.toneMapped!==void 0)this.toneMapped=e.toneMapped;if(e.userData!==void 0)this.userData=e.userData;if(e.vertexColors!==void 0)if(typeof e.vertexColors==="number")this.vertexColors=e.vertexColors>0;else this.vertexColors=e.vertexColors;if(e.size!==void 0)this.size=e.size;if(e.sizeAttenuation!==void 0)this.sizeAttenuation=e.sizeAttenuation;if(e.map!==void 0)this.map=t[e.map]||null;if(e.matcap!==void 0)this.matcap=t[e.matcap]||null;if(e.alphaMap!==void 0)this.alphaMap=t[e.alphaMap]||null;if(e.bumpMap!==void 0)this.bumpMap=t[e.bumpMap]||null;if(e.bumpScale!==void 0)this.bumpScale=e.bumpScale;if(e.normalMap!==void 0)this.normalMap=t[e.normalMap]||null;if(e.normalMapType!==void 0)this.normalMapType=e.normalMapType;if(e.normalScale!==void 0){let n=e.normalScale;if(Array.isArray(n)===!1)n=[n,n];this.normalScale=new ke().fromArray(n)}if(e.displacementMap!==void 0)this.displacementMap=t[e.displacementMap]||null;if(e.displacementScale!==void 0)this.displacementScale=e.displacementScale;if(e.displacementBias!==void 0)this.displacementBias=e.displacementBias;if(e.roughnessMap!==void 0)this.roughnessMap=t[e.roughnessMap]||null;if(e.metalnessMap!==void 0)this.metalnessMap=t[e.metalnessMap]||null;if(e.emissiveMap!==void 0)this.emissiveMap=t[e.emissiveMap]||null;if(e.emissiveIntensity!==void 0)this.emissiveIntensity=e.emissiveIntensity;if(e.specularMap!==void 0)this.specularMap=t[e.specularMap]||null;if(e.specularIntensityMap!==void 0)this.specularIntensityMap=t[e.specularIntensityMap]||null;if(e.specularColorMap!==void 0)this.specularColorMap=t[e.specularColorMap]||null;if(e.envMap!==void 0)this.envMap=t[e.envMap]||null;if(e.envMapRotation!==void 0)this.envMapRotation.fromArray(e.envMapRotation);if(e.envMapIntensity!==void 0)this.envMapIntensity=e.envMapIntensity;if(e.reflectivity!==void 0)this.reflectivity=e.reflectivity;if(e.refractionRatio!==void 0)this.refractionRatio=e.refractionRatio;if(e.lightMap!==void 0)this.lightMap=t[e.lightMap]||null;if(e.lightMapIntensity!==void 0)this.lightMapIntensity=e.lightMapIntensity;if(e.aoMap!==void 0)this.aoMap=t[e.aoMap]||null;if(e.aoMapIntensity!==void 0)this.aoMapIntensity=e.aoMapIntensity;if(e.gradientMap!==void 0)this.gradientMap=t[e.gradientMap]||null;if(e.clearcoatMap!==void 0)this.clearcoatMap=t[e.clearcoatMap]||null;if(e.clearcoatRoughnessMap!==void 0)this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null;if(e.clearcoatNormalMap!==void 0)this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null;if(e.clearcoatNormalScale!==void 0)this.clearcoatNormalScale=new ke().fromArray(e.clearcoatNormalScale);if(e.iridescenceMap!==void 0)this.iridescenceMap=t[e.iridescenceMap]||null;if(e.iridescenceThicknessMap!==void 0)this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null;if(e.transmissionMap!==void 0)this.transmissionMap=t[e.transmissionMap]||null;if(e.thicknessMap!==void 0)this.thicknessMap=t[e.thicknessMap]||null;if(e.anisotropyMap!==void 0)this.anisotropyMap=t[e.anisotropyMap]||null;if(e.sheenColorMap!==void 0)this.sheenColorMap=t[e.sheenColorMap]||null;if(e.sheenRoughnessMap!==void 0)this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null;return this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let i=t.length;n=Array(i);for(let r=0;r!==i;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){if(e===!0)this.version++}}var Gi=new z,rh=new z,gc=new z,_c=new z;class _r{constructor(e=new z,t=new z(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Gi)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);if(n<0)return t.copy(this.origin);return t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=Gi.subVectors(e,this.origin).dot(this.direction);if(t<0)return this.origin.distanceToSquared(e);return Gi.copy(this.origin).addScaledVector(this.direction,t),Gi.distanceToSquared(e)}distanceSqToSegment(e,t,n,i){rh.copy(e).add(t).multiplyScalar(0.5),gc.copy(t).sub(e).normalize(),_c.copy(this.origin).sub(rh);let r=e.distanceTo(t)*0.5,s=-this.direction.dot(gc),o=_c.dot(this.direction),a=-_c.dot(gc),c=_c.lengthSq(),l=Math.abs(1-s*s),u,h,d,f;if(l>0)if(u=s*a-o,h=s*o-a,f=r*l,u>=0)if(h>=-f)if(h<=f){let m=1/l;u*=m,h*=m,d=u*(u+s*h+2*o)+h*(s*u+h+2*a)+c}else h=r,u=Math.max(0,-(s*h+o)),d=-u*u+h*(h+2*a)+c;else h=-r,u=Math.max(0,-(s*h+o)),d=-u*u+h*(h+2*a)+c;else if(h<=-f)u=Math.max(0,-(-s*r+o)),h=u>0?-r:Math.min(Math.max(-r,-a),r),d=-u*u+h*(h+2*a)+c;else if(h<=f)u=0,h=Math.min(Math.max(-r,-a),r),d=h*(h+2*a)+c;else u=Math.max(0,-(s*r+o)),h=u>0?r:Math.min(Math.max(-r,-a),r),d=-u*u+h*(h+2*a)+c;else h=s>0?-r:r,u=Math.max(0,-(s*h+o)),d=-u*u+h*(h+2*a)+c;if(n)n.copy(this.origin).addScaledVector(this.direction,u);if(i)i.copy(rh).addScaledVector(gc,h);return d}intersectSphere(e,t){if(e.radius<0)return null;Gi.subVectors(e.center,this.origin);let n=Gi.dot(this.direction),i=Gi.dot(Gi)-n*n,r=e.radius*e.radius;if(i>r)return null;let s=Math.sqrt(r-i),o=n-s,a=n+s;if(a<0)return null;if(o<0)return this.at(a,t);return this.at(o,t)}intersectsSphere(e){if(e.radius<0)return!1;return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0){if(e.distanceToPoint(this.origin)===0)return 0;return null}let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);if(n===null)return null;return this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);if(t===0)return!0;if(e.normal.dot(this.direction)*t<0)return!0;return!1}intersectBox(e,t){let n,i,r,s,o,a,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,h=this.origin;if(c>=0)n=(e.min.x-h.x)*c,i=(e.max.x-h.x)*c;else n=(e.max.x-h.x)*c,i=(e.min.x-h.x)*c;if(l>=0)r=(e.min.y-h.y)*l,s=(e.max.y-h.y)*l;else r=(e.max.y-h.y)*l,s=(e.min.y-h.y)*l;if(n>s||r>i)return null;if(r>n||isNaN(n))n=r;if(s<i||isNaN(i))i=s;if(u>=0)o=(e.min.z-h.z)*u,a=(e.max.z-h.z)*u;else o=(e.max.z-h.z)*u,a=(e.min.z-h.z)*u;if(n>a||o>i)return null;if(o>n||n!==n)n=o;if(a<i||i!==i)i=a;if(i<0)return null;return this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,Gi)!==null}intersectTriangle(e,t,n,i,r){let s=this.origin,o=this.direction,{x:a,y:c,z:l}=o,u=e.x-s.x,h=e.y-s.y,d=e.z-s.z,f=t.x-s.x,m=t.y-s.y,_=t.z-s.z,p=n.x-s.x,g=n.y-s.y,M=n.z-s.z,T=Math.abs(a),v=Math.abs(c),S=Math.abs(l),E,R,x,w,G,C,D,ee,L,W,B,P;if(T>=v&&T>=S)if(x=a,C=u,L=f,P=p,a>=0)E=c,R=l,w=h,G=d,D=m,ee=_,W=g,B=M;else E=l,R=c,w=d,G=h,D=_,ee=m,W=M,B=g;else if(v>=S)if(x=c,C=h,L=m,P=g,c>=0)E=l,R=a,w=d,G=u,D=_,ee=f,W=M,B=p;else E=a,R=l,w=u,G=d,D=f,ee=_,W=p,B=M;else if(x=l,C=d,L=_,P=M,l>=0)E=a,R=c,w=u,G=h,D=f,ee=m,W=p,B=g;else E=c,R=a,w=h,G=u,D=m,ee=f,W=g,B=p;if(x===0)return null;let J=E/x,H=R/x,q=1/x,Q=w-J*C,ge=G-H*C,he=D-J*L,de=ee-H*L,fe=W-J*P,I=B-H*P,V=fe*de-I*he,j=Q*I-ge*fe,re=he*ge-de*Q;if(i){if(V<0||j<0||re<0)return null}else if((V<0||j<0||re<0)&&(V>0||j>0||re>0))return null;let oe=V+j+re;if(oe===0)return null;let ue=q*(V*C+j*L+re*P);if(oe>0?ue<0:ue>0)return null;return this.at(ue/oe,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class wi extends yn{constructor(e){super();this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ge(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new xi,this.combine=0,this.reflectivity=1,this.refractionRatio=0.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}var Q0=new Xe,Gr=new _r,xc=new In,ex=new z,vc=new z,yc=new z,bc=new z,sh=new z,Sc=new z,tx=new z,wc=new z;class Mt extends _t{constructor(e=new ln,t=new wi){super();this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){if(super.copy(e,t),e.morphTargetInfluences!==void 0)this.morphTargetInfluences=e.morphTargetInfluences.slice();if(e.morphTargetDictionary!==void 0)this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary);return this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(e,t){let n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,s=n.morphTargetsRelative;t.fromBufferAttribute(i,e);let o=this.morphTargetInfluences;if(r&&o){Sc.set(0,0,0);for(let a=0,c=r.length;a<c;a++){let l=o[a],u=r[a];if(l===0)continue;if(sh.fromBufferAttribute(u,e),s)Sc.addScaledVector(sh,l);else Sc.addScaledVector(sh.sub(t),l)}t.add(Sc)}return t}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.material,r=this.matrixWorld;if(i===void 0)return;if(n.boundingSphere===null)n.computeBoundingSphere();if(xc.copy(n.boundingSphere),xc.applyMatrix4(r),Gr.copy(e.ray).recast(e.near),xc.containsPoint(Gr.origin)===!1){if(Gr.intersectSphere(xc,ex)===null)return;if(Gr.origin.distanceToSquared(ex)>(e.far-e.near)**2)return}if(Q0.copy(r).invert(),Gr.copy(e.ray).applyMatrix4(Q0),n.boundingBox!==null){if(Gr.intersectsBox(n.boundingBox)===!1)return}this._computeIntersections(e,t,Gr)}_computeIntersections(e,t,n){let i,r=this.geometry,s=this.material,o=r.index,a=r.attributes.position,c=r.attributes.uv,l=r.attributes.uv1,u=r.attributes.normal,{groups:h,drawRange:d}=r;if(o!==null)if(Array.isArray(s))for(let f=0,m=h.length;f<m;f++){let _=h[f],p=s[_.materialIndex],g=Math.max(_.start,d.start),M=Math.min(o.count,Math.min(_.start+_.count,d.start+d.count));for(let T=g,v=M;T<v;T+=3){let S=o.getX(T),E=o.getX(T+1),R=o.getX(T+2);if(i=Mc(this,p,e,n,c,l,u,S,E,R),i)i.faceIndex=Math.floor(T/3),i.face.materialIndex=_.materialIndex,t.push(i)}}else{let f=Math.max(0,d.start),m=Math.min(o.count,d.start+d.count);for(let _=f,p=m;_<p;_+=3){let g=o.getX(_),M=o.getX(_+1),T=o.getX(_+2);if(i=Mc(this,s,e,n,c,l,u,g,M,T),i)i.faceIndex=Math.floor(_/3),t.push(i)}}else if(a!==void 0)if(Array.isArray(s))for(let f=0,m=h.length;f<m;f++){let _=h[f],p=s[_.materialIndex],g=Math.max(_.start,d.start),M=Math.min(a.count,Math.min(_.start+_.count,d.start+d.count));for(let T=g,v=M;T<v;T+=3){let S=T,E=T+1,R=T+2;if(i=Mc(this,p,e,n,c,l,u,S,E,R),i)i.faceIndex=Math.floor(T/3),i.face.materialIndex=_.materialIndex,t.push(i)}}else{let f=Math.max(0,d.start),m=Math.min(a.count,d.start+d.count);for(let _=f,p=m;_<p;_+=3){let g=_,M=_+1,T=_+2;if(i=Mc(this,s,e,n,c,l,u,g,M,T),i)i.faceIndex=Math.floor(_/3),t.push(i)}}}}function JM(e,t,n,i,r,s,o,a){let c;if(t.side===1)c=i.intersectTriangle(o,s,r,!0,a);else c=i.intersectTriangle(r,s,o,t.side===0,a);if(c===null)return null;wc.copy(a),wc.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(wc);if(l<n.near||l>n.far)return null;return{distance:l,point:wc.clone(),object:e}}function Mc(e,t,n,i,r,s,o,a,c,l){e.getVertexPosition(a,vc),e.getVertexPosition(c,yc),e.getVertexPosition(l,bc);let u=JM(e,t,n,i,vc,yc,bc,tx);if(u){let h=new z;if(kn.getBarycoord(tx,vc,yc,bc,h),r)u.uv=kn.getInterpolatedAttribute(r,a,c,l,h,new ke);if(s)u.uv1=kn.getInterpolatedAttribute(s,a,c,l,h,new ke);if(o){if(u.normal=kn.getInterpolatedAttribute(o,a,c,l,h,new z),u.normal.dot(i.direction)>0)u.normal.multiplyScalar(-1)}let d={a,b:c,c:l,normal:new z,materialIndex:0};kn.getNormal(vc,yc,bc,d.normal),u.face=d,u.barycoord=h}return u}var Oo=new pt,nx=new pt,ix=new pt,QM=new pt,rx=new Xe,Ec=new z,oh=new In,sx=new Xe,ah=new _r;class el extends Mt{constructor(e,t){super(e,t);this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new Xe,this.bindMatrixInverse=new Xe,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;if(this.boundingBox===null)this.boundingBox=new Vt;this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Ec),this.boundingBox.expandByPoint(Ec)}computeBoundingSphere(){let e=this.geometry;if(this.boundingSphere===null)this.boundingSphere=new In;this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Ec),this.boundingSphere.expandByPoint(Ec)}copy(e,t){if(super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null)this.boundingBox=e.boundingBox.clone();if(e.boundingSphere!==null)this.boundingSphere=e.boundingSphere.clone();return this}raycast(e,t){let n=this.material,i=this.matrixWorld;if(n===void 0)return;if(this.boundingSphere===null)this.computeBoundingSphere();if(oh.copy(this.boundingSphere),oh.applyMatrix4(i),e.ray.intersectsSphere(oh)===!1)return;if(sx.copy(i).invert(),ah.copy(e.ray).applyMatrix4(sx),this.boundingBox!==null){if(ah.intersectsBox(this.boundingBox)===!1)return}this._computeIntersections(e,t,ah)}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){if(this.skeleton=e,t===void 0)this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld;this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let e=new pt,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);let r=1/e.manhattanLength();if(r!==1/0)e.multiplyScalar(r);else e.set(1,0,0,0);t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.bindMode==="attached")this.bindMatrixInverse.copy(this.matrixWorld).invert();else if(this.bindMode==="detached")this.bindMatrixInverse.copy(this.bindMatrix).invert();else Ue("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let n=this.skeleton,i=this.geometry;if(nx.fromBufferAttribute(i.attributes.skinIndex,e),ix.fromBufferAttribute(i.attributes.skinWeight,e),t.isVector4)Oo.copy(t),t.set(0,0,0,0);else Oo.set(...t,1),t.set(0,0,0);Oo.applyMatrix4(this.bindMatrix);for(let r=0;r<4;r++){let s=ix.getComponent(r);if(s!==0){let o=nx.getComponent(r);rx.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(QM.copy(Oo).applyMatrix4(rx),s)}}if(t.isVector4)t.w=Oo.w;return t.applyMatrix4(this.bindMatrixInverse)}}class Jo extends _t{constructor(){super();this.isBone=!0,this.type="Bone"}}class Qo extends Ot{constructor(e=null,t=1,n=1,i,r,s,o,a,c=1003,l=1003,u,h){super(null,s,o,a,c,l,i,r,u,h);this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}var ox=new Xe,eE=new Xe;class ea{constructor(e=[],t=[]){this.uuid=Qn(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){Ue("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new Xe)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let n=new Xe;if(this.bones[e])n.copy(this.bones[e].matrixWorld).invert();this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];if(n)n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];if(n){if(n.parent&&n.parent.isBone)n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld);else n.matrix.copy(n.matrixWorld);n.matrix.decompose(n.position,n.quaternion,n.scale)}}}update(){let e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let r=0,s=e.length;r<s;r++){let o=e[r]?e[r].matrixWorld:eE;ox.multiplyMatrices(o,t[r]),ox.toArray(n,r*16)}if(i!==null)i.needsUpdate=!0}clone(){return new ea(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let n=new Qo(t,e,e,1023,1015);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){let i=this.bones[t];if(i.name===e)return i}return}dispose(){if(this.boneTexture!==null)this.boneTexture.dispose(),this.boneTexture=null}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){let r=e.bones[n],s=t[r];if(s===void 0)Ue("Skeleton: No bone found with UUID:",r),s=new Jo;this.bones.push(s),this.boneInverses.push(new Xe().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){let e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,n=this.boneInverses;for(let i=0,r=t.length;i<r;i++){let s=t[i];e.bones.push(s.uuid);let o=n[i];e.boneInverses.push(o.toArray())}return e}}class hr extends Kt{constructor(e,t,n,i=1){super(e,t,n);this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}var Ss=new Xe,ax=new Xe,Tc=[],cx=new Vt,tE=new Xe,Uo=new Mt,Fo=new In;class Bs extends Mt{constructor(e,t,n){super(e,t);this.isInstancedMesh=!0,this.instanceMatrix=new hr(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,tE)}computeBoundingBox(){let e=this.geometry,t=this.count;if(this.boundingBox===null)this.boundingBox=new Vt;if(e.boundingBox===null)e.computeBoundingBox();this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Ss),cx.copy(e.boundingBox).applyMatrix4(Ss),this.boundingBox.union(cx)}computeBoundingSphere(){let e=this.geometry,t=this.count;if(this.boundingSphere===null)this.boundingSphere=new In;if(e.boundingSphere===null)e.computeBoundingSphere();this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Ss),Fo.copy(e.boundingSphere).applyMatrix4(Ss),this.boundingSphere.union(Fo)}copy(e,t){if(super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null)this.morphTexture=e.morphTexture.clone();if(e.instanceColor!==null)this.instanceColor=e.instanceColor.clone();if(this.count=e.count,e.boundingBox!==null)this.boundingBox=e.boundingBox.clone();if(e.boundingSphere!==null)this.boundingSphere=e.boundingSphere.clone();return this}getColorAt(e,t){if(this.instanceColor===null)return t.setRGB(1,1,1);else return t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){return t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){let n=t.morphTargetInfluences,i=this.morphTexture.source.data.data,r=n.length+1,s=e*r+1;for(let o=0;o<n.length;o++)n[o]=i[s+o]}raycast(e,t){let n=this.matrixWorld,i=this.count;if(Uo.geometry=this.geometry,Uo.material=this.material,Uo.material===void 0)return;if(this.boundingSphere===null)this.computeBoundingSphere();if(Fo.copy(this.boundingSphere),Fo.applyMatrix4(n),e.ray.intersectsSphere(Fo)===!1)return;for(let r=0;r<i;r++){this.getMatrixAt(r,Ss),ax.multiplyMatrices(n,Ss),Uo.matrixWorld=ax,Uo.raycast(e,Tc);for(let s=0,o=Tc.length;s<o;s++){let a=Tc[s];a.instanceId=r,a.object=this,t.push(a)}Tc.length=0}}setColorAt(e,t){if(this.instanceColor===null)this.instanceColor=new hr(new Float32Array(this.instanceMatrix.count*3).fill(1),3);return t.toArray(this.instanceColor.array,e*3),this}setMatrixAt(e,t){return t.toArray(this.instanceMatrix.array,e*16),this}setMorphAt(e,t){let n=t.morphTargetInfluences,i=n.length+1;if(this.morphTexture===null)this.morphTexture=new Qo(new Float32Array(i*this.count),i,this.count,1028,1015);let r=this.morphTexture.source.data.data,s=0;for(let c=0;c<n.length;c++)s+=n[c];let o=this.geometry.morphTargetsRelative?1:1-s,a=i*e;return r[a]=o,r.set(n,a+1),this}updateMorphTargets(){}dispose(){if(super.dispose(),this.morphTexture!==null)this.morphTexture.dispose(),this.morphTexture=null}}var Hr=new In,nE=new ke(0.5,0.5),Ac=new z;class ta{constructor(e=new zn,t=new zn,n=new zn,i=new zn,r=new zn,s=new zn){this.planes=[e,t,n,i,r,s]}set(e,t,n,i,r,s){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(s),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=2000,n=!1){let i=this.planes,r=e.elements,s=r[0],o=r[1],a=r[2],c=r[3],l=r[4],u=r[5],h=r[6],d=r[7],f=r[8],m=r[9],_=r[10],p=r[11],g=r[12],M=r[13],T=r[14],v=r[15];if(i[0].setComponents(c-s,d-l,p-f,v-g).normalize(),i[1].setComponents(c+s,d+l,p+f,v+g).normalize(),i[2].setComponents(c+o,d+u,p+m,v+M).normalize(),i[3].setComponents(c-o,d-u,p-m,v-M).normalize(),n)i[4].setComponents(a,h,_,T).normalize(),i[5].setComponents(c-a,d-h,p-_,v-T).normalize();else if(i[4].setComponents(c-a,d-h,p-_,v-T).normalize(),t===2000)i[5].setComponents(c+a,d+h,p+_,v+T).normalize();else if(t===2001)i[5].setComponents(a,h,_,T).normalize();else throw Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0){if(e.boundingSphere===null)e.computeBoundingSphere();Hr.copy(e.boundingSphere).applyMatrix4(e.matrixWorld)}else{let t=e.geometry;if(t.boundingSphere===null)t.computeBoundingSphere();Hr.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Hr)}intersectsSprite(e){Hr.center.set(0,0,0);let t=nE.distanceTo(e.center);return Hr.radius=0.7071067811865476+t,Hr.applyMatrix4(e.matrixWorld),this.intersectsSphere(Hr)}intersectsSphere(e){let t=this.planes,n=e.center,i=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let i=t[n];if(Ac.x=i.normal.x>0?e.max.x:e.min.x,Ac.y=i.normal.y>0?e.max.y:e.min.y,Ac.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Ac)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class na extends yn{constructor(e){super();this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ge(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}var Oc=new z,Uc=new z,lx=new Xe,zo=new _r,Rc=new In,ch=new z,ux=new z;class xr extends _t{constructor(e=new ln,t=new na){super();this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let i=1,r=t.count;i<r;i++)Oc.fromBufferAttribute(t,i-1),Uc.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=Oc.distanceTo(Uc);e.setAttribute("lineDistance",new vn(n,1))}else Ue("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.matrixWorld,r=e.params.Line.threshold,s=n.drawRange;if(n.boundingSphere===null)n.computeBoundingSphere();if(Rc.copy(n.boundingSphere),Rc.applyMatrix4(i),Rc.radius+=r,e.ray.intersectsSphere(Rc)===!1)return;lx.copy(i).invert(),zo.copy(e.ray).applyMatrix4(lx);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=o*o,c=this.isLineSegments?2:1,l=n.index,h=n.attributes.position;if(l!==null){let d=Math.max(0,s.start),f=Math.min(l.count,s.start+s.count);for(let m=d,_=f-1;m<_;m+=c){let p=l.getX(m),g=l.getX(m+1),M=Cc(this,e,zo,a,p,g,m);if(M)t.push(M)}if(this.isLineLoop){let m=l.getX(f-1),_=l.getX(d),p=Cc(this,e,zo,a,m,_,f-1);if(p)t.push(p)}}else{let d=Math.max(0,s.start),f=Math.min(h.count,s.start+s.count);for(let m=d,_=f-1;m<_;m+=c){let p=Cc(this,e,zo,a,m,m+1,m);if(p)t.push(p)}if(this.isLineLoop){let m=Cc(this,e,zo,a,f-1,d,f-1);if(m)t.push(m)}}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function Cc(e,t,n,i,r,s,o){let a=e.geometry.attributes.position;if(Oc.fromBufferAttribute(a,r),Uc.fromBufferAttribute(a,s),n.distanceSqToSegment(Oc,Uc,ch,ux)>i)return;ch.applyMatrix4(e.matrixWorld);let l=t.ray.origin.distanceTo(ch);if(l<t.near||l>t.far)return;return{distance:l,point:ux.clone().applyMatrix4(e.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:e}}var hx=new z,dx=new z;class tl extends xr{constructor(e,t){super(e,t);this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let i=0,r=t.count;i<r;i+=2)hx.fromBufferAttribute(t,i),dx.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+hx.distanceTo(dx);e.setAttribute("lineDistance",new vn(n,1))}else Ue("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class nl extends xr{constructor(e,t){super(e,t);this.isLineLoop=!0,this.type="LineLoop"}}class ia extends yn{constructor(e){super();this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Ge(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}var fx=new Xe,hh=new _r,Ic=new In,Pc=new z;class Gs extends _t{constructor(e=new ln,t=new ia){super();this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.matrixWorld,r=e.params.Points.threshold,s=n.drawRange;if(n.boundingSphere===null)n.computeBoundingSphere();if(Ic.copy(n.boundingSphere),Ic.applyMatrix4(i),Ic.radius+=r,e.ray.intersectsSphere(Ic)===!1)return;fx.copy(i).invert(),hh.copy(e.ray).applyMatrix4(fx);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=o*o,c=n.index,u=n.attributes.position;if(c!==null){let h=Math.max(0,s.start),d=Math.min(c.count,s.start+s.count);for(let f=h,m=d;f<m;f++){let _=c.getX(f);Pc.fromBufferAttribute(u,_),px(Pc,_,a,i,e,t,this)}}else{let h=Math.max(0,s.start),d=Math.min(u.count,s.start+s.count);for(let f=h,m=d;f<m;f++)Pc.fromBufferAttribute(u,f),px(Pc,f,a,i,e,t,this)}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function px(e,t,n,i,r,s,o){let a=hh.distanceSqToPoint(e);if(a<n){let c=new z;hh.closestPointToPoint(e,c),c.applyMatrix4(i);let l=r.ray.origin.distanceTo(c);if(l<r.near||l>r.far)return;s.push({distance:l,distanceToRay:Math.sqrt(a),point:c,index:t,face:null,faceIndex:null,barycoord:null,object:o})}}class il extends Ot{constructor(e=[],t=301,n,i,r,s,o,a,c,l){super(e,t,n,i,r,s,o,a,c,l);this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Kr extends Ot{constructor(e,t,n=1014,i,r,s,o=1003,a=1003,c,l=1026,u=1){if(l!==1026&&l!==1027)throw Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let h={width:e,height:t,depth:u};super(h,i,r,s,o,a,l,n,c);this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new qo(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}}class md extends Kr{constructor(e,t=1014,n=301,i,r,s=1003,o=1003,a,c=1026){let l={width:e,height:e,depth:1},u=[l,l,l,l,l,l];super(e,e,t,n,i,r,s,o,a,c);this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class rl extends Ot{constructor(e=null){super();this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class vr extends ln{constructor(e=1,t=1,n=1,i=1,r=1,s=1){super();this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:s};let o=this;i=Math.floor(i),r=Math.floor(r),s=Math.floor(s);let a=[],c=[],l=[],u=[],h=0,d=0;f("z","y","x",-1,-1,n,t,e,s,r,0),f("z","y","x",1,-1,n,t,-e,s,r,1),f("x","z","y",1,1,e,n,t,i,s,2),f("x","z","y",1,-1,e,n,-t,i,s,3),f("x","y","z",1,-1,e,t,n,i,r,4),f("x","y","z",-1,-1,e,t,-n,i,r,5),this.setIndex(a),this.setAttribute("position",new vn(c,3)),this.setAttribute("normal",new vn(l,3)),this.setAttribute("uv",new vn(u,2));function f(m,_,p,g,M,T,v,S,E,R,x){let w=T/E,G=v/R,C=T/2,D=v/2,ee=S/2,L=E+1,W=R+1,B=0,P=0,J=new z;for(let H=0;H<W;H++){let q=H*G-D;for(let Q=0;Q<L;Q++){let ge=Q*w-C;J[m]=ge*g,J[_]=q*M,J[p]=ee,c.push(J.x,J.y,J.z),J[m]=0,J[_]=0,J[p]=S>0?1:-1,l.push(J.x,J.y,J.z),u.push(Q/E),u.push(1-H/R),B+=1}}for(let H=0;H<R;H++)for(let q=0;q<E;q++){let Q=h+q+L*H,ge=h+q+L*(H+1),he=h+(q+1)+L*(H+1),de=h+(q+1)+L*H;a.push(Q,ge,de),a.push(ge,he,de),P+=6}o.addGroup(d,P,x),d+=P,h+=B}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new vr(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class ra extends ln{constructor(e=1,t=1,n=1,i=1){super();this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};let r=e/2,s=t/2,o=Math.floor(n),a=Math.floor(i),c=o+1,l=a+1,u=e/o,h=t/a,d=[],f=[],m=[],_=[];for(let p=0;p<l;p++){let g=p*h-s;for(let M=0;M<c;M++){let T=M*u-r;f.push(T,-g,0),m.push(0,0,1),_.push(M/o),_.push(1-p/a)}}for(let p=0;p<a;p++)for(let g=0;g<o;g++){let M=g+c*p,T=g+c*(p+1),v=g+1+c*(p+1),S=g+1+c*p;d.push(M,T,S),d.push(T,v,S)}this.setIndex(d),this.setAttribute("position",new vn(f,3)),this.setAttribute("normal",new vn(m,3)),this.setAttribute("uv",new vn(_,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ra(e.width,e.height,e.widthSegments,e.heightSegments)}}function Jr(e){let t={};for(let n in e){t[n]={};for(let i in e[n]){let r=e[n][i];if(mx(r))if(r.isRenderTargetTexture)Ue("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[n][i]=null;else t[n][i]=r.clone();else if(Array.isArray(r))if(mx(r[0])){let s=[];for(let o=0,a=r.length;o<a;o++)s[o]=r[o].clone();t[n][i]=s}else t[n][i]=r.slice();else t[n][i]=r}}return t}function un(e){let t={};for(let n=0;n<e.length;n++){let i=Jr(e[n]);for(let r in i)t[r]=i[r]}return t}function mx(e){return e&&(e.isColor||e.isMatrix3||e.isMatrix4||e.isVector2||e.isVector3||e.isVector4||e.isTexture||e.isQuaternion)}function iE(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}function gd(e){let t=e.getRenderTarget();if(t===null)return e.outputColorSpace;if(t.isXRRenderTarget===!0)return t.texture.colorSpace;return Ke.workingColorSpace}var Sv={clone:Jr,merge:un},rE=`void main() {
63
63
  gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
64
- }`,iE=`void main() {
64
+ }`,sE=`void main() {
65
65
  gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
66
- }`;class Gn extends yn{constructor(e){super();if(this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=nE,this.fragmentShader=iE,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0)this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Kr(e.uniforms),this.uniformsGroups=tE(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let i in this.uniforms){let s=this.uniforms[i].value;if(s&&s.isTexture)t.uniforms[i]={type:"t",value:s.toJSON(e).uuid};else if(s&&s.isColor)t.uniforms[i]={type:"c",value:s.getHex()};else if(s&&s.isVector2)t.uniforms[i]={type:"v2",value:s.toArray()};else if(s&&s.isVector3)t.uniforms[i]={type:"v3",value:s.toArray()};else if(s&&s.isVector4)t.uniforms[i]={type:"v4",value:s.toArray()};else if(s&&s.isMatrix3)t.uniforms[i]={type:"m3",value:s.toArray()};else if(s&&s.isMatrix4)t.uniforms[i]={type:"m4",value:s.toArray()};else t.uniforms[i]={value:s}}if(Object.keys(this.defines).length>0)t.defines=this.defines;t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let i in this.extensions)if(this.extensions[i]===!0)n[i]=!0;if(Object.keys(n).length>0)t.extensions=n;return t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(let n in e.uniforms){let i=e.uniforms[n];switch(this.uniforms[n]={},i.type){case"t":this.uniforms[n].value=t[i.value]||null;break;case"c":this.uniforms[n].value=new He().setHex(i.value);break;case"v2":this.uniforms[n].value=new Be().fromArray(i.value);break;case"v3":this.uniforms[n].value=new F().fromArray(i.value);break;case"v4":this.uniforms[n].value=new pt().fromArray(i.value);break;case"m3":this.uniforms[n].value=new We().fromArray(i.value);break;case"m4":this.uniforms[n].value=new Xe().fromArray(i.value);break;default:this.uniforms[n].value=i.value}}if(e.defines!==void 0)this.defines=e.defines;if(e.vertexShader!==void 0)this.vertexShader=e.vertexShader;if(e.fragmentShader!==void 0)this.fragmentShader=e.fragmentShader;if(e.glslVersion!==void 0)this.glslVersion=e.glslVersion;if(e.extensions!==void 0)for(let n in e.extensions)this.extensions[n]=e.extensions[n];if(e.lights!==void 0)this.lights=e.lights;if(e.clipping!==void 0)this.clipping=e.clipping;return this}}class gd extends Gn{constructor(e){super(e);this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class $i extends yn{constructor(e){super();this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new He(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new He(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Be(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new xi,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Pn extends $i{constructor(e){super();this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Be(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Je(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+0.4*t)/(1-0.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new He(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new He(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new He(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._retroreflectivity=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){if(this._anisotropy>0!==e>0)this.version++;this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){if(this._clearcoat>0!==e>0)this.version++;this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){if(this._iridescence>0!==e>0)this.version++;this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){if(this._dispersion>0!==e>0)this.version++;this._dispersion=e}get retroreflectivity(){return this._retroreflectivity}set retroreflectivity(e){if(this._retroreflectivity>0!==e>0)this.version++;this._retroreflectivity=e}get sheen(){return this._sheen}set sheen(e){if(this._sheen>0!==e>0)this.version++;this._sheen=e}get transmission(){return this._transmission}set transmission(e){if(this._transmission>0!==e>0)this.version++;this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.retroreflectivity=e.retroreflectivity,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class il extends yn{constructor(e){super();this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new He(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new He(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Be(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new xi,this.combine=0,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=0.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class _d extends yn{constructor(e){super();this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class xd extends yn{constructor(e){super();this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}function lr(e,t){if(!e||e.constructor===t)return e;if(typeof t.BYTES_PER_ELEMENT==="number")return new t(e);return Array.prototype.slice.call(e)}function Lc(e){return e!==void 0&&e.inTangents!==void 0&&e.outTangents!==void 0}function rE(e){function t(r,s){return e[r]-e[s]}let n=e.length,i=Array(n);for(let r=0;r!==n;++r)i[r]=r;return i.sort(t),i}function mx(e,t,n){let i=e.length,r=new e.constructor(i);for(let s=0,o=0;o!==i;++s){let a=n[s]*t;for(let c=0;c!==t;++c)r[o++]=e[a+c]}return r}function sE(e,t,n,i){let r=1,s=e[0];while(s!==void 0&&s[i]===void 0)s=e[r++];if(s===void 0)return;let o=s[i];if(o===void 0)return;if(Array.isArray(o))do{if(o=s[i],o!==void 0)t.push(s.time),n.push(...o);s=e[r++]}while(s!==void 0);else if(o.toArray!==void 0)do{if(o=s[i],o!==void 0)t.push(s.time),o.toArray(n,n.length);s=e[r++]}while(s!==void 0);else do{if(o=s[i],o!==void 0)t.push(s.time),n.push(o);s=e[r++]}while(s!==void 0)}class Wi{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,i=t[n],r=t[n-1];e:{t:{let s;n:{i:if(!(e<i)){for(let o=n+2;;){if(i===void 0){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(r=i,i=t[++n],e<i)break t}s=t.length;break n}if(!(e>=r)){let o=t[1];if(e<o)n=2,r=o;for(let a=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===a)break;if(i=r,r=t[--n-1],e>=r)break t}s=n,n=0;break n}break e}while(n<s){let o=n+s>>>1;if(e<t[o])s=o;else n=o+1}if(i=t[n],r=t[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i;for(let s=0;s!==i;++s)t[s]=n[r+s];return t}interpolate_(){throw Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}}class vd extends Wi{constructor(e,t,n,i){super(e,t,n,i);this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:2400,endingEnd:2400}}intervalChanged_(e,t,n){let i=this.parameterPositions,r=e-2,s=e+1,o=i[r],a=i[s];if(o===void 0)switch(this.getSettings_().endingStart){case 2401:r=e,o=2*t-n;break;case 2402:r=i.length-2,o=t+i[r]-i[r+1];break;default:r=e,o=n}if(a===void 0)switch(this.getSettings_().endingEnd){case 2401:s=e,a=2*n-t;break;case 2402:s=1,a=n+i[1]-i[0];break;default:s=e-1,a=t}let c=(n-t)*0.5,l=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(a-n),this._offsetPrev=r*l,this._offsetNext=s*l}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=this._offsetPrev,u=this._offsetNext,h=this._weightPrev,d=this._weightNext,f=(n-t)/(i-t),m=f*f,_=m*f,p=-h*_+2*h*m-h*f,g=(1+h)*_+(-1.5-2*h)*m+(-0.5+h)*f+1,M=(-1-d)*_+(1.5+d)*m+0.5*f,T=d*_-d*m;for(let v=0;v!==o;++v)r[v]=p*s[l+v]+g*s[c+v]+M*s[a+v]+T*s[u+v];return r}}class rl extends Wi{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=(n-t)/(i-t),u=1-l;for(let h=0;h!==o;++h)r[h]=s[c+h]*u+s[a+h]*l;return r}}class yd extends Wi{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class bd extends Wi{interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=this.inTangents,u=this.outTangents;if(!l||!u){let f=(n-t)/(i-t),m=1-f;for(let _=0;_!==o;++_)r[_]=s[c+_]*m+s[a+_]*f;return r}let h=o*2,d=e-1;for(let f=0;f!==o;++f){let m=s[c+f],_=s[a+f],p=d*h+f*2,g=u[p],M=u[p+1],T=e*h+f*2,v=l[T],S=l[T+1],E=aE(n,t,g,v,i);r[f]=Sv(E,m,M,S,_)}return r}}function Sv(e,t,n,i,r){let s=1-e;return s*s*s*t+3*s*s*e*n+3*s*e*e*i+e*e*e*r}function oE(e,t,n,i,r){let s=1-e;return 3*s*s*(n-t)+6*s*e*(i-n)+3*e*e*(r-i)}function aE(e,t,n,i,r){let s=(e-t)/(r-t);for(let o=0;o<8;o++){let a=Sv(s,t,n,i,r)-e;if(Math.abs(a)<0.0000000001)break;let c=oE(s,t,n,i,r);if(Math.abs(c)<0.0000000001)break;s=Math.max(0,Math.min(1,s-a/c))}return s}class Ln{constructor(e,t,n,i){if(e===void 0)throw Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=lr(t,this.TimeBufferType),this.values=lr(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:lr(e.times,Array),values:lr(e.values,Array)};let i=e.getInterpolation();if(i!==e.DefaultInterpolation)n.interpolation=i;if(Lc(e.settings))n.settings={inTangents:lr(e.settings.inTangents,Array),outTangents:lr(e.settings.outTangents,Array)}}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new yd(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new rl(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new vd(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new bd(this.times,this.values,this.getValueSize(),e);if(this.settings)t.inTangents=this.settings.inTangents,t.outTangents=this.settings.outTangents;return t}setInterpolation(e){let t;switch(e){case 2300:t=this.InterpolantFactoryMethodDiscrete;break;case 2301:t=this.InterpolantFactoryMethodLinear;break;case 2302:t=this.InterpolantFactoryMethodSmooth;break;case 2303:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw Error(n);return Ue("KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return 2300;case this.InterpolantFactoryMethodLinear:return 2301;case this.InterpolantFactoryMethodSmooth:return 2302;case this.InterpolantFactoryMethodBezier:return 2303}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e;if(Lc(this.settings))gx(this.settings.inTangents,e),gx(this.settings.outTangents,e)}return this}trim(e,t){let n=this.times,i=n.length,r=0,s=i-1;while(r!==i&&n[r]<e)++r;while(s!==-1&&n[s]>t)--s;if(++s,r!==0||s!==i){if(r>=s)s=Math.max(s,1),r=s-1;let o=this.getValueSize();this.times=n.slice(r,s),this.values=this.values.slice(r*o,s*o)}return this}validate(){let e=!0,t=this.getValueSize();if(t-Math.floor(t)!==0)$e("KeyframeTrack: Invalid value size in track.",this),e=!1;let n=this.times,i=this.values,r=n.length;if(r===0)$e("KeyframeTrack: Track is empty.",this),e=!1;let s=null;for(let o=0;o!==r;o++){let a=n[o];if(typeof a==="number"&&isNaN(a)){$e("KeyframeTrack: Time is not a valid number.",this,o,a),e=!1;break}if(s!==null&&s>a){$e("KeyframeTrack: Out of order keys.",this,o,a,s),e=!1;break}s=a}if(i!==void 0){if(_M(i))for(let o=0,a=i.length;o!==a;++o){let c=i[o];if(isNaN(c)){$e("KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===2302,r=e.length-1,s=1;for(let o=1;o<r;++o){let a=!1,c=e[o],l=e[o+1];if(c!==l&&(o!==1||c!==e[0]))if(!i){let u=o*n,h=u-n,d=u+n;for(let f=0;f!==n;++f){let m=t[u+f];if(m!==t[h+f]||m!==t[d+f]){a=!0;break}}}else a=!0;if(a){if(o!==s){e[s]=e[o];let u=o*n,h=s*n;for(let d=0;d!==n;++d)t[h+d]=t[u+d]}++s}}if(r>0){e[s]=e[r];for(let o=r*n,a=s*n,c=0;c!==n;++c)t[a+c]=t[o+c];++s}if(s!==e.length)this.times=e.slice(0,s),this.values=t.slice(0,s*n);else this.times=e,this.values=t;return this}clone(){let e=this.times.slice(),t=this.values.slice(),i=new this.constructor(this.name,e,t);if(i.createInterpolant=this.createInterpolant,Lc(this.settings))i.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()};return i}}function gx(e,t){for(let n=0,i=e.length;n!==i;n+=2)e[n]*=t}Ln.prototype.ValueTypeName="";Ln.prototype.TimeBufferType=Float32Array;Ln.prototype.ValueBufferType=Float32Array;Ln.prototype.DefaultInterpolation=2301;class vr extends Ln{constructor(e,t,n){super(e,t,n)}}vr.prototype.ValueTypeName="bool";vr.prototype.ValueBufferType=Array;vr.prototype.DefaultInterpolation=2300;vr.prototype.InterpolantFactoryMethodLinear=void 0;vr.prototype.InterpolantFactoryMethodSmooth=void 0;class sl extends Ln{constructor(e,t,n,i){super(e,t,n,i)}}sl.prototype.ValueTypeName="color";class yr extends Ln{constructor(e,t,n,i){super(e,t,n,i)}}yr.prototype.ValueTypeName="number";class Sd extends Wi{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=(n-t)/(i-t),c=e*o;for(let l=c+o;c!==l;c+=4)Yt.slerpFlat(r,0,s,c-o,s,c,a);return r}}class br extends Ln{constructor(e,t,n,i){super(e,t,n,i)}InterpolantFactoryMethodLinear(e){return new Sd(this.times,this.values,this.getValueSize(),e)}}br.prototype.ValueTypeName="quaternion";br.prototype.InterpolantFactoryMethodSmooth=void 0;class Sr extends Ln{constructor(e,t,n){super(e,t,n)}}Sr.prototype.ValueTypeName="string";Sr.prototype.ValueBufferType=Array;Sr.prototype.DefaultInterpolation=2300;Sr.prototype.InterpolantFactoryMethodLinear=void 0;Sr.prototype.InterpolantFactoryMethodSmooth=void 0;class Jr extends Ln{constructor(e,t,n,i){super(e,t,n,i)}}Jr.prototype.ValueTypeName="vector";class Rs{constructor(e="",t=-1,n=[],i=2500){if(this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=Qn(),this.userData={},this.duration<0)this.resetDuration()}static parse(e){let t=[],n=e.tracks,i=1/(e.fps||1);for(let s=0,o=n.length;s!==o;++s)t.push(lE(n[s]).scale(i));let r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r.userData=JSON.parse(e.userData||"{}"),r}static toJSON(e){let t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let r=0,s=n.length;r!==s;++r)t.push(Ln.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(e,t,n,i){let r=t.length,s=[];for(let o=0;o<r;o++){let a=[],c=[];a.push((o+r-1)%r,o,(o+1)%r),c.push(0,1,0);let l=rE(a);if(a=mx(a,1,l),c=mx(c,1,l),!i&&a[0]===0)a.push(r),c.push(c[0]);s.push(new yr(".morphTargetInfluences["+t[o].name+"]",a,c).scale(1/n))}return new this(e,-1,s)}static findByName(e,t){let n=e;if(!Array.isArray(e)){let i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){let i={},r=/^([\w-]*?)([\d]+)$/;for(let o=0,a=e.length;o<a;o++){let c=e[o],l=c.name.match(r);if(l&&l.length>1){let u=l[1],h=i[u];if(!h)i[u]=h=[];h.push(c)}}let s=[];for(let o in i)s.push(this.CreateFromMorphTargetSequence(o,i[o],t,n));return s}resetDuration(){let e=this.tracks,t=0;for(let n=0,i=e.length;n!==i;++n){let r=this.tracks[n];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let n=0;n<this.tracks.length;n++)e.push(this.tracks[n].clone());let t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}}function cE(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return yr;case"vector":case"vector2":case"vector3":case"vector4":return Jr;case"color":return sl;case"quaternion":return br;case"bool":case"boolean":return vr;case"string":return Sr}throw Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function lE(e){if(e.type===void 0)throw Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=cE(e.type);if(e.times===void 0){let i=[],r=[];sE(e.keys,i,r,"value"),e.times=i,e.values=r}let n;if(t.parse!==void 0)n=t.parse(e);else n=new t(e.name,e.times,e.values,e.interpolation);if(Lc(e.settings))n.settings={inTangents:lr(e.settings.inTangents,Float32Array),outTangents:lr(e.settings.outTangents,Float32Array)};return n}var _i={enabled:!1,files:{},add:function(e,t){if(this.enabled===!1)return;if(_x(e))return;this.files[e]=t},get:function(e){if(this.enabled===!1)return;if(_x(e))return;return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};function _x(e){try{let t=e.slice(e.indexOf(":")+1);return new URL(t).protocol==="blob:"}catch(t){return!1}}class na{constructor(e,t,n){let i=this,r=!1,s=0,o=0,a=void 0,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(l){if(o++,r===!1){if(i.onStart!==void 0)i.onStart(l,s,o)}r=!0},this.itemEnd=function(l){if(s++,i.onProgress!==void 0)i.onProgress(l,s,o);if(s===o){if(r=!1,i.onLoad!==void 0)i.onLoad()}},this.itemError=function(l){if(i.onError!==void 0)i.onError(l)},this.resolveURL=function(l){if(l=l.normalize("NFC"),a)return a(l);return l},this.setURLModifier=function(l){return a=l,this},this.addHandler=function(l,u){return c.push(l,u),this},this.removeHandler=function(l){let u=c.indexOf(l);if(u!==-1)c.splice(u,2);return this},this.getHandler=function(l){for(let u=0,h=c.length;u<h;u+=2){let d=c[u],f=c[u+1];if(d.global)d.lastIndex=0;if(d.test(l))return f}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){if(!this._abortController)this._abortController=new AbortController;return this._abortController}}var wv=new na;class Zi{constructor(e){if(this.manager=e!==void 0?e:wv,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(e,t){let n=this;return new Promise(function(i,r){n.load(e,i,t,r)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}}Zi.DEFAULT_MATERIAL_NAME="__DEFAULT";var Gi={};class Mv extends Error{constructor(e,t){super(e);this.response=t}}class ia extends Zi{constructor(e){super(e);this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,n,i){if(e===void 0)e="";if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=_i.get(`file:${e}`);if(r!==void 0){this.manager.itemStart(e),setTimeout(()=>{if(t)t(r);this.manager.itemEnd(e)},0);return}if(Gi[e]!==void 0){Gi[e].push({onLoad:t,onProgress:n,onError:i});return}Gi[e]=[],Gi[e].push({onLoad:t,onProgress:n,onError:i});let s=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any==="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,a=this.responseType;fetch(s).then((c)=>{if(c.status===200||c.status===0){if(c.status===0)Ue("FileLoader: HTTP Status 0 received.");if(typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;let l=Gi[e],u=c.body.getReader(),h=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),d=h?parseInt(h):0,f=d!==0,m=0,_=new ReadableStream({start(p){g();function g(){u.read().then(({done:M,value:T})=>{if(M)p.close();else{m+=T.byteLength;let v=new ProgressEvent("progress",{lengthComputable:f,loaded:m,total:d});for(let S=0,E=l.length;S<E;S++){let R=l[S];if(R.onProgress)R.onProgress(v)}p.enqueue(T),g()}},(M)=>{p.error(M)})}}});return new Response(_)}else throw new Mv(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then((c)=>{switch(a){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then((l)=>new DOMParser().parseFromString(l,o));case"json":return c.json();default:if(o==="")return c.text();else{let u=/charset="?([^;"\s]*)"?/i.exec(o),h=u&&u[1]?u[1].toLowerCase():void 0,d=new TextDecoder(h);return c.arrayBuffer().then((f)=>d.decode(f))}}}).then((c)=>{_i.add(`file:${e}`,c);let l=Gi[e];delete Gi[e];for(let u=0,h=l.length;u<h;u++){let d=l[u];if(d.onLoad)d.onLoad(c)}}).catch((c)=>{let l=Gi[e];if(l===void 0)throw this.manager.itemError(e),c;delete Gi[e];for(let u=0,h=l.length;u<h;u++){let d=l[u];if(d.onError)d.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}var Ss=new WeakMap;class wd extends Zi{constructor(e){super(e)}load(e,t,n,i){if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=this,s=_i.get(`image:${e}`);if(s!==void 0){if(s.complete===!0)r.manager.itemStart(e),setTimeout(function(){if(t)t(s);r.manager.itemEnd(e)},0);else{let u=Ss.get(s);if(u===void 0)u=[],Ss.set(s,u);u.push({onLoad:t,onError:i})}return s}let o=Ts("img");function a(){if(l(),t)t(this);let u=Ss.get(this)||[];for(let h=0;h<u.length;h++){let d=u[h];if(d.onLoad)d.onLoad(this)}Ss.delete(this),r.manager.itemEnd(e)}function c(u){if(l(),i)i(u);_i.remove(`image:${e}`);let h=Ss.get(this)||[];for(let d=0;d<h.length;d++){let f=h[d];if(f.onError)f.onError(u)}Ss.delete(this),r.manager.itemError(e),r.manager.itemEnd(e)}function l(){o.removeEventListener("load",a,!1),o.removeEventListener("error",c,!1)}if(o.addEventListener("load",a,!1),o.addEventListener("error",c,!1),e.slice(0,5)!=="data:"){if(this.crossOrigin!==void 0)o.crossOrigin=this.crossOrigin}return _i.add(`image:${e}`,o),r.manager.itemStart(e),o.src=e,o}}class ol extends Zi{constructor(e){super(e)}load(e,t,n,i){let r=new Ot,s=new wd(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(e,function(o){if(r.image=o,r.needsUpdate=!0,t!==void 0)t(r)},n,i),r}}class Gs extends _t{constructor(e,t=1){super();this.isLight=!0,this.type="Light",this.color=new He(e),this.intensity=t}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}}class al extends Gs{constructor(e,t,n){super(e,n);this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.groundColor=new He(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){let t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}}var ch=new Xe,xx=new F,vx=new F;class ra{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Be(512,512),this.mapType=1009,this.map=null,this.mapPass=null,this.matrix=new Xe,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Jo,this._frameExtents=new Be(1,1),this._viewportCount=1,this._viewports=[new pt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getCamera(){return this.camera}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera;xx.setFromMatrixPosition(e.matrixWorld),t.position.copy(xx),vx.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(vx),t.updateMatrixWorld(),this._updateMatrix(t,this.matrix,this._frustum)}_updateMatrix(e,t,n,i){ch.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),n.setFromProjectionMatrix(ch,e.coordinateSystem,e.reversedDepth);let r=this._frameExtents,s=i?i.z/r.x:1,o=i?i.w/r.y:1,a=i?i.x/r.x:0,c=i?i.y/r.y:0;if(e.coordinateSystem===2001||e.reversedDepth)t.set(0.5*s,0,0,0.5*s+a,0,0.5*o,0,0.5*o+c,0,0,1,0,0,0,0,1);else t.set(0.5*s,0,0,0.5*s+a,0,0.5*o,0,0.5*o+c,0,0,0.5,0.5,0,0,0,1);t.multiply(ch)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){if(this.map)this.map.dispose();if(this.mapPass)this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return e.intensity=this.intensity,e.bias=this.bias,e.normalBias=this.normalBias,e.radius=this.radius,e.blurSamples=this.blurSamples,e.mapSize=this.mapSize.toArray(),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}var Ic=new F,Pc=new Yt,mi=new F;class cl extends _t{constructor(){super();this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Xe,this.projectionMatrix=new Xe,this.projectionMatrixInverse=new Xe,this.coordinateSystem=2000,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.matrixWorld.decompose(Ic,Pc,mi),mi.x===1&&mi.y===1&&mi.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(Ic,Pc,mi.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){if(super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(Ic,Pc,mi),mi.x===1&&mi.y===1&&mi.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(Ic,Pc,mi.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}var cr=new F,yx=new Be,bx=new Be;class Ht extends cl{constructor(e=50,t=1,n=0.1,i=2000){super();this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=0.5*this.getFilmHeight()/e;this.fov=Vr*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(Uo*0.5*this.fov);return 0.5*this.getFilmHeight()/e}getEffectiveFOV(){return Vr*2*Math.atan(Math.tan(Uo*0.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){cr.set(-1,-1,0.5).applyMatrix4(this.projectionMatrixInverse),t.set(cr.x,cr.y).multiplyScalar(-e/cr.z),cr.set(1,1,0.5).applyMatrix4(this.projectionMatrixInverse),n.set(cr.x,cr.y).multiplyScalar(-e/cr.z)}getViewSize(e,t){return this.getViewBounds(e,yx,bx),t.subVectors(bx,yx)}setViewOffset(e,t,n,i,r,s){if(this.aspect=e/t,this.view===null)this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1};this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){if(this.view!==null)this.view.enabled=!1;this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(Uo*0.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-0.5*i,s=this.view;if(this.view!==null&&this.view.enabled){let{fullWidth:a,fullHeight:c}=s;r+=s.offsetX*i/a,t-=s.offsetY*n/c,i*=s.width/a,n*=s.height/c}let o=this.filmOffset;if(o!==0)r+=e*o/this.getFilmWidth();this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);if(t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null)t.object.view=Object.assign({},this.view);return t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class Ev extends ra{constructor(){super(new Ht(50,1,0.5,500));this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){let t=this.camera,n=Vr*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,r=e.distance||t.far;if(n!==t.fov||i!==t.aspect||r!==t.far)t.fov=n,t.aspect=i,t.far=r,t.updateProjectionMatrix();super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this.aspect=e.aspect,this}toJSON(){let e=super.toJSON();return e.focus=this.focus,e.aspect=this.aspect,e}}class ll extends Gs{constructor(e,t,n=0,i=Math.PI/3,r=0,s=2){super(e,t);this.isSpotLight=!0,this.type="SpotLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.target=new _t,this.distance=n,this.angle=i,this.penumbra=r,this.decay=s,this.map=null,this.shadow=new Ev}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.map=e.map,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);if(t.object.distance=this.distance,t.object.angle=this.angle,t.object.decay=this.decay,t.object.penumbra=this.penumbra,t.object.target=this.target.uuid,this.map&&this.map.isTexture)t.object.map=this.map.toJSON(e).uuid;return t.object.shadow=this.shadow.toJSON(),t}}class Tv extends ra{constructor(){super(new Ht(90,1,0.5,500));this.isPointLightShadow=!0}}class Hs extends Gs{constructor(e,t,n=0,i=2){super(e,t);this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new Tv}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}}class Qr extends cl{constructor(e=-1,t=1,n=1,i=-1,r=0.1,s=2000){super();this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=r,this.far=s,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,r,s){if(this.view===null)this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1};this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){if(this.view!==null)this.view.enabled=!1;this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2,r=n-e,s=n+e,o=i+t,a=i-t;if(this.view!==null&&this.view.enabled){let c=(this.right-this.left)/this.view.fullWidth/this.zoom,l=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,s=r+c*this.view.width,o-=l*this.view.offsetY,a=o-l*this.view.height}this.projectionMatrix.makeOrthographic(r,s,o,a,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);if(t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null)t.object.view=Object.assign({},this.view);return t}}class Av extends ra{constructor(){super(new Qr(-5,5,5,-5,0.5,500));this.isDirectionalLightShadow=!0}}class Vs extends Gs{constructor(e,t){super(e,t);this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.target=new _t,this.shadow=new Av}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}}class wr{static extractUrlBase(e){let t=e.lastIndexOf("/");if(t===-1)return"./";return e.slice(0,t+1)}static resolveURL(e,t){if(typeof e!=="string"||e==="")return"";if(/^https?:\/\//i.test(t)&&/^\//.test(e))t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1");if(/^(https?:)?\/\//i.test(e))return e;if(/^data:.*,.*$/i.test(e))return e;if(/^blob:.*$/i.test(e))return e;return t+e}}var lh=new WeakMap;class ul extends Zi{constructor(e){super(e);if(this.isImageBitmapLoader=!0,typeof createImageBitmap>"u")Ue("ImageBitmapLoader: createImageBitmap() not supported.");if(typeof fetch>"u")Ue("ImageBitmapLoader: fetch() not supported.");this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,n,i){if(e===void 0)e="";if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=this,s=_i.get(`image-bitmap:${e}`);if(s!==void 0){if(r.manager.itemStart(e),s.then){s.then((c)=>{if(lh.has(s)===!0){if(i)i(lh.get(s));r.manager.itemError(e),r.manager.itemEnd(e)}else{if(t)t(c);r.manager.itemEnd(e)}});return}setTimeout(function(){if(t)t(s);r.manager.itemEnd(e)},0);return}let o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader,o.signal=typeof AbortSignal.any==="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;let a=fetch(e,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign({},r.options,{colorSpaceConversion:"none"}))}).then(function(c){if(_i.add(`image-bitmap:${e}`,c),t)t(c);return r.manager.itemEnd(e),c}).catch(function(c){if(i)i(c);lh.set(a,c),_i.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});_i.add(`image-bitmap:${e}`,a),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}var ws=-90,Ms=1;class Md extends _t{constructor(e,t,n){super();this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let i=new Ht(ws,Ms,e,t);i.layers=this.layers,this.add(i);let r=new Ht(ws,Ms,e,t);r.layers=this.layers,this.add(r);let s=new Ht(ws,Ms,e,t);s.layers=this.layers,this.add(s);let o=new Ht(ws,Ms,e,t);o.layers=this.layers,this.add(o);let a=new Ht(ws,Ms,e,t);a.layers=this.layers,this.add(a);let c=new Ht(ws,Ms,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,i,r,s,o,a]=t;for(let c of t)this.remove(c);if(e===2000)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),a.up.set(0,1,0),a.lookAt(0,0,-1);else if(e===2001)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),a.up.set(0,-1,0),a.lookAt(0,0,-1);else throw Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let c of t)this.add(c),c.updateMatrixWorld()}update(e,t){if(this.parent===null)this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:i}=this;if(this.coordinateSystem!==e.coordinateSystem)this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem();let[r,s,o,a,c,l]=this.children,u=e.getRenderTarget(),h=e.getActiveCubeFace(),d=e.getActiveMipmapLevel(),f=e.xr.enabled;e.xr.enabled=!1;let m=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let _=!1;if(e.isWebGLRenderer===!0)_=e.state.buffers.depth.getReversed();else _=e.reversedDepthBuffer;if(e.setRenderTarget(n,0,i),_&&e.autoClear===!1)e.clearDepth();if(e.render(t,r),e.setRenderTarget(n,1,i),_&&e.autoClear===!1)e.clearDepth();if(e.render(t,s),e.setRenderTarget(n,2,i),_&&e.autoClear===!1)e.clearDepth();if(e.render(t,o),e.setRenderTarget(n,3,i),_&&e.autoClear===!1)e.clearDepth();if(e.render(t,a),e.setRenderTarget(n,4,i),_&&e.autoClear===!1)e.clearDepth();if(e.render(t,c),n.texture.generateMipmaps=m,e.setRenderTarget(n,5,i),_&&e.autoClear===!1)e.clearDepth();e.render(t,l),e.setRenderTarget(u,h,d),e.xr.enabled=f,n.texture.needsPMREMUpdate=!0}}class Ed extends Ht{constructor(e=[]){super();this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class Td{constructor(e,t,n){this.binding=e,this.valueSize=n;let i,r,s;switch(t){case"quaternion":i=this._slerp,r=this._slerpAdditive,s=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":i=this._select,r=this._select,s=this._setAdditiveIdentityOther,this.buffer=Array(n*5);break;default:i=this._lerp,r=this._lerpAdditive,s=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=r,this._setIdentity=s,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let n=this.buffer,i=this.valueSize,r=e*i+i,s=this.cumulativeWeight;if(s===0){for(let o=0;o!==i;++o)n[r+o]=n[o];s=t}else{s+=t;let o=t/s;this._mixBufferRegion(n,r,0,o,i)}this.cumulativeWeight=s}accumulateAdditive(e){let t=this.buffer,n=this.valueSize,i=n*this._addIndex;if(this.cumulativeWeightAdditive===0)this._setIdentity();this._mixBufferRegionAdditive(t,i,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,n=this.buffer,i=e*t+t,r=this.cumulativeWeight,s=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){let a=t*this._origIndex;this._mixBufferRegion(n,i,a,1-r,t)}if(s>0)this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let a=t,c=t+t;a!==c;++a)if(n[a]!==n[a+t]){o.setValue(n,i);break}}saveOriginalState(){let e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let r=n,s=i;r!==s;++r)t[r]=t[i+r%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n<t;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}_select(e,t,n,i,r){if(i>=0.5)for(let s=0;s!==r;++s)e[t+s]=e[n+s]}_slerp(e,t,n,i){Yt.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){let s=this._workIndex*r;Yt.multiplyQuaternionsFlat(e,s,e,t,e,n),Yt.slerpFlat(e,t,e,t,e,s,i)}_lerp(e,t,n,i,r){let s=1-i;for(let o=0;o!==r;++o){let a=t+o;e[a]=e[a]*s+e[n+o]*i}}_lerpAdditive(e,t,n,i,r){for(let s=0;s!==r;++s){let o=t+s;e[o]=e[o]+e[n+s]*i}}}var Ad="\\[\\]\\.:\\/",uE=new RegExp("["+Ad+"]","g"),Rd="[^"+Ad+"]",hE="[^"+Ad.replace("\\.","")+"]",dE=/((?:WC+[\/:])*)/.source.replace("WC",Rd),fE=/(WCOD+)?/.source.replace("WCOD",hE),pE=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Rd),mE=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Rd),gE=new RegExp("^"+dE+fE+pE+mE+"$"),_E=["material","materials","bones","map"];class Rv{constructor(e,t,n){let i=n||ct.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];if(i!==void 0)i.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class ct{constructor(e,t,n){this.path=t,this.parsedPath=n||ct.parseTrackName(t),this.node=ct.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){if(!(e&&e.isAnimationObjectGroup))return new ct(e,t,n);else return new ct.Composite(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(uE,"")}static parseTrackName(e){let t=gE.exec(e);if(t===null)throw Error("THREE.PropertyBinding: Cannot parse trackName: "+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){let r=n.nodeName.substring(i+1);if(_E.indexOf(r)!==-1)n.nodeName=n.nodeName.substring(0,i),n.objectName=r}if(n.propertyName===null||n.propertyName.length===0)throw Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(r){for(let s=0;s<r.length;s++){let o=r[s];if(o.name===t||o.uuid===t)return o;let a=n(o.children);if(a)return a}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,{objectName:n,propertyName:i,propertyIndex:r}=t;if(!e)e=ct.findNode(this.rootNode,t.nodeName),this.node=e;if(this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){Ue("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){$e("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){$e("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){$e("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let l=0;l<e.length;l++)if(e[l].name===c){c=l;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){$e("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){$e("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){$e("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){$e("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}let s=e[i];if(s===void 0){let c=t.nodeName;$e("PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",e);return}let o=this.Versioning.None;if(this.targetObject=e,e.isMaterial===!0)o=this.Versioning.NeedsUpdate;else if(e.isObject3D===!0)o=this.Versioning.MatrixWorldNeedsUpdate;let a=this.BindingType.Direct;if(r!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){$e("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){$e("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}if(e.morphTargetDictionary[r]!==void 0)r=e.morphTargetDictionary[r]}a=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=r}else if(s.fromArray!==void 0&&s.toArray!==void 0)a=this.BindingType.HasFromToArray,this.resolvedProperty=s;else if(Array.isArray(s))a=this.BindingType.EntireArray,this.resolvedProperty=s;else this.propertyName=i;this.getValue=this.GetterByBindingType[a],this.setValue=this.SetterByBindingTypeAndVersioning[a][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}ct.Composite=Rv;ct.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};ct.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};ct.prototype.GetterByBindingType=[ct.prototype._getValue_direct,ct.prototype._getValue_array,ct.prototype._getValue_arrayElement,ct.prototype._getValue_toArray];ct.prototype.SetterByBindingTypeAndVersioning=[[ct.prototype._setValue_direct,ct.prototype._setValue_direct_setNeedsUpdate,ct.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[ct.prototype._setValue_array,ct.prototype._setValue_array_setNeedsUpdate,ct.prototype._setValue_array_setMatrixWorldNeedsUpdate],[ct.prototype._setValue_arrayElement,ct.prototype._setValue_arrayElement_setNeedsUpdate,ct.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[ct.prototype._setValue_fromArray,ct.prototype._setValue_fromArray_setNeedsUpdate,ct.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class Cd{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;let r=t.tracks,s=r.length,o=Array(s),a={endingStart:2400,endingEnd:2400};for(let c=0;c!==s;++c){let l=r[c].createInterpolant(null);o[c]=l,l.settings=a}this._interpolantSettings=a,this._interpolants=o,this._propertyBindings=Array(s),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._restoreTimeScale=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n=!1){if(e.fadeOut(t),this.fadeIn(t),n===!0){let i=this._clip.duration,r=e._clip.duration,s=r/i,o=i/r;e._restoreTimeScale=e.timeScale,this._restoreTimeScale=this.timeScale,e.warp(1,s,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,n=!1){return e.crossFadeFrom(this,t,n)}stopFading(){let e=this._weightInterpolant;if(e!==null)this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e);return this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){let i=this._mixer,r=i.time,s=this.timeScale,o=this._timeScaleInterpolant;if(o===null)o=i._lendControlInterpolant(),this._timeScaleInterpolant=o;let a=o.parameterPositions,c=o.sampleValues;return a[0]=r,a[1]=r+n,c[0]=e/s,c[1]=t/s,this}stopWarping(){let e=this._timeScaleInterpolant;if(e!==null)this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e);return this._restoreTimeScale=null,this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,i){if(!this.enabled){this._updateWeight(e);return}let r=this._startTime;if(r!==null){let a=(e-r)*n;if(a<0||n===0)t=0;else this._startTime=null,t=n*a}t*=this._updateTimeScale(e);let s=this._updateTime(t),o=this._updateWeight(e);if(o>0){let a=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case 2501:for(let l=0,u=a.length;l!==u;++l)a[l].evaluate(s),c[l].accumulateAdditive(o);break;case 2500:default:for(let l=0,u=a.length;l!==u;++l)a[l].evaluate(s),c[l].accumulate(i,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let n=this._weightInterpolant;if(n!==null){let i=n.evaluate(e)[0];if(t*=i,e>n.parameterPositions[1]){if(this.stopFading(),i===0)this.enabled=!1}}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let n=this._timeScaleInterpolant;if(n!==null){let i=n.evaluate(e)[0];if(t*=i,e>n.parameterPositions[1]){if(t===0)this.paused=!0;else{if(this._restoreTimeScale!==null)t=this._restoreTimeScale;this.timeScale=t}this.stopWarping()}}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,n=this.loop,i=this.time+e,r=this._loopCount,s=n===2202;if(e===0){if(r===-1)return i;return s&&(r&1)===1?t-i:i}if(n===2200){if(r===-1)this._loopCount=0,this._setEndings(!0,!0,!1);e:{if(i>=t)i=t;else if(i<0)i=0;else{this.time=i;break e}if(this.clampWhenFinished)this.paused=!0;else this.enabled=!1;this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(r===-1)if(e>=0)r=0,this._setEndings(!0,this.repetitions===0,s);else this._setEndings(this.repetitions===0,!0,s);if(i>=t||i<0){let o=Math.floor(i/t);i-=t*o,r+=Math.abs(o);let a=this.repetitions-r;if(a<=0){if(this.clampWhenFinished)this.paused=!0;else this.enabled=!1;i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1})}else{if(a===1){let c=e<0;this._setEndings(c,!c,s)}else this._setEndings(!1,!1,s);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this._loopCount=r,this.time=i;if(s&&(r&1)===1)return t-i}return i}_setEndings(e,t,n){let i=this._interpolantSettings;if(n)i.endingStart=2401,i.endingEnd=2401;else{if(e)i.endingStart=this.zeroSlopeAtStart?2401:2400;else i.endingStart=2402;if(t)i.endingEnd=this.zeroSlopeAtEnd?2401:2400;else i.endingEnd=2402}}_scheduleFading(e,t,n){let i=this._mixer,r=i.time,s=this._weightInterpolant;if(s===null)s=i._lendControlInterpolant(),this._weightInterpolant=s;let o=s.parameterPositions,a=s.sampleValues;return o[0]=r,a[0]=t,o[1]=r+e,a[1]=n,this}}var xE=new Float32Array(1);class hl extends ii{constructor(e){super();if(this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1,typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}_bindAction(e,t){let n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,{_propertyBindings:s,_interpolants:o}=e,a=n.uuid,c=this._bindingsByRootAndName,l=c[a];if(l===void 0)l={},c[a]=l;for(let u=0;u!==r;++u){let h=i[u],d=h.name,f=l[d];if(f!==void 0)++f.referenceCount,s[u]=f;else{if(f=s[u],f!==void 0){if(f._cacheIndex===null)++f.referenceCount,this._addInactiveBinding(f,a,d);continue}let m=t&&t._propertyBindings[u].binding.parsedPath;f=new Td(ct.create(n,d,m),h.ValueTypeName,h.getValueSize()),++f.referenceCount,this._addInactiveBinding(f,a,d),s[u]=f}o[u].resultBuffer=f.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let n=(e._localRoot||this._root).uuid,i=e._clip.uuid,r=this._actionsByClip[i];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,i,n)}let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(r.useCount++===0)this._lendBinding(r),r.saveOriginalState()}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(--r.useCount===0)r.restoreOriginalState(),this._takeBackBinding(r)}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,n){let i=this._actions,r=this._actionsByClip,s=r[t];if(s===void 0)s={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[t]=s;else{let o=s.knownActions;e._byClipCacheIndex=o.length,o.push(e)}e._cacheIndex=i.length,i.push(e),s.actionByRoot[n]=e}_removeInactiveAction(e){let t=this._actions,n=t[t.length-1],i=e._cacheIndex;n._cacheIndex=i,t[i]=n,t.pop(),e._cacheIndex=null;let r=e._clip.uuid,s=this._actionsByClip,o=s[r],a=o.knownActions,c=a[a.length-1],l=e._byClipCacheIndex;c._byClipCacheIndex=l,a[l]=c,a.pop(),e._byClipCacheIndex=null;let u=o.actionByRoot,h=(e._localRoot||this._root).uuid;if(delete u[h],a.length===0)delete s[r];this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(--r.referenceCount===0)this._removeInactiveBinding(r)}}_lendAction(e){let t=this._actions,n=e._cacheIndex,i=this._nActiveActions++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackAction(e){let t=this._actions,n=e._cacheIndex,i=--this._nActiveActions,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_addInactiveBinding(e,t,n){let i=this._bindingsByRootAndName,r=this._bindings,s=i[t];if(s===void 0)s={},i[t]=s;s[n]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){let t=this._bindings,n=e.binding,i=n.rootNode.uuid,r=n.path,s=this._bindingsByRootAndName,o=s[i],a=t[t.length-1],c=e._cacheIndex;if(a._cacheIndex=c,t[c]=a,t.pop(),delete o[r],Object.keys(o).length===0)delete s[i]}_lendBinding(e){let t=this._bindings,n=e._cacheIndex,i=this._nActiveBindings++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackBinding(e){let t=this._bindings,n=e._cacheIndex,i=--this._nActiveBindings,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,n=e[t];if(n===void 0)n=new rl(new Float32Array(2),new Float32Array(2),1,xE),n.__cacheIndex=t,e[t]=n;return n}_takeBackControlInterpolant(e){let t=this._controlInterpolants,n=e.__cacheIndex,i=--this._nActiveControlInterpolants,r=t[i];e.__cacheIndex=i,t[i]=e,r.__cacheIndex=n,t[n]=r}clipAction(e,t,n){let i=t||this._root,r=i.uuid,s=typeof e==="string"?Rs.findByName(i,e):e,o=s!==null?s.uuid:e,a=this._actionsByClip[o],c=null;if(n===void 0)if(s!==null)n=s.blendMode;else n=2500;if(a!==void 0){let u=a.actionByRoot[r];if(u!==void 0&&u.blendMode===n)return u;if(c=a.knownActions[0],s===null)s=c._clip}if(s===null)return null;let l=new Cd(this,s,t,n);return this._bindAction(l,c),this._addInactiveAction(l,o,r),l}existingAction(e,t){let n=t||this._root,i=n.uuid,r=typeof e==="string"?Rs.findByName(n,e):e,s=r?r.uuid:e,o=this._actionsByClip[s];if(o!==void 0)return o.actionByRoot[i]||null;return null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let n=t-1;n>=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;let t=this._actions,n=this._nActiveActions,i=this.time+=e,r=Math.sign(e),s=this._accuIndex^=1;for(let c=0;c!==n;++c)t[c]._update(i,e,r,s);let o=this._bindings,a=this._nActiveBindings;for(let c=0;c!==a;++c)o[c].apply(s);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,n=e.uuid,i=this._actionsByClip,r=i[n];if(r!==void 0){let s=r.knownActions;for(let o=0,a=s.length;o!==a;++o){let c=s[o];this._deactivateAction(c);let l=c._cacheIndex,u=t[t.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,u._cacheIndex=l,t[l]=u,t.pop(),this._removeInactiveBindingsForAction(c)}delete i[n]}}uncacheRoot(e){let t=e.uuid,n=this._actionsByClip;for(let s in n){let o=n[s].actionByRoot,a=o[t];if(a!==void 0)this._deactivateAction(a),this._removeInactiveAction(a)}let i=this._bindingsByRootAndName,r=i[t];if(r!==void 0)for(let s in r){let o=r[s];o.restoreOriginalState(),this._removeInactiveBinding(o)}}uncacheAction(e,t){let n=this.existingAction(e,t);if(n!==null)this._deactivateAction(n),this._removeInactiveAction(n)}}class sa{constructor(e=1,t=0,n=0){this.radius=e,this.phi=t,this.theta=n}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Je(this.phi,0.000001,Math.PI-0.000001),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){if(this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0)this.theta=0,this.phi=0;else this.theta=Math.atan2(e,n),this.phi=Math.acos(Je(t/this.radius,-1,1));return this}clone(){return new this.constructor().copy(this)}}class Id{static{Id.prototype.isMatrix2=!0}constructor(e,t,n,i){if(this.elements=[1,0,0,1],e!==void 0)this.set(e,t,n,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,i){let r=this.elements;return r[0]=e,r[2]=t,r[1]=n,r[3]=i,this}}class dl extends ii{constructor(e,t=null){super();this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(this.domElement!==null)this.disconnect();this.domElement=e}disconnect(){}dispose(){}update(){}}function Pd(e,t,n,i){let r=vE(i);switch(n){case 1021:return e*t;case 1028:return e*t/r.components*r.byteLength;case 1029:return e*t/r.components*r.byteLength;case 1030:return e*t*2/r.components*r.byteLength;case 1031:return e*t*2/r.components*r.byteLength;case 1022:return e*t*3/r.components*r.byteLength;case 1023:return e*t*4/r.components*r.byteLength;case 1033:return e*t*4/r.components*r.byteLength;case 33776:case 33777:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case 33778:case 33779:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 35841:case 35843:return Math.max(e,16)*Math.max(t,8)/4;case 35840:case 35842:return Math.max(e,8)*Math.max(t,8)/2;case 36196:case 37492:case 37488:case 37489:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case 37496:case 37490:case 37491:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 37808:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 37809:return Math.floor((e+4)/5)*Math.floor((t+3)/4)*16;case 37810:return Math.floor((e+4)/5)*Math.floor((t+4)/5)*16;case 37811:return Math.floor((e+5)/6)*Math.floor((t+4)/5)*16;case 37812:return Math.floor((e+5)/6)*Math.floor((t+5)/6)*16;case 37813:return Math.floor((e+7)/8)*Math.floor((t+4)/5)*16;case 37814:return Math.floor((e+7)/8)*Math.floor((t+5)/6)*16;case 37815:return Math.floor((e+7)/8)*Math.floor((t+7)/8)*16;case 37816:return Math.floor((e+9)/10)*Math.floor((t+4)/5)*16;case 37817:return Math.floor((e+9)/10)*Math.floor((t+5)/6)*16;case 37818:return Math.floor((e+9)/10)*Math.floor((t+7)/8)*16;case 37819:return Math.floor((e+9)/10)*Math.floor((t+9)/10)*16;case 37820:return Math.floor((e+11)/12)*Math.floor((t+9)/10)*16;case 37821:return Math.floor((e+11)/12)*Math.floor((t+11)/12)*16;case 36492:case 36494:case 36495:return Math.ceil(e/4)*Math.ceil(t/4)*16;case 36283:case 36284:return Math.ceil(e/4)*Math.ceil(t/4)*8;case 36285:case 36286:return Math.ceil(e/4)*Math.ceil(t/4)*16}throw Error(`Unable to determine texture byte length for ${n} format.`)}function vE(e){switch(e){case 1009:case 1010:return{byteLength:1,components:1};case 1012:case 1011:case 1016:return{byteLength:2,components:1};case 1017:case 1018:return{byteLength:2,components:4};case 1014:case 1013:case 1015:return{byteLength:4,components:1};case 35902:case 35899:return{byteLength:4,components:3}}throw Error(`THREE.TextureUtils: Unknown texture type ${e}.`)}if(typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"186"}}));if(typeof window<"u")if(window.__THREE__)Ue("WARNING: Multiple instances of Three.js being imported.");else window.__THREE__="186";function Yv(){let e=null,t=!1,n=null,i=null;function r(s,o){i=e.requestAnimationFrame(r),n(s,o)}return{start:function(){if(t===!0)return;if(n===null)return;if(e===null)return;i=e.requestAnimationFrame(r),t=!0},stop:function(){if(e!==null)e.cancelAnimationFrame(i);t=!1},setAnimationLoop:function(s){n=s},setContext:function(s){e=s}}}function yE(e){let t=new WeakMap;function n(a,c){let{array:l,usage:u}=a,h=l.byteLength,d=e.createBuffer();e.bindBuffer(c,d),e.bufferData(c,l,u),a.onUploadCallback();let f;if(l instanceof Float32Array)f=e.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)f=e.HALF_FLOAT;else if(l instanceof Uint16Array)if(a.isFloat16BufferAttribute)f=e.HALF_FLOAT;else f=e.UNSIGNED_SHORT;else if(l instanceof Int16Array)f=e.SHORT;else if(l instanceof Uint32Array)f=e.UNSIGNED_INT;else if(l instanceof Int32Array)f=e.INT;else if(l instanceof Int8Array)f=e.BYTE;else if(l instanceof Uint8Array)f=e.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)f=e.UNSIGNED_BYTE;else throw Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:d,type:f,bytesPerElement:l.BYTES_PER_ELEMENT,version:a.version,size:h}}function i(a,c,l){let{array:u,updateRanges:h}=c;if(e.bindBuffer(l,a),h.length===0)e.bufferSubData(l,0,u);else{h.sort((f,m)=>f.start-m.start);let d=0;for(let f=1;f<h.length;f++){let m=h[d],_=h[f];if(_.start<=m.start+m.count+1)m.count=Math.max(m.count,_.start+_.count-m.start);else++d,h[d]=_}h.length=d+1;for(let f=0,m=h.length;f<m;f++){let _=h[f];e.bufferSubData(l,_.start*u.BYTES_PER_ELEMENT,u,_.start,_.count)}c.clearUpdateRanges()}c.onUploadCallback()}function r(a){if(a.isInterleavedBufferAttribute)a=a.data;return t.get(a)}function s(a){if(a.isInterleavedBufferAttribute)a=a.data;let c=t.get(a);if(c)e.deleteBuffer(c.buffer),t.delete(a)}function o(a,c){if(a.isInterleavedBufferAttribute)a=a.data;if(a.isGLBufferAttribute){let u=t.get(a);if(!u||u.version<a.version)t.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}let l=t.get(a);if(l===void 0)t.set(a,n(a,c));else if(l.version<a.version){if(l.size!==a.array.byteLength)throw Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");i(l.buffer,a,c),l.version=a.version}}return{get:r,remove:s,update:o}}var bE=`#ifdef USE_ALPHAHASH
66
+ }`;class Gn extends yn{constructor(e){super();if(this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=rE,this.fragmentShader=sE,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0)this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Jr(e.uniforms),this.uniformsGroups=iE(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let i in this.uniforms){let s=this.uniforms[i].value;if(s&&s.isTexture)t.uniforms[i]={type:"t",value:s.toJSON(e).uuid};else if(s&&s.isColor)t.uniforms[i]={type:"c",value:s.getHex()};else if(s&&s.isVector2)t.uniforms[i]={type:"v2",value:s.toArray()};else if(s&&s.isVector3)t.uniforms[i]={type:"v3",value:s.toArray()};else if(s&&s.isVector4)t.uniforms[i]={type:"v4",value:s.toArray()};else if(s&&s.isMatrix3)t.uniforms[i]={type:"m3",value:s.toArray()};else if(s&&s.isMatrix4)t.uniforms[i]={type:"m4",value:s.toArray()};else t.uniforms[i]={value:s}}if(Object.keys(this.defines).length>0)t.defines=this.defines;t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let i in this.extensions)if(this.extensions[i]===!0)n[i]=!0;if(Object.keys(n).length>0)t.extensions=n;return t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(let n in e.uniforms){let i=e.uniforms[n];switch(this.uniforms[n]={},i.type){case"t":this.uniforms[n].value=t[i.value]||null;break;case"c":this.uniforms[n].value=new Ge().setHex(i.value);break;case"v2":this.uniforms[n].value=new ke().fromArray(i.value);break;case"v3":this.uniforms[n].value=new z().fromArray(i.value);break;case"v4":this.uniforms[n].value=new pt().fromArray(i.value);break;case"m3":this.uniforms[n].value=new We().fromArray(i.value);break;case"m4":this.uniforms[n].value=new Xe().fromArray(i.value);break;default:this.uniforms[n].value=i.value}}if(e.defines!==void 0)this.defines=e.defines;if(e.vertexShader!==void 0)this.vertexShader=e.vertexShader;if(e.fragmentShader!==void 0)this.fragmentShader=e.fragmentShader;if(e.glslVersion!==void 0)this.glslVersion=e.glslVersion;if(e.extensions!==void 0)for(let n in e.extensions)this.extensions[n]=e.extensions[n];if(e.lights!==void 0)this.lights=e.lights;if(e.clipping!==void 0)this.clipping=e.clipping;return this}}class _d extends Gn{constructor(e){super(e);this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Wi extends yn{constructor(e){super();this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Ge(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ge(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ke(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new xi,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Pn extends Wi{constructor(e){super();this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new ke(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Je(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+0.4*t)/(1-0.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Ge(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Ge(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Ge(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._retroreflectivity=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){if(this._anisotropy>0!==e>0)this.version++;this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){if(this._clearcoat>0!==e>0)this.version++;this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){if(this._iridescence>0!==e>0)this.version++;this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){if(this._dispersion>0!==e>0)this.version++;this._dispersion=e}get retroreflectivity(){return this._retroreflectivity}set retroreflectivity(e){if(this._retroreflectivity>0!==e>0)this.version++;this._retroreflectivity=e}get sheen(){return this._sheen}set sheen(e){if(this._sheen>0!==e>0)this.version++;this._sheen=e}get transmission(){return this._transmission}set transmission(e){if(this._transmission>0!==e>0)this.version++;this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.retroreflectivity=e.retroreflectivity,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class sl extends yn{constructor(e){super();this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Ge(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ge(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ke(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new xi,this.combine=0,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=0.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class xd extends yn{constructor(e){super();this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class vd extends yn{constructor(e){super();this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}function ur(e,t){if(!e||e.constructor===t)return e;if(typeof t.BYTES_PER_ELEMENT==="number")return new t(e);return Array.prototype.slice.call(e)}function Dc(e){return e!==void 0&&e.inTangents!==void 0&&e.outTangents!==void 0}function oE(e){function t(r,s){return e[r]-e[s]}let n=e.length,i=Array(n);for(let r=0;r!==n;++r)i[r]=r;return i.sort(t),i}function gx(e,t,n){let i=e.length,r=new e.constructor(i);for(let s=0,o=0;o!==i;++s){let a=n[s]*t;for(let c=0;c!==t;++c)r[o++]=e[a+c]}return r}function aE(e,t,n,i){let r=1,s=e[0];while(s!==void 0&&s[i]===void 0)s=e[r++];if(s===void 0)return;let o=s[i];if(o===void 0)return;if(Array.isArray(o))do{if(o=s[i],o!==void 0)t.push(s.time),n.push(...o);s=e[r++]}while(s!==void 0);else if(o.toArray!==void 0)do{if(o=s[i],o!==void 0)t.push(s.time),o.toArray(n,n.length);s=e[r++]}while(s!==void 0);else do{if(o=s[i],o!==void 0)t.push(s.time),n.push(o);s=e[r++]}while(s!==void 0)}class Zi{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,i=t[n],r=t[n-1];e:{t:{let s;n:{i:if(!(e<i)){for(let o=n+2;;){if(i===void 0){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(r=i,i=t[++n],e<i)break t}s=t.length;break n}if(!(e>=r)){let o=t[1];if(e<o)n=2,r=o;for(let a=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===a)break;if(i=r,r=t[--n-1],e>=r)break t}s=n,n=0;break n}break e}while(n<s){let o=n+s>>>1;if(e<t[o])s=o;else n=o+1}if(i=t[n],r=t[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i;for(let s=0;s!==i;++s)t[s]=n[r+s];return t}interpolate_(){throw Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}}class yd extends Zi{constructor(e,t,n,i){super(e,t,n,i);this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:2400,endingEnd:2400}}intervalChanged_(e,t,n){let i=this.parameterPositions,r=e-2,s=e+1,o=i[r],a=i[s];if(o===void 0)switch(this.getSettings_().endingStart){case 2401:r=e,o=2*t-n;break;case 2402:r=i.length-2,o=t+i[r]-i[r+1];break;default:r=e,o=n}if(a===void 0)switch(this.getSettings_().endingEnd){case 2401:s=e,a=2*n-t;break;case 2402:s=1,a=n+i[1]-i[0];break;default:s=e-1,a=t}let c=(n-t)*0.5,l=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(a-n),this._offsetPrev=r*l,this._offsetNext=s*l}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=this._offsetPrev,u=this._offsetNext,h=this._weightPrev,d=this._weightNext,f=(n-t)/(i-t),m=f*f,_=m*f,p=-h*_+2*h*m-h*f,g=(1+h)*_+(-1.5-2*h)*m+(-0.5+h)*f+1,M=(-1-d)*_+(1.5+d)*m+0.5*f,T=d*_-d*m;for(let v=0;v!==o;++v)r[v]=p*s[l+v]+g*s[c+v]+M*s[a+v]+T*s[u+v];return r}}class ol extends Zi{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=(n-t)/(i-t),u=1-l;for(let h=0;h!==o;++h)r[h]=s[c+h]*u+s[a+h]*l;return r}}class bd extends Zi{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class Sd extends Zi{interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=this.inTangents,u=this.outTangents;if(!l||!u){let f=(n-t)/(i-t),m=1-f;for(let _=0;_!==o;++_)r[_]=s[c+_]*m+s[a+_]*f;return r}let h=o*2,d=e-1;for(let f=0;f!==o;++f){let m=s[c+f],_=s[a+f],p=d*h+f*2,g=u[p],M=u[p+1],T=e*h+f*2,v=l[T],S=l[T+1],E=lE(n,t,g,v,i);r[f]=wv(E,m,M,S,_)}return r}}function wv(e,t,n,i,r){let s=1-e;return s*s*s*t+3*s*s*e*n+3*s*e*e*i+e*e*e*r}function cE(e,t,n,i,r){let s=1-e;return 3*s*s*(n-t)+6*s*e*(i-n)+3*e*e*(r-i)}function lE(e,t,n,i,r){let s=(e-t)/(r-t);for(let o=0;o<8;o++){let a=wv(s,t,n,i,r)-e;if(Math.abs(a)<0.0000000001)break;let c=cE(s,t,n,i,r);if(Math.abs(c)<0.0000000001)break;s=Math.max(0,Math.min(1,s-a/c))}return s}class Ln{constructor(e,t,n,i){if(e===void 0)throw Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=ur(t,this.TimeBufferType),this.values=ur(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:ur(e.times,Array),values:ur(e.values,Array)};let i=e.getInterpolation();if(i!==e.DefaultInterpolation)n.interpolation=i;if(Dc(e.settings))n.settings={inTangents:ur(e.settings.inTangents,Array),outTangents:ur(e.settings.outTangents,Array)}}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new bd(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new ol(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new yd(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new Sd(this.times,this.values,this.getValueSize(),e);if(this.settings)t.inTangents=this.settings.inTangents,t.outTangents=this.settings.outTangents;return t}setInterpolation(e){let t;switch(e){case 2300:t=this.InterpolantFactoryMethodDiscrete;break;case 2301:t=this.InterpolantFactoryMethodLinear;break;case 2302:t=this.InterpolantFactoryMethodSmooth;break;case 2303:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw Error(n);return Ue("KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return 2300;case this.InterpolantFactoryMethodLinear:return 2301;case this.InterpolantFactoryMethodSmooth:return 2302;case this.InterpolantFactoryMethodBezier:return 2303}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e;if(Dc(this.settings))_x(this.settings.inTangents,e),_x(this.settings.outTangents,e)}return this}trim(e,t){let n=this.times,i=n.length,r=0,s=i-1;while(r!==i&&n[r]<e)++r;while(s!==-1&&n[s]>t)--s;if(++s,r!==0||s!==i){if(r>=s)s=Math.max(s,1),r=s-1;let o=this.getValueSize();this.times=n.slice(r,s),this.values=this.values.slice(r*o,s*o)}return this}validate(){let e=!0,t=this.getValueSize();if(t-Math.floor(t)!==0)Ve("KeyframeTrack: Invalid value size in track.",this),e=!1;let n=this.times,i=this.values,r=n.length;if(r===0)Ve("KeyframeTrack: Track is empty.",this),e=!1;let s=null;for(let o=0;o!==r;o++){let a=n[o];if(typeof a==="number"&&isNaN(a)){Ve("KeyframeTrack: Time is not a valid number.",this,o,a),e=!1;break}if(s!==null&&s>a){Ve("KeyframeTrack: Out of order keys.",this,o,a,s),e=!1;break}s=a}if(i!==void 0){if(vM(i))for(let o=0,a=i.length;o!==a;++o){let c=i[o];if(isNaN(c)){Ve("KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===2302,r=e.length-1,s=1;for(let o=1;o<r;++o){let a=!1,c=e[o],l=e[o+1];if(c!==l&&(o!==1||c!==e[0]))if(!i){let u=o*n,h=u-n,d=u+n;for(let f=0;f!==n;++f){let m=t[u+f];if(m!==t[h+f]||m!==t[d+f]){a=!0;break}}}else a=!0;if(a){if(o!==s){e[s]=e[o];let u=o*n,h=s*n;for(let d=0;d!==n;++d)t[h+d]=t[u+d]}++s}}if(r>0){e[s]=e[r];for(let o=r*n,a=s*n,c=0;c!==n;++c)t[a+c]=t[o+c];++s}if(s!==e.length)this.times=e.slice(0,s),this.values=t.slice(0,s*n);else this.times=e,this.values=t;return this}clone(){let e=this.times.slice(),t=this.values.slice(),i=new this.constructor(this.name,e,t);if(i.createInterpolant=this.createInterpolant,Dc(this.settings))i.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()};return i}}function _x(e,t){for(let n=0,i=e.length;n!==i;n+=2)e[n]*=t}Ln.prototype.ValueTypeName="";Ln.prototype.TimeBufferType=Float32Array;Ln.prototype.ValueBufferType=Float32Array;Ln.prototype.DefaultInterpolation=2301;class yr extends Ln{constructor(e,t,n){super(e,t,n)}}yr.prototype.ValueTypeName="bool";yr.prototype.ValueBufferType=Array;yr.prototype.DefaultInterpolation=2300;yr.prototype.InterpolantFactoryMethodLinear=void 0;yr.prototype.InterpolantFactoryMethodSmooth=void 0;class al extends Ln{constructor(e,t,n,i){super(e,t,n,i)}}al.prototype.ValueTypeName="color";class br extends Ln{constructor(e,t,n,i){super(e,t,n,i)}}br.prototype.ValueTypeName="number";class wd extends Zi{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=(n-t)/(i-t),c=e*o;for(let l=c+o;c!==l;c+=4)Yt.slerpFlat(r,0,s,c-o,s,c,a);return r}}class Sr extends Ln{constructor(e,t,n,i){super(e,t,n,i)}InterpolantFactoryMethodLinear(e){return new wd(this.times,this.values,this.getValueSize(),e)}}Sr.prototype.ValueTypeName="quaternion";Sr.prototype.InterpolantFactoryMethodSmooth=void 0;class wr extends Ln{constructor(e,t,n){super(e,t,n)}}wr.prototype.ValueTypeName="string";wr.prototype.ValueBufferType=Array;wr.prototype.DefaultInterpolation=2300;wr.prototype.InterpolantFactoryMethodLinear=void 0;wr.prototype.InterpolantFactoryMethodSmooth=void 0;class Qr extends Ln{constructor(e,t,n,i){super(e,t,n,i)}}Qr.prototype.ValueTypeName="vector";class Cs{constructor(e="",t=-1,n=[],i=2500){if(this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=Qn(),this.userData={},this.duration<0)this.resetDuration()}static parse(e){let t=[],n=e.tracks,i=1/(e.fps||1);for(let s=0,o=n.length;s!==o;++s)t.push(hE(n[s]).scale(i));let r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r.userData=JSON.parse(e.userData||"{}"),r}static toJSON(e){let t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let r=0,s=n.length;r!==s;++r)t.push(Ln.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(e,t,n,i){let r=t.length,s=[];for(let o=0;o<r;o++){let a=[],c=[];a.push((o+r-1)%r,o,(o+1)%r),c.push(0,1,0);let l=oE(a);if(a=gx(a,1,l),c=gx(c,1,l),!i&&a[0]===0)a.push(r),c.push(c[0]);s.push(new br(".morphTargetInfluences["+t[o].name+"]",a,c).scale(1/n))}return new this(e,-1,s)}static findByName(e,t){let n=e;if(!Array.isArray(e)){let i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){let i={},r=/^([\w-]*?)([\d]+)$/;for(let o=0,a=e.length;o<a;o++){let c=e[o],l=c.name.match(r);if(l&&l.length>1){let u=l[1],h=i[u];if(!h)i[u]=h=[];h.push(c)}}let s=[];for(let o in i)s.push(this.CreateFromMorphTargetSequence(o,i[o],t,n));return s}resetDuration(){let e=this.tracks,t=0;for(let n=0,i=e.length;n!==i;++n){let r=this.tracks[n];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let n=0;n<this.tracks.length;n++)e.push(this.tracks[n].clone());let t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}}function uE(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return br;case"vector":case"vector2":case"vector3":case"vector4":return Qr;case"color":return al;case"quaternion":return Sr;case"bool":case"boolean":return yr;case"string":return wr}throw Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function hE(e){if(e.type===void 0)throw Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=uE(e.type);if(e.times===void 0){let i=[],r=[];aE(e.keys,i,r,"value"),e.times=i,e.values=r}let n;if(t.parse!==void 0)n=t.parse(e);else n=new t(e.name,e.times,e.values,e.interpolation);if(Dc(e.settings))n.settings={inTangents:ur(e.settings.inTangents,Float32Array),outTangents:ur(e.settings.outTangents,Float32Array)};return n}var _i={enabled:!1,files:{},add:function(e,t){if(this.enabled===!1)return;if(xx(e))return;this.files[e]=t},get:function(e){if(this.enabled===!1)return;if(xx(e))return;return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};function xx(e){try{let t=e.slice(e.indexOf(":")+1);return new URL(t).protocol==="blob:"}catch(t){return!1}}class sa{constructor(e,t,n){let i=this,r=!1,s=0,o=0,a=void 0,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(l){if(o++,r===!1){if(i.onStart!==void 0)i.onStart(l,s,o)}r=!0},this.itemEnd=function(l){if(s++,i.onProgress!==void 0)i.onProgress(l,s,o);if(s===o){if(r=!1,i.onLoad!==void 0)i.onLoad()}},this.itemError=function(l){if(i.onError!==void 0)i.onError(l)},this.resolveURL=function(l){if(l=l.normalize("NFC"),a)return a(l);return l},this.setURLModifier=function(l){return a=l,this},this.addHandler=function(l,u){return c.push(l,u),this},this.removeHandler=function(l){let u=c.indexOf(l);if(u!==-1)c.splice(u,2);return this},this.getHandler=function(l){for(let u=0,h=c.length;u<h;u+=2){let d=c[u],f=c[u+1];if(d.global)d.lastIndex=0;if(d.test(l))return f}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){if(!this._abortController)this._abortController=new AbortController;return this._abortController}}var Mv=new sa;class Xi{constructor(e){if(this.manager=e!==void 0?e:Mv,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(e,t){let n=this;return new Promise(function(i,r){n.load(e,i,t,r)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}}Xi.DEFAULT_MATERIAL_NAME="__DEFAULT";var Hi={};class Ev extends Error{constructor(e,t){super(e);this.response=t}}class oa extends Xi{constructor(e){super(e);this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,n,i){if(e===void 0)e="";if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=_i.get(`file:${e}`);if(r!==void 0){this.manager.itemStart(e),setTimeout(()=>{if(t)t(r);this.manager.itemEnd(e)},0);return}if(Hi[e]!==void 0){Hi[e].push({onLoad:t,onProgress:n,onError:i});return}Hi[e]=[],Hi[e].push({onLoad:t,onProgress:n,onError:i});let s=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any==="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,a=this.responseType;fetch(s).then((c)=>{if(c.status===200||c.status===0){if(c.status===0)Ue("FileLoader: HTTP Status 0 received.");if(typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;let l=Hi[e],u=c.body.getReader(),h=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),d=h?parseInt(h):0,f=d!==0,m=0,_=new ReadableStream({start(p){g();function g(){u.read().then(({done:M,value:T})=>{if(M)p.close();else{m+=T.byteLength;let v=new ProgressEvent("progress",{lengthComputable:f,loaded:m,total:d});for(let S=0,E=l.length;S<E;S++){let R=l[S];if(R.onProgress)R.onProgress(v)}p.enqueue(T),g()}},(M)=>{p.error(M)})}}});return new Response(_)}else throw new Ev(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then((c)=>{switch(a){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then((l)=>new DOMParser().parseFromString(l,o));case"json":return c.json();default:if(o==="")return c.text();else{let u=/charset="?([^;"\s]*)"?/i.exec(o),h=u&&u[1]?u[1].toLowerCase():void 0,d=new TextDecoder(h);return c.arrayBuffer().then((f)=>d.decode(f))}}}).then((c)=>{_i.add(`file:${e}`,c);let l=Hi[e];delete Hi[e];for(let u=0,h=l.length;u<h;u++){let d=l[u];if(d.onLoad)d.onLoad(c)}}).catch((c)=>{let l=Hi[e];if(l===void 0)throw this.manager.itemError(e),c;delete Hi[e];for(let u=0,h=l.length;u<h;u++){let d=l[u];if(d.onError)d.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}var ws=new WeakMap;class Md extends Xi{constructor(e){super(e)}load(e,t,n,i){if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=this,s=_i.get(`image:${e}`);if(s!==void 0){if(s.complete===!0)r.manager.itemStart(e),setTimeout(function(){if(t)t(s);r.manager.itemEnd(e)},0);else{let u=ws.get(s);if(u===void 0)u=[],ws.set(s,u);u.push({onLoad:t,onError:i})}return s}let o=As("img");function a(){if(l(),t)t(this);let u=ws.get(this)||[];for(let h=0;h<u.length;h++){let d=u[h];if(d.onLoad)d.onLoad(this)}ws.delete(this),r.manager.itemEnd(e)}function c(u){if(l(),i)i(u);_i.remove(`image:${e}`);let h=ws.get(this)||[];for(let d=0;d<h.length;d++){let f=h[d];if(f.onError)f.onError(u)}ws.delete(this),r.manager.itemError(e),r.manager.itemEnd(e)}function l(){o.removeEventListener("load",a,!1),o.removeEventListener("error",c,!1)}if(o.addEventListener("load",a,!1),o.addEventListener("error",c,!1),e.slice(0,5)!=="data:"){if(this.crossOrigin!==void 0)o.crossOrigin=this.crossOrigin}return _i.add(`image:${e}`,o),r.manager.itemStart(e),o.src=e,o}}class Hs extends Xi{constructor(e){super(e)}load(e,t,n,i){let r=new Ot,s=new Md(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(e,function(o){if(r.image=o,r.needsUpdate=!0,t!==void 0)t(r)},n,i),r}}class Vs extends _t{constructor(e,t=1){super();this.isLight=!0,this.type="Light",this.color=new Ge(e),this.intensity=t}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}}class cl extends Vs{constructor(e,t,n){super(e,n);this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Ge(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){let t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}}var lh=new Xe,vx=new z,yx=new z;class aa{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new ke(512,512),this.mapType=1009,this.map=null,this.mapPass=null,this.matrix=new Xe,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new ta,this._frameExtents=new ke(1,1),this._viewportCount=1,this._viewports=[new pt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getCamera(){return this.camera}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera;vx.setFromMatrixPosition(e.matrixWorld),t.position.copy(vx),yx.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(yx),t.updateMatrixWorld(),this._updateMatrix(t,this.matrix,this._frustum)}_updateMatrix(e,t,n,i){lh.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),n.setFromProjectionMatrix(lh,e.coordinateSystem,e.reversedDepth);let r=this._frameExtents,s=i?i.z/r.x:1,o=i?i.w/r.y:1,a=i?i.x/r.x:0,c=i?i.y/r.y:0;if(e.coordinateSystem===2001||e.reversedDepth)t.set(0.5*s,0,0,0.5*s+a,0,0.5*o,0,0.5*o+c,0,0,1,0,0,0,0,1);else t.set(0.5*s,0,0,0.5*s+a,0,0.5*o,0,0.5*o+c,0,0,0.5,0.5,0,0,0,1);t.multiply(lh)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){if(this.map)this.map.dispose();if(this.mapPass)this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return e.intensity=this.intensity,e.bias=this.bias,e.normalBias=this.normalBias,e.radius=this.radius,e.blurSamples=this.blurSamples,e.mapSize=this.mapSize.toArray(),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}var Lc=new z,Nc=new Yt,mi=new z;class ll extends _t{constructor(){super();this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Xe,this.projectionMatrix=new Xe,this.projectionMatrixInverse=new Xe,this.coordinateSystem=2000,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.matrixWorld.decompose(Lc,Nc,mi),mi.x===1&&mi.y===1&&mi.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(Lc,Nc,mi.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){if(super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(Lc,Nc,mi),mi.x===1&&mi.y===1&&mi.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(Lc,Nc,mi.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}var lr=new z,bx=new ke,Sx=new ke;class Ht extends ll{constructor(e=50,t=1,n=0.1,i=2000){super();this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=0.5*this.getFilmHeight()/e;this.fov=$r*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(ko*0.5*this.fov);return 0.5*this.getFilmHeight()/e}getEffectiveFOV(){return $r*2*Math.atan(Math.tan(ko*0.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){lr.set(-1,-1,0.5).applyMatrix4(this.projectionMatrixInverse),t.set(lr.x,lr.y).multiplyScalar(-e/lr.z),lr.set(1,1,0.5).applyMatrix4(this.projectionMatrixInverse),n.set(lr.x,lr.y).multiplyScalar(-e/lr.z)}getViewSize(e,t){return this.getViewBounds(e,bx,Sx),t.subVectors(Sx,bx)}setViewOffset(e,t,n,i,r,s){if(this.aspect=e/t,this.view===null)this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1};this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){if(this.view!==null)this.view.enabled=!1;this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(ko*0.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-0.5*i,s=this.view;if(this.view!==null&&this.view.enabled){let{fullWidth:a,fullHeight:c}=s;r+=s.offsetX*i/a,t-=s.offsetY*n/c,i*=s.width/a,n*=s.height/c}let o=this.filmOffset;if(o!==0)r+=e*o/this.getFilmWidth();this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);if(t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null)t.object.view=Object.assign({},this.view);return t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class Tv extends aa{constructor(){super(new Ht(50,1,0.5,500));this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){let t=this.camera,n=$r*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,r=e.distance||t.far;if(n!==t.fov||i!==t.aspect||r!==t.far)t.fov=n,t.aspect=i,t.far=r,t.updateProjectionMatrix();super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this.aspect=e.aspect,this}toJSON(){let e=super.toJSON();return e.focus=this.focus,e.aspect=this.aspect,e}}class ul extends Vs{constructor(e,t,n=0,i=Math.PI/3,r=0,s=2){super(e,t);this.isSpotLight=!0,this.type="SpotLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.target=new _t,this.distance=n,this.angle=i,this.penumbra=r,this.decay=s,this.map=null,this.shadow=new Tv}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.map=e.map,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);if(t.object.distance=this.distance,t.object.angle=this.angle,t.object.decay=this.decay,t.object.penumbra=this.penumbra,t.object.target=this.target.uuid,this.map&&this.map.isTexture)t.object.map=this.map.toJSON(e).uuid;return t.object.shadow=this.shadow.toJSON(),t}}class Av extends aa{constructor(){super(new Ht(90,1,0.5,500));this.isPointLightShadow=!0}}class $s extends Vs{constructor(e,t,n=0,i=2){super(e,t);this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new Av}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}}class es extends ll{constructor(e=-1,t=1,n=1,i=-1,r=0.1,s=2000){super();this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=r,this.far=s,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,r,s){if(this.view===null)this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1};this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){if(this.view!==null)this.view.enabled=!1;this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2,r=n-e,s=n+e,o=i+t,a=i-t;if(this.view!==null&&this.view.enabled){let c=(this.right-this.left)/this.view.fullWidth/this.zoom,l=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,s=r+c*this.view.width,o-=l*this.view.offsetY,a=o-l*this.view.height}this.projectionMatrix.makeOrthographic(r,s,o,a,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);if(t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null)t.object.view=Object.assign({},this.view);return t}}class Rv extends aa{constructor(){super(new es(-5,5,5,-5,0.5,500));this.isDirectionalLightShadow=!0}}class Ws extends Vs{constructor(e,t){super(e,t);this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.target=new _t,this.shadow=new Rv}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}}class Mr{static extractUrlBase(e){let t=e.lastIndexOf("/");if(t===-1)return"./";return e.slice(0,t+1)}static resolveURL(e,t){if(typeof e!=="string"||e==="")return"";if(/^https?:\/\//i.test(t)&&/^\//.test(e))t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1");if(/^(https?:)?\/\//i.test(e))return e;if(/^data:.*,.*$/i.test(e))return e;if(/^blob:.*$/i.test(e))return e;return t+e}}var uh=new WeakMap;class hl extends Xi{constructor(e){super(e);if(this.isImageBitmapLoader=!0,typeof createImageBitmap>"u")Ue("ImageBitmapLoader: createImageBitmap() not supported.");if(typeof fetch>"u")Ue("ImageBitmapLoader: fetch() not supported.");this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,n,i){if(e===void 0)e="";if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=this,s=_i.get(`image-bitmap:${e}`);if(s!==void 0){if(r.manager.itemStart(e),s.then){s.then((c)=>{if(uh.has(s)===!0){if(i)i(uh.get(s));r.manager.itemError(e),r.manager.itemEnd(e)}else{if(t)t(c);r.manager.itemEnd(e)}});return}setTimeout(function(){if(t)t(s);r.manager.itemEnd(e)},0);return}let o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader,o.signal=typeof AbortSignal.any==="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;let a=fetch(e,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign({},r.options,{colorSpaceConversion:"none"}))}).then(function(c){if(_i.add(`image-bitmap:${e}`,c),t)t(c);return r.manager.itemEnd(e),c}).catch(function(c){if(i)i(c);uh.set(a,c),_i.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});_i.add(`image-bitmap:${e}`,a),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}var Ms=-90,Es=1;class Ed extends _t{constructor(e,t,n){super();this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let i=new Ht(Ms,Es,e,t);i.layers=this.layers,this.add(i);let r=new Ht(Ms,Es,e,t);r.layers=this.layers,this.add(r);let s=new Ht(Ms,Es,e,t);s.layers=this.layers,this.add(s);let o=new Ht(Ms,Es,e,t);o.layers=this.layers,this.add(o);let a=new Ht(Ms,Es,e,t);a.layers=this.layers,this.add(a);let c=new Ht(Ms,Es,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,i,r,s,o,a]=t;for(let c of t)this.remove(c);if(e===2000)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),a.up.set(0,1,0),a.lookAt(0,0,-1);else if(e===2001)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),a.up.set(0,-1,0),a.lookAt(0,0,-1);else throw Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let c of t)this.add(c),c.updateMatrixWorld()}update(e,t){if(this.parent===null)this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:i}=this;if(this.coordinateSystem!==e.coordinateSystem)this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem();let[r,s,o,a,c,l]=this.children,u=e.getRenderTarget(),h=e.getActiveCubeFace(),d=e.getActiveMipmapLevel(),f=e.xr.enabled;e.xr.enabled=!1;let m=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let _=!1;if(e.isWebGLRenderer===!0)_=e.state.buffers.depth.getReversed();else _=e.reversedDepthBuffer;if(e.setRenderTarget(n,0,i),_&&e.autoClear===!1)e.clearDepth();if(e.render(t,r),e.setRenderTarget(n,1,i),_&&e.autoClear===!1)e.clearDepth();if(e.render(t,s),e.setRenderTarget(n,2,i),_&&e.autoClear===!1)e.clearDepth();if(e.render(t,o),e.setRenderTarget(n,3,i),_&&e.autoClear===!1)e.clearDepth();if(e.render(t,a),e.setRenderTarget(n,4,i),_&&e.autoClear===!1)e.clearDepth();if(e.render(t,c),n.texture.generateMipmaps=m,e.setRenderTarget(n,5,i),_&&e.autoClear===!1)e.clearDepth();e.render(t,l),e.setRenderTarget(u,h,d),e.xr.enabled=f,n.texture.needsPMREMUpdate=!0}}class Td extends Ht{constructor(e=[]){super();this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class Ad{constructor(e,t,n){this.binding=e,this.valueSize=n;let i,r,s;switch(t){case"quaternion":i=this._slerp,r=this._slerpAdditive,s=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":i=this._select,r=this._select,s=this._setAdditiveIdentityOther,this.buffer=Array(n*5);break;default:i=this._lerp,r=this._lerpAdditive,s=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=r,this._setIdentity=s,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let n=this.buffer,i=this.valueSize,r=e*i+i,s=this.cumulativeWeight;if(s===0){for(let o=0;o!==i;++o)n[r+o]=n[o];s=t}else{s+=t;let o=t/s;this._mixBufferRegion(n,r,0,o,i)}this.cumulativeWeight=s}accumulateAdditive(e){let t=this.buffer,n=this.valueSize,i=n*this._addIndex;if(this.cumulativeWeightAdditive===0)this._setIdentity();this._mixBufferRegionAdditive(t,i,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,n=this.buffer,i=e*t+t,r=this.cumulativeWeight,s=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){let a=t*this._origIndex;this._mixBufferRegion(n,i,a,1-r,t)}if(s>0)this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let a=t,c=t+t;a!==c;++a)if(n[a]!==n[a+t]){o.setValue(n,i);break}}saveOriginalState(){let e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let r=n,s=i;r!==s;++r)t[r]=t[i+r%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n<t;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}_select(e,t,n,i,r){if(i>=0.5)for(let s=0;s!==r;++s)e[t+s]=e[n+s]}_slerp(e,t,n,i){Yt.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){let s=this._workIndex*r;Yt.multiplyQuaternionsFlat(e,s,e,t,e,n),Yt.slerpFlat(e,t,e,t,e,s,i)}_lerp(e,t,n,i,r){let s=1-i;for(let o=0;o!==r;++o){let a=t+o;e[a]=e[a]*s+e[n+o]*i}}_lerpAdditive(e,t,n,i,r){for(let s=0;s!==r;++s){let o=t+s;e[o]=e[o]+e[n+s]*i}}}var Rd="\\[\\]\\.:\\/",dE=new RegExp("["+Rd+"]","g"),Cd="[^"+Rd+"]",fE="[^"+Rd.replace("\\.","")+"]",pE=/((?:WC+[\/:])*)/.source.replace("WC",Cd),mE=/(WCOD+)?/.source.replace("WCOD",fE),gE=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Cd),_E=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Cd),xE=new RegExp("^"+pE+mE+gE+_E+"$"),vE=["material","materials","bones","map"];class Cv{constructor(e,t,n){let i=n||ct.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];if(i!==void 0)i.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class ct{constructor(e,t,n){this.path=t,this.parsedPath=n||ct.parseTrackName(t),this.node=ct.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){if(!(e&&e.isAnimationObjectGroup))return new ct(e,t,n);else return new ct.Composite(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(dE,"")}static parseTrackName(e){let t=xE.exec(e);if(t===null)throw Error("THREE.PropertyBinding: Cannot parse trackName: "+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){let r=n.nodeName.substring(i+1);if(vE.indexOf(r)!==-1)n.nodeName=n.nodeName.substring(0,i),n.objectName=r}if(n.propertyName===null||n.propertyName.length===0)throw Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(r){for(let s=0;s<r.length;s++){let o=r[s];if(o.name===t||o.uuid===t)return o;let a=n(o.children);if(a)return a}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,{objectName:n,propertyName:i,propertyIndex:r}=t;if(!e)e=ct.findNode(this.rootNode,t.nodeName),this.node=e;if(this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){Ue("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){Ve("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){Ve("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){Ve("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let l=0;l<e.length;l++)if(e[l].name===c){c=l;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){Ve("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){Ve("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){Ve("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){Ve("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}let s=e[i];if(s===void 0){let c=t.nodeName;Ve("PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",e);return}let o=this.Versioning.None;if(this.targetObject=e,e.isMaterial===!0)o=this.Versioning.NeedsUpdate;else if(e.isObject3D===!0)o=this.Versioning.MatrixWorldNeedsUpdate;let a=this.BindingType.Direct;if(r!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){Ve("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){Ve("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}if(e.morphTargetDictionary[r]!==void 0)r=e.morphTargetDictionary[r]}a=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=r}else if(s.fromArray!==void 0&&s.toArray!==void 0)a=this.BindingType.HasFromToArray,this.resolvedProperty=s;else if(Array.isArray(s))a=this.BindingType.EntireArray,this.resolvedProperty=s;else this.propertyName=i;this.getValue=this.GetterByBindingType[a],this.setValue=this.SetterByBindingTypeAndVersioning[a][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}ct.Composite=Cv;ct.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};ct.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};ct.prototype.GetterByBindingType=[ct.prototype._getValue_direct,ct.prototype._getValue_array,ct.prototype._getValue_arrayElement,ct.prototype._getValue_toArray];ct.prototype.SetterByBindingTypeAndVersioning=[[ct.prototype._setValue_direct,ct.prototype._setValue_direct_setNeedsUpdate,ct.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[ct.prototype._setValue_array,ct.prototype._setValue_array_setNeedsUpdate,ct.prototype._setValue_array_setMatrixWorldNeedsUpdate],[ct.prototype._setValue_arrayElement,ct.prototype._setValue_arrayElement_setNeedsUpdate,ct.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[ct.prototype._setValue_fromArray,ct.prototype._setValue_fromArray_setNeedsUpdate,ct.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class Id{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;let r=t.tracks,s=r.length,o=Array(s),a={endingStart:2400,endingEnd:2400};for(let c=0;c!==s;++c){let l=r[c].createInterpolant(null);o[c]=l,l.settings=a}this._interpolantSettings=a,this._interpolants=o,this._propertyBindings=Array(s),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._restoreTimeScale=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n=!1){if(e.fadeOut(t),this.fadeIn(t),n===!0){let i=this._clip.duration,r=e._clip.duration,s=r/i,o=i/r;e._restoreTimeScale=e.timeScale,this._restoreTimeScale=this.timeScale,e.warp(1,s,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,n=!1){return e.crossFadeFrom(this,t,n)}stopFading(){let e=this._weightInterpolant;if(e!==null)this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e);return this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){let i=this._mixer,r=i.time,s=this.timeScale,o=this._timeScaleInterpolant;if(o===null)o=i._lendControlInterpolant(),this._timeScaleInterpolant=o;let a=o.parameterPositions,c=o.sampleValues;return a[0]=r,a[1]=r+n,c[0]=e/s,c[1]=t/s,this}stopWarping(){let e=this._timeScaleInterpolant;if(e!==null)this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e);return this._restoreTimeScale=null,this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,i){if(!this.enabled){this._updateWeight(e);return}let r=this._startTime;if(r!==null){let a=(e-r)*n;if(a<0||n===0)t=0;else this._startTime=null,t=n*a}t*=this._updateTimeScale(e);let s=this._updateTime(t),o=this._updateWeight(e);if(o>0){let a=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case 2501:for(let l=0,u=a.length;l!==u;++l)a[l].evaluate(s),c[l].accumulateAdditive(o);break;case 2500:default:for(let l=0,u=a.length;l!==u;++l)a[l].evaluate(s),c[l].accumulate(i,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let n=this._weightInterpolant;if(n!==null){let i=n.evaluate(e)[0];if(t*=i,e>n.parameterPositions[1]){if(this.stopFading(),i===0)this.enabled=!1}}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let n=this._timeScaleInterpolant;if(n!==null){let i=n.evaluate(e)[0];if(t*=i,e>n.parameterPositions[1]){if(t===0)this.paused=!0;else{if(this._restoreTimeScale!==null)t=this._restoreTimeScale;this.timeScale=t}this.stopWarping()}}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,n=this.loop,i=this.time+e,r=this._loopCount,s=n===2202;if(e===0){if(r===-1)return i;return s&&(r&1)===1?t-i:i}if(n===2200){if(r===-1)this._loopCount=0,this._setEndings(!0,!0,!1);e:{if(i>=t)i=t;else if(i<0)i=0;else{this.time=i;break e}if(this.clampWhenFinished)this.paused=!0;else this.enabled=!1;this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(r===-1)if(e>=0)r=0,this._setEndings(!0,this.repetitions===0,s);else this._setEndings(this.repetitions===0,!0,s);if(i>=t||i<0){let o=Math.floor(i/t);i-=t*o,r+=Math.abs(o);let a=this.repetitions-r;if(a<=0){if(this.clampWhenFinished)this.paused=!0;else this.enabled=!1;i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1})}else{if(a===1){let c=e<0;this._setEndings(c,!c,s)}else this._setEndings(!1,!1,s);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this._loopCount=r,this.time=i;if(s&&(r&1)===1)return t-i}return i}_setEndings(e,t,n){let i=this._interpolantSettings;if(n)i.endingStart=2401,i.endingEnd=2401;else{if(e)i.endingStart=this.zeroSlopeAtStart?2401:2400;else i.endingStart=2402;if(t)i.endingEnd=this.zeroSlopeAtEnd?2401:2400;else i.endingEnd=2402}}_scheduleFading(e,t,n){let i=this._mixer,r=i.time,s=this._weightInterpolant;if(s===null)s=i._lendControlInterpolant(),this._weightInterpolant=s;let o=s.parameterPositions,a=s.sampleValues;return o[0]=r,a[0]=t,o[1]=r+e,a[1]=n,this}}var yE=new Float32Array(1);class dl extends ii{constructor(e){super();if(this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1,typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}_bindAction(e,t){let n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,{_propertyBindings:s,_interpolants:o}=e,a=n.uuid,c=this._bindingsByRootAndName,l=c[a];if(l===void 0)l={},c[a]=l;for(let u=0;u!==r;++u){let h=i[u],d=h.name,f=l[d];if(f!==void 0)++f.referenceCount,s[u]=f;else{if(f=s[u],f!==void 0){if(f._cacheIndex===null)++f.referenceCount,this._addInactiveBinding(f,a,d);continue}let m=t&&t._propertyBindings[u].binding.parsedPath;f=new Ad(ct.create(n,d,m),h.ValueTypeName,h.getValueSize()),++f.referenceCount,this._addInactiveBinding(f,a,d),s[u]=f}o[u].resultBuffer=f.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let n=(e._localRoot||this._root).uuid,i=e._clip.uuid,r=this._actionsByClip[i];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,i,n)}let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(r.useCount++===0)this._lendBinding(r),r.saveOriginalState()}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(--r.useCount===0)r.restoreOriginalState(),this._takeBackBinding(r)}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,n){let i=this._actions,r=this._actionsByClip,s=r[t];if(s===void 0)s={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[t]=s;else{let o=s.knownActions;e._byClipCacheIndex=o.length,o.push(e)}e._cacheIndex=i.length,i.push(e),s.actionByRoot[n]=e}_removeInactiveAction(e){let t=this._actions,n=t[t.length-1],i=e._cacheIndex;n._cacheIndex=i,t[i]=n,t.pop(),e._cacheIndex=null;let r=e._clip.uuid,s=this._actionsByClip,o=s[r],a=o.knownActions,c=a[a.length-1],l=e._byClipCacheIndex;c._byClipCacheIndex=l,a[l]=c,a.pop(),e._byClipCacheIndex=null;let u=o.actionByRoot,h=(e._localRoot||this._root).uuid;if(delete u[h],a.length===0)delete s[r];this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(--r.referenceCount===0)this._removeInactiveBinding(r)}}_lendAction(e){let t=this._actions,n=e._cacheIndex,i=this._nActiveActions++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackAction(e){let t=this._actions,n=e._cacheIndex,i=--this._nActiveActions,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_addInactiveBinding(e,t,n){let i=this._bindingsByRootAndName,r=this._bindings,s=i[t];if(s===void 0)s={},i[t]=s;s[n]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){let t=this._bindings,n=e.binding,i=n.rootNode.uuid,r=n.path,s=this._bindingsByRootAndName,o=s[i],a=t[t.length-1],c=e._cacheIndex;if(a._cacheIndex=c,t[c]=a,t.pop(),delete o[r],Object.keys(o).length===0)delete s[i]}_lendBinding(e){let t=this._bindings,n=e._cacheIndex,i=this._nActiveBindings++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackBinding(e){let t=this._bindings,n=e._cacheIndex,i=--this._nActiveBindings,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,n=e[t];if(n===void 0)n=new ol(new Float32Array(2),new Float32Array(2),1,yE),n.__cacheIndex=t,e[t]=n;return n}_takeBackControlInterpolant(e){let t=this._controlInterpolants,n=e.__cacheIndex,i=--this._nActiveControlInterpolants,r=t[i];e.__cacheIndex=i,t[i]=e,r.__cacheIndex=n,t[n]=r}clipAction(e,t,n){let i=t||this._root,r=i.uuid,s=typeof e==="string"?Cs.findByName(i,e):e,o=s!==null?s.uuid:e,a=this._actionsByClip[o],c=null;if(n===void 0)if(s!==null)n=s.blendMode;else n=2500;if(a!==void 0){let u=a.actionByRoot[r];if(u!==void 0&&u.blendMode===n)return u;if(c=a.knownActions[0],s===null)s=c._clip}if(s===null)return null;let l=new Id(this,s,t,n);return this._bindAction(l,c),this._addInactiveAction(l,o,r),l}existingAction(e,t){let n=t||this._root,i=n.uuid,r=typeof e==="string"?Cs.findByName(n,e):e,s=r?r.uuid:e,o=this._actionsByClip[s];if(o!==void 0)return o.actionByRoot[i]||null;return null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let n=t-1;n>=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;let t=this._actions,n=this._nActiveActions,i=this.time+=e,r=Math.sign(e),s=this._accuIndex^=1;for(let c=0;c!==n;++c)t[c]._update(i,e,r,s);let o=this._bindings,a=this._nActiveBindings;for(let c=0;c!==a;++c)o[c].apply(s);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,n=e.uuid,i=this._actionsByClip,r=i[n];if(r!==void 0){let s=r.knownActions;for(let o=0,a=s.length;o!==a;++o){let c=s[o];this._deactivateAction(c);let l=c._cacheIndex,u=t[t.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,u._cacheIndex=l,t[l]=u,t.pop(),this._removeInactiveBindingsForAction(c)}delete i[n]}}uncacheRoot(e){let t=e.uuid,n=this._actionsByClip;for(let s in n){let o=n[s].actionByRoot,a=o[t];if(a!==void 0)this._deactivateAction(a),this._removeInactiveAction(a)}let i=this._bindingsByRootAndName,r=i[t];if(r!==void 0)for(let s in r){let o=r[s];o.restoreOriginalState(),this._removeInactiveBinding(o)}}uncacheAction(e,t){let n=this.existingAction(e,t);if(n!==null)this._deactivateAction(n),this._removeInactiveAction(n)}}class ca{constructor(e=1,t=0,n=0){this.radius=e,this.phi=t,this.theta=n}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Je(this.phi,0.000001,Math.PI-0.000001),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){if(this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0)this.theta=0,this.phi=0;else this.theta=Math.atan2(e,n),this.phi=Math.acos(Je(t/this.radius,-1,1));return this}clone(){return new this.constructor().copy(this)}}class Pd{static{Pd.prototype.isMatrix2=!0}constructor(e,t,n,i){if(this.elements=[1,0,0,1],e!==void 0)this.set(e,t,n,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,i){let r=this.elements;return r[0]=e,r[2]=t,r[1]=n,r[3]=i,this}}class fl extends ii{constructor(e,t=null){super();this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(this.domElement!==null)this.disconnect();this.domElement=e}disconnect(){}dispose(){}update(){}}function Ld(e,t,n,i){let r=bE(i);switch(n){case 1021:return e*t;case 1028:return e*t/r.components*r.byteLength;case 1029:return e*t/r.components*r.byteLength;case 1030:return e*t*2/r.components*r.byteLength;case 1031:return e*t*2/r.components*r.byteLength;case 1022:return e*t*3/r.components*r.byteLength;case 1023:return e*t*4/r.components*r.byteLength;case 1033:return e*t*4/r.components*r.byteLength;case 33776:case 33777:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case 33778:case 33779:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 35841:case 35843:return Math.max(e,16)*Math.max(t,8)/4;case 35840:case 35842:return Math.max(e,8)*Math.max(t,8)/2;case 36196:case 37492:case 37488:case 37489:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case 37496:case 37490:case 37491:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 37808:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 37809:return Math.floor((e+4)/5)*Math.floor((t+3)/4)*16;case 37810:return Math.floor((e+4)/5)*Math.floor((t+4)/5)*16;case 37811:return Math.floor((e+5)/6)*Math.floor((t+4)/5)*16;case 37812:return Math.floor((e+5)/6)*Math.floor((t+5)/6)*16;case 37813:return Math.floor((e+7)/8)*Math.floor((t+4)/5)*16;case 37814:return Math.floor((e+7)/8)*Math.floor((t+5)/6)*16;case 37815:return Math.floor((e+7)/8)*Math.floor((t+7)/8)*16;case 37816:return Math.floor((e+9)/10)*Math.floor((t+4)/5)*16;case 37817:return Math.floor((e+9)/10)*Math.floor((t+5)/6)*16;case 37818:return Math.floor((e+9)/10)*Math.floor((t+7)/8)*16;case 37819:return Math.floor((e+9)/10)*Math.floor((t+9)/10)*16;case 37820:return Math.floor((e+11)/12)*Math.floor((t+9)/10)*16;case 37821:return Math.floor((e+11)/12)*Math.floor((t+11)/12)*16;case 36492:case 36494:case 36495:return Math.ceil(e/4)*Math.ceil(t/4)*16;case 36283:case 36284:return Math.ceil(e/4)*Math.ceil(t/4)*8;case 36285:case 36286:return Math.ceil(e/4)*Math.ceil(t/4)*16}throw Error(`Unable to determine texture byte length for ${n} format.`)}function bE(e){switch(e){case 1009:case 1010:return{byteLength:1,components:1};case 1012:case 1011:case 1016:return{byteLength:2,components:1};case 1017:case 1018:return{byteLength:2,components:4};case 1014:case 1013:case 1015:return{byteLength:4,components:1};case 35902:case 35899:return{byteLength:4,components:3}}throw Error(`THREE.TextureUtils: Unknown texture type ${e}.`)}if(typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"186"}}));if(typeof window<"u")if(window.__THREE__)Ue("WARNING: Multiple instances of Three.js being imported.");else window.__THREE__="186";function Kv(){let e=null,t=!1,n=null,i=null;function r(s,o){i=e.requestAnimationFrame(r),n(s,o)}return{start:function(){if(t===!0)return;if(n===null)return;if(e===null)return;i=e.requestAnimationFrame(r),t=!0},stop:function(){if(e!==null)e.cancelAnimationFrame(i);t=!1},setAnimationLoop:function(s){n=s},setContext:function(s){e=s}}}function SE(e){let t=new WeakMap;function n(a,c){let{array:l,usage:u}=a,h=l.byteLength,d=e.createBuffer();e.bindBuffer(c,d),e.bufferData(c,l,u),a.onUploadCallback();let f;if(l instanceof Float32Array)f=e.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)f=e.HALF_FLOAT;else if(l instanceof Uint16Array)if(a.isFloat16BufferAttribute)f=e.HALF_FLOAT;else f=e.UNSIGNED_SHORT;else if(l instanceof Int16Array)f=e.SHORT;else if(l instanceof Uint32Array)f=e.UNSIGNED_INT;else if(l instanceof Int32Array)f=e.INT;else if(l instanceof Int8Array)f=e.BYTE;else if(l instanceof Uint8Array)f=e.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)f=e.UNSIGNED_BYTE;else throw Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:d,type:f,bytesPerElement:l.BYTES_PER_ELEMENT,version:a.version,size:h}}function i(a,c,l){let{array:u,updateRanges:h}=c;if(e.bindBuffer(l,a),h.length===0)e.bufferSubData(l,0,u);else{h.sort((f,m)=>f.start-m.start);let d=0;for(let f=1;f<h.length;f++){let m=h[d],_=h[f];if(_.start<=m.start+m.count+1)m.count=Math.max(m.count,_.start+_.count-m.start);else++d,h[d]=_}h.length=d+1;for(let f=0,m=h.length;f<m;f++){let _=h[f];e.bufferSubData(l,_.start*u.BYTES_PER_ELEMENT,u,_.start,_.count)}c.clearUpdateRanges()}c.onUploadCallback()}function r(a){if(a.isInterleavedBufferAttribute)a=a.data;return t.get(a)}function s(a){if(a.isInterleavedBufferAttribute)a=a.data;let c=t.get(a);if(c)e.deleteBuffer(c.buffer),t.delete(a)}function o(a,c){if(a.isInterleavedBufferAttribute)a=a.data;if(a.isGLBufferAttribute){let u=t.get(a);if(!u||u.version<a.version)t.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}let l=t.get(a);if(l===void 0)t.set(a,n(a,c));else if(l.version<a.version){if(l.size!==a.array.byteLength)throw Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");i(l.buffer,a,c),l.version=a.version}}return{get:r,remove:s,update:o}}var wE=`#ifdef USE_ALPHAHASH
67
67
  if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
68
- #endif`,SE=`#ifdef USE_ALPHAHASH
68
+ #endif`,ME=`#ifdef USE_ALPHAHASH
69
69
  const float ALPHA_HASH_SCALE = 0.05;
70
70
  float hash2D( vec2 value ) {
71
71
  return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
@@ -100,20 +100,20 @@ version 0.8.2
100
100
  : cases.z;
101
101
  return clamp( threshold , 1.0e-6, 1.0 );
102
102
  }
103
- #endif`,wE=`#ifdef USE_ALPHAMAP
103
+ #endif`,EE=`#ifdef USE_ALPHAMAP
104
104
  diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
105
- #endif`,ME=`#ifdef USE_ALPHAMAP
105
+ #endif`,TE=`#ifdef USE_ALPHAMAP
106
106
  uniform sampler2D alphaMap;
107
- #endif`,EE=`#ifdef USE_ALPHATEST
107
+ #endif`,AE=`#ifdef USE_ALPHATEST
108
108
  #ifdef ALPHA_TO_COVERAGE
109
109
  diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
110
110
  if ( diffuseColor.a == 0.0 ) discard;
111
111
  #else
112
112
  if ( diffuseColor.a < alphaTest ) discard;
113
113
  #endif
114
- #endif`,TE=`#ifdef USE_ALPHATEST
114
+ #endif`,RE=`#ifdef USE_ALPHATEST
115
115
  uniform float alphaTest;
116
- #endif`,AE=`#ifdef USE_AOMAP
116
+ #endif`,CE=`#ifdef USE_AOMAP
117
117
  float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
118
118
  reflectedLight.indirectDiffuse *= ambientOcclusion;
119
119
  #if defined( USE_CLEARCOAT )
@@ -126,10 +126,10 @@ version 0.8.2
126
126
  float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
127
127
  reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
128
128
  #endif
129
- #endif`,RE=`#ifdef USE_AOMAP
129
+ #endif`,IE=`#ifdef USE_AOMAP
130
130
  uniform sampler2D aoMap;
131
131
  uniform float aoMapIntensity;
132
- #endif`,CE=`#ifdef USE_BATCHING
132
+ #endif`,PE=`#ifdef USE_BATCHING
133
133
  #if ! defined( GL_ANGLE_multi_draw )
134
134
  #define gl_DrawID _gl_DrawID
135
135
  uniform int _gl_DrawID;
@@ -163,15 +163,15 @@ version 0.8.2
163
163
  int y = j / size;
164
164
  return texelFetch( batchingColorTexture, ivec2( x, y ), 0 );
165
165
  }
166
- #endif`,IE=`#ifdef USE_BATCHING
166
+ #endif`,LE=`#ifdef USE_BATCHING
167
167
  mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
168
- #endif`,PE=`vec3 transformed = vec3( position );
168
+ #endif`,NE=`vec3 transformed = vec3( position );
169
169
  #ifdef USE_ALPHAHASH
170
170
  vPosition = vec3( position );
171
- #endif`,LE=`vec3 objectNormal = vec3( normal );
171
+ #endif`,DE=`vec3 objectNormal = vec3( normal );
172
172
  #ifdef USE_TANGENT
173
173
  vec3 objectTangent = vec3( tangent.xyz );
174
- #endif`,NE=`float G_BlinnPhong_Implicit( ) {
174
+ #endif`,OE=`float G_BlinnPhong_Implicit( ) {
175
175
  return 0.25;
176
176
  }
177
177
  float D_BlinnPhong( const in float shininess, const in float dotNH ) {
@@ -185,7 +185,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
185
185
  float G = G_BlinnPhong_Implicit( );
186
186
  float D = D_BlinnPhong( shininess, dotNH );
187
187
  return F * ( G * D );
188
- } // validated`,DE=`#ifdef USE_IRIDESCENCE
188
+ } // validated`,UE=`#ifdef USE_IRIDESCENCE
189
189
  const mat3 XYZ_TO_REC709 = mat3(
190
190
  3.2404542, -0.9692660, 0.0556434,
191
191
  -1.5371385, 1.8760108, -0.2040259,
@@ -248,7 +248,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
248
248
  }
249
249
  return max( I, vec3( 0.0 ) );
250
250
  }
251
- #endif`,OE=`#ifdef USE_BUMPMAP
251
+ #endif`,FE=`#ifdef USE_BUMPMAP
252
252
  uniform sampler2D bumpMap;
253
253
  uniform float bumpScale;
254
254
  vec2 dHdxy_fwd() {
@@ -269,7 +269,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
269
269
  vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
270
270
  return normalize( abs( fDet ) * surf_norm - vGrad );
271
271
  }
272
- #endif`,UE=`#if NUM_CLIPPING_PLANES > 0
272
+ #endif`,zE=`#if NUM_CLIPPING_PLANES > 0
273
273
  vec4 plane;
274
274
  #ifdef ALPHA_TO_COVERAGE
275
275
  float distanceToPlane, distanceGradient;
@@ -315,20 +315,20 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
315
315
  if ( clipped ) discard;
316
316
  #endif
317
317
  #endif
318
- #endif`,FE=`#if NUM_CLIPPING_PLANES > 0
318
+ #endif`,kE=`#if NUM_CLIPPING_PLANES > 0
319
319
  varying vec3 vClipPosition;
320
320
  uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
321
- #endif`,zE=`#if NUM_CLIPPING_PLANES > 0
321
+ #endif`,BE=`#if NUM_CLIPPING_PLANES > 0
322
322
  varying vec3 vClipPosition;
323
- #endif`,kE=`#if NUM_CLIPPING_PLANES > 0
323
+ #endif`,GE=`#if NUM_CLIPPING_PLANES > 0
324
324
  vClipPosition = - mvPosition.xyz;
325
- #endif`,BE=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
325
+ #endif`,HE=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
326
326
  diffuseColor *= vColor;
327
- #endif`,GE=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
327
+ #endif`,VE=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
328
328
  varying vec4 vColor;
329
- #endif`,HE=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
329
+ #endif`,$E=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
330
330
  varying vec4 vColor;
331
- #endif`,VE=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
331
+ #endif`,WE=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
332
332
  vColor = vec4( 1.0 );
333
333
  #endif
334
334
  #ifdef USE_COLOR_ALPHA
@@ -341,7 +341,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
341
341
  #endif
342
342
  #ifdef USE_BATCHING_COLOR
343
343
  vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) );
344
- #endif`,$E=`#define PI 3.141592653589793
344
+ #endif`,ZE=`#define PI 3.141592653589793
345
345
  #define PI2 6.283185307179586
346
346
  #define PI_HALF 1.5707963267948966
347
347
  #define RECIPROCAL_PI 0.3183098861837907
@@ -412,7 +412,7 @@ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
412
412
  float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
413
413
  float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
414
414
  return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
415
- } // validated`,WE=`#ifdef ENVMAP_TYPE_CUBE_UV
415
+ } // validated`,XE=`#ifdef ENVMAP_TYPE_CUBE_UV
416
416
  #define cubeUV_minMipLevel 4.0
417
417
  #define cubeUV_minTileSize 16.0
418
418
  float getFace( vec3 direction ) {
@@ -505,7 +505,7 @@ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
505
505
  return vec4( mix( color0, color1, mipF ), 1.0 );
506
506
  }
507
507
  }
508
- #endif`,ZE=`vec3 transformedNormal = objectNormal;
508
+ #endif`,jE=`vec3 transformedNormal = objectNormal;
509
509
  #ifdef USE_TANGENT
510
510
  vec3 transformedTangent = objectTangent;
511
511
  #endif
@@ -531,21 +531,21 @@ transformedNormal = normalMatrix * transformedNormal;
531
531
  #endif
532
532
  #ifdef USE_TANGENT
533
533
  transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
534
- #endif`,XE=`#ifdef USE_DISPLACEMENTMAP
534
+ #endif`,qE=`#ifdef USE_DISPLACEMENTMAP
535
535
  uniform sampler2D displacementMap;
536
536
  uniform float displacementScale;
537
537
  uniform float displacementBias;
538
- #endif`,jE=`#ifdef USE_DISPLACEMENTMAP
538
+ #endif`,YE=`#ifdef USE_DISPLACEMENTMAP
539
539
  transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
540
- #endif`,qE=`#ifdef USE_EMISSIVEMAP
540
+ #endif`,KE=`#ifdef USE_EMISSIVEMAP
541
541
  vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
542
542
  #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
543
543
  emissiveColor = sRGBTransferEOTF( emissiveColor );
544
544
  #endif
545
545
  totalEmissiveRadiance *= emissiveColor.rgb;
546
- #endif`,YE=`#ifdef USE_EMISSIVEMAP
546
+ #endif`,JE=`#ifdef USE_EMISSIVEMAP
547
547
  uniform sampler2D emissiveMap;
548
- #endif`,KE="gl_FragColor = linearToOutputTexel( gl_FragColor );",JE=`vec4 LinearTransferOETF( in vec4 value ) {
548
+ #endif`,QE="gl_FragColor = linearToOutputTexel( gl_FragColor );",eT=`vec4 LinearTransferOETF( in vec4 value ) {
549
549
  return value;
550
550
  }
551
551
  vec4 sRGBTransferEOTF( in vec4 value ) {
@@ -553,7 +553,7 @@ vec4 sRGBTransferEOTF( in vec4 value ) {
553
553
  }
554
554
  vec4 sRGBTransferOETF( in vec4 value ) {
555
555
  return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
556
- }`,QE=`#ifdef USE_ENVMAP
556
+ }`,tT=`#ifdef USE_ENVMAP
557
557
  #ifdef ENV_WORLDPOS
558
558
  vec3 cameraToFrag;
559
559
  if ( isOrthographic ) {
@@ -580,7 +580,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
580
580
  outgoingLight += envColor.xyz * specularStrength * reflectivity;
581
581
  #endif
582
582
  #endif
583
- #endif`,eT=`#ifdef USE_ENVMAP
583
+ #endif`,nT=`#ifdef USE_ENVMAP
584
584
  uniform float envMapIntensity;
585
585
  uniform mat3 envMapRotation;
586
586
  #ifdef ENVMAP_TYPE_CUBE
@@ -588,7 +588,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
588
588
  #else
589
589
  uniform sampler2D envMap;
590
590
  #endif
591
- #endif`,tT=`#ifdef USE_ENVMAP
591
+ #endif`,iT=`#ifdef USE_ENVMAP
592
592
  uniform float reflectivity;
593
593
  #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
594
594
  #define ENV_WORLDPOS
@@ -599,7 +599,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
599
599
  #else
600
600
  varying vec3 vReflect;
601
601
  #endif
602
- #endif`,nT=`#ifdef USE_ENVMAP
602
+ #endif`,rT=`#ifdef USE_ENVMAP
603
603
  #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
604
604
  #define ENV_WORLDPOS
605
605
  #endif
@@ -610,7 +610,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
610
610
  varying vec3 vReflect;
611
611
  uniform float refractionRatio;
612
612
  #endif
613
- #endif`,iT=`#ifdef USE_ENVMAP
613
+ #endif`,sT=`#ifdef USE_ENVMAP
614
614
  #ifdef ENV_WORLDPOS
615
615
  vWorldPosition = worldPosition.xyz;
616
616
  #else
@@ -627,18 +627,18 @@ vec4 sRGBTransferOETF( in vec4 value ) {
627
627
  vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
628
628
  #endif
629
629
  #endif
630
- #endif`,rT=`#ifdef USE_FOG
630
+ #endif`,oT=`#ifdef USE_FOG
631
631
  vFogDepth = - mvPosition.z;
632
- #endif`,sT=`#ifdef USE_FOG
632
+ #endif`,aT=`#ifdef USE_FOG
633
633
  varying float vFogDepth;
634
- #endif`,oT=`#ifdef USE_FOG
634
+ #endif`,cT=`#ifdef USE_FOG
635
635
  #ifdef FOG_EXP2
636
636
  float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
637
637
  #else
638
638
  float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
639
639
  #endif
640
640
  gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
641
- #endif`,aT=`#ifdef USE_FOG
641
+ #endif`,lT=`#ifdef USE_FOG
642
642
  uniform vec3 fogColor;
643
643
  varying float vFogDepth;
644
644
  #ifdef FOG_EXP2
@@ -647,7 +647,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
647
647
  uniform float fogNear;
648
648
  uniform float fogFar;
649
649
  #endif
650
- #endif`,cT=`#ifdef USE_GRADIENTMAP
650
+ #endif`,uT=`#ifdef USE_GRADIENTMAP
651
651
  uniform sampler2D gradientMap;
652
652
  #endif
653
653
  vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
@@ -659,12 +659,12 @@ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
659
659
  vec2 fw = fwidth( coord ) * 0.5;
660
660
  return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
661
661
  #endif
662
- }`,lT=`#ifdef USE_LIGHTMAP
662
+ }`,hT=`#ifdef USE_LIGHTMAP
663
663
  uniform sampler2D lightMap;
664
664
  uniform float lightMapIntensity;
665
- #endif`,uT=`LambertMaterial material;
665
+ #endif`,dT=`LambertMaterial material;
666
666
  material.diffuseColor = diffuseColor.rgb;
667
- material.specularStrength = specularStrength;`,hT=`varying vec3 vViewPosition;
667
+ material.specularStrength = specularStrength;`,fT=`varying vec3 vViewPosition;
668
668
  struct LambertMaterial {
669
669
  vec3 diffuseColor;
670
670
  float specularStrength;
@@ -678,7 +678,7 @@ void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometr
678
678
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
679
679
  }
680
680
  #define RE_Direct RE_Direct_Lambert
681
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,dT=`uniform bool receiveShadow;
681
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,pT=`uniform bool receiveShadow;
682
682
  uniform vec3 ambientLightColor;
683
683
  #if defined( USE_LIGHT_PROBES )
684
684
  uniform vec3 lightProbe[ 9 ];
@@ -807,7 +807,7 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
807
807
  return irradiance;
808
808
  }
809
809
  #endif
810
- #include <lightprobes_pars_fragment>`,fT=`#ifdef USE_ENVMAP
810
+ #include <lightprobes_pars_fragment>`,mT=`#ifdef USE_ENVMAP
811
811
  vec3 getIBLIrradiance( const in vec3 normal ) {
812
812
  #ifdef ENVMAP_TYPE_CUBE_UV
813
813
  vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );
@@ -864,8 +864,8 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
864
864
  }
865
865
  #endif
866
866
  #endif
867
- #endif`,pT=`ToonMaterial material;
868
- material.diffuseColor = diffuseColor.rgb;`,mT=`varying vec3 vViewPosition;
867
+ #endif`,gT=`ToonMaterial material;
868
+ material.diffuseColor = diffuseColor.rgb;`,_T=`varying vec3 vViewPosition;
869
869
  struct ToonMaterial {
870
870
  vec3 diffuseColor;
871
871
  };
@@ -877,11 +877,11 @@ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPo
877
877
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
878
878
  }
879
879
  #define RE_Direct RE_Direct_Toon
880
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,gT=`BlinnPhongMaterial material;
880
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,xT=`BlinnPhongMaterial material;
881
881
  material.diffuseColor = diffuseColor.rgb;
882
882
  material.specularColor = specular;
883
883
  material.specularShininess = shininess;
884
- material.specularStrength = specularStrength;`,_T=`varying vec3 vViewPosition;
884
+ material.specularStrength = specularStrength;`,vT=`varying vec3 vViewPosition;
885
885
  struct BlinnPhongMaterial {
886
886
  vec3 diffuseColor;
887
887
  vec3 specularColor;
@@ -898,7 +898,7 @@ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geom
898
898
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
899
899
  }
900
900
  #define RE_Direct RE_Direct_BlinnPhong
901
- #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,xT=`PhysicalMaterial material;
901
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,yT=`PhysicalMaterial material;
902
902
  material.diffuseColor = diffuseColor.rgb;
903
903
  material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );
904
904
  material.metalness = metalnessFactor;
@@ -991,7 +991,7 @@ material.roughness = min( material.roughness, 1.0 );
991
991
  material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
992
992
  material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
993
993
  material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
994
- #endif`,vT=`uniform sampler2D dfgLUT;
994
+ #endif`,bT=`uniform sampler2D dfgLUT;
995
995
  struct PhysicalMaterial {
996
996
  vec3 diffuseColor;
997
997
  vec3 diffuseContribution;
@@ -1358,7 +1358,7 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia
1358
1358
  #define RE_IndirectSpecular RE_IndirectSpecular_Physical
1359
1359
  float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
1360
1360
  return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
1361
- }`,yT=`
1361
+ }`,ST=`
1362
1362
  vec3 geometryPosition = - vViewPosition;
1363
1363
  vec3 geometryNormal = normal;
1364
1364
  vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
@@ -1506,7 +1506,7 @@ IncidentLight directLight;
1506
1506
  #if defined( RE_IndirectSpecular )
1507
1507
  vec3 radiance = vec3( 0.0 );
1508
1508
  vec3 clearcoatRadiance = vec3( 0.0 );
1509
- #endif`,bT=`#if defined( RE_IndirectDiffuse )
1509
+ #endif`,wT=`#if defined( RE_IndirectDiffuse )
1510
1510
  #ifdef USE_LIGHTMAP
1511
1511
  vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
1512
1512
  vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
@@ -1536,7 +1536,7 @@ IncidentLight directLight;
1536
1536
  #ifdef USE_CLEARCOAT
1537
1537
  clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
1538
1538
  #endif
1539
- #endif`,ST=`#if defined( RE_IndirectDiffuse )
1539
+ #endif`,MT=`#if defined( RE_IndirectDiffuse )
1540
1540
  #if defined( LAMBERT ) || defined( PHONG )
1541
1541
  irradiance += iblIrradiance;
1542
1542
  #endif
@@ -1544,7 +1544,7 @@ IncidentLight directLight;
1544
1544
  #endif
1545
1545
  #if defined( RE_IndirectSpecular )
1546
1546
  RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1547
- #endif`,wT=`#ifdef USE_LIGHT_PROBES_GRID
1547
+ #endif`,ET=`#ifdef USE_LIGHT_PROBES_GRID
1548
1548
  uniform highp sampler3D probesSH;
1549
1549
  uniform vec3 probesMin;
1550
1550
  uniform vec3 probesMax;
@@ -1589,27 +1589,27 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
1589
1589
  result += c8 * 0.429043 * ( x * x - y * y );
1590
1590
  return max( result, vec3( 0.0 ) );
1591
1591
  }
1592
- #endif`,MT=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1592
+ #endif`,TT=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1593
1593
  gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
1594
- #endif`,ET=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1594
+ #endif`,AT=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1595
1595
  uniform float logDepthBufFC;
1596
1596
  varying float vFragDepth;
1597
1597
  varying float vIsPerspective;
1598
- #endif`,TT=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1598
+ #endif`,RT=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1599
1599
  varying float vFragDepth;
1600
1600
  varying float vIsPerspective;
1601
- #endif`,AT=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1601
+ #endif`,CT=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1602
1602
  vFragDepth = 1.0 + gl_Position.w;
1603
1603
  vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
1604
- #endif`,RT=`#ifdef USE_MAP
1604
+ #endif`,IT=`#ifdef USE_MAP
1605
1605
  vec4 sampledDiffuseColor = texture2D( map, vMapUv );
1606
1606
  #ifdef DECODE_VIDEO_TEXTURE
1607
1607
  sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
1608
1608
  #endif
1609
1609
  diffuseColor *= sampledDiffuseColor;
1610
- #endif`,CT=`#ifdef USE_MAP
1610
+ #endif`,PT=`#ifdef USE_MAP
1611
1611
  uniform sampler2D map;
1612
- #endif`,IT=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1612
+ #endif`,LT=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1613
1613
  #if defined( USE_POINTS_UV )
1614
1614
  vec2 uv = vUv;
1615
1615
  #else
@@ -1621,7 +1621,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
1621
1621
  #endif
1622
1622
  #ifdef USE_ALPHAMAP
1623
1623
  diffuseColor.a *= texture2D( alphaMap, uv ).g;
1624
- #endif`,PT=`#if defined( USE_POINTS_UV )
1624
+ #endif`,NT=`#if defined( USE_POINTS_UV )
1625
1625
  varying vec2 vUv;
1626
1626
  #else
1627
1627
  #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
@@ -1633,19 +1633,19 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
1633
1633
  #endif
1634
1634
  #ifdef USE_ALPHAMAP
1635
1635
  uniform sampler2D alphaMap;
1636
- #endif`,LT=`float metalnessFactor = metalness;
1636
+ #endif`,DT=`float metalnessFactor = metalness;
1637
1637
  #ifdef USE_METALNESSMAP
1638
1638
  vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
1639
1639
  metalnessFactor *= texelMetalness.b;
1640
- #endif`,NT=`#ifdef USE_METALNESSMAP
1640
+ #endif`,OT=`#ifdef USE_METALNESSMAP
1641
1641
  uniform sampler2D metalnessMap;
1642
- #endif`,DT=`#ifdef USE_INSTANCING_MORPH
1642
+ #endif`,UT=`#ifdef USE_INSTANCING_MORPH
1643
1643
  float morphTargetInfluences[ MORPHTARGETS_COUNT ];
1644
1644
  float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
1645
1645
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1646
1646
  morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
1647
1647
  }
1648
- #endif`,OT=`#if defined( USE_MORPHCOLORS )
1648
+ #endif`,FT=`#if defined( USE_MORPHCOLORS )
1649
1649
  vColor *= morphTargetBaseInfluence;
1650
1650
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1651
1651
  #if defined( USE_COLOR_ALPHA )
@@ -1654,12 +1654,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
1654
1654
  if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
1655
1655
  #endif
1656
1656
  }
1657
- #endif`,UT=`#ifdef USE_MORPHNORMALS
1657
+ #endif`,zT=`#ifdef USE_MORPHNORMALS
1658
1658
  objectNormal *= morphTargetBaseInfluence;
1659
1659
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1660
1660
  if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
1661
1661
  }
1662
- #endif`,FT=`#ifdef USE_MORPHTARGETS
1662
+ #endif`,kT=`#ifdef USE_MORPHTARGETS
1663
1663
  #ifndef USE_INSTANCING_MORPH
1664
1664
  uniform float morphTargetBaseInfluence;
1665
1665
  uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
@@ -1673,12 +1673,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
1673
1673
  ivec3 morphUV = ivec3( x, y, morphTargetIndex );
1674
1674
  return texelFetch( morphTargetsTexture, morphUV, 0 );
1675
1675
  }
1676
- #endif`,zT=`#ifdef USE_MORPHTARGETS
1676
+ #endif`,BT=`#ifdef USE_MORPHTARGETS
1677
1677
  transformed *= morphTargetBaseInfluence;
1678
1678
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1679
1679
  if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
1680
1680
  }
1681
- #endif`,kT=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
1681
+ #endif`,GT=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
1682
1682
  #ifdef FLAT_SHADED
1683
1683
  vec3 fdx = dFdx( vViewPosition );
1684
1684
  vec3 fdy = dFdy( vViewPosition );
@@ -1719,7 +1719,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
1719
1719
  tbn2[1] *= faceDirection;
1720
1720
  #endif
1721
1721
  #endif
1722
- vec3 nonPerturbedNormal = normal;`,BT=`#ifdef USE_NORMALMAP_OBJECTSPACE
1722
+ vec3 nonPerturbedNormal = normal;`,HT=`#ifdef USE_NORMALMAP_OBJECTSPACE
1723
1723
  normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
1724
1724
  #ifdef FLIP_SIDED
1725
1725
  normal = - normal;
@@ -1737,19 +1737,19 @@ vec3 nonPerturbedNormal = normal;`,BT=`#ifdef USE_NORMALMAP_OBJECTSPACE
1737
1737
  normal = normalize( tbn * mapN );
1738
1738
  #elif defined( USE_BUMPMAP )
1739
1739
  normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
1740
- #endif`,GT=`#ifndef FLAT_SHADED
1740
+ #endif`,VT=`#ifndef FLAT_SHADED
1741
1741
  varying vec3 vNormal;
1742
1742
  #ifdef USE_TANGENT
1743
1743
  varying vec3 vTangent;
1744
1744
  varying vec3 vBitangent;
1745
1745
  #endif
1746
- #endif`,HT=`#ifndef FLAT_SHADED
1746
+ #endif`,$T=`#ifndef FLAT_SHADED
1747
1747
  varying vec3 vNormal;
1748
1748
  #ifdef USE_TANGENT
1749
1749
  varying vec3 vTangent;
1750
1750
  varying vec3 vBitangent;
1751
1751
  #endif
1752
- #endif`,VT=`#ifndef FLAT_SHADED
1752
+ #endif`,WT=`#ifndef FLAT_SHADED
1753
1753
  vNormal = normalize( transformedNormal );
1754
1754
  #ifdef USE_TANGENT
1755
1755
  vTangent = normalize( transformedTangent );
@@ -1758,7 +1758,7 @@ vec3 nonPerturbedNormal = normal;`,BT=`#ifdef USE_NORMALMAP_OBJECTSPACE
1758
1758
  vBitangent = - vBitangent;
1759
1759
  #endif
1760
1760
  #endif
1761
- #endif`,$T=`#ifdef USE_NORMALMAP
1761
+ #endif`,ZT=`#ifdef USE_NORMALMAP
1762
1762
  uniform sampler2D normalMap;
1763
1763
  uniform vec2 normalScale;
1764
1764
  #endif
@@ -1780,13 +1780,13 @@ vec3 nonPerturbedNormal = normal;`,BT=`#ifdef USE_NORMALMAP_OBJECTSPACE
1780
1780
  float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
1781
1781
  return mat3( T * scale, B * scale, N );
1782
1782
  }
1783
- #endif`,WT=`#ifdef USE_CLEARCOAT
1783
+ #endif`,XT=`#ifdef USE_CLEARCOAT
1784
1784
  vec3 clearcoatNormal = nonPerturbedNormal;
1785
- #endif`,ZT=`#ifdef USE_CLEARCOAT_NORMALMAP
1785
+ #endif`,jT=`#ifdef USE_CLEARCOAT_NORMALMAP
1786
1786
  vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
1787
1787
  clearcoatMapN.xy *= clearcoatNormalScale;
1788
1788
  clearcoatNormal = normalize( tbn2 * clearcoatMapN );
1789
- #endif`,XT=`#ifdef USE_CLEARCOATMAP
1789
+ #endif`,qT=`#ifdef USE_CLEARCOATMAP
1790
1790
  uniform sampler2D clearcoatMap;
1791
1791
  #endif
1792
1792
  #ifdef USE_CLEARCOAT_NORMALMAP
@@ -1795,18 +1795,18 @@ vec3 nonPerturbedNormal = normal;`,BT=`#ifdef USE_NORMALMAP_OBJECTSPACE
1795
1795
  #endif
1796
1796
  #ifdef USE_CLEARCOAT_ROUGHNESSMAP
1797
1797
  uniform sampler2D clearcoatRoughnessMap;
1798
- #endif`,jT=`#ifdef USE_IRIDESCENCEMAP
1798
+ #endif`,YT=`#ifdef USE_IRIDESCENCEMAP
1799
1799
  uniform sampler2D iridescenceMap;
1800
1800
  #endif
1801
1801
  #ifdef USE_IRIDESCENCE_THICKNESSMAP
1802
1802
  uniform sampler2D iridescenceThicknessMap;
1803
- #endif`,qT=`#ifdef OPAQUE
1803
+ #endif`,KT=`#ifdef OPAQUE
1804
1804
  diffuseColor.a = 1.0;
1805
1805
  #endif
1806
1806
  #ifdef USE_TRANSMISSION
1807
1807
  diffuseColor.a *= material.transmissionAlpha;
1808
1808
  #endif
1809
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,YT=`vec3 packNormalToRGB( const in vec3 normal ) {
1809
+ gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,JT=`vec3 packNormalToRGB( const in vec3 normal ) {
1810
1810
  return normalize( normal ) * 0.5 + 0.5;
1811
1811
  }
1812
1812
  vec3 unpackRGBToNormal( const in vec3 rgb ) {
@@ -1885,9 +1885,9 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
1885
1885
  #else
1886
1886
  return ( near * far ) / ( ( far - near ) * depth - far );
1887
1887
  #endif
1888
- }`,KT=`#ifdef PREMULTIPLIED_ALPHA
1888
+ }`,QT=`#ifdef PREMULTIPLIED_ALPHA
1889
1889
  gl_FragColor.rgb *= gl_FragColor.a;
1890
- #endif`,JT=`vec4 mvPosition = vec4( transformed, 1.0 );
1890
+ #endif`,eA=`vec4 mvPosition = vec4( transformed, 1.0 );
1891
1891
  #ifdef USE_BATCHING
1892
1892
  mvPosition = batchingMatrix * mvPosition;
1893
1893
  #endif
@@ -1895,22 +1895,22 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
1895
1895
  mvPosition = instanceMatrix * mvPosition;
1896
1896
  #endif
1897
1897
  mvPosition = modelViewMatrix * mvPosition;
1898
- gl_Position = projectionMatrix * mvPosition;`,QT=`#ifdef DITHERING
1898
+ gl_Position = projectionMatrix * mvPosition;`,tA=`#ifdef DITHERING
1899
1899
  gl_FragColor.rgb = dithering( gl_FragColor.rgb );
1900
- #endif`,eA=`#ifdef DITHERING
1900
+ #endif`,nA=`#ifdef DITHERING
1901
1901
  vec3 dithering( vec3 color ) {
1902
1902
  float grid_position = rand( gl_FragCoord.xy );
1903
1903
  vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
1904
1904
  dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
1905
1905
  return color + dither_shift_RGB;
1906
1906
  }
1907
- #endif`,tA=`float roughnessFactor = roughness;
1907
+ #endif`,iA=`float roughnessFactor = roughness;
1908
1908
  #ifdef USE_ROUGHNESSMAP
1909
1909
  vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
1910
1910
  roughnessFactor *= texelRoughness.g;
1911
- #endif`,nA=`#ifdef USE_ROUGHNESSMAP
1911
+ #endif`,rA=`#ifdef USE_ROUGHNESSMAP
1912
1912
  uniform sampler2D roughnessMap;
1913
- #endif`,iA=`#if NUM_SPOT_LIGHT_COORDS > 0
1913
+ #endif`,sA=`#if NUM_SPOT_LIGHT_COORDS > 0
1914
1914
  varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1915
1915
  #endif
1916
1916
  #if NUM_SPOT_LIGHT_MAPS > 0
@@ -2161,7 +2161,7 @@ gl_Position = projectionMatrix * mvPosition;`,QT=`#ifdef DITHERING
2161
2161
  }
2162
2162
  #endif
2163
2163
  #endif
2164
- #endif`,rA=`#if NUM_SPOT_LIGHT_COORDS > 0
2164
+ #endif`,oA=`#if NUM_SPOT_LIGHT_COORDS > 0
2165
2165
  uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
2166
2166
  varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
2167
2167
  #endif
@@ -2206,7 +2206,7 @@ gl_Position = projectionMatrix * mvPosition;`,QT=`#ifdef DITHERING
2206
2206
  };
2207
2207
  uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
2208
2208
  #endif
2209
- #endif`,sA=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SUN_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
2209
+ #endif`,aA=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SUN_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
2210
2210
  #ifdef HAS_NORMAL
2211
2211
  vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );
2212
2212
  #else
@@ -2246,7 +2246,7 @@ gl_Position = projectionMatrix * mvPosition;`,QT=`#ifdef DITHERING
2246
2246
  vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
2247
2247
  }
2248
2248
  #pragma unroll_loop_end
2249
- #endif`,oA=`float getShadowMask() {
2249
+ #endif`,cA=`float getShadowMask() {
2250
2250
  float shadow = 1.0;
2251
2251
  #ifdef USE_SHADOWMAP
2252
2252
  #if NUM_SUN_LIGHT_SHADOWS > 0
@@ -2287,12 +2287,12 @@ gl_Position = projectionMatrix * mvPosition;`,QT=`#ifdef DITHERING
2287
2287
  #endif
2288
2288
  #endif
2289
2289
  return shadow;
2290
- }`,aA=`#ifdef USE_SKINNING
2290
+ }`,lA=`#ifdef USE_SKINNING
2291
2291
  mat4 boneMatX = getBoneMatrix( skinIndex.x );
2292
2292
  mat4 boneMatY = getBoneMatrix( skinIndex.y );
2293
2293
  mat4 boneMatZ = getBoneMatrix( skinIndex.z );
2294
2294
  mat4 boneMatW = getBoneMatrix( skinIndex.w );
2295
- #endif`,cA=`#ifdef USE_SKINNING
2295
+ #endif`,uA=`#ifdef USE_SKINNING
2296
2296
  uniform mat4 bindMatrix;
2297
2297
  uniform mat4 bindMatrixInverse;
2298
2298
  uniform highp sampler2D boneTexture;
@@ -2307,7 +2307,7 @@ gl_Position = projectionMatrix * mvPosition;`,QT=`#ifdef DITHERING
2307
2307
  vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
2308
2308
  return mat4( v1, v2, v3, v4 );
2309
2309
  }
2310
- #endif`,lA=`#ifdef USE_SKINNING
2310
+ #endif`,hA=`#ifdef USE_SKINNING
2311
2311
  vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
2312
2312
  vec4 skinned = vec4( 0.0 );
2313
2313
  skinned += boneMatX * skinVertex * skinWeight.x;
@@ -2315,7 +2315,7 @@ gl_Position = projectionMatrix * mvPosition;`,QT=`#ifdef DITHERING
2315
2315
  skinned += boneMatZ * skinVertex * skinWeight.z;
2316
2316
  skinned += boneMatW * skinVertex * skinWeight.w;
2317
2317
  transformed = ( bindMatrixInverse * skinned ).xyz;
2318
- #endif`,uA=`#ifdef USE_SKINNING
2318
+ #endif`,dA=`#ifdef USE_SKINNING
2319
2319
  mat4 skinMatrix = mat4( 0.0 );
2320
2320
  skinMatrix += skinWeight.x * boneMatX;
2321
2321
  skinMatrix += skinWeight.y * boneMatY;
@@ -2326,17 +2326,17 @@ gl_Position = projectionMatrix * mvPosition;`,QT=`#ifdef DITHERING
2326
2326
  #ifdef USE_TANGENT
2327
2327
  objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
2328
2328
  #endif
2329
- #endif`,hA=`float specularStrength;
2329
+ #endif`,fA=`float specularStrength;
2330
2330
  #ifdef USE_SPECULARMAP
2331
2331
  vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
2332
2332
  specularStrength = texelSpecular.r;
2333
2333
  #else
2334
2334
  specularStrength = 1.0;
2335
- #endif`,dA=`#ifdef USE_SPECULARMAP
2335
+ #endif`,pA=`#ifdef USE_SPECULARMAP
2336
2336
  uniform sampler2D specularMap;
2337
- #endif`,fA=`#if defined( TONE_MAPPING )
2337
+ #endif`,mA=`#if defined( TONE_MAPPING )
2338
2338
  gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
2339
- #endif`,pA=`#ifndef saturate
2339
+ #endif`,gA=`#ifndef saturate
2340
2340
  #define saturate( a ) clamp( a, 0.0, 1.0 )
2341
2341
  #endif
2342
2342
  uniform float toneMappingExposure;
@@ -2433,7 +2433,7 @@ vec3 NeutralToneMapping( vec3 color ) {
2433
2433
  float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
2434
2434
  return mix( color, vec3( newPeak ), g );
2435
2435
  }
2436
- vec3 CustomToneMapping( vec3 color ) { return color; }`,mA=`#ifdef USE_TRANSMISSION
2436
+ vec3 CustomToneMapping( vec3 color ) { return color; }`,_A=`#ifdef USE_TRANSMISSION
2437
2437
  material.transmission = transmission;
2438
2438
  material.transmissionAlpha = 1.0;
2439
2439
  material.thickness = thickness;
@@ -2454,7 +2454,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,mA=`#ifdef USE_TRANSMISS
2454
2454
  material.attenuationColor, material.attenuationDistance );
2455
2455
  material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
2456
2456
  totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
2457
- #endif`,gA=`#ifdef USE_TRANSMISSION
2457
+ #endif`,xA=`#ifdef USE_TRANSMISSION
2458
2458
  uniform float transmission;
2459
2459
  uniform float thickness;
2460
2460
  uniform float attenuationDistance;
@@ -2580,7 +2580,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,mA=`#ifdef USE_TRANSMISS
2580
2580
  float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
2581
2581
  return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
2582
2582
  }
2583
- #endif`,_A=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2583
+ #endif`,vA=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2584
2584
  varying vec2 vUv;
2585
2585
  #endif
2586
2586
  #ifdef USE_MAP
@@ -2650,7 +2650,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,mA=`#ifdef USE_TRANSMISS
2650
2650
  #ifdef USE_THICKNESSMAP
2651
2651
  uniform mat3 thicknessMapTransform;
2652
2652
  varying vec2 vThicknessMapUv;
2653
- #endif`,xA=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2653
+ #endif`,yA=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2654
2654
  varying vec2 vUv;
2655
2655
  #endif
2656
2656
  #ifdef USE_MAP
@@ -2744,7 +2744,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,mA=`#ifdef USE_TRANSMISS
2744
2744
  #ifdef USE_THICKNESSMAP
2745
2745
  uniform mat3 thicknessMapTransform;
2746
2746
  varying vec2 vThicknessMapUv;
2747
- #endif`,vA=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2747
+ #endif`,bA=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2748
2748
  vUv = vec3( uv, 1 ).xy;
2749
2749
  #endif
2750
2750
  #ifdef USE_MAP
@@ -2815,7 +2815,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,mA=`#ifdef USE_TRANSMISS
2815
2815
  #endif
2816
2816
  #ifdef USE_THICKNESSMAP
2817
2817
  vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
2818
- #endif`;var yA=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2818
+ #endif`;var SA=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2819
2819
  vec4 worldPosition = vec4( transformed, 1.0 );
2820
2820
  #ifdef USE_BATCHING
2821
2821
  worldPosition = batchingMatrix * worldPosition;
@@ -2824,12 +2824,12 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,mA=`#ifdef USE_TRANSMISS
2824
2824
  worldPosition = instanceMatrix * worldPosition;
2825
2825
  #endif
2826
2826
  worldPosition = modelMatrix * worldPosition;
2827
- #endif`,bA=`varying vec2 vUv;
2827
+ #endif`,wA=`varying vec2 vUv;
2828
2828
  uniform mat3 uvTransform;
2829
2829
  void main() {
2830
2830
  vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
2831
2831
  gl_Position = vec4( position.xy, 1.0, 1.0 );
2832
- }`,SA=`uniform sampler2D t2D;
2832
+ }`,MA=`uniform sampler2D t2D;
2833
2833
  uniform float backgroundIntensity;
2834
2834
  varying vec2 vUv;
2835
2835
  void main() {
@@ -2841,14 +2841,14 @@ void main() {
2841
2841
  gl_FragColor = texColor;
2842
2842
  #include <tonemapping_fragment>
2843
2843
  #include <colorspace_fragment>
2844
- }`,wA=`varying vec3 vWorldDirection;
2844
+ }`,EA=`varying vec3 vWorldDirection;
2845
2845
  #include <common>
2846
2846
  void main() {
2847
2847
  vWorldDirection = transformDirection( position, modelMatrix );
2848
2848
  #include <begin_vertex>
2849
2849
  #include <project_vertex>
2850
2850
  gl_Position.z = gl_Position.w;
2851
- }`,MA=`#ifdef ENVMAP_TYPE_CUBE
2851
+ }`,TA=`#ifdef ENVMAP_TYPE_CUBE
2852
2852
  uniform samplerCube envMap;
2853
2853
  #elif defined( ENVMAP_TYPE_CUBE_UV )
2854
2854
  uniform sampler2D envMap;
@@ -2870,14 +2870,14 @@ void main() {
2870
2870
  gl_FragColor = texColor;
2871
2871
  #include <tonemapping_fragment>
2872
2872
  #include <colorspace_fragment>
2873
- }`,EA=`varying vec3 vWorldDirection;
2873
+ }`,AA=`varying vec3 vWorldDirection;
2874
2874
  #include <common>
2875
2875
  void main() {
2876
2876
  vWorldDirection = transformDirection( position, modelMatrix );
2877
2877
  #include <begin_vertex>
2878
2878
  #include <project_vertex>
2879
2879
  gl_Position.z = gl_Position.w;
2880
- }`,TA=`uniform samplerCube tCube;
2880
+ }`,RA=`uniform samplerCube tCube;
2881
2881
  uniform float tFlip;
2882
2882
  uniform float opacity;
2883
2883
  varying vec3 vWorldDirection;
@@ -2887,7 +2887,7 @@ void main() {
2887
2887
  gl_FragColor.a *= opacity;
2888
2888
  #include <tonemapping_fragment>
2889
2889
  #include <colorspace_fragment>
2890
- }`,AA=`#include <common>
2890
+ }`,CA=`#include <common>
2891
2891
  #include <batching_pars_vertex>
2892
2892
  #include <uv_pars_vertex>
2893
2893
  #include <displacementmap_pars_vertex>
@@ -2914,7 +2914,7 @@ void main() {
2914
2914
  #include <logdepthbuf_vertex>
2915
2915
  #include <clipping_planes_vertex>
2916
2916
  vHighPrecisionZW = gl_Position.zw;
2917
- }`,RA=`#if DEPTH_PACKING == 3200
2917
+ }`,IA=`#if DEPTH_PACKING == 3200
2918
2918
  uniform float opacity;
2919
2919
  #endif
2920
2920
  #include <common>
@@ -2952,7 +2952,7 @@ void main() {
2952
2952
  #elif DEPTH_PACKING == 3203
2953
2953
  gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
2954
2954
  #endif
2955
- }`,CA=`#define DISTANCE
2955
+ }`,PA=`#define DISTANCE
2956
2956
  varying vec3 vWorldPosition;
2957
2957
  #include <common>
2958
2958
  #include <batching_pars_vertex>
@@ -2979,7 +2979,7 @@ void main() {
2979
2979
  #include <worldpos_vertex>
2980
2980
  #include <clipping_planes_vertex>
2981
2981
  vWorldPosition = worldPosition.xyz;
2982
- }`,IA=`#define DISTANCE
2982
+ }`,LA=`#define DISTANCE
2983
2983
  uniform vec3 referencePosition;
2984
2984
  uniform float nearDistance;
2985
2985
  uniform float farDistance;
@@ -3002,13 +3002,13 @@ void main() {
3002
3002
  dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
3003
3003
  dist = saturate( dist );
3004
3004
  gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );
3005
- }`,PA=`varying vec3 vWorldDirection;
3005
+ }`,NA=`varying vec3 vWorldDirection;
3006
3006
  #include <common>
3007
3007
  void main() {
3008
3008
  vWorldDirection = transformDirection( position, modelMatrix );
3009
3009
  #include <begin_vertex>
3010
3010
  #include <project_vertex>
3011
- }`,LA=`uniform sampler2D tEquirect;
3011
+ }`,DA=`uniform sampler2D tEquirect;
3012
3012
  varying vec3 vWorldDirection;
3013
3013
  #include <common>
3014
3014
  void main() {
@@ -3017,7 +3017,7 @@ void main() {
3017
3017
  gl_FragColor = texture2D( tEquirect, sampleUV );
3018
3018
  #include <tonemapping_fragment>
3019
3019
  #include <colorspace_fragment>
3020
- }`,NA=`uniform float scale;
3020
+ }`,OA=`uniform float scale;
3021
3021
  attribute float lineDistance;
3022
3022
  varying float vLineDistance;
3023
3023
  #include <common>
@@ -3039,7 +3039,7 @@ void main() {
3039
3039
  #include <logdepthbuf_vertex>
3040
3040
  #include <clipping_planes_vertex>
3041
3041
  #include <fog_vertex>
3042
- }`,DA=`uniform vec3 diffuse;
3042
+ }`,UA=`uniform vec3 diffuse;
3043
3043
  uniform float opacity;
3044
3044
  uniform float dashSize;
3045
3045
  uniform float totalSize;
@@ -3067,7 +3067,7 @@ void main() {
3067
3067
  #include <colorspace_fragment>
3068
3068
  #include <fog_fragment>
3069
3069
  #include <premultiplied_alpha_fragment>
3070
- }`,OA=`#include <common>
3070
+ }`,FA=`#include <common>
3071
3071
  #include <batching_pars_vertex>
3072
3072
  #include <uv_pars_vertex>
3073
3073
  #include <envmap_pars_vertex>
@@ -3099,7 +3099,7 @@ void main() {
3099
3099
  #include <worldpos_vertex>
3100
3100
  #include <envmap_vertex>
3101
3101
  #include <fog_vertex>
3102
- }`,UA=`uniform vec3 diffuse;
3102
+ }`,zA=`uniform vec3 diffuse;
3103
3103
  uniform float opacity;
3104
3104
  #ifndef FLAT_SHADED
3105
3105
  varying vec3 vNormal;
@@ -3147,7 +3147,7 @@ void main() {
3147
3147
  #include <fog_fragment>
3148
3148
  #include <premultiplied_alpha_fragment>
3149
3149
  #include <dithering_fragment>
3150
- }`,FA=`#define LAMBERT
3150
+ }`,kA=`#define LAMBERT
3151
3151
  varying vec3 vViewPosition;
3152
3152
  #include <common>
3153
3153
  #include <batching_pars_vertex>
@@ -3186,7 +3186,7 @@ void main() {
3186
3186
  #include <envmap_vertex>
3187
3187
  #include <shadowmap_vertex>
3188
3188
  #include <fog_vertex>
3189
- }`,zA=`#define LAMBERT
3189
+ }`,BA=`#define LAMBERT
3190
3190
  uniform vec3 diffuse;
3191
3191
  uniform vec3 emissive;
3192
3192
  uniform float opacity;
@@ -3244,7 +3244,7 @@ void main() {
3244
3244
  #include <fog_fragment>
3245
3245
  #include <premultiplied_alpha_fragment>
3246
3246
  #include <dithering_fragment>
3247
- }`,kA=`#define MATCAP
3247
+ }`,GA=`#define MATCAP
3248
3248
  varying vec3 vViewPosition;
3249
3249
  #include <common>
3250
3250
  #include <batching_pars_vertex>
@@ -3278,7 +3278,7 @@ void main() {
3278
3278
  #include <clipping_planes_vertex>
3279
3279
  #include <fog_vertex>
3280
3280
  vViewPosition = - mvPosition.xyz;
3281
- }`,BA=`#define MATCAP
3281
+ }`,HA=`#define MATCAP
3282
3282
  uniform vec3 diffuse;
3283
3283
  uniform float opacity;
3284
3284
  uniform sampler2D matcap;
@@ -3324,7 +3324,7 @@ void main() {
3324
3324
  #include <fog_fragment>
3325
3325
  #include <premultiplied_alpha_fragment>
3326
3326
  #include <dithering_fragment>
3327
- }`,GA=`#define NORMAL
3327
+ }`,VA=`#define NORMAL
3328
3328
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3329
3329
  varying vec3 vViewPosition;
3330
3330
  #endif
@@ -3357,7 +3357,7 @@ void main() {
3357
3357
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3358
3358
  vViewPosition = - mvPosition.xyz;
3359
3359
  #endif
3360
- }`,HA=`#define NORMAL
3360
+ }`,$A=`#define NORMAL
3361
3361
  uniform float opacity;
3362
3362
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3363
3363
  varying vec3 vViewPosition;
@@ -3378,7 +3378,7 @@ void main() {
3378
3378
  #ifdef OPAQUE
3379
3379
  gl_FragColor.a = 1.0;
3380
3380
  #endif
3381
- }`,VA=`#define PHONG
3381
+ }`,WA=`#define PHONG
3382
3382
  varying vec3 vViewPosition;
3383
3383
  #include <common>
3384
3384
  #include <batching_pars_vertex>
@@ -3417,7 +3417,7 @@ void main() {
3417
3417
  #include <envmap_vertex>
3418
3418
  #include <shadowmap_vertex>
3419
3419
  #include <fog_vertex>
3420
- }`,$A=`#define PHONG
3420
+ }`,ZA=`#define PHONG
3421
3421
  uniform vec3 diffuse;
3422
3422
  uniform vec3 emissive;
3423
3423
  uniform vec3 specular;
@@ -3477,7 +3477,7 @@ void main() {
3477
3477
  #include <fog_fragment>
3478
3478
  #include <premultiplied_alpha_fragment>
3479
3479
  #include <dithering_fragment>
3480
- }`,WA=`#define STANDARD
3480
+ }`,XA=`#define STANDARD
3481
3481
  varying vec3 vViewPosition;
3482
3482
  #ifdef USE_TRANSMISSION
3483
3483
  varying vec3 vWorldPosition;
@@ -3520,7 +3520,7 @@ void main() {
3520
3520
  #ifdef USE_TRANSMISSION
3521
3521
  vWorldPosition = worldPosition.xyz;
3522
3522
  #endif
3523
- }`,ZA=`#define STANDARD
3523
+ }`,jA=`#define STANDARD
3524
3524
  #ifdef PHYSICAL
3525
3525
  #define IOR
3526
3526
  #define USE_SPECULAR
@@ -3648,7 +3648,7 @@ void main() {
3648
3648
  #include <fog_fragment>
3649
3649
  #include <premultiplied_alpha_fragment>
3650
3650
  #include <dithering_fragment>
3651
- }`,XA=`#define TOON
3651
+ }`,qA=`#define TOON
3652
3652
  varying vec3 vViewPosition;
3653
3653
  #include <common>
3654
3654
  #include <batching_pars_vertex>
@@ -3685,7 +3685,7 @@ void main() {
3685
3685
  #include <worldpos_vertex>
3686
3686
  #include <shadowmap_vertex>
3687
3687
  #include <fog_vertex>
3688
- }`,jA=`#define TOON
3688
+ }`,YA=`#define TOON
3689
3689
  uniform vec3 diffuse;
3690
3690
  uniform vec3 emissive;
3691
3691
  uniform float opacity;
@@ -3737,7 +3737,7 @@ void main() {
3737
3737
  #include <fog_fragment>
3738
3738
  #include <premultiplied_alpha_fragment>
3739
3739
  #include <dithering_fragment>
3740
- }`,qA=`uniform float size;
3740
+ }`,KA=`uniform float size;
3741
3741
  uniform float scale;
3742
3742
  #include <common>
3743
3743
  #include <color_pars_vertex>
@@ -3768,7 +3768,7 @@ void main() {
3768
3768
  #include <clipping_planes_vertex>
3769
3769
  #include <worldpos_vertex>
3770
3770
  #include <fog_vertex>
3771
- }`,YA=`uniform vec3 diffuse;
3771
+ }`,JA=`uniform vec3 diffuse;
3772
3772
  uniform float opacity;
3773
3773
  #include <common>
3774
3774
  #include <color_pars_fragment>
@@ -3793,7 +3793,7 @@ void main() {
3793
3793
  #include <colorspace_fragment>
3794
3794
  #include <fog_fragment>
3795
3795
  #include <premultiplied_alpha_fragment>
3796
- }`,KA=`#include <common>
3796
+ }`,QA=`#include <common>
3797
3797
  #include <batching_pars_vertex>
3798
3798
  #include <fog_pars_vertex>
3799
3799
  #include <morphtarget_pars_vertex>
@@ -3816,7 +3816,7 @@ void main() {
3816
3816
  #include <worldpos_vertex>
3817
3817
  #include <shadowmap_vertex>
3818
3818
  #include <fog_vertex>
3819
- }`,JA=`uniform vec3 color;
3819
+ }`,e1=`uniform vec3 color;
3820
3820
  uniform float opacity;
3821
3821
  #include <common>
3822
3822
  #include <fog_pars_fragment>
@@ -3832,7 +3832,7 @@ void main() {
3832
3832
  #include <colorspace_fragment>
3833
3833
  #include <fog_fragment>
3834
3834
  #include <premultiplied_alpha_fragment>
3835
- }`,QA=`uniform float rotation;
3835
+ }`,t1=`uniform float rotation;
3836
3836
  uniform vec2 center;
3837
3837
  #include <common>
3838
3838
  #include <uv_pars_vertex>
@@ -3856,7 +3856,7 @@ void main() {
3856
3856
  #include <logdepthbuf_vertex>
3857
3857
  #include <clipping_planes_vertex>
3858
3858
  #include <fog_vertex>
3859
- }`,e1=`uniform vec3 diffuse;
3859
+ }`,n1=`uniform vec3 diffuse;
3860
3860
  uniform float opacity;
3861
3861
  #include <common>
3862
3862
  #include <uv_pars_fragment>
@@ -3881,7 +3881,7 @@ void main() {
3881
3881
  #include <tonemapping_fragment>
3882
3882
  #include <colorspace_fragment>
3883
3883
  #include <fog_fragment>
3884
- }`,Ye={alphahash_fragment:bE,alphahash_pars_fragment:SE,alphamap_fragment:wE,alphamap_pars_fragment:ME,alphatest_fragment:EE,alphatest_pars_fragment:TE,aomap_fragment:AE,aomap_pars_fragment:RE,batching_pars_vertex:CE,batching_vertex:IE,begin_vertex:PE,beginnormal_vertex:LE,bsdfs:NE,iridescence_fragment:DE,bumpmap_pars_fragment:OE,clipping_planes_fragment:UE,clipping_planes_pars_fragment:FE,clipping_planes_pars_vertex:zE,clipping_planes_vertex:kE,color_fragment:BE,color_pars_fragment:GE,color_pars_vertex:HE,color_vertex:VE,common:$E,cube_uv_reflection_fragment:WE,defaultnormal_vertex:ZE,displacementmap_pars_vertex:XE,displacementmap_vertex:jE,emissivemap_fragment:qE,emissivemap_pars_fragment:YE,colorspace_fragment:KE,colorspace_pars_fragment:JE,envmap_fragment:QE,envmap_common_pars_fragment:eT,envmap_pars_fragment:tT,envmap_pars_vertex:nT,envmap_physical_pars_fragment:fT,envmap_vertex:iT,fog_vertex:rT,fog_pars_vertex:sT,fog_fragment:oT,fog_pars_fragment:aT,gradientmap_pars_fragment:cT,lightmap_pars_fragment:lT,lights_lambert_fragment:uT,lights_lambert_pars_fragment:hT,lights_pars_begin:dT,lights_toon_fragment:pT,lights_toon_pars_fragment:mT,lights_phong_fragment:gT,lights_phong_pars_fragment:_T,lights_physical_fragment:xT,lights_physical_pars_fragment:vT,lights_fragment_begin:yT,lights_fragment_maps:bT,lights_fragment_end:ST,lightprobes_pars_fragment:wT,logdepthbuf_fragment:MT,logdepthbuf_pars_fragment:ET,logdepthbuf_pars_vertex:TT,logdepthbuf_vertex:AT,map_fragment:RT,map_pars_fragment:CT,map_particle_fragment:IT,map_particle_pars_fragment:PT,metalnessmap_fragment:LT,metalnessmap_pars_fragment:NT,morphinstance_vertex:DT,morphcolor_vertex:OT,morphnormal_vertex:UT,morphtarget_pars_vertex:FT,morphtarget_vertex:zT,normal_fragment_begin:kT,normal_fragment_maps:BT,normal_pars_fragment:GT,normal_pars_vertex:HT,normal_vertex:VT,normalmap_pars_fragment:$T,clearcoat_normal_fragment_begin:WT,clearcoat_normal_fragment_maps:ZT,clearcoat_pars_fragment:XT,iridescence_pars_fragment:jT,opaque_fragment:qT,packing:YT,premultiplied_alpha_fragment:KT,project_vertex:JT,dithering_fragment:QT,dithering_pars_fragment:eA,roughnessmap_fragment:tA,roughnessmap_pars_fragment:nA,shadowmap_pars_fragment:iA,shadowmap_pars_vertex:rA,shadowmap_vertex:sA,shadowmask_pars_fragment:oA,skinbase_vertex:aA,skinning_pars_vertex:cA,skinning_vertex:lA,skinnormal_vertex:uA,specularmap_fragment:hA,specularmap_pars_fragment:dA,tonemapping_fragment:fA,tonemapping_pars_fragment:pA,transmission_fragment:mA,transmission_pars_fragment:gA,uv_pars_fragment:_A,uv_pars_vertex:xA,uv_vertex:vA,worldpos_vertex:yA,background_vert:bA,background_frag:SA,backgroundCube_vert:wA,backgroundCube_frag:MA,cube_vert:EA,cube_frag:TA,depth_vert:AA,depth_frag:RA,distance_vert:CA,distance_frag:IA,equirect_vert:PA,equirect_frag:LA,linedashed_vert:NA,linedashed_frag:DA,meshbasic_vert:OA,meshbasic_frag:UA,meshlambert_vert:FA,meshlambert_frag:zA,meshmatcap_vert:kA,meshmatcap_frag:BA,meshnormal_vert:GA,meshnormal_frag:HA,meshphong_vert:VA,meshphong_frag:$A,meshphysical_vert:WA,meshphysical_frag:ZA,meshtoon_vert:XA,meshtoon_frag:jA,points_vert:qA,points_frag:YA,shadow_vert:KA,shadow_frag:JA,sprite_vert:QA,sprite_frag:e1},be={common:{diffuse:{value:new He(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new We},alphaMap:{value:null},alphaMapTransform:{value:new We},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new We}},envmap:{envMap:{value:null},envMapRotation:{value:new We},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:0.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new We}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new We}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new We},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new We},normalScale:{value:new Be(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new We},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new We}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new We}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new We}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:0.00025},fogNear:{value:1},fogFar:{value:2000},fogColor:{value:new He(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},sunLights:{value:[],properties:{direction:{},color:{}}},sunLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},sunShadowMatrix:{value:[]},sunShadowCascade:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new F},probesMax:{value:new F},probesResolution:{value:new F}},points:{diffuse:{value:new He(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new We},alphaTest:{value:0},uvTransform:{value:new We}},sprite:{diffuse:{value:new He(16777215)},opacity:{value:1},center:{value:new Be(0.5,0.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new We},alphaMap:{value:null},alphaMapTransform:{value:new We},alphaTest:{value:0}}},Ei={basic:{uniforms:un([be.common,be.specularmap,be.envmap,be.aomap,be.lightmap,be.fog]),vertexShader:Ye.meshbasic_vert,fragmentShader:Ye.meshbasic_frag},lambert:{uniforms:un([be.common,be.specularmap,be.envmap,be.aomap,be.lightmap,be.emissivemap,be.bumpmap,be.normalmap,be.displacementmap,be.fog,be.lights,{emissive:{value:new He(0)},envMapIntensity:{value:1}}]),vertexShader:Ye.meshlambert_vert,fragmentShader:Ye.meshlambert_frag},phong:{uniforms:un([be.common,be.specularmap,be.envmap,be.aomap,be.lightmap,be.emissivemap,be.bumpmap,be.normalmap,be.displacementmap,be.fog,be.lights,{emissive:{value:new He(0)},specular:{value:new He(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Ye.meshphong_vert,fragmentShader:Ye.meshphong_frag},standard:{uniforms:un([be.common,be.envmap,be.aomap,be.lightmap,be.emissivemap,be.bumpmap,be.normalmap,be.displacementmap,be.roughnessmap,be.metalnessmap,be.fog,be.lights,{emissive:{value:new He(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ye.meshphysical_vert,fragmentShader:Ye.meshphysical_frag},toon:{uniforms:un([be.common,be.aomap,be.lightmap,be.emissivemap,be.bumpmap,be.normalmap,be.displacementmap,be.gradientmap,be.fog,be.lights,{emissive:{value:new He(0)}}]),vertexShader:Ye.meshtoon_vert,fragmentShader:Ye.meshtoon_frag},matcap:{uniforms:un([be.common,be.bumpmap,be.normalmap,be.displacementmap,be.fog,{matcap:{value:null}}]),vertexShader:Ye.meshmatcap_vert,fragmentShader:Ye.meshmatcap_frag},points:{uniforms:un([be.points,be.fog]),vertexShader:Ye.points_vert,fragmentShader:Ye.points_frag},dashed:{uniforms:un([be.common,be.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ye.linedashed_vert,fragmentShader:Ye.linedashed_frag},depth:{uniforms:un([be.common,be.displacementmap]),vertexShader:Ye.depth_vert,fragmentShader:Ye.depth_frag},normal:{uniforms:un([be.common,be.bumpmap,be.normalmap,be.displacementmap,{opacity:{value:1}}]),vertexShader:Ye.meshnormal_vert,fragmentShader:Ye.meshnormal_frag},sprite:{uniforms:un([be.sprite,be.fog]),vertexShader:Ye.sprite_vert,fragmentShader:Ye.sprite_frag},background:{uniforms:{uvTransform:{value:new We},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ye.background_vert,fragmentShader:Ye.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new We}},vertexShader:Ye.backgroundCube_vert,fragmentShader:Ye.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ye.cube_vert,fragmentShader:Ye.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ye.equirect_vert,fragmentShader:Ye.equirect_frag},distance:{uniforms:un([be.common,be.displacementmap,{referencePosition:{value:new F},nearDistance:{value:1},farDistance:{value:1000}}]),vertexShader:Ye.distance_vert,fragmentShader:Ye.distance_frag},shadow:{uniforms:un([be.lights,be.fog,{color:{value:new He(0)},opacity:{value:1}}]),vertexShader:Ye.shadow_vert,fragmentShader:Ye.shadow_frag}};Ei.physical={uniforms:un([Ei.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new We},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new We},clearcoatNormalScale:{value:new Be(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new We},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new We},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new We},sheen:{value:0},sheenColor:{value:new He(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new We},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new We},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new We},transmissionSamplerSize:{value:new Be},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new We},attenuationDistance:{value:0},attenuationColor:{value:new He(0)},specularColor:{value:new He(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new We},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new We},anisotropyVector:{value:new Be},anisotropyMap:{value:null},anisotropyMapTransform:{value:new We}}]),vertexShader:Ye.meshphysical_vert,fragmentShader:Ye.meshphysical_frag};var fl={r:0,b:0,g:0},t1=new Xe,Kv=new We;Kv.set(-1,0,0,0,1,0,0,0,1);function n1(e,t,n,i,r,s){let o=new He(0),a=r===!0?0:1,c,l,u=null,h=0,d=null;function f(M){let T=M.isScene===!0?M.background:null;if(T&&T.isTexture){let v=M.backgroundBlurriness>0;T=t.get(T,v)}return T}function m(M){let T=!1,v=f(M);if(v===null)p(o,a);else if(v&&v.isColor)p(v,1),T=!0;let S=e.xr.getEnvironmentBlendMode();if(S==="additive")n.buffers.color.setClear(0,0,0,1,s);else if(S==="alpha-blend")n.buffers.color.setClear(0,0,0,0,s);if(e.autoClear||T)n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil)}function _(M,T){let v=f(T);if(v&&(v.isCubeTexture||v.mapping===Ho)){if(l===void 0)l=new Mt(new xr(1,1,1),new Gn({name:"BackgroundCubeMaterial",uniforms:Kr(Ei.backgroundCube.uniforms),vertexShader:Ei.backgroundCube.vertexShader,fragmentShader:Ei.backgroundCube.fragmentShader,side:cn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(S,E,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(l);if(l.material.uniforms.envMap.value=v,l.material.uniforms.backgroundBlurriness.value=T.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(t1.makeRotationFromEuler(T.backgroundRotation)).transpose(),v.isCubeTexture&&v.isRenderTargetTexture===!1)l.material.uniforms.backgroundRotation.value.premultiply(Kv);if(l.material.toneMapped=Ke.getTransfer(v.colorSpace)!==yt,u!==v||h!==v.version||d!==e.toneMapping)l.material.needsUpdate=!0,u=v,h=v.version,d=e.toneMapping;l.layers.enableAll(),M.unshift(l,l.geometry,l.material,0,0,null)}else if(v&&v.isTexture){if(c===void 0)c=new Mt(new ta(2,2),new Gn({name:"BackgroundMaterial",uniforms:Kr(Ei.background.uniforms),vertexShader:Ei.background.vertexShader,fragmentShader:Ei.background.fragmentShader,side:fr,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c);if(c.material.uniforms.t2D.value=v,c.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,c.material.toneMapped=Ke.getTransfer(v.colorSpace)!==yt,v.matrixAutoUpdate===!0)v.updateMatrix();if(c.material.uniforms.uvTransform.value.copy(v.matrix),u!==v||h!==v.version||d!==e.toneMapping)c.material.needsUpdate=!0,u=v,h=v.version,d=e.toneMapping;c.layers.enableAll(),M.unshift(c,c.geometry,c.material,0,0,null)}}function p(M,T){M.getRGB(fl,md(e)),n.buffers.color.setClear(fl.r,fl.g,fl.b,T,s)}function g(){if(l!==void 0)l.geometry.dispose(),l.material.dispose(),l=void 0;if(c!==void 0)c.geometry.dispose(),c.material.dispose(),c=void 0}return{getClearColor:function(){return o},setClearColor:function(M,T=1){o.set(M),a=T,p(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(M){a=M,p(o,a)},render:m,addToRenderList:_,dispose:g}}function i1(e,t){let n=e.getParameter(e.MAX_VERTEX_ATTRIBS),i={},r=d(null),s=r,o=!1;function a(C,N,ee,P,Z){let G=!1,k=h(C,P,ee,N);if(s!==k)s=k,l(s.object);if(G=f(C,P,ee,Z),G)m(C,P,ee,Z);if(Z!==null)t.update(Z,e.ELEMENT_ARRAY_BUFFER);if(G||o){if(o=!1,v(C,N,ee,P),Z!==null)e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(Z).buffer)}}function c(){return e.createVertexArray()}function l(C){return e.bindVertexArray(C)}function u(C){return e.deleteVertexArray(C)}function h(C,N,ee,P){let Z=P.wireframe===!0,G=i[N.id];if(G===void 0)G={},i[N.id]=G;let k=C.isInstancedMesh===!0?C.id:0,W=G[k];if(W===void 0)W={},G[k]=W;let B=W[ee.id];if(B===void 0)B={},W[ee.id]=B;let Y=B[Z];if(Y===void 0)Y=d(c()),B[Z]=Y;return Y}function d(C){let N=[],ee=[],P=[];for(let Z=0;Z<n;Z++)N[Z]=0,ee[Z]=0,P[Z]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:N,enabledAttributes:ee,attributeDivisors:P,object:C,attributes:{},index:null}}function f(C,N,ee,P){let Z=s.attributes,G=N.attributes,k=0,W=ee.getAttributes();for(let B in W)if(W[B].location>=0){let K=Z[B],ge=G[B];if(ge===void 0){if(B==="instanceMatrix"&&C.instanceMatrix)ge=C.instanceMatrix;if(B==="instanceColor"&&C.instanceColor)ge=C.instanceColor}if(K===void 0)return!0;if(K.attribute!==ge)return!0;if(ge&&K.data!==ge.data)return!0;k++}if(s.attributesNum!==k)return!0;if(s.index!==P)return!0;return!1}function m(C,N,ee,P){let Z={},G=N.attributes,k=0,W=ee.getAttributes();for(let B in W)if(W[B].location>=0){let K=G[B];if(K===void 0){if(B==="instanceMatrix"&&C.instanceMatrix)K=C.instanceMatrix;if(B==="instanceColor"&&C.instanceColor)K=C.instanceColor}let ge={};if(ge.attribute=K,K&&K.data)ge.data=K.data;Z[B]=ge,k++}s.attributes=Z,s.attributesNum=k,s.index=P}function _(){let C=s.newAttributes;for(let N=0,ee=C.length;N<ee;N++)C[N]=0}function p(C){g(C,0)}function g(C,N){let ee=s.newAttributes,P=s.enabledAttributes,Z=s.attributeDivisors;if(ee[C]=1,P[C]===0)e.enableVertexAttribArray(C),P[C]=1;if(Z[C]!==N)e.vertexAttribDivisor(C,N),Z[C]=N}function M(){let C=s.newAttributes,N=s.enabledAttributes;for(let ee=0,P=N.length;ee<P;ee++)if(N[ee]!==C[ee])e.disableVertexAttribArray(ee),N[ee]=0}function T(C,N,ee,P,Z,G,k){if(k===!0)e.vertexAttribIPointer(C,N,ee,Z,G);else e.vertexAttribPointer(C,N,ee,P,Z,G)}function v(C,N,ee,P){_();let Z=P.attributes,G=ee.getAttributes(),k=N.defaultAttributeValues;for(let W in G){let B=G[W];if(B.location>=0){let Y=Z[W];if(Y===void 0){if(W==="instanceMatrix"&&C.instanceMatrix)Y=C.instanceMatrix;if(W==="instanceColor"&&C.instanceColor)Y=C.instanceColor}if(Y!==void 0){let K=Y.normalized,ge=Y.itemSize,de=t.get(Y);if(de===void 0)continue;let{buffer:fe,type:he,bytesPerElement:I}=de,V=he===e.INT||he===e.UNSIGNED_INT||Y.gpuType===Sh;if(Y.isInterleavedBufferAttribute){let q=Y.data,se=q.stride,ce=Y.offset;if(q.isInstancedInterleavedBuffer){for(let ae=0;ae<B.locationSize;ae++)g(B.location+ae,q.meshPerAttribute);if(C.isInstancedMesh!==!0&&P._maxInstanceCount===void 0)P._maxInstanceCount=q.meshPerAttribute*q.count}else for(let ae=0;ae<B.locationSize;ae++)p(B.location+ae);e.bindBuffer(e.ARRAY_BUFFER,fe);for(let ae=0;ae<B.locationSize;ae++)T(B.location+ae,ge/B.locationSize,he,K,se*I,(ce+ge/B.locationSize*ae)*I,V)}else{if(Y.isInstancedBufferAttribute){for(let q=0;q<B.locationSize;q++)g(B.location+q,Y.meshPerAttribute);if(C.isInstancedMesh!==!0&&P._maxInstanceCount===void 0)P._maxInstanceCount=Y.meshPerAttribute*Y.count}else for(let q=0;q<B.locationSize;q++)p(B.location+q);e.bindBuffer(e.ARRAY_BUFFER,fe);for(let q=0;q<B.locationSize;q++)T(B.location+q,ge/B.locationSize,he,K,ge*I,ge/B.locationSize*q*I,V)}}else if(k!==void 0){let K=k[W];if(K!==void 0)switch(K.length){case 2:e.vertexAttrib2fv(B.location,K);break;case 3:e.vertexAttrib3fv(B.location,K);break;case 4:e.vertexAttrib4fv(B.location,K);break;default:e.vertexAttrib1fv(B.location,K)}}}}M()}function S(){w();for(let C in i){let N=i[C];for(let ee in N){let P=N[ee];for(let Z in P){let G=P[Z];for(let k in G)u(G[k].object),delete G[k];delete P[Z]}}delete i[C]}}function E(C){if(i[C.id]===void 0)return;let N=i[C.id];for(let ee in N){let P=N[ee];for(let Z in P){let G=P[Z];for(let k in G)u(G[k].object),delete G[k];delete P[Z]}}delete i[C.id]}function R(C){for(let N in i){let ee=i[N];for(let P in ee){let Z=ee[P];if(Z[C.id]===void 0)continue;let G=Z[C.id];for(let k in G)u(G[k].object),delete G[k];delete Z[C.id]}}}function x(C){for(let N in i){let ee=i[N],P=C.isInstancedMesh===!0?C.id:0,Z=ee[P];if(Z===void 0)continue;for(let G in Z){let k=Z[G];for(let W in k)u(k[W].object),delete k[W];delete Z[G]}if(delete ee[P],Object.keys(ee).length===0)delete i[N]}}function w(){if(H(),o=!0,s===r)return;s=r,l(s.object)}function H(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:a,reset:w,resetDefaultState:H,dispose:S,releaseStatesOfGeometry:E,releaseStatesOfObject:x,releaseStatesOfProgram:R,initAttributes:_,enableAttribute:p,disableUnusedAttributes:M}}function r1(e,t,n){let i;function r(c){i=c}function s(c,l){e.drawArrays(i,c,l),n.update(l,i,1)}function o(c,l,u){if(u===0)return;e.drawArraysInstanced(i,c,l,u),n.update(l,i,u)}function a(c,l,u){if(u===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,c,0,l,0,u);let d=0;for(let f=0;f<u;f++)d+=l[f];n.update(d,i,1)}this.setMode=r,this.render=s,this.renderInstances=o,this.renderMultiDraw=a}function s1(e,t,n,i){let r;function s(){if(r!==void 0)return r;if(t.has("EXT_texture_filter_anisotropic")===!0){let R=t.get("EXT_texture_filter_anisotropic");r=e.getParameter(R.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function o(R){if(R!==Si&&i.convert(R)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT))return!1;return!0}function a(R){let x=R===bi&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));if(R!==ni&&R!==Vi&&!x&&i.convert(R)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE))return!1;return!0}function c(R){if(R==="highp"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";R="mediump"}if(R==="mediump"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0)return"mediump"}return"lowp"}let l=n.precision!==void 0?n.precision:"highp",u=c(l);if(u!==l)Ue("WebGLRenderer:",l,"not supported, using",u,"instead."),l=u;let h=n.logarithmicDepthBuffer===!0,d=n.reversedDepthBuffer===!0&&t.has("EXT_clip_control");if(n.reversedDepthBuffer===!0&&d===!1)Ue("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");let f=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),m=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),_=e.getParameter(e.MAX_TEXTURE_SIZE),p=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),g=e.getParameter(e.MAX_VERTEX_ATTRIBS),M=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),T=e.getParameter(e.MAX_VARYING_VECTORS),v=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),S=e.getParameter(e.MAX_SAMPLES),E=e.getParameter(e.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:a,precision:l,logarithmicDepthBuffer:h,reversedDepthBuffer:d,maxTextures:f,maxVertexTextures:m,maxTextureSize:_,maxCubemapSize:p,maxAttributes:g,maxVertexUniforms:M,maxVaryings:T,maxFragmentUniforms:v,maxSamples:S,samples:E}}function o1(e){let t=this,n=null,i=0,r=!1,s=!1,o=new zn,a=new We,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(h,d){let f=h.length!==0||d||i!==0||r;return r=d,i=h.length,f},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(h,d){n=u(h,d,0)},this.setState=function(h,d,f){let{clippingPlanes:m,clipIntersection:_,clipShadows:p}=h,g=e.get(h);if(!r||m===null||m.length===0||s&&!p)if(s)u(null);else l();else{let M=s?0:i,T=M*4,v=g.clippingState||null;c.value=v,v=u(m,d,T,f);for(let S=0;S!==T;++S)v[S]=n[S];g.clippingState=v,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=M}};function l(){if(c.value!==n)c.value=n,c.needsUpdate=i>0;t.numPlanes=i,t.numIntersection=0}function u(h,d,f,m){let _=h!==null?h.length:0,p=null;if(_!==0){if(p=c.value,m!==!0||p===null){let g=f+_*4,M=d.matrixWorldInverse;if(a.getNormalMatrix(M),p===null||p.length<g)p=new Float32Array(g);for(let T=0,v=f;T!==_;++T,v+=4)o.copy(h[T]).applyMatrix4(M,a),o.normal.toArray(p,v),p[v+3]=o.constant}c.value=p,c.needsUpdate=!0}return t.numPlanes=_,t.numIntersection=0,p}}var Ws=4,a1=6,c1=20,l1=256,oa=new Qr,Cv=new He,Ld=null,Nd=0,Dd=0,Od=!1,u1=new F,es=new F;class ua{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,n=0.1,i=100,r={}){let{size:s=256,position:o=u1}=r;Ld=this._renderer.getRenderTarget(),Nd=this._renderer.getActiveCubeFace(),Dd=this._renderer.getActiveMipmapLevel(),Od=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(s);let a=this._allocateTargets();if(a.depthBuffer=!0,this._sceneToCubeUV(e,n,i,a,o),t>0)this._blur(a,0,0,t);return this._applyPMREM(a),this._cleanup(a),a}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){if(this._cubemapMaterial===null)this._cubemapMaterial=Lv(),this._compileMaterial(this._cubemapMaterial)}compileEquirectangularShader(){if(this._equirectMaterial===null)this._equirectMaterial=Pv(),this._compileMaterial(this._equirectMaterial)}dispose(){if(this._dispose(),this._cubemapMaterial!==null)this._cubemapMaterial.dispose();if(this._equirectMaterial!==null)this._equirectMaterial.dispose();if(this._backgroundBox!==null)this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){if(this._blurMaterial!==null)this._blurMaterial.dispose();if(this._ggxMaterial!==null)this._ggxMaterial.dispose();if(this._pingPongRenderTarget!==null)this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(Ld,Nd,Dd),this._renderer.xr.enabled=Od,e.scissorTest=!1,$s(e,0,0,e.width,e.height)}_fromTexture(e,t){if(e.mapping===Ps||e.mapping===$r)this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width);else this._setSize(e.image.width/4);Ld=this._renderer.getRenderTarget(),Nd=this._renderer.getActiveCubeFace(),Dd=this._renderer.getActiveMipmapLevel(),Od=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:Jt,minFilter:Jt,generateMipmaps:!1,type:bi,format:Si,colorSpace:Rn,depthBuffer:!1},i=Iv(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){if(this._pingPongRenderTarget!==null)this._dispose();this._pingPongRenderTarget=Iv(e,t,n);let{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods}=h1(r)),this._blurMaterial=f1(r,e,t),this._ggxMaterial=d1(r,e,t)}return i}_compileMaterial(e){let t=new Mt(new ln,e);this._renderer.compile(t,oa)}_sceneToCubeUV(e,t,n,i,r){let a=new Ht(90,1,t,n),c=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],u=this._renderer,{autoClear:h,toneMapping:d}=u;if(u.getClearColor(Cv),u.toneMapping=ei,u.autoClear=!1,u.state.buffers.depth.getReversed())u.setRenderTarget(i),u.clearDepth(),u.setRenderTarget(null);if(this._backgroundBox===null)this._backgroundBox=new Mt(new xr,new wi({name:"PMREM.Background",side:cn,depthWrite:!1,depthTest:!1}));let m=this._backgroundBox,_=m.material,p=!1,g=e.background;if(g){if(g.isColor)_.color.copy(g),e.background=null,p=!0}else _.color.copy(Cv),p=!0;for(let M=0;M<6;M++){let T=M%3;if(T===0)a.up.set(0,c[M],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x+l[M],r.y,r.z);else if(T===1)a.up.set(0,0,c[M]),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y+l[M],r.z);else a.up.set(0,c[M],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y,r.z+l[M]);let v=this._cubeSize;if($s(i,T*v,M>2?v:0,v,v),u.setRenderTarget(i),p)u.render(m,a);u.render(e,a)}u.toneMapping=d,u.autoClear=h,e.background=g}_textureToCubeUV(e,t){let n=this._renderer,i=e.mapping===Ps||e.mapping===$r;if(i){if(this._cubemapMaterial===null)this._cubemapMaterial=Lv();this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1}else if(this._equirectMaterial===null)this._equirectMaterial=Pv();let r=i?this._cubemapMaterial:this._equirectMaterial,s=this._lodMeshes[0];s.material=r;let o=r.uniforms;o.envMap.value=e;let a=this._cubeSize;$s(t,0,0,3*a,2*a),n.setRenderTarget(t),n.render(s,oa)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let i=this._lodMeshes.length;for(let r=1;r<i;r++)this._applyGGXFilter(e,r-1,r);t.autoClear=n}_applyGGXFilter(e,t,n){let i=this._renderer,r=this._pingPongRenderTarget,s=this._ggxMaterial,o=this._lodMeshes[n];o.material=s;let a=s.uniforms,c=n/(this._lodMeshes.length-1),l=t/(this._lodMeshes.length-1),u=Math.sqrt(c*c-l*l),h=c*1.25,d=u*h,{_lodMax:f}=this,m=this._sizeLods[n],_=3*m*(n>f-Ws?n-f+Ws:0),p=4*(this._cubeSize-m);a.envMap.value=e.texture,a.roughness.value=d,a.mipInt.value=f-t,$s(r,_,p,3*m,2*m),i.setRenderTarget(r),i.render(o,oa),a.envMap.value=r.texture,a.roughness.value=0,a.mipInt.value=f-n,$s(e,_,p,3*m,2*m),i.setRenderTarget(e),i.render(o,oa)}_blur(e,t,n,i){let r=this._pingPongRenderTarget,s=Math.min(i,Math.PI)/Math.SQRT2;this._blurPass(e,r,t,n,s),this._blurPass(r,e,n,n,s)}_blurPass(e,t,n,i,r){let s=this._renderer,o=this._blurMaterial,a=this._lodMeshes[i];a.material=o;let c=o.uniforms;c.envMap.value=e.texture,c.sigma.value=r,c.mipInt.value=this._lodMax-n;let l=this._sizeLods[i],u=3*l*(i>this._lodMax-Ws?i-this._lodMax+Ws:0),h=4*(this._cubeSize-l);$s(t,u,h,3*l,2*l),s.setRenderTarget(t),s.render(a,oa)}}function h1(e){let t=[],n=[],i=e,r=e-Ws+1+a1;for(let s=0;s<r;s++){let o=Math.pow(2,i);t.push(o);let a=1/(o-2),c=-a,l=1+a,u=[c,c,l,c,l,l,c,c,l,l,c,l],h=6,d=6,f=3,m=new Float32Array(f*d*h),_=new Float32Array(f*d*h);for(let g=0;g<h;g++){let M=g%3*2/3-1,T=g>2?0:-1,v=[M,T,0,M+0.6666666666666666,T,0,M+0.6666666666666666,T+1,0,M,T,0,M+0.6666666666666666,T+1,0,M,T+1,0];m.set(v,f*d*g);for(let S=0;S<d;S++){let E=u[S*2]*2-1,R=u[S*2+1]*2-1;if(g===0)es.set(1,R,E);else if(g===1)es.set(-E,1,-R);else if(g===2)es.set(-E,R,1);else if(g===3)es.set(-1,R,-E);else if(g===4)es.set(-E,-1,R);else es.set(E,R,-1);es.toArray(_,(g*d+S)*f)}}let p=new ln;if(p.setAttribute("position",new Kt(m,f)),p.setAttribute("outputDirection",new Kt(_,f)),n.push(new Mt(p,null)),i>Ws)i--}return{lodMeshes:n,sizeLods:t}}function Iv(e,t,n){let i=new Cn(e,t,n);return i.texture.mapping=Ho,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function $s(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function d1(e,t,n){return new Gn({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:l1,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:ml(),fragmentShader:`
3884
+ }`,Ye={alphahash_fragment:wE,alphahash_pars_fragment:ME,alphamap_fragment:EE,alphamap_pars_fragment:TE,alphatest_fragment:AE,alphatest_pars_fragment:RE,aomap_fragment:CE,aomap_pars_fragment:IE,batching_pars_vertex:PE,batching_vertex:LE,begin_vertex:NE,beginnormal_vertex:DE,bsdfs:OE,iridescence_fragment:UE,bumpmap_pars_fragment:FE,clipping_planes_fragment:zE,clipping_planes_pars_fragment:kE,clipping_planes_pars_vertex:BE,clipping_planes_vertex:GE,color_fragment:HE,color_pars_fragment:VE,color_pars_vertex:$E,color_vertex:WE,common:ZE,cube_uv_reflection_fragment:XE,defaultnormal_vertex:jE,displacementmap_pars_vertex:qE,displacementmap_vertex:YE,emissivemap_fragment:KE,emissivemap_pars_fragment:JE,colorspace_fragment:QE,colorspace_pars_fragment:eT,envmap_fragment:tT,envmap_common_pars_fragment:nT,envmap_pars_fragment:iT,envmap_pars_vertex:rT,envmap_physical_pars_fragment:mT,envmap_vertex:sT,fog_vertex:oT,fog_pars_vertex:aT,fog_fragment:cT,fog_pars_fragment:lT,gradientmap_pars_fragment:uT,lightmap_pars_fragment:hT,lights_lambert_fragment:dT,lights_lambert_pars_fragment:fT,lights_pars_begin:pT,lights_toon_fragment:gT,lights_toon_pars_fragment:_T,lights_phong_fragment:xT,lights_phong_pars_fragment:vT,lights_physical_fragment:yT,lights_physical_pars_fragment:bT,lights_fragment_begin:ST,lights_fragment_maps:wT,lights_fragment_end:MT,lightprobes_pars_fragment:ET,logdepthbuf_fragment:TT,logdepthbuf_pars_fragment:AT,logdepthbuf_pars_vertex:RT,logdepthbuf_vertex:CT,map_fragment:IT,map_pars_fragment:PT,map_particle_fragment:LT,map_particle_pars_fragment:NT,metalnessmap_fragment:DT,metalnessmap_pars_fragment:OT,morphinstance_vertex:UT,morphcolor_vertex:FT,morphnormal_vertex:zT,morphtarget_pars_vertex:kT,morphtarget_vertex:BT,normal_fragment_begin:GT,normal_fragment_maps:HT,normal_pars_fragment:VT,normal_pars_vertex:$T,normal_vertex:WT,normalmap_pars_fragment:ZT,clearcoat_normal_fragment_begin:XT,clearcoat_normal_fragment_maps:jT,clearcoat_pars_fragment:qT,iridescence_pars_fragment:YT,opaque_fragment:KT,packing:JT,premultiplied_alpha_fragment:QT,project_vertex:eA,dithering_fragment:tA,dithering_pars_fragment:nA,roughnessmap_fragment:iA,roughnessmap_pars_fragment:rA,shadowmap_pars_fragment:sA,shadowmap_pars_vertex:oA,shadowmap_vertex:aA,shadowmask_pars_fragment:cA,skinbase_vertex:lA,skinning_pars_vertex:uA,skinning_vertex:hA,skinnormal_vertex:dA,specularmap_fragment:fA,specularmap_pars_fragment:pA,tonemapping_fragment:mA,tonemapping_pars_fragment:gA,transmission_fragment:_A,transmission_pars_fragment:xA,uv_pars_fragment:vA,uv_pars_vertex:yA,uv_vertex:bA,worldpos_vertex:SA,background_vert:wA,background_frag:MA,backgroundCube_vert:EA,backgroundCube_frag:TA,cube_vert:AA,cube_frag:RA,depth_vert:CA,depth_frag:IA,distance_vert:PA,distance_frag:LA,equirect_vert:NA,equirect_frag:DA,linedashed_vert:OA,linedashed_frag:UA,meshbasic_vert:FA,meshbasic_frag:zA,meshlambert_vert:kA,meshlambert_frag:BA,meshmatcap_vert:GA,meshmatcap_frag:HA,meshnormal_vert:VA,meshnormal_frag:$A,meshphong_vert:WA,meshphong_frag:ZA,meshphysical_vert:XA,meshphysical_frag:jA,meshtoon_vert:qA,meshtoon_frag:YA,points_vert:KA,points_frag:JA,shadow_vert:QA,shadow_frag:e1,sprite_vert:t1,sprite_frag:n1},be={common:{diffuse:{value:new Ge(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new We},alphaMap:{value:null},alphaMapTransform:{value:new We},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new We}},envmap:{envMap:{value:null},envMapRotation:{value:new We},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:0.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new We}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new We}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new We},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new We},normalScale:{value:new ke(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new We},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new We}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new We}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new We}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:0.00025},fogNear:{value:1},fogFar:{value:2000},fogColor:{value:new Ge(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},sunLights:{value:[],properties:{direction:{},color:{}}},sunLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},sunShadowMatrix:{value:[]},sunShadowCascade:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new z},probesMax:{value:new z},probesResolution:{value:new z}},points:{diffuse:{value:new Ge(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new We},alphaTest:{value:0},uvTransform:{value:new We}},sprite:{diffuse:{value:new Ge(16777215)},opacity:{value:1},center:{value:new ke(0.5,0.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new We},alphaMap:{value:null},alphaMapTransform:{value:new We},alphaTest:{value:0}}},Ei={basic:{uniforms:un([be.common,be.specularmap,be.envmap,be.aomap,be.lightmap,be.fog]),vertexShader:Ye.meshbasic_vert,fragmentShader:Ye.meshbasic_frag},lambert:{uniforms:un([be.common,be.specularmap,be.envmap,be.aomap,be.lightmap,be.emissivemap,be.bumpmap,be.normalmap,be.displacementmap,be.fog,be.lights,{emissive:{value:new Ge(0)},envMapIntensity:{value:1}}]),vertexShader:Ye.meshlambert_vert,fragmentShader:Ye.meshlambert_frag},phong:{uniforms:un([be.common,be.specularmap,be.envmap,be.aomap,be.lightmap,be.emissivemap,be.bumpmap,be.normalmap,be.displacementmap,be.fog,be.lights,{emissive:{value:new Ge(0)},specular:{value:new Ge(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Ye.meshphong_vert,fragmentShader:Ye.meshphong_frag},standard:{uniforms:un([be.common,be.envmap,be.aomap,be.lightmap,be.emissivemap,be.bumpmap,be.normalmap,be.displacementmap,be.roughnessmap,be.metalnessmap,be.fog,be.lights,{emissive:{value:new Ge(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ye.meshphysical_vert,fragmentShader:Ye.meshphysical_frag},toon:{uniforms:un([be.common,be.aomap,be.lightmap,be.emissivemap,be.bumpmap,be.normalmap,be.displacementmap,be.gradientmap,be.fog,be.lights,{emissive:{value:new Ge(0)}}]),vertexShader:Ye.meshtoon_vert,fragmentShader:Ye.meshtoon_frag},matcap:{uniforms:un([be.common,be.bumpmap,be.normalmap,be.displacementmap,be.fog,{matcap:{value:null}}]),vertexShader:Ye.meshmatcap_vert,fragmentShader:Ye.meshmatcap_frag},points:{uniforms:un([be.points,be.fog]),vertexShader:Ye.points_vert,fragmentShader:Ye.points_frag},dashed:{uniforms:un([be.common,be.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ye.linedashed_vert,fragmentShader:Ye.linedashed_frag},depth:{uniforms:un([be.common,be.displacementmap]),vertexShader:Ye.depth_vert,fragmentShader:Ye.depth_frag},normal:{uniforms:un([be.common,be.bumpmap,be.normalmap,be.displacementmap,{opacity:{value:1}}]),vertexShader:Ye.meshnormal_vert,fragmentShader:Ye.meshnormal_frag},sprite:{uniforms:un([be.sprite,be.fog]),vertexShader:Ye.sprite_vert,fragmentShader:Ye.sprite_frag},background:{uniforms:{uvTransform:{value:new We},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ye.background_vert,fragmentShader:Ye.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new We}},vertexShader:Ye.backgroundCube_vert,fragmentShader:Ye.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ye.cube_vert,fragmentShader:Ye.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ye.equirect_vert,fragmentShader:Ye.equirect_frag},distance:{uniforms:un([be.common,be.displacementmap,{referencePosition:{value:new z},nearDistance:{value:1},farDistance:{value:1000}}]),vertexShader:Ye.distance_vert,fragmentShader:Ye.distance_frag},shadow:{uniforms:un([be.lights,be.fog,{color:{value:new Ge(0)},opacity:{value:1}}]),vertexShader:Ye.shadow_vert,fragmentShader:Ye.shadow_frag}};Ei.physical={uniforms:un([Ei.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new We},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new We},clearcoatNormalScale:{value:new ke(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new We},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new We},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new We},sheen:{value:0},sheenColor:{value:new Ge(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new We},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new We},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new We},transmissionSamplerSize:{value:new ke},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new We},attenuationDistance:{value:0},attenuationColor:{value:new Ge(0)},specularColor:{value:new Ge(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new We},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new We},anisotropyVector:{value:new ke},anisotropyMap:{value:null},anisotropyMapTransform:{value:new We}}]),vertexShader:Ye.meshphysical_vert,fragmentShader:Ye.meshphysical_frag};var pl={r:0,b:0,g:0},i1=new Xe,Jv=new We;Jv.set(-1,0,0,0,1,0,0,0,1);function r1(e,t,n,i,r,s){let o=new Ge(0),a=r===!0?0:1,c,l,u=null,h=0,d=null;function f(M){let T=M.isScene===!0?M.background:null;if(T&&T.isTexture){let v=M.backgroundBlurriness>0;T=t.get(T,v)}return T}function m(M){let T=!1,v=f(M);if(v===null)p(o,a);else if(v&&v.isColor)p(v,1),T=!0;let S=e.xr.getEnvironmentBlendMode();if(S==="additive")n.buffers.color.setClear(0,0,0,1,s);else if(S==="alpha-blend")n.buffers.color.setClear(0,0,0,0,s);if(e.autoClear||T)n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil)}function _(M,T){let v=f(T);if(v&&(v.isCubeTexture||v.mapping===Wo)){if(l===void 0)l=new Mt(new vr(1,1,1),new Gn({name:"BackgroundCubeMaterial",uniforms:Jr(Ei.backgroundCube.uniforms),vertexShader:Ei.backgroundCube.vertexShader,fragmentShader:Ei.backgroundCube.fragmentShader,side:cn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(S,E,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(l);if(l.material.uniforms.envMap.value=v,l.material.uniforms.backgroundBlurriness.value=T.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(i1.makeRotationFromEuler(T.backgroundRotation)).transpose(),v.isCubeTexture&&v.isRenderTargetTexture===!1)l.material.uniforms.backgroundRotation.value.premultiply(Jv);if(l.material.toneMapped=Ke.getTransfer(v.colorSpace)!==yt,u!==v||h!==v.version||d!==e.toneMapping)l.material.needsUpdate=!0,u=v,h=v.version,d=e.toneMapping;l.layers.enableAll(),M.unshift(l,l.geometry,l.material,0,0,null)}else if(v&&v.isTexture){if(c===void 0)c=new Mt(new ra(2,2),new Gn({name:"BackgroundMaterial",uniforms:Jr(Ei.background.uniforms),vertexShader:Ei.background.vertexShader,fragmentShader:Ei.background.fragmentShader,side:pr,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c);if(c.material.uniforms.t2D.value=v,c.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,c.material.toneMapped=Ke.getTransfer(v.colorSpace)!==yt,v.matrixAutoUpdate===!0)v.updateMatrix();if(c.material.uniforms.uvTransform.value.copy(v.matrix),u!==v||h!==v.version||d!==e.toneMapping)c.material.needsUpdate=!0,u=v,h=v.version,d=e.toneMapping;c.layers.enableAll(),M.unshift(c,c.geometry,c.material,0,0,null)}}function p(M,T){M.getRGB(pl,gd(e)),n.buffers.color.setClear(pl.r,pl.g,pl.b,T,s)}function g(){if(l!==void 0)l.geometry.dispose(),l.material.dispose(),l=void 0;if(c!==void 0)c.geometry.dispose(),c.material.dispose(),c=void 0}return{getClearColor:function(){return o},setClearColor:function(M,T=1){o.set(M),a=T,p(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(M){a=M,p(o,a)},render:m,addToRenderList:_,dispose:g}}function s1(e,t){let n=e.getParameter(e.MAX_VERTEX_ATTRIBS),i={},r=d(null),s=r,o=!1;function a(C,D,ee,L,W){let B=!1,P=h(C,L,ee,D);if(s!==P)s=P,l(s.object);if(B=f(C,L,ee,W),B)m(C,L,ee,W);if(W!==null)t.update(W,e.ELEMENT_ARRAY_BUFFER);if(B||o){if(o=!1,v(C,D,ee,L),W!==null)e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(W).buffer)}}function c(){return e.createVertexArray()}function l(C){return e.bindVertexArray(C)}function u(C){return e.deleteVertexArray(C)}function h(C,D,ee,L){let W=L.wireframe===!0,B=i[D.id];if(B===void 0)B={},i[D.id]=B;let P=C.isInstancedMesh===!0?C.id:0,J=B[P];if(J===void 0)J={},B[P]=J;let H=J[ee.id];if(H===void 0)H={},J[ee.id]=H;let q=H[W];if(q===void 0)q=d(c()),H[W]=q;return q}function d(C){let D=[],ee=[],L=[];for(let W=0;W<n;W++)D[W]=0,ee[W]=0,L[W]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:D,enabledAttributes:ee,attributeDivisors:L,object:C,attributes:{},index:null}}function f(C,D,ee,L){let W=s.attributes,B=D.attributes,P=0,J=ee.getAttributes();for(let H in J)if(J[H].location>=0){let Q=W[H],ge=B[H];if(ge===void 0){if(H==="instanceMatrix"&&C.instanceMatrix)ge=C.instanceMatrix;if(H==="instanceColor"&&C.instanceColor)ge=C.instanceColor}if(Q===void 0)return!0;if(Q.attribute!==ge)return!0;if(ge&&Q.data!==ge.data)return!0;P++}if(s.attributesNum!==P)return!0;if(s.index!==L)return!0;return!1}function m(C,D,ee,L){let W={},B=D.attributes,P=0,J=ee.getAttributes();for(let H in J)if(J[H].location>=0){let Q=B[H];if(Q===void 0){if(H==="instanceMatrix"&&C.instanceMatrix)Q=C.instanceMatrix;if(H==="instanceColor"&&C.instanceColor)Q=C.instanceColor}let ge={};if(ge.attribute=Q,Q&&Q.data)ge.data=Q.data;W[H]=ge,P++}s.attributes=W,s.attributesNum=P,s.index=L}function _(){let C=s.newAttributes;for(let D=0,ee=C.length;D<ee;D++)C[D]=0}function p(C){g(C,0)}function g(C,D){let ee=s.newAttributes,L=s.enabledAttributes,W=s.attributeDivisors;if(ee[C]=1,L[C]===0)e.enableVertexAttribArray(C),L[C]=1;if(W[C]!==D)e.vertexAttribDivisor(C,D),W[C]=D}function M(){let C=s.newAttributes,D=s.enabledAttributes;for(let ee=0,L=D.length;ee<L;ee++)if(D[ee]!==C[ee])e.disableVertexAttribArray(ee),D[ee]=0}function T(C,D,ee,L,W,B,P){if(P===!0)e.vertexAttribIPointer(C,D,ee,W,B);else e.vertexAttribPointer(C,D,ee,L,W,B)}function v(C,D,ee,L){_();let W=L.attributes,B=ee.getAttributes(),P=D.defaultAttributeValues;for(let J in B){let H=B[J];if(H.location>=0){let q=W[J];if(q===void 0){if(J==="instanceMatrix"&&C.instanceMatrix)q=C.instanceMatrix;if(J==="instanceColor"&&C.instanceColor)q=C.instanceColor}if(q!==void 0){let Q=q.normalized,ge=q.itemSize,he=t.get(q);if(he===void 0)continue;let{buffer:de,type:fe,bytesPerElement:I}=he,V=fe===e.INT||fe===e.UNSIGNED_INT||q.gpuType===wh;if(q.isInterleavedBufferAttribute){let j=q.data,re=j.stride,oe=q.offset;if(j.isInstancedInterleavedBuffer){for(let ue=0;ue<H.locationSize;ue++)g(H.location+ue,j.meshPerAttribute);if(C.isInstancedMesh!==!0&&L._maxInstanceCount===void 0)L._maxInstanceCount=j.meshPerAttribute*j.count}else for(let ue=0;ue<H.locationSize;ue++)p(H.location+ue);e.bindBuffer(e.ARRAY_BUFFER,de);for(let ue=0;ue<H.locationSize;ue++)T(H.location+ue,ge/H.locationSize,fe,Q,re*I,(oe+ge/H.locationSize*ue)*I,V)}else{if(q.isInstancedBufferAttribute){for(let j=0;j<H.locationSize;j++)g(H.location+j,q.meshPerAttribute);if(C.isInstancedMesh!==!0&&L._maxInstanceCount===void 0)L._maxInstanceCount=q.meshPerAttribute*q.count}else for(let j=0;j<H.locationSize;j++)p(H.location+j);e.bindBuffer(e.ARRAY_BUFFER,de);for(let j=0;j<H.locationSize;j++)T(H.location+j,ge/H.locationSize,fe,Q,ge*I,ge/H.locationSize*j*I,V)}}else if(P!==void 0){let Q=P[J];if(Q!==void 0)switch(Q.length){case 2:e.vertexAttrib2fv(H.location,Q);break;case 3:e.vertexAttrib3fv(H.location,Q);break;case 4:e.vertexAttrib4fv(H.location,Q);break;default:e.vertexAttrib1fv(H.location,Q)}}}}M()}function S(){w();for(let C in i){let D=i[C];for(let ee in D){let L=D[ee];for(let W in L){let B=L[W];for(let P in B)u(B[P].object),delete B[P];delete L[W]}}delete i[C]}}function E(C){if(i[C.id]===void 0)return;let D=i[C.id];for(let ee in D){let L=D[ee];for(let W in L){let B=L[W];for(let P in B)u(B[P].object),delete B[P];delete L[W]}}delete i[C.id]}function R(C){for(let D in i){let ee=i[D];for(let L in ee){let W=ee[L];if(W[C.id]===void 0)continue;let B=W[C.id];for(let P in B)u(B[P].object),delete B[P];delete W[C.id]}}}function x(C){for(let D in i){let ee=i[D],L=C.isInstancedMesh===!0?C.id:0,W=ee[L];if(W===void 0)continue;for(let B in W){let P=W[B];for(let J in P)u(P[J].object),delete P[J];delete W[B]}if(delete ee[L],Object.keys(ee).length===0)delete i[D]}}function w(){if(G(),o=!0,s===r)return;s=r,l(s.object)}function G(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:a,reset:w,resetDefaultState:G,dispose:S,releaseStatesOfGeometry:E,releaseStatesOfObject:x,releaseStatesOfProgram:R,initAttributes:_,enableAttribute:p,disableUnusedAttributes:M}}function o1(e,t,n){let i;function r(c){i=c}function s(c,l){e.drawArrays(i,c,l),n.update(l,i,1)}function o(c,l,u){if(u===0)return;e.drawArraysInstanced(i,c,l,u),n.update(l,i,u)}function a(c,l,u){if(u===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,c,0,l,0,u);let d=0;for(let f=0;f<u;f++)d+=l[f];n.update(d,i,1)}this.setMode=r,this.render=s,this.renderInstances=o,this.renderMultiDraw=a}function a1(e,t,n,i){let r;function s(){if(r!==void 0)return r;if(t.has("EXT_texture_filter_anisotropic")===!0){let R=t.get("EXT_texture_filter_anisotropic");r=e.getParameter(R.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function o(R){if(R!==Si&&i.convert(R)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT))return!1;return!0}function a(R){let x=R===bi&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));if(R!==ni&&R!==$i&&!x&&i.convert(R)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE))return!1;return!0}function c(R){if(R==="highp"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";R="mediump"}if(R==="mediump"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0)return"mediump"}return"lowp"}let l=n.precision!==void 0?n.precision:"highp",u=c(l);if(u!==l)Ue("WebGLRenderer:",l,"not supported, using",u,"instead."),l=u;let h=n.logarithmicDepthBuffer===!0,d=n.reversedDepthBuffer===!0&&t.has("EXT_clip_control");if(n.reversedDepthBuffer===!0&&d===!1)Ue("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");let f=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),m=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),_=e.getParameter(e.MAX_TEXTURE_SIZE),p=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),g=e.getParameter(e.MAX_VERTEX_ATTRIBS),M=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),T=e.getParameter(e.MAX_VARYING_VECTORS),v=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),S=e.getParameter(e.MAX_SAMPLES),E=e.getParameter(e.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:a,precision:l,logarithmicDepthBuffer:h,reversedDepthBuffer:d,maxTextures:f,maxVertexTextures:m,maxTextureSize:_,maxCubemapSize:p,maxAttributes:g,maxVertexUniforms:M,maxVaryings:T,maxFragmentUniforms:v,maxSamples:S,samples:E}}function c1(e){let t=this,n=null,i=0,r=!1,s=!1,o=new zn,a=new We,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(h,d){let f=h.length!==0||d||i!==0||r;return r=d,i=h.length,f},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(h,d){n=u(h,d,0)},this.setState=function(h,d,f){let{clippingPlanes:m,clipIntersection:_,clipShadows:p}=h,g=e.get(h);if(!r||m===null||m.length===0||s&&!p)if(s)u(null);else l();else{let M=s?0:i,T=M*4,v=g.clippingState||null;c.value=v,v=u(m,d,T,f);for(let S=0;S!==T;++S)v[S]=n[S];g.clippingState=v,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=M}};function l(){if(c.value!==n)c.value=n,c.needsUpdate=i>0;t.numPlanes=i,t.numIntersection=0}function u(h,d,f,m){let _=h!==null?h.length:0,p=null;if(_!==0){if(p=c.value,m!==!0||p===null){let g=f+_*4,M=d.matrixWorldInverse;if(a.getNormalMatrix(M),p===null||p.length<g)p=new Float32Array(g);for(let T=0,v=f;T!==_;++T,v+=4)o.copy(h[T]).applyMatrix4(M,a),o.normal.toArray(p,v),p[v+3]=o.constant}c.value=p,c.needsUpdate=!0}return t.numPlanes=_,t.numIntersection=0,p}}var Xs=4,l1=6,u1=20,h1=256,la=new es,Iv=new Ge,Nd=null,Dd=0,Od=0,Ud=!1,d1=new z,ts=new z;class fa{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,n=0.1,i=100,r={}){let{size:s=256,position:o=d1}=r;Nd=this._renderer.getRenderTarget(),Dd=this._renderer.getActiveCubeFace(),Od=this._renderer.getActiveMipmapLevel(),Ud=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(s);let a=this._allocateTargets();if(a.depthBuffer=!0,this._sceneToCubeUV(e,n,i,a,o),t>0)this._blur(a,0,0,t);return this._applyPMREM(a),this._cleanup(a),a}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){if(this._cubemapMaterial===null)this._cubemapMaterial=Nv(),this._compileMaterial(this._cubemapMaterial)}compileEquirectangularShader(){if(this._equirectMaterial===null)this._equirectMaterial=Lv(),this._compileMaterial(this._equirectMaterial)}dispose(){if(this._dispose(),this._cubemapMaterial!==null)this._cubemapMaterial.dispose();if(this._equirectMaterial!==null)this._equirectMaterial.dispose();if(this._backgroundBox!==null)this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){if(this._blurMaterial!==null)this._blurMaterial.dispose();if(this._ggxMaterial!==null)this._ggxMaterial.dispose();if(this._pingPongRenderTarget!==null)this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(Nd,Dd,Od),this._renderer.xr.enabled=Ud,e.scissorTest=!1,Zs(e,0,0,e.width,e.height)}_fromTexture(e,t){if(e.mapping===Ls||e.mapping===Wr)this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width);else this._setSize(e.image.width/4);Nd=this._renderer.getRenderTarget(),Dd=this._renderer.getActiveCubeFace(),Od=this._renderer.getActiveMipmapLevel(),Ud=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:Jt,minFilter:Jt,generateMipmaps:!1,type:bi,format:Si,colorSpace:Rn,depthBuffer:!1},i=Pv(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){if(this._pingPongRenderTarget!==null)this._dispose();this._pingPongRenderTarget=Pv(e,t,n);let{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods}=f1(r)),this._blurMaterial=m1(r,e,t),this._ggxMaterial=p1(r,e,t)}return i}_compileMaterial(e){let t=new Mt(new ln,e);this._renderer.compile(t,la)}_sceneToCubeUV(e,t,n,i,r){let a=new Ht(90,1,t,n),c=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],u=this._renderer,{autoClear:h,toneMapping:d}=u;if(u.getClearColor(Iv),u.toneMapping=ei,u.autoClear=!1,u.state.buffers.depth.getReversed())u.setRenderTarget(i),u.clearDepth(),u.setRenderTarget(null);if(this._backgroundBox===null)this._backgroundBox=new Mt(new vr,new wi({name:"PMREM.Background",side:cn,depthWrite:!1,depthTest:!1}));let m=this._backgroundBox,_=m.material,p=!1,g=e.background;if(g){if(g.isColor)_.color.copy(g),e.background=null,p=!0}else _.color.copy(Iv),p=!0;for(let M=0;M<6;M++){let T=M%3;if(T===0)a.up.set(0,c[M],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x+l[M],r.y,r.z);else if(T===1)a.up.set(0,0,c[M]),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y+l[M],r.z);else a.up.set(0,c[M],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y,r.z+l[M]);let v=this._cubeSize;if(Zs(i,T*v,M>2?v:0,v,v),u.setRenderTarget(i),p)u.render(m,a);u.render(e,a)}u.toneMapping=d,u.autoClear=h,e.background=g}_textureToCubeUV(e,t){let n=this._renderer,i=e.mapping===Ls||e.mapping===Wr;if(i){if(this._cubemapMaterial===null)this._cubemapMaterial=Nv();this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1}else if(this._equirectMaterial===null)this._equirectMaterial=Lv();let r=i?this._cubemapMaterial:this._equirectMaterial,s=this._lodMeshes[0];s.material=r;let o=r.uniforms;o.envMap.value=e;let a=this._cubeSize;Zs(t,0,0,3*a,2*a),n.setRenderTarget(t),n.render(s,la)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let i=this._lodMeshes.length;for(let r=1;r<i;r++)this._applyGGXFilter(e,r-1,r);t.autoClear=n}_applyGGXFilter(e,t,n){let i=this._renderer,r=this._pingPongRenderTarget,s=this._ggxMaterial,o=this._lodMeshes[n];o.material=s;let a=s.uniforms,c=n/(this._lodMeshes.length-1),l=t/(this._lodMeshes.length-1),u=Math.sqrt(c*c-l*l),h=c*1.25,d=u*h,{_lodMax:f}=this,m=this._sizeLods[n],_=3*m*(n>f-Xs?n-f+Xs:0),p=4*(this._cubeSize-m);a.envMap.value=e.texture,a.roughness.value=d,a.mipInt.value=f-t,Zs(r,_,p,3*m,2*m),i.setRenderTarget(r),i.render(o,la),a.envMap.value=r.texture,a.roughness.value=0,a.mipInt.value=f-n,Zs(e,_,p,3*m,2*m),i.setRenderTarget(e),i.render(o,la)}_blur(e,t,n,i){let r=this._pingPongRenderTarget,s=Math.min(i,Math.PI)/Math.SQRT2;this._blurPass(e,r,t,n,s),this._blurPass(r,e,n,n,s)}_blurPass(e,t,n,i,r){let s=this._renderer,o=this._blurMaterial,a=this._lodMeshes[i];a.material=o;let c=o.uniforms;c.envMap.value=e.texture,c.sigma.value=r,c.mipInt.value=this._lodMax-n;let l=this._sizeLods[i],u=3*l*(i>this._lodMax-Xs?i-this._lodMax+Xs:0),h=4*(this._cubeSize-l);Zs(t,u,h,3*l,2*l),s.setRenderTarget(t),s.render(a,la)}}function f1(e){let t=[],n=[],i=e,r=e-Xs+1+l1;for(let s=0;s<r;s++){let o=Math.pow(2,i);t.push(o);let a=1/(o-2),c=-a,l=1+a,u=[c,c,l,c,l,l,c,c,l,l,c,l],h=6,d=6,f=3,m=new Float32Array(f*d*h),_=new Float32Array(f*d*h);for(let g=0;g<h;g++){let M=g%3*2/3-1,T=g>2?0:-1,v=[M,T,0,M+0.6666666666666666,T,0,M+0.6666666666666666,T+1,0,M,T,0,M+0.6666666666666666,T+1,0,M,T+1,0];m.set(v,f*d*g);for(let S=0;S<d;S++){let E=u[S*2]*2-1,R=u[S*2+1]*2-1;if(g===0)ts.set(1,R,E);else if(g===1)ts.set(-E,1,-R);else if(g===2)ts.set(-E,R,1);else if(g===3)ts.set(-1,R,-E);else if(g===4)ts.set(-E,-1,R);else ts.set(E,R,-1);ts.toArray(_,(g*d+S)*f)}}let p=new ln;if(p.setAttribute("position",new Kt(m,f)),p.setAttribute("outputDirection",new Kt(_,f)),n.push(new Mt(p,null)),i>Xs)i--}return{lodMeshes:n,sizeLods:t}}function Pv(e,t,n){let i=new Cn(e,t,n);return i.texture.mapping=Wo,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Zs(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function p1(e,t,n){return new Gn({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:h1,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:gl(),fragmentShader:`
3885
3885
 
3886
3886
  precision highp float;
3887
3887
  precision highp int;
@@ -3985,7 +3985,7 @@ void main() {
3985
3985
 
3986
3986
  gl_FragColor = vec4(prefilteredColor, 1.0);
3987
3987
  }
3988
- `,blending:vi,depthTest:!1,depthWrite:!1})}function f1(e,t,n){return new Gn({name:"SphericalGaussianBlur",defines:{SAMPLES:c1,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},sigma:{value:0},mipInt:{value:0}},vertexShader:ml(),fragmentShader:`
3988
+ `,blending:vi,depthTest:!1,depthWrite:!1})}function m1(e,t,n){return new Gn({name:"SphericalGaussianBlur",defines:{SAMPLES:u1,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},sigma:{value:0},mipInt:{value:0}},vertexShader:gl(),fragmentShader:`
3989
3989
 
3990
3990
  precision highp float;
3991
3991
  precision highp int;
@@ -4045,7 +4045,7 @@ void main() {
4045
4045
  gl_FragColor = vec4( accumColor / accumWeight, 1.0 );
4046
4046
 
4047
4047
  }
4048
- `,blending:vi,depthTest:!1,depthWrite:!1})}function Pv(){return new Gn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:ml(),fragmentShader:`
4048
+ `,blending:vi,depthTest:!1,depthWrite:!1})}function Lv(){return new Gn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:gl(),fragmentShader:`
4049
4049
 
4050
4050
  precision mediump float;
4051
4051
  precision mediump int;
@@ -4064,7 +4064,7 @@ void main() {
4064
4064
  gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
4065
4065
 
4066
4066
  }
4067
- `,blending:vi,depthTest:!1,depthWrite:!1})}function Lv(){return new Gn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:ml(),fragmentShader:`
4067
+ `,blending:vi,depthTest:!1,depthWrite:!1})}function Nv(){return new Gn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:gl(),fragmentShader:`
4068
4068
 
4069
4069
  precision mediump float;
4070
4070
  precision mediump int;
@@ -4080,7 +4080,7 @@ void main() {
4080
4080
  gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
4081
4081
 
4082
4082
  }
4083
- `,blending:vi,depthTest:!1,depthWrite:!1})}function ml(){return`
4083
+ `,blending:vi,depthTest:!1,depthWrite:!1})}function gl(){return`
4084
4084
 
4085
4085
  precision mediump float;
4086
4086
  precision mediump int;
@@ -4095,7 +4095,7 @@ void main() {
4095
4095
  gl_Position = vec4( position, 1.0 );
4096
4096
 
4097
4097
  }
4098
- `}class Bd extends Cn{constructor(e=1,t={}){super(e,e,t);this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new tl(i),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:`
4098
+ `}class Gd extends Cn{constructor(e=1,t={}){super(e,e,t);this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new il(i),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:`
4099
4099
 
4100
4100
  varying vec3 vWorldDirection;
4101
4101
 
@@ -4130,7 +4130,7 @@ void main() {
4130
4130
  gl_FragColor = texture2D( tEquirect, sampleUV );
4131
4131
 
4132
4132
  }
4133
- `},i=new xr(5,5,5),r=new Gn({name:"CubemapFromEquirect",uniforms:Kr(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:cn,blending:vi});r.uniforms.tEquirect.value=t;let s=new Mt(i,r),o=t.minFilter;if(t.minFilter===yi)t.minFilter=Jt;return new Md(1,10,this).update(e,s),t.minFilter=o,s.geometry.dispose(),s.material.dispose(),this}clear(e,t=!0,n=!0,i=!0){let r=e.getRenderTarget();for(let s=0;s<6;s++)e.setRenderTarget(this,s),e.clear(t,n,i);e.setRenderTarget(r)}}function p1(e){let t=new WeakMap,n=new WeakMap,i=null;function r(d,f=!1){if(d===null||d===void 0)return null;if(f)return o(d);return s(d)}function s(d){if(d&&d.isTexture){let f=d.mapping;if(f===Oc||f===Uc)if(t.has(d)){let m=t.get(d).texture;return a(m,d.mapping)}else{let m=d.image;if(m&&m.height>0){let _=new Bd(m.height);return _.fromEquirectangularTexture(e,d),t.set(d,_),d.addEventListener("dispose",l),a(_.texture,d.mapping)}else return null}}return d}function o(d){if(d&&d.isTexture){let f=d.mapping,m=f===Oc||f===Uc,_=f===Ps||f===$r;if(m||_){let p=n.get(d),g=p!==void 0?p.texture.pmremVersion:0;if(d.isRenderTargetTexture&&d.pmremVersion!==g){if(i===null)i=new ua(e);return p=m?i.fromEquirectangular(d,p):i.fromCubemap(d,p),p.texture.pmremVersion=d.pmremVersion,n.set(d,p),p.texture}else if(p!==void 0)return p.texture;else{let M=d.image;if(m&&M&&M.height>0||_&&M&&c(M)){if(i===null)i=new ua(e);return p=m?i.fromEquirectangular(d):i.fromCubemap(d),p.texture.pmremVersion=d.pmremVersion,n.set(d,p),d.addEventListener("dispose",u),p.texture}else return null}}}return d}function a(d,f){if(f===Oc)d.mapping=Ps;else if(f===Uc)d.mapping=$r;return d}function c(d){let f=0,m=6;for(let _=0;_<m;_++)if(d[_]!==void 0)f++;return f===m}function l(d){let f=d.target;f.removeEventListener("dispose",l);let m=t.get(f);if(m!==void 0)t.delete(f),m.dispose()}function u(d){let f=d.target;f.removeEventListener("dispose",u);let m=n.get(f);if(m!==void 0)n.delete(f),m.dispose()}function h(){if(t=new WeakMap,n=new WeakMap,i!==null)i.dispose(),i=null}return{get:r,dispose:h}}function m1(e){let t={};function n(i){if(t[i]!==void 0)return t[i];let r=e.getExtension(i);return t[i]=r,r}return{has:function(i){return n(i)!==null},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(i){let r=n(i);if(r===null)Hr("WebGLRenderer: "+i+" extension not supported.");return r}}}function g1(e,t,n,i){let r={},s=new WeakMap;function o(h){let d=h.target;if(d.index!==null)t.remove(d.index);for(let m in d.attributes)t.remove(d.attributes[m]);d.removeEventListener("dispose",o),delete r[d.id];let f=s.get(d);if(f)t.remove(f),s.delete(d);if(i.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0)delete d._maxInstanceCount;n.memory.geometries--}function a(h,d){if(r[d.id]===!0)return d;return d.addEventListener("dispose",o),r[d.id]=!0,n.memory.geometries++,d}function c(h){let d=h.attributes;for(let f in d)t.update(d[f],e.ARRAY_BUFFER)}function l(h){let d=[],f=h.index,m=h.attributes.position,_=0;if(m===void 0)return;if(f!==null){let M=f.array;_=f.version;for(let T=0,v=M.length;T<v;T+=3){let S=M[T+0],E=M[T+1],R=M[T+2];d.push(S,E,E,R,R,S)}}else{let M=m.array;_=m.version;for(let T=0,v=M.length/3-1;T<v;T+=3){let S=T+0,E=T+1,R=T+2;d.push(S,E,E,R,R,S)}}let p=new(m.count>=65535?Kc:Yc)(d,1);p.version=_;let g=s.get(h);if(g)t.remove(g);s.set(h,p)}function u(h){let d=s.get(h);if(d){let f=h.index;if(f!==null){if(d.version<f.version)l(h)}}else l(h);return s.get(h)}return{get:a,update:c,getWireframeAttribute:u}}function _1(e,t,n){let i;function r(h){i=h}let s,o;function a(h){s=h.type,o=h.bytesPerElement}function c(h,d){e.drawElements(i,d,s,h*o),n.update(d,i,1)}function l(h,d,f){if(f===0)return;e.drawElementsInstanced(i,d,s,h*o,f),n.update(d,i,f)}function u(h,d,f){if(f===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,d,0,s,h,0,f);let _=0;for(let p=0;p<f;p++)_+=d[p];n.update(_,i,1)}this.setMode=r,this.setIndex=a,this.render=c,this.renderInstances=l,this.renderMultiDraw=u}function x1(e){let t={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function i(s,o,a){switch(n.calls++,o){case e.TRIANGLES:n.triangles+=a*(s/3);break;case e.LINES:n.lines+=a*(s/2);break;case e.LINE_STRIP:n.lines+=a*(s-1);break;case e.LINE_LOOP:n.lines+=a*s;break;case e.POINTS:n.points+=a*s;break;default:$e("WebGLInfo: Unknown draw mode:",o);break}}function r(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:t,render:n,programs:null,autoReset:!0,reset:r,update:i}}function v1(e,t,n){let i=new WeakMap,r=new pt;function s(o,a,c){let l=o.morphTargetInfluences,u=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,h=u!==void 0?u.length:0,d=i.get(a);if(d===void 0||d.count!==h){let w=function(){R.dispose(),i.delete(a),a.removeEventListener("dispose",w)};if(d!==void 0)d.texture.dispose();let f=a.morphAttributes.position!==void 0,m=a.morphAttributes.normal!==void 0,_=a.morphAttributes.color!==void 0,p=a.morphAttributes.position||[],g=a.morphAttributes.normal||[],M=a.morphAttributes.color||[],T=0;if(f===!0)T=1;if(m===!0)T=2;if(_===!0)T=3;let v=a.attributes.position.count*T,S=1;if(v>t.maxTextureSize)S=Math.ceil(v/t.maxTextureSize),v=t.maxTextureSize;let E=new Float32Array(v*S*4*h),R=new jc(E,v,S,h);R.type=Vi,R.needsUpdate=!0;let x=T*4;for(let H=0;H<h;H++){let C=p[H],N=g[H],ee=M[H],P=v*S*4*H;for(let Z=0;Z<C.count;Z++){let G=Z*x;if(f===!0)r.fromBufferAttribute(C,Z),E[P+G+0]=r.x,E[P+G+1]=r.y,E[P+G+2]=r.z,E[P+G+3]=0;if(m===!0)r.fromBufferAttribute(N,Z),E[P+G+4]=r.x,E[P+G+5]=r.y,E[P+G+6]=r.z,E[P+G+7]=0;if(_===!0)r.fromBufferAttribute(ee,Z),E[P+G+8]=r.x,E[P+G+9]=r.y,E[P+G+10]=r.z,E[P+G+11]=ee.itemSize===4?r.w:1}}d={count:h,texture:R,size:new Be(v,S)},i.set(a,d),a.addEventListener("dispose",w)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)c.getUniforms().setValue(e,"morphTexture",o.morphTexture,n);else{let f=0;for(let _=0;_<l.length;_++)f+=l[_];let m=a.morphTargetsRelative?1:1-f;c.getUniforms().setValue(e,"morphTargetBaseInfluence",m),c.getUniforms().setValue(e,"morphTargetInfluences",l)}c.getUniforms().setValue(e,"morphTargetsTexture",d.texture,n),c.getUniforms().setValue(e,"morphTargetsTextureSize",d.size)}return{update:s}}function y1(e,t,n,i,r){let s=new WeakMap;function o(l){let u=r.render.frame,h=l.geometry,d=t.get(l,h);if(s.get(d)!==u)t.update(d),s.set(d,u);if(l.isInstancedMesh){if(l.hasEventListener("dispose",c)===!1)l.addEventListener("dispose",c);if(s.get(l)!==u){if(n.update(l.instanceMatrix,e.ARRAY_BUFFER),l.instanceColor!==null)n.update(l.instanceColor,e.ARRAY_BUFFER);s.set(l,u)}}if(l.isSkinnedMesh){let f=l.skeleton;if(s.get(f)!==u)f.update(),s.set(f,u)}return d}function a(){s=new WeakMap}function c(l){let u=l.target;if(u.removeEventListener("dispose",c),i.releaseStatesOfObject(u),n.remove(u.instanceMatrix),u.instanceColor!==null)n.remove(u.instanceColor)}return{update:o,dispose:a}}var b1={[gh]:"LINEAR_TONE_MAPPING",[_h]:"REINHARD_TONE_MAPPING",[xh]:"CINEON_TONE_MAPPING",[Go]:"ACES_FILMIC_TONE_MAPPING",[yh]:"AGX_TONE_MAPPING",[bh]:"NEUTRAL_TONE_MAPPING",[vh]:"CUSTOM_TONE_MAPPING"};function S1(e,t,n,i,r,s){let o=new Cn(t,n,{type:e,depthBuffer:r,stencilBuffer:s,samples:i?4:0,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,resolveDepthBuffer:!1,resolveStencilBuffer:!1}),a=null,c=null,l=new ln;l.setAttribute("position",new vn([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new vn([0,2,0,0,2,0],2));let u=new gd({uniforms:{tDiffuse:{value:null}},vertexShader:`
4133
+ `},i=new vr(5,5,5),r=new Gn({name:"CubemapFromEquirect",uniforms:Jr(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:cn,blending:vi});r.uniforms.tEquirect.value=t;let s=new Mt(i,r),o=t.minFilter;if(t.minFilter===yi)t.minFilter=Jt;return new Ed(1,10,this).update(e,s),t.minFilter=o,s.geometry.dispose(),s.material.dispose(),this}clear(e,t=!0,n=!0,i=!0){let r=e.getRenderTarget();for(let s=0;s<6;s++)e.setRenderTarget(this,s),e.clear(t,n,i);e.setRenderTarget(r)}}function g1(e){let t=new WeakMap,n=new WeakMap,i=null;function r(d,f=!1){if(d===null||d===void 0)return null;if(f)return o(d);return s(d)}function s(d){if(d&&d.isTexture){let f=d.mapping;if(f===Fc||f===zc)if(t.has(d)){let m=t.get(d).texture;return a(m,d.mapping)}else{let m=d.image;if(m&&m.height>0){let _=new Gd(m.height);return _.fromEquirectangularTexture(e,d),t.set(d,_),d.addEventListener("dispose",l),a(_.texture,d.mapping)}else return null}}return d}function o(d){if(d&&d.isTexture){let f=d.mapping,m=f===Fc||f===zc,_=f===Ls||f===Wr;if(m||_){let p=n.get(d),g=p!==void 0?p.texture.pmremVersion:0;if(d.isRenderTargetTexture&&d.pmremVersion!==g){if(i===null)i=new fa(e);return p=m?i.fromEquirectangular(d,p):i.fromCubemap(d,p),p.texture.pmremVersion=d.pmremVersion,n.set(d,p),p.texture}else if(p!==void 0)return p.texture;else{let M=d.image;if(m&&M&&M.height>0||_&&M&&c(M)){if(i===null)i=new fa(e);return p=m?i.fromEquirectangular(d):i.fromCubemap(d),p.texture.pmremVersion=d.pmremVersion,n.set(d,p),d.addEventListener("dispose",u),p.texture}else return null}}}return d}function a(d,f){if(f===Fc)d.mapping=Ls;else if(f===zc)d.mapping=Wr;return d}function c(d){let f=0,m=6;for(let _=0;_<m;_++)if(d[_]!==void 0)f++;return f===m}function l(d){let f=d.target;f.removeEventListener("dispose",l);let m=t.get(f);if(m!==void 0)t.delete(f),m.dispose()}function u(d){let f=d.target;f.removeEventListener("dispose",u);let m=n.get(f);if(m!==void 0)n.delete(f),m.dispose()}function h(){if(t=new WeakMap,n=new WeakMap,i!==null)i.dispose(),i=null}return{get:r,dispose:h}}function _1(e){let t={};function n(i){if(t[i]!==void 0)return t[i];let r=e.getExtension(i);return t[i]=r,r}return{has:function(i){return n(i)!==null},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(i){let r=n(i);if(r===null)Vr("WebGLRenderer: "+i+" extension not supported.");return r}}}function x1(e,t,n,i){let r={},s=new WeakMap;function o(h){let d=h.target;if(d.index!==null)t.remove(d.index);for(let m in d.attributes)t.remove(d.attributes[m]);d.removeEventListener("dispose",o),delete r[d.id];let f=s.get(d);if(f)t.remove(f),s.delete(d);if(i.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0)delete d._maxInstanceCount;n.memory.geometries--}function a(h,d){if(r[d.id]===!0)return d;return d.addEventListener("dispose",o),r[d.id]=!0,n.memory.geometries++,d}function c(h){let d=h.attributes;for(let f in d)t.update(d[f],e.ARRAY_BUFFER)}function l(h){let d=[],f=h.index,m=h.attributes.position,_=0;if(m===void 0)return;if(f!==null){let M=f.array;_=f.version;for(let T=0,v=M.length;T<v;T+=3){let S=M[T+0],E=M[T+1],R=M[T+2];d.push(S,E,E,R,R,S)}}else{let M=m.array;_=m.version;for(let T=0,v=M.length/3-1;T<v;T+=3){let S=T+0,E=T+1,R=T+2;d.push(S,E,E,R,R,S)}}let p=new(m.count>=65535?Qc:Jc)(d,1);p.version=_;let g=s.get(h);if(g)t.remove(g);s.set(h,p)}function u(h){let d=s.get(h);if(d){let f=h.index;if(f!==null){if(d.version<f.version)l(h)}}else l(h);return s.get(h)}return{get:a,update:c,getWireframeAttribute:u}}function v1(e,t,n){let i;function r(h){i=h}let s,o;function a(h){s=h.type,o=h.bytesPerElement}function c(h,d){e.drawElements(i,d,s,h*o),n.update(d,i,1)}function l(h,d,f){if(f===0)return;e.drawElementsInstanced(i,d,s,h*o,f),n.update(d,i,f)}function u(h,d,f){if(f===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,d,0,s,h,0,f);let _=0;for(let p=0;p<f;p++)_+=d[p];n.update(_,i,1)}this.setMode=r,this.setIndex=a,this.render=c,this.renderInstances=l,this.renderMultiDraw=u}function y1(e){let t={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function i(s,o,a){switch(n.calls++,o){case e.TRIANGLES:n.triangles+=a*(s/3);break;case e.LINES:n.lines+=a*(s/2);break;case e.LINE_STRIP:n.lines+=a*(s-1);break;case e.LINE_LOOP:n.lines+=a*s;break;case e.POINTS:n.points+=a*s;break;default:Ve("WebGLInfo: Unknown draw mode:",o);break}}function r(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:t,render:n,programs:null,autoReset:!0,reset:r,update:i}}function b1(e,t,n){let i=new WeakMap,r=new pt;function s(o,a,c){let l=o.morphTargetInfluences,u=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,h=u!==void 0?u.length:0,d=i.get(a);if(d===void 0||d.count!==h){let w=function(){R.dispose(),i.delete(a),a.removeEventListener("dispose",w)};if(d!==void 0)d.texture.dispose();let f=a.morphAttributes.position!==void 0,m=a.morphAttributes.normal!==void 0,_=a.morphAttributes.color!==void 0,p=a.morphAttributes.position||[],g=a.morphAttributes.normal||[],M=a.morphAttributes.color||[],T=0;if(f===!0)T=1;if(m===!0)T=2;if(_===!0)T=3;let v=a.attributes.position.count*T,S=1;if(v>t.maxTextureSize)S=Math.ceil(v/t.maxTextureSize),v=t.maxTextureSize;let E=new Float32Array(v*S*4*h),R=new Yc(E,v,S,h);R.type=$i,R.needsUpdate=!0;let x=T*4;for(let G=0;G<h;G++){let C=p[G],D=g[G],ee=M[G],L=v*S*4*G;for(let W=0;W<C.count;W++){let B=W*x;if(f===!0)r.fromBufferAttribute(C,W),E[L+B+0]=r.x,E[L+B+1]=r.y,E[L+B+2]=r.z,E[L+B+3]=0;if(m===!0)r.fromBufferAttribute(D,W),E[L+B+4]=r.x,E[L+B+5]=r.y,E[L+B+6]=r.z,E[L+B+7]=0;if(_===!0)r.fromBufferAttribute(ee,W),E[L+B+8]=r.x,E[L+B+9]=r.y,E[L+B+10]=r.z,E[L+B+11]=ee.itemSize===4?r.w:1}}d={count:h,texture:R,size:new ke(v,S)},i.set(a,d),a.addEventListener("dispose",w)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)c.getUniforms().setValue(e,"morphTexture",o.morphTexture,n);else{let f=0;for(let _=0;_<l.length;_++)f+=l[_];let m=a.morphTargetsRelative?1:1-f;c.getUniforms().setValue(e,"morphTargetBaseInfluence",m),c.getUniforms().setValue(e,"morphTargetInfluences",l)}c.getUniforms().setValue(e,"morphTargetsTexture",d.texture,n),c.getUniforms().setValue(e,"morphTargetsTextureSize",d.size)}return{update:s}}function S1(e,t,n,i,r){let s=new WeakMap;function o(l){let u=r.render.frame,h=l.geometry,d=t.get(l,h);if(s.get(d)!==u)t.update(d),s.set(d,u);if(l.isInstancedMesh){if(l.hasEventListener("dispose",c)===!1)l.addEventListener("dispose",c);if(s.get(l)!==u){if(n.update(l.instanceMatrix,e.ARRAY_BUFFER),l.instanceColor!==null)n.update(l.instanceColor,e.ARRAY_BUFFER);s.set(l,u)}}if(l.isSkinnedMesh){let f=l.skeleton;if(s.get(f)!==u)f.update(),s.set(f,u)}return d}function a(){s=new WeakMap}function c(l){let u=l.target;if(u.removeEventListener("dispose",c),i.releaseStatesOfObject(u),n.remove(u.instanceMatrix),u.instanceColor!==null)n.remove(u.instanceColor)}return{update:o,dispose:a}}var w1={[_h]:"LINEAR_TONE_MAPPING",[xh]:"REINHARD_TONE_MAPPING",[vh]:"CINEON_TONE_MAPPING",[$o]:"ACES_FILMIC_TONE_MAPPING",[bh]:"AGX_TONE_MAPPING",[Sh]:"NEUTRAL_TONE_MAPPING",[yh]:"CUSTOM_TONE_MAPPING"};function M1(e,t,n,i,r,s){let o=new Cn(t,n,{type:e,depthBuffer:r,stencilBuffer:s,samples:i?4:0,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,resolveDepthBuffer:!1,resolveStencilBuffer:!1}),a=null,c=null,l=new ln;l.setAttribute("position",new vn([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new vn([0,2,0,0,2,0],2));let u=new _d({uniforms:{tDiffuse:{value:null}},vertexShader:`
4134
4134
  precision highp float;
4135
4135
 
4136
4136
  uniform mat4 modelViewMatrix;
@@ -4176,17 +4176,17 @@ void main() {
4176
4176
  #ifdef SRGB_TRANSFER
4177
4177
  gl_FragColor = sRGBTransferOETF( gl_FragColor );
4178
4178
  #endif
4179
- }`,depthTest:!1,depthWrite:!1}),h=new Mt(l,u),d=new Qr(-1,1,1,-1,0,1),f=null,m=null,_=!1,p,g=null,M=[],T=!1;this.setSize=function(v,S){if(o.setSize(v,S),a!==null)a.setSize(v,S);if(c!==null)c.setSize(v,S);for(let E=0;E<M.length;E++){let R=M[E];if(R.setSize)R.setSize(v,S)}},this.setEffects=function(v){M=v,T=M.length>0&&M[0].isRenderPass===!0;let{width:S,height:E}=o;if(M.length>0&&a===null)a=new Cn(S,E,{type:bi,depthBuffer:!1,stencilBuffer:!1}),c=new Cn(S,E,{type:bi,depthBuffer:!1,stencilBuffer:!1});for(let R=0;R<M.length;R++){let x=M[R];if(x.setSize)x.setSize(S,E)}},this.begin=function(v,S){if(_)return!1;if(v.toneMapping===ei&&M.length===0)return!1;if(g=S,S!==null){let{width:E,height:R}=S;if(o.width!==E||o.height!==R)this.setSize(E,R)}if(T===!1)v.setRenderTarget(o);return p=v.toneMapping,v.toneMapping=ei,!0},this.hasRenderPass=function(){return T},this.end=function(v,S){v.toneMapping=p,_=!0;let E=o,R=a;for(let x=0;x<M.length;x++){let w=M[x];if(w.enabled===!1)continue;if(w.render(v,R,E,S),w.needsSwap!==!1)E=R,R=R===a?c:a}if(f!==v.outputColorSpace||m!==v.toneMapping){if(f=v.outputColorSpace,m=v.toneMapping,u.defines={},Ke.getTransfer(f)===yt)u.defines.SRGB_TRANSFER="";let x=b1[m];if(x)u.defines[x]="";u.needsUpdate=!0}u.uniforms.tDiffuse.value=E.texture,v.setRenderTarget(g),v.render(h,d),g=null,_=!1},this.isCompositing=function(){return _},this.dispose=function(){if(o.dispose(),a!==null)a.dispose();if(c!==null)c.dispose();l.dispose(),u.dispose()}}var Jv=new Ot,zd=new Yr(1,1),Qv=new jc,ey=new fd,ty=new tl,Nv=[],Dv=[],Ov=new Float32Array(16),Uv=new Float32Array(9),Fv=new Float32Array(4);function Zs(e,t,n){let i=e[0];if(i<=0||i>0)return e;let r=t*n,s=Nv[r];if(s===void 0)s=new Float32Array(r),Nv[r]=s;if(t!==0){i.toArray(s,0);for(let o=1,a=0;o!==t;++o)a+=n,e[o].toArray(s,a)}return s}function $t(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n<i;n++)if(e[n]!==t[n])return!1;return!0}function Wt(e,t){for(let n=0,i=t.length;n<i;n++)e[n]=t[n]}function gl(e,t){let n=Dv[t];if(n===void 0)n=new Int32Array(t),Dv[t]=n;for(let i=0;i!==t;++i)n[i]=e.allocateTextureUnit();return n}function w1(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1f(this.addr,t),n[0]=t}function M1(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2f(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if($t(n,t))return;e.uniform2fv(this.addr,t),Wt(n,t)}}function E1(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3f(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else if(t.r!==void 0){if(n[0]!==t.r||n[1]!==t.g||n[2]!==t.b)e.uniform3f(this.addr,t.r,t.g,t.b),n[0]=t.r,n[1]=t.g,n[2]=t.b}else{if($t(n,t))return;e.uniform3fv(this.addr,t),Wt(n,t)}}function T1(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4f(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if($t(n,t))return;e.uniform4fv(this.addr,t),Wt(n,t)}}function A1(e,t){let n=this.cache,i=t.elements;if(i===void 0){if($t(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),Wt(n,t)}else{if($t(n,i))return;Fv.set(i),e.uniformMatrix2fv(this.addr,!1,Fv),Wt(n,i)}}function R1(e,t){let n=this.cache,i=t.elements;if(i===void 0){if($t(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),Wt(n,t)}else{if($t(n,i))return;Uv.set(i),e.uniformMatrix3fv(this.addr,!1,Uv),Wt(n,i)}}function C1(e,t){let n=this.cache,i=t.elements;if(i===void 0){if($t(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),Wt(n,t)}else{if($t(n,i))return;Ov.set(i),e.uniformMatrix4fv(this.addr,!1,Ov),Wt(n,i)}}function I1(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1i(this.addr,t),n[0]=t}function P1(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2i(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if($t(n,t))return;e.uniform2iv(this.addr,t),Wt(n,t)}}function L1(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3i(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else{if($t(n,t))return;e.uniform3iv(this.addr,t),Wt(n,t)}}function N1(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4i(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if($t(n,t))return;e.uniform4iv(this.addr,t),Wt(n,t)}}function D1(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1ui(this.addr,t),n[0]=t}function O1(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2ui(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if($t(n,t))return;e.uniform2uiv(this.addr,t),Wt(n,t)}}function U1(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3ui(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else{if($t(n,t))return;e.uniform3uiv(this.addr,t),Wt(n,t)}}function F1(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4ui(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if($t(n,t))return;e.uniform4uiv(this.addr,t),Wt(n,t)}}function z1(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;let s;if(this.type===e.SAMPLER_2D_SHADOW)zd.compareFunction=n.isReversedDepthBuffer()?Xc:Zc,s=zd;else s=Jv;n.setTexture2D(t||s,r)}function k1(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;n.setTexture3D(t||ey,r)}function B1(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;n.setTextureCube(t||ty,r)}function G1(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;n.setTexture2DArray(t||Qv,r)}function H1(e){switch(e){case 5126:return w1;case 35664:return M1;case 35665:return E1;case 35666:return T1;case 35674:return A1;case 35675:return R1;case 35676:return C1;case 5124:case 35670:return I1;case 35667:case 35671:return P1;case 35668:case 35672:return L1;case 35669:case 35673:return N1;case 5125:return D1;case 36294:return O1;case 36295:return U1;case 36296:return F1;case 35678:case 36198:case 36298:case 36306:case 35682:return z1;case 35679:case 36299:case 36307:return k1;case 35680:case 36300:case 36308:case 36293:return B1;case 36289:case 36303:case 36311:case 36292:return G1}}function V1(e,t){e.uniform1fv(this.addr,t)}function $1(e,t){let n=Zs(t,this.size,2);e.uniform2fv(this.addr,n)}function W1(e,t){let n=Zs(t,this.size,3);e.uniform3fv(this.addr,n)}function Z1(e,t){let n=Zs(t,this.size,4);e.uniform4fv(this.addr,n)}function X1(e,t){let n=Zs(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function j1(e,t){let n=Zs(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function q1(e,t){let n=Zs(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function Y1(e,t){e.uniform1iv(this.addr,t)}function K1(e,t){e.uniform2iv(this.addr,t)}function J1(e,t){e.uniform3iv(this.addr,t)}function Q1(e,t){e.uniform4iv(this.addr,t)}function eR(e,t){e.uniform1uiv(this.addr,t)}function tR(e,t){e.uniform2uiv(this.addr,t)}function nR(e,t){e.uniform3uiv(this.addr,t)}function iR(e,t){e.uniform4uiv(this.addr,t)}function rR(e,t,n){let i=this.cache,r=t.length,s=gl(n,r);if(!$t(i,s))e.uniform1iv(this.addr,s),Wt(i,s);let o;if(this.type===e.SAMPLER_2D_SHADOW)o=zd;else o=Jv;for(let a=0;a!==r;++a)n.setTexture2D(t[a]||o,s[a])}function sR(e,t,n){let i=this.cache,r=t.length,s=gl(n,r);if(!$t(i,s))e.uniform1iv(this.addr,s),Wt(i,s);for(let o=0;o!==r;++o)n.setTexture3D(t[o]||ey,s[o])}function oR(e,t,n){let i=this.cache,r=t.length,s=gl(n,r);if(!$t(i,s))e.uniform1iv(this.addr,s),Wt(i,s);for(let o=0;o!==r;++o)n.setTextureCube(t[o]||ty,s[o])}function aR(e,t,n){let i=this.cache,r=t.length,s=gl(n,r);if(!$t(i,s))e.uniform1iv(this.addr,s),Wt(i,s);for(let o=0;o!==r;++o)n.setTexture2DArray(t[o]||Qv,s[o])}function cR(e){switch(e){case 5126:return V1;case 35664:return $1;case 35665:return W1;case 35666:return Z1;case 35674:return X1;case 35675:return j1;case 35676:return q1;case 5124:case 35670:return Y1;case 35667:case 35671:return K1;case 35668:case 35672:return J1;case 35669:case 35673:return Q1;case 5125:return eR;case 36294:return tR;case 36295:return nR;case 36296:return iR;case 35678:case 36198:case 36298:case 36306:case 35682:return rR;case 35679:case 36299:case 36307:return sR;case 35680:case 36300:case 36308:case 36293:return oR;case 36289:case 36303:case 36311:case 36292:return aR}}class ny{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=H1(t.type)}}class iy{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=cR(t.type)}}class ry{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){let i=this.seq;for(let r=0,s=i.length;r!==s;++r){let o=i[r];o.setValue(e,t[o.id],n)}}}var Ud=/(\w+)(\])?(\[|\.)?/g;function zv(e,t){e.seq.push(t),e.map[t.id]=t}function lR(e,t,n){let i=e.name,r=i.length;Ud.lastIndex=0;while(!0){let s=Ud.exec(i),o=Ud.lastIndex,a=s[1],c=s[2]==="]",l=s[3];if(c)a=a|0;if(l===void 0||l==="["&&o+2===r){zv(n,l===void 0?new ny(a,e,t):new iy(a,e,t));break}else{let h=n.map[a];if(h===void 0)h=new ry(a),zv(n,h);n=h}}}class la{constructor(e,t){this.seq=[],this.map={};let n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let s=0;s<n;++s){let o=e.getActiveUniform(t,s),a=e.getUniformLocation(t,o.name);lR(o,a,this)}let i=[],r=[];for(let s of this.seq)if(s.type===e.SAMPLER_2D_SHADOW||s.type===e.SAMPLER_CUBE_SHADOW||s.type===e.SAMPLER_2D_ARRAY_SHADOW)i.push(s);else r.push(s);if(i.length>0)this.seq=i.concat(r)}setValue(e,t,n,i){let r=this.map[t];if(r!==void 0)r.setValue(e,n,i)}setOptional(e,t,n){let i=t[n];if(i!==void 0)this.setValue(e,n,i)}static upload(e,t,n,i){for(let r=0,s=t.length;r!==s;++r){let o=t[r],a=n[o.id];if(a.needsUpdate!==!1)o.setValue(e,a.value,i)}}static seqWithValue(e,t){let n=[];for(let i=0,r=e.length;i!==r;++i){let s=e[i];if(s.id in t)n.push(s)}return n}}function kv(e,t,n){let i=e.createShader(t);return e.shaderSource(i,n),e.compileShader(i),i}var uR=37297,hR=0;function dR(e,t){let n=e.split(`
4179
+ }`,depthTest:!1,depthWrite:!1}),h=new Mt(l,u),d=new es(-1,1,1,-1,0,1),f=null,m=null,_=!1,p,g=null,M=[],T=!1;this.setSize=function(v,S){if(o.setSize(v,S),a!==null)a.setSize(v,S);if(c!==null)c.setSize(v,S);for(let E=0;E<M.length;E++){let R=M[E];if(R.setSize)R.setSize(v,S)}},this.setEffects=function(v){M=v,T=M.length>0&&M[0].isRenderPass===!0;let{width:S,height:E}=o;if(M.length>0&&a===null)a=new Cn(S,E,{type:bi,depthBuffer:!1,stencilBuffer:!1}),c=new Cn(S,E,{type:bi,depthBuffer:!1,stencilBuffer:!1});for(let R=0;R<M.length;R++){let x=M[R];if(x.setSize)x.setSize(S,E)}},this.begin=function(v,S){if(_)return!1;if(v.toneMapping===ei&&M.length===0)return!1;if(g=S,S!==null){let{width:E,height:R}=S;if(o.width!==E||o.height!==R)this.setSize(E,R)}if(T===!1)v.setRenderTarget(o);return p=v.toneMapping,v.toneMapping=ei,!0},this.hasRenderPass=function(){return T},this.end=function(v,S){v.toneMapping=p,_=!0;let E=o,R=a;for(let x=0;x<M.length;x++){let w=M[x];if(w.enabled===!1)continue;if(w.render(v,R,E,S),w.needsSwap!==!1)E=R,R=R===a?c:a}if(f!==v.outputColorSpace||m!==v.toneMapping){if(f=v.outputColorSpace,m=v.toneMapping,u.defines={},Ke.getTransfer(f)===yt)u.defines.SRGB_TRANSFER="";let x=w1[m];if(x)u.defines[x]="";u.needsUpdate=!0}u.uniforms.tDiffuse.value=E.texture,v.setRenderTarget(g),v.render(h,d),g=null,_=!1},this.isCompositing=function(){return _},this.dispose=function(){if(o.dispose(),a!==null)a.dispose();if(c!==null)c.dispose();l.dispose(),u.dispose()}}var Qv=new Ot,kd=new Kr(1,1),ey=new Yc,ty=new pd,ny=new il,Dv=[],Ov=[],Uv=new Float32Array(16),Fv=new Float32Array(9),zv=new Float32Array(4);function js(e,t,n){let i=e[0];if(i<=0||i>0)return e;let r=t*n,s=Dv[r];if(s===void 0)s=new Float32Array(r),Dv[r]=s;if(t!==0){i.toArray(s,0);for(let o=1,a=0;o!==t;++o)a+=n,e[o].toArray(s,a)}return s}function $t(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n<i;n++)if(e[n]!==t[n])return!1;return!0}function Wt(e,t){for(let n=0,i=t.length;n<i;n++)e[n]=t[n]}function _l(e,t){let n=Ov[t];if(n===void 0)n=new Int32Array(t),Ov[t]=n;for(let i=0;i!==t;++i)n[i]=e.allocateTextureUnit();return n}function E1(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1f(this.addr,t),n[0]=t}function T1(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2f(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if($t(n,t))return;e.uniform2fv(this.addr,t),Wt(n,t)}}function A1(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3f(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else if(t.r!==void 0){if(n[0]!==t.r||n[1]!==t.g||n[2]!==t.b)e.uniform3f(this.addr,t.r,t.g,t.b),n[0]=t.r,n[1]=t.g,n[2]=t.b}else{if($t(n,t))return;e.uniform3fv(this.addr,t),Wt(n,t)}}function R1(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4f(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if($t(n,t))return;e.uniform4fv(this.addr,t),Wt(n,t)}}function C1(e,t){let n=this.cache,i=t.elements;if(i===void 0){if($t(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),Wt(n,t)}else{if($t(n,i))return;zv.set(i),e.uniformMatrix2fv(this.addr,!1,zv),Wt(n,i)}}function I1(e,t){let n=this.cache,i=t.elements;if(i===void 0){if($t(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),Wt(n,t)}else{if($t(n,i))return;Fv.set(i),e.uniformMatrix3fv(this.addr,!1,Fv),Wt(n,i)}}function P1(e,t){let n=this.cache,i=t.elements;if(i===void 0){if($t(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),Wt(n,t)}else{if($t(n,i))return;Uv.set(i),e.uniformMatrix4fv(this.addr,!1,Uv),Wt(n,i)}}function L1(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1i(this.addr,t),n[0]=t}function N1(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2i(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if($t(n,t))return;e.uniform2iv(this.addr,t),Wt(n,t)}}function D1(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3i(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else{if($t(n,t))return;e.uniform3iv(this.addr,t),Wt(n,t)}}function O1(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4i(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if($t(n,t))return;e.uniform4iv(this.addr,t),Wt(n,t)}}function U1(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1ui(this.addr,t),n[0]=t}function F1(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2ui(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if($t(n,t))return;e.uniform2uiv(this.addr,t),Wt(n,t)}}function z1(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3ui(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else{if($t(n,t))return;e.uniform3uiv(this.addr,t),Wt(n,t)}}function k1(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4ui(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if($t(n,t))return;e.uniform4uiv(this.addr,t),Wt(n,t)}}function B1(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;let s;if(this.type===e.SAMPLER_2D_SHADOW)kd.compareFunction=n.isReversedDepthBuffer()?qc:jc,s=kd;else s=Qv;n.setTexture2D(t||s,r)}function G1(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;n.setTexture3D(t||ty,r)}function H1(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;n.setTextureCube(t||ny,r)}function V1(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;n.setTexture2DArray(t||ey,r)}function $1(e){switch(e){case 5126:return E1;case 35664:return T1;case 35665:return A1;case 35666:return R1;case 35674:return C1;case 35675:return I1;case 35676:return P1;case 5124:case 35670:return L1;case 35667:case 35671:return N1;case 35668:case 35672:return D1;case 35669:case 35673:return O1;case 5125:return U1;case 36294:return F1;case 36295:return z1;case 36296:return k1;case 35678:case 36198:case 36298:case 36306:case 35682:return B1;case 35679:case 36299:case 36307:return G1;case 35680:case 36300:case 36308:case 36293:return H1;case 36289:case 36303:case 36311:case 36292:return V1}}function W1(e,t){e.uniform1fv(this.addr,t)}function Z1(e,t){let n=js(t,this.size,2);e.uniform2fv(this.addr,n)}function X1(e,t){let n=js(t,this.size,3);e.uniform3fv(this.addr,n)}function j1(e,t){let n=js(t,this.size,4);e.uniform4fv(this.addr,n)}function q1(e,t){let n=js(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function Y1(e,t){let n=js(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function K1(e,t){let n=js(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function J1(e,t){e.uniform1iv(this.addr,t)}function Q1(e,t){e.uniform2iv(this.addr,t)}function eR(e,t){e.uniform3iv(this.addr,t)}function tR(e,t){e.uniform4iv(this.addr,t)}function nR(e,t){e.uniform1uiv(this.addr,t)}function iR(e,t){e.uniform2uiv(this.addr,t)}function rR(e,t){e.uniform3uiv(this.addr,t)}function sR(e,t){e.uniform4uiv(this.addr,t)}function oR(e,t,n){let i=this.cache,r=t.length,s=_l(n,r);if(!$t(i,s))e.uniform1iv(this.addr,s),Wt(i,s);let o;if(this.type===e.SAMPLER_2D_SHADOW)o=kd;else o=Qv;for(let a=0;a!==r;++a)n.setTexture2D(t[a]||o,s[a])}function aR(e,t,n){let i=this.cache,r=t.length,s=_l(n,r);if(!$t(i,s))e.uniform1iv(this.addr,s),Wt(i,s);for(let o=0;o!==r;++o)n.setTexture3D(t[o]||ty,s[o])}function cR(e,t,n){let i=this.cache,r=t.length,s=_l(n,r);if(!$t(i,s))e.uniform1iv(this.addr,s),Wt(i,s);for(let o=0;o!==r;++o)n.setTextureCube(t[o]||ny,s[o])}function lR(e,t,n){let i=this.cache,r=t.length,s=_l(n,r);if(!$t(i,s))e.uniform1iv(this.addr,s),Wt(i,s);for(let o=0;o!==r;++o)n.setTexture2DArray(t[o]||ey,s[o])}function uR(e){switch(e){case 5126:return W1;case 35664:return Z1;case 35665:return X1;case 35666:return j1;case 35674:return q1;case 35675:return Y1;case 35676:return K1;case 5124:case 35670:return J1;case 35667:case 35671:return Q1;case 35668:case 35672:return eR;case 35669:case 35673:return tR;case 5125:return nR;case 36294:return iR;case 36295:return rR;case 36296:return sR;case 35678:case 36198:case 36298:case 36306:case 35682:return oR;case 35679:case 36299:case 36307:return aR;case 35680:case 36300:case 36308:case 36293:return cR;case 36289:case 36303:case 36311:case 36292:return lR}}class iy{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=$1(t.type)}}class ry{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=uR(t.type)}}class sy{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){let i=this.seq;for(let r=0,s=i.length;r!==s;++r){let o=i[r];o.setValue(e,t[o.id],n)}}}var Fd=/(\w+)(\])?(\[|\.)?/g;function kv(e,t){e.seq.push(t),e.map[t.id]=t}function hR(e,t,n){let i=e.name,r=i.length;Fd.lastIndex=0;while(!0){let s=Fd.exec(i),o=Fd.lastIndex,a=s[1],c=s[2]==="]",l=s[3];if(c)a=a|0;if(l===void 0||l==="["&&o+2===r){kv(n,l===void 0?new iy(a,e,t):new ry(a,e,t));break}else{let h=n.map[a];if(h===void 0)h=new sy(a),kv(n,h);n=h}}}class da{constructor(e,t){this.seq=[],this.map={};let n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let s=0;s<n;++s){let o=e.getActiveUniform(t,s),a=e.getUniformLocation(t,o.name);hR(o,a,this)}let i=[],r=[];for(let s of this.seq)if(s.type===e.SAMPLER_2D_SHADOW||s.type===e.SAMPLER_CUBE_SHADOW||s.type===e.SAMPLER_2D_ARRAY_SHADOW)i.push(s);else r.push(s);if(i.length>0)this.seq=i.concat(r)}setValue(e,t,n,i){let r=this.map[t];if(r!==void 0)r.setValue(e,n,i)}setOptional(e,t,n){let i=t[n];if(i!==void 0)this.setValue(e,n,i)}static upload(e,t,n,i){for(let r=0,s=t.length;r!==s;++r){let o=t[r],a=n[o.id];if(a.needsUpdate!==!1)o.setValue(e,a.value,i)}}static seqWithValue(e,t){let n=[];for(let i=0,r=e.length;i!==r;++i){let s=e[i];if(s.id in t)n.push(s)}return n}}function Bv(e,t,n){let i=e.createShader(t);return e.shaderSource(i,n),e.compileShader(i),i}var dR=37297,fR=0;function pR(e,t){let n=e.split(`
4180
4180
  `),i=[],r=Math.max(t-6,0),s=Math.min(t+6,n.length);for(let o=r;o<s;o++){let a=o+1;i.push(`${a===t?">":" "} ${a}: ${n[o]}`)}return i.join(`
4181
- `)}var Bv=new We;function fR(e){Ke._getMatrix(Bv,Ke.workingColorSpace,e);let t=`mat3( ${Bv.elements.map((n)=>n.toFixed(4))} )`;switch(Ke.getTransfer(e)){case ad:return[t,"LinearTransferOETF"];case yt:return[t,"sRGBTransferOETF"];default:return Ue("WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}function Gv(e,t,n){let i=e.getShaderParameter(t,e.COMPILE_STATUS),s=(e.getShaderInfoLog(t)||"").trim();if(i&&s==="")return"";let o=/ERROR: 0:(\d+)/.exec(s);if(o){let a=parseInt(o[1]);return n.toUpperCase()+`
4181
+ `)}var Gv=new We;function mR(e){Ke._getMatrix(Gv,Ke.workingColorSpace,e);let t=`mat3( ${Gv.elements.map((n)=>n.toFixed(4))} )`;switch(Ke.getTransfer(e)){case cd:return[t,"LinearTransferOETF"];case yt:return[t,"sRGBTransferOETF"];default:return Ue("WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}function Hv(e,t,n){let i=e.getShaderParameter(t,e.COMPILE_STATUS),s=(e.getShaderInfoLog(t)||"").trim();if(i&&s==="")return"";let o=/ERROR: 0:(\d+)/.exec(s);if(o){let a=parseInt(o[1]);return n.toUpperCase()+`
4182
4182
 
4183
4183
  `+s+`
4184
4184
 
4185
- `+dR(e.getShaderSource(t),a)}else return s}function pR(e,t){let n=fR(t);return[`vec4 ${e}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
4186
- `)}var mR={[gh]:"Linear",[_h]:"Reinhard",[xh]:"Cineon",[Go]:"ACESFilmic",[yh]:"AgX",[bh]:"Neutral",[vh]:"Custom"};function gR(e,t){let n=mR[t];if(n===void 0)return Ue("WebGLProgram: Unsupported toneMapping:",t),"vec3 "+e+"( vec3 color ) { return LinearToneMapping( color ); }";return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}var pl=new F;function _R(){Ke.getLuminanceCoefficients(pl);let e=pl.x.toFixed(4),t=pl.y.toFixed(4),n=pl.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${e}, ${t}, ${n} );`,"\treturn dot( weights, rgb );","}"].join(`
4187
- `)}function xR(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",e.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(ca).join(`
4188
- `)}function vR(e){let t=[];for(let n in e){let i=e[n];if(i===!1)continue;t.push("#define "+n+" "+i)}return t.join(`
4189
- `)}function yR(e,t){let n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){let s=e.getActiveAttrib(t,r),o=s.name,a=1;if(s.type===e.FLOAT_MAT2)a=2;if(s.type===e.FLOAT_MAT3)a=3;if(s.type===e.FLOAT_MAT4)a=4;n[o]={type:s.type,location:e.getAttribLocation(t,o),locationSize:a}}return n}function ca(e){return e!==""}function Hv(e,t){let n=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_SUN_LIGHTS/g,t.numSunLights).replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_SUN_LIGHT_SHADOWS/g,t.numSunLightShadows).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function Vv(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var bR=/^[ \t]*#include +<([\w\d./]+)>/gm;function kd(e){return e.replace(bR,wR)}var SR=new Map;function wR(e,t){let n=Ye[t];if(n===void 0){let i=SR.get(t);if(i!==void 0)n=Ye[i],Ue('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,i);else throw Error("THREE.WebGLProgram: Can not resolve #include <"+t+">")}return kd(n)}var MR=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function $v(e){return e.replace(MR,ER)}function ER(e,t,n,i){let r="";for(let s=parseInt(t);s<parseInt(n);s++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function Wv(e){let t=`precision ${e.precision} float;
4185
+ `+pR(e.getShaderSource(t),a)}else return s}function gR(e,t){let n=mR(t);return[`vec4 ${e}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
4186
+ `)}var _R={[_h]:"Linear",[xh]:"Reinhard",[vh]:"Cineon",[$o]:"ACESFilmic",[bh]:"AgX",[Sh]:"Neutral",[yh]:"Custom"};function xR(e,t){let n=_R[t];if(n===void 0)return Ue("WebGLProgram: Unsupported toneMapping:",t),"vec3 "+e+"( vec3 color ) { return LinearToneMapping( color ); }";return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}var ml=new z;function vR(){Ke.getLuminanceCoefficients(ml);let e=ml.x.toFixed(4),t=ml.y.toFixed(4),n=ml.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${e}, ${t}, ${n} );`,"\treturn dot( weights, rgb );","}"].join(`
4187
+ `)}function yR(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",e.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(ha).join(`
4188
+ `)}function bR(e){let t=[];for(let n in e){let i=e[n];if(i===!1)continue;t.push("#define "+n+" "+i)}return t.join(`
4189
+ `)}function SR(e,t){let n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){let s=e.getActiveAttrib(t,r),o=s.name,a=1;if(s.type===e.FLOAT_MAT2)a=2;if(s.type===e.FLOAT_MAT3)a=3;if(s.type===e.FLOAT_MAT4)a=4;n[o]={type:s.type,location:e.getAttribLocation(t,o),locationSize:a}}return n}function ha(e){return e!==""}function Vv(e,t){let n=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_SUN_LIGHTS/g,t.numSunLights).replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_SUN_LIGHT_SHADOWS/g,t.numSunLightShadows).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function $v(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var wR=/^[ \t]*#include +<([\w\d./]+)>/gm;function Bd(e){return e.replace(wR,ER)}var MR=new Map;function ER(e,t){let n=Ye[t];if(n===void 0){let i=MR.get(t);if(i!==void 0)n=Ye[i],Ue('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,i);else throw Error("THREE.WebGLProgram: Can not resolve #include <"+t+">")}return Bd(n)}var TR=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function Wv(e){return e.replace(TR,AR)}function AR(e,t,n,i){let r="";for(let s=parseInt(t);s<parseInt(n);s++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function Zv(e){let t=`precision ${e.precision} float;
4190
4190
  precision ${e.precision} int;
4191
4191
  precision ${e.precision} sampler2D;
4192
4192
  precision ${e.precision} samplerCube;
@@ -4206,30 +4206,30 @@ void main() {
4206
4206
  `;if(e.precision==="highp")t+=`
4207
4207
  #define HIGH_PRECISION`;else if(e.precision==="mediump")t+=`
4208
4208
  #define MEDIUM_PRECISION`;else if(e.precision==="lowp")t+=`
4209
- #define LOW_PRECISION`;return t}var TR={[ko]:"SHADOWMAP_TYPE_PCF",[Cs]:"SHADOWMAP_TYPE_VSM"};function AR(e){return TR[e.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}var RR={[Ps]:"ENVMAP_TYPE_CUBE",[$r]:"ENVMAP_TYPE_CUBE",[Ho]:"ENVMAP_TYPE_CUBE_UV"};function CR(e){if(e.envMap===!1)return"ENVMAP_TYPE_CUBE";return RR[e.envMapMode]||"ENVMAP_TYPE_CUBE"}var IR={[$r]:"ENVMAP_MODE_REFRACTION"};function PR(e){if(e.envMap===!1)return"ENVMAP_MODE_REFLECTION";return IR[e.envMapMode]||"ENVMAP_MODE_REFLECTION"}var LR={[Qx]:"ENVMAP_BLENDING_MULTIPLY",[ev]:"ENVMAP_BLENDING_MIX",[tv]:"ENVMAP_BLENDING_ADD"};function NR(e){if(e.envMap===!1)return"ENVMAP_BLENDING_NONE";return LR[e.combine]||"ENVMAP_BLENDING_NONE"}function DR(e){let t=e.envMapCubeUVHeight;if(t===null)return null;let n=Math.log2(t)-2,i=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:i,maxMip:n}}function OR(e,t,n,i){let r=e.getContext(),{defines:s,vertexShader:o,fragmentShader:a}=n,c=AR(n),l=CR(n),u=PR(n),h=NR(n),d=DR(n),f=xR(n),m=vR(s),_=r.createProgram(),p,g,M=n.glslVersion?"#version "+n.glslVersion+`
4210
- `:"";if(n.isRawShaderMaterial){if(p=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m].filter(ca).join(`
4209
+ #define LOW_PRECISION`;return t}var RR={[Ho]:"SHADOWMAP_TYPE_PCF",[Is]:"SHADOWMAP_TYPE_VSM"};function CR(e){return RR[e.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}var IR={[Ls]:"ENVMAP_TYPE_CUBE",[Wr]:"ENVMAP_TYPE_CUBE",[Wo]:"ENVMAP_TYPE_CUBE_UV"};function PR(e){if(e.envMap===!1)return"ENVMAP_TYPE_CUBE";return IR[e.envMapMode]||"ENVMAP_TYPE_CUBE"}var LR={[Wr]:"ENVMAP_MODE_REFRACTION"};function NR(e){if(e.envMap===!1)return"ENVMAP_MODE_REFLECTION";return LR[e.envMapMode]||"ENVMAP_MODE_REFLECTION"}var DR={[ev]:"ENVMAP_BLENDING_MULTIPLY",[tv]:"ENVMAP_BLENDING_MIX",[nv]:"ENVMAP_BLENDING_ADD"};function OR(e){if(e.envMap===!1)return"ENVMAP_BLENDING_NONE";return DR[e.combine]||"ENVMAP_BLENDING_NONE"}function UR(e){let t=e.envMapCubeUVHeight;if(t===null)return null;let n=Math.log2(t)-2,i=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:i,maxMip:n}}function FR(e,t,n,i){let r=e.getContext(),{defines:s,vertexShader:o,fragmentShader:a}=n,c=CR(n),l=PR(n),u=NR(n),h=OR(n),d=UR(n),f=yR(n),m=bR(s),_=r.createProgram(),p,g,M=n.glslVersion?"#version "+n.glslVersion+`
4210
+ `:"";if(n.isRawShaderMaterial){if(p=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m].filter(ha).join(`
4211
4211
  `),p.length>0)p+=`
4212
- `;if(g=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m].filter(ca).join(`
4212
+ `;if(g=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m].filter(ha).join(`
4213
4213
  `),g.length>0)g+=`
4214
- `}else p=[Wv(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexNormals?"#define HAS_NORMAL":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif",`
4215
- `].filter(ca).join(`
4216
- `),g=[Wv(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+l:"",n.envMap?"#define "+u:"",n.envMap?"#define "+h:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.retroreflection?"#define USE_RETROREFLECTION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas||n.batchingColor?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==ei?"#define TONE_MAPPING":"",n.toneMapping!==ei?Ye.tonemapping_pars_fragment:"",n.toneMapping!==ei?gR("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Ye.colorspace_pars_fragment,pR("linearToOutputTexel",n.outputColorSpace),_R(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
4217
- `].filter(ca).join(`
4218
- `);if(o=kd(o),o=Hv(o,n),o=Vv(o,n),a=kd(a),a=Hv(a,n),a=Vv(a,n),o=$v(o),a=$v(a),n.isRawShaderMaterial!==!0)M=`#version 300 es
4214
+ `}else p=[Zv(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexNormals?"#define HAS_NORMAL":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif",`
4215
+ `].filter(ha).join(`
4216
+ `),g=[Zv(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+l:"",n.envMap?"#define "+u:"",n.envMap?"#define "+h:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.retroreflection?"#define USE_RETROREFLECTION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas||n.batchingColor?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==ei?"#define TONE_MAPPING":"",n.toneMapping!==ei?Ye.tonemapping_pars_fragment:"",n.toneMapping!==ei?xR("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Ye.colorspace_pars_fragment,gR("linearToOutputTexel",n.outputColorSpace),vR(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
4217
+ `].filter(ha).join(`
4218
+ `);if(o=Bd(o),o=Vv(o,n),o=$v(o,n),a=Bd(a),a=Vv(a,n),a=$v(a,n),o=Wv(o),a=Wv(a),n.isRawShaderMaterial!==!0)M=`#version 300 es
4219
4219
  `,p=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(`
4220
4220
  `)+`
4221
- `+p,g=["#define varying in",n.glslVersion===cd?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===cd?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
4221
+ `+p,g=["#define varying in",n.glslVersion===ld?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===ld?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
4222
4222
  `)+`
4223
- `+g;let T=M+p+o,v=M+g+a,S=kv(r,r.VERTEX_SHADER,T),E=kv(r,r.FRAGMENT_SHADER,v);if(r.attachShader(_,S),r.attachShader(_,E),n.index0AttributeName!==void 0)r.bindAttribLocation(_,0,n.index0AttributeName);else if(n.hasPositionAttribute===!0)r.bindAttribLocation(_,0,"position");r.linkProgram(_);function R(C){if(e.debug.checkShaderErrors){let N=r.getProgramInfoLog(_)||"",ee=r.getShaderInfoLog(S)||"",P=r.getShaderInfoLog(E)||"",Z=N.trim(),G=ee.trim(),k=P.trim(),W=!0,B=!0;if(r.getProgramParameter(_,r.LINK_STATUS)===!1)if(W=!1,typeof e.debug.onShaderError==="function")e.debug.onShaderError(r,_,S,E);else{let Y=Gv(r,S,"vertex"),K=Gv(r,E,"fragment");$e("WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(_,r.VALIDATE_STATUS)+`
4223
+ `+g;let T=M+p+o,v=M+g+a,S=Bv(r,r.VERTEX_SHADER,T),E=Bv(r,r.FRAGMENT_SHADER,v);if(r.attachShader(_,S),r.attachShader(_,E),n.index0AttributeName!==void 0)r.bindAttribLocation(_,0,n.index0AttributeName);else if(n.hasPositionAttribute===!0)r.bindAttribLocation(_,0,"position");r.linkProgram(_);function R(C){if(e.debug.checkShaderErrors){let D=r.getProgramInfoLog(_)||"",ee=r.getShaderInfoLog(S)||"",L=r.getShaderInfoLog(E)||"",W=D.trim(),B=ee.trim(),P=L.trim(),J=!0,H=!0;if(r.getProgramParameter(_,r.LINK_STATUS)===!1)if(J=!1,typeof e.debug.onShaderError==="function")e.debug.onShaderError(r,_,S,E);else{let q=Hv(r,S,"vertex"),Q=Hv(r,E,"fragment");Ve("WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(_,r.VALIDATE_STATUS)+`
4224
4224
 
4225
4225
  Material Name: `+C.name+`
4226
4226
  Material Type: `+C.type+`
4227
4227
 
4228
- Program Info Log: `+Z+`
4229
- `+Y+`
4230
- `+K)}else if(Z!=="")Ue("WebGLProgram: Program Info Log:",Z);else if(G===""||k==="")B=!1;if(B)C.diagnostics={runnable:W,programLog:Z,vertexShader:{log:G,prefix:p},fragmentShader:{log:k,prefix:g}}}r.deleteShader(S),r.deleteShader(E),x=new la(r,_),w=yR(r,_)}let x;this.getUniforms=function(){if(x===void 0)R(this);return x};let w;this.getAttributes=function(){if(w===void 0)R(this);return w};let H=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){if(H===!1)H=r.getProgramParameter(_,uR);return H},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(_),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=hR++,this.cacheKey=t,this.usedTimes=1,this.program=_,this.vertexShader=S,this.fragmentShader=E,this}var UR=0;class sy{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){let i=this._getShaderCacheForMaterial(e);if(i.has(t)===!1)i.add(t),t.usedTimes++;if(i.has(n)===!1)i.add(n),n.usedTimes++;return this}remove(e){let t=this.materialCache.get(e);for(let n of t)if(n.usedTimes--,n.usedTimes===0)this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,n=t.get(e);if(n===void 0)n=new Set,t.set(e,n);return n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);if(n===void 0)n=new oy(e),t.set(e,n);return n}}class oy{constructor(e){this.id=UR++,this.code=e,this.usedTimes=0}}function FR(e){return e===jr||e===Vc||e===$c}function zR(e,t,n,i,r,s){let o=new qc,a=new sy,c=new Set,l=[],u=new Map,{logarithmicDepthBuffer:h,precision:d}=i,f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function m(x){if(c.add(x),x===0)return"uv";return`uv${x}`}function _(x,w,H,C,N,ee){let P=C.fog,Z=N.geometry,G=x.isMeshStandardMaterial||x.isMeshLambertMaterial||x.isMeshPhongMaterial?C.environment:null,k=x.isMeshStandardMaterial||x.isMeshLambertMaterial&&!x.envMap||x.isMeshPhongMaterial&&!x.envMap,W=t.get(x.envMap||G,k),B=!!W&&W.mapping===Ho?W.image.height:null,Y=f[x.type];if(x.precision!==null){if(d=i.getMaxPrecision(x.precision),d!==x.precision)Ue("WebGLProgram.getParameters:",x.precision,"not supported, using",d,"instead.")}let K=Z.morphAttributes.position||Z.morphAttributes.normal||Z.morphAttributes.color,ge=K!==void 0?K.length:0,de=0;if(Z.morphAttributes.position!==void 0)de=1;if(Z.morphAttributes.normal!==void 0)de=2;if(Z.morphAttributes.color!==void 0)de=3;let fe,he,I,V;if(Y){let bt=Ei[Y];fe=bt.vertexShader,he=bt.fragmentShader}else{fe=x.vertexShader,he=x.fragmentShader;let bt=a.getVertexShaderStage(x),ht=a.getFragmentShaderStage(x);a.update(x,bt,ht),I=bt.id,V=ht.id}let q=e.getRenderTarget(),se=e.state.buffers.depth.getReversed(),ce=N.isInstancedMesh===!0,ae=N.isBatchedMesh===!0,ke=!!x.map,Ce=!!x.matcap,Ve=!!W,rt=!!x.aoMap,nt=!!x.lightMap,Rt=!!x.bumpMap&&x.wireframe===!1,it=!!x.normalMap,tn=!!x.displacementMap,Ut=!!x.emissiveMap,It=!!x.metalnessMap,D=!!x.roughnessMap,_n=x.anisotropy>0,ut=x.clearcoat>0,Pt=x.dispersion>0,A=x.retroreflectivity>0,y=x.iridescence>0,O=x.sheen>0,J=x.transmission>0,ue=_n&&!!x.anisotropyMap,me=ut&&!!x.clearcoatMap,ve=ut&&!!x.clearcoatNormalMap,te=ut&&!!x.clearcoatRoughnessMap,re=y&&!!x.iridescenceMap,Ee=y&&!!x.iridescenceThicknessMap,Oe=O&&!!x.sheenColorMap,ye=O&&!!x.sheenRoughnessMap,pe=!!x.specularMap,ze=!!x.specularColorMap,Ge=!!x.specularIntensityMap,ot=J&&!!x.transmissionMap,z=J&&!!x.thicknessMap,_e=!!x.gradientMap,ne=!!x.alphaMap,xe=x.alphaTest>0,Te=!!x.alphaHash,le=!!x.extensions,Se=ei;if(x.toneMapped){if(q===null||q.isXRRenderTarget===!0)Se=e.toneMapping}let Ze={shaderID:Y,shaderType:x.type,shaderName:x.name,vertexShader:fe,fragmentShader:he,defines:x.defines,customVertexShaderID:I,customFragmentShaderID:V,isRawShaderMaterial:x.isRawShaderMaterial===!0,glslVersion:x.glslVersion,precision:d,batching:ae,batchingColor:ae&&N._colorsTexture!==null,instancing:ce,instancingColor:ce&&N.instanceColor!==null,instancingMorph:ce&&N.morphTexture!==null,outputColorSpace:q===null?e.outputColorSpace:q.isXRRenderTarget===!0?q.texture.colorSpace:Ke.workingColorSpace,alphaToCoverage:!!x.alphaToCoverage,map:ke,matcap:Ce,envMap:Ve,envMapMode:Ve&&W.mapping,envMapCubeUVHeight:B,aoMap:rt,lightMap:nt,bumpMap:Rt,normalMap:it,displacementMap:tn,emissiveMap:Ut,normalMapObjectSpace:it&&x.normalMapType===lv,normalMapTangentSpace:it&&x.normalMapType===od,packedNormalMap:it&&x.normalMapType===od&&FR(x.normalMap.format),metalnessMap:It,roughnessMap:D,anisotropy:_n,anisotropyMap:ue,clearcoat:ut,clearcoatMap:me,clearcoatNormalMap:ve,clearcoatRoughnessMap:te,dispersion:Pt,retroreflection:A,iridescence:y,iridescenceMap:re,iridescenceThicknessMap:Ee,sheen:O,sheenColorMap:Oe,sheenRoughnessMap:ye,specularMap:pe,specularColorMap:ze,specularIntensityMap:Ge,transmission:J,transmissionMap:ot,thicknessMap:z,gradientMap:_e,opaque:x.transparent===!1&&x.blending===Bo&&x.alphaToCoverage===!1,alphaMap:ne,alphaTest:xe,alphaHash:Te,combine:x.combine,mapUv:ke&&m(x.map.channel),aoMapUv:rt&&m(x.aoMap.channel),lightMapUv:nt&&m(x.lightMap.channel),bumpMapUv:Rt&&m(x.bumpMap.channel),normalMapUv:it&&m(x.normalMap.channel),displacementMapUv:tn&&m(x.displacementMap.channel),emissiveMapUv:Ut&&m(x.emissiveMap.channel),metalnessMapUv:It&&m(x.metalnessMap.channel),roughnessMapUv:D&&m(x.roughnessMap.channel),anisotropyMapUv:ue&&m(x.anisotropyMap.channel),clearcoatMapUv:me&&m(x.clearcoatMap.channel),clearcoatNormalMapUv:ve&&m(x.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:te&&m(x.clearcoatRoughnessMap.channel),iridescenceMapUv:re&&m(x.iridescenceMap.channel),iridescenceThicknessMapUv:Ee&&m(x.iridescenceThicknessMap.channel),sheenColorMapUv:Oe&&m(x.sheenColorMap.channel),sheenRoughnessMapUv:ye&&m(x.sheenRoughnessMap.channel),specularMapUv:pe&&m(x.specularMap.channel),specularColorMapUv:ze&&m(x.specularColorMap.channel),specularIntensityMapUv:Ge&&m(x.specularIntensityMap.channel),transmissionMapUv:ot&&m(x.transmissionMap.channel),thicknessMapUv:z&&m(x.thicknessMap.channel),alphaMapUv:ne&&m(x.alphaMap.channel),vertexTangents:!!Z.attributes.tangent&&(it||_n),vertexNormals:!!Z.attributes.normal,vertexColors:x.vertexColors,vertexAlphas:x.vertexColors===!0&&!!Z.attributes.color&&Z.attributes.color.itemSize===4,pointsUvs:N.isPoints===!0&&!!Z.attributes.uv&&(ke||ne),fog:!!P,useFog:x.fog===!0,fogExp2:!!P&&P.isFogExp2,flatShading:x.wireframe===!1&&(x.flatShading===!0||Z.attributes.normal===void 0&&it===!1&&(x.isMeshLambertMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isMeshPhysicalMaterial)),sizeAttenuation:x.sizeAttenuation===!0,logarithmicDepthBuffer:h,reversedDepthBuffer:se,skinning:N.isSkinnedMesh===!0,hasPositionAttribute:Z.attributes.position!==void 0,morphTargets:Z.morphAttributes.position!==void 0,morphNormals:Z.morphAttributes.normal!==void 0,morphColors:Z.morphAttributes.color!==void 0,morphTargetsCount:ge,morphTextureStride:de,numSunLights:w.sun.length,numDirLights:w.directional.length,numPointLights:w.point.length,numSpotLights:w.spot.length,numSpotLightMaps:w.spotLightMap.length,numRectAreaLights:w.rectArea.length,numHemiLights:w.hemi.length,numSunLightShadows:w.sunShadowMap.length,numDirLightShadows:w.directionalShadowMap.length,numPointLightShadows:w.pointShadowMap.length,numSpotLightShadows:w.spotShadowMap.length,numSpotLightShadowsWithMaps:w.numSpotLightShadowsWithMaps,numLightProbes:w.numLightProbes,numLightProbeGrids:ee.length,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:x.dithering,shadowMapEnabled:e.shadowMap.enabled&&H.length>0,shadowMapType:e.shadowMap.type,toneMapping:Se,decodeVideoTexture:ke&&x.map.isVideoTexture===!0&&Ke.getTransfer(x.map.colorSpace)===yt,decodeVideoTextureEmissive:Ut&&x.emissiveMap.isVideoTexture===!0&&Ke.getTransfer(x.emissiveMap.colorSpace)===yt,premultipliedAlpha:x.premultipliedAlpha,doubleSided:x.side===Bn,flipSided:x.side===cn,useDepthPacking:x.depthPacking>=0,depthPacking:x.depthPacking||0,index0AttributeName:x.index0AttributeName,extensionClipCullDistance:le&&x.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(le&&x.extensions.multiDraw===!0||ae)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:x.customProgramCacheKey()};return Ze.vertexUv1s=c.has(1),Ze.vertexUv2s=c.has(2),Ze.vertexUv3s=c.has(3),c.clear(),Ze}function p(x){let w=[];if(x.shaderID)w.push(x.shaderID);else w.push(x.customVertexShaderID),w.push(x.customFragmentShaderID);if(x.defines!==void 0)for(let H in x.defines)w.push(H),w.push(x.defines[H]);if(x.isRawShaderMaterial===!1)g(w,x),M(w,x),w.push(e.outputColorSpace);return w.push(x.customProgramCacheKey),w.join()}function g(x,w){x.push(w.precision),x.push(w.outputColorSpace),x.push(w.envMapMode),x.push(w.envMapCubeUVHeight),x.push(w.mapUv),x.push(w.alphaMapUv),x.push(w.lightMapUv),x.push(w.aoMapUv),x.push(w.bumpMapUv),x.push(w.normalMapUv),x.push(w.displacementMapUv),x.push(w.emissiveMapUv),x.push(w.metalnessMapUv),x.push(w.roughnessMapUv),x.push(w.anisotropyMapUv),x.push(w.clearcoatMapUv),x.push(w.clearcoatNormalMapUv),x.push(w.clearcoatRoughnessMapUv),x.push(w.iridescenceMapUv),x.push(w.iridescenceThicknessMapUv),x.push(w.sheenColorMapUv),x.push(w.sheenRoughnessMapUv),x.push(w.specularMapUv),x.push(w.specularColorMapUv),x.push(w.specularIntensityMapUv),x.push(w.transmissionMapUv),x.push(w.thicknessMapUv),x.push(w.combine),x.push(w.fogExp2),x.push(w.sizeAttenuation),x.push(w.morphTargetsCount),x.push(w.morphAttributeCount),x.push(w.numSunLights),x.push(w.numDirLights),x.push(w.numPointLights),x.push(w.numSpotLights),x.push(w.numSpotLightMaps),x.push(w.numHemiLights),x.push(w.numRectAreaLights),x.push(w.numSunLightShadows),x.push(w.numDirLightShadows),x.push(w.numPointLightShadows),x.push(w.numSpotLightShadows),x.push(w.numSpotLightShadowsWithMaps),x.push(w.numLightProbes),x.push(w.shadowMapType),x.push(w.toneMapping),x.push(w.numClippingPlanes),x.push(w.numClipIntersection),x.push(w.depthPacking)}function M(x,w){if(o.disableAll(),w.instancing)o.enable(0);if(w.instancingColor)o.enable(1);if(w.instancingMorph)o.enable(2);if(w.matcap)o.enable(3);if(w.envMap)o.enable(4);if(w.normalMapObjectSpace)o.enable(5);if(w.normalMapTangentSpace)o.enable(6);if(w.clearcoat)o.enable(7);if(w.iridescence)o.enable(8);if(w.alphaTest)o.enable(9);if(w.vertexColors)o.enable(10);if(w.vertexAlphas)o.enable(11);if(w.vertexUv1s)o.enable(12);if(w.vertexUv2s)o.enable(13);if(w.vertexUv3s)o.enable(14);if(w.vertexTangents)o.enable(15);if(w.anisotropy)o.enable(16);if(w.alphaHash)o.enable(17);if(w.batching)o.enable(18);if(w.dispersion)o.enable(19);if(w.retroreflection)o.enable(24);if(w.batchingColor)o.enable(20);if(w.gradientMap)o.enable(21);if(w.packedNormalMap)o.enable(22);if(w.vertexNormals)o.enable(23);if(x.push(o.mask),o.disableAll(),w.fog)o.enable(0);if(w.useFog)o.enable(1);if(w.flatShading)o.enable(2);if(w.logarithmicDepthBuffer)o.enable(3);if(w.reversedDepthBuffer)o.enable(4);if(w.skinning)o.enable(5);if(w.morphTargets)o.enable(6);if(w.morphNormals)o.enable(7);if(w.morphColors)o.enable(8);if(w.premultipliedAlpha)o.enable(9);if(w.shadowMapEnabled)o.enable(10);if(w.doubleSided)o.enable(11);if(w.flipSided)o.enable(12);if(w.useDepthPacking)o.enable(13);if(w.dithering)o.enable(14);if(w.transmission)o.enable(15);if(w.sheen)o.enable(16);if(w.opaque)o.enable(17);if(w.pointsUvs)o.enable(18);if(w.decodeVideoTexture)o.enable(19);if(w.decodeVideoTextureEmissive)o.enable(20);if(w.alphaToCoverage)o.enable(21);if(w.numLightProbeGrids>0)o.enable(22);if(w.hasPositionAttribute)o.enable(23);x.push(o.mask)}function T(x){let w=f[x.type],H;if(w){let C=Ei[w];H=bv.clone(C.uniforms)}else H=x.uniforms;return H}function v(x,w){let H=u.get(w);if(H!==void 0)++H.usedTimes;else H=new OR(e,w,x,r),l.push(H),u.set(w,H);return H}function S(x){if(--x.usedTimes===0){let w=l.indexOf(x);l[w]=l[l.length-1],l.pop(),u.delete(x.cacheKey),x.destroy()}}function E(x){a.remove(x)}function R(){a.dispose()}return{getParameters:_,getProgramCacheKey:p,getUniforms:T,acquireProgram:v,releaseProgram:S,releaseShaderCache:E,programs:l,dispose:R}}function kR(){let e=new WeakMap;function t(o){return e.has(o)}function n(o){let a=e.get(o);if(a===void 0)a={},e.set(o,a);return a}function i(o){e.delete(o)}function r(o,a,c){e.get(o)[a]=c}function s(){e=new WeakMap}return{has:t,get:n,remove:i,update:r,dispose:s}}function BR(e,t){if(e.groupOrder!==t.groupOrder)return e.groupOrder-t.groupOrder;else if(e.renderOrder!==t.renderOrder)return e.renderOrder-t.renderOrder;else if(e.material.id!==t.material.id)return e.material.id-t.material.id;else if(e.materialVariant!==t.materialVariant)return e.materialVariant-t.materialVariant;else if(e.z!==t.z)return e.z-t.z;else return e.id-t.id}function Zv(e,t){if(e.groupOrder!==t.groupOrder)return e.groupOrder-t.groupOrder;else if(e.renderOrder!==t.renderOrder)return e.renderOrder-t.renderOrder;else if(e.z!==t.z)return t.z-e.z;else return e.id-t.id}function Xv(){let e=[],t=0,n=[],i=[],r=[];function s(){t=0,n.length=0,i.length=0,r.length=0}function o(d){let f=0;if(d.isInstancedMesh)f+=2;if(d.isSkinnedMesh)f+=1;return f}function a(d,f,m,_,p,g){let M=e[t];if(M===void 0)M={id:d.id,object:d,geometry:f,material:m,materialVariant:o(d),groupOrder:_,renderOrder:d.renderOrder,z:p,group:g},e[t]=M;else M.id=d.id,M.object=d,M.geometry=f,M.material=m,M.materialVariant=o(d),M.groupOrder=_,M.renderOrder=d.renderOrder,M.z=p,M.group=g;return t++,M}function c(d,f,m,_,p,g,M){if(M.reversedDepth===!0)p=-p;let T=a(d,f,m,_,p,g);if(m.transmission>0)i.push(T);else if(m.transparent===!0)r.push(T);else n.push(T)}function l(d,f,m,_,p,g){let M=a(d,f,m,_,p,g);if(m.transmission>0)i.unshift(M);else if(m.transparent===!0)r.unshift(M);else n.unshift(M)}function u(d,f){if(n.length>1)n.sort(d||BR);if(i.length>1)i.sort(f||Zv);if(r.length>1)r.sort(f||Zv)}function h(){for(let d=t,f=e.length;d<f;d++){let m=e[d];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:n,transmissive:i,transparent:r,init:s,push:c,unshift:l,finish:h,sort:u}}function GR(){let e=new WeakMap;function t(i,r){let s=e.get(i),o;if(s===void 0)o=new Xv,e.set(i,[o]);else if(r>=s.length)o=new Xv,s.push(o);else o=s[r];return o}function n(){e=new WeakMap}return{get:t,dispose:n}}function HR(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case"SunLight":case"DirectionalLight":n={direction:new F,color:new He};break;case"SpotLight":n={position:new F,direction:new F,color:new He,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new F,color:new He,distance:0,decay:0};break;case"HemisphereLight":n={direction:new F,skyColor:new He,groundColor:new He};break;case"RectAreaLight":n={color:new He,position:new F,halfWidth:new F,halfHeight:new F};break}return e[t.id]=n,n}}}function VR(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case"SunLight":case"DirectionalLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Be};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Be};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Be,shadowCameraNear:1,shadowCameraFar:1000};break}return e[t.id]=n,n}}}var $R=0;function WR(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function ZR(e){let t=new HR,n=VR(),i={version:0,hash:{sunLength:-1,directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numSunShadows:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],sun:[],sunShadow:[],sunShadowMap:[],sunShadowMatrix:[],sunShadowCascade:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let l=0;l<9;l++)i.probe.push(new F);let r=new F,s=new Xe,o=new Xe;function a(l){let u=0,h=0,d=0;for(let N=0;N<9;N++)i.probe[N].set(0,0,0);let f=0,m=0,_=0,p=0,g=0,M=0,T=0,v=0,S=0,E=0,R=0,x=0,w=0,H=0;l.sort(WR);for(let N=0,ee=l.length;N<ee;N++){let P=l[N],{color:Z,intensity:G,distance:k}=P,W=null;if(P.shadow&&P.shadow.map)if(P.shadow.map.texture.format===jr)W=P.shadow.map.texture;else W=P.shadow.map.depthTexture||P.shadow.map.texture;if(P.isAmbientLight)u+=Z.r*G,h+=Z.g*G,d+=Z.b*G;else if(P.isLightProbe){for(let B=0;B<9;B++)i.probe[B].addScaledVector(P.sh.coefficients[B],G);H++}else if(P.isSunLight){let B=t.get(P);if(B.color.copy(P.color).multiplyScalar(P.intensity),P.castShadow){let Y=P.shadow,K=n.get(P);K.shadowIntensity=Y.intensity,K.shadowBias=Y.bias,K.shadowNormalBias=Y.normalBias,K.shadowRadius=Y.radius,K.shadowMapSize.copy(Y.mapSize).multiply(Y.getFrameExtents()),i.sunShadow[m]=K,i.sunShadowMap[m]=W;let ge=Y.getViewportCount();for(let de=0;de<ge;de++)i.sunShadowMatrix[_+de]=Y.getMatrix(de),i.sunShadowCascade[_+de]=Y._cascadeData[de];_+=ge,m++}i.sun[f]=B,f++}else if(P.isDirectionalLight){let B=t.get(P);if(B.color.copy(P.color).multiplyScalar(P.intensity),P.castShadow){let Y=P.shadow,K=n.get(P);K.shadowIntensity=Y.intensity,K.shadowBias=Y.bias,K.shadowNormalBias=Y.normalBias,K.shadowRadius=Y.radius,K.shadowMapSize=Y.mapSize,i.directionalShadow[p]=K,i.directionalShadowMap[p]=W,i.directionalShadowMatrix[p]=P.shadow.matrix,S++}i.directional[p]=B,p++}else if(P.isSpotLight){let B=t.get(P);B.position.setFromMatrixPosition(P.matrixWorld),B.color.copy(Z).multiplyScalar(G),B.distance=k,B.coneCos=Math.cos(P.angle),B.penumbraCos=Math.cos(P.angle*(1-P.penumbra)),B.decay=P.decay,i.spot[M]=B;let Y=P.shadow;if(P.map){if(i.spotLightMap[x]=P.map,x++,Y.updateMatrices(P),P.castShadow)w++}if(i.spotLightMatrix[M]=Y.matrix,P.castShadow){let K=n.get(P);K.shadowIntensity=Y.intensity,K.shadowBias=Y.bias,K.shadowNormalBias=Y.normalBias,K.shadowRadius=Y.radius,K.shadowMapSize=Y.mapSize,i.spotShadow[M]=K,i.spotShadowMap[M]=W,R++}M++}else if(P.isRectAreaLight){let B=t.get(P);B.color.copy(Z).multiplyScalar(G),B.halfWidth.set(P.width*0.5,0,0),B.halfHeight.set(0,P.height*0.5,0),i.rectArea[T]=B,T++}else if(P.isPointLight){let B=t.get(P);if(B.color.copy(P.color).multiplyScalar(P.intensity),B.distance=P.distance,B.decay=P.decay,P.castShadow){let Y=P.shadow,K=n.get(P);K.shadowIntensity=Y.intensity,K.shadowBias=Y.bias,K.shadowNormalBias=Y.normalBias,K.shadowRadius=Y.radius,K.shadowMapSize=Y.mapSize,K.shadowCameraNear=Y.camera.near,K.shadowCameraFar=Y.camera.far,i.pointShadow[g]=K,i.pointShadowMap[g]=W,i.pointShadowMatrix[g]=P.shadow.matrix,E++}i.point[g]=B,g++}else if(P.isHemisphereLight){let B=t.get(P);B.skyColor.copy(P.color).multiplyScalar(G),B.groundColor.copy(P.groundColor).multiplyScalar(G),i.hemi[v]=B,v++}}if(T>0)if(e.has("OES_texture_float_linear")===!0)i.rectAreaLTC1=be.LTC_FLOAT_1,i.rectAreaLTC2=be.LTC_FLOAT_2;else i.rectAreaLTC1=be.LTC_HALF_1,i.rectAreaLTC2=be.LTC_HALF_2;i.ambient[0]=u,i.ambient[1]=h,i.ambient[2]=d;let C=i.hash;if(C.sunLength!==f||C.directionalLength!==p||C.pointLength!==g||C.spotLength!==M||C.rectAreaLength!==T||C.hemiLength!==v||C.numSunShadows!==m||C.numDirectionalShadows!==S||C.numPointShadows!==E||C.numSpotShadows!==R||C.numSpotMaps!==x||C.numLightProbes!==H)i.sun.length=f,i.directional.length=p,i.spot.length=M,i.rectArea.length=T,i.point.length=g,i.hemi.length=v,i.sunShadow.length=m,i.sunShadowMap.length=m,i.sunShadowMatrix.length=_,i.sunShadowCascade.length=_,i.directionalShadow.length=S,i.directionalShadowMap.length=S,i.directionalShadowMatrix.length=S,i.pointShadow.length=E,i.pointShadowMap.length=E,i.pointShadowMatrix.length=E,i.spotShadow.length=R,i.spotShadowMap.length=R,i.spotLightMatrix.length=R+x-w,i.spotLightMap.length=x,i.numSpotLightShadowsWithMaps=w,i.numLightProbes=H,C.sunLength=f,C.directionalLength=p,C.pointLength=g,C.spotLength=M,C.rectAreaLength=T,C.hemiLength=v,C.numSunShadows=m,C.numDirectionalShadows=S,C.numPointShadows=E,C.numSpotShadows=R,C.numSpotMaps=x,C.numLightProbes=H,i.version=$R++}function c(l,u){let h=0,d=0,f=0,m=0,_=0,p=0,g=u.matrixWorldInverse;for(let M=0,T=l.length;M<T;M++){let v=l[M];if(v.isSunLight){let S=i.sun[h];S.direction.setFromMatrixPosition(v.matrixWorld),S.direction.transformDirection(g),h++}else if(v.isDirectionalLight){let S=i.directional[d];S.direction.setFromMatrixPosition(v.matrixWorld),r.setFromMatrixPosition(v.target.matrixWorld),S.direction.sub(r),S.direction.transformDirection(g),d++}else if(v.isSpotLight){let S=i.spot[m];S.position.setFromMatrixPosition(v.matrixWorld),S.position.applyMatrix4(g),S.direction.setFromMatrixPosition(v.matrixWorld),r.setFromMatrixPosition(v.target.matrixWorld),S.direction.sub(r),S.direction.transformDirection(g),m++}else if(v.isRectAreaLight){let S=i.rectArea[_];S.position.setFromMatrixPosition(v.matrixWorld),S.position.applyMatrix4(g),o.identity(),s.copy(v.matrixWorld),s.premultiply(g),o.extractRotation(s),S.halfWidth.set(v.width*0.5,0,0),S.halfHeight.set(0,v.height*0.5,0),S.halfWidth.applyMatrix4(o),S.halfHeight.applyMatrix4(o),_++}else if(v.isPointLight){let S=i.point[f];S.position.setFromMatrixPosition(v.matrixWorld),S.position.applyMatrix4(g),f++}else if(v.isHemisphereLight){let S=i.hemi[p];S.direction.setFromMatrixPosition(v.matrixWorld),S.direction.transformDirection(g),p++}}}return{setup:a,setupView:c,state:i}}function jv(e){let t=new ZR(e),n=[],i=[],r=[];function s(d){h.camera=d,n.length=0,i.length=0,r.length=0}function o(d){n.push(d)}function a(d){i.push(d)}function c(d){r.push(d)}function l(){t.setup(n)}function u(d){t.setupView(n,d)}let h={lightsArray:n,shadowsArray:i,lightProbeGridArray:r,camera:null,lights:t,transmissionRenderTarget:{},textureUnits:0};return{init:s,state:h,setupLights:l,setupLightsView:u,pushLight:o,pushShadow:a,pushLightProbeGrid:c}}function XR(e){let t=new WeakMap;function n(r,s=0){let o=t.get(r),a;if(o===void 0)a=new jv(e),t.set(r,[a]);else if(s>=o.length)a=new jv(e),o.push(a);else a=o[s];return a}function i(){t=new WeakMap}return{get:n,dispose:i}}var jR=`void main() {
4228
+ Program Info Log: `+W+`
4229
+ `+q+`
4230
+ `+Q)}else if(W!=="")Ue("WebGLProgram: Program Info Log:",W);else if(B===""||P==="")H=!1;if(H)C.diagnostics={runnable:J,programLog:W,vertexShader:{log:B,prefix:p},fragmentShader:{log:P,prefix:g}}}r.deleteShader(S),r.deleteShader(E),x=new da(r,_),w=SR(r,_)}let x;this.getUniforms=function(){if(x===void 0)R(this);return x};let w;this.getAttributes=function(){if(w===void 0)R(this);return w};let G=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){if(G===!1)G=r.getProgramParameter(_,dR);return G},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(_),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=fR++,this.cacheKey=t,this.usedTimes=1,this.program=_,this.vertexShader=S,this.fragmentShader=E,this}var zR=0;class oy{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){let i=this._getShaderCacheForMaterial(e);if(i.has(t)===!1)i.add(t),t.usedTimes++;if(i.has(n)===!1)i.add(n),n.usedTimes++;return this}remove(e){let t=this.materialCache.get(e);for(let n of t)if(n.usedTimes--,n.usedTimes===0)this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,n=t.get(e);if(n===void 0)n=new Set,t.set(e,n);return n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);if(n===void 0)n=new ay(e),t.set(e,n);return n}}class ay{constructor(e){this.id=zR++,this.code=e,this.usedTimes=0}}function kR(e){return e===qr||e===Wc||e===Zc}function BR(e,t,n,i,r,s){let o=new Kc,a=new oy,c=new Set,l=[],u=new Map,{logarithmicDepthBuffer:h,precision:d}=i,f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function m(x){if(c.add(x),x===0)return"uv";return`uv${x}`}function _(x,w,G,C,D,ee){let L=C.fog,W=D.geometry,B=x.isMeshStandardMaterial||x.isMeshLambertMaterial||x.isMeshPhongMaterial?C.environment:null,P=x.isMeshStandardMaterial||x.isMeshLambertMaterial&&!x.envMap||x.isMeshPhongMaterial&&!x.envMap,J=t.get(x.envMap||B,P),H=!!J&&J.mapping===Wo?J.image.height:null,q=f[x.type];if(x.precision!==null){if(d=i.getMaxPrecision(x.precision),d!==x.precision)Ue("WebGLProgram.getParameters:",x.precision,"not supported, using",d,"instead.")}let Q=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,ge=Q!==void 0?Q.length:0,he=0;if(W.morphAttributes.position!==void 0)he=1;if(W.morphAttributes.normal!==void 0)he=2;if(W.morphAttributes.color!==void 0)he=3;let de,fe,I,V;if(q){let bt=Ei[q];de=bt.vertexShader,fe=bt.fragmentShader}else{de=x.vertexShader,fe=x.fragmentShader;let bt=a.getVertexShaderStage(x),ht=a.getFragmentShaderStage(x);a.update(x,bt,ht),I=bt.id,V=ht.id}let j=e.getRenderTarget(),re=e.state.buffers.depth.getReversed(),oe=D.isInstancedMesh===!0,ue=D.isBatchedMesh===!0,$e=!!x.map,Ce=!!x.matcap,He=!!J,rt=!!x.aoMap,nt=!!x.lightMap,Rt=!!x.bumpMap&&x.wireframe===!1,it=!!x.normalMap,tn=!!x.displacementMap,Ut=!!x.emissiveMap,It=!!x.metalnessMap,O=!!x.roughnessMap,_n=x.anisotropy>0,ut=x.clearcoat>0,Pt=x.dispersion>0,A=x.retroreflectivity>0,y=x.iridescence>0,U=x.sheen>0,Y=x.transmission>0,le=_n&&!!x.anisotropyMap,me=ut&&!!x.clearcoatMap,ve=ut&&!!x.clearcoatNormalMap,te=ut&&!!x.clearcoatRoughnessMap,se=y&&!!x.iridescenceMap,Ee=y&&!!x.iridescenceThicknessMap,Oe=U&&!!x.sheenColorMap,ye=U&&!!x.sheenRoughnessMap,pe=!!x.specularMap,ze=!!x.specularColorMap,Be=!!x.specularIntensityMap,ot=Y&&!!x.transmissionMap,k=Y&&!!x.thicknessMap,_e=!!x.gradientMap,ne=!!x.alphaMap,xe=x.alphaTest>0,Te=!!x.alphaHash,ce=!!x.extensions,Se=ei;if(x.toneMapped){if(j===null||j.isXRRenderTarget===!0)Se=e.toneMapping}let Ze={shaderID:q,shaderType:x.type,shaderName:x.name,vertexShader:de,fragmentShader:fe,defines:x.defines,customVertexShaderID:I,customFragmentShaderID:V,isRawShaderMaterial:x.isRawShaderMaterial===!0,glslVersion:x.glslVersion,precision:d,batching:ue,batchingColor:ue&&D._colorsTexture!==null,instancing:oe,instancingColor:oe&&D.instanceColor!==null,instancingMorph:oe&&D.morphTexture!==null,outputColorSpace:j===null?e.outputColorSpace:j.isXRRenderTarget===!0?j.texture.colorSpace:Ke.workingColorSpace,alphaToCoverage:!!x.alphaToCoverage,map:$e,matcap:Ce,envMap:He,envMapMode:He&&J.mapping,envMapCubeUVHeight:H,aoMap:rt,lightMap:nt,bumpMap:Rt,normalMap:it,displacementMap:tn,emissiveMap:Ut,normalMapObjectSpace:it&&x.normalMapType===uv,normalMapTangentSpace:it&&x.normalMapType===ad,packedNormalMap:it&&x.normalMapType===ad&&kR(x.normalMap.format),metalnessMap:It,roughnessMap:O,anisotropy:_n,anisotropyMap:le,clearcoat:ut,clearcoatMap:me,clearcoatNormalMap:ve,clearcoatRoughnessMap:te,dispersion:Pt,retroreflection:A,iridescence:y,iridescenceMap:se,iridescenceThicknessMap:Ee,sheen:U,sheenColorMap:Oe,sheenRoughnessMap:ye,specularMap:pe,specularColorMap:ze,specularIntensityMap:Be,transmission:Y,transmissionMap:ot,thicknessMap:k,gradientMap:_e,opaque:x.transparent===!1&&x.blending===Vo&&x.alphaToCoverage===!1,alphaMap:ne,alphaTest:xe,alphaHash:Te,combine:x.combine,mapUv:$e&&m(x.map.channel),aoMapUv:rt&&m(x.aoMap.channel),lightMapUv:nt&&m(x.lightMap.channel),bumpMapUv:Rt&&m(x.bumpMap.channel),normalMapUv:it&&m(x.normalMap.channel),displacementMapUv:tn&&m(x.displacementMap.channel),emissiveMapUv:Ut&&m(x.emissiveMap.channel),metalnessMapUv:It&&m(x.metalnessMap.channel),roughnessMapUv:O&&m(x.roughnessMap.channel),anisotropyMapUv:le&&m(x.anisotropyMap.channel),clearcoatMapUv:me&&m(x.clearcoatMap.channel),clearcoatNormalMapUv:ve&&m(x.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:te&&m(x.clearcoatRoughnessMap.channel),iridescenceMapUv:se&&m(x.iridescenceMap.channel),iridescenceThicknessMapUv:Ee&&m(x.iridescenceThicknessMap.channel),sheenColorMapUv:Oe&&m(x.sheenColorMap.channel),sheenRoughnessMapUv:ye&&m(x.sheenRoughnessMap.channel),specularMapUv:pe&&m(x.specularMap.channel),specularColorMapUv:ze&&m(x.specularColorMap.channel),specularIntensityMapUv:Be&&m(x.specularIntensityMap.channel),transmissionMapUv:ot&&m(x.transmissionMap.channel),thicknessMapUv:k&&m(x.thicknessMap.channel),alphaMapUv:ne&&m(x.alphaMap.channel),vertexTangents:!!W.attributes.tangent&&(it||_n),vertexNormals:!!W.attributes.normal,vertexColors:x.vertexColors,vertexAlphas:x.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,pointsUvs:D.isPoints===!0&&!!W.attributes.uv&&($e||ne),fog:!!L,useFog:x.fog===!0,fogExp2:!!L&&L.isFogExp2,flatShading:x.wireframe===!1&&(x.flatShading===!0||W.attributes.normal===void 0&&it===!1&&(x.isMeshLambertMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isMeshPhysicalMaterial)),sizeAttenuation:x.sizeAttenuation===!0,logarithmicDepthBuffer:h,reversedDepthBuffer:re,skinning:D.isSkinnedMesh===!0,hasPositionAttribute:W.attributes.position!==void 0,morphTargets:W.morphAttributes.position!==void 0,morphNormals:W.morphAttributes.normal!==void 0,morphColors:W.morphAttributes.color!==void 0,morphTargetsCount:ge,morphTextureStride:he,numSunLights:w.sun.length,numDirLights:w.directional.length,numPointLights:w.point.length,numSpotLights:w.spot.length,numSpotLightMaps:w.spotLightMap.length,numRectAreaLights:w.rectArea.length,numHemiLights:w.hemi.length,numSunLightShadows:w.sunShadowMap.length,numDirLightShadows:w.directionalShadowMap.length,numPointLightShadows:w.pointShadowMap.length,numSpotLightShadows:w.spotShadowMap.length,numSpotLightShadowsWithMaps:w.numSpotLightShadowsWithMaps,numLightProbes:w.numLightProbes,numLightProbeGrids:ee.length,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:x.dithering,shadowMapEnabled:e.shadowMap.enabled&&G.length>0,shadowMapType:e.shadowMap.type,toneMapping:Se,decodeVideoTexture:$e&&x.map.isVideoTexture===!0&&Ke.getTransfer(x.map.colorSpace)===yt,decodeVideoTextureEmissive:Ut&&x.emissiveMap.isVideoTexture===!0&&Ke.getTransfer(x.emissiveMap.colorSpace)===yt,premultipliedAlpha:x.premultipliedAlpha,doubleSided:x.side===Bn,flipSided:x.side===cn,useDepthPacking:x.depthPacking>=0,depthPacking:x.depthPacking||0,index0AttributeName:x.index0AttributeName,extensionClipCullDistance:ce&&x.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ce&&x.extensions.multiDraw===!0||ue)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:x.customProgramCacheKey()};return Ze.vertexUv1s=c.has(1),Ze.vertexUv2s=c.has(2),Ze.vertexUv3s=c.has(3),c.clear(),Ze}function p(x){let w=[];if(x.shaderID)w.push(x.shaderID);else w.push(x.customVertexShaderID),w.push(x.customFragmentShaderID);if(x.defines!==void 0)for(let G in x.defines)w.push(G),w.push(x.defines[G]);if(x.isRawShaderMaterial===!1)g(w,x),M(w,x),w.push(e.outputColorSpace);return w.push(x.customProgramCacheKey),w.join()}function g(x,w){x.push(w.precision),x.push(w.outputColorSpace),x.push(w.envMapMode),x.push(w.envMapCubeUVHeight),x.push(w.mapUv),x.push(w.alphaMapUv),x.push(w.lightMapUv),x.push(w.aoMapUv),x.push(w.bumpMapUv),x.push(w.normalMapUv),x.push(w.displacementMapUv),x.push(w.emissiveMapUv),x.push(w.metalnessMapUv),x.push(w.roughnessMapUv),x.push(w.anisotropyMapUv),x.push(w.clearcoatMapUv),x.push(w.clearcoatNormalMapUv),x.push(w.clearcoatRoughnessMapUv),x.push(w.iridescenceMapUv),x.push(w.iridescenceThicknessMapUv),x.push(w.sheenColorMapUv),x.push(w.sheenRoughnessMapUv),x.push(w.specularMapUv),x.push(w.specularColorMapUv),x.push(w.specularIntensityMapUv),x.push(w.transmissionMapUv),x.push(w.thicknessMapUv),x.push(w.combine),x.push(w.fogExp2),x.push(w.sizeAttenuation),x.push(w.morphTargetsCount),x.push(w.morphAttributeCount),x.push(w.numSunLights),x.push(w.numDirLights),x.push(w.numPointLights),x.push(w.numSpotLights),x.push(w.numSpotLightMaps),x.push(w.numHemiLights),x.push(w.numRectAreaLights),x.push(w.numSunLightShadows),x.push(w.numDirLightShadows),x.push(w.numPointLightShadows),x.push(w.numSpotLightShadows),x.push(w.numSpotLightShadowsWithMaps),x.push(w.numLightProbes),x.push(w.shadowMapType),x.push(w.toneMapping),x.push(w.numClippingPlanes),x.push(w.numClipIntersection),x.push(w.depthPacking)}function M(x,w){if(o.disableAll(),w.instancing)o.enable(0);if(w.instancingColor)o.enable(1);if(w.instancingMorph)o.enable(2);if(w.matcap)o.enable(3);if(w.envMap)o.enable(4);if(w.normalMapObjectSpace)o.enable(5);if(w.normalMapTangentSpace)o.enable(6);if(w.clearcoat)o.enable(7);if(w.iridescence)o.enable(8);if(w.alphaTest)o.enable(9);if(w.vertexColors)o.enable(10);if(w.vertexAlphas)o.enable(11);if(w.vertexUv1s)o.enable(12);if(w.vertexUv2s)o.enable(13);if(w.vertexUv3s)o.enable(14);if(w.vertexTangents)o.enable(15);if(w.anisotropy)o.enable(16);if(w.alphaHash)o.enable(17);if(w.batching)o.enable(18);if(w.dispersion)o.enable(19);if(w.retroreflection)o.enable(24);if(w.batchingColor)o.enable(20);if(w.gradientMap)o.enable(21);if(w.packedNormalMap)o.enable(22);if(w.vertexNormals)o.enable(23);if(x.push(o.mask),o.disableAll(),w.fog)o.enable(0);if(w.useFog)o.enable(1);if(w.flatShading)o.enable(2);if(w.logarithmicDepthBuffer)o.enable(3);if(w.reversedDepthBuffer)o.enable(4);if(w.skinning)o.enable(5);if(w.morphTargets)o.enable(6);if(w.morphNormals)o.enable(7);if(w.morphColors)o.enable(8);if(w.premultipliedAlpha)o.enable(9);if(w.shadowMapEnabled)o.enable(10);if(w.doubleSided)o.enable(11);if(w.flipSided)o.enable(12);if(w.useDepthPacking)o.enable(13);if(w.dithering)o.enable(14);if(w.transmission)o.enable(15);if(w.sheen)o.enable(16);if(w.opaque)o.enable(17);if(w.pointsUvs)o.enable(18);if(w.decodeVideoTexture)o.enable(19);if(w.decodeVideoTextureEmissive)o.enable(20);if(w.alphaToCoverage)o.enable(21);if(w.numLightProbeGrids>0)o.enable(22);if(w.hasPositionAttribute)o.enable(23);x.push(o.mask)}function T(x){let w=f[x.type],G;if(w){let C=Ei[w];G=Sv.clone(C.uniforms)}else G=x.uniforms;return G}function v(x,w){let G=u.get(w);if(G!==void 0)++G.usedTimes;else G=new FR(e,w,x,r),l.push(G),u.set(w,G);return G}function S(x){if(--x.usedTimes===0){let w=l.indexOf(x);l[w]=l[l.length-1],l.pop(),u.delete(x.cacheKey),x.destroy()}}function E(x){a.remove(x)}function R(){a.dispose()}return{getParameters:_,getProgramCacheKey:p,getUniforms:T,acquireProgram:v,releaseProgram:S,releaseShaderCache:E,programs:l,dispose:R}}function GR(){let e=new WeakMap;function t(o){return e.has(o)}function n(o){let a=e.get(o);if(a===void 0)a={},e.set(o,a);return a}function i(o){e.delete(o)}function r(o,a,c){e.get(o)[a]=c}function s(){e=new WeakMap}return{has:t,get:n,remove:i,update:r,dispose:s}}function HR(e,t){if(e.groupOrder!==t.groupOrder)return e.groupOrder-t.groupOrder;else if(e.renderOrder!==t.renderOrder)return e.renderOrder-t.renderOrder;else if(e.material.id!==t.material.id)return e.material.id-t.material.id;else if(e.materialVariant!==t.materialVariant)return e.materialVariant-t.materialVariant;else if(e.z!==t.z)return e.z-t.z;else return e.id-t.id}function Xv(e,t){if(e.groupOrder!==t.groupOrder)return e.groupOrder-t.groupOrder;else if(e.renderOrder!==t.renderOrder)return e.renderOrder-t.renderOrder;else if(e.z!==t.z)return t.z-e.z;else return e.id-t.id}function jv(){let e=[],t=0,n=[],i=[],r=[];function s(){t=0,n.length=0,i.length=0,r.length=0}function o(d){let f=0;if(d.isInstancedMesh)f+=2;if(d.isSkinnedMesh)f+=1;return f}function a(d,f,m,_,p,g){let M=e[t];if(M===void 0)M={id:d.id,object:d,geometry:f,material:m,materialVariant:o(d),groupOrder:_,renderOrder:d.renderOrder,z:p,group:g},e[t]=M;else M.id=d.id,M.object=d,M.geometry=f,M.material=m,M.materialVariant=o(d),M.groupOrder=_,M.renderOrder=d.renderOrder,M.z=p,M.group=g;return t++,M}function c(d,f,m,_,p,g,M){if(M.reversedDepth===!0)p=-p;let T=a(d,f,m,_,p,g);if(m.transmission>0)i.push(T);else if(m.transparent===!0)r.push(T);else n.push(T)}function l(d,f,m,_,p,g){let M=a(d,f,m,_,p,g);if(m.transmission>0)i.unshift(M);else if(m.transparent===!0)r.unshift(M);else n.unshift(M)}function u(d,f){if(n.length>1)n.sort(d||HR);if(i.length>1)i.sort(f||Xv);if(r.length>1)r.sort(f||Xv)}function h(){for(let d=t,f=e.length;d<f;d++){let m=e[d];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:n,transmissive:i,transparent:r,init:s,push:c,unshift:l,finish:h,sort:u}}function VR(){let e=new WeakMap;function t(i,r){let s=e.get(i),o;if(s===void 0)o=new jv,e.set(i,[o]);else if(r>=s.length)o=new jv,s.push(o);else o=s[r];return o}function n(){e=new WeakMap}return{get:t,dispose:n}}function $R(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case"SunLight":case"DirectionalLight":n={direction:new z,color:new Ge};break;case"SpotLight":n={position:new z,direction:new z,color:new Ge,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new z,color:new Ge,distance:0,decay:0};break;case"HemisphereLight":n={direction:new z,skyColor:new Ge,groundColor:new Ge};break;case"RectAreaLight":n={color:new Ge,position:new z,halfWidth:new z,halfHeight:new z};break}return e[t.id]=n,n}}}function WR(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case"SunLight":case"DirectionalLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ke};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ke};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ke,shadowCameraNear:1,shadowCameraFar:1000};break}return e[t.id]=n,n}}}var ZR=0;function XR(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function jR(e){let t=new $R,n=WR(),i={version:0,hash:{sunLength:-1,directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numSunShadows:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],sun:[],sunShadow:[],sunShadowMap:[],sunShadowMatrix:[],sunShadowCascade:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let l=0;l<9;l++)i.probe.push(new z);let r=new z,s=new Xe,o=new Xe;function a(l){let u=0,h=0,d=0;for(let D=0;D<9;D++)i.probe[D].set(0,0,0);let f=0,m=0,_=0,p=0,g=0,M=0,T=0,v=0,S=0,E=0,R=0,x=0,w=0,G=0;l.sort(XR);for(let D=0,ee=l.length;D<ee;D++){let L=l[D],{color:W,intensity:B,distance:P}=L,J=null;if(L.shadow&&L.shadow.map)if(L.shadow.map.texture.format===qr)J=L.shadow.map.texture;else J=L.shadow.map.depthTexture||L.shadow.map.texture;if(L.isAmbientLight)u+=W.r*B,h+=W.g*B,d+=W.b*B;else if(L.isLightProbe){for(let H=0;H<9;H++)i.probe[H].addScaledVector(L.sh.coefficients[H],B);G++}else if(L.isSunLight){let H=t.get(L);if(H.color.copy(L.color).multiplyScalar(L.intensity),L.castShadow){let q=L.shadow,Q=n.get(L);Q.shadowIntensity=q.intensity,Q.shadowBias=q.bias,Q.shadowNormalBias=q.normalBias,Q.shadowRadius=q.radius,Q.shadowMapSize.copy(q.mapSize).multiply(q.getFrameExtents()),i.sunShadow[m]=Q,i.sunShadowMap[m]=J;let ge=q.getViewportCount();for(let he=0;he<ge;he++)i.sunShadowMatrix[_+he]=q.getMatrix(he),i.sunShadowCascade[_+he]=q._cascadeData[he];_+=ge,m++}i.sun[f]=H,f++}else if(L.isDirectionalLight){let H=t.get(L);if(H.color.copy(L.color).multiplyScalar(L.intensity),L.castShadow){let q=L.shadow,Q=n.get(L);Q.shadowIntensity=q.intensity,Q.shadowBias=q.bias,Q.shadowNormalBias=q.normalBias,Q.shadowRadius=q.radius,Q.shadowMapSize=q.mapSize,i.directionalShadow[p]=Q,i.directionalShadowMap[p]=J,i.directionalShadowMatrix[p]=L.shadow.matrix,S++}i.directional[p]=H,p++}else if(L.isSpotLight){let H=t.get(L);H.position.setFromMatrixPosition(L.matrixWorld),H.color.copy(W).multiplyScalar(B),H.distance=P,H.coneCos=Math.cos(L.angle),H.penumbraCos=Math.cos(L.angle*(1-L.penumbra)),H.decay=L.decay,i.spot[M]=H;let q=L.shadow;if(L.map){if(i.spotLightMap[x]=L.map,x++,q.updateMatrices(L),L.castShadow)w++}if(i.spotLightMatrix[M]=q.matrix,L.castShadow){let Q=n.get(L);Q.shadowIntensity=q.intensity,Q.shadowBias=q.bias,Q.shadowNormalBias=q.normalBias,Q.shadowRadius=q.radius,Q.shadowMapSize=q.mapSize,i.spotShadow[M]=Q,i.spotShadowMap[M]=J,R++}M++}else if(L.isRectAreaLight){let H=t.get(L);H.color.copy(W).multiplyScalar(B),H.halfWidth.set(L.width*0.5,0,0),H.halfHeight.set(0,L.height*0.5,0),i.rectArea[T]=H,T++}else if(L.isPointLight){let H=t.get(L);if(H.color.copy(L.color).multiplyScalar(L.intensity),H.distance=L.distance,H.decay=L.decay,L.castShadow){let q=L.shadow,Q=n.get(L);Q.shadowIntensity=q.intensity,Q.shadowBias=q.bias,Q.shadowNormalBias=q.normalBias,Q.shadowRadius=q.radius,Q.shadowMapSize=q.mapSize,Q.shadowCameraNear=q.camera.near,Q.shadowCameraFar=q.camera.far,i.pointShadow[g]=Q,i.pointShadowMap[g]=J,i.pointShadowMatrix[g]=L.shadow.matrix,E++}i.point[g]=H,g++}else if(L.isHemisphereLight){let H=t.get(L);H.skyColor.copy(L.color).multiplyScalar(B),H.groundColor.copy(L.groundColor).multiplyScalar(B),i.hemi[v]=H,v++}}if(T>0)if(e.has("OES_texture_float_linear")===!0)i.rectAreaLTC1=be.LTC_FLOAT_1,i.rectAreaLTC2=be.LTC_FLOAT_2;else i.rectAreaLTC1=be.LTC_HALF_1,i.rectAreaLTC2=be.LTC_HALF_2;i.ambient[0]=u,i.ambient[1]=h,i.ambient[2]=d;let C=i.hash;if(C.sunLength!==f||C.directionalLength!==p||C.pointLength!==g||C.spotLength!==M||C.rectAreaLength!==T||C.hemiLength!==v||C.numSunShadows!==m||C.numDirectionalShadows!==S||C.numPointShadows!==E||C.numSpotShadows!==R||C.numSpotMaps!==x||C.numLightProbes!==G)i.sun.length=f,i.directional.length=p,i.spot.length=M,i.rectArea.length=T,i.point.length=g,i.hemi.length=v,i.sunShadow.length=m,i.sunShadowMap.length=m,i.sunShadowMatrix.length=_,i.sunShadowCascade.length=_,i.directionalShadow.length=S,i.directionalShadowMap.length=S,i.directionalShadowMatrix.length=S,i.pointShadow.length=E,i.pointShadowMap.length=E,i.pointShadowMatrix.length=E,i.spotShadow.length=R,i.spotShadowMap.length=R,i.spotLightMatrix.length=R+x-w,i.spotLightMap.length=x,i.numSpotLightShadowsWithMaps=w,i.numLightProbes=G,C.sunLength=f,C.directionalLength=p,C.pointLength=g,C.spotLength=M,C.rectAreaLength=T,C.hemiLength=v,C.numSunShadows=m,C.numDirectionalShadows=S,C.numPointShadows=E,C.numSpotShadows=R,C.numSpotMaps=x,C.numLightProbes=G,i.version=ZR++}function c(l,u){let h=0,d=0,f=0,m=0,_=0,p=0,g=u.matrixWorldInverse;for(let M=0,T=l.length;M<T;M++){let v=l[M];if(v.isSunLight){let S=i.sun[h];S.direction.setFromMatrixPosition(v.matrixWorld),S.direction.transformDirection(g),h++}else if(v.isDirectionalLight){let S=i.directional[d];S.direction.setFromMatrixPosition(v.matrixWorld),r.setFromMatrixPosition(v.target.matrixWorld),S.direction.sub(r),S.direction.transformDirection(g),d++}else if(v.isSpotLight){let S=i.spot[m];S.position.setFromMatrixPosition(v.matrixWorld),S.position.applyMatrix4(g),S.direction.setFromMatrixPosition(v.matrixWorld),r.setFromMatrixPosition(v.target.matrixWorld),S.direction.sub(r),S.direction.transformDirection(g),m++}else if(v.isRectAreaLight){let S=i.rectArea[_];S.position.setFromMatrixPosition(v.matrixWorld),S.position.applyMatrix4(g),o.identity(),s.copy(v.matrixWorld),s.premultiply(g),o.extractRotation(s),S.halfWidth.set(v.width*0.5,0,0),S.halfHeight.set(0,v.height*0.5,0),S.halfWidth.applyMatrix4(o),S.halfHeight.applyMatrix4(o),_++}else if(v.isPointLight){let S=i.point[f];S.position.setFromMatrixPosition(v.matrixWorld),S.position.applyMatrix4(g),f++}else if(v.isHemisphereLight){let S=i.hemi[p];S.direction.setFromMatrixPosition(v.matrixWorld),S.direction.transformDirection(g),p++}}}return{setup:a,setupView:c,state:i}}function qv(e){let t=new jR(e),n=[],i=[],r=[];function s(d){h.camera=d,n.length=0,i.length=0,r.length=0}function o(d){n.push(d)}function a(d){i.push(d)}function c(d){r.push(d)}function l(){t.setup(n)}function u(d){t.setupView(n,d)}let h={lightsArray:n,shadowsArray:i,lightProbeGridArray:r,camera:null,lights:t,transmissionRenderTarget:{},textureUnits:0};return{init:s,state:h,setupLights:l,setupLightsView:u,pushLight:o,pushShadow:a,pushLightProbeGrid:c}}function qR(e){let t=new WeakMap;function n(r,s=0){let o=t.get(r),a;if(o===void 0)a=new qv(e),t.set(r,[a]);else if(s>=o.length)a=new qv(e),o.push(a);else a=o[s];return a}function i(){t=new WeakMap}return{get:n,dispose:i}}var YR=`void main() {
4231
4231
  gl_Position = vec4( position, 1.0 );
4232
- }`,qR=`uniform sampler2D shadow_pass;
4232
+ }`,KR=`uniform sampler2D shadow_pass;
4233
4233
  uniform vec2 resolution;
4234
4234
  uniform float radius;
4235
4235
  void main() {
@@ -4254,12 +4254,12 @@ void main() {
4254
4254
  squared_mean = squared_mean / samples;
4255
4255
  float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );
4256
4256
  gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );
4257
- }`,YR=[new F(1,0,0),new F(-1,0,0),new F(0,1,0),new F(0,-1,0),new F(0,0,1),new F(0,0,-1)],KR=[new F(0,-1,0),new F(0,-1,0),new F(0,0,1),new F(0,0,-1),new F(0,-1,0),new F(0,-1,0)],qv=new Xe,aa=new F,Fd=new F;function JR(e,t,n){let i=new Jo,r=new Be,s=new Be,o=new pt,a=new _d,c=new xd,l={},u=n.maxTextureSize,h={[fr]:cn,[cn]:fr,[Bn]:Bn},d=new Gn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Be},radius:{value:4}},vertexShader:jR,fragmentShader:qR}),f=d.clone();f.defines.HORIZONTAL_PASS=1;let m=new ln;m.setAttribute("position",new Kt(new Float32Array([-1,-1,0.5,3,-1,0.5,-1,3,0.5]),3));let _=new Mt(m,d),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=ko;let g=this.type;this.render=function(E,R,x){if(p.enabled===!1)return;if(p.autoUpdate===!1&&p.needsUpdate===!1)return;if(E.length===0)return;if(this.type===Ex)Ue("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=ko;let w=e.getRenderTarget(),H=e.getActiveCubeFace(),C=e.getActiveMipmapLevel(),N=e.state;if(N.setBlending(vi),N.buffers.depth.getReversed()===!0)N.buffers.color.setClear(0,0,0,0);else N.buffers.color.setClear(1,1,1,1);N.buffers.depth.setTest(!0),N.setScissorTest(!1);let ee=g!==this.type;if(ee)R.traverse(function(P){if(P.material)if(Array.isArray(P.material))P.material.forEach((Z)=>Z.needsUpdate=!0);else P.material.needsUpdate=!0});for(let P=0,Z=E.length;P<Z;P++){let G=E[P],k=G.shadow;if(k===void 0){Ue("WebGLShadowMap:",G,"has no shadow.");continue}if(k.autoUpdate===!1&&k.needsUpdate===!1)continue;r.copy(k.mapSize);let W=k.getFrameExtents();if(r.multiply(W),s.copy(k.mapSize),r.x>u||r.y>u){if(r.x>u)s.x=Math.floor(u/W.x),r.x=s.x*W.x,k.mapSize.x=s.x;if(r.y>u)s.y=Math.floor(u/W.y),r.y=s.y*W.y,k.mapSize.y=s.y}let B=e.state.buffers.depth.getReversed();if(k.camera._reversedDepth=B,k.map===null||ee===!0){if(k.map!==null){if(k.map.depthTexture!==null)k.map.depthTexture.dispose(),k.map.depthTexture=null;k.map.dispose()}if(this.type===Cs){if(G.isPointLight){Ue("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}k.map=new Cn(r.x,r.y,{format:jr,type:bi,minFilter:Jt,magFilter:Jt,generateMipmaps:!1}),k.map.texture.name=G.name+".shadowMap",k.map.depthTexture=new Yr(r.x,r.y,Vi),k.map.depthTexture.name=G.name+".shadowMapDepth",k.map.depthTexture.format=Zr,k.map.depthTexture.compareFunction=null,k.map.depthTexture.minFilter=ti,k.map.depthTexture.magFilter=ti}else{if(G.isPointLight)k.map=new Bd(r.x),k.map.depthTexture=new pd(r.x,pr);else k.map=new Cn(r.x,r.y),k.map.depthTexture=new Yr(r.x,r.y,pr);if(k.map.depthTexture.name=G.name+".shadowMap",k.map.depthTexture.format=Zr,this.type===ko)k.map.depthTexture.compareFunction=B?Xc:Zc,k.map.depthTexture.minFilter=Jt,k.map.depthTexture.magFilter=Jt;else k.map.depthTexture.compareFunction=null,k.map.depthTexture.minFilter=ti,k.map.depthTexture.magFilter=ti}k.camera.updateProjectionMatrix()}if(k.map.isWebGLCubeRenderTarget!==!0&&(k.map.width!==r.x||k.map.height!==r.y))k.map.setSize(r.x,r.y);let Y=k.map.isWebGLCubeRenderTarget?6:k.getViewportCount();if(G.isPointLight!==!0)k.updateMatrices(G,x);for(let K=0;K<Y;K++){let ge=k.getCamera(K);if(G.isPointLight){let{camera:de,matrix:fe}=k,he=G.distance||de.far;if(he!==de.far)de.far=he,de.updateProjectionMatrix();aa.setFromMatrixPosition(G.matrixWorld),de.position.copy(aa),Fd.copy(de.position),Fd.add(YR[K]),de.up.copy(KR[K]),de.lookAt(Fd),de.updateMatrixWorld(),fe.makeTranslation(-aa.x,-aa.y,-aa.z),qv.multiplyMatrices(de.projectionMatrix,de.matrixWorldInverse),k._frustum.setFromProjectionMatrix(qv,de.coordinateSystem,de.reversedDepth)}if(k.map.isWebGLCubeRenderTarget)e.setRenderTarget(k.map,K),e.clear();else{if(K===0)e.setRenderTarget(k.map),e.clear();let de=k.getViewport(K);o.set(s.x*de.x,s.y*de.y,s.x*de.z,s.y*de.w),N.viewport(o)}i=k.getFrustum(K),v(R,x,ge,G,this.type)}if(k.isPointLightShadow!==!0&&this.type===Cs)M(k,x);k.needsUpdate=!1}g=this.type,p.needsUpdate=!1,e.setRenderTarget(w,H,C)};function M(E,R){let x=t.update(_);if(d.defines.VSM_SAMPLES!==E.blurSamples)d.defines.VSM_SAMPLES=E.blurSamples,f.defines.VSM_SAMPLES=E.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0;if(E.mapPass===null)E.mapPass=new Cn(r.x,r.y,{format:jr,type:bi});else if(E.mapPass.width!==E.map.width||E.mapPass.height!==E.map.height)E.mapPass.setSize(E.map.width,E.map.height);d.uniforms.shadow_pass.value=E.map.depthTexture,d.uniforms.resolution.value.set(E.map.width,E.map.height),d.uniforms.radius.value=E.radius,e.setRenderTarget(E.mapPass),e.clear(),e.renderBufferDirect(R,null,x,d,_,null),f.uniforms.shadow_pass.value=E.mapPass.texture,f.uniforms.resolution.value.set(E.map.width,E.map.height),f.uniforms.radius.value=E.radius,e.setRenderTarget(E.map),e.clear(),e.renderBufferDirect(R,null,x,f,_,null)}function T(E,R,x,w){let H=null,C=x.isPointLight===!0?E.customDistanceMaterial:E.customDepthMaterial;if(C!==void 0)H=C;else if(H=x.isPointLight===!0?c:a,e.localClippingEnabled&&R.clipShadows===!0&&Array.isArray(R.clippingPlanes)&&R.clippingPlanes.length!==0||R.displacementMap&&R.displacementScale!==0||R.alphaMap&&R.alphaTest>0||R.map&&R.alphaTest>0||R.alphaToCoverage===!0){let N=H.uuid,ee=R.uuid,P=l[N];if(P===void 0)P={},l[N]=P;let Z=P[ee];if(Z===void 0)Z=H.clone(),P[ee]=Z,R.addEventListener("dispose",S);H=Z}if(H.visible=R.visible,H.wireframe=R.wireframe,w===Cs)H.side=R.shadowSide!==null?R.shadowSide:R.side;else H.side=R.shadowSide!==null?R.shadowSide:h[R.side];if(H.alphaMap=R.alphaMap,H.alphaTest=R.alphaToCoverage===!0?0.5:R.alphaTest,H.map=R.map,H.clipShadows=R.clipShadows,H.clippingPlanes=R.clippingPlanes,H.clipIntersection=R.clipIntersection,H.displacementMap=R.displacementMap,H.displacementScale=R.displacementScale,H.displacementBias=R.displacementBias,H.wireframeLinewidth=R.wireframeLinewidth,H.linewidth=R.linewidth,x.isPointLight===!0&&H.isMeshDistanceMaterial===!0){let N=e.properties.get(H);N.light=x}return H}function v(E,R,x,w,H){if(E.visible===!1)return;if(E.layers.test(R.layers)&&(E.isMesh||E.isLine||E.isPoints)){if((E.castShadow||E.receiveShadow&&H===Cs)&&(!E.frustumCulled||E.intersectsFrustum(i))){E.modelViewMatrix.multiplyMatrices(x.matrixWorldInverse,E.matrixWorld);let ee=t.update(E),P=E.material;if(Array.isArray(P)){let Z=ee.groups;for(let G=0,k=Z.length;G<k;G++){let W=Z[G],B=P[W.materialIndex];if(B&&B.visible){let Y=T(E,B,w,H);E.onBeforeShadow(e,E,R,x,ee,Y,W),e.renderBufferDirect(x,null,ee,Y,E,W),E.onAfterShadow(e,E,R,x,ee,Y,W)}}}else if(P.visible){let Z=T(E,P,w,H);E.onBeforeShadow(e,E,R,x,ee,Z,null),e.renderBufferDirect(x,null,ee,Z,E,null),E.onAfterShadow(e,E,R,x,ee,Z,null)}}}let N=E.children;for(let ee=0,P=N.length;ee<P;ee++)v(N[ee],R,x,w,H)}function S(E){E.target.removeEventListener("dispose",S);for(let x in l){let w=l[x],H=E.target.uuid;if(H in w)w[H].dispose(),delete w[H]}}}function QR(e,t){function n(){let z=!1,_e=new pt,ne=null,xe=new pt(0,0,0,0);return{setMask:function(Te){if(ne!==Te&&!z)e.colorMask(Te,Te,Te,Te),ne=Te},setLocked:function(Te){z=Te},setClear:function(Te,le,Se,Ze,bt){if(bt===!0)Te*=Ze,le*=Ze,Se*=Ze;if(_e.set(Te,le,Se,Ze),xe.equals(_e)===!1)e.clearColor(Te,le,Se,Ze),xe.copy(_e)},reset:function(){z=!1,ne=null,xe.set(-1,0,0,0)}}}function i(){let z=!1,_e=!1,ne=null,xe=null,Te=null;return{setReversed:function(le){if(_e!==le){let Se=t.get("EXT_clip_control");if(le)Se.clipControlEXT(Se.LOWER_LEFT_EXT,Se.ZERO_TO_ONE_EXT);else Se.clipControlEXT(Se.LOWER_LEFT_EXT,Se.NEGATIVE_ONE_TO_ONE_EXT);_e=le;let Ze=Te;Te=null,this.setClear(Ze)}},getReversed:function(){return _e},setTest:function(le){if(le)q(e.DEPTH_TEST);else se(e.DEPTH_TEST)},setMask:function(le){if(ne!==le&&!z)e.depthMask(le),ne=le},setFunc:function(le){if(_e)le=vv[le];if(xe!==le){switch(le){case Zx:e.depthFunc(e.NEVER);break;case Xx:e.depthFunc(e.ALWAYS);break;case jx:e.depthFunc(e.LESS);break;case mh:e.depthFunc(e.LEQUAL);break;case qx:e.depthFunc(e.EQUAL);break;case Yx:e.depthFunc(e.GEQUAL);break;case Kx:e.depthFunc(e.GREATER);break;case Jx:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}xe=le}},setLocked:function(le){z=le},setClear:function(le){if(Te!==le){if(Te=le,_e)le=1-le;e.clearDepth(le)}},reset:function(){z=!1,ne=null,xe=null,Te=null,_e=!1}}}function r(){let z=!1,_e=null,ne=null,xe=null,Te=null,le=null,Se=null,Ze=null,bt=null;return{setTest:function(ht){if(!z)if(ht)q(e.STENCIL_TEST);else se(e.STENCIL_TEST)},setMask:function(ht){if(_e!==ht&&!z)e.stencilMask(ht),_e=ht},setFunc:function(ht,oi,Pi){if(ne!==ht||xe!==oi||Te!==Pi)e.stencilFunc(ht,oi,Pi),ne=ht,xe=oi,Te=Pi},setOp:function(ht,oi,Pi){if(le!==ht||Se!==oi||Ze!==Pi)e.stencilOp(ht,oi,Pi),le=ht,Se=oi,Ze=Pi},setLocked:function(ht){z=ht},setClear:function(ht){if(bt!==ht)e.clearStencil(ht),bt=ht},reset:function(){z=!1,_e=null,ne=null,xe=null,Te=null,le=null,Se=null,Ze=null,bt=null}}}let s=new n,o=new i,a=new r,c=new WeakMap,l=new WeakMap,u={},h={},d={},f=new WeakMap,m=[],_=null,p=!1,g=null,M=null,T=null,v=null,S=null,E=null,R=null,x=new He(0,0,0),w=0,H=!1,C=null,N=null,ee=null,P=null,Z=null,G=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),k=!1,W=0,B=e.getParameter(e.VERSION);if(B.indexOf("WebGL")!==-1)W=parseFloat(/^WebGL (\d)/.exec(B)[1]),k=W>=1;else if(B.indexOf("OpenGL ES")!==-1)W=parseFloat(/^OpenGL ES (\d)/.exec(B)[1]),k=W>=2;let Y=null,K={},ge=e.getParameter(e.SCISSOR_BOX),de=e.getParameter(e.VIEWPORT),fe=new pt().fromArray(ge),he=new pt().fromArray(de);function I(z,_e,ne,xe){let Te=new Uint8Array(4),le=e.createTexture();e.bindTexture(z,le),e.texParameteri(z,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(z,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let Se=0;Se<ne;Se++)if(z===e.TEXTURE_3D||z===e.TEXTURE_2D_ARRAY)e.texImage3D(_e,0,e.RGBA,1,1,xe,0,e.RGBA,e.UNSIGNED_BYTE,Te);else e.texImage2D(_e+Se,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,Te);return le}let V={};V[e.TEXTURE_2D]=I(e.TEXTURE_2D,e.TEXTURE_2D,1),V[e.TEXTURE_CUBE_MAP]=I(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),V[e.TEXTURE_2D_ARRAY]=I(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),V[e.TEXTURE_3D]=I(e.TEXTURE_3D,e.TEXTURE_3D,1,1),s.setClear(0,0,0,1),o.setClear(1),a.setClear(0),q(e.DEPTH_TEST),o.setFunc(mh),Rt(!1),it(hh),q(e.CULL_FACE),rt(vi);function q(z){if(u[z]!==!0)e.enable(z),u[z]=!0}function se(z){if(u[z]!==!1)e.disable(z),u[z]=!1}function ce(z,_e){if(d[z]!==_e){if(e.bindFramebuffer(z,_e),d[z]=_e,z===e.DRAW_FRAMEBUFFER)d[e.FRAMEBUFFER]=_e;if(z===e.FRAMEBUFFER)d[e.DRAW_FRAMEBUFFER]=_e;return!0}return!1}function ae(z,_e){let ne=m,xe=!1;if(z){if(ne=f.get(_e),ne===void 0)ne=[],f.set(_e,ne);let Te=z.textures;if(ne.length!==Te.length||ne[0]!==e.COLOR_ATTACHMENT0){for(let le=0,Se=Te.length;le<Se;le++)ne[le]=e.COLOR_ATTACHMENT0+le;ne.length=Te.length,xe=!0}}else if(ne[0]!==e.BACK)ne[0]=e.BACK,xe=!0;if(xe)e.drawBuffers(ne)}function ke(z){if(_!==z)return e.useProgram(z),_=z,!0;return!1}let Ce={[Is]:e.FUNC_ADD,[Ax]:e.FUNC_SUBTRACT,[Rx]:e.FUNC_REVERSE_SUBTRACT};Ce[Cx]=e.MIN,Ce[Ix]=e.MAX;let Ve={[Px]:e.ZERO,[Lx]:e.ONE,[Nx]:e.SRC_COLOR,[Ox]:e.SRC_ALPHA,[Gx]:e.SRC_ALPHA_SATURATE,[kx]:e.DST_COLOR,[Fx]:e.DST_ALPHA,[Dx]:e.ONE_MINUS_SRC_COLOR,[Ux]:e.ONE_MINUS_SRC_ALPHA,[Bx]:e.ONE_MINUS_DST_COLOR,[zx]:e.ONE_MINUS_DST_ALPHA,[Hx]:e.CONSTANT_COLOR,[Vx]:e.ONE_MINUS_CONSTANT_COLOR,[$x]:e.CONSTANT_ALPHA,[Wx]:e.ONE_MINUS_CONSTANT_ALPHA};function rt(z,_e,ne,xe,Te,le,Se,Ze,bt,ht){if(z===vi){if(p===!0)se(e.BLEND),p=!1;return}if(p===!1)q(e.BLEND),p=!0;if(z!==Tx){if(z!==g||ht!==H){if(M!==Is||S!==Is)e.blendEquation(e.FUNC_ADD),M=Is,S=Is;if(ht)switch(z){case Bo:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case dh:e.blendFunc(e.ONE,e.ONE);break;case fh:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case ph:e.blendFuncSeparate(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ZERO,e.ONE);break;default:$e("WebGLState: Invalid blending: ",z);break}else switch(z){case Bo:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case dh:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE);break;case fh:$e("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case ph:$e("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:$e("WebGLState: Invalid blending: ",z);break}T=null,v=null,E=null,R=null,x.set(0,0,0),w=0,g=z,H=ht}return}if(Te=Te||_e,le=le||ne,Se=Se||xe,_e!==M||Te!==S)e.blendEquationSeparate(Ce[_e],Ce[Te]),M=_e,S=Te;if(ne!==T||xe!==v||le!==E||Se!==R)e.blendFuncSeparate(Ve[ne],Ve[xe],Ve[le],Ve[Se]),T=ne,v=xe,E=le,R=Se;if(Ze.equals(x)===!1||bt!==w)e.blendColor(Ze.r,Ze.g,Ze.b,bt),x.copy(Ze),w=bt;g=z,H=!1}function nt(z,_e){z.side===Bn?se(e.CULL_FACE):q(e.CULL_FACE);let ne=z.side===cn;if(_e)ne=!ne;Rt(ne),z.blending===Bo&&z.transparent===!1?rt(vi):rt(z.blending,z.blendEquation,z.blendSrc,z.blendDst,z.blendEquationAlpha,z.blendSrcAlpha,z.blendDstAlpha,z.blendColor,z.blendAlpha,z.premultipliedAlpha),o.setFunc(z.depthFunc),o.setTest(z.depthTest),o.setMask(z.depthWrite),s.setMask(z.colorWrite);let xe=z.stencilWrite;if(a.setTest(xe),xe)a.setMask(z.stencilWriteMask),a.setFunc(z.stencilFunc,z.stencilRef,z.stencilFuncMask),a.setOp(z.stencilFail,z.stencilZFail,z.stencilZPass);Ut(z.polygonOffset,z.polygonOffsetFactor,z.polygonOffsetUnits),z.alphaToCoverage===!0?q(e.SAMPLE_ALPHA_TO_COVERAGE):se(e.SAMPLE_ALPHA_TO_COVERAGE)}function Rt(z){if(C!==z){if(z)e.frontFace(e.CW);else e.frontFace(e.CCW);C=z}}function it(z){if(z!==wx){if(q(e.CULL_FACE),z!==N)if(z===hh)e.cullFace(e.BACK);else if(z===Mx)e.cullFace(e.FRONT);else e.cullFace(e.FRONT_AND_BACK)}else se(e.CULL_FACE);N=z}function tn(z){if(z!==ee){if(k)e.lineWidth(z);ee=z}}function Ut(z,_e,ne){if(z){if(q(e.POLYGON_OFFSET_FILL),P!==_e||Z!==ne){if(P=_e,Z=ne,o.getReversed())_e=-_e;e.polygonOffset(_e,ne)}}else se(e.POLYGON_OFFSET_FILL)}function It(z){if(z)q(e.SCISSOR_TEST);else se(e.SCISSOR_TEST)}function D(z){if(z===void 0)z=e.TEXTURE0+G-1;if(Y!==z)e.activeTexture(z),Y=z}function _n(z,_e,ne){if(ne===void 0)if(Y===null)ne=e.TEXTURE0+G-1;else ne=Y;let xe=K[ne];if(xe===void 0)xe={type:void 0,texture:void 0},K[ne]=xe;if(xe.type!==z||xe.texture!==_e){if(Y!==ne)e.activeTexture(ne),Y=ne;e.bindTexture(z,_e||V[z]),xe.type=z,xe.texture=_e}}function ut(){let z=K[Y];if(z!==void 0&&z.type!==void 0)e.bindTexture(z.type,null),z.type=void 0,z.texture=void 0}function Pt(){try{e.compressedTexImage2D(...arguments)}catch(z){$e("WebGLState:",z)}}function A(){try{e.compressedTexImage3D(...arguments)}catch(z){$e("WebGLState:",z)}}function y(){try{e.texSubImage2D(...arguments)}catch(z){$e("WebGLState:",z)}}function O(){try{e.texSubImage3D(...arguments)}catch(z){$e("WebGLState:",z)}}function J(){try{e.compressedTexSubImage2D(...arguments)}catch(z){$e("WebGLState:",z)}}function ue(){try{e.compressedTexSubImage3D(...arguments)}catch(z){$e("WebGLState:",z)}}function me(){try{e.texStorage2D(...arguments)}catch(z){$e("WebGLState:",z)}}function ve(){try{e.texStorage3D(...arguments)}catch(z){$e("WebGLState:",z)}}function te(){try{e.texImage2D(...arguments)}catch(z){$e("WebGLState:",z)}}function re(){try{e.texImage3D(...arguments)}catch(z){$e("WebGLState:",z)}}function Ee(z){if(h[z]!==void 0)return h[z];else return e.getParameter(z)}function Oe(z,_e){if(h[z]!==_e)e.pixelStorei(z,_e),h[z]=_e}function ye(z){if(fe.equals(z)===!1)e.scissor(z.x,z.y,z.z,z.w),fe.copy(z)}function pe(z){if(he.equals(z)===!1)e.viewport(z.x,z.y,z.z,z.w),he.copy(z)}function ze(z,_e){let ne=l.get(_e);if(ne===void 0)ne=new WeakMap,l.set(_e,ne);let xe=ne.get(z);if(xe===void 0)xe=e.getUniformBlockIndex(_e,z.name),ne.set(z,xe)}function Ge(z,_e){let xe=l.get(_e).get(z);if(c.get(_e)!==xe)e.uniformBlockBinding(_e,xe,z.__bindingPointIndex),c.set(_e,xe)}function ot(){e.disable(e.BLEND),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.blendColor(0,0,0,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(e.LESS),o.setReversed(!1),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),e.pixelStorei(e.PACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.BROWSER_DEFAULT_WEBGL),e.pixelStorei(e.PACK_ROW_LENGTH,0),e.pixelStorei(e.PACK_SKIP_PIXELS,0),e.pixelStorei(e.PACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_ROW_LENGTH,0),e.pixelStorei(e.UNPACK_IMAGE_HEIGHT,0),e.pixelStorei(e.UNPACK_SKIP_PIXELS,0),e.pixelStorei(e.UNPACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_SKIP_IMAGES,0),u={},h={},Y=null,K={},d={},f=new WeakMap,m=[],_=null,p=!1,g=null,M=null,T=null,v=null,S=null,E=null,R=null,x=new He(0,0,0),w=0,H=!1,C=null,N=null,ee=null,P=null,Z=null,fe.set(0,0,e.canvas.width,e.canvas.height),he.set(0,0,e.canvas.width,e.canvas.height),s.reset(),o.reset(),a.reset()}return{buffers:{color:s,depth:o,stencil:a},enable:q,disable:se,bindFramebuffer:ce,drawBuffers:ae,useProgram:ke,setBlending:rt,setMaterial:nt,setFlipSided:Rt,setCullFace:it,setLineWidth:tn,setPolygonOffset:Ut,setScissorTest:It,activeTexture:D,bindTexture:_n,unbindTexture:ut,compressedTexImage2D:Pt,compressedTexImage3D:A,texImage2D:te,texImage3D:re,pixelStorei:Oe,getParameter:Ee,updateUBOMapping:ze,uniformBlockBinding:Ge,texStorage2D:me,texStorage3D:ve,texSubImage2D:y,texSubImage3D:O,compressedTexSubImage2D:J,compressedTexSubImage3D:ue,scissor:ye,viewport:pe,reset:ot}}function eC(e,t,n,i,r,s,o){let a=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new Be,u=new WeakMap,h=new Set,d,f=new WeakMap,m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch(A){}function _(A,y){return m?new OffscreenCanvas(A,y):Ts("canvas")}function p(A,y,O){let J=1,ue=Pt(A);if(ue.width>O||ue.height>O)J=O/Math.max(ue.width,ue.height);if(J<1)if(typeof HTMLImageElement<"u"&&A instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&A instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&A instanceof ImageBitmap||typeof VideoFrame<"u"&&A instanceof VideoFrame){let me=Math.floor(J*ue.width),ve=Math.floor(J*ue.height);if(d===void 0)d=_(me,ve);let te=y?_(me,ve):d;return te.width=me,te.height=ve,te.getContext("2d").drawImage(A,0,0,me,ve),Ue("WebGLRenderer: Texture has been resized from ("+ue.width+"x"+ue.height+") to ("+me+"x"+ve+")."),te}else{if("data"in A)Ue("WebGLRenderer: Image in DataTexture is too big ("+ue.width+"x"+ue.height+").");return A}return A}function g(A){return A.generateMipmaps}function M(A){e.generateMipmap(A)}function T(A){if(A.isWebGLCubeRenderTarget)return e.TEXTURE_CUBE_MAP;if(A.isWebGL3DRenderTarget)return e.TEXTURE_3D;if(A.isWebGLArrayRenderTarget||A.isCompressedArrayTexture)return e.TEXTURE_2D_ARRAY;return e.TEXTURE_2D}function v(A,y,O,J,ue,me=!1){if(A!==null){if(e[A]!==void 0)return e[A];Ue("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+A+"'")}let ve;if(J){if(ve=t.get("EXT_texture_norm16"),!ve)Ue("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension")}let te=y;if(y===e.RED){if(O===e.FLOAT)te=e.R32F;if(O===e.HALF_FLOAT)te=e.R16F;if(O===e.UNSIGNED_BYTE)te=e.R8;if(O===e.UNSIGNED_SHORT&&ve)te=ve.R16_EXT;if(O===e.SHORT&&ve)te=ve.R16_SNORM_EXT}if(y===e.RED_INTEGER){if(O===e.UNSIGNED_BYTE)te=e.R8UI;if(O===e.UNSIGNED_SHORT)te=e.R16UI;if(O===e.UNSIGNED_INT)te=e.R32UI;if(O===e.BYTE)te=e.R8I;if(O===e.SHORT)te=e.R16I;if(O===e.INT)te=e.R32I}if(y===e.RG){if(O===e.FLOAT)te=e.RG32F;if(O===e.HALF_FLOAT)te=e.RG16F;if(O===e.UNSIGNED_BYTE)te=e.RG8;if(O===e.UNSIGNED_SHORT&&ve)te=ve.RG16_EXT;if(O===e.SHORT&&ve)te=ve.RG16_SNORM_EXT}if(y===e.RG_INTEGER){if(O===e.UNSIGNED_BYTE)te=e.RG8UI;if(O===e.UNSIGNED_SHORT)te=e.RG16UI;if(O===e.UNSIGNED_INT)te=e.RG32UI;if(O===e.BYTE)te=e.RG8I;if(O===e.SHORT)te=e.RG16I;if(O===e.INT)te=e.RG32I}if(y===e.RGB_INTEGER){if(O===e.UNSIGNED_BYTE)te=e.RGB8UI;if(O===e.UNSIGNED_SHORT)te=e.RGB16UI;if(O===e.UNSIGNED_INT)te=e.RGB32UI;if(O===e.BYTE)te=e.RGB8I;if(O===e.SHORT)te=e.RGB16I;if(O===e.INT)te=e.RGB32I}if(y===e.RGBA_INTEGER){if(O===e.UNSIGNED_BYTE)te=e.RGBA8UI;if(O===e.UNSIGNED_SHORT)te=e.RGBA16UI;if(O===e.UNSIGNED_INT)te=e.RGBA32UI;if(O===e.BYTE)te=e.RGBA8I;if(O===e.SHORT)te=e.RGBA16I;if(O===e.INT)te=e.RGBA32I}if(y===e.RGB){if(O===e.UNSIGNED_SHORT&&ve)te=ve.RGB16_EXT;if(O===e.SHORT&&ve)te=ve.RGB16_SNORM_EXT;if(O===e.UNSIGNED_INT_5_9_9_9_REV)te=e.RGB9_E5;if(O===e.UNSIGNED_INT_10F_11F_11F_REV)te=e.R11F_G11F_B10F}if(y===e.RGBA){let re=me?ad:Ke.getTransfer(ue);if(O===e.FLOAT)te=e.RGBA32F;if(O===e.HALF_FLOAT)te=e.RGBA16F;if(O===e.UNSIGNED_BYTE)te=re===yt?e.SRGB8_ALPHA8:e.RGBA8;if(O===e.UNSIGNED_SHORT&&ve)te=ve.RGBA16_EXT;if(O===e.SHORT&&ve)te=ve.RGBA16_SNORM_EXT;if(O===e.UNSIGNED_SHORT_4_4_4_4)te=e.RGBA4;if(O===e.UNSIGNED_SHORT_5_5_5_1)te=e.RGB5_A1}if(te===e.R16F||te===e.R32F||te===e.RG16F||te===e.RG32F||te===e.RGBA16F||te===e.RGBA32F)t.get("EXT_color_buffer_float");return te}function S(A,y){let O;if(A){if(y===null||y===pr||y===Os)O=e.DEPTH24_STENCIL8;else if(y===Vi)O=e.DEPTH32F_STENCIL8;else if(y===Vo)O=e.DEPTH24_STENCIL8,Ue("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")}else if(y===null||y===pr||y===Os)O=e.DEPTH_COMPONENT24;else if(y===Vi)O=e.DEPTH_COMPONENT32F;else if(y===Vo)O=e.DEPTH_COMPONENT16;return O}function E(A,y){if(g(A)===!0||A.isFramebufferTexture&&A.minFilter!==ti&&A.minFilter!==Jt)return Math.log2(Math.max(y.width,y.height))+1;else if(A.mipmaps!==void 0&&A.mipmaps.length>0)return A.mipmaps.length;else if(A.isCompressedTexture&&Array.isArray(A.image))return y.mipmaps.length;else return 1}function R(A){let y=A.target;if(y.removeEventListener("dispose",R),w(y),y.isVideoTexture)u.delete(y);if(y.isHTMLTexture)h.delete(y)}function x(A){let y=A.target;y.removeEventListener("dispose",x),C(y)}function w(A){let y=i.get(A);if(y.__webglInit===void 0)return;let O=A.source,J=f.get(O);if(J){let ue=J[y.__cacheKey];if(ue.usedTimes--,ue.usedTimes===0)H(A);if(Object.keys(J).length===0)f.delete(O)}i.remove(A)}function H(A){let y=i.get(A);e.deleteTexture(y.__webglTexture);let O=A.source,J=f.get(O);delete J[y.__cacheKey],o.memory.textures--}function C(A){let y=i.get(A);if(A.depthTexture)A.depthTexture.dispose(),i.remove(A.depthTexture);if(A.isWebGLCubeRenderTarget)for(let J=0;J<6;J++){if(Array.isArray(y.__webglFramebuffer[J]))for(let ue=0;ue<y.__webglFramebuffer[J].length;ue++)e.deleteFramebuffer(y.__webglFramebuffer[J][ue]);else e.deleteFramebuffer(y.__webglFramebuffer[J]);if(y.__webglDepthbuffer)e.deleteRenderbuffer(y.__webglDepthbuffer[J])}else{if(Array.isArray(y.__webglFramebuffer))for(let J=0;J<y.__webglFramebuffer.length;J++)e.deleteFramebuffer(y.__webglFramebuffer[J]);else e.deleteFramebuffer(y.__webglFramebuffer);if(y.__webglDepthbuffer)e.deleteRenderbuffer(y.__webglDepthbuffer);if(y.__webglMultisampledFramebuffer)e.deleteFramebuffer(y.__webglMultisampledFramebuffer);if(y.__webglColorRenderbuffer){for(let J=0;J<y.__webglColorRenderbuffer.length;J++)if(y.__webglColorRenderbuffer[J])e.deleteRenderbuffer(y.__webglColorRenderbuffer[J])}if(y.__webglDepthRenderbuffer)e.deleteRenderbuffer(y.__webglDepthRenderbuffer)}let O=A.textures;for(let J=0,ue=O.length;J<ue;J++){let me=i.get(O[J]);if(me.__webglTexture)e.deleteTexture(me.__webglTexture),o.memory.textures--;i.remove(O[J])}i.remove(A)}let N=0;function ee(){N=0}function P(){return N}function Z(A){N=A}function G(){let A=N;if(A>=r.maxTextures)Ue("WebGLTextures: Trying to use "+(A+1)+" texture units while this GPU supports only "+r.maxTextures);return N+=1,A}function k(A){let y=[];return y.push(A.wrapS),y.push(A.wrapT),y.push(A.wrapR||0),y.push(A.magFilter),y.push(A.minFilter),y.push(A.anisotropy),y.push(A.internalFormat),y.push(A.format),y.push(A.type),y.push(A.generateMipmaps),y.push(A.premultiplyAlpha),y.push(A.flipY),y.push(A.unpackAlignment),y.push(A.colorSpace),y.join()}function W(A,y){let O=i.get(A);if(A.isVideoTexture)_n(A);if(A.isRenderTargetTexture===!1&&A.isExternalTexture!==!0&&A.version>0&&O.__version!==A.version){let J=A.image;if(J===null)Ue("WebGLRenderer: Texture marked for update but no image data found.");else if(J.complete===!1)Ue("WebGLRenderer: Texture marked for update but image is incomplete");else{se(O,A,y);return}}else if(A.isExternalTexture)O.__webglTexture=A.sourceTexture?A.sourceTexture:null;n.bindTexture(e.TEXTURE_2D,O.__webglTexture,e.TEXTURE0+y)}function B(A,y){let O=i.get(A);if(A.isRenderTargetTexture===!1&&A.version>0&&O.__version!==A.version){se(O,A,y);return}else if(A.isExternalTexture)O.__webglTexture=A.sourceTexture?A.sourceTexture:null;n.bindTexture(e.TEXTURE_2D_ARRAY,O.__webglTexture,e.TEXTURE0+y)}function Y(A,y){let O=i.get(A);if(A.isRenderTargetTexture===!1&&A.version>0&&O.__version!==A.version){se(O,A,y);return}n.bindTexture(e.TEXTURE_3D,O.__webglTexture,e.TEXTURE0+y)}function K(A,y){let O=i.get(A);if(A.isCubeDepthTexture!==!0&&A.version>0&&O.__version!==A.version){ce(O,A,y);return}n.bindTexture(e.TEXTURE_CUBE_MAP,O.__webglTexture,e.TEXTURE0+y)}let ge={[Ls]:e.REPEAT,[Ns]:e.CLAMP_TO_EDGE,[Fc]:e.MIRRORED_REPEAT},de={[ti]:e.NEAREST,[zc]:e.NEAREST_MIPMAP_NEAREST,[Wr]:e.NEAREST_MIPMAP_LINEAR,[Jt]:e.LINEAR,[Ds]:e.LINEAR_MIPMAP_NEAREST,[yi]:e.LINEAR_MIPMAP_LINEAR},fe={[uv]:e.NEVER,[mv]:e.ALWAYS,[hv]:e.LESS,[Zc]:e.LEQUAL,[dv]:e.EQUAL,[Xc]:e.GEQUAL,[fv]:e.GREATER,[pv]:e.NOTEQUAL};function he(A,y){if(y.type===Vi&&t.has("OES_texture_float_linear")===!1&&(y.magFilter===Jt||y.magFilter===Ds||y.magFilter===Wr||y.magFilter===yi||y.minFilter===Jt||y.minFilter===Ds||y.minFilter===Wr||y.minFilter===yi))Ue("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.");if(e.texParameteri(A,e.TEXTURE_WRAP_S,ge[y.wrapS]),e.texParameteri(A,e.TEXTURE_WRAP_T,ge[y.wrapT]),A===e.TEXTURE_3D||A===e.TEXTURE_2D_ARRAY)e.texParameteri(A,e.TEXTURE_WRAP_R,ge[y.wrapR]);if(e.texParameteri(A,e.TEXTURE_MAG_FILTER,de[y.magFilter]),e.texParameteri(A,e.TEXTURE_MIN_FILTER,de[y.minFilter]),y.compareFunction)e.texParameteri(A,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(A,e.TEXTURE_COMPARE_FUNC,fe[y.compareFunction]);if(t.has("EXT_texture_filter_anisotropic")===!0){if(y.magFilter===ti)return;if(y.minFilter!==Wr&&y.minFilter!==yi)return;if(y.type===Vi&&t.has("OES_texture_float_linear")===!1)return;if(y.anisotropy>1||i.get(y).__currentAnisotropy){let O=t.get("EXT_texture_filter_anisotropic");e.texParameterf(A,O.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(y.anisotropy,r.getMaxAnisotropy())),i.get(y).__currentAnisotropy=y.anisotropy}}}function I(A,y){let O=!1;if(A.__webglInit===void 0)A.__webglInit=!0,y.addEventListener("dispose",R);let J=y.source,ue=f.get(J);if(ue===void 0)ue={},f.set(J,ue);let me=k(y);if(me!==A.__cacheKey){if(ue[me]===void 0)ue[me]={texture:e.createTexture(),usedTimes:0},o.memory.textures++,O=!0;ue[me].usedTimes++;let ve=ue[A.__cacheKey];if(ve!==void 0){if(ue[A.__cacheKey].usedTimes--,ve.usedTimes===0)H(y)}A.__cacheKey=me,A.__webglTexture=ue[me].texture}return O}function V(A,y,O){return Math.floor(Math.floor(A/O)/y)}function q(A,y,O,J){let me=A.updateRanges;if(me.length===0)n.texSubImage2D(e.TEXTURE_2D,0,0,0,y.width,y.height,O,J,y.data);else{me.sort((Oe,ye)=>Oe.start-ye.start);let ve=0;for(let Oe=1;Oe<me.length;Oe++){let ye=me[ve],pe=me[Oe],ze=ye.start+ye.count,Ge=V(pe.start,y.width,4),ot=V(ye.start,y.width,4);if(pe.start<=ze+1&&Ge===ot&&V(pe.start+pe.count-1,y.width,4)===Ge)ye.count=Math.max(ye.count,pe.start+pe.count-ye.start);else++ve,me[ve]=pe}me.length=ve+1;let te=n.getParameter(e.UNPACK_ROW_LENGTH),re=n.getParameter(e.UNPACK_SKIP_PIXELS),Ee=n.getParameter(e.UNPACK_SKIP_ROWS);n.pixelStorei(e.UNPACK_ROW_LENGTH,y.width);for(let Oe=0,ye=me.length;Oe<ye;Oe++){let pe=me[Oe],ze=Math.floor(pe.start/4),Ge=Math.ceil(pe.count/4),ot=ze%y.width,z=Math.floor(ze/y.width),_e=Ge,ne=1;n.pixelStorei(e.UNPACK_SKIP_PIXELS,ot),n.pixelStorei(e.UNPACK_SKIP_ROWS,z),n.texSubImage2D(e.TEXTURE_2D,0,ot,z,_e,1,O,J,y.data)}A.clearUpdateRanges(),n.pixelStorei(e.UNPACK_ROW_LENGTH,te),n.pixelStorei(e.UNPACK_SKIP_PIXELS,re),n.pixelStorei(e.UNPACK_SKIP_ROWS,Ee)}}function se(A,y,O){let J=e.TEXTURE_2D;if(y.isDataArrayTexture||y.isCompressedArrayTexture)J=e.TEXTURE_2D_ARRAY;if(y.isData3DTexture)J=e.TEXTURE_3D;let ue=I(A,y),me=y.source;n.bindTexture(J,A.__webglTexture,e.TEXTURE0+O);let ve=i.get(me);if(me.version!==ve.__version||ue===!0){if(n.activeTexture(e.TEXTURE0+O),(typeof ImageBitmap<"u"&&y.image instanceof ImageBitmap)===!1){let ne=Ke.getPrimaries(Ke.workingColorSpace),xe=y.colorSpace===qr?null:Ke.getPrimaries(y.colorSpace),Te=y.colorSpace===qr||ne===xe?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,y.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,y.premultiplyAlpha),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,Te)}n.pixelStorei(e.UNPACK_ALIGNMENT,y.unpackAlignment);let re=p(y.image,!1,r.maxTextureSize);re=ut(y,re);let Ee=s.convert(y.format,y.colorSpace),Oe=s.convert(y.type),ye=v(y.internalFormat,Ee,Oe,y.normalized,y.colorSpace,y.isVideoTexture);he(J,y);let pe,ze=y.mipmaps,Ge=y.isVideoTexture!==!0,ot=ve.__version===void 0||ue===!0,z=me.dataReady,_e=E(y,re);if(y.isDepthTexture){if(ye=S(y.format===Xr,y.type),ot)if(Ge)n.texStorage2D(e.TEXTURE_2D,1,ye,re.width,re.height);else n.texImage2D(e.TEXTURE_2D,0,ye,re.width,re.height,0,Ee,Oe,null)}else if(y.isDataTexture)if(ze.length>0){if(Ge&&ot)n.texStorage2D(e.TEXTURE_2D,_e,ye,ze[0].width,ze[0].height);for(let ne=0,xe=ze.length;ne<xe;ne++)if(pe=ze[ne],Ge){if(z)n.texSubImage2D(e.TEXTURE_2D,ne,0,0,pe.width,pe.height,Ee,Oe,pe.data)}else n.texImage2D(e.TEXTURE_2D,ne,ye,pe.width,pe.height,0,Ee,Oe,pe.data);y.generateMipmaps=!1}else if(Ge){if(ot)n.texStorage2D(e.TEXTURE_2D,_e,ye,re.width,re.height);if(z)q(y,re,Ee,Oe)}else n.texImage2D(e.TEXTURE_2D,0,ye,re.width,re.height,0,Ee,Oe,re.data);else if(y.isCompressedTexture)if(y.isCompressedArrayTexture){if(Ge&&ot)n.texStorage3D(e.TEXTURE_2D_ARRAY,_e,ye,ze[0].width,ze[0].height,re.depth);for(let ne=0,xe=ze.length;ne<xe;ne++)if(pe=ze[ne],y.format!==Si)if(Ee!==null)if(Ge){if(z)if(y.layerUpdates.size>0){let Te=Pd(pe.width,pe.height,y.format,y.type);for(let le of y.layerUpdates){let Se=pe.data.subarray(le*Te/pe.data.BYTES_PER_ELEMENT,(le+1)*Te/pe.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,ne,0,0,le,pe.width,pe.height,1,Ee,Se)}}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,ne,0,0,0,pe.width,pe.height,re.depth,Ee,pe.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,ne,ye,pe.width,pe.height,re.depth,0,pe.data,0,0);else Ue("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(Ge){if(z)n.texSubImage3D(e.TEXTURE_2D_ARRAY,ne,0,0,0,pe.width,pe.height,re.depth,Ee,Oe,pe.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,ne,ye,pe.width,pe.height,re.depth,0,Ee,Oe,pe.data);if(y.layerUpdates.size>0)y.clearLayerUpdates()}else{if(Ge&&ot)n.texStorage2D(e.TEXTURE_2D,_e,ye,ze[0].width,ze[0].height);for(let ne=0,xe=ze.length;ne<xe;ne++)if(pe=ze[ne],y.format!==Si)if(Ee!==null)if(Ge){if(z)n.compressedTexSubImage2D(e.TEXTURE_2D,ne,0,0,pe.width,pe.height,Ee,pe.data)}else n.compressedTexImage2D(e.TEXTURE_2D,ne,ye,pe.width,pe.height,0,pe.data);else Ue("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(Ge){if(z)n.texSubImage2D(e.TEXTURE_2D,ne,0,0,pe.width,pe.height,Ee,Oe,pe.data)}else n.texImage2D(e.TEXTURE_2D,ne,ye,pe.width,pe.height,0,Ee,Oe,pe.data)}else if(y.isDataArrayTexture)if(Ge){if(ot)n.texStorage3D(e.TEXTURE_2D_ARRAY,_e,ye,re.width,re.height,re.depth);if(z)if(y.layerUpdates.size>0){let ne=Pd(re.width,re.height,y.format,y.type);for(let xe of y.layerUpdates){let Te=re.data.subarray(xe*ne/re.data.BYTES_PER_ELEMENT,(xe+1)*ne/re.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,xe,re.width,re.height,1,Ee,Oe,Te)}y.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,re.width,re.height,re.depth,Ee,Oe,re.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,ye,re.width,re.height,re.depth,0,Ee,Oe,re.data);else if(y.isData3DTexture)if(Ge){if(ot)n.texStorage3D(e.TEXTURE_3D,_e,ye,re.width,re.height,re.depth);if(z)n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,re.width,re.height,re.depth,Ee,Oe,re.data)}else n.texImage3D(e.TEXTURE_3D,0,ye,re.width,re.height,re.depth,0,Ee,Oe,re.data);else if(y.isFramebufferTexture){if(ot)if(Ge)n.texStorage2D(e.TEXTURE_2D,_e,ye,re.width,re.height);else{let ne=re.width,xe=re.height;for(let Te=0;Te<_e;Te++)n.texImage2D(e.TEXTURE_2D,Te,ye,ne,xe,0,Ee,Oe,null),ne>>=1,xe>>=1}}else if(y.isHTMLTexture){if("texElementImage2D"in e){let ne=e.canvas;if(!ne.hasAttribute("layoutsubtree"))ne.setAttribute("layoutsubtree","true");if(re.parentNode!==ne){ne.appendChild(re),h.add(y),ne.onpaint=(xe)=>{let Te=xe.changedElements;for(let le of h)if(Te.includes(le.image))le.needsUpdate=!0},ne.requestPaint();return}if(e.texElementImage2D.length===3)e.texElementImage2D(e.TEXTURE_2D,e.RGBA8,re);else{let{RGBA:Te,RGBA:le,UNSIGNED_BYTE:Se}=e;e.texElementImage2D(e.TEXTURE_2D,0,Te,le,Se,re)}e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)}}else if(ze.length>0){if(Ge&&ot){let ne=Pt(ze[0]);n.texStorage2D(e.TEXTURE_2D,_e,ye,ne.width,ne.height)}for(let ne=0,xe=ze.length;ne<xe;ne++)if(pe=ze[ne],Ge){if(z)n.texSubImage2D(e.TEXTURE_2D,ne,0,0,Ee,Oe,pe)}else n.texImage2D(e.TEXTURE_2D,ne,ye,Ee,Oe,pe);y.generateMipmaps=!1}else if(Ge){if(ot){let ne=Pt(re);n.texStorage2D(e.TEXTURE_2D,_e,ye,ne.width,ne.height)}if(z)n.texSubImage2D(e.TEXTURE_2D,0,0,0,Ee,Oe,re)}else n.texImage2D(e.TEXTURE_2D,0,ye,Ee,Oe,re);if(g(y))M(J);if(ve.__version=me.version,y.onUpdate)y.onUpdate(y)}A.__version=y.version}function ce(A,y,O){if(y.image.length!==6)return;let J=I(A,y),ue=y.source;n.bindTexture(e.TEXTURE_CUBE_MAP,A.__webglTexture,e.TEXTURE0+O);let me=i.get(ue);if(ue.version!==me.__version||J===!0){n.activeTexture(e.TEXTURE0+O);let ve=Ke.getPrimaries(Ke.workingColorSpace),te=y.colorSpace===qr?null:Ke.getPrimaries(y.colorSpace),re=y.colorSpace===qr||ve===te?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,y.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,y.premultiplyAlpha),n.pixelStorei(e.UNPACK_ALIGNMENT,y.unpackAlignment),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,re);let Ee=y.isCompressedTexture||y.image[0].isCompressedTexture,Oe=y.image[0]&&y.image[0].isDataTexture,ye=[];for(let le=0;le<6;le++){if(!Ee&&!Oe)ye[le]=p(y.image[le],!0,r.maxCubemapSize);else ye[le]=Oe?y.image[le].image:y.image[le];ye[le]=ut(y,ye[le])}let pe=ye[0],ze=s.convert(y.format,y.colorSpace),Ge=s.convert(y.type),ot=v(y.internalFormat,ze,Ge,y.normalized,y.colorSpace),z=y.isVideoTexture!==!0,_e=me.__version===void 0||J===!0,ne=ue.dataReady,xe=E(y,pe);he(e.TEXTURE_CUBE_MAP,y);let Te;if(Ee){if(z&&_e)n.texStorage2D(e.TEXTURE_CUBE_MAP,xe,ot,pe.width,pe.height);for(let le=0;le<6;le++){Te=ye[le].mipmaps;for(let Se=0;Se<Te.length;Se++){let Ze=Te[Se];if(y.format!==Si)if(ze!==null)if(z){if(ne)n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+le,Se,0,0,Ze.width,Ze.height,ze,Ze.data)}else n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+le,Se,ot,Ze.width,Ze.height,0,Ze.data);else Ue("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()");else if(z){if(ne)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+le,Se,0,0,Ze.width,Ze.height,ze,Ge,Ze.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+le,Se,ot,Ze.width,Ze.height,0,ze,Ge,Ze.data)}}}else{if(Te=y.mipmaps,z&&_e){if(Te.length>0)xe++;let le=Pt(ye[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,xe,ot,le.width,le.height)}for(let le=0;le<6;le++)if(Oe){if(z){if(ne)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+le,0,0,0,ye[le].width,ye[le].height,ze,Ge,ye[le].data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+le,0,ot,ye[le].width,ye[le].height,0,ze,Ge,ye[le].data);for(let Se=0;Se<Te.length;Se++){let bt=Te[Se].image[le].image;if(z){if(ne)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+le,Se+1,0,0,bt.width,bt.height,ze,Ge,bt.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+le,Se+1,ot,bt.width,bt.height,0,ze,Ge,bt.data)}}else{if(z){if(ne)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+le,0,0,0,ze,Ge,ye[le])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+le,0,ot,ze,Ge,ye[le]);for(let Se=0;Se<Te.length;Se++){let Ze=Te[Se];if(z){if(ne)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+le,Se+1,0,0,ze,Ge,Ze.image[le])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+le,Se+1,ot,ze,Ge,Ze.image[le])}}}if(g(y))M(e.TEXTURE_CUBE_MAP);if(me.__version=ue.version,y.onUpdate)y.onUpdate(y)}A.__version=y.version}function ae(A,y,O,J,ue,me){let ve=s.convert(O.format,O.colorSpace),te=s.convert(O.type),re=v(O.internalFormat,ve,te,O.normalized,O.colorSpace),Ee=i.get(y),Oe=i.get(O);if(Oe.__renderTarget=y,!Ee.__hasExternalTextures){let ye=Math.max(1,y.width>>me),pe=Math.max(1,y.height>>me);if(ue===e.TEXTURE_3D||ue===e.TEXTURE_2D_ARRAY)n.texImage3D(ue,me,re,ye,pe,y.depth,0,ve,te,null);else n.texImage2D(ue,me,re,ye,pe,0,ve,te,null)}if(n.bindFramebuffer(e.FRAMEBUFFER,A),D(y))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,J,ue,Oe.__webglTexture,0,It(y));else if(ue===e.TEXTURE_2D||ue>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&ue<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)e.framebufferTexture2D(e.FRAMEBUFFER,J,ue,Oe.__webglTexture,me);n.bindFramebuffer(e.FRAMEBUFFER,null)}function ke(A,y,O){if(e.bindRenderbuffer(e.RENDERBUFFER,A),y.depthBuffer){let J=y.depthTexture,ue=J&&J.isDepthTexture?J.type:null,me=S(y.stencilBuffer,ue),ve=y.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(D(y))a.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,It(y),me,y.width,y.height);else if(O)e.renderbufferStorageMultisample(e.RENDERBUFFER,It(y),me,y.width,y.height);else e.renderbufferStorage(e.RENDERBUFFER,me,y.width,y.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,ve,e.RENDERBUFFER,A)}else{let J=y.textures;for(let ue=0;ue<J.length;ue++){let me=J[ue],ve=s.convert(me.format,me.colorSpace),te=s.convert(me.type),re=v(me.internalFormat,ve,te,me.normalized,me.colorSpace);if(D(y))a.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,It(y),re,y.width,y.height);else if(O)e.renderbufferStorageMultisample(e.RENDERBUFFER,It(y),re,y.width,y.height);else e.renderbufferStorage(e.RENDERBUFFER,re,y.width,y.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function Ce(A,y,O){let J=y.isWebGLCubeRenderTarget===!0;if(n.bindFramebuffer(e.FRAMEBUFFER,A),!(y.depthTexture&&y.depthTexture.isDepthTexture))throw Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");let ue=i.get(y.depthTexture);if(ue.__renderTarget=y,!ue.__webglTexture||y.depthTexture.image.width!==y.width||y.depthTexture.image.height!==y.height)y.depthTexture.image.width=y.width,y.depthTexture.image.height=y.height,y.depthTexture.needsUpdate=!0;if(J){if(ue.__webglInit===void 0)ue.__webglInit=!0,y.depthTexture.addEventListener("dispose",R);if(ue.__webglTexture===void 0){ue.__webglTexture=e.createTexture(),n.bindTexture(e.TEXTURE_CUBE_MAP,ue.__webglTexture),he(e.TEXTURE_CUBE_MAP,y.depthTexture);let Ee=s.convert(y.depthTexture.format),Oe=s.convert(y.depthTexture.type),ye;if(y.depthTexture.format===Zr)ye=e.DEPTH_COMPONENT24;else if(y.depthTexture.format===Xr)ye=e.DEPTH24_STENCIL8;for(let pe=0;pe<6;pe++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+pe,0,ye,y.width,y.height,0,Ee,Oe,null)}}else W(y.depthTexture,0);let me=ue.__webglTexture,ve=It(y),te=J?e.TEXTURE_CUBE_MAP_POSITIVE_X+O:e.TEXTURE_2D,re=y.depthTexture.format===Xr?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(y.depthTexture.format===Zr)if(D(y))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,re,te,me,0,ve);else e.framebufferTexture2D(e.FRAMEBUFFER,re,te,me,0);else if(y.depthTexture.format===Xr)if(D(y))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,re,te,me,0,ve);else e.framebufferTexture2D(e.FRAMEBUFFER,re,te,me,0);else throw Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Ve(A){let y=i.get(A),O=A.isWebGLCubeRenderTarget===!0;if(y.__boundDepthTexture!==A.depthTexture){let J=A.depthTexture;if(y.__depthDisposeCallback)y.__depthDisposeCallback();if(J){let ue=()=>{delete y.__boundDepthTexture,delete y.__depthDisposeCallback,J.removeEventListener("dispose",ue)};J.addEventListener("dispose",ue),y.__depthDisposeCallback=ue}y.__boundDepthTexture=J}if(A.depthTexture&&!y.__autoAllocateDepthBuffer)if(O)for(let J=0;J<6;J++)Ce(y.__webglFramebuffer[J],A,J);else{let J=A.texture.mipmaps;if(J&&J.length>0)Ce(y.__webglFramebuffer[0],A,0);else Ce(y.__webglFramebuffer,A,0)}else if(O){y.__webglDepthbuffer=[];for(let J=0;J<6;J++)if(n.bindFramebuffer(e.FRAMEBUFFER,y.__webglFramebuffer[J]),y.__webglDepthbuffer[J]===void 0)y.__webglDepthbuffer[J]=e.createRenderbuffer(),ke(y.__webglDepthbuffer[J],A,!1);else{let ue=A.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,me=y.__webglDepthbuffer[J];e.bindRenderbuffer(e.RENDERBUFFER,me),e.framebufferRenderbuffer(e.FRAMEBUFFER,ue,e.RENDERBUFFER,me)}}else{let J=A.texture.mipmaps;if(J&&J.length>0)n.bindFramebuffer(e.FRAMEBUFFER,y.__webglFramebuffer[0]);else n.bindFramebuffer(e.FRAMEBUFFER,y.__webglFramebuffer);if(y.__webglDepthbuffer===void 0)y.__webglDepthbuffer=e.createRenderbuffer(),ke(y.__webglDepthbuffer,A,!1);else{let ue=A.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,me=y.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,me),e.framebufferRenderbuffer(e.FRAMEBUFFER,ue,e.RENDERBUFFER,me)}}n.bindFramebuffer(e.FRAMEBUFFER,null)}function rt(A,y,O){let J=i.get(A);if(y!==void 0)ae(J.__webglFramebuffer,A,A.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0);if(O!==void 0)Ve(A)}function nt(A){let y=A.texture,O=i.get(A),J=i.get(y);A.addEventListener("dispose",x);let ue=A.textures,me=A.isWebGLCubeRenderTarget===!0,ve=ue.length>1;if(!ve){if(J.__webglTexture===void 0)J.__webglTexture=e.createTexture();J.__version=y.version,o.memory.textures++}if(me){O.__webglFramebuffer=[];for(let te=0;te<6;te++)if(y.mipmaps&&y.mipmaps.length>0){O.__webglFramebuffer[te]=[];for(let re=0;re<y.mipmaps.length;re++)O.__webglFramebuffer[te][re]=e.createFramebuffer()}else O.__webglFramebuffer[te]=e.createFramebuffer()}else{if(y.mipmaps&&y.mipmaps.length>0){O.__webglFramebuffer=[];for(let te=0;te<y.mipmaps.length;te++)O.__webglFramebuffer[te]=e.createFramebuffer()}else O.__webglFramebuffer=e.createFramebuffer();if(ve)for(let te=0,re=ue.length;te<re;te++){let Ee=i.get(ue[te]);if(Ee.__webglTexture===void 0)Ee.__webglTexture=e.createTexture(),o.memory.textures++}if(A.samples>0&&D(A)===!1){O.__webglMultisampledFramebuffer=e.createFramebuffer(),O.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,O.__webglMultisampledFramebuffer);for(let te=0;te<ue.length;te++){let re=ue[te];O.__webglColorRenderbuffer[te]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,O.__webglColorRenderbuffer[te]);let Ee=s.convert(re.format,re.colorSpace),Oe=s.convert(re.type),ye=v(re.internalFormat,Ee,Oe,re.normalized,re.colorSpace,A.isXRRenderTarget===!0),pe=It(A);e.renderbufferStorageMultisample(e.RENDERBUFFER,pe,ye,A.width,A.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+te,e.RENDERBUFFER,O.__webglColorRenderbuffer[te])}if(e.bindRenderbuffer(e.RENDERBUFFER,null),A.depthBuffer)O.__webglDepthRenderbuffer=e.createRenderbuffer(),ke(O.__webglDepthRenderbuffer,A,!0);n.bindFramebuffer(e.FRAMEBUFFER,null)}}if(me){n.bindTexture(e.TEXTURE_CUBE_MAP,J.__webglTexture),he(e.TEXTURE_CUBE_MAP,y);for(let te=0;te<6;te++)if(y.mipmaps&&y.mipmaps.length>0)for(let re=0;re<y.mipmaps.length;re++)ae(O.__webglFramebuffer[te][re],A,y,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+te,re);else ae(O.__webglFramebuffer[te],A,y,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+te,0);if(g(y))M(e.TEXTURE_CUBE_MAP);n.unbindTexture()}else if(ve){for(let te=0,re=ue.length;te<re;te++){let Ee=ue[te],Oe=i.get(Ee),ye=e.TEXTURE_2D;if(A.isWebGL3DRenderTarget||A.isWebGLArrayRenderTarget)ye=A.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(ye,Oe.__webglTexture),he(ye,Ee),ae(O.__webglFramebuffer,A,Ee,e.COLOR_ATTACHMENT0+te,ye,0),g(Ee))M(ye)}n.unbindTexture()}else{let te=e.TEXTURE_2D;if(A.isWebGL3DRenderTarget||A.isWebGLArrayRenderTarget)te=A.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(te,J.__webglTexture),he(te,y),y.mipmaps&&y.mipmaps.length>0)for(let re=0;re<y.mipmaps.length;re++)ae(O.__webglFramebuffer[re],A,y,e.COLOR_ATTACHMENT0,te,re);else ae(O.__webglFramebuffer,A,y,e.COLOR_ATTACHMENT0,te,0);if(g(y))M(te);n.unbindTexture()}if(A.depthBuffer)Ve(A)}function Rt(A){let y=A.textures;for(let O=0,J=y.length;O<J;O++){let ue=y[O];if(g(ue)){let me=T(A),ve=i.get(ue).__webglTexture;n.bindTexture(me,ve),M(me),n.unbindTexture()}}}let it=[],tn=[];function Ut(A){if(A.samples>0){if(D(A)===!1){let{textures:y,width:O,height:J}=A,ue=e.COLOR_BUFFER_BIT,me=A.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ve=i.get(A),te=y.length>1;if(te)for(let Ee=0;Ee<y.length;Ee++)n.bindFramebuffer(e.FRAMEBUFFER,ve.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+Ee,e.RENDERBUFFER,null),n.bindFramebuffer(e.FRAMEBUFFER,ve.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+Ee,e.TEXTURE_2D,null,0);n.bindFramebuffer(e.READ_FRAMEBUFFER,ve.__webglMultisampledFramebuffer);let re=A.texture.mipmaps;if(re&&re.length>0)n.bindFramebuffer(e.DRAW_FRAMEBUFFER,ve.__webglFramebuffer[0]);else n.bindFramebuffer(e.DRAW_FRAMEBUFFER,ve.__webglFramebuffer);for(let Ee=0;Ee<y.length;Ee++){if(A.resolveDepthBuffer){if(A.depthBuffer)ue|=e.DEPTH_BUFFER_BIT;if(A.stencilBuffer&&A.resolveStencilBuffer)ue|=e.STENCIL_BUFFER_BIT}if(te){e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,ve.__webglColorRenderbuffer[Ee]);let Oe=i.get(y[Ee]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,Oe,0)}if(e.blitFramebuffer(0,0,O,J,0,0,O,J,ue,e.NEAREST),c===!0){if(it.length=0,tn.length=0,it.push(e.COLOR_ATTACHMENT0+Ee),A.depthBuffer&&A.storeMultisampledDepthBuffer===!1)it.push(me),tn.push(me),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,tn);e.invalidateFramebuffer(e.READ_FRAMEBUFFER,it)}}if(n.bindFramebuffer(e.READ_FRAMEBUFFER,null),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),te)for(let Ee=0;Ee<y.length;Ee++){n.bindFramebuffer(e.FRAMEBUFFER,ve.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+Ee,e.RENDERBUFFER,ve.__webglColorRenderbuffer[Ee]);let Oe=i.get(y[Ee]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,ve.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+Ee,e.TEXTURE_2D,Oe,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,ve.__webglMultisampledFramebuffer)}else if(A.depthBuffer&&A.storeMultisampledDepthBuffer===!1&&c){let y=A.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[y])}}}function It(A){return Math.min(r.maxSamples,A.samples)}function D(A){let y=i.get(A);return A.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&y.__useRenderToTexture!==!1}function _n(A){let y=o.render.frame;if(u.get(A)!==y)u.set(A,y),A.update()}function ut(A,y){let{colorSpace:O,format:J,type:ue}=A;if(A.isCompressedTexture===!0||A.isVideoTexture===!0)return y;if(O!==Rn&&O!==qr)if(Ke.getTransfer(O)===yt){if(J!==Si||ue!==ni)Ue("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.")}else $e("WebGLTextures: Unsupported texture color space:",O);return y}function Pt(A){if(typeof HTMLImageElement<"u"&&A instanceof HTMLImageElement)l.width=A.naturalWidth||A.width,l.height=A.naturalHeight||A.height;else if(typeof VideoFrame<"u"&&A instanceof VideoFrame)l.width=A.displayWidth,l.height=A.displayHeight;else l.width=A.width,l.height=A.height;return l}this.allocateTextureUnit=G,this.resetTextureUnits=ee,this.getTextureUnits=P,this.setTextureUnits=Z,this.setTexture2D=W,this.setTexture2DArray=B,this.setTexture3D=Y,this.setTextureCube=K,this.rebindTextures=rt,this.setupRenderTarget=nt,this.updateRenderTargetMipmap=Rt,this.updateMultisampleRenderTarget=Ut,this.setupDepthRenderbuffer=Ve,this.setupFrameBufferTexture=ae,this.useMultisampledRTT=D,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function tC(e,t){function n(i,r=qr){let s,o=Ke.getTransfer(r);if(i===ni)return e.UNSIGNED_BYTE;if(i===wh)return e.UNSIGNED_SHORT_4_4_4_4;if(i===Mh)return e.UNSIGNED_SHORT_5_5_5_1;if(i===rv)return e.UNSIGNED_INT_5_9_9_9_REV;if(i===sv)return e.UNSIGNED_INT_10F_11F_11F_REV;if(i===nv)return e.BYTE;if(i===iv)return e.SHORT;if(i===Vo)return e.UNSIGNED_SHORT;if(i===Sh)return e.INT;if(i===pr)return e.UNSIGNED_INT;if(i===Vi)return e.FLOAT;if(i===bi)return e.HALF_FLOAT;if(i===ov)return e.ALPHA;if(i===av)return e.RGB;if(i===Si)return e.RGBA;if(i===Zr)return e.DEPTH_COMPONENT;if(i===Xr)return e.DEPTH_STENCIL;if(i===cv)return e.RED;if(i===Eh)return e.RED_INTEGER;if(i===jr)return e.RG;if(i===Th)return e.RG_INTEGER;if(i===Ah)return e.RGBA_INTEGER;if(i===kc||i===Bc||i===Gc||i===Hc)if(o===yt)if(s=t.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===kc)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Bc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Gc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Hc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=t.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===kc)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Bc)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Gc)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Hc)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Rh||i===Ch||i===Ih||i===Ph)if(s=t.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===Rh)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Ch)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Ih)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Ph)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===Lh||i===Nh||i===Dh||i===Oh||i===Uh||i===Vc||i===Fh)if(s=t.get("WEBGL_compressed_texture_etc"),s!==null){if(i===Lh||i===Nh)return o===yt?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===Dh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(i===Oh)return s.COMPRESSED_R11_EAC;if(i===Uh)return s.COMPRESSED_SIGNED_R11_EAC;if(i===Vc)return s.COMPRESSED_RG11_EAC;if(i===Fh)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===zh||i===kh||i===Bh||i===Gh||i===Hh||i===Vh||i===$h||i===Wh||i===Zh||i===Xh||i===jh||i===qh||i===Yh||i===Kh)if(s=t.get("WEBGL_compressed_texture_astc"),s!==null){if(i===zh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===kh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Bh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Gh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Hh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Vh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===$h)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Wh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Zh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Xh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===jh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===qh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Yh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Kh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===Jh||i===Qh||i===ed)if(s=t.get("EXT_texture_compression_bptc"),s!==null){if(i===Jh)return o===yt?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Qh)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===ed)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===td||i===nd||i===$c||i===id)if(s=t.get("EXT_texture_compression_rgtc"),s!==null){if(i===td)return s.COMPRESSED_RED_RGTC1_EXT;if(i===nd)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===$c)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===id)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;if(i===Os)return e.UNSIGNED_INT_24_8;return e[i]!==void 0?e[i]:null}return{convert:n}}var nC=`
4257
+ }`,JR=[new z(1,0,0),new z(-1,0,0),new z(0,1,0),new z(0,-1,0),new z(0,0,1),new z(0,0,-1)],QR=[new z(0,-1,0),new z(0,-1,0),new z(0,0,1),new z(0,0,-1),new z(0,-1,0),new z(0,-1,0)],Yv=new Xe,ua=new z,zd=new z;function eC(e,t,n){let i=new ta,r=new ke,s=new ke,o=new pt,a=new xd,c=new vd,l={},u=n.maxTextureSize,h={[pr]:cn,[cn]:pr,[Bn]:Bn},d=new Gn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ke},radius:{value:4}},vertexShader:YR,fragmentShader:KR}),f=d.clone();f.defines.HORIZONTAL_PASS=1;let m=new ln;m.setAttribute("position",new Kt(new Float32Array([-1,-1,0.5,3,-1,0.5,-1,3,0.5]),3));let _=new Mt(m,d),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Ho;let g=this.type;this.render=function(E,R,x){if(p.enabled===!1)return;if(p.autoUpdate===!1&&p.needsUpdate===!1)return;if(E.length===0)return;if(this.type===Tx)Ue("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=Ho;let w=e.getRenderTarget(),G=e.getActiveCubeFace(),C=e.getActiveMipmapLevel(),D=e.state;if(D.setBlending(vi),D.buffers.depth.getReversed()===!0)D.buffers.color.setClear(0,0,0,0);else D.buffers.color.setClear(1,1,1,1);D.buffers.depth.setTest(!0),D.setScissorTest(!1);let ee=g!==this.type;if(ee)R.traverse(function(L){if(L.material)if(Array.isArray(L.material))L.material.forEach((W)=>W.needsUpdate=!0);else L.material.needsUpdate=!0});for(let L=0,W=E.length;L<W;L++){let B=E[L],P=B.shadow;if(P===void 0){Ue("WebGLShadowMap:",B,"has no shadow.");continue}if(P.autoUpdate===!1&&P.needsUpdate===!1)continue;r.copy(P.mapSize);let J=P.getFrameExtents();if(r.multiply(J),s.copy(P.mapSize),r.x>u||r.y>u){if(r.x>u)s.x=Math.floor(u/J.x),r.x=s.x*J.x,P.mapSize.x=s.x;if(r.y>u)s.y=Math.floor(u/J.y),r.y=s.y*J.y,P.mapSize.y=s.y}let H=e.state.buffers.depth.getReversed();if(P.camera._reversedDepth=H,P.map===null||ee===!0){if(P.map!==null){if(P.map.depthTexture!==null)P.map.depthTexture.dispose(),P.map.depthTexture=null;P.map.dispose()}if(this.type===Is){if(B.isPointLight){Ue("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}P.map=new Cn(r.x,r.y,{format:qr,type:bi,minFilter:Jt,magFilter:Jt,generateMipmaps:!1}),P.map.texture.name=B.name+".shadowMap",P.map.depthTexture=new Kr(r.x,r.y,$i),P.map.depthTexture.name=B.name+".shadowMapDepth",P.map.depthTexture.format=Xr,P.map.depthTexture.compareFunction=null,P.map.depthTexture.minFilter=ti,P.map.depthTexture.magFilter=ti}else{if(B.isPointLight)P.map=new Gd(r.x),P.map.depthTexture=new md(r.x,mr);else P.map=new Cn(r.x,r.y),P.map.depthTexture=new Kr(r.x,r.y,mr);if(P.map.depthTexture.name=B.name+".shadowMap",P.map.depthTexture.format=Xr,this.type===Ho)P.map.depthTexture.compareFunction=H?qc:jc,P.map.depthTexture.minFilter=Jt,P.map.depthTexture.magFilter=Jt;else P.map.depthTexture.compareFunction=null,P.map.depthTexture.minFilter=ti,P.map.depthTexture.magFilter=ti}P.camera.updateProjectionMatrix()}if(P.map.isWebGLCubeRenderTarget!==!0&&(P.map.width!==r.x||P.map.height!==r.y))P.map.setSize(r.x,r.y);let q=P.map.isWebGLCubeRenderTarget?6:P.getViewportCount();if(B.isPointLight!==!0)P.updateMatrices(B,x);for(let Q=0;Q<q;Q++){let ge=P.getCamera(Q);if(B.isPointLight){let{camera:he,matrix:de}=P,fe=B.distance||he.far;if(fe!==he.far)he.far=fe,he.updateProjectionMatrix();ua.setFromMatrixPosition(B.matrixWorld),he.position.copy(ua),zd.copy(he.position),zd.add(JR[Q]),he.up.copy(QR[Q]),he.lookAt(zd),he.updateMatrixWorld(),de.makeTranslation(-ua.x,-ua.y,-ua.z),Yv.multiplyMatrices(he.projectionMatrix,he.matrixWorldInverse),P._frustum.setFromProjectionMatrix(Yv,he.coordinateSystem,he.reversedDepth)}if(P.map.isWebGLCubeRenderTarget)e.setRenderTarget(P.map,Q),e.clear();else{if(Q===0)e.setRenderTarget(P.map),e.clear();let he=P.getViewport(Q);o.set(s.x*he.x,s.y*he.y,s.x*he.z,s.y*he.w),D.viewport(o)}i=P.getFrustum(Q),v(R,x,ge,B,this.type)}if(P.isPointLightShadow!==!0&&this.type===Is)M(P,x);P.needsUpdate=!1}g=this.type,p.needsUpdate=!1,e.setRenderTarget(w,G,C)};function M(E,R){let x=t.update(_);if(d.defines.VSM_SAMPLES!==E.blurSamples)d.defines.VSM_SAMPLES=E.blurSamples,f.defines.VSM_SAMPLES=E.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0;if(E.mapPass===null)E.mapPass=new Cn(r.x,r.y,{format:qr,type:bi});else if(E.mapPass.width!==E.map.width||E.mapPass.height!==E.map.height)E.mapPass.setSize(E.map.width,E.map.height);d.uniforms.shadow_pass.value=E.map.depthTexture,d.uniforms.resolution.value.set(E.map.width,E.map.height),d.uniforms.radius.value=E.radius,e.setRenderTarget(E.mapPass),e.clear(),e.renderBufferDirect(R,null,x,d,_,null),f.uniforms.shadow_pass.value=E.mapPass.texture,f.uniforms.resolution.value.set(E.map.width,E.map.height),f.uniforms.radius.value=E.radius,e.setRenderTarget(E.map),e.clear(),e.renderBufferDirect(R,null,x,f,_,null)}function T(E,R,x,w){let G=null,C=x.isPointLight===!0?E.customDistanceMaterial:E.customDepthMaterial;if(C!==void 0)G=C;else if(G=x.isPointLight===!0?c:a,e.localClippingEnabled&&R.clipShadows===!0&&Array.isArray(R.clippingPlanes)&&R.clippingPlanes.length!==0||R.displacementMap&&R.displacementScale!==0||R.alphaMap&&R.alphaTest>0||R.map&&R.alphaTest>0||R.alphaToCoverage===!0){let D=G.uuid,ee=R.uuid,L=l[D];if(L===void 0)L={},l[D]=L;let W=L[ee];if(W===void 0)W=G.clone(),L[ee]=W,R.addEventListener("dispose",S);G=W}if(G.visible=R.visible,G.wireframe=R.wireframe,w===Is)G.side=R.shadowSide!==null?R.shadowSide:R.side;else G.side=R.shadowSide!==null?R.shadowSide:h[R.side];if(G.alphaMap=R.alphaMap,G.alphaTest=R.alphaToCoverage===!0?0.5:R.alphaTest,G.map=R.map,G.clipShadows=R.clipShadows,G.clippingPlanes=R.clippingPlanes,G.clipIntersection=R.clipIntersection,G.displacementMap=R.displacementMap,G.displacementScale=R.displacementScale,G.displacementBias=R.displacementBias,G.wireframeLinewidth=R.wireframeLinewidth,G.linewidth=R.linewidth,x.isPointLight===!0&&G.isMeshDistanceMaterial===!0){let D=e.properties.get(G);D.light=x}return G}function v(E,R,x,w,G){if(E.visible===!1)return;if(E.layers.test(R.layers)&&(E.isMesh||E.isLine||E.isPoints)){if((E.castShadow||E.receiveShadow&&G===Is)&&(!E.frustumCulled||E.intersectsFrustum(i))){E.modelViewMatrix.multiplyMatrices(x.matrixWorldInverse,E.matrixWorld);let ee=t.update(E),L=E.material;if(Array.isArray(L)){let W=ee.groups;for(let B=0,P=W.length;B<P;B++){let J=W[B],H=L[J.materialIndex];if(H&&H.visible){let q=T(E,H,w,G);E.onBeforeShadow(e,E,R,x,ee,q,J),e.renderBufferDirect(x,null,ee,q,E,J),E.onAfterShadow(e,E,R,x,ee,q,J)}}}else if(L.visible){let W=T(E,L,w,G);E.onBeforeShadow(e,E,R,x,ee,W,null),e.renderBufferDirect(x,null,ee,W,E,null),E.onAfterShadow(e,E,R,x,ee,W,null)}}}let D=E.children;for(let ee=0,L=D.length;ee<L;ee++)v(D[ee],R,x,w,G)}function S(E){E.target.removeEventListener("dispose",S);for(let x in l){let w=l[x],G=E.target.uuid;if(G in w)w[G].dispose(),delete w[G]}}}function tC(e,t){function n(){let k=!1,_e=new pt,ne=null,xe=new pt(0,0,0,0);return{setMask:function(Te){if(ne!==Te&&!k)e.colorMask(Te,Te,Te,Te),ne=Te},setLocked:function(Te){k=Te},setClear:function(Te,ce,Se,Ze,bt){if(bt===!0)Te*=Ze,ce*=Ze,Se*=Ze;if(_e.set(Te,ce,Se,Ze),xe.equals(_e)===!1)e.clearColor(Te,ce,Se,Ze),xe.copy(_e)},reset:function(){k=!1,ne=null,xe.set(-1,0,0,0)}}}function i(){let k=!1,_e=!1,ne=null,xe=null,Te=null;return{setReversed:function(ce){if(_e!==ce){let Se=t.get("EXT_clip_control");if(ce)Se.clipControlEXT(Se.LOWER_LEFT_EXT,Se.ZERO_TO_ONE_EXT);else Se.clipControlEXT(Se.LOWER_LEFT_EXT,Se.NEGATIVE_ONE_TO_ONE_EXT);_e=ce;let Ze=Te;Te=null,this.setClear(Ze)}},getReversed:function(){return _e},setTest:function(ce){if(ce)j(e.DEPTH_TEST);else re(e.DEPTH_TEST)},setMask:function(ce){if(ne!==ce&&!k)e.depthMask(ce),ne=ce},setFunc:function(ce){if(_e)ce=yv[ce];if(xe!==ce){switch(ce){case Xx:e.depthFunc(e.NEVER);break;case jx:e.depthFunc(e.ALWAYS);break;case qx:e.depthFunc(e.LESS);break;case gh:e.depthFunc(e.LEQUAL);break;case Yx:e.depthFunc(e.EQUAL);break;case Kx:e.depthFunc(e.GEQUAL);break;case Jx:e.depthFunc(e.GREATER);break;case Qx:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}xe=ce}},setLocked:function(ce){k=ce},setClear:function(ce){if(Te!==ce){if(Te=ce,_e)ce=1-ce;e.clearDepth(ce)}},reset:function(){k=!1,ne=null,xe=null,Te=null,_e=!1}}}function r(){let k=!1,_e=null,ne=null,xe=null,Te=null,ce=null,Se=null,Ze=null,bt=null;return{setTest:function(ht){if(!k)if(ht)j(e.STENCIL_TEST);else re(e.STENCIL_TEST)},setMask:function(ht){if(_e!==ht&&!k)e.stencilMask(ht),_e=ht},setFunc:function(ht,oi,Li){if(ne!==ht||xe!==oi||Te!==Li)e.stencilFunc(ht,oi,Li),ne=ht,xe=oi,Te=Li},setOp:function(ht,oi,Li){if(ce!==ht||Se!==oi||Ze!==Li)e.stencilOp(ht,oi,Li),ce=ht,Se=oi,Ze=Li},setLocked:function(ht){k=ht},setClear:function(ht){if(bt!==ht)e.clearStencil(ht),bt=ht},reset:function(){k=!1,_e=null,ne=null,xe=null,Te=null,ce=null,Se=null,Ze=null,bt=null}}}let s=new n,o=new i,a=new r,c=new WeakMap,l=new WeakMap,u={},h={},d={},f=new WeakMap,m=[],_=null,p=!1,g=null,M=null,T=null,v=null,S=null,E=null,R=null,x=new Ge(0,0,0),w=0,G=!1,C=null,D=null,ee=null,L=null,W=null,B=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),P=!1,J=0,H=e.getParameter(e.VERSION);if(H.indexOf("WebGL")!==-1)J=parseFloat(/^WebGL (\d)/.exec(H)[1]),P=J>=1;else if(H.indexOf("OpenGL ES")!==-1)J=parseFloat(/^OpenGL ES (\d)/.exec(H)[1]),P=J>=2;let q=null,Q={},ge=e.getParameter(e.SCISSOR_BOX),he=e.getParameter(e.VIEWPORT),de=new pt().fromArray(ge),fe=new pt().fromArray(he);function I(k,_e,ne,xe){let Te=new Uint8Array(4),ce=e.createTexture();e.bindTexture(k,ce),e.texParameteri(k,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(k,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let Se=0;Se<ne;Se++)if(k===e.TEXTURE_3D||k===e.TEXTURE_2D_ARRAY)e.texImage3D(_e,0,e.RGBA,1,1,xe,0,e.RGBA,e.UNSIGNED_BYTE,Te);else e.texImage2D(_e+Se,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,Te);return ce}let V={};V[e.TEXTURE_2D]=I(e.TEXTURE_2D,e.TEXTURE_2D,1),V[e.TEXTURE_CUBE_MAP]=I(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),V[e.TEXTURE_2D_ARRAY]=I(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),V[e.TEXTURE_3D]=I(e.TEXTURE_3D,e.TEXTURE_3D,1,1),s.setClear(0,0,0,1),o.setClear(1),a.setClear(0),j(e.DEPTH_TEST),o.setFunc(gh),Rt(!1),it(dh),j(e.CULL_FACE),rt(vi);function j(k){if(u[k]!==!0)e.enable(k),u[k]=!0}function re(k){if(u[k]!==!1)e.disable(k),u[k]=!1}function oe(k,_e){if(d[k]!==_e){if(e.bindFramebuffer(k,_e),d[k]=_e,k===e.DRAW_FRAMEBUFFER)d[e.FRAMEBUFFER]=_e;if(k===e.FRAMEBUFFER)d[e.DRAW_FRAMEBUFFER]=_e;return!0}return!1}function ue(k,_e){let ne=m,xe=!1;if(k){if(ne=f.get(_e),ne===void 0)ne=[],f.set(_e,ne);let Te=k.textures;if(ne.length!==Te.length||ne[0]!==e.COLOR_ATTACHMENT0){for(let ce=0,Se=Te.length;ce<Se;ce++)ne[ce]=e.COLOR_ATTACHMENT0+ce;ne.length=Te.length,xe=!0}}else if(ne[0]!==e.BACK)ne[0]=e.BACK,xe=!0;if(xe)e.drawBuffers(ne)}function $e(k){if(_!==k)return e.useProgram(k),_=k,!0;return!1}let Ce={[Ps]:e.FUNC_ADD,[Rx]:e.FUNC_SUBTRACT,[Cx]:e.FUNC_REVERSE_SUBTRACT};Ce[Ix]=e.MIN,Ce[Px]=e.MAX;let He={[Lx]:e.ZERO,[Nx]:e.ONE,[Dx]:e.SRC_COLOR,[Ux]:e.SRC_ALPHA,[Hx]:e.SRC_ALPHA_SATURATE,[Bx]:e.DST_COLOR,[zx]:e.DST_ALPHA,[Ox]:e.ONE_MINUS_SRC_COLOR,[Fx]:e.ONE_MINUS_SRC_ALPHA,[Gx]:e.ONE_MINUS_DST_COLOR,[kx]:e.ONE_MINUS_DST_ALPHA,[Vx]:e.CONSTANT_COLOR,[$x]:e.ONE_MINUS_CONSTANT_COLOR,[Wx]:e.CONSTANT_ALPHA,[Zx]:e.ONE_MINUS_CONSTANT_ALPHA};function rt(k,_e,ne,xe,Te,ce,Se,Ze,bt,ht){if(k===vi){if(p===!0)re(e.BLEND),p=!1;return}if(p===!1)j(e.BLEND),p=!0;if(k!==Ax){if(k!==g||ht!==G){if(M!==Ps||S!==Ps)e.blendEquation(e.FUNC_ADD),M=Ps,S=Ps;if(ht)switch(k){case Vo:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case fh:e.blendFunc(e.ONE,e.ONE);break;case ph:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case mh:e.blendFuncSeparate(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ZERO,e.ONE);break;default:Ve("WebGLState: Invalid blending: ",k);break}else switch(k){case Vo:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case fh:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE);break;case ph:Ve("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case mh:Ve("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Ve("WebGLState: Invalid blending: ",k);break}T=null,v=null,E=null,R=null,x.set(0,0,0),w=0,g=k,G=ht}return}if(Te=Te||_e,ce=ce||ne,Se=Se||xe,_e!==M||Te!==S)e.blendEquationSeparate(Ce[_e],Ce[Te]),M=_e,S=Te;if(ne!==T||xe!==v||ce!==E||Se!==R)e.blendFuncSeparate(He[ne],He[xe],He[ce],He[Se]),T=ne,v=xe,E=ce,R=Se;if(Ze.equals(x)===!1||bt!==w)e.blendColor(Ze.r,Ze.g,Ze.b,bt),x.copy(Ze),w=bt;g=k,G=!1}function nt(k,_e){k.side===Bn?re(e.CULL_FACE):j(e.CULL_FACE);let ne=k.side===cn;if(_e)ne=!ne;Rt(ne),k.blending===Vo&&k.transparent===!1?rt(vi):rt(k.blending,k.blendEquation,k.blendSrc,k.blendDst,k.blendEquationAlpha,k.blendSrcAlpha,k.blendDstAlpha,k.blendColor,k.blendAlpha,k.premultipliedAlpha),o.setFunc(k.depthFunc),o.setTest(k.depthTest),o.setMask(k.depthWrite),s.setMask(k.colorWrite);let xe=k.stencilWrite;if(a.setTest(xe),xe)a.setMask(k.stencilWriteMask),a.setFunc(k.stencilFunc,k.stencilRef,k.stencilFuncMask),a.setOp(k.stencilFail,k.stencilZFail,k.stencilZPass);Ut(k.polygonOffset,k.polygonOffsetFactor,k.polygonOffsetUnits),k.alphaToCoverage===!0?j(e.SAMPLE_ALPHA_TO_COVERAGE):re(e.SAMPLE_ALPHA_TO_COVERAGE)}function Rt(k){if(C!==k){if(k)e.frontFace(e.CW);else e.frontFace(e.CCW);C=k}}function it(k){if(k!==Mx){if(j(e.CULL_FACE),k!==D)if(k===dh)e.cullFace(e.BACK);else if(k===Ex)e.cullFace(e.FRONT);else e.cullFace(e.FRONT_AND_BACK)}else re(e.CULL_FACE);D=k}function tn(k){if(k!==ee){if(P)e.lineWidth(k);ee=k}}function Ut(k,_e,ne){if(k){if(j(e.POLYGON_OFFSET_FILL),L!==_e||W!==ne){if(L=_e,W=ne,o.getReversed())_e=-_e;e.polygonOffset(_e,ne)}}else re(e.POLYGON_OFFSET_FILL)}function It(k){if(k)j(e.SCISSOR_TEST);else re(e.SCISSOR_TEST)}function O(k){if(k===void 0)k=e.TEXTURE0+B-1;if(q!==k)e.activeTexture(k),q=k}function _n(k,_e,ne){if(ne===void 0)if(q===null)ne=e.TEXTURE0+B-1;else ne=q;let xe=Q[ne];if(xe===void 0)xe={type:void 0,texture:void 0},Q[ne]=xe;if(xe.type!==k||xe.texture!==_e){if(q!==ne)e.activeTexture(ne),q=ne;e.bindTexture(k,_e||V[k]),xe.type=k,xe.texture=_e}}function ut(){let k=Q[q];if(k!==void 0&&k.type!==void 0)e.bindTexture(k.type,null),k.type=void 0,k.texture=void 0}function Pt(){try{e.compressedTexImage2D(...arguments)}catch(k){Ve("WebGLState:",k)}}function A(){try{e.compressedTexImage3D(...arguments)}catch(k){Ve("WebGLState:",k)}}function y(){try{e.texSubImage2D(...arguments)}catch(k){Ve("WebGLState:",k)}}function U(){try{e.texSubImage3D(...arguments)}catch(k){Ve("WebGLState:",k)}}function Y(){try{e.compressedTexSubImage2D(...arguments)}catch(k){Ve("WebGLState:",k)}}function le(){try{e.compressedTexSubImage3D(...arguments)}catch(k){Ve("WebGLState:",k)}}function me(){try{e.texStorage2D(...arguments)}catch(k){Ve("WebGLState:",k)}}function ve(){try{e.texStorage3D(...arguments)}catch(k){Ve("WebGLState:",k)}}function te(){try{e.texImage2D(...arguments)}catch(k){Ve("WebGLState:",k)}}function se(){try{e.texImage3D(...arguments)}catch(k){Ve("WebGLState:",k)}}function Ee(k){if(h[k]!==void 0)return h[k];else return e.getParameter(k)}function Oe(k,_e){if(h[k]!==_e)e.pixelStorei(k,_e),h[k]=_e}function ye(k){if(de.equals(k)===!1)e.scissor(k.x,k.y,k.z,k.w),de.copy(k)}function pe(k){if(fe.equals(k)===!1)e.viewport(k.x,k.y,k.z,k.w),fe.copy(k)}function ze(k,_e){let ne=l.get(_e);if(ne===void 0)ne=new WeakMap,l.set(_e,ne);let xe=ne.get(k);if(xe===void 0)xe=e.getUniformBlockIndex(_e,k.name),ne.set(k,xe)}function Be(k,_e){let xe=l.get(_e).get(k);if(c.get(_e)!==xe)e.uniformBlockBinding(_e,xe,k.__bindingPointIndex),c.set(_e,xe)}function ot(){e.disable(e.BLEND),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.blendColor(0,0,0,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(e.LESS),o.setReversed(!1),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),e.pixelStorei(e.PACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.BROWSER_DEFAULT_WEBGL),e.pixelStorei(e.PACK_ROW_LENGTH,0),e.pixelStorei(e.PACK_SKIP_PIXELS,0),e.pixelStorei(e.PACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_ROW_LENGTH,0),e.pixelStorei(e.UNPACK_IMAGE_HEIGHT,0),e.pixelStorei(e.UNPACK_SKIP_PIXELS,0),e.pixelStorei(e.UNPACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_SKIP_IMAGES,0),u={},h={},q=null,Q={},d={},f=new WeakMap,m=[],_=null,p=!1,g=null,M=null,T=null,v=null,S=null,E=null,R=null,x=new Ge(0,0,0),w=0,G=!1,C=null,D=null,ee=null,L=null,W=null,de.set(0,0,e.canvas.width,e.canvas.height),fe.set(0,0,e.canvas.width,e.canvas.height),s.reset(),o.reset(),a.reset()}return{buffers:{color:s,depth:o,stencil:a},enable:j,disable:re,bindFramebuffer:oe,drawBuffers:ue,useProgram:$e,setBlending:rt,setMaterial:nt,setFlipSided:Rt,setCullFace:it,setLineWidth:tn,setPolygonOffset:Ut,setScissorTest:It,activeTexture:O,bindTexture:_n,unbindTexture:ut,compressedTexImage2D:Pt,compressedTexImage3D:A,texImage2D:te,texImage3D:se,pixelStorei:Oe,getParameter:Ee,updateUBOMapping:ze,uniformBlockBinding:Be,texStorage2D:me,texStorage3D:ve,texSubImage2D:y,texSubImage3D:U,compressedTexSubImage2D:Y,compressedTexSubImage3D:le,scissor:ye,viewport:pe,reset:ot}}function nC(e,t,n,i,r,s,o){let a=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new ke,u=new WeakMap,h=new Set,d,f=new WeakMap,m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch(A){}function _(A,y){return m?new OffscreenCanvas(A,y):As("canvas")}function p(A,y,U){let Y=1,le=Pt(A);if(le.width>U||le.height>U)Y=U/Math.max(le.width,le.height);if(Y<1)if(typeof HTMLImageElement<"u"&&A instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&A instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&A instanceof ImageBitmap||typeof VideoFrame<"u"&&A instanceof VideoFrame){let me=Math.floor(Y*le.width),ve=Math.floor(Y*le.height);if(d===void 0)d=_(me,ve);let te=y?_(me,ve):d;return te.width=me,te.height=ve,te.getContext("2d").drawImage(A,0,0,me,ve),Ue("WebGLRenderer: Texture has been resized from ("+le.width+"x"+le.height+") to ("+me+"x"+ve+")."),te}else{if("data"in A)Ue("WebGLRenderer: Image in DataTexture is too big ("+le.width+"x"+le.height+").");return A}return A}function g(A){return A.generateMipmaps}function M(A){e.generateMipmap(A)}function T(A){if(A.isWebGLCubeRenderTarget)return e.TEXTURE_CUBE_MAP;if(A.isWebGL3DRenderTarget)return e.TEXTURE_3D;if(A.isWebGLArrayRenderTarget||A.isCompressedArrayTexture)return e.TEXTURE_2D_ARRAY;return e.TEXTURE_2D}function v(A,y,U,Y,le,me=!1){if(A!==null){if(e[A]!==void 0)return e[A];Ue("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+A+"'")}let ve;if(Y){if(ve=t.get("EXT_texture_norm16"),!ve)Ue("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension")}let te=y;if(y===e.RED){if(U===e.FLOAT)te=e.R32F;if(U===e.HALF_FLOAT)te=e.R16F;if(U===e.UNSIGNED_BYTE)te=e.R8;if(U===e.UNSIGNED_SHORT&&ve)te=ve.R16_EXT;if(U===e.SHORT&&ve)te=ve.R16_SNORM_EXT}if(y===e.RED_INTEGER){if(U===e.UNSIGNED_BYTE)te=e.R8UI;if(U===e.UNSIGNED_SHORT)te=e.R16UI;if(U===e.UNSIGNED_INT)te=e.R32UI;if(U===e.BYTE)te=e.R8I;if(U===e.SHORT)te=e.R16I;if(U===e.INT)te=e.R32I}if(y===e.RG){if(U===e.FLOAT)te=e.RG32F;if(U===e.HALF_FLOAT)te=e.RG16F;if(U===e.UNSIGNED_BYTE)te=e.RG8;if(U===e.UNSIGNED_SHORT&&ve)te=ve.RG16_EXT;if(U===e.SHORT&&ve)te=ve.RG16_SNORM_EXT}if(y===e.RG_INTEGER){if(U===e.UNSIGNED_BYTE)te=e.RG8UI;if(U===e.UNSIGNED_SHORT)te=e.RG16UI;if(U===e.UNSIGNED_INT)te=e.RG32UI;if(U===e.BYTE)te=e.RG8I;if(U===e.SHORT)te=e.RG16I;if(U===e.INT)te=e.RG32I}if(y===e.RGB_INTEGER){if(U===e.UNSIGNED_BYTE)te=e.RGB8UI;if(U===e.UNSIGNED_SHORT)te=e.RGB16UI;if(U===e.UNSIGNED_INT)te=e.RGB32UI;if(U===e.BYTE)te=e.RGB8I;if(U===e.SHORT)te=e.RGB16I;if(U===e.INT)te=e.RGB32I}if(y===e.RGBA_INTEGER){if(U===e.UNSIGNED_BYTE)te=e.RGBA8UI;if(U===e.UNSIGNED_SHORT)te=e.RGBA16UI;if(U===e.UNSIGNED_INT)te=e.RGBA32UI;if(U===e.BYTE)te=e.RGBA8I;if(U===e.SHORT)te=e.RGBA16I;if(U===e.INT)te=e.RGBA32I}if(y===e.RGB){if(U===e.UNSIGNED_SHORT&&ve)te=ve.RGB16_EXT;if(U===e.SHORT&&ve)te=ve.RGB16_SNORM_EXT;if(U===e.UNSIGNED_INT_5_9_9_9_REV)te=e.RGB9_E5;if(U===e.UNSIGNED_INT_10F_11F_11F_REV)te=e.R11F_G11F_B10F}if(y===e.RGBA){let se=me?cd:Ke.getTransfer(le);if(U===e.FLOAT)te=e.RGBA32F;if(U===e.HALF_FLOAT)te=e.RGBA16F;if(U===e.UNSIGNED_BYTE)te=se===yt?e.SRGB8_ALPHA8:e.RGBA8;if(U===e.UNSIGNED_SHORT&&ve)te=ve.RGBA16_EXT;if(U===e.SHORT&&ve)te=ve.RGBA16_SNORM_EXT;if(U===e.UNSIGNED_SHORT_4_4_4_4)te=e.RGBA4;if(U===e.UNSIGNED_SHORT_5_5_5_1)te=e.RGB5_A1}if(te===e.R16F||te===e.R32F||te===e.RG16F||te===e.RG32F||te===e.RGBA16F||te===e.RGBA32F)t.get("EXT_color_buffer_float");return te}function S(A,y){let U;if(A){if(y===null||y===mr||y===Us)U=e.DEPTH24_STENCIL8;else if(y===$i)U=e.DEPTH32F_STENCIL8;else if(y===Zo)U=e.DEPTH24_STENCIL8,Ue("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")}else if(y===null||y===mr||y===Us)U=e.DEPTH_COMPONENT24;else if(y===$i)U=e.DEPTH_COMPONENT32F;else if(y===Zo)U=e.DEPTH_COMPONENT16;return U}function E(A,y){if(g(A)===!0||A.isFramebufferTexture&&A.minFilter!==ti&&A.minFilter!==Jt)return Math.log2(Math.max(y.width,y.height))+1;else if(A.mipmaps!==void 0&&A.mipmaps.length>0)return A.mipmaps.length;else if(A.isCompressedTexture&&Array.isArray(A.image))return y.mipmaps.length;else return 1}function R(A){let y=A.target;if(y.removeEventListener("dispose",R),w(y),y.isVideoTexture)u.delete(y);if(y.isHTMLTexture)h.delete(y)}function x(A){let y=A.target;y.removeEventListener("dispose",x),C(y)}function w(A){let y=i.get(A);if(y.__webglInit===void 0)return;let U=A.source,Y=f.get(U);if(Y){let le=Y[y.__cacheKey];if(le.usedTimes--,le.usedTimes===0)G(A);if(Object.keys(Y).length===0)f.delete(U)}i.remove(A)}function G(A){let y=i.get(A);e.deleteTexture(y.__webglTexture);let U=A.source,Y=f.get(U);delete Y[y.__cacheKey],o.memory.textures--}function C(A){let y=i.get(A);if(A.depthTexture)A.depthTexture.dispose(),i.remove(A.depthTexture);if(A.isWebGLCubeRenderTarget)for(let Y=0;Y<6;Y++){if(Array.isArray(y.__webglFramebuffer[Y]))for(let le=0;le<y.__webglFramebuffer[Y].length;le++)e.deleteFramebuffer(y.__webglFramebuffer[Y][le]);else e.deleteFramebuffer(y.__webglFramebuffer[Y]);if(y.__webglDepthbuffer)e.deleteRenderbuffer(y.__webglDepthbuffer[Y])}else{if(Array.isArray(y.__webglFramebuffer))for(let Y=0;Y<y.__webglFramebuffer.length;Y++)e.deleteFramebuffer(y.__webglFramebuffer[Y]);else e.deleteFramebuffer(y.__webglFramebuffer);if(y.__webglDepthbuffer)e.deleteRenderbuffer(y.__webglDepthbuffer);if(y.__webglMultisampledFramebuffer)e.deleteFramebuffer(y.__webglMultisampledFramebuffer);if(y.__webglColorRenderbuffer){for(let Y=0;Y<y.__webglColorRenderbuffer.length;Y++)if(y.__webglColorRenderbuffer[Y])e.deleteRenderbuffer(y.__webglColorRenderbuffer[Y])}if(y.__webglDepthRenderbuffer)e.deleteRenderbuffer(y.__webglDepthRenderbuffer)}let U=A.textures;for(let Y=0,le=U.length;Y<le;Y++){let me=i.get(U[Y]);if(me.__webglTexture)e.deleteTexture(me.__webglTexture),o.memory.textures--;i.remove(U[Y])}i.remove(A)}let D=0;function ee(){D=0}function L(){return D}function W(A){D=A}function B(){let A=D;if(A>=r.maxTextures)Ue("WebGLTextures: Trying to use "+(A+1)+" texture units while this GPU supports only "+r.maxTextures);return D+=1,A}function P(A){let y=[];return y.push(A.wrapS),y.push(A.wrapT),y.push(A.wrapR||0),y.push(A.magFilter),y.push(A.minFilter),y.push(A.anisotropy),y.push(A.internalFormat),y.push(A.format),y.push(A.type),y.push(A.generateMipmaps),y.push(A.premultiplyAlpha),y.push(A.flipY),y.push(A.unpackAlignment),y.push(A.colorSpace),y.join()}function J(A,y){let U=i.get(A);if(A.isVideoTexture)_n(A);if(A.isRenderTargetTexture===!1&&A.isExternalTexture!==!0&&A.version>0&&U.__version!==A.version){let Y=A.image;if(Y===null)Ue("WebGLRenderer: Texture marked for update but no image data found.");else if(Y.complete===!1)Ue("WebGLRenderer: Texture marked for update but image is incomplete");else{re(U,A,y);return}}else if(A.isExternalTexture)U.__webglTexture=A.sourceTexture?A.sourceTexture:null;n.bindTexture(e.TEXTURE_2D,U.__webglTexture,e.TEXTURE0+y)}function H(A,y){let U=i.get(A);if(A.isRenderTargetTexture===!1&&A.version>0&&U.__version!==A.version){re(U,A,y);return}else if(A.isExternalTexture)U.__webglTexture=A.sourceTexture?A.sourceTexture:null;n.bindTexture(e.TEXTURE_2D_ARRAY,U.__webglTexture,e.TEXTURE0+y)}function q(A,y){let U=i.get(A);if(A.isRenderTargetTexture===!1&&A.version>0&&U.__version!==A.version){re(U,A,y);return}n.bindTexture(e.TEXTURE_3D,U.__webglTexture,e.TEXTURE0+y)}function Q(A,y){let U=i.get(A);if(A.isCubeDepthTexture!==!0&&A.version>0&&U.__version!==A.version){oe(U,A,y);return}n.bindTexture(e.TEXTURE_CUBE_MAP,U.__webglTexture,e.TEXTURE0+y)}let ge={[Ns]:e.REPEAT,[Ds]:e.CLAMP_TO_EDGE,[kc]:e.MIRRORED_REPEAT},he={[ti]:e.NEAREST,[Bc]:e.NEAREST_MIPMAP_NEAREST,[Zr]:e.NEAREST_MIPMAP_LINEAR,[Jt]:e.LINEAR,[Os]:e.LINEAR_MIPMAP_NEAREST,[yi]:e.LINEAR_MIPMAP_LINEAR},de={[hv]:e.NEVER,[gv]:e.ALWAYS,[dv]:e.LESS,[jc]:e.LEQUAL,[fv]:e.EQUAL,[qc]:e.GEQUAL,[pv]:e.GREATER,[mv]:e.NOTEQUAL};function fe(A,y){if(y.type===$i&&t.has("OES_texture_float_linear")===!1&&(y.magFilter===Jt||y.magFilter===Os||y.magFilter===Zr||y.magFilter===yi||y.minFilter===Jt||y.minFilter===Os||y.minFilter===Zr||y.minFilter===yi))Ue("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.");if(e.texParameteri(A,e.TEXTURE_WRAP_S,ge[y.wrapS]),e.texParameteri(A,e.TEXTURE_WRAP_T,ge[y.wrapT]),A===e.TEXTURE_3D||A===e.TEXTURE_2D_ARRAY)e.texParameteri(A,e.TEXTURE_WRAP_R,ge[y.wrapR]);if(e.texParameteri(A,e.TEXTURE_MAG_FILTER,he[y.magFilter]),e.texParameteri(A,e.TEXTURE_MIN_FILTER,he[y.minFilter]),y.compareFunction)e.texParameteri(A,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(A,e.TEXTURE_COMPARE_FUNC,de[y.compareFunction]);if(t.has("EXT_texture_filter_anisotropic")===!0){if(y.magFilter===ti)return;if(y.minFilter!==Zr&&y.minFilter!==yi)return;if(y.type===$i&&t.has("OES_texture_float_linear")===!1)return;if(y.anisotropy>1||i.get(y).__currentAnisotropy){let U=t.get("EXT_texture_filter_anisotropic");e.texParameterf(A,U.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(y.anisotropy,r.getMaxAnisotropy())),i.get(y).__currentAnisotropy=y.anisotropy}}}function I(A,y){let U=!1;if(A.__webglInit===void 0)A.__webglInit=!0,y.addEventListener("dispose",R);let Y=y.source,le=f.get(Y);if(le===void 0)le={},f.set(Y,le);let me=P(y);if(me!==A.__cacheKey){if(le[me]===void 0)le[me]={texture:e.createTexture(),usedTimes:0},o.memory.textures++,U=!0;le[me].usedTimes++;let ve=le[A.__cacheKey];if(ve!==void 0){if(le[A.__cacheKey].usedTimes--,ve.usedTimes===0)G(y)}A.__cacheKey=me,A.__webglTexture=le[me].texture}return U}function V(A,y,U){return Math.floor(Math.floor(A/U)/y)}function j(A,y,U,Y){let me=A.updateRanges;if(me.length===0)n.texSubImage2D(e.TEXTURE_2D,0,0,0,y.width,y.height,U,Y,y.data);else{me.sort((Oe,ye)=>Oe.start-ye.start);let ve=0;for(let Oe=1;Oe<me.length;Oe++){let ye=me[ve],pe=me[Oe],ze=ye.start+ye.count,Be=V(pe.start,y.width,4),ot=V(ye.start,y.width,4);if(pe.start<=ze+1&&Be===ot&&V(pe.start+pe.count-1,y.width,4)===Be)ye.count=Math.max(ye.count,pe.start+pe.count-ye.start);else++ve,me[ve]=pe}me.length=ve+1;let te=n.getParameter(e.UNPACK_ROW_LENGTH),se=n.getParameter(e.UNPACK_SKIP_PIXELS),Ee=n.getParameter(e.UNPACK_SKIP_ROWS);n.pixelStorei(e.UNPACK_ROW_LENGTH,y.width);for(let Oe=0,ye=me.length;Oe<ye;Oe++){let pe=me[Oe],ze=Math.floor(pe.start/4),Be=Math.ceil(pe.count/4),ot=ze%y.width,k=Math.floor(ze/y.width),_e=Be,ne=1;n.pixelStorei(e.UNPACK_SKIP_PIXELS,ot),n.pixelStorei(e.UNPACK_SKIP_ROWS,k),n.texSubImage2D(e.TEXTURE_2D,0,ot,k,_e,1,U,Y,y.data)}A.clearUpdateRanges(),n.pixelStorei(e.UNPACK_ROW_LENGTH,te),n.pixelStorei(e.UNPACK_SKIP_PIXELS,se),n.pixelStorei(e.UNPACK_SKIP_ROWS,Ee)}}function re(A,y,U){let Y=e.TEXTURE_2D;if(y.isDataArrayTexture||y.isCompressedArrayTexture)Y=e.TEXTURE_2D_ARRAY;if(y.isData3DTexture)Y=e.TEXTURE_3D;let le=I(A,y),me=y.source;n.bindTexture(Y,A.__webglTexture,e.TEXTURE0+U);let ve=i.get(me);if(me.version!==ve.__version||le===!0){if(n.activeTexture(e.TEXTURE0+U),(typeof ImageBitmap<"u"&&y.image instanceof ImageBitmap)===!1){let ne=Ke.getPrimaries(Ke.workingColorSpace),xe=y.colorSpace===Yr?null:Ke.getPrimaries(y.colorSpace),Te=y.colorSpace===Yr||ne===xe?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,y.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,y.premultiplyAlpha),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,Te)}n.pixelStorei(e.UNPACK_ALIGNMENT,y.unpackAlignment);let se=p(y.image,!1,r.maxTextureSize);se=ut(y,se);let Ee=s.convert(y.format,y.colorSpace),Oe=s.convert(y.type),ye=v(y.internalFormat,Ee,Oe,y.normalized,y.colorSpace,y.isVideoTexture);fe(Y,y);let pe,ze=y.mipmaps,Be=y.isVideoTexture!==!0,ot=ve.__version===void 0||le===!0,k=me.dataReady,_e=E(y,se);if(y.isDepthTexture){if(ye=S(y.format===jr,y.type),ot)if(Be)n.texStorage2D(e.TEXTURE_2D,1,ye,se.width,se.height);else n.texImage2D(e.TEXTURE_2D,0,ye,se.width,se.height,0,Ee,Oe,null)}else if(y.isDataTexture)if(ze.length>0){if(Be&&ot)n.texStorage2D(e.TEXTURE_2D,_e,ye,ze[0].width,ze[0].height);for(let ne=0,xe=ze.length;ne<xe;ne++)if(pe=ze[ne],Be){if(k)n.texSubImage2D(e.TEXTURE_2D,ne,0,0,pe.width,pe.height,Ee,Oe,pe.data)}else n.texImage2D(e.TEXTURE_2D,ne,ye,pe.width,pe.height,0,Ee,Oe,pe.data);y.generateMipmaps=!1}else if(Be){if(ot)n.texStorage2D(e.TEXTURE_2D,_e,ye,se.width,se.height);if(k)j(y,se,Ee,Oe)}else n.texImage2D(e.TEXTURE_2D,0,ye,se.width,se.height,0,Ee,Oe,se.data);else if(y.isCompressedTexture)if(y.isCompressedArrayTexture){if(Be&&ot)n.texStorage3D(e.TEXTURE_2D_ARRAY,_e,ye,ze[0].width,ze[0].height,se.depth);for(let ne=0,xe=ze.length;ne<xe;ne++)if(pe=ze[ne],y.format!==Si)if(Ee!==null)if(Be){if(k)if(y.layerUpdates.size>0){let Te=Ld(pe.width,pe.height,y.format,y.type);for(let ce of y.layerUpdates){let Se=pe.data.subarray(ce*Te/pe.data.BYTES_PER_ELEMENT,(ce+1)*Te/pe.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,ne,0,0,ce,pe.width,pe.height,1,Ee,Se)}}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,ne,0,0,0,pe.width,pe.height,se.depth,Ee,pe.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,ne,ye,pe.width,pe.height,se.depth,0,pe.data,0,0);else Ue("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(Be){if(k)n.texSubImage3D(e.TEXTURE_2D_ARRAY,ne,0,0,0,pe.width,pe.height,se.depth,Ee,Oe,pe.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,ne,ye,pe.width,pe.height,se.depth,0,Ee,Oe,pe.data);if(y.layerUpdates.size>0)y.clearLayerUpdates()}else{if(Be&&ot)n.texStorage2D(e.TEXTURE_2D,_e,ye,ze[0].width,ze[0].height);for(let ne=0,xe=ze.length;ne<xe;ne++)if(pe=ze[ne],y.format!==Si)if(Ee!==null)if(Be){if(k)n.compressedTexSubImage2D(e.TEXTURE_2D,ne,0,0,pe.width,pe.height,Ee,pe.data)}else n.compressedTexImage2D(e.TEXTURE_2D,ne,ye,pe.width,pe.height,0,pe.data);else Ue("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(Be){if(k)n.texSubImage2D(e.TEXTURE_2D,ne,0,0,pe.width,pe.height,Ee,Oe,pe.data)}else n.texImage2D(e.TEXTURE_2D,ne,ye,pe.width,pe.height,0,Ee,Oe,pe.data)}else if(y.isDataArrayTexture)if(Be){if(ot)n.texStorage3D(e.TEXTURE_2D_ARRAY,_e,ye,se.width,se.height,se.depth);if(k)if(y.layerUpdates.size>0){let ne=Ld(se.width,se.height,y.format,y.type);for(let xe of y.layerUpdates){let Te=se.data.subarray(xe*ne/se.data.BYTES_PER_ELEMENT,(xe+1)*ne/se.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,xe,se.width,se.height,1,Ee,Oe,Te)}y.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,se.width,se.height,se.depth,Ee,Oe,se.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,ye,se.width,se.height,se.depth,0,Ee,Oe,se.data);else if(y.isData3DTexture)if(Be){if(ot)n.texStorage3D(e.TEXTURE_3D,_e,ye,se.width,se.height,se.depth);if(k)n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,se.width,se.height,se.depth,Ee,Oe,se.data)}else n.texImage3D(e.TEXTURE_3D,0,ye,se.width,se.height,se.depth,0,Ee,Oe,se.data);else if(y.isFramebufferTexture){if(ot)if(Be)n.texStorage2D(e.TEXTURE_2D,_e,ye,se.width,se.height);else{let ne=se.width,xe=se.height;for(let Te=0;Te<_e;Te++)n.texImage2D(e.TEXTURE_2D,Te,ye,ne,xe,0,Ee,Oe,null),ne>>=1,xe>>=1}}else if(y.isHTMLTexture){if("texElementImage2D"in e){let ne=e.canvas;if(!ne.hasAttribute("layoutsubtree"))ne.setAttribute("layoutsubtree","true");if(se.parentNode!==ne){ne.appendChild(se),h.add(y),ne.onpaint=(xe)=>{let Te=xe.changedElements;for(let ce of h)if(Te.includes(ce.image))ce.needsUpdate=!0},ne.requestPaint();return}if(e.texElementImage2D.length===3)e.texElementImage2D(e.TEXTURE_2D,e.RGBA8,se);else{let{RGBA:Te,RGBA:ce,UNSIGNED_BYTE:Se}=e;e.texElementImage2D(e.TEXTURE_2D,0,Te,ce,Se,se)}e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)}}else if(ze.length>0){if(Be&&ot){let ne=Pt(ze[0]);n.texStorage2D(e.TEXTURE_2D,_e,ye,ne.width,ne.height)}for(let ne=0,xe=ze.length;ne<xe;ne++)if(pe=ze[ne],Be){if(k)n.texSubImage2D(e.TEXTURE_2D,ne,0,0,Ee,Oe,pe)}else n.texImage2D(e.TEXTURE_2D,ne,ye,Ee,Oe,pe);y.generateMipmaps=!1}else if(Be){if(ot){let ne=Pt(se);n.texStorage2D(e.TEXTURE_2D,_e,ye,ne.width,ne.height)}if(k)n.texSubImage2D(e.TEXTURE_2D,0,0,0,Ee,Oe,se)}else n.texImage2D(e.TEXTURE_2D,0,ye,Ee,Oe,se);if(g(y))M(Y);if(ve.__version=me.version,y.onUpdate)y.onUpdate(y)}A.__version=y.version}function oe(A,y,U){if(y.image.length!==6)return;let Y=I(A,y),le=y.source;n.bindTexture(e.TEXTURE_CUBE_MAP,A.__webglTexture,e.TEXTURE0+U);let me=i.get(le);if(le.version!==me.__version||Y===!0){n.activeTexture(e.TEXTURE0+U);let ve=Ke.getPrimaries(Ke.workingColorSpace),te=y.colorSpace===Yr?null:Ke.getPrimaries(y.colorSpace),se=y.colorSpace===Yr||ve===te?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,y.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,y.premultiplyAlpha),n.pixelStorei(e.UNPACK_ALIGNMENT,y.unpackAlignment),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,se);let Ee=y.isCompressedTexture||y.image[0].isCompressedTexture,Oe=y.image[0]&&y.image[0].isDataTexture,ye=[];for(let ce=0;ce<6;ce++){if(!Ee&&!Oe)ye[ce]=p(y.image[ce],!0,r.maxCubemapSize);else ye[ce]=Oe?y.image[ce].image:y.image[ce];ye[ce]=ut(y,ye[ce])}let pe=ye[0],ze=s.convert(y.format,y.colorSpace),Be=s.convert(y.type),ot=v(y.internalFormat,ze,Be,y.normalized,y.colorSpace),k=y.isVideoTexture!==!0,_e=me.__version===void 0||Y===!0,ne=le.dataReady,xe=E(y,pe);fe(e.TEXTURE_CUBE_MAP,y);let Te;if(Ee){if(k&&_e)n.texStorage2D(e.TEXTURE_CUBE_MAP,xe,ot,pe.width,pe.height);for(let ce=0;ce<6;ce++){Te=ye[ce].mipmaps;for(let Se=0;Se<Te.length;Se++){let Ze=Te[Se];if(y.format!==Si)if(ze!==null)if(k){if(ne)n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Se,0,0,Ze.width,Ze.height,ze,Ze.data)}else n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Se,ot,Ze.width,Ze.height,0,Ze.data);else Ue("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()");else if(k){if(ne)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Se,0,0,Ze.width,Ze.height,ze,Be,Ze.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Se,ot,Ze.width,Ze.height,0,ze,Be,Ze.data)}}}else{if(Te=y.mipmaps,k&&_e){if(Te.length>0)xe++;let ce=Pt(ye[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,xe,ot,ce.width,ce.height)}for(let ce=0;ce<6;ce++)if(Oe){if(k){if(ne)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,0,0,ye[ce].width,ye[ce].height,ze,Be,ye[ce].data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,ot,ye[ce].width,ye[ce].height,0,ze,Be,ye[ce].data);for(let Se=0;Se<Te.length;Se++){let bt=Te[Se].image[ce].image;if(k){if(ne)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Se+1,0,0,bt.width,bt.height,ze,Be,bt.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Se+1,ot,bt.width,bt.height,0,ze,Be,bt.data)}}else{if(k){if(ne)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,0,0,ze,Be,ye[ce])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,ot,ze,Be,ye[ce]);for(let Se=0;Se<Te.length;Se++){let Ze=Te[Se];if(k){if(ne)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Se+1,0,0,ze,Be,Ze.image[ce])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Se+1,ot,ze,Be,Ze.image[ce])}}}if(g(y))M(e.TEXTURE_CUBE_MAP);if(me.__version=le.version,y.onUpdate)y.onUpdate(y)}A.__version=y.version}function ue(A,y,U,Y,le,me){let ve=s.convert(U.format,U.colorSpace),te=s.convert(U.type),se=v(U.internalFormat,ve,te,U.normalized,U.colorSpace),Ee=i.get(y),Oe=i.get(U);if(Oe.__renderTarget=y,!Ee.__hasExternalTextures){let ye=Math.max(1,y.width>>me),pe=Math.max(1,y.height>>me);if(le===e.TEXTURE_3D||le===e.TEXTURE_2D_ARRAY)n.texImage3D(le,me,se,ye,pe,y.depth,0,ve,te,null);else n.texImage2D(le,me,se,ye,pe,0,ve,te,null)}if(n.bindFramebuffer(e.FRAMEBUFFER,A),O(y))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,Y,le,Oe.__webglTexture,0,It(y));else if(le===e.TEXTURE_2D||le>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&le<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)e.framebufferTexture2D(e.FRAMEBUFFER,Y,le,Oe.__webglTexture,me);n.bindFramebuffer(e.FRAMEBUFFER,null)}function $e(A,y,U){if(e.bindRenderbuffer(e.RENDERBUFFER,A),y.depthBuffer){let Y=y.depthTexture,le=Y&&Y.isDepthTexture?Y.type:null,me=S(y.stencilBuffer,le),ve=y.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(O(y))a.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,It(y),me,y.width,y.height);else if(U)e.renderbufferStorageMultisample(e.RENDERBUFFER,It(y),me,y.width,y.height);else e.renderbufferStorage(e.RENDERBUFFER,me,y.width,y.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,ve,e.RENDERBUFFER,A)}else{let Y=y.textures;for(let le=0;le<Y.length;le++){let me=Y[le],ve=s.convert(me.format,me.colorSpace),te=s.convert(me.type),se=v(me.internalFormat,ve,te,me.normalized,me.colorSpace);if(O(y))a.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,It(y),se,y.width,y.height);else if(U)e.renderbufferStorageMultisample(e.RENDERBUFFER,It(y),se,y.width,y.height);else e.renderbufferStorage(e.RENDERBUFFER,se,y.width,y.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function Ce(A,y,U){let Y=y.isWebGLCubeRenderTarget===!0;if(n.bindFramebuffer(e.FRAMEBUFFER,A),!(y.depthTexture&&y.depthTexture.isDepthTexture))throw Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");let le=i.get(y.depthTexture);if(le.__renderTarget=y,!le.__webglTexture||y.depthTexture.image.width!==y.width||y.depthTexture.image.height!==y.height)y.depthTexture.image.width=y.width,y.depthTexture.image.height=y.height,y.depthTexture.needsUpdate=!0;if(Y){if(le.__webglInit===void 0)le.__webglInit=!0,y.depthTexture.addEventListener("dispose",R);if(le.__webglTexture===void 0){le.__webglTexture=e.createTexture(),n.bindTexture(e.TEXTURE_CUBE_MAP,le.__webglTexture),fe(e.TEXTURE_CUBE_MAP,y.depthTexture);let Ee=s.convert(y.depthTexture.format),Oe=s.convert(y.depthTexture.type),ye;if(y.depthTexture.format===Xr)ye=e.DEPTH_COMPONENT24;else if(y.depthTexture.format===jr)ye=e.DEPTH24_STENCIL8;for(let pe=0;pe<6;pe++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+pe,0,ye,y.width,y.height,0,Ee,Oe,null)}}else J(y.depthTexture,0);let me=le.__webglTexture,ve=It(y),te=Y?e.TEXTURE_CUBE_MAP_POSITIVE_X+U:e.TEXTURE_2D,se=y.depthTexture.format===jr?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(y.depthTexture.format===Xr)if(O(y))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,se,te,me,0,ve);else e.framebufferTexture2D(e.FRAMEBUFFER,se,te,me,0);else if(y.depthTexture.format===jr)if(O(y))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,se,te,me,0,ve);else e.framebufferTexture2D(e.FRAMEBUFFER,se,te,me,0);else throw Error("THREE.WebGLTextures: Unknown depthTexture format.")}function He(A){let y=i.get(A),U=A.isWebGLCubeRenderTarget===!0;if(y.__boundDepthTexture!==A.depthTexture){let Y=A.depthTexture;if(y.__depthDisposeCallback)y.__depthDisposeCallback();if(Y){let le=()=>{delete y.__boundDepthTexture,delete y.__depthDisposeCallback,Y.removeEventListener("dispose",le)};Y.addEventListener("dispose",le),y.__depthDisposeCallback=le}y.__boundDepthTexture=Y}if(A.depthTexture&&!y.__autoAllocateDepthBuffer)if(U)for(let Y=0;Y<6;Y++)Ce(y.__webglFramebuffer[Y],A,Y);else{let Y=A.texture.mipmaps;if(Y&&Y.length>0)Ce(y.__webglFramebuffer[0],A,0);else Ce(y.__webglFramebuffer,A,0)}else if(U){y.__webglDepthbuffer=[];for(let Y=0;Y<6;Y++)if(n.bindFramebuffer(e.FRAMEBUFFER,y.__webglFramebuffer[Y]),y.__webglDepthbuffer[Y]===void 0)y.__webglDepthbuffer[Y]=e.createRenderbuffer(),$e(y.__webglDepthbuffer[Y],A,!1);else{let le=A.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,me=y.__webglDepthbuffer[Y];e.bindRenderbuffer(e.RENDERBUFFER,me),e.framebufferRenderbuffer(e.FRAMEBUFFER,le,e.RENDERBUFFER,me)}}else{let Y=A.texture.mipmaps;if(Y&&Y.length>0)n.bindFramebuffer(e.FRAMEBUFFER,y.__webglFramebuffer[0]);else n.bindFramebuffer(e.FRAMEBUFFER,y.__webglFramebuffer);if(y.__webglDepthbuffer===void 0)y.__webglDepthbuffer=e.createRenderbuffer(),$e(y.__webglDepthbuffer,A,!1);else{let le=A.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,me=y.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,me),e.framebufferRenderbuffer(e.FRAMEBUFFER,le,e.RENDERBUFFER,me)}}n.bindFramebuffer(e.FRAMEBUFFER,null)}function rt(A,y,U){let Y=i.get(A);if(y!==void 0)ue(Y.__webglFramebuffer,A,A.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0);if(U!==void 0)He(A)}function nt(A){let y=A.texture,U=i.get(A),Y=i.get(y);A.addEventListener("dispose",x);let le=A.textures,me=A.isWebGLCubeRenderTarget===!0,ve=le.length>1;if(!ve){if(Y.__webglTexture===void 0)Y.__webglTexture=e.createTexture();Y.__version=y.version,o.memory.textures++}if(me){U.__webglFramebuffer=[];for(let te=0;te<6;te++)if(y.mipmaps&&y.mipmaps.length>0){U.__webglFramebuffer[te]=[];for(let se=0;se<y.mipmaps.length;se++)U.__webglFramebuffer[te][se]=e.createFramebuffer()}else U.__webglFramebuffer[te]=e.createFramebuffer()}else{if(y.mipmaps&&y.mipmaps.length>0){U.__webglFramebuffer=[];for(let te=0;te<y.mipmaps.length;te++)U.__webglFramebuffer[te]=e.createFramebuffer()}else U.__webglFramebuffer=e.createFramebuffer();if(ve)for(let te=0,se=le.length;te<se;te++){let Ee=i.get(le[te]);if(Ee.__webglTexture===void 0)Ee.__webglTexture=e.createTexture(),o.memory.textures++}if(A.samples>0&&O(A)===!1){U.__webglMultisampledFramebuffer=e.createFramebuffer(),U.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,U.__webglMultisampledFramebuffer);for(let te=0;te<le.length;te++){let se=le[te];U.__webglColorRenderbuffer[te]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,U.__webglColorRenderbuffer[te]);let Ee=s.convert(se.format,se.colorSpace),Oe=s.convert(se.type),ye=v(se.internalFormat,Ee,Oe,se.normalized,se.colorSpace,A.isXRRenderTarget===!0),pe=It(A);e.renderbufferStorageMultisample(e.RENDERBUFFER,pe,ye,A.width,A.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+te,e.RENDERBUFFER,U.__webglColorRenderbuffer[te])}if(e.bindRenderbuffer(e.RENDERBUFFER,null),A.depthBuffer)U.__webglDepthRenderbuffer=e.createRenderbuffer(),$e(U.__webglDepthRenderbuffer,A,!0);n.bindFramebuffer(e.FRAMEBUFFER,null)}}if(me){n.bindTexture(e.TEXTURE_CUBE_MAP,Y.__webglTexture),fe(e.TEXTURE_CUBE_MAP,y);for(let te=0;te<6;te++)if(y.mipmaps&&y.mipmaps.length>0)for(let se=0;se<y.mipmaps.length;se++)ue(U.__webglFramebuffer[te][se],A,y,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+te,se);else ue(U.__webglFramebuffer[te],A,y,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+te,0);if(g(y))M(e.TEXTURE_CUBE_MAP);n.unbindTexture()}else if(ve){for(let te=0,se=le.length;te<se;te++){let Ee=le[te],Oe=i.get(Ee),ye=e.TEXTURE_2D;if(A.isWebGL3DRenderTarget||A.isWebGLArrayRenderTarget)ye=A.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(ye,Oe.__webglTexture),fe(ye,Ee),ue(U.__webglFramebuffer,A,Ee,e.COLOR_ATTACHMENT0+te,ye,0),g(Ee))M(ye)}n.unbindTexture()}else{let te=e.TEXTURE_2D;if(A.isWebGL3DRenderTarget||A.isWebGLArrayRenderTarget)te=A.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(te,Y.__webglTexture),fe(te,y),y.mipmaps&&y.mipmaps.length>0)for(let se=0;se<y.mipmaps.length;se++)ue(U.__webglFramebuffer[se],A,y,e.COLOR_ATTACHMENT0,te,se);else ue(U.__webglFramebuffer,A,y,e.COLOR_ATTACHMENT0,te,0);if(g(y))M(te);n.unbindTexture()}if(A.depthBuffer)He(A)}function Rt(A){let y=A.textures;for(let U=0,Y=y.length;U<Y;U++){let le=y[U];if(g(le)){let me=T(A),ve=i.get(le).__webglTexture;n.bindTexture(me,ve),M(me),n.unbindTexture()}}}let it=[],tn=[];function Ut(A){if(A.samples>0){if(O(A)===!1){let{textures:y,width:U,height:Y}=A,le=e.COLOR_BUFFER_BIT,me=A.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ve=i.get(A),te=y.length>1;if(te)for(let Ee=0;Ee<y.length;Ee++)n.bindFramebuffer(e.FRAMEBUFFER,ve.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+Ee,e.RENDERBUFFER,null),n.bindFramebuffer(e.FRAMEBUFFER,ve.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+Ee,e.TEXTURE_2D,null,0);n.bindFramebuffer(e.READ_FRAMEBUFFER,ve.__webglMultisampledFramebuffer);let se=A.texture.mipmaps;if(se&&se.length>0)n.bindFramebuffer(e.DRAW_FRAMEBUFFER,ve.__webglFramebuffer[0]);else n.bindFramebuffer(e.DRAW_FRAMEBUFFER,ve.__webglFramebuffer);for(let Ee=0;Ee<y.length;Ee++){if(A.resolveDepthBuffer){if(A.depthBuffer)le|=e.DEPTH_BUFFER_BIT;if(A.stencilBuffer&&A.resolveStencilBuffer)le|=e.STENCIL_BUFFER_BIT}if(te){e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,ve.__webglColorRenderbuffer[Ee]);let Oe=i.get(y[Ee]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,Oe,0)}if(e.blitFramebuffer(0,0,U,Y,0,0,U,Y,le,e.NEAREST),c===!0){if(it.length=0,tn.length=0,it.push(e.COLOR_ATTACHMENT0+Ee),A.depthBuffer&&A.storeMultisampledDepthBuffer===!1)it.push(me),tn.push(me),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,tn);e.invalidateFramebuffer(e.READ_FRAMEBUFFER,it)}}if(n.bindFramebuffer(e.READ_FRAMEBUFFER,null),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),te)for(let Ee=0;Ee<y.length;Ee++){n.bindFramebuffer(e.FRAMEBUFFER,ve.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+Ee,e.RENDERBUFFER,ve.__webglColorRenderbuffer[Ee]);let Oe=i.get(y[Ee]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,ve.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+Ee,e.TEXTURE_2D,Oe,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,ve.__webglMultisampledFramebuffer)}else if(A.depthBuffer&&A.storeMultisampledDepthBuffer===!1&&c){let y=A.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[y])}}}function It(A){return Math.min(r.maxSamples,A.samples)}function O(A){let y=i.get(A);return A.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&y.__useRenderToTexture!==!1}function _n(A){let y=o.render.frame;if(u.get(A)!==y)u.set(A,y),A.update()}function ut(A,y){let{colorSpace:U,format:Y,type:le}=A;if(A.isCompressedTexture===!0||A.isVideoTexture===!0)return y;if(U!==Rn&&U!==Yr)if(Ke.getTransfer(U)===yt){if(Y!==Si||le!==ni)Ue("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.")}else Ve("WebGLTextures: Unsupported texture color space:",U);return y}function Pt(A){if(typeof HTMLImageElement<"u"&&A instanceof HTMLImageElement)l.width=A.naturalWidth||A.width,l.height=A.naturalHeight||A.height;else if(typeof VideoFrame<"u"&&A instanceof VideoFrame)l.width=A.displayWidth,l.height=A.displayHeight;else l.width=A.width,l.height=A.height;return l}this.allocateTextureUnit=B,this.resetTextureUnits=ee,this.getTextureUnits=L,this.setTextureUnits=W,this.setTexture2D=J,this.setTexture2DArray=H,this.setTexture3D=q,this.setTextureCube=Q,this.rebindTextures=rt,this.setupRenderTarget=nt,this.updateRenderTargetMipmap=Rt,this.updateMultisampleRenderTarget=Ut,this.setupDepthRenderbuffer=He,this.setupFrameBufferTexture=ue,this.useMultisampledRTT=O,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function iC(e,t){function n(i,r=Yr){let s,o=Ke.getTransfer(r);if(i===ni)return e.UNSIGNED_BYTE;if(i===Mh)return e.UNSIGNED_SHORT_4_4_4_4;if(i===Eh)return e.UNSIGNED_SHORT_5_5_5_1;if(i===sv)return e.UNSIGNED_INT_5_9_9_9_REV;if(i===ov)return e.UNSIGNED_INT_10F_11F_11F_REV;if(i===iv)return e.BYTE;if(i===rv)return e.SHORT;if(i===Zo)return e.UNSIGNED_SHORT;if(i===wh)return e.INT;if(i===mr)return e.UNSIGNED_INT;if(i===$i)return e.FLOAT;if(i===bi)return e.HALF_FLOAT;if(i===av)return e.ALPHA;if(i===cv)return e.RGB;if(i===Si)return e.RGBA;if(i===Xr)return e.DEPTH_COMPONENT;if(i===jr)return e.DEPTH_STENCIL;if(i===lv)return e.RED;if(i===Th)return e.RED_INTEGER;if(i===qr)return e.RG;if(i===Ah)return e.RG_INTEGER;if(i===Rh)return e.RGBA_INTEGER;if(i===Gc||i===Hc||i===Vc||i===$c)if(o===yt)if(s=t.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===Gc)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Hc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Vc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===$c)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=t.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===Gc)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Hc)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Vc)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===$c)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Ch||i===Ih||i===Ph||i===Lh)if(s=t.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===Ch)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Ih)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Ph)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Lh)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===Nh||i===Dh||i===Oh||i===Uh||i===Fh||i===Wc||i===zh)if(s=t.get("WEBGL_compressed_texture_etc"),s!==null){if(i===Nh||i===Dh)return o===yt?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===Oh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(i===Uh)return s.COMPRESSED_R11_EAC;if(i===Fh)return s.COMPRESSED_SIGNED_R11_EAC;if(i===Wc)return s.COMPRESSED_RG11_EAC;if(i===zh)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===kh||i===Bh||i===Gh||i===Hh||i===Vh||i===$h||i===Wh||i===Zh||i===Xh||i===jh||i===qh||i===Yh||i===Kh||i===Jh)if(s=t.get("WEBGL_compressed_texture_astc"),s!==null){if(i===kh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Bh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Gh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Hh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Vh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===$h)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Wh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Zh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Xh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===jh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===qh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Yh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Kh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Jh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===Qh||i===ed||i===td)if(s=t.get("EXT_texture_compression_bptc"),s!==null){if(i===Qh)return o===yt?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===ed)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===td)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===nd||i===id||i===Zc||i===rd)if(s=t.get("EXT_texture_compression_rgtc"),s!==null){if(i===nd)return s.COMPRESSED_RED_RGTC1_EXT;if(i===id)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Zc)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===rd)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;if(i===Us)return e.UNSIGNED_INT_24_8;return e[i]!==void 0?e[i]:null}return{convert:n}}var rC=`
4258
4258
  void main() {
4259
4259
 
4260
4260
  gl_Position = vec4( position, 1.0 );
4261
4261
 
4262
- }`,iC=`
4262
+ }`,sC=`
4263
4263
  uniform sampler2DArray depthColor;
4264
4264
  uniform float depthWidth;
4265
4265
  uniform float depthHeight;
@@ -4278,4 +4278,4 @@ void main() {
4278
4278
 
4279
4279
  }
4280
4280
 
4281
- }`;class ay{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new nl(e.texture);if(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)this.depthNear=e.depthNear,this.depthFar=e.depthFar;this.texture=n}}getMesh(e){if(this.texture!==null){if(this.mesh===null){let t=e.cameras[0].viewport,n=new Gn({vertexShader:nC,fragmentShader:iC,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Mt(new ta(20,20),n)}}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class cy extends ii{constructor(e,t){super();let n=this,i=null,r=1,s=null,o="local-floor",a=1,c=null,l=null,u=null,h=null,d=null,f=null,m=typeof XRWebGLBinding<"u",_=new ay,p={},g=t.getContextAttributes(),M=null,T=null,v=[],S=[],E=new Be,R=null,x=null,w=new Ht;w.viewport=new pt;let H=new Ht;H.viewport=new pt;let C=[w,H],N=new Ed,ee=null,P=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(I){let V=v[I];if(V===void 0)V=new Xo,v[I]=V;return V.getTargetRaySpace()},this.getControllerGrip=function(I){let V=v[I];if(V===void 0)V=new Xo,v[I]=V;return V.getGripSpace()},this.getHand=function(I){let V=v[I];if(V===void 0)V=new Xo,v[I]=V;return V.getHandSpace()};function Z(I){let V=S.indexOf(I.inputSource);if(V===-1)return;let q=v[V];if(q!==void 0)q.update(I.inputSource,I.frame,c||s),q.dispatchEvent({type:I.type,data:I.inputSource})}function G(){i.removeEventListener("select",Z),i.removeEventListener("selectstart",Z),i.removeEventListener("selectend",Z),i.removeEventListener("squeeze",Z),i.removeEventListener("squeezestart",Z),i.removeEventListener("squeezeend",Z),i.removeEventListener("end",G),i.removeEventListener("inputsourceschange",k);for(let I=0;I<v.length;I++){let V=S[I];if(V===null)continue;S[I]=null,v[I].disconnect(V)}ee=null,P=null,_.reset();for(let I in p)delete p[I];if(e.setRenderTarget(M),d=null,h=null,u=null,i=null,T=null,he.stop(),n.isPresenting=!1,e.setPixelRatio(R),e.setSize(E.width,E.height,!1),x!==null){let I=x.camera;I.fov=x.fov,I.zoom=x.zoom,I.updateProjectionMatrix(),x=null}n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(I){if(r=I,n.isPresenting===!0)Ue("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(I){if(o=I,n.isPresenting===!0)Ue("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||s},this.setReferenceSpace=function(I){c=I},this.getBaseLayer=function(){return h!==null?h:d},this.getBinding=function(){if(u===null&&m)u=new XRWebGLBinding(i,t);return u},this.getFrame=function(){return f},this.getSession=function(){return i},this.setSession=async function(I){if(i=I,i!==null){if(M=e.getRenderTarget(),i.addEventListener("select",Z),i.addEventListener("selectstart",Z),i.addEventListener("selectend",Z),i.addEventListener("squeeze",Z),i.addEventListener("squeezestart",Z),i.addEventListener("squeezeend",Z),i.addEventListener("end",G),i.addEventListener("inputsourceschange",k),g.xrCompatible!==!0)await t.makeXRCompatible();if(R=e.getPixelRatio(),e.getSize(E),!(m&&("createProjectionLayer"in XRWebGLBinding.prototype))){let q={antialias:g.antialias,alpha:!0,depth:g.depth,stencil:g.stencil,framebufferScaleFactor:r};d=new XRWebGLLayer(i,t,q),i.updateRenderState({baseLayer:d}),e.setPixelRatio(1),e.setSize(d.framebufferWidth,d.framebufferHeight,!1),T=new Cn(d.framebufferWidth,d.framebufferHeight,{format:Si,type:ni,colorSpace:e.outputColorSpace,stencilBuffer:g.stencil,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1,storeMultisampledDepthBuffer:d.ignoreDepthValues===!1,storeMultisampledStencilBuffer:d.ignoreDepthValues===!1})}else{let q=null,se=null,ce=null;if(g.depth)ce=g.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,q=g.stencil?Xr:Zr,se=g.stencil?Os:pr;let ae={colorFormat:t.RGBA8,depthFormat:ce,scaleFactor:r};u=this.getBinding(),h=u.createProjectionLayer(ae),i.updateRenderState({layers:[h]}),e.setPixelRatio(1),e.setSize(h.textureWidth,h.textureHeight,!1),T=new Cn(h.textureWidth,h.textureHeight,{format:Si,type:ni,depthTexture:new Yr(h.textureWidth,h.textureHeight,se,void 0,void 0,void 0,void 0,void 0,void 0,q),stencilBuffer:g.stencil,colorSpace:e.outputColorSpace,samples:g.antialias?4:0,resolveDepthBuffer:h.ignoreDepthValues===!1,resolveStencilBuffer:h.ignoreDepthValues===!1,storeMultisampledDepthBuffer:h.ignoreDepthValues===!1,storeMultisampledStencilBuffer:h.ignoreDepthValues===!1})}T.isXRRenderTarget=!0,this.setFoveation(a),c=null,s=await i.requestReferenceSpace(o),he.setContext(i),he.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return _.getDepthTexture()};function k(I){for(let V=0;V<I.removed.length;V++){let q=I.removed[V],se=S.indexOf(q);if(se>=0)S[se]=null,v[se].disconnect(q)}for(let V=0;V<I.added.length;V++){let q=I.added[V],se=S.indexOf(q);if(se===-1){for(let ae=0;ae<v.length;ae++)if(ae>=S.length){S.push(q),se=ae;break}else if(S[ae]===null){S[ae]=q,se=ae;break}if(se===-1)break}let ce=v[se];if(ce)ce.connect(q)}}let W=new F,B=new F;function Y(I,V,q){W.setFromMatrixPosition(V.matrixWorld),B.setFromMatrixPosition(q.matrixWorld);let se=W.distanceTo(B),ce=V.projectionMatrix.elements,ae=q.projectionMatrix.elements,ke=ce[14]/(ce[10]-1),Ce=ce[14]/(ce[10]+1),Ve=(ce[9]+1)/ce[5],rt=(ce[9]-1)/ce[5],nt=(ce[8]-1)/ce[0],Rt=(ae[8]+1)/ae[0],it=ke*nt,tn=ke*Rt,Ut=se/(-nt+Rt),It=Ut*-nt;if(V.matrixWorld.decompose(I.position,I.quaternion,I.scale),I.translateX(It),I.translateZ(Ut),I.matrixWorld.compose(I.position,I.quaternion,I.scale),I.matrixWorldInverse.copy(I.matrixWorld).invert(),ce[10]===-1)I.projectionMatrix.copy(V.projectionMatrix),I.projectionMatrixInverse.copy(V.projectionMatrixInverse);else{let D=ke+Ut,_n=Ce+Ut,ut=it-It,Pt=tn+(se-It),A=Ve*Ce/_n*D,y=rt*Ce/_n*D;I.projectionMatrix.makePerspective(ut,Pt,A,y,D,_n),I.projectionMatrixInverse.copy(I.projectionMatrix).invert()}}function K(I,V){if(V===null)I.matrixWorld.copy(I.matrix);else I.matrixWorld.multiplyMatrices(V.matrixWorld,I.matrix);I.matrixWorldInverse.copy(I.matrixWorld).invert()}this.updateCamera=function(I){if(i===null)return;let{near:V,far:q}=I;if(_.texture!==null){if(_.depthNear>0)V=_.depthNear;if(_.depthFar>0)q=_.depthFar}if(N.near=H.near=w.near=V,N.far=H.far=w.far=q,ee!==N.near||P!==N.far)i.updateRenderState({depthNear:N.near,depthFar:N.far}),ee=N.near,P=N.far;N.layers.mask=I.layers.mask|6,w.layers.mask=N.layers.mask&-5,H.layers.mask=N.layers.mask&-3;let se=I.parent,ce=N.cameras;K(N,se);for(let ae=0;ae<ce.length;ae++)K(ce[ae],se);if(ce.length===2)Y(N,w,H);else N.projectionMatrix.copy(w.projectionMatrix);if(x===null&&I.isPerspectiveCamera)x={camera:I,fov:I.fov,zoom:I.zoom};ge(I,N,se)};function ge(I,V,q){if(q===null)I.matrix.copy(V.matrixWorld);else I.matrix.copy(q.matrixWorld),I.matrix.invert(),I.matrix.multiply(V.matrixWorld);if(I.matrix.decompose(I.position,I.quaternion,I.scale),I.updateMatrixWorld(!0),I.projectionMatrix.copy(V.projectionMatrix),I.projectionMatrixInverse.copy(V.projectionMatrixInverse),I.isPerspectiveCamera)I.fov=Vr*2*Math.atan(1/I.projectionMatrix.elements[5]),I.zoom=1}this.getCamera=function(){return N},this.getFoveation=function(){if(h===null&&d===null)return;return a},this.setFoveation=function(I){if(a=I,h!==null)h.fixedFoveation=I;if(d!==null&&d.fixedFoveation!==void 0)d.fixedFoveation=I},this.hasDepthSensing=function(){return _.texture!==null},this.getDepthSensingMesh=function(){return _.getMesh(N)},this.getCameraTexture=function(I){return p[I]};let de=null;function fe(I,V){if(l=V.getViewerPose(c||s),f=V,l!==null){let q=l.views;if(d!==null)e.setRenderTargetFramebuffer(T,d.framebuffer),e.setRenderTarget(T);let se=!1;if(q.length!==N.cameras.length)N.cameras.length=0,se=!0;for(let Ce=0;Ce<q.length;Ce++){let Ve=q[Ce],rt=null;if(d!==null)rt=d.getViewport(Ve);else{let Rt=u.getViewSubImage(h,Ve);if(rt=Rt.viewport,Ce===0)e.setRenderTargetTextures(T,Rt.colorTexture,Rt.depthStencilTexture),e.setRenderTarget(T)}let nt=C[Ce];if(nt===void 0)nt=new Ht,nt.layers.enable(Ce),nt.viewport=new pt,C[Ce]=nt;if(nt.matrix.fromArray(Ve.transform.matrix),nt.matrix.decompose(nt.position,nt.quaternion,nt.scale),nt.projectionMatrix.fromArray(Ve.projectionMatrix),nt.projectionMatrixInverse.copy(nt.projectionMatrix).invert(),nt.viewport.set(rt.x,rt.y,rt.width,rt.height),Ce===0)N.matrix.copy(nt.matrix),N.matrix.decompose(N.position,N.quaternion,N.scale);if(se===!0)N.cameras.push(nt)}let ce=i.enabledFeatures;if(ce&&ce.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&m){u=n.getBinding();let Ce=u.getDepthInformation(q[0]);if(Ce&&Ce.isValid&&Ce.texture)_.init(Ce,i.renderState)}if(ce&&ce.includes("camera-access")&&m){e.state.unbindTexture(),u=n.getBinding();for(let Ce=0;Ce<q.length;Ce++){let Ve=q[Ce].camera;if(Ve){let rt=p[Ve];if(!rt)rt=new nl,p[Ve]=rt;let nt=u.getCameraImage(Ve);rt.sourceTexture=nt}}}}for(let q=0;q<v.length;q++){let se=S[q],ce=v[q];if(se!==null&&ce!==void 0)ce.update(se,V,c||s)}if(de)de(I,V);if(V.detectedPlanes)n.dispatchEvent({type:"planesdetected",data:V});f=null}let he=new Yv;he.setAnimationLoop(fe),this.setAnimationLoop=function(I){de=I},this.dispose=function(){}}}var rC=new Xe,ly=new We;ly.set(-1,0,0,0,1,0,0,0,1);function sC(e,t){function n(p,g){if(p.matrixAutoUpdate===!0)p.updateMatrix();g.value.copy(p.matrix)}function i(p,g){if(g.color.getRGB(p.fogColor.value,md(e)),g.isFog)p.fogNear.value=g.near,p.fogFar.value=g.far;else if(g.isFogExp2)p.fogDensity.value=g.density}function r(p,g,M,T,v){if(g.isNodeMaterial)g.uniformsNeedUpdate=!1;else if(g.isMeshBasicMaterial)s(p,g);else if(g.isMeshLambertMaterial){if(s(p,g),g.envMap)p.envMapIntensity.value=g.envMapIntensity}else if(g.isMeshToonMaterial)s(p,g),h(p,g);else if(g.isMeshPhongMaterial){if(s(p,g),u(p,g),g.envMap)p.envMapIntensity.value=g.envMapIntensity}else if(g.isMeshStandardMaterial){if(s(p,g),d(p,g),g.isMeshPhysicalMaterial)f(p,g,v)}else if(g.isMeshMatcapMaterial)s(p,g),m(p,g);else if(g.isMeshDepthMaterial)s(p,g);else if(g.isMeshDistanceMaterial)s(p,g),_(p,g);else if(g.isMeshNormalMaterial)s(p,g);else if(g.isLineBasicMaterial){if(o(p,g),g.isLineDashedMaterial)a(p,g)}else if(g.isPointsMaterial)c(p,g,M,T);else if(g.isSpriteMaterial)l(p,g);else if(g.isShadowMaterial)p.color.value.copy(g.color),p.opacity.value=g.opacity;else if(g.isShaderMaterial)g.uniformsNeedUpdate=!1}function s(p,g){if(p.opacity.value=g.opacity,g.color)p.diffuse.value.copy(g.color);if(g.emissive)p.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity);if(g.map)p.map.value=g.map,n(g.map,p.mapTransform);if(g.alphaMap)p.alphaMap.value=g.alphaMap,n(g.alphaMap,p.alphaMapTransform);if(g.bumpMap){if(p.bumpMap.value=g.bumpMap,n(g.bumpMap,p.bumpMapTransform),p.bumpScale.value=g.bumpScale,g.side===cn)p.bumpScale.value*=-1}if(g.normalMap){if(p.normalMap.value=g.normalMap,n(g.normalMap,p.normalMapTransform),p.normalScale.value.copy(g.normalScale),g.side===cn)p.normalScale.value.negate()}if(g.displacementMap)p.displacementMap.value=g.displacementMap,n(g.displacementMap,p.displacementMapTransform),p.displacementScale.value=g.displacementScale,p.displacementBias.value=g.displacementBias;if(g.emissiveMap)p.emissiveMap.value=g.emissiveMap,n(g.emissiveMap,p.emissiveMapTransform);if(g.specularMap)p.specularMap.value=g.specularMap,n(g.specularMap,p.specularMapTransform);if(g.alphaTest>0)p.alphaTest.value=g.alphaTest;let M=t.get(g),{envMap:T,envMapRotation:v}=M;if(T){if(p.envMap.value=T,p.envMapRotation.value.setFromMatrix4(rC.makeRotationFromEuler(v)).transpose(),T.isCubeTexture&&T.isRenderTargetTexture===!1)p.envMapRotation.value.premultiply(ly);p.reflectivity.value=g.reflectivity,p.ior.value=g.ior,p.refractionRatio.value=g.refractionRatio}if(g.lightMap)p.lightMap.value=g.lightMap,p.lightMapIntensity.value=g.lightMapIntensity,n(g.lightMap,p.lightMapTransform);if(g.aoMap)p.aoMap.value=g.aoMap,p.aoMapIntensity.value=g.aoMapIntensity,n(g.aoMap,p.aoMapTransform)}function o(p,g){if(p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,g.map)p.map.value=g.map,n(g.map,p.mapTransform)}function a(p,g){p.dashSize.value=g.dashSize,p.totalSize.value=g.dashSize+g.gapSize,p.scale.value=g.scale}function c(p,g,M,T){if(p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.size.value=g.size*M,p.scale.value=T*0.5,g.map)p.map.value=g.map,n(g.map,p.uvTransform);if(g.alphaMap)p.alphaMap.value=g.alphaMap,n(g.alphaMap,p.alphaMapTransform);if(g.alphaTest>0)p.alphaTest.value=g.alphaTest}function l(p,g){if(p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.rotation.value=g.rotation,g.map)p.map.value=g.map,n(g.map,p.mapTransform);if(g.alphaMap)p.alphaMap.value=g.alphaMap,n(g.alphaMap,p.alphaMapTransform);if(g.alphaTest>0)p.alphaTest.value=g.alphaTest}function u(p,g){p.specular.value.copy(g.specular),p.shininess.value=Math.max(g.shininess,0.0001)}function h(p,g){if(g.gradientMap)p.gradientMap.value=g.gradientMap}function d(p,g){if(p.metalness.value=g.metalness,g.metalnessMap)p.metalnessMap.value=g.metalnessMap,n(g.metalnessMap,p.metalnessMapTransform);if(p.roughness.value=g.roughness,g.roughnessMap)p.roughnessMap.value=g.roughnessMap,n(g.roughnessMap,p.roughnessMapTransform);if(g.envMap)p.envMapIntensity.value=g.envMapIntensity}function f(p,g,M){if(p.ior.value=g.ior,g.sheen>0){if(p.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),p.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap)p.sheenColorMap.value=g.sheenColorMap,n(g.sheenColorMap,p.sheenColorMapTransform);if(g.sheenRoughnessMap)p.sheenRoughnessMap.value=g.sheenRoughnessMap,n(g.sheenRoughnessMap,p.sheenRoughnessMapTransform)}if(g.clearcoat>0){if(p.clearcoat.value=g.clearcoat,p.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap)p.clearcoatMap.value=g.clearcoatMap,n(g.clearcoatMap,p.clearcoatMapTransform);if(g.clearcoatRoughnessMap)p.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,n(g.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform);if(g.clearcoatNormalMap){if(p.clearcoatNormalMap.value=g.clearcoatNormalMap,n(g.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===cn)p.clearcoatNormalScale.value.negate()}}if(g.dispersion>0)p.dispersion.value=g.dispersion;if(g.retroreflectivity>0)p.retroreflectivity.value=g.retroreflectivity;if(g.iridescence>0){if(p.iridescence.value=g.iridescence,p.iridescenceIOR.value=g.iridescenceIOR,p.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap)p.iridescenceMap.value=g.iridescenceMap,n(g.iridescenceMap,p.iridescenceMapTransform);if(g.iridescenceThicknessMap)p.iridescenceThicknessMap.value=g.iridescenceThicknessMap,n(g.iridescenceThicknessMap,p.iridescenceThicknessMapTransform)}if(g.transmission>0){if(p.transmission.value=g.transmission,p.transmissionSamplerMap.value=M.texture,p.transmissionSamplerSize.value.set(M.width,M.height),g.transmissionMap)p.transmissionMap.value=g.transmissionMap,n(g.transmissionMap,p.transmissionMapTransform);if(p.thickness.value=g.thickness,g.thicknessMap)p.thicknessMap.value=g.thicknessMap,n(g.thicknessMap,p.thicknessMapTransform);p.attenuationDistance.value=g.attenuationDistance,p.attenuationColor.value.copy(g.attenuationColor)}if(g.anisotropy>0){if(p.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap)p.anisotropyMap.value=g.anisotropyMap,n(g.anisotropyMap,p.anisotropyMapTransform)}if(p.specularIntensity.value=g.specularIntensity,p.specularColor.value.copy(g.specularColor),g.specularColorMap)p.specularColorMap.value=g.specularColorMap,n(g.specularColorMap,p.specularColorMapTransform);if(g.specularIntensityMap)p.specularIntensityMap.value=g.specularIntensityMap,n(g.specularIntensityMap,p.specularIntensityMapTransform)}function m(p,g){if(g.matcap)p.matcap.value=g.matcap}function _(p,g){let M=t.get(g).light;p.referencePosition.value.setFromMatrixPosition(M.matrixWorld),p.nearDistance.value=M.shadow.camera.near,p.farDistance.value=M.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function oC(e,t,n,i){let r={},s={},o=[],a=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function c(v,S){let E=S.program;i.uniformBlockBinding(v,E)}function l(v,S){let E=r[v.id];if(E===void 0)p(v),E=u(v),r[v.id]=E,v.addEventListener("dispose",M);let R=S.program;i.updateUBOMapping(v,R);let x=t.render.frame;if(s[v.id]!==x)d(v),s[v.id]=x}function u(v){let S=h();v.__bindingPointIndex=S;let E=e.createBuffer(),{__size:R,usage:x}=v;return e.bindBuffer(e.UNIFORM_BUFFER,E),e.bufferData(e.UNIFORM_BUFFER,R,x),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,S,E),E}function h(){for(let v=0;v<a;v++)if(o.indexOf(v)===-1)return o.push(v),v;return $e("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(v){let S=r[v.id],{uniforms:E,__cache:R}=v;e.bindBuffer(e.UNIFORM_BUFFER,S);for(let x=0,w=E.length;x<w;x++){let H=E[x];if(Array.isArray(H))for(let C=0,N=H.length;C<N;C++)f(H[C],x,C,R);else f(H,x,0,R)}e.bindBuffer(e.UNIFORM_BUFFER,null)}function f(v,S,E,R){if(_(v,S,E,R)===!0){let{__offset:x,value:w}=v;if(Array.isArray(w)){let H=0;for(let C=0;C<w.length;C++){let N=w[C],ee=g(N);if(m(N,v.__data,H),typeof N!=="number"&&typeof N!=="boolean"&&!N.isMatrix3&&!ArrayBuffer.isView(N))H+=ee.storage/Float32Array.BYTES_PER_ELEMENT}}else m(w,v.__data,0);e.bufferSubData(e.UNIFORM_BUFFER,x,v.__data)}}function m(v,S,E){if(typeof v==="number"||typeof v==="boolean")S[0]=v;else if(v.isMatrix3)S[0]=v.elements[0],S[1]=v.elements[1],S[2]=v.elements[2],S[3]=0,S[4]=v.elements[3],S[5]=v.elements[4],S[6]=v.elements[5],S[7]=0,S[8]=v.elements[6],S[9]=v.elements[7],S[10]=v.elements[8],S[11]=0;else if(ArrayBuffer.isView(v))S.set(new v.constructor(v.buffer,v.byteOffset,S.length));else v.toArray(S,E)}function _(v,S,E,R){let x=v.value,w=S+"_"+E;if(R[w]===void 0){if(typeof x==="number"||typeof x==="boolean")R[w]=x;else if(ArrayBuffer.isView(x))R[w]=x.slice();else R[w]=x.clone();return!0}else{let H=R[w];if(typeof x==="number"||typeof x==="boolean"){if(H!==x)return R[w]=x,!0}else if(ArrayBuffer.isView(x))return!0;else if(H.equals(x)===!1)return H.copy(x),!0}return!1}function p(v){let S=v.uniforms,E=0,R=16;for(let w=0,H=S.length;w<H;w++){let C=Array.isArray(S[w])?S[w]:[S[w]];for(let N=0,ee=C.length;N<ee;N++){let P=C[N],Z=Array.isArray(P.value)?P.value:[P.value];for(let G=0,k=Z.length;G<k;G++){let W=Z[G],B=g(W),Y=E%R,K=Y%B.boundary,ge=Y+K;if(E+=K,ge!==0&&R-ge<B.storage)E+=R-ge;P.__data=new Float32Array(B.storage/Float32Array.BYTES_PER_ELEMENT),P.__offset=E,E+=B.storage}}}let x=E%R;if(x>0)E+=R-x;return v.__size=E,v.__cache={},this}function g(v){let S={boundary:0,storage:0};if(typeof v==="number"||typeof v==="boolean")S.boundary=4,S.storage=4;else if(v.isVector2)S.boundary=8,S.storage=8;else if(v.isVector3||v.isColor)S.boundary=16,S.storage=12;else if(v.isVector4)S.boundary=16,S.storage=16;else if(v.isMatrix3)S.boundary=48,S.storage=48;else if(v.isMatrix4)S.boundary=64,S.storage=64;else if(v.isTexture)Ue("WebGLRenderer: Texture samplers can not be part of an uniforms group.");else if(ArrayBuffer.isView(v))S.boundary=16,S.storage=v.byteLength;else Ue("WebGLRenderer: Unsupported uniform value type.",v);return S}function M(v){let S=v.target;S.removeEventListener("dispose",M);let E=o.indexOf(S.__bindingPointIndex);o.splice(E,1),e.deleteBuffer(r[S.id]),delete r[S.id],delete s[S.id]}function T(){for(let v in r)e.deleteBuffer(r[v]);o=[],r={},s={}}return{bind:c,update:l,dispose:T}}var aC=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),Mi=null;function cC(){if(Mi===null)Mi=new Yo(aC,16,16,jr,bi),Mi.name="DFG_LUT",Mi.minFilter=Jt,Mi.magFilter=Jt,Mi.wrapS=Ns,Mi.wrapT=Ns,Mi.generateMipmaps=!1,Mi.needsUpdate=!0;return Mi}class Gd{constructor(e={}){let{canvas:t=gv(),context:n=null,depth:i=!0,stencil:r=!1,alpha:s=!1,antialias:o=!1,premultipliedAlpha:a=!0,preserveDrawingBuffer:c=!1,powerPreference:l="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:h=!1,outputBufferType:d=ni}=e;this.isWebGLRenderer=!0;let f;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");f=n.getContextAttributes().alpha}else f=s;let m=d,_=new Set([Ah,Th,Eh]),p=new Set([ni,pr,Vo,Os,wh,Mh]),g=new Uint32Array(4),M=new Int32Array(4),T=new F,v=null,S=null,E=[],R=[],x=null;this.domElement=t,this.debug={checkShaderErrors:!0,diagnostics:{keywords:!1},onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=ei,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let w=this,H=!1,C=null,N=null,ee=null,P=null;this._outputColorSpace=mr;let Z=0,G=0,k=null,W=-1,B=null,Y=new pt,K=new pt,ge=null,de=new He(0),fe=0,{width:he,height:I}=t,V=1,q=null,se=null,ce=new pt(0,0,he,I),ae=new pt(0,0,he,I),ke=!1,Ce=new Jo,Ve=!1,rt=!1,nt=new Xe,Rt=new F,it=new pt,tn={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},Ut=!1;function It(){return k===null?V:1}let D=n;function _n(b,U){return t.getContext(b,U)}let ut,Pt,A,y,O,J,ue,me,ve,te,re,Ee,Oe,ye,pe,ze,Ge,ot,z,_e,ne,xe,Te;try{let b={alpha:!0,depth:i,stencil:r,antialias:o,premultipliedAlpha:a,preserveDrawingBuffer:c,powerPreference:l,failIfMajorPerformanceCaveat:u};if("setAttribute"in t)t.setAttribute("data-engine",`three.js r${Sx}`);if(t.addEventListener("webglcontextlost",Ze,!1),t.addEventListener("webglcontextrestored",bt,!1),t.addEventListener("webglcontextcreationerror",ht,!1),D===null){if(D=_n("webgl2",b),D===null)if(_n("webgl2"))throw Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes.");else throw Error("THREE.WebGLRenderer: Error creating WebGL context.")}le()}catch(b){throw t.removeEventListener("webglcontextlost",Ze,!1),t.removeEventListener("webglcontextrestored",bt,!1),t.removeEventListener("webglcontextcreationerror",ht,!1),$e("WebGLRenderer: "+b.message),b}function le(){if(ut=new m1(D),ut.init(),ne=new tC(D,ut),Pt=new s1(D,ut,e,ne),A=new QR(D,ut),Pt.reversedDepthBuffer&&h)A.buffers.depth.setReversed(!0);N=D.createFramebuffer(),ee=D.createFramebuffer(),P=D.createFramebuffer(),y=new x1(D),O=new kR,J=new eC(D,ut,A,O,Pt,ne,y),ue=new p1(w),me=new yE(D),xe=new i1(D,me),ve=new g1(D,me,y,xe),te=new y1(D,ve,me,xe,y),ot=new v1(D,Pt,J),pe=new o1(O),re=new zR(w,ue,ut,Pt,xe,pe),Ee=new sC(w,O),Oe=new GR,ye=new XR(ut),Ge=new n1(w,ue,A,te,f,a),ze=new JR(w,te,Pt),Te=new oC(D,y,Pt,A),z=new r1(D,ut,y),_e=new _1(D,ut,y),y.programs=re.programs,w.capabilities=Pt,w.extensions=ut,w.properties=O,w.renderLists=Oe,w.shadowMap=ze,w.state=A,w.info=y}if(m!==ni)x=new S1(m,t.width,t.height,o,i,r);let Se=new cy(w,D);this.xr=Se,this.getContext=function(){return D},this.getContextAttributes=function(){return D.getContextAttributes()},this.forceContextLoss=function(){let b=ut.get("WEBGL_lose_context");if(b)b.loseContext()},this.forceContextRestore=function(){let b=ut.get("WEBGL_lose_context");if(b)b.restoreContext()},this.getPixelRatio=function(){return V},this.setPixelRatio=function(b){if(b===void 0)return;V=b,this.setSize(he,I,!1)},this.getSize=function(b){return b.set(he,I)},this.setSize=function(b,U,Q=!0){if(Se.isPresenting){Ue("WebGLRenderer: Can't change size while VR device is presenting.");return}if(he=b,I=U,t.width=Math.floor(b*V),t.height=Math.floor(U*V),Q===!0)t.style.width=b+"px",t.style.height=U+"px";if(x!==null)x.setSize(t.width,t.height);this.setViewport(0,0,b,U)},this.getDrawingBufferSize=function(b){return b.set(he*V,I*V).floor()},this.setDrawingBufferSize=function(b,U,Q){he=b,I=U,V=Q,t.width=Math.floor(b*Q),t.height=Math.floor(U*Q),this.setViewport(0,0,b,U)},this.setEffects=function(b){if(m===ni){$e("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(b){for(let U=0;U<b.length;U++)if(b[U].isOutputPass===!0){Ue("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}x.setEffects(b||[])},this.getCurrentViewport=function(b){return b.copy(Y)},this.getViewport=function(b){return b.copy(ce)},this.setViewport=function(b,U,Q,X){if(b.isVector4)ce.set(b.x,b.y,b.z,b.w);else ce.set(b,U,Q,X);A.viewport(Y.copy(ce).multiplyScalar(V).round())},this.getScissor=function(b){return b.copy(ae)},this.setScissor=function(b,U,Q,X){if(b.isVector4)ae.set(b.x,b.y,b.z,b.w);else ae.set(b,U,Q,X);A.scissor(K.copy(ae).multiplyScalar(V).round())},this.getScissorTest=function(){return ke},this.setScissorTest=function(b){A.setScissorTest(ke=b)},this.setOpaqueSort=function(b){q=b},this.setTransparentSort=function(b){se=b},this.getClearColor=function(b){return b.copy(Ge.getClearColor())},this.setClearColor=function(){Ge.setClearColor(...arguments)},this.getClearAlpha=function(){return Ge.getClearAlpha()},this.setClearAlpha=function(){Ge.setClearAlpha(...arguments)},this.clear=function(b=!0,U=!0,Q=!0){let X=0;if(b){let j=!1;if(k!==null){let Me=k.texture.format;j=_.has(Me)}if(j){let Me=k.texture.type,Re=p.has(Me),we=Ge.getClearColor(),Ie=Ge.getClearAlpha(),{r:Ne,g:je,b:et}=we;if(Re)g[0]=Ne,g[1]=je,g[2]=et,g[3]=Ie,D.clearBufferuiv(D.COLOR,0,g);else M[0]=Ne,M[1]=je,M[2]=et,M[3]=Ie,D.clearBufferiv(D.COLOR,0,M)}else X|=D.COLOR_BUFFER_BIT}if(U)X|=D.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0);if(Q)X|=D.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295);if(X!==0)D.clear(X)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(b){b.setRenderer(this),C=b},this.dispose=function(){t.removeEventListener("webglcontextlost",Ze,!1),t.removeEventListener("webglcontextrestored",bt,!1),t.removeEventListener("webglcontextcreationerror",ht,!1),Ge.dispose(),Oe.dispose(),ye.dispose(),O.dispose(),ue.dispose(),te.dispose(),xe.dispose(),Te.dispose(),re.dispose(),Se.dispose(),Se.removeEventListener("sessionstart",_f),Se.removeEventListener("sessionend",xf),Pr.stop()};function Ze(b){b.preventDefault(),zo("WebGLRenderer: Context Lost."),H=!0}function bt(){zo("WebGLRenderer: Context Restored."),H=!1;let b=y.autoReset,U=ze.enabled,Q=ze.autoUpdate,X=ze.needsUpdate,j=ze.type;le(),y.autoReset=b,ze.enabled=U,ze.autoUpdate=Q,ze.needsUpdate=X,ze.type=j}function ht(b){$e("WebGLRenderer: A WebGL context could not be created. Reason: ",b.statusMessage)}function oi(b){let U=b.target;U.removeEventListener("dispose",oi),Pi(U)}function Pi(b){Rb(b),O.remove(b)}function Rb(b){let U=O.get(b).programs;if(U!==void 0){if(U.forEach(function(Q){re.releaseProgram(Q)}),b.isShaderMaterial)re.releaseShaderCache(b)}}this.renderBufferDirect=function(b,U,Q,X,j,Me){if(U===null)U=tn;let Re=j.isMesh&&j.matrixWorld.determinantAffine()<0,we=Pb(b,U,Q,X,j);A.setMaterial(X,Re);let Ie=Q.index,Ne=1;if(X.wireframe===!0){if(Ie=ve.getWireframeAttribute(Q),Ie===void 0)return;Ne=2}let je=Q.drawRange,et=Q.attributes.position,Pe=je.start*Ne,dt=(je.start+je.count)*Ne;if(Me!==null)Pe=Math.max(Pe,Me.start*Ne),dt=Math.min(dt,(Me.start+Me.count)*Ne);if(Ie!==null)Pe=Math.max(Pe,0),dt=Math.min(dt,Ie.count);else if(et!==void 0&&et!==null)Pe=Math.max(Pe,0),dt=Math.min(dt,et.count);let Bt=dt-Pe;if(Bt<0||Bt===1/0)return;xe.setup(j,X,we,Q,Ie);let Et,xt=z;if(Ie!==null)Et=me.get(Ie),xt=_e,xt.setIndex(Et);if(j.isMesh)if(X.wireframe===!0)A.setLineWidth(X.wireframeLinewidth*It()),xt.setMode(D.LINES);else xt.setMode(D.TRIANGLES);else if(j.isLine){let sn=X.linewidth;if(sn===void 0)sn=1;if(A.setLineWidth(sn*It()),j.isLineSegments)xt.setMode(D.LINES);else if(j.isLineLoop)xt.setMode(D.LINE_LOOP);else xt.setMode(D.LINE_STRIP)}else if(j.isPoints)xt.setMode(D.POINTS);else if(j.isSprite)xt.setMode(D.TRIANGLES);if(j.isBatchedMesh)if(!ut.get("WEBGL_multi_draw")){let{_multiDrawStarts:sn,_multiDrawCounts:Ae,_multiDrawCount:dn}=j,st=Ie?me.get(Ie).bytesPerElement:1,Nn=O.get(X).currentProgram.getUniforms();for(let ai=0;ai<dn;ai++)Nn.setValue(D,"_gl_DrawID",ai),xt.render(sn[ai]/st,Ae[ai])}else xt.renderMultiDraw(j._multiDrawStarts,j._multiDrawCounts,j._multiDrawCount);else if(j.isInstancedMesh)xt.renderInstances(Pe,Bt,j.count);else if(Q.isInstancedBufferGeometry){let sn=Q._maxInstanceCount!==void 0?Q._maxInstanceCount:1/0,Ae=Math.min(Q.instanceCount,sn);xt.renderInstances(Pe,Bt,Ae)}else xt.render(Pe,Bt)};function gf(b,U,Q,X){if(C!==null&&b.isNodeMaterial)C.setObject(X,b);if(Ve===!0)pe.setState(b,Q,!1);if(b.transparent===!0&&b.side===Bn&&b.forceSinglePass===!1)b.side=cn,b.needsUpdate=!0,Ma(b,U,X),b.side=fr,b.needsUpdate=!0,Ma(b,U,X),b.side=Bn;else Ma(b,U,X)}this.compile=function(b,U,Q=null){if(Q===null)Q=b;if(C!==null)C.renderStart(b,U,Q);if(S=ye.get(Q),S.init(U),R.push(S),Q.traverseVisible(function(j){if(j.isLight&&j.layers.test(U.layers)){if(S.pushLight(j),j.castShadow)S.pushShadow(j)}}),b!==Q)b.traverseVisible(function(j){if(j.isLight&&j.layers.test(U.layers)){if(S.pushLight(j),j.castShadow)S.pushShadow(j)}});if(S.setupLights(),C!==null)C.updateLights(S.state.lightsArray);if(rt=this.localClippingEnabled,Ve=pe.init(this.clippingPlanes,rt),Ve===!0)pe.setGlobalState(this.clippingPlanes,U);if(C!==null)ze.render(S.state.shadowsArray,Q,U);let X=new Set;if(b.traverse(function(j){if(!(j.isMesh||j.isPoints||j.isLine||j.isSprite))return;let Me=j.material;if(Me)if(Array.isArray(Me))for(let Re=0;Re<Me.length;Re++){let we=Me[Re];gf(we,Q,U,j),X.add(we)}else gf(Me,Q,U,j),X.add(Me)}),S=R.pop(),C!==null)C.renderEnd();return X},this.compileAsync=function(b,U,Q=null){let X=this.compile(b,U,Q);return new Promise((j)=>{function Me(){if(X.forEach(function(Re){let Ie=O.get(Re).currentProgram;if(Ie===void 0||Ie.isReady())X.delete(Re)}),X.size===0){j(b);return}setTimeout(Me,10)}if(ut.get("KHR_parallel_shader_compile")!==null)Me();else setTimeout(Me,10)})};let wl=null;function Cb(b){if(wl)wl(b)}function _f(){Pr.stop()}function xf(){Pr.start()}let Pr=new Yv;if(Pr.setAnimationLoop(Cb),typeof self<"u")Pr.setContext(self);this.setAnimationLoop=function(b){wl=b,Se.setAnimationLoop(b),b===null?Pr.stop():Pr.start()},Se.addEventListener("sessionstart",_f),Se.addEventListener("sessionend",xf),this.render=function(b,U){if(U!==void 0&&U.isCamera!==!0){$e("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(H===!0)return;if(C!==null)C.renderStart(b,U);let Q=Se.enabled===!0&&Se.isPresenting===!0,X=x!==null&&(k===null||Q)&&x.begin(w,k);if(b.matrixWorldAutoUpdate===!0)b.updateMatrixWorld();if(U.parent===null&&U.matrixWorldAutoUpdate===!0)U.updateMatrixWorld();if(Se.enabled===!0&&Se.isPresenting===!0&&(x===null||x.isCompositing()===!1)){if(Se.cameraAutoUpdate===!0)Se.updateCamera(U);U=Se.getCamera()}if(b.isScene===!0)b.onBeforeRender(w,b,U,k);if(S=ye.get(b,R.length),S.init(U),S.state.textureUnits=J.getTextureUnits(),R.push(S),nt.multiplyMatrices(U.projectionMatrix,U.matrixWorldInverse),Ce.setFromProjectionMatrix(nt,ld,U.reversedDepth),rt=this.localClippingEnabled,Ve=pe.init(this.clippingPlanes,rt),v=Oe.get(b,E.length),v.init(),E.push(v),Se.enabled===!0&&Se.isPresenting===!0){let Re=w.xr.getDepthSensingMesh();if(Re!==null)Ml(Re,U,-1/0,w.sortObjects)}if(Ml(b,U,0,w.sortObjects),v.finish(),C!==null)C.updateLights(S.state.lightsArray);if(w.sortObjects===!0)v.sort(q,se);if(Ut=Se.enabled===!1||Se.isPresenting===!1||Se.hasDepthSensing()===!1,Ut)Ge.addToRenderList(v,b);if(this.info.render.frame++,this.info.autoReset===!0)this.info.reset();if(Ve===!0)pe.beginShadows();let j=S.state.shadowsArray;if(ze.render(j,b,U),Ve===!0)pe.endShadows();if((X&&x.hasRenderPass())===!1){let Re=v.opaque,we=v.transmissive;if(S.setupLights(),U.isArrayCamera){let Ie=U.cameras;if(we.length>0)for(let Ne=0,je=Ie.length;Ne<je;Ne++){let et=Ie[Ne];yf(Re,we,b,et)}if(Ut)Ge.render(b);for(let Ne=0,je=Ie.length;Ne<je;Ne++){let et=Ie[Ne];vf(v,b,et,et.viewport)}}else{if(we.length>0)yf(Re,we,b,U);if(Ut)Ge.render(b);vf(v,b,U)}}if(k!==null&&G===0)J.updateMultisampleRenderTarget(k),J.updateRenderTargetMipmap(k);if(X)x.end(w);if(b.isScene===!0)b.onAfterRender(w,b,U);if(xe.resetDefaultState(),W=-1,B=null,R.pop(),R.length>0){if(S=R[R.length-1],J.setTextureUnits(S.state.textureUnits),Ve===!0)pe.setGlobalState(w.clippingPlanes,S.state.camera)}else S=null;if(E.pop(),E.length>0)v=E[E.length-1];else v=null;if(C!==null)C.renderEnd()};function Ml(b,U,Q,X){if(b.visible===!1)return;if(b.layers.test(U.layers)){if(b.isGroup)Q=b.renderOrder;else if(b.isLOD){if(b.autoUpdate===!0)b.update(U)}else if(b.isLightProbeGrid)S.pushLightProbeGrid(b);else if(b.isLight){if(S.pushLight(b),b.castShadow)S.pushShadow(b)}else if(b.isSprite){if(!b.frustumCulled||b.intersectsFrustum(Ce)){if(X)it.setFromMatrixPosition(b.matrixWorld).applyMatrix4(nt);let Re=te.update(b),we=b.material;if(we.visible)v.push(b,Re,we,Q,it.z,null,U)}}else if(b.isMesh||b.isLine||b.isPoints){if(!b.frustumCulled||b.intersectsFrustum(Ce)){let Re=te.update(b),we=b.material;if(X){if(b.boundingSphere!==void 0){if(b.boundingSphere===null)b.computeBoundingSphere();it.copy(b.boundingSphere.center)}else{if(Re.boundingSphere===null)Re.computeBoundingSphere();it.copy(Re.boundingSphere.center)}it.applyMatrix4(b.matrixWorld).applyMatrix4(nt)}if(Array.isArray(we)){let Ie=Re.groups;for(let Ne=0,je=Ie.length;Ne<je;Ne++){let et=Ie[Ne],Pe=we[et.materialIndex];if(Pe&&Pe.visible)v.push(b,Re,Pe,Q,it.z,et,U)}}else if(we.visible)v.push(b,Re,we,Q,it.z,null,U)}}}let Me=b.children;for(let Re=0,we=Me.length;Re<we;Re++)Ml(Me[Re],U,Q,X)}function vf(b,U,Q,X){let{opaque:j,transmissive:Me,transparent:Re}=b;if(S.setupLightsView(Q),Ve===!0)pe.setGlobalState(w.clippingPlanes,Q);if(X)A.viewport(Y.copy(X));if(j.length>0)wa(j,U,Q);if(Me.length>0)wa(Me,U,Q);if(Re.length>0)wa(Re,U,Q);A.buffers.depth.setTest(!0),A.buffers.depth.setMask(!0),A.buffers.color.setMask(!0),A.setPolygonOffset(!1)}function yf(b,U,Q,X){if((Q.isScene===!0?Q.overrideMaterial:null)!==null)return;if(S.state.transmissionRenderTarget[X.id]===void 0){let Pe=ut.has("EXT_color_buffer_half_float")||ut.has("EXT_color_buffer_float");S.state.transmissionRenderTarget[X.id]=new Cn(1,1,{generateMipmaps:!0,type:Pe?bi:ni,minFilter:yi,samples:Math.max(4,Pt.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:Ke.workingColorSpace})}let Me=S.state.transmissionRenderTarget[X.id],Re=X.viewport||Y;Me.setSize(Re.z*w.transmissionResolutionScale,Re.w*w.transmissionResolutionScale);let we=w.getRenderTarget(),Ie=w.getActiveCubeFace(),Ne=w.getActiveMipmapLevel();if(w.setRenderTarget(Me),w.getClearColor(de),fe=w.getClearAlpha(),fe<1)w.setClearColor(16777215,0.5);if(w.clear(),Ut)Ge.render(Q);let je=w.toneMapping;w.toneMapping=ei;let et=X.viewport;if(X.viewport!==void 0)X.viewport=void 0;if(S.setupLightsView(X),Ve===!0)pe.setGlobalState(w.clippingPlanes,X);if(wa(b,Q,X),J.updateMultisampleRenderTarget(Me),J.updateRenderTargetMipmap(Me),ut.has("WEBGL_multisampled_render_to_texture")===!1){let Pe=!1;for(let dt=0,Bt=U.length;dt<Bt;dt++){let Et=U[dt],{object:xt,geometry:sn,material:Ae,group:dn}=Et;if(Ae.side===Bn&&xt.layers.test(X.layers)){let st=Ae.side;Ae.side=cn,Ae.needsUpdate=!0,bf(xt,Q,X,sn,Ae,dn),Ae.side=st,Ae.needsUpdate=!0,Pe=!0}}if(Pe===!0)J.updateMultisampleRenderTarget(Me),J.updateRenderTargetMipmap(Me)}if(w.setRenderTarget(we,Ie,Ne),w.setClearColor(de,fe),et!==void 0)X.viewport=et;w.toneMapping=je}function wa(b,U,Q){let X=U.isScene===!0?U.overrideMaterial:null;for(let j=0,Me=b.length;j<Me;j++){let Re=b[j],{object:we,geometry:Ie,group:Ne}=Re,je=Re.material;if(je.allowOverride===!0&&X!==null)je=X;if(we.layers.test(Q.layers))bf(we,U,Q,Ie,je,Ne)}}function bf(b,U,Q,X,j,Me){if(C!==null&&j.isNodeMaterial)C.setObject(b,j);if(b.onBeforeRender(w,U,Q,X,j,Me),b.modelViewMatrix.multiplyMatrices(Q.matrixWorldInverse,b.matrixWorld),b.normalMatrix.getNormalMatrix(b.modelViewMatrix),j.onBeforeRender(w,U,Q,X,b,Me),j.transparent===!0&&j.side===Bn&&j.forceSinglePass===!1)j.side=cn,j.needsUpdate=!0,w.renderBufferDirect(Q,U,X,j,b,Me),j.side=fr,j.needsUpdate=!0,w.renderBufferDirect(Q,U,X,j,b,Me),j.side=Bn;else w.renderBufferDirect(Q,U,X,j,b,Me);b.onAfterRender(w,U,Q,X,j,Me)}function Ma(b,U,Q){if(U.isScene!==!0)U=tn;let X=O.get(b),j=S.state.lights,Me=S.state.shadowsArray,Re=j.state.version,we=re.getParameters(b,j.state,Me,U,Q,S.state.lightProbeGridArray),Ie=re.getProgramCacheKey(we),Ne=X.programs;X.environment=b.isMeshStandardMaterial||b.isMeshLambertMaterial||b.isMeshPhongMaterial?U.environment:null,X.fog=U.fog;let je=b.isMeshStandardMaterial||b.isMeshLambertMaterial&&!b.envMap||b.isMeshPhongMaterial&&!b.envMap;if(X.envMap=ue.get(b.envMap||X.environment,je),X.envMapRotation=X.environment!==null&&b.envMap===null?U.environmentRotation:b.envMapRotation,Ne===void 0)b.addEventListener("dispose",oi),Ne=new Map,X.programs=Ne;let et=Ne.get(Ie);if(et!==void 0){if(X.currentProgram===et&&X.lightsStateVersion===Re)return wf(b,we),et}else{if(we.uniforms=re.getUniforms(b),C!==null&&b.isNodeMaterial)C.build(b,Q,we);b.onBeforeCompile(we,w),et=re.acquireProgram(we,Ie),Ne.set(Ie,et),X.uniforms=we.uniforms}let Pe=X.uniforms;if(!b.isShaderMaterial&&!b.isRawShaderMaterial||b.clipping===!0)Pe.clippingPlanes=pe.uniform;if(wf(b,we),X.needsLights=Nb(b),X.lightsStateVersion=Re,X.needsLights)Pe.ambientLightColor.value=j.state.ambient,Pe.lightProbe.value=j.state.probe,Pe.sunLights.value=j.state.sun,Pe.sunLightShadows.value=j.state.sunShadow,Pe.directionalLights.value=j.state.directional,Pe.directionalLightShadows.value=j.state.directionalShadow,Pe.spotLights.value=j.state.spot,Pe.spotLightShadows.value=j.state.spotShadow,Pe.rectAreaLights.value=j.state.rectArea,Pe.ltc_1.value=j.state.rectAreaLTC1,Pe.ltc_2.value=j.state.rectAreaLTC2,Pe.pointLights.value=j.state.point,Pe.pointLightShadows.value=j.state.pointShadow,Pe.hemisphereLights.value=j.state.hemi,Pe.sunShadowMatrix.value=j.state.sunShadowMatrix,Pe.sunShadowCascade.value=j.state.sunShadowCascade,Pe.directionalShadowMatrix.value=j.state.directionalShadowMatrix,Pe.spotLightMatrix.value=j.state.spotLightMatrix,Pe.spotLightMap.value=j.state.spotLightMap,Pe.pointShadowMatrix.value=j.state.pointShadowMatrix;return X.lightProbeGrid=S.state.lightProbeGridArray.length>0,X.currentProgram=et,X.uniformsList=null,et}function Sf(b){if(b.uniformsList===null){let U=b.currentProgram.getUniforms();b.uniformsList=la.seqWithValue(U.seq,b.uniforms)}return b.uniformsList}function wf(b,U){let Q=O.get(b);Q.outputColorSpace=U.outputColorSpace,Q.batching=U.batching,Q.batchingColor=U.batchingColor,Q.instancing=U.instancing,Q.instancingColor=U.instancingColor,Q.instancingMorph=U.instancingMorph,Q.skinning=U.skinning,Q.morphTargets=U.morphTargets,Q.morphNormals=U.morphNormals,Q.morphColors=U.morphColors,Q.morphTargetsCount=U.morphTargetsCount,Q.numClippingPlanes=U.numClippingPlanes,Q.numIntersection=U.numClipIntersection,Q.vertexAlphas=U.vertexAlphas,Q.vertexTangents=U.vertexTangents,Q.toneMapping=U.toneMapping}function Ib(b,U){if(b.length===0)return null;if(b.length===1)return b[0].texture!==null?b[0]:null;T.setFromMatrixPosition(U.matrixWorld);for(let Q=0,X=b.length;Q<X;Q++){let j=b[Q];if(j.texture!==null&&j.boundingBox.containsPoint(T))return j}return null}function Pb(b,U,Q,X,j){if(U.isScene!==!0)U=tn;J.resetTextureUnits();let Me=U.fog,Re=X.isMeshStandardMaterial||X.isMeshLambertMaterial||X.isMeshPhongMaterial?U.environment:null,we=k===null?w.outputColorSpace:k.isXRRenderTarget===!0?k.texture.colorSpace:Ke.workingColorSpace,Ie=X.isMeshStandardMaterial||X.isMeshLambertMaterial&&!X.envMap||X.isMeshPhongMaterial&&!X.envMap,Ne=ue.get(X.envMap||Re,Ie),je=X.vertexColors===!0&&!!Q.attributes.color&&Q.attributes.color.itemSize===4,et=!!Q.attributes.tangent&&(!!X.normalMap||X.anisotropy>0),Pe=!!Q.morphAttributes.position,dt=!!Q.morphAttributes.normal,Bt=!!Q.morphAttributes.color,Et=ei;if(X.toneMapped){if(k===null||k.isXRRenderTarget===!0)Et=w.toneMapping}let xt=Q.morphAttributes.position||Q.morphAttributes.normal||Q.morphAttributes.color,sn=xt!==void 0?xt.length:0,Ae=O.get(X),dn=S.state.lights;if(Ve===!0){if(rt===!0||b!==B){let St=b===B&&X.id===W;pe.setState(X,b,St)}}let st=!1;if(X.version===Ae.__version){if(Ae.needsLights&&Ae.lightsStateVersion!==dn.state.version)st=!0;else if(Ae.outputColorSpace!==we)st=!0;else if(j.isBatchedMesh&&Ae.batching===!1)st=!0;else if(!j.isBatchedMesh&&Ae.batching===!0)st=!0;else if(j.isBatchedMesh&&Ae.batchingColor===!0&&j._colorsTexture===null)st=!0;else if(j.isBatchedMesh&&Ae.batchingColor===!1&&j._colorsTexture!==null)st=!0;else if(j.isInstancedMesh&&Ae.instancing===!1)st=!0;else if(!j.isInstancedMesh&&Ae.instancing===!0)st=!0;else if(j.isSkinnedMesh&&Ae.skinning===!1)st=!0;else if(!j.isSkinnedMesh&&Ae.skinning===!0)st=!0;else if(j.isInstancedMesh&&Ae.instancingColor===!0&&j.instanceColor===null)st=!0;else if(j.isInstancedMesh&&Ae.instancingColor===!1&&j.instanceColor!==null)st=!0;else if(j.isInstancedMesh&&Ae.instancingMorph===!0&&j.morphTexture===null)st=!0;else if(j.isInstancedMesh&&Ae.instancingMorph===!1&&j.morphTexture!==null)st=!0;else if(Ae.envMap!==Ne)st=!0;else if(X.fog===!0&&Ae.fog!==Me)st=!0;else if(Ae.numClippingPlanes!==void 0&&(Ae.numClippingPlanes!==pe.numPlanes||Ae.numIntersection!==pe.numIntersection))st=!0;else if(Ae.vertexAlphas!==je)st=!0;else if(Ae.vertexTangents!==et)st=!0;else if(Ae.morphTargets!==Pe)st=!0;else if(Ae.morphNormals!==dt)st=!0;else if(Ae.morphColors!==Bt)st=!0;else if(Ae.toneMapping!==Et)st=!0;else if(Ae.morphTargetsCount!==sn)st=!0;else if(!!Ae.lightProbeGrid!==S.state.lightProbeGridArray.length>0)st=!0}else st=!0,Ae.__version=X.version;let Nn=Ae.currentProgram;if(st===!0){if(Nn=Ma(X,U,j),C&&X.isNodeMaterial)C.onUpdateProgram(X,Nn,Ae)}let ai=!1,ji=!1,rs=!1,gt=Nn.getUniforms(),Ft=Ae.uniforms;if(A.useProgram(Nn.program))ai=!0,ji=!0,rs=!0;if(X.id!==W)W=X.id,ji=!0;if(Ae.needsLights){let St=Ib(S.state.lightProbeGridArray,j);if(Ae.lightProbeGrid!==St)Ae.lightProbeGrid=St,ji=!0}if(ai||B!==b){if(A.buffers.depth.getReversed()&&b.reversedDepth!==!0)b._reversedDepth=!0,b.updateProjectionMatrix();gt.setValue(D,"projectionMatrix",b.projectionMatrix),gt.setValue(D,"viewMatrix",b.matrixWorldInverse);let Yi=gt.map.cameraPosition;if(Yi!==void 0)Yi.setValue(D,Rt.setFromMatrixPosition(b.matrixWorld));if(Pt.logarithmicDepthBuffer)gt.setValue(D,"logDepthBufFC",2/(Math.log(b.far+1)/Math.LN2));if(X.isMeshPhongMaterial||X.isMeshToonMaterial||X.isMeshLambertMaterial||X.isMeshBasicMaterial||X.isMeshStandardMaterial||X.isShaderMaterial)gt.setValue(D,"isOrthographic",b.isOrthographicCamera===!0);if(B!==b)B=b,ji=!0,rs=!0}if(Ae.needsLights){if(dn.state.sunShadowMap.length>0)gt.setValue(D,"sunShadowMap",dn.state.sunShadowMap,J);if(dn.state.directionalShadowMap.length>0)gt.setValue(D,"directionalShadowMap",dn.state.directionalShadowMap,J);if(dn.state.spotShadowMap.length>0)gt.setValue(D,"spotShadowMap",dn.state.spotShadowMap,J);if(dn.state.pointShadowMap.length>0)gt.setValue(D,"pointShadowMap",dn.state.pointShadowMap,J)}if(j.isSkinnedMesh){gt.setOptional(D,j,"bindMatrix"),gt.setOptional(D,j,"bindMatrixInverse");let St=j.skeleton;if(St){if(St.boneTexture===null)St.computeBoneTexture();gt.setValue(D,"boneTexture",St.boneTexture,J)}}if(j.isBatchedMesh){if(gt.setOptional(D,j,"batchingTexture"),gt.setValue(D,"batchingTexture",j._matricesTexture,J),gt.setOptional(D,j,"batchingIdTexture"),gt.setValue(D,"batchingIdTexture",j._indirectTexture,J),gt.setOptional(D,j,"batchingColorTexture"),j._colorsTexture!==null)gt.setValue(D,"batchingColorTexture",j._colorsTexture,J)}let qi=Q.morphAttributes;if(qi.position!==void 0||qi.normal!==void 0||qi.color!==void 0)ot.update(j,Q,Nn);if(ji||Ae.receiveShadow!==j.receiveShadow)Ae.receiveShadow=j.receiveShadow,gt.setValue(D,"receiveShadow",j.receiveShadow);if((X.isMeshStandardMaterial||X.isMeshLambertMaterial||X.isMeshPhongMaterial)&&X.envMap===null&&U.environment!==null)Ft.envMapIntensity.value=U.environmentIntensity;if(Ft.dfgLUT!==void 0)Ft.dfgLUT.value=cC();if(ji){if(gt.setValue(D,"toneMappingExposure",w.toneMappingExposure),Ae.needsLights)Lb(Ft,rs);if(Me&&X.fog===!0)Ee.refreshFogUniforms(Ft,Me);if(Ee.refreshMaterialUniforms(Ft,X,V,I,S.state.transmissionRenderTarget[b.id]),Ae.needsLights&&Ae.lightProbeGrid){let St=Ae.lightProbeGrid;Ft.probesSH.value=St.texture,Ft.probesMin.value.copy(St.boundingBox.min),Ft.probesMax.value.copy(St.boundingBox.max),Ft.probesResolution.value.copy(St.resolution)}la.upload(D,Sf(Ae),Ft,J)}if(X.isShaderMaterial&&X.uniformsNeedUpdate===!0)la.upload(D,Sf(Ae),Ft,J),X.uniformsNeedUpdate=!1;if(X.isSpriteMaterial)gt.setValue(D,"center",j.center);if(gt.setValue(D,"modelViewMatrix",j.modelViewMatrix),gt.setValue(D,"normalMatrix",j.normalMatrix),gt.setValue(D,"modelMatrix",j.matrixWorld),X.uniformsGroups!==void 0){let St=X.uniformsGroups;for(let Yi=0,ss=St.length;Yi<ss;Yi++){let Ef=St[Yi];Te.update(Ef,Nn),Te.bind(Ef,Nn)}}return Nn}function Lb(b,U){b.ambientLightColor.needsUpdate=U,b.lightProbe.needsUpdate=U,b.sunLights.needsUpdate=U,b.sunLightShadows.needsUpdate=U,b.directionalLights.needsUpdate=U,b.directionalLightShadows.needsUpdate=U,b.pointLights.needsUpdate=U,b.pointLightShadows.needsUpdate=U,b.spotLights.needsUpdate=U,b.spotLightShadows.needsUpdate=U,b.rectAreaLights.needsUpdate=U,b.hemisphereLights.needsUpdate=U}function Nb(b){return b.isMeshLambertMaterial||b.isMeshToonMaterial||b.isMeshPhongMaterial||b.isMeshStandardMaterial||b.isShadowMaterial||b.isShaderMaterial&&b.lights===!0}this.getActiveCubeFace=function(){return Z},this.getActiveMipmapLevel=function(){return G},this.getRenderTarget=function(){return k},this.setRenderTargetTextures=function(b,U,Q){let X=O.get(b);if(X.__autoAllocateDepthBuffer=b.resolveDepthBuffer===!1,X.__autoAllocateDepthBuffer===!1)X.__useRenderToTexture=!1;O.get(b.texture).__webglTexture=U,O.get(b.depthTexture).__webglTexture=X.__autoAllocateDepthBuffer?void 0:Q,X.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(b,U){let Q=O.get(b);Q.__webglFramebuffer=U,Q.__useDefaultFramebuffer=U===void 0},this.setRenderTarget=function(b,U=0,Q=0){k=b,Z=U,G=Q;let X=null,j=!1,Me=!1;if(b){let we=O.get(b);if(we.__useDefaultFramebuffer!==void 0){A.bindFramebuffer(D.FRAMEBUFFER,we.__webglFramebuffer),Y.copy(b.viewport),K.copy(b.scissor),ge=b.scissorTest,A.viewport(Y),A.scissor(K),A.setScissorTest(ge),W=-1;return}else if(we.__webglFramebuffer===void 0)J.setupRenderTarget(b);else if(we.__hasExternalTextures)J.rebindTextures(b,O.get(b.texture).__webglTexture,O.get(b.depthTexture).__webglTexture);else if(b.depthBuffer){let je=b.depthTexture;if(we.__boundDepthTexture!==je){if(je!==null&&O.has(je)&&(b.width!==je.image.width||b.height!==je.image.height))throw Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");J.setupDepthRenderbuffer(b)}}let Ie=b.texture;if(Ie.isData3DTexture||Ie.isDataArrayTexture||Ie.isCompressedArrayTexture)Me=!0;let Ne=O.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget){if(Array.isArray(Ne[U]))X=Ne[U][Q];else X=Ne[U];j=!0}else if(b.samples>0&&J.useMultisampledRTT(b)===!1)X=O.get(b).__webglMultisampledFramebuffer;else if(Array.isArray(Ne))X=Ne[Q];else X=Ne;Y.copy(b.viewport),K.copy(b.scissor),ge=b.scissorTest}else Y.copy(ce).multiplyScalar(V).floor(),K.copy(ae).multiplyScalar(V).floor(),ge=ke;if(Q!==0)X=N;if(A.bindFramebuffer(D.FRAMEBUFFER,X))A.drawBuffers(b,X);if(A.viewport(Y),A.scissor(K),A.setScissorTest(ge),j){let we=O.get(b.texture);D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_CUBE_MAP_POSITIVE_X+U,we.__webglTexture,Q)}else if(Me){let we=U;for(let Ie=0;Ie<b.textures.length;Ie++){let Ne=O.get(b.textures[Ie]);D.framebufferTextureLayer(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0+Ie,Ne.__webglTexture,Q,we)}}else if(b!==null&&Q!==0){let we=O.get(b.texture);D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,we.__webglTexture,Q)}W=-1};function Mf(b){let U=O.get(b);if(U.__readFormat!==b.format||U.__readType!==b.type)U.__readFormat=b.format,U.__readType=b.type,U.__formatReadable=Pt.textureFormatReadable(b.format),U.__typeReadable=Pt.textureTypeReadable(b.type);return U}if(this.readRenderTargetPixels=function(b,U,Q,X,j,Me,Re,we=0){if(!(b&&b.isWebGLRenderTarget)){$e("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ie=O.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget&&Re!==void 0)Ie=Ie[Re];if(Ie){A.bindFramebuffer(D.FRAMEBUFFER,Ie);try{let Ne=b.textures[we],{format:je,type:et}=Ne;if(b.textures.length>1)D.readBuffer(D.COLOR_ATTACHMENT0+we);let Pe=Mf(Ne);if(Pe.__formatReadable===!1){$e("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(Pe.__typeReadable===!1){$e("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}if(U>=0&&U<=b.width-X&&(Q>=0&&Q<=b.height-j))D.readPixels(U,Q,X,j,ne.convert(je),ne.convert(et),Me)}finally{let Ne=k!==null?O.get(k).__webglFramebuffer:null;A.bindFramebuffer(D.FRAMEBUFFER,Ne)}}},this.readRenderTargetPixelsAsync=async function(b,U,Q,X,j,Me,Re,we=0){if(!(b&&b.isWebGLRenderTarget))throw Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Ie=O.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget&&Re!==void 0)Ie=Ie[Re];if(Ie)if(U>=0&&U<=b.width-X&&(Q>=0&&Q<=b.height-j)){A.bindFramebuffer(D.FRAMEBUFFER,Ie);let Ne=b.textures[we],{format:je,type:et}=Ne;if(b.textures.length>1)D.readBuffer(D.COLOR_ATTACHMENT0+we);let Pe=Mf(Ne);if(Pe.__formatReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(Pe.__typeReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let dt=D.createBuffer();D.bindBuffer(D.PIXEL_PACK_BUFFER,dt),D.bufferData(D.PIXEL_PACK_BUFFER,Me.byteLength,D.STREAM_READ),D.readPixels(U,Q,X,j,ne.convert(je),ne.convert(et),0),D.bindBuffer(D.PIXEL_PACK_BUFFER,null);let Bt=k!==null?O.get(k).__webglFramebuffer:null;A.bindFramebuffer(D.FRAMEBUFFER,Bt);let Et=D.fenceSync(D.SYNC_GPU_COMMANDS_COMPLETE,0);return D.flush(),await xv(D,Et,4),D.bindBuffer(D.PIXEL_PACK_BUFFER,dt),D.getBufferSubData(D.PIXEL_PACK_BUFFER,0,Me),D.bindBuffer(D.PIXEL_PACK_BUFFER,null),D.deleteBuffer(dt),D.deleteSync(Et),Me}else throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(b,U=null,Q=0){let X=Math.pow(2,-Q),j=Math.floor(b.image.width*X),Me=Math.floor(b.image.height*X),Re=U!==null?U.x:0,we=U!==null?U.y:0;J.setTexture2D(b,0),D.copyTexSubImage2D(D.TEXTURE_2D,Q,0,0,Re,we,j,Me),A.unbindTexture()},this.copyTextureToTexture=function(b,U,Q=null,X=null,j=0,Me=0){let Re,we,Ie,Ne,je,et,Pe,dt,Bt,Et=b.isCompressedTexture?b.mipmaps[Me]:b.image;if(Q!==null)Re=Q.max.x-Q.min.x,we=Q.max.y-Q.min.y,Ie=Q.isBox3?Q.max.z-Q.min.z:1,Ne=Q.min.x,je=Q.min.y,et=Q.isBox3?Q.min.z:0;else{let Ft=Math.pow(2,-j);if(Re=Math.floor(Et.width*Ft),we=Math.floor(Et.height*Ft),b.isDataArrayTexture)Ie=Et.depth;else if(b.isData3DTexture)Ie=Math.floor(Et.depth*Ft);else Ie=1;Ne=0,je=0,et=0}if(X!==null)Pe=X.x,dt=X.y,Bt=X.z;else Pe=0,dt=0,Bt=0;let xt=ne.convert(U.format),sn=ne.convert(U.type),Ae;if(U.isData3DTexture)J.setTexture3D(U,0),Ae=D.TEXTURE_3D;else if(U.isDataArrayTexture||U.isCompressedArrayTexture)J.setTexture2DArray(U,0),Ae=D.TEXTURE_2D_ARRAY;else J.setTexture2D(U,0),Ae=D.TEXTURE_2D;A.activeTexture(D.TEXTURE0),A.pixelStorei(D.UNPACK_FLIP_Y_WEBGL,U.flipY),A.pixelStorei(D.UNPACK_PREMULTIPLY_ALPHA_WEBGL,U.premultiplyAlpha),A.pixelStorei(D.UNPACK_ALIGNMENT,U.unpackAlignment);let dn=A.getParameter(D.UNPACK_ROW_LENGTH),st=A.getParameter(D.UNPACK_IMAGE_HEIGHT),Nn=A.getParameter(D.UNPACK_SKIP_PIXELS),ai=A.getParameter(D.UNPACK_SKIP_ROWS),ji=A.getParameter(D.UNPACK_SKIP_IMAGES);A.pixelStorei(D.UNPACK_ROW_LENGTH,Et.width),A.pixelStorei(D.UNPACK_IMAGE_HEIGHT,Et.height),A.pixelStorei(D.UNPACK_SKIP_PIXELS,Ne),A.pixelStorei(D.UNPACK_SKIP_ROWS,je),A.pixelStorei(D.UNPACK_SKIP_IMAGES,et);let rs=b.isDataArrayTexture||b.isData3DTexture,gt=U.isDataArrayTexture||U.isData3DTexture;if(b.isDepthTexture){let Ft=O.get(b),qi=O.get(U),St=O.get(Ft.__renderTarget),Yi=O.get(qi.__renderTarget);A.bindFramebuffer(D.READ_FRAMEBUFFER,St.__webglFramebuffer),A.bindFramebuffer(D.DRAW_FRAMEBUFFER,Yi.__webglFramebuffer);for(let ss=0;ss<Ie;ss++){if(rs)D.framebufferTextureLayer(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,O.get(b).__webglTexture,j,et+ss),D.framebufferTextureLayer(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,O.get(U).__webglTexture,Me,Bt+ss);D.blitFramebuffer(Ne,je,Re,we,Pe,dt,Re,we,D.DEPTH_BUFFER_BIT,D.NEAREST)}A.bindFramebuffer(D.READ_FRAMEBUFFER,null),A.bindFramebuffer(D.DRAW_FRAMEBUFFER,null)}else if(j!==0||b.isRenderTargetTexture||O.has(b)){let Ft=O.get(b),qi=O.get(U);A.bindFramebuffer(D.READ_FRAMEBUFFER,ee),A.bindFramebuffer(D.DRAW_FRAMEBUFFER,P);for(let St=0;St<Ie;St++){if(rs)D.framebufferTextureLayer(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,Ft.__webglTexture,j,et+St);else D.framebufferTexture2D(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,Ft.__webglTexture,j);if(gt)D.framebufferTextureLayer(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,qi.__webglTexture,Me,Bt+St);else D.framebufferTexture2D(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,qi.__webglTexture,Me);if(j!==0)D.blitFramebuffer(Ne,je,Re,we,Pe,dt,Re,we,D.COLOR_BUFFER_BIT,D.NEAREST);else if(gt)D.copyTexSubImage3D(Ae,Me,Pe,dt,Bt+St,Ne,je,Re,we);else D.copyTexSubImage2D(Ae,Me,Pe,dt,Ne,je,Re,we)}A.bindFramebuffer(D.READ_FRAMEBUFFER,null),A.bindFramebuffer(D.DRAW_FRAMEBUFFER,null)}else if(gt)if(b.isDataTexture||b.isData3DTexture)D.texSubImage3D(Ae,Me,Pe,dt,Bt,Re,we,Ie,xt,sn,Et.data);else if(U.isCompressedArrayTexture)D.compressedTexSubImage3D(Ae,Me,Pe,dt,Bt,Re,we,Ie,xt,Et.data);else D.texSubImage3D(Ae,Me,Pe,dt,Bt,Re,we,Ie,xt,sn,Et);else if(b.isDataTexture)D.texSubImage2D(D.TEXTURE_2D,Me,Pe,dt,Re,we,xt,sn,Et.data);else if(b.isCompressedTexture)D.compressedTexSubImage2D(D.TEXTURE_2D,Me,Pe,dt,Et.width,Et.height,xt,Et.data);else D.texSubImage2D(D.TEXTURE_2D,Me,Pe,dt,Re,we,xt,sn,Et);if(A.pixelStorei(D.UNPACK_ROW_LENGTH,dn),A.pixelStorei(D.UNPACK_IMAGE_HEIGHT,st),A.pixelStorei(D.UNPACK_SKIP_PIXELS,Nn),A.pixelStorei(D.UNPACK_SKIP_ROWS,ai),A.pixelStorei(D.UNPACK_SKIP_IMAGES,ji),Me===0&&U.generateMipmaps)D.generateMipmap(Ae);A.unbindTexture()},this.initRenderTarget=function(b){if(O.get(b).__webglFramebuffer===void 0)J.setupRenderTarget(b)},this.initTexture=function(b){if(b.isCubeTexture)J.setTextureCube(b,0);else if(b.isData3DTexture)J.setTexture3D(b,0);else if(b.isDataArrayTexture||b.isCompressedArrayTexture)J.setTexture2DArray(b,0);else J.setTexture2D(b,0);A.unbindTexture()},this.resetState=function(){Z=0,G=0,k=null,A.reset(),xe.reset()},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ld}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=Ke._getDrawingBufferColorSpace(e),t.unpackColorSpace=Ke._getUnpackColorSpace()}}function Hd(e,t){if(t===sd)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t===Us||t===$o){let n=e.getIndex();if(n===null){let s=[],o=e.getAttribute("position");if(o!==void 0){for(let a=0;a<o.count;a++)s.push(a);e.setIndex(s),n=e.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e}let i=n.count-2,r=[];if(t===Us)for(let s=1;s<=i;s++)r.push(n.getX(0)),r.push(n.getX(s)),r.push(n.getX(s+1));else for(let s=0;s<i;s++)if(s%2===0)r.push(n.getX(s)),r.push(n.getX(s+1)),r.push(n.getX(s+2));else r.push(n.getX(s+2)),r.push(n.getX(s+1)),r.push(n.getX(s));if(r.length/3!==i)console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");return e.setIndex(r),e.clearGroups(),e}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),e}function hy(e){let t=new Map,n=new Map,i=e.clone();return dy(e,i,function(r,s){t.set(s,r),n.set(r,s)}),i.traverse(function(r){if(!r.isSkinnedMesh)return;let s=r,o=t.get(r),a=o.skeleton.bones;s.skeleton=o.skeleton.clone(),s.bindMatrix.copy(o.bindMatrix),s.skeleton.bones=a.map(function(c){return n.get(c)}),s.bind(s.skeleton,s.bindMatrix)}),i}function dy(e,t,n){n(e,t);for(let i=0;i<e.children.length;i++)dy(e.children[i],t.children[i],n)}class qd extends Zi{constructor(e){super(e);this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new yy(t)}),this.register(function(t){return new by(t)}),this.register(function(t){return new Iy(t)}),this.register(function(t){return new Py(t)}),this.register(function(t){return new Ly(t)}),this.register(function(t){return new wy(t)}),this.register(function(t){return new My(t)}),this.register(function(t){return new Ey(t)}),this.register(function(t){return new Ty(t)}),this.register(function(t){return new vy(t)}),this.register(function(t){return new Ay(t)}),this.register(function(t){return new Sy(t)}),this.register(function(t){return new Cy(t)}),this.register(function(t){return new Ry(t)}),this.register(function(t){return new _y(t)}),this.register(function(t){return new Zd(t,Qe.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new Zd(t,Qe.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new Ny(t)})}load(e,t,n,i){let r=this,s;if(this.resourcePath!=="")s=this.resourcePath;else if(this.path!==""){let c=wr.extractUrlBase(e);s=wr.resolveURL(c,this.path)}else s=wr.extractUrlBase(e);this.manager.itemStart(e);let o=function(c){if(i)i(c);else console.error(c);r.manager.itemError(e),r.manager.itemEnd(e)},a=new ia(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(c){try{r.parse(c,s,function(l){t(l),r.manager.itemEnd(e)},o)}catch(l){o(l)}},n,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){if(this.pluginCallbacks.indexOf(e)===-1)this.pluginCallbacks.push(e);return this}unregister(e){if(this.pluginCallbacks.indexOf(e)!==-1)this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1);return this}parse(e,t,n,i){let r,s={},o={},a=new TextDecoder;if(typeof e==="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(a.decode(new Uint8Array(e,0,4))===Dy){try{s[Qe.KHR_BINARY_GLTF]=new Oy(e)}catch(u){if(i)i(u);return}r=JSON.parse(s[Qe.KHR_BINARY_GLTF].content)}else r=JSON.parse(a.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){if(i)i(Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}let c=new By(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let l=0;l<this.pluginCallbacks.length;l++){let u=this.pluginCallbacks[l](c);if(!u.name)console.error("THREE.GLTFLoader: Invalid plugin found: missing name");o[u.name]=u,s[u.name]=!0}if(r.extensionsUsed)for(let l=0;l<r.extensionsUsed.length;++l){let u=r.extensionsUsed[l],h=r.extensionsRequired||[];switch(u){case Qe.KHR_MATERIALS_UNLIT:s[u]=new xy;break;case Qe.KHR_DRACO_MESH_COMPRESSION:s[u]=new Uy(r,this.dracoLoader);break;case Qe.KHR_TEXTURE_TRANSFORM:s[u]=new Fy;break;case Qe.KHR_MESH_QUANTIZATION:s[u]=new zy;break;default:if(h.indexOf(u)>=0&&o[u]===void 0)console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(s),c.setPlugins(o),c.parse(n,i)}parseAsync(e,t){let n=this;return new Promise(function(i,r){n.parse(e,t,i,r)})}}function lC(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}function kt(e,t,n){let i=e.json.materials[t];if(i.extensions&&i.extensions[n])return i.extensions[n];return null}var Qe={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class _y{constructor(e){this.parser=e,this.name=Qe.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){let r=t[n];if(r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0)e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){let t=this.parser,n="light:"+e,i=t.cache.get(n);if(i)return i;let r=t.json,a=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e],c,l=new He(16777215);if(a.color!==void 0)l.setRGB(a.color[0],a.color[1],a.color[2],Rn);let u=a.range!==void 0?a.range:0;switch(a.type){case"directional":c=new Vs(l),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new Hs(l),c.distance=u;break;case"spot":c=new ll(l),c.distance=u,a.spot=a.spot||{},a.spot.innerConeAngle=a.spot.innerConeAngle!==void 0?a.spot.innerConeAngle:0,a.spot.outerConeAngle=a.spot.outerConeAngle!==void 0?a.spot.outerConeAngle:Math.PI/4,c.angle=a.spot.outerConeAngle,c.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw Error("THREE.GLTFLoader: Unexpected light type: "+a.type)}if(c.position.set(0,0,0),Ti(c,a),a.intensity!==void 0)c.intensity=a.intensity;return c.name=t.createUniqueName(a.name||"light_"+e),i=Promise.resolve(c),t.cache.add(n,i),i}getDependency(e,t){if(e!=="light")return;return this._loadLight(t)}createNodeAttachment(e){let t=this,n=this.parser,r=n.json.nodes[e],o=(r.extensions&&r.extensions[this.name]||{}).light;if(o===void 0)return null;return this._loadLight(o).then(function(a){return n._getNodeRef(t.cache,o,a)})}}class xy{constructor(){this.name=Qe.KHR_MATERIALS_UNLIT}getMaterialType(){return wi}extendParams(e,t,n){let i=[];e.color=new He(1,1,1),e.opacity=1;let r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){let s=r.baseColorFactor;e.color.setRGB(s[0],s[1],s[2],Rn),e.opacity=s[3]}if(r.baseColorTexture!==void 0)i.push(n.assignTexture(e,"map",r.baseColorTexture,mr))}return Promise.all(i)}}class vy{constructor(e){this.parser=e,this.name=Qe.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let n=kt(this.parser,e,this.name);if(n===null)return Promise.resolve();if(n.emissiveStrength!==void 0)t.emissiveIntensity=n.emissiveStrength;return Promise.resolve()}}class yy{constructor(e){this.parser=e,this.name=Qe.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return kt(this.parser,e,this.name)!==null?Pn:null}extendMaterialParams(e,t){let n=kt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.clearcoatFactor!==void 0)t.clearcoat=n.clearcoatFactor;if(n.clearcoatTexture!==void 0)i.push(this.parser.assignTexture(t,"clearcoatMap",n.clearcoatTexture));if(n.clearcoatRoughnessFactor!==void 0)t.clearcoatRoughness=n.clearcoatRoughnessFactor;if(n.clearcoatRoughnessTexture!==void 0)i.push(this.parser.assignTexture(t,"clearcoatRoughnessMap",n.clearcoatRoughnessTexture));if(n.clearcoatNormalTexture!==void 0){if(i.push(this.parser.assignTexture(t,"clearcoatNormalMap",n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0){let r=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Be(r,r)}}return Promise.all(i)}}class by{constructor(e){this.parser=e,this.name=Qe.KHR_MATERIALS_DISPERSION}getMaterialType(e){return kt(this.parser,e,this.name)!==null?Pn:null}extendMaterialParams(e,t){let n=kt(this.parser,e,this.name);if(n===null)return Promise.resolve();return t.dispersion=n.dispersion!==void 0?n.dispersion:0,Promise.resolve()}}class Sy{constructor(e){this.parser=e,this.name=Qe.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return kt(this.parser,e,this.name)!==null?Pn:null}extendMaterialParams(e,t){let n=kt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.iridescenceFactor!==void 0)t.iridescence=n.iridescenceFactor;if(n.iridescenceTexture!==void 0)i.push(this.parser.assignTexture(t,"iridescenceMap",n.iridescenceTexture));if(n.iridescenceIor!==void 0)t.iridescenceIOR=n.iridescenceIor;if(t.iridescenceThicknessRange===void 0)t.iridescenceThicknessRange=[100,400];if(n.iridescenceThicknessMinimum!==void 0)t.iridescenceThicknessRange[0]=n.iridescenceThicknessMinimum;if(n.iridescenceThicknessMaximum!==void 0)t.iridescenceThicknessRange[1]=n.iridescenceThicknessMaximum;if(n.iridescenceThicknessTexture!==void 0)i.push(this.parser.assignTexture(t,"iridescenceThicknessMap",n.iridescenceThicknessTexture));return Promise.all(i)}}class wy{constructor(e){this.parser=e,this.name=Qe.KHR_MATERIALS_SHEEN}getMaterialType(e){return kt(this.parser,e,this.name)!==null?Pn:null}extendMaterialParams(e,t){let n=kt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.sheenColor=new He(0,0,0),t.sheenRoughness=0,t.sheen=1,n.sheenColorFactor!==void 0){let r=n.sheenColorFactor;t.sheenColor.setRGB(r[0],r[1],r[2],Rn)}if(n.sheenRoughnessFactor!==void 0)t.sheenRoughness=n.sheenRoughnessFactor;if(n.sheenColorTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenColorMap",n.sheenColorTexture,mr));if(n.sheenRoughnessTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenRoughnessMap",n.sheenRoughnessTexture));return Promise.all(i)}}class My{constructor(e){this.parser=e,this.name=Qe.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return kt(this.parser,e,this.name)!==null?Pn:null}extendMaterialParams(e,t){let n=kt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.transmissionFactor!==void 0)t.transmission=n.transmissionFactor;if(n.transmissionTexture!==void 0)i.push(this.parser.assignTexture(t,"transmissionMap",n.transmissionTexture));return Promise.all(i)}}class Ey{constructor(e){this.parser=e,this.name=Qe.KHR_MATERIALS_VOLUME}getMaterialType(e){return kt(this.parser,e,this.name)!==null?Pn:null}extendMaterialParams(e,t){let n=kt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.thickness=n.thicknessFactor!==void 0?n.thicknessFactor:0,n.thicknessTexture!==void 0)i.push(this.parser.assignTexture(t,"thicknessMap",n.thicknessTexture));t.attenuationDistance=n.attenuationDistance||1/0;let r=n.attenuationColor||[1,1,1];return t.attenuationColor=new He().setRGB(r[0],r[1],r[2],Rn),Promise.all(i)}}class Ty{constructor(e){this.parser=e,this.name=Qe.KHR_MATERIALS_IOR}getMaterialType(e){return kt(this.parser,e,this.name)!==null?Pn:null}extendMaterialParams(e,t){let n=kt(this.parser,e,this.name);if(n===null)return Promise.resolve();if(t.ior=n.ior!==void 0?n.ior:1.5,t.ior===0)t.ior=1000;return Promise.resolve()}}class Ay{constructor(e){this.parser=e,this.name=Qe.KHR_MATERIALS_SPECULAR}getMaterialType(e){return kt(this.parser,e,this.name)!==null?Pn:null}extendMaterialParams(e,t){let n=kt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.specularIntensity=n.specularFactor!==void 0?n.specularFactor:1,n.specularTexture!==void 0)i.push(this.parser.assignTexture(t,"specularIntensityMap",n.specularTexture));let r=n.specularColorFactor||[1,1,1];if(t.specularColor=new He().setRGB(r[0],r[1],r[2],Rn),n.specularColorTexture!==void 0)i.push(this.parser.assignTexture(t,"specularColorMap",n.specularColorTexture,mr));return Promise.all(i)}}class Ry{constructor(e){this.parser=e,this.name=Qe.EXT_MATERIALS_BUMP}getMaterialType(e){return kt(this.parser,e,this.name)!==null?Pn:null}extendMaterialParams(e,t){let n=kt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.bumpScale=n.bumpFactor!==void 0?n.bumpFactor:1,n.bumpTexture!==void 0)i.push(this.parser.assignTexture(t,"bumpMap",n.bumpTexture));return Promise.all(i)}}class Cy{constructor(e){this.parser=e,this.name=Qe.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return kt(this.parser,e,this.name)!==null?Pn:null}extendMaterialParams(e,t){let n=kt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.anisotropyStrength!==void 0)t.anisotropy=n.anisotropyStrength;if(n.anisotropyRotation!==void 0)t.anisotropyRotation=n.anisotropyRotation;if(n.anisotropyTexture!==void 0)i.push(this.parser.assignTexture(t,"anisotropyMap",n.anisotropyTexture));return Promise.all(i)}}class Iy{constructor(e){this.parser=e,this.name=Qe.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;let r=i.extensions[this.name],s=t.options.ktx2Loader;if(!s)if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");else return null;return t.loadTextureImage(e,r.source,s)}}class Py{constructor(e){this.parser=e,this.name=Qe.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;let s=r.extensions[t],o=i.images[s.source],a=n.textureLoader;if(o.uri){let c=n.options.manager.getHandler(o.uri);if(c!==null)a=c}return n.loadTextureImage(e,s.source,a)}}class Ly{constructor(e){this.parser=e,this.name=Qe.EXT_TEXTURE_AVIF}loadTexture(e){let t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;let s=r.extensions[t],o=i.images[s.source],a=n.textureLoader;if(o.uri){let c=n.options.manager.getHandler(o.uri);if(c!==null)a=c}return n.loadTextureImage(e,s.source,a)}}class Zd{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let i=n.extensions[this.name],r=this.parser.getDependency("buffer",i.buffer),s=this.parser.options.meshoptDecoder;if(!s||!s.supported)if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");else return null;return r.then(function(o){let a=i.byteOffset||0,c=i.byteLength||0,{count:l,byteStride:u}=i,h=new Uint8Array(o,a,c);if(s.decodeGltfBufferAsync)return s.decodeGltfBufferAsync(l,u,h,i.mode,i.filter).then(function(d){return d.buffer});else return s.ready.then(function(){let d=new ArrayBuffer(l*u);return s.decodeGltfBuffer(new Uint8Array(d),l,u,h,i.mode,i.filter),d})})}else return null}}class Ny{constructor(e){this.name=Qe.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let i=t.meshes[n.mesh];for(let c of i.primitives)if(c.mode!==Hn.TRIANGLES&&c.mode!==Hn.TRIANGLE_STRIP&&c.mode!==Hn.TRIANGLE_FAN&&c.mode!==void 0)return null;let s=n.extensions[this.name].attributes,o=[],a={};for(let c in s)o.push(this.parser.getDependency("accessor",s[c]).then((l)=>(a[c]=l,a[c])));if(o.length<1)return null;return o.push(this.parser.createNodeMesh(e)),Promise.all(o).then((c)=>{let l=c.pop(),u=l.isGroup?l.children:[l],h=c[0].count,d=[];for(let f of u){let m=new Xe,_=new F,p=new Yt,g=new F(1,1,1),M=new ks(f.geometry,f.material,h);for(let v=0;v<h;v++){if(a.TRANSLATION)_.fromBufferAttribute(a.TRANSLATION,v);if(a.ROTATION)p.fromBufferAttribute(a.ROTATION,v);if(a.SCALE)g.fromBufferAttribute(a.SCALE,v);M.setMatrixAt(v,m.compose(_,p,g))}let T=null;for(let v in a)if(v==="_COLOR_0"){let S=a[v];M.instanceColor=new ur(S.array,S.itemSize,S.normalized)}else if(v!=="TRANSLATION"&&v!=="ROTATION"&&v!=="SCALE"){if(T===null){let E=M.geometry;T=new ln,T.name=E.name;for(let R in E.attributes)T.setAttribute(R,E.attributes[R]);for(let R in E.morphAttributes)T.morphAttributes[R]=E.morphAttributes[R];if(E.index!==null)T.setIndex(E.index);T.morphTargetsRelative=E.morphTargetsRelative;for(let R of E.groups)T.addGroup(R.start,R.count,R.materialIndex);if(E.boundingBox!==null)T.boundingBox=E.boundingBox.clone();if(E.boundingSphere!==null)T.boundingSphere=E.boundingSphere.clone();T.drawRange.start=E.drawRange.start,T.drawRange.count=E.drawRange.count,T.userData=Object.assign({},E.userData),M.geometry=T}let S=a[v];T.setAttribute(v,new ur(S.array,S.itemSize,S.normalized))}_t.prototype.copy.call(M,f),this.parser.assignFinalMaterial(M),d.push(M)}if(l.isGroup)return l.clear(),l.add(...d),l;return d[0]})}}var Dy="glTF",ha=12,fy={JSON:1313821514,BIN:5130562};class Oy{constructor(e){this.name=Qe.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,ha),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Dy)throw Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");else if(this.header.version<2)throw Error("THREE.GLTFLoader: Legacy binary file detected.");let i=this.header.length-ha,r=new DataView(e,ha),s=0;while(s<i){let o=r.getUint32(s,!0);s+=4;let a=r.getUint32(s,!0);if(s+=4,a===fy.JSON){let c=new Uint8Array(e,ha+s,o);this.content=n.decode(c)}else if(a===fy.BIN){let c=ha+s;this.body=e.slice(c,c+o)}s+=o}if(this.content===null)throw Error("THREE.GLTFLoader: JSON content not found.")}}class Uy{constructor(e,t){if(!t)throw Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Qe.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let n=this.json,i=this.dracoLoader,r=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,o={},a={},c={};for(let l in s){let u=Xd[l]||l.toLowerCase();o[u]=s[l]}for(let l in e.attributes){let u=Xd[l]||l.toLowerCase();if(s[l]!==void 0){let h=n.accessors[e.attributes[l]],d=Xs[h.componentType];c[u]=d.name,a[u]=h.normalized===!0}}return t.getDependency("bufferView",r).then(function(l){return new Promise(function(u,h){i.decodeDracoFile(l,function(d){for(let f in d.attributes){let m=d.attributes[f],_=a[f];if(_!==void 0)m.normalized=_}u(d)},o,c,Rn,h)})})}}class Fy{constructor(){this.name=Qe.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){if((t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0)return e;if(e=e.clone(),t.texCoord!==void 0)e.channel=t.texCoord;if(t.offset!==void 0)e.offset.fromArray(t.offset);if(t.rotation!==void 0)e.rotation=t.rotation;if(t.scale!==void 0)e.repeat.fromArray(t.scale);if(t.rotation!==void 0){let n=Math.cos(e.rotation),i=Math.sin(e.rotation);e.matrix.set(e.repeat.x*n,e.repeat.y*i,e.offset.x,-e.repeat.x*i,e.repeat.y*n,e.offset.y,0,0,1),e.matrixAutoUpdate=!1}return e.needsUpdate=!0,e}}class zy{constructor(){this.name=Qe.KHR_MESH_QUANTIZATION}}class Yd extends Wi{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i*3+i;for(let s=0;s!==i;s++)t[s]=n[r+s];return t}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=o*2,c=o*3,l=i-t,u=(n-t)/l,h=u*u,d=h*u,f=e*c,m=f-c,_=-2*d+3*h,p=d-h,g=1-_,M=p-h+u;for(let T=0;T!==o;T++){let v=s[m+T+o],S=s[m+T+a]*l,E=s[f+T+o],R=s[f+T]*l;r[T]=g*v+M*S+_*E+p*R}return r}}var uC=new Yt;class ky extends Yd{interpolate_(e,t,n,i){let r=super.interpolate_(e,t,n,i);return uC.fromArray(r).normalize().toArray(r),r}}var Hn={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},Xs={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},py={9728:ti,9729:Jt,9984:zc,9985:Ds,9986:Wr,9987:yi},my={33071:Ns,33648:Fc,10497:Ls},Vd={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Xd={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Mr={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},hC={CUBICSPLINE:void 0,LINEAR:Wc,STEP:rd},$d={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function dC(e){if(e.DefaultMaterial===void 0)e.DefaultMaterial=new $i({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:fr});return e.DefaultMaterial}function ts(e,t,n){for(let i in n.extensions)if(e[i]===void 0)t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=n.extensions[i]}function Ti(e,t){if(t.extras!==void 0)if(typeof t.extras==="object")Object.assign(e.userData,t.extras);else console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras)}function fC(e,t,n){let i=!1,r=!1,s=!1;for(let l=0,u=t.length;l<u;l++){let h=t[l];if(h.POSITION!==void 0)i=!0;if(h.NORMAL!==void 0)r=!0;if(h.COLOR_0!==void 0)s=!0;if(i&&r&&s)break}if(!i&&!r&&!s)return Promise.resolve(e);let o=[],a=[],c=[];for(let l=0,u=t.length;l<u;l++){let h=t[l];if(i){let d=h.POSITION!==void 0?n.getDependency("accessor",h.POSITION):e.attributes.position;o.push(d)}if(r){let d=h.NORMAL!==void 0?n.getDependency("accessor",h.NORMAL):e.attributes.normal;a.push(d)}if(s){let d=h.COLOR_0!==void 0?n.getDependency("accessor",h.COLOR_0):e.attributes.color;c.push(d)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c)]).then(function(l){let u=l[0],h=l[1],d=l[2];if(i)e.morphAttributes.position=u;if(r)e.morphAttributes.normal=h;if(s)e.morphAttributes.color=d;return e.morphTargetsRelative=!0,e})}function pC(e,t){if(e.updateMorphTargets(),t.weights!==void 0)for(let n=0,i=t.weights.length;n<i;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){let n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let i=0,r=n.length;i<r;i++)e.morphTargetDictionary[n[i]]=i}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function mC(e){let t,n=e.extensions&&e.extensions[Qe.KHR_DRACO_MESH_COMPRESSION];if(n)t="draco:"+n.bufferView+":"+n.indices+":"+Wd(n.attributes);else t=e.indices+":"+Wd(e.attributes)+":"+e.mode;if(e.targets!==void 0)for(let i=0,r=e.targets.length;i<r;i++)t+=":"+Wd(e.targets[i]);return t}function Wd(e){let t="",n=Object.keys(e).sort();for(let i=0,r=n.length;i<r;i++)t+=n[i]+":"+e[n[i]]+";";return t}function jd(e){switch(e){case Int8Array:return 0.007874015748031496;case Uint8Array:return 0.00392156862745098;case Int16Array:return 0.00003051850947599719;case Uint16Array:return 0.000015259021896696422;default:throw Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function gC(e){if(e.search(/\.jpe?g($|\?)/i)>0||e.search(/^data\:image\/jpeg/)===0)return"image/jpeg";if(e.search(/\.webp($|\?)/i)>0||e.search(/^data\:image\/webp/)===0)return"image/webp";if(e.search(/\.ktx2($|\?)/i)>0||e.search(/^data\:image\/ktx2/)===0)return"image/ktx2";return"image/png"}var _C=new Xe;class By{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new lC,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=-1,r=!1,s=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){let o=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(o)===!0;let a=o.match(/Version\/(\d+)/);i=n&&a?parseInt(a[1],10):-1,r=o.indexOf("Firefox")>-1,s=r?o.match(/Firefox\/([0-9]+)\./)[1]:-1}if(typeof createImageBitmap>"u"||n&&i<17||r&&s<98)this.textureLoader=new ol(this.options.manager);else this.textureLoader=new ul(this.options.manager);if(this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new ia(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials")this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(s){return s._markDefs&&s._markDefs()}),Promise.all(this._invokeAll(function(s){return s.beforeRoot&&s.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(s){let o={scene:s[0][i.scene||0],scenes:s[0],animations:s[1],cameras:s[2],asset:i.asset,parser:n,userData:{}};return ts(r,o,i),Ti(o,i),Promise.all(n._invokeAll(function(a){return a.afterRoot&&a.afterRoot(o)})).then(function(){for(let a of o.scenes)a.updateMatrixWorld();e(o)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,r=t.length;i<r;i++){let s=t[i].joints;for(let o=0,a=s.length;o<a;o++)e[s[o]].isBone=!0}for(let i=0,r=e.length;i<r;i++){let s=e[i];if(s.mesh!==void 0){if(this._addNodeRef(this.meshCache,s.mesh),s.skin!==void 0)n[s.mesh].isSkinnedMesh=!0}if(s.camera!==void 0)this._addNodeRef(this.cameraCache,s.camera)}}_addNodeRef(e,t){if(t===void 0)return;if(e.refs[t]===void 0)e.refs[t]=e.uses[t]=0;e.refs[t]++}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;let i=n.clone(),r=(s,o)=>{let a=this.associations.get(s);if(a!=null)this.associations.set(o,a);for(let[c,l]of s.children.entries())r(l,o.children[c])};return r(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){let i=e(t[n]);if(i)return i}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let n=[];for(let i=0;i<t.length;i++){let r=e(t[i]);if(r)n.push(r)}return n}getDependency(e,t){let n=e+":"+t,i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":i=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!i)throw Error("Unknown type: "+e);break}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){let n=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(i.map(function(r,s){return n.getDependency(e,s)})),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[Qe.KHR_BINARY_GLTF].body);let i=this.options;return new Promise(function(r,s){n.load(wr.resolveURL(t.uri,i.path),r,void 0,function(){s(Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){let t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){let i=t.byteLength||0,r=t.byteOffset||0;return n.slice(r,r+i)})}loadAccessor(e){let t=this,n=this.json,i=this.json.accessors[e];if(i.bufferView===void 0&&i.sparse===void 0){let s=Vd[i.type],o=Xs[i.componentType],a=i.normalized===!0,c=new o(i.count*s);return Promise.resolve(new Kt(c,s,a))}let r=[];if(i.bufferView!==void 0)r.push(this.getDependency("bufferView",i.bufferView));else r.push(null);if(i.sparse!==void 0)r.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",i.sparse.values.bufferView));return Promise.all(r).then(function(s){let o=s[0],a=Vd[i.type],c=Xs[i.componentType],l=c.BYTES_PER_ELEMENT,u=l*a,h=i.byteOffset||0,d=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,f=i.normalized===!0,m,_;if(d&&d!==u){let p=Math.floor(h/d),g="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+p+":"+i.count,M=t.cache.get(g);if(!M)m=new c(o,p*d,i.count*d/l),M=new jo(m,d/l),t.cache.add(g,M);_=new zs(M,a,h%d/l,f)}else{if(o===null)m=new c(i.count*a);else m=new c(o,h,i.count*a);_=new Kt(m,a,f)}if(i.sparse!==void 0){let p=Vd.SCALAR,g=Xs[i.sparse.indices.componentType],M=i.sparse.indices.byteOffset||0,T=i.sparse.values.byteOffset||0,v=new g(s[1],M,i.sparse.count*p),S=new c(s[2],T,i.sparse.count*a);if(o!==null)_=new Kt(_.array.slice(),_.itemSize,_.normalized);_.normalized=!1;for(let E=0,R=v.length;E<R;E++){let x=v[E];if(_.setX(x,S[E*a]),a>=2)_.setY(x,S[E*a+1]);if(a>=3)_.setZ(x,S[E*a+2]);if(a>=4)_.setW(x,S[E*a+3]);if(a>=5)throw Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}_.normalized=f}return _})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,s=t.images[r],o=this.textureLoader;if(s.uri){let a=n.manager.getHandler(s.uri);if(a!==null)o=a}return this.loadTextureImage(e,r,o)}loadTextureImage(e,t,n){let i=this,r=this.json,s=r.textures[e],o=r.images[t],a=(o.uri||o.bufferView)+":"+s.sampler;if(this.textureCache[a])return this.textureCache[a];let c=this.loadImageSource(t,n).then(function(l){if(l.flipY=!1,l.name=s.name||o.name||"",l.name===""&&typeof o.uri==="string"&&o.uri.startsWith("data:image/")===!1)l.name=o.uri;let h=(r.samplers||{})[s.sampler]||{};return l.magFilter=py[h.magFilter]||Jt,l.minFilter=py[h.minFilter]||yi,l.wrapS=my[h.wrapS]||Ls,l.wrapT=my[h.wrapT]||Ls,l.generateMipmaps=!l.isCompressedTexture&&l.minFilter!==ti&&l.minFilter!==Jt,i.associations.set(l,{textures:e}),l}).catch(function(){return null});return this.textureCache[a]=c,c}loadImageSource(e,t){let n=this,i=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then((u)=>u.clone());let s=i.images[e],o=self.URL||self.webkitURL,a=s.uri||"",c=!1;if(s.bufferView!==void 0)a=n.getDependency("bufferView",s.bufferView).then(function(u){c=!0;let h=new Blob([u],{type:s.mimeType});return a=o.createObjectURL(h),a});else if(s.uri===void 0)throw Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let l=Promise.resolve(a).then(function(u){return new Promise(function(h,d){let f=h;if(t.isImageBitmapLoader===!0)f=function(m){let _=new Ot(m);_.needsUpdate=!0,h(_)};t.load(wr.resolveURL(u,r.path),f,void 0,d)})}).then(function(u){if(c===!0)o.revokeObjectURL(a);return Ti(u,s),u.userData.mimeType=s.mimeType||gC(s.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),u});return this.sourceCache[e]=l,l}assignTexture(e,t,n,i){let r=this;return this.getDependency("texture",n.index).then(function(s){if(!s)return null;if(n.texCoord!==void 0&&n.texCoord>0)s=s.clone(),s.channel=n.texCoord;if(r.extensions[Qe.KHR_TEXTURE_TRANSFORM]){let o=n.extensions!==void 0?n.extensions[Qe.KHR_TEXTURE_TRANSFORM]:void 0;if(o){let a=r.associations.get(s);s=r.extensions[Qe.KHR_TEXTURE_TRANSFORM].extendTexture(s,o),r.associations.set(s,a)}}if(i!==void 0)s.colorSpace=i;return e[t]=s,s})}assignFinalMaterial(e){let{geometry:t,material:n}=e,i=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,s=t.attributes.normal===void 0;if(e.isPoints){let o="PointsMaterial:"+n.uuid,a=this.cache.get(o);if(!a)a=new ea,yn.prototype.copy.call(a,n),a.color.copy(n.color),a.map=n.map,a.sizeAttenuation=!1,this.cache.add(o,a);n=a}else if(e.isLine){let o="LineBasicMaterial:"+n.uuid,a=this.cache.get(o);if(!a)a=new Qo,yn.prototype.copy.call(a,n),a.color.copy(n.color),a.map=n.map,this.cache.add(o,a);n=a}if(i||r||s){let o="ClonedMaterial:"+n.uuid+":";if(i)o+="derivative-tangents:";if(r)o+="vertex-colors:";if(s)o+="flat-shading:";let a=this.cache.get(o);if(!a){if(a=n.clone(),r)a.vertexColors=!0;if(s)a.flatShading=!0;if(i){if(a.normalScale)a.normalScale.y*=-1;if(a.clearcoatNormalScale)a.clearcoatNormalScale.y*=-1}this.cache.add(o,a),this.associations.set(a,this.associations.get(n))}n=a}e.material=n}getMaterialType(){return $i}loadMaterial(e){let t=this,n=this.json,i=this.extensions,r=n.materials[e],s,o={},a=r.extensions||{},c=[];if(a[Qe.KHR_MATERIALS_UNLIT]){let u=i[Qe.KHR_MATERIALS_UNLIT];s=u.getMaterialType(),c.push(u.extendParams(o,r,t))}else{let u=r.pbrMetallicRoughness||{};if(o.color=new He(1,1,1),o.opacity=1,Array.isArray(u.baseColorFactor)){let h=u.baseColorFactor;o.color.setRGB(h[0],h[1],h[2],Rn),o.opacity=h[3]}if(u.baseColorTexture!==void 0)c.push(t.assignTexture(o,"map",u.baseColorTexture,mr));if(o.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,o.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0)c.push(t.assignTexture(o,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(o,"roughnessMap",u.metallicRoughnessTexture));s=this._invokeOne(function(h){return h.getMaterialType&&h.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(h){return h.extendMaterialParams&&h.extendMaterialParams(e,o)})))}if(r.doubleSided===!0)o.side=Bn;let l=r.alphaMode||$d.OPAQUE;if(l===$d.BLEND)o.transparent=!0,o.depthWrite=!1;else if(o.transparent=!1,l===$d.MASK)o.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:0.5;if(r.normalTexture!==void 0&&s!==wi){if(c.push(t.assignTexture(o,"normalMap",r.normalTexture)),o.normalScale=new Be(1,1),r.normalTexture.scale!==void 0){let u=r.normalTexture.scale;o.normalScale.set(u,u)}}if(r.occlusionTexture!==void 0&&s!==wi){if(c.push(t.assignTexture(o,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0)o.aoMapIntensity=r.occlusionTexture.strength}if(r.emissiveFactor!==void 0&&s!==wi){let u=r.emissiveFactor;o.emissive=new He().setRGB(u[0],u[1],u[2],Rn)}if(r.emissiveTexture!==void 0&&s!==wi)c.push(t.assignTexture(o,"emissiveMap",r.emissiveTexture,mr));return Promise.all(c).then(function(){let u=new s(o);if(r.name)u.name=r.name;if(Ti(u,r),t.associations.set(u,{materials:e}),r.extensions)ts(i,u,r);return u})}createUniqueName(e){let t=ct.sanitizeNodeName(e||"");if(t in this.nodeNamesUsed)return t+"_"+ ++this.nodeNamesUsed[t];else return this.nodeNamesUsed[t]=0,t}loadGeometries(e){let t=this,n=this.extensions,i=this.primitiveCache;function r(o){return n[Qe.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(a){return gy(a,o,t)})}let s=[];for(let o=0,a=e.length;o<a;o++){let c=e[o],l=mC(c),u=i[l];if(u)s.push(u.promise);else{let h;if(c.extensions&&c.extensions[Qe.KHR_DRACO_MESH_COMPRESSION])h=r(c);else h=gy(new ln,c,t);if(c.mode===Hn.TRIANGLE_STRIP)h=h.then((d)=>Hd(d,$o));else if(c.mode===Hn.TRIANGLE_FAN)h=h.then((d)=>Hd(d,Us));i[l]={primitive:c,promise:h},s.push(h)}}return Promise.all(s)}loadMesh(e){let t=this,n=this.json,i=this.extensions,r=n.meshes[e],s=r.primitives,o=[];for(let a=0,c=s.length;a<c;a++){let l=s[a].material===void 0?dC(this.cache):this.getDependency("material",s[a].material);o.push(l)}return o.push(t.loadGeometries(s)),Promise.all(o).then(async function(a){let c=a.slice(0,a.length-1),l=a[a.length-1],u=[];for(let d=0,f=l.length;d<f;d++){let m=l[d],_=s[d],p,g=c[d];if(_.mode===Hn.TRIANGLES||_.mode===Hn.TRIANGLE_STRIP||_.mode===Hn.TRIANGLE_FAN||_.mode===void 0){let M=r.isSkinnedMesh===!0,T=m.hasAttribute("skinIndex")&&m.hasAttribute("skinWeight");if(M&&T===!1)console.warn("THREE.GLTFLoader: Missing skinIndex or skinWeight attributes. Skinning disabled.");if(p=M&&T?new Jc(m,g):new Mt(m,g),p.isSkinnedMesh===!0)p.normalizeSkinWeights()}else if(_.mode===Hn.LINES)p=new Qc(m,g);else if(_.mode===Hn.LINE_STRIP)p=new _r(m,g);else if(_.mode===Hn.LINE_LOOP)p=new el(m,g);else if(_.mode===Hn.POINTS)p=new Bs(m,g);else throw Error("THREE.GLTFLoader: Primitive mode unsupported: "+_.mode);if(Object.keys(p.geometry.morphAttributes).length>0)pC(p,r);if(p.name=t.createUniqueName(r.name||"mesh_"+e),Ti(p,r),_.extensions)ts(i,p,_);t.assignFinalMaterial(p),u.push(p)}for(let d=0,f=u.length;d<f;d++)t.associations.set(u[d],{meshes:e,primitives:d});if(u.length===1){if(r.extensions)ts(i,u[0],r);return u[0]}let h=new gi;if(r.extensions)ts(i,h,r);t.associations.set(h,{meshes:e});for(let d=0,f=u.length;d<f;d++)h.add(u[d]);return h})}loadCamera(e){let t,n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}if(n.type==="perspective")t=new Ht(Wo.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2000000);else if(n.type==="orthographic")t=new Qr(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar);if(n.name)t.name=this.createUniqueName(n.name);return Ti(t,n),Promise.resolve(t)}loadSkin(e){let t=this.json.skins[e],n=[];for(let i=0,r=t.joints.length;i<r;i++)n.push(this._loadNodeShallow(t.joints[i]));if(t.inverseBindMatrices!==void 0)n.push(this.getDependency("accessor",t.inverseBindMatrices));else n.push(null);return Promise.all(n).then(function(i){let r=i.pop(),s=i,o=[],a=[];for(let c=0,l=s.length;c<l;c++){let u=s[c];if(u){o.push(u);let h=new Xe;if(r!==null)h.fromArray(r.array,c*16);a.push(h)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new Ko(o,a)})}loadAnimation(e){let t=this.json,n=this,i=t.animations[e],r=i.name?i.name:"animation_"+e,s=[],o=[],a=[],c=[],l=[];for(let u=0,h=i.channels.length;u<h;u++){let d=i.channels[u],f=i.samplers[d.sampler],m=d.target,_=m.node,p=i.parameters!==void 0?i.parameters[f.input]:f.input,g=i.parameters!==void 0?i.parameters[f.output]:f.output;if(m.node===void 0)continue;s.push(this.getDependency("node",_)),o.push(this.getDependency("accessor",p)),a.push(this.getDependency("accessor",g)),c.push(f),l.push(m)}return Promise.all([Promise.all(s),Promise.all(o),Promise.all(a),Promise.all(c),Promise.all(l)]).then(function(u){let h=u[0],d=u[1],f=u[2],m=u[3],_=u[4],p=[];for(let M=0,T=h.length;M<T;M++){let v=h[M],S=d[M],E=f[M],R=m[M],x=_[M];if(v===void 0)continue;if(v.updateMatrix)v.updateMatrix();let w=n._createAnimationTracks(v,S,E,R,x);if(w)for(let H=0;H<w.length;H++)p.push(w[H])}let g=new Rs(r,void 0,p);return Ti(g,i),g})}createNodeMesh(e){let t=this.json,n=this,i=t.nodes[e];if(i.mesh===void 0)return null;return n.getDependency("mesh",i.mesh).then(function(r){let s=n._getNodeRef(n.meshCache,i.mesh,r);if(i.weights!==void 0)s.traverse(function(o){if(!o.isMesh)return;for(let a=0,c=i.weights.length;a<c;a++)o.morphTargetInfluences[a]=i.weights[a]});return s})}loadNode(e){let t=this.json,n=this,i=t.nodes[e],r=n._loadNodeShallow(e),s=[],o=i.children||[];for(let c=0,l=o.length;c<l;c++)s.push(n.getDependency("node",o[c]));let a=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([r,Promise.all(s),a]).then(function(c){let l=c[0],u=c[1],h=c[2];if(h!==null)l.traverse(function(d){if(!d.isSkinnedMesh)return;d.bind(h,_C)});for(let d=0,f=u.length;d<f;d++)l.add(u[d]);if(l.userData.pivot!==void 0&&u.length>0){let d=l.userData.pivot,f=u[0];l.pivot=new F().fromArray(d),l.position.x-=d[0],l.position.y-=d[1],l.position.z-=d[2],f.position.set(0,0,0),delete l.userData.pivot}return l})}_loadNodeShallow(e){let t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let r=t.nodes[e],s=r.name?i.createUniqueName(r.name):"",o=[],a=i._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});if(a)o.push(a);if(r.camera!==void 0)o.push(i.getDependency("camera",r.camera).then(function(c){return i._getNodeRef(i.cameraCache,r.camera,c)}));return i._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){o.push(c)}),this.nodeCache[e]=Promise.all(o).then(function(c){let l;if(r.isBone===!0)l=new qo;else if(c.length>1)l=new gi;else if(c.length===1)l=c[0];else l=new _t;if(l!==c[0])for(let u=0,h=c.length;u<h;u++)l.add(c[u]);if(r.name)l.userData.name=r.name,l.name=s;if(Ti(l,r),r.extensions)ts(n,l,r);if(r.matrix!==void 0){let u=new Xe;u.fromArray(r.matrix),l.applyMatrix4(u)}else{if(r.translation!==void 0)l.position.fromArray(r.translation);if(r.rotation!==void 0)l.quaternion.fromArray(r.rotation);if(r.scale!==void 0)l.scale.fromArray(r.scale)}if(!i.associations.has(l))i.associations.set(l,{});else if(r.mesh!==void 0&&i.meshCache.refs[r.mesh]>1){let u=i.associations.get(l);i.associations.set(l,{...u})}return i.associations.get(l).nodes=e,l}),this.nodeCache[e]}loadScene(e){let t=this.extensions,n=this.json.scenes[e],i=this,r=new gi;if(n.name)r.name=i.createUniqueName(n.name);if(Ti(r,n),n.extensions)ts(t,r,n);let s=n.nodes||[],o=[];for(let a=0,c=s.length;a<c;a++)o.push(i.getDependency("node",s[a]));return Promise.all(o).then(function(a){for(let l=0,u=a.length;l<u;l++){let h=a[l];if(h.parent!==null)r.add(hy(h));else r.add(h)}let c=(l)=>{let u=new Map;for(let[h,d]of i.associations)if(h instanceof yn||h instanceof Ot)u.set(h,d);return l.traverse((h)=>{let d=i.associations.get(h);if(d!=null)u.set(h,d)}),u};return i.associations=c(r),r})}_createAnimationTracks(e,t,n,i,r){let s=[],o=e.name?e.name:e.uuid,a=[];function c(d){if(d.morphTargetInfluences)a.push(d.name?d.name:d.uuid)}if(Mr[r.path]===Mr.weights){if(c(e),e.isGroup)e.children.forEach(c)}else a.push(o);let l;switch(Mr[r.path]){case Mr.weights:l=yr;break;case Mr.rotation:l=br;break;case Mr.translation:case Mr.scale:l=Jr;break;default:switch(n.itemSize){case 1:l=yr;break;case 2:case 3:default:l=Jr;break}break}let u=i.interpolation!==void 0?hC[i.interpolation]:Wc,h=this._getArrayFromAccessor(n);for(let d=0,f=a.length;d<f;d++){let m=new l(a[d]+"."+Mr[r.path],t.array,h,u);if(i.interpolation==="CUBICSPLINE")this._createCubicSplineTrackInterpolant(m);s.push(m)}return s}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let n=jd(t.constructor),i=new Float32Array(t.length);for(let r=0,s=t.length;r<s;r++)i[r]=t[r]*n;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){return new(this instanceof br?ky:Yd)(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function xC(e,t,n){let i=t.attributes,r=new Vt;if(i.POSITION!==void 0){let a=n.json.accessors[i.POSITION],{min:c,max:l}=a;if(c!==void 0&&l!==void 0){if(r.set(new F(c[0],c[1],c[2]),new F(l[0],l[1],l[2])),a.normalized){let u=jd(Xs[a.componentType]);r.min.multiplyScalar(u),r.max.multiplyScalar(u)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;let s=t.targets;if(s!==void 0){let a=new F,c=new F;for(let l=0,u=s.length;l<u;l++){let h=s[l];if(h.POSITION!==void 0){let d=n.json.accessors[h.POSITION],{min:f,max:m}=d;if(f!==void 0&&m!==void 0){if(c.setX(Math.max(Math.abs(f[0]),Math.abs(m[0]))),c.setY(Math.max(Math.abs(f[1]),Math.abs(m[1]))),c.setZ(Math.max(Math.abs(f[2]),Math.abs(m[2]))),d.normalized){let _=jd(Xs[d.componentType]);c.multiplyScalar(_)}a.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(a)}e.boundingBox=r;let o=new In;r.getCenter(o.center),o.radius=r.min.distanceTo(r.max)/2,e.boundingSphere=o}function gy(e,t,n){let i=t.attributes,r=[];function s(o,a){return n.getDependency("accessor",o).then(function(c){e.setAttribute(a,c)})}for(let o in i){let a=Xd[o]||o.toLowerCase();if(a in e.attributes)continue;r.push(s(i[o],a))}if(t.indices!==void 0&&!e.index){let o=n.getDependency("accessor",t.indices).then(function(a){e.setIndex(a)});r.push(o)}if(Ke.workingColorSpace!==Rn&&"COLOR_0"in i)console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${Ke.workingColorSpace}" not supported.`);return Ti(e,t),xC(e,t,n),Promise.all(r).then(function(){return t.targets!==void 0?fC(e,t.targets,n):e})}var Gy={type:"change"},Jd={type:"start"},Vy={type:"end"},_l=new gr,Hy=new zn,vC=Math.cos(70*Wo.DEG2RAD),Zt=new F,bn=2*Math.PI,mt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Kd=0.000001;class Qd extends dl{constructor(e,t=null){super(e,t);if(this.state=mt.NONE,this.target=new F,this.cursor=new F,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=0.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:hr.ROTATE,MIDDLE:hr.DOLLY,RIGHT:hr.PAN},this.touches={ONE:dr.ROTATE,TWO:dr.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle="auto",this._domElementKeyEvents=null,this._lastPosition=new F,this._lastQuaternion=new Yt,this._lastTargetPosition=new F,this._quat=new Yt().setFromUnitVectors(e.up,new F(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new sa,this._sphericalDelta=new sa,this._scale=1,this._panOffset=new F,this._rotateStart=new Be,this._rotateEnd=new Be,this._rotateDelta=new Be,this._panStart=new Be,this._panEnd=new Be,this._panDelta=new Be,this._dollyStart=new Be,this._dollyEnd=new Be,this._dollyDelta=new Be,this._dollyDirection=new F,this._mouse=new Be,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=bC.bind(this),this._onPointerDown=yC.bind(this),this._onPointerUp=SC.bind(this),this._onContextMenu=CC.bind(this),this._onMouseWheel=EC.bind(this),this._onKeyDown=TC.bind(this),this._onTouchStart=AC.bind(this),this._onTouchMove=RC.bind(this),this._onMouseDown=wC.bind(this),this._onMouseMove=MC.bind(this),this._interceptControlDown=IC.bind(this),this._interceptControlUp=PC.bind(this),this.domElement!==null)this.connect(this.domElement);this.update()}set cursorStyle(e){if(this._cursorStyle=e,e==="grab")this.domElement.style.cursor="grab";else this.domElement.style.cursor="auto"}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.state=mt.NONE,this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents();let e=this.domElement.getRootNode();e.removeEventListener("keydown",this._interceptControlDown,{capture:!0}),e.removeEventListener("keyup",this._interceptControlUp,{capture:!0}),this._controlActive=!1,this._pointers.length=0,this._pointerPositions={},this.domElement.style.touchAction="",this.domElement.style.cursor="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){if(this._domElementKeyEvents!==null)this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(Gy),this.update(),this.state=mt.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){let t=this.object.position;if(Zt.copy(t).sub(this.target),Zt.applyQuaternion(this._quat),this._spherical.setFromVector3(Zt),this.autoRotate&&this.state===mt.NONE)this._rotateLeft(this._getAutoRotationAngle(e));if(this.enableDamping)this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor;else this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi;let n=this.minAzimuthAngle,i=this.maxAzimuthAngle;if(isFinite(n)&&isFinite(i)){if(n<-Math.PI)n+=bn;else if(n>Math.PI)n-=bn;if(i<-Math.PI)i+=bn;else if(i>Math.PI)i-=bn;if(n<=i)this._spherical.theta=Math.max(n,Math.min(i,this._spherical.theta));else this._spherical.theta=this._spherical.theta>(n+i)/2?Math.max(n,this._spherical.theta):Math.min(i,this._spherical.theta)}if(this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0)this.target.addScaledVector(this._panOffset,this.dampingFactor);else this.target.add(this._panOffset);this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{let s=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=s!=this._spherical.radius}if(Zt.setFromSpherical(this._spherical),Zt.applyQuaternion(this._quatInverse),t.copy(this.target).add(Zt),this.object.lookAt(this.target),this.enableDamping===!0)this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor);else this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0);if(this.zoomToCursor&&this._performCursorZoom){let s=null;if(this.object.isPerspectiveCamera){let o=Zt.length();s=this._clampDistance(o*this._scale);let a=o-s;this.object.position.addScaledVector(this._dollyDirection,a),this.object.updateMatrixWorld(),r=!!a}else if(this.object.isOrthographicCamera){let o=new F(this._mouse.x,this._mouse.y,0);o.unproject(this.object);let a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=a!==this.object.zoom;let c=new F(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),s=Zt.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;if(s!==null)if(this.screenSpacePanning)this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(s).add(this.object.position);else if(_l.origin.copy(this.object.position),_l.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(_l.direction))<vC)this.object.lookAt(this.target);else Hy.setFromNormalAndCoplanarPoint(this.object.up,this.target),_l.intersectPlane(Hy,this.target)}else if(this.object.isOrthographicCamera){let s=this.object.zoom;if(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),s!==this.object.zoom)this.object.updateProjectionMatrix(),r=!0}if(this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>Kd||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Kd||this._lastTargetPosition.distanceToSquared(this.target)>Kd)return this.dispatchEvent(Gy),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0;return!1}_getAutoRotationAngle(e){if(e!==null)return bn/60*this.autoRotateSpeed*e;else return bn/60/60*this.autoRotateSpeed}_getZoomScale(e){let t=Math.abs(e*0.01);return Math.pow(0.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Zt.setFromMatrixColumn(t,0),Zt.multiplyScalar(-e),this._panOffset.add(Zt)}_panUp(e,t){if(this.screenSpacePanning===!0)Zt.setFromMatrixColumn(t,1);else Zt.setFromMatrixColumn(t,0),Zt.crossVectors(this.object.up,Zt);Zt.multiplyScalar(e),this._panOffset.add(Zt)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let i=this.object.position;Zt.copy(i).sub(this.target);let r=Zt.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/n.clientHeight,this.object.matrix),this._panUp(2*t*r/n.clientHeight,this.object.matrix)}else if(this.object.isOrthographicCamera)this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix);else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1}_dollyOut(e){if(this.object.isPerspectiveCamera||this.object.isOrthographicCamera)this._scale/=e;else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1}_dollyIn(e){if(this.object.isPerspectiveCamera||this.object.isOrthographicCamera)this._scale*=e;else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;let n=this.domElement.getBoundingClientRect(),i=e-n.left,r=t-n.top,{width:s,height:o}=n;this._mouse.x=i/s*2-1,this._mouse.y=-(r/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(bn*this._rotateDelta.x/t.clientHeight),this._rotateUp(bn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){if(this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0)this._dollyOut(this._getZoomScale(this._dollyDelta.y));else if(this._dollyDelta.y<0)this._dollyIn(this._getZoomScale(this._dollyDelta.y));this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){if(this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0)this._dollyIn(this._getZoomScale(e.deltaY));else if(e.deltaY>0)this._dollyOut(this._getZoomScale(e.deltaY));this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateUp(bn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(0,this.keyPanSpeed);t=!0;break;case this.keys.BOTTOM:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateUp(-bn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(0,-this.keyPanSpeed);t=!0;break;case this.keys.LEFT:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateLeft(bn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(this.keyPanSpeed,0);t=!0;break;case this.keys.RIGHT:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateLeft(-bn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(-this.keyPanSpeed,0);t=!0;break}if(t)e.preventDefault(),this.update()}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._rotateStart.set(n,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._panStart.set(n,i)}}_handleTouchStartDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){if(this.enableZoom)this._handleTouchStartDolly(e);if(this.enablePan)this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){if(this.enableZoom)this._handleTouchStartDolly(e);if(this.enableRotate)this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{let n=this._getSecondPointerPosition(e),i=0.5*(e.pageX+n.x),r=0.5*(e.pageY+n.y);this._rotateEnd.set(i,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(bn*this._rotateDelta.x/t.clientHeight),this._rotateUp(bn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._panEnd.set(n,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let s=(e.pageX+t.x)*0.5,o=(e.pageY+t.y)*0.5;this._updateZoomParameters(s,o)}_handleTouchMoveDollyPan(e){if(this.enableZoom)this._handleTouchMoveDolly(e);if(this.enablePan)this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){if(this.enableZoom)this._handleTouchMoveDolly(e);if(this.enableRotate)this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];if(t===void 0)t=new Be,this._pointerPositions[e.pointerId]=t;t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){let t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){let t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}if(e.ctrlKey&&!this._controlActive)n.deltaY*=10;return n}}function yC(e){if(this.enabled===!1)return;if(this._pointers.length===0)this.domElement.setPointerCapture(e.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp);if(this._isTrackingPointer(e))return;if(this._addPointer(e),e.pointerType==="touch")this._onTouchStart(e);else this._onMouseDown(e);if(this._cursorStyle==="grab")this.domElement.style.cursor="grabbing"}function bC(e){if(this.enabled===!1)return;if(e.pointerType==="touch")this._onTouchMove(e);else this._onMouseMove(e)}function SC(e){switch(this._removePointer(e),this._pointers.length){case 0:if(this.domElement.releasePointerCapture(e.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(Vy),this.state=mt.NONE,this._cursorStyle==="grab")this.domElement.style.cursor="grab";break;case 1:let t=this._pointers[0],n=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:n.x,pageY:n.y});break}}function wC(e){let t;switch(e.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case hr.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(e),this.state=mt.DOLLY;break;case hr.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=mt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=mt.ROTATE}break;case hr.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=mt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=mt.PAN}break;default:this.state=mt.NONE}if(this.state!==mt.NONE)this.dispatchEvent(Jd)}function MC(e){switch(this.state){case mt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(e);break;case mt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(e);break;case mt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(e);break}}function EC(e){if(this.enabled===!1||this.enableZoom===!1||this.state!==mt.NONE)return;e.preventDefault(),this.dispatchEvent(Jd),this._handleMouseWheel(this._customWheelEvent(e)),this.dispatchEvent(Vy)}function TC(e){if(this.enabled===!1)return;this._handleKeyDown(e)}function AC(e){switch(this._trackPointer(e),this._pointers.length){case 1:switch(this.touches.ONE){case dr.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(e),this.state=mt.TOUCH_ROTATE;break;case dr.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(e),this.state=mt.TOUCH_PAN;break;default:this.state=mt.NONE}break;case 2:switch(this.touches.TWO){case dr.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(e),this.state=mt.TOUCH_DOLLY_PAN;break;case dr.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(e),this.state=mt.TOUCH_DOLLY_ROTATE;break;default:this.state=mt.NONE}break;default:this.state=mt.NONE}if(this.state!==mt.NONE)this.dispatchEvent(Jd)}function RC(e){switch(this._trackPointer(e),this.state){case mt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(e),this.update();break;case mt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(e),this.update();break;case mt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(e),this.update();break;case mt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(e),this.update();break;default:this.state=mt.NONE}}function CC(e){if(this.enabled===!1)return;e.preventDefault()}function IC(e){if(e.key==="Control")this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}function PC(e){if(e.key==="Control")this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}class ef extends Fs{constructor(){super();this.name="RoomEnvironment",this.position.y=-3.5;let e=new xr;e.deleteAttribute("uv");let t=new $i({side:cn}),n=new $i,i=new Hs(16777215,900,28,2);i.position.set(0.418,16.199,0.3),this.add(i);let r=new Mt(e,t);r.position.set(-0.757,13.219,0.717),r.scale.set(31.713,28.305,28.591),this.add(r);let s=new ks(e,n,6),o=new _t;o.position.set(-10.906,2.009,1.846),o.rotation.set(0,-0.195,0),o.scale.set(2.328,7.905,4.651),o.updateMatrix(),s.setMatrixAt(0,o.matrix),o.position.set(-5.607,-0.754,-0.758),o.rotation.set(0,0.994,0),o.scale.set(1.97,1.534,3.955),o.updateMatrix(),s.setMatrixAt(1,o.matrix),o.position.set(6.167,0.857,7.803),o.rotation.set(0,0.561,0),o.scale.set(3.927,6.285,3.687),o.updateMatrix(),s.setMatrixAt(2,o.matrix),o.position.set(-2.017,0.018,6.124),o.rotation.set(0,0.333,0),o.scale.set(2.002,4.566,2.064),o.updateMatrix(),s.setMatrixAt(3,o.matrix),o.position.set(2.291,-0.756,-2.621),o.rotation.set(0,-0.286,0),o.scale.set(1.546,1.552,1.496),o.updateMatrix(),s.setMatrixAt(4,o.matrix),o.position.set(-2.193,-0.369,-5.547),o.rotation.set(0,0.516,0),o.scale.set(3.875,3.487,2.986),o.updateMatrix(),s.setMatrixAt(5,o.matrix),this.add(s);let a=new Mt(e,js(50));a.position.set(-16.116,14.37,8.208),a.scale.set(0.1,2.428,2.739),this.add(a);let c=new Mt(e,js(50));c.position.set(-16.109,18.021,-8.207),c.scale.set(0.1,2.425,2.751),this.add(c);let l=new Mt(e,js(17));l.position.set(14.904,12.198,-1.832),l.scale.set(0.15,4.265,6.331),this.add(l);let u=new Mt(e,js(43));u.position.set(-0.462,8.89,14.52),u.scale.set(4.38,5.441,0.088),this.add(u);let h=new Mt(e,js(20));h.position.set(3.235,11.486,-12.541),h.scale.set(2.5,2,0.1),this.add(h);let d=new Mt(e,js(100));d.position.set(0,20,0),d.scale.set(1,0.1,1),this.add(d)}dispose(){let e=new Set;this.traverse((t)=>{if(t.isMesh)e.add(t.geometry),e.add(t.material)});for(let t of e)t.dispose()}}function js(e){return new il({color:0,emissive:16777215,emissiveIntensity:e})}function $y(e,t,n=40,i=[e]){let r=e.getCenter(new F),s=Math.max(e.getSize(new F).length()/2,0.01),o=new F(1,0.65,1.25).normalize(),a=new F().crossVectors(new F(0,1,0),o).normalize(),c=new F().crossVectors(o,a),l=[];for(let M of i.length?i:[e])for(let T of[M.min.x,M.max.x])for(let v of[M.min.y,M.max.y])for(let S of[M.min.z,M.max.z])l.push(new F(T,v,S));let u=1/0,h=-1/0,d=1/0,f=-1/0;for(let M of l){let T=M.clone().sub(r),v=T.dot(a),S=T.dot(c);u=Math.min(u,v),h=Math.max(h,v),d=Math.min(d,S),f=Math.max(f,S)}r.addScaledVector(a,(u+h)/2),r.addScaledVector(c,(d+f)/2);let m=Math.tan(n*Math.PI/360),_=m*t,p=s;for(let M of l){let T=M.clone().sub(r),v=T.dot(o);p=Math.max(p,v+Math.abs(T.dot(a))*1.12/_,v+Math.abs(T.dot(c))*1.12/m)}let g=r.clone().addScaledVector(o,p);return{center:r,radius:s,distance:p,position:g}}function tf(e,t){return{position:e.position.clone(),target:t.clone()}}function nf(e,t,n,i){e.position.copy(n.position),t.copy(n.target);let r=Math.max(i.getSize(new F).length(),0.001);e.near=Math.min(0.01,Math.max(r/1e5,0.00001)),e.far=Math.max(e.position.distanceTo(i.getCenter(new F))+r*20,10),e.updateProjectionMatrix()}function Wy(e,t,n){let i=e.getWorldDirection(new F);if(i.y=0,i.lengthSq()<0.00000001)i.set(0,0,-1);i.normalize();let r=i.clone().cross(new F(0,1,0)),s=new F;if(t.has("KeyW")||t.has("ArrowUp"))s.add(i);if(t.has("KeyS")||t.has("ArrowDown"))s.sub(i);if(t.has("KeyD")||t.has("ArrowRight"))s.add(r);if(t.has("KeyA")||t.has("ArrowLeft"))s.sub(r);if(t.has("KeyE"))s.y++;if(t.has("KeyQ"))s.y--;return s.normalize().multiplyScalar(n)}function Zy(e){let t=e.filter((i)=>Number.isFinite(i)&&i>0).sort((i,r)=>i-r);if(!t.length)throw Error("No frame timing evidence was collected.");let n=(i)=>t[Math.max(0,Math.ceil(t.length*i)-1)];return{samples:t.length,min:t[0],p50:n(0.5),p95:n(0.95),max:t.at(-1)}}async function Xy(e,t){let n=t();if(n===void 0)throw Error("Wait for the selected artifact to be loaded before measuring.");let i=JSON.stringify(n),r=await e();if(JSON.stringify(t())!==i)throw Error("The artifact changed during measurement. Measure the loaded revision again.");return{...r,artifact:n}}function jy(e,t,n){if(t())return e;n(e);return}function xl(e,t){let n=e.parser.json.nodes??[],i=new Set;if(n.forEach((s,o)=>{if(s?.extensions?.KHR_node_visibility?.visible===!1)i.add(o)}),i.size===0)return 0;let r=0;for(let s of t)s.traverse((o)=>{let a=e.parser.associations.get(o)?.nodes;if(a===void 0||!i.has(a))return;o.visible=!1,r++});return r}function vl(e){let t=!1;if(e.traverse((s)=>{if(!s.visible)t=!0}),!t)return new Vt().setFromObject(e,!0);e.updateWorldMatrix(!0,!0);let n=new Vt,i=new Vt,r=new F;return e.traverseVisible((s)=>{let o=s,a=o.geometry;if(!a)return;let c=a.getAttribute("position");if(c&&o.isInstancedMesh!==!0){for(let u=0;u<c.count;u++){if(o.isMesh)o.getVertexPosition(u,r);else r.fromBufferAttribute(c,u);n.expandByPoint(r.applyMatrix4(s.matrixWorld))}return}let l=s;if(l.boundingBox!==void 0){if(l.boundingBox===null)l.computeBoundingBox();i.copy(l.boundingBox)}else{if(a.boundingBox===null)a.computeBoundingBox();i.copy(a.boundingBox)}n.union(i.applyMatrix4(s.matrixWorld))}),n.isEmpty()?new Vt().setFromObject(e,!0):n}function da(e){let t=0;return e.traverseVisible((n)=>{let i=n;if(!i.isMesh)return;let r=i.geometry.index?.count??i.geometry.attributes.position?.count??0;t+=r/3*(i.isInstancedMesh?i.count:1)}),t}async function qy(e){let t=e.parser.json.nodes??[],n=new Map;e.scene.traverse((c)=>{let l=e.parser.associations.get(c)?.nodes;if(l!==void 0&&!n.has(l))n.set(l,c)});let i=new Set,r=[];for(let[c,l]of n){let u=t[c]?.extensions?.MSFT_lod?.ids;if(!Array.isArray(u)||u.length===0)continue;if(u.some((m)=>!Number.isInteger(m)||!t[m]||n.has(m)))continue;let h=l.parent;while(h&&!i.has(h))h=h.parent;if(h)continue;let d=[l];for(let m of u)d.push(await e.parser.getDependency("node",m));xl(e,d.slice(1)),i.add(l);let f=(l.name.replace(/[_ -]?LOD0$/i,"")||l.parent?.name||`Part ${c}`).replace(/^Mesh_/,"");r.push({id:String(c),label:f,levels:d})}if(r.length===0)return;let s=da(e.scene)-r.reduce((c,l)=>c+rf(l,0),0),o=Math.max(...r.map((c)=>c.levels.length)),a=Array.from({length:o},(c,l)=>s+r.reduce((u,h)=>u+rf(h,l),0));return{chains:r,triangles:a}}var Yy=(e,t)=>e.levels[Math.min(Math.max(Number.isFinite(t)?Math.floor(t):0,0),e.levels.length-1)];function rf(e,t){let n=e.levels.find((i)=>i.parent)?.parent;while(n){if(!n.visible)return 0;n=n.parent}return da(Yy(e,t))}function Ky(e,t){let n=Yy(e,t),i=e.levels.find((s)=>s.parent!==null);if(!i||i===n)return;let r=i.parent;r.children[r.children.indexOf(i)]=n,n.parent=r,i.parent=null}function Jy(e,t){for(let n of e.chains)Ky(n,t)}function Qy(e,t,n){let i=e.chains.find((r)=>r.id===t);if(!i)return!1;return Ky(i,n),!0}function eb(e,t){if(!e)return;return{triangles:da(t),levels:e.triangles,chains:e.chains.map((n)=>({id:n.id,label:n.label,level:n.levels.findIndex((i)=>i.parent!==null),triangles:n.levels.map((i,r)=>rf(n,r))}))}}function fa(e){return(e?.chains??[]).flatMap((t)=>t.levels.filter((n)=>n.parent===null))}function sf(e){return e.map((t,n)=>`LOD${n} · ${t.toLocaleString()} triangles`)}function pa(e){let t=new Gd({antialias:!0,alpha:!1});t.setPixelRatio(Math.min(devicePixelRatio,2)),t.setClearColor(1382930),t.toneMapping=Go,t.toneMappingExposure=1.15,e.replaceChildren(t.domElement);let n=new Fs,i=new Ht(40,1,0.01,1000),r=new Qd(i,t.domElement);r.enableDamping=!0,t.domElement.tabIndex=0,t.domElement.setAttribute("aria-label","Interactive 3D asset. Drag to orbit or use Explore navigation.");let s=new Set,o=!1,a=1,c=new Set(["KeyW","KeyA","KeyS","KeyD","KeyQ","KeyE","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","ShiftLeft","ShiftRight"]),l=(W)=>{if(!o||!c.has(W.code))return;W.preventDefault(),s.add(W.code)},u=(W)=>s.delete(W.code),h=()=>s.clear();t.domElement.addEventListener("keydown",l),t.domElement.addEventListener("keyup",u),t.domElement.addEventListener("blur",h);let d=new ua(t),f=new ef,m=d.fromScene(f,0.04);n.environment=m.texture,f.dispose(),d.dispose();let _=new Vs(16773591,2.4);_.position.set(4,8,5),n.add(_),n.add(new al(14806490,5065021,1.7));let p,g,M,T=[],v=!0,S=performance.now(),E=0,R=0,x=!1,w,H,C,N=(W)=>{if(!C)return;clearTimeout(C.timeout),C.reject(Error(W)),C=void 0},ee=(W)=>{let B=t.getContext(),Y=B.getExtension("WEBGL_debug_renderer_info");return{version:"kiln.viewer-performance.v1",measuredAt:new Date().toISOString(),windowMs:W-C.started,frameMs:Zy(C.samples),...H===void 0?{}:{loadToFirstFrameMs:H},drawCalls:t.info.render.calls,triangles:t.info.render.triangles,lines:t.info.render.lines,points:t.info.render.points,geometryObjects:t.info.memory.geometries,textureObjects:t.info.memory.textures,shaderPrograms:t.info.programs?.length??0,viewport:{cssWidth:e.clientWidth,cssHeight:e.clientHeight,bufferWidth:t.domElement.width,bufferHeight:t.domElement.height,devicePixelRatio:t.getPixelRatio()},renderer:{version:String(B.getParameter(B.VERSION)),vendor:String(B.getParameter(B.VENDOR)),renderer:String(B.getParameter(B.RENDERER)),browser:navigator.userAgent,...Y?{unmaskedVendor:String(B.getParameter(Y.UNMASKED_VENDOR_WEBGL)),unmaskedRenderer:String(B.getParameter(Y.UNMASKED_RENDERER_WEBGL))}:{}},camera:{position:i.position.toArray(),target:r.target.toArray(),fov:i.fov},limitations:["Exploratory measurement: workloads outside this page are uncontrolled. This is not an isolated performance baseline or budget acceptance.","Frame intervals measure browser requestAnimationFrame pacing, including scheduling and vertical sync; they are not GPU execution time.","Load-to-first-frame begins at GLB parsing and ends after the first render submission; it excludes download time and does not measure presentation latency.","Draw and resource counts come from this Three.js renderer, including studio lighting resources. Object counts are not GPU memory bytes.","This receipt describes this viewport, camera and device only. It is not a performance qualification for other consumers or hardware."]}},P=(W)=>{let B=new Set,Y=new Set,K=new Set;W.traverse((ge)=>{let de=ge;if(!de.isMesh)return;B.add(de.geometry);for(let fe of Array.isArray(de.material)?de.material:[de.material]){Y.add(fe);for(let he of Object.values(fe))if(he instanceof Ot)K.add(he)}});for(let ge of[...B,...Y,...K])ge.dispose()},Z=()=>{if(!p)return;let W=vl(p),B=[];p.traverseVisible((fe)=>{if(fe instanceof Mt||fe instanceof _r||fe instanceof Bs){let he=new Vt().setFromObject(fe,!0);if(!he.isEmpty())B.push(he)}});let{center:Y,radius:K,distance:ge,position:de}=$y(W,i.aspect,i.fov,B);if(r.target.copy(Y),i.position.copy(de),i.near=Math.max(K/1000,0.0001),i.far=ge+K*100,r.minDistance=K*0.1,r.maxDistance=K*80,a=Math.max(K*0.35,0.01),o)r.minDistance=K*0.00001;i.updateProjectionMatrix(),r.update()},G=new ResizeObserver(()=>{let{clientWidth:W,clientHeight:B}=e;if(!W||!B)return;t.setSize(W,B),i.aspect=W/B,i.updateProjectionMatrix()});G.observe(e);let k=(W)=>{if(x)return;let B=Math.min((W-S)/1000,0.1);if(S=W,e.clientWidth&&e.clientHeight){if(v)M?.update(B);if(o&&s.size){let Y=Wy(i,s,B*a*(s.has("ShiftLeft")||s.has("ShiftRight")?3:1));i.position.add(Y),r.target.add(Y)}if(r.update(),t.render(n,i),w!==void 0)H=performance.now()-w,w=void 0;if(C){if(C.previous>0&&C.samples.length<1800)C.samples.push(W-C.previous);if(C.previous=W,W-C.started>=C.duration&&C.samples.length){let Y=ee(W);clearTimeout(C.timeout),C.resolve(Y),C=void 0}}}else s.clear(),N("Keep the measured viewport visible for the complete sampling window.");E=requestAnimationFrame(k)};return E=requestAnimationFrame(k),{async load(W,B={}){let Y=performance.now(),K=++R;N("The artifact changed during measurement. Measure the new revision again."),zu(W);let ge=new na;ge.setURLModifier((ae)=>{if(!ae.startsWith("blob:")&&!ae.startsWith("data:"))throw Error("External model resources are not loaded");return ae});let de=await new qd(ge).parseAsync(Uint8Array.from(W).buffer,"");xl(de,[de.scene]);let fe=await qy(de),he=jy(de,()=>!x&&K===R&&B.isCurrent?.()!==!1,(ae)=>{P(ae.scene);for(let ke of fa(fe))P(ke)});if(!he)return;let I=p&&B.preserveView?tf(i,r.target):void 0;if(p){M?.stopAllAction(),M?.uncacheRoot(p),n.remove(p),P(p);for(let ae of fa(g))P(ae)}p=he.scene,g=fe,w=Y,H=void 0,n.add(p),T=he.animations,M=new hl(p),v=!0;let{clientWidth:V,clientHeight:q}=e;if(t.setSize(V,q),i.aspect=V&&q?V/q:i.aspect,Z(),I)nf(i,r.target,I,vl(p)),r.update();let se=0,ce=new Set;return p.traverseVisible((ae)=>{let ke=ae;if(!ke.isMesh)return;se++;for(let Ce of Array.isArray(ke.material)?ke.material:[ke.material])ce.add(Ce)}),B.onCommit?.(),{triangles:da(p),meshes:se,materials:ce.size,clips:T.map((ae)=>ae.name),...g?{levels:g.triangles}:{}}},level(W){if(N("The level of detail changed. Measure the displayed combination again."),g)Jy(g,W)},partLevel(W,B){if(N("The level of detail changed. Measure the displayed combination again."),g)Qy(g,W,B)},lod(){return p?eb(g,p):void 0},reset:Z,cancelMeasurement:N,measure(W=3000){if(x||!p||!e.clientWidth||!e.clientHeight)return Promise.reject(Error("Load an artifact in a visible viewport before measuring."));if(!Number.isFinite(W)||W<1000||W>5000)return Promise.reject(Error("Measurement duration must be 1–5 seconds."));if(C)return Promise.reject(Error("A measurement is already running."));return new Promise((B,Y)=>{C={started:performance.now(),previous:0,duration:W,samples:[],resolve:B,reject:Y,timeout:setTimeout(()=>N("Measurement was interrupted or the browser stopped delivering frames."),W+2000)}})},view(){return tf(i,r.target)},setView(W){if(!p)return;nf(i,r.target,W,vl(p)),r.update()},navigation(W){if(o=W==="explore",s.clear(),r.minDistance=o?0.00001:a/3.5,o)i.near=0.0001,i.updateProjectionMatrix()},wire(W){for(let B of p?[p,...fa(g)]:[])B.traverse((Y)=>{let K=Y;if(K.isMesh){for(let ge of Array.isArray(K.material)?K.material:[K.material])if("wireframe"in ge)ge.wireframe=W}})},lighting(W){t.toneMappingExposure=W==="bright"?1.65:W==="soft"?0.85:1.15,_.intensity=W==="soft"?0.8:2.4},clip(W){if(M?.stopAllAction(),T[W])M?.clipAction(T[W]).play()},pause(W){v=!W},dispose(){if(N("The viewport closed before measurement finished."),x=!0,R++,cancelAnimationFrame(E),G.disconnect(),r.dispose(),t.domElement.removeEventListener("keydown",l),t.domElement.removeEventListener("keyup",u),t.domElement.removeEventListener("blur",h),p)P(p);for(let W of fa(g))P(W);m.dispose(),t.dispose(),e.replaceChildren()}}}var oe=(e)=>document.getElementById(e);function L(e,t,n){let i=document.createElement(e);if(t!==void 0)i.textContent=t;if(n)i.className=n;return i}function hn(e){let t=oe("dashboard-status");t.textContent=e instanceof Error?e.message:String(e),t.hidden=!t.textContent}async function Xt(e,t){let n=await fetch(e,t?{method:t.method,headers:{"Content-Type":"application/json"},body:JSON.stringify(t.body)}:void 0),i=await n.json();if(!n.ok)throw Error(i.error??`Request failed (${n.status})`);return i}function qs(e,t){let n=L("div",void 0,"empty");return n.append(L("b",e),L("p",t)),n}function ri(e,t){try{localStorage.setItem(e,t)}catch{}}function Er(e){try{return localStorage.getItem(e)}catch{return null}}function Qt(e){return e?e.slice(0,15):"Unspecified"}function Ys(e,t){let n=L("details",void 0,"record-details");return n.append(L("summary",e),L("pre",JSON.stringify(t,null,2))),n}function ma(e,t,n,i){let r=n.lod();if(e.hidden=!r,t.hidden=!r,t.replaceChildren(),e.replaceChildren(),e.onchange=null,!r)return;e.append(...sf(r.levels).map((l,u)=>new Option(l,String(u))));let s=new Option("Mixed part levels","mixed");s.disabled=!0,e.append(s);let o=L("p","","lod-total");o.setAttribute("role","status"),t.append(o);let a=new Map;if(r.chains.length>1){let l=L("details",void 0,"lod-parts");l.append(L("summary","Per-part levels")),l.append(L("p","Choose a level for each part. The main selector sets every part to the same index.","subtle"));let u=L("div",void 0,"lod-part-fields"),h=new Set(r.chains.filter((d,f,m)=>m.findIndex((_)=>_.label===d.label)!==f).map((d)=>d.label));for(let[d,f]of r.chains.entries()){let m=h.has(f.label)?`${f.label} (part ${d+1})`:f.label,_=L("label",m,"inline-field"),p=L("select");p.setAttribute("aria-label",`${m} level of detail`),p.append(...sf(f.triangles).map((g,M)=>new Option(g,String(M)))),p.onchange=()=>{n.partLevel(f.id,Number(p.value)),c(),i?.()},a.set(f.id,p),_.append(p),u.append(_)}l.append(u),t.append(l)}function c(){let l=n.lod();if(!l)return;let u=l.levels.findIndex((h,d)=>l.chains.every((f)=>f.level===Math.min(d,f.triangles.length-1)));e.value=u<0?"mixed":String(u),o.textContent=`${l.triangles.toLocaleString()} triangles displayed`;for(let h of l.chains){let d=a.get(h.id);if(d)d.value=String(h.level)}}return e.onchange=()=>{if(e.value==="mixed")return;let l=Number(e.value);n.level(l),c(),i?.(l)},c(),{refresh:c}}var tb=/^[a-z][a-z0-9_-]{0,79}$/u,LC=/^r_[a-z0-9_-]{1,77}$/u;function nb(e){let t=new URLSearchParams(e),n=t.get("collection"),i=t.get("asset"),r=t.get("revision");if(!n||!i||!r||!tb.test(n)||!tb.test(i)||!LC.test(r))return;return{collection:n,assetId:i,revisionId:r}}var ib=new TextEncoder,NC=new TextDecoder,Ks=(e)=>e!==null&&typeof e==="object"&&!Array.isArray(e),of=(e,t)=>Object.hasOwn(e,t);async function rb(e){let t=await crypto.subtle.digest("SHA-256",Uint8Array.from(e));return`sha256:${Array.from(new Uint8Array(t),(n)=>n.toString(16).padStart(2,"0")).join("")}`}function DC(e){if(e.length>200||!/^[a-z0-9][a-z0-9._-]*\.kiln-metadata\.json$/i.test(e)||/^(con|prn|aux|nul|com[0-9]|lpt[0-9])\./i.test(e))throw Error("Runtime metadata filename must be a portable sibling *.kiln-metadata.json filename")}async function sb(e,t={}){let n=t.profile??"editable";if(n!=="editable"&&n!=="runtime")throw Error("Unknown export profile");oc(e);let i=e.files["asset.glb"];if(n==="editable")return{profile:n,glb:i};let r=t.metadataFileName??"runtime.kiln-metadata.json";DC(r);for(let[M,T]of Object.entries(e.files))if(await rb(T)!==e.manifest.files[M].sha256)throw Error(`Asset integrity mismatch: ${M}`);let s=new DataView(i.buffer,i.byteOffset,i.byteLength),o=12;while(o<i.length){if(o+8>i.length)throw Error("Invalid GLB chunk header");let M=s.getUint32(o,!0);if(M%4||o+8+M>i.length)throw Error("Invalid GLB chunk length");o+=8+M}let a=20+s.getUint32(12,!0),c=JSON.parse(NC.decode(i.subarray(20,a)));if(!Ks(c)||!Ks(c.asset)||c.asset.version!=="2.0")throw Error("Invalid glTF asset");let l=c.asset;if(of(l,"extras")&&!Ks(l.extras))throw Error("Cannot add provenance to non-object asset extras");let u=l.extras??{};if(of(u,"kilnProvenanceV1"))throw Error("Asset extras already contain kilnProvenanceV1; export from the canonical revision");let h=[];if(c.scenes!==void 0&&!Array.isArray(c.scenes))throw Error("Invalid glTF scenes");for(let[M,T]of(c.scenes??[]).entries()){if(!Ks(T)||!Ks(T.extras)||!of(T.extras,"kilnReviewClipsV1"))continue;let v=T.extras.kilnReviewClipsV1;if(!Ks(v)||v.version!==1&&v.version!==2||!Array.isArray(v.clips))throw Error("Unsupported scenes[].extras.kilnReviewClipsV1");h.push({index:M,kilnReviewClipsV1:v}),delete T.extras.kilnReviewClipsV1}let d={version:"kiln.runtime-metadata.v1",source:{assetId:e.manifest.assetId,revisionId:e.manifest.revisionId,glbSha256:e.manifest.files["asset.glb"].sha256,...e.manifest.files["source.kiln.js"]?{sourceSha256:e.manifest.files["source.kiln.js"].sha256}:{}},scenes:h},f=ib.encode(JSON.stringify(d));l.extras={...u,kilnProvenanceV1:{version:"kiln.provenance.v1",profile:"runtime",metadata:{uri:r,sha256:await rb(f)}}};let m=ib.encode(JSON.stringify(c)),_=Math.ceil(m.length/4)*4,p=new Uint8Array(20+_+i.length-a);if(p.length>Un||f.length>Un)throw Error("Runtime export exceeds 64 MiB");p.set(i.subarray(0,20));let g=new DataView(p.buffer);return g.setUint32(8,p.length,!0),g.setUint32(12,_,!0),p.fill(32,20,20+_),p.set(m,20),p.set(i.subarray(a),20+_),{profile:n,glb:p,metadata:{name:r,bytes:f}}}var si=Fe().regex(/^[a-z][a-z0-9_-]{0,79}$/).refine((e)=>!/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/.test(e),"Reserved filesystem name"),af=Fe().regex(/^r_[0-9]{10}_[a-f0-9]{64}$/),cb=Fe().regex(/^sha256:[a-f0-9]{64}$/),Js=Fe().max(4000),lb=Fe().regex(/^[a-zA-Z0-9][a-zA-Z0-9_.:/-]{0,199}$/),ob=qe({collectionId:si,assetId:si,revisionId:si}).strict(),ab=qe({style:Js.default(""),scale:Fe().max(1000).default(""),palette:wt(qe({role:Fe().min(1).max(100),color:Fe().regex(/^#[a-fA-F0-9]{6}$/)}).strict()).max(64).default([]),materialRoles:wt(qe({role:Fe().min(1).max(100),description:Js.default(""),resourceId:lb.optional()}).strict()).max(128).default([]),conventions:wt(Fe().max(1000)).max(100).default([]),exceptions:wt(Fe().max(1000)).max(100).default([])}).strict(),OC=qe({resourceId:lb,revisionId:Fe().min(1).max(200),sha256:cb,role:Fe().max(100).optional()}).strict(),UC=wt(OC).max(512),Ai={name:Fe().trim().min(1).max(200),brief:Fe().max(16000).default(""),design:ab.default(()=>ab.parse({})),inventory:wt(qe({id:si,name:Fe().trim().min(1).max(200),kind:pn(["asset","environment"]).default("asset"),brief:Js.default(""),references:wt(si).max(64).default([]),asset:ob.optional()}).strict()).max(1000).default([]),deliveryProfiles:wt(qe({id:si,target:pn(["three","godot","unity","unreal","roblox","sbox","usdz","custom"]),description:Js.default(""),performanceIntent:Fe().max(1000).default(""),constraints:wt(Fe().max(1000)).max(100).default([])}).strict()).max(32).default([]),materialDependencies:UC.default([]),references:wt(qe({id:si,title:Fe().min(1).max(200),uri:Fe().min(1).max(2048),description:Js.default(""),sha256:cb.optional()}).strict()).max(256).default([]),reviews:wt(qe({id:si,inventoryId:si,projectRevisionId:af,asset:ob,reviewer:Fe().trim().min(1).max(200),verdict:pn(["comment","changes-requested","accepted"]),notes:Js}).strict()).max(2000).default([])};function ub(e,t){let n=(o,a)=>{if(new Set(o).size!==o.length)t.addIssue({code:nc.custom,path:[a],message:"Duplicate identity"})};n(e.inventory.map((o)=>o.id),"inventory"),n(e.references.map((o)=>o.id),"references"),n(e.deliveryProfiles.map((o)=>o.id),"deliveryProfiles"),n(e.materialDependencies.map((o)=>o.resourceId),"materialDependencies"),n(e.reviews.map((o)=>o.id),"reviews"),n(e.design.palette.map((o)=>o.role),"design.palette"),n(e.design.materialRoles.map((o)=>o.role),"design.materialRoles");let i=new Set(e.references.map((o)=>o.id)),r=new Set(e.inventory.map((o)=>o.id)),s=new Set(e.materialDependencies.map((o)=>o.resourceId));for(let o of e.inventory)if(n(o.references,`inventory.${o.id}.references`),o.references.some((a)=>!i.has(a)))t.addIssue({code:nc.custom,path:["inventory"],message:"Unknown reference"});if(e.reviews.some((o)=>!r.has(o.inventoryId)))t.addIssue({code:nc.custom,path:["reviews"],message:"Unknown inventory item"});if(e.design.materialRoles.some((o)=>o.resourceId&&!s.has(o.resourceId)))t.addIssue({code:nc.custom,path:["design"],message:"Material role requires a locked resource"})}var hb=qe({projectId:si.optional(),...Ai}).strict().superRefine(ub),OO=qe({name:Ai.name.optional(),brief:Ai.brief.removeDefault().optional(),design:Ai.design.removeDefault().optional(),inventory:Ai.inventory.removeDefault().optional(),deliveryProfiles:Ai.deliveryProfiles.removeDefault().optional(),materialDependencies:Ai.materialDependencies.removeDefault().optional(),references:Ai.references.removeDefault().optional(),reviews:Ai.reviews.removeDefault().optional()}).strict(),UO=qe({version:jt("kiln.project.v1"),projectId:si,revisionId:af,parentRevision:af.optional(),createdAt:Fe().datetime(),...Ai}).strict().superRefine(ub);function db(e){let{palette:t,materialRoles:n,conventions:i,exceptions:r}=e.design??{};return{design:{palette:t??[],materialRoles:n??[],conventions:i??[],exceptions:r??[]},inventory:e.inventory??[],deliveryProfiles:e.deliveryProfiles??[],materialDependencies:e.materialDependencies??[],references:e.references??[],reviews:e.reviews??[]}}function fb(e,t){let n=JSON.parse(e);if(!n||typeof n!=="object"||Array.isArray(n))throw Error("Project configuration must be a JSON object.");let i=n,r=i.design??{};if(!r||typeof r!=="object"||Array.isArray(r))throw Error("Design configuration must be a JSON object.");return hb.parse({...i,name:t.name,brief:t.brief,design:{...r,style:t.style,scale:t.scale}})}function pb(e){let t=[],n=Er("kiln.project")??"",i,r=()=>{let c=oe("project-list");c.replaceChildren();for(let T of t){let v=L("button",void 0,T.projectId===n?"active":"");if(v.append(L("strong",T.name),L("small",`${T.inventory.length} inventory items · ${T.materialDependencies.length} resources`)),T.projectId===n)v.setAttribute("aria-current","true");v.onclick=()=>{n=T.projectId,ri("kiln.project",n),r()},c.append(v)}let l=t.find((T)=>T.projectId===n),u=oe("project-detail");if(u.replaceChildren(),!l){u.append(qs("A direction for what comes next.","Projects are optional. Group related assets, materials and design decisions here, or build and review standalone assets in Library and Live Review."));return}let h=L("div",void 0,"project-summary"),d=L("div");d.append(L("h2",l.name),L("p",l.brief||"Add a brief to describe what this project should deliver."));let f=L("button","Edit project","secondary");f.onclick=()=>o(l),h.append(d,f),u.append(h);let m=L("p",`${l.projectId} · ${Qt(l.revisionId)} · ${new Date(l.createdAt).toLocaleString()}`,"mono");u.append(m);let _=L("div",void 0,"project-metrics");for(let[T,v]of[[l.inventory.length,"inventory items"],[l.materialDependencies.length,"locked resources"],[l.deliveryProfiles.length,"delivery profiles"]]){let S=L("div");S.append(L("strong",String(T)),L("span",String(v))),_.append(S)}u.append(_);let p=L("div",void 0,"profile-grid");for(let[T,v]of[["Visual direction",l.design.style||"Not specified"],["Scale",l.design.scale||"Not specified"]]){let S=L("div");S.append(L("span",T,"label"),L("p",v)),p.append(S)}u.append(p);let g=L("div",void 0,"palette");for(let T of l.design.palette){let v=L("div",void 0,"swatch"),S=document.createElementNS("http://www.w3.org/2000/svg","svg");S.setAttribute("viewBox","0 0 24 24"),S.setAttribute("aria-hidden","true");let E=document.createElementNS("http://www.w3.org/2000/svg","rect");E.setAttribute("width","24"),E.setAttribute("height","24"),E.setAttribute("fill",T.color),S.append(E);let R=L("span",T.role);R.append(L("small",T.color)),v.append(S,R),g.append(v)}if(g.childElementCount)u.append(g);for(let[T,v]of[["Conventions",l.design.conventions],["Declared exceptions",l.design.exceptions]]){if(!v.length)continue;u.append(L("h3",T));let S=L("ul",void 0,"subtle");for(let E of v)S.append(L("li",E));u.append(S)}if(u.append(L("h3","Inventory")),!l.inventory.length)u.append(L("p","No inventory yet. Add deliberate asset and environment entries in the project configuration.","subtle"));else{let T=L("div",void 0,"table-wrap"),v=L("table"),S=L("thead"),E=L("tr");for(let x of["Item","Kind","Saved revision","Review"])E.append(L("th",x));S.append(E),v.append(S);let R=L("tbody");for(let x of l.inventory){let w=L("tr"),H=L("td",x.name);H.append(L("small",x.brief));let C=L("td"),N=L("td");if(x.asset){let ee=L("button",Qt(x.asset.revisionId),"secondary");ee.onclick=()=>e.openAsset(x.asset),C.append(ee);let P=[...l.reviews].reverse().find((G)=>G.inventoryId===x.id&&G.asset.revisionId===x.asset.revisionId&&G.asset.assetId===x.asset.assetId&&G.asset.collectionId===x.asset.collectionId);N.append(L("small",P?`${P.verdict} · ${P.reviewer}`:"Unreviewed"));let Z=L("button","Record review","secondary");Z.onclick=()=>a(l,x),N.append(Z)}else C.textContent="Not linked",N.textContent="No saved revision";w.append(H,L("td",x.kind),C,N),R.append(w)}v.append(R),T.append(v),u.append(T)}if(l.design.materialRoles.length){u.append(L("h3","Material roles"));for(let T of l.design.materialRoles)u.append(L("p",`${T.role}: ${T.description||"No description"}${T.resourceId?` · ${T.resourceId}`:" · No resource assigned"}`,"subtle"))}if(l.deliveryProfiles.length){u.append(L("h3","Delivery intent"));for(let T of l.deliveryProfiles){if(u.append(L("p",`${T.target} · ${T.description||T.id}`,"subtle")),T.performanceIntent)u.append(L("p",T.performanceIntent,"subtle"));for(let v of T.constraints)u.append(L("p",v,"subtle"))}u.append(L("p","Declared targets are project intent. They do not establish consumer or performance qualification.","subtle"))}if(l.references.length){u.append(L("h3","Reference records"));for(let T of l.references){let v=L("p",`${T.title}: ${T.uri}`,"subtle");if(T.description)v.append(L("small",` · ${T.description}`));u.append(v)}}u.append(L("h3","Project downloads"));let M=L("div",void 0,"downloads");for(let T of["editable","runtime"]){let v=L("a",T==="editable"?"Download editable project bundle":"Download runtime project bundle"),S=new URLSearchParams({profile:T,revision:l.revisionId});v.href=`/api/projects/${encodeURIComponent(l.projectId)}/bundle?${S}`,v.download=`${l.projectId}-${T}.zip`,M.append(v)}M.append(L("p","Both downloads bind this exact project revision and its linked saved inventory. Editable includes authored source and material resources for rebuilding. Runtime is delivery-only and cannot restore editable source. Unlinked inventory entries remain plans, not bundled assets.")),u.append(M),u.append(Ys("Exact project configuration and review records",l))},s=async()=>{let c=await Xt("/api/projects");if(t.length===c.projects.length&&t.every((l,u)=>l.revisionId===c.projects[u]?.revisionId))return;if(t=c.projects,!t.some((l)=>l.projectId===n))n=t[0]?.projectId??"";r(),e.changed(t)};function o(c){i=c,oe("project-editor-title").textContent=c?"Edit project":"New project",oe("project-name").value=c?.name??"",oe("project-brief").value=c?.brief??"",oe("project-style").value=c?.design.style??"",oe("project-scale").value=c?.design.scale??"",oe("project-config").value=JSON.stringify(db(c??{name:""}),null,2),oe("project-save-status").textContent="",oe("project-editor").showModal(),oe("project-name").focus()}function a(c,l){if(!l.asset)return;let u=L("dialog"),h=L("form"),d=L("div",void 0,"editor-content"),f=L("h2",`Review ${l.name}`);f.id="review-dialog-title",u.setAttribute("aria-labelledby",f.id),d.append(f,L("p","Record an assessment of this exact saved revision. This is a review annotation; structural QA and release qualification remain separate.","subtle"),L("code",`${l.asset.assetId} / ${l.asset.revisionId}`,"mono"));let m=L("input");m.required=!0,m.value=Er("kiln.reviewer")??"",m.maxLength=200;let _=L("label","Reviewer","field");_.append(m);let p=L("select");for(let[R,x]of[["comment","Comment"],["changes-requested","Changes requested"],["accepted","Visually accepted"]])p.append(new Option(x,R));let g=L("label","Assessment","field");g.append(p);let M=L("textarea");M.rows=4,M.maxLength=4000;let T=L("label","Notes","field");T.append(M);let v=L("p");v.setAttribute("role","status");let S=L("button","Save review");S.type="submit";let E=L("button","Cancel","secondary");E.type="button",E.onclick=()=>u.close(),d.append(_,g,T,v,S,E),h.append(d),u.append(h),document.body.append(u),u.addEventListener("close",()=>u.remove()),h.onsubmit=async(R)=>{R.preventDefault(),S.disabled=!0,v.textContent="Saving review…";try{await Xt(`/api/projects/${encodeURIComponent(c.projectId)}`,{method:"PATCH",body:{expectedRevision:c.revisionId,patch:{reviews:[...c.reviews,{id:`review_${crypto.randomUUID().replaceAll("-","")}`,inventoryId:l.id,projectRevisionId:c.revisionId,asset:l.asset,reviewer:m.value.trim(),verdict:p.value,notes:M.value}]}}}),ri("kiln.reviewer",m.value.trim()),u.close(),await s()}catch(x){v.textContent=x instanceof Error?x.message:String(x)}finally{S.disabled=!1}},u.showModal(),m.focus()}return oe("new-project").onclick=()=>o(),oe("close-project-editor").onclick=()=>oe("project-editor").close(),oe("project-form").onsubmit=async(c)=>{c.preventDefault();let l=oe("save-project");l.disabled=!0,oe("project-save-status").textContent="Saving revision…";try{let u=fb(oe("project-config").value,{name:oe("project-name").value,brief:oe("project-brief").value,style:oe("project-style").value,scale:oe("project-scale").value});n=(await Xt(i?`/api/projects/${encodeURIComponent(i.projectId)}`:"/api/projects",i?{method:"PATCH",body:{expectedRevision:i.revisionId,patch:u}}:{method:"POST",body:u})).projectId,ri("kiln.project",n),oe("project-editor").close(),hn("Project revision saved."),await s()}catch(u){oe("project-save-status").textContent=u instanceof Error?u.message:String(u)}finally{l.disabled=!1}},{refresh:s}}function mb(e){if(!e.presetId.trim())throw Error("Choose a material preset");if(!e.seed.trim())throw Error("Enter an explicit seed");let t=Number(e.seed),n=Number(e.size);if(!Number.isInteger(t)||t<-2147483648||t>2147483647)throw Error("Seed must be a signed 32-bit integer");if(![64,128,256,512].includes(n))throw Error("Choose a supported map size");if(!e.creator.trim()||!e.spdx.trim()||!e.url.trim())throw Error("Creator and license details are required");let i=new URL(e.url.trim());if(i.protocol!=="https:"&&i.protocol!=="http:")throw Error("License URL must be HTTP(S)");return{presetId:e.presetId,seed:t,size:n,creator:e.creator.trim(),license:{spdx:e.spdx.trim(),url:e.url.trim(),attribution:e.attribution}}}function gb(e){let t=[],n=[],i=[],r=oe("materials-project"),s=L("button","Create from preset");oe("materials-refresh").before(s);let o=L("dialog");o.setAttribute("aria-labelledby","material-preset-heading");let a=L("form"),c=L("div",void 0,"detail-top"),l=L("h2","Create a material resource");l.id="material-preset-heading";let u=L("button","Cancel","secondary");u.type="button",u.onclick=()=>o.close(),c.append(l,u);let h=L("div",void 0,"editor-content");h.append(L("p","Offline starting recipes with editable layers and height-derived normals. Choose an explicit seed and provenance for the resource. Map images are not shaded material previews.","subtle"));function d(C,N){let ee=L("label",C,"field");return ee.append(N),h.append(ee),N}let f=d("Preset",L("select")),m=L("p",void 0,"subtle");h.append(m);let _=d("Seed",L("input"));_.type="number",_.step="1",_.required=!0,_.min="-2147483648",_.max="2147483647",_.value="0";let p=d("Map size",L("select"));for(let C of[64,128,256,512])p.append(new Option(`${C} × ${C}`,String(C)));p.value="256";let g=d("Creator",L("input"));g.required=!0,g.maxLength=1000;let M=d("License identifier",L("input"));M.required=!0,M.placeholder="For example, CC0-1.0";let T=d("License URL",L("input"));T.type="url",T.required=!0;let v=d("Attribution text",L("textarea"));v.rows=2;let S=L("p");S.setAttribute("role","status");let E=L("button","Create resource");E.type="submit",h.append(S,E),a.append(c,h),o.append(a),document.body.append(o);let R=()=>{let C=i.find((N)=>N.id===f.value);m.textContent=C?`${C.description} Repeat scale: ${C.physicalSizeMeters.width} × ${C.physicalSizeMeters.height} m.`:""};f.onchange=R,s.onclick=async()=>{s.disabled=!0;try{i=(await Xt("/api/material-presets")).presets,f.replaceChildren(...i.map((C)=>new Option(C.name,C.id))),R(),S.textContent="",E.disabled=!i.length,o.showModal()}catch(C){hn(C)}finally{s.disabled=!1}},a.onsubmit=async(C)=>{C.preventDefault(),E.disabled=!0,S.textContent="Creating immutable material resource…";try{let N=mb({presetId:f.value,seed:_.value,size:p.value,creator:g.value,spdx:M.value,url:T.value,attribution:v.value}),ee=await Xt("/api/materials/preset",{method:"POST",body:N});await H(),o.close(),hn(`${ee.material.name} created at ${ee.material.revisionId}. Ready for standalone assets. You can also lock this revision to an optional project.`)}catch(N){S.textContent=N instanceof Error?N.message:String(N)}finally{E.disabled=!1}};let x=(C)=>`/api/materials/${encodeURIComponent(C.materialId)}/${encodeURIComponent(C.revisionId)}`;function w(){let C=n.find((G)=>G.projectId===r.value),N=oe("material-dependencies");if(N.replaceChildren(),C)if(N.append(L("h2",`${C.name}: locked resources`)),!C.materialDependencies.length)N.append(L("p","No materials are locked to this project yet. Select a resource revision below or configure dependencies with your agent.","subtle"));else{let G=L("table"),k=L("thead"),W=L("tr"),B=L("tbody");for(let K of["Resource / role","Exact revision","Local availability"])W.append(L("th",K));k.append(W),G.append(k);for(let K of C.materialDependencies){let ge=t.find((he)=>he.materialId===K.resourceId&&he.revisionId===K.revisionId),de=L("tr"),fe=L("td",K.resourceId);fe.append(L("small",K.role??C.design.materialRoles.filter((he)=>he.resourceId===K.resourceId).map((he)=>he.role).join(", "))),de.append(fe,L("td",K.revisionId,"mono"),L("td",ge&&ge.revisionId===K.sha256?"Exact local record available":ge?"Dependency hash differs":"Not in local catalog")),B.append(de)}G.append(B);let Y=L("div",void 0,"table-wrap");Y.append(G),N.append(Y)}let ee=oe("material-list");ee.replaceChildren();let P=oe("material-search").value.trim().toLowerCase(),Z=t.filter((G)=>`${G.name} ${G.materialId} ${G.tags.join(" ")} ${G.sources.map((k)=>k.provider).join(" ")}`.toLowerCase().includes(P));if(oe("material-count").textContent=`${Z.length} material revision${Z.length===1?"":"s"}`,!Z.length){ee.append(qs(P?"No matching materials":"Your material catalog starts here",P?"Try another material name, tag or provider.":"Materials added through Kiln appear here with their map roles, source records and exact revisions."));return}for(let G of Z){let k=L("article",void 0,"material-card"),W=G.maps.find((fe)=>fe.slot==="baseColor")??G.maps[0];if(W){let fe=L("img");fe.src=`${x(G)}/${encodeURIComponent(W.file)}`,fe.alt=`${G.name}: ${W.slot} map, not a shaded material preview`,fe.loading="lazy",fe.className="material-map",k.append(fe,L("p",`${W.slot} map · unshaded`,"subtle"))}k.append(L("h3",G.name),L("p",G.tags.join(" · "),"subtle"));let B=L("dl"),Y=(fe,he)=>B.append(L("dt",fe),L("dd",he));Y("Revision",G.revisionId),Y("Physical scale",G.physicalSizeMeters?`${G.physicalSizeMeters.width} × ${G.physicalSizeMeters.height} m`:"Not specified"),Y("Tiling",G.tileable?"Declared tileable":"Not declared tileable"),Y("Maps",G.maps.map((fe)=>`${fe.slot} ${fe.width}×${fe.height} (${fe.colorSpace})`).join(" · ")),Y("Surface factors",`Roughness ×${G.parameters.roughness} · Metalness ×${G.parameters.metalness}${G.maps.some((fe)=>fe.slot==="metallicRoughness")?" · multiplied by packed map channels":""}`),k.append(B);for(let fe of G.sources){let he=L("p",`${fe.provider} · ${fe.creator} · ${fe.kind}`,"subtle"),I=L("a",fe.license.spdx);if(I.href=fe.license.url,I.target="_blank",I.rel="noreferrer",he.append(document.createTextNode(" · "),I),fe.assetUrl){let V=L("a","Source");V.href=fe.assetUrl,V.target="_blank",V.rel="noreferrer",he.append(document.createTextNode(" · "),V)}if(k.append(he),fe.license.attribution)k.append(L("p",fe.license.attribution,"subtle"))}let K=L("div",void 0,"material-map-links");for(let fe of G.maps){let he=L("a",fe.slot);he.href=`${x(G)}/${encodeURIComponent(fe.file)}`,he.target="_blank",he.rel="noopener",K.append(he)}k.append(K);let ge=C?.materialDependencies.find((fe)=>fe.resourceId===G.materialId),de=L("button",ge?.revisionId===G.revisionId?"Locked to project":ge?"Use this revision":"Add to project","secondary");if(de.disabled=!C||ge?.revisionId===G.revisionId,!C)de.title="Select a project to add a material dependency";de.onclick=async()=>{if(!C)return;de.disabled=!0;try{let fe=C.materialDependencies.filter((he)=>he.resourceId!==G.materialId);fe.push({resourceId:G.materialId,revisionId:G.revisionId,sha256:G.revisionId,...ge?.role?{role:ge.role}:{}}),await Xt(`/api/projects/${encodeURIComponent(C.projectId)}`,{method:"PATCH",body:{expectedRevision:C.revisionId,patch:{materialDependencies:fe}}}),hn(`${G.name} is locked to ${C.name} at this exact revision.`),await e()}catch(fe){hn(fe),de.disabled=!1}},k.append(de,Ys("Map recipes, transformations and provenance",G)),ee.append(k)}}let H=async()=>{t=(await Xt("/api/materials")).materials,w()};return oe("material-search").oninput=w,r.onchange=w,oe("materials-refresh").onclick=()=>void H().catch(hn),{refresh:H,projects(C){n=C;let N=r.value;r.replaceChildren(new Option("All materials",""));for(let ee of n)r.append(new Option(ee.name,ee.projectId));if(n.some((ee)=>ee.projectId===N))r.value=N;w()}}}function cf(e,t,n){return n?`${n.triangles.toLocaleString()} triangles displayed · ${t}`:`${e.triangles.toLocaleString()} triangles · ${e.meshes} meshes · ${t}`}var _b=(e,t)=>e.startedAt.localeCompare(t.startedAt)||e.operationId.localeCompare(t.operationId);function ga(e,t){let n=new Map(e.operations.map((c)=>[c.operationId,c])),i=t.map((c)=>{let l=n.get(c.operationId);return l&&l.revision>c.revision?l:c}).sort(_b),r=(c)=>i.find((l)=>l.operationId===c?.operationId)??c,s=e.following?i.at(-1):r(e.selected),o=(c)=>!!c&&!!s&&c.projectId===s.projectId&&c.workId===s.workId&&_b(c,s)<=0&&(c.sessionId===s.sessionId||e.following&&e.crossRunContinuity===!0&&!!s.workId),a=s?.artifact?s:s?i.filter((c)=>c.artifact&&o(c)).at(-1)??(o(e.displayed)?e.displayed:void 0):void 0;return{...e,operations:i,selected:s,displayed:a,pinned:r(e.pinned)}}function lf(e,t){return ga({...e,following:!1,selected:e.operations.find((n)=>n.operationId===t)??e.selected},e.operations)}function Tr(e,t){return e?.artifact&&t?.artifact&&e.operationId===t.operationId&&e.revision===t.revision&&e.artifact.sha256===t.artifact.sha256?t:void 0}function xb(e,t,n,i){if(e.status!=="complete"||!e.artifact)throw Error("Save requires a completed operation with an artifact.");if(!Tr(e,Tr(i,n)))throw Error("The visible artifact changed or has not loaded. Close this dialog and review it before saving.");let r=t.trim();if(!r||r.length>200)throw Error("Choose an asset name of 1–200 characters.");return{path:`/api/live/${encodeURIComponent(e.operationId)}/save`,body:{expectedRevision:e.revision,name:r,collection:"project"}}}function yl(e,t,n,i){let r;e.onclick=async()=>{let s=n();if(!s){t.replaceChildren(L("p","Load an artifact before measuring.","subtle"));return}e.disabled=!0,t.replaceChildren(L("p","Measuring frame pacing for 3 seconds. Keep this viewport visible and the camera steady.","subtle"));try{let o=await Xy(()=>s.measure(3000),i),a=L("div",void 0,"evidence-card");a.append(L("h3","Exploratory browser measurement"),L("p","Other workloads are not controlled. This sample is not an isolated performance baseline or budget acceptance."),L("strong",`p50 ${o.frameMs.p50.toFixed(1)} ms · p95 ${o.frameMs.p95.toFixed(1)} ms`),L("p",`${o.frameMs.samples} frame intervals · ${(o.windowMs/1000).toFixed(2)} s · ${o.drawCalls} draws · ${o.triangles.toLocaleString()} rendered triangles`),L("p",`${o.geometryObjects} geometry objects · ${o.textureObjects} texture objects. These counts are not GPU memory bytes.`),L("p",`GLB parse to first frame submission: ${o.loadToFirstFrameMs?.toFixed(1)??"unavailable"} ms. Download time excluded.`),L("p",`${o.viewport.cssWidth}×${o.viewport.cssHeight} CSS pixels · DPR ${o.viewport.devicePixelRatio.toFixed(2)}. Frame pacing includes browser scheduling and vertical sync, not GPU execution timing.`));let c=Ys("Exact measurement receipt and limitations",o);if(r)URL.revokeObjectURL(r);r=URL.createObjectURL(new Blob([JSON.stringify(o,null,2)],{type:"application/json"}));let l=L("a","Download measurement receipt");l.href=r,l.download="kiln-viewer-performance.json",a.append(c,l),t.replaceChildren(a)}catch(o){t.replaceChildren(L("p",o instanceof Error?o.message:String(o),"subtle"))}finally{e.disabled=!1}}}function uf(e,t,n,i){let r=e.inventory.find((o)=>o.id===t);if(!r&&!n)throw Error("Inventory item not found");let s=e.inventory.map((o)=>{if(o.id!==t)return o;let{asset:a,...c}=o;return n?{...c,asset:n}:c});if(!r&&n)s.push({id:t,name:i,kind:"asset",brief:"",references:[],asset:n});return{inventory:s}}async function _a(e,t,n,i){e.replaceChildren(L("h3","Project membership"));let{projects:r}=await Xt("/api/projects");if(!e.isConnected)return;let s=L("div");e.append(s);let o=L("p");o.setAttribute("role","status");let a=()=>_a(e,t,n,i);for(let _ of r)for(let p of _.inventory){if(!p.asset||p.asset.collectionId!==t.collectionId||p.asset.assetId!==t.assetId)continue;let g=L("div",void 0,"membership-row");g.append(L("span",`${_.name} / ${p.name} · ${Qt(p.asset.revisionId)}${p.asset.revisionId===t.revisionId?" · this revision":" · another revision"}`));let M=L("button","Remove membership","secondary");M.onclick=async()=>{M.disabled=!0;try{await Xt(`/api/projects/${encodeURIComponent(_.projectId)}`,{method:"PATCH",body:{expectedRevision:_.revisionId,patch:uf(_,p.id,null,n)}}),await i(),await a()}catch(T){o.textContent=`${T instanceof Error?T.message:T} Reopen membership to load the current project.`,M.disabled=!1}},g.append(M),s.append(g)}if(!s.childElementCount)s.append(L("p","This asset is standalone. Project membership is optional.","subtle"));if(!r.length){s.append(L("p","Create a named project in Projects to organize related assets."));return}let c=L("form"),l=L("select"),u=L("select"),h=L("label","Project","field"),d=L("label","Inventory item","field");h.append(l),d.append(u);for(let _ of r)l.append(new Option(_.name,_.projectId));let f=()=>{let _=r.find((g)=>g.projectId===l.value);u.replaceChildren(new Option("Add as a new inventory item",""));for(let g of _.inventory)u.append(new Option(`${g.name}${g.asset?" (replace linked revision)":""}`,g.id));let p=_.inventory.find((g)=>g.asset?.collectionId===t.collectionId&&g.asset.assetId===t.assetId);if(p)u.value=p.id};l.onchange=f,f();let m=L("button","Link this exact revision");m.type="submit",c.append(h,d,L("p","Linking preserves the saved asset and its original build provenance. Replacing a link advances only this project.","subtle"),m,o),c.onsubmit=async(_)=>{_.preventDefault(),m.disabled=!0;let p=r.find((M)=>M.projectId===l.value),g=u.value||`asset_${crypto.randomUUID().replaceAll("-","")}`;try{await Xt(`/api/projects/${encodeURIComponent(p.projectId)}`,{method:"PATCH",body:{expectedRevision:p.revisionId,patch:uf(p,g,t,n)}}),await i(),await a()}catch(M){o.textContent=`${M instanceof Error?M.message:M} Reopen membership to load the current project.`,m.disabled=!1}},s.append(c)}function vb(){let e={following:!0,crossRunContinuity:!0,operations:[]},t=[],n="",i=0,r=!1,s,o=0,a,c,l,u,h,d,f,m=0,_=0,p=!1,g=!1,M=oe("live-project"),T=oe("live-source"),v=(I)=>T.value?`${I}${I.includes("?")?"&":"?"}source=${encodeURIComponent(T.value)}`:I,S=oe("live-run"),E=oe("live-work"),R=()=>`kiln.live.selection.${T.value}.${M.value}.${E.value}.${S.value}`,x=()=>`kiln.live.pin.${T.value}`,w=()=>t.filter((I)=>(!S.value||I.sessionId===S.value)&&(!E.value||(E.value==="ungrouped"?!I.workId:I.workId===E.value))),H=(I,V)=>{let q=oe("live-connection");q.textContent=I?"Connected":"Reconnecting",q.className=`pill ${I?"connected":"warning"}`,oe("connection-status").textContent=V};function C(){let I=E.value,V=[...new Set(t.flatMap((ce)=>ce.workId?[ce.workId]:[]))];if(E.replaceChildren(new Option("All authoring items",""),new Option("Ungrouped history","ungrouped"),...V.map((ce)=>new Option(ce,ce))),I==="ungrouped"||V.includes(I))E.value=I;let q=S.value,se=[...new Set(t.map((ce)=>ce.sessionId))];S.replaceChildren(new Option("All runs",""));for(let ce of se){let ae=t.find((ke)=>ke.sessionId===ce);S.append(new Option(`${ae.transport} · ${Qt(ce)}`,ce))}if(se.includes(q))S.value=q}function N(){let I=oe("live-timeline"),V=I.scrollTop,q=I.contains(document.activeElement)?document.activeElement.dataset.operation:void 0;if(I.replaceChildren(),!e.operations.length){I.append(qs("Nothing observed yet","Actual Kiln operations will appear here. There is no agent running state to infer."));return}for(let se of[...e.operations].reverse()){let ce=L("button",void 0,`timeline-item ${se.status}${e.selected?.operationId===se.operationId?" selected":""}${se.pinned?" pinned":""}`);ce.dataset.operation=se.operationId;let ae=L("span",void 0,"timeline-meta");if(ae.append(L("span",se.transport.toUpperCase()),L("time",new Date(se.startedAt).toLocaleTimeString())),ce.append(ae,L("strong",se.tool.replace(/^kiln_/,"")),L("small",`${se.status} · ${se.artifact?"artifact available":"no artifact"}`),L("small",se.workId?`Item ${se.workId}`:`Ungrouped · run ${Qt(se.sessionId)}`)),ce.setAttribute("aria-label",`${se.tool}, ${se.status}, ${new Date(se.startedAt).toLocaleString()}`),e.selected?.operationId===se.operationId)ce.setAttribute("aria-current","true");if(ce.onclick=()=>{e=lf(e,se.operationId),ri(R(),se.operationId),Y()},I.append(ce),q===se.operationId)ce.focus({preventScroll:!0})}I.scrollTop=V}function ee(I){let V=L("div",void 0,"evidence-card");V.append(L("h3","Capture fidelity"));let q=I.viewFidelity,se=q&&typeof q==="object"?q:void 0;if(V.append(L("strong",se?String(se.delivered??"Reported"):"No capture receipt yet")),V.append(L("p",se?.materialFaithful===!0?"Material-faithful capture reported.":se?"Geometry evidence only. Do not use this capture to judge materials.":"The interactive viewport uses local browser lighting; it is not a recorded capture.")),se?.degradeReason)V.append(L("p",String(se.degradeReason)));if(se?.rendererId)V.append(L("p",`Renderer: ${String(se.rendererId)}`,"mono"));if(se?.inputGlbSha256)V.append(L("p",`Capture input: ${String(se.inputGlbSha256)}`,"mono"));if(se)V.append(L("p",se.exactArtifact===!0?"Receipt identifies the exact evaluated artifact.":"Capture does not claim exact artifact equivalence."));return V}function P(){let I=oe("live-evidence"),V=oe("live-downloads");I.replaceChildren(),V.replaceChildren();let q=e.displayed;if(!q?.artifact)return;let se=L("div",void 0,"evidence-card");if(se.append(L("h3","Selected observed artifact"),L("strong",`${(q.artifact.bytes/1024).toFixed(0)} KB GLB`),L("p",q.artifact.sha256,"mono"),L("p",`Source: ${q.programRef??"See authored source download"}`,"mono")),I.append(se,ee(q)),q.captures.length)for(let ce of q.captures){let ae=L("div",void 0,"evidence-card");ae.append(L("h3",ce.name));let ke=q.viewFidelity&&typeof q.viewFidelity==="object"?q.viewFidelity:void 0;ae.append(L("p",ke?.materialFaithful===!0?`Recorded capture · ${String(ke.delivered??"material-faithful")}`:`Recorded capture · ${String(ke?.delivered??"fidelity unreported")}. Materials are not verified.`,ke?.materialFaithful===!0?"subtle":"warning"));let Ce=L("a"),Ve=L("img");Ve.src=ce.url,Ve.alt=`Recorded ${ce.name} for ${q.tool}`,Ve.loading="lazy",Ce.href=ce.url,Ce.target="_blank",Ce.rel="noopener",Ce.append(Ve),ae.append(Ce,L("p",ce.sha256,"mono")),I.append(ae)}else{let ce=L("div",void 0,"evidence-card");ce.append(L("h3","Recorded captures"),L("p",q.status==="evaluated"||q.status==="running"?"Artifact is ready. Capture work may still be in progress.":"No capture image was retained for this operation.")),I.append(ce)}for(let[ce,ae,ke]of[[q.artifact.url,"Observed GLB","asset.glb"],[v(`/api/live/${encodeURIComponent(q.operationId)}/source.kiln.js`),"Authored source","source.kiln.js"]]){let Ce=L("a",ae);Ce.href=ce,Ce.download=ke,V.append(Ce)}V.append(L("p","These are the observed artifact and source. Use the saved Library revision for an editable bundle with resources or a separate runtime export. A live observation is not a saved release."))}function Z(){let I=Tr(e.displayed,l);oe("pin-build").disabled=!I,de.disabled=I?.status!=="complete"}function G(){if(h&&l)oe("live-stage-label").textContent=cf(h,Qt(l.operationId),a?.lod())}function k(){if(d&&u)oe("compare-stage-label").textContent=`Pinned · ${cf(d,Qt(u.operationId),c?.lod())}`}async function W(I){if(oe("live-panel").hidden)return;let V=++m;if(!Tr(I,l))a?.cancelMeasurement("The review selection changed. Measure the loaded revision again.");if(!I?.artifact){oe("live-performance").replaceChildren(),a?.dispose(),a=void 0,l=void 0,h=void 0,oe("live-level-field").hidden=!0,oe("live-lod").replaceChildren(),oe("live-lod").hidden=!0,oe("live-stage-status").textContent="No completed artifact available for this run.",oe("live-stage-label").textContent="Current",Z();return}if(l?.artifact?.sha256===I.artifact.sha256){l=I,oe("live-stage-status").textContent="",G(),Z();return}oe("live-stage-status").textContent=`Loading ${Qt(I.operationId)}…${l?` Previous artifact ${Qt(l.operationId)} remains visible; Save and Pin are unavailable until the selection loads.`:""}`;try{let q=await fetch(I.artifact.url);if(!q.ok)throw Error("This retained artifact is no longer available");let se=new Uint8Array(await q.arrayBuffer());if(V!==m)return;a??=pa(oe("live-stage"));let ce=await a.load(se,{isCurrent:()=>V===m,onCommit:()=>{l=I},preserveView:l?.projectId===I.projectId&&(l?.sessionId===I.sessionId||e.following)});if(!ce||V!==m)return;oe("live-performance").replaceChildren(),l=I,h=ce,Z();let ae=oe("live-level");if(oe("live-level-field").hidden=!ce.levels,ma(ae,oe("live-lod"),a,(ke)=>{if(ke!==void 0)c?.level(ke),f?.refresh(),k();G()}),a.wire(p),a.navigation(oe("live-navigation").value),oe("live-stage-status").textContent="",G(),c)c.setView(a.view())}catch(q){if(V!==m)return;oe("live-stage-status").textContent=`${q instanceof Error?q.message:q}.${l?` Previous artifact ${Qt(l.operationId)} remains visible. Save and Pin are unavailable for the unloaded selection.`:""}`,Z()}}async function B(I){if(oe("live-panel").hidden)return;let V=++_;if(oe("compare-viewport").hidden=!I?.artifact,oe("review-viewports").classList.toggle("comparing",!!I?.artifact),!I?.artifact){c?.dispose(),c=void 0,u=void 0,d=void 0,f=void 0,oe("compare-lod").replaceChildren(),oe("compare-level-field").hidden=!0;return}if(u?.artifact?.sha256===I.artifact.sha256){u=I,k(),oe("compare-stage-status").textContent="";return}if(!u)oe("compare-stage-label").textContent="Comparison";oe("compare-stage-status").textContent=`Loading pinned ${Qt(I.operationId)}…`;try{let q=await fetch(I.artifact.url);if(!q.ok)throw Error("Pinned artifact unavailable");let se=new Uint8Array(await q.arrayBuffer());if(V!==_)return;c??=pa(oe("compare-stage"));let ce=await c.load(se,{preserveView:!0,isCurrent:()=>V===_,onCommit:()=>{u=I}});if(!ce||V!==_)return;if(u=I,d=ce,a)c.setView(a.view());let ae=Number(oe("live-level").value||0);c.level(Number.isFinite(ae)?ae:0),oe("compare-level-field").hidden=!ce.levels,f=ma(oe("compare-level"),oe("compare-lod"),c,k),k(),c.wire(p),c.navigation(oe("live-navigation").value),oe("compare-stage-status").textContent=""}catch(q){if(V===_)oe("compare-stage-status").textContent=`${q instanceof Error?q.message:String(q)}.${u?` Previous comparison ${Qt(u.operationId)} remains visible.`:""}`}}function Y(){N();let I=e.selected,V=e.displayed,q=oe("follow-latest");q.textContent=e.following?"Following latest":"Follow latest",q.setAttribute("aria-pressed",String(e.following));let se=oe("live-current-summary");if(se.replaceChildren(),I){se.append(L("h2",I.tool.replace(/^kiln_/,"")),L("p",`${I.status} · ${I.transport} · Run ${Qt(I.sessionId)} · ${new Date(I.updatedAt).toLocaleString()}`));let ke=L("div",void 0,"tags");if(I.projectId)ke.append(L("span",I.projectId,"tag"));for(let Ce of I.phases)ke.append(L("span",Ce.phase,"tag"));se.append(ke)}else se.append(L("h2","No build selected"),L("p","Run Kiln tools from your agent or CLI. Completed evaluations appear here automatically."));let ce=I&&"observationIssues"in I&&Array.isArray(I.observationIssues)?I.observationIssues.map(String):[],ae=[I?.error,...ce,I&&V&&I.operationId!==V.operationId?`Current ${I.status} operation has no retained artifact. Showing the last successful artifact ${Qt(V.operationId)} from run ${Qt(V.sessionId)}.`:"",I&&!e.operations.some((ke)=>ke.operationId===I.operationId)?"This selection is outside the current retained history. Its loaded view remains until you choose another build.":""].filter(Boolean);oe("live-failure").textContent=ae.join(" "),oe("live-failure").hidden=!ae.length,Z(),oe("clear-pin").hidden=!e.pinned,oe("live-count").textContent=`${e.operations.length} retained operation${e.operations.length===1?"":"s"}`,oe("live-record").textContent=JSON.stringify({selected:I,displayedArtifactOperation:V?.operationId,pinnedOperation:e.pinned?.operationId},null,2),P(),W(V),B(e.pinned)}async function K(){if(r)return;r=!0;let I=i;try{let V=new URLSearchParams;if(M.value)V.set("project",M.value);if(n)V.set("cursor",n);let q=await Xt(v(`/api/live?${V}`));if(I!==i)return;if(o=0,H(!0,"Connected · checks every 2 seconds"),n=q.cursor,oe("live-history-note").textContent=`Up to ${q.retention.maxOperations} operations`,oe("live-history-issues").textContent=q.observationIssues?.join(" ")??"",oe("live-history-issues").hidden=!q.observationIssues?.length,!q.unchanged){if(t=q.operations,C(),e=ga(e,w()),!g){g=!0;let se=Er(R());if(se&&e.operations.some((ae)=>ae.operationId===se))e=lf(e,se);let ce=Er(x());e.pinned=t.find((ae)=>ae.operationId===ce&&ae.pinned)??[...t].reverse().find((ae)=>ae.pinned&&ae.artifact)}Y()}}catch(V){o++,H(!1,`Connection lost. Retrying; retained views remain available. ${V instanceof Error?V.message:V}`)}finally{if(r=!1,s)clearTimeout(s);s=setTimeout(()=>void K(),document.hidden?1e4:Math.min(30000,2000*2**Math.min(o,4)))}}M.onchange=()=>{i++,n="",t=[],g=!1,S.replaceChildren(new Option("All runs","")),E.value="",e={following:!0,crossRunContinuity:!0,operations:[]},Y(),K()},T.onchange=()=>{M.value="",e.pinned=void 0,M.dispatchEvent(new Event("change"))},Xt("/api/live-sources").then(({sources:I})=>{T.replaceChildren(...I.map((V)=>new Option(V.label,V.id)))}).catch(hn),S.onchange=()=>{e=ga({...e,selected:void 0,displayed:void 0,following:!0,crossRunContinuity:!S.value},w()),Y()},E.onchange=()=>S.dispatchEvent(new Event("change")),oe("follow-latest").onclick=()=>{e=ga({...e,following:!e.following},w()),ri(R(),e.following?"":e.selected?.operationId??""),Y()},oe("live-refresh").onclick=()=>{n="",K(),Y()},oe("pin-build").onclick=async()=>{let I=Tr(e.displayed,l);if(!I?.artifact)return;let V=oe("pin-build");V.disabled=!0;try{await Xt(v(`/api/live/${encodeURIComponent(I.operationId)}/pin`),{method:"POST",body:{pinned:!0}}),e.pinned={...I,pinned:!0},ri(x(),I.operationId),n="",Y(),K()}catch(q){hn(q),Z()}},oe("clear-pin").onclick=async()=>{if(!e.pinned)return;try{await Xt(v(`/api/live/${encodeURIComponent(e.pinned.operationId)}/pin`),{method:"POST",body:{pinned:!1}}),e.pinned=void 0,ri(x(),""),n="",Y(),K()}catch(I){hn(I)}},oe("live-frame").onclick=()=>{if(a?.reset(),a)c?.setView(a.view())},oe("live-wire").onclick=()=>{p=!p,a?.wire(p),c?.wire(p),oe("live-wire").setAttribute("aria-pressed",String(p))};let ge=L("button","Match comparison camera","secondary");ge.onclick=()=>{if(a)c?.setView(a.view())},oe("live-frame").parentElement?.append(ge);let de=L("button","Save exact artifact");de.disabled=!0,oe("live-frame").parentElement?.prepend(de);let fe=L("button","Measure 3 s","secondary"),he=L("div");return he.id="live-performance",oe("live-evidence").after(he),oe("live-frame").parentElement?.append(fe),yl(fe,he,()=>a,()=>Tr(e.displayed,l)?{operationId:l.operationId,revision:l.revision,glbSha256:l.artifact?.sha256}:void 0),de.onclick=()=>{let I=Tr(e.displayed,l);if(I?.status!=="complete")return;let V=L("dialog"),q=L("form"),se=L("div",void 0,"editor-content"),ce=L("h2","Save reviewed artifact");ce.id="save-review-title",V.setAttribute("aria-labelledby",ce.id),se.append(ce,L("p","Save the exact source, GLB and recorded capture to Library. Then optionally link the saved revision to one or more named projects. Kiln will not evaluate the source again.","subtle"),L("p",`${I.operationId} · revision ${I.revision}`,"mono"),L("p",I.artifact.sha256,"mono"));let ae=L("input");ae.required=!0,ae.maxLength=200,ae.value="";let ke=L("label","Asset name","field");ke.append(ae);let Ce=L("p");Ce.setAttribute("role","status");let Ve=L("button","Save exact artifact");Ve.type="submit";let rt=L("button","Cancel","secondary");rt.type="button",rt.onclick=()=>V.close(),se.append(ke,Ce,Ve,rt),q.append(se),V.append(q),document.body.append(V),V.addEventListener("close",()=>V.remove()),q.onsubmit=async(nt)=>{nt.preventDefault(),Ve.disabled=!0,Ce.textContent="Saving retained bytes…";try{let Rt=xb(I,ae.value,l,e.displayed),it=await Xt(v(Rt.path),{method:"POST",body:Rt.body});Ce.replaceChildren(L("span",`Saved ${it.asset.assetId} / ${it.asset.revisionId}. `));let tn=L("a","Open saved revision"),Ut=new URLSearchParams({collection:it.collection,asset:it.asset.assetId,revision:it.asset.revisionId});tn.href=`/?${Ut}`,Ce.append(tn);let It=L("div");se.append(It),_a(It,{collectionId:it.collection,assetId:it.asset.assetId,revisionId:it.asset.revisionId},it.asset.name,async()=>{}).catch((D)=>{It.textContent=`Asset saved; membership unavailable: ${D instanceof Error?D.message:D}. Open the saved asset in Library to link it.`}),ae.disabled=!0,Ve.textContent="Saved",rt.textContent="Close"}catch(Rt){Ce.textContent=Rt instanceof Error?Rt.message:String(Rt),Ve.disabled=!1}},V.showModal(),ae.focus()},oe("live-navigation").onchange=(I)=>{let V=I.target.value;a?.navigation(V),c?.navigation(V),oe("live-navigation-help").textContent=V==="explore"?"Focus a viewport, then W A S D to move · Q / E down / up · Shift faster · Drag to look around · No collision simulation.":"Drag to orbit · Scroll to zoom · Right-drag to pan · Your camera stays in place between iterations."},window.addEventListener("online",()=>{n="",K()}),document.addEventListener("visibilitychange",()=>{if(!document.hidden)K()}),K(),{activate:Y,projects(I){let V=M.value;M.replaceChildren(new Option("All work",""));for(let q of I)M.append(new Option(q.name,q.projectId));if(I.some((q)=>q.projectId===V))M.value=V}}}var hf=["projects","live","library","materials"];function yb(e,t){let n=new URLSearchParams(e);if(n.has("asset")||n.has("open"))return"library";return t&&hf.some((i)=>i===t)?t:"library"}function bb(e,t=()=>{}){let n=hf;function i(c){if(!n.includes(c))return;for(let l of n)oe(`${l}-panel`).hidden=l!==c;for(let l of document.querySelectorAll("#workspace-nav button")){let u=l.dataset.section===c;if(l.classList.toggle("active",u),u)l.setAttribute("aria-current","page");else l.removeAttribute("aria-current")}if(ri("kiln.section",c),c==="live")r.activate();if(c==="materials")s.refresh().catch(hn)}for(let c of document.querySelectorAll("#workspace-nav button"))c.onclick=()=>i(c.dataset.section);oe("open-files").onclick=()=>oe("open").click();let r=vb(),s=gb(()=>o.refresh()),o=pb({changed:(c)=>{r.projects(c),s.projects(c),t(c)},openAsset:(c)=>{i("library"),e(c)}});i(yb(location.search,Er("kiln.section"))),o.refresh().catch(hn),s.refresh().catch(hn);let a=!1;return window.setInterval(async()=>{if(document.hidden||a||oe("project-editor").open)return;a=!0;try{await o.refresh()}catch{}finally{a=!1}},5000),{library:()=>i("library"),refreshProjects:o.refresh}}var Ri=(e)=>`${e.collection}/${e.manifest.assetId}`;function Sb(e,t,n){if(!n)return e;if(n==="standalone"){let r=new Set(t.flatMap((s)=>s.inventory.flatMap((o)=>o.asset?[`${o.asset.collectionId}/${o.asset.assetId}`]:[])));return e.filter((s)=>!r.has(Ri(s)))}let i=new Set(t.find((r)=>r.projectId===n)?.inventory.flatMap((r)=>r.asset?[`${r.asset.collectionId}/${r.asset.assetId}/${r.asset.revisionId}`]:[])??[]);return e.filter((r)=>i.has(`${Ri(r)}/${r.manifest.revisionId}`))}var Le=(e)=>document.getElementById(e),lt=(e,t,n)=>{let i=document.createElement(e);if(t!==void 0)i.textContent=t;if(n)i.className=n;return i},ba=[],ya=[],Ir=[],ns=[],bl="",Rr,Ci,en,Ar=0,wb=0,xa=!1,va=!1,Cr=new Set,mf=[],Mb=[],Xi=(e)=>`${e.collection}/${e.manifest.assetId}/${e.manifest.revisionId}`,ff=(e)=>{Le("status").textContent=e},Ii=(e)=>ff(e instanceof Error?e.message:String(e)),is=(e,t,n=mf)=>{let i=URL.createObjectURL(new Blob([Uint8Array.from(e)],{type:t}));return n.push(i),i};async function pf(e){let t=await fetch(e),n=await t.json();if(!t.ok)throw Error(n.error??"Request failed");return n}async function df(e,t){if(e.local){let i=e.local.files[t];if(!i)throw Error("File unavailable");return i}if(e.loose&&t==="asset.glb")return e.loose;let n=await fetch(`/files/${Xi(e)}/${t}`);if(!n.ok)throw Error((await n.json()).error??"File unavailable");return new Uint8Array(await n.arrayBuffer())}function FC(e,t){if(e.local){if(t==="editable.zip")return is(ku([e.local]),"application/zip");return is(e.local.files[t],t.endsWith(".js")?"text/javascript":"model/gltf-binary")}if(e.loose)return is(e.loose,"model/gltf-binary");return`/files/${Xi(e)}/${t}?download`}function Eb(e,t){try{localStorage.setItem(e,t)}catch{}}function zC(e){try{return localStorage.getItem(e)}catch{return null}}function kC(){let e=Le("collections");e.replaceChildren();for(let t of[{id:"all",label:"All saved assets"},...ba,...ns.length?[{id:"opened-files",label:"Opened files"}]:[]]){let n=lt("button",t.label,bl===t.id?"active":"");n.onclick=()=>void Qs(t.id).catch(Ii),e.append(n)}}async function Qs(e,t=!0){if(t)Ab.library();let n=++wb;bl=e,Cr.clear(),kC(),ff("");let i=e==="all"?await(async()=>{let r=await pf("/api/library");if(r.errors.length)ff(r.errors.map((s)=>`${s.collectionId}: ${s.message}`).join(" · "));return r.entries.map((s)=>({collection:s.collectionId,manifest:s.manifest}))})():e==="opened-files"?ns:(await pf(`/api/assets?collection=${encodeURIComponent(e)}`)).assets.map((r)=>({collection:e,manifest:r}));if(n!==wb)return;Ir=i,Eb("kiln.collection",e),Le("collection-title").textContent=e==="all"?"Library":e==="opened-files"?"Opened files":ba.find((r)=>r.id===e)?.label??e,Le("collection-caption").textContent=e==="opened-files"?"Previewed in your browser. Your original files stay untouched.":"Saved assets across registered storage. Projects link exact revisions; standalone assets belong here too.",Sl()}function BC(){let e=new Map;for(let t of Sb(Ir,ya,Le("library-project").value)){let n=Ri(t);e.set(n,[...e.get(n)??[],t])}return[...e.values()].map((t)=>(t.sort((n,i)=>i.manifest.createdAt.localeCompare(n.manifest.createdAt)||i.manifest.revisionId.localeCompare(n.manifest.revisionId)),t.find((n)=>n.manifest.revisionId===zC(`kiln.revision.${n.collection}.${n.manifest.assetId}`))??t[0]))}function Sl(){for(let i of Mb.splice(0))URL.revokeObjectURL(i);let e=Le("cards");e.replaceChildren();let t=Le("search").value.toLowerCase(),n=BC().filter((i)=>`${i.manifest.name} ${i.manifest.tags.join(" ")}`.toLowerCase().includes(t));if(Le("count").textContent=`${n.length} asset${n.length===1?"":"s"}`,Le("export-selection").disabled=!Cr.size,!n.length){let i=lt("div",void 0,"empty");if(i.append(lt("b",t?"No matching assets":"Your next idea belongs here."),lt("p",t?"Try another name or tag.":"Save an asset with your agent, or open a GLB or editable bundle.")),!t)i.append(lt("code",'kiln save asset.kiln.js --name "My asset"'));e.append(i);return}for(let i of n){let r=i.manifest,s=lt("article",void 0,"card"),o=lt("button",void 0,"card-open");o.setAttribute("aria-label",`View ${r.name}`),o.onclick=()=>void Sa(i).catch(Ii);let a=lt("div",void 0,"thumb");if(r.files["preview.png"]){let m=lt("img");m.loading="lazy",m.alt=r.name,m.src=i.local?is(i.local.files["preview.png"],"image/png",Mb):`/files/${Xi(i)}/preview.png`,m.onerror=()=>{m.remove(),a.textContent="◇"},a.append(m)}else a.textContent="◇";let c=lt("div",void 0,"card-content");c.append(lt("span",r.name,"card-title"));let l=Ir.filter((m)=>Ri(m)===Ri(i)),u=new Set(l.map((m)=>m.manifest.parentRevision)),h=l.filter((m)=>!u.has(m.manifest.revisionId));c.append(lt("span",`${r.editable?"Editable source":"Source unavailable"} · ${l.length} revision${l.length===1?"":"s"}${h.length>1?` · ${h.length} branches`:""}`,"card-meta"));let d=lt("div",void 0,"tags");for(let m of r.tags)d.append(lt("span",m,"tag"));c.append(d),c.append(lt("small",ba.find((m)=>m.id===i.collection)?.label??i.collection,"card-meta"));let f=ya.filter((m)=>m.inventory.some((_)=>_.asset&&_.asset.collectionId===i.collection&&_.asset.assetId===r.assetId));if(c.append(lt("small",f.length?f.map((m)=>m.name).join(" · "):"No project membership","card-meta")),o.append(a,c),s.append(o),!i.loose){let m=lt("input");m.type="checkbox",m.className="selection",m.checked=Cr.has(Xi(i)),m.setAttribute("aria-label",`Select ${r.name}`),m.onchange=()=>{if(m.checked)Cr.add(Xi(i));else Cr.delete(Xi(i));Le("export-selection").disabled=!Cr.size},s.append(m)}e.append(s)}}async function Sa(e){let t=++Ar;Rr=e,Ci=void 0,en?.cancelMeasurement("The Library selection changed. Measure the loaded revision again."),Le("library-performance").replaceChildren(),Eb(`kiln.revision.${e.collection}.${e.manifest.assetId}`,e.manifest.revisionId);for(let l of mf.splice(0))URL.revokeObjectURL(l);let n=Le("detail");if(!n.open)n.showModal();Le("asset-name").textContent=e.manifest.name;let i=Le("asset-membership");if(i.replaceChildren(),!e.local&&!e.loose){let l=lt("div");i.append(l),_a(l,{collectionId:e.collection,assetId:e.manifest.assetId,revisionId:e.manifest.revisionId},e.manifest.name,Ab.refreshProjects).catch(Ii)}let r=Le("revisions");r.replaceChildren();for(let l of Ir.filter((u)=>Ri(u)===Ri(e))){let u=lt("option",`${new Date(l.manifest.createdAt).toLocaleString()} · ${l.manifest.description||l.manifest.revisionId.slice(0,10)}`);u.value=l.manifest.revisionId,u.selected=l.manifest.revisionId===e.manifest.revisionId,r.append(u)}r.onchange=()=>{let l=Ir.find((u)=>Ri(u)===Ri(e)&&u.manifest.revisionId===r.value);if(l)Sa(l).catch(Ii)},Le("asset-description").textContent=e.manifest.description??e.manifest.brief??(e.manifest.editable?"Source travels with this revision. Download the editable bundle to continue elsewhere.":"This GLB has no saved Kiln source. You can view and use the model.");let s=Le("asset-attribution");s.replaceChildren();for(let l of z0(e.manifest)){let u=lt("div");u.append(lt("span",l.label),lt("strong",l.value)),s.append(u)}s.hidden=!s.childElementCount,Le("provenance").textContent=e.loose?"Standalone GLB. No source or build provenance supplied.":JSON.stringify(e.manifest,null,2);let o=Le("downloads");o.replaceChildren();for(let[l,u]of[["asset.glb","Original GLB"],...e.manifest.editable?[["source.kiln.js","Download source"]]:[],...!e.loose?[["editable.zip",e.manifest.editable?"Download editable bundle":"Download asset bundle"]]:[]]){let h=lt("a",u);h.href=FC(e,l),h.download=`${e.manifest.name.replace(/[^a-z0-9_-]/gi,"-")}${l==="asset.glb"?".glb":l==="source.kiln.js"?".kiln.js":".zip"}`,o.append(h)}if(!e.loose){let l=lt("button","Runtime GLB"),u=lt("span");u.setAttribute("role","status"),l.onclick=async()=>{l.disabled=!0,u.textContent="Preparing runtime download…";try{let h=e.local?await sb(e.local,{profile:"runtime"}):void 0,[d,f]=h?.profile==="runtime"?[h.glb,h.metadata.bytes]:await Promise.all([df(e,"runtime.glb"),df(e,"runtime.kiln-metadata.json")]);if(t!==Ar)return;let m=lt("a","Runtime GLB");m.href=is(d,"model/gltf-binary"),m.download="runtime.glb";let _=lt("a","Runtime metadata");_.href=is(f,"application/json"),_.download="runtime.kiln-metadata.json",l.replaceWith(m,_),u.textContent="Keep the companion metadata for traceability.",m.click()}catch(h){if(t!==Ar)return;u.textContent=`Runtime export unavailable: ${h instanceof Error?h.message:h}`,l.disabled=!1}},o.append(l,u),o.append(lt("p","Original GLB retains Kiln review data. Runtime GLB moves duplicate animation-review data into a companion JSON file; geometry and textures are unchanged. Keep the editable bundle for source and build records."))}Le("refine").disabled=!e.manifest.editable,Le("asset-stats").replaceChildren(),Le("stage-status").textContent="Loading saved GLB…",xa=!1,va=!1,Le("wire").setAttribute("aria-pressed","false"),Le("play").textContent="Pause";let a=Le("animation");a.replaceChildren(new Option("Rest pose","")),Le("play").disabled=!0;let c=Le("level");c.replaceChildren(),c.hidden=!0,Le("library-lod").replaceChildren(),Le("library-lod").hidden=!0;try{en??=pa(Le("stage"));let l=await df(e,"asset.glb");if(t!==Ar)return;let u=await en.load(l,{isCurrent:()=>t===Ar,onCommit:()=>{Ci=e}});if(!u||t!==Ar)return;Ci=e,en.wire(!1),en.navigation(Le("library-navigation").value),en.lighting(Le("lighting").value),ma(c,Le("library-lod"),en);for(let[h,d]of[...u.levels?u.levels.map((f,m)=>[f.toLocaleString(),`LOD${m} triangles`]):[[u.triangles.toLocaleString(),"triangles"]],[u.meshes,u.levels?"LOD0 meshes":"meshes"],[u.materials,u.levels?"LOD0 materials":"materials"],[`${(l.length/1024).toFixed(0)} KB`,"GLB"]]){let f=lt("div");f.append(lt("strong",String(h)),lt("span",String(d))),Le("asset-stats").append(f)}for(let h=0;h<u.clips.length;h++)a.append(new Option(u.clips[h],String(h)));Le("stage-status").textContent=""}catch(l){if(t===Ar)en?.dispose(),en=void 0,Le("stage-status").textContent=`3D preview unavailable: ${l instanceof Error?l.message:l}. Downloads remain available.`}}async function Tb(e){for(let t of e){if(t.bytes.length>Un)throw Error("File exceeds 64 MiB");if(t.name.toLowerCase().endsWith(".zip"))for(let n of F0(t.bytes)){for(let[i,r]of Object.entries(n.files))if(`sha256:${Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",Uint8Array.from(r)))).map((o)=>o.toString(16).padStart(2,"0")).join("")}`!==n.manifest.files[i]?.sha256)throw Error(`Bundle integrity failure: ${i}`);if(!ns.some((i)=>i.manifest.revisionId===n.manifest.revisionId&&i.manifest.assetId===n.manifest.assetId))ns.push({collection:"opened-files",manifest:n.manifest,local:n})}else{let n=`a_${crypto.randomUUID().replaceAll("-","")}`;ns.push({collection:"opened-files",loose:t.bytes,manifest:{version:"kiln.asset.v1",assetId:n,revisionId:`r_${n}`,name:t.name.replace(/\.glb$/i,""),tags:[],createdAt:new Date().toISOString(),editable:!1,files:{}}})}}await Qs("opened-files")}Le("open").onchange=async(e)=>{try{let t=Array.from(e.target.files??[]);if(t.some((n)=>n.size>Un))throw Error("File exceeds 64 MiB");await Tb(await Promise.all(t.map(async(n)=>({name:n.name,bytes:new Uint8Array(await n.arrayBuffer())}))))}catch(t){Ii(t)}};Le("refresh").onclick=()=>void Qs(bl).catch(Ii);Le("search").oninput=Sl;Le("library-project").onchange=()=>void Qs("all").catch(Ii);Le("close-detail").onclick=()=>Le("detail").close();Le("detail").addEventListener("close",()=>{Ar++,Ci=void 0,en?.dispose(),en=void 0;for(let e of mf.splice(0))URL.revokeObjectURL(e);Sl()});Le("frame").onclick=()=>en?.reset();Le("wire").onclick=()=>{xa=!xa,en?.wire(xa),Le("wire").setAttribute("aria-pressed",String(xa))};Le("lighting").onchange=(e)=>en?.lighting(e.target.value);Le("library-navigation").onchange=(e)=>{let t=e.target.value;en?.navigation(t),Le("library-navigation-help").textContent=t==="explore"?"Focus the viewport, then W A S D to move · Q / E down / up · Shift faster · Drag to look around · No collision simulation.":"Drag to orbit · Scroll to zoom · Right-drag to pan"};Le("animation").onchange=(e)=>{let t=e.target.value;en?.clip(t===""?-1:Number(t)),Le("play").disabled=t===""};Le("play").onclick=()=>{va=!va,en?.pause(va),Le("play").textContent=va?"Play":"Pause"};Le("refine").onclick=async()=>{if(!Rr)return;let e=Rr.manifest,t=Rr.local?`Import the downloaded editable bundle using kiln import <bundle.zip>. Restore asset ${e.assetId}, revision ${e.revisionId}, using kiln_assets action=restore. Read its source with kiln_source, refine it with kiln_edit, review the result, and save a child revision with kiln_save. Requested change: `:`Use kiln_assets with action=restore, collection=${Rr.collection}, assetId=${e.assetId}, revisionId=${e.revisionId}. Read the returned programRef with kiln_source, refine it with kiln_edit, review the result, and save with kiln_save using assetId=${e.assetId}, parentRevision=${e.revisionId}, collection=${Rr.collection}. Requested change: `;try{await navigator.clipboard.writeText(t),Le("refine").textContent="Instructions copied"}catch{Le("provenance").textContent=t,Le("provenance").parentElement?.setAttribute("open","")}};Le("export-selection").onclick=()=>{try{let e=lt("a");if(bl==="opened-files")e.href=is(ku(Ir.filter((t)=>Cr.has(Xi(t))).map((t)=>t.local)),"application/zip");else{let t=new URLSearchParams;for(let n of Cr)t.append("revision",n);e.href=`/api/bundle?${t}`}e.download="kiln-assets.zip",e.click()}catch(e){Ii(e)}};async function GC(){ba=(await pf("/api/collections")).collections;let e=nb(location.search);if(await Qs(ba.find((t)=>t.id===e?.collection)?.id??"all",!1),e){let t=Ir.find((n)=>n.collection===e.collection&&n.manifest.assetId===e.assetId&&n.manifest.revisionId===e.revisionId);if(!t)throw Error("The requested saved revision is not available.");await Sa(t)}if(new URLSearchParams(location.search).has("open")){let t=await fetch("/api/standalone");if(!t.ok)throw Error("File unavailable");if(await Tb([{name:t.headers.get("Content-Type")?.includes("zip")?"asset.zip":"asset.glb",bytes:new Uint8Array(await t.arrayBuffer())}]),ns.length===1)await Sa(ns[0])}}var Ab=bb((e)=>{(async()=>{await Qs(e.collectionId);let t=Ir.find((n)=>n.manifest.assetId===e.assetId&&n.manifest.revisionId===e.revisionId);if(!t)throw Error("The linked saved revision is not available in this collection.");await Sa(t)})().catch(Ii)},(e)=>{ya=e;let t=Le("library-project"),n=t.value;t.replaceChildren(new Option("All projects and standalone",""),new Option("Standalone assets","standalone"));for(let i of ya)t.append(new Option(i.name,i.projectId));if(n==="standalone"||ya.some((i)=>i.projectId===n))t.value=n;Sl()});yl(Le("measure-library"),Le("library-performance"),()=>en,()=>Ci&&Rr&&Xi(Ci)===Xi(Rr)?{collection:Ci.collection,assetId:Ci.manifest.assetId,revisionId:Ci.manifest.revisionId,glbSha256:Ci.manifest.files["asset.glb"]?.sha256}:void 0);GC().catch(Ii);
4281
+ }`;class cy{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new rl(e.texture);if(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)this.depthNear=e.depthNear,this.depthFar=e.depthFar;this.texture=n}}getMesh(e){if(this.texture!==null){if(this.mesh===null){let t=e.cameras[0].viewport,n=new Gn({vertexShader:rC,fragmentShader:sC,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Mt(new ra(20,20),n)}}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class ly extends ii{constructor(e,t){super();let n=this,i=null,r=1,s=null,o="local-floor",a=1,c=null,l=null,u=null,h=null,d=null,f=null,m=typeof XRWebGLBinding<"u",_=new cy,p={},g=t.getContextAttributes(),M=null,T=null,v=[],S=[],E=new ke,R=null,x=null,w=new Ht;w.viewport=new pt;let G=new Ht;G.viewport=new pt;let C=[w,G],D=new Td,ee=null,L=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(I){let V=v[I];if(V===void 0)V=new Yo,v[I]=V;return V.getTargetRaySpace()},this.getControllerGrip=function(I){let V=v[I];if(V===void 0)V=new Yo,v[I]=V;return V.getGripSpace()},this.getHand=function(I){let V=v[I];if(V===void 0)V=new Yo,v[I]=V;return V.getHandSpace()};function W(I){let V=S.indexOf(I.inputSource);if(V===-1)return;let j=v[V];if(j!==void 0)j.update(I.inputSource,I.frame,c||s),j.dispatchEvent({type:I.type,data:I.inputSource})}function B(){i.removeEventListener("select",W),i.removeEventListener("selectstart",W),i.removeEventListener("selectend",W),i.removeEventListener("squeeze",W),i.removeEventListener("squeezestart",W),i.removeEventListener("squeezeend",W),i.removeEventListener("end",B),i.removeEventListener("inputsourceschange",P);for(let I=0;I<v.length;I++){let V=S[I];if(V===null)continue;S[I]=null,v[I].disconnect(V)}ee=null,L=null,_.reset();for(let I in p)delete p[I];if(e.setRenderTarget(M),d=null,h=null,u=null,i=null,T=null,fe.stop(),n.isPresenting=!1,e.setPixelRatio(R),e.setSize(E.width,E.height,!1),x!==null){let I=x.camera;I.fov=x.fov,I.zoom=x.zoom,I.updateProjectionMatrix(),x=null}n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(I){if(r=I,n.isPresenting===!0)Ue("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(I){if(o=I,n.isPresenting===!0)Ue("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||s},this.setReferenceSpace=function(I){c=I},this.getBaseLayer=function(){return h!==null?h:d},this.getBinding=function(){if(u===null&&m)u=new XRWebGLBinding(i,t);return u},this.getFrame=function(){return f},this.getSession=function(){return i},this.setSession=async function(I){if(i=I,i!==null){if(M=e.getRenderTarget(),i.addEventListener("select",W),i.addEventListener("selectstart",W),i.addEventListener("selectend",W),i.addEventListener("squeeze",W),i.addEventListener("squeezestart",W),i.addEventListener("squeezeend",W),i.addEventListener("end",B),i.addEventListener("inputsourceschange",P),g.xrCompatible!==!0)await t.makeXRCompatible();if(R=e.getPixelRatio(),e.getSize(E),!(m&&("createProjectionLayer"in XRWebGLBinding.prototype))){let j={antialias:g.antialias,alpha:!0,depth:g.depth,stencil:g.stencil,framebufferScaleFactor:r};d=new XRWebGLLayer(i,t,j),i.updateRenderState({baseLayer:d}),e.setPixelRatio(1),e.setSize(d.framebufferWidth,d.framebufferHeight,!1),T=new Cn(d.framebufferWidth,d.framebufferHeight,{format:Si,type:ni,colorSpace:e.outputColorSpace,stencilBuffer:g.stencil,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1,storeMultisampledDepthBuffer:d.ignoreDepthValues===!1,storeMultisampledStencilBuffer:d.ignoreDepthValues===!1})}else{let j=null,re=null,oe=null;if(g.depth)oe=g.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,j=g.stencil?jr:Xr,re=g.stencil?Us:mr;let ue={colorFormat:t.RGBA8,depthFormat:oe,scaleFactor:r};u=this.getBinding(),h=u.createProjectionLayer(ue),i.updateRenderState({layers:[h]}),e.setPixelRatio(1),e.setSize(h.textureWidth,h.textureHeight,!1),T=new Cn(h.textureWidth,h.textureHeight,{format:Si,type:ni,depthTexture:new Kr(h.textureWidth,h.textureHeight,re,void 0,void 0,void 0,void 0,void 0,void 0,j),stencilBuffer:g.stencil,colorSpace:e.outputColorSpace,samples:g.antialias?4:0,resolveDepthBuffer:h.ignoreDepthValues===!1,resolveStencilBuffer:h.ignoreDepthValues===!1,storeMultisampledDepthBuffer:h.ignoreDepthValues===!1,storeMultisampledStencilBuffer:h.ignoreDepthValues===!1})}T.isXRRenderTarget=!0,this.setFoveation(a),c=null,s=await i.requestReferenceSpace(o),fe.setContext(i),fe.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return _.getDepthTexture()};function P(I){for(let V=0;V<I.removed.length;V++){let j=I.removed[V],re=S.indexOf(j);if(re>=0)S[re]=null,v[re].disconnect(j)}for(let V=0;V<I.added.length;V++){let j=I.added[V],re=S.indexOf(j);if(re===-1){for(let ue=0;ue<v.length;ue++)if(ue>=S.length){S.push(j),re=ue;break}else if(S[ue]===null){S[ue]=j,re=ue;break}if(re===-1)break}let oe=v[re];if(oe)oe.connect(j)}}let J=new z,H=new z;function q(I,V,j){J.setFromMatrixPosition(V.matrixWorld),H.setFromMatrixPosition(j.matrixWorld);let re=J.distanceTo(H),oe=V.projectionMatrix.elements,ue=j.projectionMatrix.elements,$e=oe[14]/(oe[10]-1),Ce=oe[14]/(oe[10]+1),He=(oe[9]+1)/oe[5],rt=(oe[9]-1)/oe[5],nt=(oe[8]-1)/oe[0],Rt=(ue[8]+1)/ue[0],it=$e*nt,tn=$e*Rt,Ut=re/(-nt+Rt),It=Ut*-nt;if(V.matrixWorld.decompose(I.position,I.quaternion,I.scale),I.translateX(It),I.translateZ(Ut),I.matrixWorld.compose(I.position,I.quaternion,I.scale),I.matrixWorldInverse.copy(I.matrixWorld).invert(),oe[10]===-1)I.projectionMatrix.copy(V.projectionMatrix),I.projectionMatrixInverse.copy(V.projectionMatrixInverse);else{let O=$e+Ut,_n=Ce+Ut,ut=it-It,Pt=tn+(re-It),A=He*Ce/_n*O,y=rt*Ce/_n*O;I.projectionMatrix.makePerspective(ut,Pt,A,y,O,_n),I.projectionMatrixInverse.copy(I.projectionMatrix).invert()}}function Q(I,V){if(V===null)I.matrixWorld.copy(I.matrix);else I.matrixWorld.multiplyMatrices(V.matrixWorld,I.matrix);I.matrixWorldInverse.copy(I.matrixWorld).invert()}this.updateCamera=function(I){if(i===null)return;let{near:V,far:j}=I;if(_.texture!==null){if(_.depthNear>0)V=_.depthNear;if(_.depthFar>0)j=_.depthFar}if(D.near=G.near=w.near=V,D.far=G.far=w.far=j,ee!==D.near||L!==D.far)i.updateRenderState({depthNear:D.near,depthFar:D.far}),ee=D.near,L=D.far;D.layers.mask=I.layers.mask|6,w.layers.mask=D.layers.mask&-5,G.layers.mask=D.layers.mask&-3;let re=I.parent,oe=D.cameras;Q(D,re);for(let ue=0;ue<oe.length;ue++)Q(oe[ue],re);if(oe.length===2)q(D,w,G);else D.projectionMatrix.copy(w.projectionMatrix);if(x===null&&I.isPerspectiveCamera)x={camera:I,fov:I.fov,zoom:I.zoom};ge(I,D,re)};function ge(I,V,j){if(j===null)I.matrix.copy(V.matrixWorld);else I.matrix.copy(j.matrixWorld),I.matrix.invert(),I.matrix.multiply(V.matrixWorld);if(I.matrix.decompose(I.position,I.quaternion,I.scale),I.updateMatrixWorld(!0),I.projectionMatrix.copy(V.projectionMatrix),I.projectionMatrixInverse.copy(V.projectionMatrixInverse),I.isPerspectiveCamera)I.fov=$r*2*Math.atan(1/I.projectionMatrix.elements[5]),I.zoom=1}this.getCamera=function(){return D},this.getFoveation=function(){if(h===null&&d===null)return;return a},this.setFoveation=function(I){if(a=I,h!==null)h.fixedFoveation=I;if(d!==null&&d.fixedFoveation!==void 0)d.fixedFoveation=I},this.hasDepthSensing=function(){return _.texture!==null},this.getDepthSensingMesh=function(){return _.getMesh(D)},this.getCameraTexture=function(I){return p[I]};let he=null;function de(I,V){if(l=V.getViewerPose(c||s),f=V,l!==null){let j=l.views;if(d!==null)e.setRenderTargetFramebuffer(T,d.framebuffer),e.setRenderTarget(T);let re=!1;if(j.length!==D.cameras.length)D.cameras.length=0,re=!0;for(let Ce=0;Ce<j.length;Ce++){let He=j[Ce],rt=null;if(d!==null)rt=d.getViewport(He);else{let Rt=u.getViewSubImage(h,He);if(rt=Rt.viewport,Ce===0)e.setRenderTargetTextures(T,Rt.colorTexture,Rt.depthStencilTexture),e.setRenderTarget(T)}let nt=C[Ce];if(nt===void 0)nt=new Ht,nt.layers.enable(Ce),nt.viewport=new pt,C[Ce]=nt;if(nt.matrix.fromArray(He.transform.matrix),nt.matrix.decompose(nt.position,nt.quaternion,nt.scale),nt.projectionMatrix.fromArray(He.projectionMatrix),nt.projectionMatrixInverse.copy(nt.projectionMatrix).invert(),nt.viewport.set(rt.x,rt.y,rt.width,rt.height),Ce===0)D.matrix.copy(nt.matrix),D.matrix.decompose(D.position,D.quaternion,D.scale);if(re===!0)D.cameras.push(nt)}let oe=i.enabledFeatures;if(oe&&oe.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&m){u=n.getBinding();let Ce=u.getDepthInformation(j[0]);if(Ce&&Ce.isValid&&Ce.texture)_.init(Ce,i.renderState)}if(oe&&oe.includes("camera-access")&&m){e.state.unbindTexture(),u=n.getBinding();for(let Ce=0;Ce<j.length;Ce++){let He=j[Ce].camera;if(He){let rt=p[He];if(!rt)rt=new rl,p[He]=rt;let nt=u.getCameraImage(He);rt.sourceTexture=nt}}}}for(let j=0;j<v.length;j++){let re=S[j],oe=v[j];if(re!==null&&oe!==void 0)oe.update(re,V,c||s)}if(he)he(I,V);if(V.detectedPlanes)n.dispatchEvent({type:"planesdetected",data:V});f=null}let fe=new Kv;fe.setAnimationLoop(de),this.setAnimationLoop=function(I){he=I},this.dispose=function(){}}}var oC=new Xe,uy=new We;uy.set(-1,0,0,0,1,0,0,0,1);function aC(e,t){function n(p,g){if(p.matrixAutoUpdate===!0)p.updateMatrix();g.value.copy(p.matrix)}function i(p,g){if(g.color.getRGB(p.fogColor.value,gd(e)),g.isFog)p.fogNear.value=g.near,p.fogFar.value=g.far;else if(g.isFogExp2)p.fogDensity.value=g.density}function r(p,g,M,T,v){if(g.isNodeMaterial)g.uniformsNeedUpdate=!1;else if(g.isMeshBasicMaterial)s(p,g);else if(g.isMeshLambertMaterial){if(s(p,g),g.envMap)p.envMapIntensity.value=g.envMapIntensity}else if(g.isMeshToonMaterial)s(p,g),h(p,g);else if(g.isMeshPhongMaterial){if(s(p,g),u(p,g),g.envMap)p.envMapIntensity.value=g.envMapIntensity}else if(g.isMeshStandardMaterial){if(s(p,g),d(p,g),g.isMeshPhysicalMaterial)f(p,g,v)}else if(g.isMeshMatcapMaterial)s(p,g),m(p,g);else if(g.isMeshDepthMaterial)s(p,g);else if(g.isMeshDistanceMaterial)s(p,g),_(p,g);else if(g.isMeshNormalMaterial)s(p,g);else if(g.isLineBasicMaterial){if(o(p,g),g.isLineDashedMaterial)a(p,g)}else if(g.isPointsMaterial)c(p,g,M,T);else if(g.isSpriteMaterial)l(p,g);else if(g.isShadowMaterial)p.color.value.copy(g.color),p.opacity.value=g.opacity;else if(g.isShaderMaterial)g.uniformsNeedUpdate=!1}function s(p,g){if(p.opacity.value=g.opacity,g.color)p.diffuse.value.copy(g.color);if(g.emissive)p.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity);if(g.map)p.map.value=g.map,n(g.map,p.mapTransform);if(g.alphaMap)p.alphaMap.value=g.alphaMap,n(g.alphaMap,p.alphaMapTransform);if(g.bumpMap){if(p.bumpMap.value=g.bumpMap,n(g.bumpMap,p.bumpMapTransform),p.bumpScale.value=g.bumpScale,g.side===cn)p.bumpScale.value*=-1}if(g.normalMap){if(p.normalMap.value=g.normalMap,n(g.normalMap,p.normalMapTransform),p.normalScale.value.copy(g.normalScale),g.side===cn)p.normalScale.value.negate()}if(g.displacementMap)p.displacementMap.value=g.displacementMap,n(g.displacementMap,p.displacementMapTransform),p.displacementScale.value=g.displacementScale,p.displacementBias.value=g.displacementBias;if(g.emissiveMap)p.emissiveMap.value=g.emissiveMap,n(g.emissiveMap,p.emissiveMapTransform);if(g.specularMap)p.specularMap.value=g.specularMap,n(g.specularMap,p.specularMapTransform);if(g.alphaTest>0)p.alphaTest.value=g.alphaTest;let M=t.get(g),{envMap:T,envMapRotation:v}=M;if(T){if(p.envMap.value=T,p.envMapRotation.value.setFromMatrix4(oC.makeRotationFromEuler(v)).transpose(),T.isCubeTexture&&T.isRenderTargetTexture===!1)p.envMapRotation.value.premultiply(uy);p.reflectivity.value=g.reflectivity,p.ior.value=g.ior,p.refractionRatio.value=g.refractionRatio}if(g.lightMap)p.lightMap.value=g.lightMap,p.lightMapIntensity.value=g.lightMapIntensity,n(g.lightMap,p.lightMapTransform);if(g.aoMap)p.aoMap.value=g.aoMap,p.aoMapIntensity.value=g.aoMapIntensity,n(g.aoMap,p.aoMapTransform)}function o(p,g){if(p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,g.map)p.map.value=g.map,n(g.map,p.mapTransform)}function a(p,g){p.dashSize.value=g.dashSize,p.totalSize.value=g.dashSize+g.gapSize,p.scale.value=g.scale}function c(p,g,M,T){if(p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.size.value=g.size*M,p.scale.value=T*0.5,g.map)p.map.value=g.map,n(g.map,p.uvTransform);if(g.alphaMap)p.alphaMap.value=g.alphaMap,n(g.alphaMap,p.alphaMapTransform);if(g.alphaTest>0)p.alphaTest.value=g.alphaTest}function l(p,g){if(p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.rotation.value=g.rotation,g.map)p.map.value=g.map,n(g.map,p.mapTransform);if(g.alphaMap)p.alphaMap.value=g.alphaMap,n(g.alphaMap,p.alphaMapTransform);if(g.alphaTest>0)p.alphaTest.value=g.alphaTest}function u(p,g){p.specular.value.copy(g.specular),p.shininess.value=Math.max(g.shininess,0.0001)}function h(p,g){if(g.gradientMap)p.gradientMap.value=g.gradientMap}function d(p,g){if(p.metalness.value=g.metalness,g.metalnessMap)p.metalnessMap.value=g.metalnessMap,n(g.metalnessMap,p.metalnessMapTransform);if(p.roughness.value=g.roughness,g.roughnessMap)p.roughnessMap.value=g.roughnessMap,n(g.roughnessMap,p.roughnessMapTransform);if(g.envMap)p.envMapIntensity.value=g.envMapIntensity}function f(p,g,M){if(p.ior.value=g.ior,g.sheen>0){if(p.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),p.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap)p.sheenColorMap.value=g.sheenColorMap,n(g.sheenColorMap,p.sheenColorMapTransform);if(g.sheenRoughnessMap)p.sheenRoughnessMap.value=g.sheenRoughnessMap,n(g.sheenRoughnessMap,p.sheenRoughnessMapTransform)}if(g.clearcoat>0){if(p.clearcoat.value=g.clearcoat,p.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap)p.clearcoatMap.value=g.clearcoatMap,n(g.clearcoatMap,p.clearcoatMapTransform);if(g.clearcoatRoughnessMap)p.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,n(g.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform);if(g.clearcoatNormalMap){if(p.clearcoatNormalMap.value=g.clearcoatNormalMap,n(g.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===cn)p.clearcoatNormalScale.value.negate()}}if(g.dispersion>0)p.dispersion.value=g.dispersion;if(g.retroreflectivity>0)p.retroreflectivity.value=g.retroreflectivity;if(g.iridescence>0){if(p.iridescence.value=g.iridescence,p.iridescenceIOR.value=g.iridescenceIOR,p.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap)p.iridescenceMap.value=g.iridescenceMap,n(g.iridescenceMap,p.iridescenceMapTransform);if(g.iridescenceThicknessMap)p.iridescenceThicknessMap.value=g.iridescenceThicknessMap,n(g.iridescenceThicknessMap,p.iridescenceThicknessMapTransform)}if(g.transmission>0){if(p.transmission.value=g.transmission,p.transmissionSamplerMap.value=M.texture,p.transmissionSamplerSize.value.set(M.width,M.height),g.transmissionMap)p.transmissionMap.value=g.transmissionMap,n(g.transmissionMap,p.transmissionMapTransform);if(p.thickness.value=g.thickness,g.thicknessMap)p.thicknessMap.value=g.thicknessMap,n(g.thicknessMap,p.thicknessMapTransform);p.attenuationDistance.value=g.attenuationDistance,p.attenuationColor.value.copy(g.attenuationColor)}if(g.anisotropy>0){if(p.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap)p.anisotropyMap.value=g.anisotropyMap,n(g.anisotropyMap,p.anisotropyMapTransform)}if(p.specularIntensity.value=g.specularIntensity,p.specularColor.value.copy(g.specularColor),g.specularColorMap)p.specularColorMap.value=g.specularColorMap,n(g.specularColorMap,p.specularColorMapTransform);if(g.specularIntensityMap)p.specularIntensityMap.value=g.specularIntensityMap,n(g.specularIntensityMap,p.specularIntensityMapTransform)}function m(p,g){if(g.matcap)p.matcap.value=g.matcap}function _(p,g){let M=t.get(g).light;p.referencePosition.value.setFromMatrixPosition(M.matrixWorld),p.nearDistance.value=M.shadow.camera.near,p.farDistance.value=M.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function cC(e,t,n,i){let r={},s={},o=[],a=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function c(v,S){let E=S.program;i.uniformBlockBinding(v,E)}function l(v,S){let E=r[v.id];if(E===void 0)p(v),E=u(v),r[v.id]=E,v.addEventListener("dispose",M);let R=S.program;i.updateUBOMapping(v,R);let x=t.render.frame;if(s[v.id]!==x)d(v),s[v.id]=x}function u(v){let S=h();v.__bindingPointIndex=S;let E=e.createBuffer(),{__size:R,usage:x}=v;return e.bindBuffer(e.UNIFORM_BUFFER,E),e.bufferData(e.UNIFORM_BUFFER,R,x),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,S,E),E}function h(){for(let v=0;v<a;v++)if(o.indexOf(v)===-1)return o.push(v),v;return Ve("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(v){let S=r[v.id],{uniforms:E,__cache:R}=v;e.bindBuffer(e.UNIFORM_BUFFER,S);for(let x=0,w=E.length;x<w;x++){let G=E[x];if(Array.isArray(G))for(let C=0,D=G.length;C<D;C++)f(G[C],x,C,R);else f(G,x,0,R)}e.bindBuffer(e.UNIFORM_BUFFER,null)}function f(v,S,E,R){if(_(v,S,E,R)===!0){let{__offset:x,value:w}=v;if(Array.isArray(w)){let G=0;for(let C=0;C<w.length;C++){let D=w[C],ee=g(D);if(m(D,v.__data,G),typeof D!=="number"&&typeof D!=="boolean"&&!D.isMatrix3&&!ArrayBuffer.isView(D))G+=ee.storage/Float32Array.BYTES_PER_ELEMENT}}else m(w,v.__data,0);e.bufferSubData(e.UNIFORM_BUFFER,x,v.__data)}}function m(v,S,E){if(typeof v==="number"||typeof v==="boolean")S[0]=v;else if(v.isMatrix3)S[0]=v.elements[0],S[1]=v.elements[1],S[2]=v.elements[2],S[3]=0,S[4]=v.elements[3],S[5]=v.elements[4],S[6]=v.elements[5],S[7]=0,S[8]=v.elements[6],S[9]=v.elements[7],S[10]=v.elements[8],S[11]=0;else if(ArrayBuffer.isView(v))S.set(new v.constructor(v.buffer,v.byteOffset,S.length));else v.toArray(S,E)}function _(v,S,E,R){let x=v.value,w=S+"_"+E;if(R[w]===void 0){if(typeof x==="number"||typeof x==="boolean")R[w]=x;else if(ArrayBuffer.isView(x))R[w]=x.slice();else R[w]=x.clone();return!0}else{let G=R[w];if(typeof x==="number"||typeof x==="boolean"){if(G!==x)return R[w]=x,!0}else if(ArrayBuffer.isView(x))return!0;else if(G.equals(x)===!1)return G.copy(x),!0}return!1}function p(v){let S=v.uniforms,E=0,R=16;for(let w=0,G=S.length;w<G;w++){let C=Array.isArray(S[w])?S[w]:[S[w]];for(let D=0,ee=C.length;D<ee;D++){let L=C[D],W=Array.isArray(L.value)?L.value:[L.value];for(let B=0,P=W.length;B<P;B++){let J=W[B],H=g(J),q=E%R,Q=q%H.boundary,ge=q+Q;if(E+=Q,ge!==0&&R-ge<H.storage)E+=R-ge;L.__data=new Float32Array(H.storage/Float32Array.BYTES_PER_ELEMENT),L.__offset=E,E+=H.storage}}}let x=E%R;if(x>0)E+=R-x;return v.__size=E,v.__cache={},this}function g(v){let S={boundary:0,storage:0};if(typeof v==="number"||typeof v==="boolean")S.boundary=4,S.storage=4;else if(v.isVector2)S.boundary=8,S.storage=8;else if(v.isVector3||v.isColor)S.boundary=16,S.storage=12;else if(v.isVector4)S.boundary=16,S.storage=16;else if(v.isMatrix3)S.boundary=48,S.storage=48;else if(v.isMatrix4)S.boundary=64,S.storage=64;else if(v.isTexture)Ue("WebGLRenderer: Texture samplers can not be part of an uniforms group.");else if(ArrayBuffer.isView(v))S.boundary=16,S.storage=v.byteLength;else Ue("WebGLRenderer: Unsupported uniform value type.",v);return S}function M(v){let S=v.target;S.removeEventListener("dispose",M);let E=o.indexOf(S.__bindingPointIndex);o.splice(E,1),e.deleteBuffer(r[S.id]),delete r[S.id],delete s[S.id]}function T(){for(let v in r)e.deleteBuffer(r[v]);o=[],r={},s={}}return{bind:c,update:l,dispose:T}}var lC=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),Mi=null;function uC(){if(Mi===null)Mi=new Qo(lC,16,16,qr,bi),Mi.name="DFG_LUT",Mi.minFilter=Jt,Mi.magFilter=Jt,Mi.wrapS=Ds,Mi.wrapT=Ds,Mi.generateMipmaps=!1,Mi.needsUpdate=!0;return Mi}class Hd{constructor(e={}){let{canvas:t=_v(),context:n=null,depth:i=!0,stencil:r=!1,alpha:s=!1,antialias:o=!1,premultipliedAlpha:a=!0,preserveDrawingBuffer:c=!1,powerPreference:l="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:h=!1,outputBufferType:d=ni}=e;this.isWebGLRenderer=!0;let f;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");f=n.getContextAttributes().alpha}else f=s;let m=d,_=new Set([Rh,Ah,Th]),p=new Set([ni,mr,Zo,Us,Mh,Eh]),g=new Uint32Array(4),M=new Int32Array(4),T=new z,v=null,S=null,E=[],R=[],x=null;this.domElement=t,this.debug={checkShaderErrors:!0,diagnostics:{keywords:!1},onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=ei,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let w=this,G=!1,C=null,D=null,ee=null,L=null;this._outputColorSpace=gr;let W=0,B=0,P=null,J=-1,H=null,q=new pt,Q=new pt,ge=null,he=new Ge(0),de=0,{width:fe,height:I}=t,V=1,j=null,re=null,oe=new pt(0,0,fe,I),ue=new pt(0,0,fe,I),$e=!1,Ce=new ta,He=!1,rt=!1,nt=new Xe,Rt=new z,it=new pt,tn={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},Ut=!1;function It(){return P===null?V:1}let O=n;function _n(b,F){return t.getContext(b,F)}let ut,Pt,A,y,U,Y,le,me,ve,te,se,Ee,Oe,ye,pe,ze,Be,ot,k,_e,ne,xe,Te;try{let b={alpha:!0,depth:i,stencil:r,antialias:o,premultipliedAlpha:a,preserveDrawingBuffer:c,powerPreference:l,failIfMajorPerformanceCaveat:u};if("setAttribute"in t)t.setAttribute("data-engine",`three.js r${wx}`);if(t.addEventListener("webglcontextlost",Ze,!1),t.addEventListener("webglcontextrestored",bt,!1),t.addEventListener("webglcontextcreationerror",ht,!1),O===null){if(O=_n("webgl2",b),O===null)if(_n("webgl2"))throw Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes.");else throw Error("THREE.WebGLRenderer: Error creating WebGL context.")}ce()}catch(b){throw t.removeEventListener("webglcontextlost",Ze,!1),t.removeEventListener("webglcontextrestored",bt,!1),t.removeEventListener("webglcontextcreationerror",ht,!1),Ve("WebGLRenderer: "+b.message),b}function ce(){if(ut=new _1(O),ut.init(),ne=new iC(O,ut),Pt=new a1(O,ut,e,ne),A=new tC(O,ut),Pt.reversedDepthBuffer&&h)A.buffers.depth.setReversed(!0);D=O.createFramebuffer(),ee=O.createFramebuffer(),L=O.createFramebuffer(),y=new y1(O),U=new GR,Y=new nC(O,ut,A,U,Pt,ne,y),le=new g1(w),me=new SE(O),xe=new s1(O,me),ve=new x1(O,me,y,xe),te=new S1(O,ve,me,xe,y),ot=new b1(O,Pt,Y),pe=new c1(U),se=new BR(w,le,ut,Pt,xe,pe),Ee=new aC(w,U),Oe=new VR,ye=new qR(ut),Be=new r1(w,le,A,te,f,a),ze=new eC(w,te,Pt),Te=new cC(O,y,Pt,A),k=new o1(O,ut,y),_e=new v1(O,ut,y),y.programs=se.programs,w.capabilities=Pt,w.extensions=ut,w.properties=U,w.renderLists=Oe,w.shadowMap=ze,w.state=A,w.info=y}if(m!==ni)x=new M1(m,t.width,t.height,o,i,r);let Se=new ly(w,O);this.xr=Se,this.getContext=function(){return O},this.getContextAttributes=function(){return O.getContextAttributes()},this.forceContextLoss=function(){let b=ut.get("WEBGL_lose_context");if(b)b.loseContext()},this.forceContextRestore=function(){let b=ut.get("WEBGL_lose_context");if(b)b.restoreContext()},this.getPixelRatio=function(){return V},this.setPixelRatio=function(b){if(b===void 0)return;V=b,this.setSize(fe,I,!1)},this.getSize=function(b){return b.set(fe,I)},this.setSize=function(b,F,K=!0){if(Se.isPresenting){Ue("WebGLRenderer: Can't change size while VR device is presenting.");return}if(fe=b,I=F,t.width=Math.floor(b*V),t.height=Math.floor(F*V),K===!0)t.style.width=b+"px",t.style.height=F+"px";if(x!==null)x.setSize(t.width,t.height);this.setViewport(0,0,b,F)},this.getDrawingBufferSize=function(b){return b.set(fe*V,I*V).floor()},this.setDrawingBufferSize=function(b,F,K){fe=b,I=F,V=K,t.width=Math.floor(b*K),t.height=Math.floor(F*K),this.setViewport(0,0,b,F)},this.setEffects=function(b){if(m===ni){Ve("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(b){for(let F=0;F<b.length;F++)if(b[F].isOutputPass===!0){Ue("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}x.setEffects(b||[])},this.getCurrentViewport=function(b){return b.copy(q)},this.getViewport=function(b){return b.copy(oe)},this.setViewport=function(b,F,K,Z){if(b.isVector4)oe.set(b.x,b.y,b.z,b.w);else oe.set(b,F,K,Z);A.viewport(q.copy(oe).multiplyScalar(V).round())},this.getScissor=function(b){return b.copy(ue)},this.setScissor=function(b,F,K,Z){if(b.isVector4)ue.set(b.x,b.y,b.z,b.w);else ue.set(b,F,K,Z);A.scissor(Q.copy(ue).multiplyScalar(V).round())},this.getScissorTest=function(){return $e},this.setScissorTest=function(b){A.setScissorTest($e=b)},this.setOpaqueSort=function(b){j=b},this.setTransparentSort=function(b){re=b},this.getClearColor=function(b){return b.copy(Be.getClearColor())},this.setClearColor=function(){Be.setClearColor(...arguments)},this.getClearAlpha=function(){return Be.getClearAlpha()},this.setClearAlpha=function(){Be.setClearAlpha(...arguments)},this.clear=function(b=!0,F=!0,K=!0){let Z=0;if(b){let X=!1;if(P!==null){let Me=P.texture.format;X=_.has(Me)}if(X){let Me=P.texture.type,Re=p.has(Me),we=Be.getClearColor(),Ie=Be.getClearAlpha(),{r:Ne,g:je,b:et}=we;if(Re)g[0]=Ne,g[1]=je,g[2]=et,g[3]=Ie,O.clearBufferuiv(O.COLOR,0,g);else M[0]=Ne,M[1]=je,M[2]=et,M[3]=Ie,O.clearBufferiv(O.COLOR,0,M)}else Z|=O.COLOR_BUFFER_BIT}if(F)Z|=O.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0);if(K)Z|=O.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295);if(Z!==0)O.clear(Z)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(b){b.setRenderer(this),C=b},this.dispose=function(){t.removeEventListener("webglcontextlost",Ze,!1),t.removeEventListener("webglcontextrestored",bt,!1),t.removeEventListener("webglcontextcreationerror",ht,!1),Be.dispose(),Oe.dispose(),ye.dispose(),U.dispose(),le.dispose(),te.dispose(),xe.dispose(),Te.dispose(),se.dispose(),Se.dispose(),Se.removeEventListener("sessionstart",xf),Se.removeEventListener("sessionend",vf),Lr.stop()};function Ze(b){b.preventDefault(),Go("WebGLRenderer: Context Lost."),G=!0}function bt(){Go("WebGLRenderer: Context Restored."),G=!1;let b=y.autoReset,F=ze.enabled,K=ze.autoUpdate,Z=ze.needsUpdate,X=ze.type;ce(),y.autoReset=b,ze.enabled=F,ze.autoUpdate=K,ze.needsUpdate=Z,ze.type=X}function ht(b){Ve("WebGLRenderer: A WebGL context could not be created. Reason: ",b.statusMessage)}function oi(b){let F=b.target;F.removeEventListener("dispose",oi),Li(F)}function Li(b){Ib(b),U.remove(b)}function Ib(b){let F=U.get(b).programs;if(F!==void 0){if(F.forEach(function(K){se.releaseProgram(K)}),b.isShaderMaterial)se.releaseShaderCache(b)}}this.renderBufferDirect=function(b,F,K,Z,X,Me){if(F===null)F=tn;let Re=X.isMesh&&X.matrixWorld.determinantAffine()<0,we=Nb(b,F,K,Z,X);A.setMaterial(Z,Re);let Ie=K.index,Ne=1;if(Z.wireframe===!0){if(Ie=ve.getWireframeAttribute(K),Ie===void 0)return;Ne=2}let je=K.drawRange,et=K.attributes.position,Pe=je.start*Ne,dt=(je.start+je.count)*Ne;if(Me!==null)Pe=Math.max(Pe,Me.start*Ne),dt=Math.min(dt,(Me.start+Me.count)*Ne);if(Ie!==null)Pe=Math.max(Pe,0),dt=Math.min(dt,Ie.count);else if(et!==void 0&&et!==null)Pe=Math.max(Pe,0),dt=Math.min(dt,et.count);let Bt=dt-Pe;if(Bt<0||Bt===1/0)return;xe.setup(X,Z,we,K,Ie);let Et,xt=k;if(Ie!==null)Et=me.get(Ie),xt=_e,xt.setIndex(Et);if(X.isMesh)if(Z.wireframe===!0)A.setLineWidth(Z.wireframeLinewidth*It()),xt.setMode(O.LINES);else xt.setMode(O.TRIANGLES);else if(X.isLine){let sn=Z.linewidth;if(sn===void 0)sn=1;if(A.setLineWidth(sn*It()),X.isLineSegments)xt.setMode(O.LINES);else if(X.isLineLoop)xt.setMode(O.LINE_LOOP);else xt.setMode(O.LINE_STRIP)}else if(X.isPoints)xt.setMode(O.POINTS);else if(X.isSprite)xt.setMode(O.TRIANGLES);if(X.isBatchedMesh)if(!ut.get("WEBGL_multi_draw")){let{_multiDrawStarts:sn,_multiDrawCounts:Ae,_multiDrawCount:dn}=X,st=Ie?me.get(Ie).bytesPerElement:1,Nn=U.get(Z).currentProgram.getUniforms();for(let ai=0;ai<dn;ai++)Nn.setValue(O,"_gl_DrawID",ai),xt.render(sn[ai]/st,Ae[ai])}else xt.renderMultiDraw(X._multiDrawStarts,X._multiDrawCounts,X._multiDrawCount);else if(X.isInstancedMesh)xt.renderInstances(Pe,Bt,X.count);else if(K.isInstancedBufferGeometry){let sn=K._maxInstanceCount!==void 0?K._maxInstanceCount:1/0,Ae=Math.min(K.instanceCount,sn);xt.renderInstances(Pe,Bt,Ae)}else xt.render(Pe,Bt)};function _f(b,F,K,Z){if(C!==null&&b.isNodeMaterial)C.setObject(Z,b);if(He===!0)pe.setState(b,K,!1);if(b.transparent===!0&&b.side===Bn&&b.forceSinglePass===!1)b.side=cn,b.needsUpdate=!0,Ta(b,F,Z),b.side=pr,b.needsUpdate=!0,Ta(b,F,Z),b.side=Bn;else Ta(b,F,Z)}this.compile=function(b,F,K=null){if(K===null)K=b;if(C!==null)C.renderStart(b,F,K);if(S=ye.get(K),S.init(F),R.push(S),K.traverseVisible(function(X){if(X.isLight&&X.layers.test(F.layers)){if(S.pushLight(X),X.castShadow)S.pushShadow(X)}}),b!==K)b.traverseVisible(function(X){if(X.isLight&&X.layers.test(F.layers)){if(S.pushLight(X),X.castShadow)S.pushShadow(X)}});if(S.setupLights(),C!==null)C.updateLights(S.state.lightsArray);if(rt=this.localClippingEnabled,He=pe.init(this.clippingPlanes,rt),He===!0)pe.setGlobalState(this.clippingPlanes,F);if(C!==null)ze.render(S.state.shadowsArray,K,F);let Z=new Set;if(b.traverse(function(X){if(!(X.isMesh||X.isPoints||X.isLine||X.isSprite))return;let Me=X.material;if(Me)if(Array.isArray(Me))for(let Re=0;Re<Me.length;Re++){let we=Me[Re];_f(we,K,F,X),Z.add(we)}else _f(Me,K,F,X),Z.add(Me)}),S=R.pop(),C!==null)C.renderEnd();return Z},this.compileAsync=function(b,F,K=null){let Z=this.compile(b,F,K);return new Promise((X)=>{function Me(){if(Z.forEach(function(Re){let Ie=U.get(Re).currentProgram;if(Ie===void 0||Ie.isReady())Z.delete(Re)}),Z.size===0){X(b);return}setTimeout(Me,10)}if(ut.get("KHR_parallel_shader_compile")!==null)Me();else setTimeout(Me,10)})};let Ml=null;function Pb(b){if(Ml)Ml(b)}function xf(){Lr.stop()}function vf(){Lr.start()}let Lr=new Kv;if(Lr.setAnimationLoop(Pb),typeof self<"u")Lr.setContext(self);this.setAnimationLoop=function(b){Ml=b,Se.setAnimationLoop(b),b===null?Lr.stop():Lr.start()},Se.addEventListener("sessionstart",xf),Se.addEventListener("sessionend",vf),this.render=function(b,F){if(F!==void 0&&F.isCamera!==!0){Ve("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(G===!0)return;if(C!==null)C.renderStart(b,F);let K=Se.enabled===!0&&Se.isPresenting===!0,Z=x!==null&&(P===null||K)&&x.begin(w,P);if(b.matrixWorldAutoUpdate===!0)b.updateMatrixWorld();if(F.parent===null&&F.matrixWorldAutoUpdate===!0)F.updateMatrixWorld();if(Se.enabled===!0&&Se.isPresenting===!0&&(x===null||x.isCompositing()===!1)){if(Se.cameraAutoUpdate===!0)Se.updateCamera(F);F=Se.getCamera()}if(b.isScene===!0)b.onBeforeRender(w,b,F,P);if(S=ye.get(b,R.length),S.init(F),S.state.textureUnits=Y.getTextureUnits(),R.push(S),nt.multiplyMatrices(F.projectionMatrix,F.matrixWorldInverse),Ce.setFromProjectionMatrix(nt,ud,F.reversedDepth),rt=this.localClippingEnabled,He=pe.init(this.clippingPlanes,rt),v=Oe.get(b,E.length),v.init(),E.push(v),Se.enabled===!0&&Se.isPresenting===!0){let Re=w.xr.getDepthSensingMesh();if(Re!==null)El(Re,F,-1/0,w.sortObjects)}if(El(b,F,0,w.sortObjects),v.finish(),C!==null)C.updateLights(S.state.lightsArray);if(w.sortObjects===!0)v.sort(j,re);if(Ut=Se.enabled===!1||Se.isPresenting===!1||Se.hasDepthSensing()===!1,Ut)Be.addToRenderList(v,b);if(this.info.render.frame++,this.info.autoReset===!0)this.info.reset();if(He===!0)pe.beginShadows();let X=S.state.shadowsArray;if(ze.render(X,b,F),He===!0)pe.endShadows();if((Z&&x.hasRenderPass())===!1){let Re=v.opaque,we=v.transmissive;if(S.setupLights(),F.isArrayCamera){let Ie=F.cameras;if(we.length>0)for(let Ne=0,je=Ie.length;Ne<je;Ne++){let et=Ie[Ne];bf(Re,we,b,et)}if(Ut)Be.render(b);for(let Ne=0,je=Ie.length;Ne<je;Ne++){let et=Ie[Ne];yf(v,b,et,et.viewport)}}else{if(we.length>0)bf(Re,we,b,F);if(Ut)Be.render(b);yf(v,b,F)}}if(P!==null&&B===0)Y.updateMultisampleRenderTarget(P),Y.updateRenderTargetMipmap(P);if(Z)x.end(w);if(b.isScene===!0)b.onAfterRender(w,b,F);if(xe.resetDefaultState(),J=-1,H=null,R.pop(),R.length>0){if(S=R[R.length-1],Y.setTextureUnits(S.state.textureUnits),He===!0)pe.setGlobalState(w.clippingPlanes,S.state.camera)}else S=null;if(E.pop(),E.length>0)v=E[E.length-1];else v=null;if(C!==null)C.renderEnd()};function El(b,F,K,Z){if(b.visible===!1)return;if(b.layers.test(F.layers)){if(b.isGroup)K=b.renderOrder;else if(b.isLOD){if(b.autoUpdate===!0)b.update(F)}else if(b.isLightProbeGrid)S.pushLightProbeGrid(b);else if(b.isLight){if(S.pushLight(b),b.castShadow)S.pushShadow(b)}else if(b.isSprite){if(!b.frustumCulled||b.intersectsFrustum(Ce)){if(Z)it.setFromMatrixPosition(b.matrixWorld).applyMatrix4(nt);let Re=te.update(b),we=b.material;if(we.visible)v.push(b,Re,we,K,it.z,null,F)}}else if(b.isMesh||b.isLine||b.isPoints){if(!b.frustumCulled||b.intersectsFrustum(Ce)){let Re=te.update(b),we=b.material;if(Z){if(b.boundingSphere!==void 0){if(b.boundingSphere===null)b.computeBoundingSphere();it.copy(b.boundingSphere.center)}else{if(Re.boundingSphere===null)Re.computeBoundingSphere();it.copy(Re.boundingSphere.center)}it.applyMatrix4(b.matrixWorld).applyMatrix4(nt)}if(Array.isArray(we)){let Ie=Re.groups;for(let Ne=0,je=Ie.length;Ne<je;Ne++){let et=Ie[Ne],Pe=we[et.materialIndex];if(Pe&&Pe.visible)v.push(b,Re,Pe,K,it.z,et,F)}}else if(we.visible)v.push(b,Re,we,K,it.z,null,F)}}}let Me=b.children;for(let Re=0,we=Me.length;Re<we;Re++)El(Me[Re],F,K,Z)}function yf(b,F,K,Z){let{opaque:X,transmissive:Me,transparent:Re}=b;if(S.setupLightsView(K),He===!0)pe.setGlobalState(w.clippingPlanes,K);if(Z)A.viewport(q.copy(Z));if(X.length>0)Ea(X,F,K);if(Me.length>0)Ea(Me,F,K);if(Re.length>0)Ea(Re,F,K);A.buffers.depth.setTest(!0),A.buffers.depth.setMask(!0),A.buffers.color.setMask(!0),A.setPolygonOffset(!1)}function bf(b,F,K,Z){if((K.isScene===!0?K.overrideMaterial:null)!==null)return;if(S.state.transmissionRenderTarget[Z.id]===void 0){let Pe=ut.has("EXT_color_buffer_half_float")||ut.has("EXT_color_buffer_float");S.state.transmissionRenderTarget[Z.id]=new Cn(1,1,{generateMipmaps:!0,type:Pe?bi:ni,minFilter:yi,samples:Math.max(4,Pt.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:Ke.workingColorSpace})}let Me=S.state.transmissionRenderTarget[Z.id],Re=Z.viewport||q;Me.setSize(Re.z*w.transmissionResolutionScale,Re.w*w.transmissionResolutionScale);let we=w.getRenderTarget(),Ie=w.getActiveCubeFace(),Ne=w.getActiveMipmapLevel();if(w.setRenderTarget(Me),w.getClearColor(he),de=w.getClearAlpha(),de<1)w.setClearColor(16777215,0.5);if(w.clear(),Ut)Be.render(K);let je=w.toneMapping;w.toneMapping=ei;let et=Z.viewport;if(Z.viewport!==void 0)Z.viewport=void 0;if(S.setupLightsView(Z),He===!0)pe.setGlobalState(w.clippingPlanes,Z);if(Ea(b,K,Z),Y.updateMultisampleRenderTarget(Me),Y.updateRenderTargetMipmap(Me),ut.has("WEBGL_multisampled_render_to_texture")===!1){let Pe=!1;for(let dt=0,Bt=F.length;dt<Bt;dt++){let Et=F[dt],{object:xt,geometry:sn,material:Ae,group:dn}=Et;if(Ae.side===Bn&&xt.layers.test(Z.layers)){let st=Ae.side;Ae.side=cn,Ae.needsUpdate=!0,Sf(xt,K,Z,sn,Ae,dn),Ae.side=st,Ae.needsUpdate=!0,Pe=!0}}if(Pe===!0)Y.updateMultisampleRenderTarget(Me),Y.updateRenderTargetMipmap(Me)}if(w.setRenderTarget(we,Ie,Ne),w.setClearColor(he,de),et!==void 0)Z.viewport=et;w.toneMapping=je}function Ea(b,F,K){let Z=F.isScene===!0?F.overrideMaterial:null;for(let X=0,Me=b.length;X<Me;X++){let Re=b[X],{object:we,geometry:Ie,group:Ne}=Re,je=Re.material;if(je.allowOverride===!0&&Z!==null)je=Z;if(we.layers.test(K.layers))Sf(we,F,K,Ie,je,Ne)}}function Sf(b,F,K,Z,X,Me){if(C!==null&&X.isNodeMaterial)C.setObject(b,X);if(b.onBeforeRender(w,F,K,Z,X,Me),b.modelViewMatrix.multiplyMatrices(K.matrixWorldInverse,b.matrixWorld),b.normalMatrix.getNormalMatrix(b.modelViewMatrix),X.onBeforeRender(w,F,K,Z,b,Me),X.transparent===!0&&X.side===Bn&&X.forceSinglePass===!1)X.side=cn,X.needsUpdate=!0,w.renderBufferDirect(K,F,Z,X,b,Me),X.side=pr,X.needsUpdate=!0,w.renderBufferDirect(K,F,Z,X,b,Me),X.side=Bn;else w.renderBufferDirect(K,F,Z,X,b,Me);b.onAfterRender(w,F,K,Z,X,Me)}function Ta(b,F,K){if(F.isScene!==!0)F=tn;let Z=U.get(b),X=S.state.lights,Me=S.state.shadowsArray,Re=X.state.version,we=se.getParameters(b,X.state,Me,F,K,S.state.lightProbeGridArray),Ie=se.getProgramCacheKey(we),Ne=Z.programs;Z.environment=b.isMeshStandardMaterial||b.isMeshLambertMaterial||b.isMeshPhongMaterial?F.environment:null,Z.fog=F.fog;let je=b.isMeshStandardMaterial||b.isMeshLambertMaterial&&!b.envMap||b.isMeshPhongMaterial&&!b.envMap;if(Z.envMap=le.get(b.envMap||Z.environment,je),Z.envMapRotation=Z.environment!==null&&b.envMap===null?F.environmentRotation:b.envMapRotation,Ne===void 0)b.addEventListener("dispose",oi),Ne=new Map,Z.programs=Ne;let et=Ne.get(Ie);if(et!==void 0){if(Z.currentProgram===et&&Z.lightsStateVersion===Re)return Mf(b,we),et}else{if(we.uniforms=se.getUniforms(b),C!==null&&b.isNodeMaterial)C.build(b,K,we);b.onBeforeCompile(we,w),et=se.acquireProgram(we,Ie),Ne.set(Ie,et),Z.uniforms=we.uniforms}let Pe=Z.uniforms;if(!b.isShaderMaterial&&!b.isRawShaderMaterial||b.clipping===!0)Pe.clippingPlanes=pe.uniform;if(Mf(b,we),Z.needsLights=Ob(b),Z.lightsStateVersion=Re,Z.needsLights)Pe.ambientLightColor.value=X.state.ambient,Pe.lightProbe.value=X.state.probe,Pe.sunLights.value=X.state.sun,Pe.sunLightShadows.value=X.state.sunShadow,Pe.directionalLights.value=X.state.directional,Pe.directionalLightShadows.value=X.state.directionalShadow,Pe.spotLights.value=X.state.spot,Pe.spotLightShadows.value=X.state.spotShadow,Pe.rectAreaLights.value=X.state.rectArea,Pe.ltc_1.value=X.state.rectAreaLTC1,Pe.ltc_2.value=X.state.rectAreaLTC2,Pe.pointLights.value=X.state.point,Pe.pointLightShadows.value=X.state.pointShadow,Pe.hemisphereLights.value=X.state.hemi,Pe.sunShadowMatrix.value=X.state.sunShadowMatrix,Pe.sunShadowCascade.value=X.state.sunShadowCascade,Pe.directionalShadowMatrix.value=X.state.directionalShadowMatrix,Pe.spotLightMatrix.value=X.state.spotLightMatrix,Pe.spotLightMap.value=X.state.spotLightMap,Pe.pointShadowMatrix.value=X.state.pointShadowMatrix;return Z.lightProbeGrid=S.state.lightProbeGridArray.length>0,Z.currentProgram=et,Z.uniformsList=null,et}function wf(b){if(b.uniformsList===null){let F=b.currentProgram.getUniforms();b.uniformsList=da.seqWithValue(F.seq,b.uniforms)}return b.uniformsList}function Mf(b,F){let K=U.get(b);K.outputColorSpace=F.outputColorSpace,K.batching=F.batching,K.batchingColor=F.batchingColor,K.instancing=F.instancing,K.instancingColor=F.instancingColor,K.instancingMorph=F.instancingMorph,K.skinning=F.skinning,K.morphTargets=F.morphTargets,K.morphNormals=F.morphNormals,K.morphColors=F.morphColors,K.morphTargetsCount=F.morphTargetsCount,K.numClippingPlanes=F.numClippingPlanes,K.numIntersection=F.numClipIntersection,K.vertexAlphas=F.vertexAlphas,K.vertexTangents=F.vertexTangents,K.toneMapping=F.toneMapping}function Lb(b,F){if(b.length===0)return null;if(b.length===1)return b[0].texture!==null?b[0]:null;T.setFromMatrixPosition(F.matrixWorld);for(let K=0,Z=b.length;K<Z;K++){let X=b[K];if(X.texture!==null&&X.boundingBox.containsPoint(T))return X}return null}function Nb(b,F,K,Z,X){if(F.isScene!==!0)F=tn;Y.resetTextureUnits();let Me=F.fog,Re=Z.isMeshStandardMaterial||Z.isMeshLambertMaterial||Z.isMeshPhongMaterial?F.environment:null,we=P===null?w.outputColorSpace:P.isXRRenderTarget===!0?P.texture.colorSpace:Ke.workingColorSpace,Ie=Z.isMeshStandardMaterial||Z.isMeshLambertMaterial&&!Z.envMap||Z.isMeshPhongMaterial&&!Z.envMap,Ne=le.get(Z.envMap||Re,Ie),je=Z.vertexColors===!0&&!!K.attributes.color&&K.attributes.color.itemSize===4,et=!!K.attributes.tangent&&(!!Z.normalMap||Z.anisotropy>0),Pe=!!K.morphAttributes.position,dt=!!K.morphAttributes.normal,Bt=!!K.morphAttributes.color,Et=ei;if(Z.toneMapped){if(P===null||P.isXRRenderTarget===!0)Et=w.toneMapping}let xt=K.morphAttributes.position||K.morphAttributes.normal||K.morphAttributes.color,sn=xt!==void 0?xt.length:0,Ae=U.get(Z),dn=S.state.lights;if(He===!0){if(rt===!0||b!==H){let St=b===H&&Z.id===J;pe.setState(Z,b,St)}}let st=!1;if(Z.version===Ae.__version){if(Ae.needsLights&&Ae.lightsStateVersion!==dn.state.version)st=!0;else if(Ae.outputColorSpace!==we)st=!0;else if(X.isBatchedMesh&&Ae.batching===!1)st=!0;else if(!X.isBatchedMesh&&Ae.batching===!0)st=!0;else if(X.isBatchedMesh&&Ae.batchingColor===!0&&X._colorsTexture===null)st=!0;else if(X.isBatchedMesh&&Ae.batchingColor===!1&&X._colorsTexture!==null)st=!0;else if(X.isInstancedMesh&&Ae.instancing===!1)st=!0;else if(!X.isInstancedMesh&&Ae.instancing===!0)st=!0;else if(X.isSkinnedMesh&&Ae.skinning===!1)st=!0;else if(!X.isSkinnedMesh&&Ae.skinning===!0)st=!0;else if(X.isInstancedMesh&&Ae.instancingColor===!0&&X.instanceColor===null)st=!0;else if(X.isInstancedMesh&&Ae.instancingColor===!1&&X.instanceColor!==null)st=!0;else if(X.isInstancedMesh&&Ae.instancingMorph===!0&&X.morphTexture===null)st=!0;else if(X.isInstancedMesh&&Ae.instancingMorph===!1&&X.morphTexture!==null)st=!0;else if(Ae.envMap!==Ne)st=!0;else if(Z.fog===!0&&Ae.fog!==Me)st=!0;else if(Ae.numClippingPlanes!==void 0&&(Ae.numClippingPlanes!==pe.numPlanes||Ae.numIntersection!==pe.numIntersection))st=!0;else if(Ae.vertexAlphas!==je)st=!0;else if(Ae.vertexTangents!==et)st=!0;else if(Ae.morphTargets!==Pe)st=!0;else if(Ae.morphNormals!==dt)st=!0;else if(Ae.morphColors!==Bt)st=!0;else if(Ae.toneMapping!==Et)st=!0;else if(Ae.morphTargetsCount!==sn)st=!0;else if(!!Ae.lightProbeGrid!==S.state.lightProbeGridArray.length>0)st=!0}else st=!0,Ae.__version=Z.version;let Nn=Ae.currentProgram;if(st===!0){if(Nn=Ta(Z,F,X),C&&Z.isNodeMaterial)C.onUpdateProgram(Z,Nn,Ae)}let ai=!1,qi=!1,ss=!1,gt=Nn.getUniforms(),Ft=Ae.uniforms;if(A.useProgram(Nn.program))ai=!0,qi=!0,ss=!0;if(Z.id!==J)J=Z.id,qi=!0;if(Ae.needsLights){let St=Lb(S.state.lightProbeGridArray,X);if(Ae.lightProbeGrid!==St)Ae.lightProbeGrid=St,qi=!0}if(ai||H!==b){if(A.buffers.depth.getReversed()&&b.reversedDepth!==!0)b._reversedDepth=!0,b.updateProjectionMatrix();gt.setValue(O,"projectionMatrix",b.projectionMatrix),gt.setValue(O,"viewMatrix",b.matrixWorldInverse);let Ki=gt.map.cameraPosition;if(Ki!==void 0)Ki.setValue(O,Rt.setFromMatrixPosition(b.matrixWorld));if(Pt.logarithmicDepthBuffer)gt.setValue(O,"logDepthBufFC",2/(Math.log(b.far+1)/Math.LN2));if(Z.isMeshPhongMaterial||Z.isMeshToonMaterial||Z.isMeshLambertMaterial||Z.isMeshBasicMaterial||Z.isMeshStandardMaterial||Z.isShaderMaterial)gt.setValue(O,"isOrthographic",b.isOrthographicCamera===!0);if(H!==b)H=b,qi=!0,ss=!0}if(Ae.needsLights){if(dn.state.sunShadowMap.length>0)gt.setValue(O,"sunShadowMap",dn.state.sunShadowMap,Y);if(dn.state.directionalShadowMap.length>0)gt.setValue(O,"directionalShadowMap",dn.state.directionalShadowMap,Y);if(dn.state.spotShadowMap.length>0)gt.setValue(O,"spotShadowMap",dn.state.spotShadowMap,Y);if(dn.state.pointShadowMap.length>0)gt.setValue(O,"pointShadowMap",dn.state.pointShadowMap,Y)}if(X.isSkinnedMesh){gt.setOptional(O,X,"bindMatrix"),gt.setOptional(O,X,"bindMatrixInverse");let St=X.skeleton;if(St){if(St.boneTexture===null)St.computeBoneTexture();gt.setValue(O,"boneTexture",St.boneTexture,Y)}}if(X.isBatchedMesh){if(gt.setOptional(O,X,"batchingTexture"),gt.setValue(O,"batchingTexture",X._matricesTexture,Y),gt.setOptional(O,X,"batchingIdTexture"),gt.setValue(O,"batchingIdTexture",X._indirectTexture,Y),gt.setOptional(O,X,"batchingColorTexture"),X._colorsTexture!==null)gt.setValue(O,"batchingColorTexture",X._colorsTexture,Y)}let Yi=K.morphAttributes;if(Yi.position!==void 0||Yi.normal!==void 0||Yi.color!==void 0)ot.update(X,K,Nn);if(qi||Ae.receiveShadow!==X.receiveShadow)Ae.receiveShadow=X.receiveShadow,gt.setValue(O,"receiveShadow",X.receiveShadow);if((Z.isMeshStandardMaterial||Z.isMeshLambertMaterial||Z.isMeshPhongMaterial)&&Z.envMap===null&&F.environment!==null)Ft.envMapIntensity.value=F.environmentIntensity;if(Ft.dfgLUT!==void 0)Ft.dfgLUT.value=uC();if(qi){if(gt.setValue(O,"toneMappingExposure",w.toneMappingExposure),Ae.needsLights)Db(Ft,ss);if(Me&&Z.fog===!0)Ee.refreshFogUniforms(Ft,Me);if(Ee.refreshMaterialUniforms(Ft,Z,V,I,S.state.transmissionRenderTarget[b.id]),Ae.needsLights&&Ae.lightProbeGrid){let St=Ae.lightProbeGrid;Ft.probesSH.value=St.texture,Ft.probesMin.value.copy(St.boundingBox.min),Ft.probesMax.value.copy(St.boundingBox.max),Ft.probesResolution.value.copy(St.resolution)}da.upload(O,wf(Ae),Ft,Y)}if(Z.isShaderMaterial&&Z.uniformsNeedUpdate===!0)da.upload(O,wf(Ae),Ft,Y),Z.uniformsNeedUpdate=!1;if(Z.isSpriteMaterial)gt.setValue(O,"center",X.center);if(gt.setValue(O,"modelViewMatrix",X.modelViewMatrix),gt.setValue(O,"normalMatrix",X.normalMatrix),gt.setValue(O,"modelMatrix",X.matrixWorld),Z.uniformsGroups!==void 0){let St=Z.uniformsGroups;for(let Ki=0,os=St.length;Ki<os;Ki++){let Tf=St[Ki];Te.update(Tf,Nn),Te.bind(Tf,Nn)}}return Nn}function Db(b,F){b.ambientLightColor.needsUpdate=F,b.lightProbe.needsUpdate=F,b.sunLights.needsUpdate=F,b.sunLightShadows.needsUpdate=F,b.directionalLights.needsUpdate=F,b.directionalLightShadows.needsUpdate=F,b.pointLights.needsUpdate=F,b.pointLightShadows.needsUpdate=F,b.spotLights.needsUpdate=F,b.spotLightShadows.needsUpdate=F,b.rectAreaLights.needsUpdate=F,b.hemisphereLights.needsUpdate=F}function Ob(b){return b.isMeshLambertMaterial||b.isMeshToonMaterial||b.isMeshPhongMaterial||b.isMeshStandardMaterial||b.isShadowMaterial||b.isShaderMaterial&&b.lights===!0}this.getActiveCubeFace=function(){return W},this.getActiveMipmapLevel=function(){return B},this.getRenderTarget=function(){return P},this.setRenderTargetTextures=function(b,F,K){let Z=U.get(b);if(Z.__autoAllocateDepthBuffer=b.resolveDepthBuffer===!1,Z.__autoAllocateDepthBuffer===!1)Z.__useRenderToTexture=!1;U.get(b.texture).__webglTexture=F,U.get(b.depthTexture).__webglTexture=Z.__autoAllocateDepthBuffer?void 0:K,Z.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(b,F){let K=U.get(b);K.__webglFramebuffer=F,K.__useDefaultFramebuffer=F===void 0},this.setRenderTarget=function(b,F=0,K=0){P=b,W=F,B=K;let Z=null,X=!1,Me=!1;if(b){let we=U.get(b);if(we.__useDefaultFramebuffer!==void 0){A.bindFramebuffer(O.FRAMEBUFFER,we.__webglFramebuffer),q.copy(b.viewport),Q.copy(b.scissor),ge=b.scissorTest,A.viewport(q),A.scissor(Q),A.setScissorTest(ge),J=-1;return}else if(we.__webglFramebuffer===void 0)Y.setupRenderTarget(b);else if(we.__hasExternalTextures)Y.rebindTextures(b,U.get(b.texture).__webglTexture,U.get(b.depthTexture).__webglTexture);else if(b.depthBuffer){let je=b.depthTexture;if(we.__boundDepthTexture!==je){if(je!==null&&U.has(je)&&(b.width!==je.image.width||b.height!==je.image.height))throw Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");Y.setupDepthRenderbuffer(b)}}let Ie=b.texture;if(Ie.isData3DTexture||Ie.isDataArrayTexture||Ie.isCompressedArrayTexture)Me=!0;let Ne=U.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget){if(Array.isArray(Ne[F]))Z=Ne[F][K];else Z=Ne[F];X=!0}else if(b.samples>0&&Y.useMultisampledRTT(b)===!1)Z=U.get(b).__webglMultisampledFramebuffer;else if(Array.isArray(Ne))Z=Ne[K];else Z=Ne;q.copy(b.viewport),Q.copy(b.scissor),ge=b.scissorTest}else q.copy(oe).multiplyScalar(V).floor(),Q.copy(ue).multiplyScalar(V).floor(),ge=$e;if(K!==0)Z=D;if(A.bindFramebuffer(O.FRAMEBUFFER,Z))A.drawBuffers(b,Z);if(A.viewport(q),A.scissor(Q),A.setScissorTest(ge),X){let we=U.get(b.texture);O.framebufferTexture2D(O.FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_CUBE_MAP_POSITIVE_X+F,we.__webglTexture,K)}else if(Me){let we=F;for(let Ie=0;Ie<b.textures.length;Ie++){let Ne=U.get(b.textures[Ie]);O.framebufferTextureLayer(O.FRAMEBUFFER,O.COLOR_ATTACHMENT0+Ie,Ne.__webglTexture,K,we)}}else if(b!==null&&K!==0){let we=U.get(b.texture);O.framebufferTexture2D(O.FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_2D,we.__webglTexture,K)}J=-1};function Ef(b){let F=U.get(b);if(F.__readFormat!==b.format||F.__readType!==b.type)F.__readFormat=b.format,F.__readType=b.type,F.__formatReadable=Pt.textureFormatReadable(b.format),F.__typeReadable=Pt.textureTypeReadable(b.type);return F}if(this.readRenderTargetPixels=function(b,F,K,Z,X,Me,Re,we=0){if(!(b&&b.isWebGLRenderTarget)){Ve("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ie=U.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget&&Re!==void 0)Ie=Ie[Re];if(Ie){A.bindFramebuffer(O.FRAMEBUFFER,Ie);try{let Ne=b.textures[we],{format:je,type:et}=Ne;if(b.textures.length>1)O.readBuffer(O.COLOR_ATTACHMENT0+we);let Pe=Ef(Ne);if(Pe.__formatReadable===!1){Ve("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(Pe.__typeReadable===!1){Ve("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}if(F>=0&&F<=b.width-Z&&(K>=0&&K<=b.height-X))O.readPixels(F,K,Z,X,ne.convert(je),ne.convert(et),Me)}finally{let Ne=P!==null?U.get(P).__webglFramebuffer:null;A.bindFramebuffer(O.FRAMEBUFFER,Ne)}}},this.readRenderTargetPixelsAsync=async function(b,F,K,Z,X,Me,Re,we=0){if(!(b&&b.isWebGLRenderTarget))throw Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Ie=U.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget&&Re!==void 0)Ie=Ie[Re];if(Ie)if(F>=0&&F<=b.width-Z&&(K>=0&&K<=b.height-X)){A.bindFramebuffer(O.FRAMEBUFFER,Ie);let Ne=b.textures[we],{format:je,type:et}=Ne;if(b.textures.length>1)O.readBuffer(O.COLOR_ATTACHMENT0+we);let Pe=Ef(Ne);if(Pe.__formatReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(Pe.__typeReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let dt=O.createBuffer();O.bindBuffer(O.PIXEL_PACK_BUFFER,dt),O.bufferData(O.PIXEL_PACK_BUFFER,Me.byteLength,O.STREAM_READ),O.readPixels(F,K,Z,X,ne.convert(je),ne.convert(et),0),O.bindBuffer(O.PIXEL_PACK_BUFFER,null);let Bt=P!==null?U.get(P).__webglFramebuffer:null;A.bindFramebuffer(O.FRAMEBUFFER,Bt);let Et=O.fenceSync(O.SYNC_GPU_COMMANDS_COMPLETE,0);return O.flush(),await vv(O,Et,4),O.bindBuffer(O.PIXEL_PACK_BUFFER,dt),O.getBufferSubData(O.PIXEL_PACK_BUFFER,0,Me),O.bindBuffer(O.PIXEL_PACK_BUFFER,null),O.deleteBuffer(dt),O.deleteSync(Et),Me}else throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(b,F=null,K=0){let Z=Math.pow(2,-K),X=Math.floor(b.image.width*Z),Me=Math.floor(b.image.height*Z),Re=F!==null?F.x:0,we=F!==null?F.y:0;Y.setTexture2D(b,0),O.copyTexSubImage2D(O.TEXTURE_2D,K,0,0,Re,we,X,Me),A.unbindTexture()},this.copyTextureToTexture=function(b,F,K=null,Z=null,X=0,Me=0){let Re,we,Ie,Ne,je,et,Pe,dt,Bt,Et=b.isCompressedTexture?b.mipmaps[Me]:b.image;if(K!==null)Re=K.max.x-K.min.x,we=K.max.y-K.min.y,Ie=K.isBox3?K.max.z-K.min.z:1,Ne=K.min.x,je=K.min.y,et=K.isBox3?K.min.z:0;else{let Ft=Math.pow(2,-X);if(Re=Math.floor(Et.width*Ft),we=Math.floor(Et.height*Ft),b.isDataArrayTexture)Ie=Et.depth;else if(b.isData3DTexture)Ie=Math.floor(Et.depth*Ft);else Ie=1;Ne=0,je=0,et=0}if(Z!==null)Pe=Z.x,dt=Z.y,Bt=Z.z;else Pe=0,dt=0,Bt=0;let xt=ne.convert(F.format),sn=ne.convert(F.type),Ae;if(F.isData3DTexture)Y.setTexture3D(F,0),Ae=O.TEXTURE_3D;else if(F.isDataArrayTexture||F.isCompressedArrayTexture)Y.setTexture2DArray(F,0),Ae=O.TEXTURE_2D_ARRAY;else Y.setTexture2D(F,0),Ae=O.TEXTURE_2D;A.activeTexture(O.TEXTURE0),A.pixelStorei(O.UNPACK_FLIP_Y_WEBGL,F.flipY),A.pixelStorei(O.UNPACK_PREMULTIPLY_ALPHA_WEBGL,F.premultiplyAlpha),A.pixelStorei(O.UNPACK_ALIGNMENT,F.unpackAlignment);let dn=A.getParameter(O.UNPACK_ROW_LENGTH),st=A.getParameter(O.UNPACK_IMAGE_HEIGHT),Nn=A.getParameter(O.UNPACK_SKIP_PIXELS),ai=A.getParameter(O.UNPACK_SKIP_ROWS),qi=A.getParameter(O.UNPACK_SKIP_IMAGES);A.pixelStorei(O.UNPACK_ROW_LENGTH,Et.width),A.pixelStorei(O.UNPACK_IMAGE_HEIGHT,Et.height),A.pixelStorei(O.UNPACK_SKIP_PIXELS,Ne),A.pixelStorei(O.UNPACK_SKIP_ROWS,je),A.pixelStorei(O.UNPACK_SKIP_IMAGES,et);let ss=b.isDataArrayTexture||b.isData3DTexture,gt=F.isDataArrayTexture||F.isData3DTexture;if(b.isDepthTexture){let Ft=U.get(b),Yi=U.get(F),St=U.get(Ft.__renderTarget),Ki=U.get(Yi.__renderTarget);A.bindFramebuffer(O.READ_FRAMEBUFFER,St.__webglFramebuffer),A.bindFramebuffer(O.DRAW_FRAMEBUFFER,Ki.__webglFramebuffer);for(let os=0;os<Ie;os++){if(ss)O.framebufferTextureLayer(O.READ_FRAMEBUFFER,O.COLOR_ATTACHMENT0,U.get(b).__webglTexture,X,et+os),O.framebufferTextureLayer(O.DRAW_FRAMEBUFFER,O.COLOR_ATTACHMENT0,U.get(F).__webglTexture,Me,Bt+os);O.blitFramebuffer(Ne,je,Re,we,Pe,dt,Re,we,O.DEPTH_BUFFER_BIT,O.NEAREST)}A.bindFramebuffer(O.READ_FRAMEBUFFER,null),A.bindFramebuffer(O.DRAW_FRAMEBUFFER,null)}else if(X!==0||b.isRenderTargetTexture||U.has(b)){let Ft=U.get(b),Yi=U.get(F);A.bindFramebuffer(O.READ_FRAMEBUFFER,ee),A.bindFramebuffer(O.DRAW_FRAMEBUFFER,L);for(let St=0;St<Ie;St++){if(ss)O.framebufferTextureLayer(O.READ_FRAMEBUFFER,O.COLOR_ATTACHMENT0,Ft.__webglTexture,X,et+St);else O.framebufferTexture2D(O.READ_FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_2D,Ft.__webglTexture,X);if(gt)O.framebufferTextureLayer(O.DRAW_FRAMEBUFFER,O.COLOR_ATTACHMENT0,Yi.__webglTexture,Me,Bt+St);else O.framebufferTexture2D(O.DRAW_FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_2D,Yi.__webglTexture,Me);if(X!==0)O.blitFramebuffer(Ne,je,Re,we,Pe,dt,Re,we,O.COLOR_BUFFER_BIT,O.NEAREST);else if(gt)O.copyTexSubImage3D(Ae,Me,Pe,dt,Bt+St,Ne,je,Re,we);else O.copyTexSubImage2D(Ae,Me,Pe,dt,Ne,je,Re,we)}A.bindFramebuffer(O.READ_FRAMEBUFFER,null),A.bindFramebuffer(O.DRAW_FRAMEBUFFER,null)}else if(gt)if(b.isDataTexture||b.isData3DTexture)O.texSubImage3D(Ae,Me,Pe,dt,Bt,Re,we,Ie,xt,sn,Et.data);else if(F.isCompressedArrayTexture)O.compressedTexSubImage3D(Ae,Me,Pe,dt,Bt,Re,we,Ie,xt,Et.data);else O.texSubImage3D(Ae,Me,Pe,dt,Bt,Re,we,Ie,xt,sn,Et);else if(b.isDataTexture)O.texSubImage2D(O.TEXTURE_2D,Me,Pe,dt,Re,we,xt,sn,Et.data);else if(b.isCompressedTexture)O.compressedTexSubImage2D(O.TEXTURE_2D,Me,Pe,dt,Et.width,Et.height,xt,Et.data);else O.texSubImage2D(O.TEXTURE_2D,Me,Pe,dt,Re,we,xt,sn,Et);if(A.pixelStorei(O.UNPACK_ROW_LENGTH,dn),A.pixelStorei(O.UNPACK_IMAGE_HEIGHT,st),A.pixelStorei(O.UNPACK_SKIP_PIXELS,Nn),A.pixelStorei(O.UNPACK_SKIP_ROWS,ai),A.pixelStorei(O.UNPACK_SKIP_IMAGES,qi),Me===0&&F.generateMipmaps)O.generateMipmap(Ae);A.unbindTexture()},this.initRenderTarget=function(b){if(U.get(b).__webglFramebuffer===void 0)Y.setupRenderTarget(b)},this.initTexture=function(b){if(b.isCubeTexture)Y.setTextureCube(b,0);else if(b.isData3DTexture)Y.setTexture3D(b,0);else if(b.isDataArrayTexture||b.isCompressedArrayTexture)Y.setTexture2DArray(b,0);else Y.setTexture2D(b,0);A.unbindTexture()},this.resetState=function(){W=0,B=0,P=null,A.reset(),xe.reset()},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ud}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=Ke._getDrawingBufferColorSpace(e),t.unpackColorSpace=Ke._getUnpackColorSpace()}}var dy={type:"change"},$d={type:"start"},py={type:"end"},xl=new _r,fy=new zn,hC=Math.cos(70*jo.DEG2RAD),Zt=new z,bn=2*Math.PI,mt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Vd=0.000001;class Wd extends fl{constructor(e,t=null){super(e,t);if(this.state=mt.NONE,this.target=new z,this.cursor=new z,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=0.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:dr.ROTATE,MIDDLE:dr.DOLLY,RIGHT:dr.PAN},this.touches={ONE:fr.ROTATE,TWO:fr.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle="auto",this._domElementKeyEvents=null,this._lastPosition=new z,this._lastQuaternion=new Yt,this._lastTargetPosition=new z,this._quat=new Yt().setFromUnitVectors(e.up,new z(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new ca,this._sphericalDelta=new ca,this._scale=1,this._panOffset=new z,this._rotateStart=new ke,this._rotateEnd=new ke,this._rotateDelta=new ke,this._panStart=new ke,this._panEnd=new ke,this._panDelta=new ke,this._dollyStart=new ke,this._dollyEnd=new ke,this._dollyDelta=new ke,this._dollyDirection=new z,this._mouse=new ke,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=fC.bind(this),this._onPointerDown=dC.bind(this),this._onPointerUp=pC.bind(this),this._onContextMenu=bC.bind(this),this._onMouseWheel=_C.bind(this),this._onKeyDown=xC.bind(this),this._onTouchStart=vC.bind(this),this._onTouchMove=yC.bind(this),this._onMouseDown=mC.bind(this),this._onMouseMove=gC.bind(this),this._interceptControlDown=SC.bind(this),this._interceptControlUp=wC.bind(this),this.domElement!==null)this.connect(this.domElement);this.update()}set cursorStyle(e){if(this._cursorStyle=e,e==="grab")this.domElement.style.cursor="grab";else this.domElement.style.cursor="auto"}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.state=mt.NONE,this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents();let e=this.domElement.getRootNode();e.removeEventListener("keydown",this._interceptControlDown,{capture:!0}),e.removeEventListener("keyup",this._interceptControlUp,{capture:!0}),this._controlActive=!1,this._pointers.length=0,this._pointerPositions={},this.domElement.style.touchAction="",this.domElement.style.cursor="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){if(this._domElementKeyEvents!==null)this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(dy),this.update(),this.state=mt.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){let t=this.object.position;if(Zt.copy(t).sub(this.target),Zt.applyQuaternion(this._quat),this._spherical.setFromVector3(Zt),this.autoRotate&&this.state===mt.NONE)this._rotateLeft(this._getAutoRotationAngle(e));if(this.enableDamping)this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor;else this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi;let n=this.minAzimuthAngle,i=this.maxAzimuthAngle;if(isFinite(n)&&isFinite(i)){if(n<-Math.PI)n+=bn;else if(n>Math.PI)n-=bn;if(i<-Math.PI)i+=bn;else if(i>Math.PI)i-=bn;if(n<=i)this._spherical.theta=Math.max(n,Math.min(i,this._spherical.theta));else this._spherical.theta=this._spherical.theta>(n+i)/2?Math.max(n,this._spherical.theta):Math.min(i,this._spherical.theta)}if(this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0)this.target.addScaledVector(this._panOffset,this.dampingFactor);else this.target.add(this._panOffset);this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{let s=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=s!=this._spherical.radius}if(Zt.setFromSpherical(this._spherical),Zt.applyQuaternion(this._quatInverse),t.copy(this.target).add(Zt),this.object.lookAt(this.target),this.enableDamping===!0)this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor);else this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0);if(this.zoomToCursor&&this._performCursorZoom){let s=null;if(this.object.isPerspectiveCamera){let o=Zt.length();s=this._clampDistance(o*this._scale);let a=o-s;this.object.position.addScaledVector(this._dollyDirection,a),this.object.updateMatrixWorld(),r=!!a}else if(this.object.isOrthographicCamera){let o=new z(this._mouse.x,this._mouse.y,0);o.unproject(this.object);let a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=a!==this.object.zoom;let c=new z(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),s=Zt.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;if(s!==null)if(this.screenSpacePanning)this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(s).add(this.object.position);else if(xl.origin.copy(this.object.position),xl.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(xl.direction))<hC)this.object.lookAt(this.target);else fy.setFromNormalAndCoplanarPoint(this.object.up,this.target),xl.intersectPlane(fy,this.target)}else if(this.object.isOrthographicCamera){let s=this.object.zoom;if(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),s!==this.object.zoom)this.object.updateProjectionMatrix(),r=!0}if(this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>Vd||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Vd||this._lastTargetPosition.distanceToSquared(this.target)>Vd)return this.dispatchEvent(dy),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0;return!1}_getAutoRotationAngle(e){if(e!==null)return bn/60*this.autoRotateSpeed*e;else return bn/60/60*this.autoRotateSpeed}_getZoomScale(e){let t=Math.abs(e*0.01);return Math.pow(0.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Zt.setFromMatrixColumn(t,0),Zt.multiplyScalar(-e),this._panOffset.add(Zt)}_panUp(e,t){if(this.screenSpacePanning===!0)Zt.setFromMatrixColumn(t,1);else Zt.setFromMatrixColumn(t,0),Zt.crossVectors(this.object.up,Zt);Zt.multiplyScalar(e),this._panOffset.add(Zt)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let i=this.object.position;Zt.copy(i).sub(this.target);let r=Zt.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/n.clientHeight,this.object.matrix),this._panUp(2*t*r/n.clientHeight,this.object.matrix)}else if(this.object.isOrthographicCamera)this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix);else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1}_dollyOut(e){if(this.object.isPerspectiveCamera||this.object.isOrthographicCamera)this._scale/=e;else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1}_dollyIn(e){if(this.object.isPerspectiveCamera||this.object.isOrthographicCamera)this._scale*=e;else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;let n=this.domElement.getBoundingClientRect(),i=e-n.left,r=t-n.top,{width:s,height:o}=n;this._mouse.x=i/s*2-1,this._mouse.y=-(r/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(bn*this._rotateDelta.x/t.clientHeight),this._rotateUp(bn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){if(this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0)this._dollyOut(this._getZoomScale(this._dollyDelta.y));else if(this._dollyDelta.y<0)this._dollyIn(this._getZoomScale(this._dollyDelta.y));this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){if(this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0)this._dollyIn(this._getZoomScale(e.deltaY));else if(e.deltaY>0)this._dollyOut(this._getZoomScale(e.deltaY));this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateUp(bn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(0,this.keyPanSpeed);t=!0;break;case this.keys.BOTTOM:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateUp(-bn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(0,-this.keyPanSpeed);t=!0;break;case this.keys.LEFT:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateLeft(bn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(this.keyPanSpeed,0);t=!0;break;case this.keys.RIGHT:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateLeft(-bn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(-this.keyPanSpeed,0);t=!0;break}if(t)e.preventDefault(),this.update()}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._rotateStart.set(n,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._panStart.set(n,i)}}_handleTouchStartDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){if(this.enableZoom)this._handleTouchStartDolly(e);if(this.enablePan)this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){if(this.enableZoom)this._handleTouchStartDolly(e);if(this.enableRotate)this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{let n=this._getSecondPointerPosition(e),i=0.5*(e.pageX+n.x),r=0.5*(e.pageY+n.y);this._rotateEnd.set(i,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(bn*this._rotateDelta.x/t.clientHeight),this._rotateUp(bn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._panEnd.set(n,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let s=(e.pageX+t.x)*0.5,o=(e.pageY+t.y)*0.5;this._updateZoomParameters(s,o)}_handleTouchMoveDollyPan(e){if(this.enableZoom)this._handleTouchMoveDolly(e);if(this.enablePan)this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){if(this.enableZoom)this._handleTouchMoveDolly(e);if(this.enableRotate)this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];if(t===void 0)t=new ke,this._pointerPositions[e.pointerId]=t;t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){let t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){let t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}if(e.ctrlKey&&!this._controlActive)n.deltaY*=10;return n}}function dC(e){if(this.enabled===!1)return;if(this._pointers.length===0)this.domElement.setPointerCapture(e.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp);if(this._isTrackingPointer(e))return;if(this._addPointer(e),e.pointerType==="touch")this._onTouchStart(e);else this._onMouseDown(e);if(this._cursorStyle==="grab")this.domElement.style.cursor="grabbing"}function fC(e){if(this.enabled===!1)return;if(e.pointerType==="touch")this._onTouchMove(e);else this._onMouseMove(e)}function pC(e){switch(this._removePointer(e),this._pointers.length){case 0:if(this.domElement.releasePointerCapture(e.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(py),this.state=mt.NONE,this._cursorStyle==="grab")this.domElement.style.cursor="grab";break;case 1:let t=this._pointers[0],n=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:n.x,pageY:n.y});break}}function mC(e){let t;switch(e.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case dr.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(e),this.state=mt.DOLLY;break;case dr.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=mt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=mt.ROTATE}break;case dr.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=mt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=mt.PAN}break;default:this.state=mt.NONE}if(this.state!==mt.NONE)this.dispatchEvent($d)}function gC(e){switch(this.state){case mt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(e);break;case mt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(e);break;case mt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(e);break}}function _C(e){if(this.enabled===!1||this.enableZoom===!1||this.state!==mt.NONE)return;e.preventDefault(),this.dispatchEvent($d),this._handleMouseWheel(this._customWheelEvent(e)),this.dispatchEvent(py)}function xC(e){if(this.enabled===!1)return;this._handleKeyDown(e)}function vC(e){switch(this._trackPointer(e),this._pointers.length){case 1:switch(this.touches.ONE){case fr.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(e),this.state=mt.TOUCH_ROTATE;break;case fr.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(e),this.state=mt.TOUCH_PAN;break;default:this.state=mt.NONE}break;case 2:switch(this.touches.TWO){case fr.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(e),this.state=mt.TOUCH_DOLLY_PAN;break;case fr.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(e),this.state=mt.TOUCH_DOLLY_ROTATE;break;default:this.state=mt.NONE}break;default:this.state=mt.NONE}if(this.state!==mt.NONE)this.dispatchEvent($d)}function yC(e){switch(this._trackPointer(e),this.state){case mt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(e),this.update();break;case mt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(e),this.update();break;case mt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(e),this.update();break;case mt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(e),this.update();break;default:this.state=mt.NONE}}function bC(e){if(this.enabled===!1)return;e.preventDefault()}function SC(e){if(e.key==="Control")this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}function wC(e){if(e.key==="Control")this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}class Zd extends zs{constructor(){super();this.name="RoomEnvironment",this.position.y=-3.5;let e=new vr;e.deleteAttribute("uv");let t=new Wi({side:cn}),n=new Wi,i=new $s(16777215,900,28,2);i.position.set(0.418,16.199,0.3),this.add(i);let r=new Mt(e,t);r.position.set(-0.757,13.219,0.717),r.scale.set(31.713,28.305,28.591),this.add(r);let s=new Bs(e,n,6),o=new _t;o.position.set(-10.906,2.009,1.846),o.rotation.set(0,-0.195,0),o.scale.set(2.328,7.905,4.651),o.updateMatrix(),s.setMatrixAt(0,o.matrix),o.position.set(-5.607,-0.754,-0.758),o.rotation.set(0,0.994,0),o.scale.set(1.97,1.534,3.955),o.updateMatrix(),s.setMatrixAt(1,o.matrix),o.position.set(6.167,0.857,7.803),o.rotation.set(0,0.561,0),o.scale.set(3.927,6.285,3.687),o.updateMatrix(),s.setMatrixAt(2,o.matrix),o.position.set(-2.017,0.018,6.124),o.rotation.set(0,0.333,0),o.scale.set(2.002,4.566,2.064),o.updateMatrix(),s.setMatrixAt(3,o.matrix),o.position.set(2.291,-0.756,-2.621),o.rotation.set(0,-0.286,0),o.scale.set(1.546,1.552,1.496),o.updateMatrix(),s.setMatrixAt(4,o.matrix),o.position.set(-2.193,-0.369,-5.547),o.rotation.set(0,0.516,0),o.scale.set(3.875,3.487,2.986),o.updateMatrix(),s.setMatrixAt(5,o.matrix),this.add(s);let a=new Mt(e,qs(50));a.position.set(-16.116,14.37,8.208),a.scale.set(0.1,2.428,2.739),this.add(a);let c=new Mt(e,qs(50));c.position.set(-16.109,18.021,-8.207),c.scale.set(0.1,2.425,2.751),this.add(c);let l=new Mt(e,qs(17));l.position.set(14.904,12.198,-1.832),l.scale.set(0.15,4.265,6.331),this.add(l);let u=new Mt(e,qs(43));u.position.set(-0.462,8.89,14.52),u.scale.set(4.38,5.441,0.088),this.add(u);let h=new Mt(e,qs(20));h.position.set(3.235,11.486,-12.541),h.scale.set(2.5,2,0.1),this.add(h);let d=new Mt(e,qs(100));d.position.set(0,20,0),d.scale.set(1,0.1,1),this.add(d)}dispose(){let e=new Set;this.traverse((t)=>{if(t.isMesh)e.add(t.geometry),e.add(t.material)});for(let t of e)t.dispose()}}function qs(e){return new sl({color:0,emissive:16777215,emissiveIntensity:e})}function Xd(e,t){if(t===od)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t===Fs||t===Xo){let n=e.getIndex();if(n===null){let s=[],o=e.getAttribute("position");if(o!==void 0){for(let a=0;a<o.count;a++)s.push(a);e.setIndex(s),n=e.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e}let i=n.count-2,r=[];if(t===Fs)for(let s=1;s<=i;s++)r.push(n.getX(0)),r.push(n.getX(s)),r.push(n.getX(s+1));else for(let s=0;s<i;s++)if(s%2===0)r.push(n.getX(s)),r.push(n.getX(s+1)),r.push(n.getX(s+2));else r.push(n.getX(s+2)),r.push(n.getX(s+1)),r.push(n.getX(s));if(r.length/3!==i)console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");return e.setIndex(r),e.clearGroups(),e}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),e}function my(e){let t=new Map,n=new Map,i=e.clone();return gy(e,i,function(r,s){t.set(s,r),n.set(r,s)}),i.traverse(function(r){if(!r.isSkinnedMesh)return;let s=r,o=t.get(r),a=o.skeleton.bones;s.skeleton=o.skeleton.clone(),s.bindMatrix.copy(o.bindMatrix),s.skeleton.bones=a.map(function(c){return n.get(c)}),s.bind(s.skeleton,s.bindMatrix)}),i}function gy(e,t,n){n(e,t);for(let i=0;i<e.children.length;i++)gy(e.children[i],t.children[i],n)}class ef extends Xi{constructor(e){super(e);this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new My(t)}),this.register(function(t){return new Ey(t)}),this.register(function(t){return new Dy(t)}),this.register(function(t){return new Oy(t)}),this.register(function(t){return new Uy(t)}),this.register(function(t){return new Ay(t)}),this.register(function(t){return new Ry(t)}),this.register(function(t){return new Cy(t)}),this.register(function(t){return new Iy(t)}),this.register(function(t){return new wy(t)}),this.register(function(t){return new Py(t)}),this.register(function(t){return new Ty(t)}),this.register(function(t){return new Ny(t)}),this.register(function(t){return new Ly(t)}),this.register(function(t){return new by(t)}),this.register(function(t){return new Kd(t,Qe.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new Kd(t,Qe.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new Fy(t)})}load(e,t,n,i){let r=this,s;if(this.resourcePath!=="")s=this.resourcePath;else if(this.path!==""){let c=Mr.extractUrlBase(e);s=Mr.resolveURL(c,this.path)}else s=Mr.extractUrlBase(e);this.manager.itemStart(e);let o=function(c){if(i)i(c);else console.error(c);r.manager.itemError(e),r.manager.itemEnd(e)},a=new oa(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(c){try{r.parse(c,s,function(l){t(l),r.manager.itemEnd(e)},o)}catch(l){o(l)}},n,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){if(this.pluginCallbacks.indexOf(e)===-1)this.pluginCallbacks.push(e);return this}unregister(e){if(this.pluginCallbacks.indexOf(e)!==-1)this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1);return this}parse(e,t,n,i){let r,s={},o={},a=new TextDecoder;if(typeof e==="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(a.decode(new Uint8Array(e,0,4))===zy){try{s[Qe.KHR_BINARY_GLTF]=new ky(e)}catch(u){if(i)i(u);return}r=JSON.parse(s[Qe.KHR_BINARY_GLTF].content)}else r=JSON.parse(a.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){if(i)i(Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}let c=new $y(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let l=0;l<this.pluginCallbacks.length;l++){let u=this.pluginCallbacks[l](c);if(!u.name)console.error("THREE.GLTFLoader: Invalid plugin found: missing name");o[u.name]=u,s[u.name]=!0}if(r.extensionsUsed)for(let l=0;l<r.extensionsUsed.length;++l){let u=r.extensionsUsed[l],h=r.extensionsRequired||[];switch(u){case Qe.KHR_MATERIALS_UNLIT:s[u]=new Sy;break;case Qe.KHR_DRACO_MESH_COMPRESSION:s[u]=new By(r,this.dracoLoader);break;case Qe.KHR_TEXTURE_TRANSFORM:s[u]=new Gy;break;case Qe.KHR_MESH_QUANTIZATION:s[u]=new Hy;break;default:if(h.indexOf(u)>=0&&o[u]===void 0)console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(s),c.setPlugins(o),c.parse(n,i)}parseAsync(e,t){let n=this;return new Promise(function(i,r){n.parse(e,t,i,r)})}}function MC(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}function kt(e,t,n){let i=e.json.materials[t];if(i.extensions&&i.extensions[n])return i.extensions[n];return null}var Qe={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class by{constructor(e){this.parser=e,this.name=Qe.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){let r=t[n];if(r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0)e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){let t=this.parser,n="light:"+e,i=t.cache.get(n);if(i)return i;let r=t.json,a=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e],c,l=new Ge(16777215);if(a.color!==void 0)l.setRGB(a.color[0],a.color[1],a.color[2],Rn);let u=a.range!==void 0?a.range:0;switch(a.type){case"directional":c=new Ws(l),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new $s(l),c.distance=u;break;case"spot":c=new ul(l),c.distance=u,a.spot=a.spot||{},a.spot.innerConeAngle=a.spot.innerConeAngle!==void 0?a.spot.innerConeAngle:0,a.spot.outerConeAngle=a.spot.outerConeAngle!==void 0?a.spot.outerConeAngle:Math.PI/4,c.angle=a.spot.outerConeAngle,c.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw Error("THREE.GLTFLoader: Unexpected light type: "+a.type)}if(c.position.set(0,0,0),Ti(c,a),a.intensity!==void 0)c.intensity=a.intensity;return c.name=t.createUniqueName(a.name||"light_"+e),i=Promise.resolve(c),t.cache.add(n,i),i}getDependency(e,t){if(e!=="light")return;return this._loadLight(t)}createNodeAttachment(e){let t=this,n=this.parser,r=n.json.nodes[e],o=(r.extensions&&r.extensions[this.name]||{}).light;if(o===void 0)return null;return this._loadLight(o).then(function(a){return n._getNodeRef(t.cache,o,a)})}}class Sy{constructor(){this.name=Qe.KHR_MATERIALS_UNLIT}getMaterialType(){return wi}extendParams(e,t,n){let i=[];e.color=new Ge(1,1,1),e.opacity=1;let r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){let s=r.baseColorFactor;e.color.setRGB(s[0],s[1],s[2],Rn),e.opacity=s[3]}if(r.baseColorTexture!==void 0)i.push(n.assignTexture(e,"map",r.baseColorTexture,gr))}return Promise.all(i)}}class wy{constructor(e){this.parser=e,this.name=Qe.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let n=kt(this.parser,e,this.name);if(n===null)return Promise.resolve();if(n.emissiveStrength!==void 0)t.emissiveIntensity=n.emissiveStrength;return Promise.resolve()}}class My{constructor(e){this.parser=e,this.name=Qe.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return kt(this.parser,e,this.name)!==null?Pn:null}extendMaterialParams(e,t){let n=kt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.clearcoatFactor!==void 0)t.clearcoat=n.clearcoatFactor;if(n.clearcoatTexture!==void 0)i.push(this.parser.assignTexture(t,"clearcoatMap",n.clearcoatTexture));if(n.clearcoatRoughnessFactor!==void 0)t.clearcoatRoughness=n.clearcoatRoughnessFactor;if(n.clearcoatRoughnessTexture!==void 0)i.push(this.parser.assignTexture(t,"clearcoatRoughnessMap",n.clearcoatRoughnessTexture));if(n.clearcoatNormalTexture!==void 0){if(i.push(this.parser.assignTexture(t,"clearcoatNormalMap",n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0){let r=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new ke(r,r)}}return Promise.all(i)}}class Ey{constructor(e){this.parser=e,this.name=Qe.KHR_MATERIALS_DISPERSION}getMaterialType(e){return kt(this.parser,e,this.name)!==null?Pn:null}extendMaterialParams(e,t){let n=kt(this.parser,e,this.name);if(n===null)return Promise.resolve();return t.dispersion=n.dispersion!==void 0?n.dispersion:0,Promise.resolve()}}class Ty{constructor(e){this.parser=e,this.name=Qe.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return kt(this.parser,e,this.name)!==null?Pn:null}extendMaterialParams(e,t){let n=kt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.iridescenceFactor!==void 0)t.iridescence=n.iridescenceFactor;if(n.iridescenceTexture!==void 0)i.push(this.parser.assignTexture(t,"iridescenceMap",n.iridescenceTexture));if(n.iridescenceIor!==void 0)t.iridescenceIOR=n.iridescenceIor;if(t.iridescenceThicknessRange===void 0)t.iridescenceThicknessRange=[100,400];if(n.iridescenceThicknessMinimum!==void 0)t.iridescenceThicknessRange[0]=n.iridescenceThicknessMinimum;if(n.iridescenceThicknessMaximum!==void 0)t.iridescenceThicknessRange[1]=n.iridescenceThicknessMaximum;if(n.iridescenceThicknessTexture!==void 0)i.push(this.parser.assignTexture(t,"iridescenceThicknessMap",n.iridescenceThicknessTexture));return Promise.all(i)}}class Ay{constructor(e){this.parser=e,this.name=Qe.KHR_MATERIALS_SHEEN}getMaterialType(e){return kt(this.parser,e,this.name)!==null?Pn:null}extendMaterialParams(e,t){let n=kt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.sheenColor=new Ge(0,0,0),t.sheenRoughness=0,t.sheen=1,n.sheenColorFactor!==void 0){let r=n.sheenColorFactor;t.sheenColor.setRGB(r[0],r[1],r[2],Rn)}if(n.sheenRoughnessFactor!==void 0)t.sheenRoughness=n.sheenRoughnessFactor;if(n.sheenColorTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenColorMap",n.sheenColorTexture,gr));if(n.sheenRoughnessTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenRoughnessMap",n.sheenRoughnessTexture));return Promise.all(i)}}class Ry{constructor(e){this.parser=e,this.name=Qe.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return kt(this.parser,e,this.name)!==null?Pn:null}extendMaterialParams(e,t){let n=kt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.transmissionFactor!==void 0)t.transmission=n.transmissionFactor;if(n.transmissionTexture!==void 0)i.push(this.parser.assignTexture(t,"transmissionMap",n.transmissionTexture));return Promise.all(i)}}class Cy{constructor(e){this.parser=e,this.name=Qe.KHR_MATERIALS_VOLUME}getMaterialType(e){return kt(this.parser,e,this.name)!==null?Pn:null}extendMaterialParams(e,t){let n=kt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.thickness=n.thicknessFactor!==void 0?n.thicknessFactor:0,n.thicknessTexture!==void 0)i.push(this.parser.assignTexture(t,"thicknessMap",n.thicknessTexture));t.attenuationDistance=n.attenuationDistance||1/0;let r=n.attenuationColor||[1,1,1];return t.attenuationColor=new Ge().setRGB(r[0],r[1],r[2],Rn),Promise.all(i)}}class Iy{constructor(e){this.parser=e,this.name=Qe.KHR_MATERIALS_IOR}getMaterialType(e){return kt(this.parser,e,this.name)!==null?Pn:null}extendMaterialParams(e,t){let n=kt(this.parser,e,this.name);if(n===null)return Promise.resolve();if(t.ior=n.ior!==void 0?n.ior:1.5,t.ior===0)t.ior=1000;return Promise.resolve()}}class Py{constructor(e){this.parser=e,this.name=Qe.KHR_MATERIALS_SPECULAR}getMaterialType(e){return kt(this.parser,e,this.name)!==null?Pn:null}extendMaterialParams(e,t){let n=kt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.specularIntensity=n.specularFactor!==void 0?n.specularFactor:1,n.specularTexture!==void 0)i.push(this.parser.assignTexture(t,"specularIntensityMap",n.specularTexture));let r=n.specularColorFactor||[1,1,1];if(t.specularColor=new Ge().setRGB(r[0],r[1],r[2],Rn),n.specularColorTexture!==void 0)i.push(this.parser.assignTexture(t,"specularColorMap",n.specularColorTexture,gr));return Promise.all(i)}}class Ly{constructor(e){this.parser=e,this.name=Qe.EXT_MATERIALS_BUMP}getMaterialType(e){return kt(this.parser,e,this.name)!==null?Pn:null}extendMaterialParams(e,t){let n=kt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.bumpScale=n.bumpFactor!==void 0?n.bumpFactor:1,n.bumpTexture!==void 0)i.push(this.parser.assignTexture(t,"bumpMap",n.bumpTexture));return Promise.all(i)}}class Ny{constructor(e){this.parser=e,this.name=Qe.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return kt(this.parser,e,this.name)!==null?Pn:null}extendMaterialParams(e,t){let n=kt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.anisotropyStrength!==void 0)t.anisotropy=n.anisotropyStrength;if(n.anisotropyRotation!==void 0)t.anisotropyRotation=n.anisotropyRotation;if(n.anisotropyTexture!==void 0)i.push(this.parser.assignTexture(t,"anisotropyMap",n.anisotropyTexture));return Promise.all(i)}}class Dy{constructor(e){this.parser=e,this.name=Qe.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;let r=i.extensions[this.name],s=t.options.ktx2Loader;if(!s)if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");else return null;return t.loadTextureImage(e,r.source,s)}}class Oy{constructor(e){this.parser=e,this.name=Qe.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;let s=r.extensions[t],o=i.images[s.source],a=n.textureLoader;if(o.uri){let c=n.options.manager.getHandler(o.uri);if(c!==null)a=c}return n.loadTextureImage(e,s.source,a)}}class Uy{constructor(e){this.parser=e,this.name=Qe.EXT_TEXTURE_AVIF}loadTexture(e){let t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;let s=r.extensions[t],o=i.images[s.source],a=n.textureLoader;if(o.uri){let c=n.options.manager.getHandler(o.uri);if(c!==null)a=c}return n.loadTextureImage(e,s.source,a)}}class Kd{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let i=n.extensions[this.name],r=this.parser.getDependency("buffer",i.buffer),s=this.parser.options.meshoptDecoder;if(!s||!s.supported)if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");else return null;return r.then(function(o){let a=i.byteOffset||0,c=i.byteLength||0,{count:l,byteStride:u}=i,h=new Uint8Array(o,a,c);if(s.decodeGltfBufferAsync)return s.decodeGltfBufferAsync(l,u,h,i.mode,i.filter).then(function(d){return d.buffer});else return s.ready.then(function(){let d=new ArrayBuffer(l*u);return s.decodeGltfBuffer(new Uint8Array(d),l,u,h,i.mode,i.filter),d})})}else return null}}class Fy{constructor(e){this.name=Qe.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let i=t.meshes[n.mesh];for(let c of i.primitives)if(c.mode!==Hn.TRIANGLES&&c.mode!==Hn.TRIANGLE_STRIP&&c.mode!==Hn.TRIANGLE_FAN&&c.mode!==void 0)return null;let s=n.extensions[this.name].attributes,o=[],a={};for(let c in s)o.push(this.parser.getDependency("accessor",s[c]).then((l)=>(a[c]=l,a[c])));if(o.length<1)return null;return o.push(this.parser.createNodeMesh(e)),Promise.all(o).then((c)=>{let l=c.pop(),u=l.isGroup?l.children:[l],h=c[0].count,d=[];for(let f of u){let m=new Xe,_=new z,p=new Yt,g=new z(1,1,1),M=new Bs(f.geometry,f.material,h);for(let v=0;v<h;v++){if(a.TRANSLATION)_.fromBufferAttribute(a.TRANSLATION,v);if(a.ROTATION)p.fromBufferAttribute(a.ROTATION,v);if(a.SCALE)g.fromBufferAttribute(a.SCALE,v);M.setMatrixAt(v,m.compose(_,p,g))}let T=null;for(let v in a)if(v==="_COLOR_0"){let S=a[v];M.instanceColor=new hr(S.array,S.itemSize,S.normalized)}else if(v!=="TRANSLATION"&&v!=="ROTATION"&&v!=="SCALE"){if(T===null){let E=M.geometry;T=new ln,T.name=E.name;for(let R in E.attributes)T.setAttribute(R,E.attributes[R]);for(let R in E.morphAttributes)T.morphAttributes[R]=E.morphAttributes[R];if(E.index!==null)T.setIndex(E.index);T.morphTargetsRelative=E.morphTargetsRelative;for(let R of E.groups)T.addGroup(R.start,R.count,R.materialIndex);if(E.boundingBox!==null)T.boundingBox=E.boundingBox.clone();if(E.boundingSphere!==null)T.boundingSphere=E.boundingSphere.clone();T.drawRange.start=E.drawRange.start,T.drawRange.count=E.drawRange.count,T.userData=Object.assign({},E.userData),M.geometry=T}let S=a[v];T.setAttribute(v,new hr(S.array,S.itemSize,S.normalized))}_t.prototype.copy.call(M,f),this.parser.assignFinalMaterial(M),d.push(M)}if(l.isGroup)return l.clear(),l.add(...d),l;return d[0]})}}var zy="glTF",pa=12,_y={JSON:1313821514,BIN:5130562};class ky{constructor(e){this.name=Qe.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,pa),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==zy)throw Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");else if(this.header.version<2)throw Error("THREE.GLTFLoader: Legacy binary file detected.");let i=this.header.length-pa,r=new DataView(e,pa),s=0;while(s<i){let o=r.getUint32(s,!0);s+=4;let a=r.getUint32(s,!0);if(s+=4,a===_y.JSON){let c=new Uint8Array(e,pa+s,o);this.content=n.decode(c)}else if(a===_y.BIN){let c=pa+s;this.body=e.slice(c,c+o)}s+=o}if(this.content===null)throw Error("THREE.GLTFLoader: JSON content not found.")}}class By{constructor(e,t){if(!t)throw Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Qe.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let n=this.json,i=this.dracoLoader,r=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,o={},a={},c={};for(let l in s){let u=Jd[l]||l.toLowerCase();o[u]=s[l]}for(let l in e.attributes){let u=Jd[l]||l.toLowerCase();if(s[l]!==void 0){let h=n.accessors[e.attributes[l]],d=Ys[h.componentType];c[u]=d.name,a[u]=h.normalized===!0}}return t.getDependency("bufferView",r).then(function(l){return new Promise(function(u,h){i.decodeDracoFile(l,function(d){for(let f in d.attributes){let m=d.attributes[f],_=a[f];if(_!==void 0)m.normalized=_}u(d)},o,c,Rn,h)})})}}class Gy{constructor(){this.name=Qe.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){if((t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0)return e;if(e=e.clone(),t.texCoord!==void 0)e.channel=t.texCoord;if(t.offset!==void 0)e.offset.fromArray(t.offset);if(t.rotation!==void 0)e.rotation=t.rotation;if(t.scale!==void 0)e.repeat.fromArray(t.scale);if(t.rotation!==void 0){let n=Math.cos(e.rotation),i=Math.sin(e.rotation);e.matrix.set(e.repeat.x*n,e.repeat.y*i,e.offset.x,-e.repeat.x*i,e.repeat.y*n,e.offset.y,0,0,1),e.matrixAutoUpdate=!1}return e.needsUpdate=!0,e}}class Hy{constructor(){this.name=Qe.KHR_MESH_QUANTIZATION}}class tf extends Zi{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i*3+i;for(let s=0;s!==i;s++)t[s]=n[r+s];return t}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=o*2,c=o*3,l=i-t,u=(n-t)/l,h=u*u,d=h*u,f=e*c,m=f-c,_=-2*d+3*h,p=d-h,g=1-_,M=p-h+u;for(let T=0;T!==o;T++){let v=s[m+T+o],S=s[m+T+a]*l,E=s[f+T+o],R=s[f+T]*l;r[T]=g*v+M*S+_*E+p*R}return r}}var EC=new Yt;class Vy extends tf{interpolate_(e,t,n,i){let r=super.interpolate_(e,t,n,i);return EC.fromArray(r).normalize().toArray(r),r}}var Hn={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},Ys={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},xy={9728:ti,9729:Jt,9984:Bc,9985:Os,9986:Zr,9987:yi},vy={33071:Ds,33648:kc,10497:Ns},jd={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Jd={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Er={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},TC={CUBICSPLINE:void 0,LINEAR:Xc,STEP:sd},qd={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function AC(e){if(e.DefaultMaterial===void 0)e.DefaultMaterial=new Wi({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:pr});return e.DefaultMaterial}function ns(e,t,n){for(let i in n.extensions)if(e[i]===void 0)t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=n.extensions[i]}function Ti(e,t){if(t.extras!==void 0)if(typeof t.extras==="object")Object.assign(e.userData,t.extras);else console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras)}function RC(e,t,n){let i=!1,r=!1,s=!1;for(let l=0,u=t.length;l<u;l++){let h=t[l];if(h.POSITION!==void 0)i=!0;if(h.NORMAL!==void 0)r=!0;if(h.COLOR_0!==void 0)s=!0;if(i&&r&&s)break}if(!i&&!r&&!s)return Promise.resolve(e);let o=[],a=[],c=[];for(let l=0,u=t.length;l<u;l++){let h=t[l];if(i){let d=h.POSITION!==void 0?n.getDependency("accessor",h.POSITION):e.attributes.position;o.push(d)}if(r){let d=h.NORMAL!==void 0?n.getDependency("accessor",h.NORMAL):e.attributes.normal;a.push(d)}if(s){let d=h.COLOR_0!==void 0?n.getDependency("accessor",h.COLOR_0):e.attributes.color;c.push(d)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c)]).then(function(l){let u=l[0],h=l[1],d=l[2];if(i)e.morphAttributes.position=u;if(r)e.morphAttributes.normal=h;if(s)e.morphAttributes.color=d;return e.morphTargetsRelative=!0,e})}function CC(e,t){if(e.updateMorphTargets(),t.weights!==void 0)for(let n=0,i=t.weights.length;n<i;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){let n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let i=0,r=n.length;i<r;i++)e.morphTargetDictionary[n[i]]=i}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function IC(e){let t,n=e.extensions&&e.extensions[Qe.KHR_DRACO_MESH_COMPRESSION];if(n)t="draco:"+n.bufferView+":"+n.indices+":"+Yd(n.attributes);else t=e.indices+":"+Yd(e.attributes)+":"+e.mode;if(e.targets!==void 0)for(let i=0,r=e.targets.length;i<r;i++)t+=":"+Yd(e.targets[i]);return t}function Yd(e){let t="",n=Object.keys(e).sort();for(let i=0,r=n.length;i<r;i++)t+=n[i]+":"+e[n[i]]+";";return t}function Qd(e){switch(e){case Int8Array:return 0.007874015748031496;case Uint8Array:return 0.00392156862745098;case Int16Array:return 0.00003051850947599719;case Uint16Array:return 0.000015259021896696422;default:throw Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function PC(e){if(e.search(/\.jpe?g($|\?)/i)>0||e.search(/^data\:image\/jpeg/)===0)return"image/jpeg";if(e.search(/\.webp($|\?)/i)>0||e.search(/^data\:image\/webp/)===0)return"image/webp";if(e.search(/\.ktx2($|\?)/i)>0||e.search(/^data\:image\/ktx2/)===0)return"image/ktx2";return"image/png"}var LC=new Xe;class $y{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new MC,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=-1,r=!1,s=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){let o=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(o)===!0;let a=o.match(/Version\/(\d+)/);i=n&&a?parseInt(a[1],10):-1,r=o.indexOf("Firefox")>-1,s=r?o.match(/Firefox\/([0-9]+)\./)[1]:-1}if(typeof createImageBitmap>"u"||n&&i<17||r&&s<98)this.textureLoader=new Hs(this.options.manager);else this.textureLoader=new hl(this.options.manager);if(this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new oa(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials")this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(s){return s._markDefs&&s._markDefs()}),Promise.all(this._invokeAll(function(s){return s.beforeRoot&&s.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(s){let o={scene:s[0][i.scene||0],scenes:s[0],animations:s[1],cameras:s[2],asset:i.asset,parser:n,userData:{}};return ns(r,o,i),Ti(o,i),Promise.all(n._invokeAll(function(a){return a.afterRoot&&a.afterRoot(o)})).then(function(){for(let a of o.scenes)a.updateMatrixWorld();e(o)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,r=t.length;i<r;i++){let s=t[i].joints;for(let o=0,a=s.length;o<a;o++)e[s[o]].isBone=!0}for(let i=0,r=e.length;i<r;i++){let s=e[i];if(s.mesh!==void 0){if(this._addNodeRef(this.meshCache,s.mesh),s.skin!==void 0)n[s.mesh].isSkinnedMesh=!0}if(s.camera!==void 0)this._addNodeRef(this.cameraCache,s.camera)}}_addNodeRef(e,t){if(t===void 0)return;if(e.refs[t]===void 0)e.refs[t]=e.uses[t]=0;e.refs[t]++}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;let i=n.clone(),r=(s,o)=>{let a=this.associations.get(s);if(a!=null)this.associations.set(o,a);for(let[c,l]of s.children.entries())r(l,o.children[c])};return r(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){let i=e(t[n]);if(i)return i}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let n=[];for(let i=0;i<t.length;i++){let r=e(t[i]);if(r)n.push(r)}return n}getDependency(e,t){let n=e+":"+t,i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":i=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!i)throw Error("Unknown type: "+e);break}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){let n=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(i.map(function(r,s){return n.getDependency(e,s)})),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[Qe.KHR_BINARY_GLTF].body);let i=this.options;return new Promise(function(r,s){n.load(Mr.resolveURL(t.uri,i.path),r,void 0,function(){s(Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){let t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){let i=t.byteLength||0,r=t.byteOffset||0;return n.slice(r,r+i)})}loadAccessor(e){let t=this,n=this.json,i=this.json.accessors[e];if(i.bufferView===void 0&&i.sparse===void 0){let s=jd[i.type],o=Ys[i.componentType],a=i.normalized===!0,c=new o(i.count*s);return Promise.resolve(new Kt(c,s,a))}let r=[];if(i.bufferView!==void 0)r.push(this.getDependency("bufferView",i.bufferView));else r.push(null);if(i.sparse!==void 0)r.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",i.sparse.values.bufferView));return Promise.all(r).then(function(s){let o=s[0],a=jd[i.type],c=Ys[i.componentType],l=c.BYTES_PER_ELEMENT,u=l*a,h=i.byteOffset||0,d=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,f=i.normalized===!0,m,_;if(d&&d!==u){let p=Math.floor(h/d),g="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+p+":"+i.count,M=t.cache.get(g);if(!M)m=new c(o,p*d,i.count*d/l),M=new Ko(m,d/l),t.cache.add(g,M);_=new ks(M,a,h%d/l,f)}else{if(o===null)m=new c(i.count*a);else m=new c(o,h,i.count*a);_=new Kt(m,a,f)}if(i.sparse!==void 0){let p=jd.SCALAR,g=Ys[i.sparse.indices.componentType],M=i.sparse.indices.byteOffset||0,T=i.sparse.values.byteOffset||0,v=new g(s[1],M,i.sparse.count*p),S=new c(s[2],T,i.sparse.count*a);if(o!==null)_=new Kt(_.array.slice(),_.itemSize,_.normalized);_.normalized=!1;for(let E=0,R=v.length;E<R;E++){let x=v[E];if(_.setX(x,S[E*a]),a>=2)_.setY(x,S[E*a+1]);if(a>=3)_.setZ(x,S[E*a+2]);if(a>=4)_.setW(x,S[E*a+3]);if(a>=5)throw Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}_.normalized=f}return _})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,s=t.images[r],o=this.textureLoader;if(s.uri){let a=n.manager.getHandler(s.uri);if(a!==null)o=a}return this.loadTextureImage(e,r,o)}loadTextureImage(e,t,n){let i=this,r=this.json,s=r.textures[e],o=r.images[t],a=(o.uri||o.bufferView)+":"+s.sampler;if(this.textureCache[a])return this.textureCache[a];let c=this.loadImageSource(t,n).then(function(l){if(l.flipY=!1,l.name=s.name||o.name||"",l.name===""&&typeof o.uri==="string"&&o.uri.startsWith("data:image/")===!1)l.name=o.uri;let h=(r.samplers||{})[s.sampler]||{};return l.magFilter=xy[h.magFilter]||Jt,l.minFilter=xy[h.minFilter]||yi,l.wrapS=vy[h.wrapS]||Ns,l.wrapT=vy[h.wrapT]||Ns,l.generateMipmaps=!l.isCompressedTexture&&l.minFilter!==ti&&l.minFilter!==Jt,i.associations.set(l,{textures:e}),l}).catch(function(){return null});return this.textureCache[a]=c,c}loadImageSource(e,t){let n=this,i=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then((u)=>u.clone());let s=i.images[e],o=self.URL||self.webkitURL,a=s.uri||"",c=!1;if(s.bufferView!==void 0)a=n.getDependency("bufferView",s.bufferView).then(function(u){c=!0;let h=new Blob([u],{type:s.mimeType});return a=o.createObjectURL(h),a});else if(s.uri===void 0)throw Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let l=Promise.resolve(a).then(function(u){return new Promise(function(h,d){let f=h;if(t.isImageBitmapLoader===!0)f=function(m){let _=new Ot(m);_.needsUpdate=!0,h(_)};t.load(Mr.resolveURL(u,r.path),f,void 0,d)})}).then(function(u){if(c===!0)o.revokeObjectURL(a);return Ti(u,s),u.userData.mimeType=s.mimeType||PC(s.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),u});return this.sourceCache[e]=l,l}assignTexture(e,t,n,i){let r=this;return this.getDependency("texture",n.index).then(function(s){if(!s)return null;if(n.texCoord!==void 0&&n.texCoord>0)s=s.clone(),s.channel=n.texCoord;if(r.extensions[Qe.KHR_TEXTURE_TRANSFORM]){let o=n.extensions!==void 0?n.extensions[Qe.KHR_TEXTURE_TRANSFORM]:void 0;if(o){let a=r.associations.get(s);s=r.extensions[Qe.KHR_TEXTURE_TRANSFORM].extendTexture(s,o),r.associations.set(s,a)}}if(i!==void 0)s.colorSpace=i;return e[t]=s,s})}assignFinalMaterial(e){let{geometry:t,material:n}=e,i=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,s=t.attributes.normal===void 0;if(e.isPoints){let o="PointsMaterial:"+n.uuid,a=this.cache.get(o);if(!a)a=new ia,yn.prototype.copy.call(a,n),a.color.copy(n.color),a.map=n.map,a.sizeAttenuation=!1,this.cache.add(o,a);n=a}else if(e.isLine){let o="LineBasicMaterial:"+n.uuid,a=this.cache.get(o);if(!a)a=new na,yn.prototype.copy.call(a,n),a.color.copy(n.color),a.map=n.map,this.cache.add(o,a);n=a}if(i||r||s){let o="ClonedMaterial:"+n.uuid+":";if(i)o+="derivative-tangents:";if(r)o+="vertex-colors:";if(s)o+="flat-shading:";let a=this.cache.get(o);if(!a){if(a=n.clone(),r)a.vertexColors=!0;if(s)a.flatShading=!0;if(i){if(a.normalScale)a.normalScale.y*=-1;if(a.clearcoatNormalScale)a.clearcoatNormalScale.y*=-1}this.cache.add(o,a),this.associations.set(a,this.associations.get(n))}n=a}e.material=n}getMaterialType(){return Wi}loadMaterial(e){let t=this,n=this.json,i=this.extensions,r=n.materials[e],s,o={},a=r.extensions||{},c=[];if(a[Qe.KHR_MATERIALS_UNLIT]){let u=i[Qe.KHR_MATERIALS_UNLIT];s=u.getMaterialType(),c.push(u.extendParams(o,r,t))}else{let u=r.pbrMetallicRoughness||{};if(o.color=new Ge(1,1,1),o.opacity=1,Array.isArray(u.baseColorFactor)){let h=u.baseColorFactor;o.color.setRGB(h[0],h[1],h[2],Rn),o.opacity=h[3]}if(u.baseColorTexture!==void 0)c.push(t.assignTexture(o,"map",u.baseColorTexture,gr));if(o.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,o.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0)c.push(t.assignTexture(o,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(o,"roughnessMap",u.metallicRoughnessTexture));s=this._invokeOne(function(h){return h.getMaterialType&&h.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(h){return h.extendMaterialParams&&h.extendMaterialParams(e,o)})))}if(r.doubleSided===!0)o.side=Bn;let l=r.alphaMode||qd.OPAQUE;if(l===qd.BLEND)o.transparent=!0,o.depthWrite=!1;else if(o.transparent=!1,l===qd.MASK)o.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:0.5;if(r.normalTexture!==void 0&&s!==wi){if(c.push(t.assignTexture(o,"normalMap",r.normalTexture)),o.normalScale=new ke(1,1),r.normalTexture.scale!==void 0){let u=r.normalTexture.scale;o.normalScale.set(u,u)}}if(r.occlusionTexture!==void 0&&s!==wi){if(c.push(t.assignTexture(o,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0)o.aoMapIntensity=r.occlusionTexture.strength}if(r.emissiveFactor!==void 0&&s!==wi){let u=r.emissiveFactor;o.emissive=new Ge().setRGB(u[0],u[1],u[2],Rn)}if(r.emissiveTexture!==void 0&&s!==wi)c.push(t.assignTexture(o,"emissiveMap",r.emissiveTexture,gr));return Promise.all(c).then(function(){let u=new s(o);if(r.name)u.name=r.name;if(Ti(u,r),t.associations.set(u,{materials:e}),r.extensions)ns(i,u,r);return u})}createUniqueName(e){let t=ct.sanitizeNodeName(e||"");if(t in this.nodeNamesUsed)return t+"_"+ ++this.nodeNamesUsed[t];else return this.nodeNamesUsed[t]=0,t}loadGeometries(e){let t=this,n=this.extensions,i=this.primitiveCache;function r(o){return n[Qe.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(a){return yy(a,o,t)})}let s=[];for(let o=0,a=e.length;o<a;o++){let c=e[o],l=IC(c),u=i[l];if(u)s.push(u.promise);else{let h;if(c.extensions&&c.extensions[Qe.KHR_DRACO_MESH_COMPRESSION])h=r(c);else h=yy(new ln,c,t);if(c.mode===Hn.TRIANGLE_STRIP)h=h.then((d)=>Xd(d,Xo));else if(c.mode===Hn.TRIANGLE_FAN)h=h.then((d)=>Xd(d,Fs));i[l]={primitive:c,promise:h},s.push(h)}}return Promise.all(s)}loadMesh(e){let t=this,n=this.json,i=this.extensions,r=n.meshes[e],s=r.primitives,o=[];for(let a=0,c=s.length;a<c;a++){let l=s[a].material===void 0?AC(this.cache):this.getDependency("material",s[a].material);o.push(l)}return o.push(t.loadGeometries(s)),Promise.all(o).then(async function(a){let c=a.slice(0,a.length-1),l=a[a.length-1],u=[];for(let d=0,f=l.length;d<f;d++){let m=l[d],_=s[d],p,g=c[d];if(_.mode===Hn.TRIANGLES||_.mode===Hn.TRIANGLE_STRIP||_.mode===Hn.TRIANGLE_FAN||_.mode===void 0){let M=r.isSkinnedMesh===!0,T=m.hasAttribute("skinIndex")&&m.hasAttribute("skinWeight");if(M&&T===!1)console.warn("THREE.GLTFLoader: Missing skinIndex or skinWeight attributes. Skinning disabled.");if(p=M&&T?new el(m,g):new Mt(m,g),p.isSkinnedMesh===!0)p.normalizeSkinWeights()}else if(_.mode===Hn.LINES)p=new tl(m,g);else if(_.mode===Hn.LINE_STRIP)p=new xr(m,g);else if(_.mode===Hn.LINE_LOOP)p=new nl(m,g);else if(_.mode===Hn.POINTS)p=new Gs(m,g);else throw Error("THREE.GLTFLoader: Primitive mode unsupported: "+_.mode);if(Object.keys(p.geometry.morphAttributes).length>0)CC(p,r);if(p.name=t.createUniqueName(r.name||"mesh_"+e),Ti(p,r),_.extensions)ns(i,p,_);t.assignFinalMaterial(p),u.push(p)}for(let d=0,f=u.length;d<f;d++)t.associations.set(u[d],{meshes:e,primitives:d});if(u.length===1){if(r.extensions)ns(i,u[0],r);return u[0]}let h=new gi;if(r.extensions)ns(i,h,r);t.associations.set(h,{meshes:e});for(let d=0,f=u.length;d<f;d++)h.add(u[d]);return h})}loadCamera(e){let t,n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}if(n.type==="perspective")t=new Ht(jo.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2000000);else if(n.type==="orthographic")t=new es(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar);if(n.name)t.name=this.createUniqueName(n.name);return Ti(t,n),Promise.resolve(t)}loadSkin(e){let t=this.json.skins[e],n=[];for(let i=0,r=t.joints.length;i<r;i++)n.push(this._loadNodeShallow(t.joints[i]));if(t.inverseBindMatrices!==void 0)n.push(this.getDependency("accessor",t.inverseBindMatrices));else n.push(null);return Promise.all(n).then(function(i){let r=i.pop(),s=i,o=[],a=[];for(let c=0,l=s.length;c<l;c++){let u=s[c];if(u){o.push(u);let h=new Xe;if(r!==null)h.fromArray(r.array,c*16);a.push(h)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new ea(o,a)})}loadAnimation(e){let t=this.json,n=this,i=t.animations[e],r=i.name?i.name:"animation_"+e,s=[],o=[],a=[],c=[],l=[];for(let u=0,h=i.channels.length;u<h;u++){let d=i.channels[u],f=i.samplers[d.sampler],m=d.target,_=m.node,p=i.parameters!==void 0?i.parameters[f.input]:f.input,g=i.parameters!==void 0?i.parameters[f.output]:f.output;if(m.node===void 0)continue;s.push(this.getDependency("node",_)),o.push(this.getDependency("accessor",p)),a.push(this.getDependency("accessor",g)),c.push(f),l.push(m)}return Promise.all([Promise.all(s),Promise.all(o),Promise.all(a),Promise.all(c),Promise.all(l)]).then(function(u){let h=u[0],d=u[1],f=u[2],m=u[3],_=u[4],p=[];for(let M=0,T=h.length;M<T;M++){let v=h[M],S=d[M],E=f[M],R=m[M],x=_[M];if(v===void 0)continue;if(v.updateMatrix)v.updateMatrix();let w=n._createAnimationTracks(v,S,E,R,x);if(w)for(let G=0;G<w.length;G++)p.push(w[G])}let g=new Cs(r,void 0,p);return Ti(g,i),g})}createNodeMesh(e){let t=this.json,n=this,i=t.nodes[e];if(i.mesh===void 0)return null;return n.getDependency("mesh",i.mesh).then(function(r){let s=n._getNodeRef(n.meshCache,i.mesh,r);if(i.weights!==void 0)s.traverse(function(o){if(!o.isMesh)return;for(let a=0,c=i.weights.length;a<c;a++)o.morphTargetInfluences[a]=i.weights[a]});return s})}loadNode(e){let t=this.json,n=this,i=t.nodes[e],r=n._loadNodeShallow(e),s=[],o=i.children||[];for(let c=0,l=o.length;c<l;c++)s.push(n.getDependency("node",o[c]));let a=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([r,Promise.all(s),a]).then(function(c){let l=c[0],u=c[1],h=c[2];if(h!==null)l.traverse(function(d){if(!d.isSkinnedMesh)return;d.bind(h,LC)});for(let d=0,f=u.length;d<f;d++)l.add(u[d]);if(l.userData.pivot!==void 0&&u.length>0){let d=l.userData.pivot,f=u[0];l.pivot=new z().fromArray(d),l.position.x-=d[0],l.position.y-=d[1],l.position.z-=d[2],f.position.set(0,0,0),delete l.userData.pivot}return l})}_loadNodeShallow(e){let t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let r=t.nodes[e],s=r.name?i.createUniqueName(r.name):"",o=[],a=i._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});if(a)o.push(a);if(r.camera!==void 0)o.push(i.getDependency("camera",r.camera).then(function(c){return i._getNodeRef(i.cameraCache,r.camera,c)}));return i._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){o.push(c)}),this.nodeCache[e]=Promise.all(o).then(function(c){let l;if(r.isBone===!0)l=new Jo;else if(c.length>1)l=new gi;else if(c.length===1)l=c[0];else l=new _t;if(l!==c[0])for(let u=0,h=c.length;u<h;u++)l.add(c[u]);if(r.name)l.userData.name=r.name,l.name=s;if(Ti(l,r),r.extensions)ns(n,l,r);if(r.matrix!==void 0){let u=new Xe;u.fromArray(r.matrix),l.applyMatrix4(u)}else{if(r.translation!==void 0)l.position.fromArray(r.translation);if(r.rotation!==void 0)l.quaternion.fromArray(r.rotation);if(r.scale!==void 0)l.scale.fromArray(r.scale)}if(!i.associations.has(l))i.associations.set(l,{});else if(r.mesh!==void 0&&i.meshCache.refs[r.mesh]>1){let u=i.associations.get(l);i.associations.set(l,{...u})}return i.associations.get(l).nodes=e,l}),this.nodeCache[e]}loadScene(e){let t=this.extensions,n=this.json.scenes[e],i=this,r=new gi;if(n.name)r.name=i.createUniqueName(n.name);if(Ti(r,n),n.extensions)ns(t,r,n);let s=n.nodes||[],o=[];for(let a=0,c=s.length;a<c;a++)o.push(i.getDependency("node",s[a]));return Promise.all(o).then(function(a){for(let l=0,u=a.length;l<u;l++){let h=a[l];if(h.parent!==null)r.add(my(h));else r.add(h)}let c=(l)=>{let u=new Map;for(let[h,d]of i.associations)if(h instanceof yn||h instanceof Ot)u.set(h,d);return l.traverse((h)=>{let d=i.associations.get(h);if(d!=null)u.set(h,d)}),u};return i.associations=c(r),r})}_createAnimationTracks(e,t,n,i,r){let s=[],o=e.name?e.name:e.uuid,a=[];function c(d){if(d.morphTargetInfluences)a.push(d.name?d.name:d.uuid)}if(Er[r.path]===Er.weights){if(c(e),e.isGroup)e.children.forEach(c)}else a.push(o);let l;switch(Er[r.path]){case Er.weights:l=br;break;case Er.rotation:l=Sr;break;case Er.translation:case Er.scale:l=Qr;break;default:switch(n.itemSize){case 1:l=br;break;case 2:case 3:default:l=Qr;break}break}let u=i.interpolation!==void 0?TC[i.interpolation]:Xc,h=this._getArrayFromAccessor(n);for(let d=0,f=a.length;d<f;d++){let m=new l(a[d]+"."+Er[r.path],t.array,h,u);if(i.interpolation==="CUBICSPLINE")this._createCubicSplineTrackInterpolant(m);s.push(m)}return s}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let n=Qd(t.constructor),i=new Float32Array(t.length);for(let r=0,s=t.length;r<s;r++)i[r]=t[r]*n;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){return new(this instanceof Sr?Vy:tf)(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function NC(e,t,n){let i=t.attributes,r=new Vt;if(i.POSITION!==void 0){let a=n.json.accessors[i.POSITION],{min:c,max:l}=a;if(c!==void 0&&l!==void 0){if(r.set(new z(c[0],c[1],c[2]),new z(l[0],l[1],l[2])),a.normalized){let u=Qd(Ys[a.componentType]);r.min.multiplyScalar(u),r.max.multiplyScalar(u)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;let s=t.targets;if(s!==void 0){let a=new z,c=new z;for(let l=0,u=s.length;l<u;l++){let h=s[l];if(h.POSITION!==void 0){let d=n.json.accessors[h.POSITION],{min:f,max:m}=d;if(f!==void 0&&m!==void 0){if(c.setX(Math.max(Math.abs(f[0]),Math.abs(m[0]))),c.setY(Math.max(Math.abs(f[1]),Math.abs(m[1]))),c.setZ(Math.max(Math.abs(f[2]),Math.abs(m[2]))),d.normalized){let _=Qd(Ys[d.componentType]);c.multiplyScalar(_)}a.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(a)}e.boundingBox=r;let o=new In;r.getCenter(o.center),o.radius=r.min.distanceTo(r.max)/2,e.boundingSphere=o}function yy(e,t,n){let i=t.attributes,r=[];function s(o,a){return n.getDependency("accessor",o).then(function(c){e.setAttribute(a,c)})}for(let o in i){let a=Jd[o]||o.toLowerCase();if(a in e.attributes)continue;r.push(s(i[o],a))}if(t.indices!==void 0&&!e.index){let o=n.getDependency("accessor",t.indices).then(function(a){e.setIndex(a)});r.push(o)}if(Ke.workingColorSpace!==Rn&&"COLOR_0"in i)console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${Ke.workingColorSpace}" not supported.`);return Ti(e,t),NC(e,t,n),Promise.all(r).then(function(){return t.targets!==void 0?RC(e,t.targets,n):e})}function Ai(e){let t=new Set,n=new Set,i=new Set;e.traverse((r)=>{let s=r;if(!s.isMesh)return;t.add(s.geometry);for(let o of Array.isArray(s.material)?s.material:[s.material]){n.add(o);for(let a of Object.values(o))if(a instanceof Ot)i.add(a)}});for(let r of[...t,...n,...i])r.dispose()}async function Wy(e){ku(e);let t=new sa,n=!1;t.onError=()=>{n=!0},t.addHandler(/^data:image\//,new Hs(t)),t.setURLModifier((s)=>{if(!s.startsWith("blob:")&&!s.startsWith("data:"))throw Error("External model resources are not loaded");return s});let i=new ef(t);i.register((s)=>({name:"KILN_embedded_images",async beforeRoot(){for(let o of s.json.images??[]){if(o.bufferView===void 0)continue;let a=new Uint8Array(await s.getDependency("bufferView",o.bufferView)),c="";for(let l=0;l<a.length;l+=8192)c+=String.fromCharCode(...a.subarray(l,l+8192));if(!/^image\/(png|jpeg|webp|avif)$/.test(o.mimeType??""))throw Error("Unsupported embedded image type");o.uri=`data:${o.mimeType};base64,${btoa(c)}`,delete o.bufferView}}}));let r=await i.parseAsync(Uint8Array.from(e).buffer,"");if(n){for(let s of r.scenes)Ai(s);throw Error("An embedded texture could not be decoded.")}return Object.assign(r,{assertTexturesLoaded(){if(n)throw Error("An embedded texture could not be decoded.")}})}function Zy(e,t,n=40,i=[e]){let r=e.getCenter(new z),s=Math.max(e.getSize(new z).length()/2,0.01),o=new z(1,0.65,1.25).normalize(),a=new z().crossVectors(new z(0,1,0),o).normalize(),c=new z().crossVectors(o,a),l=[];for(let M of i.length?i:[e])for(let T of[M.min.x,M.max.x])for(let v of[M.min.y,M.max.y])for(let S of[M.min.z,M.max.z])l.push(new z(T,v,S));let u=1/0,h=-1/0,d=1/0,f=-1/0;for(let M of l){let T=M.clone().sub(r),v=T.dot(a),S=T.dot(c);u=Math.min(u,v),h=Math.max(h,v),d=Math.min(d,S),f=Math.max(f,S)}r.addScaledVector(a,(u+h)/2),r.addScaledVector(c,(d+f)/2);let m=Math.tan(n*Math.PI/360),_=m*t,p=s;for(let M of l){let T=M.clone().sub(r),v=T.dot(o);p=Math.max(p,v+Math.abs(T.dot(a))*1.12/_,v+Math.abs(T.dot(c))*1.12/m)}let g=r.clone().addScaledVector(o,p);return{center:r,radius:s,distance:p,position:g}}function nf(e,t){return{position:e.position.clone(),target:t.clone()}}function rf(e,t,n,i){e.position.copy(n.position),t.copy(n.target);let r=Math.max(i.getSize(new z).length(),0.001);e.near=Math.min(0.01,Math.max(r/1e5,0.00001)),e.far=Math.max(e.position.distanceTo(i.getCenter(new z))+r*20,10),e.updateProjectionMatrix()}function Xy(e,t,n){let i=e.getWorldDirection(new z);if(i.y=0,i.lengthSq()<0.00000001)i.set(0,0,-1);i.normalize();let r=i.clone().cross(new z(0,1,0)),s=new z;if(t.has("KeyW")||t.has("ArrowUp"))s.add(i);if(t.has("KeyS")||t.has("ArrowDown"))s.sub(i);if(t.has("KeyD")||t.has("ArrowRight"))s.add(r);if(t.has("KeyA")||t.has("ArrowLeft"))s.sub(r);if(t.has("KeyE"))s.y++;if(t.has("KeyQ"))s.y--;return s.normalize().multiplyScalar(n)}function jy(e){let t=e.filter((i)=>Number.isFinite(i)&&i>0).sort((i,r)=>i-r);if(!t.length)throw Error("No frame timing evidence was collected.");let n=(i)=>t[Math.max(0,Math.ceil(t.length*i)-1)];return{samples:t.length,min:t[0],p50:n(0.5),p95:n(0.95),max:t.at(-1)}}async function qy(e,t){let n=t();if(n===void 0)throw Error("Wait for the selected artifact to be loaded before measuring.");let i=JSON.stringify(n),r=await e();if(JSON.stringify(t())!==i)throw Error("The artifact changed during measurement. Measure the loaded revision again.");return{...r,artifact:n}}function Yy(e,t,n){if(t())return e;n(e);return}function vl(e,t){let n=e.parser.json.nodes??[],i=new Set;if(n.forEach((s,o)=>{if(s?.extensions?.KHR_node_visibility?.visible===!1)i.add(o)}),i.size===0)return 0;let r=0;for(let s of t)s.traverse((o)=>{let a=e.parser.associations.get(o)?.nodes;if(a===void 0||!i.has(a))return;o.visible=!1,r++});return r}function yl(e){let t=!1;if(e.traverse((s)=>{if(!s.visible)t=!0}),!t)return new Vt().setFromObject(e,!0);e.updateWorldMatrix(!0,!0);let n=new Vt,i=new Vt,r=new z;return e.traverseVisible((s)=>{let o=s,a=o.geometry;if(!a)return;let c=a.getAttribute("position");if(c&&o.isInstancedMesh!==!0){for(let u=0;u<c.count;u++){if(o.isMesh)o.getVertexPosition(u,r);else r.fromBufferAttribute(c,u);n.expandByPoint(r.applyMatrix4(s.matrixWorld))}return}let l=s;if(l.boundingBox!==void 0){if(l.boundingBox===null)l.computeBoundingBox();i.copy(l.boundingBox)}else{if(a.boundingBox===null)a.computeBoundingBox();i.copy(a.boundingBox)}n.union(i.applyMatrix4(s.matrixWorld))}),n.isEmpty()?new Vt().setFromObject(e,!0):n}function ma(e){let t=0;return e.traverseVisible((n)=>{let i=n;if(!i.isMesh)return;let r=i.geometry.index?.count??i.geometry.attributes.position?.count??0;t+=r/3*(i.isInstancedMesh?i.count:1)}),t}async function Ky(e){let t=e.parser.json.nodes??[],n=new Map;e.scene.traverse((c)=>{let l=e.parser.associations.get(c)?.nodes;if(l!==void 0&&!n.has(l))n.set(l,c)});let i=new Set,r=[];for(let[c,l]of n){let u=t[c]?.extensions?.MSFT_lod?.ids;if(!Array.isArray(u)||u.length===0)continue;if(u.some((m)=>!Number.isInteger(m)||!t[m]||n.has(m)))continue;let h=l.parent;while(h&&!i.has(h))h=h.parent;if(h)continue;let d=[l];for(let m of u)d.push(await e.parser.getDependency("node",m));vl(e,d.slice(1)),i.add(l);let f=(l.name.replace(/[_ -]?LOD0$/i,"")||l.parent?.name||`Part ${c}`).replace(/^Mesh_/,"");r.push({id:String(c),label:f,levels:d})}if(r.length===0)return;let s=ma(e.scene)-r.reduce((c,l)=>c+sf(l,0),0),o=Math.max(...r.map((c)=>c.levels.length)),a=Array.from({length:o},(c,l)=>s+r.reduce((u,h)=>u+sf(h,l),0));return{chains:r,triangles:a}}var Jy=(e,t)=>e.levels[Math.min(Math.max(Number.isFinite(t)?Math.floor(t):0,0),e.levels.length-1)];function sf(e,t){let n=e.levels.find((i)=>i.parent)?.parent;while(n){if(!n.visible)return 0;n=n.parent}return ma(Jy(e,t))}function Qy(e,t){let n=Jy(e,t),i=e.levels.find((s)=>s.parent!==null);if(!i||i===n)return;let r=i.parent;r.children[r.children.indexOf(i)]=n,n.parent=r,i.parent=null}function eb(e,t){for(let n of e.chains)Qy(n,t)}function tb(e,t,n){let i=e.chains.find((r)=>r.id===t);if(!i)return!1;return Qy(i,n),!0}function nb(e,t){if(!e)return;return{triangles:ma(t),levels:e.triangles,chains:e.chains.map((n)=>({id:n.id,label:n.label,level:n.levels.findIndex((i)=>i.parent!==null),triangles:n.levels.map((i,r)=>sf(n,r))}))}}function Ks(e){return(e?.chains??[]).flatMap((t)=>t.levels.filter((n)=>n.parent===null))}function of(e){return e.map((t,n)=>`LOD${n} · ${t.toLocaleString()} triangles`)}function ga(e){let t=new Hd({antialias:!0,alpha:!1});t.setPixelRatio(Math.min(devicePixelRatio,2)),t.setClearColor(1382930),t.toneMapping=$o,t.toneMappingExposure=1.15,e.replaceChildren(t.domElement);let n=new zs,i=new Ht(40,1,0.01,1000),r=new Wd(i,t.domElement);r.enableDamping=!0,t.domElement.tabIndex=0,t.domElement.setAttribute("aria-label","Interactive 3D asset. Drag to orbit or use Explore navigation.");let s=new Set,o=!1,a=1,c=new Set(["KeyW","KeyA","KeyS","KeyD","KeyQ","KeyE","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","ShiftLeft","ShiftRight"]),l=(P)=>{if(!o||!c.has(P.code))return;P.preventDefault(),s.add(P.code)},u=(P)=>s.delete(P.code),h=()=>s.clear();t.domElement.addEventListener("keydown",l),t.domElement.addEventListener("keyup",u),t.domElement.addEventListener("blur",h);let d=new fa(t),f=new Zd,m=d.fromScene(f,0.04);n.environment=m.texture,f.dispose(),d.dispose();let _=new Ws(16773591,2.4);_.position.set(4,8,5),n.add(_),n.add(new cl(14806490,5065021,1.7));let p,g,M,T=[],v=!0,S=performance.now(),E=0,R=0,x=!1,w,G,C,D=(P)=>{if(!C)return;clearTimeout(C.timeout),C.reject(Error(P)),C=void 0},ee=(P)=>{let J=t.getContext(),H=J.getExtension("WEBGL_debug_renderer_info");return{version:"kiln.viewer-performance.v1",measuredAt:new Date().toISOString(),windowMs:P-C.started,frameMs:jy(C.samples),...G===void 0?{}:{loadToFirstFrameMs:G},drawCalls:t.info.render.calls,triangles:t.info.render.triangles,lines:t.info.render.lines,points:t.info.render.points,geometryObjects:t.info.memory.geometries,textureObjects:t.info.memory.textures,shaderPrograms:t.info.programs?.length??0,viewport:{cssWidth:e.clientWidth,cssHeight:e.clientHeight,bufferWidth:t.domElement.width,bufferHeight:t.domElement.height,devicePixelRatio:t.getPixelRatio()},renderer:{version:String(J.getParameter(J.VERSION)),vendor:String(J.getParameter(J.VENDOR)),renderer:String(J.getParameter(J.RENDERER)),browser:navigator.userAgent,...H?{unmaskedVendor:String(J.getParameter(H.UNMASKED_VENDOR_WEBGL)),unmaskedRenderer:String(J.getParameter(H.UNMASKED_RENDERER_WEBGL))}:{}},camera:{position:i.position.toArray(),target:r.target.toArray(),fov:i.fov},limitations:["Exploratory measurement: workloads outside this page are uncontrolled. This is not an isolated performance baseline or budget acceptance.","Frame intervals measure browser requestAnimationFrame pacing, including scheduling and vertical sync; they are not GPU execution time.","Load-to-first-frame begins at GLB parsing and ends after the first render submission; it excludes download time and does not measure presentation latency.","Draw and resource counts come from this Three.js renderer, including studio lighting resources. Object counts are not GPU memory bytes.","This receipt describes this viewport, camera and device only. It is not a performance qualification for other consumers or hardware."]}},L=()=>{if(!p)return;let P=yl(p),J=[];p.traverseVisible((he)=>{if(he instanceof Mt||he instanceof xr||he instanceof Gs){let de=new Vt().setFromObject(he,!0);if(!de.isEmpty())J.push(de)}});let{center:H,radius:q,distance:Q,position:ge}=Zy(P,i.aspect,i.fov,J);if(r.target.copy(H),i.position.copy(ge),i.near=Math.max(q/1000,0.0001),i.far=Q+q*100,r.minDistance=q*0.1,r.maxDistance=q*80,a=Math.max(q*0.35,0.01),o)r.minDistance=q*0.00001;i.updateProjectionMatrix(),r.update()},W=new ResizeObserver(()=>{let{clientWidth:P,clientHeight:J}=e;if(!P||!J)return;t.setSize(P,J),i.aspect=P/J,i.updateProjectionMatrix()});W.observe(e);let B=(P)=>{if(x)return;let J=Math.min((P-S)/1000,0.1);if(S=P,e.clientWidth&&e.clientHeight){if(v)M?.update(J);if(o&&s.size){let H=Xy(i,s,J*a*(s.has("ShiftLeft")||s.has("ShiftRight")?3:1));i.position.add(H),r.target.add(H)}if(r.update(),t.render(n,i),w!==void 0)G=performance.now()-w,w=void 0;if(C){if(C.previous>0&&C.samples.length<1800)C.samples.push(P-C.previous);if(C.previous=P,P-C.started>=C.duration&&C.samples.length){let H=ee(P);clearTimeout(C.timeout),C.resolve(H),C=void 0}}}else s.clear(),D("Keep the measured viewport visible for the complete sampling window.");E=requestAnimationFrame(B)};return E=requestAnimationFrame(B),{async load(P,J={}){let H=performance.now(),q=++R;D("The artifact changed during measurement. Measure the new revision again.");let Q=await Wy(P);vl(Q,[Q.scene]);let ge=await Ky(Q);try{Q.assertTexturesLoaded()}catch(re){Ai(Q.scene);for(let oe of Ks(ge))Ai(oe);throw re}let he=Yy(Q,()=>!x&&q===R&&J.isCurrent?.()!==!1,(re)=>{Ai(re.scene);for(let oe of Ks(ge))Ai(oe)});if(!he)return;let de=p&&J.preserveView?nf(i,r.target):void 0;if(p){M?.stopAllAction(),M?.uncacheRoot(p),n.remove(p),Ai(p);for(let re of Ks(g))Ai(re)}p=he.scene,g=ge,w=H,G=void 0,n.add(p),T=he.animations,M=new dl(p),v=!0;let{clientWidth:fe,clientHeight:I}=e;if(t.setSize(fe,I),i.aspect=fe&&I?fe/I:i.aspect,L(),de)rf(i,r.target,de,yl(p)),r.update();let V=0,j=new Set;return p.traverseVisible((re)=>{let oe=re;if(!oe.isMesh)return;V++;for(let ue of Array.isArray(oe.material)?oe.material:[oe.material])j.add(ue)}),J.onCommit?.(),{triangles:ma(p),meshes:V,materials:j.size,clips:T.map((re)=>re.name),...g?{levels:g.triangles}:{}}},level(P){if(D("The level of detail changed. Measure the displayed combination again."),g)eb(g,P)},partLevel(P,J){if(D("The level of detail changed. Measure the displayed combination again."),g)tb(g,P,J)},lod(){return p?nb(g,p):void 0},reset:L,cancelMeasurement:D,measure(P=3000){if(x||!p||!e.clientWidth||!e.clientHeight)return Promise.reject(Error("Load an artifact in a visible viewport before measuring."));if(!Number.isFinite(P)||P<1000||P>5000)return Promise.reject(Error("Measurement duration must be 1–5 seconds."));if(C)return Promise.reject(Error("A measurement is already running."));return new Promise((J,H)=>{C={started:performance.now(),previous:0,duration:P,samples:[],resolve:J,reject:H,timeout:setTimeout(()=>D("Measurement was interrupted or the browser stopped delivering frames."),P+2000)}})},view(){return nf(i,r.target)},setView(P){if(!p)return;rf(i,r.target,P,yl(p)),r.update()},navigation(P){if(o=P==="explore",s.clear(),r.minDistance=o?0.00001:a/3.5,o)i.near=0.0001,i.updateProjectionMatrix()},wire(P){for(let J of p?[p,...Ks(g)]:[])J.traverse((H)=>{let q=H;if(q.isMesh){for(let Q of Array.isArray(q.material)?q.material:[q.material])if("wireframe"in Q)Q.wireframe=P}})},lighting(P){t.toneMappingExposure=P==="bright"?1.65:P==="soft"?0.85:1.15,_.intensity=P==="soft"?0.8:2.4},clip(P){if(M?.stopAllAction(),T[P])M?.clipAction(T[P]).play()},pause(P){v=!P},dispose(){if(D("The viewport closed before measurement finished."),x=!0,R++,cancelAnimationFrame(E),W.disconnect(),r.dispose(),t.domElement.removeEventListener("keydown",l),t.domElement.removeEventListener("keyup",u),t.domElement.removeEventListener("blur",h),p)Ai(p);for(let P of Ks(g))Ai(P);m.dispose(),t.dispose(),e.replaceChildren()}}}var ae=(e)=>document.getElementById(e);function N(e,t,n){let i=document.createElement(e);if(t!==void 0)i.textContent=t;if(n)i.className=n;return i}function hn(e){let t=ae("dashboard-status");t.textContent=e instanceof Error?e.message:String(e),t.hidden=!t.textContent}async function Xt(e,t){let n=await fetch(e,t?{method:t.method,headers:{"Content-Type":"application/json"},body:JSON.stringify(t.body)}:void 0),i=await n.json();if(!n.ok)throw Error(i.error??`Request failed (${n.status})`);return i}function Js(e,t){let n=N("div",void 0,"empty");return n.append(N("b",e),N("p",t)),n}function ri(e,t){try{localStorage.setItem(e,t)}catch{}}function Tr(e){try{return localStorage.getItem(e)}catch{return null}}function Qt(e){return e?e.slice(0,15):"Unspecified"}function Qs(e,t){let n=N("details",void 0,"record-details");return n.append(N("summary",e),N("pre",JSON.stringify(t,null,2))),n}function _a(e,t,n,i){let r=n.lod();if(e.hidden=!r,t.hidden=!r,t.replaceChildren(),e.replaceChildren(),e.onchange=null,!r)return;e.append(...of(r.levels).map((l,u)=>new Option(l,String(u))));let s=new Option("Mixed part levels","mixed");s.disabled=!0,e.append(s);let o=N("p","","lod-total");o.setAttribute("role","status"),t.append(o);let a=new Map;if(r.chains.length>1){let l=N("details",void 0,"lod-parts");l.append(N("summary","Per-part levels")),l.append(N("p","Choose a level for each part. The main selector sets every part to the same index.","subtle"));let u=N("div",void 0,"lod-part-fields"),h=new Set(r.chains.filter((d,f,m)=>m.findIndex((_)=>_.label===d.label)!==f).map((d)=>d.label));for(let[d,f]of r.chains.entries()){let m=h.has(f.label)?`${f.label} (part ${d+1})`:f.label,_=N("label",m,"inline-field"),p=N("select");p.setAttribute("aria-label",`${m} level of detail`),p.append(...of(f.triangles).map((g,M)=>new Option(g,String(M)))),p.onchange=()=>{n.partLevel(f.id,Number(p.value)),c(),i?.()},a.set(f.id,p),_.append(p),u.append(_)}l.append(u),t.append(l)}function c(){let l=n.lod();if(!l)return;let u=l.levels.findIndex((h,d)=>l.chains.every((f)=>f.level===Math.min(d,f.triangles.length-1)));e.value=u<0?"mixed":String(u),o.textContent=`${l.triangles.toLocaleString()} triangles displayed`;for(let h of l.chains){let d=a.get(h.id);if(d)d.value=String(h.level)}}return e.onchange=()=>{if(e.value==="mixed")return;let l=Number(e.value);n.level(l),c(),i?.(l)},c(),{refresh:c}}var ib=/^[a-z][a-z0-9_-]{0,79}$/u,DC=/^r_[a-z0-9_-]{1,77}$/u;function rb(e){let t=new URLSearchParams(e),n=t.get("collection"),i=t.get("asset"),r=t.get("revision");if(!n||!i||!r||!ib.test(n)||!ib.test(i)||!DC.test(r))return;return{collection:n,assetId:i,revisionId:r}}var sb=new TextEncoder,OC=new TextDecoder,eo=(e)=>e!==null&&typeof e==="object"&&!Array.isArray(e),af=(e,t)=>Object.hasOwn(e,t);async function ob(e){let t=await crypto.subtle.digest("SHA-256",Uint8Array.from(e));return`sha256:${Array.from(new Uint8Array(t),(n)=>n.toString(16).padStart(2,"0")).join("")}`}function UC(e){if(e.length>200||!/^[a-z0-9][a-z0-9._-]*\.kiln-metadata\.json$/i.test(e)||/^(con|prn|aux|nul|com[0-9]|lpt[0-9])\./i.test(e))throw Error("Runtime metadata filename must be a portable sibling *.kiln-metadata.json filename")}async function ab(e,t={}){let n=t.profile??"editable";if(n!=="editable"&&n!=="runtime")throw Error("Unknown export profile");cc(e);let i=e.files["asset.glb"];if(n==="editable")return{profile:n,glb:i};let r=t.metadataFileName??"runtime.kiln-metadata.json";UC(r);for(let[M,T]of Object.entries(e.files))if(await ob(T)!==e.manifest.files[M].sha256)throw Error(`Asset integrity mismatch: ${M}`);let s=new DataView(i.buffer,i.byteOffset,i.byteLength),o=12;while(o<i.length){if(o+8>i.length)throw Error("Invalid GLB chunk header");let M=s.getUint32(o,!0);if(M%4||o+8+M>i.length)throw Error("Invalid GLB chunk length");o+=8+M}let a=20+s.getUint32(12,!0),c=JSON.parse(OC.decode(i.subarray(20,a)));if(!eo(c)||!eo(c.asset)||c.asset.version!=="2.0")throw Error("Invalid glTF asset");let l=c.asset;if(af(l,"extras")&&!eo(l.extras))throw Error("Cannot add provenance to non-object asset extras");let u=l.extras??{};if(af(u,"kilnProvenanceV1"))throw Error("Asset extras already contain kilnProvenanceV1; export from the canonical revision");let h=[];if(c.scenes!==void 0&&!Array.isArray(c.scenes))throw Error("Invalid glTF scenes");for(let[M,T]of(c.scenes??[]).entries()){if(!eo(T)||!eo(T.extras)||!af(T.extras,"kilnReviewClipsV1"))continue;let v=T.extras.kilnReviewClipsV1;if(!eo(v)||v.version!==1&&v.version!==2||!Array.isArray(v.clips))throw Error("Unsupported scenes[].extras.kilnReviewClipsV1");h.push({index:M,kilnReviewClipsV1:v}),delete T.extras.kilnReviewClipsV1}let d={version:"kiln.runtime-metadata.v1",source:{assetId:e.manifest.assetId,revisionId:e.manifest.revisionId,glbSha256:e.manifest.files["asset.glb"].sha256,...e.manifest.files["source.kiln.js"]?{sourceSha256:e.manifest.files["source.kiln.js"].sha256}:{}},scenes:h},f=sb.encode(JSON.stringify(d));l.extras={...u,kilnProvenanceV1:{version:"kiln.provenance.v1",profile:"runtime",metadata:{uri:r,sha256:await ob(f)}}};let m=sb.encode(JSON.stringify(c)),_=Math.ceil(m.length/4)*4,p=new Uint8Array(20+_+i.length-a);if(p.length>Un||f.length>Un)throw Error("Runtime export exceeds 64 MiB");p.set(i.subarray(0,20));let g=new DataView(p.buffer);return g.setUint32(8,p.length,!0),g.setUint32(12,_,!0),p.fill(32,20,20+_),p.set(m,20),p.set(i.subarray(a),20+_),{profile:n,glb:p,metadata:{name:r,bytes:f}}}var si=Fe().regex(/^[a-z][a-z0-9_-]{0,79}$/).refine((e)=>!/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/.test(e),"Reserved filesystem name"),cf=Fe().regex(/^r_[0-9]{10}_[a-f0-9]{64}$/),ub=Fe().regex(/^sha256:[a-f0-9]{64}$/),to=Fe().max(4000),hb=Fe().regex(/^[a-zA-Z0-9][a-zA-Z0-9_.:/-]{0,199}$/),cb=qe({collectionId:si,assetId:si,revisionId:si}).strict(),lb=qe({style:to.default(""),scale:Fe().max(1000).default(""),palette:wt(qe({role:Fe().min(1).max(100),color:Fe().regex(/^#[a-fA-F0-9]{6}$/)}).strict()).max(64).default([]),materialRoles:wt(qe({role:Fe().min(1).max(100),description:to.default(""),resourceId:hb.optional()}).strict()).max(128).default([]),conventions:wt(Fe().max(1000)).max(100).default([]),exceptions:wt(Fe().max(1000)).max(100).default([])}).strict(),FC=qe({resourceId:hb,revisionId:Fe().min(1).max(200),sha256:ub,role:Fe().max(100).optional()}).strict(),zC=wt(FC).max(512),Ri={name:Fe().trim().min(1).max(200),brief:Fe().max(16000).default(""),design:lb.default(()=>lb.parse({})),inventory:wt(qe({id:si,name:Fe().trim().min(1).max(200),kind:pn(["asset","environment"]).default("asset"),brief:to.default(""),references:wt(si).max(64).default([]),asset:cb.optional()}).strict()).max(1000).default([]),deliveryProfiles:wt(qe({id:si,target:pn(["three","godot","unity","unreal","roblox","sbox","usdz","custom"]),description:to.default(""),performanceIntent:Fe().max(1000).default(""),constraints:wt(Fe().max(1000)).max(100).default([])}).strict()).max(32).default([]),materialDependencies:zC.default([]),references:wt(qe({id:si,title:Fe().min(1).max(200),uri:Fe().min(1).max(2048),description:to.default(""),sha256:ub.optional()}).strict()).max(256).default([]),reviews:wt(qe({id:si,inventoryId:si,projectRevisionId:cf,asset:cb,reviewer:Fe().trim().min(1).max(200),verdict:pn(["comment","changes-requested","accepted"]),notes:to}).strict()).max(2000).default([])};function db(e,t){let n=(o,a)=>{if(new Set(o).size!==o.length)t.addIssue({code:rc.custom,path:[a],message:"Duplicate identity"})};n(e.inventory.map((o)=>o.id),"inventory"),n(e.references.map((o)=>o.id),"references"),n(e.deliveryProfiles.map((o)=>o.id),"deliveryProfiles"),n(e.materialDependencies.map((o)=>o.resourceId),"materialDependencies"),n(e.reviews.map((o)=>o.id),"reviews"),n(e.design.palette.map((o)=>o.role),"design.palette"),n(e.design.materialRoles.map((o)=>o.role),"design.materialRoles");let i=new Set(e.references.map((o)=>o.id)),r=new Set(e.inventory.map((o)=>o.id)),s=new Set(e.materialDependencies.map((o)=>o.resourceId));for(let o of e.inventory)if(n(o.references,`inventory.${o.id}.references`),o.references.some((a)=>!i.has(a)))t.addIssue({code:rc.custom,path:["inventory"],message:"Unknown reference"});if(e.reviews.some((o)=>!r.has(o.inventoryId)))t.addIssue({code:rc.custom,path:["reviews"],message:"Unknown inventory item"});if(e.design.materialRoles.some((o)=>o.resourceId&&!s.has(o.resourceId)))t.addIssue({code:rc.custom,path:["design"],message:"Material role requires a locked resource"})}var fb=qe({projectId:si.optional(),...Ri}).strict().superRefine(db),BO=qe({name:Ri.name.optional(),brief:Ri.brief.removeDefault().optional(),design:Ri.design.removeDefault().optional(),inventory:Ri.inventory.removeDefault().optional(),deliveryProfiles:Ri.deliveryProfiles.removeDefault().optional(),materialDependencies:Ri.materialDependencies.removeDefault().optional(),references:Ri.references.removeDefault().optional(),reviews:Ri.reviews.removeDefault().optional()}).strict(),GO=qe({version:jt("kiln.project.v1"),projectId:si,revisionId:cf,parentRevision:cf.optional(),createdAt:Fe().datetime(),...Ri}).strict().superRefine(db);function pb(e){let{palette:t,materialRoles:n,conventions:i,exceptions:r}=e.design??{};return{design:{palette:t??[],materialRoles:n??[],conventions:i??[],exceptions:r??[]},inventory:e.inventory??[],deliveryProfiles:e.deliveryProfiles??[],materialDependencies:e.materialDependencies??[],references:e.references??[],reviews:e.reviews??[]}}function mb(e,t){let n=JSON.parse(e);if(!n||typeof n!=="object"||Array.isArray(n))throw Error("Project configuration must be a JSON object.");let i=n,r=i.design??{};if(!r||typeof r!=="object"||Array.isArray(r))throw Error("Design configuration must be a JSON object.");return fb.parse({...i,name:t.name,brief:t.brief,design:{...r,style:t.style,scale:t.scale}})}function gb(e){let t=[],n=Tr("kiln.project")??"",i,r=()=>{let c=ae("project-list");c.replaceChildren();for(let T of t){let v=N("button",void 0,T.projectId===n?"active":"");if(v.append(N("strong",T.name),N("small",`${T.inventory.length} inventory items · ${T.materialDependencies.length} resources`)),T.projectId===n)v.setAttribute("aria-current","true");v.onclick=()=>{n=T.projectId,ri("kiln.project",n),r()},c.append(v)}let l=t.find((T)=>T.projectId===n),u=ae("project-detail");if(u.replaceChildren(),!l){u.append(Js("A direction for what comes next.","Projects are optional. Group related assets, materials and design decisions here, or build and review standalone assets in Library and Live Review."));return}let h=N("div",void 0,"project-summary"),d=N("div");d.append(N("h2",l.name),N("p",l.brief||"Add a brief to describe what this project should deliver."));let f=N("button","Edit project","secondary");f.onclick=()=>o(l),h.append(d,f),u.append(h);let m=N("p",`${l.projectId} · ${Qt(l.revisionId)} · ${new Date(l.createdAt).toLocaleString()}`,"mono");u.append(m);let _=N("div",void 0,"project-metrics");for(let[T,v]of[[l.inventory.length,"inventory items"],[l.materialDependencies.length,"locked resources"],[l.deliveryProfiles.length,"delivery profiles"]]){let S=N("div");S.append(N("strong",String(T)),N("span",String(v))),_.append(S)}u.append(_);let p=N("div",void 0,"profile-grid");for(let[T,v]of[["Visual direction",l.design.style||"Not specified"],["Scale",l.design.scale||"Not specified"]]){let S=N("div");S.append(N("span",T,"label"),N("p",v)),p.append(S)}u.append(p);let g=N("div",void 0,"palette");for(let T of l.design.palette){let v=N("div",void 0,"swatch"),S=document.createElementNS("http://www.w3.org/2000/svg","svg");S.setAttribute("viewBox","0 0 24 24"),S.setAttribute("aria-hidden","true");let E=document.createElementNS("http://www.w3.org/2000/svg","rect");E.setAttribute("width","24"),E.setAttribute("height","24"),E.setAttribute("fill",T.color),S.append(E);let R=N("span",T.role);R.append(N("small",T.color)),v.append(S,R),g.append(v)}if(g.childElementCount)u.append(g);for(let[T,v]of[["Conventions",l.design.conventions],["Declared exceptions",l.design.exceptions]]){if(!v.length)continue;u.append(N("h3",T));let S=N("ul",void 0,"subtle");for(let E of v)S.append(N("li",E));u.append(S)}if(u.append(N("h3","Inventory")),!l.inventory.length)u.append(N("p","No inventory yet. Add deliberate asset and environment entries in the project configuration.","subtle"));else{let T=N("div",void 0,"table-wrap"),v=N("table"),S=N("thead"),E=N("tr");for(let x of["Item","Kind","Saved revision","Review"])E.append(N("th",x));S.append(E),v.append(S);let R=N("tbody");for(let x of l.inventory){let w=N("tr"),G=N("td",x.name);G.append(N("small",x.brief));let C=N("td"),D=N("td");if(x.asset){let ee=N("button",Qt(x.asset.revisionId),"secondary");ee.onclick=()=>e.openAsset(x.asset),C.append(ee);let L=[...l.reviews].reverse().find((B)=>B.inventoryId===x.id&&B.asset.revisionId===x.asset.revisionId&&B.asset.assetId===x.asset.assetId&&B.asset.collectionId===x.asset.collectionId);D.append(N("small",L?`${L.verdict} · ${L.reviewer}`:"Unreviewed"));let W=N("button","Record review","secondary");W.onclick=()=>a(l,x),D.append(W)}else C.textContent="Not linked",D.textContent="No saved revision";w.append(G,N("td",x.kind),C,D),R.append(w)}v.append(R),T.append(v),u.append(T)}if(l.design.materialRoles.length){u.append(N("h3","Material roles"));for(let T of l.design.materialRoles)u.append(N("p",`${T.role}: ${T.description||"No description"}${T.resourceId?` · ${T.resourceId}`:" · No resource assigned"}`,"subtle"))}if(l.deliveryProfiles.length){u.append(N("h3","Delivery intent"));for(let T of l.deliveryProfiles){if(u.append(N("p",`${T.target} · ${T.description||T.id}`,"subtle")),T.performanceIntent)u.append(N("p",T.performanceIntent,"subtle"));for(let v of T.constraints)u.append(N("p",v,"subtle"))}u.append(N("p","Declared targets are project intent. They do not establish consumer or performance qualification.","subtle"))}if(l.references.length){u.append(N("h3","Reference records"));for(let T of l.references){let v=N("p",`${T.title}: ${T.uri}`,"subtle");if(T.description)v.append(N("small",` · ${T.description}`));u.append(v)}}u.append(N("h3","Project downloads"));let M=N("div",void 0,"downloads");for(let T of["editable","runtime"]){let v=N("a",T==="editable"?"Download editable project bundle":"Download runtime project bundle"),S=new URLSearchParams({profile:T,revision:l.revisionId});v.href=`/api/projects/${encodeURIComponent(l.projectId)}/bundle?${S}`,v.download=`${l.projectId}-${T}.zip`,M.append(v)}M.append(N("p","Both downloads bind this exact project revision and its linked saved inventory. Editable includes authored source and material resources for rebuilding. Runtime is delivery-only and cannot restore editable source. Unlinked inventory entries remain plans, not bundled assets.")),u.append(M),u.append(Qs("Exact project configuration and review records",l))},s=async()=>{let c=await Xt("/api/projects");if(t.length===c.projects.length&&t.every((l,u)=>l.revisionId===c.projects[u]?.revisionId))return;if(t=c.projects,!t.some((l)=>l.projectId===n))n=t[0]?.projectId??"";r(),e.changed(t)};function o(c){i=c,ae("project-editor-title").textContent=c?"Edit project":"New project",ae("project-name").value=c?.name??"",ae("project-brief").value=c?.brief??"",ae("project-style").value=c?.design.style??"",ae("project-scale").value=c?.design.scale??"",ae("project-config").value=JSON.stringify(pb(c??{name:""}),null,2),ae("project-save-status").textContent="",ae("project-editor").showModal(),ae("project-name").focus()}function a(c,l){if(!l.asset)return;let u=N("dialog"),h=N("form"),d=N("div",void 0,"editor-content"),f=N("h2",`Review ${l.name}`);f.id="review-dialog-title",u.setAttribute("aria-labelledby",f.id),d.append(f,N("p","Record an assessment of this exact saved revision. This is a review annotation; structural QA and release qualification remain separate.","subtle"),N("code",`${l.asset.assetId} / ${l.asset.revisionId}`,"mono"));let m=N("input");m.required=!0,m.value=Tr("kiln.reviewer")??"",m.maxLength=200;let _=N("label","Reviewer","field");_.append(m);let p=N("select");for(let[R,x]of[["comment","Comment"],["changes-requested","Changes requested"],["accepted","Visually accepted"]])p.append(new Option(x,R));let g=N("label","Assessment","field");g.append(p);let M=N("textarea");M.rows=4,M.maxLength=4000;let T=N("label","Notes","field");T.append(M);let v=N("p");v.setAttribute("role","status");let S=N("button","Save review");S.type="submit";let E=N("button","Cancel","secondary");E.type="button",E.onclick=()=>u.close(),d.append(_,g,T,v,S,E),h.append(d),u.append(h),document.body.append(u),u.addEventListener("close",()=>u.remove()),h.onsubmit=async(R)=>{R.preventDefault(),S.disabled=!0,v.textContent="Saving review…";try{await Xt(`/api/projects/${encodeURIComponent(c.projectId)}`,{method:"PATCH",body:{expectedRevision:c.revisionId,patch:{reviews:[...c.reviews,{id:`review_${crypto.randomUUID().replaceAll("-","")}`,inventoryId:l.id,projectRevisionId:c.revisionId,asset:l.asset,reviewer:m.value.trim(),verdict:p.value,notes:M.value}]}}}),ri("kiln.reviewer",m.value.trim()),u.close(),await s()}catch(x){v.textContent=x instanceof Error?x.message:String(x)}finally{S.disabled=!1}},u.showModal(),m.focus()}return ae("new-project").onclick=()=>o(),ae("close-project-editor").onclick=()=>ae("project-editor").close(),ae("project-form").onsubmit=async(c)=>{c.preventDefault();let l=ae("save-project");l.disabled=!0,ae("project-save-status").textContent="Saving revision…";try{let u=mb(ae("project-config").value,{name:ae("project-name").value,brief:ae("project-brief").value,style:ae("project-style").value,scale:ae("project-scale").value});n=(await Xt(i?`/api/projects/${encodeURIComponent(i.projectId)}`:"/api/projects",i?{method:"PATCH",body:{expectedRevision:i.revisionId,patch:u}}:{method:"POST",body:u})).projectId,ri("kiln.project",n),ae("project-editor").close(),hn("Project revision saved."),await s()}catch(u){ae("project-save-status").textContent=u instanceof Error?u.message:String(u)}finally{l.disabled=!1}},{refresh:s}}function _b(e){if(!e.presetId.trim())throw Error("Choose a material preset");if(!e.seed.trim())throw Error("Enter an explicit seed");let t=Number(e.seed),n=Number(e.size);if(!Number.isInteger(t)||t<-2147483648||t>2147483647)throw Error("Seed must be a signed 32-bit integer");if(![64,128,256,512].includes(n))throw Error("Choose a supported map size");if(!e.creator.trim()||!e.spdx.trim()||!e.url.trim())throw Error("Creator and license details are required");let i=new URL(e.url.trim());if(i.protocol!=="https:"&&i.protocol!=="http:")throw Error("License URL must be HTTP(S)");return{presetId:e.presetId,seed:t,size:n,creator:e.creator.trim(),license:{spdx:e.spdx.trim(),url:e.url.trim(),attribution:e.attribution}}}function xb(e){let t=[],n=[],i=[],r=ae("materials-project"),s=N("button","Create from preset");ae("materials-refresh").before(s);let o=N("dialog");o.setAttribute("aria-labelledby","material-preset-heading");let a=N("form"),c=N("div",void 0,"detail-top"),l=N("h2","Create a material resource");l.id="material-preset-heading";let u=N("button","Cancel","secondary");u.type="button",u.onclick=()=>o.close(),c.append(l,u);let h=N("div",void 0,"editor-content");h.append(N("p","Offline starting recipes with editable layers and height-derived normals. Choose an explicit seed and provenance for the resource. Map images are not shaded material previews.","subtle"));function d(C,D){let ee=N("label",C,"field");return ee.append(D),h.append(ee),D}let f=d("Preset",N("select")),m=N("p",void 0,"subtle");h.append(m);let _=d("Seed",N("input"));_.type="number",_.step="1",_.required=!0,_.min="-2147483648",_.max="2147483647",_.value="0";let p=d("Map size",N("select"));for(let C of[64,128,256,512])p.append(new Option(`${C} × ${C}`,String(C)));p.value="256";let g=d("Creator",N("input"));g.required=!0,g.maxLength=1000;let M=d("License identifier",N("input"));M.required=!0,M.placeholder="For example, CC0-1.0";let T=d("License URL",N("input"));T.type="url",T.required=!0;let v=d("Attribution text",N("textarea"));v.rows=2;let S=N("p");S.setAttribute("role","status");let E=N("button","Create resource");E.type="submit",h.append(S,E),a.append(c,h),o.append(a),document.body.append(o);let R=()=>{let C=i.find((D)=>D.id===f.value);m.textContent=C?`${C.description} Repeat scale: ${C.physicalSizeMeters.width} × ${C.physicalSizeMeters.height} m.`:""};f.onchange=R,s.onclick=async()=>{s.disabled=!0;try{i=(await Xt("/api/material-presets")).presets,f.replaceChildren(...i.map((C)=>new Option(C.name,C.id))),R(),S.textContent="",E.disabled=!i.length,o.showModal()}catch(C){hn(C)}finally{s.disabled=!1}},a.onsubmit=async(C)=>{C.preventDefault(),E.disabled=!0,S.textContent="Creating immutable material resource…";try{let D=_b({presetId:f.value,seed:_.value,size:p.value,creator:g.value,spdx:M.value,url:T.value,attribution:v.value}),ee=await Xt("/api/materials/preset",{method:"POST",body:D});await G(),o.close(),hn(`${ee.material.name} created at ${ee.material.revisionId}. Ready for standalone assets. You can also lock this revision to an optional project.`)}catch(D){S.textContent=D instanceof Error?D.message:String(D)}finally{E.disabled=!1}};let x=(C)=>`/api/materials/${encodeURIComponent(C.materialId)}/${encodeURIComponent(C.revisionId)}`;function w(){let C=n.find((B)=>B.projectId===r.value),D=ae("material-dependencies");if(D.replaceChildren(),C)if(D.append(N("h2",`${C.name}: locked resources`)),!C.materialDependencies.length)D.append(N("p","No materials are locked to this project yet. Select a resource revision below or configure dependencies with your agent.","subtle"));else{let B=N("table"),P=N("thead"),J=N("tr"),H=N("tbody");for(let Q of["Resource / role","Exact revision","Local availability"])J.append(N("th",Q));P.append(J),B.append(P);for(let Q of C.materialDependencies){let ge=t.find((fe)=>fe.materialId===Q.resourceId&&fe.revisionId===Q.revisionId),he=N("tr"),de=N("td",Q.resourceId);de.append(N("small",Q.role??C.design.materialRoles.filter((fe)=>fe.resourceId===Q.resourceId).map((fe)=>fe.role).join(", "))),he.append(de,N("td",Q.revisionId,"mono"),N("td",ge&&ge.revisionId===Q.sha256?"Exact local record available":ge?"Dependency hash differs":"Not in local catalog")),H.append(he)}B.append(H);let q=N("div",void 0,"table-wrap");q.append(B),D.append(q)}let ee=ae("material-list");ee.replaceChildren();let L=ae("material-search").value.trim().toLowerCase(),W=t.filter((B)=>`${B.name} ${B.materialId} ${B.tags.join(" ")} ${B.sources.map((P)=>P.provider).join(" ")}`.toLowerCase().includes(L));if(ae("material-count").textContent=`${W.length} material revision${W.length===1?"":"s"}`,!W.length){ee.append(Js(L?"No matching materials":"Your material catalog starts here",L?"Try another material name, tag or provider.":"Materials added through Kiln appear here with their map roles, source records and exact revisions."));return}for(let B of W){let P=N("article",void 0,"material-card"),J=B.maps.find((de)=>de.slot==="baseColor")??B.maps[0];if(J){let de=N("img");de.src=`${x(B)}/${encodeURIComponent(J.file)}`,de.alt=`${B.name}: ${J.slot} map, not a shaded material preview`,de.loading="lazy",de.className="material-map",P.append(de,N("p",`${J.slot} map · unshaded`,"subtle"))}P.append(N("h3",B.name),N("p",B.tags.join(" · "),"subtle"));let H=N("dl"),q=(de,fe)=>H.append(N("dt",de),N("dd",fe));q("Revision",B.revisionId),q("Physical scale",B.physicalSizeMeters?`${B.physicalSizeMeters.width} × ${B.physicalSizeMeters.height} m`:"Not specified"),q("Tiling",B.tileable?"Declared tileable":"Not declared tileable"),q("Maps",B.maps.map((de)=>`${de.slot} ${de.width}×${de.height} (${de.colorSpace})`).join(" · ")),q("Surface factors",`Roughness ×${B.parameters.roughness} · Metalness ×${B.parameters.metalness}${B.maps.some((de)=>de.slot==="metallicRoughness")?" · multiplied by packed map channels":""}`),P.append(H);for(let de of B.sources){let fe=N("p",`${de.provider} · ${de.creator} · ${de.kind}`,"subtle"),I=N("a",de.license.spdx);if(I.href=de.license.url,I.target="_blank",I.rel="noreferrer",fe.append(document.createTextNode(" · "),I),de.assetUrl){let V=N("a","Source");V.href=de.assetUrl,V.target="_blank",V.rel="noreferrer",fe.append(document.createTextNode(" · "),V)}if(P.append(fe),de.license.attribution)P.append(N("p",de.license.attribution,"subtle"))}let Q=N("div",void 0,"material-map-links");for(let de of B.maps){let fe=N("a",de.slot);fe.href=`${x(B)}/${encodeURIComponent(de.file)}`,fe.target="_blank",fe.rel="noopener",Q.append(fe)}P.append(Q);let ge=C?.materialDependencies.find((de)=>de.resourceId===B.materialId),he=N("button",ge?.revisionId===B.revisionId?"Locked to project":ge?"Use this revision":"Add to project","secondary");if(he.disabled=!C||ge?.revisionId===B.revisionId,!C)he.title="Select a project to add a material dependency";he.onclick=async()=>{if(!C)return;he.disabled=!0;try{let de=C.materialDependencies.filter((fe)=>fe.resourceId!==B.materialId);de.push({resourceId:B.materialId,revisionId:B.revisionId,sha256:B.revisionId,...ge?.role?{role:ge.role}:{}}),await Xt(`/api/projects/${encodeURIComponent(C.projectId)}`,{method:"PATCH",body:{expectedRevision:C.revisionId,patch:{materialDependencies:de}}}),hn(`${B.name} is locked to ${C.name} at this exact revision.`),await e()}catch(de){hn(de),he.disabled=!1}},P.append(he,Qs("Map recipes, transformations and provenance",B)),ee.append(P)}}let G=async()=>{t=(await Xt("/api/materials")).materials,w()};return ae("material-search").oninput=w,r.onchange=w,ae("materials-refresh").onclick=()=>void G().catch(hn),{refresh:G,projects(C){n=C;let D=r.value;r.replaceChildren(new Option("All materials",""));for(let ee of n)r.append(new Option(ee.name,ee.projectId));if(n.some((ee)=>ee.projectId===D))r.value=D;w()}}}function lf(e,t,n){return n?`${n.triangles.toLocaleString()} triangles displayed · ${t}`:`${e.triangles.toLocaleString()} triangles · ${e.meshes} meshes · ${t}`}var vb=(e,t)=>e.startedAt.localeCompare(t.startedAt)||e.operationId.localeCompare(t.operationId);function xa(e,t){let n=new Map(e.operations.map((c)=>[c.operationId,c])),i=t.map((c)=>{let l=n.get(c.operationId);return l&&l.revision>c.revision?l:c}).sort(vb),r=(c)=>i.find((l)=>l.operationId===c?.operationId)??c,s=e.following?i.at(-1):r(e.selected),o=(c)=>!!c&&!!s&&c.projectId===s.projectId&&c.workId===s.workId&&vb(c,s)<=0&&(c.sessionId===s.sessionId||e.following&&e.crossRunContinuity===!0&&!!s.workId),a=s?.artifact?s:s?i.filter((c)=>c.artifact&&o(c)).at(-1)??(o(e.displayed)?e.displayed:void 0):void 0;return{...e,operations:i,selected:s,displayed:a,pinned:r(e.pinned)}}function uf(e,t){return xa({...e,following:!1,selected:e.operations.find((n)=>n.operationId===t)??e.selected},e.operations)}function Ar(e,t){return e?.artifact&&t?.artifact&&e.operationId===t.operationId&&e.revision===t.revision&&e.artifact.sha256===t.artifact.sha256?t:void 0}function yb(e,t,n,i){if(e.status!=="complete"||!e.artifact)throw Error("Save requires a completed operation with an artifact.");if(!Ar(e,Ar(i,n)))throw Error("The visible artifact changed or has not loaded. Close this dialog and review it before saving.");let r=t.trim();if(!r||r.length>200)throw Error("Choose an asset name of 1–200 characters.");return{path:`/api/live/${encodeURIComponent(e.operationId)}/save`,body:{expectedRevision:e.revision,name:r,collection:"project"}}}function bl(e,t,n,i){let r;e.onclick=async()=>{let s=n();if(!s){t.replaceChildren(N("p","Load an artifact before measuring.","subtle"));return}e.disabled=!0,t.replaceChildren(N("p","Measuring frame pacing for 3 seconds. Keep this viewport visible and the camera steady.","subtle"));try{let o=await qy(()=>s.measure(3000),i),a=N("div",void 0,"evidence-card");a.append(N("h3","Exploratory browser measurement"),N("p","Other workloads are not controlled. This sample is not an isolated performance baseline or budget acceptance."),N("strong",`p50 ${o.frameMs.p50.toFixed(1)} ms · p95 ${o.frameMs.p95.toFixed(1)} ms`),N("p",`${o.frameMs.samples} frame intervals · ${(o.windowMs/1000).toFixed(2)} s · ${o.drawCalls} draws · ${o.triangles.toLocaleString()} rendered triangles`),N("p",`${o.geometryObjects} geometry objects · ${o.textureObjects} texture objects. These counts are not GPU memory bytes.`),N("p",`GLB parse to first frame submission: ${o.loadToFirstFrameMs?.toFixed(1)??"unavailable"} ms. Download time excluded.`),N("p",`${o.viewport.cssWidth}×${o.viewport.cssHeight} CSS pixels · DPR ${o.viewport.devicePixelRatio.toFixed(2)}. Frame pacing includes browser scheduling and vertical sync, not GPU execution timing.`));let c=Qs("Exact measurement receipt and limitations",o);if(r)URL.revokeObjectURL(r);r=URL.createObjectURL(new Blob([JSON.stringify(o,null,2)],{type:"application/json"}));let l=N("a","Download measurement receipt");l.href=r,l.download="kiln-viewer-performance.json",a.append(c,l),t.replaceChildren(a)}catch(o){t.replaceChildren(N("p",o instanceof Error?o.message:String(o),"subtle"))}finally{e.disabled=!1}}}function hf(e,t,n,i){let r=e.inventory.find((o)=>o.id===t);if(!r&&!n)throw Error("Inventory item not found");let s=e.inventory.map((o)=>{if(o.id!==t)return o;let{asset:a,...c}=o;return n?{...c,asset:n}:c});if(!r&&n)s.push({id:t,name:i,kind:"asset",brief:"",references:[],asset:n});return{inventory:s}}async function va(e,t,n,i){e.replaceChildren(N("h3","Project membership"));let{projects:r}=await Xt("/api/projects");if(!e.isConnected)return;let s=N("div");e.append(s);let o=N("p");o.setAttribute("role","status");let a=()=>va(e,t,n,i);for(let _ of r)for(let p of _.inventory){if(!p.asset||p.asset.collectionId!==t.collectionId||p.asset.assetId!==t.assetId)continue;let g=N("div",void 0,"membership-row");g.append(N("span",`${_.name} / ${p.name} · ${Qt(p.asset.revisionId)}${p.asset.revisionId===t.revisionId?" · this revision":" · another revision"}`));let M=N("button","Remove membership","secondary");M.onclick=async()=>{M.disabled=!0;try{await Xt(`/api/projects/${encodeURIComponent(_.projectId)}`,{method:"PATCH",body:{expectedRevision:_.revisionId,patch:hf(_,p.id,null,n)}}),await i(),await a()}catch(T){o.textContent=`${T instanceof Error?T.message:T} Reopen membership to load the current project.`,M.disabled=!1}},g.append(M),s.append(g)}if(!s.childElementCount)s.append(N("p","This asset is standalone. Project membership is optional.","subtle"));if(!r.length){s.append(N("p","Create a named project in Projects to organize related assets."));return}let c=N("form"),l=N("select"),u=N("select"),h=N("label","Project","field"),d=N("label","Inventory item","field");h.append(l),d.append(u);for(let _ of r)l.append(new Option(_.name,_.projectId));let f=()=>{let _=r.find((g)=>g.projectId===l.value);u.replaceChildren(new Option("Add as a new inventory item",""));for(let g of _.inventory)u.append(new Option(`${g.name}${g.asset?" (replace linked revision)":""}`,g.id));let p=_.inventory.find((g)=>g.asset?.collectionId===t.collectionId&&g.asset.assetId===t.assetId);if(p)u.value=p.id};l.onchange=f,f();let m=N("button","Link this exact revision");m.type="submit",c.append(h,d,N("p","Linking preserves the saved asset and its original build provenance. Replacing a link advances only this project.","subtle"),m,o),c.onsubmit=async(_)=>{_.preventDefault(),m.disabled=!0;let p=r.find((M)=>M.projectId===l.value),g=u.value||`asset_${crypto.randomUUID().replaceAll("-","")}`;try{await Xt(`/api/projects/${encodeURIComponent(p.projectId)}`,{method:"PATCH",body:{expectedRevision:p.revisionId,patch:hf(p,g,t,n)}}),await i(),await a()}catch(M){o.textContent=`${M instanceof Error?M.message:M} Reopen membership to load the current project.`,m.disabled=!1}},s.append(c)}function bb(){let e={following:!0,crossRunContinuity:!0,operations:[]},t=[],n="",i=0,r=!1,s,o=0,a,c,l,u,h,d,f,m=0,_=0,p=!1,g=!1,M=ae("live-project"),T=ae("live-source"),v=(I)=>T.value?`${I}${I.includes("?")?"&":"?"}source=${encodeURIComponent(T.value)}`:I,S=ae("live-run"),E=ae("live-work"),R=()=>`kiln.live.selection.${T.value}.${M.value}.${E.value}.${S.value}`,x=()=>`kiln.live.pin.${T.value}`,w=()=>t.filter((I)=>(!S.value||I.sessionId===S.value)&&(!E.value||(E.value==="ungrouped"?!I.workId:I.workId===E.value))),G=(I,V)=>{let j=ae("live-connection");j.textContent=I?"Connected":"Reconnecting",j.className=`pill ${I?"connected":"warning"}`,ae("connection-status").textContent=V};function C(){let I=E.value,V=[...new Set(t.flatMap((oe)=>oe.workId?[oe.workId]:[]))];if(E.replaceChildren(new Option("All authoring items",""),new Option("Ungrouped history","ungrouped"),...V.map((oe)=>new Option(oe,oe))),I==="ungrouped"||V.includes(I))E.value=I;let j=S.value,re=[...new Set(t.map((oe)=>oe.sessionId))];S.replaceChildren(new Option("All runs",""));for(let oe of re){let ue=t.find(($e)=>$e.sessionId===oe);S.append(new Option(`${ue.transport} · ${Qt(oe)}`,oe))}if(re.includes(j))S.value=j}function D(){let I=ae("live-timeline"),V=I.scrollTop,j=I.contains(document.activeElement)?document.activeElement.dataset.operation:void 0;if(I.replaceChildren(),!e.operations.length){I.append(Js("Nothing observed yet","Actual Kiln operations will appear here. There is no agent running state to infer."));return}for(let re of[...e.operations].reverse()){let oe=N("button",void 0,`timeline-item ${re.status}${e.selected?.operationId===re.operationId?" selected":""}${re.pinned?" pinned":""}`);oe.dataset.operation=re.operationId;let ue=N("span",void 0,"timeline-meta");if(ue.append(N("span",re.transport.toUpperCase()),N("time",new Date(re.startedAt).toLocaleTimeString())),oe.append(ue,N("strong",re.tool.replace(/^kiln_/,"")),N("small",`${re.status} · ${re.artifact?"artifact available":"no artifact"}`),N("small",re.workId?`Item ${re.workId}`:`Ungrouped · run ${Qt(re.sessionId)}`)),oe.setAttribute("aria-label",`${re.tool}, ${re.status}, ${new Date(re.startedAt).toLocaleString()}`),e.selected?.operationId===re.operationId)oe.setAttribute("aria-current","true");if(oe.onclick=()=>{e=uf(e,re.operationId),ri(R(),re.operationId),q()},I.append(oe),j===re.operationId)oe.focus({preventScroll:!0})}I.scrollTop=V}function ee(I){let V=N("div",void 0,"evidence-card");V.append(N("h3","Capture fidelity"));let j=I.viewFidelity,re=j&&typeof j==="object"?j:void 0;if(V.append(N("strong",re?String(re.delivered??"Reported"):"No capture receipt yet")),V.append(N("p",re?.materialFaithful===!0?"Material-faithful capture reported.":re?"Geometry evidence only. Do not use this capture to judge materials.":"The interactive viewport uses local browser lighting; it is not a recorded capture.")),re?.degradeReason)V.append(N("p",String(re.degradeReason)));if(re?.rendererId)V.append(N("p",`Renderer: ${String(re.rendererId)}`,"mono"));if(re?.inputGlbSha256)V.append(N("p",`Capture input: ${String(re.inputGlbSha256)}`,"mono"));if(re)V.append(N("p",re.exactArtifact===!0?"Receipt identifies the exact evaluated artifact.":"Capture does not claim exact artifact equivalence."));return V}function L(){let I=ae("live-evidence"),V=ae("live-downloads");I.replaceChildren(),V.replaceChildren();let j=e.displayed;if(!j?.artifact)return;let re=N("div",void 0,"evidence-card");if(re.append(N("h3","Selected observed artifact"),N("strong",`${(j.artifact.bytes/1024).toFixed(0)} KB GLB`),N("p",j.artifact.sha256,"mono"),N("p",`Source: ${j.programRef??"See authored source download"}`,"mono")),I.append(re,ee(j)),j.captures.length)for(let oe of j.captures){let ue=N("div",void 0,"evidence-card");ue.append(N("h3",oe.name));let $e=j.viewFidelity&&typeof j.viewFidelity==="object"?j.viewFidelity:void 0;ue.append(N("p",$e?.materialFaithful===!0?`Recorded capture · ${String($e.delivered??"material-faithful")}`:`Recorded capture · ${String($e?.delivered??"fidelity unreported")}. Materials are not verified.`,$e?.materialFaithful===!0?"subtle":"warning"));let Ce=N("a"),He=N("img");He.src=oe.url,He.alt=`Recorded ${oe.name} for ${j.tool}`,He.loading="lazy",Ce.href=oe.url,Ce.target="_blank",Ce.rel="noopener",Ce.append(He),ue.append(Ce,N("p",oe.sha256,"mono")),I.append(ue)}else{let oe=N("div",void 0,"evidence-card");oe.append(N("h3","Recorded captures"),N("p",j.status==="evaluated"||j.status==="running"?"Artifact is ready. Capture work may still be in progress.":"No capture image was retained for this operation.")),I.append(oe)}for(let[oe,ue,$e]of[[j.artifact.url,"Observed GLB","asset.glb"],[v(`/api/live/${encodeURIComponent(j.operationId)}/source.kiln.js`),"Authored source","source.kiln.js"]]){let Ce=N("a",ue);Ce.href=oe,Ce.download=$e,V.append(Ce)}V.append(N("p","These are the observed artifact and source. Use the saved Library revision for an editable bundle with resources or a separate runtime export. A live observation is not a saved release."))}function W(){let I=Ar(e.displayed,l);ae("pin-build").disabled=!I,he.disabled=I?.status!=="complete"}function B(){if(h&&l)ae("live-stage-label").textContent=lf(h,Qt(l.operationId),a?.lod())}function P(){if(d&&u)ae("compare-stage-label").textContent=`Pinned · ${lf(d,Qt(u.operationId),c?.lod())}`}async function J(I){if(ae("live-panel").hidden)return;let V=++m;if(!Ar(I,l))a?.cancelMeasurement("The review selection changed. Measure the loaded revision again.");if(!I?.artifact){ae("live-performance").replaceChildren(),a?.dispose(),a=void 0,l=void 0,h=void 0,ae("live-level-field").hidden=!0,ae("live-lod").replaceChildren(),ae("live-lod").hidden=!0,ae("live-stage-status").textContent="No completed artifact available for this run.",ae("live-stage-label").textContent="Current",W();return}if(l?.artifact?.sha256===I.artifact.sha256){l=I,ae("live-stage-status").textContent="",B(),W();return}ae("live-stage-status").textContent=`Loading ${Qt(I.operationId)}…${l?` Previous artifact ${Qt(l.operationId)} remains visible; Save and Pin are unavailable until the selection loads.`:""}`;try{let j=await fetch(I.artifact.url);if(!j.ok)throw Error("This retained artifact is no longer available");let re=new Uint8Array(await j.arrayBuffer());if(V!==m)return;a??=ga(ae("live-stage"));let oe=await a.load(re,{isCurrent:()=>V===m,onCommit:()=>{l=I},preserveView:l?.projectId===I.projectId&&(l?.sessionId===I.sessionId||e.following)});if(!oe||V!==m)return;ae("live-performance").replaceChildren(),l=I,h=oe,W();let ue=ae("live-level");if(ae("live-level-field").hidden=!oe.levels,_a(ue,ae("live-lod"),a,($e)=>{if($e!==void 0)c?.level($e),f?.refresh(),P();B()}),a.wire(p),a.navigation(ae("live-navigation").value),ae("live-stage-status").textContent="",B(),c)c.setView(a.view())}catch(j){if(V!==m)return;ae("live-stage-status").textContent=`${j instanceof Error?j.message:j}.${l?` Previous artifact ${Qt(l.operationId)} remains visible. Save and Pin are unavailable for the unloaded selection.`:""}`,W()}}async function H(I){if(ae("live-panel").hidden)return;let V=++_;if(ae("compare-viewport").hidden=!I?.artifact,ae("review-viewports").classList.toggle("comparing",!!I?.artifact),!I?.artifact){c?.dispose(),c=void 0,u=void 0,d=void 0,f=void 0,ae("compare-lod").replaceChildren(),ae("compare-level-field").hidden=!0;return}if(u?.artifact?.sha256===I.artifact.sha256){u=I,P(),ae("compare-stage-status").textContent="";return}if(!u)ae("compare-stage-label").textContent="Comparison";ae("compare-stage-status").textContent=`Loading pinned ${Qt(I.operationId)}…`;try{let j=await fetch(I.artifact.url);if(!j.ok)throw Error("Pinned artifact unavailable");let re=new Uint8Array(await j.arrayBuffer());if(V!==_)return;c??=ga(ae("compare-stage"));let oe=await c.load(re,{preserveView:!0,isCurrent:()=>V===_,onCommit:()=>{u=I}});if(!oe||V!==_)return;if(u=I,d=oe,a)c.setView(a.view());let ue=Number(ae("live-level").value||0);c.level(Number.isFinite(ue)?ue:0),ae("compare-level-field").hidden=!oe.levels,f=_a(ae("compare-level"),ae("compare-lod"),c,P),P(),c.wire(p),c.navigation(ae("live-navigation").value),ae("compare-stage-status").textContent=""}catch(j){if(V===_)ae("compare-stage-status").textContent=`${j instanceof Error?j.message:String(j)}.${u?` Previous comparison ${Qt(u.operationId)} remains visible.`:""}`}}function q(){D();let I=e.selected,V=e.displayed,j=ae("follow-latest");j.textContent=e.following?"Following latest":"Follow latest",j.setAttribute("aria-pressed",String(e.following));let re=ae("live-current-summary");if(re.replaceChildren(),I){re.append(N("h2",I.tool.replace(/^kiln_/,"")),N("p",`${I.status} · ${I.transport} · Run ${Qt(I.sessionId)} · ${new Date(I.updatedAt).toLocaleString()}`));let $e=N("div",void 0,"tags");if(I.projectId)$e.append(N("span",I.projectId,"tag"));for(let Ce of I.phases)$e.append(N("span",Ce.phase,"tag"));re.append($e)}else re.append(N("h2","No build selected"),N("p","Run Kiln tools from your agent or CLI. Completed evaluations appear here automatically."));let oe=I&&"observationIssues"in I&&Array.isArray(I.observationIssues)?I.observationIssues.map(String):[],ue=[I?.error,...oe,I&&V&&I.operationId!==V.operationId?`Current ${I.status} operation has no retained artifact. Showing the last successful artifact ${Qt(V.operationId)} from run ${Qt(V.sessionId)}.`:"",I&&!e.operations.some(($e)=>$e.operationId===I.operationId)?"This selection is outside the current retained history. Its loaded view remains until you choose another build.":""].filter(Boolean);ae("live-failure").textContent=ue.join(" "),ae("live-failure").hidden=!ue.length,W(),ae("clear-pin").hidden=!e.pinned,ae("live-count").textContent=`${e.operations.length} retained operation${e.operations.length===1?"":"s"}`,ae("live-record").textContent=JSON.stringify({selected:I,displayedArtifactOperation:V?.operationId,pinnedOperation:e.pinned?.operationId},null,2),L(),J(V),H(e.pinned)}async function Q(){if(r)return;r=!0;let I=i;try{let V=new URLSearchParams;if(M.value)V.set("project",M.value);if(n)V.set("cursor",n);let j=await Xt(v(`/api/live?${V}`));if(I!==i)return;if(o=0,G(!0,"Connected · checks every 2 seconds"),n=j.cursor,ae("live-history-note").textContent=`Up to ${j.retention.maxOperations} operations`,ae("live-history-issues").textContent=j.observationIssues?.join(" ")??"",ae("live-history-issues").hidden=!j.observationIssues?.length,!j.unchanged){if(t=j.operations,C(),e=xa(e,w()),!g){g=!0;let re=Tr(R());if(re&&e.operations.some((ue)=>ue.operationId===re))e=uf(e,re);let oe=Tr(x());e.pinned=t.find((ue)=>ue.operationId===oe&&ue.pinned)??[...t].reverse().find((ue)=>ue.pinned&&ue.artifact)}q()}}catch(V){o++,G(!1,`Connection lost. Retrying; retained views remain available. ${V instanceof Error?V.message:V}`)}finally{if(r=!1,s)clearTimeout(s);s=setTimeout(()=>void Q(),document.hidden?1e4:Math.min(30000,2000*2**Math.min(o,4)))}}M.onchange=()=>{i++,n="",t=[],g=!1,S.replaceChildren(new Option("All runs","")),E.value="",e={following:!0,crossRunContinuity:!0,operations:[]},q(),Q()},T.onchange=()=>{M.value="",e.pinned=void 0,M.dispatchEvent(new Event("change"))},Xt("/api/live-sources").then(({sources:I})=>{T.replaceChildren(...I.map((V)=>new Option(V.label,V.id)))}).catch(hn),S.onchange=()=>{e=xa({...e,selected:void 0,displayed:void 0,following:!0,crossRunContinuity:!S.value},w()),q()},E.onchange=()=>S.dispatchEvent(new Event("change")),ae("follow-latest").onclick=()=>{e=xa({...e,following:!e.following},w()),ri(R(),e.following?"":e.selected?.operationId??""),q()},ae("live-refresh").onclick=()=>{n="",Q(),q()},ae("pin-build").onclick=async()=>{let I=Ar(e.displayed,l);if(!I?.artifact)return;let V=ae("pin-build");V.disabled=!0;try{await Xt(v(`/api/live/${encodeURIComponent(I.operationId)}/pin`),{method:"POST",body:{pinned:!0}}),e.pinned={...I,pinned:!0},ri(x(),I.operationId),n="",q(),Q()}catch(j){hn(j),W()}},ae("clear-pin").onclick=async()=>{if(!e.pinned)return;try{await Xt(v(`/api/live/${encodeURIComponent(e.pinned.operationId)}/pin`),{method:"POST",body:{pinned:!1}}),e.pinned=void 0,ri(x(),""),n="",q(),Q()}catch(I){hn(I)}},ae("live-frame").onclick=()=>{if(a?.reset(),a)c?.setView(a.view())},ae("live-wire").onclick=()=>{p=!p,a?.wire(p),c?.wire(p),ae("live-wire").setAttribute("aria-pressed",String(p))};let ge=N("button","Match comparison camera","secondary");ge.onclick=()=>{if(a)c?.setView(a.view())},ae("live-frame").parentElement?.append(ge);let he=N("button","Save exact artifact");he.disabled=!0,ae("live-frame").parentElement?.prepend(he);let de=N("button","Measure 3 s","secondary"),fe=N("div");return fe.id="live-performance",ae("live-evidence").after(fe),ae("live-frame").parentElement?.append(de),bl(de,fe,()=>a,()=>Ar(e.displayed,l)?{operationId:l.operationId,revision:l.revision,glbSha256:l.artifact?.sha256}:void 0),he.onclick=()=>{let I=Ar(e.displayed,l);if(I?.status!=="complete")return;let V=N("dialog"),j=N("form"),re=N("div",void 0,"editor-content"),oe=N("h2","Save reviewed artifact");oe.id="save-review-title",V.setAttribute("aria-labelledby",oe.id),re.append(oe,N("p","Save the exact source, GLB and recorded capture to Library. Then optionally link the saved revision to one or more named projects. Kiln will not evaluate the source again.","subtle"),N("p",`${I.operationId} · revision ${I.revision}`,"mono"),N("p",I.artifact.sha256,"mono"));let ue=N("input");ue.required=!0,ue.maxLength=200,ue.value="";let $e=N("label","Asset name","field");$e.append(ue);let Ce=N("p");Ce.setAttribute("role","status");let He=N("button","Save exact artifact");He.type="submit";let rt=N("button","Cancel","secondary");rt.type="button",rt.onclick=()=>V.close(),re.append($e,Ce,He,rt),j.append(re),V.append(j),document.body.append(V),V.addEventListener("close",()=>V.remove()),j.onsubmit=async(nt)=>{nt.preventDefault(),He.disabled=!0,Ce.textContent="Saving retained bytes…";try{let Rt=yb(I,ue.value,l,e.displayed),it=await Xt(v(Rt.path),{method:"POST",body:Rt.body});Ce.replaceChildren(N("span",`Saved ${it.asset.assetId} / ${it.asset.revisionId}. `));let tn=N("a","Open saved revision"),Ut=new URLSearchParams({collection:it.collection,asset:it.asset.assetId,revision:it.asset.revisionId});tn.href=`/?${Ut}`,Ce.append(tn);let It=N("div");re.append(It),va(It,{collectionId:it.collection,assetId:it.asset.assetId,revisionId:it.asset.revisionId},it.asset.name,async()=>{}).catch((O)=>{It.textContent=`Asset saved; membership unavailable: ${O instanceof Error?O.message:O}. Open the saved asset in Library to link it.`}),ue.disabled=!0,He.textContent="Saved",rt.textContent="Close"}catch(Rt){Ce.textContent=Rt instanceof Error?Rt.message:String(Rt),He.disabled=!1}},V.showModal(),ue.focus()},ae("live-navigation").onchange=(I)=>{let V=I.target.value;a?.navigation(V),c?.navigation(V),ae("live-navigation-help").textContent=V==="explore"?"Focus a viewport, then W A S D to move · Q / E down / up · Shift faster · Drag to look around · No collision simulation.":"Drag to orbit · Scroll to zoom · Right-drag to pan · Your camera stays in place between iterations."},window.addEventListener("online",()=>{n="",Q()}),document.addEventListener("visibilitychange",()=>{if(!document.hidden)Q()}),Q(),{activate:q,projects(I){let V=M.value;M.replaceChildren(new Option("All work",""));for(let j of I)M.append(new Option(j.name,j.projectId));if(I.some((j)=>j.projectId===V))M.value=V}}}var df=["projects","live","library","materials"];function Sb(e,t){let n=new URLSearchParams(e);if(n.has("asset")||n.has("open"))return"library";return t&&df.some((i)=>i===t)?t:"library"}function wb(e,t=()=>{}){let n=df;function i(c){if(!n.includes(c))return;for(let l of n)ae(`${l}-panel`).hidden=l!==c;for(let l of document.querySelectorAll("#workspace-nav button")){let u=l.dataset.section===c;if(l.classList.toggle("active",u),u)l.setAttribute("aria-current","page");else l.removeAttribute("aria-current")}if(ri("kiln.section",c),c==="live")r.activate();if(c==="materials")s.refresh().catch(hn)}for(let c of document.querySelectorAll("#workspace-nav button"))c.onclick=()=>i(c.dataset.section);ae("open-files").onclick=()=>ae("open").click();let r=bb(),s=xb(()=>o.refresh()),o=gb({changed:(c)=>{r.projects(c),s.projects(c),t(c)},openAsset:(c)=>{i("library"),e(c)}});i(Sb(location.search,Tr("kiln.section"))),o.refresh().catch(hn),s.refresh().catch(hn);let a=!1;return window.setInterval(async()=>{if(document.hidden||a||ae("project-editor").open)return;a=!0;try{await o.refresh()}catch{}finally{a=!1}},5000),{library:()=>i("library"),refreshProjects:o.refresh}}var Ci=(e)=>`${e.collection}/${e.manifest.assetId}`;function Mb(e,t,n){if(!n)return e;if(n==="standalone"){let r=new Set(t.flatMap((s)=>s.inventory.flatMap((o)=>o.asset?[`${o.asset.collectionId}/${o.asset.assetId}`]:[])));return e.filter((s)=>!r.has(Ci(s)))}let i=new Set(t.find((r)=>r.projectId===n)?.inventory.flatMap((r)=>r.asset?[`${r.asset.collectionId}/${r.asset.assetId}/${r.asset.revisionId}`]:[])??[]);return e.filter((r)=>i.has(`${Ci(r)}/${r.manifest.revisionId}`))}var Le=(e)=>document.getElementById(e),lt=(e,t,n)=>{let i=document.createElement(e);if(t!==void 0)i.textContent=t;if(n)i.className=n;return i},wa=[],Sa=[],Pr=[],is=[],Sl="",Cr,Ii,en,Rr=0,Eb=0,ya=!1,ba=!1,Ir=new Set,gf=[],Tb=[],ji=(e)=>`${e.collection}/${e.manifest.assetId}/${e.manifest.revisionId}`,pf=(e)=>{Le("status").textContent=e},Pi=(e)=>pf(e instanceof Error?e.message:String(e)),rs=(e,t,n=gf)=>{let i=URL.createObjectURL(new Blob([Uint8Array.from(e)],{type:t}));return n.push(i),i};async function mf(e){let t=await fetch(e),n=await t.json();if(!t.ok)throw Error(n.error??"Request failed");return n}async function ff(e,t){if(e.local){let i=e.local.files[t];if(!i)throw Error("File unavailable");return i}if(e.loose&&t==="asset.glb")return e.loose;let n=await fetch(`/files/${ji(e)}/${t}`);if(!n.ok)throw Error((await n.json()).error??"File unavailable");return new Uint8Array(await n.arrayBuffer())}function kC(e,t){if(e.local){if(t==="editable.zip")return rs(Bu([e.local]),"application/zip");return rs(e.local.files[t],t.endsWith(".js")?"text/javascript":"model/gltf-binary")}if(e.loose)return rs(e.loose,"model/gltf-binary");return`/files/${ji(e)}/${t}?download`}function Ab(e,t){try{localStorage.setItem(e,t)}catch{}}function BC(e){try{return localStorage.getItem(e)}catch{return null}}function GC(){let e=Le("collections");e.replaceChildren();for(let t of[{id:"all",label:"All saved assets"},...wa,...is.length?[{id:"opened-files",label:"Opened files"}]:[]]){let n=lt("button",t.label,Sl===t.id?"active":"");n.onclick=()=>void no(t.id).catch(Pi),e.append(n)}}async function no(e,t=!0){if(t)Cb.library();let n=++Eb;Sl=e,Ir.clear(),GC(),pf("");let i=e==="all"?await(async()=>{let r=await mf("/api/library");if(r.errors.length)pf(r.errors.map((s)=>`${s.collectionId}: ${s.message}`).join(" · "));return r.entries.map((s)=>({collection:s.collectionId,manifest:s.manifest}))})():e==="opened-files"?is:(await mf(`/api/assets?collection=${encodeURIComponent(e)}`)).assets.map((r)=>({collection:e,manifest:r}));if(n!==Eb)return;Pr=i,Ab("kiln.collection",e),Le("collection-title").textContent=e==="all"?"Library":e==="opened-files"?"Opened files":wa.find((r)=>r.id===e)?.label??e,Le("collection-caption").textContent=e==="opened-files"?"Previewed in your browser. Your original files stay untouched.":"Saved assets across registered storage. Projects link exact revisions; standalone assets belong here too.",wl()}function HC(){let e=new Map;for(let t of Mb(Pr,Sa,Le("library-project").value)){let n=Ci(t);e.set(n,[...e.get(n)??[],t])}return[...e.values()].map((t)=>(t.sort((n,i)=>i.manifest.createdAt.localeCompare(n.manifest.createdAt)||i.manifest.revisionId.localeCompare(n.manifest.revisionId)),t.find((n)=>n.manifest.revisionId===BC(`kiln.revision.${n.collection}.${n.manifest.assetId}`))??t[0]))}function wl(){for(let i of Tb.splice(0))URL.revokeObjectURL(i);let e=Le("cards");e.replaceChildren();let t=Le("search").value.toLowerCase(),n=HC().filter((i)=>`${i.manifest.name} ${i.manifest.tags.join(" ")}`.toLowerCase().includes(t));if(Le("count").textContent=`${n.length} asset${n.length===1?"":"s"}`,Le("export-selection").disabled=!Ir.size,!n.length){let i=lt("div",void 0,"empty");if(i.append(lt("b",t?"No matching assets":"Your next idea belongs here."),lt("p",t?"Try another name or tag.":"Save an asset with your agent, or open a GLB or editable bundle.")),!t)i.append(lt("code",'kiln save asset.kiln.js --name "My asset"'));e.append(i);return}for(let i of n){let r=i.manifest,s=lt("article",void 0,"card"),o=lt("button",void 0,"card-open");o.setAttribute("aria-label",`View ${r.name}`),o.onclick=()=>void Ma(i).catch(Pi);let a=lt("div",void 0,"thumb");if(r.files["preview.png"]){let m=lt("img");m.loading="lazy",m.alt=r.name,m.src=i.local?rs(i.local.files["preview.png"],"image/png",Tb):`/files/${ji(i)}/preview.png`,m.onerror=()=>{m.remove(),a.textContent="◇"},a.append(m)}else a.textContent="◇";let c=lt("div",void 0,"card-content");c.append(lt("span",r.name,"card-title"));let l=Pr.filter((m)=>Ci(m)===Ci(i)),u=new Set(l.map((m)=>m.manifest.parentRevision)),h=l.filter((m)=>!u.has(m.manifest.revisionId));c.append(lt("span",`${r.editable?"Editable source":"Source unavailable"} · ${l.length} revision${l.length===1?"":"s"}${h.length>1?` · ${h.length} branches`:""}`,"card-meta"));let d=lt("div",void 0,"tags");for(let m of r.tags)d.append(lt("span",m,"tag"));c.append(d),c.append(lt("small",wa.find((m)=>m.id===i.collection)?.label??i.collection,"card-meta"));let f=Sa.filter((m)=>m.inventory.some((_)=>_.asset&&_.asset.collectionId===i.collection&&_.asset.assetId===r.assetId));if(c.append(lt("small",f.length?f.map((m)=>m.name).join(" · "):"No project membership","card-meta")),o.append(a,c),s.append(o),!i.loose){let m=lt("input");m.type="checkbox",m.className="selection",m.checked=Ir.has(ji(i)),m.setAttribute("aria-label",`Select ${r.name}`),m.onchange=()=>{if(m.checked)Ir.add(ji(i));else Ir.delete(ji(i));Le("export-selection").disabled=!Ir.size},s.append(m)}e.append(s)}}async function Ma(e){let t=++Rr;Cr=e,Ii=void 0,en?.cancelMeasurement("The Library selection changed. Measure the loaded revision again."),Le("library-performance").replaceChildren(),Ab(`kiln.revision.${e.collection}.${e.manifest.assetId}`,e.manifest.revisionId);for(let l of gf.splice(0))URL.revokeObjectURL(l);let n=Le("detail");if(!n.open)n.showModal();Le("asset-name").textContent=e.manifest.name;let i=Le("asset-membership");if(i.replaceChildren(),!e.local&&!e.loose){let l=lt("div");i.append(l),va(l,{collectionId:e.collection,assetId:e.manifest.assetId,revisionId:e.manifest.revisionId},e.manifest.name,Cb.refreshProjects).catch(Pi)}let r=Le("revisions");r.replaceChildren();for(let l of Pr.filter((u)=>Ci(u)===Ci(e))){let u=lt("option",`${new Date(l.manifest.createdAt).toLocaleString()} · ${l.manifest.description||l.manifest.revisionId.slice(0,10)}`);u.value=l.manifest.revisionId,u.selected=l.manifest.revisionId===e.manifest.revisionId,r.append(u)}r.onchange=()=>{let l=Pr.find((u)=>Ci(u)===Ci(e)&&u.manifest.revisionId===r.value);if(l)Ma(l).catch(Pi)},Le("asset-description").textContent=e.manifest.description??e.manifest.brief??(e.manifest.editable?"Source travels with this revision. Download the editable bundle to continue elsewhere.":"This GLB has no saved Kiln source. You can view and use the model.");let s=Le("asset-attribution");s.replaceChildren();for(let l of k0(e.manifest)){let u=lt("div");u.append(lt("span",l.label),lt("strong",l.value)),s.append(u)}s.hidden=!s.childElementCount,Le("provenance").textContent=e.loose?"Standalone GLB. No source or build provenance supplied.":JSON.stringify(e.manifest,null,2);let o=Le("downloads");o.replaceChildren();for(let[l,u]of[["asset.glb","Original GLB"],...e.manifest.editable?[["source.kiln.js","Download source"]]:[],...!e.loose?[["editable.zip",e.manifest.editable?"Download editable bundle":"Download asset bundle"]]:[]]){let h=lt("a",u);h.href=kC(e,l),h.download=`${e.manifest.name.replace(/[^a-z0-9_-]/gi,"-")}${l==="asset.glb"?".glb":l==="source.kiln.js"?".kiln.js":".zip"}`,o.append(h)}if(!e.loose){let l=lt("button","Runtime GLB"),u=lt("span");u.setAttribute("role","status"),l.onclick=async()=>{l.disabled=!0,u.textContent="Preparing runtime download…";try{let h=e.local?await ab(e.local,{profile:"runtime"}):void 0,[d,f]=h?.profile==="runtime"?[h.glb,h.metadata.bytes]:await Promise.all([ff(e,"runtime.glb"),ff(e,"runtime.kiln-metadata.json")]);if(t!==Rr)return;let m=lt("a","Runtime GLB");m.href=rs(d,"model/gltf-binary"),m.download="runtime.glb";let _=lt("a","Runtime metadata");_.href=rs(f,"application/json"),_.download="runtime.kiln-metadata.json",l.replaceWith(m,_),u.textContent="Keep the companion metadata for traceability.",m.click()}catch(h){if(t!==Rr)return;u.textContent=`Runtime export unavailable: ${h instanceof Error?h.message:h}`,l.disabled=!1}},o.append(l,u),o.append(lt("p","Original GLB retains Kiln review data. Runtime GLB moves duplicate animation-review data into a companion JSON file; geometry and textures are unchanged. Keep the editable bundle for source and build records."))}Le("refine").disabled=!e.manifest.editable,Le("asset-stats").replaceChildren(),Le("stage-status").textContent="Loading saved GLB…",ya=!1,ba=!1,Le("wire").setAttribute("aria-pressed","false"),Le("play").textContent="Pause";let a=Le("animation");a.replaceChildren(new Option("Rest pose","")),Le("play").disabled=!0;let c=Le("level");c.replaceChildren(),c.hidden=!0,Le("library-lod").replaceChildren(),Le("library-lod").hidden=!0;try{en??=ga(Le("stage"));let l=await ff(e,"asset.glb");if(t!==Rr)return;let u=await en.load(l,{isCurrent:()=>t===Rr,onCommit:()=>{Ii=e}});if(!u||t!==Rr)return;Ii=e,en.wire(!1),en.navigation(Le("library-navigation").value),en.lighting(Le("lighting").value),_a(c,Le("library-lod"),en);for(let[h,d]of[...u.levels?u.levels.map((f,m)=>[f.toLocaleString(),`LOD${m} triangles`]):[[u.triangles.toLocaleString(),"triangles"]],[u.meshes,u.levels?"LOD0 meshes":"meshes"],[u.materials,u.levels?"LOD0 materials":"materials"],[`${(l.length/1024).toFixed(0)} KB`,"GLB"]]){let f=lt("div");f.append(lt("strong",String(h)),lt("span",String(d))),Le("asset-stats").append(f)}for(let h=0;h<u.clips.length;h++)a.append(new Option(u.clips[h],String(h)));Le("stage-status").textContent=""}catch(l){if(t===Rr)en?.dispose(),en=void 0,Le("stage-status").textContent=`3D preview unavailable: ${l instanceof Error?l.message:l}. Downloads remain available.`}}async function Rb(e){for(let t of e){if(t.bytes.length>Un)throw Error("File exceeds 64 MiB");if(t.name.toLowerCase().endsWith(".zip"))for(let n of z0(t.bytes)){for(let[i,r]of Object.entries(n.files))if(`sha256:${Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",Uint8Array.from(r)))).map((o)=>o.toString(16).padStart(2,"0")).join("")}`!==n.manifest.files[i]?.sha256)throw Error(`Bundle integrity failure: ${i}`);if(!is.some((i)=>i.manifest.revisionId===n.manifest.revisionId&&i.manifest.assetId===n.manifest.assetId))is.push({collection:"opened-files",manifest:n.manifest,local:n})}else{let n=`a_${crypto.randomUUID().replaceAll("-","")}`;is.push({collection:"opened-files",loose:t.bytes,manifest:{version:"kiln.asset.v1",assetId:n,revisionId:`r_${n}`,name:t.name.replace(/\.glb$/i,""),tags:[],createdAt:new Date().toISOString(),editable:!1,files:{}}})}}await no("opened-files")}Le("open").onchange=async(e)=>{try{let t=Array.from(e.target.files??[]);if(t.some((n)=>n.size>Un))throw Error("File exceeds 64 MiB");await Rb(await Promise.all(t.map(async(n)=>({name:n.name,bytes:new Uint8Array(await n.arrayBuffer())}))))}catch(t){Pi(t)}};Le("refresh").onclick=()=>void no(Sl).catch(Pi);Le("search").oninput=wl;Le("library-project").onchange=()=>void no("all").catch(Pi);Le("close-detail").onclick=()=>Le("detail").close();Le("detail").addEventListener("close",()=>{Rr++,Ii=void 0,en?.dispose(),en=void 0;for(let e of gf.splice(0))URL.revokeObjectURL(e);wl()});Le("frame").onclick=()=>en?.reset();Le("wire").onclick=()=>{ya=!ya,en?.wire(ya),Le("wire").setAttribute("aria-pressed",String(ya))};Le("lighting").onchange=(e)=>en?.lighting(e.target.value);Le("library-navigation").onchange=(e)=>{let t=e.target.value;en?.navigation(t),Le("library-navigation-help").textContent=t==="explore"?"Focus the viewport, then W A S D to move · Q / E down / up · Shift faster · Drag to look around · No collision simulation.":"Drag to orbit · Scroll to zoom · Right-drag to pan"};Le("animation").onchange=(e)=>{let t=e.target.value;en?.clip(t===""?-1:Number(t)),Le("play").disabled=t===""};Le("play").onclick=()=>{ba=!ba,en?.pause(ba),Le("play").textContent=ba?"Play":"Pause"};Le("refine").onclick=async()=>{if(!Cr)return;let e=Cr.manifest,t=Cr.local?`Import the downloaded editable bundle using kiln import <bundle.zip>. Restore asset ${e.assetId}, revision ${e.revisionId}, using kiln_assets action=restore. Read its source with kiln_source, refine it with kiln_edit, review the result, and save a child revision with kiln_save. Requested change: `:`Use kiln_assets with action=restore, collection=${Cr.collection}, assetId=${e.assetId}, revisionId=${e.revisionId}. Read the returned programRef with kiln_source, refine it with kiln_edit, review the result, and save with kiln_save using assetId=${e.assetId}, parentRevision=${e.revisionId}, collection=${Cr.collection}. Requested change: `;try{await navigator.clipboard.writeText(t),Le("refine").textContent="Instructions copied"}catch{Le("provenance").textContent=t,Le("provenance").parentElement?.setAttribute("open","")}};Le("export-selection").onclick=()=>{try{let e=lt("a");if(Sl==="opened-files")e.href=rs(Bu(Pr.filter((t)=>Ir.has(ji(t))).map((t)=>t.local)),"application/zip");else{let t=new URLSearchParams;for(let n of Ir)t.append("revision",n);e.href=`/api/bundle?${t}`}e.download="kiln-assets.zip",e.click()}catch(e){Pi(e)}};async function VC(){wa=(await mf("/api/collections")).collections;let e=rb(location.search);if(await no(wa.find((t)=>t.id===e?.collection)?.id??"all",!1),e){let t=Pr.find((n)=>n.collection===e.collection&&n.manifest.assetId===e.assetId&&n.manifest.revisionId===e.revisionId);if(!t)throw Error("The requested saved revision is not available.");await Ma(t)}if(new URLSearchParams(location.search).has("open")){let t=await fetch("/api/standalone");if(!t.ok)throw Error("File unavailable");if(await Rb([{name:t.headers.get("Content-Type")?.includes("zip")?"asset.zip":"asset.glb",bytes:new Uint8Array(await t.arrayBuffer())}]),is.length===1)await Ma(is[0])}}var Cb=wb((e)=>{(async()=>{await no(e.collectionId);let t=Pr.find((n)=>n.manifest.assetId===e.assetId&&n.manifest.revisionId===e.revisionId);if(!t)throw Error("The linked saved revision is not available in this collection.");await Ma(t)})().catch(Pi)},(e)=>{Sa=e;let t=Le("library-project"),n=t.value;t.replaceChildren(new Option("All projects and standalone",""),new Option("Standalone assets","standalone"));for(let i of Sa)t.append(new Option(i.name,i.projectId));if(n==="standalone"||Sa.some((i)=>i.projectId===n))t.value=n;wl()});bl(Le("measure-library"),Le("library-performance"),()=>en,()=>Ii&&Cr&&ji(Ii)===ji(Cr)?{collection:Ii.collection,assetId:Ii.manifest.assetId,revisionId:Ii.manifest.revisionId,glbSha256:Ii.manifest.files["asset.glb"]?.sha256}:void 0);VC().catch(Pi);