From 9a750cf0910a543b4318e6b84c9e7372fc7e283d Mon Sep 17 00:00:00 2001 From: Lucas Garron Date: Tue, 22 Jun 2021 15:46:50 -0700 Subject: [PATCH] FREEZE.indexed --- package.json | 2 +- script/build.js | 2 +- src/cubing/solve/worker/worker-inside-generated-string.cjs | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) delete mode 100644 src/cubing/solve/worker/worker-inside-generated-string.cjs diff --git a/package.json b/package.json index 10d6843ec..88aa1c033 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "generate-js-parsers": "npx peggy --format es src/cubing/kpuzzle/parser/parser-peggy.peggy", "generate-js-svg": "echo \"TODO: Generating JS for SVGs is not implemented yet.\"", "dev": "node ./script/build.js snowpack dev", - "clean": "rm -rf dist .cache .parcel-cache coverage .rpt2_cache /tmp/cubing-js-parcel src/cubing/solve/worker/worker-inside-generated.cjs", + "clean": "rm -rf dist .cache .parcel-cache coverage .rpt2_cache /tmp/cubing-js-parcel src/cubing/solve/worker/worker-inside-generated.js", "test": "npm run test-jest && npm run lint && npm run test-import-restrictions && npm run test-tsc # keep test.yml in sync with this", "test-experiments": "node src/test-experiments/test.js", "test-import-restrictions": "node src/import-restrictions/build.js", diff --git a/script/build.js b/script/build.js index 61f20a03a..8043fccef 100644 --- a/script/build.js +++ b/script/build.js @@ -40,7 +40,7 @@ const stringWrappingPlugin = { execPromise( "rm src/cubing/solve/worker/worker-inside-generated-string.js", ); - console.log("removed worker-inside-generated-string.cjs"); + console.log("removed worker-inside-generated-string.js"); resolve(); } readFile( diff --git a/src/cubing/solve/worker/worker-inside-generated-string.cjs b/src/cubing/solve/worker/worker-inside-generated-string.cjs deleted file mode 100644 index dc7f5b739..000000000 --- a/src/cubing/solve/worker/worker-inside-generated-string.cjs +++ /dev/null @@ -1 +0,0 @@ -export const workerSource = "var f2=Object.create;var ka=Object.defineProperty;var h2=Object.getOwnPropertyDescriptor;var p2=Object.getOwnPropertyNames,d0=Object.getOwnPropertySymbols,d2=Object.getPrototypeOf,m0=Object.prototype.hasOwnProperty,m2=Object.prototype.propertyIsEnumerable;var g0=(n,e,t)=>e in n?ka(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,y0=(n,e)=>{for(var t in e||(e={}))m0.call(e,t)&&g0(n,t,e[t]);if(d0)for(var t of d0(e))m2.call(e,t)&&g0(n,t,e[t]);return n};var v0=n=>ka(n,\"__esModule\",{value:!0});var Ae=(n,e)=>()=>(n&&(e=n(n=0)),e);var Qn=(n,e)=>{v0(n);for(var t in e)ka(n,t,{get:e[t],enumerable:!0})},g2=(n,e,t)=>{if(e&&typeof e==\"object\"||typeof e==\"function\")for(let i of p2(e))!m0.call(n,i)&&i!==\"default\"&&ka(n,i,{get:()=>e[i],enumerable:!(t=h2(e,i))||t.enumerable});return n},x0=n=>g2(v0(ka(n!=null?f2(d2(n)):{},\"default\",n&&n.__esModule&&\"default\"in n?{get:()=>n.default,enumerable:!0}:{value:n,enumerable:!0})),n);var wh=(n,e,t)=>{if(!e.has(n))throw TypeError(\"Cannot \"+t)};var M=(n,e,t)=>(wh(n,e,\"read from private field\"),t?t.call(n):e.get(n)),ce=(n,e,t)=>{if(e.has(n))throw TypeError(\"Cannot add the same private member more than once\");e instanceof WeakSet?e.add(n):e.set(n,t)},ye=(n,e,t,i)=>(wh(n,e,\"write to private field\"),i?i.call(n,t):e.set(n,t),t);var Ke=(n,e,t)=>(wh(n,e,\"access private method\"),t);var se=(n,e,t)=>new Promise((i,r)=>{var o=l=>{try{a(t.next(l))}catch(c){r(c)}},s=l=>{try{a(t.throw(l))}catch(c){r(c)}},a=l=>l.done?i(l.value):Promise.resolve(l.value).then(o,s);a((t=t.apply(n,e)).next())});var b0={};Qn(b0,{default:()=>v2});function y2(n){let e=new WeakMap;return{postMessage:n.postMessage.bind(n),addEventListener:(t,i)=>{let r=o=>{\"handleEvent\"in i?i.handleEvent({data:o}):i({data:o})};n.on(\"message\",r),e.set(i,r)},removeEventListener:(t,i)=>{let r=e.get(i);!r||(n.off(\"message\",r),e.delete(i))},start:n.start&&n.start.bind(n)}}var v2,w0=Ae(()=>{v2=y2});var L2,Tc,Zt,Gi=Ae(()=>{L2=!1,Tc=class{is(e){return this instanceof e}as(e){return this instanceof e?this:null}},Zt=class extends Tc{constructor(){super();L2&&Object.defineProperty(this,\"_debugStr\",{get:function(){return this.toString()}})}}});function C0(n,e=!0){if(!e)return n;switch(n){case 1:return-1;case-1:return 1}}function Ia(n,e){return e===-1?Array.from(n).reverse():n}function R0(n){return Array.from(n).reverse()}function*_h(n,e){return e===-1?yield*C2(n):yield*n}function*C2(n){for(let e of Array.from(n).reverse())yield e}var Pe,ri=Ae(()=>{(function(t){t[t.Forwards=1]=\"Forwards\",t[t.Backwards=-1]=\"Backwards\"})(Pe||(Pe={}))});var Fa,Xo,P0,Th=Ae(()=>{Fa=2147483647,Xo=\"2^31 - 1\",P0=-2147483648});var uo,co,Ah=Ae(()=>{Wi();co=class{constructor(){ce(this,uo,[])}push(e){M(this,uo).push(e)}experimentalNumUnits(){return M(this,uo).length}toAlg(){return new le(M(this,uo))}reset(){ye(this,uo,[])}};uo=new WeakMap});var fo,ho,Ac,Jt,Na=Ae(()=>{Wi();Gi();ri();Ac=class extends Zt{constructor(e,t){super();ce(this,fo,void 0);ce(this,ho,void 0);ye(this,fo,mr(e)),ye(this,ho,mr(t))}get A(){return M(this,fo)}get B(){return M(this,ho)}isIdentical(e){let t=e.as(Ac);return!!((t==null?void 0:t.A.isIdentical(this.A))&&(t==null?void 0:t.B.isIdentical(this.B)))}invert(){return new Ac(M(this,ho),M(this,fo))}*experimentalExpand(e=Pe.Forwards,t){t!=null||(t=Infinity),t===0?yield e===Pe.Forwards?this:this.invert():e===Pe.Forwards?(yield*this.A.experimentalExpand(Pe.Forwards,t-1),yield*this.B.experimentalExpand(Pe.Forwards,t-1),yield*this.A.experimentalExpand(Pe.Backwards,t-1),yield*this.B.experimentalExpand(Pe.Backwards,t-1)):(yield*this.B.experimentalExpand(Pe.Forwards,t-1),yield*this.A.experimentalExpand(Pe.Forwards,t-1),yield*this.B.experimentalExpand(Pe.Backwards,t-1),yield*this.A.experimentalExpand(Pe.Backwards,t-1))}toString(){return`[${M(this,fo)}, ${M(this,ho)}]`}},Jt=Ac;fo=new WeakMap,ho=new WeakMap});var Zo,Jo,Dc,Nt,Ba=Ae(()=>{Wi();Gi();ri();Dc=class extends Zt{constructor(e,t){super();ce(this,Zo,void 0);ce(this,Jo,void 0);ye(this,Zo,mr(e)),ye(this,Jo,mr(t))}get A(){return M(this,Zo)}get B(){return M(this,Jo)}isIdentical(e){let t=e.as(Dc);return!!((t==null?void 0:t.A.isIdentical(this.A))&&(t==null?void 0:t.B.isIdentical(this.B)))}invert(){return new Dc(M(this,Zo),M(this,Jo).invert())}*experimentalExpand(e,t){t!=null||(t=Infinity),t===0?yield e===Pe.Forwards?this:this.invert():(yield*this.A.experimentalExpand(Pe.Forwards,t-1),yield*this.B.experimentalExpand(e,t-1),yield*this.A.experimentalExpand(Pe.Backwards,t-1))}toString(){return`[${this.A}: ${this.B}]`}},Nt=Dc;Zo=new WeakMap,Jo=new WeakMap});var gr,Dh,oi,Oa=Ae(()=>{Gi();ri();Dh=class extends Zt{constructor(e){super();ce(this,gr,void 0);if(e.includes(`\n`)||e.includes(\"\\r\"))throw new Error(\"LineComment cannot contain newline\");ye(this,gr,e)}get text(){return M(this,gr)}isIdentical(e){let t=e;return e.is(Dh)&&M(this,gr)===M(t,gr)}invert(){return this}*experimentalExpand(e=Pe.Forwards,t=Infinity){yield this}toString(){return`//${M(this,gr)}`}},oi=Dh;gr=new WeakMap});var pn,Ua=Ae(()=>{Gi();ri();pn=class extends Zt{toString(){return`\n`}isIdentical(e){return e.is(pn)}invert(){return this}*experimentalExpand(e=Pe.Forwards,t=Infinity){yield this}}});var dn,Ga=Ae(()=>{Gi();ri();dn=class extends Zt{toString(){return\".\"}isIdentical(e){return e.is(dn)}invert(){return this}*experimentalExpand(e=Pe.Forwards,t=Infinity){yield this}}});function Lc(n,e){return n?parseInt(n):e}function Lh(n){return new Cc().parseAlg(n)}function z0(n){return new Cc().parseMove(n)}function I0(n){return new Cc().parseQuantumMove(n)}function mn(n,e,t){let i=n;return i.startCharIndex=e,i.endCharIndex=t,i}function F0(n,e){return\"startCharIndex\"in n&&(e.startCharIndex=n.startCharIndex),\"endCharIndex\"in n&&(e.endCharIndex=n.endCharIndex),e}var k0,R2,P2,k2,z2,I2,_n,Ie,Cc,Ch=Ae(()=>{Wi();Ah();Na();Ba();Rc();Oa();yr();Ua();Ga();k0=/^(\\d+)?('?)/,R2=/^[_\\dA-Za-z]/,P2=/^((([1-9]\\d*)-)?([1-9]\\d*))?([_A-Za-z]+)?/,k2=/^[^\\n]*/,z2=/^(-?\\d+), ?/,I2=/^(-?\\d+)\\)/;Cc=class{constructor(){ce(this,_n,\"\");ce(this,Ie,0)}parseAlg(e){ye(this,_n,e),ye(this,Ie,0);let t=this.parseAlgWithStopping([]);return this.mustBeAtEndOfInput(),t}parseMove(e){ye(this,_n,e),ye(this,Ie,0);let t=this.parseMoveImpl();return this.mustBeAtEndOfInput(),t}parseQuantumMove(e){ye(this,_n,e),ye(this,Ie,0);let t=this.parseQuantumMoveImpl();return this.mustBeAtEndOfInput(),t}mustBeAtEndOfInput(){if(M(this,Ie)!==M(this,_n).length)throw new Error(\"parsing unexpectedly ended early\")}parseAlgWithStopping(e){let t=M(this,Ie),i=M(this,Ie),r=new co,o=!1,s=a=>{if(o)throw new Error(`Unexpected character at index ${a}. Are you missing a space?`)};e:for(;M(this,Ie)0)throw new Error(\"expected stopping\");return mn(r.toAlg(),t,i)}parseQuantumMoveImpl(){let[,,,e,t,i]=this.parseRegex(P2);return new We(i,Lc(t,void 0),Lc(e,void 0))}parseMoveImpl(){let e=M(this,Ie);if(this.tryConsumeNext(\"/\"))return mn(new k(\"_SLASH_\"),e,M(this,Ie));let t=this.parseQuantumMoveImpl(),[i,r]=this.parseAmountAndTrackEmptyAbsAmount(),o=this.parseMoveSuffix();if(o){if(i<0)throw new Error(\"uh-oh\");if((o===\"++\"||o===\"--\")&&i!==1)throw new Error(\"Pochmann ++ or -- moves cannot have an amount other than 1.\");if((o===\"++\"||o===\"--\")&&!r)throw new Error(\"Pochmann ++ or -- moves cannot have an amount written as a number.\");if((o===\"+\"||o===\"-\")&&r)throw new Error(\"Clock dial moves must have an amount written as a natural number followed by + or -.\");o.startsWith(\"+\")&&(t=t.modified({family:`${t.family}_${o===\"+\"?\"PLUS\":\"PLUSPLUS\"}_`})),o.startsWith(\"-\")&&(t=t.modified({family:`${t.family}_${o===\"-\"?\"PLUS\":\"PLUSPLUS\"}_`}),i*=-1)}return mn(new k(t,i),e,M(this,Ie))}parseMoveSuffix(){return this.tryConsumeNext(\"+\")?this.tryConsumeNext(\"+\")?\"++\":\"+\":this.tryConsumeNext(\"-\")?this.tryConsumeNext(\"-\")?\"--\":\"-\":null}parseAmountAndTrackEmptyAbsAmount(){let e=M(this,Ie),[,t,i]=this.parseRegex(k0);if((t==null?void 0:t.startsWith(\"0\"))&&t!==\"0\")throw new Error(`Error at char index ${e}: An amount can only start with 0 if it's exactly the digit 0.`);return[Lc(t,1)*(i===\"'\"?-1:1),!t]}parseAmount(){let e=M(this,Ie),[,t,i]=this.parseRegex(k0);if((t==null?void 0:t.startsWith(\"0\"))&&t!==\"0\")throw new Error(`Error at char index ${e}: An amount number can only start with 0 if it's exactly the digit 0.`);return Lc(t,1)*(i===\"'\"?-1:1)}parseRegex(e){let t=e.exec(this.remaining());if(t===null)throw new Error(\"internal parsing error\");return ye(this,Ie,M(this,Ie)+t[0].length),t}tryRegex(e){let t=e.exec(this.remaining());return t===null?null:(ye(this,Ie,M(this,Ie)+t[0].length),t)}remaining(){return M(this,_n).slice(M(this,Ie))}popNext(){var t;let e=M(this,_n)[M(this,Ie)];return ye(this,Ie,(t=+M(this,Ie))+1),e}tryConsumeNext(e){var t;return M(this,_n)[M(this,Ie)]===e?(ye(this,Ie,(t=+M(this,Ie))+1),!0):!1}mustConsumeNext(e){let t=this.popNext();if(t!==e)throw new Error(`expected \\`${e}\\` while parsing, encountered ${t}`);return t}};_n=new WeakMap,Ie=new WeakMap});function Pc(n){N0.has(n)||(console.warn(n),N0.add(n))}var N0,Rh=Ae(()=>{N0=new Set});var Ko,Ph=Ae(()=>{ri();Th();Ko=class{constructor(e,t=1){if(this.quantum=e,this.amount=t,!Number.isInteger(this.amount)||this.amountFa)throw new Error(`Unit amount absolute value must be a non-negative integer from ${Xo} to ${Xo}.`)}suffix(){let e=\"\",t=Math.abs(this.amount);return t!==1&&(e+=t),this.amount<0&&(e+=\"'\"),e}isIdentical(e){return this.quantum.isIdentical(e.quantum)&&this.amount===e.amount}*experimentalExpand(e,t){let i=Math.abs(this.amount),r=C0(e,this.amount<0);for(let o=0;o{Gi();ri();Th();Ch();Rh();Ph();kc=class extends Tc{constructor(e,t,i){super();ce(this,Hi,void 0);ce(this,$t,void 0);ce(this,en,void 0);if(ye(this,Hi,e),ye(this,$t,t!=null?t:null),ye(this,en,i!=null?i:null),Object.freeze(this),M(this,$t)!==null&&(!Number.isInteger(M(this,$t))||M(this,$t)<1||M(this,$t)>Fa))throw new Error(`QuantumMove inner layer must be a positive integer below ${Xo}.`);if(M(this,en)!==null&&(!Number.isInteger(M(this,en))||M(this,en)<1||M(this,en)>Fa))throw new Error(`QuantumMove outer layer must be a positive integer below ${Xo}.`);if(M(this,en)!==null&&M(this,$t)!==null&&M(this,$t)<=M(this,en))throw new Error(\"QuantumMove outer layer must be smaller than inner layer.\");if(M(this,en)!==null&&M(this,$t)===null)throw new Error(\"QuantumMove with an outer layer must have an inner layer\")}static fromString(e){return I0(e)}modified(e){var t,i,r;return new kc((t=e.family)!=null?t:M(this,Hi),(i=e.innerLayer)!=null?i:M(this,$t),(r=e.outerLayer)!=null?r:M(this,en))}isIdentical(e){let t=e;return e.is(kc)&&M(this,Hi)===M(t,Hi)&&M(this,$t)===M(t,$t)&&M(this,en)===M(t,en)}get family(){return M(this,Hi)}get outerLayer(){return M(this,en)}get innerLayer(){return M(this,$t)}experimentalExpand(){throw new Error(\"experimentalExpand() cannot be called on a `QuantumMove` directly.\")}toString(){let e=M(this,Hi);return M(this,$t)!==null&&(e=String(M(this,$t))+e,M(this,en)!==null&&(e=String(M(this,en))+\"-\"+e)),e}},We=kc;Hi=new WeakMap,$t=new WeakMap,en=new WeakMap;$o=class extends Zt{constructor(...e){super();ce(this,Bt,void 0);var t;if(typeof e[0]==\"string\")if((t=e[1])!=null?t:null){ye(this,Bt,new Ko(We.fromString(e[0]),e[1]));return}else return $o.fromString(e[0]);ye(this,Bt,new Ko(e[0],e[1]))}isIdentical(e){let t=e.as($o);return!!t&&M(this,Bt).isIdentical(M(t,Bt))}invert(){return F0(this,new $o(M(this,Bt).quantum,-this.amount))}*experimentalExpand(e=Pe.Forwards){e===Pe.Forwards?yield this:yield this.modified({amount:-this.amount})}get quantum(){return M(this,Bt).quantum}equals(e){return this.quantum.isIdentical(e.quantum)&&M(this,Bt).isIdentical(M(e,Bt))}modified(e){var t;return new $o(M(this,Bt).quantum.modified(e),(t=e.amount)!=null?t:this.amount)}static fromString(e){return z0(e)}get amount(){return M(this,Bt).amount}get type(){return Pc(\"deprecated: type\"),\"blockMove\"}get family(){var e;return(e=M(this,Bt).quantum.family)!=null?e:void 0}get outerLayer(){var e;return(e=M(this,Bt).quantum.outerLayer)!=null?e:void 0}get innerLayer(){var e;return(e=M(this,Bt).quantum.innerLayer)!=null?e:void 0}toString(){if(this.family===\"_SLASH_\")return\"/\";if(this.family.endsWith(\"_PLUS_\"))return M(this,Bt).quantum.toString().slice(0,-6)+Math.abs(this.amount)+(this.amount<0?\"-\":\"+\");if(this.family.endsWith(\"_PLUSPLUS_\")){let e=Math.abs(this.amount);return M(this,Bt).quantum.toString().slice(0,-10)+(e===1?\"\":e)+(this.amount<0?\"--\":\"++\")}return M(this,Bt).quantum.toString()+M(this,Bt).suffix()}},k=$o;Bt=new WeakMap});var B0,O0,Tn,zc,Kt,Rc=Ae(()=>{Wi();Gi();ri();yr();Ph();B0=class{constructor(){this.quantumU_SQ_=null;this.quantumD_SQ_=null}format(e){let t=this.tuple(e);return t?`(${t.map(i=>i.amount).join(\", \")})`:null}tuple(e){var i,r;this.quantumU_SQ_||(this.quantumU_SQ_=new We(\"U_SQ_\")),this.quantumD_SQ_||(this.quantumD_SQ_=new We(\"D_SQ_\"));let t=e.alg;if(t.experimentalNumUnits()===2){let[o,s]=t.units();if(((i=o.as(k))==null?void 0:i.quantum.isIdentical(this.quantumU_SQ_))&&((r=s.as(k))==null?void 0:r.quantum.isIdentical(this.quantumD_SQ_))){if(e.amount!==1)throw new Error(\"Square-1 tuples cannot have an amount other than 1.\");return[o,s]}}return null}},O0=new B0,zc=class extends Zt{constructor(e,t){super();ce(this,Tn,void 0);let i=mr(e);ye(this,Tn,new Ko(i,t))}isIdentical(e){let t=e;return e.is(zc)&&M(this,Tn).isIdentical(M(t,Tn))}get alg(){return M(this,Tn).quantum}get amount(){return M(this,Tn).amount}get experimentalRepetitionSuffix(){return M(this,Tn).suffix()}invert(){return new zc(M(this,Tn).quantum,-M(this,Tn).amount)}*experimentalExpand(e=Pe.Forwards,t){t!=null||(t=Infinity),t===0?yield e===Pe.Forwards?this:this.invert():yield*M(this,Tn).experimentalExpand(e,t-1)}static fromString(){throw new Error(\"unimplemented\")}toString(){var e;return(e=O0.format(this))!=null?e:`(${M(this,Tn).quantum.toString()})${M(this,Tn).suffix()}`}experimentalAsSquare1Tuple(){return O0.tuple(this)}},Kt=zc;Tn=new WeakMap});var Ic=Ae(()=>{Rc();Oa();Na();Ba();yr();Ua();Ga()});function Fn(n,e){return n instanceof e}function U0(n){return Fn(n,Kt)||Fn(n,oi)||Fn(n,Jt)||Fn(n,Nt)||Fn(n,k)||Fn(n,pn)||Fn(n,dn)}var kh=Ae(()=>{Ic()});function G0(n,e,t){if(e.is(Kt))return n.traverseGrouping(e,t);if(e.is(k))return n.traverseMove(e,t);if(e.is(Jt))return n.traverseCommutator(e,t);if(e.is(Nt))return n.traverseConjugate(e,t);if(e.is(dn))return n.traversePause(e,t);if(e.is(pn))return n.traverseNewline(e,t);if(e.is(oi))return n.traverseLineComment(e,t);throw new Error(\"unknown unit\")}function W0(n){if(n.is(Kt)||n.is(k)||n.is(Jt)||n.is(Nt)||n.is(dn)||n.is(pn)||n.is(oi))return n;throw\"internal error: expected unit\"}var Di,An,H0,V0,j0,zh=Ae(()=>{Rc();Na();yr();Ua();Ga();Ba();Oa();Di=class{traverseUnit(e,t){return G0(this,e,t)}traverseIntoUnit(e,t){return W0(this.traverseUnit(e,t))}},An=class extends Di{traverseUnit(e){return G0(this,e,void 0)}traverseIntoUnit(e){return W0(this.traverseUnit(e))}},H0=class extends Di{*traverseAlg(e,t){var l;if(t.depth===0){yield*e.units();return}let i=[],r=null,o=(l=t==null?void 0:t.collapseMoves)!=null?l:!0;function s(c){if(o&&(r==null?void 0:r.is(k))&&c.is(k)){let f=r,u=c;if(f.quantum.isIdentical(u.quantum)){i.pop();let h=f.amount+u.amount;if(t==null?void 0:t.quantumMoveOrder){let p=t.quantumMoveOrder(f.quantum);h=(h%p+p+1)%p-1}if(h!==0){let p=new k(f.quantum,h);i.push(p),r=p}else r=i.slice(-1)[0]}else i.push(c),r=c}else i.push(c),r=c}let a={depth:t.depth?t.depth-1:null};for(let c of e.units())for(let f of this.traverseUnit(c,a))s(f);for(let c of i)yield c}*traverseGrouping(e,t){if(t.depth===0){yield e;return}let i={depth:t.depth?t.depth-1:null};yield new Kt(this.traverseAlg(e.alg,i))}*traverseMove(e,t){yield e}*traverseCommutator(e,t){if(t.depth===0){yield e;return}let i={depth:t.depth?t.depth-1:null};yield new Jt(this.traverseAlg(e.A,i),this.traverseAlg(e.B,i))}*traverseConjugate(e,t){if(t.depth===0){yield e;return}let i={depth:t.depth?t.depth-1:null};yield new Nt(this.traverseAlg(e.A,i),this.traverseAlg(e.B,i))}*traversePause(e,t){yield e}*traverseNewline(e,t){yield e}*traverseLineComment(e,t){yield e}},V0=new H0,j0=V0.traverseAlg.bind(V0)});function q0(n){if(!n)return[];if(Fn(n,le))return n.units();if(typeof n==\"string\")return Lh(n).units();let e=n;if(typeof e[Symbol.iterator]==\"function\")return e;throw\"Invalid unit\"}function mr(n){return Fn(n,le)?n:new le(n)}function F2(n,e){return n.is(pn)||e.is(pn)?\"\":n.is(oi)&&!e.is(pn)?`\n`:\" \"}var Dn,po,le,Wi=Ae(()=>{Gi();kh();ri();Ch();zh();Oa();yr();Ua();Rh();po=class extends Zt{constructor(e){super();ce(this,Dn,void 0);ye(this,Dn,Array.from(q0(e)));for(let t of M(this,Dn))if(!U0(t))throw new Error(\"An alg can only contain units.\")}isIdentical(e){let t=e;if(!e.is(po))return!1;let i=Array.from(M(this,Dn)),r=Array.from(M(t,Dn));if(i.length!==r.length)return!1;for(let o=0;oe.invert())))}*experimentalExpand(e=Pe.Forwards,t){t!=null||(t=Infinity);for(let i of Ia(M(this,Dn),e))yield*i.experimentalExpand(e,t)}expand(e){var t;return new po(this.experimentalExpand(Pe.Forwards,(t=e==null?void 0:e.depth)!=null?t:Infinity))}*experimentalLeafMoves(){for(let e of this.experimentalExpand())e.is(k)&&(yield e)}concat(e){return new po(Array.from(M(this,Dn)).concat(Array.from(q0(e))))}experimentalIsEmpty(){for(let e of M(this,Dn))return!1;return!0}static fromString(e){return Lh(e)}*units(){for(let e of M(this,Dn))yield e}experimentalNumUnits(){return Array.from(M(this,Dn)).length}get type(){return Pc(\"deprecated: type\"),\"sequence\"}toString(){let e=\"\",t=null;for(let i of M(this,Dn))t&&(e+=F2(t,i)),e+=i.toString(),t=i;return e}simplify(e){return new po(j0(this,e!=null?e:{}))}},le=po;Dn=new WeakMap});var N2,Q0=Ae(()=>{Wi();Ic();Na();Ba();yr();Ga();N2={Sune:new le([new k(\"R\",1),new k(\"U\",1),new k(\"R\",-1),new k(\"U\",1),new k(\"R\",1),new k(\"U\",-2),new k(\"R\",-1)]),AntiSune:new le([new k(\"R\",1),new k(\"U\",2),new k(\"R\",-1),new k(\"U\",-1),new k(\"R\",1),new k(\"U\",-1),new k(\"R\",-1)]),SuneCommutator:new le([new Jt(new le([new k(\"R\",1),new k(\"U\",1),new k(\"R\",-2)]),new le([new Nt(new le([new k(\"R\",1)]),new le([new k(\"U\",1)]))]))]),Niklas:new le([new k(\"R\",1),new k(\"U\",-1),new k(\"L\",-1),new k(\"U\",1),new k(\"R\",-1),new k(\"U\",-1),new k(\"L\",1),new k(\"U\",1)]),EPerm:new le([new k(\"x\",-1),new Jt(new le([new Nt(new le([new k(\"R\",1)]),new le([new k(\"U\",-1)]))]),new le([new k(\"D\",1)])),new Jt(new le([new Nt(new le([new k(\"R\",1)]),new le([new k(\"U\",1)]))]),new le([new k(\"D\",1)])),new k(\"x\",1)]),FURURFCompact:new le([new Nt(new le([new k(\"F\",1)]),new le([new Jt(new le([new k(\"U\",1)]),new le([new k(\"R\",1)]))]))]),APermCompact:new le([new Nt(new le([new k(\"R\",2)]),new le([new Jt(new le([new k(\"F\",2)]),new le([new k(\"R\",-1),new k(\"B\",-1),new k(\"R\",1)]))]))]),FURURFMoves:new le([new k(\"F\",1),new k(\"U\",1),new k(\"R\",1),new k(\"U\",-1),new k(\"R\",-1),new k(\"F\",-1)]),TPerm:new le([new k(\"R\",1),new k(\"U\",1),new k(\"R\",-1),new k(\"U\",-1),new k(\"R\",-1),new k(\"F\",1),new k(\"R\",2),new k(\"U\",-1),new k(\"R\",-1),new k(\"U\",-1),new k(\"R\",1),new k(\"U\",1),new k(\"R\",-1),new k(\"F\",-1)]),HeadlightSwaps:new le([new Nt(new le([new k(\"F\",1)]),new le([new Kt(new le([new Jt(new le([new k(\"R\",1)]),new le([new k(\"U\",1)]))]),3)]))]),TriplePause:new le([new dn,new dn,new dn])}});var k5,Y0=Ae(()=>{yr();k5={73:new k(\"R\"),75:new k(\"R'\"),87:new k(\"B\"),79:new k(\"B'\"),83:new k(\"D\"),76:new k(\"D'\"),68:new k(\"L\"),69:new k(\"L'\"),74:new k(\"U\"),70:new k(\"U'\"),72:new k(\"F\"),71:new k(\"F'\"),78:new k(\"x'\"),67:new k(\"l\"),82:new k(\"l'\"),85:new k(\"r\"),77:new k(\"r'\"),88:new k(\"d\"),188:new k(\"d'\"),84:new k(\"x\"),89:new k(\"x\"),66:new k(\"x'\"),186:new k(\"y\"),59:new k(\"y\"),65:new k(\"y'\"),80:new k(\"z\"),81:new k(\"z'\"),90:new k(\"M'\"),190:new k(\"M'\")}});var X0=Ae(()=>{});function Fc(n,e,t){let i=Array.from(n.units()),r=i[i.length-1];if((t==null?void 0:t.coalesce)&&r&&r.quantum&&r.quantum.isIdentical(e.quantum)){let o=i.slice(0,i.length-1),s=r.amount+e.amount,a=t==null?void 0:t.mod;return a&&(s=(s%a+a)%a,s*2>a&&(s-=a)),s!==0&&o.push(r.modified({amount:s})),new le(o)}else return new le([...i,e])}var Z0=Ae(()=>{Wi()});var nt=Ae(()=>{Wi();Ah();zh();Q0();Y0();Ic();X0();Z0();kh();ri()});function wr(n){if(!Gh[n]){let e=Array(n);for(let t=0;t1;)e*=n,n--;return e}function K2(n,e){if(n>e){let t=n;n=e,e=t}for(;n>0;){let t=e%n;e=n,n=t}return e}function Hh(n,e){return n/K2(n,e)*e}var Gh,Wh,Ln,ja=Ae(()=>{Gh=[],Wh=[];Ln=class{constructor(e){this.n=e.length,this.p=e}toString(){return\"Perm[\"+this.p.join(\" \")+\"]\"}mul(e){let t=Array(this.n);for(let i=0;i{ss=class{notationToInternal(e){return e}notationToExternal(e){return e}}});var Gc,ig=Ae(()=>{nt();Gc=class{constructor(e,t){this.child=e;this.sw=t}notationToInternal(e){return e.family===\"T\"&&e.innerLayer===void 0&&e.outerLayer===void 0?new k(new We(\"FLRv\",e.innerLayer,e.outerLayer),e.amount):this.child.notationToInternal(e)}notationToExternal(e){let t=e.family;return t.length>0&&t[t.length-1]===\"v\"&&(t=t.substring(0,t.length-1)),this.sw.spinmatch(t,\"FLUR\")?new k(new We(\"T\",e.innerLayer,e.outerLayer),e.amount):this.child.notationToExternal(e)}}});var qa,rg=Ae(()=>{nt();qa=class{constructor(e,t){this.internalNames=e;this.externalNames=t}convertString(e,t,i){let r=\"\";(e.endsWith(\"v\")||e.endsWith(\"v\"))&&e<=\"_\"&&(r=e.slice(e.length-1),e=e.slice(0,e.length-1));let o=e.toUpperCase(),s=!1;return e!==o&&(s=!0,e=o),e=i.joinByFaceIndices(t.splitByFaceNames(e)),s&&(e=e.toLowerCase()),e+r}convert(e,t,i){let r=e.family,o=this.convertString(r,t,i);return r===o?e:new k(new We(o,e.innerLayer,e.outerLayer),e.amount)}notationToInternal(e){return this.convert(e,this.externalNames,this.internalNames)}notationToExternal(e){return this.convert(e,this.internalNames,this.externalNames)}}});var Wc,og=Ae(()=>{nt();Wc=class{constructor(e){this.child=e}notationToInternal(e){if(e.innerLayer===void 0&&e.outerLayer===void 0){if(Math.abs(e.amount)===1){if(e.family===\"R++\")return new k(new We(\"L\",3,2),-2*e.amount);if(e.family===\"R--\")return new k(new We(\"L\",3,2),2*e.amount);if(e.family===\"D++\")return new k(new We(\"U\",3,2),-2*e.amount);if(e.family===\"D--\")return new k(new We(\"U\",3,2),2*e.amount);if(e.family===\"R_PLUSPLUS_\")return new k(new We(\"L\",3,2),-2*e.amount);if(e.family===\"D_PLUSPLUS_\")return new k(new We(\"U\",3,2),-2*e.amount)}if(e.family===\"y\")return new k(\"Uv\",e.amount)}return this.child.notationToInternal(e)}notationToExternal(e){return e.family===\"Uv\"?new k(new We(\"y\",e.innerLayer,e.outerLayer),e.amount):e.family===\"Dv\"?new k(\"y\",-e.amount):this.child.notationToExternal(e)}}});var Hc,sg=Ae(()=>{nt();Hc=class{constructor(e){this.slices=e}notationToInternal(e){let t=e.family;return!e.innerLayer&&!e.outerLayer&&(t===\"x\"?e=new k(\"Rv\",e.amount):t===\"y\"?e=new k(\"Uv\",e.amount):t===\"z\"&&(e=new k(\"Fv\",e.amount)),(this.slices&1)==1&&(t===\"E\"?e=new k(new We(\"D\",(this.slices+1)/2),e.amount):t===\"M\"?e=new k(new We(\"L\",(this.slices+1)/2),e.amount):t===\"S\"&&(e=new k(new We(\"F\",(this.slices+1)/2),e.amount))),this.slices>2&&(t===\"e\"?e=new k(new We(\"D\",this.slices-1,2),e.amount):t===\"m\"?e=new k(new We(\"L\",this.slices-1,2),e.amount):t===\"s\"&&(e=new k(new We(\"F\",this.slices-1,2),e.amount)))),e}notationToExternal(e){let t=e.family;if(!e.innerLayer&&!e.outerLayer){if(t===\"Rv\")return new k(\"x\",e.amount);if(t===\"Uv\")return new k(\"y\",e.amount);if(t===\"Fv\")return new k(\"z\",e.amount);if(t===\"Lv\")return new k(\"x\",-e.amount);if(t===\"Dv\")return new k(\"y\",-e.amount);if(t===\"Bv\")return new k(\"z\",-e.amount)}return e}}});var ag,lg,$2,cg,Vc,ug=Ae(()=>{nt();ag={U:\"frl\",L:\"fld\",R:\"fdr\",B:\"dlr\",u:\"FRL\",l:\"FLD\",r:\"FDR\",b:\"DLR\",Uv:\"FRLv\",Lv:\"FLDv\",Rv:\"FDRv\",Bv:\"DLRv\",D:\"D\",F:\"F\",BL:\"L\",BR:\"R\"},lg={U:\"FRL\",L:\"FLD\",R:\"FDR\",B:\"DLR\"},$2=new We(\"y\"),cg=new We(\"Dv\"),Vc=class{constructor(e){this.child=e}notationToInternal(e){if(e.innerLayer===2&&!e.outerLayer){let i=lg[e.family];if(i)return new k(new We(i,e.innerLayer,e.outerLayer),e.amount)}if(e.innerLayer||e.outerLayer)return null;let t=ag[e.family];return t?new k(new We(t,e.innerLayer,e.outerLayer),e.amount):$2.isIdentical(e.quantum)?new k(cg,-e.amount):null}notationToExternal(e){if(e.innerLayer===2&&!e.outerLayer){for(let[t,i]of Object.entries(lg))if(this.child.spinmatch(e.family,i))return new k(new We(t,e.innerLayer,e.outerLayer),e.amount)}for(let[t,i]of Object.entries(ag))if(this.child.spinmatch(e.family,i))return new k(new We(t,e.innerLayer,e.outerLayer),e.amount);return cg.isIdentical(e.quantum)?new k(\"y\",-e.amount):null}}});var fg,jc,hg=Ae(()=>{nt();fg={U:\"UBL\",UL:\"ULF\",F:\"UFR\",UR:\"URB\",B:\"DBL\",D:\"DFR\",L:\"DLF\",R:\"DRB\"},jc=class{constructor(e){this.child=e}notationToInternal(e){if(e.innerLayer||e.outerLayer)return null;let t=fg[e.family];return t?new k(new We(t,e.outerLayer,e.innerLayer),e.amount):null}notationToExternal(e){for(let[t,i]of Object.entries(fg))if(this.child.spinmatch(e.family,i))return new k(new We(t,e.innerLayer,e.outerLayer),e.amount);return null}}});var Vh=Ae(()=>{ng();ig();rg();og();sg();ug();hg()});function jh(n,e){let t=k.fromString(e),i=n.notationToExternal(t);return i===null||t===i?e:i.toString()}function pg(n,e){let t=n.moveops.length;if(t>30)throw new Error(\"Canon info too big for bitmask\");let i=[],r=[];for(let s=0;s>p&1)==0&&(u&r[p]&(1<{Vh();ja();nt();go=class{constructor(e,t){this.size=e;this.mod=t}reassemblySize(){return tg(this.size)*Math.pow(this.mod,this.size)}};Mr=class{constructor(e,t,i,r,o){this.orbitnames=e;this.orbitdefs=t;this.solved=i;this.movenames=r;this.moveops=o}transformToKPuzzle(e){let t={};for(let i=0;i1){f=!1;let p=new Qh(this.orbitdefs[o].size*s);for(let d=0;dnew Ri(o)))}scramble(e){let t=[];for(let r=0;rr+1).join(\" \")),!this.zeroOris()))if(i){let r=new Array(this.ori.length);for(let o=0;oa*r+t));t+=r*this.orbits[i].perm.length}return e}order(){let e=1;for(let t=0;t>=1;if(e===1)return t;let i=t,r=this.e();for(;e>0;)e&1&&(r=r.mul(i)),e>1&&(i=i.mul(i)),e>>=1;return r}inv(){return new Ri(this.internalInv())}e(){return new Ri(this.orbits.map(e=>si.e(e.perm.length,e.orimod)))}},Sr=class extends qh{constructor(e){super(e)}mul(e){return new Sr(this.internalMul(e))}},Qh=class{constructor(e){this.n=e;this.heads=new Array(e);for(let t=0;tr&&(this.heads[i]=r)}}});var Qa,dg=Ae(()=>{Qa=class{constructor(e,t){this.facenames=e;this.prefixFree=!0;this.gripnames=[];t&&(this.gripnames=t);for(let i=0;this.prefixFree&&i0&&ithis.facenames[r].length)&&(r=o);if(r>=0)t.push(r),i+=this.facenames[r].length;else throw new Error(\"Could not split \"+e+\" into face names.\")}return t}joinByFaceIndices(e){let t=\"\",i=[];for(let r=0;r{qc={\"2x2x2\":\"c f 0\",\"3x3x3\":\"c f 0.333333333333333\",\"4x4x4\":\"c f 0.5 f 0\",\"5x5x5\":\"c f 0.6 f 0.2\",\"6x6x6\":\"c f 0.666666666666667 f 0.333333333333333 f 0\",\"7x7x7\":\"c f 0.714285714285714 f 0.428571428571429 f 0.142857142857143\",\"8x8x8\":\"c f 0.75 f 0.5 f 0.25 f 0\",\"9x9x9\":\"c f 0.777777777777778 f 0.555555555555556 f 0.333333333333333 f 0.111111111111111\",\"10x10x10\":\"c f 0.8 f 0.6 f 0.4 f 0.2 f 0\",\"11x11x11\":\"c f 0.818181818181818 f 0.636363636363636 f 0.454545454545455 f 0.272727272727273 f 0.0909090909090909\",\"12x12x12\":\"c f 0.833333333333333 f 0.666666666666667 f 0.5 f 0.333333333333333 f 0.166666666666667 f 0\",\"13x13x13\":\"c f 0.846153846153846 f 0.692307692307692 f 0.538461538461538 f 0.384615384615385 f 0.230769230769231 f 0.0769230769230769\",\"20x20x20\":\"c f 0 f .1 f .2 f .3 f .4 f .5 f .6 f .7 f .8 f .9\",\"30x30x30\":\"c f 0 f .066667 f .133333 f .2 f .266667 f .333333 f .4 f .466667 f .533333 f .6 f .666667 f .733333 f .8 f .866667 f .933333\",\"40x40x40\":\"c f 0 f .05 f .1 f .15 f .2 f .25 f .3 f .35 f .4 f .45 f .5 f .55 f .6 f .65 f .7 f .75 f .8 f .85 f .9 f .95\",skewb:\"c v 0\",\"master skewb\":\"c v 0.275\",\"professor skewb\":\"c v 0 v 0.38\",\"compy cube\":\"c v 0.915641442663986\",helicopter:\"c e 0.707106781186547\",\"curvy copter\":\"c e 0.83\",dino:\"c v 0.577350269189626\",\"little chop\":\"c e 0\",pyramorphix:\"t e 0\",mastermorphix:\"t e 0.346184634065199\",pyraminx:\"t v 0.333333333333333 v 1.66666666666667\",\"master pyraminx\":\"t v 0 v 1 v 2\",\"professor pyraminx\":\"t v -0.2 v 0.6 v 1.4 v 2.2\",\"Jing pyraminx\":\"t f 0\",\"master pyramorphix\":\"t e 0.866025403784437\",megaminx:\"d f 0.7\",gigaminx:\"d f 0.64 f 0.82\",teraminx:\"d f 0.64 f 0.76 f 0.88\",petaminx:\"d f 0.64 f 0.73 f 0.82 f 0.91\",examinx:\"d f 0.64 f 0.712 f 0.784 f 0.856 f 0.928\",zetaminx:\"d f 0.64 f 0.7 f 0.76 f 0.82 f 0.88 f 0.94\",yottaminx:\"d f 0.64 f 0.6914 f 0.7429 f 0.7943 f 0.8457 f 0.8971 f 0.9486\",pentultimate:\"d f 0\",\"master pentultimate\":\"d f 0.1\",\"elite pentultimate\":\"d f 0 f 0.145905\",starminx:\"d v 0.937962370425399\",\"starminx 2\":\"d f 0.23606797749979\",\"pyraminx crystal\":\"d f 0.447213595499989\",chopasaurus:\"d v 0\",\"big chop\":\"d e 0\",\"skewb diamond\":\"o f 0\",FTO:\"o f 0.333333333333333\",\"master FTO\":\"o f 0.5 f 0\",\"Christopher's jewel\":\"o v 0.577350269189626\",octastar:\"o e 0\",\"Trajber's octahedron\":\"o v 0.433012701892219\",\"radio chop\":\"i f 0\",icosamate:\"i v 0\",\"icosahedron 2\":\"i v 0.18759247376021\",\"icosahedron 3\":\"i v 0.18759247376021 e 0\",\"icosahedron static faces\":\"i v 0.84\",\"icosahedron moving faces\":\"i v 0.73\",\"Eitan's star\":\"i f 0.61803398874989\",\"2x2x2 + dino\":\"c f 0 v 0.577350269189626\",\"2x2x2 + little chop\":\"c f 0 e 0\",\"dino + little chop\":\"c v 0.577350269189626 e 0\",\"2x2x2 + dino + little chop\":\"c f 0 v 0.577350269189626 e 0\",\"megaminx + chopasaurus\":\"d f 0.61803398875 v 0\",\"starminx combo\":\"d f 0.23606797749979 v 0.937962370425399\"}});function gg(n,e){let t=[];for(let i=0;i0&&s>i[o].a||i[o].a<0&&s{yo=1e-9;as=class{constructor(e,t,i){this.face=e;this.left=t;this.right=i}split(e){var i,r;let t=e.cutface(this.face);return t!==null&&(this.left===void 0?(this.left=new as(t[0]),this.right=new as(t[1])):(this.left=(i=this.left)==null?void 0:i.split(e),this.right=(r=this.right)==null?void 0:r.split(e))),this}collect(e,t){var i,r,o,s;return this.left===void 0?e.push(this.face):t?((i=this.left)==null||i.collect(e,!1),(r=this.right)==null||r.collect(e,!0)):((o=this.right)==null||o.collect(e,!1),(s=this.left)==null||s.collect(e,!0)),e}},Oe=class{constructor(e,t,i,r){this.a=e;this.b=t;this.c=i;this.d=r}mul(e){return new Oe(this.a*e.a-this.b*e.b-this.c*e.c-this.d*e.d,this.a*e.b+this.b*e.a+this.c*e.d-this.d*e.c,this.a*e.c-this.b*e.d+this.c*e.a+this.d*e.b,this.a*e.d+this.b*e.c-this.c*e.b+this.d*e.a)}toString(){return\"Q[\"+this.a+\",\"+this.b+\",\"+this.c+\",\"+this.d+\"]\"}dist(e){return Math.hypot(this.a-e.a,this.b-e.b,this.c-e.c,this.d-e.d)}len(){return Math.hypot(this.a,this.b,this.c,this.d)}cross(e){return new Oe(0,this.c*e.d-this.d*e.c,this.d*e.b-this.b*e.d,this.b*e.c-this.c*e.b)}dot(e){return this.b*e.b+this.c*e.c+this.d*e.d}normalize(){let e=Math.sqrt(this.dot(this));return new Oe(this.a/e,this.b/e,this.c/e,this.d/e)}makenormal(){return new Oe(0,this.b,this.c,this.d).normalize()}normalizeplane(){let e=Math.hypot(this.b,this.c,this.d);return new Oe(this.a/e,this.b/e,this.c/e,this.d/e)}smul(e){return new Oe(this.a*e,this.b*e,this.c*e,this.d*e)}sum(e){return new Oe(this.a+e.a,this.b+e.b,this.c+e.c,this.d+e.d)}sub(e){return new Oe(this.a-e.a,this.b-e.b,this.c-e.c,this.d-e.d)}angle(){return 2*Math.acos(this.a)}invrot(){return new Oe(this.a,-this.b,-this.c,-this.d)}det3x3(e,t,i,r,o,s,a,l,c){return e*(o*c-s*l)+t*(s*a-r*c)+i*(r*l-o*a)}rotateplane(e){let t=e.mul(new Oe(0,this.b,this.c,this.d)).mul(e.invrot());return t.a=this.a,t}orthogonal(){let e=Math.abs(this.b),t=Math.abs(this.c),i=Math.abs(this.d);return et.rotatepoint(this))}rotatecubie(e){return e.map(t=>this.rotateface(t))}intersect3(e,t){let i=this.det3x3(this.b,this.c,this.d,e.b,e.c,e.d,t.b,t.c,t.d);return Math.abs(i)yo?1:e<-yo?-1:0}cutface(e){let t=this.a,i=0,r=null;for(let o=0;othis.side(s.dot(this)-t));for(let s=-1;s<=1;s+=2){let a=[];for(let l=0;l{Qc();Yc=1e-9});function _g(n){Jh=n}function iM(){return{4:[[\"F\",\"D\",\"L\",\"R\"]],6:[[\"F\",\"D\",\"L\",\"U\",\"R\"],[\"R\",\"F\",\"\",\"B\",\"\"]],8:[[\"F\",\"D\",\"L\",\"R\"],[\"D\",\"F\",\"BR\",\"\"],[\"BR\",\"D\",\"\",\"BB\"],[\"BB\",\"BR\",\"U\",\"BL\"]],12:[[\"U\",\"F\",\"\",\"\",\"\",\"\"],[\"F\",\"U\",\"R\",\"C\",\"A\",\"L\"],[\"R\",\"F\",\"\",\"\",\"E\",\"\"],[\"E\",\"R\",\"\",\"BF\",\"\",\"\"],[\"BF\",\"E\",\"BR\",\"BL\",\"I\",\"D\"]],20:[[\"R\",\"C\",\"F\",\"E\"],[\"F\",\"R\",\"L\",\"U\"],[\"L\",\"F\",\"A\",\"\"],[\"E\",\"R\",\"G\",\"I\"],[\"I\",\"E\",\"S\",\"H\"],[\"S\",\"I\",\"J\",\"B\"],[\"B\",\"S\",\"K\",\"D\"],[\"K\",\"B\",\"M\",\"O\"],[\"O\",\"K\",\"P\",\"N\"],[\"P\",\"O\",\"Q\",\"\"]]}}function rM(){return{4:{F:\"#00ff00\",D:\"#ffff00\",L:\"#ff0000\",R:\"#0000ff\"},6:{U:\"#ffffff\",F:\"#00ff00\",R:\"#ff0000\",D:\"#ffff00\",B:\"#0000ff\",L:\"#ff8000\"},8:{U:\"#ffffff\",F:\"#ff0000\",R:\"#00bb00\",D:\"#ffff00\",BB:\"#1122ff\",L:\"#9524c5\",BL:\"#ff8800\",BR:\"#aaaaaa\"},12:{U:\"#ffffff\",F:\"#006633\",R:\"#ff0000\",C:\"#ffffd0\",A:\"#3399ff\",L:\"#660099\",E:\"#ff66cc\",BF:\"#99ff00\",BR:\"#0000ff\",BL:\"#ffff00\",I:\"#ff6633\",D:\"#999999\"},20:{R:\"#db69f0\",C:\"#178fde\",F:\"#23238b\",E:\"#9cc726\",L:\"#2c212d\",U:\"#177fa7\",A:\"#e0de7f\",G:\"#2b57c0\",I:\"#41126b\",S:\"#4b8c28\",H:\"#7c098d\",J:\"#7fe7b4\",B:\"#85fb74\",K:\"#3f4bc3\",D:\"#0ff555\",M:\"#f1c2c8\",O:\"#58d340\",P:\"#c514f2\",N:\"#14494e\",Q:\"#8b1be1\"}}}function oM(){return{4:[\"F\",\"D\",\"L\",\"R\"],6:[\"U\",\"D\",\"F\",\"B\",\"L\",\"R\"],8:[\"F\",\"BB\",\"D\",\"U\",\"BR\",\"L\",\"R\",\"BL\"],12:[\"L\",\"E\",\"F\",\"BF\",\"R\",\"I\",\"U\",\"D\",\"BR\",\"A\",\"BL\",\"C\"],20:[\"L\",\"S\",\"E\",\"O\",\"F\",\"B\",\"I\",\"P\",\"R\",\"K\",\"U\",\"D\",\"J\",\"A\",\"Q\",\"H\",\"G\",\"N\",\"M\",\"C\"]}}function sM(){return{4:[\"FLR\",[0,1,0],\"F\",[0,0,1]],6:[\"U\",[0,1,0],\"F\",[0,0,1]],8:[\"U\",[0,1,0],\"F\",[0,0,1]],12:[\"U\",[0,1,0],\"F\",[0,0,1]],20:[\"GUQMJ\",[0,1,0],\"F\",[0,0,1]]}}function ls(n,e){for(let t=0;t0&&(o=String(e[1]+1));else if(e[0]===0)r=r.toLowerCase(),e[1]>1&&(o=String(e[1]+1));else throw\"We only support slice and outer block moves right now. \"+e;return[o+r,i]}function lM(n,e){let t=[],i=0;for(;i0&&ir.length&&(r=e[o][1]);if(r!==\"\")t.push(r),i+=r.length;else throw new Error(\"Could not split \"+n+\" into face names.\")}return t}function Xc(n,e){return[n.b/e,-n.c/e,n.d/e]}function Ya(n,e){let t=[],i=n.length;for(let r=0;r=0&&(r=!1)}if(r)return t;e/=2}return n}var eM,Jh,Ut,tM,nM,Zc,Lg,Cg=Ae(()=>{nt();dg();Vh();ja();Yh();mg();Eg();Qc();eM=.77,Jh=!0;Ut=1e-9,tM=\"PuzzleGeometry 0.1 Copyright 2018 Tomas Rokicki.\",nM=!1;Zc=class{constructor(e,t,i){this.args=\"\";this.cmovesbyslice=[];this.verbose=0;this.allmoves=!1;this.cornersets=!0;this.centersets=!0;this.edgesets=!0;this.omitsets=[];this.graycorners=!1;this.graycenters=!1;this.grayedges=!1;this.killorientation=!1;this.optimize=!1;this.scramble=0;this.fixPiece=\"\";this.orientCenters=!1;this.duplicatedFaces=[];this.duplicatedCubies=[];this.fixedCubie=-1;this.net=[];this.colors=[];this.faceorder=[];this.faceprecedence=[];this.notationMapper=new ss;this.addNotationMapper=\"\";this.setReidOrder=!1;function r(s){return typeof s==\"string\"?JSON.parse(s):s}function o(s){return typeof s==\"string\"?s!==\"false\":!!s}if(i!==void 0){if(i.length%2!=0)throw new Error(\"Odd length in option list?\");for(let s=0;ss.join(\" \")).join(\" \"),i&&(this.args+=\" \"+i.join(\" \")),this.verbose>0&&console.log(this.header(\"# \")),this.create(e,t)}create(e,t){this.moveplanes=[],this.moveplanes2=[],this.faces=[],this.cubies=[];let i=null;switch(e){case\"c\":i=vg();break;case\"o\":i=Mg();break;case\"i\":i=wg();break;case\"t\":i=xg();break;case\"d\":i=bg();break;default:throw new Error(\"Bad shape argument: \"+e)}this.rotations=Sg(i),this.verbose&&console.log(\"# Rotations: \"+this.rotations.length);let r=i[0];this.baseplanerot=Xh(r,this.rotations);let o=this.baseplanerot.map(P=>r.rotateplane(P));this.baseplanes=o,this.basefacecount=o.length;let s=iM()[o.length];this.net=s,this.colors=rM()[o.length],this.faceorder=oM()[o.length],this.verbose&&console.log(\"# Base planes: \"+o.length);let a=Zh(o),l=new Oe(0,0,0,0);this.verbose&&console.log(\"# Face vertices: \"+a.length);let c=o[0].makenormal(),f=a[0].sum(a[1]).makenormal(),u=a[0].makenormal(),h=new Oe(1,c.b,c.c,c.d);this.verbose&&console.log(\"# Boundary is \"+h);let d=Xh(h,this.rotations).map(P=>h.rotateplane(P)),g=[Zh(d)];this.edgedistance=g[0][0].sum(g[0][1]).smul(.5).dist(l),this.vertexdistance=g[0][0].dist(l);let v=[],y=[],m=!1,S=!1,b=!1;for(let P=0;PP[1]));let D=this.swizzler.prefixFree?\"\":\"_\";for(let P=0;P1&&(console.log(\"# Face precedence list: \"+this.faceorder.join(\" \")),console.log(\"# Face names: \"+w.map(P=>P[1]).join(\" \")),console.log(\"# Edge names: \"+O.map(P=>P[1]).join(\" \")),console.log(\"# Vertex names: \"+A.map(P=>P[1]).join(\" \")));let z=[];for(let P=0;PP[1]);this.swizzler.setGripNames(G),this.verbose&&console.log(\"# Distances: face \"+1+\" edge \"+this.edgedistance+\" vertex \"+this.vertexdistance);for(let P=0;P0){let r=e.dot(this.moveplanesets[i][0]),o=0,s=1;for(;s*2<=this.moveplanesets[i].length;)s*=2;for(;s>0;s>>=1)o+s<=this.moveplanesets[i].length&&r>this.moveplanesets[i][o+s-1].a&&(o+=s);t=t+\" \"+o}return t}findface(e){let t=Vi(e),i=this.keyface2(t),r=this.facelisthash[i];if(r.length===1)return r[0];for(let o=0;o+1D.normalizeplane()),R=t[C];for(let D=0;DUt&&(N[D]=N[D].smul(-1));N.sort((D,z)=>D.a-z.a),e[C]=N}this.moveplanesets=e,this.moveplanenormals=t;let i=e.map(C=>C.length);this.verbose&&console.log(\"# Move plane sets: \"+i);let r=[];for(let C=0;CUt&&(N[D]=N[D].smul(-1));N.sort((D,z)=>D.angle()-z.angle()),r[C][0].dot(t[C])<0&&N.reverse()}let o=r.map(C=>1+C.length);this.movesetorders=o;let s=[],a=\"?\";for(let C=0;C5)throw new Error(\"Bad math; too many faces on this cubie \"+N.length);let R=N.map(ee=>Vi(ee)),D=this.keyface2(R[0]),z=c[D],G=Vi(R);for(let ee=0;N.length>2;ee++){let ie=!1;for(let P=0;P1e3)throw new Error(\"Bad epsilon math; too close to border\")}let Q=0,te=this.findface(N[Q]);for(let ee=1;eeh[C].map(N=>this.getfaceindex(this.findface(N))).join(\" \"),U=[];for(let C=0;C1||R[P]===void 0)&&(R[P]=D++),O[ie]=R[P],w[ie]=b,U[b].push(ie),x[ie]=A[b]++;let X=Vi(h[ie][0]);if(te.length2||this.fixPiece===\"e\"&&h[C].length===2||this.fixPiece===\"f\"&&h[C].length===1){this.fixedCubie=C;break}if(this.fixedCubie<0)throw new Error(\"Could not find a cubie of type \"+this.fixPiece+\" to fix.\")}this.verbose&&console.log(\"# Cubie orbit sizes \"+A)}unswizzle(e){let t=this.notationMapper.notationToInternal(e);return t===null?\"\":this.swizzler.unswizzle(t.family)}stringToBlockMove(e){let t=RegExp(\"^(([0-9]+)-)?([0-9]+)?([^0-9]+)([0-9]+'?)?$\"),i=e.match(t);if(i===null)throw new Error(\"Bad move passed \"+e);let r=i[4],o,s;if(i[2]!==void 0){if(i[3]===void 0)throw new Error(\"Missing second number in range\");o=parseInt(i[2],10)}i[3]!==void 0&&(s=parseInt(i[3],10));let a=\"1\",l=1;return i[5]!==void 0&&(a=i[5],a[0]===\"'\"&&(a=\"-\"+a.substring(1)),l=parseInt(a,10)),new k(new We(r,s,o),l)}parseMove(e){let t=this.notationMapper.notationToInternal(e);if(t===null)throw new Error(\"Bad move \"+e.family);e=t;let i=e.family,r=!1;if(i.endsWith(\"v\")&&i[0]<=\"Z\"){if(e.innerLayer!==void 0||e.outerLayer!==void 0)throw new Error(\"Cannot use a prefix with full cube rotations\");i=i.slice(0,-1),r=!0}i.endsWith(\"w\")&&i[0]<=\"Z\"&&(i=i.slice(0,-1).toLowerCase());let o,s=-1,a=this.swizzler.unswizzle(i),l=!1;for(let h=0;hthis.moveplanesets[s].length||f<0||f>this.moveplanesets[s].length)throw new Error(\"Bad slice spec \"+c+\" \"+f+\" vs \"+this.moveplanesets[s].length);if(!nM&&c===0&&f===this.moveplanesets[s].length&&!r)throw new Error(\"! full puzzle rotations must be specified with v suffix.\");return[void 0,s,c,f,l,e.amount]}parsemove(e){let t=this.parseMove(this.stringToBlockMove(e));return t[0]=e,t}genperms(){if(this.cmovesbyslice.length>0)return;let e=[];if(this.orientCenters){for(let t=0;t0){let u=this.facecentermass[c].dot(i[0]);for(let h=s;h>0;h>>=1)f+h<=i.length&&u>i[f+h-1].a&&(f+=h);f=i.length-f}for(r.push(f);o.length<=f;)o.push(0);o[f]++}let a=new Array(o.length);for(let c=0;c2&&this.orientCenters&&(this.cubies[f[0]].length===1||this.cubies[f[0]][0]===this.cubies[f[0]][1])&&this.facecentermass[c].dist(Vi(this.basefaces[this.getfaceindex(c)]))2&&!l[f[0]]){if(f.length!==2*this.movesetorders[t])throw new Error(\"Bad length in perm gen\");for(let g=0;ge.map(t=>[t.b,t.c,t.d]))}getboundarygeometry(){return{baseplanes:this.baseplanes,facenames:this.facenames,faceplanes:this.faceplanes,vertexnames:this.vertexnames,edgenames:this.edgenames,geonormals:this.geonormals}}getmovesets(e){let t=this.moveplanesets[e].length,i=[];if(this.parsedmovelist!==void 0)for(let r=0;rt?i.push([r,t]):i.push([0,r]):i.push([r,r]),i.push(1));if(this.fixedCubie>=0){let r=+this.cubiekeys[this.fixedCubie].trim().split(\" \")[e],o=[];for(let s=0;s=a[0]&&r<=a[1])if(a[0]===0)a=[a[1]+1,t];else if(t===a[1])a=[0,a[0]-1];else throw Error(\"fixed cubie option would disconnect move\");let l=!1;for(let c=0;c2&&(this.graycorners||!this.cornersets)}skipbyori(e){let t=this.cubies[e].length;return this.duplicatedCubies[e]&&(t=1),t===1&&!this.centersets||t===2&&!this.edgesets||t>2&&!this.cornersets}skipcubie(e){return this.skipbyori(e)}skipset(e){if(e.length===0)return!0;let t=e[0];return this.skipbyori(this.facetocubies[t][0])}header(e){return e+tM+`\n`+e+this.args+`\n`}writegap(){let e=this.getOrbitsDef(!1),t=[],i=[];for(let o=0;o\"[\"+o.map(s=>s+1).join(\",\")+\"]\").join(\",\")+\"];\"),t.push(\"\"),this.header(\"# \")+t.join(`\n`)}writeksolve(e=\"PuzzleGeometryPuzzle\"){let t=this.getOrbitsDef(!1);return this.header(\"# \")+t.toKsolve(e,this.notationMapper).join(`\n`)}writekpuzzle(e=!0){let t=this.getOrbitsDef(e),i=t.toKpuzzle();return i.moveNotation=new Lg(this,t),i}getMoveFromBits(e,t,i,r,o,s){let a=[],l=[],c=[];for(let h=0;h1&&!this.killorientation&&(c[v]=c[v].slice()));for(let S=0;S1&&!this.killorientation&&(c[v][g[S]]=(g[(S+m)%g.length]-g[(S+1)%g.length]+2*this.orbitoris[v])%this.orbitoris[v])}}let f=new si(Ci(24),wr(24),1);for(let h=0;h3?s[u]=2:s[u]=0;else if(s[u]===3)s[u]=0;else throw new Error(\"Impossible addrot val\")}for(let u=0;ue.toPerm())}showcanon(e){pg(this.getOrbitsDef(!1),e)}getsolved(){let e=[];for(let t=0;ts(ue[0])+\" \"+s(ue[1])).join(\" \")+`\"/>\n`}let l=this.addrotations,c=this.addrotations,f=this.addrotations;for(let W=0;W{if(r){let F=.5*i+.25*e,ue=this.baseplanes[W].rotateplane(Q).d<0?1:-1;return[i+e*.5+ue*(F-j.b*te),i+t*.5+j.c*te]}else{let F=A[this.facenames[W][1]];return[i+j.dot(F[0])+F[2].b,i+t-j.dot(F[1])-F[2].c]}};for(let W=0;Wee(F,ue)))}let ie=[];for(let W=0;W\"),ie.push(\"\"+this.facenames[W][1]+`\n`);for(let j=0;j\")}let P=[];function X(W,j,F,ue){let xe=ee(W,F);for(let De=0;De\n\n`+ie.join(\"\")+\"\";return this.svggrips=P,J}dist(e,t){return Math.hypot(e[0]-t[0],e[1]-t[1],e[2]-t[2])}triarea(e,t,i){let r=this.dist(e,t),o=this.dist(t,i),s=this.dist(e,i),a=(r+o+s)/2;return Math.sqrt(a*(a-r)*(a-o)*(a-s))}polyarea(e){let t=0;for(let i=2;i0&&(S=cM(S,c)),i.push({coords:Ya(S,a),color:m,orbit:this.cubiesetnames[v],ord:y,ori:g}),this.duplicatedFaces[h])for(let w=1;w{});function zg(n,e){let t=n[0].p.length,i=eg(t),r=[],o=[],s=[],a=[],l=[];function c(p){for(let d=p.p.length-1;d>=0;d--){let g=p.p[d];if(g!==d){if(!r[d][g])return!1;p=p.mul(o[d][g])}}return!0}function f(p,d,g){a[p].push(d),l[p].push(g);for(let v=0;v1&&S.multiply(w);let A=x/w;m.push(A),y+=A}e(\"\"+g+\": sz \"+d+\" T \"+v+\" sol \"+y+\" none \"+p+\" mults \"+S)}return d}return h()}var kg,Ig=Ae(()=>{ja();kg=class{constructor(){this.mult=[]}multiply(e){for(let t=2;t*t<=e;t++)for(;e%t==0;)this.mult[t]!==void 0?this.mult[t]++:this.mult[t]=1,e/=t;e>1&&(this.mult[e]!==void 0?this.mult[e]++:this.mult[e]=1)}toString(){let e=\"\";for(let t=0;t1&&(e+=\"^\"+this.mult[t]));return e}}});var Fg={};Qn(Fg,{Orbit:()=>si,OrbitDef:()=>go,OrbitsDef:()=>Mr,Perm:()=>Ln,PuzzleGeometry:()=>Zc,Quat:()=>Oe,Transformation:()=>Ri,VisibleState:()=>Sr,getPuzzleGeometryByDesc:()=>$h,getPuzzleGeometryByName:()=>Dg,getpuzzle:()=>Ag,getpuzzles:()=>Tg,parsedesc:()=>Kh,parseoptions:()=>Rg,schreierSims:()=>zg,useNewFaceNames:()=>_g});var Ng=Ae(()=>{ja();Yh();Cg();Pg();Qc();Ig()});var Bg={};Qn(Bg,{cube2x2x2KPuzzle:()=>uM});var uM,Og=Ae(()=>{uM={name:\"2x2x2\",orbits:{CORNERS:{numPieces:8,orientations:3}},startPieces:{CORNERS:{permutation:[0,1,2,3,4,5,6,7],orientation:[0,0,0,0,0,0,0,0]}},moves:{U:{CORNERS:{permutation:[1,2,3,0,4,5,6,7],orientation:[0,0,0,0,0,0,0,0]}},y:{CORNERS:{permutation:[1,2,3,0,7,4,5,6],orientation:[0,0,0,0,0,0,0,0]}},x:{CORNERS:{permutation:[4,0,3,5,7,6,2,1],orientation:[2,1,2,1,1,2,1,2]}},L:{CORNERS:{permutation:[0,1,6,2,4,3,5,7],orientation:[0,0,2,1,0,2,1,0]}},F:{CORNERS:{permutation:[3,1,2,5,0,4,6,7],orientation:[1,0,0,2,2,1,0,0]}},R:{CORNERS:{permutation:[4,0,2,3,7,5,6,1],orientation:[2,1,0,0,1,0,0,2]}},B:{CORNERS:{permutation:[0,7,1,3,4,5,2,6],orientation:[0,2,1,0,0,0,2,1]}},D:{CORNERS:{permutation:[0,1,2,3,5,6,7,4],orientation:[0,0,0,0,0,0,0,0]}},z:{CORNERS:{permutation:[3,2,6,5,0,4,7,1],orientation:[1,2,1,2,2,1,2,1]}}}}});var Ug={};Qn(Ug,{default:()=>fM});var fM,Gg=Ae(()=>{fM=`\n\n\n 2x2x2\n \n \n \n \n \n \n \n \n \n\n \n \n \n\n \n \n \n\n \n \n \n\n \n \n \n\n \n \n \n\n \n \n \n\n \n \n \n \n\n`});var Wg={};Qn(Wg,{default:()=>hM});var hM,Hg=Ae(()=>{hM=`\n\n\n 3x3x3\n \n \n \n \n \n\n\n\n\n\n\n\n\n\n\n\n\n\n \n \n \n \n \n\n \n \n \n\n \n \n \n\n \n \n \n\n \n \n \n\n \n \n \n\n \n \n \n\n \n \n \n\n \n \n \n\n \n \n\n \n \n\n \n \n\n \n \n\n \n \n\n \n \n\n \n \n\n \n \n\n \n \n\n \n \n\n \n \n\n \n \n \n \n \n \n\n \n \n \n \n\n \n \n \n \n\n \n \n \n \n\n \n \n \n \n\n \n \n \n \n \n\n`});var Vg={};Qn(Vg,{default:()=>pM});var pM,jg=Ae(()=>{pM=`\n\n 3x3x3 LL\n \n \n \n \n \n \n \n \n \n \n\n \n \n \n \n \n \n \n \n \n \n \n \n\n \n \n \n \n \n \n \n \n\n \n \n \n \n \n \n\n \n \n \n\n \n \n \n\n \n \n \n\n \n \n \n\n \n \n\n \n \n\n \n \n\n \n \n\n \n \n\n \n \n\n \n \n\n \n \n \n \n \n \n\n \n \n \n \n\n \n \n \n \n\n \n \n \n \n\n \n \n \n \n \n`});var qg={};Qn(qg,{clockKPuzzle:()=>dM});var dM,Qg=Ae(()=>{dM={name:\"Clock\",orbits:{DIALS:{numPieces:18,orientations:12},FACES:{numPieces:18,orientations:1},FRAME:{numPieces:1,orientations:2}},startPieces:{DIALS:{permutation:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17],orientation:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},FACES:{permutation:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17],orientation:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},FRAME:{permutation:[0],orientation:[0]}},moves:{UR_PLUS_:{DIALS:{permutation:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17],orientation:[0,1,1,0,1,1,0,0,0,-1,0,0,0,0,0,0,0,0]},FACES:{permutation:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17],orientation:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},FRAME:{permutation:[0],orientation:[0]}},DR_PLUS_:{DIALS:{permutation:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17],orientation:[0,0,0,0,1,1,0,1,1,0,0,0,0,0,0,-1,0,0]},FACES:{permutation:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17],orientation:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},FRAME:{permutation:[0],orientation:[0]}},DL_PLUS_:{DIALS:{permutation:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17],orientation:[0,0,0,1,1,0,1,1,0,0,0,0,0,0,0,0,0,-1]},FACES:{permutation:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17],orientation:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},FRAME:{permutation:[0],orientation:[0]}},UL_PLUS_:{DIALS:{permutation:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17],orientation:[1,1,0,1,1,0,0,0,0,0,0,-1,0,0,0,0,0,0]},FACES:{permutation:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17],orientation:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},FRAME:{permutation:[0],orientation:[0]}},U_PLUS_:{DIALS:{permutation:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17],orientation:[1,1,1,1,1,1,0,0,0,-1,0,-1,0,0,0,0,0,0]},FACES:{permutation:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17],orientation:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},FRAME:{permutation:[0],orientation:[0]}},R_PLUS_:{DIALS:{permutation:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17],orientation:[0,1,1,0,1,1,0,1,1,-1,0,0,0,0,0,-1,0,0]},FACES:{permutation:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17],orientation:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},FRAME:{permutation:[0],orientation:[0]}},D_PLUS_:{DIALS:{permutation:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17],orientation:[0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,-1,0,-1]},FACES:{permutation:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17],orientation:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},FRAME:{permutation:[0],orientation:[0]}},L_PLUS_:{DIALS:{permutation:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17],orientation:[1,1,0,1,1,0,1,1,0,0,0,-1,0,0,0,0,0,-1]},FACES:{permutation:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17],orientation:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},FRAME:{permutation:[0],orientation:[0]}},ALL_PLUS_:{DIALS:{permutation:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17],orientation:[1,1,1,1,1,1,1,1,1,-1,0,-1,0,0,0,-1,0,-1]},FACES:{permutation:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17],orientation:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},FRAME:{permutation:[0],orientation:[0]}},y2:{DIALS:{permutation:[9,10,11,12,13,14,15,16,17,0,1,2,3,4,5,6,7,8],orientation:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},FACES:{permutation:[9,10,11,12,13,14,15,16,17,0,1,2,3,4,5,6,7,8],orientation:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},FRAME:{permutation:[0],orientation:[1]}},UL:{DIALS:{permutation:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17],orientation:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},FACES:{permutation:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17],orientation:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},FRAME:{permutation:[0],orientation:[0]}},UR:{DIALS:{permutation:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17],orientation:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},FACES:{permutation:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17],orientation:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},FRAME:{permutation:[0],orientation:[0]}},DL:{DIALS:{permutation:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17],orientation:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},FACES:{permutation:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17],orientation:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},FRAME:{permutation:[0],orientation:[0]}},DR:{DIALS:{permutation:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17],orientation:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},FACES:{permutation:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17],orientation:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},FRAME:{permutation:[0],orientation:[0]}}}}});var Yg={};Qn(Yg,{default:()=>mM});var mM,Xg=Ae(()=>{mM=`\n\n clock\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n`});var t1={};Qn(t1,{default:()=>gM});var gM,n1=Ae(()=>{gM=`\n\n\n \n \n pyraminx\n \n \n \n \n \n \n \n \n\n\n\n\n\n\n\n\n\n\n \n \n \n \n \n\n \n \n \n\n \n \n \n\n \n \n \n\n \n \n \n \n\n \n \n \n\n \n \n \n\n \n \n \n\n \n \n \n\n \n \n\n \n \n\n \n \n\n \n \n\n \n \n \n\n`});var r1={};Qn(r1,{sq1HyperOrbitKPuzzle:()=>yM});var yM,o1=Ae(()=>{yM={name:\"Square-1\",orbits:{WEDGES:{numPieces:24,orientations:9},EQUATOR:{numPieces:2,orientations:6}},startPieces:{WEDGES:{permutation:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23],orientation:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},EQUATOR:{permutation:[0,1],orientation:[0,0]}},moves:{U_SQ_:{WEDGES:{permutation:[11,0,1,2,3,4,5,6,7,8,9,10,12,13,14,15,16,17,18,19,20,21,22,23],orientation:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},EQUATOR:{permutation:[0,1],orientation:[0,0]}},D_SQ_:{WEDGES:{permutation:[0,1,2,3,4,5,6,7,8,9,10,11,23,12,13,14,15,16,17,18,19,20,21,22],orientation:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},EQUATOR:{permutation:[0,1],orientation:[0,0]}},_SLASH_:{WEDGES:{permutation:[0,1,2,3,4,5,12,13,14,15,16,17,6,7,8,9,10,11,18,19,20,21,22,23],orientation:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},EQUATOR:{permutation:[0,1],orientation:[0,3]}}}}});var s1={};Qn(s1,{default:()=>vM});var vM,a1=Ae(()=>{vM=`\n\n \n sq1-fancy\n Created with Sketch.\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n`});var sb=Ae(()=>{});var ab={};Qn(ab,{cachedData222:()=>nL});var nL,lb=Ae(()=>{sb();nL={baseorder:[[\"CORNERS\",3],[\"CORNERS\",7],[\"CORNERS\",4],[\"CORNERS\",1],[\"CORNERS\",6],[\"CORNERS\",5],[\"CORNERS\",2],[\"CORNERS\",0]],esgs:[[[[\"F2'\",{CORNERS:{permutation:[3,6,2,0,4,5,1,7],orientation:[0,0,0,0,0,0,0,0]}}],[\"U F'\",{CORNERS:{permutation:[1,3,5,0,4,6,2,7],orientation:[1,2,0,1,0,0,2,0]}}],[\"R' F\",{CORNERS:{permutation:[6,2,4,0,1,5,3,7],orientation:[1,1,1,2,2,0,2,0]}}]],[[\"D'\",{CORNERS:{permutation:[0,4,2,1,7,5,6,3],orientation:[0,0,0,0,0,0,0,0]}}],[\"F\",{CORNERS:{permutation:[6,0,2,1,4,5,3,7],orientation:[1,2,0,1,0,0,2,0]}}],[\"R F2'\",{CORNERS:{permutation:[3,6,0,1,2,5,4,7],orientation:[0,0,1,2,2,0,1,0]}}]],[[\"U F2'\",{CORNERS:{permutation:[3,0,5,2,4,6,1,7],orientation:[0,0,0,0,0,0,0,0]}}],[\"U2' F'\",{CORNERS:{permutation:[1,3,6,2,4,0,5,7],orientation:[1,2,0,1,0,0,2,0]}}],[\"R' F2'\",{CORNERS:{permutation:[3,6,4,2,1,5,0,7],orientation:[0,0,1,2,2,0,1,0]}}]],[null,[\"D F\",{CORNERS:{permutation:[6,0,2,3,1,5,7,4],orientation:[1,2,0,1,0,0,2,0]}}],[\"L' F'\",{CORNERS:{permutation:[1,7,2,3,4,6,0,5],orientation:[1,1,0,2,0,2,2,1]}}]],[[\"D2'\",{CORNERS:{permutation:[0,7,2,4,3,5,6,1],orientation:[0,0,0,0,0,0,0,0]}}],[\"D' F\",{CORNERS:{permutation:[6,0,2,4,7,5,1,3],orientation:[1,2,0,1,0,0,2,0]}}],[\"R F\",{CORNERS:{permutation:[6,1,0,4,2,5,3,7],orientation:[1,1,1,2,2,0,2,0]}}]],[[\"L2'\",{CORNERS:{permutation:[0,1,2,5,4,3,7,6],orientation:[0,0,0,0,0,0,0,0]}}],[\"U' F'\",{CORNERS:{permutation:[1,3,0,5,4,2,6,7],orientation:[1,2,0,1,0,0,2,0]}}],[\"L F'\",{CORNERS:{permutation:[1,6,2,5,4,7,0,3],orientation:[1,1,0,2,0,2,2,1]}}]],[[\"U' F2'\",{CORNERS:{permutation:[3,5,0,6,4,2,1,7],orientation:[0,0,0,0,0,0,0,0]}}],[\"F'\",{CORNERS:{permutation:[1,3,2,6,4,5,0,7],orientation:[1,2,0,1,0,0,2,0]}}],[\"L\",{CORNERS:{permutation:[0,1,2,6,4,7,5,3],orientation:[0,0,0,2,0,2,1,1]}}]],[[\"D\",{CORNERS:{permutation:[0,3,2,7,1,5,6,4],orientation:[0,0,0,0,0,0,0,0]}}],[\"L2' F'\",{CORNERS:{permutation:[1,5,2,7,4,3,0,6],orientation:[1,2,0,1,0,0,2,0]}}],[\"L'\",{CORNERS:{permutation:[0,1,2,7,4,6,3,5],orientation:[0,0,0,2,0,2,1,1]}}]]],[[[\"U' B2'\",{CORNERS:{permutation:[6,1,7,3,2,4,5,0],orientation:[0,0,0,0,0,0,0,0]}}],[\"R B2'\",{CORNERS:{permutation:[1,4,7,3,5,2,6,0],orientation:[2,1,0,0,0,2,0,1]}}],[\"R2' B'\",{CORNERS:{permutation:[4,2,5,3,1,7,6,0],orientation:[0,0,2,0,1,1,0,2]}}]],[[\"R2' B2'\",{CORNERS:{permutation:[4,2,7,3,5,0,6,1],orientation:[0,0,0,0,0,0,0,0]}}],[\"R' B'\",{CORNERS:{permutation:[2,0,5,3,4,7,6,1],orientation:[2,1,2,0,2,1,0,1]}}],[\"R U' B2'\",{CORNERS:{permutation:[6,4,7,3,0,2,5,1],orientation:[0,1,0,0,1,2,0,2]}}]],[[\"B2'\",{CORNERS:{permutation:[0,1,7,3,5,4,6,2],orientation:[0,0,0,0,0,0,0,0]}}],[\"R B'\",{CORNERS:{permutation:[1,4,5,3,0,7,6,2],orientation:[2,1,2,0,2,1,0,1]}}],[\"U' B\",{CORNERS:{permutation:[6,1,4,3,7,0,5,2],orientation:[0,0,2,0,1,1,0,2]}}]],null,[[\"F D F'\",{CORNERS:{permutation:[1,7,2,3,0,5,6,4],orientation:[2,2,0,0,2,0,0,0]}}],[\"R' B2'\",{CORNERS:{permutation:[2,0,7,3,5,1,6,4],orientation:[2,1,0,0,0,2,0,1]}}],[\"B'\",{CORNERS:{permutation:[0,1,5,3,2,7,6,4],orientation:[0,0,2,0,1,1,0,2]}}]],[[\"U B2'\",{CORNERS:{permutation:[2,1,7,3,6,4,0,5],orientation:[0,0,0,0,0,0,0,0]}}],[\"F2' L' F2'\",{CORNERS:{permutation:[7,0,2,3,4,1,6,5],orientation:[2,1,0,0,0,2,0,1]}}],[\"B\",{CORNERS:{permutation:[0,1,4,3,7,2,6,5],orientation:[0,0,2,0,1,1,0,2]}}]],[[\"U2' B2'\",{CORNERS:{permutation:[5,1,7,3,0,4,2,6],orientation:[0,0,0,0,0,0,0,0]}}],[\"U2' R B'\",{CORNERS:{permutation:[1,4,0,3,5,7,2,6],orientation:[2,1,2,0,2,1,0,1]}}],[\"U B\",{CORNERS:{permutation:[2,1,4,3,7,5,0,6],orientation:[0,0,2,0,1,1,0,2]}}]],[null,[\"B2' R B'\",{CORNERS:{permutation:[1,5,4,3,0,2,6,7],orientation:[2,1,2,0,2,1,0,1]}}],[\"B R' B2'\",{CORNERS:{permutation:[4,0,5,3,2,1,6,7],orientation:[1,1,2,0,1,2,0,2]}}]]],[[[\"R2'\",{CORNERS:{permutation:[4,2,1,3,0,5,6,7],orientation:[0,0,0,0,0,0,0,0]}}],[\"F R' F'\",{CORNERS:{permutation:[6,1,4,3,0,5,2,7],orientation:[0,0,1,0,1,0,1,0]}}],[\"U' R\",{CORNERS:{permutation:[1,4,6,3,0,2,5,7],orientation:[2,1,1,0,2,0,0,0]}}]],[[\"L2' D L2'\",{CORNERS:{permutation:[0,5,2,3,1,6,4,7],orientation:[0,0,0,0,0,0,0,0]}}],[\"R U' R\",{CORNERS:{permutation:[4,2,6,3,1,0,5,7],orientation:[0,0,1,0,1,1,0,0]}}],[\"R'\",{CORNERS:{permutation:[2,0,4,3,1,5,6,7],orientation:[2,1,1,0,2,0,0,0]}}]],[[\"U R2'\",{CORNERS:{permutation:[4,5,1,3,2,6,0,7],orientation:[0,0,0,0,0,0,0,0]}}],[\"L' B' L\",{CORNERS:{permutation:[0,1,6,3,2,4,5,7],orientation:[0,0,1,0,1,1,0,0]}}],[\"R\",{CORNERS:{permutation:[1,4,0,3,2,5,6,7],orientation:[2,1,1,0,2,0,0,0]}}]],null,[null,[\"R' U R2'\",{CORNERS:{permutation:[1,5,0,3,4,6,2,7],orientation:[2,0,1,0,1,0,2,0]}}],[\"R2' U' R\",{CORNERS:{permutation:[2,0,6,3,4,1,5,7],orientation:[2,1,1,0,2,0,0,0]}}]],[[\"U2' R2'\",{CORNERS:{permutation:[4,6,1,3,5,0,2,7],orientation:[0,0,0,0,0,0,0,0]}}],[\"U2' F R' F'\",{CORNERS:{permutation:[2,1,4,3,5,0,6,7],orientation:[0,0,1,0,1,0,1,0]}}],[\"U R\",{CORNERS:{permutation:[1,4,2,3,5,6,0,7],orientation:[2,1,1,0,2,0,0,0]}}]],[[\"U' R2'\",{CORNERS:{permutation:[4,0,1,3,6,2,5,7],orientation:[0,0,0,0,0,0,0,0]}}],[\"F R2' F'\",{CORNERS:{permutation:[2,1,0,3,6,5,4,7],orientation:[1,0,2,0,1,0,2,0]}}],[\"U2' R\",{CORNERS:{permutation:[1,4,5,3,6,0,2,7],orientation:[2,1,1,0,2,0,0,0]}}]]],[[[\"F2' D' L2' D F2'\",{CORNERS:{permutation:[1,0,2,3,4,6,5,7],orientation:[0,0,0,0,0,0,0,0]}}],[\"F' U' F\",{CORNERS:{permutation:[5,0,1,3,4,2,6,7],orientation:[1,1,1,0,0,0,0,0]}}],[\"L F L'\",{CORNERS:{permutation:[5,0,2,3,4,6,1,7],orientation:[2,2,0,0,0,0,2,0]}}]],[null,[\"F' U2' L F' L' F2'\",{CORNERS:{permutation:[6,1,0,3,4,5,2,7],orientation:[1,1,2,0,0,1,1,0]}}],[\"L F' L2' U L F'\",{CORNERS:{permutation:[6,1,5,3,4,0,2,7],orientation:[2,2,2,0,0,1,2,0]}}]],[[\"F D2' B' D2' F'\",{CORNERS:{permutation:[1,2,5,3,4,0,6,7],orientation:[1,0,2,0,0,0,0,0]}}],[\"D R' D' F\",{CORNERS:{permutation:[6,2,1,3,4,5,0,7],orientation:[1,1,1,0,0,0,0,0]}}],[\"F' U F\",{CORNERS:{permutation:[1,2,5,3,4,0,6,7],orientation:[2,2,0,0,0,2,0,0]}}]],null,null,[[\"F' L F' L' F2'\",{CORNERS:{permutation:[6,5,2,3,4,1,0,7],orientation:[1,0,0,0,0,2,0,0]}}],[\"L F2' L'\",{CORNERS:{permutation:[6,5,2,3,4,1,0,7],orientation:[2,1,0,0,0,2,1,0]}}],[\"F' U2' F\",{CORNERS:{permutation:[2,5,0,3,4,1,6,7],orientation:[1,2,2,0,0,1,0,0]}}]],[[\"L' F2' L F2' L\",{CORNERS:{permutation:[1,6,2,3,4,0,5,7],orientation:[2,0,0,0,0,0,1,0]}}],[\"L F' L'\",{CORNERS:{permutation:[1,6,2,3,4,0,5,7],orientation:[1,1,0,0,0,1,0,0]}}],[\"U F' U2' F\",{CORNERS:{permutation:[5,6,2,3,4,1,0,7],orientation:[1,2,2,0,0,1,0,0]}}]]],[[[\"U\",{CORNERS:{permutation:[2,1,5,3,4,6,0,7],orientation:[0,0,0,0,0,0,0,0]}}],[\"L2' D2' R' D2' L2'\",{CORNERS:{permutation:[2,1,5,3,4,6,0,7],orientation:[2,0,1,0,0,2,1,0]}}],[\"F2' D2' B' D2' F2'\",{CORNERS:{permutation:[2,1,5,3,4,6,0,7],orientation:[1,0,2,0,0,1,2,0]}}]],null,[[\"U2'\",{CORNERS:{permutation:[5,1,6,3,4,0,2,7],orientation:[0,0,0,0,0,0,0,0]}}],[\"F2' D2' B D2' F2' U'\",{CORNERS:{permutation:[5,1,6,3,4,0,2,7],orientation:[2,0,1,0,0,2,1,0]}}],[\"U F2' D2' B' D2' F2'\",{CORNERS:{permutation:[5,1,6,3,4,0,2,7],orientation:[1,0,2,0,0,1,2,0]}}]],null,null,[[\"U'\",{CORNERS:{permutation:[6,1,0,3,4,2,5,7],orientation:[0,0,0,0,0,0,0,0]}}],[\"L2' D2' R D2' L2'\",{CORNERS:{permutation:[6,1,0,3,4,2,5,7],orientation:[2,0,1,0,0,2,1,0]}}],[\"F2' D2' B D2' F2'\",{CORNERS:{permutation:[6,1,0,3,4,2,5,7],orientation:[1,0,2,0,0,1,2,0]}}]],[null,[\"F2' D2' B' D2' F2' U'\",{CORNERS:{permutation:[0,1,2,3,4,5,6,7],orientation:[2,0,1,0,0,2,1,0]}}],[\"U' F2' D2' B' D2' F2'\",{CORNERS:{permutation:[0,1,2,3,4,5,6,7],orientation:[1,0,2,0,0,1,2,0]}}]]],[[[\"U' F R D B' D' F'\",{CORNERS:{permutation:[5,1,2,3,4,0,6,7],orientation:[1,0,2,0,0,0,0,0]}}],[\"R F L F U' F' D' F'\",{CORNERS:{permutation:[2,1,5,3,4,0,6,7],orientation:[0,0,2,0,0,1,0,0]}}],[\"F U R D' F' L' D\",{CORNERS:{permutation:[5,1,2,3,4,0,6,7],orientation:[0,0,1,0,0,2,0,0]}}]],null,[[\"L U' L' U' F' L F\",{CORNERS:{permutation:[0,1,5,3,4,2,6,7],orientation:[2,0,1,0,0,0,0,0]}}],[\"R F D' F2' L' F' D F2'\",{CORNERS:{permutation:[5,1,0,3,4,2,6,7],orientation:[1,0,1,0,0,1,0,0]}}],[\"F' R' U L F D L'\",{CORNERS:{permutation:[0,1,5,3,4,2,6,7],orientation:[1,0,0,0,0,2,0,0]}}]],null,null,[null,[\"F' U F U L F' L'\",{CORNERS:{permutation:[2,1,0,3,4,5,6,7],orientation:[0,0,2,0,0,1,0,0]}}],[\"L B U' F' L' D' F\",{CORNERS:{permutation:[2,1,0,3,4,5,6,7],orientation:[1,0,0,0,0,2,0,0]}}]]],[[[\"U' F2' L2' F' L' D F2' D' L F'\",{CORNERS:{permutation:[2,1,0,3,4,5,6,7],orientation:[0,0,0,0,0,0,0,0]}}],[\"U2' F D' L' D2' R2' F' D' L F'\",{CORNERS:{permutation:[2,1,0,3,4,5,6,7],orientation:[2,0,1,0,0,0,0,0]}}],[\"U B2' D F R F' L2' D' F D' F'\",{CORNERS:{permutation:[2,1,0,3,4,5,6,7],orientation:[1,0,2,0,0,0,0,0]}}]],null,[null,[\"R B L2' D2' F' L' D L' D F'\",{CORNERS:{permutation:[0,1,2,3,4,5,6,7],orientation:[2,0,1,0,0,0,0,0]}}],[\"U F U2' R2' F' D' L F' D F'\",{CORNERS:{permutation:[0,1,2,3,4,5,6,7],orientation:[1,0,2,0,0,0,0,0]}}]]]]}});function M0(){return se(this,null,function*(){return(yield Promise.resolve().then(()=>(w0(),b0))).default})}function S0(){return se(this,null,function*(){return(yield import(\"worker_threads\")).parentPort})}var E0=Symbol(\"Comlink.proxy\"),x2=Symbol(\"Comlink.endpoint\"),b2=Symbol(\"Comlink.releaseProxy\"),Mh=Symbol(\"Comlink.thrown\"),_0=n=>typeof n==\"object\"&&n!==null||typeof n==\"function\",w2={canHandle:n=>_0(n)&&n[E0],serialize(n){let{port1:e,port2:t}=new MessageChannel;return za(n,e),[t,[t]]},deserialize(n){return n.start(),E2(n)}},M2={canHandle:n=>_0(n)&&Mh in n,serialize({value:n}){let e;return n instanceof Error?e={isError:!0,value:{message:n.message,name:n.name,stack:n.stack}}:e={isError:!1,value:n},[e,[]]},deserialize(n){throw n.isError?Object.assign(new Error(n.value.message),n.value):n.value}},T0=new Map([[\"proxy\",w2],[\"throw\",M2]]);function za(n,e=self){e.addEventListener(\"message\",function t(i){if(!i||!i.data)return;let{id:r,type:o,path:s}=Object.assign({path:[]},i.data),a=(i.data.argumentList||[]).map(lo),l;try{let c=s.slice(0,-1).reduce((u,h)=>u[h],n),f=s.reduce((u,h)=>u[h],n);switch(o){case\"GET\":l=f;break;case\"SET\":c[s.slice(-1)[0]]=lo(i.data.value),l=!0;break;case\"APPLY\":l=f.apply(c,a);break;case\"CONSTRUCT\":{let u=new f(...a);l=A2(u)}break;case\"ENDPOINT\":{let{port1:u,port2:h}=new MessageChannel;za(n,h),l=T2(u,[u])}break;case\"RELEASE\":l=void 0;break;default:return}}catch(c){l={value:c,[Mh]:0}}Promise.resolve(l).catch(c=>({value:c,[Mh]:0})).then(c=>{let[f,u]=Eh(c);e.postMessage(Object.assign(Object.assign({},f),{id:r}),u),o===\"RELEASE\"&&(e.removeEventListener(\"message\",t),A0(e))})}),e.start&&e.start()}function S2(n){return n.constructor.name===\"MessagePort\"}function A0(n){S2(n)&&n.close()}function E2(n,e){return Sh(n,[],e)}function _c(n){if(n)throw new Error(\"Proxy has been released and is not useable\")}function Sh(n,e=[],t=function(){}){let i=!1,r=new Proxy(t,{get(o,s){if(_c(i),s===b2)return()=>Yo(n,{type:\"RELEASE\",path:e.map(a=>a.toString())}).then(()=>{A0(n),i=!0});if(s===\"then\"){if(e.length===0)return{then:()=>r};let a=Yo(n,{type:\"GET\",path:e.map(l=>l.toString())}).then(lo);return a.then.bind(a)}return Sh(n,[...e,s])},set(o,s,a){_c(i);let[l,c]=Eh(a);return Yo(n,{type:\"SET\",path:[...e,s].map(f=>f.toString()),value:l},c).then(lo)},apply(o,s,a){_c(i);let l=e[e.length-1];if(l===x2)return Yo(n,{type:\"ENDPOINT\"}).then(lo);if(l===\"bind\")return Sh(n,e.slice(0,-1));let[c,f]=D0(a);return Yo(n,{type:\"APPLY\",path:e.map(u=>u.toString()),argumentList:c},f).then(lo)},construct(o,s){_c(i);let[a,l]=D0(s);return Yo(n,{type:\"CONSTRUCT\",path:e.map(c=>c.toString()),argumentList:a},l).then(lo)}});return r}function _2(n){return Array.prototype.concat.apply([],n)}function D0(n){let e=n.map(Eh);return[e.map(t=>t[0]),_2(e.map(t=>t[1]))]}var L0=new WeakMap;function T2(n,e){return L0.set(n,e),n}function A2(n){return Object.assign(n,{[E0]:!0})}function Eh(n){for(let[e,t]of T0)if(t.canHandle(n)){let[i,r]=t.serialize(n);return[{type:\"HANDLER\",name:e,value:i},r]}return[{type:\"RAW\",value:n},L0.get(n)||[]]}function lo(n){switch(n.type){case\"HANDLER\":return T0.get(n.name).deserialize(n.value);case\"RAW\":return n.value}}function Yo(n,e,t){return new Promise(i=>{let r=D2();n.addEventListener(\"message\",function o(s){!s.data||!s.data.id||s.data.id!==r||(n.removeEventListener(\"message\",o),i(s.data))}),n.start&&n.start(),n.postMessage(Object.assign({id:r},e),t)})}function D2(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join(\"-\")}nt();var es;function Ih(n,e){if(e===es)return!0;let t=e.permutation,i=t.length;for(let r=0;r1){let r=e.orientation;for(let o=0;o0){for(u=1,h=1;u{let h=i.orbits;if(!h)return;let p=h[o];if(!p)return;let d=p.pieces[a];if(!d)return;let g=d.facelets[l];if(!g)return;let v=typeof g==\"string\"?g:g==null?void 0:g.appearance,y=G2[v];y&&(u=y[u])})():u=f.style.fill,this.originalColors[c]=u,this.gradients[c]=this.newGradient(c,u),this.gradientDefs.appendChild(this.gradients[c]),f.setAttribute(\"style\",`fill: url(#grad-${this.svgID}-${c})`)}}}drawKPuzzle(e,t,i){this.draw(e.definition,e.state,t,i)}draw(e,t,i,r){for(let o in e.orbits){let s=e.orbits[o],a=t[o],l=i?i[o]:null;for(let c=0;cthis.move(t))}};function Li(n,e){return se(this,null,function*(){let t=yield n.def(),i=new Ha(t),r=new Va(t),o=()=>r.move(\"U\"),s=()=>r.or(r.moves([\"U\",\"D\"])),a=()=>r.not(s()),l=()=>r.or(r.moves([\"L\",\"R\"])),c=()=>r.not(l()),f=()=>r.or(r.moves([\"F\",\"B\"])),u=()=>r.not(f()),h=()=>r.not(o()),p=()=>r.and([o(),c(),u()]),d=()=>r.and([r.and(r.moves([\"F\",\"R\"])),r.not(s())]),g=()=>r.and(r.moves([\"D\",\"R\",\"F\"])),v=()=>r.or([g(),d()]),y=()=>r.or([r.and([c(),a()]),r.and([c(),u()]),r.and([a(),u()])]),m=()=>r.or([r.and([c(),s(),f()]),r.and([a(),l(),f()]),r.and([u(),s(),l()])]),S=()=>r.not(r.or([y(),m()])),b=()=>r.or([c(),r.and([o(),m()])]);function w(){i.set(h(),pe.Dim)}function x(){i.set(o(),pe.PermuteNonPrimary),i.set(p(),pe.Dim)}function A(){i.set(o(),pe.IgnoreNonPrimary),i.set(p(),pe.Regular)}function O(){i.set(o(),pe.Ignoriented),i.set(p(),pe.Dim)}switch(e){case\"full\":break;case\"PLL\":w(),x();break;case\"CLS\":w(),i.set(r.and(r.moves([\"D\",\"R\",\"F\"])),pe.Regular),i.set(o(),pe.Ignoriented),i.set(r.and([o(),S()]),pe.IgnoreNonPrimary);break;case\"OLL\":w(),A();break;case\"COLL\":w(),x(),i.set(r.and([o(),S()]),pe.Regular);break;case\"OCLL\":w(),O(),i.set(r.and([o(),S()]),pe.IgnoreNonPrimary);break;case\"CLL\":w(),i.set(r.not(r.and([S(),o()])),pe.Dim);break;case\"ELL\":w(),i.set(o(),pe.Dim),i.set(r.and([o(),m()]),pe.Regular);break;case\"ELS\":w(),A(),i.set(r.and([o(),S()]),pe.Ignored),i.set(d(),pe.Regular),i.set(g(),pe.Ignored);break;case\"LL\":w();break;case\"F2L\":i.set(o(),pe.Ignored);break;case\"ZBLL\":w(),i.set(o(),pe.PermuteNonPrimary),i.set(p(),pe.Dim),i.set(r.and([o(),S()]),pe.Regular);break;case\"ZBLS\":w(),i.set(v(),pe.Regular),A(),i.set(r.and([o(),S()]),pe.Ignored);break;case\"WVLS\":case\"VLS\":w(),i.set(v(),pe.Regular),A();break;case\"LS\":w(),i.set(v(),pe.Regular),i.set(o(),pe.Ignored),i.set(p(),pe.Dim);break;case\"EO\":i.set(S(),pe.Ignored),i.set(m(),pe.OrientationWithoutPermutation);break;case\"CMLL\":i.set(h(),pe.Dim),i.set(b(),pe.Ignored),i.set(r.and([o(),S()]),pe.Regular);break;case\"L6E\":i.set(r.not(b()),pe.Dim);break;case\"L6EO\":i.set(r.not(b()),pe.Dim),i.set(b(),pe.OrientationWithoutPermutation),i.set(r.and([y(),s()]),pe.OrientationStickers);break;case\"Daisy\":i.set(r.all(),pe.Ignored),i.set(y(),pe.Dim),i.set(r.and([r.move(\"D\"),y()]),pe.Regular),i.set(r.and([r.move(\"U\"),m()]),pe.IgnoreNonPrimary);break;case\"Cross\":i.set(r.all(),pe.Ignored),i.set(y(),pe.Dim),i.set(r.and([r.move(\"D\"),y()]),pe.Regular),i.set(r.and([r.move(\"D\"),m()]),pe.Regular);break;case\"2x2x2\":i.set(r.or(r.moves([\"U\",\"F\",\"R\"])),pe.Ignored),i.set(r.and([r.or(r.moves([\"U\",\"F\",\"R\"])),y()]),pe.Dim);break;case\"2x2x3\":i.set(r.all(),pe.Dim),i.set(r.or(r.moves([\"U\",\"F\",\"R\"])),pe.Ignored),i.set(r.and([r.or(r.moves([\"U\",\"F\",\"R\"])),y()]),pe.Dim),i.set(r.and([r.move(\"F\"),r.not(r.or(r.moves([\"U\",\"R\"])))]),pe.Regular);break;case\"Void Cube\":i.set(y(),pe.Invisible);break;case\"picture\":case\"invisible\":i.set(r.all(),pe.Invisible);break;case\"centers-only\":i.set(r.not(y()),pe.Ignored);break;default:console.warn(`Unsupported stickering for ${n.id}: ${e}. Setting all pieces to dim.`),i.set(r.and(r.moves([])),pe.Dim)}return i.toAppearance()})}function os(){return se(this,null,function*(){return[\"full\",\"PLL\",\"CLS\",\"OLL\",\"COLL\",\"OCLL\",\"ELL\",\"ELS\",\"LL\",\"F2L\",\"ZBLL\",\"ZBLS\",\"WVLS\",\"VLS\",\"LS\",\"EO\",\"CMLL\",\"L6E\",\"L6EO\",\"Daisy\",\"Cross\",\"2x2x2\",\"2x2x3\",\"Void Cube\",\"picture\",\"invisible\",\"centers-only\"]})}function ji(n){return se(this,null,function*(){return(yield Promise.resolve().then(()=>(Ng(),Fg))).getPuzzleGeometryByName(n,[\"allmoves\",\"true\",\"orientcenters\",\"true\",\"rotations\",\"true\"])})}function ep(n){return se(this,null,function*(){return(yield ji(n)).writekpuzzle(!0)})}function Er(n,e,t){let i={id:n,fullName:e,def:()=>se(this,null,function*(){return ep(n)}),svg:()=>se(this,null,function*(){return(yield ji(n)).generatesvg()}),pg:()=>se(this,null,function*(){return ji(n)})};return(t==null?void 0:t.inventedBy)&&(i.inventedBy=t.inventedBy),(t==null?void 0:t.inventionYear)&&(i.inventionYear=t.inventionYear),i}function cs(n,e,t){let i=Er(n,e,t);return i.appearance=Li.bind(Li,i),i.stickerings=os,i}var tp={id:\"2x2x2\",fullName:\"2\\xD72\\xD72 Cube\",def:()=>se(void 0,null,function*(){return(yield Promise.resolve().then(()=>(Og(),Bg))).cube2x2x2KPuzzle}),svg:()=>se(void 0,null,function*(){return(yield Promise.resolve().then(()=>(Gg(),Ug))).default}),pg:()=>se(void 0,null,function*(){return ji(\"2x2x2\")}),appearance:n=>Li(tp,n),stickerings:os};var np={id:\"3x3x3\",fullName:\"3\\xD73\\xD73 Cube\",inventedBy:[\"Ern\\u0151 Rubik\"],inventionYear:1974,def:()=>se(void 0,null,function*(){return Ot}),svg:()=>se(void 0,null,function*(){return(yield Promise.resolve().then(()=>(Hg(),Wg))).default}),llSVG:()=>se(void 0,null,function*(){return(yield Promise.resolve().then(()=>(jg(),Vg))).default}),pg:()=>se(void 0,null,function*(){return ji(\"3x3x3\")}),appearance:n=>Li(np,n),stickerings:os};var Zg={id:\"clock\",fullName:\"Clock\",inventedBy:[\"Christopher C. Wiggs\",\"Christopher J. Taylor\"],inventionYear:1988,def:()=>se(void 0,null,function*(){return(yield Promise.resolve().then(()=>(Qg(),qg))).clockKPuzzle}),svg:()=>se(void 0,null,function*(){return(yield Promise.resolve().then(()=>(Xg(),Yg))).default})};function Jg(n,e){return se(this,null,function*(){let t=yield n.def(),i=new Ha(t),r=new Va(t),o=()=>r.and([r.move(\"U\"),r.not(r.or(r.moves([\"F\",\"BL\",\"BR\"])))]),s=()=>r.and([r.move(\"U\"),r.not(r.move(\"F\"))]),a=()=>r.or([s(),r.and([r.move(\"F\"),r.not(r.or(r.moves([\"U\",\"BL\",\"BR\"])))])]),l=()=>r.not(r.or([r.and([r.move(\"U\"),r.move(\"F\")]),r.and([r.move(\"F\"),r.move(\"BL\")]),r.and([r.move(\"F\"),r.move(\"BR\")]),r.and([r.move(\"BL\"),r.move(\"BR\")])])),c=()=>r.not(r.or([r.and([r.move(\"F\"),r.move(\"BL\")]),r.and([r.move(\"F\"),r.move(\"BR\")])]));switch(e){case\"full\":break;case\"experimental-fto-fc\":i.set(r.not(o()),pe.Ignored);break;case\"experimental-fto-f2t\":i.set(r.not(s()),pe.Ignored);break;case\"experimental-fto-sc\":i.set(r.not(a()),pe.Ignored);break;case\"experimental-fto-l2c\":i.set(r.not(l()),pe.Ignored);break;case\"experimental-fto-lbt\":i.set(r.not(c()),pe.Ignored);break;default:console.warn(`Unsupported stickering for ${n.id}: ${e}. Setting all pieces to dim.`),i.set(r.and(r.moves([])),pe.Dim)}return i.toAppearance()})}function Kg(){return se(this,null,function*(){return[\"full\",\"experimental-fto-fc\",\"experimental-fto-f2t\",\"experimental-fto-sc\",\"experimental-fto-l2c\",\"experimental-fto-lbt\"]})}var Xa=Er(\"FTO\",\"Face-Turning Octahedron\",{inventedBy:[\"Karl Rohrbach\",\"David Pitcher\"],inventionYear:1983});Xa.appearance=n=>Jg(Xa,n);Xa.stickerings=Kg;function $g(n,e){return se(this,null,function*(){switch(e){case\"full\":case\"F2L\":case\"LL\":return Li(n,e);default:console.warn(`Unsupported stickering for ${n.id}: ${e}. Setting all pieces to dim.`)}return Li(n,\"full\")})}function e1(){return se(this,null,function*(){return[\"full\",\"F2L\",\"LL\"]})}var Za=Er(\"megaminx\",\"Megaminx\",{inventionYear:1981});Za.appearance=n=>$g(Za,n);Za.stickerings=e1;var i1={id:\"pyraminx\",fullName:\"Pyraminx\",inventedBy:[\"Uwe Meffert\"],inventionYear:1970,def:()=>se(void 0,null,function*(){return ep(\"pyraminx\")}),svg:()=>se(void 0,null,function*(){return(yield Promise.resolve().then(()=>(n1(),t1))).default}),pg:()=>se(void 0,null,function*(){return ji(\"pyraminx\")})};var l1={id:\"square1\",fullName:\"Square-1\",inventedBy:[\"Karel Hr\\u0161el\",\"Vojtech Kopsk\\xFD\"],inventionYear:1990,def:()=>se(void 0,null,function*(){return(yield Promise.resolve().then(()=>(o1(),r1))).sq1HyperOrbitKPuzzle}),svg:()=>se(void 0,null,function*(){return(yield Promise.resolve().then(()=>(a1(),s1))).default})};var gn={\"3x3x3\":np,\"2x2x2\":tp,\"4x4x4\":cs(\"4x4x4\",\"4\\xD74\\xD74 Cube\"),\"5x5x5\":cs(\"5x5x5\",\"5\\xD75\\xD75 Cube\"),\"6x6x6\":cs(\"6x6x6\",\"6\\xD76\\xD76 Cube\"),\"7x7x7\":cs(\"7x7x7\",\"7\\xD77\\xD77 Cube\"),\"40x40x40\":cs(\"40x40x40\",\"40\\xD740\\xD740 Cube\"),clock:Zg,megaminx:Za,pyraminx:i1,skewb:Er(\"skewb\",\"Skewb\",{inventedBy:[\"Tony Durham\"]}),square1:l1,fto:Xa,gigaminx:Er(\"gigaminx\",\"Gigaminx\",{inventedBy:[\"Tyler Fox\"],inventionYear:2006})};function c1(n){let e=n.CENTERS.permutation[0],t=n.CENTERS.permutation[5],i=n.CENTERS.permutation[1],r=i;return enew Array(6));{let n=new Yn(Ot),e=[\"\",\"z\",\"x\",\"z'\",\"x'\",\"x2\"].map(i=>le.fromString(i)),t=new le(\"y\");for(let i of e){n.reset(),n.applyAlg(i);for(let r=0;r<4;r++){n.applyAlg(t);let[o,s]=c1(n.state);xM[o][s]=xr(Ot,n.state)}}}function f1(){return se(this,null,function*(){if(typeof crypto!=\"undefined\"&&typeof crypto.getRandomValues!=\"undefined\")return crypto.getRandomValues.bind(crypto);{let e=yield import(\"crypto\");return t=>{if(!(t instanceof Uint32Array))throw new Error(\"The getRandomValues() shim only takes unsigned 32-bit int arrays\");for(var i=e.randomBytes(t.length*4),r=[],o=0;oh1)throw new Error(\"Called randomInt.below() with max == \"+n+\", which is larger than Javascript can handle with integer precision.\")}function qi(){return se(this,null,function*(){let n=yield f1(),e=t=>{SM(t);var i=MM(n),r=Math.floor(h1/t)*t;return ie[n(e.length)]})}var EM=qi();function p1(n){return se(this,null,function*(){for(let e=1;e>8&255]+rn[n>>16&255]+rn[n>>24&255]+\"-\"+rn[e&255]+rn[e>>8&255]+\"-\"+rn[e>>16&15|64]+rn[e>>24&255]+\"-\"+rn[t&63|128]+rn[t>>8&255]+\"-\"+rn[t>>16&255]+rn[t>>24&255]+rn[i&255]+rn[i>>8&255]+rn[i>>16&255]+rn[i>>24&255]).toUpperCase()},clamp:function(n,e,t){return Math.max(e,Math.min(t,n))},euclideanModulo:function(n,e){return(n%e+e)%e},mapLinear:function(n,e,t,i,r){return i+(n-e)*(r-i)/(t-e)},lerp:function(n,e,t){return(1-t)*n+t*e},damp:function(n,e,t,i){return Fe.lerp(n,e,1-Math.exp(-t*i))},pingpong:function(n,e=1){return e-Math.abs(Fe.euclideanModulo(n,e*2)-e)},smoothstep:function(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*(3-2*n))},smootherstep:function(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*n*(n*(n*6-15)+10))},randInt:function(n,e){return n+Math.floor(Math.random()*(e-n+1))},randFloat:function(n,e){return n+Math.random()*(e-n)},randFloatSpread:function(n){return n*(.5-Math.random())},seededRandom:function(n){return n!==void 0&&(au=n%2147483647),au=au*16807%2147483647,(au-1)/2147483646},degToRad:function(n){return n*Fe.DEG2RAD},radToDeg:function(n){return n*Fe.RAD2DEG},isPowerOfTwo:function(n){return(n&n-1)==0&&n!==0},ceilPowerOfTwo:function(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))},floorPowerOfTwo:function(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))},setQuaternionFromProperEuler:function(n,e,t,i,r){let o=Math.cos,s=Math.sin,a=o(t/2),l=s(t/2),c=o((e+i)/2),f=s((e+i)/2),u=o((e-i)/2),h=s((e-i)/2),p=o((i-e)/2),d=s((i-e)/2);switch(r){case\"XYX\":n.set(a*f,l*u,l*h,a*c);break;case\"YZY\":n.set(l*h,a*f,l*u,a*c);break;case\"ZXZ\":n.set(l*u,l*h,a*f,a*c);break;case\"XZX\":n.set(a*f,l*d,l*p,a*c);break;case\"YXY\":n.set(l*p,a*f,l*d,a*c);break;case\"ZYZ\":n.set(l*d,l*p,a*f,a*c);break;default:console.warn(\"THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: \"+r)}}},ne=class{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 new Error(\"index is out of range: \"+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error(\"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,t){return t!==void 0?(console.warn(\"THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead.\"),this.addVectors(e,t)):(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,t){return t!==void 0?(console.warn(\"THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.\"),this.subVectors(e,t)):(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,i=this.y,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6],this.y=r[1]*t+r[4]*i+r[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=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(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}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,i=this.y-e.y;return t*t+i*i}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,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,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,i){return i!==void 0&&console.warn(\"THREE.Vector2: offset has been removed from .fromBufferAttribute().\"),this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let i=Math.cos(t),r=Math.sin(t),o=this.x-e.x,s=this.y-e.y;return this.x=o*i-s*r+e.x,this.y=o*r+s*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}};ne.prototype.isVector2=!0;var Vt=class{constructor(){this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error(\"THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.\")}set(e,t,i,r,o,s,a,l,c){let f=this.elements;return f[0]=e,f[1]=r,f[2]=a,f[3]=t,f[4]=o,f[5]=l,f[6]=i,f[7]=s,f[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.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 i=e.elements,r=t.elements,o=this.elements,s=i[0],a=i[3],l=i[6],c=i[1],f=i[4],u=i[7],h=i[2],p=i[5],d=i[8],g=r[0],v=r[3],y=r[6],m=r[1],S=r[4],b=r[7],w=r[2],x=r[5],A=r[8];return o[0]=s*g+a*m+l*w,o[3]=s*v+a*S+l*x,o[6]=s*y+a*b+l*A,o[1]=c*g+f*m+u*w,o[4]=c*v+f*S+u*x,o[7]=c*y+f*b+u*A,o[2]=h*g+p*m+d*w,o[5]=h*v+p*S+d*x,o[8]=h*y+p*b+d*A,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],i=e[1],r=e[2],o=e[3],s=e[4],a=e[5],l=e[6],c=e[7],f=e[8];return t*s*f-t*a*c-i*o*f+i*a*l+r*o*c-r*s*l}invert(){let e=this.elements,t=e[0],i=e[1],r=e[2],o=e[3],s=e[4],a=e[5],l=e[6],c=e[7],f=e[8],u=f*s-a*c,h=a*l-f*o,p=c*o-s*l,d=t*u+i*h+r*p;if(d===0)return this.set(0,0,0,0,0,0,0,0,0);let g=1/d;return e[0]=u*g,e[1]=(r*c-f*i)*g,e[2]=(a*i-r*s)*g,e[3]=h*g,e[4]=(f*t-r*l)*g,e[5]=(r*o-a*t)*g,e[6]=p*g,e[7]=(i*l-c*t)*g,e[8]=(s*t-i*o)*g,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,i,r,o,s,a){let l=Math.cos(o),c=Math.sin(o);return this.set(i*l,i*c,-i*(l*s+c*a)+s+e,-r*c,r*l,-r*(-c*s+l*a)+a+t,0,0,1),this}scale(e,t){let i=this.elements;return i[0]*=e,i[3]*=e,i[6]*=e,i[1]*=t,i[4]*=t,i[7]*=t,this}rotate(e){let t=Math.cos(e),i=Math.sin(e),r=this.elements,o=r[0],s=r[3],a=r[6],l=r[1],c=r[4],f=r[7];return r[0]=t*o+i*l,r[3]=t*s+i*c,r[6]=t*a+i*f,r[1]=-i*o+t*l,r[4]=-i*s+t*c,r[7]=-i*a+t*f,this}translate(e,t){let i=this.elements;return i[0]+=e*i[2],i[3]+=e*i[5],i[6]+=e*i[8],i[1]+=t*i[2],i[4]+=t*i[5],i[7]+=t*i[8],this}equals(e){let t=this.elements,i=e.elements;for(let r=0;r<9;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){let i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}};Vt.prototype.isMatrix3=!0;var gs,ys={getDataURL:function(n){if(/^data:/i.test(n.src)||typeof HTMLCanvasElement==\"undefined\")return n.src;let e;if(n instanceof HTMLCanvasElement)e=n;else{gs===void 0&&(gs=document.createElementNS(\"http://www.w3.org/1999/xhtml\",\"canvas\")),gs.width=n.width,gs.height=n.height;let t=gs.getContext(\"2d\");n instanceof ImageData?t.putImageData(n,0,0):t.drawImage(n,0,0,n.width,n.height),e=gs}return e.width>2048||e.height>2048?e.toDataURL(\"image/jpeg\",.6):e.toDataURL(\"image/png\")}},t3=0,jt=class extends Tr{constructor(e=jt.DEFAULT_IMAGE,t=jt.DEFAULT_MAPPING,i=Bn,r=Bn,o=nn,s=$c,a=ci,l=fp,c=1,f=ds){super();Object.defineProperty(this,\"id\",{value:t3++}),this.uuid=Fe.generateUUID(),this.name=\"\",this.image=e,this.mipmaps=[],this.mapping=t,this.wrapS=i,this.wrapT=r,this.magFilter=o,this.minFilter=s,this.anisotropy=c,this.format=a,this.internalFormat=null,this.type=l,this.offset=new ne(0,0),this.repeat=new ne(1,1),this.center=new ne(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Vt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=f,this.version=0,this.onUpdate=null}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.image=e.image,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,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.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.encoding=e.encoding,this}toJSON(e){let t=e===void 0||typeof e==\"string\";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let i={metadata:{version:4.5,type:\"Texture\",generator:\"Texture.toJSON\"},uuid:this.uuid,name:this.name,mapping:this.mapping,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,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(this.image!==void 0){let r=this.image;if(r.uuid===void 0&&(r.uuid=Fe.generateUUID()),!t&&e.images[r.uuid]===void 0){let o;if(Array.isArray(r)){o=[];for(let s=0,a=r.length;s1)switch(this.wrapS){case cp:e.x=e.x-Math.floor(e.x);break;case Bn:e.x=e.x<0?0:1;break;case up:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case cp:e.y=e.y-Math.floor(e.y);break;case Bn:e.y=e.y<0?0:1;break;case up:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&this.version++}};jt.DEFAULT_IMAGE=void 0;jt.DEFAULT_MAPPING=_1;jt.prototype.isTexture=!0;function gp(n){return typeof HTMLImageElement!=\"undefined\"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement!=\"undefined\"&&n instanceof HTMLCanvasElement||typeof ImageBitmap!=\"undefined\"&&n instanceof ImageBitmap?ys.getDataURL(n):n.data?{data:Array.prototype.slice.call(n.data),width:n.width,height:n.height,type:n.data.constructor.name}:(console.warn(\"THREE.Texture: Unable to serialize Texture.\"),{})}var ut=class{constructor(e=0,t=0,i=0,r=1){this.x=e,this.y=t,this.z=i,this.w=r}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,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,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 new Error(\"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 new Error(\"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,t){return t!==void 0?(console.warn(\"THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead.\"),this.addVectors(e,t)):(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,t){return t!==void 0?(console.warn(\"THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.\"),this.subVectors(e,t)):(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,i=this.y,r=this.z,o=this.w,s=e.elements;return this.x=s[0]*t+s[4]*i+s[8]*r+s[12]*o,this.y=s[1]*t+s[5]*i+s[9]*r+s[13]*o,this.z=s[2]*t+s[6]*i+s[10]*r+s[14]*o,this.w=s[3]*t+s[7]*i+s[11]*r+s[15]*o,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);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,r,o,s=.01,a=.1,l=e.elements,c=l[0],f=l[4],u=l[8],h=l[1],p=l[5],d=l[9],g=l[2],v=l[6],y=l[10];if(Math.abs(f-h)b&&S>w?Sw?b=0?1:-1,S=1-y*y;if(S>Number.EPSILON){let w=Math.sqrt(S),x=Math.atan2(w,y*m);v=Math.sin(v*x)/w,a=Math.sin(a*x)/w}let b=a*m;if(l=l*v+h*b,c=c*v+p*b,f=f*v+d*b,u=u*v+g*b,v===1-a){let w=1/Math.sqrt(l*l+c*c+f*f+u*u);l*=w,c*=w,f*=w,u*=w}}e[t]=l,e[t+1]=c,e[t+2]=f,e[t+3]=u}static multiplyQuaternionsFlat(e,t,i,r,o,s){let a=i[r],l=i[r+1],c=i[r+2],f=i[r+3],u=o[s],h=o[s+1],p=o[s+2],d=o[s+3];return e[t]=a*d+f*u+l*p-c*h,e[t+1]=l*d+f*h+c*u-a*p,e[t+2]=c*d+f*p+a*h-l*u,e[t+3]=f*d-a*u-l*h-c*p,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,i,r){return this._x=e,this._y=t,this._z=i,this._w=r,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){if(!(e&&e.isEuler))throw new Error(\"THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.\");let i=e._x,r=e._y,o=e._z,s=e._order,a=Math.cos,l=Math.sin,c=a(i/2),f=a(r/2),u=a(o/2),h=l(i/2),p=l(r/2),d=l(o/2);switch(s){case\"XYZ\":this._x=h*f*u+c*p*d,this._y=c*p*u-h*f*d,this._z=c*f*d+h*p*u,this._w=c*f*u-h*p*d;break;case\"YXZ\":this._x=h*f*u+c*p*d,this._y=c*p*u-h*f*d,this._z=c*f*d-h*p*u,this._w=c*f*u+h*p*d;break;case\"ZXY\":this._x=h*f*u-c*p*d,this._y=c*p*u+h*f*d,this._z=c*f*d+h*p*u,this._w=c*f*u-h*p*d;break;case\"ZYX\":this._x=h*f*u-c*p*d,this._y=c*p*u+h*f*d,this._z=c*f*d-h*p*u,this._w=c*f*u+h*p*d;break;case\"YZX\":this._x=h*f*u+c*p*d,this._y=c*p*u+h*f*d,this._z=c*f*d-h*p*u,this._w=c*f*u-h*p*d;break;case\"XZY\":this._x=h*f*u-c*p*d,this._y=c*p*u-h*f*d,this._z=c*f*d+h*p*u,this._w=c*f*u+h*p*d;break;default:console.warn(\"THREE.Quaternion: .setFromEuler() encountered an unknown order: \"+s)}return t!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let i=t/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,i=t[0],r=t[4],o=t[8],s=t[1],a=t[5],l=t[9],c=t[2],f=t[6],u=t[10],h=i+a+u;if(h>0){let p=.5/Math.sqrt(h+1);this._w=.25/p,this._x=(f-l)*p,this._y=(o-c)*p,this._z=(s-r)*p}else if(i>a&&i>u){let p=2*Math.sqrt(1+i-a-u);this._w=(f-l)/p,this._x=.25*p,this._y=(r+s)/p,this._z=(o+c)/p}else if(a>u){let p=2*Math.sqrt(1+a-i-u);this._w=(o-c)/p,this._x=(r+s)/p,this._y=.25*p,this._z=(l+f)/p}else{let p=2*Math.sqrt(1+u-i-a);this._w=(s-r)/p,this._x=(o+c)/p,this._y=(l+f)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=1e-6,r=e.dot(t)+1;return rMath.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(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=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Fe.clamp(this.dot(e),-1,1)))}rotateTowards(e,t){let i=this.angleTo(e);if(i===0)return this;let r=Math.min(1,t/i);return this.slerp(e,r),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();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e,t){return t!==void 0?(console.warn(\"THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead.\"),this.multiplyQuaternions(e,t)):this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let i=e._x,r=e._y,o=e._z,s=e._w,a=t._x,l=t._y,c=t._z,f=t._w;return this._x=i*f+s*a+r*c-o*l,this._y=r*f+s*l+o*a-i*c,this._z=o*f+s*c+i*l-r*a,this._w=s*f-i*a-r*l-o*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let i=this._x,r=this._y,o=this._z,s=this._w,a=s*e._w+i*e._x+r*e._y+o*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=s,this._x=i,this._y=r,this._z=o,this;let l=1-a*a;if(l<=Number.EPSILON){let p=1-t;return this._w=p*s+t*this._w,this._x=p*i+t*this._x,this._y=p*r+t*this._y,this._z=p*o+t*this._z,this.normalize(),this._onChangeCallback(),this}let c=Math.sqrt(l),f=Math.atan2(c,a),u=Math.sin((1-t)*f)/c,h=Math.sin(t*f)/c;return this._w=s*u+this._w*h,this._x=i*u+this._x*h,this._y=r*u+this._y*h,this._z=o*u+this._z*h,this._onChangeCallback(),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._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}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}};qt.prototype.isQuaternion=!0;var E=class{constructor(e=0,t=0,i=0){this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,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 new Error(\"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 new Error(\"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,t){return t!==void 0?(console.warn(\"THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead.\"),this.addVectors(e,t)):(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,t){return t!==void 0?(console.warn(\"THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.\"),this.subVectors(e,t)):(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,t){return t!==void 0?(console.warn(\"THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead.\"),this.multiplyVectors(e,t)):(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 e&&e.isEuler||console.error(\"THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.\"),this.applyQuaternion(Y1.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Y1.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,i=this.y,r=this.z,o=e.elements;return this.x=o[0]*t+o[3]*i+o[6]*r,this.y=o[1]*t+o[4]*i+o[7]*r,this.z=o[2]*t+o[5]*i+o[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,i=this.y,r=this.z,o=e.elements,s=1/(o[3]*t+o[7]*i+o[11]*r+o[15]);return this.x=(o[0]*t+o[4]*i+o[8]*r+o[12])*s,this.y=(o[1]*t+o[5]*i+o[9]*r+o[13])*s,this.z=(o[2]*t+o[6]*i+o[10]*r+o[14])*s,this}applyQuaternion(e){let t=this.x,i=this.y,r=this.z,o=e.x,s=e.y,a=e.z,l=e.w,c=l*t+s*r-a*i,f=l*i+a*t-o*r,u=l*r+o*i-s*t,h=-o*t-s*i-a*r;return this.x=c*l+h*-o+f*-a-u*-s,this.y=f*l+h*-s+u*-o-c*-a,this.z=u*l+h*-a+c*-s-f*-o,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,i=this.y,r=this.z,o=e.elements;return this.x=o[0]*t+o[4]*i+o[8]*r,this.y=o[1]*t+o[5]*i+o[9]*r,this.z=o[2]*t+o[6]*i+o[10]*r,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=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(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,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e,t){return t!==void 0?(console.warn(\"THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead.\"),this.crossVectors(e,t)):this.crossVectors(this,e)}crossVectors(e,t){let i=e.x,r=e.y,o=e.z,s=t.x,a=t.y,l=t.z;return this.x=r*l-o*a,this.y=o*s-i*l,this.z=i*a-r*s,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return yp.copy(this).projectOnVector(e),this.sub(yp)}reflect(e){return this.sub(yp.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 i=this.dot(e)/t;return Math.acos(Fe.clamp(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return t*t+i*i+r*r}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,i){let r=Math.sin(t)*e;return this.x=r*Math.sin(i),this.y=Math.cos(t)*e,this.z=r*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,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(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}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,i){return i!==void 0&&console.warn(\"THREE.Vector3: offset has been removed from .fromBufferAttribute().\"),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}};E.prototype.isVector3=!0;var yp=new E,Y1=new qt,On=class{constructor(e=new E(Infinity,Infinity,Infinity),t=new E(-Infinity,-Infinity,-Infinity)){this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){let t=Infinity,i=Infinity,r=Infinity,o=-Infinity,s=-Infinity,a=-Infinity;for(let l=0,c=e.length;lo&&(o=f),u>s&&(s=u),h>a&&(a=h)}return this.min.set(t,i,r),this.max.set(o,s,a),this}setFromBufferAttribute(e){let t=Infinity,i=Infinity,r=Infinity,o=-Infinity,s=-Infinity,a=-Infinity;for(let l=0,c=e.count;lo&&(o=f),u>s&&(s=u),h>a&&(a=h)}return this.min.set(t,i,r),this.max.set(o,s,a),this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;tthis.max.x||e.ythis.max.y||e.zthis.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===void 0&&(console.warn(\"THREE.Box3: .getParameter() target is now required\"),t=new E),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.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)}intersectsSphere(e){return this.clampPoint(e.center,rl),rl.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(ol),lu.subVectors(this.max,ol),vs.subVectors(e.a,ol),xs.subVectors(e.b,ol),bs.subVectors(e.c,ol),Dr.subVectors(xs,vs),Lr.subVectors(bs,xs),xo.subVectors(vs,bs);let t=[0,-Dr.z,Dr.y,0,-Lr.z,Lr.y,0,-xo.z,xo.y,Dr.z,0,-Dr.x,Lr.z,0,-Lr.x,xo.z,0,-xo.x,-Dr.y,Dr.x,0,-Lr.y,Lr.x,0,-xo.y,xo.x,0];return!xp(t,vs,xs,bs,lu)||(t=[1,0,0,0,1,0,0,0,1],!xp(t,vs,xs,bs,lu))?!1:(cu.crossVectors(Dr,Lr),t=[cu.x,cu.y,cu.z],xp(t,vs,xs,bs,lu))}clampPoint(e,t){return t===void 0&&(console.warn(\"THREE.Box3: .clampPoint() target is now required\"),t=new E),t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return rl.copy(e).clamp(this.min,this.max).sub(e).length()}getBoundingSphere(e){return e===void 0&&console.error(\"THREE.Box3: .getBoundingSphere() target is now required\"),this.getCenter(e.center),e.radius=this.getSize(rl).length()*.5,e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Qi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Qi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Qi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Qi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Qi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Qi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Qi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Qi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Qi),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)}};On.prototype.isBox3=!0;var Qi=[new E,new E,new E,new E,new E,new E,new E,new E],rl=new E,vp=new On,vs=new E,xs=new E,bs=new E,Dr=new E,Lr=new E,xo=new E,ol=new E,lu=new E,cu=new E,bo=new E;function xp(n,e,t,i,r){for(let o=0,s=n.length-3;o<=s;o+=3){bo.fromArray(n,o);let a=r.x*Math.abs(bo.x)+r.y*Math.abs(bo.y)+r.z*Math.abs(bo.z),l=e.dot(bo),c=t.dot(bo),f=i.dot(bo);if(Math.max(-Math.max(l,c,f),Math.min(l,c,f))>a)return!1}return!0}var n3=new On,wo=class{constructor(e=new E,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let i=this.center;t!==void 0?i.copy(t):n3.setFromPoints(e).getCenter(i);let r=0;for(let o=0,s=e.length;othis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return e===void 0&&(console.warn(\"THREE.Sphere: .getBoundingBox() target is now required\"),e=new On),this.isEmpty()?(e.makeEmpty(),e):(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}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}},Yi=new E,bp=new E,uu=new E,Cr=new E,wp=new E,fu=new E,Mp=new E,Rr=class{constructor(e=new E,t=new E(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===void 0&&(console.warn(\"THREE.Ray: .at() target is now required\"),t=new E),t.copy(this.direction).multiplyScalar(e).add(this.origin)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Yi)),this}closestPointToPoint(e,t){t===void 0&&(console.warn(\"THREE.Ray: .closestPointToPoint() target is now required\"),t=new E),t.subVectors(e,this.origin);let i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(i).add(this.origin)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=Yi.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Yi.copy(this.direction).multiplyScalar(t).add(this.origin),Yi.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){bp.copy(e).add(t).multiplyScalar(.5),uu.copy(t).sub(e).normalize(),Cr.copy(this.origin).sub(bp);let o=e.distanceTo(t)*.5,s=-this.direction.dot(uu),a=Cr.dot(this.direction),l=-Cr.dot(uu),c=Cr.lengthSq(),f=Math.abs(1-s*s),u,h,p,d;if(f>0)if(u=s*l-a,h=s*a-l,d=o*f,u>=0)if(h>=-d)if(h<=d){let g=1/f;u*=g,h*=g,p=u*(u+s*h+2*a)+h*(s*u+h+2*l)+c}else h=o,u=Math.max(0,-(s*h+a)),p=-u*u+h*(h+2*l)+c;else h=-o,u=Math.max(0,-(s*h+a)),p=-u*u+h*(h+2*l)+c;else h<=-d?(u=Math.max(0,-(-s*o+a)),h=u>0?-o:Math.min(Math.max(-o,-l),o),p=-u*u+h*(h+2*l)+c):h<=d?(u=0,h=Math.min(Math.max(-o,-l),o),p=h*(h+2*l)+c):(u=Math.max(0,-(s*o+a)),h=u>0?o:Math.min(Math.max(-o,-l),o),p=-u*u+h*(h+2*l)+c);else h=s>0?-o:o,u=Math.max(0,-(s*h+a)),p=-u*u+h*(h+2*l)+c;return i&&i.copy(this.direction).multiplyScalar(u).add(this.origin),r&&r.copy(uu).multiplyScalar(h).add(bp),p}intersectSphere(e,t){Yi.subVectors(e.center,this.origin);let i=Yi.dot(this.direction),r=Yi.dot(Yi)-i*i,o=e.radius*e.radius;if(r>o)return null;let s=Math.sqrt(o-r),a=i-s,l=i+s;return a<0&&l<0?null:a<0?this.at(l,t):this.at(a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){let i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,r,o,s,a,l,c=1/this.direction.x,f=1/this.direction.y,u=1/this.direction.z,h=this.origin;return c>=0?(i=(e.min.x-h.x)*c,r=(e.max.x-h.x)*c):(i=(e.max.x-h.x)*c,r=(e.min.x-h.x)*c),f>=0?(o=(e.min.y-h.y)*f,s=(e.max.y-h.y)*f):(o=(e.max.y-h.y)*f,s=(e.min.y-h.y)*f),i>s||o>r||((o>i||i!==i)&&(i=o),(s=0?(a=(e.min.z-h.z)*u,l=(e.max.z-h.z)*u):(a=(e.max.z-h.z)*u,l=(e.min.z-h.z)*u),i>l||a>r)||((a>i||i!==i)&&(i=a),(l=0?i:r,t)}intersectsBox(e){return this.intersectBox(e,Yi)!==null}intersectTriangle(e,t,i,r,o){wp.subVectors(t,e),fu.subVectors(i,e),Mp.crossVectors(wp,fu);let s=this.direction.dot(Mp),a;if(s>0){if(r)return null;a=1}else if(s<0)a=-1,s=-s;else return null;Cr.subVectors(this.origin,e);let l=a*this.direction.dot(fu.crossVectors(Cr,fu));if(l<0)return null;let c=a*this.direction.dot(wp.cross(Cr));if(c<0||l+c>s)return null;let f=-a*Cr.dot(Mp);return f<0?null:this.at(f/s,o)}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)}},ve=class{constructor(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error(\"THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.\")}set(e,t,i,r,o,s,a,l,c,f,u,h,p,d,g,v){let y=this.elements;return y[0]=e,y[4]=t,y[8]=i,y[12]=r,y[1]=o,y[5]=s,y[9]=a,y[13]=l,y[2]=c,y[6]=f,y[10]=u,y[14]=h,y[3]=p,y[7]=d,y[11]=g,y[15]=v,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 ve().fromArray(this.elements)}copy(e){let t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){let t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[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,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){let t=this.elements,i=e.elements,r=1/ws.setFromMatrixColumn(e,0).length(),o=1/ws.setFromMatrixColumn(e,1).length(),s=1/ws.setFromMatrixColumn(e,2).length();return t[0]=i[0]*r,t[1]=i[1]*r,t[2]=i[2]*r,t[3]=0,t[4]=i[4]*o,t[5]=i[5]*o,t[6]=i[6]*o,t[7]=0,t[8]=i[8]*s,t[9]=i[9]*s,t[10]=i[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){e&&e.isEuler||console.error(\"THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.\");let t=this.elements,i=e.x,r=e.y,o=e.z,s=Math.cos(i),a=Math.sin(i),l=Math.cos(r),c=Math.sin(r),f=Math.cos(o),u=Math.sin(o);if(e.order===\"XYZ\"){let h=s*f,p=s*u,d=a*f,g=a*u;t[0]=l*f,t[4]=-l*u,t[8]=c,t[1]=p+d*c,t[5]=h-g*c,t[9]=-a*l,t[2]=g-h*c,t[6]=d+p*c,t[10]=s*l}else if(e.order===\"YXZ\"){let h=l*f,p=l*u,d=c*f,g=c*u;t[0]=h+g*a,t[4]=d*a-p,t[8]=s*c,t[1]=s*u,t[5]=s*f,t[9]=-a,t[2]=p*a-d,t[6]=g+h*a,t[10]=s*l}else if(e.order===\"ZXY\"){let h=l*f,p=l*u,d=c*f,g=c*u;t[0]=h-g*a,t[4]=-s*u,t[8]=d+p*a,t[1]=p+d*a,t[5]=s*f,t[9]=g-h*a,t[2]=-s*c,t[6]=a,t[10]=s*l}else if(e.order===\"ZYX\"){let h=s*f,p=s*u,d=a*f,g=a*u;t[0]=l*f,t[4]=d*c-p,t[8]=h*c+g,t[1]=l*u,t[5]=g*c+h,t[9]=p*c-d,t[2]=-c,t[6]=a*l,t[10]=s*l}else if(e.order===\"YZX\"){let h=s*l,p=s*c,d=a*l,g=a*c;t[0]=l*f,t[4]=g-h*u,t[8]=d*u+p,t[1]=u,t[5]=s*f,t[9]=-a*f,t[2]=-c*f,t[6]=p*u+d,t[10]=h-g*u}else if(e.order===\"XZY\"){let h=s*l,p=s*c,d=a*l,g=a*c;t[0]=l*f,t[4]=-u,t[8]=c*f,t[1]=h*u+g,t[5]=s*f,t[9]=p*u-d,t[2]=d*u-p,t[6]=a*f,t[10]=g*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(i3,e,r3)}lookAt(e,t,i){let r=this.elements;return Un.subVectors(e,t),Un.lengthSq()===0&&(Un.z=1),Un.normalize(),Pr.crossVectors(i,Un),Pr.lengthSq()===0&&(Math.abs(i.z)===1?Un.x+=1e-4:Un.z+=1e-4,Un.normalize(),Pr.crossVectors(i,Un)),Pr.normalize(),hu.crossVectors(Un,Pr),r[0]=Pr.x,r[4]=hu.x,r[8]=Un.x,r[1]=Pr.y,r[5]=hu.y,r[9]=Un.y,r[2]=Pr.z,r[6]=hu.z,r[10]=Un.z,this}multiply(e,t){return t!==void 0?(console.warn(\"THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead.\"),this.multiplyMatrices(e,t)):this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let i=e.elements,r=t.elements,o=this.elements,s=i[0],a=i[4],l=i[8],c=i[12],f=i[1],u=i[5],h=i[9],p=i[13],d=i[2],g=i[6],v=i[10],y=i[14],m=i[3],S=i[7],b=i[11],w=i[15],x=r[0],A=r[4],O=r[8],B=r[12],U=r[1],C=r[5],N=r[9],R=r[13],D=r[2],z=r[6],G=r[10],Q=r[14],te=r[3],ee=r[7],ie=r[11],P=r[15];return o[0]=s*x+a*U+l*D+c*te,o[4]=s*A+a*C+l*z+c*ee,o[8]=s*O+a*N+l*G+c*ie,o[12]=s*B+a*R+l*Q+c*P,o[1]=f*x+u*U+h*D+p*te,o[5]=f*A+u*C+h*z+p*ee,o[9]=f*O+u*N+h*G+p*ie,o[13]=f*B+u*R+h*Q+p*P,o[2]=d*x+g*U+v*D+y*te,o[6]=d*A+g*C+v*z+y*ee,o[10]=d*O+g*N+v*G+y*ie,o[14]=d*B+g*R+v*Q+y*P,o[3]=m*x+S*U+b*D+w*te,o[7]=m*A+S*C+b*z+w*ee,o[11]=m*O+S*N+b*G+w*ie,o[15]=m*B+S*R+b*Q+w*P,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],i=e[4],r=e[8],o=e[12],s=e[1],a=e[5],l=e[9],c=e[13],f=e[2],u=e[6],h=e[10],p=e[14],d=e[3],g=e[7],v=e[11],y=e[15];return d*(+o*l*u-r*c*u-o*a*h+i*c*h+r*a*p-i*l*p)+g*(+t*l*p-t*c*h+o*s*h-r*s*p+r*c*f-o*l*f)+v*(+t*c*u-t*a*p-o*s*u+i*s*p+o*a*f-i*c*f)+y*(-r*a*f-t*l*u+t*a*h+r*s*u-i*s*h+i*l*f)}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,i){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=i),this}invert(){let e=this.elements,t=e[0],i=e[1],r=e[2],o=e[3],s=e[4],a=e[5],l=e[6],c=e[7],f=e[8],u=e[9],h=e[10],p=e[11],d=e[12],g=e[13],v=e[14],y=e[15],m=u*v*c-g*h*c+g*l*p-a*v*p-u*l*y+a*h*y,S=d*h*c-f*v*c-d*l*p+s*v*p+f*l*y-s*h*y,b=f*g*c-d*u*c+d*a*p-s*g*p-f*a*y+s*u*y,w=d*u*l-f*g*l-d*a*h+s*g*h+f*a*v-s*u*v,x=t*m+i*S+r*b+o*w;if(x===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let A=1/x;return e[0]=m*A,e[1]=(g*h*o-u*v*o-g*r*p+i*v*p+u*r*y-i*h*y)*A,e[2]=(a*v*o-g*l*o+g*r*c-i*v*c-a*r*y+i*l*y)*A,e[3]=(u*l*o-a*h*o-u*r*c+i*h*c+a*r*p-i*l*p)*A,e[4]=S*A,e[5]=(f*v*o-d*h*o+d*r*p-t*v*p-f*r*y+t*h*y)*A,e[6]=(d*l*o-s*v*o-d*r*c+t*v*c+s*r*y-t*l*y)*A,e[7]=(s*h*o-f*l*o+f*r*c-t*h*c-s*r*p+t*l*p)*A,e[8]=b*A,e[9]=(d*u*o-f*g*o-d*i*p+t*g*p+f*i*y-t*u*y)*A,e[10]=(s*g*o-d*a*o+d*i*c-t*g*c-s*i*y+t*a*y)*A,e[11]=(f*a*o-s*u*o-f*i*c+t*u*c+s*i*p-t*a*p)*A,e[12]=w*A,e[13]=(f*g*r-d*u*r+d*i*h-t*g*h-f*i*v+t*u*v)*A,e[14]=(d*a*r-s*g*r-d*i*l+t*g*l+s*i*v-t*a*v)*A,e[15]=(s*u*r-f*a*r+f*i*l-t*u*l-s*i*h+t*a*h)*A,this}scale(e){let t=this.elements,i=e.x,r=e.y,o=e.z;return t[0]*=i,t[4]*=r,t[8]*=o,t[1]*=i,t[5]*=r,t[9]*=o,t[2]*=i,t[6]*=r,t[10]*=o,t[3]*=i,t[7]*=r,t[11]*=o,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,r))}makeTranslation(e,t,i){return this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let i=Math.cos(t),r=Math.sin(t),o=1-i,s=e.x,a=e.y,l=e.z,c=o*s,f=o*a;return this.set(c*s+i,c*a-r*l,c*l+r*a,0,c*a+r*l,f*a+i,f*l-r*s,0,c*l-r*a,f*l+r*s,o*l*l+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i){return this.set(1,t,i,0,e,1,i,0,e,t,1,0,0,0,0,1),this}compose(e,t,i){let r=this.elements,o=t._x,s=t._y,a=t._z,l=t._w,c=o+o,f=s+s,u=a+a,h=o*c,p=o*f,d=o*u,g=s*f,v=s*u,y=a*u,m=l*c,S=l*f,b=l*u,w=i.x,x=i.y,A=i.z;return r[0]=(1-(g+y))*w,r[1]=(p+b)*w,r[2]=(d-S)*w,r[3]=0,r[4]=(p-b)*x,r[5]=(1-(h+y))*x,r[6]=(v+m)*x,r[7]=0,r[8]=(d+S)*A,r[9]=(v-m)*A,r[10]=(1-(h+g))*A,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,i){let r=this.elements,o=ws.set(r[0],r[1],r[2]).length(),s=ws.set(r[4],r[5],r[6]).length(),a=ws.set(r[8],r[9],r[10]).length();this.determinant()<0&&(o=-o),e.x=r[12],e.y=r[13],e.z=r[14],ui.copy(this);let c=1/o,f=1/s,u=1/a;return ui.elements[0]*=c,ui.elements[1]*=c,ui.elements[2]*=c,ui.elements[4]*=f,ui.elements[5]*=f,ui.elements[6]*=f,ui.elements[8]*=u,ui.elements[9]*=u,ui.elements[10]*=u,t.setFromRotationMatrix(ui),i.x=o,i.y=s,i.z=a,this}makePerspective(e,t,i,r,o,s){s===void 0&&console.warn(\"THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.\");let a=this.elements,l=2*o/(t-e),c=2*o/(i-r),f=(t+e)/(t-e),u=(i+r)/(i-r),h=-(s+o)/(s-o),p=-2*s*o/(s-o);return a[0]=l,a[4]=0,a[8]=f,a[12]=0,a[1]=0,a[5]=c,a[9]=u,a[13]=0,a[2]=0,a[6]=0,a[10]=h,a[14]=p,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(e,t,i,r,o,s){let a=this.elements,l=1/(t-e),c=1/(i-r),f=1/(s-o),u=(t+e)*l,h=(i+r)*c,p=(s+o)*f;return a[0]=2*l,a[4]=0,a[8]=0,a[12]=-u,a[1]=0,a[5]=2*c,a[9]=0,a[13]=-h,a[2]=0,a[6]=0,a[10]=-2*f,a[14]=-p,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this}equals(e){let t=this.elements,i=e.elements;for(let r=0;r<16;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){let i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}};ve.prototype.isMatrix4=!0;var ws=new E,ui=new ve,i3=new E(0,0,0),r3=new E(1,1,1),Pr=new E,hu=new E,Un=new E,X1=new ve,Z1=new qt,ln=class{constructor(e=0,t=0,i=0,r=ln.DefaultOrder){this._x=e,this._y=t,this._z=i,this._order=r}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,i,r){return this._x=e,this._y=t,this._z=i,this._order=r||this._order,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,i){let r=Fe.clamp,o=e.elements,s=o[0],a=o[4],l=o[8],c=o[1],f=o[5],u=o[9],h=o[2],p=o[6],d=o[10];switch(t=t||this._order,t){case\"XYZ\":this._y=Math.asin(r(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,d),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(p,f),this._z=0);break;case\"YXZ\":this._x=Math.asin(-r(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(l,d),this._z=Math.atan2(c,f)):(this._y=Math.atan2(-h,s),this._z=0);break;case\"ZXY\":this._x=Math.asin(r(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(-h,d),this._z=Math.atan2(-a,f)):(this._y=0,this._z=Math.atan2(c,s));break;case\"ZYX\":this._y=Math.asin(-r(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(p,d),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-a,f));break;case\"YZX\":this._z=Math.asin(r(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-u,f),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(l,d));break;case\"XZY\":this._z=Math.asin(-r(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(p,f),this._y=Math.atan2(l,s)):(this._x=Math.atan2(-u,d),this._y=0);break;default:console.warn(\"THREE.Euler: .setFromRotationMatrix() encountered an unknown order: \"+t)}return this._order=t,i!==!1&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return X1.makeRotationFromQuaternion(e),this.setFromRotationMatrix(X1,t,i)}setFromVector3(e,t){return this.set(e.x,e.y,e.z,t||this._order)}reorder(e){return Z1.setFromEuler(this),this.setFromQuaternion(Z1,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[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._order,e}toVector3(e){return e?e.set(this._x,this._y,this._z):new E(this._x,this._y,this._z)}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}};ln.prototype.isEuler=!0;ln.DefaultOrder=\"XYZ\";ln.RotationOrders=[\"XYZ\",\"YZX\",\"ZXY\",\"XZY\",\"YXZ\",\"ZYX\"];var Sp=class{constructor(){this.mask=1|0}set(e){this.mask=1<1){for(let e=0;e1){for(let t=0;t0){i.children=[];for(let s=0;s0){i.animations=[];for(let s=0;s0&&(t.geometries=s),a.length>0&&(t.materials=a),l.length>0&&(t.textures=l),c.length>0&&(t.images=c),f.length>0&&(t.shapes=f),u.length>0&&(t.skeletons=u),h.length>0&&(t.animations=h)}return t.object=i,t;function o(s){let a=[];for(let l in s){let c=s[l];delete c.metadata,a.push(c)}return a}},clone:function(n){return new this.constructor().copy(this,n)},copy:function(n,e=!0){if(this.name=n.name,this.up.copy(n.up),this.position.copy(n.position),this.rotation.order=n.rotation.order,this.quaternion.copy(n.quaternion),this.scale.copy(n.scale),this.matrix.copy(n.matrix),this.matrixWorld.copy(n.matrixWorld),this.matrixAutoUpdate=n.matrixAutoUpdate,this.matrixWorldNeedsUpdate=n.matrixWorldNeedsUpdate,this.layers.mask=n.layers.mask,this.visible=n.visible,this.castShadow=n.castShadow,this.receiveShadow=n.receiveShadow,this.frustumCulled=n.frustumCulled,this.renderOrder=n.renderOrder,this.userData=JSON.parse(JSON.stringify(n.userData)),e===!0)for(let t=0;t1))return t.copy(i).multiplyScalar(o).add(e.start)}intersectsLine(e){let t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e===void 0&&(console.warn(\"THREE.Plane: .coplanarPoint() target is now required\"),e=new E),e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let i=t||u3.getNormalMatrix(e),r=this.coplanarPoint(Ep).applyMatrix4(e),o=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(o),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)}};fi.prototype.isPlane=!0;var hi=new E,Zi=new E,_p=new E,Ji=new E,Ss=new E,Es=new E,ny=new E,Tp=new E,Ap=new E,Dp=new E,At=class{constructor(e=new E,t=new E,i=new E){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,r){r===void 0&&(console.warn(\"THREE.Triangle: .getNormal() target is now required\"),r=new E),r.subVectors(i,t),hi.subVectors(e,t),r.cross(hi);let o=r.lengthSq();return o>0?r.multiplyScalar(1/Math.sqrt(o)):r.set(0,0,0)}static getBarycoord(e,t,i,r,o){hi.subVectors(r,t),Zi.subVectors(i,t),_p.subVectors(e,t);let s=hi.dot(hi),a=hi.dot(Zi),l=hi.dot(_p),c=Zi.dot(Zi),f=Zi.dot(_p),u=s*c-a*a;if(o===void 0&&(console.warn(\"THREE.Triangle: .getBarycoord() target is now required\"),o=new E),u===0)return o.set(-2,-1,-1);let h=1/u,p=(c*l-a*f)*h,d=(s*f-a*l)*h;return o.set(1-p-d,d,p)}static containsPoint(e,t,i,r){return this.getBarycoord(e,t,i,r,Ji),Ji.x>=0&&Ji.y>=0&&Ji.x+Ji.y<=1}static getUV(e,t,i,r,o,s,a,l){return this.getBarycoord(e,t,i,r,Ji),l.set(0,0),l.addScaledVector(o,Ji.x),l.addScaledVector(s,Ji.y),l.addScaledVector(a,Ji.z),l}static isFrontFacing(e,t,i,r){return hi.subVectors(i,t),Zi.subVectors(e,t),hi.cross(Zi).dot(r)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,r){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[r]),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 hi.subVectors(this.c,this.b),Zi.subVectors(this.a,this.b),hi.cross(Zi).length()*.5}getMidpoint(e){return e===void 0&&(console.warn(\"THREE.Triangle: .getMidpoint() target is now required\"),e=new E),e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return At.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e===void 0&&(console.warn(\"THREE.Triangle: .getPlane() target is now required\"),e=new fi),e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return At.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,i,r,o){return At.getUV(e,this.a,this.b,this.c,t,i,r,o)}containsPoint(e){return At.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return At.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){t===void 0&&(console.warn(\"THREE.Triangle: .closestPointToPoint() target is now required\"),t=new E);let i=this.a,r=this.b,o=this.c,s,a;Ss.subVectors(r,i),Es.subVectors(o,i),Tp.subVectors(e,i);let l=Ss.dot(Tp),c=Es.dot(Tp);if(l<=0&&c<=0)return t.copy(i);Ap.subVectors(e,r);let f=Ss.dot(Ap),u=Es.dot(Ap);if(f>=0&&u<=f)return t.copy(r);let h=l*u-f*c;if(h<=0&&l>=0&&f<=0)return s=l/(l-f),t.copy(i).addScaledVector(Ss,s);Dp.subVectors(e,o);let p=Ss.dot(Dp),d=Es.dot(Dp);if(d>=0&&p<=d)return t.copy(o);let g=p*c-l*d;if(g<=0&&c>=0&&d<=0)return a=c/(c-d),t.copy(i).addScaledVector(Es,a);let v=f*d-p*u;if(v<=0&&u-f>=0&&p-d>=0)return ny.subVectors(o,r),a=(u-f)/(u-f+(p-d)),t.copy(r).addScaledVector(ny,a);let y=1/(v+g+h);return s=g*y,a=h*y,t.copy(i).addScaledVector(Ss,s).addScaledVector(Es,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},f3=0;function Dt(){Object.defineProperty(this,\"id\",{value:f3++}),this.uuid=Fe.generateUUID(),this.name=\"\",this.type=\"Material\",this.fog=!0,this.blending=$a,this.side=Jc,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=S1,this.blendDst=E1,this.blendEquation=us,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=rp,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=e3,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=mp,this.stencilZFail=mp,this.stencilZPass=mp,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.alphaTest=0,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0}Dt.prototype=Object.assign(Object.create(Tr.prototype),{constructor:Dt,isMaterial:!0,onBeforeCompile:function(){},customProgramCacheKey:function(){return this.onBeforeCompile.toString()},setValues:function(n){if(n!==void 0)for(let e in n){let t=n[e];if(t===void 0){console.warn(\"THREE.Material: '\"+e+\"' parameter is undefined.\");continue}if(e===\"shading\"){console.warn(\"THREE.\"+this.type+\": .shading has been removed. Use the boolean .flatShading instead.\"),this.flatShading=t===y1;continue}let i=this[e];if(i===void 0){console.warn(\"THREE.\"+this.type+\": '\"+e+\"' is not a property of this material.\");continue}i&&i.isColor?i.set(t):i&&i.isVector3&&t&&t.isVector3?i.copy(t):this[e]=t}},toJSON:function(n){let e=n===void 0||typeof n==\"string\";e&&(n={textures:{},images:{}});let t={metadata:{version:4.5,type:\"Material\",generator:\"Material.toJSON\"}};t.uuid=this.uuid,t.type=this.type,this.name!==\"\"&&(t.name=this.name),this.color&&this.color.isColor&&(t.color=this.color.getHex()),this.roughness!==void 0&&(t.roughness=this.roughness),this.metalness!==void 0&&(t.metalness=this.metalness),this.sheen&&this.sheen.isColor&&(t.sheen=this.sheen.getHex()),this.emissive&&this.emissive.isColor&&(t.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(t.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(t.specular=this.specular.getHex()),this.shininess!==void 0&&(t.shininess=this.shininess),this.clearcoat!==void 0&&(t.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(t.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(t.clearcoatMap=this.clearcoatMap.toJSON(n).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(t.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(n).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(t.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(n).uuid,t.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.map&&this.map.isTexture&&(t.map=this.map.toJSON(n).uuid),this.matcap&&this.matcap.isTexture&&(t.matcap=this.matcap.toJSON(n).uuid),this.alphaMap&&this.alphaMap.isTexture&&(t.alphaMap=this.alphaMap.toJSON(n).uuid),this.lightMap&&this.lightMap.isTexture&&(t.lightMap=this.lightMap.toJSON(n).uuid,t.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(t.aoMap=this.aoMap.toJSON(n).uuid,t.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(t.bumpMap=this.bumpMap.toJSON(n).uuid,t.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(t.normalMap=this.normalMap.toJSON(n).uuid,t.normalMapType=this.normalMapType,t.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(t.displacementMap=this.displacementMap.toJSON(n).uuid,t.displacementScale=this.displacementScale,t.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(t.roughnessMap=this.roughnessMap.toJSON(n).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(t.metalnessMap=this.metalnessMap.toJSON(n).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(t.emissiveMap=this.emissiveMap.toJSON(n).uuid),this.specularMap&&this.specularMap.isTexture&&(t.specularMap=this.specularMap.toJSON(n).uuid),this.envMap&&this.envMap.isTexture&&(t.envMap=this.envMap.toJSON(n).uuid,t.reflectivity=this.reflectivity,t.refractionRatio=this.refractionRatio,this.combine!==void 0&&(t.combine=this.combine),this.envMapIntensity!==void 0&&(t.envMapIntensity=this.envMapIntensity)),this.gradientMap&&this.gradientMap.isTexture&&(t.gradientMap=this.gradientMap.toJSON(n).uuid),this.size!==void 0&&(t.size=this.size),this.sizeAttenuation!==void 0&&(t.sizeAttenuation=this.sizeAttenuation),this.blending!==$a&&(t.blending=this.blending),this.side!==Jc&&(t.side=this.side),this.vertexColors&&(t.vertexColors=!0),this.opacity<1&&(t.opacity=this.opacity),this.transparent===!0&&(t.transparent=this.transparent),t.depthFunc=this.depthFunc,t.depthTest=this.depthTest,t.depthWrite=this.depthWrite,t.stencilWrite=this.stencilWrite,t.stencilWriteMask=this.stencilWriteMask,t.stencilFunc=this.stencilFunc,t.stencilRef=this.stencilRef,t.stencilFuncMask=this.stencilFuncMask,t.stencilFail=this.stencilFail,t.stencilZFail=this.stencilZFail,t.stencilZPass=this.stencilZPass,this.rotation&&this.rotation!==0&&(t.rotation=this.rotation),this.polygonOffset===!0&&(t.polygonOffset=!0),this.polygonOffsetFactor!==0&&(t.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(t.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth&&this.linewidth!==1&&(t.linewidth=this.linewidth),this.dashSize!==void 0&&(t.dashSize=this.dashSize),this.gapSize!==void 0&&(t.gapSize=this.gapSize),this.scale!==void 0&&(t.scale=this.scale),this.dithering===!0&&(t.dithering=!0),this.alphaTest>0&&(t.alphaTest=this.alphaTest),this.premultipliedAlpha===!0&&(t.premultipliedAlpha=this.premultipliedAlpha),this.wireframe===!0&&(t.wireframe=this.wireframe),this.wireframeLinewidth>1&&(t.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==\"round\"&&(t.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==\"round\"&&(t.wireframeLinejoin=this.wireframeLinejoin),this.morphTargets===!0&&(t.morphTargets=!0),this.morphNormals===!0&&(t.morphNormals=!0),this.skinning===!0&&(t.skinning=!0),this.flatShading===!0&&(t.flatShading=this.flatShading),this.visible===!1&&(t.visible=!1),this.toneMapped===!1&&(t.toneMapped=!1),JSON.stringify(this.userData)!==\"{}\"&&(t.userData=this.userData);function i(r){let o=[];for(let s in r){let a=r[s];delete a.metadata,o.push(a)}return o}if(e){let r=i(n.textures),o=i(n.images);r.length>0&&(t.textures=r),o.length>0&&(t.images=o)}return t},clone:function(){return new this.constructor().copy(this)},copy:function(n){this.name=n.name,this.fog=n.fog,this.blending=n.blending,this.side=n.side,this.vertexColors=n.vertexColors,this.opacity=n.opacity,this.transparent=n.transparent,this.blendSrc=n.blendSrc,this.blendDst=n.blendDst,this.blendEquation=n.blendEquation,this.blendSrcAlpha=n.blendSrcAlpha,this.blendDstAlpha=n.blendDstAlpha,this.blendEquationAlpha=n.blendEquationAlpha,this.depthFunc=n.depthFunc,this.depthTest=n.depthTest,this.depthWrite=n.depthWrite,this.stencilWriteMask=n.stencilWriteMask,this.stencilFunc=n.stencilFunc,this.stencilRef=n.stencilRef,this.stencilFuncMask=n.stencilFuncMask,this.stencilFail=n.stencilFail,this.stencilZFail=n.stencilZFail,this.stencilZPass=n.stencilZPass,this.stencilWrite=n.stencilWrite;let e=n.clippingPlanes,t=null;if(e!==null){let i=e.length;t=new Array(i);for(let r=0;r!==i;++r)t[r]=e[r].clone()}return this.clippingPlanes=t,this.clipIntersection=n.clipIntersection,this.clipShadows=n.clipShadows,this.shadowSide=n.shadowSide,this.colorWrite=n.colorWrite,this.precision=n.precision,this.polygonOffset=n.polygonOffset,this.polygonOffsetFactor=n.polygonOffsetFactor,this.polygonOffsetUnits=n.polygonOffsetUnits,this.dithering=n.dithering,this.alphaTest=n.alphaTest,this.premultipliedAlpha=n.premultipliedAlpha,this.visible=n.visible,this.toneMapped=n.toneMapped,this.userData=JSON.parse(JSON.stringify(n.userData)),this},dispose:function(){this.dispatchEvent({type:\"dispose\"})}});Object.defineProperty(Dt.prototype,\"needsUpdate\",{set:function(n){n===!0&&this.version++}});var iy={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},pi={h:0,s:0,l:0},du={h:0,s:0,l:0};function Lp(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}function Cp(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function Rp(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}var Me=class{constructor(e,t,i){return t===void 0&&i===void 0?this.set(e):this.setRGB(e,t,i)}set(e){return e&&e.isColor?this.copy(e):typeof e==\"number\"?this.setHex(e):typeof e==\"string\"&&this.setStyle(e),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,this}setRGB(e,t,i){return this.r=e,this.g=t,this.b=i,this}setHSL(e,t,i){if(e=Fe.euclideanModulo(e,1),t=Fe.clamp(t,0,1),i=Fe.clamp(i,0,1),t===0)this.r=this.g=this.b=i;else{let r=i<=.5?i*(1+t):i+t-i*t,o=2*i-r;this.r=Lp(o,r,e+1/3),this.g=Lp(o,r,e),this.b=Lp(o,r,e-1/3)}return this}setStyle(e){function t(r){r!==void 0&&parseFloat(r)<1&&console.warn(\"THREE.Color: Alpha component of \"+e+\" will be ignored.\")}let i;if(i=/^((?:rgb|hsl)a?)\\(([^\\)]*)\\)/.exec(e)){let r,o=i[1],s=i[2];switch(o){case\"rgb\":case\"rgba\":if(r=/^\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*(?:,\\s*(\\d*\\.?\\d+)\\s*)?$/.exec(s))return this.r=Math.min(255,parseInt(r[1],10))/255,this.g=Math.min(255,parseInt(r[2],10))/255,this.b=Math.min(255,parseInt(r[3],10))/255,t(r[4]),this;if(r=/^\\s*(\\d+)\\%\\s*,\\s*(\\d+)\\%\\s*,\\s*(\\d+)\\%\\s*(?:,\\s*(\\d*\\.?\\d+)\\s*)?$/.exec(s))return this.r=Math.min(100,parseInt(r[1],10))/100,this.g=Math.min(100,parseInt(r[2],10))/100,this.b=Math.min(100,parseInt(r[3],10))/100,t(r[4]),this;break;case\"hsl\":case\"hsla\":if(r=/^\\s*(\\d*\\.?\\d+)\\s*,\\s*(\\d+)\\%\\s*,\\s*(\\d+)\\%\\s*(?:,\\s*(\\d*\\.?\\d+)\\s*)?$/.exec(s)){let a=parseFloat(r[1])/360,l=parseInt(r[2],10)/100,c=parseInt(r[3],10)/100;return t(r[4]),this.setHSL(a,l,c)}break}}else if(i=/^\\#([A-Fa-f\\d]+)$/.exec(e)){let r=i[1],o=r.length;if(o===3)return this.r=parseInt(r.charAt(0)+r.charAt(0),16)/255,this.g=parseInt(r.charAt(1)+r.charAt(1),16)/255,this.b=parseInt(r.charAt(2)+r.charAt(2),16)/255,this;if(o===6)return this.r=parseInt(r.charAt(0)+r.charAt(1),16)/255,this.g=parseInt(r.charAt(2)+r.charAt(3),16)/255,this.b=parseInt(r.charAt(4)+r.charAt(5),16)/255,this}return e&&e.length>0?this.setColorName(e):this}setColorName(e){let t=iy[e];return t!==void 0?this.setHex(t):console.warn(\"THREE.Color: Unknown color \"+e),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}copyGammaToLinear(e,t=2){return this.r=Math.pow(e.r,t),this.g=Math.pow(e.g,t),this.b=Math.pow(e.b,t),this}copyLinearToGamma(e,t=2){let i=t>0?1/t:1;return this.r=Math.pow(e.r,i),this.g=Math.pow(e.g,i),this.b=Math.pow(e.b,i),this}convertGammaToLinear(e){return this.copyGammaToLinear(this,e),this}convertLinearToGamma(e){return this.copyLinearToGamma(this,e),this}copySRGBToLinear(e){return this.r=Cp(e.r),this.g=Cp(e.g),this.b=Cp(e.b),this}copyLinearToSRGB(e){return this.r=Rp(e.r),this.g=Rp(e.g),this.b=Rp(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(){return this.r*255<<16^this.g*255<<8^this.b*255<<0}getHexString(){return(\"000000\"+this.getHex().toString(16)).slice(-6)}getHSL(e){e===void 0&&(console.warn(\"THREE.Color: .getHSL() target is now required\"),e={h:0,s:0,l:0});let t=this.r,i=this.g,r=this.b,o=Math.max(t,i,r),s=Math.min(t,i,r),a,l,c=(s+o)/2;if(s===o)a=0,l=0;else{let f=o-s;switch(l=c<=.5?f/(o+s):f/(2-o-s),o){case t:a=(i-r)/f+(ie&&(e=n[t]);return e}var h3=0,Pi=new ve,Bp=new ke,_s=new E,Gn=new On,cl=new On,Qt=new E;function $e(){Object.defineProperty(this,\"id\",{value:h3++}),this.uuid=Fe.generateUUID(),this.name=\"\",this.type=\"BufferGeometry\",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:Infinity},this.userData={}}$e.prototype=Object.assign(Object.create(Tr.prototype),{constructor:$e,isBufferGeometry:!0,getIndex:function(){return this.index},setIndex:function(n){return Array.isArray(n)?this.index=new(ry(n)>65535?ll:al)(n,1):this.index=n,this},getAttribute:function(n){return this.attributes[n]},setAttribute:function(n,e){return this.attributes[n]=e,this},deleteAttribute:function(n){return delete this.attributes[n],this},hasAttribute:function(n){return this.attributes[n]!==void 0},addGroup:function(n,e,t=0){this.groups.push({start:n,count:e,materialIndex:t})},clearGroups:function(){this.groups=[]},setDrawRange:function(n,e){this.drawRange.start=n,this.drawRange.count=e},applyMatrix4:function(n){let e=this.attributes.position;e!==void 0&&(e.applyMatrix4(n),e.needsUpdate=!0);let t=this.attributes.normal;if(t!==void 0){let r=new Vt().getNormalMatrix(n);t.applyNormalMatrix(r),t.needsUpdate=!0}let i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(n),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this},rotateX:function(n){return Pi.makeRotationX(n),this.applyMatrix4(Pi),this},rotateY:function(n){return Pi.makeRotationY(n),this.applyMatrix4(Pi),this},rotateZ:function(n){return Pi.makeRotationZ(n),this.applyMatrix4(Pi),this},translate:function(n,e,t){return Pi.makeTranslation(n,e,t),this.applyMatrix4(Pi),this},scale:function(n,e,t){return Pi.makeScale(n,e,t),this.applyMatrix4(Pi),this},lookAt:function(n){return Bp.lookAt(n),Bp.updateMatrix(),this.applyMatrix4(Bp.matrix),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(_s).negate(),this.translate(_s.x,_s.y,_s.z),this},setFromPoints:function(n){let e=[];for(let t=0,i=n.length;t0&&(n.userData=this.userData),this.parameters!==void 0){let a=this.parameters;for(let l in a)a[l]!==void 0&&(n[l]=a[l]);return n}n.data={attributes:{}};let e=this.index;e!==null&&(n.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});let t=this.attributes;for(let a in t){let l=t[a],c=l.toJSON(n.data);l.name!==\"\"&&(c.name=l.name),n.data.attributes[a]=c}let i={},r=!1;for(let a in this.morphAttributes){let l=this.morphAttributes[a],c=[];for(let f=0,u=l.length;f0&&(i[a]=c,r=!0)}r&&(n.data.morphAttributes=i,n.data.morphTargetsRelative=this.morphTargetsRelative);let o=this.groups;o.length>0&&(n.data.groups=JSON.parse(JSON.stringify(o)));let s=this.boundingSphere;return s!==null&&(n.data.boundingSphere={center:s.center.toArray(),radius:s.radius}),n},clone:function(){return new $e().copy(this)},copy:function(n){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let e={};this.name=n.name;let t=n.index;t!==null&&this.setIndex(t.clone(e));let i=n.attributes;for(let l in i){let c=i[l];this.setAttribute(l,c.clone(e))}let r=n.morphAttributes;for(let l in r){let c=[],f=r[l];for(let u=0,h=f.length;u0){let i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=i.length;r0&&console.error(\"THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.\")}},raycast:function(n,e){let t=this.geometry,i=this.material,r=this.matrixWorld;if(i===void 0||(t.boundingSphere===null&&t.computeBoundingSphere(),Op.copy(t.boundingSphere),Op.applyMatrix4(r),n.ray.intersectsSphere(Op)===!1)||(oy.copy(r).invert(),Ts.copy(n.ray).applyMatrix4(oy),t.boundingBox!==null&&Ts.intersectsBox(t.boundingBox)===!1))return;let o;if(t.isBufferGeometry){let s=t.index,a=t.attributes.position,l=t.morphAttributes.position,c=t.morphTargetsRelative,f=t.attributes.uv,u=t.attributes.uv2,h=t.groups,p=t.drawRange;if(s!==null)if(Array.isArray(i))for(let d=0,g=h.length;dt.far?null:{distance:c,point:Su.clone(),object:n}}function Eu(n,e,t,i,r,o,s,a,l,c,f,u){kr.fromBufferAttribute(r,c),zr.fromBufferAttribute(r,f),Ir.fromBufferAttribute(r,u);let h=n.morphTargetInfluences;if(e.morphTargets&&o&&h){yu.set(0,0,0),vu.set(0,0,0),xu.set(0,0,0);for(let d=0,g=o.length;d0?1:-1,f.push(ee.x,ee.y,ee.z),u.push(X/A),u.push(1-ie/O),Q+=1}}for(let ie=0;ie0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader;let t={};for(let i in this.extensions)this.extensions[i]===!0&&(t[i]=!0);return Object.keys(t).length>0&&(e.extensions=t),e};function Ls(){ke.call(this),this.type=\"Camera\",this.matrixWorldInverse=new ve,this.projectionMatrix=new ve,this.projectionMatrixInverse=new ve}Ls.prototype=Object.assign(Object.create(ke.prototype),{constructor:Ls,isCamera:!0,copy:function(n,e){return ke.prototype.copy.call(this,n,e),this.matrixWorldInverse.copy(n.matrixWorldInverse),this.projectionMatrix.copy(n.projectionMatrix),this.projectionMatrixInverse.copy(n.projectionMatrixInverse),this},getWorldDirection:function(n){n===void 0&&(console.warn(\"THREE.Camera: .getWorldDirection() target is now required\"),n=new E),this.updateWorldMatrix(!0,!1);let e=this.matrixWorld.elements;return n.set(-e[8],-e[9],-e[10]).normalize()},updateMatrixWorld:function(n){ke.prototype.updateMatrixWorld.call(this,n),this.matrixWorldInverse.copy(this.matrixWorld).invert()},updateWorldMatrix:function(n,e){ke.prototype.updateWorldMatrix.call(this,n,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()},clone:function(){return new this.constructor().copy(this)}});function on(n=50,e=1,t=.1,i=2e3){Ls.call(this),this.type=\"PerspectiveCamera\",this.fov=n,this.zoom=1,this.near=t,this.far=i,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}on.prototype=Object.assign(Object.create(Ls.prototype),{constructor:on,isPerspectiveCamera:!0,copy:function(n,e){return Ls.prototype.copy.call(this,n,e),this.fov=n.fov,this.zoom=n.zoom,this.near=n.near,this.far=n.far,this.focus=n.focus,this.aspect=n.aspect,this.view=n.view===null?null:Object.assign({},n.view),this.filmGauge=n.filmGauge,this.filmOffset=n.filmOffset,this},setFocalLength:function(n){let e=.5*this.getFilmHeight()/n;this.fov=Fe.RAD2DEG*2*Math.atan(e),this.updateProjectionMatrix()},getFocalLength:function(){let n=Math.tan(Fe.DEG2RAD*.5*this.fov);return .5*this.getFilmHeight()/n},getEffectiveFOV:function(){return Fe.RAD2DEG*2*Math.atan(Math.tan(Fe.DEG2RAD*.5*this.fov)/this.zoom)},getFilmWidth:function(){return this.filmGauge*Math.min(this.aspect,1)},getFilmHeight:function(){return this.filmGauge/Math.max(this.aspect,1)},setViewOffset:function(n,e,t,i,r,o){this.aspect=n/e,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=n,this.view.fullHeight=e,this.view.offsetX=t,this.view.offsetY=i,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()},clearViewOffset:function(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){let n=this.near,e=n*Math.tan(Fe.DEG2RAD*.5*this.fov)/this.zoom,t=2*e,i=this.aspect*t,r=-.5*i,o=this.view;if(this.view!==null&&this.view.enabled){let a=o.fullWidth,l=o.fullHeight;r+=o.offsetX*i/a,e-=o.offsetY*t/l,i*=o.width/a,t*=o.height/l}let s=this.filmOffset;s!==0&&(r+=n*s/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,e,e-t,n,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()},toJSON:function(n){let e=ke.prototype.toJSON.call(this,n);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,this.view!==null&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}});var Cs=90,Rs=1,_u=class extends ke{constructor(e,t,i){super();if(this.type=\"CubeCamera\",i.isWebGLCubeRenderTarget!==!0){console.error(\"THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.\");return}this.renderTarget=i;let r=new on(Cs,Rs,e,t);r.layers=this.layers,r.up.set(0,-1,0),r.lookAt(new E(1,0,0)),this.add(r);let o=new on(Cs,Rs,e,t);o.layers=this.layers,o.up.set(0,-1,0),o.lookAt(new E(-1,0,0)),this.add(o);let s=new on(Cs,Rs,e,t);s.layers=this.layers,s.up.set(0,0,1),s.lookAt(new E(0,1,0)),this.add(s);let a=new on(Cs,Rs,e,t);a.layers=this.layers,a.up.set(0,0,-1),a.lookAt(new E(0,-1,0)),this.add(a);let l=new on(Cs,Rs,e,t);l.layers=this.layers,l.up.set(0,-1,0),l.lookAt(new E(0,0,1)),this.add(l);let c=new on(Cs,Rs,e,t);c.layers=this.layers,c.up.set(0,-1,0),c.lookAt(new E(0,0,-1)),this.add(c)}update(e,t){this.parent===null&&this.updateMatrixWorld();let i=this.renderTarget,[r,o,s,a,l,c]=this.children,f=e.xr.enabled,u=e.getRenderTarget();e.xr.enabled=!1;let h=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0),e.render(t,r),e.setRenderTarget(i,1),e.render(t,o),e.setRenderTarget(i,2),e.render(t,s),e.setRenderTarget(i,3),e.render(t,a),e.setRenderTarget(i,4),e.render(t,l),i.texture.generateMipmaps=h,e.setRenderTarget(i,5),e.render(t,c),e.setRenderTarget(u),e.xr.enabled=f}},ul=class extends jt{constructor(e,t,i,r,o,s,a,l,c,f){e=e!==void 0?e:[],t=t!==void 0?t:op,a=a!==void 0?a:vo,super(e,t,i,r,o,s,a,l,c,f),this._needsFlipEnvMap=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}};ul.prototype.isCubeTexture=!0;var Vp=class extends Ar{constructor(e,t,i){Number.isInteger(t)&&(console.warn(\"THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )\"),t=i),super(e,e,t),t=t||{},this.texture=new ul(void 0,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.encoding),this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:nn,this.texture._needsFlipEnvMap=!1}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.format=ci,this.texture.encoding=t.encoding,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let i={uniforms:{tEquirect:{value:null}},vertexShader:`\n\n varying vec3 vWorldDirection;\n\n vec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n }\n\n void main() {\n\n vWorldDirection = transformDirection( position, modelMatrix );\n\n #include \n #include \n\n }\n `,fragmentShader:`\n\n uniform sampler2D tEquirect;\n\n varying vec3 vWorldDirection;\n\n #include \n\n void main() {\n\n vec3 direction = normalize( vWorldDirection );\n\n vec2 sampleUV = equirectUv( direction );\n\n gl_FragColor = texture2D( tEquirect, sampleUV );\n\n }\n `},r=new As(5,5,5),o=new Zn({name:\"CubemapFromEquirect\",uniforms:Ds(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:wt,blending:Ka});o.uniforms.tEquirect.value=t;let s=new St(r,o),a=t.minFilter;return t.minFilter===$c&&(t.minFilter=nn),new _u(1,10,this).update(e,s),t.minFilter=a,s.geometry.dispose(),s.material.dispose(),this}clear(e,t,i,r){let o=e.getRenderTarget();for(let s=0;s<6;s++)e.setRenderTarget(this,s),e.clear(t,i,r);e.setRenderTarget(o)}};Vp.prototype.isWebGLCubeRenderTarget=!0;var Tu=class extends jt{constructor(e,t,i,r,o,s,a,l,c,f,u,h){super(null,s,a,l,c,f,r,o,u,h);this.image={data:e||null,width:t||1,height:i||1},this.magFilter=c!==void 0?c:yn,this.minFilter=f!==void 0?f:yn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}};Tu.prototype.isDataTexture=!0;var Ps=new wo,Au=new E,fl=class{constructor(e=new fi,t=new fi,i=new fi,r=new fi,o=new fi,s=new fi){this.planes=[e,t,i,r,o,s]}set(e,t,i,r,o,s){let a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(i),a[3].copy(r),a[4].copy(o),a[5].copy(s),this}copy(e){let t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e){let t=this.planes,i=e.elements,r=i[0],o=i[1],s=i[2],a=i[3],l=i[4],c=i[5],f=i[6],u=i[7],h=i[8],p=i[9],d=i[10],g=i[11],v=i[12],y=i[13],m=i[14],S=i[15];return t[0].setComponents(a-r,u-l,g-h,S-v).normalize(),t[1].setComponents(a+r,u+l,g+h,S+v).normalize(),t[2].setComponents(a+o,u+c,g+p,S+y).normalize(),t[3].setComponents(a-o,u-c,g-p,S-y).normalize(),t[4].setComponents(a-s,u-f,g-d,S-m).normalize(),t[5].setComponents(a+s,u+f,g+d,S+m).normalize(),this}intersectsObject(e){let t=e.geometry;return t.boundingSphere===null&&t.computeBoundingSphere(),Ps.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(Ps)}intersectsSprite(e){return Ps.center.set(0,0,0),Ps.radius=.7071067811865476,Ps.applyMatrix4(e.matrixWorld),this.intersectsSphere(Ps)}intersectsSphere(e){let t=this.planes,i=e.center,r=-e.radius;for(let o=0;o<6;o++)if(t[o].distanceToPoint(i)0?e.max.x:e.min.x,Au.y=r.normal.y>0?e.max.y:e.min.y,Au.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Au)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};function sy(){let n=null,e=!1,t=null,i=null;function r(o,s){t(o,s),i=n.requestAnimationFrame(r)}return{start:function(){e!==!0&&t!==null&&(i=n.requestAnimationFrame(r),e=!0)},stop:function(){n.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(o){t=o},setContext:function(o){n=o}}}function y3(n,e){let t=e.isWebGL2,i=new WeakMap;function r(c,f){let u=c.array,h=c.usage,p=n.createBuffer();n.bindBuffer(f,p),n.bufferData(f,u,h),c.onUploadCallback();let d=5126;return u instanceof Float32Array?d=5126:u instanceof Float64Array?console.warn(\"THREE.WebGLAttributes: Unsupported data buffer format: Float64Array.\"):u instanceof Uint16Array?c.isFloat16BufferAttribute?t?d=5131:console.warn(\"THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.\"):d=5123:u instanceof Int16Array?d=5122:u instanceof Uint32Array?d=5125:u instanceof Int32Array?d=5124:u instanceof Int8Array?d=5120:u instanceof Uint8Array&&(d=5121),{buffer:p,type:d,bytesPerElement:u.BYTES_PER_ELEMENT,version:c.version}}function o(c,f,u){let h=f.array,p=f.updateRange;n.bindBuffer(u,c),p.count===-1?n.bufferSubData(u,0,h):(t?n.bufferSubData(u,p.offset*h.BYTES_PER_ELEMENT,h,p.offset,p.count):n.bufferSubData(u,p.offset*h.BYTES_PER_ELEMENT,h.subarray(p.offset,p.offset+p.count)),p.count=-1)}function s(c){return c.isInterleavedBufferAttribute&&(c=c.data),i.get(c)}function a(c){c.isInterleavedBufferAttribute&&(c=c.data);let f=i.get(c);f&&(n.deleteBuffer(f.buffer),i.delete(c))}function l(c,f){if(c.isGLBufferAttribute){let h=i.get(c);(!h||h.version 0.0 ) {\n distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n }\n return distanceFalloff;\n#else\n if( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n return pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n }\n return 1.0;\n#endif\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n return RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n float fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n return ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nvec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {\n float fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );\n vec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;\n return Fr * fresnel + F0;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n float a2 = pow2( alpha );\n float gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n float gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n return 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n float a2 = pow2( alpha );\n float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n return 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n float a2 = pow2( alpha );\n float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n return RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n float alpha = pow2( roughness );\n vec3 halfDir = normalize( incidentLight.direction + viewDir );\n float dotNL = saturate( dot( normal, incidentLight.direction ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n vec3 F = F_Schlick( specularColor, dotLH );\n float G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n float D = D_GGX( alpha, dotNH );\n return F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n const float LUT_SIZE = 64.0;\n const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n const float LUT_BIAS = 0.5 / LUT_SIZE;\n float dotNV = saturate( dot( N, V ) );\n vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n uv = uv * LUT_SCALE + LUT_BIAS;\n return uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n float l = length( f );\n return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n float x = dot( v1, v2 );\n float y = abs( x );\n float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n float b = 3.4175940 + ( 4.1616724 + y ) * y;\n float v = a / b;\n float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n return cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n vec3 lightNormal = cross( v1, v2 );\n if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n vec3 T1, T2;\n T1 = normalize( V - N * dot( V, N ) );\n T2 = - cross( N, T1 );\n mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n vec3 coords[ 4 ];\n coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n coords[ 0 ] = normalize( coords[ 0 ] );\n coords[ 1 ] = normalize( coords[ 1 ] );\n coords[ 2 ] = normalize( coords[ 2 ] );\n coords[ 3 ] = normalize( coords[ 3 ] );\n vec3 vectorFormFactor = vec3( 0.0 );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n float result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n return vec3( result );\n}\nvec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n return specularColor * brdf.x + brdf.y;\n}\nvoid BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n vec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );\n vec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n vec3 FssEss = F * brdf.x + brdf.y;\n float Ess = brdf.x + brdf.y;\n float Ems = 1.0 - Ess;\n vec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n singleScatter += FssEss;\n multiScatter += Fms * Ems;\n}\nfloat G_BlinnPhong_Implicit( ) {\n return 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n vec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n float dotNH = saturate( dot( geometry.normal, halfDir ) );\n float dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n vec3 F = F_Schlick( specularColor, dotLH );\n float G = G_BlinnPhong_Implicit( );\n float D = D_BlinnPhong( shininess, dotNH );\n return F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n return ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n return sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie(float roughness, float NoH) {\n float invAlpha = 1.0 / roughness;\n float cos2h = NoH * NoH;\n float sin2h = max(1.0 - cos2h, 0.0078125); return (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n}\nfloat V_Neubelt(float NoV, float NoL) {\n return saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\n}\nvec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {\n vec3 N = geometry.normal;\n vec3 V = geometry.viewDir;\n vec3 H = normalize( V + L );\n float dotNH = saturate( dot( N, H ) );\n return specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );\n}\n#endif`,T3=`#ifdef USE_BUMPMAP\n uniform sampler2D bumpMap;\n uniform float bumpScale;\n vec2 dHdxy_fwd() {\n vec2 dSTdx = dFdx( vUv );\n vec2 dSTdy = dFdy( vUv );\n float Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n float dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n float dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n return vec2( dBx, dBy );\n }\n vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n vec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n vec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n vec3 vN = surf_norm;\n vec3 R1 = cross( vSigmaY, vN );\n vec3 R2 = cross( vN, vSigmaX );\n float fDet = dot( vSigmaX, R1 ) * faceDirection;\n vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n return normalize( abs( fDet ) * surf_norm - vGrad );\n }\n#endif`,A3=`#if NUM_CLIPPING_PLANES > 0\n vec4 plane;\n #pragma unroll_loop_start\n for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n plane = clippingPlanes[ i ];\n if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n }\n #pragma unroll_loop_end\n #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n bool clipped = true;\n #pragma unroll_loop_start\n for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n plane = clippingPlanes[ i ];\n clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n }\n #pragma unroll_loop_end\n if ( clipped ) discard;\n #endif\n#endif`,D3=`#if NUM_CLIPPING_PLANES > 0\n varying vec3 vClipPosition;\n uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif`,L3=`#if NUM_CLIPPING_PLANES > 0\n varying vec3 vClipPosition;\n#endif`,C3=`#if NUM_CLIPPING_PLANES > 0\n vClipPosition = - mvPosition.xyz;\n#endif`,R3=`#ifdef USE_COLOR\n diffuseColor.rgb *= vColor;\n#endif`,P3=`#ifdef USE_COLOR\n varying vec3 vColor;\n#endif`,k3=`#if defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n varying vec3 vColor;\n#endif`,z3=`#if defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n vColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n vColor.xyz *= color.xyz;\n#endif\n#ifdef USE_INSTANCING_COLOR\n vColor.xyz *= instanceColor.xyz;\n#endif`,I3=`#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n const highp float a = 12.9898, b = 78.233, c = 43758.5453;\n highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n return fract(sin(sn) * c);\n}\n#ifdef HIGH_PRECISION\n float precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n float max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }\n float precisionSafeLength( vec3 v ) {\n float maxComponent = max3( abs( v ) );\n return length( v / maxComponent ) * maxComponent;\n }\n#endif\nstruct IncidentLight {\n vec3 color;\n vec3 direction;\n bool visible;\n};\nstruct ReflectedLight {\n vec3 directDiffuse;\n vec3 directSpecular;\n vec3 indirectDiffuse;\n vec3 indirectSpecular;\n};\nstruct GeometricContext {\n vec3 position;\n vec3 normal;\n vec3 viewDir;\n#ifdef CLEARCOAT\n vec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n float distance = dot( planeNormal, point - pointOnPlane );\n return - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n return sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n return lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n mat3 tmp;\n tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n return tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n vec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n return dot( weights, color.rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n return m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n return vec2( u, v );\n}`,F3=`#ifdef ENVMAP_TYPE_CUBE_UV\n #define cubeUV_maxMipLevel 8.0\n #define cubeUV_minMipLevel 4.0\n #define cubeUV_maxTileSize 256.0\n #define cubeUV_minTileSize 16.0\n float getFace( vec3 direction ) {\n vec3 absDirection = abs( direction );\n float face = - 1.0;\n if ( absDirection.x > absDirection.z ) {\n if ( absDirection.x > absDirection.y )\n face = direction.x > 0.0 ? 0.0 : 3.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n } else {\n if ( absDirection.z > absDirection.y )\n face = direction.z > 0.0 ? 2.0 : 5.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n }\n return face;\n }\n vec2 getUV( vec3 direction, float face ) {\n vec2 uv;\n if ( face == 0.0 ) {\n uv = vec2( direction.z, direction.y ) / abs( direction.x );\n } else if ( face == 1.0 ) {\n uv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n } else if ( face == 2.0 ) {\n uv = vec2( - direction.x, direction.y ) / abs( direction.z );\n } else if ( face == 3.0 ) {\n uv = vec2( - direction.z, direction.y ) / abs( direction.x );\n } else if ( face == 4.0 ) {\n uv = vec2( - direction.x, direction.z ) / abs( direction.y );\n } else {\n uv = vec2( direction.x, direction.y ) / abs( direction.z );\n }\n return 0.5 * ( uv + 1.0 );\n }\n vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n float face = getFace( direction );\n float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n mipInt = max( mipInt, cubeUV_minMipLevel );\n float faceSize = exp2( mipInt );\n float texelSize = 1.0 / ( 3.0 * cubeUV_maxTileSize );\n vec2 uv = getUV( direction, face ) * ( faceSize - 1.0 );\n vec2 f = fract( uv );\n uv += 0.5 - f;\n if ( face > 2.0 ) {\n uv.y += faceSize;\n face -= 3.0;\n }\n uv.x += face * faceSize;\n if ( mipInt < cubeUV_maxMipLevel ) {\n uv.y += 2.0 * cubeUV_maxTileSize;\n }\n uv.y += filterInt * 2.0 * cubeUV_minTileSize;\n uv.x += 3.0 * max( 0.0, cubeUV_maxTileSize - 2.0 * faceSize );\n uv *= texelSize;\n vec3 tl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n uv.x += texelSize;\n vec3 tr = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n uv.y += texelSize;\n vec3 br = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n uv.x -= texelSize;\n vec3 bl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n vec3 tm = mix( tl, tr, f.x );\n vec3 bm = mix( bl, br, f.x );\n return mix( tm, bm, f.y );\n }\n #define r0 1.0\n #define v0 0.339\n #define m0 - 2.0\n #define r1 0.8\n #define v1 0.276\n #define m1 - 1.0\n #define r4 0.4\n #define v4 0.046\n #define m4 2.0\n #define r5 0.305\n #define v5 0.016\n #define m5 3.0\n #define r6 0.21\n #define v6 0.0038\n #define m6 4.0\n float roughnessToMip( float roughness ) {\n float mip = 0.0;\n if ( roughness >= r1 ) {\n mip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0;\n } else if ( roughness >= r4 ) {\n mip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1;\n } else if ( roughness >= r5 ) {\n mip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4;\n } else if ( roughness >= r6 ) {\n mip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5;\n } else {\n mip = - 2.0 * log2( 1.16 * roughness ); }\n return mip;\n }\n vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n float mip = clamp( roughnessToMip( roughness ), m0, cubeUV_maxMipLevel );\n float mipF = fract( mip );\n float mipInt = floor( mip );\n vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n if ( mipF == 0.0 ) {\n return vec4( color0, 1.0 );\n } else {\n vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n return vec4( mix( color0, color1, mipF ), 1.0 );\n }\n }\n#endif`,N3=`vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n mat3 m = mat3( instanceMatrix );\n transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n transformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n transformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n #ifdef FLIP_SIDED\n transformedTangent = - transformedTangent;\n #endif\n#endif`,B3=`#ifdef USE_DISPLACEMENTMAP\n uniform sampler2D displacementMap;\n uniform float displacementScale;\n uniform float displacementBias;\n#endif`,O3=`#ifdef USE_DISPLACEMENTMAP\n transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n#endif`,U3=`#ifdef USE_EMISSIVEMAP\n vec4 emissiveColor = texture2D( emissiveMap, vUv );\n emissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n totalEmissiveRadiance *= emissiveColor.rgb;\n#endif`,G3=`#ifdef USE_EMISSIVEMAP\n uniform sampler2D emissiveMap;\n#endif`,W3=\"gl_FragColor = linearToOutputTexel( gl_FragColor );\",H3=`\nvec4 LinearToLinear( in vec4 value ) {\n return value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n return vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n return vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n 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 );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n return vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n float maxComponent = max( max( value.r, value.g ), value.b );\n float fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n return vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n return vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n float maxRGB = max( value.r, max( value.g, value.b ) );\n float M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n M = ceil( M * 255.0 ) / 255.0;\n return vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n return vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n float maxRGB = max( value.r, max( value.g, value.b ) );\n float D = max( maxRange / maxRGB, 1.0 );\n D = clamp( floor( D ) / 255.0, 0.0, 1.0 );\n return vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n vec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n Xp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n vec4 vResult;\n vResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n float Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n vResult.w = fract( Le );\n vResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n return vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n float Le = value.z * 255.0 + value.w;\n vec3 Xp_Y_XYZp;\n Xp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n Xp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n Xp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n vec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n return vec4( max( vRGB, 0.0 ), 1.0 );\n}`,V3=`#ifdef USE_ENVMAP\n #ifdef ENV_WORLDPOS\n vec3 cameraToFrag;\n if ( isOrthographic ) {\n cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n } else {\n cameraToFrag = normalize( vWorldPosition - cameraPosition );\n }\n vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n #ifdef ENVMAP_MODE_REFLECTION\n vec3 reflectVec = reflect( cameraToFrag, worldNormal );\n #else\n vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n #endif\n #else\n vec3 reflectVec = vReflect;\n #endif\n #ifdef ENVMAP_TYPE_CUBE\n vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n #elif defined( ENVMAP_TYPE_CUBE_UV )\n vec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\n #else\n vec4 envColor = vec4( 0.0 );\n #endif\n #ifndef ENVMAP_TYPE_CUBE_UV\n envColor = envMapTexelToLinear( envColor );\n #endif\n #ifdef ENVMAP_BLENDING_MULTIPLY\n outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n #elif defined( ENVMAP_BLENDING_MIX )\n outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n #elif defined( ENVMAP_BLENDING_ADD )\n outgoingLight += envColor.xyz * specularStrength * reflectivity;\n #endif\n#endif`,j3=`#ifdef USE_ENVMAP\n uniform float envMapIntensity;\n uniform float flipEnvMap;\n uniform int maxMipLevel;\n #ifdef ENVMAP_TYPE_CUBE\n uniform samplerCube envMap;\n #else\n uniform sampler2D envMap;\n #endif\n \n#endif`,q3=`#ifdef USE_ENVMAP\n uniform float reflectivity;\n #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n #define ENV_WORLDPOS\n #endif\n #ifdef ENV_WORLDPOS\n varying vec3 vWorldPosition;\n uniform float refractionRatio;\n #else\n varying vec3 vReflect;\n #endif\n#endif`,Q3=`#ifdef USE_ENVMAP\n #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n #define ENV_WORLDPOS\n #endif\n #ifdef ENV_WORLDPOS\n \n varying vec3 vWorldPosition;\n #else\n varying vec3 vReflect;\n uniform float refractionRatio;\n #endif\n#endif`,Y3=`#ifdef USE_ENVMAP\n #ifdef ENV_WORLDPOS\n vWorldPosition = worldPosition.xyz;\n #else\n vec3 cameraToVertex;\n if ( isOrthographic ) {\n cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n } else {\n cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n }\n vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n #ifdef ENVMAP_MODE_REFLECTION\n vReflect = reflect( cameraToVertex, worldNormal );\n #else\n vReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n #endif\n #endif\n#endif`,X3=`#ifdef USE_FOG\n fogDepth = - mvPosition.z;\n#endif`,Z3=`#ifdef USE_FOG\n varying float fogDepth;\n#endif`,J3=`#ifdef USE_FOG\n #ifdef FOG_EXP2\n float fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );\n #else\n float fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n #endif\n gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif`,K3=`#ifdef USE_FOG\n uniform vec3 fogColor;\n varying float fogDepth;\n #ifdef FOG_EXP2\n uniform float fogDensity;\n #else\n uniform float fogNear;\n uniform float fogFar;\n #endif\n#endif`,$3=`#ifdef USE_GRADIENTMAP\n uniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n float dotNL = dot( normal, lightDirection );\n vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n #ifdef USE_GRADIENTMAP\n return texture2D( gradientMap, coord ).rgb;\n #else\n return ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n #endif\n}`,eE=`#ifdef USE_LIGHTMAP\n vec4 lightMapTexel= texture2D( lightMap, vUv2 );\n reflectedLight.indirectDiffuse += PI * lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n#endif`,tE=`#ifdef USE_LIGHTMAP\n uniform sampler2D lightMap;\n uniform float lightMapIntensity;\n#endif`,nE=`vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n vLightBack = vec3( 0.0 );\n vIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\nvIndirectFront += getAmbientLightIrradiance( ambientLightColor );\nvIndirectFront += getLightProbeIrradiance( lightProbe, geometry );\n#ifdef DOUBLE_SIDED\n vIndirectBack += getAmbientLightIrradiance( ambientLightColor );\n vIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry );\n#endif\n#if NUM_POINT_LIGHTS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n getPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n dotNL = dot( geometry.normal, directLight.direction );\n directLightColor_Diffuse = PI * directLight.color;\n vLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n #ifdef DOUBLE_SIDED\n vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n #endif\n }\n #pragma unroll_loop_end\n#endif\n#if NUM_SPOT_LIGHTS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n getSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n dotNL = dot( geometry.normal, directLight.direction );\n directLightColor_Diffuse = PI * directLight.color;\n vLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n #ifdef DOUBLE_SIDED\n vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n #endif\n }\n #pragma unroll_loop_end\n#endif\n#if NUM_DIR_LIGHTS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n getDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n dotNL = dot( geometry.normal, directLight.direction );\n directLightColor_Diffuse = PI * directLight.color;\n vLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n #ifdef DOUBLE_SIDED\n vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n #endif\n }\n #pragma unroll_loop_end\n#endif\n#if NUM_HEMI_LIGHTS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n vIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n #ifdef DOUBLE_SIDED\n vIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n #endif\n }\n #pragma unroll_loop_end\n#endif`,iE=`uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n float x = normal.x, y = normal.y, z = normal.z;\n vec3 result = shCoefficients[ 0 ] * 0.886227;\n result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n return result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {\n vec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n return irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n vec3 irradiance = ambientLightColor;\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n irradiance *= PI;\n #endif\n return irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n struct DirectionalLight {\n vec3 direction;\n vec3 color;\n };\n uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n void getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n directLight.color = directionalLight.color;\n directLight.direction = directionalLight.direction;\n directLight.visible = true;\n }\n#endif\n#if NUM_POINT_LIGHTS > 0\n struct PointLight {\n vec3 position;\n vec3 color;\n float distance;\n float decay;\n };\n uniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n void getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n vec3 lVector = pointLight.position - geometry.position;\n directLight.direction = normalize( lVector );\n float lightDistance = length( lVector );\n directLight.color = pointLight.color;\n directLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n directLight.visible = ( directLight.color != vec3( 0.0 ) );\n }\n#endif\n#if NUM_SPOT_LIGHTS > 0\n struct SpotLight {\n vec3 position;\n vec3 direction;\n vec3 color;\n float distance;\n float decay;\n float coneCos;\n float penumbraCos;\n };\n uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n void getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n vec3 lVector = spotLight.position - geometry.position;\n directLight.direction = normalize( lVector );\n float lightDistance = length( lVector );\n float angleCos = dot( directLight.direction, spotLight.direction );\n if ( angleCos > spotLight.coneCos ) {\n float spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n directLight.color = spotLight.color;\n directLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n directLight.visible = true;\n } else {\n directLight.color = vec3( 0.0 );\n directLight.visible = false;\n }\n }\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n struct RectAreaLight {\n vec3 color;\n vec3 position;\n vec3 halfWidth;\n vec3 halfHeight;\n };\n uniform sampler2D ltc_1; uniform sampler2D ltc_2;\n uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n struct HemisphereLight {\n vec3 direction;\n vec3 skyColor;\n vec3 groundColor;\n };\n uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n float dotNL = dot( geometry.normal, hemiLight.direction );\n float hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n irradiance *= PI;\n #endif\n return irradiance;\n }\n#endif`,rE=`#if defined( USE_ENVMAP )\n #ifdef ENVMAP_MODE_REFRACTION\n uniform float refractionRatio;\n #endif\n vec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n vec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n #ifdef ENVMAP_TYPE_CUBE\n vec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n #ifdef TEXTURE_LOD_EXT\n vec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n #else\n vec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n #endif\n envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n #elif defined( ENVMAP_TYPE_CUBE_UV )\n vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n #else\n vec4 envMapColor = vec4( 0.0 );\n #endif\n return PI * envMapColor.rgb * envMapIntensity;\n }\n float getSpecularMIPLevel( const in float roughness, const in int maxMIPLevel ) {\n float maxMIPLevelScalar = float( maxMIPLevel );\n float sigma = PI * roughness * roughness / ( 1.0 + roughness );\n float desiredMIPLevel = maxMIPLevelScalar + log2( sigma );\n return clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n }\n vec3 getLightProbeIndirectRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) {\n #ifdef ENVMAP_MODE_REFLECTION\n vec3 reflectVec = reflect( -viewDir, normal );\n reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n #else\n vec3 reflectVec = refract( -viewDir, normal, refractionRatio );\n #endif\n reflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n float specularMIPLevel = getSpecularMIPLevel( roughness, maxMIPLevel );\n #ifdef ENVMAP_TYPE_CUBE\n vec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n #ifdef TEXTURE_LOD_EXT\n vec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n #else\n vec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n #endif\n envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n #elif defined( ENVMAP_TYPE_CUBE_UV )\n vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n #endif\n return envMapColor.rgb * envMapIntensity;\n }\n#endif`,oE=`ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;`,sE=`varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\nstruct ToonMaterial {\n vec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n irradiance *= PI;\n #endif\n reflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_Toon\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon\n#define Material_LightProbeLOD( material ) (0)`,aE=`BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;`,lE=`varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n vec3 diffuseColor;\n vec3 specularColor;\n float specularShininess;\n float specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n float dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n irradiance *= PI;\n #endif\n reflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n reflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_BlinnPhong\n#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material ) (0)`,cE=`PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.specularRoughness = max( roughnessFactor, 0.0525 );material.specularRoughness += geometryRoughness;\nmaterial.specularRoughness = min( material.specularRoughness, 1.0 );\n#ifdef REFLECTIVITY\n material.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n#else\n material.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#endif\n#ifdef CLEARCOAT\n material.clearcoat = clearcoat;\n material.clearcoatRoughness = clearcoatRoughness;\n #ifdef USE_CLEARCOATMAP\n material.clearcoat *= texture2D( clearcoatMap, vUv ).x;\n #endif\n #ifdef USE_CLEARCOAT_ROUGHNESSMAP\n material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;\n #endif\n material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n material.clearcoatRoughness += geometryRoughness;\n material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_SHEEN\n material.sheenColor = sheen;\n#endif`,uE=`struct PhysicalMaterial {\n vec3 diffuseColor;\n float specularRoughness;\n vec3 specularColor;\n#ifdef CLEARCOAT\n float clearcoat;\n float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n vec3 sheenColor;\n#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearcoatDHRApprox( const in float roughness, const in float dotNL ) {\n return DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 normal = geometry.normal;\n vec3 viewDir = geometry.viewDir;\n vec3 position = geometry.position;\n vec3 lightPos = rectAreaLight.position;\n vec3 halfWidth = rectAreaLight.halfWidth;\n vec3 halfHeight = rectAreaLight.halfHeight;\n vec3 lightColor = rectAreaLight.color;\n float roughness = material.specularRoughness;\n vec3 rectCoords[ 4 ];\n rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n vec2 uv = LTC_Uv( normal, viewDir, roughness );\n vec4 t1 = texture2D( ltc_1, uv );\n vec4 t2 = texture2D( ltc_2, uv );\n mat3 mInv = mat3(\n vec3( t1.x, 0, t1.y ),\n vec3( 0, 1, 0 ),\n vec3( t1.z, 0, t1.w )\n );\n vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n }\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n float dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n irradiance *= PI;\n #endif\n #ifdef CLEARCOAT\n float ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n vec3 ccIrradiance = ccDotNL * directLight.color;\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n ccIrradiance *= PI;\n #endif\n float clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n reflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n #else\n float clearcoatDHR = 0.0;\n #endif\n #ifdef USE_SHEEN\n reflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(\n material.specularRoughness,\n directLight.direction,\n geometry,\n material.sheenColor\n );\n #else\n reflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);\n #endif\n reflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n #ifdef CLEARCOAT\n float ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n reflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n float ccDotNL = ccDotNV;\n float clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n #else\n float clearcoatDHR = 0.0;\n #endif\n float clearcoatInv = 1.0 - clearcoatDHR;\n vec3 singleScattering = vec3( 0.0 );\n vec3 multiScattering = vec3( 0.0 );\n vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n BRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );\n vec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n reflectedLight.indirectSpecular += clearcoatInv * radiance * singleScattering;\n reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct RE_Direct_Physical\n#define RE_Direct_RectArea RE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular RE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}`,fE=`\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef CLEARCOAT\n geometry.clearcoatNormal = clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n PointLight pointLight;\n #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n PointLightShadow pointLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n pointLight = pointLights[ i ];\n getPointDirectLightIrradiance( pointLight, geometry, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n pointLightShadow = pointLightShadows[ i ];\n directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n #endif\n RE_Direct( directLight, geometry, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n SpotLight spotLight;\n #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n SpotLightShadow spotLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n spotLight = spotLights[ i ];\n getSpotDirectLightIrradiance( spotLight, geometry, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n spotLightShadow = spotLightShadows[ i ];\n directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometry, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n DirectionalLight directionalLight;\n #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n directionalLight = directionalLights[ i ];\n getDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n directionalLightShadow = directionalLightShadows[ i ];\n directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometry, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n RectAreaLight rectAreaLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n rectAreaLight = rectAreaLights[ i ];\n RE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n vec3 iblIrradiance = vec3( 0.0 );\n vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n irradiance += getLightProbeIrradiance( lightProbe, geometry );\n #if ( NUM_HEMI_LIGHTS > 0 )\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n }\n #pragma unroll_loop_end\n #endif\n#endif\n#if defined( RE_IndirectSpecular )\n vec3 radiance = vec3( 0.0 );\n vec3 clearcoatRadiance = vec3( 0.0 );\n#endif`,hE=`#if defined( RE_IndirectDiffuse )\n #ifdef USE_LIGHTMAP\n vec4 lightMapTexel= texture2D( lightMap, vUv2 );\n vec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n lightMapIrradiance *= PI;\n #endif\n irradiance += lightMapIrradiance;\n #endif\n #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n iblIrradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n #endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n radiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel );\n #ifdef CLEARCOAT\n clearcoatRadiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );\n #endif\n#endif`,pE=`#if defined( RE_IndirectDiffuse )\n RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif`,dE=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif`,mE=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n uniform float logDepthBufFC;\n varying float vFragDepth;\n varying float vIsPerspective;\n#endif`,gE=`#ifdef USE_LOGDEPTHBUF\n #ifdef USE_LOGDEPTHBUF_EXT\n varying float vFragDepth;\n varying float vIsPerspective;\n #else\n uniform float logDepthBufFC;\n #endif\n#endif`,yE=`#ifdef USE_LOGDEPTHBUF\n #ifdef USE_LOGDEPTHBUF_EXT\n vFragDepth = 1.0 + gl_Position.w;\n vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n #else\n if ( isPerspectiveMatrix( projectionMatrix ) ) {\n gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n gl_Position.z *= gl_Position.w;\n }\n #endif\n#endif`,vE=`#ifdef USE_MAP\n vec4 texelColor = texture2D( map, vUv );\n texelColor = mapTexelToLinear( texelColor );\n diffuseColor *= texelColor;\n#endif`,xE=`#ifdef USE_MAP\n uniform sampler2D map;\n#endif`,bE=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n#endif\n#ifdef USE_MAP\n vec4 mapTexel = texture2D( map, uv );\n diffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n#ifdef USE_ALPHAMAP\n diffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif`,wE=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n uniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\n uniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n uniform sampler2D alphaMap;\n#endif`,ME=`float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n vec4 texelMetalness = texture2D( metalnessMap, vUv );\n metalnessFactor *= texelMetalness.b;\n#endif`,SE=`#ifdef USE_METALNESSMAP\n uniform sampler2D metalnessMap;\n#endif`,EE=`#ifdef USE_MORPHNORMALS\n objectNormal *= morphTargetBaseInfluence;\n objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n#endif`,_E=`#ifdef USE_MORPHTARGETS\n uniform float morphTargetBaseInfluence;\n #ifndef USE_MORPHNORMALS\n uniform float morphTargetInfluences[ 8 ];\n #else\n uniform float morphTargetInfluences[ 4 ];\n #endif\n#endif`,TE=`#ifdef USE_MORPHTARGETS\n transformed *= morphTargetBaseInfluence;\n transformed += morphTarget0 * morphTargetInfluences[ 0 ];\n transformed += morphTarget1 * morphTargetInfluences[ 1 ];\n transformed += morphTarget2 * morphTargetInfluences[ 2 ];\n transformed += morphTarget3 * morphTargetInfluences[ 3 ];\n #ifndef USE_MORPHNORMALS\n transformed += morphTarget4 * morphTargetInfluences[ 4 ];\n transformed += morphTarget5 * morphTargetInfluences[ 5 ];\n transformed += morphTarget6 * morphTargetInfluences[ 6 ];\n transformed += morphTarget7 * morphTargetInfluences[ 7 ];\n #endif\n#endif`,AE=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n vec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n vec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n vec3 normal = normalize( cross( fdx, fdy ) );\n#else\n vec3 normal = normalize( vNormal );\n #ifdef DOUBLE_SIDED\n normal = normal * faceDirection;\n #endif\n #ifdef USE_TANGENT\n vec3 tangent = normalize( vTangent );\n vec3 bitangent = normalize( vBitangent );\n #ifdef DOUBLE_SIDED\n tangent = tangent * faceDirection;\n bitangent = bitangent * faceDirection;\n #endif\n #if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n mat3 vTBN = mat3( tangent, bitangent, normal );\n #endif\n #endif\n#endif\nvec3 geometryNormal = normal;`,DE=`#ifdef OBJECTSPACE_NORMALMAP\n normal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n #ifdef FLIP_SIDED\n normal = - normal;\n #endif\n #ifdef DOUBLE_SIDED\n normal = normal * faceDirection;\n #endif\n normal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n vec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n mapN.xy *= normalScale;\n #ifdef USE_TANGENT\n normal = normalize( vTBN * mapN );\n #else\n normal = perturbNormal2Arb( -vViewPosition, normal, mapN, faceDirection );\n #endif\n#elif defined( USE_BUMPMAP )\n normal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif`,LE=`#ifdef USE_NORMALMAP\n uniform sampler2D normalMap;\n uniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n uniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {\n vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n vec2 st0 = dFdx( vUv.st );\n vec2 st1 = dFdy( vUv.st );\n vec3 N = surf_norm;\n vec3 q1perp = cross( q1, N );\n vec3 q0perp = cross( N, q0 );\n vec3 T = q1perp * st0.x + q0perp * st1.x;\n vec3 B = q1perp * st0.y + q0perp * st1.y;\n float det = max( dot( T, T ), dot( B, B ) );\n float scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det );\n return normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z );\n }\n#endif`,CE=`#ifdef CLEARCOAT\n vec3 clearcoatNormal = geometryNormal;\n#endif`,RE=`#ifdef USE_CLEARCOAT_NORMALMAP\n vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n clearcoatMapN.xy *= clearcoatNormalScale;\n #ifdef USE_TANGENT\n clearcoatNormal = normalize( vTBN * clearcoatMapN );\n #else\n clearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection );\n #endif\n#endif`,PE=`#ifdef USE_CLEARCOATMAP\n uniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n uniform sampler2D clearcoatRoughnessMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n uniform sampler2D clearcoatNormalMap;\n uniform vec2 clearcoatNormalScale;\n#endif`,kE=`vec3 packNormalToRGB( const in vec3 normal ) {\n return normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n return 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n vec4 r = vec4( fract( v * PackFactors ), v );\n r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n return dot( v, UnpackFactors );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ));\n return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w);\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n return ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n return linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n return (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n return ( near * far ) / ( ( far - near ) * invClipZ - far );\n}`,zE=`#ifdef PREMULTIPLIED_ALPHA\n gl_FragColor.rgb *= gl_FragColor.a;\n#endif`,IE=`vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n mvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;`,FE=`#ifdef DITHERING\n gl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif`,NE=`#ifdef DITHERING\n vec3 dithering( vec3 color ) {\n float grid_position = rand( gl_FragCoord.xy );\n vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n return color + dither_shift_RGB;\n }\n#endif`,BE=`float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n vec4 texelRoughness = texture2D( roughnessMap, vUv );\n roughnessFactor *= texelRoughness.g;\n#endif`,OE=`#ifdef USE_ROUGHNESSMAP\n uniform sampler2D roughnessMap;\n#endif`,UE=`#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n struct DirectionalLightShadow {\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n struct SpotLightShadow {\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n struct PointLightShadow {\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n float shadowCameraNear;\n float shadowCameraFar;\n };\n uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n }\n vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n return unpackRGBATo2Half( texture2D( shadow, uv ) );\n }\n float VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n float occlusion = 1.0;\n vec2 distribution = texture2DDistribution( shadow, uv );\n float hard_shadow = step( compare , distribution.x );\n if (hard_shadow != 1.0 ) {\n float distance = compare - distribution.x ;\n float variance = max( 0.00000, distribution.y * distribution.y );\n float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n }\n return occlusion;\n }\n float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\n shadowCoord.z += shadowBias;\n bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n bool inFrustum = all( inFrustumVec );\n bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n bool frustumTest = all( frustumTestVec );\n if ( frustumTest ) {\n #if defined( SHADOWMAP_TYPE_PCF )\n vec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n float dx0 = - texelSize.x * shadowRadius;\n float dy0 = - texelSize.y * shadowRadius;\n float dx1 = + texelSize.x * shadowRadius;\n float dy1 = + texelSize.y * shadowRadius;\n float dx2 = dx0 / 2.0;\n float dy2 = dy0 / 2.0;\n float dx3 = dx1 / 2.0;\n float dy3 = dy1 / 2.0;\n shadow = (\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n ) * ( 1.0 / 17.0 );\n #elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n vec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n float dx = texelSize.x;\n float dy = texelSize.y;\n vec2 uv = shadowCoord.xy;\n vec2 f = fract( uv * shadowMapSize + 0.5 );\n uv -= f * texelSize;\n shadow = (\n texture2DCompare( shadowMap, uv, shadowCoord.z ) +\n texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), \n texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n f.x ) +\n mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), \n texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n f.x ) +\n mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), \n texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n f.y ) +\n mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), \n texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n f.y ) +\n mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), \n texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n f.x ),\n mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), \n texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n f.x ),\n f.y )\n ) * ( 1.0 / 9.0 );\n #elif defined( SHADOWMAP_TYPE_VSM )\n shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n #else\n shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n #endif\n }\n return shadow;\n }\n vec2 cubeToUV( vec3 v, float texelSizeY ) {\n vec3 absV = abs( v );\n float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n absV *= scaleToCube;\n v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n vec2 planar = v.xy;\n float almostATexel = 1.5 * texelSizeY;\n float almostOne = 1.0 - almostATexel;\n if ( absV.z >= almostOne ) {\n if ( v.z > 0.0 )\n planar.x = 4.0 - v.x;\n } else if ( absV.x >= almostOne ) {\n float signX = sign( v.x );\n planar.x = v.z * signX + 2.0 * signX;\n } else if ( absV.y >= almostOne ) {\n float signY = sign( v.y );\n planar.x = v.x + 2.0 * signY + 2.0;\n planar.y = v.z * signY - 2.0;\n }\n return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n }\n float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n vec3 lightToPosition = shadowCoord.xyz;\n float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;\n vec3 bd3D = normalize( lightToPosition );\n #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n return (\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n ) * ( 1.0 / 9.0 );\n #else\n return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n #endif\n }\n#endif`,GE=`#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n struct DirectionalLightShadow {\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n uniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n struct SpotLightShadow {\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n struct PointLightShadow {\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n float shadowCameraNear;\n float shadowCameraFar;\n };\n uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n#endif`,WE=`#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0\n vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n vec4 shadowWorldPosition;\n #endif\n #if NUM_DIR_LIGHT_SHADOWS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 );\n vSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n #endif\n#endif`,HE=`float getShadowMask() {\n float shadow = 1.0;\n #ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n directionalLight = directionalLightShadows[ i ];\n shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n SpotLightShadow spotLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n spotLight = spotLightShadows[ i ];\n shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n PointLightShadow pointLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n pointLight = pointLightShadows[ i ];\n shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #endif\n return shadow;\n}`,VE=`#ifdef USE_SKINNING\n mat4 boneMatX = getBoneMatrix( skinIndex.x );\n mat4 boneMatY = getBoneMatrix( skinIndex.y );\n mat4 boneMatZ = getBoneMatrix( skinIndex.z );\n mat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif`,jE=`#ifdef USE_SKINNING\n uniform mat4 bindMatrix;\n uniform mat4 bindMatrixInverse;\n #ifdef BONE_TEXTURE\n uniform highp sampler2D boneTexture;\n uniform int boneTextureSize;\n mat4 getBoneMatrix( const in float i ) {\n float j = i * 4.0;\n float x = mod( j, float( boneTextureSize ) );\n float y = floor( j / float( boneTextureSize ) );\n float dx = 1.0 / float( boneTextureSize );\n float dy = 1.0 / float( boneTextureSize );\n y = dy * ( y + 0.5 );\n vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n mat4 bone = mat4( v1, v2, v3, v4 );\n return bone;\n }\n #else\n uniform mat4 boneMatrices[ MAX_BONES ];\n mat4 getBoneMatrix( const in float i ) {\n mat4 bone = boneMatrices[ int(i) ];\n return bone;\n }\n #endif\n#endif`,qE=`#ifdef USE_SKINNING\n vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n vec4 skinned = vec4( 0.0 );\n skinned += boneMatX * skinVertex * skinWeight.x;\n skinned += boneMatY * skinVertex * skinWeight.y;\n skinned += boneMatZ * skinVertex * skinWeight.z;\n skinned += boneMatW * skinVertex * skinWeight.w;\n transformed = ( bindMatrixInverse * skinned ).xyz;\n#endif`,QE=`#ifdef USE_SKINNING\n mat4 skinMatrix = mat4( 0.0 );\n skinMatrix += skinWeight.x * boneMatX;\n skinMatrix += skinWeight.y * boneMatY;\n skinMatrix += skinWeight.z * boneMatZ;\n skinMatrix += skinWeight.w * boneMatW;\n skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n #ifdef USE_TANGENT\n objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n #endif\n#endif`,YE=`float specularStrength;\n#ifdef USE_SPECULARMAP\n vec4 texelSpecular = texture2D( specularMap, vUv );\n specularStrength = texelSpecular.r;\n#else\n specularStrength = 1.0;\n#endif`,XE=`#ifdef USE_SPECULARMAP\n uniform sampler2D specularMap;\n#endif`,ZE=`#if defined( TONE_MAPPING )\n gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif`,JE=`#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n return toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n return saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n color = max( vec3( 0.0 ), color - 0.004 );\n return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n vec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n return a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n const mat3 ACESInputMat = mat3(\n vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),\n vec3( 0.04823, 0.01566, 0.83777 )\n );\n const mat3 ACESOutputMat = mat3(\n vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),\n vec3( -0.07367, -0.00605, 1.07602 )\n );\n color *= toneMappingExposure / 0.6;\n color = ACESInputMat * color;\n color = RRTAndODTFit( color );\n color = ACESOutputMat * color;\n return saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }`,KE=`#ifdef USE_TRANSMISSIONMAP\n totalTransmission *= texture2D( transmissionMap, vUv ).r;\n#endif`,$E=`#ifdef USE_TRANSMISSIONMAP\n uniform sampler2D transmissionMap;\n#endif`,e_=`#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n varying vec2 vUv;\n#endif`,t_=`#ifdef USE_UV\n #ifdef UVS_VERTEX_ONLY\n vec2 vUv;\n #else\n varying vec2 vUv;\n #endif\n uniform mat3 uvTransform;\n#endif`,n_=`#ifdef USE_UV\n vUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif`,i_=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n varying vec2 vUv2;\n#endif`,r_=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n attribute vec2 uv2;\n varying vec2 vUv2;\n uniform mat3 uv2Transform;\n#endif`,o_=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n#endif`,s_=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n vec4 worldPosition = vec4( transformed, 1.0 );\n #ifdef USE_INSTANCING\n worldPosition = instanceMatrix * worldPosition;\n #endif\n worldPosition = modelMatrix * worldPosition;\n#endif`,a_=`uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n vec4 texColor = texture2D( t2D, vUv );\n gl_FragColor = mapTexelToLinear( texColor );\n #include \n #include \n}`,l_=`varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n vUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n gl_Position = vec4( position.xy, 1.0, 1.0 );\n}`,c_=`#include \nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n vec3 vReflect = vWorldDirection;\n #include \n gl_FragColor = envColor;\n gl_FragColor.a *= opacity;\n #include \n #include \n}`,u_=`varying vec3 vWorldDirection;\n#include \nvoid main() {\n vWorldDirection = transformDirection( position, modelMatrix );\n #include \n #include \n gl_Position.z = gl_Position.w;\n}`,f_=`#if DEPTH_PACKING == 3200\n uniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n #include \n vec4 diffuseColor = vec4( 1.0 );\n #if DEPTH_PACKING == 3200\n diffuseColor.a = opacity;\n #endif\n #include \n #include \n #include \n #include \n float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n #if DEPTH_PACKING == 3200\n gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n #elif DEPTH_PACKING == 3201\n gl_FragColor = packDepthToRGBA( fragCoordZ );\n #endif\n}`,h_=`#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n #include \n #include \n #ifdef USE_DISPLACEMENTMAP\n #include \n #include \n #include \n #endif\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vHighPrecisionZW = gl_Position.zw;\n}`,p_=`#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n #include \n vec4 diffuseColor = vec4( 1.0 );\n #include \n #include \n #include \n float dist = length( vWorldPosition - referencePosition );\n dist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n dist = saturate( dist );\n gl_FragColor = packDepthToRGBA( dist );\n}`,d_=`#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #ifdef USE_DISPLACEMENTMAP\n #include \n #include \n #include \n #endif\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vWorldPosition = worldPosition.xyz;\n}`,m_=`uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n vec3 direction = normalize( vWorldDirection );\n vec2 sampleUV = equirectUv( direction );\n vec4 texColor = texture2D( tEquirect, sampleUV );\n gl_FragColor = mapTexelToLinear( texColor );\n #include \n #include \n}`,g_=`varying vec3 vWorldDirection;\n#include \nvoid main() {\n vWorldDirection = transformDirection( position, modelMatrix );\n #include \n #include \n}`,y_=`uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n if ( mod( vLineDistance, totalSize ) > dashSize ) {\n discard;\n }\n vec3 outgoingLight = vec3( 0.0 );\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n #include \n outgoingLight = diffuseColor.rgb;\n gl_FragColor = vec4( outgoingLight, diffuseColor.a );\n #include \n #include \n #include \n #include \n}`,v_=`uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n vLineDistance = scale * lineDistance;\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n}`,x_=`uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n #include \n #include \n #include \n #include \n #include \n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n #ifdef USE_LIGHTMAP\n \n vec4 lightMapTexel= texture2D( lightMap, vUv2 );\n reflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n #else\n reflectedLight.indirectDiffuse += vec3( 1.0 );\n #endif\n #include \n reflectedLight.indirectDiffuse *= diffuseColor.rgb;\n vec3 outgoingLight = reflectedLight.indirectDiffuse;\n #include \n gl_FragColor = vec4( outgoingLight, diffuseColor.a );\n #include \n #include \n #include \n #include \n #include \n}`,b_=`#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #ifdef USE_ENVMAP\n #include \n #include \n #include \n #include \n #endif\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n}`,w_=`uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n varying vec3 vLightBack;\n varying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n vec4 diffuseColor = vec4( diffuse, opacity );\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #ifdef DOUBLE_SIDED\n reflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n #else\n reflectedLight.indirectDiffuse += vIndirectFront;\n #endif\n #include \n reflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n #ifdef DOUBLE_SIDED\n reflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n #else\n reflectedLight.directDiffuse = vLightFront;\n #endif\n reflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n #include \n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n #include \n gl_FragColor = vec4( outgoingLight, diffuseColor.a );\n #include \n #include \n #include \n #include \n #include \n}`,M_=`#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n varying vec3 vLightBack;\n varying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n}`,S_=`#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vec3 viewDir = normalize( vViewPosition );\n vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n vec3 y = cross( viewDir, x );\n vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n #ifdef USE_MATCAP\n vec4 matcapColor = texture2D( matcap, uv );\n matcapColor = matcapTexelToLinear( matcapColor );\n #else\n vec4 matcapColor = vec4( 1.0 );\n #endif\n vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n gl_FragColor = vec4( outgoingLight, diffuseColor.a );\n #include \n #include \n #include \n #include \n #include \n}`,E_=`#define MATCAP\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #ifndef FLAT_SHADED\n vNormal = normalize( transformedNormal );\n #endif\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vViewPosition = - mvPosition.xyz;\n}`,__=`#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n vec4 diffuseColor = vec4( diffuse, opacity );\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n gl_FragColor = vec4( outgoingLight, diffuseColor.a );\n #include \n #include \n #include \n #include \n #include \n}`,T_=`#define TOON\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n#ifndef FLAT_SHADED\n vNormal = normalize( transformedNormal );\n#endif\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vViewPosition = - mvPosition.xyz;\n #include \n #include \n #include \n}`,A_=`#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n vec4 diffuseColor = vec4( diffuse, opacity );\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n #include \n gl_FragColor = vec4( outgoingLight, diffuseColor.a );\n #include \n #include \n #include \n #include \n #include \n}`,D_=`#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n#ifndef FLAT_SHADED\n vNormal = normalize( transformedNormal );\n#endif\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vViewPosition = - mvPosition.xyz;\n #include \n #include \n #include \n #include \n}`,L_=`#define STANDARD\n#ifdef PHYSICAL\n #define REFLECTIVITY\n #define CLEARCOAT\n #define TRANSMISSION\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef TRANSMISSION\n uniform float transmission;\n#endif\n#ifdef REFLECTIVITY\n uniform float reflectivity;\n#endif\n#ifdef CLEARCOAT\n uniform float clearcoat;\n uniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n uniform vec3 sheen;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n #ifdef USE_TANGENT\n varying vec3 vTangent;\n varying vec3 vBitangent;\n #endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n vec4 diffuseColor = vec4( diffuse, opacity );\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #ifdef TRANSMISSION\n float totalTransmission = transmission;\n #endif\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n #ifdef TRANSMISSION\n diffuseColor.a *= mix( saturate( 1. - totalTransmission + linearToRelativeLuminance( reflectedLight.directSpecular + reflectedLight.indirectSpecular ) ), 1.0, metalness );\n #endif\n gl_FragColor = vec4( outgoingLight, diffuseColor.a );\n #include \n #include \n #include \n #include \n #include \n}`,C_=`#define STANDARD\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n #ifdef USE_TANGENT\n varying vec3 vTangent;\n varying vec3 vBitangent;\n #endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n#ifndef FLAT_SHADED\n vNormal = normalize( transformedNormal );\n #ifdef USE_TANGENT\n vTangent = normalize( transformedTangent );\n vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n #endif\n#endif\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vViewPosition = - mvPosition.xyz;\n #include \n #include \n #include \n}`,R_=`#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n varying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n #ifdef USE_TANGENT\n varying vec3 vTangent;\n varying vec3 vBitangent;\n #endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n gl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}`,P_=`#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n varying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n #ifdef USE_TANGENT\n varying vec3 vTangent;\n varying vec3 vBitangent;\n #endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #include \n #include \n#ifndef FLAT_SHADED\n vNormal = normalize( transformedNormal );\n #ifdef USE_TANGENT\n vTangent = normalize( transformedTangent );\n vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n #endif\n#endif\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n vViewPosition = - mvPosition.xyz;\n#endif\n}`,k_=`uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n vec3 outgoingLight = vec3( 0.0 );\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n #include \n #include \n #include \n outgoingLight = diffuseColor.rgb;\n gl_FragColor = vec4( outgoingLight, diffuseColor.a );\n #include \n #include \n #include \n #include \n}`,z_=`uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n gl_PointSize = size;\n #ifdef USE_SIZEATTENUATION\n bool isPerspective = isPerspectiveMatrix( projectionMatrix );\n if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n #endif\n #include \n #include \n #include \n #include \n}`,I_=`uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n #include \n #include \n #include \n}`,F_=`#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n}`,N_=`uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n vec3 outgoingLight = vec3( 0.0 );\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n #include \n #include \n #include \n outgoingLight = diffuseColor.rgb;\n gl_FragColor = vec4( outgoingLight, diffuseColor.a );\n #include \n #include \n #include \n}`,B_=`uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n vec2 scale;\n scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n #ifndef USE_SIZEATTENUATION\n bool isPerspective = isPerspectiveMatrix( projectionMatrix );\n if ( isPerspective ) scale *= - mvPosition.z;\n #endif\n vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n mvPosition.xy += rotatedPosition;\n gl_Position = projectionMatrix * mvPosition;\n #include \n #include \n #include \n}`,Xe={alphamap_fragment:v3,alphamap_pars_fragment:x3,alphatest_fragment:b3,aomap_fragment:w3,aomap_pars_fragment:M3,begin_vertex:S3,beginnormal_vertex:E3,bsdfs:_3,bumpmap_pars_fragment:T3,clipping_planes_fragment:A3,clipping_planes_pars_fragment:D3,clipping_planes_pars_vertex:L3,clipping_planes_vertex:C3,color_fragment:R3,color_pars_fragment:P3,color_pars_vertex:k3,color_vertex:z3,common:I3,cube_uv_reflection_fragment:F3,defaultnormal_vertex:N3,displacementmap_pars_vertex:B3,displacementmap_vertex:O3,emissivemap_fragment:U3,emissivemap_pars_fragment:G3,encodings_fragment:W3,encodings_pars_fragment:H3,envmap_fragment:V3,envmap_common_pars_fragment:j3,envmap_pars_fragment:q3,envmap_pars_vertex:Q3,envmap_physical_pars_fragment:rE,envmap_vertex:Y3,fog_vertex:X3,fog_pars_vertex:Z3,fog_fragment:J3,fog_pars_fragment:K3,gradientmap_pars_fragment:$3,lightmap_fragment:eE,lightmap_pars_fragment:tE,lights_lambert_vertex:nE,lights_pars_begin:iE,lights_toon_fragment:oE,lights_toon_pars_fragment:sE,lights_phong_fragment:aE,lights_phong_pars_fragment:lE,lights_physical_fragment:cE,lights_physical_pars_fragment:uE,lights_fragment_begin:fE,lights_fragment_maps:hE,lights_fragment_end:pE,logdepthbuf_fragment:dE,logdepthbuf_pars_fragment:mE,logdepthbuf_pars_vertex:gE,logdepthbuf_vertex:yE,map_fragment:vE,map_pars_fragment:xE,map_particle_fragment:bE,map_particle_pars_fragment:wE,metalnessmap_fragment:ME,metalnessmap_pars_fragment:SE,morphnormal_vertex:EE,morphtarget_pars_vertex:_E,morphtarget_vertex:TE,normal_fragment_begin:AE,normal_fragment_maps:DE,normalmap_pars_fragment:LE,clearcoat_normal_fragment_begin:CE,clearcoat_normal_fragment_maps:RE,clearcoat_pars_fragment:PE,packing:kE,premultiplied_alpha_fragment:zE,project_vertex:IE,dithering_fragment:FE,dithering_pars_fragment:NE,roughnessmap_fragment:BE,roughnessmap_pars_fragment:OE,shadowmap_pars_fragment:UE,shadowmap_pars_vertex:GE,shadowmap_vertex:WE,shadowmask_pars_fragment:HE,skinbase_vertex:VE,skinning_pars_vertex:jE,skinning_vertex:qE,skinnormal_vertex:QE,specularmap_fragment:YE,specularmap_pars_fragment:XE,tonemapping_fragment:ZE,tonemapping_pars_fragment:JE,transmissionmap_fragment:KE,transmissionmap_pars_fragment:$E,uv_pars_fragment:e_,uv_pars_vertex:t_,uv_vertex:n_,uv2_pars_fragment:i_,uv2_pars_vertex:r_,uv2_vertex:o_,worldpos_vertex:s_,background_frag:a_,background_vert:l_,cube_frag:c_,cube_vert:u_,depth_frag:f_,depth_vert:h_,distanceRGBA_frag:p_,distanceRGBA_vert:d_,equirect_frag:m_,equirect_vert:g_,linedashed_frag:y_,linedashed_vert:v_,meshbasic_frag:x_,meshbasic_vert:b_,meshlambert_frag:w_,meshlambert_vert:M_,meshmatcap_frag:S_,meshmatcap_vert:E_,meshtoon_frag:__,meshtoon_vert:T_,meshphong_frag:A_,meshphong_vert:D_,meshphysical_frag:L_,meshphysical_vert:C_,normal_frag:R_,normal_vert:P_,points_frag:k_,points_vert:z_,shadow_frag:I_,shadow_vert:F_,sprite_frag:N_,sprite_vert:B_},de={common:{diffuse:{value:new Me(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new Vt},uv2Transform:{value:new Vt},alphaMap:{value:null}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},refractionRatio:{value:.98},maxMipLevel:{value:0}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new ne(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Me(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Me(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},uvTransform:{value:new Vt}},sprite:{diffuse:{value:new Me(15658734)},opacity:{value:1},center:{value:new ne(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},uvTransform:{value:new Vt}}},ki={basic:{uniforms:cn([de.common,de.specularmap,de.envmap,de.aomap,de.lightmap,de.fog]),vertexShader:Xe.meshbasic_vert,fragmentShader:Xe.meshbasic_frag},lambert:{uniforms:cn([de.common,de.specularmap,de.envmap,de.aomap,de.lightmap,de.emissivemap,de.fog,de.lights,{emissive:{value:new Me(0)}}]),vertexShader:Xe.meshlambert_vert,fragmentShader:Xe.meshlambert_frag},phong:{uniforms:cn([de.common,de.specularmap,de.envmap,de.aomap,de.lightmap,de.emissivemap,de.bumpmap,de.normalmap,de.displacementmap,de.fog,de.lights,{emissive:{value:new Me(0)},specular:{value:new Me(1118481)},shininess:{value:30}}]),vertexShader:Xe.meshphong_vert,fragmentShader:Xe.meshphong_frag},standard:{uniforms:cn([de.common,de.envmap,de.aomap,de.lightmap,de.emissivemap,de.bumpmap,de.normalmap,de.displacementmap,de.roughnessmap,de.metalnessmap,de.fog,de.lights,{emissive:{value:new Me(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Xe.meshphysical_vert,fragmentShader:Xe.meshphysical_frag},toon:{uniforms:cn([de.common,de.aomap,de.lightmap,de.emissivemap,de.bumpmap,de.normalmap,de.displacementmap,de.gradientmap,de.fog,de.lights,{emissive:{value:new Me(0)}}]),vertexShader:Xe.meshtoon_vert,fragmentShader:Xe.meshtoon_frag},matcap:{uniforms:cn([de.common,de.bumpmap,de.normalmap,de.displacementmap,de.fog,{matcap:{value:null}}]),vertexShader:Xe.meshmatcap_vert,fragmentShader:Xe.meshmatcap_frag},points:{uniforms:cn([de.points,de.fog]),vertexShader:Xe.points_vert,fragmentShader:Xe.points_frag},dashed:{uniforms:cn([de.common,de.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Xe.linedashed_vert,fragmentShader:Xe.linedashed_frag},depth:{uniforms:cn([de.common,de.displacementmap]),vertexShader:Xe.depth_vert,fragmentShader:Xe.depth_frag},normal:{uniforms:cn([de.common,de.bumpmap,de.normalmap,de.displacementmap,{opacity:{value:1}}]),vertexShader:Xe.normal_vert,fragmentShader:Xe.normal_frag},sprite:{uniforms:cn([de.sprite,de.fog]),vertexShader:Xe.sprite_vert,fragmentShader:Xe.sprite_frag},background:{uniforms:{uvTransform:{value:new Vt},t2D:{value:null}},vertexShader:Xe.background_vert,fragmentShader:Xe.background_frag},cube:{uniforms:cn([de.envmap,{opacity:{value:1}}]),vertexShader:Xe.cube_vert,fragmentShader:Xe.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Xe.equirect_vert,fragmentShader:Xe.equirect_frag},distanceRGBA:{uniforms:cn([de.common,de.displacementmap,{referencePosition:{value:new E},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Xe.distanceRGBA_vert,fragmentShader:Xe.distanceRGBA_frag},shadow:{uniforms:cn([de.lights,de.fog,{color:{value:new Me(0)},opacity:{value:1}}]),vertexShader:Xe.shadow_vert,fragmentShader:Xe.shadow_frag}};ki.physical={uniforms:cn([ki.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new ne(1,1)},clearcoatNormalMap:{value:null},sheen:{value:new Me(0)},transmission:{value:0},transmissionMap:{value:null}}]),vertexShader:Xe.meshphysical_vert,fragmentShader:Xe.meshphysical_frag};function O_(n,e,t,i,r){let o=new Me(0),s=0,a,l,c=null,f=0,u=null;function h(d,g,v,y){let m=g.isScene===!0?g.background:null;m&&m.isTexture&&(m=e.get(m));let S=n.xr,b=S.getSession&&S.getSession();b&&b.environmentBlendMode===\"additive\"&&(m=null),m===null?p(o,s):m&&m.isColor&&(p(m,1),y=!0),(n.autoClear||y)&&n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil),m&&(m.isCubeTexture||m.isWebGLCubeRenderTarget||m.mapping===ap)?(l===void 0&&(l=new St(new As(1,1,1),new Zn({name:\"BackgroundCubeMaterial\",uniforms:Ds(ki.cube.uniforms),vertexShader:ki.cube.vertexShader,fragmentShader:ki.cube.fragmentShader,side:wt,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute(\"normal\"),l.geometry.deleteAttribute(\"uv\"),l.onBeforeRender=function(w,x,A){this.matrixWorld.copyPosition(A.matrixWorld)},Object.defineProperty(l.material,\"envMap\",{get:function(){return this.uniforms.envMap.value}}),i.update(l)),m.isWebGLCubeRenderTarget&&(m=m.texture),l.material.uniforms.envMap.value=m,l.material.uniforms.flipEnvMap.value=m.isCubeTexture&&m._needsFlipEnvMap?-1:1,(c!==m||f!==m.version||u!==n.toneMapping)&&(l.material.needsUpdate=!0,c=m,f=m.version,u=n.toneMapping),d.unshift(l,l.geometry,l.material,0,0,null)):m&&m.isTexture&&(a===void 0&&(a=new St(new ay(2,2),new Zn({name:\"BackgroundMaterial\",uniforms:Ds(ki.background.uniforms),vertexShader:ki.background.vertexShader,fragmentShader:ki.background.fragmentShader,side:Jc,depthTest:!1,depthWrite:!1,fog:!1})),a.geometry.deleteAttribute(\"normal\"),Object.defineProperty(a.material,\"map\",{get:function(){return this.uniforms.t2D.value}}),i.update(a)),a.material.uniforms.t2D.value=m,m.matrixAutoUpdate===!0&&m.updateMatrix(),a.material.uniforms.uvTransform.value.copy(m.matrix),(c!==m||f!==m.version||u!==n.toneMapping)&&(a.material.needsUpdate=!0,c=m,f=m.version,u=n.toneMapping),d.unshift(a,a.geometry,a.material,0,0,null))}function p(d,g){t.buffers.color.setClear(d.r,d.g,d.b,g,r)}return{getClearColor:function(){return o},setClearColor:function(d,g=1){o.set(d),s=g,p(o,s)},getClearAlpha:function(){return s},setClearAlpha:function(d){s=d,p(o,s)},render:h}}function U_(n,e,t,i){let r=n.getParameter(34921),o=i.isWebGL2?null:e.get(\"OES_vertex_array_object\"),s=i.isWebGL2||o!==null,a={},l=g(null),c=l;function f(R,D,z,G,Q){let te=!1;if(s){let ee=d(G,z,D);c!==ee&&(c=ee,h(c.object)),te=v(G,Q),te&&y(G,Q)}else{let ee=D.wireframe===!0;(c.geometry!==G.id||c.program!==z.id||c.wireframe!==ee)&&(c.geometry=G.id,c.program=z.id,c.wireframe=ee,te=!0)}R.isInstancedMesh===!0&&(te=!0),Q!==null&&t.update(Q,34963),te&&(A(R,D,z,G),Q!==null&&n.bindBuffer(34963,t.get(Q).buffer))}function u(){return i.isWebGL2?n.createVertexArray():o.createVertexArrayOES()}function h(R){return i.isWebGL2?n.bindVertexArray(R):o.bindVertexArrayOES(R)}function p(R){return i.isWebGL2?n.deleteVertexArray(R):o.deleteVertexArrayOES(R)}function d(R,D,z){let G=z.wireframe===!0,Q=a[R.id];Q===void 0&&(Q={},a[R.id]=Q);let te=Q[D.id];te===void 0&&(te={},Q[D.id]=te);let ee=te[G];return ee===void 0&&(ee=g(u()),te[G]=ee),ee}function g(R){let D=[],z=[],G=[];for(let Q=0;Q=0){let X=Q[ie];if(X!==void 0){let J=X.normalized,W=X.itemSize,j=t.get(X);if(j===void 0)continue;let F=j.buffer,ue=j.type,xe=j.bytesPerElement;if(X.isInterleavedBufferAttribute){let De=X.data,we=De.stride,Ue=X.offset;De&&De.isInstancedInterleavedBuffer?(b(P,De.meshPerAttribute),G._maxInstanceCount===void 0&&(G._maxInstanceCount=De.meshPerAttribute*De.count)):S(P),n.bindBuffer(34962,F),x(P,W,ue,J,we*xe,Ue*xe)}else X.isInstancedBufferAttribute?(b(P,X.meshPerAttribute),G._maxInstanceCount===void 0&&(G._maxInstanceCount=X.meshPerAttribute*X.count)):S(P),n.bindBuffer(34962,F),x(P,W,ue,J,0,0)}else if(ie===\"instanceMatrix\"){let J=t.get(R.instanceMatrix);if(J===void 0)continue;let W=J.buffer,j=J.type;b(P+0,1),b(P+1,1),b(P+2,1),b(P+3,1),n.bindBuffer(34962,W),n.vertexAttribPointer(P+0,4,j,!1,64,0),n.vertexAttribPointer(P+1,4,j,!1,64,16),n.vertexAttribPointer(P+2,4,j,!1,64,32),n.vertexAttribPointer(P+3,4,j,!1,64,48)}else if(ie===\"instanceColor\"){let J=t.get(R.instanceColor);if(J===void 0)continue;let W=J.buffer,j=J.type;b(P,1),n.bindBuffer(34962,W),n.vertexAttribPointer(P,3,j,!1,12,0)}else if(ee!==void 0){let J=ee[ie];if(J!==void 0)switch(J.length){case 2:n.vertexAttrib2fv(P,J);break;case 3:n.vertexAttrib3fv(P,J);break;case 4:n.vertexAttrib4fv(P,J);break;default:n.vertexAttrib1fv(P,J)}}}}w()}function O(){C();for(let R in a){let D=a[R];for(let z in D){let G=D[z];for(let Q in G)p(G[Q].object),delete G[Q];delete D[z]}delete a[R]}}function B(R){if(a[R.id]===void 0)return;let D=a[R.id];for(let z in D){let G=D[z];for(let Q in G)p(G[Q].object),delete G[Q];delete D[z]}delete a[R.id]}function U(R){for(let D in a){let z=a[D];if(z[R.id]===void 0)continue;let G=z[R.id];for(let Q in G)p(G[Q].object),delete G[Q];delete z[R.id]}}function C(){N(),c!==l&&(c=l,h(c.object))}function N(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:f,reset:C,resetDefaultState:N,dispose:O,releaseStatesOfGeometry:B,releaseStatesOfProgram:U,initAttributes:m,enableAttribute:S,disableUnusedAttributes:w}}function G_(n,e,t,i){let r=i.isWebGL2,o;function s(c){o=c}function a(c,f){n.drawArrays(o,c,f),t.update(f,o,1)}function l(c,f,u){if(u===0)return;let h,p;if(r)h=n,p=\"drawArraysInstanced\";else if(h=e.get(\"ANGLE_instanced_arrays\"),p=\"drawArraysInstancedANGLE\",h===null){console.error(\"THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.\");return}h[p](o,c,f,u),t.update(f,o,u)}this.setMode=s,this.render=a,this.renderInstances=l}function W_(n,e,t){let i;function r(){if(i!==void 0)return i;if(e.has(\"EXT_texture_filter_anisotropic\")===!0){let x=e.get(\"EXT_texture_filter_anisotropic\");i=n.getParameter(x.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function o(x){if(x===\"highp\"){if(n.getShaderPrecisionFormat(35633,36338).precision>0&&n.getShaderPrecisionFormat(35632,36338).precision>0)return\"highp\";x=\"mediump\"}return x===\"mediump\"&&n.getShaderPrecisionFormat(35633,36337).precision>0&&n.getShaderPrecisionFormat(35632,36337).precision>0?\"mediump\":\"lowp\"}let s=typeof WebGL2RenderingContext!=\"undefined\"&&n instanceof WebGL2RenderingContext||typeof WebGL2ComputeRenderingContext!=\"undefined\"&&n instanceof WebGL2ComputeRenderingContext,a=t.precision!==void 0?t.precision:\"highp\",l=o(a);l!==a&&(console.warn(\"THREE.WebGLRenderer:\",a,\"not supported, using\",l,\"instead.\"),a=l);let c=t.logarithmicDepthBuffer===!0,f=n.getParameter(34930),u=n.getParameter(35660),h=n.getParameter(3379),p=n.getParameter(34076),d=n.getParameter(34921),g=n.getParameter(36347),v=n.getParameter(36348),y=n.getParameter(36349),m=u>0,S=s||e.has(\"OES_texture_float\"),b=m&&S,w=s?n.getParameter(36183):0;return{isWebGL2:s,getMaxAnisotropy:r,getMaxPrecision:o,precision:a,logarithmicDepthBuffer:c,maxTextures:f,maxVertexTextures:u,maxTextureSize:h,maxCubemapSize:p,maxAttributes:d,maxVertexUniforms:g,maxVaryings:v,maxFragmentUniforms:y,vertexTextures:m,floatFragmentTextures:S,floatVertexTextures:b,maxSamples:w}}function H_(n){let e=this,t=null,i=0,r=!1,o=!1,s=new fi,a=new Vt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(u,h,p){let d=u.length!==0||h||i!==0||r;return r=h,t=f(u,p,0),i=u.length,d},this.beginShadows=function(){o=!0,f(null)},this.endShadows=function(){o=!1,c()},this.setState=function(u,h,p){let d=u.clippingPlanes,g=u.clipIntersection,v=u.clipShadows,y=n.get(u);if(!r||d===null||d.length===0||o&&!v)o?f(null):c();else{let m=o?0:i,S=m*4,b=y.clippingState||null;l.value=b,b=f(d,h,S,p);for(let w=0;w!==S;++w)b[w]=t[w];y.clippingState=b,this.numIntersection=g?this.numPlanes:0,this.numPlanes+=m}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function f(u,h,p,d){let g=u!==null?u.length:0,v=null;if(g!==0){if(v=l.value,d!==!0||v===null){let y=p+g*4,m=h.matrixWorldInverse;a.getNormalMatrix(m),(v===null||v.length0){let c=n.getRenderTarget(),f=new Vp(l.height/2);return f.fromEquirectangularTexture(n,s),e.set(s,f),n.setRenderTarget(c),s.addEventListener(\"dispose\",r),t(f.texture,s.mapping)}else return null}}return s}function r(s){let a=s.target;a.removeEventListener(\"dispose\",r);let l=e.get(a);l!==void 0&&(e.delete(a),l.dispose())}function o(){e=new WeakMap}return{get:i,dispose:o}}function j_(n){let e={};function t(i){if(e[i]!==void 0)return e[i];let r;switch(i){case\"WEBGL_depth_texture\":r=n.getExtension(\"WEBGL_depth_texture\")||n.getExtension(\"MOZ_WEBGL_depth_texture\")||n.getExtension(\"WEBKIT_WEBGL_depth_texture\");break;case\"EXT_texture_filter_anisotropic\":r=n.getExtension(\"EXT_texture_filter_anisotropic\")||n.getExtension(\"MOZ_EXT_texture_filter_anisotropic\")||n.getExtension(\"WEBKIT_EXT_texture_filter_anisotropic\");break;case\"WEBGL_compressed_texture_s3tc\":r=n.getExtension(\"WEBGL_compressed_texture_s3tc\")||n.getExtension(\"MOZ_WEBGL_compressed_texture_s3tc\")||n.getExtension(\"WEBKIT_WEBGL_compressed_texture_s3tc\");break;case\"WEBGL_compressed_texture_pvrtc\":r=n.getExtension(\"WEBGL_compressed_texture_pvrtc\")||n.getExtension(\"WEBKIT_WEBGL_compressed_texture_pvrtc\");break;default:r=n.getExtension(i)}return e[i]=r,r}return{has:function(i){return t(i)!==null},init:function(i){i.isWebGL2?t(\"EXT_color_buffer_float\"):(t(\"WEBGL_depth_texture\"),t(\"OES_texture_float\"),t(\"OES_texture_half_float\"),t(\"OES_texture_half_float_linear\"),t(\"OES_standard_derivatives\"),t(\"OES_element_index_uint\"),t(\"OES_vertex_array_object\"),t(\"ANGLE_instanced_arrays\")),t(\"OES_texture_float_linear\"),t(\"EXT_color_buffer_half_float\")},get:function(i){let r=t(i);return r===null&&console.warn(\"THREE.WebGLRenderer: \"+i+\" extension not supported.\"),r}}}function q_(n,e,t,i){let r={},o=new WeakMap;function s(u){let h=u.target;h.index!==null&&e.remove(h.index);for(let d in h.attributes)e.remove(h.attributes[d]);h.removeEventListener(\"dispose\",s),delete r[h.id];let p=o.get(h);p&&(e.remove(p),o.delete(h)),i.releaseStatesOfGeometry(h),h.isInstancedBufferGeometry===!0&&delete h._maxInstanceCount,t.memory.geometries--}function a(u,h){return r[h.id]===!0||(h.addEventListener(\"dispose\",s),r[h.id]=!0,t.memory.geometries++),h}function l(u){let h=u.attributes;for(let d in h)e.update(h[d],34962);let p=u.morphAttributes;for(let d in p){let g=p[d];for(let v=0,y=g.length;v65535?ll:al)(h,1);v.version=g;let y=o.get(u);y&&e.remove(y),o.set(u,v)}function f(u){let h=o.get(u);if(h){let p=u.index;p!==null&&h.version0)return n;let r=e*t,o=uy[r];if(o===void 0&&(o=new Float32Array(r),uy[r]=o),e!==0){i.toArray(o,0);for(let s=1,a=0;s!==e;++s)a+=t,n[s].toArray(o,a)}return o}function Jn(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t/gm;function Yp(n){return n.replace(GT,WT)}function WT(n,e){let t=Xe[e];if(t===void 0)throw new Error(\"Can not resolve #include <\"+e+\">\");return Yp(t)}var HT=/#pragma unroll_loop[\\s]+?for \\( int i \\= (\\d+)\\; i < (\\d+)\\; i \\+\\+ \\) \\{([\\s\\S]+?)(?=\\})\\}/g,VT=/#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 Ey(n){return n.replace(VT,_y).replace(HT,jT)}function jT(n,e,t,i){return console.warn(\"WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead.\"),_y(n,e,t,i)}function _y(n,e,t,i){let r=\"\";for(let o=parseInt(e);o0?n.gammaFactor:1,p=t.isWebGL2?\"\":BT(t),d=OT(o),g=r.createProgram(),v,y,m=t.glslVersion?\"#version \"+t.glslVersion+`\n`:\"\";t.isRawShaderMaterial?(v=[d].filter(pl).join(`\n`),v.length>0&&(v+=`\n`),y=[p,d].filter(pl).join(`\n`),y.length>0&&(y+=`\n`)):(v=[Ty(t),\"#define SHADER_NAME \"+t.shaderName,d,t.instancing?\"#define USE_INSTANCING\":\"\",t.instancingColor?\"#define USE_INSTANCING_COLOR\":\"\",t.supportsVertexTextures?\"#define VERTEX_TEXTURES\":\"\",\"#define GAMMA_FACTOR \"+h,\"#define MAX_BONES \"+t.maxBones,t.useFog&&t.fog?\"#define USE_FOG\":\"\",t.useFog&&t.fogExp2?\"#define FOG_EXP2\":\"\",t.map?\"#define USE_MAP\":\"\",t.envMap?\"#define USE_ENVMAP\":\"\",t.envMap?\"#define \"+f:\"\",t.lightMap?\"#define USE_LIGHTMAP\":\"\",t.aoMap?\"#define USE_AOMAP\":\"\",t.emissiveMap?\"#define USE_EMISSIVEMAP\":\"\",t.bumpMap?\"#define USE_BUMPMAP\":\"\",t.normalMap?\"#define USE_NORMALMAP\":\"\",t.normalMap&&t.objectSpaceNormalMap?\"#define OBJECTSPACE_NORMALMAP\":\"\",t.normalMap&&t.tangentSpaceNormalMap?\"#define TANGENTSPACE_NORMALMAP\":\"\",t.clearcoatMap?\"#define USE_CLEARCOATMAP\":\"\",t.clearcoatRoughnessMap?\"#define USE_CLEARCOAT_ROUGHNESSMAP\":\"\",t.clearcoatNormalMap?\"#define USE_CLEARCOAT_NORMALMAP\":\"\",t.displacementMap&&t.supportsVertexTextures?\"#define USE_DISPLACEMENTMAP\":\"\",t.specularMap?\"#define USE_SPECULARMAP\":\"\",t.roughnessMap?\"#define USE_ROUGHNESSMAP\":\"\",t.metalnessMap?\"#define USE_METALNESSMAP\":\"\",t.alphaMap?\"#define USE_ALPHAMAP\":\"\",t.transmissionMap?\"#define USE_TRANSMISSIONMAP\":\"\",t.vertexTangents?\"#define USE_TANGENT\":\"\",t.vertexColors?\"#define USE_COLOR\":\"\",t.vertexUvs?\"#define USE_UV\":\"\",t.uvsVertexOnly?\"#define UVS_VERTEX_ONLY\":\"\",t.flatShading?\"#define FLAT_SHADED\":\"\",t.skinning?\"#define USE_SKINNING\":\"\",t.useVertexTexture?\"#define BONE_TEXTURE\":\"\",t.morphTargets?\"#define USE_MORPHTARGETS\":\"\",t.morphNormals&&t.flatShading===!1?\"#define USE_MORPHNORMALS\":\"\",t.doubleSided?\"#define DOUBLE_SIDED\":\"\",t.flipSided?\"#define FLIP_SIDED\":\"\",t.shadowMapEnabled?\"#define USE_SHADOWMAP\":\"\",t.shadowMapEnabled?\"#define \"+l:\"\",t.sizeAttenuation?\"#define USE_SIZEATTENUATION\":\"\",t.logarithmicDepthBuffer?\"#define USE_LOGDEPTHBUF\":\"\",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?\"#define USE_LOGDEPTHBUF_EXT\":\"\",\"uniform mat4 modelMatrix;\",\"uniform mat4 modelViewMatrix;\",\"uniform mat4 projectionMatrix;\",\"uniform mat4 viewMatrix;\",\"uniform mat3 normalMatrix;\",\"uniform vec3 cameraPosition;\",\"uniform bool isOrthographic;\",\"#ifdef USE_INSTANCING\",\" attribute mat4 instanceMatrix;\",\"#endif\",\"#ifdef USE_INSTANCING_COLOR\",\" attribute vec3 instanceColor;\",\"#endif\",\"attribute vec3 position;\",\"attribute vec3 normal;\",\"attribute vec2 uv;\",\"#ifdef USE_TANGENT\",\" attribute vec4 tangent;\",\"#endif\",\"#ifdef USE_COLOR\",\" attribute vec3 color;\",\"#endif\",\"#ifdef USE_MORPHTARGETS\",\" attribute vec3 morphTarget0;\",\" attribute vec3 morphTarget1;\",\" attribute vec3 morphTarget2;\",\" attribute vec3 morphTarget3;\",\" #ifdef USE_MORPHNORMALS\",\" attribute vec3 morphNormal0;\",\" attribute vec3 morphNormal1;\",\" attribute vec3 morphNormal2;\",\" attribute vec3 morphNormal3;\",\" #else\",\" attribute vec3 morphTarget4;\",\" attribute vec3 morphTarget5;\",\" attribute vec3 morphTarget6;\",\" attribute vec3 morphTarget7;\",\" #endif\",\"#endif\",\"#ifdef USE_SKINNING\",\" attribute vec4 skinIndex;\",\" attribute vec4 skinWeight;\",\"#endif\",`\n`].filter(pl).join(`\n`),y=[p,Ty(t),\"#define SHADER_NAME \"+t.shaderName,d,t.alphaTest?\"#define ALPHATEST \"+t.alphaTest+(t.alphaTest%1?\"\":\".0\"):\"\",\"#define GAMMA_FACTOR \"+h,t.useFog&&t.fog?\"#define USE_FOG\":\"\",t.useFog&&t.fogExp2?\"#define FOG_EXP2\":\"\",t.map?\"#define USE_MAP\":\"\",t.matcap?\"#define USE_MATCAP\":\"\",t.envMap?\"#define USE_ENVMAP\":\"\",t.envMap?\"#define \"+c:\"\",t.envMap?\"#define \"+f:\"\",t.envMap?\"#define \"+u:\"\",t.lightMap?\"#define USE_LIGHTMAP\":\"\",t.aoMap?\"#define USE_AOMAP\":\"\",t.emissiveMap?\"#define USE_EMISSIVEMAP\":\"\",t.bumpMap?\"#define USE_BUMPMAP\":\"\",t.normalMap?\"#define USE_NORMALMAP\":\"\",t.normalMap&&t.objectSpaceNormalMap?\"#define OBJECTSPACE_NORMALMAP\":\"\",t.normalMap&&t.tangentSpaceNormalMap?\"#define TANGENTSPACE_NORMALMAP\":\"\",t.clearcoatMap?\"#define USE_CLEARCOATMAP\":\"\",t.clearcoatRoughnessMap?\"#define USE_CLEARCOAT_ROUGHNESSMAP\":\"\",t.clearcoatNormalMap?\"#define USE_CLEARCOAT_NORMALMAP\":\"\",t.specularMap?\"#define USE_SPECULARMAP\":\"\",t.roughnessMap?\"#define USE_ROUGHNESSMAP\":\"\",t.metalnessMap?\"#define USE_METALNESSMAP\":\"\",t.alphaMap?\"#define USE_ALPHAMAP\":\"\",t.sheen?\"#define USE_SHEEN\":\"\",t.transmissionMap?\"#define USE_TRANSMISSIONMAP\":\"\",t.vertexTangents?\"#define USE_TANGENT\":\"\",t.vertexColors||t.instancingColor?\"#define USE_COLOR\":\"\",t.vertexUvs?\"#define USE_UV\":\"\",t.uvsVertexOnly?\"#define UVS_VERTEX_ONLY\":\"\",t.gradientMap?\"#define USE_GRADIENTMAP\":\"\",t.flatShading?\"#define FLAT_SHADED\":\"\",t.doubleSided?\"#define DOUBLE_SIDED\":\"\",t.flipSided?\"#define FLIP_SIDED\":\"\",t.shadowMapEnabled?\"#define USE_SHADOWMAP\":\"\",t.shadowMapEnabled?\"#define \"+l:\"\",t.premultipliedAlpha?\"#define PREMULTIPLIED_ALPHA\":\"\",t.physicallyCorrectLights?\"#define PHYSICALLY_CORRECT_LIGHTS\":\"\",t.logarithmicDepthBuffer?\"#define USE_LOGDEPTHBUF\":\"\",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?\"#define USE_LOGDEPTHBUF_EXT\":\"\",(t.extensionShaderTextureLOD||t.envMap)&&t.rendererExtensionShaderTextureLod?\"#define TEXTURE_LOD_EXT\":\"\",\"uniform mat4 viewMatrix;\",\"uniform vec3 cameraPosition;\",\"uniform bool isOrthographic;\",t.toneMapping!==el?\"#define TONE_MAPPING\":\"\",t.toneMapping!==el?Xe.tonemapping_pars_fragment:\"\",t.toneMapping!==el?NT(\"toneMapping\",t.toneMapping):\"\",t.dithering?\"#define DITHERING\":\"\",Xe.encodings_pars_fragment,t.map?hl(\"mapTexelToLinear\",t.mapEncoding):\"\",t.matcap?hl(\"matcapTexelToLinear\",t.matcapEncoding):\"\",t.envMap?hl(\"envMapTexelToLinear\",t.envMapEncoding):\"\",t.emissiveMap?hl(\"emissiveMapTexelToLinear\",t.emissiveMapEncoding):\"\",t.lightMap?hl(\"lightMapTexelToLinear\",t.lightMapEncoding):\"\",FT(\"linearToOutputTexel\",t.outputEncoding),t.depthPacking?\"#define DEPTH_PACKING \"+t.depthPacking:\"\",`\n`].filter(pl).join(`\n`)),s=Yp(s),s=My(s,t),s=Sy(s,t),a=Yp(a),a=My(a,t),a=Sy(a,t),s=Ey(s),a=Ey(a),t.isWebGL2&&t.isRawShaderMaterial!==!0&&(m=`#version 300 es\n`,v=[\"#define attribute in\",\"#define varying out\",\"#define texture2D texture\"].join(`\n`)+`\n`+v,y=[\"#define varying in\",t.glslVersion===q1?\"\":\"out highp vec4 pc_fragColor;\",t.glslVersion===q1?\"\":\"#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(`\n`)+`\n`+y);let S=m+v+s,b=m+y+a,w=xy(r,35633,S),x=xy(r,35632,b);if(r.attachShader(g,w),r.attachShader(g,x),t.index0AttributeName!==void 0?r.bindAttribLocation(g,0,t.index0AttributeName):t.morphTargets===!0&&r.bindAttribLocation(g,0,\"position\"),r.linkProgram(g),n.debug.checkShaderErrors){let B=r.getProgramInfoLog(g).trim(),U=r.getShaderInfoLog(w).trim(),C=r.getShaderInfoLog(x).trim(),N=!0,R=!0;if(r.getProgramParameter(g,35714)===!1){N=!1;let D=wy(r,w,\"vertex\"),z=wy(r,x,\"fragment\");console.error(\"THREE.WebGLProgram: shader error: \",r.getError(),\"35715\",r.getProgramParameter(g,35715),\"gl.getProgramInfoLog\",B,D,z)}else B!==\"\"?console.warn(\"THREE.WebGLProgram: gl.getProgramInfoLog()\",B):(U===\"\"||C===\"\")&&(R=!1);R&&(this.diagnostics={runnable:N,programLog:B,vertexShader:{log:U,prefix:v},fragmentShader:{log:C,prefix:y}})}r.deleteShader(w),r.deleteShader(x);let A;this.getUniforms=function(){return A===void 0&&(A=new Fr(r,g)),A};let O;return this.getAttributes=function(){return O===void 0&&(O=UT(r,g)),O},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(g),this.program=void 0},this.name=t.shaderName,this.id=zT++,this.cacheKey=e,this.usedTimes=1,this.program=g,this.vertexShader=w,this.fragmentShader=x,this}function JT(n,e,t,i,r,o){let s=[],a=i.isWebGL2,l=i.logarithmicDepthBuffer,c=i.floatVertexTextures,f=i.maxVertexUniforms,u=i.vertexTextures,h=i.precision,p={MeshDepthMaterial:\"depth\",MeshDistanceMaterial:\"distanceRGBA\",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\"},d=[\"precision\",\"isWebGL2\",\"supportsVertexTextures\",\"outputEncoding\",\"instancing\",\"instancingColor\",\"map\",\"mapEncoding\",\"matcap\",\"matcapEncoding\",\"envMap\",\"envMapMode\",\"envMapEncoding\",\"envMapCubeUV\",\"lightMap\",\"lightMapEncoding\",\"aoMap\",\"emissiveMap\",\"emissiveMapEncoding\",\"bumpMap\",\"normalMap\",\"objectSpaceNormalMap\",\"tangentSpaceNormalMap\",\"clearcoatMap\",\"clearcoatRoughnessMap\",\"clearcoatNormalMap\",\"displacementMap\",\"specularMap\",\"roughnessMap\",\"metalnessMap\",\"gradientMap\",\"alphaMap\",\"combine\",\"vertexColors\",\"vertexTangents\",\"vertexUvs\",\"uvsVertexOnly\",\"fog\",\"useFog\",\"fogExp2\",\"flatShading\",\"sizeAttenuation\",\"logarithmicDepthBuffer\",\"skinning\",\"maxBones\",\"useVertexTexture\",\"morphTargets\",\"morphNormals\",\"maxMorphTargets\",\"maxMorphNormals\",\"premultipliedAlpha\",\"numDirLights\",\"numPointLights\",\"numSpotLights\",\"numHemiLights\",\"numRectAreaLights\",\"numDirLightShadows\",\"numPointLightShadows\",\"numSpotLightShadows\",\"shadowMapEnabled\",\"shadowMapType\",\"toneMapping\",\"physicallyCorrectLights\",\"alphaTest\",\"doubleSided\",\"flipSided\",\"numClippingPlanes\",\"numClipIntersection\",\"depthPacking\",\"dithering\",\"sheen\",\"transmissionMap\"];function g(x){let O=x.skeleton.bones;if(c)return 1024;{let U=Math.floor((f-20)/4),C=Math.min(U,O.length);return C0,maxBones:z,useVertexTexture:c,morphTargets:x.morphTargets,morphNormals:x.morphNormals,maxMorphTargets:n.maxMorphTargets,maxMorphNormals:n.maxMorphNormals,numDirLights:A.directional.length,numPointLights:A.point.length,numSpotLights:A.spot.length,numRectAreaLights:A.rectArea.length,numHemiLights:A.hemi.length,numDirLightShadows:A.directionalShadowMap.length,numPointLightShadows:A.pointShadowMap.length,numSpotLightShadows:A.spotShadowMap.length,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:x.dithering,shadowMapEnabled:n.shadowMap.enabled&&O.length>0,shadowMapType:n.shadowMap.type,toneMapping:x.toneMapped?n.toneMapping:el,physicallyCorrectLights:n.physicallyCorrectLights,premultipliedAlpha:x.premultipliedAlpha,alphaTest:x.alphaTest,doubleSided:x.side===li,flipSided:x.side===wt,depthPacking:x.depthPacking!==void 0?x.depthPacking:!1,index0AttributeName:x.index0AttributeName,extensionDerivatives:x.extensions&&x.extensions.derivatives,extensionFragDepth:x.extensions&&x.extensions.fragDepth,extensionDrawBuffers:x.extensions&&x.extensions.drawBuffers,extensionShaderTextureLOD:x.extensions&&x.extensions.shaderTextureLOD,rendererExtensionFragDepth:a||t.has(\"EXT_frag_depth\"),rendererExtensionDrawBuffers:a||t.has(\"WEBGL_draw_buffers\"),rendererExtensionShaderTextureLod:a||t.has(\"EXT_shader_texture_lod\"),customProgramCacheKey:x.customProgramCacheKey()}}function m(x){let A=[];if(x.shaderID?A.push(x.shaderID):(A.push(x.fragmentShader),A.push(x.vertexShader)),x.defines!==void 0)for(let O in x.defines)A.push(O),A.push(x.defines[O]);if(x.isRawShaderMaterial===!1){for(let O=0;O1&&i.sort(h||$T),r.length>1&&r.sort(p||eA)}function u(){for(let h=t,p=e.length;h=e.get(r).length?(s=new Ay(n),e.get(r).push(s)):s=e.get(r)[o],s}function i(){e=new WeakMap}return{get:t,dispose:i}}function nA(){let n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case\"DirectionalLight\":t={direction:new E,color:new Me};break;case\"SpotLight\":t={position:new E,direction:new E,color:new Me,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case\"PointLight\":t={position:new E,color:new Me,distance:0,decay:0};break;case\"HemisphereLight\":t={direction:new E,skyColor:new Me,groundColor:new Me};break;case\"RectAreaLight\":t={color:new Me,position:new E,halfWidth:new E,halfHeight:new E};break}return n[e.id]=t,t}}}function iA(){let n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case\"DirectionalLight\":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ne};break;case\"SpotLight\":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ne};break;case\"PointLight\":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ne,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}var rA=0;function oA(n,e){return(e.castShadow?1:0)-(n.castShadow?1:0)}function sA(n,e){let t=new nA,i=iA(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadow:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]};for(let f=0;f<9;f++)r.probe.push(new E);let o=new E,s=new ve,a=new ve;function l(f){let u=0,h=0,p=0;for(let A=0;A<9;A++)r.probe[A].set(0,0,0);let d=0,g=0,v=0,y=0,m=0,S=0,b=0,w=0;f.sort(oA);for(let A=0,O=f.length;A0&&(e.isWebGL2||n.has(\"OES_texture_float_linear\")===!0?(r.rectAreaLTC1=de.LTC_FLOAT_1,r.rectAreaLTC2=de.LTC_FLOAT_2):n.has(\"OES_texture_half_float_linear\")===!0?(r.rectAreaLTC1=de.LTC_HALF_1,r.rectAreaLTC2=de.LTC_HALF_2):console.error(\"THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.\")),r.ambient[0]=u,r.ambient[1]=h,r.ambient[2]=p;let x=r.hash;(x.directionalLength!==d||x.pointLength!==g||x.spotLength!==v||x.rectAreaLength!==y||x.hemiLength!==m||x.numDirectionalShadows!==S||x.numPointShadows!==b||x.numSpotShadows!==w)&&(r.directional.length=d,r.spot.length=v,r.rectArea.length=y,r.point.length=g,r.hemi.length=m,r.directionalShadow.length=S,r.directionalShadowMap.length=S,r.pointShadow.length=b,r.pointShadowMap.length=b,r.spotShadow.length=w,r.spotShadowMap.length=w,r.directionalShadowMatrix.length=S,r.pointShadowMatrix.length=b,r.spotShadowMatrix.length=w,x.directionalLength=d,x.pointLength=g,x.spotLength=v,x.rectAreaLength=y,x.hemiLength=m,x.numDirectionalShadows=S,x.numPointShadows=b,x.numSpotShadows=w,r.version=rA++)}function c(f,u){let h=0,p=0,d=0,g=0,v=0,y=u.matrixWorldInverse;for(let m=0,S=f.length;m=t.get(o).length?(a=new Dy(n,e),t.get(o).push(a)):a=t.get(o)[s],a}function r(){t=new WeakMap}return{get:i,dispose:r}}var Xp=class extends Dt{constructor(e){super();this.type=\"MeshDepthMaterial\",this.depthPacking=JS,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.skinning=e.skinning,this.morphTargets=e.morphTargets,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}};Xp.prototype.isMeshDepthMaterial=!0;var Zp=class extends Dt{constructor(e){super();this.type=\"MeshDistanceMaterial\",this.referencePosition=new E,this.nearDistance=1,this.farDistance=1e3,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.setValues(e)}copy(e){return super.copy(e),this.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}};Zp.prototype.isMeshDistanceMaterial=!0;var lA=`uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include \nvoid main() {\n float mean = 0.0;\n float squared_mean = 0.0;\n float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy ) / resolution ) );\n for ( float i = -1.0; i < 1.0 ; i += SAMPLE_RATE) {\n #ifdef HORIZONTAL_PASS\n vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( i, 0.0 ) * radius ) / resolution ) );\n mean += distribution.x;\n squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n #else\n float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, i ) * radius ) / resolution ) );\n mean += depth;\n squared_mean += depth * depth;\n #endif\n }\n mean = mean * HALF_SAMPLE_RATE;\n squared_mean = squared_mean * HALF_SAMPLE_RATE;\n float std_dev = sqrt( squared_mean - mean * mean );\n gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}`,cA=`void main() {\n gl_Position = vec4( position, 1.0 );\n}`;function Ly(n,e,t){let i=new fl,r=new ne,o=new ne,s=new ut,a=[],l=[],c={},f={0:wt,1:Jc,2:li},u=new Zn({defines:{SAMPLE_RATE:2/8,HALF_SAMPLE_RATE:1/8},uniforms:{shadow_pass:{value:null},resolution:{value:new ne},radius:{value:4}},vertexShader:cA,fragmentShader:lA}),h=u.clone();h.defines.HORIZONTAL_PASS=1;let p=new $e;p.setAttribute(\"position\",new Ne(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let d=new St(p,u),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=g1,this.render=function(w,x,A){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||w.length===0)return;let O=n.getRenderTarget(),B=n.getActiveCubeFace(),U=n.getActiveMipmapLevel(),C=n.state;C.setBlending(Ka),C.buffers.color.setClear(1,1,1,1),C.buffers.depth.setTest(!0),C.setScissorTest(!1);for(let N=0,R=w.length;Nt||r.y>t)&&(r.x>t&&(o.x=Math.floor(t/G.x),r.x=o.x*G.x,z.mapSize.x=o.x),r.y>t&&(o.y=Math.floor(t/G.y),r.y=o.y*G.y,z.mapSize.y=o.y)),z.map===null&&!z.isPointLightShadow&&this.type===Ja){let te={minFilter:nn,magFilter:nn,format:ci};z.map=new Ar(r.x,r.y,te),z.map.texture.name=D.name+\".shadowMap\",z.mapPass=new Ar(r.x,r.y,te),z.camera.updateProjectionMatrix()}if(z.map===null){let te={minFilter:yn,magFilter:yn,format:ci};z.map=new Ar(r.x,r.y,te),z.map.texture.name=D.name+\".shadowMap\",z.camera.updateProjectionMatrix()}n.setRenderTarget(z.map),n.clear();let Q=z.getViewportCount();for(let te=0;te0);let G=!1;w.isSkinnedMesh===!0&&(A.skinning===!0?G=!0:console.warn(\"THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:\",w));let Q=w.isInstancedMesh===!0;N=R(z,G,Q)}else N=D;if(n.localClippingEnabled&&A.clipShadows===!0&&A.clippingPlanes.length!==0){let z=N.uuid,G=A.uuid,Q=c[z];Q===void 0&&(Q={},c[z]=Q);let te=Q[G];te===void 0&&(te=N.clone(),Q[G]=te),N=te}return N.visible=A.visible,N.wireframe=A.wireframe,C===Ja?N.side=A.shadowSide!==null?A.shadowSide:A.side:N.side=A.shadowSide!==null?A.shadowSide:f[A.side],N.clipShadows=A.clipShadows,N.clippingPlanes=A.clippingPlanes,N.clipIntersection=A.clipIntersection,N.wireframeLinewidth=A.wireframeLinewidth,N.linewidth=A.linewidth,O.isPointLight===!0&&N.isMeshDistanceMaterial===!0&&(N.referencePosition.setFromMatrixPosition(O.matrixWorld),N.nearDistance=B,N.farDistance=U),N}function b(w,x,A,O,B){if(w.visible===!1)return;if(w.layers.test(x.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&B===Ja)&&(!w.frustumCulled||i.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,w.matrixWorld);let N=e.update(w),R=w.material;if(Array.isArray(R)){let D=N.groups;for(let z=0,G=D.length;z=1):R.indexOf(\"OpenGL ES\")!==-1&&(N=parseFloat(/^OpenGL ES (\\d)/.exec(R)[1]),C=N>=2);let D=null,z={},G=new ut,Q=new ut;function te(I,ae,ge){let be=new Uint8Array(4),oe=n.createTexture();n.bindTexture(I,oe),n.texParameteri(I,10241,9728),n.texParameteri(I,10240,9728);for(let Le=0;Le$||L.height>$)&&(I=$/Math.max(L.width,L.height)),I<1||_===!0)if(typeof HTMLImageElement!=\"undefined\"&&L instanceof HTMLImageElement||typeof HTMLCanvasElement!=\"undefined\"&&L instanceof HTMLCanvasElement||typeof ImageBitmap!=\"undefined\"&&L instanceof ImageBitmap){let ae=_?Fe.floorPowerOfTwo:Math.floor,ge=ae(I*L.width),be=ae(I*L.height);p===void 0&&(p=g(ge,be));let oe=Z?g(ge,be):p;return oe.width=ge,oe.height=be,oe.getContext(\"2d\").drawImage(L,0,0,ge,be),console.warn(\"THREE.WebGLRenderer: Texture has been resized from (\"+L.width+\"x\"+L.height+\") to (\"+ge+\"x\"+be+\").\"),oe}else return\"data\"in L&&console.warn(\"THREE.WebGLRenderer: Image in DataTexture is too big (\"+L.width+\"x\"+L.height+\").\"),L;return L}function y(L){return Fe.isPowerOfTwo(L.width)&&Fe.isPowerOfTwo(L.height)}function m(L){return a?!1:L.wrapS!==Bn||L.wrapT!==Bn||L.minFilter!==yn&&L.minFilter!==nn}function S(L,_){return L.generateMipmaps&&_&&L.minFilter!==yn&&L.minFilter!==nn}function b(L,_,Z,$){n.generateMipmap(L);let I=i.get(_);I.__maxMipLevel=Math.log2(Math.max(Z,$))}function w(L,_,Z){if(a===!1)return _;if(L!==null){if(n[L]!==void 0)return n[L];console.warn(\"THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '\"+L+\"'\")}let $=_;return _===6403&&(Z===5126&&($=33326),Z===5131&&($=33325),Z===5121&&($=33321)),_===6407&&(Z===5126&&($=34837),Z===5131&&($=34843),Z===5121&&($=32849)),_===6408&&(Z===5126&&($=34836),Z===5131&&($=34842),Z===5121&&($=32856)),($===33325||$===33326||$===34842||$===34836)&&e.get(\"EXT_color_buffer_float\"),$}function x(L){return L===yn||L===D1||L===L1?9728:9729}function A(L){let _=L.target;_.removeEventListener(\"dispose\",A),B(_),_.isVideoTexture&&h.delete(_),s.memory.textures--}function O(L){let _=L.target;_.removeEventListener(\"dispose\",O),U(_),s.memory.textures--}function B(L){let _=i.get(L);_.__webglInit!==void 0&&(n.deleteTexture(_.__webglTexture),i.remove(L))}function U(L){let _=L.texture,Z=i.get(L),$=i.get(_);if(!!L){if($.__webglTexture!==void 0&&n.deleteTexture($.__webglTexture),L.depthTexture&&L.depthTexture.dispose(),L.isWebGLCubeRenderTarget)for(let I=0;I<6;I++)n.deleteFramebuffer(Z.__webglFramebuffer[I]),Z.__webglDepthbuffer&&n.deleteRenderbuffer(Z.__webglDepthbuffer[I]);else n.deleteFramebuffer(Z.__webglFramebuffer),Z.__webglDepthbuffer&&n.deleteRenderbuffer(Z.__webglDepthbuffer),Z.__webglMultisampledFramebuffer&&n.deleteFramebuffer(Z.__webglMultisampledFramebuffer),Z.__webglColorRenderbuffer&&n.deleteRenderbuffer(Z.__webglColorRenderbuffer),Z.__webglDepthRenderbuffer&&n.deleteRenderbuffer(Z.__webglDepthRenderbuffer);i.remove(_),i.remove(L)}}let C=0;function N(){C=0}function R(){let L=C;return L>=l&&console.warn(\"THREE.WebGLTextures: Trying to use \"+L+\" texture units while this GPU supports only \"+l),C+=1,L}function D(L,_){let Z=i.get(L);if(L.isVideoTexture&&K(L),L.version>0&&Z.__version!==L.version){let $=L.image;if($===void 0)console.warn(\"THREE.WebGLRenderer: Texture marked for update but image is undefined\");else if($.complete===!1)console.warn(\"THREE.WebGLRenderer: Texture marked for update but image is incomplete\");else{X(Z,L,_);return}}t.activeTexture(33984+_),t.bindTexture(3553,Z.__webglTexture)}function z(L,_){let Z=i.get(L);if(L.version>0&&Z.__version!==L.version){X(Z,L,_);return}t.activeTexture(33984+_),t.bindTexture(35866,Z.__webglTexture)}function G(L,_){let Z=i.get(L);if(L.version>0&&Z.__version!==L.version){X(Z,L,_);return}t.activeTexture(33984+_),t.bindTexture(32879,Z.__webglTexture)}function Q(L,_){let Z=i.get(L);if(L.version>0&&Z.__version!==L.version){J(Z,L,_);return}t.activeTexture(33984+_),t.bindTexture(34067,Z.__webglTexture)}let te={[cp]:10497,[Bn]:33071,[up]:33648},ee={[yn]:9728,[D1]:9984,[L1]:9986,[nn]:9729,[eS]:9985,[$c]:9987};function ie(L,_,Z){if(Z?(n.texParameteri(L,10242,te[_.wrapS]),n.texParameteri(L,10243,te[_.wrapT]),(L===32879||L===35866)&&n.texParameteri(L,32882,te[_.wrapR]),n.texParameteri(L,10240,ee[_.magFilter]),n.texParameteri(L,10241,ee[_.minFilter])):(n.texParameteri(L,10242,33071),n.texParameteri(L,10243,33071),(L===32879||L===35866)&&n.texParameteri(L,32882,33071),(_.wrapS!==Bn||_.wrapT!==Bn)&&console.warn(\"THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.\"),n.texParameteri(L,10240,x(_.magFilter)),n.texParameteri(L,10241,x(_.minFilter)),_.minFilter!==yn&&_.minFilter!==nn&&console.warn(\"THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.\")),e.has(\"EXT_texture_filter_anisotropic\")===!0){let $=e.get(\"EXT_texture_filter_anisotropic\");if(_.type===_r&&e.has(\"OES_texture_float_linear\")===!1||a===!1&&_.type===nu&&e.has(\"OES_texture_half_float_linear\")===!1)return;(_.anisotropy>1||i.get(_).__currentAnisotropy)&&(n.texParameterf(L,$.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(_.anisotropy,r.getMaxAnisotropy())),i.get(_).__currentAnisotropy=_.anisotropy)}}function P(L,_){L.__webglInit===void 0&&(L.__webglInit=!0,_.addEventListener(\"dispose\",A),L.__webglTexture=n.createTexture(),s.memory.textures++)}function X(L,_,Z){let $=3553;_.isDataTexture2DArray&&($=35866),_.isDataTexture3D&&($=32879),P(L,_),t.activeTexture(33984+Z),t.bindTexture($,L.__webglTexture),n.pixelStorei(37440,_.flipY),n.pixelStorei(37441,_.premultiplyAlpha),n.pixelStorei(3317,_.unpackAlignment),n.pixelStorei(37443,0);let I=m(_)&&y(_.image)===!1,ae=v(_.image,I,!1,f),ge=y(ae)||a,be=o.convert(_.format),oe=o.convert(_.type),Le=w(_.internalFormat,be,oe);ie($,_,ge);let Ce,Ee=_.mipmaps;if(_.isDepthTexture)Le=6402,a?_.type===_r?Le=36012:_.type===tu?Le=33190:_.type===tl?Le=35056:Le=33189:_.type===_r&&console.error(\"WebGLRenderer: Floating point depth texture requires WebGL2.\"),_.format===fs&&Le===6402&&_.type!==eu&&_.type!==tu&&(console.warn(\"THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture.\"),_.type=eu,oe=o.convert(_.type)),_.format===nl&&Le===6402&&(Le=34041,_.type!==tl&&(console.warn(\"THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture.\"),_.type=tl,oe=o.convert(_.type))),t.texImage2D(3553,0,Le,ae.width,ae.height,0,be,oe,null);else if(_.isDataTexture)if(Ee.length>0&&ge){for(let _e=0,Te=Ee.length;_e0&&ge){for(let _e=0,Te=Ee.length;_eh+p?(l.inputState.pinching=!1,this.dispatchEvent({type:\"pinchend\",handedness:n.handedness,target:this})):!l.inputState.pinching&&u<=h-p&&(l.inputState.pinching=!0,this.dispatchEvent({type:\"pinchstart\",handedness:n.handedness,target:this}))}else s!==null&&(i=e.getPose(n.targetRaySpace,t),i!==null&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale))),a!==null&&n.gripSpace&&(r=e.getPose(n.gripSpace,t),r!==null&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale)));return s!==null&&(s.visible=i!==null),a!==null&&(a.visible=r!==null),l!==null&&(l.visible=o!==null),this}});function Cy(n,e){let t=this,i=null,r=1,o=null,s=\"local-floor\",a=null,l=[],c=new Map,f=new on;f.layers.enable(1),f.viewport=new ut;let u=new on;u.layers.enable(2),u.viewport=new ut;let h=[f,u],p=new Jp;p.layers.enable(1),p.layers.enable(2);let d=null,g=null;this.enabled=!1,this.isPresenting=!1,this.getController=function(U){let C=l[U];return C===void 0&&(C=new dl,l[U]=C),C.getTargetRaySpace()},this.getControllerGrip=function(U){let C=l[U];return C===void 0&&(C=new dl,l[U]=C),C.getGripSpace()},this.getHand=function(U){let C=l[U];return C===void 0&&(C=new dl,l[U]=C),C.getHandSpace()};function v(U){let C=c.get(U.inputSource);C&&C.dispatchEvent({type:U.type,data:U.inputSource})}function y(){c.forEach(function(U,C){U.disconnect(C)}),c.clear(),d=null,g=null,n.setFramebuffer(null),n.setRenderTarget(n.getRenderTarget()),B.stop(),t.isPresenting=!1,t.dispatchEvent({type:\"sessionend\"})}this.setFramebufferScaleFactor=function(U){r=U,t.isPresenting===!0&&console.warn(\"THREE.WebXRManager: Cannot change framebuffer scale while presenting.\")},this.setReferenceSpaceType=function(U){s=U,t.isPresenting===!0&&console.warn(\"THREE.WebXRManager: Cannot change reference space type while presenting.\")},this.getReferenceSpace=function(){return o},this.getSession=function(){return i},this.setSession=function(U){return se(this,null,function*(){if(i=U,i!==null){i.addEventListener(\"select\",v),i.addEventListener(\"selectstart\",v),i.addEventListener(\"selectend\",v),i.addEventListener(\"squeeze\",v),i.addEventListener(\"squeezestart\",v),i.addEventListener(\"squeezeend\",v),i.addEventListener(\"end\",y),i.addEventListener(\"inputsourceschange\",m);let C=e.getContextAttributes();C.xrCompatible!==!0&&(yield e.makeXRCompatible());let N={antialias:C.antialias,alpha:C.alpha,depth:C.depth,stencil:C.stencil,framebufferScaleFactor:r},R=new XRWebGLLayer(i,e,N);i.updateRenderState({baseLayer:R}),o=yield i.requestReferenceSpace(s),B.setContext(i),B.start(),t.isPresenting=!0,t.dispatchEvent({type:\"sessionstart\"})}})};function m(U){let C=i.inputSources;for(let N=0;N0&&f0(Je,T,q),ze.length>0&&f0(ze,T,q),T.isScene===!0&&T.onAfterRender(g,T,q),b!==null&&(re.updateRenderTargetMipmap(b),re.updateMultisampleRenderTarget(b)),we.buffers.depth.setTest(!0),we.buffers.depth.setMask(!0),we.buffers.color.setMask(!0),we.setPolygonOffset(!1),d.pop(),d.length>0?h=d[d.length-1]:h=null,p.pop(),p.length>0?u=p[p.length-1]:u=null};function u0(T,q,V,Y){if(T.visible===!1)return;if(T.layers.test(q.layers)){if(T.isGroup)V=T.renderOrder;else if(T.isLOD)T.autoUpdate===!0&&T.update(q);else if(T.isLight)h.pushLight(T),T.castShadow&&h.pushShadow(T);else if(T.isSprite){if(!T.frustumCulled||ee.intersectsSprite(T)){Y&&J.setFromMatrixPosition(T.matrixWorld).applyMatrix4(X);let ze=L.update(T),Ge=T.material;Ge.visible&&u.push(T,ze,Ge,V,J.z,null)}}else if(T.isImmediateRenderObject)Y&&J.setFromMatrixPosition(T.matrixWorld).applyMatrix4(X),u.push(T,null,T.material,V,J.z,null);else if((T.isMesh||T.isLine||T.isPoints)&&(T.isSkinnedMesh&&T.skeleton.frame!==Ue.render.frame&&(T.skeleton.update(),T.skeleton.frame=Ue.render.frame),!T.frustumCulled||ee.intersectsObject(T))){Y&&J.setFromMatrixPosition(T.matrixWorld).applyMatrix4(X);let ze=L.update(T),Ge=T.material;if(Array.isArray(Ge)){let He=ze.groups;for(let Rt=0,yt=He.length;Rt=0&&q<=T.width-Y&&V>=0&&V<=T.height-he&&F.readPixels(q,V,Y,he,Ce.convert(yt),Ce.convert(Be),Je):console.error(\"THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.\")}finally{He&&F.bindFramebuffer(36160,w)}}},this.copyFramebufferToTexture=function(T,q,V=0){let Y=Math.pow(2,-V),he=Math.floor(q.image.width*Y),Je=Math.floor(q.image.height*Y),ze=Ce.convert(q.format);re.setTexture2D(q,0),F.copyTexImage2D(3553,V,ze,T.x,T.y,he,Je,0),we.unbindTexture()},this.copyTextureToTexture=function(T,q,V,Y=0){let he=q.image.width,Je=q.image.height,ze=Ce.convert(V.format),Ge=Ce.convert(V.type);re.setTexture2D(V,0),F.pixelStorei(37440,V.flipY),F.pixelStorei(37441,V.premultiplyAlpha),F.pixelStorei(3317,V.unpackAlignment),q.isDataTexture?F.texSubImage2D(3553,Y,T.x,T.y,he,Je,ze,Ge,q.image.data):q.isCompressedTexture?F.compressedTexSubImage2D(3553,Y,T.x,T.y,q.mipmaps[0].width,q.mipmaps[0].height,ze,q.mipmaps[0].data):F.texSubImage2D(3553,Y,T.x,T.y,ze,Ge,q.image),Y===0&&V.generateMipmaps&&F.generateMipmap(3553),we.unbindTexture()},this.copyTextureToTexture3D=function(T,q,V,Y,he=0){if(g.isWebGL1Renderer){console.warn(\"THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.\");return}let{width:Je,height:ze,data:Ge}=V.image,He=Ce.convert(Y.format),Rt=Ce.convert(Y.type),yt;if(Y.isDataTexture3D)re.setTexture3D(Y,0),yt=32879;else if(Y.isDataTexture2DArray)re.setTexture2DArray(Y,0),yt=35866;else{console.warn(\"THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.\");return}F.pixelStorei(37440,Y.flipY),F.pixelStorei(37441,Y.premultiplyAlpha),F.pixelStorei(3317,Y.unpackAlignment);let Be=F.getParameter(3314),st=F.getParameter(32878),ii=F.getParameter(3316),vt=F.getParameter(3315),Ui=F.getParameter(32877);F.pixelStorei(3314,Je),F.pixelStorei(32878,ze),F.pixelStorei(3316,T.min.x),F.pixelStorei(3315,T.min.y),F.pixelStorei(32877,T.min.z),F.texSubImage3D(yt,he,q.x,q.y,q.z,T.max.x-T.min.x+1,T.max.y-T.min.y+1,T.max.z-T.min.z+1,He,Rt,Ge),F.pixelStorei(3314,Be),F.pixelStorei(32878,st),F.pixelStorei(3316,ii),F.pixelStorei(3315,vt),F.pixelStorei(32877,Ui),he===0&&Y.generateMipmaps&&F.generateMipmap(yt),we.unbindTexture()},this.initTexture=function(T){re.setTexture2D(T,0),we.unbindTexture()},this.resetState=function(){we.reset(),Ee.reset()},typeof __THREE_DEVTOOLS__!=\"undefined\"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(\"observe\",{detail:this}))}var Ry=class extends ft{};Ry.prototype.isWebGL1Renderer=!0;var Du=class{constructor(e,t){this.name=\"\",this.color=new Me(e),this.density=t!==void 0?t:25e-5}clone(){return new Du(this.color,this.density)}toJSON(){return{type:\"FogExp2\",color:this.color.getHex(),density:this.density}}};Du.prototype.isFogExp2=!0;var Lu=class{constructor(e,t,i){this.name=\"\",this.color=new Me(e),this.near=t!==void 0?t:1,this.far=i!==void 0?i:1e3}clone(){return new Lu(this.color,this.near,this.far)}toJSON(){return{type:\"Fog\",color:this.color.getHex(),near:this.near,far:this.far}}};Lu.prototype.isFog=!0;var ml=class extends ke{constructor(){super();this.type=\"Scene\",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,typeof __THREE_DEVTOOLS__!=\"undefined\"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(\"observe\",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.autoUpdate=e.autoUpdate,this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.background!==null&&(t.object.background=this.background.toJSON(e)),this.environment!==null&&(t.object.environment=this.environment.toJSON(e)),this.fog!==null&&(t.object.fog=this.fog.toJSON()),t}};ml.prototype.isScene=!0;function Kn(n,e){this.array=n,this.stride=e,this.count=n!==void 0?n.length/e:0,this.usage=su,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Fe.generateUUID()}Object.defineProperty(Kn.prototype,\"needsUpdate\",{set:function(n){n===!0&&this.version++}});Object.assign(Kn.prototype,{isInterleavedBuffer:!0,onUploadCallback:function(){},setUsage:function(n){return this.usage=n,this},copy:function(n){return this.array=new n.array.constructor(n.array),this.count=n.count,this.stride=n.stride,this.usage=n.usage,this},copyAt:function(n,e,t){n*=this.stride,t*=e.stride;for(let i=0,r=this.stride;ie.far||t.push({distance:l,point:yl.clone(),uv:At.getUV(yl,Cu,xl,Ru,ky,$p,zy,new ne),face:null,object:this})}copy(e){return super.copy(e),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}};Iy.prototype.isSprite=!0;function Pu(n,e,t,i,r,o){Ns.subVectors(n,t).addScalar(.5).multiply(i),r!==void 0?(vl.x=o*Ns.x-r*Ns.y,vl.y=r*Ns.x+o*Ns.y):vl.copy(Ns),n.copy(e),n.x+=vl.x,n.y+=vl.y,n.applyMatrix4(Py)}var ku=new E,Fy=new E,Ny=class extends ke{constructor(){super();this._currentLevel=0,this.type=\"LOD\",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);let t=e.levels;for(let i=0,r=t.length;i0){let i,r;for(i=1,r=t.length;i0){ku.setFromMatrixPosition(this.matrixWorld);let r=e.ray.origin.distanceTo(ku);this.getObjectForDistance(r).raycast(e,t)}}update(e){let t=this.levels;if(t.length>1){ku.setFromMatrixPosition(e.matrixWorld),Fy.setFromMatrixPosition(this.matrixWorld);let i=ku.distanceTo(Fy)/e.zoom;t[0].object.visible=!0;let r,o;for(r=1,o=t.length;r=t[r].distance;r++)t[r-1].object.visible=!1,t[r].object.visible=!0;for(this._currentLevel=r-1;rs)continue;f.applyMatrix4(this.matrixWorld);let w=n.ray.origin.distanceTo(f);wn.far||e.push({distance:w,point:c.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}else for(let g=0,v=d.count-1;gs)continue;f.applyMatrix4(this.matrixWorld);let m=n.ray.origin.distanceTo(f);mn.far||e.push({distance:m,point:c.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this})}}else t.isGeometry&&console.error(\"THREE.Line.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.\")},updateMorphTargets:function(){let n=this.geometry;if(n.isBufferGeometry){let e=n.morphAttributes,t=Object.keys(e);if(t.length>0){let i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=i.length;r0&&console.error(\"THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.\")}}});var Xy=new E,Zy=new E;function Nu(n,e){wl.call(this,n,e),this.type=\"LineSegments\"}Nu.prototype=Object.assign(Object.create(wl.prototype),{constructor:Nu,isLineSegments:!0,computeLineDistances:function(){let n=this.geometry;if(n.isBufferGeometry)if(n.index===null){let e=n.attributes.position,t=[];for(let i=0,r=e.count;i0){let i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=i.length;r0&&console.error(\"THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.\")}}});function ev(n,e,t,i,r,o,s){let a=rd.distanceSqToPoint(n);if(ar.far)return;o.push({distance:c,distanceToRay:Math.sqrt(a),point:l,index:e,face:null,object:s})}}var tv=class extends jt{constructor(e,t,i,r,o,s,a,l,c){super(e,t,i,r,o,s,a,l,c);this.format=a!==void 0?a:vo,this.minFilter=s!==void 0?s:nn,this.magFilter=o!==void 0?o:nn,this.generateMipmaps=!1;let f=this;function u(){f.needsUpdate=!0,e.requestVideoFrameCallback(u)}\"requestVideoFrameCallback\"in e&&e.requestVideoFrameCallback(u)}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;\"requestVideoFrameCallback\"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}};tv.prototype.isVideoTexture=!0;var od=class extends jt{constructor(e,t,i,r,o,s,a,l,c,f,u,h){super(null,s,a,l,c,f,r,o,u,h);this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}};od.prototype.isCompressedTexture=!0;var nv=class extends jt{constructor(e,t,i,r,o,s,a,l,c){super(e,t,i,r,o,s,a,l,c);this.needsUpdate=!0}};nv.prototype.isCanvasTexture=!0;var iv=class extends jt{constructor(e,t,i,r,o,s,a,l,c,f){if(f=f!==void 0?f:fs,f!==fs&&f!==nl)throw new Error(\"DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat\");i===void 0&&f===fs&&(i=eu),i===void 0&&f===nl&&(i=tl),super(null,r,o,s,a,l,f,i,c),this.image={width:e,height:t},this.magFilter=a!==void 0?a:yn,this.minFilter=l!==void 0?l:yn,this.flipY=!1,this.generateMipmaps=!1}};iv.prototype.isDepthTexture=!0;var tk=new E,nk=new E,ik=new E,rk=new At;var yA={triangulate:function(n,e,t){t=t||2;let i=e&&e.length,r=i?e[0]*t:n.length,o=rv(n,0,r,t,!0),s=[];if(!o||o.next===o.prev)return s;let a,l,c,f,u,h,p;if(i&&(o=MA(n,e,o,t)),n.length>80*t){a=c=n[0],l=f=n[1];for(let d=t;dc&&(c=u),h>f&&(f=h);p=Math.max(c-a,f-l),p=p!==0?1/p:0}return Ml(o,s,t,a,l,p),s}};function rv(n,e,t,i,r){let o,s;if(r===kA(n,e,t,i)>0)for(o=e;o=e;o-=i)s=av(o,n[o],n[o+1],s);return s&&Uu(s,s.next)&&(El(s),s=s.next),s}function Nr(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(Uu(t,t.next)||Lt(t.prev,t,t.next)===0)){if(El(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function Ml(n,e,t,i,r,o,s){if(!n)return;!s&&o&&AA(n,i,r,o);let a=n,l,c;for(;n.prev!==n.next;){if(l=n.prev,c=n.next,o?xA(n,i,r,o):vA(n)){e.push(l.i/t),e.push(n.i/t),e.push(c.i/t),El(n),n=c.next,a=c.next;continue}if(n=c,n===a){s?s===1?(n=bA(Nr(n),e,t),Ml(n,e,t,i,r,o,2)):s===2&&wA(n,e,t,i,r,o):Ml(Nr(n),e,t,i,r,o,1);break}}}function vA(n){let e=n.prev,t=n,i=n.next;if(Lt(e,t,i)>=0)return!1;let r=n.next.next;for(;r!==n.prev;){if(Os(e.x,e.y,t.x,t.y,i.x,i.y,r.x,r.y)&&Lt(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function xA(n,e,t,i){let r=n.prev,o=n,s=n.next;if(Lt(r,o,s)>=0)return!1;let a=r.xo.x?r.x>s.x?r.x:s.x:o.x>s.x?o.x:s.x,f=r.y>o.y?r.y>s.y?r.y:s.y:o.y>s.y?o.y:s.y,u=sd(a,l,e,t,i),h=sd(c,f,e,t,i),p=n.prevZ,d=n.nextZ;for(;p&&p.z>=u&&d&&d.z<=h;){if(p!==n.prev&&p!==n.next&&Os(r.x,r.y,o.x,o.y,s.x,s.y,p.x,p.y)&&Lt(p.prev,p,p.next)>=0||(p=p.prevZ,d!==n.prev&&d!==n.next&&Os(r.x,r.y,o.x,o.y,s.x,s.y,d.x,d.y)&&Lt(d.prev,d,d.next)>=0))return!1;d=d.nextZ}for(;p&&p.z>=u;){if(p!==n.prev&&p!==n.next&&Os(r.x,r.y,o.x,o.y,s.x,s.y,p.x,p.y)&&Lt(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;d&&d.z<=h;){if(d!==n.prev&&d!==n.next&&Os(r.x,r.y,o.x,o.y,s.x,s.y,d.x,d.y)&&Lt(d.prev,d,d.next)>=0)return!1;d=d.nextZ}return!0}function bA(n,e,t){let i=n;do{let r=i.prev,o=i.next.next;!Uu(r,o)&&ov(r,i,i.next,o)&&Sl(r,o)&&Sl(o,r)&&(e.push(r.i/t),e.push(i.i/t),e.push(o.i/t),El(i),El(i.next),i=n=o),i=i.next}while(i!==n);return Nr(i)}function wA(n,e,t,i,r,o){let s=n;do{let a=s.next.next;for(;a!==s.prev;){if(s.i!==a.i&&CA(s,a)){let l=sv(s,a);s=Nr(s,s.next),l=Nr(l,l.next),Ml(s,e,t,i,r,o),Ml(l,e,t,i,r,o);return}a=a.next}s=s.next}while(s!==n)}function MA(n,e,t,i){let r=[],o,s,a,l,c;for(o=0,s=e.length;o=t.next.y&&t.next.y!==t.y){let h=t.x+(r-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(h<=i&&h>o){if(o=h,h===i){if(r===t.y)return t;if(r===t.next.y)return t.next}s=t.x=t.x&&t.x>=l&&i!==t.x&&Os(rs.x||t.x===s.x&&TA(s,t)))&&(s=t,f=u)),t=t.next;while(t!==a);return s}function TA(n,e){return Lt(n.prev,n,e.prev)<0&&Lt(e.next,n,n.next)<0}function AA(n,e,t,i){let r=n;do r.z===null&&(r.z=sd(r.x,r.y,e,t,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==n);r.prevZ.nextZ=null,r.prevZ=null,DA(r)}function DA(n){let e,t,i,r,o,s,a,l,c=1;do{for(t=n,n=null,o=null,s=0;t;){for(s++,i=t,a=0,e=0;e0||l>0&&i;)a!==0&&(l===0||!i||t.z<=i.z)?(r=t,t=t.nextZ,a--):(r=i,i=i.nextZ,l--),o?o.nextZ=r:n=r,r.prevZ=o,o=r;t=i}o.nextZ=null,c*=2}while(s>1);return n}function sd(n,e,t,i,r){return n=32767*(n-t)*r,e=32767*(e-i)*r,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function LA(n){let e=n,t=n;do(e.x=0&&(n-s)*(i-a)-(t-s)*(e-a)>=0&&(t-s)*(o-a)-(r-s)*(i-a)>=0}function CA(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!RA(n,e)&&(Sl(n,e)&&Sl(e,n)&&PA(n,e)&&(Lt(n.prev,n,e.prev)||Lt(n,e.prev,e))||Uu(n,e)&&Lt(n.prev,n,n.next)>0&&Lt(e.prev,e,e.next)>0)}function Lt(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function Uu(n,e){return n.x===e.x&&n.y===e.y}function ov(n,e,t,i){let r=Wu(Lt(n,e,t)),o=Wu(Lt(n,e,i)),s=Wu(Lt(t,i,n)),a=Wu(Lt(t,i,e));return!!(r!==o&&s!==a||r===0&&Gu(n,t,e)||o===0&&Gu(n,i,e)||s===0&&Gu(t,n,i)||a===0&&Gu(t,e,i))}function Gu(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function Wu(n){return n>0?1:n<0?-1:0}function RA(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&ov(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function Sl(n,e){return Lt(n.prev,n,n.next)<0?Lt(n,e,n.next)>=0&&Lt(n,n.prev,e)>=0:Lt(n,e,n.prev)<0||Lt(n,n.next,e)<0}function PA(n,e){let t=n,i=!1,r=(n.x+e.x)/2,o=(n.y+e.y)/2;do t.y>o!=t.next.y>o&&t.next.y!==t.y&&r<(t.next.x-t.x)*(o-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function sv(n,e){let t=new ad(n.i,n.x,n.y),i=new ad(e.i,e.x,e.y),r=n.next,o=e.prev;return n.next=e,e.prev=n,t.next=r,r.prev=t,i.next=t,t.prev=i,o.next=i,i.prev=o,i}function av(n,e,t,i){let r=new ad(n,e,t);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function El(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function ad(n,e,t){this.i=n,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function kA(n,e,t,i){let r=0;for(let o=e,s=t-i;o2&&n[e-1].equals(n[0])&&n.pop()}function cv(n,e){for(let t=0;tNumber.EPSILON){let be=Math.sqrt(ae),oe=Math.sqrt($*$+I*I),Le=re.x-Z/be,Ce=re.y+_/be,Ee=fe.x-I/oe,_e=fe.y+$/oe,Te=((Ee-Le)*I-(_e-Ce)*$)/(_*I-Z*$);Se=Le+_*Te-K.x,me=Ce+Z*Te-K.y;let Tt=Se*Se+me*me;if(Tt<=2)return new ne(Se,me);L=Math.sqrt(Tt/2)}else{let be=!1;_>Number.EPSILON?$>Number.EPSILON&&(be=!0):_<-Number.EPSILON?$<-Number.EPSILON&&(be=!0):Math.sign(Z)===Math.sign(I)&&(be=!0),be?(Se=-Z,me=_,L=Math.sqrt(ae)):(Se=_,me=Z,L=Math.sqrt(ae/2))}return new ne(Se/L,me/L)}let ee=[];for(let K=0,re=D.length,fe=re-1,Se=K+1;K=0;K--){let re=K/v,fe=p*Math.cos(re*Math.PI/2),Se=d*Math.sin(re*Math.PI/2)+g;for(let me=0,L=D.length;me=0;){let Se=fe,me=fe-1;me<0&&(me=K.length-1);for(let L=0,_=f+v*2;L<_;L++){let Z=G*L,$=G*(L+1),I=re+Se+Z,ae=re+me+Z,ge=re+me+$,be=re+Se+$;De(I,ae,ge,be)}}}function ue(K,re,fe){l.push(K),l.push(re),l.push(fe)}function xe(K,re,fe){we(K),we(re),we(fe);let Se=r.length/3,me=m.generateTopUV(i,r,Se-3,Se-2,Se-1);Ue(me[0]),Ue(me[1]),Ue(me[2])}function De(K,re,fe,Se){we(K),we(re),we(Se),we(re),we(fe),we(Se);let me=r.length/3,L=m.generateSideWallUV(i,r,me-6,me-3,me-2,me-1);Ue(L[0]),Ue(L[1]),Ue(L[3]),Ue(L[1]),Ue(L[2]),Ue(L[3])}function we(K){r.push(l[K*3+0]),r.push(l[K*3+1]),r.push(l[K*3+2])}function Ue(K){o.push(K.x),o.push(K.y)}}}toJSON(){let e=$e.prototype.toJSON.call(this),t=this.parameters.shapes,i=this.parameters.options;return IA(t,i,e)}},zA={generateTopUV:function(n,e,t,i,r){let o=e[t*3],s=e[t*3+1],a=e[i*3],l=e[i*3+1],c=e[r*3],f=e[r*3+1];return[new ne(o,s),new ne(a,l),new ne(c,f)]},generateSideWallUV:function(n,e,t,i,r,o){let s=e[t*3],a=e[t*3+1],l=e[t*3+2],c=e[i*3],f=e[i*3+1],u=e[i*3+2],h=e[r*3],p=e[r*3+1],d=e[r*3+2],g=e[o*3],v=e[o*3+1],y=e[o*3+2];return Math.abs(a-f)<.01?[new ne(s,1-l),new ne(c,1-u),new ne(h,1-d),new ne(g,1-y)]:[new ne(a,1-l),new ne(f,1-u),new ne(p,1-d),new ne(v,1-y)]}};function IA(n,e,t){if(t.shapes=[],Array.isArray(n))for(let i=0,r=n.length;i=0?(n(y-a,g,f),u.subVectors(c,f)):(n(y+a,g,f),u.subVectors(f,c)),g-a>=0?(n(y,g-a,f),h.subVectors(c,f)):(n(y,g+a,f),h.subVectors(f,c)),l.crossVectors(u,h).normalize(),o.push(l.x,l.y,l.z),s.push(y,g)}}for(let d=0;d=i)){u.push(c.times[p]);for(let g=0;go.tracks[l].times[0]&&(a=o.tracks[l].times[0]);for(let l=0;l=a.times[d]){let y=d*u+f,m=y+u-f;g=Et.arraySlice(a.values,y,m)}else{let y=a.createInterpolant(),m=f,S=u-f;y.evaluate(o),g=Et.arraySlice(y.resultBuffer,m,S)}l===\"quaternion\"&&new qt().fromArray(g).normalize().conjugate().toArray(g);let v=c.times.length;for(let y=0;y=r)){let s=e[1];n=r)break t}o=t,t=0;break n}break e}for(;t>>1;nt;)--s;if(++s,o!==0||s!==r){o>=s&&(s=Math.max(s,1),o=s-1);let a=this.getValueSize();this.times=Et.arraySlice(i,o,s),this.values=Et.arraySlice(this.values,o*a,s*a)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!=0&&(console.error(\"THREE.KeyframeTrack: Invalid value size in track.\",this),e=!1);let i=this.times,r=this.values,o=i.length;o===0&&(console.error(\"THREE.KeyframeTrack: Track is empty.\",this),e=!1);let s=null;for(let a=0;a!==o;a++){let l=i[a];if(typeof l==\"number\"&&isNaN(l)){console.error(\"THREE.KeyframeTrack: Time is not a valid number.\",this,a,l),e=!1;break}if(s!==null&&s>l){console.error(\"THREE.KeyframeTrack: Out of order keys.\",this,a,l,s),e=!1;break}s=l}if(r!==void 0&&Et.isTypedArray(r))for(let a=0,l=r.length;a!==l;++a){let c=r[a];if(isNaN(c)){console.error(\"THREE.KeyframeTrack: Value is not a valid number.\",this,a,c),e=!1;break}}return e}optimize(){let e=Et.arraySlice(this.times),t=Et.arraySlice(this.values),i=this.getValueSize(),r=this.getInterpolation()===hp,o=e.length-1,s=1;for(let a=1;a0){e[s]=e[o];for(let a=o*i,l=s*i,c=0;c!==i;++c)t[l+c]=t[a+c];++s}return s!==e.length?(this.times=Et.arraySlice(e,0,s),this.values=Et.arraySlice(t,0,s*i)):(this.times=e,this.values=t),this}clone(){let e=Et.arraySlice(this.times,0),t=Et.arraySlice(this.values,0),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};di.prototype.TimeBufferType=Float32Array;di.prototype.ValueBufferType=Float32Array;di.prototype.DefaultInterpolation=ru;var So=class extends di{};So.prototype.ValueTypeName=\"bool\";So.prototype.ValueBufferType=Array;So.prototype.DefaultInterpolation=iu;So.prototype.InterpolantFactoryMethodLinear=void 0;So.prototype.InterpolantFactoryMethodSmooth=void 0;var hd=class extends di{};hd.prototype.ValueTypeName=\"color\";var Tl=class extends di{};Tl.prototype.ValueTypeName=\"number\";function pd(n,e,t,i){$n.call(this,n,e,t,i)}pd.prototype=Object.assign(Object.create($n.prototype),{constructor:pd,interpolate_:function(n,e,t,i){let r=this.resultBuffer,o=this.sampleValues,s=this.valueSize,a=(t-e)/(i-e),l=n*s;for(let c=l+s;l!==c;l+=4)qt.slerpFlat(r,0,o,l-s,o,l,a);return r}});var Gs=class extends di{InterpolantFactoryMethodLinear(e){return new pd(this.times,this.values,this.getValueSize(),e)}};Gs.prototype.ValueTypeName=\"quaternion\";Gs.prototype.DefaultInterpolation=ru;Gs.prototype.InterpolantFactoryMethodSmooth=void 0;var Eo=class extends di{};Eo.prototype.ValueTypeName=\"string\";Eo.prototype.ValueBufferType=Array;Eo.prototype.DefaultInterpolation=iu;Eo.prototype.InterpolantFactoryMethodLinear=void 0;Eo.prototype.InterpolantFactoryMethodSmooth=void 0;var Al=class extends di{};Al.prototype.ValueTypeName=\"vector\";var dd=class{constructor(e,t=-1,i,r=pp){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=Fe.generateUUID(),this.duration<0&&this.resetDuration()}static parse(e){let t=[],i=e.tracks,r=1/(e.fps||1);for(let s=0,a=i.length;s!==a;++s)t.push(BA(i[s]).scale(r));let o=new this(e.name,e.duration,t,e.blendMode);return o.uuid=e.uuid,o}static toJSON(e){let t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let o=0,s=i.length;o!==s;++o)t.push(di.toJSON(i[o]));return r}static CreateFromMorphTargetSequence(e,t,i,r){let o=t.length,s=[];for(let a=0;a1){let u=f[1],h=r[u];h||(r[u]=h=[]),h.push(c)}}let s=[];for(let a in r)s.push(this.CreateFromMorphTargetSequence(a,r[a],t,i));return s}static parseAnimation(e,t){if(!e)return console.error(\"THREE.AnimationClip: No animation in JSONLoader data.\"),null;let i=function(u,h,p,d,g){if(p.length!==0){let v=[],y=[];Et.flattenJSON(p,v,y,d),v.length!==0&&g.push(new u(h,v,y))}},r=[],o=e.name||\"default\",s=e.fps||30,a=e.blendMode,l=e.length||-1,c=e.hierarchy||[];for(let u=0;u0||n.search(/^data\\:image\\/jpeg/)===0;r.format=a?vo:ci,r.needsUpdate=!0,e!==void 0&&e(r)},t,i),r}});function Cn(){this.type=\"Curve\",this.arcLengthDivisions=200}Object.assign(Cn.prototype,{getPoint:function(){return console.warn(\"THREE.Curve: .getPoint() not implemented.\"),null},getPointAt:function(n,e){let t=this.getUtoTmapping(n);return this.getPoint(t,e)},getPoints:function(n=5){let e=[];for(let t=0;t<=n;t++)e.push(this.getPoint(t/n));return e},getSpacedPoints:function(n=5){let e=[];for(let t=0;t<=n;t++)e.push(this.getPointAt(t/n));return e},getLength:function(){let n=this.getLengths();return n[n.length-1]},getLengths:function(n){if(n===void 0&&(n=this.arcLengthDivisions),this.cacheArcLengths&&this.cacheArcLengths.length===n+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let e=[],t,i=this.getPoint(0),r=0;e.push(0);for(let o=1;o<=n;o++)t=this.getPoint(o/n),r+=t.distanceTo(i),e.push(r),i=t;return this.cacheArcLengths=e,e},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()},getUtoTmapping:function(n,e){let t=this.getLengths(),i=0,r=t.length,o;e?o=e:o=n*t[r-1];let s=0,a=r-1,l;for(;s<=a;)if(i=Math.floor(s+(a-s)/2),l=t[i]-o,l<0)s=i+1;else if(l>0)a=i-1;else{a=i;break}if(i=a,t[i]===o)return i/(r-1);let c=t[i],u=t[i+1]-c,h=(o-c)/u;return(i+h)/(r-1)},getTangent:function(n,e){let t=1e-4,i=n-t,r=n+t;i<0&&(i=0),r>1&&(r=1);let o=this.getPoint(i),s=this.getPoint(r),a=e||(o.isVector2?new ne:new E);return a.copy(s).sub(o).normalize(),a},getTangentAt:function(n,e){let t=this.getUtoTmapping(n);return this.getTangent(t,e)},computeFrenetFrames:function(n,e){let t=new E,i=[],r=[],o=[],s=new E,a=new ve;for(let h=0;h<=n;h++){let p=h/n;i[h]=this.getTangentAt(p,new E),i[h].normalize()}r[0]=new E,o[0]=new E;let l=Number.MAX_VALUE,c=Math.abs(i[0].x),f=Math.abs(i[0].y),u=Math.abs(i[0].z);c<=l&&(l=c,t.set(1,0,0)),f<=l&&(l=f,t.set(0,1,0)),u<=l&&t.set(0,0,1),s.crossVectors(i[0],t).normalize(),r[0].crossVectors(i[0],s),o[0].crossVectors(i[0],r[0]);for(let h=1;h<=n;h++){if(r[h]=r[h-1].clone(),o[h]=o[h-1].clone(),s.crossVectors(i[h-1],i[h]),s.length()>Number.EPSILON){s.normalize();let p=Math.acos(Fe.clamp(i[h-1].dot(i[h]),-1,1));r[h].applyMatrix4(a.makeRotationAxis(s,p))}o[h].crossVectors(i[h],r[h])}if(e===!0){let h=Math.acos(Fe.clamp(r[0].dot(r[n]),-1,1));h/=n,i[0].dot(s.crossVectors(r[0],r[n]))>0&&(h=-h);for(let p=1;p<=n;p++)r[p].applyMatrix4(a.makeRotationAxis(i[p],h*p)),o[p].crossVectors(i[p],r[p])}return{tangents:i,normals:r,binormals:o}},clone:function(){return new this.constructor().copy(this)},copy:function(n){return this.arcLengthDivisions=n.arcLengthDivisions,this},toJSON:function(){let n={metadata:{version:4.5,type:\"Curve\",generator:\"Curve.toJSON\"}};return n.arcLengthDivisions=this.arcLengthDivisions,n.type=this.type,n},fromJSON:function(n){return this.arcLengthDivisions=n.arcLengthDivisions,this}});var Cl=class extends Cn{constructor(e=0,t=0,i=1,r=1,o=0,s=Math.PI*2,a=!1,l=0){super();this.type=\"EllipseCurve\",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=o,this.aEndAngle=s,this.aClockwise=a,this.aRotation=l}getPoint(e,t){let i=t||new ne,r=Math.PI*2,o=this.aEndAngle-this.aStartAngle,s=Math.abs(o)r;)o-=r;o0?0:(Math.floor(Math.abs(a)/o)+1)*o:l===0&&a===o-1&&(a=o-2,l=1);let c,f;this.closed||a>0?c=r[(a-1)%o]:(Vu.subVectors(r[0],r[1]).add(r[0]),c=Vu);let u=r[a%o],h=r[(a+1)%o];if(this.closed||a+2r.length-2?r.length-1:s+1],u=r[s>r.length-3?r.length-1:s+2];return i.set(wv(a,l.x,c.x,f.x,u.x),wv(a,l.y,c.y,f.y,u.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t=t){let o=i[r]-t,s=this.curves[r],a=s.getLength(),l=a===0?0:1-o/a;return s.getPointAt(l)}r++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let i=0,r=this.curves.length;i1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t0){let u=c.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(c);let f=c.getPoint(1);return this.currentPoint.copy(f),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},_o=class extends zl{constructor(e){super(e);this.uuid=Fe.generateUUID(),this.type=\"Shape\",this.holes=[]}getPointsHoles(e){let t=[];for(let i=0,r=this.holes.length;iNumber.EPSILON){if(C<0&&(O=S[A],U=-U,B=S[x],C=-C),m.yB.y)continue;if(m.y===O.y){if(m.x===O.x)return!0}else{let N=C*(m.x-O.x)-U*(m.y-O.y);if(N===0)return!0;if(N<0)continue;w=!w}}else{if(m.y!==O.y)continue;if(B.x<=m.x&&m.x<=O.x||O.x<=m.x&&m.x<=B.x)return!0}}return w}let o=Br.isClockWise,s=this.subPaths;if(s.length===0)return[];if(t===!0)return i(s);let a,l,c,f=[];if(s.length===1)return l=s[0],c=new _o,c.curves=l.curves,f.push(c),f;let u=!o(s[0].getPoints());u=e?!u:u;let h=[],p=[],d=[],g=0,v;p[g]=void 0,d[g]=[];for(let m=0,S=s.length;m1){let m=!1,S=[];for(let b=0,w=p.length;b0&&(m||(d=h))}let y;for(let m=0,S=p.length;m0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e0&&this._mixBufferRegionAdditive(i,r,this._addIndex*t,1,t);for(let l=t,c=t+t;l!==c;++l)if(i[l]!==i[l+t]){a.setValue(i,r);break}}saveOriginalState(){let e=this.binding,t=this.buffer,i=this.valueSize,r=i*this._origIndex;e.getValue(t,r);for(let o=i,s=r;o!==s;++o)t[o]=t[r+o%i];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 i=e;i=.5)for(let s=0;s!==o;++s)e[t+s]=e[i+s]}_slerp(e,t,i,r){qt.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,o){let s=this._workIndex*o;qt.multiplyQuaternionsFlat(e,s,e,t,e,i),qt.slerpFlat(e,t,e,t,e,s,r)}_lerp(e,t,i,r,o){let s=1-r;for(let a=0;a!==o;++a){let l=t+a;e[l]=e[l]*s+e[i+a]*r}}_lerpAdditive(e,t,i,r,o){for(let s=0;s!==o;++s){let a=t+s;e[a]=e[a]+e[i+s]*r}}},Rd=\"\\\\[\\\\]\\\\.:\\\\/\",$A=new RegExp(\"[\"+Rd+\"]\",\"g\"),Pd=\"[^\"+Rd+\"]\",eD=\"[^\"+Rd.replace(\"\\\\.\",\"\")+\"]\",tD=/((?:WC+[\\/:])*)/.source.replace(\"WC\",Pd),nD=/(WCOD+)?/.source.replace(\"WCOD\",eD),iD=/(?:\\.(WC+)(?:\\[(.+)\\])?)?/.source.replace(\"WC\",Pd),rD=/\\.(WC+)(?:\\[(.+)\\])?/.source.replace(\"WC\",Pd),oD=new RegExp(\"^\"+tD+nD+iD+rD+\"$\"),sD=[\"material\",\"materials\",\"bones\"];function Vv(n,e,t){let i=t||vn.parseTrackName(e);this._targetGroup=n,this._bindings=n.subscribe_(e,i)}Object.assign(Vv.prototype,{getValue:function(n,e){this.bind();let t=this._targetGroup.nCachedObjects_,i=this._bindings[t];i!==void 0&&i.getValue(n,e)},setValue:function(n,e){let t=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=t.length;i!==r;++i)t[i].setValue(n,e)},bind:function(){let n=this._bindings;for(let e=this._targetGroup.nCachedObjects_,t=n.length;e!==t;++e)n[e].bind()},unbind:function(){let n=this._bindings;for(let e=this._targetGroup.nCachedObjects_,t=n.length;e!==t;++e)n[e].unbind()}});function vn(n,e,t){this.path=e,this.parsedPath=t||vn.parseTrackName(e),this.node=vn.findNode(n,this.parsedPath.nodeName)||n,this.rootNode=n}Object.assign(vn,{Composite:Vv,create:function(n,e,t){return n&&n.isAnimationObjectGroup?new vn.Composite(n,e,t):new vn(n,e,t)},sanitizeNodeName:function(n){return n.replace(/\\s/g,\"_\").replace($A,\"\")},parseTrackName:function(n){let e=oD.exec(n);if(!e)throw new Error(\"PropertyBinding: Cannot parse trackName: \"+n);let t={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},i=t.nodeName&&t.nodeName.lastIndexOf(\".\");if(i!==void 0&&i!==-1){let r=t.nodeName.substring(i+1);sD.indexOf(r)!==-1&&(t.nodeName=t.nodeName.substring(0,i),t.objectName=r)}if(t.propertyName===null||t.propertyName.length===0)throw new Error(\"PropertyBinding: can not parse propertyName from trackName: \"+n);return t},findNode:function(n,e){if(!e||e===\"\"||e===\".\"||e===-1||e===n.name||e===n.uuid)return n;if(n.skeleton){let t=n.skeleton.getBoneByName(e);if(t!==void 0)return t}if(n.children){let t=function(r){for(let o=0;o=o){let u=o++,h=e[u];t[h.uuid]=f,e[f]=h,t[c]=u,e[u]=l;for(let p=0,d=r;p!==d;++p){let g=i[p],v=g[u],y=g[f];g[f]=v,g[u]=y}}}this.nCachedObjects_=o}uncache(){let e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length,o=this.nCachedObjects_,s=e.length;for(let a=0,l=arguments.length;a!==l;++a){let c=arguments[a],f=c.uuid,u=t[f];if(u!==void 0)if(delete t[f],u0&&(t[p.uuid]=u),e[u]=p,e.pop();for(let d=0,g=r;d!==g;++d){let v=i[d];v[u]=v[h],v.pop()}}}this.nCachedObjects_=o}subscribe_(e,t){let i=this._bindingsIndicesByPath,r=i[e],o=this._bindings;if(r!==void 0)return o[r];let s=this._paths,a=this._parsedPaths,l=this._objects,c=l.length,f=this.nCachedObjects_,u=new Array(c);r=o.length,i[e]=r,s.push(e),a.push(t),o.push(u);for(let h=f,p=l.length;h!==p;++h){let d=l[h];u[h]=new vn(d,e,t)}return u}unsubscribe_(e){let t=this._bindingsIndicesByPath,i=t[e];if(i!==void 0){let r=this._paths,o=this._parsedPaths,s=this._bindings,a=s.length-1,l=s[a],c=e[a];t[c]=i,s[i]=l,s.pop(),o[i]=o[a],o.pop(),r[i]=r[a],r.pop()}}};jv.prototype.isAnimationObjectGroup=!0;var qv=class{constructor(e,t,i=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=r;let o=t.tracks,s=o.length,a=new Array(s),l={endingStart:hs,endingEnd:hs};for(let c=0;c!==s;++c){let f=o[c].createInterpolant(null);a[c]=f,f.settings=l}this._interpolantSettings=l,this._interpolants=a,this._propertyBindings=new Array(s),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=QS,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=Infinity,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,i){if(e.fadeOut(t),this.fadeIn(t),i){let r=this._clip.duration,o=e._clip.duration,s=o/r,a=r/o;e.warp(1,s,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,i){return e.crossFadeFrom(this,t,i)}stopFading(){let e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),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,i){let r=this._mixer,o=r.time,s=this.timeScale,a=this._timeScaleInterpolant;a===null&&(a=r._lendControlInterpolant(),this._timeScaleInterpolant=a);let l=a.parameterPositions,c=a.sampleValues;return l[0]=o,l[1]=o+i,c[0]=e/s,c[1]=t/s,this}stopWarping(){let e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,r){if(!this.enabled){this._updateWeight(e);return}let o=this._startTime;if(o!==null){let l=(e-o)*i;if(l<0||i===0)return;this._startTime=null,t=i*l}t*=this._updateTimeScale(e);let s=this._updateTime(t),a=this._updateWeight(e);if(a>0){let l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case U1:for(let f=0,u=l.length;f!==u;++f)l[f].evaluate(s),c[f].accumulateAdditive(a);break;case pp:default:for(let f=0,u=l.length;f!==u;++f)l[f].evaluate(s),c[f].accumulate(r,a)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let i=this._weightInterpolant;if(i!==null){let r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let i=this._timeScaleInterpolant;i!==null&&(t*=i.evaluate(e)[0],e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t))}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,i=this.loop,r=this.time+e,o=this._loopCount,s=i===YS;if(e===0)return o===-1?r:s&&(o&1)==1?t-r:r;if(i===qS){o===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:\"finished\",action:this,direction:e<0?-1:1})}}else{if(o===-1&&(e>=0?(o=0,this._setEndings(!0,this.repetitions===0,s)):this._setEndings(this.repetitions===0,!0,s)),r>=t||r<0){let a=Math.floor(r/t);r-=t*a,o+=Math.abs(a);let l=this.repetitions-o;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:\"finished\",action:this,direction:e>0?1:-1});else{if(l===1){let c=e<0;this._setEndings(c,!c,s)}else this._setEndings(!1,!1,s);this._loopCount=o,this.time=r,this._mixer.dispatchEvent({type:\"loop\",action:this,loopDelta:a})}}else this.time=r;if(s&&(o&1)==1)return t-r}return r}_setEndings(e,t,i){let r=this._interpolantSettings;i?(r.endingStart=ps,r.endingEnd=ps):(e?r.endingStart=this.zeroSlopeAtStart?ps:hs:r.endingStart=ou,t?r.endingEnd=this.zeroSlopeAtEnd?ps:hs:r.endingEnd=ou)}_scheduleFading(e,t,i){let r=this._mixer,o=r.time,s=this._weightInterpolant;s===null&&(s=r._lendControlInterpolant(),this._weightInterpolant=s);let a=s.parameterPositions,l=s.sampleValues;return a[0]=o,l[0]=t,a[1]=o+e,l[1]=i,this}},Qv=class extends Tr{constructor(e){super();this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){let i=e._localRoot||this._root,r=e._clip.tracks,o=r.length,s=e._propertyBindings,a=e._interpolants,l=i.uuid,c=this._bindingsByRootAndName,f=c[l];f===void 0&&(f={},c[l]=f);for(let u=0;u!==o;++u){let h=r[u],p=h.name,d=f[p];if(d!==void 0)s[u]=d;else{if(d=s[u],d!==void 0){d._cacheIndex===null&&(++d.referenceCount,this._addInactiveBinding(d,l,p));continue}let g=t&&t._propertyBindings[u].binding.parsedPath;d=new Hv(vn.create(i,p,g),h.ValueTypeName,h.getValueSize()),++d.referenceCount,this._addInactiveBinding(d,l,p),s[u]=d}a[u].resultBuffer=d.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let i=(e._localRoot||this._root).uuid,r=e._clip.uuid,o=this._actionsByClip[r];this._bindAction(e,o&&o.knownActions[0]),this._addInactiveAction(e,r,i)}let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let o=t[i];o.useCount++==0&&(this._lendBinding(o),o.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let o=t[i];--o.useCount==0&&(o.restoreOriginalState(),this._takeBackBinding(o))}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=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;let t=this._actions,i=this._nActiveActions,r=this.time+=e,o=Math.sign(e),s=this._accuIndex^=1;for(let c=0;c!==i;++c)t[c]._update(r,e,o,s);let a=this._bindings,l=this._nActiveBindings;for(let c=0;c!==l;++c)a[c].apply(s);return this}setTime(e){this.time=0;for(let t=0;tthis.max.x||e.ythis.max.y)}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}getParameter(e,t){return t===void 0&&(console.warn(\"THREE.Box2: .getParameter() target is now required\"),t=new ne),t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y)}clampPoint(e,t){return t===void 0&&(console.warn(\"THREE.Box2: .clampPoint() target is now required\"),t=new ne),t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return Kv.copy(e).clamp(this.min,this.max).sub(e).length()}intersect(e){return this.min.max(e.min),this.max.min(e.max),this}union(e){return this.min.min(e.min),this.max.max(e.max),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)}};Hs.prototype.isBox2=!0;var $v=new E,Ku=new E,ex=class{constructor(e=new E,t=new E){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e===void 0&&(console.warn(\"THREE.Line3: .getCenter() target is now required\"),e=new E),e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e===void 0&&(console.warn(\"THREE.Line3: .delta() target is now required\"),e=new E),e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return t===void 0&&(console.warn(\"THREE.Line3: .at() target is now required\"),t=new E),this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){$v.subVectors(e,this.start),Ku.subVectors(this.end,this.start);let i=Ku.dot(Ku),o=Ku.dot($v)/i;return t&&(o=Fe.clamp(o,0,1)),o}closestPointToPoint(e,t,i){let r=this.closestPointToPointParameter(e,t);return i===void 0&&(console.warn(\"THREE.Line3: .closestPointToPoint() target is now required\"),i=new E),this.delta(i).multiplyScalar(r).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}};function $u(n){ke.call(this),this.material=n,this.render=function(){},this.hasPositions=!1,this.hasNormals=!1,this.hasColors=!1,this.hasUvs=!1,this.positionArray=null,this.normalArray=null,this.colorArray=null,this.uvArray=null,this.count=0}$u.prototype=Object.create(ke.prototype);$u.prototype.constructor=$u;$u.prototype.isImmediateRenderObject=!0;var Ur=new E,ef=new ve,Id=new ve,tx=class extends Nu{constructor(e){let t=nx(e),i=new $e,r=[],o=[],s=new Me(0,0,1),a=new Me(0,1,0);for(let c=0;c canvas {\n max-width: 100%;\n max-height: 100%;\n}\n\n.wrapper.invisible {\n opacity: 0;\n}\n`);var lx=1e-8,fD=!0,hD=!0,Fd=500,pD=50,cx=.75;function ux(n){return(Math.exp(1-n)-(1-n))/(1-Math.E)+1}var Nd=class{constructor(e,t,i,r){this.startTimestamp=e;this.momentumX=t;this.momentumY=i;this.callback=r;this.scheduler=new Ki(this.render.bind(this));this.scheduler.requestAnimFrame(),this.lastTimestamp=e}render(e){let t=(this.lastTimestamp-this.startTimestamp)/Fd,i=Math.min(1,(e-this.startTimestamp)/Fd);if(t===0&&i>pD/Fd)return;let r=ux(i)-ux(t);this.callback(this.momentumX*r*1e3,this.momentumY*r*1e3),i<1&&this.scheduler.requestAnimFrame(),this.lastTimestamp=e}},Bd=class{constructor(e,t,i){this.camera=e;this.canvas=t;this.scheduleRender=i;this.experimentalInertia=fD;this.experimentalLatitudeLimits=hD;this.lastTouchClientX=0;this.lastTouchClientY=0;this.currentTouchID=null;this.onMoveBound=this.onMove.bind(this);this.onMouseMoveBound=this.onMouseMove.bind(this);this.onMouseEndBound=this.onMouseEnd.bind(this);this.onTouchMoveBound=this.onTouchMove.bind(this);this.onTouchEndBound=this.onTouchEnd.bind(this);this.tempSpherical=new zd;this.lastTouchTimestamp=0;this.lastTouchMoveMomentumX=0;this.lastTouchMoveMomentumY=0;this.lastMouseTimestamp=0;this.lastMouseMoveMomentumX=0;this.lastMouseMoveMomentumY=0;this.experimentalHasBeenMoved=!1;t.addEventListener(\"mousedown\",this.onMouseStart.bind(this)),t.addEventListener(\"touchstart\",this.onTouchStart.bind(this))}temperMovement(e){return Math.sign(e)*Math.log(Math.abs(e*10)+1)/6}onMouseStart(e){window.addEventListener(\"mousemove\",this.onMouseMoveBound),window.addEventListener(\"mouseup\",this.onMouseEndBound),this.onStart(e),this.lastMouseTimestamp=e.timeStamp}onMouseMove(e){if(e.buttons===0){this.onMouseEnd(e);return}let t=Math.min(this.canvas.offsetWidth,this.canvas.offsetHeight),i=this.temperMovement(e.movementX/t),r=this.temperMovement(e.movementY/t*cx);this.onMove(i,r),this.lastMouseMoveMomentumX=i/(e.timeStamp-this.lastMouseTimestamp),this.lastMouseMoveMomentumY=r/(e.timeStamp-this.lastMouseTimestamp),this.lastMouseTimestamp=e.timeStamp}onMouseEnd(e){window.removeEventListener(\"mousemove\",this.onMouseMoveBound),window.removeEventListener(\"mouseup\",this.onMouseEndBound),this.onEnd(e),this.experimentalInertia&&new Nd(this.lastMouseTimestamp,this.lastMouseMoveMomentumX,this.lastMouseMoveMomentumY,this.onMoveBound)}onTouchStart(e){this.currentTouchID===null&&(this.currentTouchID=e.changedTouches[0].identifier,this.lastTouchClientX=e.touches[0].clientX,this.lastTouchClientY=e.touches[0].clientY,window.addEventListener(\"touchmove\",this.onTouchMoveBound),window.addEventListener(\"touchend\",this.onTouchEndBound),window.addEventListener(\"touchcanel\",this.onTouchEndBound),this.onStart(e),this.lastTouchTimestamp=e.timeStamp)}onTouchMove(e){for(let t=0;t=o+1e3&&(a.update(s*1e3/(f-o),100),o=f,s=0,c)){var u=performance.memory;c.update(u.usedJSHeapSize/1048576,u.jsHeapSizeLimit/1048576)}return f},update:function(){r=this.end()},domElement:e,setMode:i}};Do.Panel=function(n,e,t){var i=Infinity,r=0,o=Math.round,s=o(window.devicePixelRatio||1),a=80*s,l=48*s,c=3*s,f=2*s,u=3*s,h=15*s,p=74*s,d=30*s,g=document.createElement(\"canvas\");g.width=a,g.height=l,g.style.cssText=\"width:80px;height:48px\";var v=g.getContext(\"2d\");return v.font=\"bold \"+9*s+\"px Helvetica,Arial,sans-serif\",v.textBaseline=\"top\",v.fillStyle=t,v.fillRect(0,0,a,l),v.fillStyle=e,v.fillText(n,c,f),v.fillRect(u,h,p,d),v.fillStyle=t,v.globalAlpha=.9,v.fillRect(u,h,p,d),{dom:g,update:function(y,m){i=Math.min(i,y),r=Math.max(r,y),v.fillStyle=t,v.globalAlpha=1,v.fillRect(0,0,a,h),v.fillStyle=e,v.fillText(o(y)+\" \"+n+\" (\"+o(i)+\"-\"+o(r)+\")\",c,f),v.drawImage(g,u+s,h,p-s,d,u,h,p-s,d),v.fillRect(u+p-s,h,s,d),v.fillStyle=t,v.globalAlpha=.9,v.fillRect(u+p-s,h,s,o((1-y/m)*d))}}};var dD=!1;var mD=!1;var nf=null;function fx(){return new ft({antialias:!0,alpha:!0})}function gD(){return nf!=null?nf:nf=fx()}var Fl,qs,Lo,rf,js=class extends sn{constructor(e,t={}){super();ce(this,Lo);this.legacyExperimentalShift=0;this.scheduler=new Ki(this.render.bind(this));this.resizePending=!1;this.stats=null;ce(this,Fl,!1);ce(this,qs,null);var r,o;this.addCSS(ax),this.scene=e,(r=this.scene)==null||r.addRenderTarget(this),dD&&(this.stats=Do(),this.stats.dom.style.position=\"absolute\",this.addElement(this.stats.dom)),this.rendererIsShared=mD,this.renderer=this.rendererIsShared?gD():fx(),this.canvas=this.rendererIsShared?document.createElement(\"canvas\"):this.renderer.domElement,this.canvas2DContext=this.canvas.getContext(\"2d\"),this.addElement(this.canvas),this.camera=new on(20,1,.1,20),this.camera.position.copy((o=t.experimentalCameraPosition)!=null?o:new E(2,4,4)),t.negateCameraPosition&&this.camera.position.multiplyScalar(-1),this.camera.lookAt(new E(0,0,0)),this.orbitControls=new Bd(this.camera,this.canvas,this.scheduleRender.bind(this)),new ResizeObserver(this.onResize.bind(this)).observe(this.contentWrapper)}setMirror(e){this.orbitControls.setMirror(e.orbitControls),e.orbitControls.setMirror(this.orbitControls)}experimentalSetLatitudeLimits(e){this.orbitControls.experimentalLatitudeLimits=e}connectedCallback(){Ke(this,Lo,rf).call(this),this.render()}scheduleRender(){this.scheduler.requestAnimFrame()}makeInvisibleUntilRender(){this.contentWrapper.classList.add(\"invisible\"),ye(this,Fl,!0)}experimentalSetOnRenderFinish(e){ye(this,qs,e)}render(){var e,t;(e=this.stats)==null||e.begin(),this.scheduler.cancelAnimFrame(),this.resizePending&&Ke(this,Lo,rf).call(this),this.rendererIsShared&&(this.renderer.setSize(this.canvas.width,this.canvas.height,!1),this.canvas2DContext.clearRect(0,0,this.canvas.width,this.canvas.height)),this.scene&&this.renderer.render(this.scene,this.camera),this.rendererIsShared&&this.canvas2DContext.drawImage(this.renderer.domElement,0,0),M(this,Fl)&&this.contentWrapper.classList.remove(\"invisible\"),(t=this.stats)==null||t.end(),M(this,qs)&&M(this,qs).call(this)}onResize(){this.resizePending=!0,this.scheduleRender()}renderToDataURL(e={}){Ke(this,Lo,rf).call(this,e.minWidth,e.minHeight),this.render();let t;if(!e.squareCrop||this.canvas.width===this.canvas.height)t=this.canvas.toDataURL();else{let i=document.createElement(\"canvas\"),r=Math.min(this.canvas.width,this.canvas.height);i.width=r,i.height=r,i.getContext(\"2d\").drawImage(this.canvas,-(this.canvas.width-r)/2,-(this.canvas.height-r)/2),t=i.toDataURL()}return Ke(this,Lo,rf).call(this),t}};Fl=new WeakMap,qs=new WeakMap,Lo=new WeakSet,rf=function(e=0,t=0){this.resizePending=!1;let i=Math.max(this.contentWrapper.clientWidth,e),r=Math.max(this.contentWrapper.clientHeight,t),o=0;this.legacyExperimentalShift>0?o=Math.max(0,Math.floor((i-r)*.5)):this.legacyExperimentalShift<0&&(o=-Math.max(0,Math.floor((i-r)*.5)));let s=0,a=0;r>i&&(a=r-i,s=-Math.floor(.5*a)),this.camera.aspect=i/r,this.camera.setViewOffset(i,r-a,o,s,i,r),this.camera.updateProjectionMatrix(),this.rendererIsShared?(this.canvas.width=i*tf(),this.canvas.height=r*tf(),this.canvas.style.width=i.toString(),this.canvas.style.height=i.toString()):(this.renderer.setPixelRatio(tf()),this.renderer.setSize(i,r,!0)),this.scheduleRender()};Ct.define(\"twisty-3d-canvas\",js);nt();nt();var hx=class extends An{constructor(e){super();this.metric=e}traverseAlg(e){let t=0;for(let i of e.units())t+=this.traverseUnit(i);return t}traverseGrouping(e){let t=e.alg;return this.traverseAlg(t)*Math.abs(e.amount)}traverseMove(e){return this.metric(e)}traverseCommutator(e){return 2*(this.traverseAlg(e.A)+this.traverseAlg(e.B))}traverseConjugate(e){return 2*this.traverseAlg(e.A)+this.traverseAlg(e.B)}traversePause(e){return 0}traverseNewline(e){return 0}traverseLineComment(e){return 0}};function yD(n){return\"A\"<=n&&n<=\"Z\"}function vD(n){let e=n.family;return yD(e[0])&&e[e.length-1]===\"v\"||e===\"x\"||e===\"y\"||e===\"z\"||e===\"T\"?0:1}var px=new hx(vD),of=px.traverseAlg.bind(px);nt();var dx=class extends An{traverseAlg(e){let t=0;for(let i of e.units())t+=this.traverseUnit(i);return t}traverseGrouping(e){return this.traverseAlg(e.alg)*Math.abs(e.amount)}traverseMove(e){return 1}traverseCommutator(e){return 2*(this.traverseAlg(e.A)+this.traverseAlg(e.B))}traverseConjugate(e){return 2*this.traverseAlg(e.A)+this.traverseAlg(e.B)}traversePause(e){return 1}traverseNewline(e){return 0}traverseLineComment(e){return 0}},mx=new dx,Od=mx.traverseAlg.bind(mx);nt();function sf(n){return n*n*n*(10-n*(15-6*n))}nt();var af=class{constructor(e){e?typeof e==\"string\"?this.setString(e):this.setValue(e):this.setValue(this.defaultValue())}setString(e){return this.string===e?!1:(this.string=e,this.value=this.toValue(e),!0)}setValue(e){let t=this.toString(e);return this.string===t?!1:(this.string=t,this.value=e,!0)}defaultValue(){return new le([])}toValue(e){return le.fromString(e)}toString(e){return e.toString()}},yi=class{constructor(e,t){this.enumVal=e;this.setString(t!=null?t:this.defaultValue())}setString(e){if(this.string===e)return!1;if(!(e in this.enumVal))throw new Error(`Invalid string for attribute!: ${e}`);return this.string=e,this.value=this.toValue(e),!0}setValue(e){return this.setString(e)}defaultValue(){return Object.keys(this.enumVal)[0]}toValue(e){return e}};var Nl,Ud=class{constructor(e,t){ce(this,Nl,void 0);ye(this,Nl,e),this.setValue(t!=null?t:this.defaultValue())}setString(e){return this.setValue(e===\"\"?null:this.toValue(e))}setValue(e){let t=this.toString(e);return this.string===t?!1:(this.string=t,this.value=e,!0)}defaultValue(){return M(this,Nl)}toValue(e){if(!e.startsWith(\"[\"))throw new Error(\"TODO\");if(!e.endsWith(\"]\"))throw new Error(\"TODO\");let t=e.slice(1,e.length-1).split(\",\");if(t.length!==3)throw new Error(\"TODO\");let[i,r,o]=t.map(s=>parseInt(s,10));return new E(i,r,o)}toString(e){return e?`[${e.x}, ${e.y}, ${e.z}]`:\"\"}};Nl=new WeakMap;var Wr,Ii=class{constructor(e,t,i){this.elem=e;this.prefix=t;this.validSuffixes=i;ce(this,Wr,null)}clearValue(){M(this,Wr)&&this.elem.contentWrapper.classList.remove(M(this,Wr)),ye(this,Wr,null)}setValue(e){if(!this.validSuffixes.includes(e))throw new Error(`Invalid suffix: ${e}`);let t=`${this.prefix}${e}`,i=M(this,Wr)!==t;return i&&(this.clearValue(),this.elem.contentWrapper.classList.add(t),ye(this,Wr,t)),i}};Wr=new WeakMap;var gx=new fn(`\n:host {\n width: 384px;\n height: 256px;\n display: grid;\n}\n\n.wrapper {\n width: 100%;\n height: 100%;\n display: grid;\n overflow: hidden;\n}\n\n.wrapper > * {\n width: 100%;\n height: 100%;\n overflow: hidden;\n}\n\n.wrapper.back-view-side-by-side {\n grid-template-columns: 1fr 1fr;\n}\n\n.wrapper.back-view-top-right {\n grid-template-columns: 3fr 1fr;\n grid-template-rows: 1fr 3fr;\n}\n\n.wrapper.back-view-top-right > :nth-child(1) {\n grid-row: 1 / 3;\n grid-column: 1 / 3;\n}\n\n.wrapper.back-view-top-right > :nth-child(2) {\n grid-row: 1 / 2;\n grid-column: 2 / 3;\n}\n`);var Gd={none:!0,\"side-by-side\":!0,\"top-right\":!0},Bl,lf=class extends sn{constructor(e={}){super();ce(this,Bl,new Ii(this,\"back-view-\",[\"none\",\"side-by-side\",\"top-right\"]));this.addCSS(gx),e.backView&&e.backView in Gd&&M(this,Bl).setValue(e.backView)}setBackView(e){return M(this,Bl).setValue(e)}clear(){this.contentWrapper.innerHTML=\"\"}};Bl=new WeakMap;Ct.define(\"twisty-viewer-wrapper\",lf);var yx=5,xD=yx*(2/(1+Math.sqrt(5))),vx=new E(0,xD,yx),xx=new E(3,4,5),bD={start:!0,end:!0},wD={\"3D\":!0,\"2D\":!0,\"experimental-2D-LL\":!0,PG3D:!0},MD={checkered:!0,none:!0},Wd={floating:!0,none:!0},Hd={full:!0,\"centers-only\":!0,PLL:!0,CLS:!0,OLL:!0,COLL:!0,OCLL:!0,CLL:!0,ELL:!0,ELS:!0,LL:!0,F2L:!0,ZBLL:!0,ZBLS:!0,WVLS:!0,VLS:!0,LS:!0,EO:!0,CMLL:!0,L6E:!0,L6EO:!0,Daisy:!0,Cross:!0,\"2x2x2\":!0,\"2x2x3\":!0,\"Void Cube\":!0,invisible:!0,picture:!0,\"experimental-centers-U\":!0,\"experimental-centers-U-D\":!0,\"experimental-centers-U-L-D\":!0,\"experimental-centers-U-L-B-D\":!0,\"experimental-centers\":!0,\"experimental-fto-fc\":!0,\"experimental-fto-f2t\":!0,\"experimental-fto-sc\":!0,\"experimental-fto-l2c\":!0,\"experimental-fto-lbt\":!0},SD={\"bottom-row\":!0,none:!0},ED={\"3x3x3\":!0,custom:!0,\"2x2x2\":!0,\"4x4x4\":!0,\"5x5x5\":!0,\"6x6x6\":!0,\"7x7x7\":!0,\"40x40x40\":!0,megaminx:!0,pyraminx:!0,square1:!0,clock:!0,skewb:!0,fto:!0,gigaminx:!0},_D={twizzle:!0,none:!0},bx={alg:\"alg\",\"experimental-setup-alg\":\"experimentalSetupAlg\",\"experimental-setup-anchor\":\"experimentalSetupAnchor\",puzzle:\"puzzle\",visualization:\"visualization\",\"hint-facelets\":\"hintFacelets\",\"experimental-stickering\":\"experimentalStickering\",background:\"background\",\"control-panel\":\"controlPanel\",\"back-view\":\"backView\",\"experimental-camera-position\":\"experimentalCameraPosition\",\"viewer-link\":\"viewerLink\"},cf=class{constructor(e,t){this.twistyPlayer=e;this.attributes={alg:new af(t.alg),\"experimental-setup-alg\":new af(t.experimentalSetupAlg),\"experimental-setup-anchor\":new yi(bD,t.experimentalSetupAnchor),puzzle:new yi(ED,t.puzzle),visualization:new yi(wD,t.visualization),\"hint-facelets\":new yi(Wd,t.hintFacelets),\"experimental-stickering\":new yi(Hd,t.experimentalStickering),background:new yi(MD,t.background),\"control-panel\":new yi(SD,t.controlPanel),\"back-view\":new yi(Gd,t.backView),\"experimental-camera-position\":new Ud(null,t.experimentalCameraPosition),\"viewer-link\":new yi(_D,t.viewerLink)}}static get observedAttributes(){return Object.keys(bx)}attributeChangedCallback(e,t,i){let r=this.attributes[e];if(r){t!==null&&r.string!==t&&console.warn(\"Attribute out of sync!\",e,r.string,t),r.setString(i);let o=bx[e];this.twistyPlayer[o]=r.value}}};var Hn=Math.PI*2;var wx=new Ll,TD=new zt({color:4473924,side:li}),AD=new zt({color:13421772,side:wt}),Mx=new zt({visible:!1}),DD=new zt({color:16746751}),LD=new zt({color:16746751,side:wt}),Co=class{constructor(e,t,i,r){this.vector=e;this.fromZ=t;this.color=i;this.dimColor=r;this.stickerMaterial={regular:new zt({color:i,side:li}),dim:new zt({color:r,side:li}),oriented:DD,ignored:TD,invisible:Mx},this.hintStickerMaterial={regular:new zt({color:i,side:wt}),dim:new zt({color:r,side:wt,transparent:!0,opacity:.75}),oriented:LD,ignored:AD,invisible:Mx}}},$i=[new Co(new E(0,1,0),new ln(-Hn/4,0,0),16777215,14540253),new Co(new E(-1,0,0),new ln(0,-Hn/4,0),16746496,8930304),new Co(new E(0,0,1),new ln(0,0,0),65280,34816),new Co(new E(1,0,0),new ln(0,Hn/4,0),16711680,6684672),new Co(new E(0,0,-1),new ln(0,Hn/2,0),255,136),new Co(new E(0,-1,0),new ln(Hn/4,0,0),16776960,8947712)],pt={U:0,L:1,F:2,R:3,B:4,D:5},CD={U:pt.U,u:pt.U,Uw:pt.U,y:pt.U,L:pt.L,l:pt.L,Lw:pt.L,M:pt.L,F:pt.F,f:pt.F,Fw:pt.F,S:pt.F,z:pt.F,R:pt.R,r:pt.R,Rw:pt.R,x:pt.R,B:pt.B,b:pt.B,Bw:pt.B,D:pt.D,d:pt.D,Dw:pt.D,E:pt.D},Hr={stickerWidth:.85,stickerElevation:.503,foundationWidth:1,hintStickerElevation:1.45},RD=2;var PD={showMainStickers:!0,hintFacelets:\"floating\",showFoundation:!0,experimentalStickering:\"full\"},kD=new zt({color:0,opacity:1,transparent:!0}),zD=new zt({color:0,opacity:.3,transparent:!0}),gt=class{constructor(e,t,i){this.orbit=e;let r=typeof t==\"string\"?t.split(\"\"):t;this.stickerFaces=r.map(o=>pt[o]),this.matrix=new ve,this.matrix.setPosition(uf[e]),this.matrix.premultiply(new ve().makeRotationFromQuaternion(i))}};function Ve(n,e){return new qt().setFromAxisAngle(n,Hn*e/4)}var je={O:new E(0,0,0),U:new E(0,-1,0),L:new E(1,0,0),F:new E(0,0,-1),R:new E(-1,0,0),B:new E(0,0,1),D:new E(0,1,0)},uf={EDGES:new E(0,1,1),CORNERS:new E(1,1,1),CENTERS:new E(0,1,0)},ID={EDGES:[0,1].map(n=>new ve().makeRotationAxis(uf.EDGES.clone().normalize(),-n*Hn/2)),CORNERS:[0,1,2].map(n=>new ve().makeRotationAxis(uf.CORNERS.clone().normalize(),-n*Hn/3)),CENTERS:[0,1,2,3].map(n=>new ve().makeRotationAxis(uf.CENTERS.clone().normalize(),-n*Hn/4))},Vd=[pt.U,pt.F,pt.R],Ol={EDGES:[new gt(\"EDGES\",\"UF\",Ve(je.O,0)),new gt(\"EDGES\",\"UR\",Ve(je.U,3)),new gt(\"EDGES\",\"UB\",Ve(je.U,2)),new gt(\"EDGES\",\"UL\",Ve(je.U,1)),new gt(\"EDGES\",\"DF\",Ve(je.F,2)),new gt(\"EDGES\",\"DR\",Ve(je.F,2).premultiply(Ve(je.D,1))),new gt(\"EDGES\",\"DB\",Ve(je.F,2).premultiply(Ve(je.D,2))),new gt(\"EDGES\",\"DL\",Ve(je.F,2).premultiply(Ve(je.D,3))),new gt(\"EDGES\",\"FR\",Ve(je.U,3).premultiply(Ve(je.R,3))),new gt(\"EDGES\",\"FL\",Ve(je.U,1).premultiply(Ve(je.R,3))),new gt(\"EDGES\",\"BR\",Ve(je.U,3).premultiply(Ve(je.R,1))),new gt(\"EDGES\",\"BL\",Ve(je.U,1).premultiply(Ve(je.R,1)))],CORNERS:[new gt(\"CORNERS\",\"UFR\",Ve(je.O,0)),new gt(\"CORNERS\",\"URB\",Ve(je.U,3)),new gt(\"CORNERS\",\"UBL\",Ve(je.U,2)),new gt(\"CORNERS\",\"ULF\",Ve(je.U,1)),new gt(\"CORNERS\",\"DRF\",Ve(je.F,2).premultiply(Ve(je.D,1))),new gt(\"CORNERS\",\"DFL\",Ve(je.F,2).premultiply(Ve(je.D,0))),new gt(\"CORNERS\",\"DLB\",Ve(je.F,2).premultiply(Ve(je.D,3))),new gt(\"CORNERS\",\"DBR\",Ve(je.F,2).premultiply(Ve(je.D,2)))],CENTERS:[new gt(\"CENTERS\",\"U\",Ve(je.O,0)),new gt(\"CENTERS\",\"L\",Ve(je.R,3).premultiply(Ve(je.U,1))),new gt(\"CENTERS\",\"F\",Ve(je.R,3)),new gt(\"CENTERS\",\"R\",Ve(je.R,3).premultiply(Ve(je.D,1))),new gt(\"CENTERS\",\"B\",Ve(je.R,3).premultiply(Ve(je.D,2))),new gt(\"CENTERS\",\"D\",Ve(je.R,2))]},jd=1/3,ff={EDGES:[[[0,4,6],[0,4,5]],[[3,5,7],[0,7,5]],[[2,4,8],[0,10,5]],[[1,3,7],[0,1,5]],[[2,4,2],[2,4,3]],[[3,5,1],[2,7,3]],[[2,4,2],[2,10,3]],[[1,3,1],[2,1,3]],[[3,5,4],[3,6,4]],[[1,3,4],[1,2,4]],[[1,9,4],[1,8,4]],[[3,11,4],[3,0,4]]],CORNERS:[[[0,5,6],[0,5,5],[0,6,5]],[[3,5,8],[0,8,5],[0,9,5]],[[2,3,8],[0,11,5],[0,0,5]],[[1,3,6],[0,2,5],[0,3,5]],[[3,5,2],[2,6,3],[2,5,3]],[[2,3,2],[2,3,3],[2,2,3]],[[1,3,0],[2,0,3],[2,11,3]],[[0,5,0],[2,9,3],[2,8,3]]],CENTERS:[[[0,4,7]],[[0,1,4]],[[0,4,4]],[[0,7,4]],[[0,10,4]],[[0,4,1]]]},hf=null;function FD(){return hf!=null?hf:hf=new As(Hr.foundationWidth,Hr.foundationWidth,Hr.foundationWidth)}function Sx(){let n=new $e,e=.5*Hr.stickerWidth;return n.setAttribute(\"position\",new Ne(new Float32Array([e,e,0,-e,e,0,e,-e,0,-e,e,0,-e,-e,0,e,-e,0]),3)),n.setAttribute(\"uv\",new Ne(new Float32Array([1,1,0,1,1,0,0,1,0,0,1,0,0,1,0,0,1,1,0,0,1,0,1,1]),2)),n}var pf=null;function ND(){return pf!=null?pf:pf=Sx()}var Qs=class extends ke{constructor(e,t,i,r={}){super();this.def=e;this.scheduleRenderCallback=i;this.pieces={};this.experimentalHintStickerMeshes=[];this.experimentalFoundationMeshes=[];this.sprite=new Promise(e=>{this.setSpriteURL=t=>{wx.load(t,e)}});this.hintSprite=new Promise(e=>{this.setHintSpriteURL=t=>{wx.load(t,e)}});if(this.options=y0({},PD),Object.assign(this.options,r),this.def.name!==\"3x3x3\")throw new Error(`Invalid puzzle for this Cube3D implementation: ${this.def.name}`);this.kpuzzleFaceletInfo={};for(let o in Ol){let s=[];this.kpuzzleFaceletInfo[o]=s,this.pieces[o]=Ol[o].map(this.createCubie.bind(this,o,s))}this.scale.set(jd,jd,jd),this.options.experimentalStickering&&this.setStickering(this.options.experimentalStickering),t==null||t.addPositionListener(this)}experimentalSetStickerSpriteURL(e){this.setSpriteURL(e)}experimentalSetHintStickerSpriteURL(e){this.setHintSpriteURL(e)}setStickering(e){(()=>se(this,null,function*(){let t=yield gn[\"3x3x3\"].appearance(e!=null?e:\"full\");this.setAppearance(t!=null?t:yield gn[\"3x3x3\"].appearance(\"full\"))}))()}setAppearance(e){var t;for(let[i,r]of Object.entries(e.orbits))for(let o=0;ose(this,null,function*(){let p=d=>se(this,null,function*(){let g=yield d?this.hintSprite:this.sprite,v=this.createSticker($i[Vd[a]],$i[i.stickerFaces[a]],d);v.material=new zt({map:g,side:d?wt:li,transparent:!0});let y=u/12,m=(u+1)/12,S=h/9,b=(h+1)/9,w=new ne(y,S),x=new ne(y,b),A=new ne(m,b),O=new ne(m,S);switch(f){case 1:[w,x,A,O]=[x,A,O,w];break;case 2:[w,x,A,O]=[A,O,w,x];break;case 3:[w,x,A,O]=[O,w,x,A];break}v.geometry.setAttribute(\"uv\",new Ne(new Float32Array([A.x,A.y,x.x,x.y,O.x,O.y,x.x,x.y,w.x,w.y,O.x,O.y]),2)),s.add(v)});p(!0),p(!1)}))()}o.push(c)}return s.matrix.copy(i.matrix),s.matrixAutoUpdate=!1,this.add(s),s}createCubieFoundation(){let e=FD();return new St(e,this.options.experimentalStickering===\"picture\"?kD:zD)}createSticker(e,t,i){let r=this.options.experimentalStickering===\"picture\"?Sx():ND(),o=new St(r,i?t.hintStickerMaterial.regular:t.stickerMaterial.regular);return o.setRotationFromEuler(e.fromZ),o.position.copy(e.vector),o.position.multiplyScalar(i?this.options.experimentalStickering===\"picture\"?RD:Hr.hintStickerElevation:Hr.stickerElevation),o}experimentalSetFoundationOpacity(e){this.experimentalFoundationMeshes[0].material.opacity=e}experimentalSetStickerWidth(e){for(let t of Object.values(this.kpuzzleFaceletInfo))for(let i of t)for(let r of i)r.facelet.scale.setScalar(e/Hr.stickerWidth)}experimentalSetCenterStickerWidth(e){for(let t of[this.kpuzzleFaceletInfo.CENTERS])for(let i of t)for(let r of i)r.facelet.scale.setScalar(e/Hr.stickerWidth)}ease(e){return sf(e)}};var Ex=new zt({side:li,color:0}),_x=new zt({vertexColors:!0}),Ul=new zt({visible:!1}),qd=class{constructor(e,t=!0){this.sz=e;this.colored=t;this.vertices=new Float32Array(9*e),t&&(this.colors=new Uint8Array(9*e),this.ind=new Uint8Array(e)),this.pos=0,this.ipos=0}add(e,t){this.vertices[this.pos]=e[0],this.vertices[this.pos+1]=e[1],this.vertices[this.pos+2]=e[2],this.colors[this.pos]=t>>16,this.colors[this.pos+1]=t>>8&255,this.colors[this.pos+2]=t&255,this.pos+=3}addUncolored(e){this.vertices[this.pos]=e[0],this.vertices[this.pos+1]=e[1],this.vertices[this.pos+2]=e[2],this.pos+=3}setind(e){this.ind[this.ipos++]=e}setAttributes(e){e.setAttribute(\"position\",new Ne(this.vertices,3)),this.colored&&e.setAttribute(\"color\",new Ne(this.colors,3,!0))}makeGroups(e){e.clearGroups();for(let t=0;ta&&(a=p,l=h)}let c=new E;l.getNormal(c),c.multiplyScalar(.5);let f=[];for(let u=0;u>16,i=e>>8&255,r=e&255;for(let o of this.faceArray)for(let s=0;s<9;s+=3)this.filler.colors[9*o+s]=t,this.filler.colors[9*o+s+1]=i,this.filler.colors[9*o+s+2]=r;return 1}else return 0}},Ax=class{constructor(e){this.cubie=new zi;let t=e.coords,i=new qd(t.length-2,!0);for(let o=1;o+10;)t%2==1&&(i=this.combine(i,e)),t=Math.floor(t/2),t>0&&(e=this.combine(e,e));return i}},vi=class extends Lx{constructor(e){super();this.definition=e;this.moveCache={}}static fromID(e){return se(this,null,function*(){return new vi(yield gn[e].def())})}startState(){return this.definition.startPieces}invert(e){return xr(this.definition,e)}combine(e,t){return Nn(this.definition,e,t)}stateFromMove(e){let t=e.toString();return this.moveCache[t]||(this.moveCache[t]=br(this.definition,e)),this.moveCache[t]}identity(){return vr(this.definition)}equivalent(e,t){return Bh(this.definition,e,t)}};nt();nt();var BD=16;function OD(n,e){let t=new co,i=new co;for(let r of n.units())i.push(r),i.experimentalNumUnits()>=e&&(t.push(new Kt(i.toAlg())),i.reset());return t.push(new Kt(i.toAlg())),t.toAlg()}var Cx=class extends An{traverseAlg(e){let t=e.experimentalNumUnits();return t=0&&this.i===e?this.move!==void 0:this.dosearch(e,Infinity)}moveByDuration(e){return this.dur>=0&&this.dur=e?this.move!==void 0:this.dosearch(Infinity,e)}dosearch(e,t){return this.goali=e,this.goaldur=t,this.i=0,this.dur=0,this.move=void 0,this.moveDuration=0,this.back=!1,this.st=this.puz.identity(),this.algOrUnit.is(le)?this.traverseAlg(this.algOrUnit,this.root):this.traverseUnit(this.algOrUnit,this.root)}traverseAlg(e,t){if(!this.firstcheck(t))return!1;let i=t.back?e.experimentalNumUnits()-1:0;for(let r of _h(e.units(),t.back?Pe.Backwards:Pe.Forwards)){if(this.traverseUnit(r,new Gt(t.apd.children[i],t.back)))return!0;i+=t.back?-1:1}return!1}traverseGrouping(e,t){if(!this.firstcheck(t))return!1;let i=this.domult(t,e.amount);return this.traverseAlg(e.alg,new Gt(t.apd.children[0],i))}traverseMove(e,t){return this.firstcheck(t)?(this.move=e,this.moveDuration=t.apd.duration,this.back=t.back,!0):!1}traverseCommutator(e,t){if(!this.firstcheck(t))return!1;let i=this.domult(t,1);return i?this.traverseAlg(e.B,new Gt(t.apd.children[2],!i))||this.traverseAlg(e.A,new Gt(t.apd.children[1],!i))||this.traverseAlg(e.B,new Gt(t.apd.children[2],i))||this.traverseAlg(e.A,new Gt(t.apd.children[1],i)):this.traverseAlg(e.A,new Gt(t.apd.children[1],i))||this.traverseAlg(e.B,new Gt(t.apd.children[2],i))||this.traverseAlg(e.A,new Gt(t.apd.children[1],!i))||this.traverseAlg(e.B,new Gt(t.apd.children[2],!i))}traverseConjugate(e,t){if(!this.firstcheck(t))return!1;let i=this.domult(t,1);return i?this.traverseAlg(e.A,new Gt(t.apd.children[1],!i))||this.traverseAlg(e.B,new Gt(t.apd.children[2],i))||this.traverseAlg(e.A,new Gt(t.apd.children[1],i)):this.traverseAlg(e.A,new Gt(t.apd.children[1],i))||this.traverseAlg(e.B,new Gt(t.apd.children[2],i))||this.traverseAlg(e.A,new Gt(t.apd.children[1],!i))}traversePause(e,t){return this.firstcheck(t)?(this.move=e,this.moveDuration=t.apd.duration,this.back=t.back,!0):!1}traverseNewline(e,t){return!1}traverseLineComment(e,t){return!1}firstcheck(e){return e.apd.moveCount+this.i<=this.goali&&e.apd.duration+this.dur0&&this.keepgoing(new Gt(r,i),o),i}keepgoing(e,t=1){return this.i+=t*e.apd.moveCount,this.dur+=t*e.apd.duration,t!==1?e.back?this.st=this.puz.combine(this.st,this.puz.multiply(e.apd.backward,t)):this.st=this.puz.combine(this.st,this.puz.multiply(e.apd.forward,t)):e.back?this.st=this.puz.combine(this.st,e.apd.backward):this.st=this.puz.combine(this.st,e.apd.forward),!1}};var xi=class{constructor(e,t){this.puzzle=e;let i=new Xd(this.puzzle),r=Px(t);this.decoration=i.traverseAlg(r),this.walker=new Zd(this.puzzle,r,this.decoration)}getMove(e){if(this.walker.moveByIndex(e)){if(!this.walker.move)throw new Error(\"`this.walker.mv` missing\");let t=this.walker.move;return this.walker.back?t.invert():t}return null}indexToMoveStartTimestamp(e){if(this.walker.moveByIndex(e)||this.walker.i===e)return this.walker.dur;throw new Error(\"Out of algorithm: index \"+e)}indexToMovesInProgress(e){if(this.walker.moveByIndex(e)||this.walker.i===e)return this.walker.dur;throw new Error(\"Out of algorithm: index \"+e)}stateAtIndex(e,t){return this.walker.moveByIndex(e),this.puzzle.combine(t!=null?t:this.puzzle.startState(),this.walker.st)}transformAtIndex(e){return this.walker.moveByIndex(e),this.walker.st}numMoves(){return this.decoration.moveCount}timestampToIndex(e){return this.walker.moveByDuration(e),this.walker.i}algDuration(){return this.decoration.duration}moveDuration(e){return this.walker.moveByIndex(e),this.walker.moveDuration}};var It;(function(i){i[i.Forwards=1]=\"Forwards\",i[i.Paused=0]=\"Paused\",i[i.Backwards=-1]=\"Backwards\"})(It||(It={}));function df(n){return n}var Vn;(function(t){t[t.Move=0]=\"Move\",t[t.EntireTimeline=1]=\"EntireTimeline\"})(Vn||(Vn={}));var mf=class{constructor(e,t,i,r,o){this.timeline=e;this.def=t;this.alg=i;this.positionListeners=new Set;this.indexerConstructor=xi;this.ksolvePuzzle=new vi(t),o&&(this.indexerConstructor=this.indexerConstructor),this.instantiateIndexer(i),this.startState=r?this.algToState(r):this.ksolvePuzzle.startState(),e.addTimestampListener(this)}setStartState(e){this.startState=e,this.dispatchPositionForTimestamp(this.timeline.timestamp)}experimentalSetIndexer(e){this.indexerConstructor=e,this.instantiateIndexer(this.alg),this.timeline.onCursorChange(this),this.dispatchPositionForTimestamp(this.timeline.timestamp)}instantiateIndexer(e){this.indexer=new this.indexerConstructor(this.ksolvePuzzle,e)}algToState(e){let t=new Yn(this.def);return t.applyAlg(e),this.ksolvePuzzle.combine(this.def.startPieces,t.state)}timeRange(){return{start:0,end:this.indexer.algDuration()}}experimentalTimestampForStartOfLastMove(){let e=this.indexer.numMoves();return e>0?this.indexer.indexToMoveStartTimestamp(e-1):0}addPositionListener(e){this.positionListeners.add(e),this.dispatchPositionForTimestamp(this.timeline.timestamp,[e])}removePositionListener(e){this.positionListeners.delete(e)}onTimelineTimestampChange(e){this.dispatchPositionForTimestamp(e)}dispatchPositionForTimestamp(e,t=this.positionListeners){var r;let i;if(this.indexer.timestampToPosition)i=this.indexer.timestampToPosition(e,this.startState);else{let o=this.indexer.timestampToIndex(e),s=this.indexer.stateAtIndex(o,this.startState);if(i={state:s,movesInProgress:[]},this.indexer.numMoves()>0){let a=(r=this.indexer.getMove(o))==null?void 0:r.as(k);if(!a)return;let l=(e-this.indexer.indexToMoveStartTimestamp(o))/this.indexer.moveDuration(o);l===1?i.state=this.ksolvePuzzle.combine(s,this.ksolvePuzzle.stateFromMove(a)):l>0&&a&&i.movesInProgress.push({move:a,direction:It.Forwards,fraction:l})}}for(let o of t)o.onPositionChange(i)}onTimeRangeChange(e){}setAlg(e,t){t!=null||(t=this.indexerConstructor),!(e.isIdentical(this.alg)&&this.indexerConstructor===t)&&(this.indexerConstructor=t,this.alg=e,this.instantiateIndexer(e),this.timeline.onCursorChange(this),this.dispatchPositionForTimestamp(this.timeline.timestamp))}moveBoundary(e,t){if(this.indexer.numMoves()===0)return null;let i=df(t)*.001,r=this.indexer.timestampToIndex(e+i),o=this.indexer.indexToMoveStartTimestamp(r);if(t===It.Backwards)return e>=o?o:null;{let s=o+this.indexer.moveDuration(r);return e<=s?s:null}}setPuzzle(e,t=this.alg,i){this.ksolvePuzzle=new vi(e),this.def=e,this.indexer=new this.indexerConstructor(this.ksolvePuzzle,t),t!==this.alg&&this.timeline.onCursorChange(this),this.setStartState(i?this.algToState(i):this.ksolvePuzzle.startState()),this.alg=t}experimentalTimestampFromIndex(e){return this.indexer.indexToMoveStartTimestamp(e)}experimentalIndexFromTimestamp(e){return this.indexer.timestampToIndex(e)}experimentalMoveAtIndex(e){return this.indexer.getMove(e)}};nt();var gf=class{constructor(e,t){this.puzzle=e;this.durationFn=new Gl(tr);this.moves=new le(t.experimentalExpand())}getMove(e){return Array.from(this.moves.units())[e]}indexToMoveStartTimestamp(e){let t=new le(Array.from(this.moves.units()).slice(0,e));return this.durationFn.traverseAlg(t)}timestampToIndex(e){let t=0,i;for(i=0;i=e)return i;return i}stateAtIndex(e){return this.puzzle.combine(this.puzzle.startState(),this.transformAtIndex(e))}transformAtIndex(e){let t=this.puzzle.identity();for(let i of Array.from(this.moves.units()).slice(0,e))t=this.puzzle.combine(t,this.puzzle.stateFromMove(i));return t}algDuration(){return this.durationFn.traverseAlg(this.moves)}numMoves(){return Od(this.moves)}moveDuration(e){return this.durationFn.traverseMove(this.getMove(e))}};nt();nt();var kx={u:\"y\",l:\"x\",f:\"z\",r:\"x\",b:\"z\",d:\"y\",m:\"x\",e:\"y\",s:\"z\",x:\"x\",y:\"y\",z:\"z\"};function UD(n,e){return kx[n.family[0].toLowerCase()]===kx[e.family[0].toLowerCase()]}var zx=class extends An{traverseAlg(e){let t=[];for(let i of e.units())t.push(this.traverseUnit(i));return Array.prototype.concat(...t)}traverseGroupingOnce(e){if(e.experimentalIsEmpty())return[];for(let o of e.units())if(!o.is(k))return this.traverseAlg(e);let t=Array.from(e.units()),i=tr(t[0].amount);for(let o=0;o({move:o,msUntilNext:0,duration:i}));return r[r.length-1].msUntilNext=i,r}traverseGrouping(e){let t=[],i=e.amount>0?e.alg:e.alg.invert();for(let r=0;r{let r={move:i.move,start:e,end:e+i.duration};return e+=i.msUntilNext,r})}var WD={\"y' y' U' E D R2 r2 F2 B2 U E D' R2 L2' z2 S2 U U D D S2 F2' B2\":[{move:new k(\"y\",-1),start:0,end:1e3},{move:new k(\"y\",-1),start:1e3,end:2e3},{move:new k(\"U\",-1),start:1e3,end:1600},{move:new k(\"E\",1),start:1200,end:1800},{move:new k(\"D\"),start:1400,end:2e3},{move:new k(\"R\",2),start:2e3,end:3500},{move:new k(\"r\",2),start:2e3,end:3500},{move:new k(\"F\",2),start:3500,end:4200},{move:new k(\"B\",2),start:3800,end:4500},{move:new k(\"U\",1),start:4500,end:5500},{move:new k(\"E\",1),start:4500,end:5500},{move:new k(\"D\",-1),start:4500,end:5500},{move:new k(\"R\",2),start:5500,end:6500},{move:new k(\"L\",-2),start:5500,end:6500},{move:new k(\"z\",2),start:5500,end:6500},{move:new k(\"S\",2),start:6500,end:7500},{move:new k(\"U\"),start:7500,end:8e3},{move:new k(\"U\"),start:8e3,end:8500},{move:new k(\"D\"),start:7750,end:8250},{move:new k(\"D\"),start:8250,end:8750},{move:new k(\"S\",2),start:8750,end:9250},{move:new k(\"F\",-2),start:8750,end:1e4},{move:new k(\"B\",2),start:8750,end:1e4}],\"M' R' U' D' M R\":[{move:new k(\"M\",-1),start:0,end:1e3},{move:new k(\"R\",-1),start:0,end:1e3},{move:new k(\"U\",-1),start:1e3,end:2e3},{move:new k(\"D\",-1),start:1e3,end:2e3},{move:new k(\"M\"),start:2e3,end:3e3},{move:new k(\"R\"),start:2e3,end:3e3}],\"U' E' r E r2' E r U E\":[{move:new k(\"U\",-1),start:0,end:1e3},{move:new k(\"E\",-1),start:0,end:1e3},{move:new k(\"r\"),start:1e3,end:2500},{move:new k(\"E\"),start:2500,end:3500},{move:new k(\"r\",-2),start:3500,end:5e3},{move:new k(\"E\"),start:5e3,end:6e3},{move:new k(\"r\"),start:6e3,end:7e3},{move:new k(\"U\"),start:7e3,end:8e3},{move:new k(\"E\"),start:7e3,end:8e3}]},Jd=class{constructor(e,t){this.puzzle=e;var i;this.moves=(i=WD[t.toString()])!=null?i:Fx(t)}getMove(e){return this.moves[Math.min(e,this.moves.length-1)].move}getMoveWithRange(e){return this.moves[Math.min(e,this.moves.length-1)]}indexToMoveStartTimestamp(e){let t=0;return this.moves.length>0&&(t=this.moves[Math.min(e,this.moves.length-1)].start),t}timestampToIndex(e){let t=0;for(t=0;t=e)return Math.max(0,t-1);return Math.max(0,t-1)}timestampToPosition(e,t){let i={state:t!=null?t:this.puzzle.identity(),movesInProgress:[]};for(let r of this.moves)if(r.end<=e)i.state=this.puzzle.combine(i.state,this.puzzle.stateFromMove(r.move));else if(r.start{if(this.animating){let i=Kd();this.timestamp=this.timestamp+this.tempoScale*df(this.direction)*(i-this.lastAnimFrameNow),this.lastAnimFrameNow=i,(this.direction===It.Backwards?this.timestamp<=this.cachedNextBoundary:this.timestamp>=this.cachedNextBoundary)&&(this.timestamp=this.cachedNextBoundary,this.animating&&(this.animating=!1,this.dispatchAction(hn.Pausing)))}this.timestamp!==this.lastAnimFrameTimestamp&&(this.dispatchTimestamp(),this.lastAnimFrameTimestamp=this.timestamp),this.animating&&this.scheduler.requestAnimFrame()};this.scheduler=new Ki(e)}addCursor(e){this.cursors.add(e),this.dispatchTimeRange()}removeCursor(e){this.cursors.delete(e),this.clampTimestampToRange(),this.dispatchTimeRange()}clampTimestampToRange(){let e=this.timeRange();this.timestampe.end&&this.setTimestamp(e.end)}onCursorChange(e){this.timestamp>this.maxTimestamp()&&(this.timestamp=this.maxTimestamp()),this.dispatchTimeRange()}timeRange(){let e=0,t=0;for(let i of this.cursors){let r=i.timeRange();e=Math.min(e,r.start),t=Math.max(t,r.end)}return{start:e,end:t}}minTimestamp(){return this.timeRange().start}maxTimestamp(){return this.timeRange().end}dispatchTimeRange(){let e=this.timeRange();for(let t of this.cursors)t.onTimeRangeChange(e);for(let t of this.timestampListeners)t.onTimeRangeChange(e)}dispatchTimestamp(){for(let e of this.cursors)e.onTimelineTimestampChange(this.timestamp);for(let e of this.timestampListeners)e.onTimelineTimestampChange(this.timestamp)}addTimestampListener(e){this.timestampListeners.add(e)}removeTimestampListener(e){this.timestampListeners.delete(e)}addActionListener(e){this.actionListeners.add(e)}removeActionListener(e){this.actionListeners.delete(e)}play(){this.experimentalPlay(It.Forwards,Vn.EntireTimeline)}experimentalPlay(e,t=Vn.EntireTimeline){this.direction=e,this.boundaryType=t;let i=this.nextBoundary(this.timestamp,e,this.boundaryType);i!==null&&(this.cachedNextBoundary=i,this.animating||(this.animating=!0,this.lastAnimFrameNow=Kd(),this.dispatchAction(hn.StartingToPlay),this.scheduler.requestAnimFrame()))}nextBoundary(e,t,i=Vn.EntireTimeline){switch(i){case Vn.EntireTimeline:switch(t){case It.Backwards:return e<=this.minTimestamp()?null:this.minTimestamp();case It.Forwards:return e>=this.maxTimestamp()?null:this.maxTimestamp();default:throw new Error(\"invalid direction\")}case Vn.Move:{let r=null;for(let o of this.cursors){let s=o.moveBoundary(e,t);if(s!==null)switch(t){case It.Backwards:{r=Math.min(r!=null?r:s,s);break}case It.Forwards:{r=Math.max(r!=null?r:s,s);break}default:throw new Error(\"invalid direction\")}}return r}default:throw new Error(\"invalid boundary type\")}}pause(){this.animating&&(this.animating=!1,this.dispatchAction(hn.Pausing),this.scheduler.requestAnimFrame())}playPause(){this.animating?this.pause():(this.timestamp>=this.maxTimestamp()&&(this.timestamp=0),this.experimentalPlay(It.Forwards,Vn.EntireTimeline))}setTimestamp(e){let t=this.timestamp;this.timestamp=e,this.lastAnimFrameNow=Kd(),t!==e&&(this.dispatchAction(hn.Jumping),this.scheduler.requestAnimFrame()),HD&&(this.animating=!1,this.dispatchAction(hn.Pausing))}jumpToStart(){this.setTimestamp(this.minTimestamp())}jumpToEnd(){this.setTimestamp(this.maxTimestamp())}experimentalJumpToLastMove(){var t;let e=0;for(let i of this.cursors)e=Math.max(e,(t=i.experimentalTimestampForStartOfLastMove())!=null?t:0);this.setTimestamp(e)}dispatchAction(e){let t=jn.MiddleOfMove;switch(this.timestamp){case this.minTimestamp():t=jn.StartOfTimeline;break;case this.maxTimestamp():t=jn.EndOfTimeline;break}let i={action:e,locationType:t};for(let r of this.actionListeners)r.onTimelineAction(i)}};var Nx=new fn(`\n:host {\n width: 384px;\n height: 24px;\n display: grid;\n}\n\n.wrapper {\n width: 100%;\n height: 100%;\n display: grid;\n overflow: hidden;\n backdrop-filter: blur(4px);\n -webkit-backdrop-filter: blur(4px);\n}\n\n.wrapper {\n grid-auto-flow: column;\n}\n\n.viewer-link-none .twizzle-link-button {\n display: none;\n}\n\n.wrapper twisty-control-button {\n width: inherit;\n height: inherit;\n}\n`),Bx=new fn(`\n:host {\n width: 48px;\n height: 24px;\n display: grid;\n}\n\n.wrapper {\n width: 100%;\n height: 100%;\n}\n\nbutton {\n width: 100%;\n height: 100%;\n border: none;\n \n background-position: center;\n background-repeat: no-repeat;\n background-size: contain;\n\n background-color: rgba(196, 196, 196, 0.75);\n}\n\nbutton:enabled {\n background-color: rgba(196, 196, 196, 0.75)\n}\n\nbutton:disabled {\n background-color: rgba(0, 0, 0, 0.4);\n opacity: 0.25;\n pointer-events: none;\n}\n\nbutton:enabled:hover {\n background-color: rgba(255, 255, 255, 0.75);\n box-shadow: 0 0 1em rgba(0, 0, 0, 0.25);\n cursor: pointer;\n}\n\n/* TODO: fullscreen icons have too much padding?? */\nbutton.svg-skip-to-start {\n background-image: url(\"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzNTg0IiBoZWlnaHQ9IjM1ODQiIHZpZXdCb3g9IjAgMCAzNTg0IDM1ODQiPjxwYXRoIGQ9Ik0yNjQzIDEwMzdxMTktMTkgMzItMTN0MTMgMzJ2MTQ3MnEwIDI2LTEzIDMydC0zMi0xM2wtNzEwLTcxMHEtOS05LTEzLTE5djcxMHEwIDI2LTEzIDMydC0zMi0xM2wtNzEwLTcxMHEtOS05LTEzLTE5djY3OHEwIDI2LTE5IDQ1dC00NSAxOUg5NjBxLTI2IDAtNDUtMTl0LTE5LTQ1VjEwODhxMC0yNiAxOS00NXQ0NS0xOWgxMjhxMjYgMCA0NSAxOXQxOSA0NXY2NzhxNC0xMSAxMy0xOWw3MTAtNzEwcTE5LTE5IDMyLTEzdDEzIDMydjcxMHE0LTExIDEzLTE5eiIvPjwvc3ZnPg==\");\n}\n\nbutton.svg-skip-to-end {\n background-image: url(\"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzNTg0IiBoZWlnaHQ9IjM1ODQiIHZpZXdCb3g9IjAgMCAzNTg0IDM1ODQiPjxwYXRoIGQ9Ik05NDEgMjU0N3EtMTkgMTktMzIgMTN0LTEzLTMyVjEwNTZxMC0yNiAxMy0zMnQzMiAxM2w3MTAgNzEwcTggOCAxMyAxOXYtNzEwcTAtMjYgMTMtMzJ0MzIgMTNsNzEwIDcxMHE4IDggMTMgMTl2LTY3OHEwLTI2IDE5LTQ1dDQ1LTE5aDEyOHEyNiAwIDQ1IDE5dDE5IDQ1djE0MDhxMCAyNi0xOSA0NXQtNDUgMTloLTEyOHEtMjYgMC00NS0xOXQtMTktNDV2LTY3OHEtNSAxMC0xMyAxOWwtNzEwIDcxMHEtMTkgMTktMzIgMTN0LTEzLTMydi03MTBxLTUgMTAtMTMgMTl6Ii8+PC9zdmc+\");\n}\n\nbutton.svg-step-forward {\n background-image: url(\"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzNTg0IiBoZWlnaHQ9IjM1ODQiIHZpZXdCb3g9IjAgMCAzNTg0IDM1ODQiPjxwYXRoIGQ9Ik0yNjg4IDE1NjhxMCAyNi0xOSA0NWwtNTEyIDUxMnEtMTkgMTktNDUgMTl0LTQ1LTE5cS0xOS0xOS0xOS00NXYtMjU2aC0yMjRxLTk4IDAtMTc1LjUgNnQtMTU0IDIxLjVxLTc2LjUgMTUuNS0xMzMgNDIuNXQtMTA1LjUgNjkuNXEtNDkgNDIuNS04MCAxMDF0LTQ4LjUgMTM4LjVxLTE3LjUgODAtMTcuNSAxODEgMCA1NSA1IDEyMyAwIDYgMi41IDIzLjV0Mi41IDI2LjVxMCAxNS04LjUgMjV0LTIzLjUgMTBxLTE2IDAtMjgtMTctNy05LTEzLTIydC0xMy41LTMwcS03LjUtMTctMTAuNS0yNC0xMjctMjg1LTEyNy00NTEgMC0xOTkgNTMtMzMzIDE2Mi00MDMgODc1LTQwM2gyMjR2LTI1NnEwLTI2IDE5LTQ1dDQ1LTE5cTI2IDAgNDUgMTlsNTEyIDUxMnExOSAxOSAxOSA0NXoiLz48L3N2Zz4=\");\n}\n\nbutton.svg-step-backward {\n background-image: url(\"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzNTg0IiBoZWlnaHQ9IjM1ODQiIHZpZXdCb3g9IjAgMCAzNTg0IDM1ODQiPjxwYXRoIGQ9Ik0yNjg4IDIwNDhxMCAxNjYtMTI3IDQ1MS0zIDctMTAuNSAyNHQtMTMuNSAzMHEtNiAxMy0xMyAyMi0xMiAxNy0yOCAxNy0xNSAwLTIzLjUtMTB0LTguNS0yNXEwLTkgMi41LTI2LjV0Mi41LTIzLjVxNS02OCA1LTEyMyAwLTEwMS0xNy41LTE4MXQtNDguNS0xMzguNXEtMzEtNTguNS04MC0xMDF0LTEwNS41LTY5LjVxLTU2LjUtMjctMTMzLTQyLjV0LTE1NC0yMS41cS03Ny41LTYtMTc1LjUtNmgtMjI0djI1NnEwIDI2LTE5IDQ1dC00NSAxOXEtMjYgMC00NS0xOWwtNTEyLTUxMnEtMTktMTktMTktNDV0MTktNDVsNTEyLTUxMnExOS0xOSA0NS0xOXQ0NSAxOXExOSAxOSAxOSA0NXYyNTZoMjI0cTcxMyAwIDg3NSA0MDMgNTMgMTM0IDUzIDMzM3oiLz48L3N2Zz4=\");\n}\n\nbutton.svg-pause {\n background-image: url(\"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzNTg0IiBoZWlnaHQ9IjM1ODQiIHZpZXdCb3g9IjAgMCAzNTg0IDM1ODQiPjxwYXRoIGQ9Ik0yNTYwIDEwODh2MTQwOHEwIDI2LTE5IDQ1dC00NSAxOWgtNTEycS0yNiAwLTQ1LTE5dC0xOS00NVYxMDg4cTAtMjYgMTktNDV0NDUtMTloNTEycTI2IDAgNDUgMTl0MTkgNDV6bS04OTYgMHYxNDA4cTAgMjYtMTkgNDV0LTQ1IDE5aC01MTJxLTI2IDAtNDUtMTl0LTE5LTQ1VjEwODhxMC0yNiAxOS00NXQ0NS0xOWg1MTJxMjYgMCA0NSAxOXQxOSA0NXoiLz48L3N2Zz4=\");\n}\n\nbutton.svg-play {\n background-image: url(\"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzNTg0IiBoZWlnaHQ9IjM1ODQiIHZpZXdCb3g9IjAgMCAzNTg0IDM1ODQiPjxwYXRoIGQ9Ik0yNDcyLjUgMTgyM2wtMTMyOCA3MzhxLTIzIDEzLTM5LjUgM3QtMTYuNS0zNlYxMDU2cTAtMjYgMTYuNS0zNnQzOS41IDNsMTMyOCA3MzhxMjMgMTMgMjMgMzF0LTIzIDMxeiIvPjwvc3ZnPg==\");\n}\n\nbutton.svg-enter-fullscreen {\n background-image: url(\"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMjgiIHZpZXdCb3g9IjAgMCAyOCAyOCIgd2lkdGg9IjI4Ij48cGF0aCBkPSJNMiAyaDI0djI0SDJ6IiBmaWxsPSJub25lIi8+PHBhdGggZD0iTTkgMTZIN3Y1aDV2LTJIOXYtM3ptLTItNGgyVjloM1Y3SDd2NXptMTIgN2gtM3YyaDV2LTVoLTJ2M3pNMTYgN3YyaDN2M2gyVjdoLTV6Ii8+PC9zdmc+\");\n}\n\nbutton.svg-exit-fullscreen {\n background-image: url(\"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMjgiIHZpZXdCb3g9IjAgMCAyOCAyOCIgd2lkdGg9IjI4Ij48cGF0aCBkPSJNMiAyaDI0djI0SDJ6IiBmaWxsPSJub25lIi8+PHBhdGggZD0iTTcgMThoM3YzaDJ2LTVIN3Yyem0zLThIN3YyaDVWN2gtMnYzem02IDExaDJ2LTNoM3YtMmgtNXY1em0yLTExVjdoLTJ2NWg1di0yaC0zeiIvPjwvc3ZnPg==\");\n}\n\nbutton.svg-twizzle-tw {\n background-image: url(\"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iODY0IiBoZWlnaHQ9IjYwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNMzk3LjU4MSAxNTEuMTh2NTcuMDg0aC04OS43MDN2MjQwLjM1MmgtNjYuOTU1VjIwOC4yNjRIMTUxLjIydi01Ny4wODNoMjQ2LjM2MXptNTQuMzEgNzEuNjc3bDcuNTEyIDMzLjY5MmMyLjcxOCAxMi4xNiA1LjU4IDI0LjY4IDguNTg0IDM3LjU1NWEyMTgwLjc3NSAyMTgwLjc3NSAwIDAwOS40NDIgMzguODQzIDEyNjYuMyAxMjY2LjMgMCAwMDEwLjA4NiAzNy41NTVjMy43Mi0xMi41OSA3LjM2OC0yNS40NjYgMTAuOTQ1LTM4LjYyOCAzLjU3Ni0xMy4xNjIgNy4wMS0yNi4xMSAxMC4zLTM4Ljg0M2w1Ljc2OS0yMi40NTZjMS4yNDgtNC44ODcgMi40NzItOS43MDUgMy42NzQtMTQuNDU1IDMuMDA0LTExLjg3NSA1LjY1MS0yMi45NjIgNy45NC0zMy4yNjNoNDYuMzU0bDIuMzg0IDEwLjU2M2EyMDAwLjc3IDIwMDAuNzcgMCAwMDMuOTM1IDE2LjgyOGw2LjcxMSAyNy43MWMxLjIxMyA0Ljk1NiAyLjQ1IDkuOTggMy43MDkgMTUuMDczYTMxMTkuNzc3IDMxMTkuNzc3IDAgMDA5Ljg3MSAzOC44NDMgMTI0OS4yMjcgMTI0OS4yMjcgMCAwMDEwLjczIDM4LjYyOCAxOTA3LjYwNSAxOTA3LjYwNSAwIDAwMTAuMzAxLTM3LjU1NSAxMzk3Ljk0IDEzOTcuOTQgMCAwMDkuNjU3LTM4Ljg0M2w0LjQtMTkuMDQ2Yy43MTUtMy4xMyAxLjQyMS02LjIzNiAyLjExOC05LjMyMWw5LjU3Ny00Mi44OGg2Ni41MjZhMjk4OC43MTggMjk4OC43MTggMCAwMS0xOS41MjkgNjYuMzExbC01LjcyOCAxOC40ODJhMzIzNy40NiAzMjM3LjQ2IDAgMDEtMTQuMDE1IDQzLjc1MmMtNi40MzggMTkuNi0xMi43MzMgMzcuNjk4LTE4Ljg4NSA1NC4yOTRsLTMuMzA2IDguODI1Yy00Ljg4NCAxMi44OTgtOS40MzMgMjQuMjYzLTEzLjY0NyAzNC4wOTVoLTQ5Ljc4N2E4NDE3LjI4OSA4NDE3LjI4OSAwIDAxLTIxLjAzMS02NC44MDkgMTI4OC42ODYgMTI4OC42ODYgMCAwMS0xOC44ODUtNjQuODEgMTk3Mi40NDQgMTk3Mi40NDQgMCAwMS0xOC4yNCA2NC44MSAyNTc5LjQxMiAyNTc5LjQxMiAwIDAxLTIwLjM4OCA2NC44MWgtNDkuNzg3Yy00LjY4Mi0xMC45MjYtOS43Mi0yMy43NDMtMTUuMTEtMzguNDUxbC0xLjYyOS00LjQ3Yy01LjI1OC0xNC41MjEtMTAuNjgtMzAuMTkyLTE2LjI2Ni00Ny4wMTRsLTIuNDA0LTcuMjhjLTYuNDM4LTE5LjYtMTMuMDItNDAuMzQ0LTE5Ljc0My02Mi4yMzRhMjk4OC43MDcgMjk4OC43MDcgMCAwMS0xOS41MjktNjYuMzExaDY3LjM4NXoiIGZpbGw9IiM0Mjg1RjQiIGZpbGwtcnVsZT0ibm9uemVybyIvPjwvc3ZnPg==\");\n}\n`);var nr=class extends sn{constructor(e,t,i){super();this.currentIconName=null;this.button=document.createElement(\"button\");this.fullscreenElement=null;this.visitTwizzleLinkCallback=null;var r,o;switch(this.fullscreenElement=(r=i==null?void 0:i.fullscreenElement)!=null?r:null,this.visitTwizzleLinkCallback=(o=i==null?void 0:i.visitTwizzleLinkCallback)!=null?o:null,e||console.warn(\"Must have timeline!\"),this.timeline=e,t||console.warn(\"Must have timelineCommand!\"),this.timelineCommand=t,this.addCSS(Bx),this.setIcon(this.initialIcon()),this.setHoverTitle(this.initialHoverTitle()),this.addElement(this.button),this.addEventListener(\"click\",this.onPress.bind(this)),this.timelineCommand){case\"fullscreen\":document.fullscreenEnabled||(this.button.disabled=!0);break;case\"jump-to-start\":case\"play-step-backwards\":this.button.disabled=!0;break}if(this.timeline){switch(this.timeline.addActionListener(this),this.timelineCommand){case\"play-pause\":case\"play-step-backwards\":case\"play-step\":this.timeline.addTimestampListener(this);break}this.autoSetTimelineBasedDisabled()}}autoSetTimelineBasedDisabled(){switch(this.timelineCommand){case\"jump-to-start\":case\"play-pause\":case\"play-step-backwards\":case\"play-step\":case\"jump-to-end\":{let e=this.timeline.timeRange();if(e.start===e.end){this.button.disabled=!0;return}switch(this.timelineCommand){case\"jump-to-start\":case\"play-step-backwards\":this.button.disabled=this.timeline.timestampthis.timeline.minTimestamp();break;default:this.button.disabled=!1}break}}}setIcon(e){this.currentIconName!==e&&(this.currentIconName&&this.button.classList.remove(`svg-${this.currentIconName}`),this.button.classList.add(`svg-${e}`),this.currentIconName=e)}initialIcon(){return{\"jump-to-start\":\"skip-to-start\",\"play-pause\":\"play\",\"play-step\":\"step-forward\",\"play-step-backwards\":\"step-backward\",\"jump-to-end\":\"skip-to-end\",fullscreen:\"enter-fullscreen\",\"twizzle-link\":\"twizzle-tw\"}[this.timelineCommand]}initialHoverTitle(){return{\"jump-to-start\":\"Restart\",\"play-pause\":\"Play\",\"play-step\":\"Step forward\",\"play-step-backwards\":\"Step backward\",\"jump-to-end\":\"Skip to End\",fullscreen:\"Enter fullscreen\",\"twizzle-link\":\"View at Twizzle\"}[this.timelineCommand]}setHoverTitle(e){this.button.title=e}onPress(){switch(this.timelineCommand){case\"fullscreen\":document.fullscreenElement===this.fullscreenElement?document.exitFullscreen():(this.setIcon(\"exit-fullscreen\"),this.fullscreenElement.requestFullscreen().then(()=>{let e=()=>{document.fullscreenElement!==this.fullscreenElement&&(this.setIcon(\"enter-fullscreen\"),window.removeEventListener(\"fullscreenchange\",e))};window.addEventListener(\"fullscreenchange\",e)}));break;case\"jump-to-start\":this.timeline.setTimestamp(0);break;case\"jump-to-end\":this.timeline.jumpToEnd();break;case\"play-pause\":this.timeline.playPause();break;case\"play-step\":this.timeline.experimentalPlay(It.Forwards,Vn.Move);break;case\"play-step-backwards\":this.timeline.experimentalPlay(It.Backwards,Vn.Move);break;case\"twizzle-link\":this.visitTwizzleLinkCallback&&this.visitTwizzleLinkCallback();break}}onTimelineAction(e){switch(this.timelineCommand){case\"jump-to-start\":this.button.disabled=e.locationType===jn.StartOfTimeline&&e.action!==hn.StartingToPlay;break;case\"jump-to-end\":this.button.disabled=e.locationType===jn.EndOfTimeline&&e.action!==hn.StartingToPlay;break;case\"play-pause\":switch(e.action){case hn.Pausing:this.setIcon(\"play\"),this.setHoverTitle(\"Play\");break;case hn.StartingToPlay:this.setIcon(\"pause\"),this.setHoverTitle(\"Pause\");break}break;case\"play-step\":this.button.disabled=e.locationType===jn.EndOfTimeline&&e.action!==hn.StartingToPlay;break;case\"play-step-backwards\":this.button.disabled=e.locationType===jn.StartOfTimeline&&e.action!==hn.StartingToPlay;break}}onTimelineTimestampChange(e){}onTimeRangeChange(e){this.autoSetTimelineBasedDisabled()}};Ct.define(\"twisty-control-button\",nr);var Wl,yf=class extends sn{constructor(e,t){super();ce(this,Wl,new Ii(this,\"viewer-link-\",[\"none\",\"twizzle\"]));var i;this.addCSS(Nx),M(this,Wl).setValue((i=t==null?void 0:t.viewerLink)!=null?i:\"none\"),this.addElement(new nr(e,\"fullscreen\",{fullscreenElement:t==null?void 0:t.fullscreenElement})),this.addElement(new nr(e,\"jump-to-start\")),this.addElement(new nr(e,\"play-step-backwards\")),this.addElement(new nr(e,\"play-pause\")),this.addElement(new nr(e,\"play-step\")),this.addElement(new nr(e,\"jump-to-end\")),this.addElement(new nr(e,\"twizzle-link\",{visitTwizzleLinkCallback:t==null?void 0:t.viewerLinkCallback})).classList.add(\"twizzle-link-button\")}setViewerLink(e){M(this,Wl).setValue(e)}};Wl=new WeakMap;Ct.define(\"twisty-control-button-panel\",yf);var Ox=new fn(`\n:host {\n width: 384px;\n height: 16px;\n display: grid;\n}\n\n.wrapper {\n width: 100%;\n height: 100%;\n display: grid;\n overflow: hidden;\n backdrop-filter: blur(4px);\n -webkit-backdrop-filter: blur(4px);\n}\n\ninput {\n margin: 0; width: 100%;\n}\n\ninput {\n background: none;\n}\n\n::-moz-range-track {\n background: rgba(0, 0, 0, 0.25);\n height: 50%;\n border: 1px solid rgba(0, 0, 0, 0.1);\n}\n\n::-webkit-slider-runnable-track {\n background: rgba(0, 0, 0, 0.05);\n}\n\n::-moz-range-progress {\n background: #3273F6;\n height: 50%;\n border: 1px solid rgba(0, 0, 0, 0.1);\n}\n\n::-ms-fill-lower {\n background: #3273F6;\n height: 50%;\n border: 1px solid rgba(0, 0, 0, 0.1);\n}\n`);var vf=class extends sn{constructor(e){super();this.range=document.createElement(\"input\");var t,i,r,o;this.timeline=e,this.addCSS(Ox),(t=this.timeline)==null||t.addTimestampListener(this),this.range.type=\"range\",this.range.step=1 .toString(),this.range.min=(i=this.timeline)==null?void 0:i.minTimestamp().toString(),this.range.max=(r=this.timeline)==null?void 0:r.maxTimestamp().toString(),this.range.value=(o=this.timeline)==null?void 0:o.timestamp.toString(),this.range.addEventListener(\"input\",this.onInput.bind(this)),this.addElement(this.range)}onTimelineTimestampChange(e){this.range.value=e.toString()}onTimeRangeChange(e){this.range.min=e.start.toString(),this.range.max=e.end.toString()}onInput(){this.timeline.setTimestamp(parseInt(this.range.value,10))}};Ct.define(\"twisty-scrubber\",vf);var Ux=new fn(`\n:host {\n width: 384px;\n height: 256px;\n display: grid;\n}\n\n.wrapper {\n display: grid;\n overflow: hidden;\n grid-template-rows: 7fr 1em 1fr;\n}\n\n.wrapper > * {\n width: inherit;\n height: inherit;\n overflow: hidden;\n}\n\n.wrapper.controls-none {\n grid-template-rows: 7fr;\n}\n\n.wrapper.controls-none twisty-scrubber,\n.wrapper.controls-none twisty-control-button-panel {\n display: none;\n}\n\ntwisty-scrubber {\n background: rgba(196, 196, 196, 0.5);\n}\n\n.wrapper.checkered {\n background-color: #EAEAEA;\n background-image: linear-gradient(45deg, #DDD 25%, transparent 25%, transparent 75%, #DDD 75%, #DDD),\n linear-gradient(45deg, #DDD 25%, transparent 25%, transparent 75%, #DDD 75%, #DDD);\n background-size: 32px 32px;\n background-position: 0 0, 16px 16px;\n}\n`);var Gx=new fn(`\n:host {\n width: 384px;\n height: 256px;\n display: grid;\n}\n\n.wrapper {\n width: 100%;\n height: 100%;\n display: grid;\n overflow: hidden;\n}\n\n.svg-wrapper,\ntwisty-2d-svg,\nsvg {\n width: 100%;\n height: 100%;\n display: grid;\n min-height: 0;\n}\n`);var Zs,Hl=class extends sn{constructor(e,t,i,r,o){super();this.svgSource=i;this.options=r;this.puzzleLoader=o;this.scheduler=new Ki(this.render.bind(this));ce(this,Zs,null);var s;this.addCSS(Gx),this.definition=t,this.resetSVG(),e==null||e.addPositionListener(this),((s=this.options)==null?void 0:s.experimentalStickering)&&this.experimentalSetStickering(this.options.experimentalStickering)}onPositionChange(e){if(e.movesInProgress.length>0){let t=e.movesInProgress[0].move,i=this.definition,r=t;e.movesInProgress[0].direction===It.Backwards&&(r=t.invert());let o=Nn(i,e.state,br(i,r));this.svg.draw(this.definition,e.state,o,e.movesInProgress[0].fraction)}else this.svg.draw(this.definition,e.state),ye(this,Zs,e)}scheduleRender(){this.scheduler.requestAnimFrame()}experimentalSetStickering(e){(()=>se(this,null,function*(){var i;if(!((i=this.puzzleLoader)==null?void 0:i.appearance))return;let t=yield this.puzzleLoader.appearance(e);this.resetSVG(t)}))()}resetSVG(e){this.svg&&this.removeElement(this.svg.element),!!this.definition&&(this.svg=new Bc(this.definition,this.svgSource,e),this.addElement(this.svg.element),M(this,Zs)&&this.onPositionChange(M(this,Zs)))}render(){}};Zs=new WeakMap;Ct.define(\"twisty-2d-svg\",Hl);function Wx(n){return[\"3D\",\"PG3D\"].includes(n)}var VD={simple:gf,tree:xi,simultaneous:Jd},at,Vl,Fi,jl,jr,Rn,ql,$s,ea,ir,Js,Ql,Hx,Po,rr,Ks,ta,or,Yl,Vx,Xl,jx,xf,jD,bf,qD,wf,QD,Zl,qx,Jl,Qx,Kl,Yx,Mf,YD,$l,Xx,Ro=class extends sn{constructor(e={},t=null,i=()=>{}){super();ce(this,ir);ce(this,Ql);ce(this,rr);ce(this,Yl);ce(this,Xl);ce(this,xf);ce(this,bf);ce(this,wf);ce(this,Zl);ce(this,Jl);ce(this,Kl);ce(this,Mf);ce(this,$l);ce(this,at,void 0);this.scene=null;this.twisty3D=null;ce(this,Vl,!1);ce(this,Fi,null);this.legacyExperimentalPG3D=null;ce(this,jl,null);this.viewerElems=[];this.controlElems=[];ce(this,jr,!1);ce(this,Rn,void 0);this.legacyExperimentalCoalesceModFunc=e=>0;ce(this,ql,new Ii(this,\"controls-\",[\"none\",\"bottom-row\"]));ce(this,$s,void 0);ce(this,ea,!1);ce(this,Po,\"tree\");ce(this,ta,[]);ce(this,or,null);this.addCSS(Ux),ye(this,at,new cf(this,e)),ye(this,$s,i),this.timeline=new $d,this.timeline.addActionListener(this),this.contentWrapper.classList.add(\"checkered\"),ye(this,Fi,t)}set alg(e){var t;typeof e==\"string\"&&(e=le.fromString(e)),M(this,at).attributes.alg.setValue(e),(t=this.cursor)==null||t.setAlg(e,Ke(this,rr,Ks).call(this)),Ke(this,ir,Js).call(this),this.dispatchEvent(new CustomEvent(\"experimental-alg-update\",{detail:{alg:this.alg}}))}get alg(){return M(this,at).attributes.alg.value}set experimentalSetupAlg(e){typeof e==\"string\"&&(console.warn(\"`experimentalSetupAlg` for a `TwistyPlayer` was set using a string. It should be set using a `Sequence`!\"),e=new le(e)),M(this,at).attributes[\"experimental-setup-alg\"].setValue(e),Ke(this,ir,Js).call(this)}get experimentalSetupAlg(){return M(this,at).attributes[\"experimental-setup-alg\"].value}set experimentalSetupAnchor(e){M(this,at).attributes[\"experimental-setup-anchor\"].setValue(e),Ke(this,ir,Js).call(this)}get experimentalSetupAnchor(){return M(this,at).attributes[\"experimental-setup-anchor\"].value}set puzzle(e){M(this,at).attributes.puzzle.setValue(e)&&this.updatePuzzleDOM()}get puzzle(){return M(this,at).attributes.puzzle.value}set visualization(e){M(this,at).attributes.visualization.setValue(e)&&this.updatePuzzleDOM()}get visualization(){return M(this,at).attributes.visualization.value}set hintFacelets(e){M(this,at).attributes[\"hint-facelets\"].setValue(e)&&this.twisty3D instanceof Qs&&this.twisty3D.experimentalUpdateOptions({hintFacelets:e})}get hintFacelets(){return M(this,at).attributes[\"hint-facelets\"].value}get experimentalStickering(){return M(this,at).attributes[\"experimental-stickering\"].value}set experimentalStickering(e){if(M(this,at).attributes[\"experimental-stickering\"].setValue(e)){let t=this.twisty3D;t instanceof Qs&&t.experimentalUpdateOptions({experimentalStickering:e}),t instanceof Ys&&(()=>se(this,null,function*(){let i=yield Ke(this,Jl,Qx).call(this);t.experimentalSetAppearance(i)}))(),this.viewerElems[0]instanceof Hl&&this.viewerElems[0].experimentalSetStickering(this.experimentalStickering)}}set background(e){M(this,at).attributes.background.setValue(e)&&this.contentWrapper.classList.toggle(\"checkered\",e===\"checkered\")}get background(){return M(this,at).attributes.background.value}set controlPanel(e){M(this,at).attributes[\"control-panel\"].setValue(e),M(this,ql).setValue(e)}get controlPanel(){return M(this,at).attributes[\"control-panel\"].value}set controls(e){this.controlPanel=e}get controls(){return this.controlPanel}set backView(e){if(M(this,at).attributes[\"back-view\"].setValue(e),e!==\"none\"&&this.viewerElems.length===1&&Ke(this,Kl,Yx).call(this),e===\"none\"&&this.viewerElems.length>1&&Ke(this,Mf,YD).call(this),M(this,Rn)&&M(this,Rn).setBackView(e))for(let t of this.viewerElems)t.makeInvisibleUntilRender()}get backView(){return M(this,at).attributes[\"back-view\"].value}set experimentalCameraPosition(e){var t,i,r,o,s,a;M(this,at).attributes[\"experimental-camera-position\"].setValue(e),this.viewerElems&&[\"3D\",\"PG3D\"].includes(M(this,at).attributes.visualization.value)&&((t=this.viewerElems[0])==null||t.camera.position.copy(this.effectiveCameraPosition),(i=this.viewerElems[0])==null||i.camera.lookAt(new E(0,0,0)),(r=this.viewerElems[0])==null||r.scheduleRender(),(o=this.viewerElems[1])==null||o.camera.position.copy(this.effectiveCameraPosition).multiplyScalar(-1),(s=this.viewerElems[1])==null||s.camera.lookAt(new E(0,0,0)),(a=this.viewerElems[1])==null||a.scheduleRender())}get experimentalCameraPosition(){return M(this,at).attributes[\"experimental-camera-position\"].value}set viewerLink(e){M(this,at).attributes[\"viewer-link\"].setValue(e);let t=this.controlElems[1];(t==null?void 0:t.setViewerLink)&&t.setViewerLink(e)}get viewerLink(){return M(this,at).attributes[\"viewer-link\"].value}get effectiveCameraPosition(){var e;return(e=this.experimentalCameraPosition)!=null?e:this.defaultCameraPosition}get defaultCameraPosition(){return this.puzzle[1]===\"x\"?xx:vx}static get observedAttributes(){return cf.observedAttributes}attributeChangedCallback(e,t,i){M(this,at).attributeChangedCallback(e,t,i)}experimentalSetStartStateOverride(e){ye(this,jl,e),Ke(this,ir,Js).call(this)}experimentalSetCursorIndexer(e){var t;M(this,Po)!==e&&(ye(this,Po,e),(t=this.cursor)==null||t.experimentalSetIndexer(Ke(this,rr,Ks).call(this)))}connectedCallback(){this.contentWrapper.classList.toggle(\"checkered\",this.background===\"checkered\");let t=this.backView&&Wx(this.visualization)?this.backView:\"none\";ye(this,Rn,new lf({backView:t})),this.addElement(M(this,Rn));let i=new vf(this.timeline),r=new yf(this.timeline,{fullscreenElement:this,viewerLinkCallback:this.visitTwizzleLink.bind(this),viewerLink:this.viewerLink});this.controlElems=[i,r],M(this,ql).setValue(this.controlPanel),this.addElement(this.controlElems[0]),this.addElement(this.controlElems[1]),ye(this,Vl,!0),this.updatePuzzleDOM(!0).then(()=>{M(this,ea)||(ye(this,ea,!0),this.dispatchEvent(new CustomEvent(\"initialized\")))})}get initialized(){return M(this,ea)}twizzleLink(){let e=new URL(\"https://experiments.cubing.net/cubing.js/alg.cubing.net/index.html\");return this.alg.experimentalIsEmpty()||e.searchParams.set(\"alg\",this.alg.toString()),this.experimentalSetupAlg.experimentalIsEmpty()||e.searchParams.set(\"experimental-setup-alg\",this.experimentalSetupAlg.toString()),this.experimentalSetupAnchor!==\"start\"&&e.searchParams.set(\"experimental-setup-anchor\",this.experimentalSetupAnchor),this.experimentalStickering!==\"full\"&&e.searchParams.set(\"experimental-stickering\",this.experimentalStickering),this.puzzle!==\"3x3x3\"&&e.searchParams.set(\"puzzle\",this.puzzle),e.toString()}visitTwizzleLink(){let e=document.createElement(\"a\");e.href=this.twizzleLink(),e.target=\"_blank\",e.click()}updatePuzzleDOM(e=!1){return se(this,null,function*(){var s,a,l,c,f;if(!M(this,Vl))return;let t;this.puzzle===\"custom\"?t={id:\"custom\",fullName:\"Custom (PG3D)\",def:()=>Promise.resolve(M(this,Fi).def),svg:()=>se(this,null,function*(){throw\"unimplemented\"})}:t=gn[this.puzzle];for(let u of M(this,ta))u.cancelled=!0;ye(this,ta,[]);let i={cancelled:!1};M(this,ta).push(i);let r=yield t.def();if(i.cancelled)return;let o;try{o=new mf(this.timeline,r,this.alg,Ke(this,Ql,Hx).call(this),Ke(this,rr,Ks).call(this)),Ke(this,Zl,qx).call(this,o)}catch(u){e&&M(this,$s).call(this,this.alg),o=new mf(this.timeline,r,new le,new le,Ke(this,rr,Ks).call(this)),Ke(this,Zl,qx).call(this,o)}switch(e&&this.experimentalSetupAlg.experimentalIsEmpty()&&this.experimentalSetupAnchor!==\"end\"&&this.timeline.jumpToEnd(),this.visualization){case\"2D\":case\"experimental-2D-LL\":{let u={};this.experimentalStickering&&(u.experimentalStickering=this.experimentalStickering),Ke(this,Xl,jx).call(this);let h=this.visualization===\"2D\"?t.svg:(s=t.llSVG)!=null?s:t.svg,p=new Hl(o,r,yield h(),u,t);i.cancelled||Ke(this,xf,jD).call(this,p)}break;case\"3D\":case\"PG3D\":{Ke(this,bf,qD).call(this);let u=this.scene,h;if(this.visualization===\"3D\"&&this.puzzle===\"3x3x3\")h=new Qs(r,o,u.scheduleRender.bind(u),{hintFacelets:this.hintFacelets,experimentalStickering:this.experimentalStickering});else{let p,d,g=t.pg;if(this.puzzle===\"custom\")p=M(this,Fi).def,d=M(this,Fi).stickerDat;else if(g){let m=yield g();if(i.cancelled)return;p=m.writekpuzzle(!0),d=m.get3d()}else throw\"Unimplemented!\";let v={},y=new Ys(o,u.scheduleRender.bind(u),p,d,(l=(a=M(this,Fi))==null?void 0:a.showFoundation)!=null?l:!0,(f=(c=M(this,Fi))==null?void 0:c.hintStickers)!=null?f:this.hintFacelets===\"floating\",v);(()=>se(this,null,function*(){let m=yield Ke(this,Jl,Qx).call(this);m&&y.experimentalSetAppearance(m)}))(),this.legacyExperimentalPG3D=y,h=y}Ke(this,wf,QD).call(this,h)}break}})}setCustomPuzzleGeometry(e){return se(this,null,function*(){this.puzzle=\"custom\",ye(this,Fi,e),yield this.updatePuzzleDOM()})}experimentalAddMove(e,t=!1,i=!1){M(this,jr)&&Ke(this,$l,Xx).call(this);let r=of(this.alg),o=Fc(this.alg,e,{coalesce:t&&!i,mod:this.legacyExperimentalCoalesceModFunc(e)});t&&i&&ye(this,jr,!0),this.alg=o,r<=of(o)?this.timeline.experimentalJumpToLastMove():this.timeline.jumpToEnd(),this.timeline.play()}onTimelineAction(e){e.action===hn.Pausing&&e.locationType===jn.EndOfTimeline&&M(this,jr)&&(Ke(this,$l,Xx).call(this),this.timeline.jumpToEnd())}fullscreen(){this.requestFullscreen()}};at=new WeakMap,Vl=new WeakMap,Fi=new WeakMap,jl=new WeakMap,jr=new WeakMap,Rn=new WeakMap,ql=new WeakMap,$s=new WeakMap,ea=new WeakMap,ir=new WeakSet,Js=function(){var e;this.cursor&&this.cursor.setStartState((e=M(this,jl))!=null?e:this.cursor.algToState(Ke(this,Ql,Hx).call(this)))},Ql=new WeakSet,Hx=function(){let e=this.experimentalSetupAlg;return this.experimentalSetupAnchor===\"end\"&&(e=e.concat(this.alg.invert())),e},Po=new WeakMap,rr=new WeakSet,Ks=function(){return VD[M(this,Po)]},ta=new WeakMap,or=new WeakMap,Yl=new WeakSet,Vx=function(){switch(M(this,or)){case\"3D\":this.scene=null,this.twisty3D=null,this.legacyExperimentalPG3D=null,this.viewerElems=[],M(this,Rn).clear();break;case\"2D\":this.viewerElems=[],M(this,Rn).clear();break}ye(this,or,null)},Xl=new WeakSet,jx=function(){M(this,or)!==\"2D\"&&(Ke(this,Yl,Vx).call(this),ye(this,or,\"2D\"))},xf=new WeakSet,jD=function(e){Ke(this,Xl,jx).call(this),M(this,Rn).clear(),M(this,Rn).addElement(e),this.viewerElems.push(e)},bf=new WeakSet,qD=function(){if(M(this,or)===\"3D\")return;Ke(this,Yl,Vx).call(this),this.scene=new Yd;let e=new js(this.scene,{experimentalCameraPosition:this.effectiveCameraPosition});this.viewerElems.push(e),M(this,Rn).addElement(e),this.backView!==\"none\"&&Ke(this,Kl,Yx).call(this),ye(this,or,\"3D\")},wf=new WeakSet,QD=function(e){this.twisty3D&&(this.scene.removeTwisty3DPuzzle(this.twisty3D),this.twisty3D instanceof Ys&&this.twisty3D.dispose(),this.twisty3D=null),this.twisty3D=e,this.scene.addTwisty3DPuzzle(e)},Zl=new WeakSet,qx=function(e){let t=this.cursor;this.cursor=e;try{this.cursor.setAlg(this.alg,Ke(this,rr,Ks).call(this)),Ke(this,ir,Js).call(this)}catch(i){this.cursor.setAlg(new le,Ke(this,rr,Ks).call(this)),this.cursor.setStartState(this.cursor.algToState(new le)),M(this,$s).call(this,this.alg)}Ke(this,ir,Js).call(this),this.timeline.addCursor(e),t&&(this.timeline.removeCursor(t),this.timeline.removeTimestampListener(t)),this.experimentalSetCursorIndexer(M(this,Po))},Jl=new WeakSet,Qx=function(){return se(this,null,function*(){var t;let e=gn[this.puzzle];return(e==null?void 0:e.appearance)?e.appearance((t=this.experimentalStickering)!=null?t:\"full\"):null})},Kl=new WeakSet,Yx=function(){if(!Wx(this.visualization))throw new Error(\"Back viewer requires a 3D visualization\");let e=new js(this.scene,{experimentalCameraPosition:this.effectiveCameraPosition,negateCameraPosition:!0});this.viewerElems.push(e),this.viewerElems[0].setMirror(e),M(this,Rn).addElement(e)},Mf=new WeakSet,YD=function(){if(this.viewerElems.length!==2)throw new Error(\"Tried to remove non-existent back view!\");M(this,Rn).removeElement(this.viewerElems.pop())},$l=new WeakSet,Xx=function(){let e=Array.from(this.alg.units()),t=e.length,i=M(this,jr);if(ye(this,jr,!1),i&&t>1&&e[t-1].is(k)){let r=e[t-1],o=Fc(new le(e.slice(0,t-1)),r,{coalesce:!0,mod:this.legacyExperimentalCoalesceModFunc(r)});this.alg=o}};Ct.define(\"twisty-player\",Ro);nt();var XD=250;var ko=class extends Gr{constructor(e,t,i,r,o){super();this.algOrUnit=r;this.textContent=t,this.classList.add(e),this.addEventListener(\"click\",()=>{i.twistyAlgViewer.jumpToIndex(i.earliestMoveIndex,o)})}pathToIndex(e){return[]}};Ct.define(\"twisty-alg-leaf-elem\",ko);var zo=class extends Gr{constructor(e,t){super();this.algOrUnit=t;this.queue=[];this.classList.add(e)}addString(e){this.queue.push(document.createTextNode(e))}addElem(e){return this.queue.push(e.element),e.moveCount}flushQueue(e=Pe.Forwards){for(let t of Zx(this.queue,e))this.append(t);this.queue=[]}pathToIndex(e){return[]}};Ct.define(\"twisty-alg-wrapper-elem\",zo);function ZD(n){return n===Pe.Forwards?Pe.Backwards:Pe.Forwards}function JD(n,e){return e<0?ZD(n):n}function Zx(n,e){if(e===Pe.Forwards)return n;let t=Array.from(n);return t.reverse(),t}var Jx=class extends Di{traverseAlg(e,t){let i=0,r=new zo(\"twisty-alg-alg\",e),o=!0;for(let s of Ia(e.units(),t.direction))o||r.addString(\" \"),o=!1,i+=r.addElem(this.traverseUnit(s,{earliestMoveIndex:t.earliestMoveIndex+i,twistyAlgViewer:t.twistyAlgViewer,direction:t.direction}));return r.flushQueue(t.direction),{moveCount:i,element:r}}traverseGrouping(e,t){let i=e.experimentalAsSquare1Tuple(),r=JD(t.direction,e.amount),o=0,s=new zo(\"twisty-alg-grouping\",e);return s.addString(\"(\"),i?(o+=s.addElem({moveCount:1,element:new ko(\"twisty-alg-move\",i[0].amount.toString(),t,i[0],!0)}),s.addString(\", \"),o+=s.addElem({moveCount:1,element:new ko(\"twisty-alg-move\",i[1].amount.toString(),t,i[1],!0)})):o+=s.addElem(this.traverseAlg(e.alg,{earliestMoveIndex:t.earliestMoveIndex+o,twistyAlgViewer:t.twistyAlgViewer,direction:r})),s.addString(\")\"+e.experimentalRepetitionSuffix),s.flushQueue(),{moveCount:o*Math.abs(e.amount),element:s}}traverseMove(e,t){let i=new ko(\"twisty-alg-move\",e.toString(),t,e,!0);return t.twistyAlgViewer.highlighter.addMove(e.startCharIndex,i),{moveCount:1,element:i}}traverseCommutator(e,t){let i=0,r=new zo(\"twisty-alg-commutator\",e);r.addString(\"[\"),r.flushQueue();let[o,s]=Zx([e.A,e.B],t.direction);return i+=r.addElem(this.traverseAlg(o,{earliestMoveIndex:t.earliestMoveIndex+i,twistyAlgViewer:t.twistyAlgViewer,direction:t.direction})),r.addString(\", \"),i+=r.addElem(this.traverseAlg(s,{earliestMoveIndex:t.earliestMoveIndex+i,twistyAlgViewer:t.twistyAlgViewer,direction:t.direction})),r.flushQueue(t.direction),r.addString(\"]\"),r.flushQueue(),{moveCount:i*2,element:r}}traverseConjugate(e,t){let i=0,r=new zo(\"twisty-alg-conjugate\",e);r.addString(\"[\");let o=r.addElem(this.traverseAlg(e.A,{earliestMoveIndex:t.earliestMoveIndex+i,twistyAlgViewer:t.twistyAlgViewer,direction:t.direction}));return i+=o,r.addString(\": \"),i+=r.addElem(this.traverseAlg(e.B,{earliestMoveIndex:t.earliestMoveIndex+i,twistyAlgViewer:t.twistyAlgViewer,direction:t.direction})),r.addString(\"]\"),r.flushQueue(),{moveCount:i+o,element:r}}traversePause(e,t){return{moveCount:1,element:new ko(\"twisty-alg-pause\",\".\",t,e,!0)}}traverseNewline(e,t){let i=new zo(\"twisty-alg-newline\",e);return i.append(document.createElement(\"br\")),{moveCount:0,element:i}}traverseLineComment(e,t){return{moveCount:0,element:new ko(\"twisty-alg-line-comment\",`//${e.text}`,t,e,!1)}}},Kx=new Jx,KD=Kx.traverseAlg.bind(Kx),$x=class{constructor(){this.moveCharIndexMap=new Map;this.currentElem=null}addMove(e,t){this.moveCharIndexMap.set(e,t)}set(e){var i,r;let t=e&&(i=this.moveCharIndexMap.get(e.startCharIndex))!=null?i:null;this.currentElem!==t&&((r=this.currentElem)==null||r.classList.remove(\"twisty-alg-current-move\"),t==null||t.classList.add(\"twisty-alg-current-move\"),this.currentElem=t)}},ec,em=class extends Gr{constructor(e){super();this.highlighter=new $x;ce(this,ec,void 0);this.twistyPlayer=null;this.lastClickTimestamp=null;(e==null?void 0:e.twistyPlayer)&&this.setTwistyPlayer(e==null?void 0:e.twistyPlayer)}connectedCallback(){}setAlg(e){ye(this,ec,KD(e,{earliestMoveIndex:0,twistyAlgViewer:this,direction:Pe.Forwards}).element),this.textContent=\"\",this.appendChild(M(this,ec))}setTwistyPlayer(e){if(this.twistyPlayer){console.warn(\"twisty-player reassignment is not supported\");return}this.twistyPlayer=e,this.twistyPlayer.addEventListener(\"experimental-alg-update\",r=>{this.setAlg(r.detail.alg)});let t=this.twistyPlayer.alg,i=\"charIndex\"in t?t:le.fromString(t.toString());this.setAlg(i),(()=>se(this,null,function*(){let r=new vi(yield gn[e.puzzle].def()),o=new xi(r,i);e.timeline.addTimestampListener({onTimelineTimestampChange:s=>{this.highlighter.set(o.getMove(o.timestampToIndex(s)))},onTimeRangeChange(s){}})}))(),e.timeline.addTimestampListener({onTimelineTimestampChange:r=>{var s,a,l;r!==this.lastClickTimestamp&&(this.lastClickTimestamp=null);let o=(l=(a=(s=this.twistyPlayer)==null?void 0:s.cursor)==null?void 0:a.experimentalIndexFromTimestamp(r))!=null?l:null},onTimeRangeChange:r=>{}})}jumpToIndex(e,t){var i,r;if(this.twistyPlayer&&this.twistyPlayer.cursor){let o=t?XD:0,s=((i=this.twistyPlayer.cursor.experimentalTimestampFromIndex(e))!=null?i:-o)+o;(r=this.twistyPlayer)==null||r.timeline.setTimestamp(s),this.lastClickTimestamp===s?(this.twistyPlayer.timeline.play(),this.lastClickTimestamp=null):this.lastClickTimestamp=s}}attributeChangedCallback(e,t,i){if(e===\"for\"){let r=document.getElementById(i);if(!r){console.warn(\"for= elem does not exist\");return}if(!(r instanceof Ro)){console.warn(\"for= elem is not a twisty-player\");return}this.setTwistyPlayer(r)}}static get observedAttributes(){return[\"for\"]}};ec=new WeakMap;Ct.define(\"twisty-alg-viewer\",em);nt();var eb=new fn(`\n:host {\n width: 384px;\n display: grid;\n}\n\n.wrapper {\n /*overflow: hidden;\n resize: horizontal;*/\n\n background: var(--background, none);\n display: grid;\n}\n\ntextarea, .carbon-copy {\n grid-area: 1 / 1 / 2 / 2;\n\n width: 100%;\n font-family: sans-serif;\n line-height: 1.2em;\n\n font-size: var(--font-size, inherit);\n font-family: var(--font-family, sans-serif);\n\n box-sizing: border-box;\n\n padding: var(--padding, 0.5em);\n}\n\ntextarea {\n resize: none;\n background: none;\n z-index: 2;\n overflow: hidden;\n border: 1px solid var(--border-color, rgba(0, 0, 0, 0.25));\n}\n\n.carbon-copy {\n white-space: pre-wrap;\n word-wrap: break-word;\n color: transparent;\n user-select: none;\n pointer-events: none;\n\n z-index: 1;\n}\n\n.carbon-copy .highlight {\n background: var(--highlight-color, rgba(255, 128, 0, 0.5));\n padding: 0.1em 0.2em;\n margin: -0.1em -0.2em;\n border-radius: 0.2em;\n}\n\n.wrapper.issue-warning textarea,\n.wrapper.valid-for-puzzle-warning textarea {\n outline: none;\n border: 1px solid rgba(200, 200, 0, 0.5);\n background: rgba(255, 255, 0, 0.1);\n}\n\n.wrapper.issue-error textarea,\n.wrapper.valid-for-puzzle-error textarea {\n outline: none;\n border: 1px solid red;\n background: rgba(255, 0, 0, 0.1);\n}\n`);nt();var tb=class extends Di{traverseAlg(e,t){let i=t.numMovesSofar;for(let r of e.units()){let o={targetCharIdx:t.targetCharIdx,numMovesSofar:i},s=this.traverseUnit(r,o);if(\"latestUnit\"in s)return s;i+=s.animatedMoveCount}return{animatedMoveCount:i-t.numMovesSofar}}traverseGrouping(e,t){let i=this.traverseAlg(e.alg,t);return\"latestUnit\"in i?i:{animatedMoveCount:i.animatedMoveCount*Math.abs(e.amount)}}traverseMove(e,t){let i=e;return i.endCharIndex>t.targetCharIdx?{latestUnit:i,animatedMoveIdx:t.numMovesSofar}:{animatedMoveCount:1}}traverseCommutator(e,t){let i=this.traverseAlg(e.A,t);if(\"latestUnit\"in i)return i;let r={targetCharIdx:t.targetCharIdx,numMovesSofar:t.numMovesSofar+i.animatedMoveCount},o=this.traverseAlg(e.B,r);return\"latestUnit\"in o?o:{animatedMoveCount:2*(i.animatedMoveCount+o.animatedMoveCount)}}traverseConjugate(e,t){let i=this.traverseAlg(e.A,t);if(\"latestUnit\"in i)return i;let r={targetCharIdx:t.targetCharIdx,numMovesSofar:t.numMovesSofar+i.animatedMoveCount},o=this.traverseAlg(e.B,r);return\"latestUnit\"in o?o:{animatedMoveCount:i.animatedMoveCount*2+o.animatedMoveCount}}traversePause(e,t){let i=e;return i.endCharIndex>t.targetCharIdx?{latestUnit:i,animatedMoveIdx:t.numMovesSofar}:{animatedMoveCount:1}}traverseNewline(e,t){return{animatedMoveCount:0}}traverseLineComment(e,t){return{animatedMoveCount:0}}},nb=new tb,ib=nb.traverseAlg.bind(nb);var Sf=\"for-twisty-player\",rb=\"placeholder\",ob=\"twisty-player-prop\",sr,ht,Io,Fo,ar,tc,nc,Ef,No,lr,na,ia,tm=class extends sn{constructor(e){super();ce(this,sr,new le);ce(this,ht,document.createElement(\"textarea\"));ce(this,Io,document.createElement(\"div\"));ce(this,Fo,document.createElement(\"span\"));ce(this,ar,document.createElement(\"span\"));ce(this,tc,null);ce(this,nc,new Ii(this,\"issue-\",[\"none\",\"warning\",\"error\"]));ce(this,Ef,new Ii(this,\"valid-for-puzzle-\",[\"none\",\"warning\",\"error\"]));ce(this,No,null);ce(this,lr,void 0);ce(this,na,new ResizeObserver(e=>this.onResize(e)));ce(this,ia,null);var t;M(this,Io).classList.add(\"carbon-copy\"),this.addElement(M(this,Io)),M(this,ht).rows=1,this.addElement(M(this,ht)),M(this,Fo).classList.add(\"prefix\"),M(this,Io).appendChild(M(this,Fo)),M(this,ar).classList.add(\"highlight\"),M(this,Io).appendChild(M(this,ar)),M(this,ht).setAttribute(\"spellcheck\",\"false\"),this.addCSS(eb),M(this,ht).addEventListener(\"input\",()=>this.onInput()),document.addEventListener(\"selectionchange\",()=>this.onSelectionChange()),(e==null?void 0:e.twistyPlayer)&&(this.twistyPlayer=e.twistyPlayer),ye(this,lr,(t=e==null?void 0:e.twistyPlayerProp)!=null?t:\"alg\"),M(this,na).observe(this.contentWrapper)}onResize(e){var i,r;let t=e[0].contentRect;(t.height!==((i=M(this,ia))==null?void 0:i.height)||t.width!==((r=M(this,ia))==null?void 0:r.width))&&(M(this,na).unobserve(this.contentWrapper),this.resizeTextarea(),requestAnimationFrame(()=>{M(this,na).observe(this.contentWrapper)}),ye(this,ia,t))}set algString(e){M(this,ht).value=e,this.onInput()}get algString(){return M(this,ht).value}set placeholder(e){M(this,ht).placeholder=e}resizeTextarea(){if(M(this,ht).clientHeight=e.latestUnit.startCharIndex&&M(this,ht).selectionStart{try{e[M(this,lr)]=t.detail.alg,this.setAlgValidForPuzzle(!0)}catch(i){console.error(\"cannot set alg for puzzle\",i),e[M(this,lr)]=new le,this.setAlgValidForPuzzle(!1)}}),M(this,lr)===\"alg\"&&(this.addEventListener(\"animatedMoveIndexChange\",t=>{try{let i=e.cursor.experimentalTimestampFromIndex(t.detail.idx);e.timeline.setTimestamp(i+(t.detail.isAtStartOfLeaf?250:0))}catch(i){e.timeline.timestamp=0}}),e.timeline.addTimestampListener({onTimelineTimestampChange:t=>{let i=e.cursor.experimentalIndexFromTimestamp(t),r=e.cursor.experimentalMoveAtIndex(i);r&&this.highlightLeaf(r)},onTimeRangeChange:t=>{}})))}attributeChangedCallback(e,t,i){switch(e){case Sf:let r=document.getElementById(i);if(!r){console.warn(`${Sf}= elem does not exist`);return}if(!(r instanceof Ro)){console.warn(`${Sf}=is not a twisty-player`);return}this.twistyPlayer=r;return;case rb:this.placeholder=i;return;case ob:if(M(this,No))throw new Error(\"cannot set prop after twisty player\");ye(this,lr,i);return}}static get observedAttributes(){return[Sf,rb,ob]}};sr=new WeakMap,ht=new WeakMap,Io=new WeakMap,Fo=new WeakMap,ar=new WeakMap,tc=new WeakMap,nc=new WeakMap,Ef=new WeakMap,No=new WeakMap,lr=new WeakMap,na=new WeakMap,ia=new WeakMap;Ct.define(\"twisty-alg-editor\",tm);var $D=5;function eL(n,e){var t=[],i=[];return function(){Object.keys(n.moves).forEach(function(r){var o=Nh(n,n.moves[r]),a=new xi(e,le.fromString(r)).transformAtIndex(1);let l=a;for(var c=1;c{if(c===0){var u=this.sgsPhaseSolve(l);f.length+u[0]se(this,null,function*(){let n=yield gn[\"2x2x2\"].def(),e=Object.assign({},n);delete e.moves.x,delete e.moves.y,delete e.moves.z;let t=(yield Promise.resolve().then(()=>(lb(),ab))).cachedData222;return new nm(e,t)}))())})}function fb(){return se(this,null,function*(){yield ub()})}function iL(n){return se(this,null,function*(){return(yield ub()).solve(n,3)})}function rL(n,e,t,i){return se(this,null,function*(){let r=yield qi();yield p1(t[e].permutation);let o=n.orbits[e],s=t[e].orientation,a=0;for(let l=0;le[t][i][r]).join(\"\")}nt();function mb(n,e,t){for(let i in n.orbits)if(!Wa(n,i,e,t,{ignoreOrientation:i===\"CENTERS\"}))return!1;return!0}function gb(n,e){let t=new Yn(n);if(mb(n,t.state,e))return!1;for(let i of\"ULFRBD\")for(let r=1;r<4;r++)if(t.reset(),t.applyMove(new k(i,r)),mb(n,t.state,e))return!1;return!0}var lt={3:1},xn=4194303,qr=1048575,fL=524288,im=65536,Wt=65535,Pt={11:1,3:1},Yt={17:1,3:1},rm=14540032,ic=286331153,ot={10:1,3:1},qe,_f={};function yb(){}function hL(n){function e(){}return e.prototype=n||{},new e}function pL(n){return n instanceof Array?n[0]:null}function Tf(){}function rc(n,e,t){var i=_f,r=dL,o=pL,s=i[n],a=o(s);s&&!a?qe=s:(qe=i[n]=e?r(e):{},qe.castableTypeMap$=t,qe.constructor=qe,!e&&(qe.typeMarker$=yb));for(var l=3;l>24}function sm(){++bL,this.typeName=null,this.simpleName=null,this.packageName=null,this.compoundName=null,this.canonicalName=null,this.typeId=null,this.arrayLiterals=null}function am(n,e){var t;return t=new sm,t.packageName=n,t.compoundName=e,t}function Ni(n,e,t){var i;return i=am(n,e),xL(t,i),i}function yL(n,e){var t;return t=am(n,e),t.modifiers=2,t}function Df(n,e){var t;return t=am(\"\",n),t.typeId=e,t.modifiers=1,t}function xb(n,e){var t=n.arrayLiterals=n.arrayLiterals||[];return t[e]||(t[e]=n.createClassLiteralForArray(e))}function vL(n){if(n.isPrimitive())return null;var e=n.typeId,t=_f[e];return t}function xL(n,e){var t;if(!!n){e.typeId=n;var i=vL(e);if(!i){_f[n]=[e];return}i.___clazz$=e}}rc(79,1,{},sm);qe.createClassLiteralForArray=function(e){var t;return t=new sm,t.modifiers=4,e>1?t.componentType=xb(this,e-1):t.componentType=this,t};qe.isPrimitive=function(){return(this.modifiers&1)!=0};var bL=1;function lm(){lm=Tf,NOT_SET=new vb}function wL(n){lm(),this.cause=null,this.detailMessage=null,this.description=\"\",this.e=n,this.description=\"\"}function et(n,e){return xb(n,e)}function Ze(n,e,t,i,r,o){var s;return s=wb(r,i),tt(et(n,o),e,t,r,s),s}function bn(n,e,t,i,r,o){return bb(n,e,t,i,r,0,o)}function bb(n,e,t,i,r,o,s){var a,l,c,f,u;if(f=r[o],c=o==s-1,a=c?i:0,u=wb(a,f),tt(et(n,s-o),e[o],t[o],a,u),!c)for(++o,l=0;l>22&xn,i=n<0?qr:0,EL(e,t,i)}function EL(n,e,t){return{l:n,m:e,h:t}}function _L(n,e){var t,i,r;return t=n.l+e.l,i=n.m+e.m+(t>>22),r=n.h+e.h+(i>>22),{l:t&xn,m:i&xn,h:r&qr}}function bi(n,e){return{l:n.l&e.l,m:n.m&e.m,h:n.h&e.h}}function cm(n){var e,t;return n>-129&&n<128?(e=n+128,Rf==null&&(Rf=Ze(iC,lt,293,256,0,1)),t=Rf[e],!t&&(t=Rf[e]=Mb(n)),t):Mb(n)}function Sb(n,e){var t,i;return t=n.h>>19,i=e.h>>19,t==0?i!=0||n.h>e.h||n.h==e.h&&n.m>e.m||n.h==e.h&&n.m==e.m&&n.l>=e.l:!(i==0||n.h>22-e,r=n.h<>22-e):e<44?(t=0,i=n.l<>44-e):(t=0,i=0,r=n.l<>e,o=n.m>>e|t<<22-e,r=n.l>>e|n.m<<22-e):e<44?(s=i?qr:0,o=t>>e-22,r=n.m>>e-22|t<<44-e):(s=i?qr:0,o=i?xn:0,r=t>>e-44),{l:r&xn,m:o&xn,h:s&qr}}function Eb(n,e){var t,i,r;return t=n.l-e.l,i=n.m-e.m+(t>>22),r=n.h-e.h+(i>>22),{l:t&xn,m:i&xn,h:r&qr}}function Bo(n){return n.l|n.m<<22}var Rf;function TL(n){this.string=n}function Yr(n,e){return n>e?n:e}function fm(n,e){return n=im?(e=55296+(n-im>>10&1023)&Wt,t=56320+(n-im&1023)&Wt,valueOf_0(e)+valueOf_0(t)):String.fromCharCode(n&Wt)}var RL=Ni(\"java.lang\",\"String\",2);function _b(n){return n.string+=\" \",n}function hm(n,e){return n.string+=e,n}function PL(){TL.call(this,\"\")}function Pf(n,e){var t;if(n===e)return!0;if(n.length!=e.length)return!1;for(t=0;t>=3,n.twist=ua[e.twist][Go[t<<3|e.tsym]],n.tsym=n.twist&7^e.tsym,n.twist>>=3,n.prun=Yr(Yr(Pn(If,n.twist*495+Zr[n.slice_0][n.tsym]),Pn(zf,n.flip*495+Zr[n.slice_0][n.fsym])),Pn(ca,n.twist<<11|eo[n.flip<<3|n.fsym^n.tsym])),n.prun}function zL(n,e,t){return t=(Qe(),uc)[3][t],n.flipc=aa[e.flipc>>3][Go[t<<3|e.flipc&7]]^e.flipc&7,n.twistc=ua[e.twistc>>3][Go[t<<3|e.twistc&7]]^e.twistc&7,Pn(ca,n.twistc>>3<<11|eo[n.flipc^n.twistc&7])}function Tb(n,e,t){var i;return n.twist=(Qe(),fc)[Of(e)],n.flip=Uo[Bf(e)],n.tsym=n.twist&7,n.twist=n.twist>>3,n.prun=Pn(ca,n.twist<<11|eo[n.flip^n.tsym]),n.prun>t||(n.fsym=n.flip&7,n.flip=n.flip>>3,n.slice_0=494-pa(e.ea,8,!0),n.prun=Yr(n.prun,Yr(Pn(If,n.twist*495+Zr[n.slice_0][n.tsym]),Pn(zf,n.flip*495+Zr[n.slice_0][n.fsym]))),n.prun>t)?!1:(i=new dt,lc(e,1,i),cc(e,1,i),n.twistc=fc[Of(i)],n.flipc=Uo[Bf(i)],n.prun=Yr(n.prun,Pn(ca,n.twistc>>3<<11|eo[n.flipc^n.twistc&7])),n.prun<=t)}function oc(){Xr()}function Pn(n,e){return Xr(),n[e>>3]>>(e<<2)&15}function Ab(n){Xr(),!(Ff==2||Ff==1&&!n)&&(Ff==0&&(QL(),IL(),NL(),OL(),FL(),Qe(),vm(2048,xm,Uo,kb=Ze(kt,Pt,0,336,7,1),0),vm(2187,Sm,fc,Mm=Ze(kt,Pt,0,324,7,1),1),BL(),UL(),GL()),sc(kf,la,ac,ra,(Qe(),wm),584244,n),sc(oa,pm,Oo,sa,wm,514084,n),sc(If,Jr,Zr,ua,Mm,431619,n),sc(zf,Jr,Zr,aa,kb,431619,n),sc(ca,null,null,ua,Mm,103939,n),Ff=n?2:1)}function IL(){var n,e,t,i;for(n=new dt,e=new dt,t=0;t<2768;t++)for(VL(n,(Qe(),fa)[t]),i=0;i<10;i++)Kr(n,mt[(an(),Mi)[i]],e),ra[t][i]=Wf(ur[zn(e.ca,8,!1)])&Wt}function FL(){var n,e,t,i,r;for(n=new dt,e=new dt,pm=bn(kt,[lt,Pt],[11,0],7,[140,10],2),t=0;t<140;t++){for(Ub(n.ca,t%70,0,!1),r=0;r<10;r++)Kr(n,(Qe(),mt)[(an(),Mi)[r]],e),pm[t][r]=pa(e.ca,0,!1)+70*(165>>r&1^~~(t/70))&Wt;for(i=0;i<16;i++)lc(n,(Qe(),kn)[0][i],e),Oo[t][i]=pa(e.ca,0,!1)+70*~~(t/70)&Wt}}function NL(){var n,e,t,i;for(n=new dt,e=new dt,t=0;t<2768;t++)for(Cb(n,(Qe(),fa)[t]),i=0;i<10;i++)ei(n,mt[(an(),Mi)[i]],e),sa[t][i]=ur[zn(e.ea,8,!0)]}function BL(){var n,e,t,i;for(n=new dt,e=new dt,t=0;t<336;t++)for(gm(n,(Qe(),xm)[t]),i=0;i<18;i++)ei(n,mt[i],e),aa[t][i]=Uo[Bf(e)]}function OL(){var n,e,t,i,r;for(n=new dt,e=new dt,t=0;t<24;t++){for(Wo(n.ea,t,12,!0),r=0;r<10;r++)ei(n,(Qe(),mt)[(an(),Mi)[r]],e),la[t][r]=zn(e.ea,12,!0)%24&Wt;for(i=0;i<16;i++)cc(n,(Qe(),kn)[0][i],e),ac[t][i]=zn(e.ea,12,!0)%24&Wt}}function sc(n,e,t,i,r,o,s){var a,l,c,f,u,h,p,d,g,v,y,m,S,b,w,x,A,O,B,U,C,N,R,D,z,G,Q,te,ee,ie,P,X,J,W,j,F,ue;if(S=o&15,y=(o>>4&1)==1?rm:0,c=(o>>5&1)==1,a=o>>8&15,f=o>>12&15,u=o>>16&15,v=s?f:u,m=(1<>3]>>(g<<2)&15)-1,x=0,w==-1){for(B=0;B<~~(g/8)+1;B++)n[B]=ic;n[0]^=1,w=0,x=1}for(;w>1,n[U]+=F&F>>2⁣for(R=w>a,P=R?w+2:w,ie=P*ic,b=R?w:w+2,++w,ue=w^w+1,j=0,B=0;B>=4){if((B&7)==0&&(j=n[B>>3],((j^ie)-ic&~(j^ie)&-2004318072)==0)){B+=7;continue}if((j&15)==P)for(te=B%d,X=~~(B/d),A=0,O=0,l&&(A=(Qe(),Uo)[te],O=A&7,A>>=3),z=0;z>=S,C=W*d+ee,Q=n[C>>3]>>(C<<2)&15,Q!=b){Q>z&3);continue}if(++x,R){n[B>>3]^=ue<<(B<<2);break}for(n[C>>3]^=ue<<(C<<2),D=1,J=r[W];(J>>=1)!=0;D++)(J&1)==1&&(N=W*d,l?N+=(Qe(),eo)[Uo[ee]^D]:N+=t[ee][D^y>>(D<<1)&3],(n[N>>3]>>(N<<2)&15)==b&&(n[N>>3]^=ue<<(N<<2),++x))}}}}function UL(){var n,e,t,i;for(n=new dt,e=new dt,t=0;t<324;t++)for(ym(n,(Qe(),Sm)[t]),i=0;i<18;i++)Kr(n,mt[i],e),ua[t][i]=fc[Of(e)]}function GL(){var n,e,t,i,r,o,s,a;for(n=new dt,e=new dt,i=0;i<495;i++){for(Ub(n.ea,494-i,8,!0),o=0;o<18;o+=3)ei(n,(Qe(),mt)[o],e),Jr[i][o]=494-pa(e.ea,8,!0)&Wt;for(r=0;r<16;r+=2)cc(n,(Qe(),kn)[0][r],e),Zr[i][r>>1]=494-pa(e.ea,8,!0)&Wt}for(t=0;t<495;t++)for(r=0;r<18;r+=3)for(a=Jr[t][r],s=1;s<3;s++)a=Jr[a][r],Jr[t][r+s]=a&Wt}rc(31,1,{31:1},oc);qe.flip=0;qe.flipc=0;qe.fsym=0;qe.prun=0;qe.slice_0=0;qe.tsym=0;qe.twist=0;qe.twistc=0;var Oo,pm,ra,oa,sa,aa,kf,ac,la,ca,ua,Zr,zf,Jr,If,Ff=0,Nf=Ni(\"org.cubing.min2phase.client\",\"CoordCube\",31);function Qe(){Qe=Tf,cr=Ze(hc,lt,7,16,0,1),mt=Ze(hc,lt,7,18,0,1),Vf=Ze(rC,lt,0,18,6,1),Em=Ze(Xt,Yt,0,48,7,1),fr=bn(Xt,[lt,Yt],[17,0],7,[16,16],2),kn=bn(Xt,[lt,Yt],[17,0],7,[16,16],2),uc=bn(Xt,[lt,Yt],[17,0],7,[16,18],2),Go=Ze(Xt,Yt,0,144,7,1),to=bn(Xt,[lt,Yt],[17,0],7,[16,18],2),xm=Ze(kt,Pt,0,336,7,1),Sm=Ze(kt,Pt,0,324,7,1),fa=Ze(kt,Pt,0,2768,7,1),ha=Ze(it,ot,0,2768,7,1),bm=Ze(kt,Pt,0,2768,7,1),Hf=Ze(it,ot,0,24,7,1),Uo=Ze(kt,Pt,0,2048,7,1),fc=Ze(kt,Pt,0,2187,7,1),ur=Ze(kt,Pt,0,40320,7,1),eo=Ze(kt,Pt,0,2688,7,1),_m=new wi(2531,1373,67026819,1367),Tm=new wi(2089,1906,322752913,2040),jf=tt(et(it,2),lt,10,0,[tt(et(it,1),ot,0,7,[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17]),tt(et(it,1),ot,0,7,[6,7,8,0,1,2,3,4,5,15,16,17,9,10,11,12,13,14]),tt(et(it,1),ot,0,7,[3,4,5,6,7,8,0,1,2,12,13,14,15,16,17,9,10,11]),tt(et(it,1),ot,0,7,[2,1,0,5,4,3,8,7,6,11,10,9,14,13,12,17,16,15]),tt(et(it,1),ot,0,7,[8,7,6,2,1,0,5,4,3,17,16,15,11,10,9,14,13,12]),tt(et(it,1),ot,0,7,[5,4,3,8,7,6,2,1,0,14,13,12,17,16,15,11,10,9])]),qL(),YL()}function dm(n){n.ca=tt(et(it,1),ot,0,7,[0,1,2,3,4,5,6,7]),n.ea=tt(et(it,1),ot,0,7,[0,2,4,6,8,10,12,14,16,18,20,22])}function Db(n){!n.temps&&(n.temps=new dt),Kr(Tm,n,n.temps),Kr(n.temps,_m,n),ei(Tm,n,n.temps),ei(n.temps,_m,n)}function mm(n,e){var t,i;for(i=0;i<8;i++)n.ca[i]=e.ca[i];for(t=0;t<12;t++)n.ea[t]=e.ea[t]}function WL(n){return Wf(ur[zn(n.ca,8,!1)])}function HL(n){return ur[zn(n.ea,8,!0)]}function Bf(n){var e,t;for(t=0,e=0;e<11;e++)t=t<<1|n.ea[e]&1;return t}function Of(n){var e,t;for(t=0,e=0;e<7;e++)t+=(t<<1)+(n.ca[e]>>3);return t}function Uf(n){var e,t;for(!n.temps&&(n.temps=new dt),t=0;t<12;t++)n.temps.ea[n.ea[t]>>1]=(t<<1|n.ea[t]&1)<<24>>24;for(e=0;e<8;e++)n.temps.ca[n.ca[e]&7]=(e|32>>(n.ca[e]>>3)&24)<<24>>24;mm(n,n.temps)}function Lb(n){var e,t,i,r,o,s,a;for(e=new Rb(n),r=new dt,t=Wf(ur[zn(e.ca,8,!1)])>>4,s={l:0,m:0,h:0},a=0;a<6;a++){if(i=Wf(ur[zn(e.ca,8,!1)])>>4,t==i)for(o=0;o<16;o++)lc(e,kn[0][o],r),Pf(r.ca,n.ca)&&(cc(e,kn[0][o],r),Pf(r.ea,n.ea)&&(s=um(s,Cf({l:1,m:0,h:0},(a<<4|o)<48?a<<4|o:48))));Db(e),a%3==2&&Uf(e)}return s}function VL(n,e){Wo(n.ca,e,8,!1)}function Cb(n,e){Wo(n.ea,e,8,!0)}function gm(n,e){var t,i,r;for(i=0,t=10;t>=0;--t,e>>=1)i^=r=e&1,n.ea[t]=(n.ea[t]&-2|r)<<24>>24;n.ea[11]=(n.ea[11]&-2|i)<<24>>24}function ym(n,e){var t,i,r;for(i=15,t=6;t>=0;--t,e=~~(e/3))i-=r=e%3,n.ca[t]=(n.ca[t]&7|r<<3)<<24>>24;n.ca[7]=(n.ca[7]&7|i%3<<3)<<24>>24}function jL(n){var e,t,i,r,o;for(o=0,r=0,i=0;i<12;i++)r|=1<<(n.ea[i]>>1),o^=n.ea[i]&1;if(r!=4095)return-2;if(o!=0)return-3;for(t=0,o=0,e=0;e<8;e++)t|=1<<(n.ca[e]&7),o+=n.ca[e]>>3;return t!=255?-4:o%3!=0?-5:(Dm(zn(n.ea,12,!0),12)^Dm(zn(n.ca,8,!1),8))!=0?-6:0}function lc(n,e,t){Qe();var i,r,o,s,a,l;for(l=cr[kn[0][e]],a=cr[e],i=0;i<8;i++)o=l.ca[n.ca[a.ca[i]&7]&7]>>3,s=n.ca[a.ca[i]&7]>>3,r=o<3?s:(3-s)%3,t.ca[i]=(l.ca[n.ca[a.ca[i]&7]&7]&7|r<<3)<<24>>24}function Kr(n,e,t){Qe();var i,r,o;for(i=0;i<8;i++)r=n.ca[e.ca[i]&7]>>3,o=e.ca[i]>>3,t.ca[i]=(n.ca[e.ca[i]&7]&7|(r+o)%3<<3)<<24>>24}function Gf(n,e,t){var i,r,o,s;for(i=0;i<8;i++)o=n.ca[e.ca[i]&7]>>3,s=e.ca[i]>>3,r=o+(o<3?s:6-s),r=r%3+(o<3==s<3?0:3),t.ca[i]=(n.ca[e.ca[i]&7]&7|r<<3)<<24>>24}function dt(){Qe(),dm(this)}function wi(n,e,t,i){dm(this),Wo(this.ca,n,8,!1),ym(this,e),Wo(this.ea,t,12,!0),gm(this,i)}function Rb(n){dm(this),mm(this,n)}function Wf(n){return Qe(),n^rm>>((n&15)<<1)&3}function cc(n,e,t){Qe();var i,r,o;for(o=cr[kn[0][e]],r=cr[e],i=0;i<12;i++)t.ea[i]=(o.ea[n.ea[r.ea[i]>>1]>>1]^n.ea[r.ea[i]>>1]&1^r.ea[i]&1)<<24>>24}function ei(n,e,t){Qe();var i;for(i=0;i<12;i++)t.ea[i]=(n.ea[e.ea[i]>>1]^e.ea[i]&1)<<24>>24}function $r(n,e,t){Qe();var i;return i=bm[n],t&&(i=i^rm>>((i&15)<<1)&3),i&65520|fr[i&15][e]}function Pb(n){Qe();var e,t;for(t=0,e=1;Lf(n=Qr(n,1),{l:0,m:0,h:0});e++)eq(bi(n,{l:1,m:0,h:0}),{l:1,m:0,h:0})&&(t|=Em[e]);return t}function qL(){var n,e;for(mt[0]=new wi(15120,0,119750400,0),mt[3]=new wi(21021,1494,323403417,0),mt[6]=new wi(8064,1236,29441808,550),mt[9]=new wi(9,0,5880,0),mt[12]=new wi(1230,412,2949660,0),mt[15]=new wi(224,137,328552,137),n=0;n<18;n+=3)for(e=0;e<2;e++)mt[n+e+1]=new dt,ei(mt[n+e],mt[n],mt[n+e+1]),Kr(mt[n+e],mt[n],mt[n+e+1])}function QL(){Qe();var n,e,t;for(vm(40320,fa,ur,wm=Ze(kt,Pt,0,2768,7,1),2),n=new dt,t=0;t<2768;t++)Cb(n,fa[t]),ha[t]=pa(n.ea,0,!0)+Dm(fa[t],8)*70<<24>>24,Uf(n),bm[t]=ur[zn(n.ea,8,!0)];for(e=0;e<24;e++)Wo(n.ea,e,12,!0),Uf(n),Hf[e]=zn(n.ea,12,!0)%24<<24>>24}function YL(){var n,e,t,i,r,o,s,a,l,c,f,u,h,p,d,g;for(n=new dt,e=new dt,t=new wi(28783,0,259268407,0),g=new wi(15138,0,119765538,7),u=new wi(5167,0,83473207,0),r=0;r<8;r++)u.ca[r]=Af(u.ca[r]|24);for(o=0;o<16;o++)cr[o]=new Rb(n),Gf(n,g,e),ei(n,g,e),d=e,e=n,n=d,o%4==3&&(Gf(d,u,e),ei(d,u,e),d=e,e=n,n=d),o%8==7&&(Gf(d,t,e),ei(d,t,e),d=e,e=n,n=d);for(s=0;s<16;s++)for(l=0;l<16;l++)for(Gf(cr[s],cr[l],n),f=0;f<16;f++)if(Pf(cr[f].ca,n.ca)){fr[s][l]=f,kn[f][l]=s;break}for(c=0;c<18;c++)for(p=0;p<16;p++){for(lc(mt[c],kn[0][p],n),h=0;h<18;h++)if(Pf(mt[h].ca,n.ca)){uc[p][c]=h,to[p][(an(),da)[c]]=da[h];break}p%2==0&&(Go[c<<3|p>>1]=uc[p][c])}for(i=0;i<18;i++)for(Vf[i]=Lb(mt[i]),a=i,p=0;p<48;p++)uc[p%16][a]=2?1:2,f=r!=1,l=0;l>1]=c&Wt),c==l&&(i[s]=(i[s]|1<<~~(u/p))&Wt),h=~~((s<<4|u)/p),t[c]=h&Wt}e[s++]=l&Wt}return s}var cr,ur,fa,Uo,xm,eo,Hf,ha,bm,Go,uc,to,fr,kn,kb,wm,Mm,fc,Sm,Em,mt,Vf,_m,Tm,jf,hc=Ni(\"org.cubing.min2phase.client\",\"CubieCube\",7);function XL(n,e,t,i,r,o,s,a){var l,c,f,u,h;if(u=Yr(Pn((Xr(),oa),(s>>4)*140+Oo[(Qe(),ha)[a>>4]&255][kn[s&15][a&15]]),Yr(Pn(oa,i*140+Oo[ha[e]&255][kn[r][t]]),Pn(kf,e*24+ac[o][t]))),u>n.maxDep2)return u-n.maxDep2;for(l=n.maxDep2;l>=u&&(h=Fb(n,i,r,e,t,o,l,n.depth1,10),!(h<0));l--){for(l-=h,n.solLen=0,n.solution=new Wb,nC(n.solution,n.verbose,n.urfIdx,n.depth1),f=0;f=0;c--)Gb(n.solution,n.preMoves[c]);n.solLen=n.solution.length_0}return l!=n.maxDep2?(n.maxDep2=fm(Bb,n.solLen-n.length1-1),Sb(n.probe,n.probeMin)?0:1):1}function ZL(n){var e,t,i,r,o,s,a,l,c,f,u,h,p,d,g;if(n.isRec=!1,Sb(n.probe,n.solution?n.probeMin:n.probeMax))return 0;for(n.probe=_L(n.probe,{l:1,m:0,h:0}),i=n.valid1;i>=4,c=HL(n.phase1Cubie[n.depth1]),f=c&15,c>>=4,u=zn(n.phase1Cubie[n.depth1].ea,12,!0)%24,t=$r(c,f,!1),e=$r(a,l,!0),r=n.depth1==0?-1:n.move[n.depth1-1],o=n.preMoveLen==0?-1:n.preMoves[n.preMoveLen-1],g=0,d=(n.preMoveLen==0?1:2)*(n.depth1==0?1:2),h=0,p=(1<>h&1)!=0){if(p&=~(1<2)break;g==2&&(p&=4<0?(s=(an(),da)[~~(r/3)*3+1],n.move[n.depth1-1]=Mi[s]*2-n.move[n.depth1-1],u=(Xr(),la)[u][s],a=ra[a][(Qe(),to)[l][s]],l=fr[a&15][l],a>>=4,c=sa[c][to[f][s]],f=fr[c&15][f],c>>=4,e=$r(a,l,!0),t=$r(c,f,!1)):n.preMoveLen>0&&(s=(an(),da)[~~(o/3)*3+1],n.preMoves[n.preMoveLen-1]=Mi[s]*2-n.preMoves[n.preMoveLen-1],u=(Qe(),Hf)[(Xr(),la)[Hf[u]][s]],a=ra[e>>4][to[e&15][s]],e=a&-16|fr[a&15][e&15],a=$r(e>>4,e&15,!0),l=a&15,a>>=4,c=sa[t>>4][to[t&15][s]],t=c&-16|fr[c&15][t&15],c=$r(t>>4,t&15,!1),f=c&15,c>>=4)}return n.depth1>0&&(n.move[n.depth1-1]=r),n.preMoveLen>0&&(n.preMoves[n.preMoveLen-1]=o),g==0?0:2}function JL(n){var e;for(n.conjMask=0,n.selfSym=Lb(n.cc),n.conjMask|=Lf(bi(Qr(n.selfSym,16),{l:Wt,m:0,h:0}),{l:0,m:0,h:0})?18:0,n.conjMask|=Lf(bi(Qr(n.selfSym,32),{l:Wt,m:0,h:0}),{l:0,m:0,h:0})?36:0,n.conjMask|=Lf(bi(Qr(n.selfSym,48),{l:Wt,m:0,h:0}),{l:0,m:0,h:0})?56:0,n.selfSym=bi(n.selfSym,{l:xn,m:xn,h:15}),n.maxPreMoves=n.conjMask>7?0:20,e=0;e<6;e++)mm(n.urfCubieCube[e],n.cc),Tb(n.urfCoordCube[e],n.urfCubieCube[e],20),Db(n.cc),e%3==2&&Uf(n.cc)}function zb(n,e,t,i,r){var o,s,a,l,c,f;if(e.prun==0&&i<5)return n.allowShorter||i==0?(n.depth1-=i,c=ZL(n),n.depth1+=i,c):1;for(f=Pb(cm(t)),o=0;o<18;o+=3)if(!(o==r||o==r-9)){for(a=0;a<3;a++)if(s=o+a,!(n.isRec&&s!=n.move[n.depth1-i]||f!=0&&(f&1<i)break;if(l==i)continue;if(l=zL(n.nodeUD[i],e,s),l>i)break;if(l==i)continue;if(n.move[n.depth1-i]=s,n.valid1=fm(n.valid1,n.depth1-i),c=zb(n,n.nodeUD[i],t&Bo((Qe(),Vf)[s]),i-1,o),c==0)return 0;if(c>=2)break}}return 1}function Ib(n,e,t,i,r){var o,s,a;if(n.preMoveLen=n.maxPreMoves-e,(n.isRec?n.depth1==n.length1-n.preMoveLen:n.preMoveLen==0||(225207>>t&1)==0)&&(n.depth1=n.length1-n.preMoveLen,n.phase1Cubie[0]=i,n.allowShorter=n.depth1==Am&&n.preMoveLen!=0,Tb(n.nodeUD[n.depth1+1],i,n.depth1)&&zb(n,n.nodeUD[n.depth1+1],r,n.depth1,-1)==0))return 0;if(e==0||n.preMoveLen+Am>=n.length1)return 1;for(a=Pb(cm(r)),(e==1||n.preMoveLen+1+Am>=n.length1)&&(a|=225207),t=~~(t/3)*3,o=0;o<18;o++){if(o==t||o==t-9||o==t+9){o+=2;continue}if(!(n.isRec&&o!=n.preMoves[n.maxPreMoves-e]||(a&1<>g&1)!=0){g+=66>>g&3;continue}if(v=(Xr(),la)[o][g],f=ra[i][(Qe(),to)[r][g]],u=fr[f&15][r],f>>=4,p=sa[e][to[t][g]],d=fr[p&15][t],p>>=4,h=$r(p,d,!1),c=$r(f,u,!0),m=Pn(oa,(h>>4)*140+Oo[ha[c>>4]&255][kn[h&15][c&15]]),m>s+1)return s-m+1;if(m>=s){g+=66>>g&3&s-m;continue}if(m=Yr(Pn(kf,f*24+ac[v][u]),Pn(oa,p*140+Oo[ha[f]&255][kn[d][u]])),m>=s){g+=66>>g&3&s-m;continue}if(S=Fb(n,p,d,f,u,v,s-1,a+1,g),S>=0)return n.move[a]=Mi[g],S;if(S<-2)break;S<-1&&(g+=66>>g&3)}return-1}function KL(n){for(n.length1=n.isRec?n.length1:0;n.length1>24,r[o]==-1)return-1;i+=1<<(r[o]<<2)}}catch(s){if(s=SL(s),om(s,9))return-1;throw ML(s)}return i!=10066329?-1:(tC(r,n.cc),jL(n.cc))}function Nb(){var n,e,t;for(this.move=Ze(Xt,Yt,0,31,7,1),this.nodeUD=Ze(Nf,lt,31,21,0,1),this.nodeRL=Ze(Nf,lt,31,21,0,1),this.nodeFB=Ze(Nf,lt,31,21,0,1),this.cc=new dt,this.urfCubieCube=Ze(hc,lt,7,6,0,1),this.urfCoordCube=Ze(Nf,lt,31,6,0,1),this.phase1Cubie=Ze(hc,lt,7,21,0,1),this.preMoveCubes=Ze(hc,lt,7,21,0,1),this.preMoves=Ze(Xt,Yt,0,20,7,1),e=0;e<21;e++)this.nodeUD[e]=new oc,this.nodeRL[e]=new oc,this.nodeFB[e]=new oc,this.phase1Cubie[e]=new dt;for(t=0;t<6;t++)this.urfCubieCube[t]=new dt,this.urfCoordCube[t]=new oc;for(n=0;n<20;n++)this.preMoveCubes[n+1]=new dt}rc(72,1,{},Nb);qe.allowShorter=!1;qe.conjMask=0;qe.depth1=0;qe.isRec=!1;qe.length1=0;qe.maxDep2=0;qe.maxPreMoves=0;qe.preMoveLen=0;qe.probe={l:0,m:0,h:0};qe.probeMax={l:0,m:0,h:0};qe.probeMin={l:0,m:0,h:0};qe.selfSym={l:0,m:0,h:0};qe.solLen=0;qe.urfIdx=0;qe.valid1=0;qe.verbose=0;var Bb=12,Am=7,t9=Ni(\"org.cubing.min2phase.client\",\"Search\",72);function an(){an=Tf;var n,e,t,i,r,o;for(Ho=tt(et(it,2),lt,10,0,[tt(et(it,1),ot,0,7,[8,9,20]),tt(et(it,1),ot,0,7,[6,18,38]),tt(et(it,1),ot,0,7,[0,36,47]),tt(et(it,1),ot,0,7,[2,45,11]),tt(et(it,1),ot,0,7,[29,26,15]),tt(et(it,1),ot,0,7,[27,44,24]),tt(et(it,1),ot,0,7,[33,53,42]),tt(et(it,1),ot,0,7,[35,17,51])]),pr=tt(et(it,2),lt,10,0,[tt(et(it,1),ot,0,7,[5,10]),tt(et(it,1),ot,0,7,[7,19]),tt(et(it,1),ot,0,7,[3,37]),tt(et(it,1),ot,0,7,[1,46]),tt(et(it,1),ot,0,7,[32,16]),tt(et(it,1),ot,0,7,[28,25]),tt(et(it,1),ot,0,7,[30,43]),tt(et(it,1),ot,0,7,[34,52]),tt(et(it,1),ot,0,7,[23,12]),tt(et(it,1),ot,0,7,[21,41]),tt(et(it,1),ot,0,7,[50,39]),tt(et(it,1),ot,0,7,[48,14])]),hr=bn(Xt,[lt,Yt],[17,0],7,[13,13],2),Lm=tt(et(RL,1),lt,2,4,[\"U \",\"U2\",\"U'\",\"R \",\"R2\",\"R'\",\"F \",\"F2\",\"F'\",\"D \",\"D2\",\"D'\",\"L \",\"L2\",\"L'\",\"B \",\"B2\",\"B'\"]),Mi=tt(et(Xt,1),Yt,0,7,[0,1,2,4,7,9,10,11,13,16,3,5,6,8,12,14,15,17]),da=Ze(Xt,Yt,0,18,7,1),pc=Ze(Xt,Yt,0,11,7,1),e=0;e<18;e++)da[Mi[e]]=e;for(t=0;t<10;t++)for(i=~~(Mi[t]/3),pc[t]=0,r=0;r<10;r++)o=~~(Mi[r]/3),pc[t]|=(i==o||i%3==o%3&&i>=o?1:0)<=0;r--)s=Ob(n[r],t),(s&12)==e&&(o+=hr[r][a--]);return o}function Dm(n,e){an();var t,i;for(i=0,t=e-2;t>=0;t--)i^=n%(e-t),n=~~(n/(e-t));return i&1}function zn(n,e,t){an();var i,r,o,s;for(r=0,s={l:1323536,m:2777561,h:1043915},i=0;i>1:n&7}function Ub(n,e,t,i){an();var r,o,s,a;for(r=n.length-1,a=4,o=r,s=r;s>=0;s--)e>=hr[s][a]?(e-=hr[s][a--],n[s]=qf(n[s],a|t,i)):((o&12)==t&&(o-=4),n[s]=qf(n[s],o--,i))}function Wo(n,e,t,i){an();var r,o,s,a,l,c;for(c={l:1323536,m:2777561,h:1043915},r={l:0,m:0,h:0},a=2;a<=t;a++)r=um(Cf(r,4),cm(e%a)),e=~~(e/a);for(o=0;o>24}function tC(n,e){an();var t,i,r,o,s,a,l,c;for(o=0;o<8;o++)e.ca[o]=0;for(s=0;s<12;s++)e.ea[s]=0;for(a=0;a<8;a++){for(c=0;c<3&&!(n[Ho[a][c]]==0||n[Ho[a][c]]==3);c++);for(t=n[Ho[a][(c+1)%3]],i=n[Ho[a][(c+2)%3]],l=0;l<8;l++)if(t==~~(Ho[l][1]/9)&&i==~~(Ho[l][2]/9)){e.ca[a]=Af(c%3<<3|l);break}}for(r=0;r<12;r++)for(l=0;l<12;l++){if(n[pr[r][0]]==~~(pr[l][0]/9)&&n[pr[r][1]]==~~(pr[l][1]/9)){e.ea[r]=Af(l<<1);break}if(n[pr[r][0]]==~~(pr[l][1]/9)&&n[pr[r][1]]==~~(pr[l][0]/9)){e.ea[r]=Af(l<<1|1);break}}}var hr,pc,Ho,pr,Lm,da,Mi;function Gb(n,e){var t,i,r;if(n.length_0==0){n.moves[n.length_0++]=e;return}if(t=~~(e/3),i=~~(n.moves[n.length_0-1]/3),t==i){r=(e%3+n.moves[n.length_0-1]%3+1)%4,r==3?--n.length_0:n.moves[n.length_0-1]=t*3+r;return}if(n.length_0>1&&t%3==i%3&&t==~~(n.moves[n.length_0-2]/3)){r=(e%3+n.moves[n.length_0-2]%3+1)%4,r==3?(n.moves[n.length_0-2]=n.moves[n.length_0-1],--n.length_0):n.moves[n.length_0-2]=t*3+r;return}n.moves[n.length_0++]=e}function nC(n,e,t,i){n.verbose=e,n.urfIdx=t,n.depth1=i}function Cm(n){var e,t,i;if(t=new PL,i=(n.verbose&2)!=0?(n.urfIdx+3)%6:n.urfIdx,i<3)for(e=0;e=0;e--)_b(hm(t,(an(),Lm)[(Qe(),jf)[i][n.moves[e]]])),(n.verbose&1)!=0&&e==n.depth1&&(t.string+=\". \");return(n.verbose&4)!=0&&hm($append_0((t.string+=\"(\",t),n.length_0),\"f)\"),t.string}function Wb(){this.moves=Ze(Xt,Yt,0,31,7,1)}rc(150,1,{},Wb);qe.toString$=function(){return Cm(this)};qe.depth1=0;qe.length_0=0;qe.urfIdx=0;qe.verbose=0;var n9=Ni(\"org.cubing.min2phase.client\",\"Util/Solution\",150);var Xt=Df(\"int\",\"I\"),i9=Ni(\"com.google.gwt.lang\",\"CollapsedPropertyHolder\",252),r9=Ni(\"com.google.gwt.lang\",\"JavaClassHierarchySetupUtil\",254),iC=Ni(\"com.google.gwt.lang\",\"LongLibBase/LongEmul\",null),o9=Ni(\"com.google.gwt.lang\",\"ModuleUtils\",257),it=Df(\"byte\",\"B\"),rC=Df(\"long\",\"J\"),kt=Df(\"char\",\"C\"),s9=Ni(\"com.google.gwt.user.client.rpc\",\"XsrfToken\",null),a9=yL(\"java.util\",\"Map/Entry\"),Hb=function(){Ab(!1)},Vb=function(n){return $L(new Nb,n)};var jb=[[\"R U'\",\"R2 B\",\"D2 B2\",\"D' L B'\",\"R' U'\",\"B\",\"D B2\",\"R' B\",\"L' U\",\"L2 B'\",\"B2\",\"D L B'\",\"L U\",\"B'\",\"U'\",\"R B\",\"D' B2\",\"L B'\",\"U2\",\"U L' B'\",\"\",\"U' L' B'\",\"U\",\"L' B'\"],[\"F2 L2\",\"F' L'\",\"R' F L2\",\"D' L2\",\"F L2\",\"F2 L'\",\"R' F' L'\",\"R2 F L2\",\"R2 F2 L'\",\"L2\",\"F L'\",\"D' L\",\"D2 L2\",\"R2 F' L'\",\"D L\",\"\",\"L2 F L'\",\"L F' L2\",\"L F L'\",\"F' L2\",\"L'\",\"D L2\",\"D F L'\",\"L\"],[\"R B U2 B'\",\"R2 B U' B'\",\"F2 B U B'\",\"F B2 L' B2\",\"B2 L B2\",\"B U' B'\",\"R2 B U2 B'\",\"R' B U' B'\",\"B2 L' B2\",\"F B U B'\",\"B2 U' B2\",\"B' L B\",\"L F' B D' B'\",\"B' U' B2 D B'\",\"B U2 B'\",\"R B U' B'\",\"B2 L2 B2\",\"D' B' L B\",\"B U B'\",\"F' B2 L' B2\",\"\",\"B2 L' B' U' B'\"],[\"U F2 L2 U'\",\"F' U L' U'\",\"F2 U L' U'\",\"U F L2 U'\",\"U2 B2 U2\",\"R' U' B U\",\"D2 U L U'\",\"D U2 B' U2\",\"U L2 U'\",\"F U L' U'\",\"D U L U'\",\"U2 B' U2\",\"\",\"U2 B' U' L' U'\",\"U2 L' U2\",\"U' B U\",\"U L U'\",\"D' U2 B' U2\",\"U L' U'\",\"U2 B U2\"],[\"R' D' F2\",\"F'\",\"F2\",\"D R F'\",\"R D' F2\",\"R2 F'\",\"D' F2\",\"R F'\",\"F2 R' D' F2\",\"F\",\"D2 F2\",\"D' R F'\",\"R2 D' F2\",\"R' F'\",\"D F2\",\"D2 R F'\",\"\",\"F R' D' F2\"],[\"R' D2 F' D F\",\"R F2 R2 F2\",\"R2 F' D2 F\",\"F' R2 D2 F\",\"L D' L'\",\"D F' D2 F\",\"F2 R2 F2\",\"R F' D2 F\",\"F' R2 D' F\",\"F' R' D2 F\",\"F2 R' F2\",\"L D L'\",\"F' R D' F\",\"F2 R F2\",\"F' D2 F\",\"\",\"L D2 R D' L'\",\"F' D2 F' R F2\",\"D2 R2 F2 R2 F2\",\"D F' D' F\",\"F' D F\"],[\"U F2 U'\",\"R U F' U'\",\"D R U F2 U'\",\"U F U'\",\"R2 U F2 U'\",\"R' U F' U'\",\"R U F2 U'\",\"R2 U F' U'\",\"\",\"U L D L' F U'\",\"F2 D' R D F2\",\"D2 U F U'\",\"R' U F2 U'\",\"U F' U'\",\"F2 D2 R D2 F2\",\"D U F U'\"],[\"R2\",\"R' B' D B\",\"D R'\",\"F' R2 F\",\"\",\"R B' D B\",\"R'\",\"B' D B\",\"D' R'\",\"D2 F' R2 F\",\"R\",\"R2 B' D B\",\"D2 R'\",\"B' D' B\"],[\"R2 D' R2\",\"F' R' F R\",\"R D' R2 D R'\",\"D2 R2 D2 R2\",\"R' D' F' R F\",\"U F D F' U'\",\"\",\"R2 D2 B R' B' R'\",\"R' F D' F2 R F\",\"R2 D R2\",\"F2 U F U' F\",\"R' D F' R F\",\"D R2 D2 R2\",\"U F D' F' U'\",\"D R' D2 F' R F\",\"R2 D2 R2\",\"U F D2 F' U'\",\"R' D2 F' R F\"],[\"B R B'\",\"F D F' B R2 B'\",\"D B R2 B'\",\"D2 B R' B'\",\"B R2 B'\",\"D B R' B'\",\"D' B R2 B'\",\"B R' B'\",\"\",\"B R2 B' D B R' B'\",\"D2 B R2 B'\",\"D' B R' B'\"],[\"\",\"R' D R F D2 F'\",\"R' D R\",\"D F D' F'\",\"R F' R' F\",\"F D' F'\",\"R' D' R\",\"F D2 F'\",\"R' D2 R\",\"F D F'\"],[\"\",\"F2 D2 R F' R' D2 F' D2 F'\",\"F2 D2 F' D' F D' F' D2 F'\",\"F2 D F2 D F2 D2 F2\",\"D2 F L D2 L' D2 F'\",\"D F D2 L D2 L' F'\",\"R' D B' D2 B D' R\",\"R' D2 B' D2 B R\",\"F D2 F' D F D F'\",\"F D' L D2 L' D F'\",\"B D' F D B' D' F'\",\"F D2 L D2 L' F'\",\"F D' L D L' D F'\",\"F L D2 L' D2 F'\",\"R' B' D2 B D2 R\"],[\"D'\",\"F L D L' D' F'\",\"D2\",\"L B D B' D' L'\",\"D\",\"B' L' D' L D B\",\"\",\"D F L D L' D' F'\"],[\"F' D2 F D F' D F\",\"F' D' R' D R F\",\"F' R' D' R D F\",\"B D R D' R' B'\",\"\",\"D B' D' L' D L B\"],[\"D F D F' D F D2 F'\",\"F' U2 B' R' B U2 F' L F' L' F'\",\"\",\"D2 L D L2 F L F2 D F\"],[\"L B' L' F L B L' F'\",\"F2 U F' D2 F U' F' D2 F'\",\"D' F' D B D' F D B'\",\"F L2 F R2 F' L2 F R2 F2\",\"D B D' F' D B' D' F\",\"R F L F' R' F L' F'\",\"\",\"D2 B L' U2 L B' D2 B L' U2 L B'\",\"D2 F R' U2 R F' D2 F R' U2 R F'\",\"R F L' F' R' F L F'\",\"D F D' B' D F' D' B\",\"L2 F2 L' B2 L F2 L' B2 L'\"],[\"L B R' B' L' B R B'\",\"R' B R F' R' B' R F\",\"L D2 L U L' D2 L U' L2\",\"\",\"D2 B' D2 F D' L2 F L2 F' D2 B D' F'\",\"D2 F' R' F R2 B' D2 B D2 R' F D2 F'\",\"L B L' F L B' L' F'\",\"F' D2 F' U' F D2 F' U F2\",\"D' B' D F D' B D F'\"],[\"\",\"D2 F' L U2 L' F D2 F' L U2 L' F\",\"D2 B' R U2 R' B D2 B' R U2 R' B\"]];function qb(){return se(this,null,function*(){let n=yield gn[\"3x3x3\"].def(),e=new Yn(n);for(let t of jb)e.applyAlg(le.fromString((yield ip())(t)));return gb(n,e.state)?e.state:qb()})}function oC(n){return se(this,null,function*(){return le.fromString(Vb(db(n)))})}function Qf(){return se(this,null,function*(){return oC(yield qb())})}function Qb(){return se(this,null,function*(){Hb()})}nt();var Rm=!1;function Pm(n){return Array.isArray(n)}\"use strict\";var bt=[],km=[1];for(var Ft=0;Ft<32;++Ft)for(bt[Ft]=[],Si=0;Si<32;++Si)bt[Ft][Si]=0;var Si;for(var Ft=0;Ft<32;++Ft)for(bt[Ft][0]=bt[Ft][Ft]=1,km[Ft+1]=km[Ft]*(Ft+1),Si=1;Si1;r--)n[arguments[r]]=n[arguments[r-1]];return n[arguments[1]]=i,ct}function Yb(n,e){return n[e>>3]>>((e&7)<<2)&15}function sC(n,e,t){e=e||8;for(var i=0,r=1985229328,o=0;o>s&7),r-=286331152<>1:i}function zm(n,e,t,i){t=(t||8)-1;var r=1985229328,o=0;i<0&&(e<<=1);for(var s=0;s>l&7;var c=(1<>4&~c)}return i<0&&(o&1)!=0?(n[t]=n[t-1],n[t-1]=r&7):n[t]=r&7,n}function aC(n,e,t){for(var i=Math.abs(t),r=t<0?0:n[0]%i,o=e-1;o>0;o--)r=r*i+n[o]%i;return r}function lC(n,e,t,i){for(var r=Math.abs(i),o=r*t,s=1;s>1]^e.ea[i]&1};wn.CornMult=function(n,e,t){for(var i=0;i<8;i++){var r=((n.ca[e.ca[i]&7]>>3)+(e.ca[i]>>3))%3;t.ca[i]=n.ca[e.ca[i]&7]&7|r<<3}};wn.CubeMult=function(n,e,t){wn.CornMult(n,e,t),wn.EdgeMult(n,e,t)};wn.prototype.init=function(n,e){return this.ca=n.slice(),this.ea=e.slice(),this};wn.prototype.isEqual=function(n){for(var e=0;e<8;e++)if(this.ca[e]!=n.ca[e])return!1;for(var e=0;e<12;e++)if(this.ea[e]!=n.ea[e])return!1;return!0};var Xb=[[8,9,20],[6,18,38],[0,36,47],[2,45,11],[29,26,15],[27,44,24],[33,53,42],[35,17,51]],Zb=[[5,10],[7,19],[3,37],[1,46],[32,16],[28,25],[30,43],[34,52],[23,12],[21,41],[50,39],[48,14]];wn.prototype.toFaceCube=function(n,e){n=n||Xb,e=e||Zb;for(var t=\"URFDLB\",i=[],r=0;r<54;r++)i[r]=t[~~(r/9)];for(var o=0;o<8;o++)for(var s=this.ca[o]&7,a=this.ca[o]>>3,l=0;l<3;l++)i[n[o][(l+a)%3]]=t[~~(n[s][l]/9)];for(var c=0;c<12;c++)for(var s=this.ea[c]>>1,a=this.ea[c]&1,l=0;l<2;l++)i[e[c][(l+a)%2]]=t[~~(e[s][l]/9)];return i.join(\"\")};wn.prototype.invFrom=function(n){for(var e=0;e<12;e++)this.ea[n.ea[e]>>1]=e<<1|n.ea[e]&1;for(var t=0;t<8;t++)this.ca[n.ca[t]&7]=t|32>>(n.ca[t]>>3)&24;return this};wn.prototype.fromFacelet=function(n,e,t){e=e||Xb,t=t||Zb;var i=0,r=[],o=n[4]+n[13]+n[22]+n[31]+n[40]+n[49];for(let u=0;u<54;++u){if(r[u]=o.indexOf(n[u]),r[u]==-1)return-1;i+=1<<(r[u]<<2)}if(i!=10066329)return-1;var s,a,l,c,f;for(l=0;l<8;++l){for(f=0;f<3&&!(r[e[l][f]]==0||r[e[l][f]]==3);++f);for(s=r[e[l][(f+1)%3]],a=r[e[l][(f+2)%3]],c=0;c<8;++c)if(s==~~(e[c][1]/9)&&a==~~(e[c][2]/9)){this.ca[l]=c|f%3<<3;break}}for(l=0;l<12;++l)for(c=0;c<12;++c){if(r[t[l][0]]==~~(t[c][0]/9)&&r[t[l][1]]==~~(t[c][1]/9)){this.ea[l]=c<<1;break}if(r[t[l][0]]==~~(t[c][1]/9)&&r[t[l][1]]==~~(t[c][0]/9)){this.ea[l]=c<<1|1;break}}return this};var In=[];for(var Ft=0;Ft<18;Ft++)In[Ft]=new wn;In[0].init([3,0,1,2,4,5,6,7],[6,0,2,4,8,10,12,14,16,18,20,22]);In[3].init([20,1,2,8,15,5,6,19],[16,2,4,6,22,10,12,14,8,18,20,0]);In[6].init([9,21,2,3,16,12,6,7],[0,19,4,6,8,17,12,14,3,11,20,22]);In[9].init([0,1,2,3,5,6,7,4],[0,2,4,6,10,12,14,8,16,18,20,22]);In[12].init([0,10,22,3,4,17,13,7],[0,2,20,6,8,10,18,14,16,4,12,22]);In[15].init([0,1,11,23,4,5,18,14],[0,2,4,23,8,10,12,21,16,18,7,15]);for(var no=0;no<18;no+=3)for(Vo=0;Vo<2;Vo++)wn.EdgeMult(In[no+Vo],In[no],In[no+Vo+1]),wn.CornMult(In[no+Vo],In[no],In[no+Vo+1]);var Vo;wn.moveCube=In;wn.prototype.edgeCycles=function(){for(var n=[],e=[0,0,0],t=0,i=!1,r=0;r<12;++r)if(!n[r]){var o=-1,s=!1,a=r;do n[a]=!0,++o,s^=this.ea[a]&1,a=this.ea[a]>>1;while(a!=r);t+=o>>1,o&1&&(i=!i,++t),s&&(o==0?++e[0]:o&1?e[2]^=1:++e[1])}if(e[1]+=e[2],e[0]>1;else{var l=[0,2,3,5,6,8,9];t+=e[1]+l[e[0]-e[1]>>1]}return t-i};function fC(n,e,t,i,r,o,s,a){var l=Pm(r);o=o||6,s=s||3,a=a||256,i=i||256;for(var c=0,f=t+7>>>3;c>3]^=15<<((e&7)<<2);for(var u=0,h=0;h<=i;h++){var p=0,d=h>=a,g=h+1^15,v=d?15:h,y=d?h:15;e:for(var m=0;m>=4){if((m&7)==0&&(u=n[m>>3],!d&&u==-1)){m+=7;continue}if((u&15)==v){for(var S=0;S>3]^=g<<((m&7)<<2);continue e}n[b>>3]^=g<<((b&7)<<2)}}}if(p==0)break;Rm&&console.log(\"[prun]\",p)}}function hC(n,e,t){this.N_STATES=t.length,this.N_MOVES=n,this.N_POWER=e,this.state_params=t,this.inited=!1}var Bi=hC.prototype;Bi.search=function(n,e,t){if(t=(t||99)+1,!this.inited){this.move=[],this.prun=[];for(var i=0;ie)return!1;if(e==0)return!0;for(var o=n[0]+e+t+1,s=0;se||n in this.visited)return!1;if(this.visited[n]=0,e==0)return this.sols.push(this.sol.slice()),this.sols.length>=this.nsol;var i=t==null?-1:this.moves[t];for(var r in this.moves){var o=this.moves[r]^i;if(!(o==0||(o&15)==0&&r0){let r=[null,0,!1][n];for(var i=0;i=0;--e)n.ct[e]===1&&(t+=bt[e][i--]);return t}function Zf(n){var e,t;if(ma!==null)return ma[Xf(n)];for(t=0;t<48;++t){if(e=PC(Xf(n)),e!==-1)return e*64+t;rt(n,0),t%2==1&&rt(n,1),t%8==7&&rt(n,2),t%16==15&&rt(n,3)}}function Ei(n,e){var t;switch(t=e%3,e=~~(e/3),e){case 0:H(n.ct,0,1,2,3,t);break;case 1:H(n.ct,16,17,18,19,t);break;case 2:H(n.ct,8,9,10,11,t);break;case 3:H(n.ct,4,5,6,7,t);break;case 4:H(n.ct,20,21,22,23,t);break;case 5:H(n.ct,12,13,14,15,t);break;case 6:H(n.ct,0,1,2,3,t),H(n.ct,8,20,12,16,t),H(n.ct,9,21,13,17,t);break;case 7:H(n.ct,16,17,18,19,t),H(n.ct,1,15,5,9,t),H(n.ct,2,12,6,10,t);break;case 8:H(n.ct,8,9,10,11,t),H(n.ct,2,19,4,21,t),H(n.ct,3,16,5,22,t);break;case 9:H(n.ct,4,5,6,7,t),H(n.ct,10,18,14,22,t),H(n.ct,11,19,15,23,t);break;case 10:H(n.ct,20,21,22,23,t),H(n.ct,0,8,4,14,t),H(n.ct,3,11,7,13,t);break;case 11:H(n.ct,12,13,14,15,t),H(n.ct,1,20,7,18,t),H(n.ct,0,23,6,17,t)}}function rt(n,e){switch(e){case 0:Ei(n,19),Ei(n,28);break;case 1:Ei(n,21),Ei(n,32);break;case 2:H(n.ct,0,3,1,2,1),H(n.ct,8,11,9,10,1),H(n.ct,4,7,5,6,1),H(n.ct,12,15,13,14,1),H(n.ct,16,19,21,22,1),H(n.ct,17,18,20,23,1);break;case 3:Ei(n,18),Ei(n,29),Ei(n,24),Ei(n,35)}}function aw(n,e){var t;for(t=0;t=0;--t)n.ct[t]=0,e>=bt[t][i]&&(e-=bt[t][i--],n.ct[t]=1)}function Jf(n,e){var t;for(t=0;t<24;++t)n.ct[t]=e.ct[t]}function mc(){var n;for(Um(this),n=0;n<8;++n)this.ct[n]=1;for(n=8;n<24;++n)this.ct[n]=0}function Kf(n,e){var t;for(Um(this),t=0;t<24;++t)this.ct[t]=~~(n.ct[t]/2)===e?1:0}function gc(n){var e;for(Um(this),e=0;e<24;++e)this.ct[e]=n[e]}function AC(){var n,e,t,i;for(n=new mc,e=new mc,t=0;t<15582;++t)for(Gm(e,eh[t]),i=0;i<36;++i)Jf(n,e),Ei(n,i),$f[t][i]=Zf(n)}function DC(){var n,e,t,i,r,o,s,a;for(vh(_i),_i[0]=0,e=0,t=1;t!==15582;)for(o=e>4,a=o?-1:e,n=o?e:-1,++e,i=0;i<15582;++i)if(_i[i]===a){for(s=0;s<27;++s)if(r=~~$f[i][s]>>>6,_i[r]===n)if(++t,o){_i[i]=e;break}else _i[r]=e}}function LC(n){var e,t,i,r;for(e=new gc(n.ct),r=0;r<48;++r){for(t=!0,i=0;i<24;++i)if(e.ct[i]!==~~(i/4)){t=!1;break}if(t)return r;rt(e,0),r%2==1&&rt(e,1),r%8==7&&rt(e,2),r%16==15&&rt(e,3)}return-1}function CC(){var n,e,t,i,r,o,s;for(n=new mc,r=0;r<24;++r)n.ct[r]=r;for(e=new gc(n.ct),t=new gc(n.ct),i=new gc(n.ct),r=0;r<48;++r){for(o=0;o<48;++o){for(s=0;s<48;++s)sw(n,e)&&(ya[r][o]=s,s===0&&(ga[r]=o)),rt(e,0),s%2==1&&rt(e,1),s%8==7&&rt(e,2),s%16==15&&rt(e,3);rt(n,0),o%2==1&&rt(n,1),o%8==7&&rt(n,2),o%16==15&&rt(n,3)}rt(n,0),r%2==1&&rt(n,1),r%8==7&&rt(n,2),r%16==15&&rt(n,3)}for(r=0;r<48;++r)for(Jf(n,t),aw(n,ga[r]),o=0;o<36;++o)for(Jf(e,n),Ei(e,o),aw(e,r),s=0;s<36;++s)if(Jf(i,t),Ei(i,s),sw(i,e)){Ti[r][o]=s;break}for(Gm(n,0),r=0;r<48;++r)Wm[ga[r]]=Xf(n),rt(n,0),r%2==1&&rt(n,1),r%8==7&&rt(n,2),r%16==15&&rt(n,3)}function RC(){var n,e,t,i,r,o;for(n=new mc,o=Re(22984),t=0;t<22984;t++)o[t]=0;for(e=0,t=0;t<735471;++t)if((o[~~t>>>5]&1<<(t&31))==0){for(Gm(n,t),r=0;r<48;++r)i=Xf(n),o[~~i>>>5]|=1<<(i&31),ma!==null&&(ma[i]=e<<6|ga[r]),rt(n,0),r%2==1&&rt(n,1),r%8==7&&rt(n,2),r%16==15&&rt(n,3);eh[e++]=t}}function PC(n){var e;return e=T4(eh,n),e>=0?e:-1}qn(153,1,io([Kb]),mc,Kf,gc);var _i,$f,Wm,ma=null,eh,ga,Ti,ya,lw=!1;function kC(){lw||(lw=!0,rh=Re(70,28),ih=Re(6435,28),dw=Re(70,16),hw=Re(6435,16),Mn=Re(450450),pw=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,1,0,1,0,0,0])}function th(n){var e,t,i;for(t=0,i=8,e=14;e>=0;--e)n.ct[e]!==n.ct[15]&&(t+=bt[e][i--]);return t}function nh(n){var e,t,i;for(t=0,i=4,e=6;e>=0;--e)n.rl[e]!==n.rl[7]&&(t+=bt[e][i--]);return t*2+n.parity}function va(n,e){var t;switch(n.parity^=pw[e],t=e%3,e=~~(e/3),e){case 0:H(n.ct,0,1,2,3,t);break;case 1:H(n.rl,0,1,2,3,t);break;case 2:H(n.ct,8,9,10,11,t);break;case 3:H(n.ct,4,5,6,7,t);break;case 4:H(n.rl,4,5,6,7,t);break;case 5:H(n.ct,12,13,14,15,t);break;case 6:H(n.ct,0,1,2,3,t),H(n.rl,0,5,4,1,t),H(n.ct,8,9,12,13,t);break;case 7:H(n.rl,0,1,2,3,t),H(n.ct,1,15,5,9,t),H(n.ct,2,12,6,10,t);break;case 8:H(n.ct,8,9,10,11,t),H(n.rl,0,3,6,5,t),H(n.ct,3,2,5,4,t);break;case 9:H(n.ct,4,5,6,7,t),H(n.rl,3,2,7,6,t),H(n.ct,11,10,15,14,t);break;case 10:H(n.rl,4,5,6,7,t),H(n.ct,0,8,4,14,t),H(n.ct,3,11,7,13,t);break;case 11:H(n.ct,12,13,14,15,t),H(n.rl,1,4,7,2,t),H(n.ct,1,0,7,6,t)}}function xa(n,e){switch(e){case 0:va(n,19),va(n,28);break;case 1:va(n,21),va(n,32);break;case 2:H(n.ct,0,3,1,2,1),H(n.ct,8,11,9,10,1),H(n.ct,4,7,5,6,1),H(n.ct,12,15,13,14,1),H(n.rl,0,3,5,6,1),H(n.rl,1,2,4,7,1)}}function cw(n,e,t){var i;for(i=0;i<16;++i)n.ct[i]=~~(e.ct[i]/2);for(i=0;i<8;++i)n.rl[i]=e.ct[i+16];n.parity=t}function uw(n,e){var t,i;for(i=8,n.ct[15]=0,t=14;t>=0;--t)e>=bt[t][i]?(e-=bt[t][i--],n.ct[t]=1):n.ct[t]=0}function fw(n,e){var t,i;for(n.parity=e&1,e>>>=1,i=4,n.rl[7]=0,t=6;t>=0;--t)e>=bt[t][i]?(e-=bt[t][i--],n.rl[t]=1):n.rl[t]=0}function Hm(){this.rl=Re(8),this.ct=Re(16)}function zC(){var n,e,t,i,r,o,s,a,l,c,f;for(n=new Hm,o=0;o<70;++o)for(l=0;l<28;++l)fw(n,o),va(n,qo[l]),rh[o][l]=nh(n);for(o=0;o<70;++o)for(fw(n,o),a=0;a<16;++a)dw[o][a]=nh(n),xa(n,0),a%2==1&&xa(n,1),a%8==7&&xa(n,2);for(o=0;o<6435;++o)for(uw(n,o),a=0;a<16;++a)hw[o][a]=th(n)&65535,xa(n,0),a%2==1&&xa(n,1),a%8==7&&xa(n,2);for(o=0;o<6435;++o)for(l=0;l<28;++l)uw(n,o),va(n,qo[l]),ih[o][l]=th(n)&65535;for(vh(Mn),Mn[0]=Mn[18]=Mn[28]=Mn[46]=Mn[54]=Mn[56]=0,i=0,r=6;r!==450450;){var u=i>6,h=u?-1:i,p=u?i:-1;for(++i,o=0;o<450450;++o)if(Mn[o]===h){for(e=~~(o/70),c=o%70,l=0;l<23;++l)if(t=ih[e][l],f=rh[c][l],s=t*70+f,Mn[s]===p)if(++r,u){Mn[o]=i;break}else Mn[s]=i}}}qn(154,1,{},Hm);Ye.parity=0;var ih,Mn,hw,pw,rh,dw,mw=!1;function IC(){mw||(mw=!0,yc=Re(29400,20),yw=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1],ro=Re(29400),qm=[0,9,14,23,27,28,41,42,46,55,60,69],Qm=Re(70))}function Vm(n){var e,t,i,r,o;for(i=0,o=4,t=6;t>=0;--t)n.ud[t]!==n.ud[7]&&(i+=bt[t][o--]);for(i*=35,o=4,t=6;t>=0;--t)n.fb[t]!==n.fb[7]&&(i+=bt[t][o--]);for(i*=12,e=n.fb[7]^n.ud[7],r=0,o=4,t=7;t>=0;--t)n.rl[t]!==e&&(r+=bt[t][o--]);return n.parity+2*(i+Qm[r])}function FC(n,e){switch(n.parity^=yw[e],e){case 0:case 1:case 2:H(n.ud,0,1,2,3,e%3);break;case 3:H(n.rl,0,1,2,3,1);break;case 4:case 5:case 6:H(n.fb,0,1,2,3,(e-1)%3);break;case 7:case 8:case 9:H(n.ud,4,5,6,7,(e-1)%3);break;case 10:H(n.rl,4,5,6,7,1);break;case 11:case 12:case 13:H(n.fb,4,5,6,7,(e+1)%3);break;case 14:H(n.ud,0,1,2,3,1),H(n.rl,0,5,4,1,1),H(n.fb,0,5,4,1,1);break;case 15:H(n.rl,0,1,2,3,1),H(n.fb,1,4,7,2,1),H(n.ud,1,6,5,2,1);break;case 16:H(n.fb,0,1,2,3,1),H(n.ud,3,2,5,4,1),H(n.rl,0,3,6,5,1);break;case 17:H(n.ud,4,5,6,7,1),H(n.rl,3,2,7,6,1),H(n.fb,3,2,7,6,1);break;case 18:H(n.rl,4,5,6,7,1),H(n.fb,0,3,6,5,1),H(n.ud,0,3,4,7,1);break;case 19:H(n.fb,4,5,6,7,1),H(n.ud,0,7,6,1,1),H(n.rl,1,4,7,2,1)}}function gw(n,e,t){var i,r;for(r=(e.ct[0]>e.ct[8]?1:0)^(e.ct[8]>e.ct[16]?1:0)^(e.ct[0]>e.ct[16]?1:0)?1:0,i=0;i<8;++i)n.ud[i]=e.ct[i]&1^1,n.fb[i]=e.ct[i+8]&1^1,n.rl[i]=e.ct[i+16]&1^1^r;n.parity=r^t}function NC(n,e){var t,i,r,o;for(n.parity=e&1,e>>>=1,r=qm[e%12],e=~~(e/12),o=4,t=7;t>=0;--t)n.rl[t]=0,r>=bt[t][o]&&(r-=bt[t][o--],n.rl[t]=1);for(i=e%35,e=~~(e/35),o=4,n.fb[7]=0,t=6;t>=0;--t)i>=bt[t][o]?(i-=bt[t][o--],n.fb[t]=1):n.fb[t]=0;for(o=4,n.ud[7]=0,t=6;t>=0;--t)e>=bt[t][o]?(e-=bt[t][o--],n.ud[t]=1):n.ud[t]=0}function jm(){this.ud=Re(8),this.rl=Re(8),this.fb=Re(8)}function BC(){var n,e,t,i,r;for(i=0;i<12;++i)Qm[qm[i]]=i;for(n=new jm,i=0;i<29400;++i)for(r=0;r<20;++r)NC(n,i),FC(n,r),yc[i][r]=Vm(n)&65535;for(vh(ro),ro[0]=0,e=0,t=1;t!==29400;){for(i=0;i<29400;++i)if(ro[i]===e)for(r=0;r<17;++r)ro[yc[i][r]]===-1&&(ro[yc[i][r]]=e+1,++t);++e}}qn(155,1,{},jm);Ye.parity=0;var yc,yw,ro,qm,Qm,vw=!1;function OC(){vw||(vw=!0,WC=[0,4,2,1,5,3])}function UC(n,e){var t;for(t=0;t<24;++t)n.ct[t]=e.ct[t]}function GC(n,e){var t;switch(t=e%3,e=~~(e/3),e){case 0:H(n.ct,0,1,2,3,t);break;case 1:H(n.ct,16,17,18,19,t);break;case 2:H(n.ct,8,9,10,11,t);break;case 3:H(n.ct,4,5,6,7,t);break;case 4:H(n.ct,20,21,22,23,t);break;case 5:H(n.ct,12,13,14,15,t);break;case 6:H(n.ct,0,1,2,3,t),H(n.ct,8,20,12,16,t),H(n.ct,9,21,13,17,t);break;case 7:H(n.ct,16,17,18,19,t),H(n.ct,1,15,5,9,t),H(n.ct,2,12,6,10,t);break;case 8:H(n.ct,8,9,10,11,t),H(n.ct,2,19,4,21,t),H(n.ct,3,16,5,22,t);break;case 9:H(n.ct,4,5,6,7,t),H(n.ct,10,18,14,22,t),H(n.ct,11,19,15,23,t);break;case 10:H(n.ct,20,21,22,23,t),H(n.ct,0,8,4,14,t),H(n.ct,3,11,7,13,t);break;case 11:H(n.ct,12,13,14,15,t),H(n.ct,1,20,7,18,t),H(n.ct,0,23,6,17,t)}}function Ym(){var n;for(this.ct=Re(24),n=0;n<24;++n)this.ct[n]=~~(n/4)}function xw(n){var e,t,i;for(Ym.call(this),e=0;e<23;++e)i=e+n(24-e),this.ct[i]!==this.ct[e]&&(t=this.ct[e],this.ct[e]=this.ct[i],this.ct[i]=t)}qn(156,1,{},Ym,xw);var WC,bw=!1;function HC(){bw||(bw=!0,ti=Re(18),QC=[[8,9,20],[6,18,38],[0,36,47],[2,45,11],[29,26,15],[27,44,24],[33,53,42],[35,17,51]],qC())}function ww(n){n.cp=[0,1,2,3,4,5,6,7],n.co=[0,0,0,0,0,0,0,0]}function Mw(n,e){var t;for(t=0;t<8;++t)n.cp[t]=e.cp[t],n.co[t]=e.co[t]}function VC(n,e){!n.temps&&(n.temps=new oh),Sw(n,ti[e],n.temps),Mw(n,n.temps)}function jC(n,e){var t,i;for(i=0,t=6;t>=0;--t)i+=n.co[t]=e%3,e=~~(e/3);n.co[7]=(15-i)%3}function Sw(n,e,t){var i,r,o,s;for(i=0;i<8;++i)t.cp[i]=n.cp[e.cp[i]],o=n.co[e.cp[i]],s=e.co[i],r=o,r=r+(o<3?s:6-s),r=r%3,(o>=3?1:0)^(s>=3?1:0)&&(r=r+3),t.co[i]=r}function oh(){ww(this)}function oo(n,e){ww(this),zm(this.cp,n),jC(this,e)}function Ew(n){oo.call(this,n(40320),n(2187))}function qC(){var n,e;for(ti[0]=new oo(15120,0),ti[3]=new oo(21021,1494),ti[6]=new oo(8064,1236),ti[9]=new oo(9,0),ti[12]=new oo(1230,412),ti[15]=new oo(224,137),n=0;n<18;n+=3)for(e=0;e<2;++e)ti[n+e+1]=new oh,Sw(ti[n+e],ti[n],ti[n+e+1])}qn(157,1,io([mC]),oh,oo,Ew);Ye.temps=null;var QC,ti,_w=!1;function YC(){_w||(_w=!0,$C=[1,4,16,55,324,1922,12275,77640,485359,2778197,11742425,27492416,31002941,31006080],Ai=Re(1937880),ch=Re(1538),uh=Re(1538),Ea=Re(11880),Rw=[0,1,6,3,4,5,2,7],Km=Re(160,12),$m=Re(160,12),Jm=[1,1,1,3,12,60,360,2520,20160,181440,1814400,19958400,239500800],Zm=[0,2,4,6,1,3,7,5,8,9,10,11])}function ba(n,e,t,i,r){var o;o=n.edgeo[r],n.edgeo[r]=n.edge[i],n.edge[i]=n.edgeo[t],n.edgeo[t]=n.edge[e],n.edge[e]=o}function wa(n,e){var t,i,r,o,s;for(n.isStd||Lw(n),i=0,s=1985229328,o=47768,t=0;t=32?(i+=o>>r-32&15,o-=4368<>r&15,o-=4369,s-=286331152<>=3,ah(n,r),t=wa(n,10)%20160,i*20160+t}function sh(n,e){switch(n.isStd=!1,e){case 0:ct(n.edge,0,4,1,5),ct(n.edgeo,0,4,1,5);break;case 1:_t(n.edge,0,4,1,5),_t(n.edgeo,0,4,1,5);break;case 2:ct(n.edge,0,5,1,4),ct(n.edgeo,0,5,1,4);break;case 3:_t(n.edge,5,10,6,11),_t(n.edgeo,5,10,6,11);break;case 4:ct(n.edge,0,11,3,8),ct(n.edgeo,0,11,3,8);break;case 5:_t(n.edge,0,11,3,8),_t(n.edgeo,0,11,3,8);break;case 6:ct(n.edge,0,8,3,11),ct(n.edgeo,0,8,3,11);break;case 7:ct(n.edge,2,7,3,6),ct(n.edgeo,2,7,3,6);break;case 8:_t(n.edge,2,7,3,6),_t(n.edgeo,2,7,3,6);break;case 9:ct(n.edge,2,6,3,7),ct(n.edgeo,2,6,3,7);break;case 10:_t(n.edge,4,8,7,9),_t(n.edgeo,4,8,7,9);break;case 11:ct(n.edge,1,9,2,10),ct(n.edgeo,1,9,2,10);break;case 12:_t(n.edge,1,9,2,10),_t(n.edgeo,1,9,2,10);break;case 13:ct(n.edge,1,10,2,9),ct(n.edgeo,1,10,2,9);break;case 14:_t(n.edge,0,4,1,5),_t(n.edgeo,0,4,1,5),ct(n.edge,9,11),ct(n.edgeo,8,10);break;case 15:_t(n.edge,5,10,6,11),_t(n.edgeo,5,10,6,11),ct(n.edge,1,3),ct(n.edgeo,0,2);break;case 16:_t(n.edge,0,11,3,8),_t(n.edgeo,0,11,3,8),ct(n.edge,5,7),ct(n.edgeo,4,6);break;case 17:_t(n.edge,2,7,3,6),_t(n.edgeo,2,7,3,6),ct(n.edge,8,10),ct(n.edgeo,9,11);break;case 18:_t(n.edge,4,8,7,9),_t(n.edgeo,4,8,7,9),ct(n.edge,0,2),ct(n.edgeo,1,3);break;case 19:_t(n.edge,1,9,2,10),_t(n.edgeo,1,9,2,10),ct(n.edge,4,6),ct(n.edgeo,5,7)}}function Ma(n,e){switch(n.isStd=!1,e){case 0:sh(n,14),sh(n,17);break;case 1:ba(n,11,5,10,6),ba(n,5,10,6,11),ba(n,1,2,3,0),ba(n,4,9,7,8),ba(n,8,4,9,7),ba(n,0,1,2,3);break;case 2:ni(n,4,5),ni(n,5,4),ni(n,11,8),ni(n,8,11),ni(n,7,6),ni(n,6,7),ni(n,9,10),ni(n,10,9),ni(n,1,1),ni(n,0,0),ni(n,3,3),ni(n,2,2)}}function ah(n,e){for(;e>=2;)e-=2,Ma(n,1),Ma(n,2);e!==0&&Ma(n,0)}function vc(n,e){var t,i,r,o,s,a;for(s=1985229328,a=47768,r=0,t=0;t<11;++t)if(i=Jm[11-t],o=~~(e/i),e=e%i,r^=o,o<<=2,o>=32){o=o-32,n.edge[t]=a>>o&15;var l=(1<>4&~l)}else{n.edge[t]=s>>o&15;var l=(1<>>4&~l)+(a<<28),a=a>>4}for((r&1)==0?n.edge[11]=s:(n.edge[11]=n.edge[10],n.edge[10]=s),t=0;t<12;++t)n.edgeo[t]=t;n.isStd=!0}function Aw(n,e){var t;for(t=0;t<12;++t)n.edge[t]=e.edge[t],n.edgeo[t]=e.edgeo[t];n.isStd=e.isStd}function Dw(n,e){var t,i,r,o;for(n.temp===null&&(n.temp=Re(12)),t=0;t<12;++t)n.temp[t]=t,n.edge[t]=e.ep[Zm[t]+12]%12;for(i=1,t=0;t<12;++t)for(;n.edge[t]!==t;)o=n.edge[t],n.edge[t]=n.edge[o],n.edge[o]=o,r=n.temp[t],n.temp[t]=n.temp[o],n.temp[o]=r,i^=1;for(t=0;t<12;++t)n.edge[t]=n.temp[e.ep[Zm[t]]%12];return i}function Lw(n){var e;for(n.temp===null&&(n.temp=Re(12)),e=0;e<12;++e)n.temp[n.edgeo[e]]=e;for(e=0;e<12;++e)n.edge[e]=n.temp[n.edge[e]],n.edgeo[e]=e;n.isStd=!0}function _t(n,e,t,i,r){var o;o=n[e],n[e]=n[i],n[i]=o,o=n[t],n[t]=n[r],n[r]=o}function ni(n,e,t){var i;i=n.edge[e],n.edge[e]=n.edgeo[t],n.edgeo[t]=i}function dr(){this.edge=Re(12),this.edgeo=Re(12)}function XC(){var n,e,t,i,r,o,s,a,l,c,f,u,h,p,d,g,v,y,m,S,b,w,x,A,O;for(l=new dr,f=new dr,h=new dr,vh(Ai),a=0,lh=1,Xm(Ai,0,0);lh!==31006080&&(y=a>9,s=a%3,o=(a+1)%3,u=y?3:s,n=y?s:3,!(a>=9));){for(d=0;d<31006080;d+=16)if(O=Ai[~~d>>4],!(!y&&O===-1)){for(p=d,c=d+16;p>=2)if((O&3)===u){for(w=~~(p/20160),e=ch[w],i=p%20160,vc(l,e*20160+i),S=0;S<17;++S)if(t=Sa(l.edge,S<<3,4),x=Ea[t],A=x&7,x>>=3,r=Sa(l.edge,S<<3|A,10)%20160,g=x*20160+r,xc(Ai,g)===n){if(Xm(Ai,y?p:g,o),++lh,y)break;if(b=uh[x],b!==1)for(Aw(f,l),sh(f,S),ah(f,A),m=1;(b=~~b>>1&65535)!=0;++m)(b&1)==1&&(Aw(h,f),ah(h,m),v=x*20160+wa(h,10)%20160,xc(Ai,v)===n&&(Xm(Ai,v,o),++lh))}}}++a}}function xc(n,e){return n[e>>4]>>((e&15)<<1)&3}function Sa(n,e,t){var i,r,o,s,a,l,c;for(s=$m[e],o=Km[e],r=0,c=1985229328,l=47768,i=0;i=32?(r+=l>>a-32&15,l-=4368<>a&15,l-=4369,c-=286331152<>=3,r=Sa(a.edge,c<<3|h,10)%20160,l=u*20160+r,xc(Ai,l)===o){++s,n=l;break}return s}function ZC(n,e){var t;return t=xc(Ai,n),t===3?10:(1227133513<>e&3)+e-1}function JC(){var n,e,t,i;for(n=new dr,t=0;t<20;++t)for(i=0;i<8;++i){for(vc(n,0),sh(n,t),ah(n,i),e=0;e<12;++e)Km[t<<3|i][e]=n.edge[e];for(Lw(n),e=0;e<12;++e)$m[t<<3|i][e]=n.temp[e]}}function KC(){var n,e,t,i,r,o;for(e=new dr,o=Re(1485),t=0;t<1485;t++)o[t]=0;for(n=0,t=0;t<11880;++t)if((o[~~t>>>3]&1<<(t&7))==0){for(vc(e,t*Jm[8]),r=0;r<8;++r)i=wa(e,4),i===t&&(uh[n]=(uh[n]|1<>3]=o[~~i>>3]|1<<(i&7),Ea[i]=n<<3|Rw[r],Ma(e,0),r%2==1&&(Ma(e,1),Ma(e,2));ch[n++]=t}}function Xm(n,e,t){n[e>>4]^=(3^t)<<((e&15)<<1)}qn(158,1,io([gC]),dr);Ye.isStd=!0;Ye.temp=null;var Zm,lh=0,Ai,Jm,Km,$m,$C,Ea,ch,Rw,uh,Pw=!1;function e4(){Pw||(Pw=!0,r4=[[2,0],[5,0],[3,0],[4,0],[3,1],[5,1],[2,1],[4,1],[2,5],[3,5],[3,4],[2,4]],o4=[19,37,46,10,52,43,25,16,21,50,48,23,7,3,1,5,34,30,28,32,41,39,14,12])}function t4(n){var e,t,i;for(e=0,i=!1,t=0;t<12;++t)e|=1<=12;return e&=~~e>>12,e===0&&!i}function n4(n,e){var t;for(t=0;t<24;++t)n.ep[t]=e.ep[t]}function i4(n,e){var t;switch(t=e%3,e=~~(e/3),e){case 0:H(n.ep,0,1,2,3,t),H(n.ep,12,13,14,15,t);break;case 1:H(n.ep,11,15,10,19,t),H(n.ep,23,3,22,7,t);break;case 2:H(n.ep,0,11,6,8,t),H(n.ep,12,23,18,20,t);break;case 3:H(n.ep,4,5,6,7,t),H(n.ep,16,17,18,19,t);break;case 4:H(n.ep,1,20,5,21,t),H(n.ep,13,8,17,9,t);break;case 5:H(n.ep,2,9,4,10,t),H(n.ep,14,21,16,22,t);break;case 6:H(n.ep,0,1,2,3,t),H(n.ep,12,13,14,15,t),H(n.ep,9,22,11,20,t);break;case 7:H(n.ep,11,15,10,19,t),H(n.ep,23,3,22,7,t),H(n.ep,2,16,6,12,t);break;case 8:H(n.ep,0,11,6,8,t),H(n.ep,12,23,18,20,t),H(n.ep,3,19,5,13,t);break;case 9:H(n.ep,4,5,6,7,t),H(n.ep,16,17,18,19,t),H(n.ep,8,23,10,21,t);break;case 10:H(n.ep,1,20,5,21,t),H(n.ep,13,8,17,9,t),H(n.ep,14,0,18,4,t);break;case 11:H(n.ep,2,9,4,10,t),H(n.ep,14,21,16,22,t),H(n.ep,7,15,1,17,t)}}function e0(){var n;for(this.ep=Re(24),n=0;n<24;++n)this.ep[n]=n}function kw(n){var e,t,i;for(e0.call(this),e=0;e<23;++e)i=e+n(24-e),i!==e&&(t=this.ep[e],this.ep[e]=this.ep[i],this.ep[i]=t)}qn(159,1,{},e0,kw);var r4,o4,zw=!1;function s4(){zw||(zw=!0,t0=[35,1,34,2,4,6,22,5,19])}function Iw(n){n.moveBuffer=Re(60)}function a4(n,e){return n.value-e.value}function _a(n,e){var t;for(n4(n.edge,e.edge),UC(n.center,e.center),Mw(n.corner,e.corner),n.value=e.value,n.add1=e.add1,n.length1=e.length1,n.length2=e.length2,n.length3=e.length3,n.sym=e.sym,t=0;t<60;++t)n.moveBuffer[t]=e.moveBuffer[t];n.moveLength=e.moveLength,n.edgeAvail=e.edgeAvail,n.centerAvail=e.centerAvail,n.cornerAvail=e.cornerAvail}function so(n){for(;n.centerAvail=27?(t[r++]=Ti[l][n.moveBuffer[i]]-9,s=t0[Ti[l][n.moveBuffer[i]]-27],l=ya[l][s]):t[r++]=Ti[l][n.moveBuffer[i]];for(e=ya[ga[l]][LC(so(n))],a=\"\",l=e,i=r-1;i>=0;--i)o=t[i],o=~~(o/3)*3+(2-o%3),Ti[l][o]>=27?(a=a+n0[Ti[l][o]-9]+\" \",s=t0[Ti[l][o]-27],l=ya[l][s]):a=a+n0[Ti[l][o]]+\" \";return a}function jo(n,e){n.moveBuffer[n.moveLength++]=e}function fh(){Iw(this),this.edge=new e0,this.center=new Ym,this.corner=new oh}function hh(n){fh.call(this),_a(this,n)}function Nw(n){Iw(this),this.edge=new kw(n),this.center=new xw(n),this.corner=new Ew(n)}qn(160,1,io([$b,vC]),fh,hh,Nw);Ye.compareTo$=function(e){return a4(this,e)};Ye.add1=!1;Ye.center=null;Ye.centerAvail=0;Ye.corner=null;Ye.cornerAvail=0;Ye.edge=null;Ye.edgeAvail=0;Ye.length1=0;Ye.length2=0;Ye.length3=0;Ye.moveLength=0;Ye.sym=0;Ye.value=0;var t0;function c4(n,e){return e.value-n.value}function ph(n,e){return c4(n,e)}function Bw(){}qn(161,1,{},Bw);Ye.compare=function(e,t){return ph(e,t)};var Ow=!1;function u4(){if(!Ow){Ow=!0;var n,e;for(n0=[\"U \",\"U2 \",\"U' \",\"R \",\"R2 \",\"R' \",\"F \",\"F2 \",\"F' \",\"D \",\"D2 \",\"D' \",\"L \",\"L2 \",\"L' \",\"B \",\"B2 \",\"B' \",\"Uw \",\"Uw2\",\"Uw'\",\"Rw \",\"Rw2\",\"Rw'\",\"Fw \",\"Fw2\",\"Fw'\",\"Dw \",\"Dw2\",\"Dw'\",\"Lw \",\"Lw2\",\"Lw'\",\"Bw \",\"Bw2\",\"Bw'\"],qo=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,19,21,22,23,25,28,30,31,32,34,36],wc=[0,1,2,4,6,7,8,9,10,11,13,15,16,17,19,22,25,28,31,34,36],Uw=Re(37),Gw=Re(37),Ta=Re(37,36),dh=Re(29,28),mh=Re(21,20),i0=Re(36),Mc=Re(28),Aa=Re(20),n=0;n<29;++n)Uw[qo[n]]=n;for(n=0;n<21;++n)Gw[wc[n]]=n;for(n=0;n<36;++n){for(e=0;e<36;++e)Ta[n][e]=~~(n/3)==~~(e/3)||~~(n/3)%3==~~(e/3)%3&&n>e;Ta[36][n]=!1}for(n=0;n<29;++n)for(e=0;e<28;++e)dh[n][e]=Ta[qo[n]][qo[e]];for(n=0;n<21;++n)for(e=0;e<20;++e)mh[n][e]=Ta[wc[n]][wc[e]];for(n=0;n<36;++n)for(i0[n]=36,e=n;e<36;++e)if(!Ta[n][e]){i0[n]=e-1;break}for(n=0;n<28;++n)for(Mc[n]=28,e=n;e<28;++e)if(!dh[n][e]){Mc[n]=e-1;break}for(n=0;n<20;++n)for(Aa[n]=20,e=n;e<20;++e)if(!mh[n][e]){Aa[n]=e-1;break}}}var Ta,dh,mh,qo,n0,wc,i0,Mc,Aa,Uw,Gw;function f4(n){var e,t,i,r,o,s,a,l,c,f,u,h,p,d,g,v,y,m,S,b,w;for(n.solution=\"\",b=Zf(new Kf(so(n.c),0)),s=Zf(new Kf(so(n.c),1)),g=Zf(new Kf(so(n.c),2)),w=_i[~~b>>6],a=_i[~~s>>6],v=_i[~~g>>6],n.p1SolsCnt=0,n.arr2idx=0,w4(n.p1sols.heap),n.length1=(w>>6,g&63,n.length1,-1,0)||w<=n.length1&&gh(n,~~b>>>6,b&63,n.length1,-1,0)||a<=n.length1&&gh(n,~~s>>>6,s&63,n.length1,-1,0));++n.length1);p=P4(n.p1sols,Nm(z4,io([yC,Im,Fm]),$b,0,0)),p.sort(function(x,A){return x.value-A.value}),e=9;do{e:for(u=p[0].value;u<100;++u)for(l=0;lu);++l)if(!(u-p[l].length1>e)&&(_a(n.c1,p[l]),cw(n.ct2,so(n.c1),yh(bc(n.c1).ep)),y=th(n.ct2),m=nh(n.ct2),n.length1=p[l].length1,n.length2=u-p[l].length1,Ww(n,y,m,n.length2,28,0)))break e;++e}while(u===100);n.arr2.sort(function(x,A){return x.value-A.value}),c=0,t=13;do{e:for(h=n.arr2[0].value;h<100;++h)for(l=0;lh);++l)if(!(h-n.arr2[l].length1-n.arr2[l].length2>t)&&(o=Dw(n.e12,bc(n.arr2[l])),gw(n.ct3,so(n.arr2[l]),o^yh(Fw(n.arr2[l]).cp)),i=Vm(n.ct3),r=wa(n.e12,10),d=Cw(Tw(n.e12)),d<=h-n.arr2[l].length1-n.arr2[l].length2&&Hw(n,r,i,d,h-n.arr2[l].length1-n.arr2[l].length2,20,0))){c=l;break e}++t}while(h===100);for(S=new hh(n.arr2[c]),n.length1=S.length1,n.length2=S.length2,f=h-n.length1-n.length2,l=0;ln.c1.value&&_a(r,n.c1)),v4(n.p1sols,r),n.p1SolsCnt===1e4}function p4(n){var e,t,i,r;for(_a(n.c2,n.c1),i=0;i>>6],f>=i){if(f>i)break;continue}if(u=ya[t][a&63],a>>>=6,n.move1[o]=l,gh(n,a,u,i-1,s,o+1))return!0}return!1}function Ww(n,e,t,i,r,o){var s,a,l,c;if(e===0&&Mn[t]===0)return i===0&&p4(n);for(a=0;a<23;++a){if(dh[r][a]){a=Mc[a];continue}if(s=ih[e][a],c=rh[t][a],l=Mn[s*70+c],l>=i){l>i&&(a=Mc[a]);continue}if(n.move2[o]=qo[a],Ww(n,s,c,i-1,a,o+1))return!0}return!1}function Hw(n,e,t,i,r,o,s){var a,l,c,f,u,h,p,d,g;if(r===0)return e===0&&t===0;for(vc(n.tempe[s],e),u=0;u<17;++u){if(mh[o][u]){u=Aa[u];continue}if(c=yc[t][u],h=ro[c],h>=r){h>r&&u<14&&(u=Aa[u]);continue}if(f=Sa(n.tempe[s].edge,u<<3,10),a=~~(f/20160),d=Ea[a],g=d&7,d>>=3,l=Sa(n.tempe[s].edge,u<<3|g,10)%20160,p=ZC(d*20160+l,i),p>=r){p>r&&u<14&&(u=Aa[u]);continue}if(Hw(n,f,c,p,r-1,u,s+1))return n.move3[s]=u,!0}return!1}function Vw(){var n;for(this.p1sols=new $w(new Bw),this.move1=Re(15),this.move2=Re(20),this.move3=Re(20),this.c1=new fh,this.c2=new fh,this.ct2=new Hm,this.ct3=new jm,this.e12=new dr,this.tempe=Re(20),this.arr2=Re(100),n=0;n<20;++n)this.tempe[n]=new dr}function jw(){qw||(CC(),ma=Re(735471),RC(),AC(),ma=null,DC(),zC(),BC(),JC(),KC(),XC(),qw=!0)}qn(163,1,io([xC]),Vw);Ye.add1=!1;Ye.arr2idx=0;Ye.c=null;Ye.length1=0;Ye.length2=0;Ye.p1SolsCnt=0;Ye.solution=\"\";var qw=!1,Qw=!1;function m4(){Qw||(Qw=!0,g4=[85,68,70,66,82,76])}function yh(n){var e,t,i,r;for(r=0,e=0,i=n.length;en[t]&&(r^=1);return r}function H(n,e,t,i,r,o){var s;switch(o){case 0:s=n[r],n[r]=n[i],n[i]=n[t],n[t]=n[e],n[e]=s;return;case 1:s=n[e],n[e]=n[i],n[i]=s,s=n[t],n[t]=n[r],n[r]=s;return;case 2:s=n[e],n[e]=n[t],n[t]=n[i],n[i]=n[r],n[r]=s;return}}var g4;function Yw(){}function Xw(n,e,t,i){var r;return r=new Yw,r.typeName=n+e,Jw(t!==0?-t:0)&&Kw(t!==0?-t:0,r),r.modifiers=4,r.superclass=r0,r.componentType=i,r}function Zw(n,e,t,i){var r;return r=new Yw,r.typeName=n+e,Jw(t)&&Kw(t,r),r.superclass=i,r}function y4(n){var e=dc[n.seedId];return n=null,e}function Jw(n){return typeof n==\"number\"&&n>0}function Kw(n,e){var t;if(e.seedId=n,n===2)t=String.prototype;else if(n>0){var i=y4(e);if(i)t=i.prototype;else{i=dc[n]=function(){},i.___clazz$=e;return}}else return;t.___clazz$=e}Ye.val$outerIter=null;function v4(n,e){if(L4(n,e))return!0}function x4(n){n.array=Nm(e2,io([Im,Fm]),Jb,0,0)}function b4(n,e){return Yf(n.array,n.size++,e),!0}function w4(n){n.array=Nm(e2,io([Im,Fm]),Jb,0,0),n.size=0}function ao(n,e){return n.array[e]}function M4(n,e){var t;return t=n.array[e],_4(n.array,e,1),--n.size,t}function Da(n,e,t){var i;return i=n.array[e],Yf(n.array,e,t),i}function S4(n,e){var t;for(e.lengthn.size&&Yf(e,n.size,null),e}function E4(){x4(this),this.array.length=500}function _4(n,e,t){n.splice(e,t)}Ye.size=0;function T4(n,e){var t,i,r,o;for(i=0,t=n.length-1;i<=t;)if(r=i+(~~(t-i)>>1),o=n[r],oe)t=r-1;else return r;return-i-1}function vh(n){A4(n,n.length)}function A4(n,e){var t;for(t=0;t0;){if(t=i,i=~~((i-1)/2),ph(ao(n.heap,i),e)<=0)return Da(n.heap,t,e),!0;Da(n.heap,t,ao(n.heap,i))}return Da(n.heap,i,e),!0}function C4(n){var e;return n.heap.size===0?null:(e=ao(n.heap,0),R4(n),e)}function R4(n){var e;e=M4(n.heap,n.heap.size-1),0se(void 0,null,function*(){switch(n){case\"222\":return La(\"preInitialize222\",fb);case\"333\":case\"333oh\":case\"333ft\":return La(\"initialize333\",Qb);case\"444\":return La(\"initialize444\",o0);default:throw new Error(`unsupported event: ${n}`)}}),randomScramble:n=>se(void 0,null,function*(){switch(n){case\"222\":return La(\"random222Scramble\",hb);case\"333\":case\"333oh\":case\"333ft\":return La(\"random333Scramble\",Qf);case\"444\":return La(\"random444Scramble\",s0);default:throw new Error(`unsupported event: ${n}`)}}),randomScrambleStringForEvent:n=>se(void 0,null,function*(){return(yield Sc.randomScramble(n)).toString()})};Sc.randomScramble(\"333\").then(n=>console.info(n.toString()));var Ec={getParentPort:{node:null},getNodeAdapter:{esm:null}};function o2(){return se(this,null,function*(){if(typeof WorkerNavigator==\"undefined\"){let n=yield Ec.getParentPort.node(),e=yield Ec.getNodeAdapter.esm();za(Sc,e(n))}else za(Sc)})}Ec.getParentPort.node=S0;Ec.getNodeAdapter.esm=M0;o2();\n"; \ No newline at end of file