diff --git a/docs/assets/chunk-Y3BVWVFU-t7GqMKda.js b/docs/assets/chunk-Y3BVWVFU-DzU6t54e.js similarity index 95% rename from docs/assets/chunk-Y3BVWVFU-t7GqMKda.js rename to docs/assets/chunk-Y3BVWVFU-DzU6t54e.js index ccc1230..850ce2b 100644 --- a/docs/assets/chunk-Y3BVWVFU-t7GqMKda.js +++ b/docs/assets/chunk-Y3BVWVFU-DzU6t54e.js @@ -1,2 +1,2 @@ -import{J as h}from"./index-lVaISq9J.js";function S(g,b){const s=[],n=[];for(const t of b.split(` +import{J as h}from"./index-BA4_IlXs.js";function S(g,b){const s=[],n=[];for(const t of b.split(` `)){const a=t.split(" ");if(!t.startsWith("SetOrder ")){if(t.startsWith("Alg ")){const e=h.fromString(t.substring(4));n.push({alg:e,transformation:g.algToTransformation(e)})}else if(t.startsWith("SubgroupSizes "))for(let e=1;e=0;t--){const a=[];for(let o=f[t];o{throw TypeError(i)};var y3=(i,e,t)=>e in `)||t.includes("\r"))throw new Error("LineComment cannot contain newline");et(this,La,t)}get text(){return P(this,La)}isIdentical(t){const n=t;return t.is(hc)&&P(this,La)===P(n,La)}invert(){return this}*experimentalExpand(t=1,n=1/0){yield this}toString(){return`//${P(this,La)}`}},La=new WeakMap,hc),Zo=class G1 extends Ha{toString(){return` `}isIdentical(e){return e.is(G1)}invert(){return this}*experimentalExpand(e=1,t=1/0){yield this}},cr=class Z1 extends Ha{constructor(){super(...arguments);Z(this,"experimentalNISSGrouping")}toString(){return"."}isIdentical(t){return t.is(Z1)}invert(){return this}*experimentalExpand(t=1,n=1/0){yield this}};function Td(i,e){return i?parseInt(i):e}var ab=/^(\d+)?('?)/,eA=/^[_\dA-Za-z]/,tA=/^((([1-9]\d*)-)?([1-9]\d*))?([_A-Za-z]+)/,nA=/^[^\n]*/,iA=/^(-?\d+), ?/,rA=/^(-?\d+)\)/;function q1(i){return new AR().parseAlg(i)}function sA(i){return new AR().parseMove(i)}function aA(i){return new AR().parseQuantumMove(i)}function ii(i,e,t){const n=i;return n.startCharIndex=e,n.endCharIndex=t,n}function oA(i,e){return"startCharIndex"in i&&(e.startCharIndex=i.startCharIndex),"endCharIndex"in i&&(e.endCharIndex=i.endCharIndex),e}var Xi,St,uc,r1,AR=(r1=class{constructor(){Be(this,Xi,"");Be(this,St,0);Be(this,uc,[])}parseAlg(i){et(this,Xi,i),et(this,St,0);const e=this.parseAlgWithStopping([]);this.mustBeAtEndOfInput();const t=Array.from(e.childAlgNodes());if(P(this,uc).length>0)for(const a of P(this,uc).reverse())t.push(a);const n=new Qe(t),{startCharIndex:r,endCharIndex:s}=e;return ii(n,r,s),n}parseMove(i){et(this,Xi,i),et(this,St,0);const e=this.parseMoveImpl();return this.mustBeAtEndOfInput(),e}parseQuantumMove(i){et(this,Xi,i),et(this,St,0);const e=this.parseQuantumMoveImpl();return this.mustBeAtEndOfInput(),e}mustBeAtEndOfInput(){if(P(this,St)!==P(this,Xi).length)throw new Error("parsing unexpectedly ended early")}parseAlgWithStopping(i){let e=P(this,St),t=P(this,St);const n=new yp;let r=!1;const s=a=>{if(r)throw new Error(`Unexpected character at index ${a}. Are you missing a space?`)};e:for(;P(this,St)0)throw new Error("expected stopping");return ii(n.toAlg(),e,t)}parseQuantumMoveImpl(){const[,,,i,e,t]=this.parseRegex(tA);return new Zs(t,Td(e,void 0),Td(i,void 0))}parseMoveImpl(){const i=P(this,St);if(this.tryConsumeNext("/"))return ii(new ce("_SLASH_"),i,P(this,St));let e=this.parseQuantumMoveImpl(),[t,n]=this.parseAmountAndTrackEmptyAbsAmount();const r=this.parseMoveSuffix();if(r){if(t<0)throw new Error("uh-oh");if((r==="++"||r==="--")&&t!==1)throw new Error("Pochmann ++ or -- moves cannot have an amount other than 1.");if((r==="++"||r==="--")&&!n)throw new Error("Pochmann ++ or -- moves cannot have an amount written as a number.");if((r==="+"||r==="-")&&n)throw new Error("Clock dial moves must have an amount written as a natural number followed by + or -.");r.startsWith("+")&&(e=e.modified({family:`${e.family}_${r==="+"?"PLUS":"PLUSPLUS"}_`})),r.startsWith("-")&&(e=e.modified({family:`${e.family}_${r==="-"?"PLUS":"PLUSPLUS"}_`}),t*=-1)}return ii(new ce(e,t),i,P(this,St))}parseMoveSuffix(){return this.tryConsumeNext("+")?this.tryConsumeNext("+")?"++":"+":this.tryConsumeNext("-")?this.tryConsumeNext("-")?"--":"-":null}parseAmountAndTrackEmptyAbsAmount(){const i=P(this,St),[,e,t]=this.parseRegex(ab);if(e!=null&&e.startsWith("0")&&e!=="0")throw new Error(`Error at char index ${i}: An amount can only start with 0 if it's exactly the digit 0.`);return[Td(e,1)*(t==="'"?-1:1),!e]}parseAmount(){const i=P(this,St),[,e,t]=this.parseRegex(ab);if(e!=null&&e.startsWith("0")&&e!=="0")throw new Error(`Error at char index ${i}: An amount number can only start with 0 if it's exactly the digit 0.`);return Td(e,1)*(t==="'"?-1:1)}parseRegex(i){const e=i.exec(this.remaining());if(e===null)throw new Error("internal parsing error");return et(this,St,P(this,St)+e[0].length),e}tryRegex(i){const e=i.exec(this.remaining());return e===null?null:(et(this,St,P(this,St)+e[0].length),e)}remaining(){return P(this,Xi).slice(P(this,St))}popNext(){const i=P(this,Xi)[P(this,St)];return Ad(this,St)._++,i}tryConsumeNext(i){return P(this,Xi)[P(this,St)]===i?(Ad(this,St)._++,!0):!1}mustConsumeNext(i){const e=this.popNext();if(e!==i)throw new Error(`expected \`${i}\` while parsing, encountered ${e}`);return e}},Xi=new WeakMap,St=new WeakMap,uc=new WeakMap,r1),ob=new Set;function X1(i){ob.has(i)||(console.warn(i),ob.add(i))}var $0=class{constructor(i,e=1){Z(this,"quantum");Z(this,"amount");if(this.quantum=i,this.amount=e,!Number.isInteger(this.amount)||this.amountj0)throw new Error(`AlgNode amount absolute value must be a non-negative integer below ${Y0}.`)}suffix(){let i="";const e=Math.abs(this.amount);return e!==1&&(i+=e),this.amount<0&&(i+="'"),i}isIdentical(i){return this.quantum.isIdentical(i.quantum)&&this.amount===i.amount}*experimentalExpand(i,e){const t=Math.abs(this.amount),n=Y3(i,this.amount<0);for(let r=0;rj0))throw new Error(`QuantumMove inner layer must be a positive integer below ${Y0}.`);if(P(this,pi)!==null&&(!Number.isInteger(P(this,pi))||P(this,pi)<1||P(this,pi)>j0))throw new Error(`QuantumMove outer layer must be a positive integer below ${Y0}.`);if(P(this,pi)!==null&&P(this,fi)!==null&&P(this,fi)<=P(this,pi))throw new Error("QuantumMove outer layer must be smaller than inner layer.");if(P(this,pi)!==null&&P(this,fi)===null)throw new Error("QuantumMove with an outer layer must have an inner layer")}static fromString(t){return aA(t)}modified(t){return new nl(t.family??P(this,Fs),t.innerLayer??P(this,fi),t.outerLayer??P(this,pi))}isIdentical(t){const n=t;return t.is(nl)&&P(this,Fs)===P(n,Fs)&&P(this,fi)===P(n,fi)&&P(this,pi)===P(n,pi)}get family(){return P(this,Fs)}get outerLayer(){return P(this,pi)}get innerLayer(){return P(this,fi)}experimentalExpand(){throw new Error("experimentalExpand() cannot be called on a `QuantumMove` directly.")}toString(){let t=P(this,Fs);return P(this,fi)!==null&&(t=String(P(this,fi))+t,P(this,pi)!==null&&(t=`${String(P(this,pi))}-${t}`)),t}},Fs=new WeakMap,fi=new WeakMap,pi=new WeakMap,nl),oi,Gs,ce=(Gs=class extends Ha{constructor(...t){super();Be(this,oi);if(typeof t[0]=="string")if(t[1]??null){et(this,oi,new $0(Zs.fromString(t[0]),t[1]));return}else return Gs.fromString(t[0]);et(this,oi,new $0(t[0],t[1]))}isIdentical(t){const n=t.as(Gs);return!!n&&P(this,oi).isIdentical(P(n,oi))}invert(){return oA(this,new Gs(P(this,oi).quantum,-this.amount))}*experimentalExpand(t=1){t===1?yield this:yield this.modified({amount:-this.amount})}get quantum(){return P(this,oi).quantum}modified(t){return new Gs(P(this,oi).quantum.modified(t),t.amount??this.amount)}static fromString(t){return sA(t)}get amount(){return P(this,oi).amount}get type(){return X1("deprecated: type"),"blockMove"}get family(){return P(this,oi).quantum.family??void 0}get outerLayer(){return P(this,oi).quantum.outerLayer??void 0}get innerLayer(){return P(this,oi).quantum.innerLayer??void 0}toString(){if(this.family==="_SLASH_")return"/";if(this.family.endsWith("_PLUS_"))return P(this,oi).quantum.toString().slice(0,-6)+Math.abs(this.amount)+(this.amount<0?"-":"+");if(this.family.endsWith("_PLUSPLUS_")){const t=Math.abs(this.amount);return P(this,oi).quantum.toString().slice(0,-10)+(t===1?"":t)+(this.amount<0?"--":"++")}return P(this,oi).quantum.toString()+P(this,oi).suffix()}},oi=new WeakMap,Gs),lA=class{constructor(){Z(this,"quantumU_SQ_",null);Z(this,"quantumD_SQ_",null)}format(i){if(i.amount!==1)return null;const e=this.tuple(i);return e?`(${e.map(t=>t.amount).join(", ")})`:null}tuple(i){var t,n;if(i.amount!==1)return null;this.quantumU_SQ_||(this.quantumU_SQ_=new Zs("U_SQ_")),this.quantumD_SQ_||(this.quantumD_SQ_=new Zs("D_SQ_"));const e=i.alg;if(e.experimentalNumChildAlgNodes()===2){const[r,s]=e.childAlgNodes();if((t=r.as(ce))!=null&&t.quantum.isIdentical(this.quantumU_SQ_)&&((n=s.as(ce))!=null&&n.quantum.isIdentical(this.quantumD_SQ_)))return[r,s]}return null}},Fg=new lA,ji,Qp,j1,Oa,Pi=(Oa=class extends Ha{constructor(t,n){super();Be(this,Qp);Be(this,ji);Z(this,"experimentalNISSPlaceholder");const r=qh(t);et(this,ji,new $0(r,n))}isIdentical(t){const n=t;return t.is(Oa)&&P(this,ji).isIdentical(P(n,ji))}get alg(){return P(this,ji).quantum}get amount(){return P(this,ji).amount}get experimentalRepetitionSuffix(){return P(this,ji).suffix()}invert(){const t=Fg.tuple(this);if(t){const[n,r]=t;return new Oa(new Qe([n.invert(),r.invert()]))}return new Oa(P(this,ji).quantum,-P(this,ji).amount)}*experimentalExpand(t=1,n){n??(n=1/0),n===0?yield t===1?this:this.invert():yield*P(this,ji).experimentalExpand(t,n-1)}static fromString(){throw new Error("unimplemented")}toString(){return Fg.format(this)??`${Yt(this,Qp,j1).call(this)}${P(this,ji).suffix()}`}experimentalAsSquare1Tuple(){return Fg.tuple(this)}},ji=new WeakMap,Qp=new WeakSet,j1=function(){const t=P(this,ji).quantum.toString(),n=this.alg.childAlgNodes(),{value:r}=n.next();return n.next().done&&(r!=null&&r.is(br)||r!=null&&r.is($i))?t:`(${t})`},Oa);function Es(i,e){return i instanceof e}function cA(i){return Es(i,Pi)||Es(i,td)||Es(i,br)||Es(i,$i)||Es(i,ce)||Es(i,Zo)||Es(i,cr)}function Y1(i,e,t){if(e.is(Pi))return i.traverseGrouping(e,t);if(e.is(ce))return i.traverseMove(e,t);if(e.is(br))return i.traverseCommutator(e,t);if(e.is($i))return i.traverseConjugate(e,t);if(e.is(cr))return i.traversePause(e,t);if(e.is(Zo))return i.traverseNewline(e,t);if(e.is(td))return i.traverseLineComment(e,t);throw new Error("unknown AlgNode")}function $1(i){if(i.is(Pi)||i.is(ce)||i.is(br)||i.is($i)||i.is(cr)||i.is(Zo)||i.is(td))return i;throw new Error("internal error: expected AlgNode")}var kc=class{traverseAlgNode(i,e){return Y1(this,i,e)}traverseIntoAlgNode(i,e){return $1(this.traverseAlgNode(i,e))}},fl=class extends kc{traverseAlgNode(i){return Y1(this,i,void 0)}traverseIntoAlgNode(i){return $1(this.traverseAlgNode(i))}};function dr(i,e){const t=new i(...e??[]);return t.traverseAlg.bind(t)}var hA="any-direction",K1=class{constructor(i={}){this.config=i}cancelQuantum(){const{cancel:i}=this.config;return i===!0?hA:i===!1?"none":(i==null?void 0:i.directional)??"none"}cancelAny(){return this.config.cancel&&this.cancelQuantum()!=="none"}cancelPuzzleSpecificModWrap(){const{cancel:i}=this.config;return i===!0||i===!1?"canonical-centered":i!=null&&i.puzzleSpecificModWrap?i==null?void 0:i.puzzleSpecificModWrap:(i==null?void 0:i.directional)==="same-direction"?"preserve-sign":"canonical-centered"}puzzleSpecificSimplifyOptions(){var i;return((i=this.config.puzzleLoader)==null?void 0:i.puzzleSpecificSimplifyOptions)??this.config.puzzleSpecificSimplifyOptions}};function uA(i,e){return i*Math.sign(e.amount)>=0}function J1(i,e,t=0){return((i-t)%e+e)%e+t}function Q1(i,e,t){var l;const n=new K1(t),r=Array.from(i.childAlgNodes());let s=[e];function a(){return new Qe([...r,...s])}function o(c){var m;if(n.cancelPuzzleSpecificModWrap()==="none")return c;const h=(m=n.puzzleSpecificSimplifyOptions())==null?void 0:m.quantumMoveOrder;if(!h)return c;const u=h(e.quantum);let d;switch(n.cancelPuzzleSpecificModWrap()){case"gravity":{d=-Math.floor((u-(c.amount<0?0:1))/2);break}case"canonical-centered":{d=-Math.floor((u-1)/2);break}case"canonical-positive":{d=0;break}case"preserve-sign":{d=c.amount<0?1-u:0;break}default:throw new Error("Unknown mod wrap")}const p=J1(c.amount,u,d);return c.modified({amount:p})}if(n.cancelAny()){let c;const h=(l=n.puzzleSpecificSimplifyOptions())==null?void 0:l.axis;if(h)c=v=>h.areQuantumMovesSameAxis(e.quantum,v.quantum);else{const v=e.quantum.toString();c=b=>b.quantum.toString()===v}const u=n.cancelQuantum()==="same-direction",d=new Map;d.set(e.quantum.toString(),Math.sign(e.amount));let p;for(p=r.length-1;p>=0;p--){const v=r[p].as(ce);if(!v||!c(v))break;const b=v.quantum.toString();if(u){const R=d.get(b);if(R&&!uA(R,v))break;d.set(b,Math.sign(v.amount))}}const m=[...r.splice(p+1),e];if(h)s=h.simplifySameAxisMoves(m,n.cancelPuzzleSpecificModWrap()!=="none");else{const v=m.reduce((b,R)=>b+R.amount,0);if(d.size!==1)throw new Error("Internal error: multiple quantums when one was expected");s=[new ce(e.quantum,v)]}}return s=s.map(c=>o(c)).filter(c=>c.amount!==0),a()}function dA(i,e,t){const n=e.as(ce);return n?Q1(i,n,t):new Qe([...i.childAlgNodes(),e])}var em,lr,K0,xh,J0,s1,fA=(s1=class extends kc{constructor(){super(...arguments);Be(this,lr);Be(this,em)}*traverseAlg(e,t){if(t.depth===0){yield*e.childAlgNodes();return}let n=[];const r=Yt(this,lr,xh).call(this,t);for(const s of e.childAlgNodes())for(const a of this.traverseAlgNode(s,r))n=Array.from(dA(new Qe(n),a,r).childAlgNodes());for(const s of n)yield s}*traverseGrouping(e,t){if(t.depth===0){yield e;return}if(e.amount===0)return;const n=new Pi(this.traverseAlg(e.alg,Yt(this,lr,xh).call(this,t)),e.amount);if(n.alg.experimentalIsEmpty())return;const r=Yt(this,lr,K0).call(this).get(e);r&&(n.experimentalNISSPlaceholder=r,r.experimentalNISSGrouping=n),yield n}*traverseMove(e,t){yield e}*traverseCommutator(e,t){if(t.depth===0){yield e;return}const n=Yt(this,lr,xh).call(this,t),r=new br(this.traverseAlg(e.A,n),this.traverseAlg(e.B,n));r.A.experimentalIsEmpty()||r.B.experimentalIsEmpty()||r.A.isIdentical(r.B)||r.A.isIdentical(r.B.invert())||Yt(this,lr,J0).call(this,r.A,r.B,t)||(yield r)}*traverseConjugate(e,t){if(t.depth===0){yield e;return}const n=Yt(this,lr,xh).call(this,t),r=new $i(this.traverseAlg(e.A,n),this.traverseAlg(e.B,n));if(!r.B.experimentalIsEmpty()){if(r.A.experimentalIsEmpty()||r.A.isIdentical(r.B)||r.A.isIdentical(r.B.invert())||Yt(this,lr,J0).call(this,r.A,r.B,t)){yield*e.B.childAlgNodes();return}yield r}}*traversePause(e,t){if(e.experimentalNISSGrouping){const n=new cr;Yt(this,lr,K0).call(this).set(e.experimentalNISSGrouping,n),yield n}else yield e}*traverseNewline(e,t){yield e}*traverseLineComment(e,t){yield e}},em=new WeakMap,lr=new WeakSet,K0=function(){return P(this,em)??et(this,em,new Map)},xh=function(e){return{...e,depth:e.depth?e.depth-1:null}},J0=function(e,t,n){var r,s,a,o;if(e.experimentalNumChildAlgNodes()===1&&t.experimentalNumChildAlgNodes()===1){const l=(r=Array.from(e.childAlgNodes())[0])==null?void 0:r.as(ce),c=(s=Array.from(t.childAlgNodes())[0])==null?void 0:s.as(ce);if(!(l&&c))return!1;if(c.quantum.isIdentical(l.quantum)||(o=(a=new K1(n).puzzleSpecificSimplifyOptions())==null?void 0:a.axis)!=null&&o.areQuantumMovesSameAxis(l.quantum,c.quantum))return!0}return!1},s1),pA=dr(fA);function lb(i){if(!i)return[];if(Es(i,Qe))return i.childAlgNodes();if(typeof i=="string")return q1(i).childAlgNodes();const e=i;if(typeof e[Symbol.iterator]=="function")return e;throw new Error("Invalid AlgNode")}function qh(i){return Es(i,Qe)?i:new Qe(i)}var Yi,is,Qe=(is=class extends Ha{constructor(t){super();Be(this,Yi);et(this,Yi,Array.from(lb(t)));for(const n of P(this,Yi))if(!cA(n))throw new Error("An alg can only contain alg nodes.")}isIdentical(t){const n=t;if(!t.is(is))return!1;const r=Array.from(P(this,Yi)),s=Array.from(P(n,Yi));if(r.length!==s.length)return!1;for(let a=0;at.invert())))}*experimentalExpand(t=1,n){n??(n=1/0);for(const r of W1(P(this,Yi),t))yield*r.experimentalExpand(t,n)}expand(t){return new is(this.experimentalExpand(1,(t==null?void 0:t.depth)??1/0))}*experimentalLeafMoves(){for(const t of this.experimentalExpand())t.is(ce)&&(yield t)}concat(t){return new is(Array.from(P(this,Yi)).concat(Array.from(lb(t))))}experimentalIsEmpty(){for(const t of P(this,Yi))return!1;return!0}static fromString(t){return q1(t)}units(){return this.childAlgNodes()}*childAlgNodes(){for(const t of P(this,Yi))yield t}experimentalNumUnits(){return this.experimentalNumChildAlgNodes()}experimentalNumChildAlgNodes(){return Array.from(P(this,Yi)).length}get type(){return X1("deprecated: type"),"sequence"}toString(){var r,s;let t="",n=null;for(const a of P(this,Yi)){n&&(t+=mA(n,a));const o=(r=a.as(cr))==null?void 0:r.experimentalNISSGrouping;if(o){if(o.amount!==-1)throw new Error("Invalid NISS Grouping amount!");t+=`^(${o.alg.toString()})`}else(s=a.as(Pi))!=null&&s.experimentalNISSPlaceholder||(t+=a.toString());n=a}return t}experimentalSimplify(t){return new is(pA(this,t??{}))}simplify(t){return this.experimentalSimplify(t)}},Yi=new WeakMap,is);function mA(i,e){var t;return i.is(Zo)||e.is(Zo)||(t=e.as(Pi))!=null&&t.experimentalNISSPlaceholder?"":i.is(td)&&!e.is(Zo)?` -`:" "}new Qe([new ce("R",1),new ce("U",1),new ce("R",-1),new ce("U",1),new ce("R",1),new ce("U",-2),new ce("R",-1)]),new Qe([new ce("R",1),new ce("U",2),new ce("R",-1),new ce("U",-1),new ce("R",1),new ce("U",-1),new ce("R",-1)]),new Qe([new br(new Qe([new ce("R",1),new ce("U",1),new ce("R",-2)]),new Qe([new $i(new Qe([new ce("R",1)]),new Qe([new ce("U",1)]))]))]),new Qe([new ce("R",1),new ce("U",-1),new ce("L",-1),new ce("U",1),new ce("R",-1),new ce("U",-1),new ce("L",1),new ce("U",1)]),new Qe([new ce("x",-1),new br(new Qe([new $i(new Qe([new ce("R",1)]),new Qe([new ce("U",-1)]))]),new Qe([new ce("D",1)])),new br(new Qe([new $i(new Qe([new ce("R",1)]),new Qe([new ce("U",1)]))]),new Qe([new ce("D",1)])),new ce("x",1)]),new Qe([new $i(new Qe([new ce("F",1)]),new Qe([new br(new Qe([new ce("U",1)]),new Qe([new ce("R",1)]))]))]),new Qe([new $i(new Qe([new ce("R",2)]),new Qe([new br(new Qe([new ce("F",2)]),new Qe([new ce("R",-1),new ce("B",-1),new ce("R",1)]))]))]),new Qe([new ce("F",1),new ce("U",1),new ce("R",1),new ce("U",-1),new ce("R",-1),new ce("F",-1)]),new Qe([new ce("R",1),new ce("U",1),new ce("R",-1),new ce("U",-1),new ce("R",-1),new ce("F",1),new ce("R",2),new ce("U",-1),new ce("R",-1),new ce("U",-1),new ce("R",1),new ce("U",1),new ce("R",-1),new ce("F",-1)]),new Qe([new $i(new Qe([new ce("F",1)]),new Qe([new Pi(new Qe([new br(new Qe([new ce("R",1)]),new Qe([new ce("U",1)]))]),3)]))]),new Qe([new cr,new cr,new cr]);new ce("R"),new ce("R'"),new ce("B"),new ce("B'"),new ce("D"),new ce("D'"),new ce("L"),new ce("L'"),new ce("U"),new ce("U'"),new ce("F"),new ce("F'"),new ce("x'"),new ce("l"),new ce("l'"),new ce("r"),new ce("r'"),new ce("d"),new ce("d'"),new ce("x"),new ce("x"),new ce("x'"),new ce("y"),new ce("y"),new ce("y'"),new ce("z"),new ce("z'"),new ce("M'"),new ce("M'"),new cr;function Q0(i,e,t){const n={};for(const r of i.orbits){const s=e[r.orbitName],a=t[r.orbitName];if(_p(r.numOrientations,a))n[r.orbitName]=s;else if(_p(r.numOrientations,s))n[r.orbitName]=a;else{const o=new Array(r.numPieces);if(r.numOrientations===1){for(let l=0;l1){const{orientationDelta:r}=e;for(let s=0;s{const e={};for(const t of this.definition.orbits)e[t.orbitName]=t;return e})()),P(this,Iu)[i]}name(){return this.definition.name}identityTransformation(){return Jl.experimentalConstructIdentity(this)}moveToTransformation(i){typeof i=="string"&&(i=new ce(i));const e=i.toString(),t=P(this,dc).get(e);if(t)return new Jl(this,t);if(this.experimentalPGNotation){const r=this.experimentalPGNotation.lookupMove(i);if(!r)throw new Error(`could not map to internal move: ${i}`);return P(this,dc).set(e,r),new Jl(this,r)}const n=RA(this,i);return P(this,dc).set(e,n),new Jl(this,n)}algToTransformation(i){return typeof i=="string"&&(i=new Qe(i)),LA(i,this)}toTransformation(i){var e,t;return typeof i=="string"?this.algToTransformation(i):(e=i==null?void 0:i.is)!=null&&e.call(i,Qe)?this.algToTransformation(i):(t=i==null?void 0:i.is)!=null&&t.call(i,ce)?this.moveToTransformation(i):i}defaultPattern(){return new Lc(this,this.definition.defaultPattern)}canConvertDefaultPatternToUniqueTransformation(){return P(this,tm)??et(this,tm,(()=>{for(const i of this.definition.orbits){const e=new Array(i.numPieces).fill(!1);for(const t of this.definition.defaultPattern[i.orbitName].pieces)e[t]=!0;for(const t of e)if(!t)return!1}return!0})())}},Iu=new WeakMap,dc=new WeakMap,tm=new WeakMap,a1),t_=class $f extends Promise{constructor(e){super(t=>{t()}),this._executor=e}static from(e){return new $f(t=>{t(e())})}static resolve(e){return new $f(t=>{t(e)})}static reject(e){return new $f((t,n)=>{n(e)})}then(e,t){return this._promise=this._promise||new Promise(this._executor),this._promise.then(e,t)}catch(e){return this._promise=this._promise||new Promise(this._executor),this._promise.catch(e)}};function Em(i){return new t_(e=>{e(i())})}function G9(i,e,t,n,r){var l;const a=i.orbits[e].pieces[t];if(a===null)return Rr;const o=(l=a.facelets)==null?void 0:l[n];return o===null?Rr:typeof o=="string"?o:(console.log(o),o.mask)}var vo=class{constructor(i,e){Z(this,"stickerings",new Map);for(const t of i.definition.orbits)this.stickerings.set(t.orbitName,new Array(t.numPieces).fill(e))}},Rr="regular",On="ignored",Ll="oriented",MA="experimentalOriented2",Jc="invisible",eo="dim",wA={Regular:{facelets:[Rr,Rr,Rr,Rr,Rr]},Ignored:{facelets:[On,On,On,On,On]},OrientationStickers:{facelets:[Ll,Ll,Ll,Ll,Ll]},IgnoreNonPrimary:{facelets:[Rr,On,On,On,On]},Invisible:{facelets:[Jc,Jc,Jc,Jc,Jc]},PermuteNonPrimary:{facelets:[eo,Rr,Rr,Rr,Rr]},Dim:{facelets:[eo,eo,eo,eo,eo]},Ignoriented:{facelets:[eo,On,On,On,On]},OrientationWithoutPermutation:{facelets:[Ll,On,On,On,On]},ExperimentalOrientationWithoutPermutation2:{facelets:[MA,On,On,On,On]}};function n_(i){return wA[i]}var i_=class extends vo{constructor(i){super(i,"Regular")}set(i,e){for(const[t,n]of this.stickerings.entries())for(let r=0;rthis.move(e))}orbits(i){const e=new vo(this.kpuzzle,!1);for(const t of i)e.stickerings.get(t).fill(!0);return e}orbitPrefix(i){const e=new vo(this.kpuzzle,!1);for(const t of this.kpuzzle.definition.orbits)t.orbitName.startsWith(i)&&e.stickerings.get(t.orbitName).fill(!0);return e}},ub="Last Layer",db="Last Slot",Ar={"3x3x3":ub,megaminx:ub},da={"3x3x3":db,megaminx:db},AA={full:{groups:{"3x3x3":"Stickering",megaminx:"Stickering"}},OLL:{groups:Ar},PLL:{groups:Ar},LL:{groups:Ar},EOLL:{groups:Ar},COLL:{groups:Ar},OCLL:{groups:Ar},CPLL:{groups:Ar},CLL:{groups:Ar},EPLL:{groups:Ar},ELL:{groups:Ar},ZBLL:{groups:Ar},LS:{groups:da},LSOLL:{groups:da},LSOCLL:{groups:da},ELS:{groups:da},CLS:{groups:da},ZBLS:{groups:da},VLS:{groups:da},WVLS:{groups:da},F2L:{groups:{"3x3x3":"CFOP (Fridrich)"}},Daisy:{groups:{"3x3x3":"CFOP (Fridrich)"}},Cross:{groups:{"3x3x3":"CFOP (Fridrich)"}},EO:{groups:{"3x3x3":"ZZ"}},EOline:{groups:{"3x3x3":"ZZ"}},EOcross:{groups:{"3x3x3":"ZZ"}},CMLL:{groups:{"3x3x3":"Roux"}},L10P:{groups:{"3x3x3":"Roux"}},L6E:{groups:{"3x3x3":"Roux"}},L6EO:{groups:{"3x3x3":"Roux"}},"2x2x2":{groups:{"3x3x3":"Petrus"}},"2x2x3":{groups:{"3x3x3":"Petrus"}},G1:{groups:{"3x3x3":"FMC"}},L2C:{groups:{"4x4x4":"Reduction","5x5x5":"Reduction","6x6x6":"Reduction"}},PBL:{groups:{"2x2x2":"Ortega"}},"Void Cube":{groups:{"3x3x3":"Miscellaneous"}},invisible:{groups:{"3x3x3":"Miscellaneous"}},picture:{groups:{"3x3x3":"Miscellaneous"}},"centers-only":{groups:{"3x3x3":"Miscellaneous"}},"experimental-centers-U":{},"experimental-centers-U-D":{},"experimental-centers-U-L-D":{},"experimental-centers-U-L-B-D":{},"experimental-centers":{},"experimental-fto-fc":{groups:{fto:"Bencisco"}},"experimental-fto-f2t":{groups:{fto:"Bencisco"}},"experimental-fto-sc":{groups:{fto:"Bencisco"}},"experimental-fto-l2c":{groups:{fto:"Bencisco"}},"experimental-fto-lbt":{groups:{fto:"Bencisco"}},"experimental-fto-l3t":{groups:{fto:"Bencisco"}}};async function Xh(i,e){return(await EA(i,e)).toStickeringMask()}async function EA(i,e){const t=await i.kpuzzle(),n=new i_(t),r=new r_(t),s=()=>r.move("U"),a=()=>r.or(r.moves(["U","D"])),o=()=>r.or(r.moves(["L","R"])),l=()=>r.not(o()),c=()=>r.not(s()),h=()=>r.orbitPrefix("CENTER"),u=()=>r.orbitPrefix("EDGE"),d=()=>r.or([r.orbitPrefix("CORNER"),r.orbitPrefix("C4RNER"),r.orbitPrefix("C5RNER")]),p=()=>r.or([l(),r.and([s(),u()])]),m=()=>r.and([s(),h()]),v=()=>r.and([r.and(r.moves(["F","R"])),u()]),b=()=>r.and([r.and(r.moves(["F","R"])),d(),r.not(s())]),R=()=>r.or([b(),v()]);function L(){n.set(c(),"Dim")}function _(){n.set(s(),"PermuteNonPrimary"),n.set(m(),"Dim")}function S(){n.set(s(),"IgnoreNonPrimary"),n.set(m(),"Regular")}function D(){n.set(s(),"Ignoriented"),n.set(m(),"Dim")}switch(e){case"full":break;case"PLL":{L(),_();break}case"CLS":{L(),n.set(b(),"Regular"),n.set(s(),"Ignoriented"),n.set(r.and([s(),h()]),"Dim"),n.set(r.and([s(),d()]),"IgnoreNonPrimary");break}case"OLL":{L(),S();break}case"EOLL":{L(),S(),n.set(r.and([s(),d()]),"Ignored");break}case"COLL":{L(),n.set(r.and([s(),u()]),"Ignoriented"),n.set(r.and([s(),h()]),"Dim"),n.set(r.and([s(),d()]),"Regular");break}case"OCLL":{L(),D(),n.set(r.and([s(),d()]),"IgnoreNonPrimary");break}case"CPLL":{L(),n.set(r.and([d(),s()]),"PermuteNonPrimary"),n.set(r.and([r.not(d()),s()]),"Dim");break}case"CLL":{L(),n.set(r.not(r.and([d(),s()])),"Dim");break}case"EPLL":{L(),n.set(s(),"Dim"),n.set(r.and([s(),u()]),"PermuteNonPrimary");break}case"ELL":{L(),n.set(s(),"Dim"),n.set(r.and([s(),u()]),"Regular");break}case"ELS":{L(),S(),n.set(r.and([s(),d()]),"Ignored"),n.set(v(),"Regular"),n.set(b(),"Ignored");break}case"LL":{L();break}case"F2L":{n.set(s(),"Ignored");break}case"ZBLL":{L(),n.set(s(),"PermuteNonPrimary"),n.set(m(),"Dim"),n.set(r.and([s(),d()]),"Regular");break}case"ZBLS":{L(),n.set(R(),"Regular"),S(),n.set(r.and([s(),d()]),"Ignored");break}case"VLS":{L(),n.set(R(),"Regular"),S();break}case"WVLS":{L(),n.set(R(),"Regular"),n.set(r.and([s(),u()]),"Ignoriented"),n.set(r.and([s(),h()]),"Dim"),n.set(r.and([s(),d()]),"IgnoreNonPrimary");break}case"LS":{L(),n.set(R(),"Regular"),n.set(s(),"Ignored"),n.set(m(),"Dim");break}case"LSOLL":{L(),S(),n.set(R(),"Regular");break}case"LSOCLL":{L(),D(),n.set(r.and([s(),d()]),"IgnoreNonPrimary"),n.set(R(),"Regular");break}case"EO":{n.set(d(),"Ignored"),n.set(u(),"OrientationWithoutPermutation");break}case"EOline":{n.set(d(),"Ignored"),n.set(u(),"OrientationWithoutPermutation"),n.set(r.and(r.moves(["D","M"])),"Regular");break}case"EOcross":{n.set(u(),"OrientationWithoutPermutation"),n.set(r.move("D"),"Regular"),n.set(d(),"Ignored");break}case"CMLL":{n.set(c(),"Dim"),n.set(p(),"Ignored"),n.set(r.and([s(),d()]),"Regular");break}case"L10P":{n.set(r.not(p()),"Dim"),n.set(r.and([d(),s()]),"Regular");break}case"L6E":{n.set(r.not(p()),"Dim");break}case"L6EO":{n.set(r.not(p()),"Dim"),n.set(p(),"OrientationWithoutPermutation"),n.set(r.and([h(),a()]),"OrientationStickers");break}case"Daisy":{n.set(r.all(),"Ignored"),n.set(h(),"Dim"),n.set(r.and([r.move("D"),h()]),"Regular"),n.set(r.and([r.move("U"),u()]),"IgnoreNonPrimary");break}case"Cross":{n.set(r.all(),"Ignored"),n.set(h(),"Dim"),n.set(r.and([r.move("D"),h()]),"Regular"),n.set(r.and([r.move("D"),u()]),"Regular");break}case"2x2x2":{n.set(r.or(r.moves(["U","F","R"])),"Ignored"),n.set(r.and([r.or(r.moves(["U","F","R"])),h()]),"Dim");break}case"2x2x3":{n.set(r.all(),"Dim"),n.set(r.or(r.moves(["U","F","R"])),"Ignored"),n.set(r.and([r.or(r.moves(["U","F","R"])),h()]),"Dim"),n.set(r.and([r.move("F"),r.not(r.or(r.moves(["U","R"])))]),"Regular");break}case"G1":{n.set(r.all(),"ExperimentalOrientationWithoutPermutation2"),n.set(r.or(r.moves(["E"])),"OrientationWithoutPermutation"),n.set(r.and(r.moves(["E","S"])),"Ignored");break}case"L2C":{n.set(r.or(r.moves(["L","R","B","D"])),"Dim"),n.set(r.not(h()),"Ignored");break}case"PBL":{n.set(r.all(),"Ignored"),n.set(r.or(r.moves(["U","D"])),"PermuteNonPrimary");break}case"Void Cube":{n.set(h(),"Invisible");break}case"picture":case"invisible":{n.set(r.all(),"Invisible");break}case"centers-only":{n.set(r.not(h()),"Ignored");break}default:console.warn(`Unsupported stickering for ${i.id}: ${e}. Setting all pieces to dim.`),n.set(r.and(r.moves([])),"Dim")}return n}async function Tm(i,e){const t=[],n=[];for(const[r,s]of Object.entries(AA))s.groups&&(i in s.groups?t.push(r):e!=null&&e.use3x3x3Fallbacks&&"3x3x3"in s.groups&&n.push(r));return t.concat(n)}function Mn(i){let e=null;return()=>e??(e=i())}async function ER(i){return(await an(()=>import("./index-BSjPx7-K.js"),[])).getPuzzleGeometryByName(i,{allMoves:!0,orientCenters:!0,addRotations:!0})}async function s_(i,e){const t=await i,n=t.getKPuzzleDefinition(!0);n.name=e;const r=await an(()=>import("./index-BSjPx7-K.js"),[]),s=new r.ExperimentalPGNotation(t,t.getOrbitsDef(!0));return new ra(s.remapKPuzzleDefinition(n),{experimentalPGNotation:s})}var nm,im,rm,o1,qo=(o1=class{constructor(i){Z(this,"pgId");Z(this,"id");Z(this,"fullName");Z(this,"inventedBy");Z(this,"inventionYear");Be(this,nm);Be(this,im);Be(this,rm);Z(this,"puzzleSpecificSimplifyOptionsPromise",a_(this.kpuzzle.bind(this)));this.pgId=i.pgID,this.id=i.id,this.fullName=i.fullName,this.inventedBy=i.inventedBy,this.inventionYear=i.inventionYear}pg(){return P(this,nm)??et(this,nm,ER(this.pgId??this.id))}kpuzzle(){return P(this,im)??et(this,im,s_(this.pg(),this.id))}svg(){return P(this,rm)??et(this,rm,(async()=>(await this.pg()).generatesvg())())}},nm=new WeakMap,im=new WeakMap,rm=new WeakMap,o1),Rh=class extends qo{constructor(){super(...arguments);Z(this,"stickerings",()=>Tm(this.id,{use3x3x3Fallbacks:!0}))}stickeringMask(e){return Xh(this,e)}};function a_(i){return new t_(async e=>{const t=await i();e({quantumMoveOrder:n=>t.moveToTransformation(new ce(n)).repetitionOrder()})})}var Lp={name:"3x3x3",orbits:[{orbitName:"EDGES",numPieces:12,numOrientations:2},{orbitName:"CORNERS",numPieces:8,numOrientations:3},{orbitName:"CENTERS",numPieces:6,numOrientations:4}],defaultPattern:{EDGES:{pieces:[0,1,2,3,4,5,6,7,8,9,10,11],orientation:[0,0,0,0,0,0,0,0,0,0,0,0]},CORNERS:{pieces:[0,1,2,3,4,5,6,7],orientation:[0,0,0,0,0,0,0,0]},CENTERS:{pieces:[0,1,2,3,4,5],orientation:[0,0,0,0,0,0],orientationMod:[1,1,1,1,1,1]}},moves:{U:{EDGES:{permutation:[1,2,3,0,4,5,6,7,8,9,10,11],orientationDelta:[0,0,0,0,0,0,0,0,0,0,0,0]},CORNERS:{permutation:[1,2,3,0,4,5,6,7],orientationDelta:[0,0,0,0,0,0,0,0]},CENTERS:{permutation:[0,1,2,3,4,5],orientationDelta:[1,0,0,0,0,0]}},y:{EDGES:{permutation:[1,2,3,0,5,6,7,4,10,8,11,9],orientationDelta:[0,0,0,0,0,0,0,0,1,1,1,1]},CORNERS:{permutation:[1,2,3,0,7,4,5,6],orientationDelta:[0,0,0,0,0,0,0,0]},CENTERS:{permutation:[0,2,3,4,1,5],orientationDelta:[1,0,0,0,0,3]}},x:{EDGES:{permutation:[4,8,0,9,6,10,2,11,5,7,1,3],orientationDelta:[1,0,1,0,1,0,1,0,0,0,0,0]},CORNERS:{permutation:[4,0,3,5,7,6,2,1],orientationDelta:[2,1,2,1,1,2,1,2]},CENTERS:{permutation:[2,1,5,3,0,4],orientationDelta:[0,3,0,1,2,2]}},L:{EDGES:{permutation:[0,1,2,11,4,5,6,9,8,3,10,7],orientationDelta:[0,0,0,0,0,0,0,0,0,0,0,0]},CORNERS:{permutation:[0,1,6,2,4,3,5,7],orientationDelta:[0,0,2,1,0,2,1,0]},CENTERS:{permutation:[0,1,2,3,4,5],orientationDelta:[0,1,0,0,0,0]}},F:{EDGES:{permutation:[9,1,2,3,8,5,6,7,0,4,10,11],orientationDelta:[1,0,0,0,1,0,0,0,1,1,0,0]},CORNERS:{permutation:[3,1,2,5,0,4,6,7],orientationDelta:[1,0,0,2,2,1,0,0]},CENTERS:{permutation:[0,1,2,3,4,5],orientationDelta:[0,0,1,0,0,0]}},R:{EDGES:{permutation:[0,8,2,3,4,10,6,7,5,9,1,11],orientationDelta:[0,0,0,0,0,0,0,0,0,0,0,0]},CORNERS:{permutation:[4,0,2,3,7,5,6,1],orientationDelta:[2,1,0,0,1,0,0,2]},CENTERS:{permutation:[0,1,2,3,4,5],orientationDelta:[0,0,0,1,0,0]}},B:{EDGES:{permutation:[0,1,10,3,4,5,11,7,8,9,6,2],orientationDelta:[0,0,1,0,0,0,1,0,0,0,1,1]},CORNERS:{permutation:[0,7,1,3,4,5,2,6],orientationDelta:[0,2,1,0,0,0,2,1]},CENTERS:{permutation:[0,1,2,3,4,5],orientationDelta:[0,0,0,0,1,0]}},D:{EDGES:{permutation:[0,1,2,3,7,4,5,6,8,9,10,11],orientationDelta:[0,0,0,0,0,0,0,0,0,0,0,0]},CORNERS:{permutation:[0,1,2,3,5,6,7,4],orientationDelta:[0,0,0,0,0,0,0,0]},CENTERS:{permutation:[0,1,2,3,4,5],orientationDelta:[0,0,0,0,0,1]}},z:{EDGES:{permutation:[9,3,11,7,8,1,10,5,0,4,2,6],orientationDelta:[1,1,1,1,1,1,1,1,1,1,1,1]},CORNERS:{permutation:[3,2,6,5,0,4,7,1],orientationDelta:[1,2,1,2,2,1,2,1]},CENTERS:{permutation:[1,5,2,0,4,3],orientationDelta:[1,1,1,1,3,1]}},M:{EDGES:{permutation:[2,1,6,3,0,5,4,7,8,9,10,11],orientationDelta:[1,0,1,0,1,0,1,0,0,0,0,0]},CORNERS:{permutation:[0,1,2,3,4,5,6,7],orientationDelta:[0,0,0,0,0,0,0,0]},CENTERS:{permutation:[4,1,0,3,5,2],orientationDelta:[2,0,0,0,2,0]}},E:{EDGES:{permutation:[0,1,2,3,4,5,6,7,9,11,8,10],orientationDelta:[0,0,0,0,0,0,0,0,1,1,1,1]},CORNERS:{permutation:[0,1,2,3,4,5,6,7],orientationDelta:[0,0,0,0,0,0,0,0]},CENTERS:{permutation:[0,4,1,2,3,5],orientationDelta:[0,0,0,0,0,0]}},S:{EDGES:{permutation:[0,3,2,7,4,1,6,5,8,9,10,11],orientationDelta:[0,1,0,1,0,1,0,1,0,0,0,0]},CORNERS:{permutation:[0,1,2,3,4,5,6,7],orientationDelta:[0,0,0,0,0,0,0,0]},CENTERS:{permutation:[1,5,2,0,4,3],orientationDelta:[1,1,0,1,0,1]}},u:{EDGES:{permutation:[1,2,3,0,4,5,6,7,10,8,11,9],orientationDelta:[0,0,0,0,0,0,0,0,1,1,1,1]},CORNERS:{permutation:[1,2,3,0,4,5,6,7],orientationDelta:[0,0,0,0,0,0,0,0]},CENTERS:{permutation:[0,2,3,4,1,5],orientationDelta:[1,0,0,0,0,0]}},l:{EDGES:{permutation:[2,1,6,11,0,5,4,9,8,3,10,7],orientationDelta:[1,0,1,0,1,0,1,0,0,0,0,0]},CORNERS:{permutation:[0,1,6,2,4,3,5,7],orientationDelta:[0,0,2,1,0,2,1,0]},CENTERS:{permutation:[4,1,0,3,5,2],orientationDelta:[2,1,0,0,2,0]}},f:{EDGES:{permutation:[9,3,2,7,8,1,6,5,0,4,10,11],orientationDelta:[1,1,0,1,1,1,0,1,1,1,0,0]},CORNERS:{permutation:[3,1,2,5,0,4,6,7],orientationDelta:[1,0,0,2,2,1,0,0]},CENTERS:{permutation:[1,5,2,0,4,3],orientationDelta:[1,1,1,1,0,1]}},r:{EDGES:{permutation:[4,8,0,3,6,10,2,7,5,9,1,11],orientationDelta:[1,0,1,0,1,0,1,0,0,0,0,0]},CORNERS:{permutation:[4,0,2,3,7,5,6,1],orientationDelta:[2,1,0,0,1,0,0,2]},CENTERS:{permutation:[2,1,5,3,0,4],orientationDelta:[0,0,0,1,2,2]}},b:{EDGES:{permutation:[0,5,10,1,4,7,11,3,8,9,6,2],orientationDelta:[0,1,1,1,0,1,1,1,0,0,1,1]},CORNERS:{permutation:[0,7,1,3,4,5,2,6],orientationDelta:[0,2,1,0,0,0,2,1]},CENTERS:{permutation:[3,0,2,5,4,1],orientationDelta:[3,3,0,3,1,3]}},d:{EDGES:{permutation:[0,1,2,3,7,4,5,6,9,11,8,10],orientationDelta:[0,0,0,0,0,0,0,0,1,1,1,1]},CORNERS:{permutation:[0,1,2,3,5,6,7,4],orientationDelta:[0,0,0,0,0,0,0,0]},CENTERS:{permutation:[0,4,1,2,3,5],orientationDelta:[0,0,0,0,0,1]}}},derivedMoves:{Uw:"u",Lw:"l",Fw:"f",Rw:"r",Bw:"b",Dw:"d",Uv:"y",Lv:"x'",Fv:"z",Rv:"x",Bv:"z'",Dv:"y'","2U":"u U'","2L":"l L'","2F":"f F'","2R":"r R'","2B":"b B'","2D":"d D'"}};async function TA(i){const e=await(i.puzzleSpecificSimplifyOptions??i.puzzleSpecificSimplifyOptionsPromise);return e?{puzzleLoader:{puzzleSpecificSimplifyOptions:e}}:{}}new Array(24);async function Sp(i,e){return(await an(()=>import("./index-BSjPx7-K.js"),[])).getPuzzleGeometryByDesc(i,{allMoves:!0,orientCenters:!0,addRotations:!0,...e})}async function o_(i,e){const t=Sp(i,e);return s_(t,`description: ${i}`)}var FA=1;function CA(i,e){const t=FA++;let n=null;const r=async()=>n??(n=o_(i)),s={id:`custom-${t}`,fullName:(e==null?void 0:e.fullName)??`Custom Puzzle (instance #${t})`,kpuzzle:r,svg:async()=>(await Sp(i)).generatesvg(),pg:async()=>Sp(i),puzzleSpecificSimplifyOptionsPromise:a_(r)};return e!=null&&e.inventedBy&&(s.inventedBy=e.inventedBy),e!=null&&e.inventionYear&&(s.inventionYear=e.inventionYear),s}var l_=new ra(Lp);Lp.experimentalIsPatternSolved=IA;function c_(i){const e=i.patternData.CENTERS.pieces[0],t=i.patternData.CENTERS.pieces[5],n=i.patternData.CENTERS.pieces[1];let r=n;return enew Array(6));function DA(){{const i=["","z","x","z'","x'","x2"].map(t=>Qe.fromString(t)),e=new Qe("y");for(const t of i){let n=l_.algToTransformation(t);for(let r=0;r<4;r++){n=n.applyAlg(e);const[s,a]=c_(n.toKPattern());fb[s][a]=n.invert()}}}return fb}function PA(i){const[e,t]=c_(i),n=DA()[e][t];return i.applyTransformation(n)}function IA(i,e){var t;return e.ignorePuzzleOrientation&&(i=PA(i)),e.ignoreCenterOrientation&&(i=new Lc(i.kpuzzle,{EDGES:i.patternData.EDGES,CORNERS:i.patternData.CORNERS,CENTERS:{pieces:i.patternData.CENTERS.pieces,orientation:new Array(6).fill(0)}})),!!((t=i.experimentalToTransformation())!=null&&t.isIdentityTransformation())}/** +`:" "}new Qe([new ce("R",1),new ce("U",1),new ce("R",-1),new ce("U",1),new ce("R",1),new ce("U",-2),new ce("R",-1)]),new Qe([new ce("R",1),new ce("U",2),new ce("R",-1),new ce("U",-1),new ce("R",1),new ce("U",-1),new ce("R",-1)]),new Qe([new br(new Qe([new ce("R",1),new ce("U",1),new ce("R",-2)]),new Qe([new $i(new Qe([new ce("R",1)]),new Qe([new ce("U",1)]))]))]),new Qe([new ce("R",1),new ce("U",-1),new ce("L",-1),new ce("U",1),new ce("R",-1),new ce("U",-1),new ce("L",1),new ce("U",1)]),new Qe([new ce("x",-1),new br(new Qe([new $i(new Qe([new ce("R",1)]),new Qe([new ce("U",-1)]))]),new Qe([new ce("D",1)])),new br(new Qe([new $i(new Qe([new ce("R",1)]),new Qe([new ce("U",1)]))]),new Qe([new ce("D",1)])),new ce("x",1)]),new Qe([new $i(new Qe([new ce("F",1)]),new Qe([new br(new Qe([new ce("U",1)]),new Qe([new ce("R",1)]))]))]),new Qe([new $i(new Qe([new ce("R",2)]),new Qe([new br(new Qe([new ce("F",2)]),new Qe([new ce("R",-1),new ce("B",-1),new ce("R",1)]))]))]),new Qe([new ce("F",1),new ce("U",1),new ce("R",1),new ce("U",-1),new ce("R",-1),new ce("F",-1)]),new Qe([new ce("R",1),new ce("U",1),new ce("R",-1),new ce("U",-1),new ce("R",-1),new ce("F",1),new ce("R",2),new ce("U",-1),new ce("R",-1),new ce("U",-1),new ce("R",1),new ce("U",1),new ce("R",-1),new ce("F",-1)]),new Qe([new $i(new Qe([new ce("F",1)]),new Qe([new Pi(new Qe([new br(new Qe([new ce("R",1)]),new Qe([new ce("U",1)]))]),3)]))]),new Qe([new cr,new cr,new cr]);new ce("R"),new ce("R'"),new ce("B"),new ce("B'"),new ce("D"),new ce("D'"),new ce("L"),new ce("L'"),new ce("U"),new ce("U'"),new ce("F"),new ce("F'"),new ce("x'"),new ce("l"),new ce("l'"),new ce("r"),new ce("r'"),new ce("d"),new ce("d'"),new ce("x"),new ce("x"),new ce("x'"),new ce("y"),new ce("y"),new ce("y'"),new ce("z"),new ce("z'"),new ce("M'"),new ce("M'"),new cr;function Q0(i,e,t){const n={};for(const r of i.orbits){const s=e[r.orbitName],a=t[r.orbitName];if(_p(r.numOrientations,a))n[r.orbitName]=s;else if(_p(r.numOrientations,s))n[r.orbitName]=a;else{const o=new Array(r.numPieces);if(r.numOrientations===1){for(let l=0;l1){const{orientationDelta:r}=e;for(let s=0;s{const e={};for(const t of this.definition.orbits)e[t.orbitName]=t;return e})()),P(this,Iu)[i]}name(){return this.definition.name}identityTransformation(){return Jl.experimentalConstructIdentity(this)}moveToTransformation(i){typeof i=="string"&&(i=new ce(i));const e=i.toString(),t=P(this,dc).get(e);if(t)return new Jl(this,t);if(this.experimentalPGNotation){const r=this.experimentalPGNotation.lookupMove(i);if(!r)throw new Error(`could not map to internal move: ${i}`);return P(this,dc).set(e,r),new Jl(this,r)}const n=RA(this,i);return P(this,dc).set(e,n),new Jl(this,n)}algToTransformation(i){return typeof i=="string"&&(i=new Qe(i)),LA(i,this)}toTransformation(i){var e,t;return typeof i=="string"?this.algToTransformation(i):(e=i==null?void 0:i.is)!=null&&e.call(i,Qe)?this.algToTransformation(i):(t=i==null?void 0:i.is)!=null&&t.call(i,ce)?this.moveToTransformation(i):i}defaultPattern(){return new Lc(this,this.definition.defaultPattern)}canConvertDefaultPatternToUniqueTransformation(){return P(this,tm)??et(this,tm,(()=>{for(const i of this.definition.orbits){const e=new Array(i.numPieces).fill(!1);for(const t of this.definition.defaultPattern[i.orbitName].pieces)e[t]=!0;for(const t of e)if(!t)return!1}return!0})())}},Iu=new WeakMap,dc=new WeakMap,tm=new WeakMap,a1),t_=class $f extends Promise{constructor(e){super(t=>{t()}),this._executor=e}static from(e){return new $f(t=>{t(e())})}static resolve(e){return new $f(t=>{t(e)})}static reject(e){return new $f((t,n)=>{n(e)})}then(e,t){return this._promise=this._promise||new Promise(this._executor),this._promise.then(e,t)}catch(e){return this._promise=this._promise||new Promise(this._executor),this._promise.catch(e)}};function Em(i){return new t_(e=>{e(i())})}function G9(i,e,t,n,r){var l;const a=i.orbits[e].pieces[t];if(a===null)return Rr;const o=(l=a.facelets)==null?void 0:l[n];return o===null?Rr:typeof o=="string"?o:(console.log(o),o.mask)}var vo=class{constructor(i,e){Z(this,"stickerings",new Map);for(const t of i.definition.orbits)this.stickerings.set(t.orbitName,new Array(t.numPieces).fill(e))}},Rr="regular",On="ignored",Ll="oriented",MA="experimentalOriented2",Jc="invisible",eo="dim",wA={Regular:{facelets:[Rr,Rr,Rr,Rr,Rr]},Ignored:{facelets:[On,On,On,On,On]},OrientationStickers:{facelets:[Ll,Ll,Ll,Ll,Ll]},IgnoreNonPrimary:{facelets:[Rr,On,On,On,On]},Invisible:{facelets:[Jc,Jc,Jc,Jc,Jc]},PermuteNonPrimary:{facelets:[eo,Rr,Rr,Rr,Rr]},Dim:{facelets:[eo,eo,eo,eo,eo]},Ignoriented:{facelets:[eo,On,On,On,On]},OrientationWithoutPermutation:{facelets:[Ll,On,On,On,On]},ExperimentalOrientationWithoutPermutation2:{facelets:[MA,On,On,On,On]}};function n_(i){return wA[i]}var i_=class extends vo{constructor(i){super(i,"Regular")}set(i,e){for(const[t,n]of this.stickerings.entries())for(let r=0;rthis.move(e))}orbits(i){const e=new vo(this.kpuzzle,!1);for(const t of i)e.stickerings.get(t).fill(!0);return e}orbitPrefix(i){const e=new vo(this.kpuzzle,!1);for(const t of this.kpuzzle.definition.orbits)t.orbitName.startsWith(i)&&e.stickerings.get(t.orbitName).fill(!0);return e}},ub="Last Layer",db="Last Slot",Ar={"3x3x3":ub,megaminx:ub},da={"3x3x3":db,megaminx:db},AA={full:{groups:{"3x3x3":"Stickering",megaminx:"Stickering"}},OLL:{groups:Ar},PLL:{groups:Ar},LL:{groups:Ar},EOLL:{groups:Ar},COLL:{groups:Ar},OCLL:{groups:Ar},CPLL:{groups:Ar},CLL:{groups:Ar},EPLL:{groups:Ar},ELL:{groups:Ar},ZBLL:{groups:Ar},LS:{groups:da},LSOLL:{groups:da},LSOCLL:{groups:da},ELS:{groups:da},CLS:{groups:da},ZBLS:{groups:da},VLS:{groups:da},WVLS:{groups:da},F2L:{groups:{"3x3x3":"CFOP (Fridrich)"}},Daisy:{groups:{"3x3x3":"CFOP (Fridrich)"}},Cross:{groups:{"3x3x3":"CFOP (Fridrich)"}},EO:{groups:{"3x3x3":"ZZ"}},EOline:{groups:{"3x3x3":"ZZ"}},EOcross:{groups:{"3x3x3":"ZZ"}},CMLL:{groups:{"3x3x3":"Roux"}},L10P:{groups:{"3x3x3":"Roux"}},L6E:{groups:{"3x3x3":"Roux"}},L6EO:{groups:{"3x3x3":"Roux"}},"2x2x2":{groups:{"3x3x3":"Petrus"}},"2x2x3":{groups:{"3x3x3":"Petrus"}},G1:{groups:{"3x3x3":"FMC"}},L2C:{groups:{"4x4x4":"Reduction","5x5x5":"Reduction","6x6x6":"Reduction"}},PBL:{groups:{"2x2x2":"Ortega"}},"Void Cube":{groups:{"3x3x3":"Miscellaneous"}},invisible:{groups:{"3x3x3":"Miscellaneous"}},picture:{groups:{"3x3x3":"Miscellaneous"}},"centers-only":{groups:{"3x3x3":"Miscellaneous"}},"experimental-centers-U":{},"experimental-centers-U-D":{},"experimental-centers-U-L-D":{},"experimental-centers-U-L-B-D":{},"experimental-centers":{},"experimental-fto-fc":{groups:{fto:"Bencisco"}},"experimental-fto-f2t":{groups:{fto:"Bencisco"}},"experimental-fto-sc":{groups:{fto:"Bencisco"}},"experimental-fto-l2c":{groups:{fto:"Bencisco"}},"experimental-fto-lbt":{groups:{fto:"Bencisco"}},"experimental-fto-l3t":{groups:{fto:"Bencisco"}}};async function Xh(i,e){return(await EA(i,e)).toStickeringMask()}async function EA(i,e){const t=await i.kpuzzle(),n=new i_(t),r=new r_(t),s=()=>r.move("U"),a=()=>r.or(r.moves(["U","D"])),o=()=>r.or(r.moves(["L","R"])),l=()=>r.not(o()),c=()=>r.not(s()),h=()=>r.orbitPrefix("CENTER"),u=()=>r.orbitPrefix("EDGE"),d=()=>r.or([r.orbitPrefix("CORNER"),r.orbitPrefix("C4RNER"),r.orbitPrefix("C5RNER")]),p=()=>r.or([l(),r.and([s(),u()])]),m=()=>r.and([s(),h()]),v=()=>r.and([r.and(r.moves(["F","R"])),u()]),b=()=>r.and([r.and(r.moves(["F","R"])),d(),r.not(s())]),R=()=>r.or([b(),v()]);function L(){n.set(c(),"Dim")}function _(){n.set(s(),"PermuteNonPrimary"),n.set(m(),"Dim")}function S(){n.set(s(),"IgnoreNonPrimary"),n.set(m(),"Regular")}function D(){n.set(s(),"Ignoriented"),n.set(m(),"Dim")}switch(e){case"full":break;case"PLL":{L(),_();break}case"CLS":{L(),n.set(b(),"Regular"),n.set(s(),"Ignoriented"),n.set(r.and([s(),h()]),"Dim"),n.set(r.and([s(),d()]),"IgnoreNonPrimary");break}case"OLL":{L(),S();break}case"EOLL":{L(),S(),n.set(r.and([s(),d()]),"Ignored");break}case"COLL":{L(),n.set(r.and([s(),u()]),"Ignoriented"),n.set(r.and([s(),h()]),"Dim"),n.set(r.and([s(),d()]),"Regular");break}case"OCLL":{L(),D(),n.set(r.and([s(),d()]),"IgnoreNonPrimary");break}case"CPLL":{L(),n.set(r.and([d(),s()]),"PermuteNonPrimary"),n.set(r.and([r.not(d()),s()]),"Dim");break}case"CLL":{L(),n.set(r.not(r.and([d(),s()])),"Dim");break}case"EPLL":{L(),n.set(s(),"Dim"),n.set(r.and([s(),u()]),"PermuteNonPrimary");break}case"ELL":{L(),n.set(s(),"Dim"),n.set(r.and([s(),u()]),"Regular");break}case"ELS":{L(),S(),n.set(r.and([s(),d()]),"Ignored"),n.set(v(),"Regular"),n.set(b(),"Ignored");break}case"LL":{L();break}case"F2L":{n.set(s(),"Ignored");break}case"ZBLL":{L(),n.set(s(),"PermuteNonPrimary"),n.set(m(),"Dim"),n.set(r.and([s(),d()]),"Regular");break}case"ZBLS":{L(),n.set(R(),"Regular"),S(),n.set(r.and([s(),d()]),"Ignored");break}case"VLS":{L(),n.set(R(),"Regular"),S();break}case"WVLS":{L(),n.set(R(),"Regular"),n.set(r.and([s(),u()]),"Ignoriented"),n.set(r.and([s(),h()]),"Dim"),n.set(r.and([s(),d()]),"IgnoreNonPrimary");break}case"LS":{L(),n.set(R(),"Regular"),n.set(s(),"Ignored"),n.set(m(),"Dim");break}case"LSOLL":{L(),S(),n.set(R(),"Regular");break}case"LSOCLL":{L(),D(),n.set(r.and([s(),d()]),"IgnoreNonPrimary"),n.set(R(),"Regular");break}case"EO":{n.set(d(),"Ignored"),n.set(u(),"OrientationWithoutPermutation");break}case"EOline":{n.set(d(),"Ignored"),n.set(u(),"OrientationWithoutPermutation"),n.set(r.and(r.moves(["D","M"])),"Regular");break}case"EOcross":{n.set(u(),"OrientationWithoutPermutation"),n.set(r.move("D"),"Regular"),n.set(d(),"Ignored");break}case"CMLL":{n.set(c(),"Dim"),n.set(p(),"Ignored"),n.set(r.and([s(),d()]),"Regular");break}case"L10P":{n.set(r.not(p()),"Dim"),n.set(r.and([d(),s()]),"Regular");break}case"L6E":{n.set(r.not(p()),"Dim");break}case"L6EO":{n.set(r.not(p()),"Dim"),n.set(p(),"OrientationWithoutPermutation"),n.set(r.and([h(),a()]),"OrientationStickers");break}case"Daisy":{n.set(r.all(),"Ignored"),n.set(h(),"Dim"),n.set(r.and([r.move("D"),h()]),"Regular"),n.set(r.and([r.move("U"),u()]),"IgnoreNonPrimary");break}case"Cross":{n.set(r.all(),"Ignored"),n.set(h(),"Dim"),n.set(r.and([r.move("D"),h()]),"Regular"),n.set(r.and([r.move("D"),u()]),"Regular");break}case"2x2x2":{n.set(r.or(r.moves(["U","F","R"])),"Ignored"),n.set(r.and([r.or(r.moves(["U","F","R"])),h()]),"Dim");break}case"2x2x3":{n.set(r.all(),"Dim"),n.set(r.or(r.moves(["U","F","R"])),"Ignored"),n.set(r.and([r.or(r.moves(["U","F","R"])),h()]),"Dim"),n.set(r.and([r.move("F"),r.not(r.or(r.moves(["U","R"])))]),"Regular");break}case"G1":{n.set(r.all(),"ExperimentalOrientationWithoutPermutation2"),n.set(r.or(r.moves(["E"])),"OrientationWithoutPermutation"),n.set(r.and(r.moves(["E","S"])),"Ignored");break}case"L2C":{n.set(r.or(r.moves(["L","R","B","D"])),"Dim"),n.set(r.not(h()),"Ignored");break}case"PBL":{n.set(r.all(),"Ignored"),n.set(r.or(r.moves(["U","D"])),"PermuteNonPrimary");break}case"Void Cube":{n.set(h(),"Invisible");break}case"picture":case"invisible":{n.set(r.all(),"Invisible");break}case"centers-only":{n.set(r.not(h()),"Ignored");break}default:console.warn(`Unsupported stickering for ${i.id}: ${e}. Setting all pieces to dim.`),n.set(r.and(r.moves([])),"Dim")}return n}async function Tm(i,e){const t=[],n=[];for(const[r,s]of Object.entries(AA))s.groups&&(i in s.groups?t.push(r):e!=null&&e.use3x3x3Fallbacks&&"3x3x3"in s.groups&&n.push(r));return t.concat(n)}function Mn(i){let e=null;return()=>e??(e=i())}async function ER(i){return(await an(()=>import("./index-Dti57iVT.js"),[])).getPuzzleGeometryByName(i,{allMoves:!0,orientCenters:!0,addRotations:!0})}async function s_(i,e){const t=await i,n=t.getKPuzzleDefinition(!0);n.name=e;const r=await an(()=>import("./index-Dti57iVT.js"),[]),s=new r.ExperimentalPGNotation(t,t.getOrbitsDef(!0));return new ra(s.remapKPuzzleDefinition(n),{experimentalPGNotation:s})}var nm,im,rm,o1,qo=(o1=class{constructor(i){Z(this,"pgId");Z(this,"id");Z(this,"fullName");Z(this,"inventedBy");Z(this,"inventionYear");Be(this,nm);Be(this,im);Be(this,rm);Z(this,"puzzleSpecificSimplifyOptionsPromise",a_(this.kpuzzle.bind(this)));this.pgId=i.pgID,this.id=i.id,this.fullName=i.fullName,this.inventedBy=i.inventedBy,this.inventionYear=i.inventionYear}pg(){return P(this,nm)??et(this,nm,ER(this.pgId??this.id))}kpuzzle(){return P(this,im)??et(this,im,s_(this.pg(),this.id))}svg(){return P(this,rm)??et(this,rm,(async()=>(await this.pg()).generatesvg())())}},nm=new WeakMap,im=new WeakMap,rm=new WeakMap,o1),Rh=class extends qo{constructor(){super(...arguments);Z(this,"stickerings",()=>Tm(this.id,{use3x3x3Fallbacks:!0}))}stickeringMask(e){return Xh(this,e)}};function a_(i){return new t_(async e=>{const t=await i();e({quantumMoveOrder:n=>t.moveToTransformation(new ce(n)).repetitionOrder()})})}var Lp={name:"3x3x3",orbits:[{orbitName:"EDGES",numPieces:12,numOrientations:2},{orbitName:"CORNERS",numPieces:8,numOrientations:3},{orbitName:"CENTERS",numPieces:6,numOrientations:4}],defaultPattern:{EDGES:{pieces:[0,1,2,3,4,5,6,7,8,9,10,11],orientation:[0,0,0,0,0,0,0,0,0,0,0,0]},CORNERS:{pieces:[0,1,2,3,4,5,6,7],orientation:[0,0,0,0,0,0,0,0]},CENTERS:{pieces:[0,1,2,3,4,5],orientation:[0,0,0,0,0,0],orientationMod:[1,1,1,1,1,1]}},moves:{U:{EDGES:{permutation:[1,2,3,0,4,5,6,7,8,9,10,11],orientationDelta:[0,0,0,0,0,0,0,0,0,0,0,0]},CORNERS:{permutation:[1,2,3,0,4,5,6,7],orientationDelta:[0,0,0,0,0,0,0,0]},CENTERS:{permutation:[0,1,2,3,4,5],orientationDelta:[1,0,0,0,0,0]}},y:{EDGES:{permutation:[1,2,3,0,5,6,7,4,10,8,11,9],orientationDelta:[0,0,0,0,0,0,0,0,1,1,1,1]},CORNERS:{permutation:[1,2,3,0,7,4,5,6],orientationDelta:[0,0,0,0,0,0,0,0]},CENTERS:{permutation:[0,2,3,4,1,5],orientationDelta:[1,0,0,0,0,3]}},x:{EDGES:{permutation:[4,8,0,9,6,10,2,11,5,7,1,3],orientationDelta:[1,0,1,0,1,0,1,0,0,0,0,0]},CORNERS:{permutation:[4,0,3,5,7,6,2,1],orientationDelta:[2,1,2,1,1,2,1,2]},CENTERS:{permutation:[2,1,5,3,0,4],orientationDelta:[0,3,0,1,2,2]}},L:{EDGES:{permutation:[0,1,2,11,4,5,6,9,8,3,10,7],orientationDelta:[0,0,0,0,0,0,0,0,0,0,0,0]},CORNERS:{permutation:[0,1,6,2,4,3,5,7],orientationDelta:[0,0,2,1,0,2,1,0]},CENTERS:{permutation:[0,1,2,3,4,5],orientationDelta:[0,1,0,0,0,0]}},F:{EDGES:{permutation:[9,1,2,3,8,5,6,7,0,4,10,11],orientationDelta:[1,0,0,0,1,0,0,0,1,1,0,0]},CORNERS:{permutation:[3,1,2,5,0,4,6,7],orientationDelta:[1,0,0,2,2,1,0,0]},CENTERS:{permutation:[0,1,2,3,4,5],orientationDelta:[0,0,1,0,0,0]}},R:{EDGES:{permutation:[0,8,2,3,4,10,6,7,5,9,1,11],orientationDelta:[0,0,0,0,0,0,0,0,0,0,0,0]},CORNERS:{permutation:[4,0,2,3,7,5,6,1],orientationDelta:[2,1,0,0,1,0,0,2]},CENTERS:{permutation:[0,1,2,3,4,5],orientationDelta:[0,0,0,1,0,0]}},B:{EDGES:{permutation:[0,1,10,3,4,5,11,7,8,9,6,2],orientationDelta:[0,0,1,0,0,0,1,0,0,0,1,1]},CORNERS:{permutation:[0,7,1,3,4,5,2,6],orientationDelta:[0,2,1,0,0,0,2,1]},CENTERS:{permutation:[0,1,2,3,4,5],orientationDelta:[0,0,0,0,1,0]}},D:{EDGES:{permutation:[0,1,2,3,7,4,5,6,8,9,10,11],orientationDelta:[0,0,0,0,0,0,0,0,0,0,0,0]},CORNERS:{permutation:[0,1,2,3,5,6,7,4],orientationDelta:[0,0,0,0,0,0,0,0]},CENTERS:{permutation:[0,1,2,3,4,5],orientationDelta:[0,0,0,0,0,1]}},z:{EDGES:{permutation:[9,3,11,7,8,1,10,5,0,4,2,6],orientationDelta:[1,1,1,1,1,1,1,1,1,1,1,1]},CORNERS:{permutation:[3,2,6,5,0,4,7,1],orientationDelta:[1,2,1,2,2,1,2,1]},CENTERS:{permutation:[1,5,2,0,4,3],orientationDelta:[1,1,1,1,3,1]}},M:{EDGES:{permutation:[2,1,6,3,0,5,4,7,8,9,10,11],orientationDelta:[1,0,1,0,1,0,1,0,0,0,0,0]},CORNERS:{permutation:[0,1,2,3,4,5,6,7],orientationDelta:[0,0,0,0,0,0,0,0]},CENTERS:{permutation:[4,1,0,3,5,2],orientationDelta:[2,0,0,0,2,0]}},E:{EDGES:{permutation:[0,1,2,3,4,5,6,7,9,11,8,10],orientationDelta:[0,0,0,0,0,0,0,0,1,1,1,1]},CORNERS:{permutation:[0,1,2,3,4,5,6,7],orientationDelta:[0,0,0,0,0,0,0,0]},CENTERS:{permutation:[0,4,1,2,3,5],orientationDelta:[0,0,0,0,0,0]}},S:{EDGES:{permutation:[0,3,2,7,4,1,6,5,8,9,10,11],orientationDelta:[0,1,0,1,0,1,0,1,0,0,0,0]},CORNERS:{permutation:[0,1,2,3,4,5,6,7],orientationDelta:[0,0,0,0,0,0,0,0]},CENTERS:{permutation:[1,5,2,0,4,3],orientationDelta:[1,1,0,1,0,1]}},u:{EDGES:{permutation:[1,2,3,0,4,5,6,7,10,8,11,9],orientationDelta:[0,0,0,0,0,0,0,0,1,1,1,1]},CORNERS:{permutation:[1,2,3,0,4,5,6,7],orientationDelta:[0,0,0,0,0,0,0,0]},CENTERS:{permutation:[0,2,3,4,1,5],orientationDelta:[1,0,0,0,0,0]}},l:{EDGES:{permutation:[2,1,6,11,0,5,4,9,8,3,10,7],orientationDelta:[1,0,1,0,1,0,1,0,0,0,0,0]},CORNERS:{permutation:[0,1,6,2,4,3,5,7],orientationDelta:[0,0,2,1,0,2,1,0]},CENTERS:{permutation:[4,1,0,3,5,2],orientationDelta:[2,1,0,0,2,0]}},f:{EDGES:{permutation:[9,3,2,7,8,1,6,5,0,4,10,11],orientationDelta:[1,1,0,1,1,1,0,1,1,1,0,0]},CORNERS:{permutation:[3,1,2,5,0,4,6,7],orientationDelta:[1,0,0,2,2,1,0,0]},CENTERS:{permutation:[1,5,2,0,4,3],orientationDelta:[1,1,1,1,0,1]}},r:{EDGES:{permutation:[4,8,0,3,6,10,2,7,5,9,1,11],orientationDelta:[1,0,1,0,1,0,1,0,0,0,0,0]},CORNERS:{permutation:[4,0,2,3,7,5,6,1],orientationDelta:[2,1,0,0,1,0,0,2]},CENTERS:{permutation:[2,1,5,3,0,4],orientationDelta:[0,0,0,1,2,2]}},b:{EDGES:{permutation:[0,5,10,1,4,7,11,3,8,9,6,2],orientationDelta:[0,1,1,1,0,1,1,1,0,0,1,1]},CORNERS:{permutation:[0,7,1,3,4,5,2,6],orientationDelta:[0,2,1,0,0,0,2,1]},CENTERS:{permutation:[3,0,2,5,4,1],orientationDelta:[3,3,0,3,1,3]}},d:{EDGES:{permutation:[0,1,2,3,7,4,5,6,9,11,8,10],orientationDelta:[0,0,0,0,0,0,0,0,1,1,1,1]},CORNERS:{permutation:[0,1,2,3,5,6,7,4],orientationDelta:[0,0,0,0,0,0,0,0]},CENTERS:{permutation:[0,4,1,2,3,5],orientationDelta:[0,0,0,0,0,1]}}},derivedMoves:{Uw:"u",Lw:"l",Fw:"f",Rw:"r",Bw:"b",Dw:"d",Uv:"y",Lv:"x'",Fv:"z",Rv:"x",Bv:"z'",Dv:"y'","2U":"u U'","2L":"l L'","2F":"f F'","2R":"r R'","2B":"b B'","2D":"d D'"}};async function TA(i){const e=await(i.puzzleSpecificSimplifyOptions??i.puzzleSpecificSimplifyOptionsPromise);return e?{puzzleLoader:{puzzleSpecificSimplifyOptions:e}}:{}}new Array(24);async function Sp(i,e){return(await an(()=>import("./index-Dti57iVT.js"),[])).getPuzzleGeometryByDesc(i,{allMoves:!0,orientCenters:!0,addRotations:!0,...e})}async function o_(i,e){const t=Sp(i,e);return s_(t,`description: ${i}`)}var FA=1;function CA(i,e){const t=FA++;let n=null;const r=async()=>n??(n=o_(i)),s={id:`custom-${t}`,fullName:(e==null?void 0:e.fullName)??`Custom Puzzle (instance #${t})`,kpuzzle:r,svg:async()=>(await Sp(i)).generatesvg(),pg:async()=>Sp(i),puzzleSpecificSimplifyOptionsPromise:a_(r)};return e!=null&&e.inventedBy&&(s.inventedBy=e.inventedBy),e!=null&&e.inventionYear&&(s.inventionYear=e.inventionYear),s}var l_=new ra(Lp);Lp.experimentalIsPatternSolved=IA;function c_(i){const e=i.patternData.CENTERS.pieces[0],t=i.patternData.CENTERS.pieces[5],n=i.patternData.CENTERS.pieces[1];let r=n;return enew Array(6));function DA(){{const i=["","z","x","z'","x'","x2"].map(t=>Qe.fromString(t)),e=new Qe("y");for(const t of i){let n=l_.algToTransformation(t);for(let r=0;r<4;r++){n=n.applyAlg(e);const[s,a]=c_(n.toKPattern());fb[s][a]=n.invert()}}}return fb}function PA(i){const[e,t]=c_(i),n=DA()[e][t];return i.applyTransformation(n)}function IA(i,e){var t;return e.ignorePuzzleOrientation&&(i=PA(i)),e.ignoreCenterOrientation&&(i=new Lc(i.kpuzzle,{EDGES:i.patternData.EDGES,CORNERS:i.patternData.CORNERS,CENTERS:{pieces:i.patternData.CENTERS.pieces,orientation:new Array(6).fill(0)}})),!!((t=i.experimentalToTransformation())!=null&&t.isIdentityTransformation())}/** * @license * Copyright 2010-2024 Three.js Authors * SPDX-License-Identifier: MIT @@ -3817,7 +3817,7 @@ void main() { } -}`;class BP{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,n){if(this.texture===null){const r=new Bn,s=e.properties.get(r);s.__webglTexture=t.texture,(t.depthNear!=n.depthNear||t.depthFar!=n.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=r}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new Nr({vertexShader:PP,fragmentShader:IP,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new qn(new Vc(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}}class OP extends sa{constructor(e,t){super();const n=this;let r=null,s=1,a=null,o="local-floor",l=1,c=null,h=null,u=null,d=null,p=null,m=null;const v=new BP,b=t.getContextAttributes();let R=null,L=null;const _=[],S=[],D=new Ie;let T=null;const x=new mi;x.layers.enable(1),x.viewport=new un;const O=new mi;O.layers.enable(2),O.viewport=new un;const A=[x,O],E=new CL;E.layers.enable(1),E.layers.enable(2);let z=null,ie=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(X){let $=_[X];return $===void 0&&($=new n0,_[X]=$),$.getTargetRaySpace()},this.getControllerGrip=function(X){let $=_[X];return $===void 0&&($=new n0,_[X]=$),$.getGripSpace()},this.getHand=function(X){let $=_[X];return $===void 0&&($=new n0,_[X]=$),$.getHandSpace()};function J(X){const $=S.indexOf(X.inputSource);if($===-1)return;const De=_[$];De!==void 0&&(De.update(X.inputSource,X.frame,c||a),De.dispatchEvent({type:X.type,data:X.inputSource}))}function he(){r.removeEventListener("select",J),r.removeEventListener("selectstart",J),r.removeEventListener("selectend",J),r.removeEventListener("squeeze",J),r.removeEventListener("squeezestart",J),r.removeEventListener("squeezeend",J),r.removeEventListener("end",he),r.removeEventListener("inputsourceschange",me);for(let X=0;X<_.length;X++){const $=S[X];$!==null&&(S[X]=null,_[X].disconnect($))}z=null,ie=null,v.reset(),e.setRenderTarget(R),p=null,d=null,u=null,r=null,L=null,_e.stop(),n.isPresenting=!1,e.setPixelRatio(T),e.setSize(D.width,D.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(X){s=X,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(X){o=X,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(X){c=X},this.getBaseLayer=function(){return d!==null?d:p},this.getBinding=function(){return u},this.getFrame=function(){return m},this.getSession=function(){return r},this.setSession=async function(X){if(r=X,r!==null){if(R=e.getRenderTarget(),r.addEventListener("select",J),r.addEventListener("selectstart",J),r.addEventListener("selectend",J),r.addEventListener("squeeze",J),r.addEventListener("squeezestart",J),r.addEventListener("squeezeend",J),r.addEventListener("end",he),r.addEventListener("inputsourceschange",me),b.xrCompatible!==!0&&await t.makeXRCompatible(),T=e.getPixelRatio(),e.getSize(D),r.renderState.layers===void 0){const $={antialias:b.antialias,alpha:!0,depth:b.depth,stencil:b.stencil,framebufferScaleFactor:s};p=new XRWebGLLayer(r,t,$),r.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),L=new kr(p.framebufferWidth,p.framebufferHeight,{format:Ji,type:ea,colorSpace:e.outputColorSpace,stencilBuffer:b.stencil})}else{let $=null,De=null,Le=null;b.depth&&(Le=b.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,$=b.stencil?sl:jo,De=b.stencil?rl:il);const dt={colorFormat:t.RGBA8,depthFormat:Le,scaleFactor:s};u=new XRWebGLBinding(r,t),d=u.createProjectionLayer(dt),r.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),L=new kr(d.textureWidth,d.textureHeight,{format:Ji,type:ea,depthTexture:new XR(d.textureWidth,d.textureHeight,De,void 0,void 0,void 0,void 0,void 0,void 0,$),stencilBuffer:b.stencil,colorSpace:e.outputColorSpace,samples:b.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1})}L.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await r.requestReferenceSpace(o),_e.setContext(r),_e.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode};function me(X){for(let $=0;$=0&&(S[Le]=null,_[Le].disconnect(De))}for(let $=0;$=S.length){S.push(De),Le=at;break}else if(S[at]===null){S[at]=De,Le=at;break}if(Le===-1)break}const dt=_[Le];dt&&dt.connect(De)}}const oe=new V,Ue=new V;function ve(X,$,De){oe.setFromMatrixPosition($.matrixWorld),Ue.setFromMatrixPosition(De.matrixWorld);const Le=oe.distanceTo(Ue),dt=$.projectionMatrix.elements,at=De.projectionMatrix.elements,ut=dt[14]/(dt[10]-1),Y=dt[14]/(dt[10]+1),Te=(dt[9]+1)/dt[5],Se=(dt[9]-1)/dt[5],qe=(dt[8]-1)/dt[0],Ne=(at[8]+1)/at[0],ze=ut*qe,te=ut*Ne,Ye=Le/(-qe+Ne),Lt=Ye*-qe;$.matrixWorld.decompose(X.position,X.quaternion,X.scale),X.translateX(Lt),X.translateZ(Ye),X.matrixWorld.compose(X.position,X.quaternion,X.scale),X.matrixWorldInverse.copy(X.matrixWorld).invert();const H=ut+Ye,C=Y+Ye,de=ze-Lt,Pe=te+(Le-Lt),Ce=Te*Y/C*H,ue=Se*Y/C*H;X.projectionMatrix.makePerspective(de,Pe,Ce,ue,H,C),X.projectionMatrixInverse.copy(X.projectionMatrix).invert()}function We(X,$){$===null?X.matrixWorld.copy(X.matrix):X.matrixWorld.multiplyMatrices($.matrixWorld,X.matrix),X.matrixWorldInverse.copy(X.matrixWorld).invert()}this.updateCamera=function(X){if(r===null)return;v.texture!==null&&(X.near=v.depthNear,X.far=v.depthFar),E.near=O.near=x.near=X.near,E.far=O.far=x.far=X.far,(z!==E.near||ie!==E.far)&&(r.updateRenderState({depthNear:E.near,depthFar:E.far}),z=E.near,ie=E.far,x.near=z,x.far=ie,O.near=z,O.far=ie,x.updateProjectionMatrix(),O.updateProjectionMatrix(),X.updateProjectionMatrix());const $=X.parent,De=E.cameras;We(E,$);for(let Le=0;Le0&&(b.alphaTest.value=R.alphaTest);const L=e.get(R),_=L.envMap,S=L.envMapRotation;_&&(b.envMap.value=_,ao.copy(S),ao.x*=-1,ao.y*=-1,ao.z*=-1,_.isCubeTexture&&_.isRenderTargetTexture===!1&&(ao.y*=-1,ao.z*=-1),b.envMapRotation.value.setFromMatrix4(kP.makeRotationFromEuler(ao)),b.flipEnvMap.value=_.isCubeTexture&&_.isRenderTargetTexture===!1?-1:1,b.reflectivity.value=R.reflectivity,b.ior.value=R.ior,b.refractionRatio.value=R.refractionRatio),R.lightMap&&(b.lightMap.value=R.lightMap,b.lightMapIntensity.value=R.lightMapIntensity,t(R.lightMap,b.lightMapTransform)),R.aoMap&&(b.aoMap.value=R.aoMap,b.aoMapIntensity.value=R.aoMapIntensity,t(R.aoMap,b.aoMapTransform))}function a(b,R){b.diffuse.value.copy(R.color),b.opacity.value=R.opacity,R.map&&(b.map.value=R.map,t(R.map,b.mapTransform))}function o(b,R){b.dashSize.value=R.dashSize,b.totalSize.value=R.dashSize+R.gapSize,b.scale.value=R.scale}function l(b,R,L,_){b.diffuse.value.copy(R.color),b.opacity.value=R.opacity,b.size.value=R.size*L,b.scale.value=_*.5,R.map&&(b.map.value=R.map,t(R.map,b.uvTransform)),R.alphaMap&&(b.alphaMap.value=R.alphaMap,t(R.alphaMap,b.alphaMapTransform)),R.alphaTest>0&&(b.alphaTest.value=R.alphaTest)}function c(b,R){b.diffuse.value.copy(R.color),b.opacity.value=R.opacity,b.rotation.value=R.rotation,R.map&&(b.map.value=R.map,t(R.map,b.mapTransform)),R.alphaMap&&(b.alphaMap.value=R.alphaMap,t(R.alphaMap,b.alphaMapTransform)),R.alphaTest>0&&(b.alphaTest.value=R.alphaTest)}function h(b,R){b.specular.value.copy(R.specular),b.shininess.value=Math.max(R.shininess,1e-4)}function u(b,R){R.gradientMap&&(b.gradientMap.value=R.gradientMap)}function d(b,R){b.metalness.value=R.metalness,R.metalnessMap&&(b.metalnessMap.value=R.metalnessMap,t(R.metalnessMap,b.metalnessMapTransform)),b.roughness.value=R.roughness,R.roughnessMap&&(b.roughnessMap.value=R.roughnessMap,t(R.roughnessMap,b.roughnessMapTransform)),R.envMap&&(b.envMapIntensity.value=R.envMapIntensity)}function p(b,R,L){b.ior.value=R.ior,R.sheen>0&&(b.sheenColor.value.copy(R.sheenColor).multiplyScalar(R.sheen),b.sheenRoughness.value=R.sheenRoughness,R.sheenColorMap&&(b.sheenColorMap.value=R.sheenColorMap,t(R.sheenColorMap,b.sheenColorMapTransform)),R.sheenRoughnessMap&&(b.sheenRoughnessMap.value=R.sheenRoughnessMap,t(R.sheenRoughnessMap,b.sheenRoughnessMapTransform))),R.clearcoat>0&&(b.clearcoat.value=R.clearcoat,b.clearcoatRoughness.value=R.clearcoatRoughness,R.clearcoatMap&&(b.clearcoatMap.value=R.clearcoatMap,t(R.clearcoatMap,b.clearcoatMapTransform)),R.clearcoatRoughnessMap&&(b.clearcoatRoughnessMap.value=R.clearcoatRoughnessMap,t(R.clearcoatRoughnessMap,b.clearcoatRoughnessMapTransform)),R.clearcoatNormalMap&&(b.clearcoatNormalMap.value=R.clearcoatNormalMap,t(R.clearcoatNormalMap,b.clearcoatNormalMapTransform),b.clearcoatNormalScale.value.copy(R.clearcoatNormalScale),R.side===Bi&&b.clearcoatNormalScale.value.negate())),R.dispersion>0&&(b.dispersion.value=R.dispersion),R.iridescence>0&&(b.iridescence.value=R.iridescence,b.iridescenceIOR.value=R.iridescenceIOR,b.iridescenceThicknessMinimum.value=R.iridescenceThicknessRange[0],b.iridescenceThicknessMaximum.value=R.iridescenceThicknessRange[1],R.iridescenceMap&&(b.iridescenceMap.value=R.iridescenceMap,t(R.iridescenceMap,b.iridescenceMapTransform)),R.iridescenceThicknessMap&&(b.iridescenceThicknessMap.value=R.iridescenceThicknessMap,t(R.iridescenceThicknessMap,b.iridescenceThicknessMapTransform))),R.transmission>0&&(b.transmission.value=R.transmission,b.transmissionSamplerMap.value=L.texture,b.transmissionSamplerSize.value.set(L.width,L.height),R.transmissionMap&&(b.transmissionMap.value=R.transmissionMap,t(R.transmissionMap,b.transmissionMapTransform)),b.thickness.value=R.thickness,R.thicknessMap&&(b.thicknessMap.value=R.thicknessMap,t(R.thicknessMap,b.thicknessMapTransform)),b.attenuationDistance.value=R.attenuationDistance,b.attenuationColor.value.copy(R.attenuationColor)),R.anisotropy>0&&(b.anisotropyVector.value.set(R.anisotropy*Math.cos(R.anisotropyRotation),R.anisotropy*Math.sin(R.anisotropyRotation)),R.anisotropyMap&&(b.anisotropyMap.value=R.anisotropyMap,t(R.anisotropyMap,b.anisotropyMapTransform))),b.specularIntensity.value=R.specularIntensity,b.specularColor.value.copy(R.specularColor),R.specularColorMap&&(b.specularColorMap.value=R.specularColorMap,t(R.specularColorMap,b.specularColorMapTransform)),R.specularIntensityMap&&(b.specularIntensityMap.value=R.specularIntensityMap,t(R.specularIntensityMap,b.specularIntensityMapTransform))}function m(b,R){R.matcap&&(b.matcap.value=R.matcap)}function v(b,R){const L=e.get(R).light;b.referencePosition.value.setFromMatrixPosition(L.matrixWorld),b.nearDistance.value=L.shadow.camera.near,b.farDistance.value=L.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:r}}function zP(i,e,t,n){let r={},s={},a=[];const o=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function l(L,_){const S=_.program;n.uniformBlockBinding(L,S)}function c(L,_){let S=r[L.id];S===void 0&&(m(L),S=h(L),r[L.id]=S,L.addEventListener("dispose",b));const D=_.program;n.updateUBOMapping(L,D);const T=e.render.frame;s[L.id]!==T&&(d(L),s[L.id]=T)}function h(L){const _=u();L.__bindingPointIndex=_;const S=i.createBuffer(),D=L.__size,T=L.usage;return i.bindBuffer(i.UNIFORM_BUFFER,S),i.bufferData(i.UNIFORM_BUFFER,D,T),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,_,S),S}function u(){for(let L=0;L0&&(S+=D-T),L.__size=S,L.__cache={},this}function v(L){const _={boundary:0,storage:0};return typeof L=="number"||typeof L=="boolean"?(_.boundary=4,_.storage=4):L.isVector2?(_.boundary=8,_.storage=8):L.isVector3||L.isColor?(_.boundary=16,_.storage=12):L.isVector4?(_.boundary=16,_.storage=16):L.isMatrix3?(_.boundary=48,_.storage=48):L.isMatrix4?(_.boundary=64,_.storage=64):L.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",L),_}function b(L){const _=L.target;_.removeEventListener("dispose",b);const S=a.indexOf(_.__bindingPointIndex);a.splice(S,1),i.deleteBuffer(r[_.id]),delete r[_.id],delete s[_.id]}function R(){for(const L in r)i.deleteBuffer(r[L]);a=[],r={},s={}}return{bind:l,update:c,dispose:R}}class VP{constructor(e={}){const{canvas:t=xL(),context:n=null,depth:r=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1}=e;this.isWebGLRenderer=!0;let d;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");d=n.getContextAttributes().alpha}else d=a;const p=new Uint32Array(4),m=new Int32Array(4);let v=null,b=null;const R=[],L=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=vr,this.toneMapping=Xs,this.toneMappingExposure=1;const _=this;let S=!1,D=0,T=0,x=null,O=-1,A=null;const E=new un,z=new un;let ie=null;const J=new ht(0);let he=0,me=t.width,oe=t.height,Ue=1,ve=null,We=null;const je=new un(0,0,me,oe),q=new un(0,0,me,oe);let le=!1;const _e=new ad;let X=!1,$=!1;const De=new Mt,Le=new V,dt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let at=!1;function ut(){return x===null?Ue:1}let Y=n;function Te(B,ee){return t.getContext(B,ee)}try{const B={alpha:!0,depth:r,stencil:s,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Fm}`),t.addEventListener("webglcontextlost",st,!1),t.addEventListener("webglcontextrestored",Ae,!1),t.addEventListener("webglcontextcreationerror",Fe,!1),Y===null){const ee="webgl2";if(Y=Te(ee,B),Y===null)throw Te(ee)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(B){throw console.error("THREE.WebGLRenderer: "+B.message),B}let Se,qe,Ne,ze,te,Ye,Lt,H,C,de,Pe,Ce,ue,ot,$e,Oe,wt,Ve,rt,Tt,gt,Xe,At,Pt;function on(){Se=new QC(Y),Se.init(),Xe=new FL(Y,Se),qe=new XC(Y,Se,e,Xe),Ne=new FP(Y),ze=new nD(Y),te=new vP,Ye=new CP(Y,Se,Ne,te,qe,Xe,ze),Lt=new YC(_),H=new JC(_),C=new cT(Y),At=new ZC(Y,C),de=new eD(Y,C,ze,At),Pe=new rD(Y,de,C,ze),rt=new iD(Y,qe,Ye),Oe=new jC(te),Ce=new RP(_,Lt,H,Se,qe,At,Oe),ue=new NP(_,te),ot=new UP,$e=new wP(Se),Ve=new GC(_,Lt,H,Ne,Pe,d,l),wt=new TP(_,Pe,qe),Pt=new zP(Y,ze,qe,Ne),Tt=new qC(Y,Se,ze),gt=new tD(Y,Se,ze),ze.programs=Ce.programs,_.capabilities=qe,_.extensions=Se,_.properties=te,_.renderLists=ot,_.shadowMap=wt,_.state=Ne,_.info=ze}on();const K=new OP(_,Y);this.xr=K,this.getContext=function(){return Y},this.getContextAttributes=function(){return Y.getContextAttributes()},this.forceContextLoss=function(){const B=Se.get("WEBGL_lose_context");B&&B.loseContext()},this.forceContextRestore=function(){const B=Se.get("WEBGL_lose_context");B&&B.restoreContext()},this.getPixelRatio=function(){return Ue},this.setPixelRatio=function(B){B!==void 0&&(Ue=B,this.setSize(me,oe,!1))},this.getSize=function(B){return B.set(me,oe)},this.setSize=function(B,ee,pe=!0){if(K.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}me=B,oe=ee,t.width=Math.floor(B*Ue),t.height=Math.floor(ee*Ue),pe===!0&&(t.style.width=B+"px",t.style.height=ee+"px"),this.setViewport(0,0,B,ee)},this.getDrawingBufferSize=function(B){return B.set(me*Ue,oe*Ue).floor()},this.setDrawingBufferSize=function(B,ee,pe){me=B,oe=ee,Ue=pe,t.width=Math.floor(B*pe),t.height=Math.floor(ee*pe),this.setViewport(0,0,B,ee)},this.getCurrentViewport=function(B){return B.copy(E)},this.getViewport=function(B){return B.copy(je)},this.setViewport=function(B,ee,pe,Re){B.isVector4?je.set(B.x,B.y,B.z,B.w):je.set(B,ee,pe,Re),Ne.viewport(E.copy(je).multiplyScalar(Ue).round())},this.getScissor=function(B){return B.copy(q)},this.setScissor=function(B,ee,pe,Re){B.isVector4?q.set(B.x,B.y,B.z,B.w):q.set(B,ee,pe,Re),Ne.scissor(z.copy(q).multiplyScalar(Ue).round())},this.getScissorTest=function(){return le},this.setScissorTest=function(B){Ne.setScissorTest(le=B)},this.setOpaqueSort=function(B){ve=B},this.setTransparentSort=function(B){We=B},this.getClearColor=function(B){return B.copy(Ve.getClearColor())},this.setClearColor=function(){Ve.setClearColor.apply(Ve,arguments)},this.getClearAlpha=function(){return Ve.getClearAlpha()},this.setClearAlpha=function(){Ve.setClearAlpha.apply(Ve,arguments)},this.clear=function(B=!0,ee=!0,pe=!0){let Re=0;if(B){let ae=!1;if(x!==null){const He=x.texture.format;ae=He===kR||He===OR||He===BR}if(ae){const He=x.texture.type,tt=He===ea||He===il||He===Qh||He===rl||He===DR||He===PR,ft=Ve.getClearColor(),it=Ve.getClearAlpha(),Rt=ft.r,Ut=ft.g,vt=ft.b;tt?(p[0]=Rt,p[1]=Ut,p[2]=vt,p[3]=it,Y.clearBufferuiv(Y.COLOR,0,p)):(m[0]=Rt,m[1]=Ut,m[2]=vt,m[3]=it,Y.clearBufferiv(Y.COLOR,0,m))}else Re|=Y.COLOR_BUFFER_BIT}ee&&(Re|=Y.DEPTH_BUFFER_BIT),pe&&(Re|=Y.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),Y.clear(Re)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",st,!1),t.removeEventListener("webglcontextrestored",Ae,!1),t.removeEventListener("webglcontextcreationerror",Fe,!1),ot.dispose(),$e.dispose(),te.dispose(),Lt.dispose(),H.dispose(),Pe.dispose(),At.dispose(),Pt.dispose(),Ce.dispose(),K.dispose(),K.removeEventListener("sessionstart",ei),K.removeEventListener("sessionend",ti),Vn.stop()};function st(B){B.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),S=!0}function Ae(){console.log("THREE.WebGLRenderer: Context Restored."),S=!1;const B=ze.autoReset,ee=wt.enabled,pe=wt.autoUpdate,Re=wt.needsUpdate,ae=wt.type;on(),ze.autoReset=B,wt.enabled=ee,wt.autoUpdate=pe,wt.needsUpdate=Re,wt.type=ae}function Fe(B){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",B.statusMessage)}function Ze(B){const ee=B.target;ee.removeEventListener("dispose",Ze),bt(ee)}function bt(B){Ht(B),te.remove(B)}function Ht(B){const ee=te.get(B).programs;ee!==void 0&&(ee.forEach(function(pe){Ce.releaseProgram(pe)}),B.isShaderMaterial&&Ce.releaseShaderCache(B))}this.renderBufferDirect=function(B,ee,pe,Re,ae,He){ee===null&&(ee=dt);const tt=ae.isMesh&&ae.matrixWorld.determinant()<0,ft=ps(B,ee,pe,Re,ae);Ne.setMaterial(Re,tt);let it=pe.index,Rt=1;if(Re.wireframe===!0){if(it=de.getWireframeAttribute(pe),it===void 0)return;Rt=2}const Ut=pe.drawRange,vt=pe.attributes.position;let Kt=Ut.start*Rt,mn=(Ut.start+Ut.count)*Rt;He!==null&&(Kt=Math.max(Kt,He.start*Rt),mn=Math.min(mn,(He.start+He.count)*Rt)),it!==null?(Kt=Math.max(Kt,0),mn=Math.min(mn,it.count)):vt!=null&&(Kt=Math.max(Kt,0),mn=Math.min(mn,vt.count));const k=mn-Kt;if(k<0||k===1/0)return;At.setup(ae,Re,ft,pe,it);let G,se=Tt;if(it!==null&&(G=C.get(it),se=gt,se.setIndex(G)),ae.isMesh)Re.wireframe===!0?(Ne.setLineWidth(Re.wireframeLinewidth*ut()),se.setMode(Y.LINES)):se.setMode(Y.TRIANGLES);else if(ae.isLine){let re=Re.linewidth;re===void 0&&(re=1),Ne.setLineWidth(re*ut()),ae.isLineSegments?se.setMode(Y.LINES):ae.isLineLoop?se.setMode(Y.LINE_LOOP):se.setMode(Y.LINE_STRIP)}else ae.isPoints?se.setMode(Y.POINTS):ae.isSprite&&se.setMode(Y.TRIANGLES);if(ae.isBatchedMesh)ae._multiDrawInstances!==null?se.renderMultiDrawInstances(ae._multiDrawStarts,ae._multiDrawCounts,ae._multiDrawCount,ae._multiDrawInstances):se.renderMultiDraw(ae._multiDrawStarts,ae._multiDrawCounts,ae._multiDrawCount);else if(ae.isInstancedMesh)se.renderInstances(Kt,k,ae.count);else if(pe.isInstancedBufferGeometry){const re=pe._maxInstanceCount!==void 0?pe._maxInstanceCount:1/0,Me=Math.min(pe.instanceCount,re);se.renderInstances(Kt,k,Me)}else se.render(Kt,k)};function Vt(B,ee,pe){B.transparent===!0&&B.side===ns&&B.forceSinglePass===!1?(B.side=Bi,B.needsUpdate=!0,Gr(B,ee,pe),B.side=Js,B.needsUpdate=!0,Gr(B,ee,pe),B.side=ns):Gr(B,ee,pe)}this.compile=function(B,ee,pe=null){pe===null&&(pe=B),b=$e.get(pe),b.init(ee),L.push(b),pe.traverseVisible(function(ae){ae.isLight&&ae.layers.test(ee.layers)&&(b.pushLight(ae),ae.castShadow&&b.pushShadow(ae))}),B!==pe&&B.traverseVisible(function(ae){ae.isLight&&ae.layers.test(ee.layers)&&(b.pushLight(ae),ae.castShadow&&b.pushShadow(ae))}),b.setupLights();const Re=new Set;return B.traverse(function(ae){const He=ae.material;if(He)if(Array.isArray(He))for(let tt=0;tt{function He(){if(Re.forEach(function(tt){te.get(tt).currentProgram.isReady()&&Re.delete(tt)}),Re.size===0){ae(B);return}setTimeout(He,10)}Se.get("KHR_parallel_shader_compile")!==null?He():setTimeout(He,10)})};let Xt=null;function Wt(B){Xt&&Xt(B)}function ei(){Vn.stop()}function ti(){Vn.start()}const Vn=new SL;Vn.setAnimationLoop(Wt),typeof self<"u"&&Vn.setContext(self),this.setAnimationLoop=function(B){Xt=B,K.setAnimationLoop(B),B===null?Vn.stop():Vn.start()},K.addEventListener("sessionstart",ei),K.addEventListener("sessionend",ti),this.render=function(B,ee){if(ee!==void 0&&ee.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(S===!0)return;if(B.matrixWorldAutoUpdate===!0&&B.updateMatrixWorld(),ee.parent===null&&ee.matrixWorldAutoUpdate===!0&&ee.updateMatrixWorld(),K.enabled===!0&&K.isPresenting===!0&&(K.cameraAutoUpdate===!0&&K.updateCamera(ee),ee=K.getCamera()),B.isScene===!0&&B.onBeforeRender(_,B,ee,x),b=$e.get(B,L.length),b.init(ee),L.push(b),De.multiplyMatrices(ee.projectionMatrix,ee.matrixWorldInverse),_e.setFromProjectionMatrix(De),$=this.localClippingEnabled,X=Oe.init(this.clippingPlanes,$),v=ot.get(B,R.length),v.init(),R.push(v),K.enabled===!0&&K.isPresenting===!0){const He=_.xr.getDepthSensingMesh();He!==null&&Ei(He,ee,-1/0,_.sortObjects)}Ei(B,ee,0,_.sortObjects),v.finish(),_.sortObjects===!0&&v.sort(ve,We),at=K.enabled===!1||K.isPresenting===!1||K.hasDepthSensing()===!1,at&&Ve.addToRenderList(v,B),this.info.render.frame++,X===!0&&Oe.beginShadows();const pe=b.state.shadowsArray;wt.render(pe,B,ee),X===!0&&Oe.endShadows(),this.info.autoReset===!0&&this.info.reset();const Re=v.opaque,ae=v.transmissive;if(b.setupLights(),ee.isArrayCamera){const He=ee.cameras;if(ae.length>0)for(let tt=0,ft=He.length;tt0&&Vi(Re,ae,B,ee),at&&Ve.render(B),zi(v,B,ee);x!==null&&(Ye.updateMultisampleRenderTarget(x),Ye.updateRenderTargetMipmap(x)),B.isScene===!0&&B.onAfterRender(_,B,ee),At.resetDefaultState(),O=-1,A=null,L.pop(),L.length>0?(b=L[L.length-1],X===!0&&Oe.setGlobalState(_.clippingPlanes,b.state.camera)):b=null,R.pop(),R.length>0?v=R[R.length-1]:v=null};function Ei(B,ee,pe,Re){if(B.visible===!1)return;if(B.layers.test(ee.layers)){if(B.isGroup)pe=B.renderOrder;else if(B.isLOD)B.autoUpdate===!0&&B.update(ee);else if(B.isLight)b.pushLight(B),B.castShadow&&b.pushShadow(B);else if(B.isSprite){if(!B.frustumCulled||_e.intersectsSprite(B)){Re&&Le.setFromMatrixPosition(B.matrixWorld).applyMatrix4(De);const tt=Pe.update(B),ft=B.material;ft.visible&&v.push(B,tt,ft,pe,Le.z,null)}}else if((B.isMesh||B.isLine||B.isPoints)&&(!B.frustumCulled||_e.intersectsObject(B))){const tt=Pe.update(B),ft=B.material;if(Re&&(B.boundingSphere!==void 0?(B.boundingSphere===null&&B.computeBoundingSphere(),Le.copy(B.boundingSphere.center)):(tt.boundingSphere===null&&tt.computeBoundingSphere(),Le.copy(tt.boundingSphere.center)),Le.applyMatrix4(B.matrixWorld).applyMatrix4(De)),Array.isArray(ft)){const it=tt.groups;for(let Rt=0,Ut=it.length;Rt0&&er(ae,ee,pe),He.length>0&&er(He,ee,pe),tt.length>0&&er(tt,ee,pe),Ne.buffers.depth.setTest(!0),Ne.buffers.depth.setMask(!0),Ne.buffers.color.setMask(!0),Ne.setPolygonOffset(!1)}function Vi(B,ee,pe,Re){if((pe.isScene===!0?pe.overrideMaterial:null)!==null)return;b.state.transmissionRenderTarget[Re.id]===void 0&&(b.state.transmissionRenderTarget[Re.id]=new kr(1,1,{generateMipmaps:!0,type:Se.has("EXT_color_buffer_half_float")||Se.has("EXT_color_buffer_float")?id:ea,minFilter:rs,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:sn.workingColorSpace}));const He=b.state.transmissionRenderTarget[Re.id],tt=Re.viewport||E;He.setSize(tt.z,tt.w);const ft=_.getRenderTarget();_.setRenderTarget(He),_.getClearColor(J),he=_.getClearAlpha(),he<1&&_.setClearColor(16777215,.5),at?Ve.render(pe):_.clear();const it=_.toneMapping;_.toneMapping=Xs;const Rt=Re.viewport;if(Re.viewport!==void 0&&(Re.viewport=void 0),b.setupLightsView(Re),X===!0&&Oe.setGlobalState(_.clippingPlanes,Re),er(B,pe,Re),Ye.updateMultisampleRenderTarget(He),Ye.updateRenderTargetMipmap(He),Se.has("WEBGL_multisampled_render_to_texture")===!1){let Ut=!1;for(let vt=0,Kt=ee.length;vt0),vt=!!pe.morphAttributes.position,Kt=!!pe.morphAttributes.normal,mn=!!pe.morphAttributes.color;let k=Xs;Re.toneMapped&&(x===null||x.isXRRenderTarget===!0)&&(k=_.toneMapping);const G=pe.morphAttributes.position||pe.morphAttributes.normal||pe.morphAttributes.color,se=G!==void 0?G.length:0,re=te.get(Re),Me=b.state.lights;if(X===!0&&($===!0||B!==A)){const pn=B===A&&Re.id===O;Oe.setState(Re,B,pn)}let ge=!1;Re.version===re.__version?(re.needsLights&&re.lightsStateVersion!==Me.state.version||re.outputColorSpace!==ft||ae.isBatchedMesh&&re.batching===!1||!ae.isBatchedMesh&&re.batching===!0||ae.isBatchedMesh&&re.batchingColor===!0&&ae.colorTexture===null||ae.isBatchedMesh&&re.batchingColor===!1&&ae.colorTexture!==null||ae.isInstancedMesh&&re.instancing===!1||!ae.isInstancedMesh&&re.instancing===!0||ae.isSkinnedMesh&&re.skinning===!1||!ae.isSkinnedMesh&&re.skinning===!0||ae.isInstancedMesh&&re.instancingColor===!0&&ae.instanceColor===null||ae.isInstancedMesh&&re.instancingColor===!1&&ae.instanceColor!==null||ae.isInstancedMesh&&re.instancingMorph===!0&&ae.morphTexture===null||ae.isInstancedMesh&&re.instancingMorph===!1&&ae.morphTexture!==null||re.envMap!==it||Re.fog===!0&&re.fog!==He||re.numClippingPlanes!==void 0&&(re.numClippingPlanes!==Oe.numPlanes||re.numIntersection!==Oe.numIntersection)||re.vertexAlphas!==Rt||re.vertexTangents!==Ut||re.morphTargets!==vt||re.morphNormals!==Kt||re.morphColors!==mn||re.toneMapping!==k||re.morphTargetsCount!==se)&&(ge=!0):(ge=!0,re.__version=Re.version);let ke=re.currentProgram;ge===!0&&(ke=Gr(Re,ee,ae));let pt=!1,Ke=!1,_t=!1;const Ft=ke.getUniforms(),En=re.uniforms;if(Ne.useProgram(ke.program)&&(pt=!0,Ke=!0,_t=!0),Re.id!==O&&(O=Re.id,Ke=!0),pt||A!==B){Ft.setValue(Y,"projectionMatrix",B.projectionMatrix),Ft.setValue(Y,"viewMatrix",B.matrixWorldInverse);const pn=Ft.map.cameraPosition;pn!==void 0&&pn.setValue(Y,Le.setFromMatrixPosition(B.matrixWorld)),qe.logarithmicDepthBuffer&&Ft.setValue(Y,"logDepthBufFC",2/(Math.log(B.far+1)/Math.LN2)),(Re.isMeshPhongMaterial||Re.isMeshToonMaterial||Re.isMeshLambertMaterial||Re.isMeshBasicMaterial||Re.isMeshStandardMaterial||Re.isShaderMaterial)&&Ft.setValue(Y,"isOrthographic",B.isOrthographicCamera===!0),A!==B&&(A=B,Ke=!0,_t=!0)}if(ae.isSkinnedMesh){Ft.setOptional(Y,ae,"bindMatrix"),Ft.setOptional(Y,ae,"bindMatrixInverse");const pn=ae.skeleton;pn&&(pn.boneTexture===null&&pn.computeBoneTexture(),Ft.setValue(Y,"boneTexture",pn.boneTexture,Ye))}ae.isBatchedMesh&&(Ft.setOptional(Y,ae,"batchingTexture"),Ft.setValue(Y,"batchingTexture",ae._matricesTexture,Ye),Ft.setOptional(Y,ae,"batchingColorTexture"),ae._colorsTexture!==null&&Ft.setValue(Y,"batchingColorTexture",ae._colorsTexture,Ye));const Hn=pe.morphAttributes;if((Hn.position!==void 0||Hn.normal!==void 0||Hn.color!==void 0)&&rt.update(ae,pe,ke),(Ke||re.receiveShadow!==ae.receiveShadow)&&(re.receiveShadow=ae.receiveShadow,Ft.setValue(Y,"receiveShadow",ae.receiveShadow)),Re.isMeshGouraudMaterial&&Re.envMap!==null&&(En.envMap.value=it,En.flipEnvMap.value=it.isCubeTexture&&it.isRenderTargetTexture===!1?-1:1),Re.isMeshStandardMaterial&&Re.envMap===null&&ee.environment!==null&&(En.envMapIntensity.value=ee.environmentIntensity),Ke&&(Ft.setValue(Y,"toneMappingExposure",_.toneMappingExposure),re.needsLights&&Ya(En,_t),He&&Re.fog===!0&&ue.refreshFogUniforms(En,He),ue.refreshMaterialUniforms(En,Re,Ue,oe,b.state.transmissionRenderTarget[B.id]),ip.upload(Y,fs(re),En,Ye)),Re.isShaderMaterial&&Re.uniformsNeedUpdate===!0&&(ip.upload(Y,fs(re),En,Ye),Re.uniformsNeedUpdate=!1),Re.isSpriteMaterial&&Ft.setValue(Y,"center",ae.center),Ft.setValue(Y,"modelViewMatrix",ae.modelViewMatrix),Ft.setValue(Y,"normalMatrix",ae.normalMatrix),Ft.setValue(Y,"modelMatrix",ae.matrixWorld),Re.isShaderMaterial||Re.isRawShaderMaterial){const pn=Re.uniformsGroups;for(let Xn=0,xi=pn.length;Xn0&&Ye.useMultisampledRTT(B)===!1?ae=te.get(B).__webglMultisampledFramebuffer:Array.isArray(Ut)?ae=Ut[pe]:ae=Ut,E.copy(B.viewport),z.copy(B.scissor),ie=B.scissorTest}else E.copy(je).multiplyScalar(Ue).floor(),z.copy(q).multiplyScalar(Ue).floor(),ie=le;if(Ne.bindFramebuffer(Y.FRAMEBUFFER,ae)&&Re&&Ne.drawBuffers(B,ae),Ne.viewport(E),Ne.scissor(z),Ne.setScissorTest(ie),He){const it=te.get(B.texture);Y.framebufferTexture2D(Y.FRAMEBUFFER,Y.COLOR_ATTACHMENT0,Y.TEXTURE_CUBE_MAP_POSITIVE_X+ee,it.__webglTexture,pe)}else if(tt){const it=te.get(B.texture),Rt=ee||0;Y.framebufferTextureLayer(Y.FRAMEBUFFER,Y.COLOR_ATTACHMENT0,it.__webglTexture,pe||0,Rt)}O=-1},this.readRenderTargetPixels=function(B,ee,pe,Re,ae,He,tt){if(!(B&&B.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ft=te.get(B).__webglFramebuffer;if(B.isWebGLCubeRenderTarget&&tt!==void 0&&(ft=ft[tt]),ft){Ne.bindFramebuffer(Y.FRAMEBUFFER,ft);try{const it=B.texture,Rt=it.format,Ut=it.type;if(!qe.textureFormatReadable(Rt)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!qe.textureTypeReadable(Ut)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}ee>=0&&ee<=B.width-Re&&pe>=0&&pe<=B.height-ae&&Y.readPixels(ee,pe,Re,ae,Xe.convert(Rt),Xe.convert(Ut),He)}finally{const it=x!==null?te.get(x).__webglFramebuffer:null;Ne.bindFramebuffer(Y.FRAMEBUFFER,it)}}},this.readRenderTargetPixelsAsync=async function(B,ee,pe,Re,ae,He,tt){if(!(B&&B.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let ft=te.get(B).__webglFramebuffer;if(B.isWebGLCubeRenderTarget&&tt!==void 0&&(ft=ft[tt]),ft){Ne.bindFramebuffer(Y.FRAMEBUFFER,ft);try{const it=B.texture,Rt=it.format,Ut=it.type;if(!qe.textureFormatReadable(Rt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!qe.textureTypeReadable(Ut))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(ee>=0&&ee<=B.width-Re&&pe>=0&&pe<=B.height-ae){const vt=Y.createBuffer();Y.bindBuffer(Y.PIXEL_PACK_BUFFER,vt),Y.bufferData(Y.PIXEL_PACK_BUFFER,He.byteLength,Y.STREAM_READ),Y.readPixels(ee,pe,Re,ae,Xe.convert(Rt),Xe.convert(Ut),0),Y.flush();const Kt=Y.fenceSync(Y.SYNC_GPU_COMMANDS_COMPLETE,0);await PE(Y,Kt,4);try{Y.bindBuffer(Y.PIXEL_PACK_BUFFER,vt),Y.getBufferSubData(Y.PIXEL_PACK_BUFFER,0,He)}finally{Y.deleteBuffer(vt),Y.deleteSync(Kt)}return He}}finally{const it=x!==null?te.get(x).__webglFramebuffer:null;Ne.bindFramebuffer(Y.FRAMEBUFFER,it)}}},this.copyFramebufferToTexture=function(B,ee=null,pe=0){B.isTexture!==!0&&(console.warn("WebGLRenderer: copyFramebufferToTexture function signature has changed."),ee=arguments[0]||null,B=arguments[1]);const Re=Math.pow(2,-pe),ae=Math.floor(B.image.width*Re),He=Math.floor(B.image.height*Re),tt=ee!==null?ee.x:0,ft=ee!==null?ee.y:0;Ye.setTexture2D(B,0),Y.copyTexSubImage2D(Y.TEXTURE_2D,pe,0,0,tt,ft,ae,He),Ne.unbindTexture()},this.copyTextureToTexture=function(B,ee,pe=null,Re=null,ae=0){B.isTexture!==!0&&(console.warn("WebGLRenderer: copyTextureToTexture function signature has changed."),Re=arguments[0]||null,B=arguments[1],ee=arguments[2],ae=arguments[3]||0,pe=null);let He,tt,ft,it,Rt,Ut;pe!==null?(He=pe.max.x-pe.min.x,tt=pe.max.y-pe.min.y,ft=pe.min.x,it=pe.min.y):(He=B.image.width,tt=B.image.height,ft=0,it=0),Re!==null?(Rt=Re.x,Ut=Re.y):(Rt=0,Ut=0);const vt=Xe.convert(ee.format),Kt=Xe.convert(ee.type);Ye.setTexture2D(ee,0),Y.pixelStorei(Y.UNPACK_FLIP_Y_WEBGL,ee.flipY),Y.pixelStorei(Y.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ee.premultiplyAlpha),Y.pixelStorei(Y.UNPACK_ALIGNMENT,ee.unpackAlignment);const mn=Y.getParameter(Y.UNPACK_ROW_LENGTH),k=Y.getParameter(Y.UNPACK_IMAGE_HEIGHT),G=Y.getParameter(Y.UNPACK_SKIP_PIXELS),se=Y.getParameter(Y.UNPACK_SKIP_ROWS),re=Y.getParameter(Y.UNPACK_SKIP_IMAGES),Me=B.isCompressedTexture?B.mipmaps[ae]:B.image;Y.pixelStorei(Y.UNPACK_ROW_LENGTH,Me.width),Y.pixelStorei(Y.UNPACK_IMAGE_HEIGHT,Me.height),Y.pixelStorei(Y.UNPACK_SKIP_PIXELS,ft),Y.pixelStorei(Y.UNPACK_SKIP_ROWS,it),B.isDataTexture?Y.texSubImage2D(Y.TEXTURE_2D,ae,Rt,Ut,He,tt,vt,Kt,Me.data):B.isCompressedTexture?Y.compressedTexSubImage2D(Y.TEXTURE_2D,ae,Rt,Ut,Me.width,Me.height,vt,Me.data):Y.texSubImage2D(Y.TEXTURE_2D,ae,Rt,Ut,vt,Kt,Me),Y.pixelStorei(Y.UNPACK_ROW_LENGTH,mn),Y.pixelStorei(Y.UNPACK_IMAGE_HEIGHT,k),Y.pixelStorei(Y.UNPACK_SKIP_PIXELS,G),Y.pixelStorei(Y.UNPACK_SKIP_ROWS,se),Y.pixelStorei(Y.UNPACK_SKIP_IMAGES,re),ae===0&&ee.generateMipmaps&&Y.generateMipmap(Y.TEXTURE_2D),Ne.unbindTexture()},this.copyTextureToTexture3D=function(B,ee,pe=null,Re=null,ae=0){B.isTexture!==!0&&(console.warn("WebGLRenderer: copyTextureToTexture3D function signature has changed."),pe=arguments[0]||null,Re=arguments[1]||null,B=arguments[2],ee=arguments[3],ae=arguments[4]||0);let He,tt,ft,it,Rt,Ut,vt,Kt,mn;const k=B.isCompressedTexture?B.mipmaps[ae]:B.image;pe!==null?(He=pe.max.x-pe.min.x,tt=pe.max.y-pe.min.y,ft=pe.max.z-pe.min.z,it=pe.min.x,Rt=pe.min.y,Ut=pe.min.z):(He=k.width,tt=k.height,ft=k.depth,it=0,Rt=0,Ut=0),Re!==null?(vt=Re.x,Kt=Re.y,mn=Re.z):(vt=0,Kt=0,mn=0);const G=Xe.convert(ee.format),se=Xe.convert(ee.type);let re;if(ee.isData3DTexture)Ye.setTexture3D(ee,0),re=Y.TEXTURE_3D;else if(ee.isDataArrayTexture||ee.isCompressedArrayTexture)Ye.setTexture2DArray(ee,0),re=Y.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}Y.pixelStorei(Y.UNPACK_FLIP_Y_WEBGL,ee.flipY),Y.pixelStorei(Y.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ee.premultiplyAlpha),Y.pixelStorei(Y.UNPACK_ALIGNMENT,ee.unpackAlignment);const Me=Y.getParameter(Y.UNPACK_ROW_LENGTH),ge=Y.getParameter(Y.UNPACK_IMAGE_HEIGHT),ke=Y.getParameter(Y.UNPACK_SKIP_PIXELS),pt=Y.getParameter(Y.UNPACK_SKIP_ROWS),Ke=Y.getParameter(Y.UNPACK_SKIP_IMAGES);Y.pixelStorei(Y.UNPACK_ROW_LENGTH,k.width),Y.pixelStorei(Y.UNPACK_IMAGE_HEIGHT,k.height),Y.pixelStorei(Y.UNPACK_SKIP_PIXELS,it),Y.pixelStorei(Y.UNPACK_SKIP_ROWS,Rt),Y.pixelStorei(Y.UNPACK_SKIP_IMAGES,Ut),B.isDataTexture||B.isData3DTexture?Y.texSubImage3D(re,ae,vt,Kt,mn,He,tt,ft,G,se,k.data):ee.isCompressedArrayTexture?Y.compressedTexSubImage3D(re,ae,vt,Kt,mn,He,tt,ft,G,k.data):Y.texSubImage3D(re,ae,vt,Kt,mn,He,tt,ft,G,se,k),Y.pixelStorei(Y.UNPACK_ROW_LENGTH,Me),Y.pixelStorei(Y.UNPACK_IMAGE_HEIGHT,ge),Y.pixelStorei(Y.UNPACK_SKIP_PIXELS,ke),Y.pixelStorei(Y.UNPACK_SKIP_ROWS,pt),Y.pixelStorei(Y.UNPACK_SKIP_IMAGES,Ke),ae===0&&ee.generateMipmaps&&Y.generateMipmap(re),Ne.unbindTexture()},this.initRenderTarget=function(B){te.get(B).__webglFramebuffer===void 0&&Ye.setupRenderTarget(B)},this.initTexture=function(B){B.isCubeTexture?Ye.setTextureCube(B,0):B.isData3DTexture?Ye.setTexture3D(B,0):B.isDataArrayTexture||B.isCompressedArrayTexture?Ye.setTexture2DArray(B,0):Ye.setTexture2D(B,0),Ne.unbindTexture()},this.resetState=function(){D=0,T=0,x=null,Ne.reset(),At.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ss}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=e===Pm?"display-p3":"srgb",t.unpackColorSpace=sn.workingColorSpace===rd?"display-p3":"srgb"}}class zm{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new ht(e),this.density=t}clone(){return new zm(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class Vm{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new ht(e),this.near=t,this.far=n}clone(){return new Vm(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class DL extends rn{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new ki,this.environmentIntensity=1,this.environmentRotation=new ki,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__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()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class Hm{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=su,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=hr()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return HR("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,s=this.stride;re.far||t.push({distance:l,point:ih.clone(),uv:ar.getInterpolation(ih,Jd,sh,Qd,tU,i0,nU,new Ie),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function ef(i,e,t,n,r,s){Gl.subVectors(i,t).addScalar(.5).multiply(n),r!==void 0?(rh.x=s*Gl.x-r*Gl.y,rh.y=r*Gl.x+s*Gl.y):rh.copy(Gl),i.copy(e),i.x+=rh.x,i.y+=rh.y,i.applyMatrix4(PL)}const tf=new V,iU=new V;class BL extends rn{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);const t=e.levels;for(let n=0,r=t.length;n0){let n,r;for(n=1,r=t.length;n0){tf.setFromMatrixPosition(this.matrixWorld);const r=e.ray.origin.distanceTo(tf);this.getObjectForDistance(r).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){tf.setFromMatrixPosition(e.matrixWorld),iU.setFromMatrixPosition(this.matrixWorld);const n=tf.distanceTo(iU)/e.zoom;t[0].object.visible=!0;let r,s;for(r=1,s=t.length;r=a)t[r-1].object.visible=!1,t[r].object.visible=!0;else break}for(this._currentLevel=r-1;r=n.length&&n.push({start:-1,count:-1,z:-1});const s=n[this.index];r.push(s),this.index++,s.start=e.start,s.count=e.count,s.z=t}reset(){this.list.length=0,this.index=0}}const ql="batchId",va=new Mt,a0=new Mt,jP=new Mt,YP=new ht(1,1,1),dU=new Mt,o0=new ad,sf=new Oi,oo=new Si,lh=new V,fU=new V,$P=new V,l0=new XP,yi=new qn,af=[];function KP(i,e,t=0){const n=e.itemSize;if(i.isInterleavedBufferAttribute||i.array.constructor!==e.array.constructor){const r=i.count;for(let s=0;s65536?new Uint32Array(s):new Uint16Array(s);t.setIndex(new fn(o,1))}const a=r>65536?new Uint32Array(n):new Uint16Array(n);t.setAttribute(ql,new fn(a,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(ql))throw new Error(`BatchedMesh: Geometry cannot use attribute "${ql}"`);const t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('BatchedMesh: All geometries must consistently have "index".');for(const n in t.attributes){if(n===ql)continue;if(!e.hasAttribute(n))throw new Error(`BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);const r=e.getAttribute(n),s=t.getAttribute(n);if(r.itemSize!==s.itemSize||r.normalized!==s.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Oi);const e=this._geometryCount,t=this.boundingBox,n=this._active;t.makeEmpty();for(let r=0;r=this._maxGeometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");const r={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1};let s=null;const a=this._reservedRanges,o=this._drawRanges,l=this._bounds;this._geometryCount!==0&&(s=a[a.length-1]),t===-1?r.vertexCount=e.getAttribute("position").count:r.vertexCount=t,s===null?r.vertexStart=0:r.vertexStart=s.vertexStart+s.vertexCount;const c=e.getIndex(),h=c!==null;if(h&&(n===-1?r.indexCount=c.count:r.indexCount=n,s===null?r.indexStart=0:r.indexStart=s.indexStart+s.indexCount),r.indexStart!==-1&&r.indexStart+r.indexCount>this._maxIndexCount||r.vertexStart+r.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");const u=this._visibility,d=this._active,p=this._matricesTexture,m=this._matricesTexture.image.data,v=this._colorsTexture;u.push(!0),d.push(!0);const b=this._geometryCount;this._geometryCount++,jP.toArray(m,b*16),p.needsUpdate=!0,v!==null&&(YP.toArray(v.image.data,b*4),v.needsUpdate=!0),a.push(r),o.push({start:h?r.indexStart:r.vertexStart,count:-1}),l.push({boxInitialized:!1,box:new Oi,sphereInitialized:!1,sphere:new Si});const R=this.geometry.getAttribute(ql);for(let L=0;L=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const n=this.geometry,r=n.getIndex()!==null,s=n.getIndex(),a=t.getIndex(),o=this._reservedRanges[e];if(r&&a.count>o.indexCount||t.attributes.position.count>o.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const l=o.vertexStart,c=o.vertexCount;for(const p in n.attributes){if(p===ql)continue;const m=t.getAttribute(p),v=n.getAttribute(p);KP(m,v,l);const b=m.itemSize;for(let R=m.count,L=c;R=t.length||t[e]===!1?this:(t[e]=!1,this._visibilityChanged=!0,this)}getInstanceCountAt(e){return this._multiDrawInstances===null?null:this._multiDrawInstances[e]}setInstanceCountAt(e,t){return this._multiDrawInstances===null&&(this._multiDrawInstances=new Int32Array(this._maxGeometryCount).fill(1)),this._multiDrawInstances[e]=t,e}getBoundingBoxAt(e,t){if(this._active[e]===!1)return null;const r=this._bounds[e],s=r.box,a=this.geometry;if(r.boxInitialized===!1){s.makeEmpty();const o=a.index,l=a.attributes.position,c=this._drawRanges[e];for(let h=c.start,u=c.start+c.count;h=a||n[e]===!1?this:(t.toArray(s,e*16),r.needsUpdate=!0,this)}getMatrixAt(e,t){const n=this._active,r=this._matricesTexture.image.data,s=this._geometryCount;return e>=s||n[e]===!1?null:t.fromArray(r,e*16)}setColorAt(e,t){this._colorsTexture===null&&this._initColorsTexture();const n=this._active,r=this._colorsTexture,s=this._colorsTexture.image.data,a=this._geometryCount;return e>=a||n[e]===!1?this:(t.toArray(s,e*4),r.needsUpdate=!0,this)}getColorAt(e,t){const n=this._active,r=this._colorsTexture.image.data,s=this._geometryCount;return e>=s||n[e]===!1?null:t.fromArray(r,e*4)}setVisibleAt(e,t){const n=this._visibility,r=this._active,s=this._geometryCount;return e>=s||r[e]===!1||n[e]===t?this:(n[e]=t,this._visibilityChanged=!0,this)}getVisibleAt(e){const t=this._visibility,n=this._active,r=this._geometryCount;return e>=r||n[e]===!1?!1:t[e]}raycast(e,t){const n=this._visibility,r=this._active,s=this._drawRanges,a=this._geometryCount,o=this.matrixWorld,l=this.geometry;yi.material=this.material,yi.geometry.index=l.index,yi.geometry.attributes=l.attributes,yi.geometry.boundingBox===null&&(yi.geometry.boundingBox=new Oi),yi.geometry.boundingSphere===null&&(yi.geometry.boundingSphere=new Si);for(let c=0;c({...t})),this._reservedRanges=e._reservedRanges.map(t=>({...t})),this._visibility=e._visibility.slice(),this._active=e._active.slice(),this._bounds=e._bounds.map(t=>({boxInitialized:t.boxInitialized,box:t.box.clone(),sphereInitialized:t.sphereInitialized,sphere:t.sphere.clone()})),this._maxGeometryCount=e._maxGeometryCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.slice(),this._colorsTexture!==null&&(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.slice()),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null),this}onBeforeRender(e,t,n,r,s){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const a=r.getIndex(),o=a===null?1:a.array.BYTES_PER_ELEMENT,l=this._active,c=this._visibility,h=this._multiDrawStarts,u=this._multiDrawCounts,d=this._drawRanges,p=this.perObjectFrustumCulled;p&&(dU.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),o0.setFromProjectionMatrix(dU,e.coordinateSystem));let m=0;if(this.sortObjects){a0.copy(this.matrixWorld).invert(),lh.setFromMatrixPosition(n.matrixWorld).applyMatrix4(a0),fU.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(a0);for(let R=0,L=c.length;R0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;sn)return;c0.applyMatrix4(i.matrixWorld);const l=e.ray.origin.distanceTo(c0);if(!(le.far))return{distance:l,point:mU.clone().applyMatrix4(i.matrixWorld),index:r,face:null,faceIndex:null,object:i}}const gU=new V,xU=new V;class ds extends Na{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[];for(let r=0,s=t.count;r0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;sr.far)return;s.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,object:a})}}class JP extends Bn{constructor(e,t,n,r,s,a,o,l,c){super(e,t,n,r,s,a,o,l,c),this.isVideoTexture=!0,this.minFilter=a!==void 0?a:Zn,this.magFilter=s!==void 0?s:Zn,this.generateMipmaps=!1;const h=this;function u(){h.needsUpdate=!0,e.requestVideoFrameCallback(u)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(u)}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class QP extends Bn{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=li,this.minFilter=li,this.generateMipmaps=!1,this.needsUpdate=!0}}class Gm extends Bn{constructor(e,t,n,r,s,a,o,l,c,h,u,d){super(null,a,o,l,c,h,r,s,u,d),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class e4 extends Gm{constructor(e,t,n,r,s,a){super(e,t,n,s,a),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=Ur,this.layerUpdates=new Set}addLayerUpdates(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class t4 extends Gm{constructor(e,t,n){super(void 0,e[0].width,e[0].height,t,n,Qs),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class n4 extends Bn{constructor(e,t,n,r,s,a,o,l,c){super(e,t,n,r,s,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Vr{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,r=this.getPoint(0),s=0;t.push(0);for(let a=1;a<=e;a++)n=this.getPoint(a/e),s+=n.distanceTo(r),t.push(s),r=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const n=this.getLengths();let r=0;const s=n.length;let a;t?a=t:a=e*n[s-1];let o=0,l=s-1,c;for(;o<=l;)if(r=Math.floor(o+(l-o)/2),c=n[r]-a,c<0)o=r+1;else if(c>0)l=r-1;else{l=r;break}if(r=l,n[r]===a)return r/(s-1);const h=n[r],d=n[r+1]-h,p=(a-h)/d;return(r+p)/(s-1)}getTangent(e,t){let r=e-1e-4,s=e+1e-4;r<0&&(r=0),s>1&&(s=1);const a=this.getPoint(r),o=this.getPoint(s),l=t||(a.isVector2?new Ie:new V);return l.copy(o).sub(a).normalize(),l}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new V,r=[],s=[],a=[],o=new V,l=new Mt;for(let p=0;p<=e;p++){const m=p/e;r[p]=this.getTangentAt(m,new V)}s[0]=new V,a[0]=new V;let c=Number.MAX_VALUE;const h=Math.abs(r[0].x),u=Math.abs(r[0].y),d=Math.abs(r[0].z);h<=c&&(c=h,n.set(1,0,0)),u<=c&&(c=u,n.set(0,1,0)),d<=c&&n.set(0,0,1),o.crossVectors(r[0],n).normalize(),s[0].crossVectors(r[0],o),a[0].crossVectors(r[0],s[0]);for(let p=1;p<=e;p++){if(s[p]=s[p-1].clone(),a[p]=a[p-1].clone(),o.crossVectors(r[p-1],r[p]),o.length()>Number.EPSILON){o.normalize();const m=Math.acos(Pn(r[p-1].dot(r[p]),-1,1));s[p].applyMatrix4(l.makeRotationAxis(o,m))}a[p].crossVectors(r[p],s[p])}if(t===!0){let p=Math.acos(Pn(s[0].dot(s[e]),-1,1));p/=e,r[0].dot(o.crossVectors(s[0],s[e]))>0&&(p=-p);for(let m=1;m<=e;m++)s[m].applyMatrix4(l.makeRotationAxis(r[m],p*m)),a[m].crossVectors(r[m],s[m])}return{tangents:r,normals:s,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Zm extends Vr{constructor(e=0,t=0,n=1,r=1,s=0,a=Math.PI*2,o=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=a,this.aClockwise=o,this.aRotation=l}getPoint(e,t=new Ie){const n=t,r=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const a=Math.abs(s)r;)s-=r;s0?0:(Math.floor(Math.abs(o)/s)+1)*s:l===0&&o===s-1&&(o=s-2,l=1);let c,h;this.closed||o>0?c=r[(o-1)%s]:(uf.subVectors(r[0],r[1]).add(r[0]),c=uf);const u=r[o%s],d=r[(o+1)%s];if(this.closed||o+2r.length-2?r.length-1:a+1],u=r[a>r.length-3?r.length-1:a+2];return n.set(bU(o,l.x,c.x,h.x,u.x),bU(o,l.y,c.y,h.y,u.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t=n){const a=r[s]-n,o=this.curves[s],l=o.getLength(),c=l===0?0:1-a/l;return o.getPointAt(c,t)}s++}return null}getLength(){const 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;const e=[];let t=0;for(let n=0,r=this.curves.length;n1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t0){const u=c.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(c);const h=c.getPoint(1);return this.currentPoint.copy(h),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class od extends zt{constructor(e=[new Ie(0,-.5),new Ie(.5,0),new Ie(0,.5)],t=12,n=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:r},t=Math.floor(t),r=Pn(r,0,Math.PI*2);const s=[],a=[],o=[],l=[],c=[],h=1/t,u=new V,d=new Ie,p=new V,m=new V,v=new V;let b=0,R=0;for(let L=0;L<=e.length-1;L++)switch(L){case 0:b=e[L+1].x-e[L].x,R=e[L+1].y-e[L].y,p.x=R*1,p.y=-b,p.z=R*0,v.copy(p),p.normalize(),l.push(p.x,p.y,p.z);break;case e.length-1:l.push(v.x,v.y,v.z);break;default:b=e[L+1].x-e[L].x,R=e[L+1].y-e[L].y,p.x=R*1,p.y=-b,p.z=R*0,m.copy(p),p.x+=v.x,p.y+=v.y,p.z+=v.z,p.normalize(),l.push(p.x,p.y,p.z),v.copy(m)}for(let L=0;L<=t;L++){const _=n+L*h*r,S=Math.sin(_),D=Math.cos(_);for(let T=0;T<=e.length-1;T++){u.x=e[T].x*S,u.y=e[T].y,u.z=e[T].x*D,a.push(u.x,u.y,u.z),d.x=L/t,d.y=T/(e.length-1),o.push(d.x,d.y);const x=l[3*T+0]*S,O=l[3*T+1],A=l[3*T+0]*D;c.push(x,O,A)}}for(let L=0;L0&&_(!0),t>0&&_(!1)),this.setIndex(h),this.setAttribute("position",new mt(u,3)),this.setAttribute("normal",new mt(d,3)),this.setAttribute("uv",new mt(p,2));function L(){const S=new V,D=new V;let T=0;const x=(t-e)/n;for(let O=0;O<=s;O++){const A=[],E=O/s,z=E*(t-e)+e;for(let ie=0;ie<=r;ie++){const J=ie/r,he=J*l+o,me=Math.sin(he),oe=Math.cos(he);D.x=z*me,D.y=-E*n+b,D.z=z*oe,u.push(D.x,D.y,D.z),S.set(me,x,oe).normalize(),d.push(S.x,S.y,S.z),p.push(J,1-E),A.push(m++)}v.push(A)}for(let O=0;O.9&&x<.1&&(_<.2&&(a[L+0]+=1),S<.2&&(a[L+2]+=1),D<.2&&(a[L+4]+=1))}}function d(L){s.push(L.x,L.y,L.z)}function p(L,_){const S=L*3;_.x=e[S+0],_.y=e[S+1],_.z=e[S+2]}function m(){const L=new V,_=new V,S=new V,D=new V,T=new Ie,x=new Ie,O=new Ie;for(let A=0,E=0;A80*t){o=c=i[0],l=h=i[1];for(let m=t;mc&&(c=u),d>h&&(h=d);p=Math.max(c-o,h-l),p=p!==0?32767/p:0}return cu(s,a,t,o,l,p,0),a}};function jL(i,e,t,n,r){let s,a;if(r===M4(i,e,t,n)>0)for(s=e;s=e;s-=n)a=UU(s,i[s],i[s+1],a);return a&&$m(a,a.next)&&(uu(a),a=a.next),a}function ol(i,e){if(!i)return i;e||(e=i);let t=i,n;do if(n=!1,!t.steiner&&($m(t,t.next)||Fn(t.prev,t,t.next)===0)){if(uu(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function cu(i,e,t,n,r,s,a){if(!i)return;!a&&s&&b4(i,n,r,s);let o=i,l,c;for(;i.prev!==i.next;){if(l=i.prev,c=i.next,s?d4(i,n,r,s):u4(i)){e.push(l.i/t|0),e.push(i.i/t|0),e.push(c.i/t|0),uu(i),i=c.next,o=c.next;continue}if(i=c,i===o){a?a===1?(i=f4(ol(i),e,t),cu(i,e,t,n,r,s,2)):a===2&&p4(i,e,t,n,r,s):cu(ol(i),e,t,n,r,s,1);break}}}function u4(i){const e=i.prev,t=i,n=i.next;if(Fn(e,t,n)>=0)return!1;const r=e.x,s=t.x,a=n.x,o=e.y,l=t.y,c=n.y,h=rs?r>a?r:a:s>a?s:a,p=o>l?o>c?o:c:l>c?l:c;let m=n.next;for(;m!==e;){if(m.x>=h&&m.x<=d&&m.y>=u&&m.y<=p&&ic(r,o,s,l,a,c,m.x,m.y)&&Fn(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function d4(i,e,t,n){const r=i.prev,s=i,a=i.next;if(Fn(r,s,a)>=0)return!1;const o=r.x,l=s.x,c=a.x,h=r.y,u=s.y,d=a.y,p=ol?o>c?o:c:l>c?l:c,b=h>u?h>d?h:d:u>d?u:d,R=Ox(p,m,e,t,n),L=Ox(v,b,e,t,n);let _=i.prevZ,S=i.nextZ;for(;_&&_.z>=R&&S&&S.z<=L;){if(_.x>=p&&_.x<=v&&_.y>=m&&_.y<=b&&_!==r&&_!==a&&ic(o,h,l,u,c,d,_.x,_.y)&&Fn(_.prev,_,_.next)>=0||(_=_.prevZ,S.x>=p&&S.x<=v&&S.y>=m&&S.y<=b&&S!==r&&S!==a&&ic(o,h,l,u,c,d,S.x,S.y)&&Fn(S.prev,S,S.next)>=0))return!1;S=S.nextZ}for(;_&&_.z>=R;){if(_.x>=p&&_.x<=v&&_.y>=m&&_.y<=b&&_!==r&&_!==a&&ic(o,h,l,u,c,d,_.x,_.y)&&Fn(_.prev,_,_.next)>=0)return!1;_=_.prevZ}for(;S&&S.z<=L;){if(S.x>=p&&S.x<=v&&S.y>=m&&S.y<=b&&S!==r&&S!==a&&ic(o,h,l,u,c,d,S.x,S.y)&&Fn(S.prev,S,S.next)>=0)return!1;S=S.nextZ}return!0}function f4(i,e,t){let n=i;do{const r=n.prev,s=n.next.next;!$m(r,s)&&YL(r,n,n.next,s)&&hu(r,s)&&hu(s,r)&&(e.push(r.i/t|0),e.push(n.i/t|0),e.push(s.i/t|0),uu(n),uu(n.next),n=i=s),n=n.next}while(n!==i);return ol(n)}function p4(i,e,t,n,r,s){let a=i;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&_4(a,o)){let l=$L(a,o);a=ol(a,a.next),l=ol(l,l.next),cu(a,e,t,n,r,s,0),cu(l,e,t,n,r,s,0);return}o=o.next}a=a.next}while(a!==i)}function m4(i,e,t,n){const r=[];let s,a,o,l,c;for(s=0,a=e.length;s=t.next.y&&t.next.y!==t.y){const d=t.x+(a-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=s&&d>n&&(n=d,r=t.x=t.x&&t.x>=l&&s!==t.x&&ic(ar.x||t.x===r.x&&v4(r,t)))&&(r=t,h=u)),t=t.next;while(t!==o);return r}function v4(i,e){return Fn(i.prev,i,e.prev)<0&&Fn(e.next,i,i.next)<0}function b4(i,e,t,n){let r=i;do r.z===0&&(r.z=Ox(r.x,r.y,e,t,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,U4(r)}function U4(i){let e,t,n,r,s,a,o,l,c=1;do{for(t=i,i=null,s=null,a=0;t;){for(a++,n=t,o=0,e=0;e0||l>0&&n;)o!==0&&(l===0||!n||t.z<=n.z)?(r=t,t=t.nextZ,o--):(r=n,n=n.nextZ,l--),s?s.nextZ=r:i=r,r.prevZ=s,s=r;t=n}s.nextZ=null,c*=2}while(a>1);return i}function Ox(i,e,t,n,r){return i=(i-t)*r|0,e=(e-n)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,i|e<<1}function y4(i){let e=i,t=i;do(e.x=(i-a)*(s-o)&&(i-a)*(n-o)>=(t-a)*(e-o)&&(t-a)*(s-o)>=(r-a)*(n-o)}function _4(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!L4(i,e)&&(hu(i,e)&&hu(e,i)&&S4(i,e)&&(Fn(i.prev,i,e.prev)||Fn(i,e.prev,e))||$m(i,e)&&Fn(i.prev,i,i.next)>0&&Fn(e.prev,e,e.next)>0)}function Fn(i,e,t){return(e.y-i.y)*(t.x-e.x)-(e.x-i.x)*(t.y-e.y)}function $m(i,e){return i.x===e.x&&i.y===e.y}function YL(i,e,t,n){const r=gf(Fn(i,e,t)),s=gf(Fn(i,e,n)),a=gf(Fn(t,n,i)),o=gf(Fn(t,n,e));return!!(r!==s&&a!==o||r===0&&mf(i,t,e)||s===0&&mf(i,n,e)||a===0&&mf(t,i,n)||o===0&&mf(t,e,n))}function mf(i,e,t){return e.x<=Math.max(i.x,t.x)&&e.x>=Math.min(i.x,t.x)&&e.y<=Math.max(i.y,t.y)&&e.y>=Math.min(i.y,t.y)}function gf(i){return i>0?1:i<0?-1:0}function L4(i,e){let t=i;do{if(t.i!==i.i&&t.next.i!==i.i&&t.i!==e.i&&t.next.i!==e.i&&YL(t,t.next,i,e))return!0;t=t.next}while(t!==i);return!1}function hu(i,e){return Fn(i.prev,i,i.next)<0?Fn(i,e,i.next)>=0&&Fn(i,i.prev,e)>=0:Fn(i,e,i.prev)<0||Fn(i,i.next,e)<0}function S4(i,e){let t=i,n=!1;const r=(i.x+e.x)/2,s=(i.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==i);return n}function $L(i,e){const t=new kx(i.i,i.x,i.y),n=new kx(e.i,e.x,e.y),r=i.next,s=e.prev;return i.next=e,e.prev=i,t.next=r,r.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function UU(i,e,t,n){const r=new kx(i,e,t);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function uu(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function kx(i,e,t){this.i=i,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function M4(i,e,t,n){let r=0;for(let s=e,a=t-n;s2&&i[e-1].equals(i[0])&&i.pop()}function _U(i,e){for(let t=0;tNumber.EPSILON){const Ce=Math.sqrt(de),ue=Math.sqrt(H*H+C*C),ot=Se.x-Lt/Ce,$e=Se.y+Ye/Ce,Oe=qe.x-C/ue,wt=qe.y+H/ue,Ve=((Oe-ot)*C-(wt-$e)*H)/(Ye*C-Lt*H);Ne=ot+Ye*Ve-Te.x,ze=$e+Lt*Ve-Te.y;const rt=Ne*Ne+ze*ze;if(rt<=2)return new Ie(Ne,ze);te=Math.sqrt(rt/2)}else{let Ce=!1;Ye>Number.EPSILON?H>Number.EPSILON&&(Ce=!0):Ye<-Number.EPSILON?H<-Number.EPSILON&&(Ce=!0):Math.sign(Lt)===Math.sign(C)&&(Ce=!0),Ce?(Ne=-Lt,ze=Ye,te=Math.sqrt(de)):(Ne=Ye,ze=Lt,te=Math.sqrt(de/2))}return new Ie(Ne/te,ze/te)}const We=[];for(let Te=0,Se=he.length,qe=Se-1,Ne=Te+1;Te=0;Te--){const Se=Te/b,qe=p*Math.cos(Se*Math.PI/2),Ne=m*Math.sin(Se*Math.PI/2)+v;for(let ze=0,te=he.length;ze=0;){const Ne=qe;let ze=qe-1;ze<0&&(ze=Te.length-1);for(let te=0,Ye=h+b*2;te0)&&p.push(_,S,T),(R!==n-1||l0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class tS extends Ai{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new ht(16777215),this.specular=new ht(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ht(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Wa,this.normalScale=new Ie(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ki,this.combine=nd,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class nS extends Ai{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new ht(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ht(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Wa,this.normalScale=new Ie(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class iS extends Ai{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Wa,this.normalScale=new Ie(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class rS extends Ai{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new ht(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ht(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Wa,this.normalScale=new Ie(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ki,this.combine=nd,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class sS extends Ai{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new ht(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Wa,this.normalScale=new Ie(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class aS extends Ni{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function To(i,e,t){return!i||!t&&i.constructor===e?i:typeof e.BYTES_PER_ELEMENT=="number"?new e(i):Array.prototype.slice.call(i)}function oS(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function lS(i){function e(r,s){return i[r]-i[s]}const t=i.length,n=new Array(t);for(let r=0;r!==t;++r)n[r]=r;return n.sort(e),n}function Nx(i,e,t){const n=i.length,r=new i.constructor(n);for(let s=0,a=0;a!==n;++s){const o=t[s]*e;for(let l=0;l!==e;++l)r[a++]=i[o+l]}return r}function av(i,e,t,n){let r=1,s=i[0];for(;s!==void 0&&s[n]===void 0;)s=i[r++];if(s===void 0)return;let a=s[n];if(a!==void 0)if(Array.isArray(a))do a=s[n],a!==void 0&&(e.push(s.time),t.push.apply(t,a)),s=i[r++];while(s!==void 0);else if(a.toArray!==void 0)do a=s[n],a!==void 0&&(e.push(s.time),a.toArray(t,t.length)),s=i[r++];while(s!==void 0);else do a=s[n],a!==void 0&&(e.push(s.time),t.push(a)),s=i[r++];while(s!==void 0)}function T4(i,e,t,n,r=30){const s=i.clone();s.name=e;const a=[];for(let l=0;l=n)){u.push(c.times[p]);for(let v=0;vs.tracks[l].times[0]&&(o=s.tracks[l].times[0]);for(let l=0;l=o.times[m]){const R=m*u+h,L=R+u-h;v=o.values.slice(R,L)}else{const R=o.createInterpolant(),L=h,_=u-h;R.evaluate(s),v=R.resultBuffer.slice(L,_)}l==="quaternion"&&new gi().fromArray(v).normalize().conjugate().toArray(v);const b=c.times.length;for(let R=0;R=s)){const o=t[1];e=s)break t}a=n,n=0;break n}break e}for(;n>>1;et;)--a;if(++a,s!==0||a!==r){s>=a&&(a=Math.max(a,1),s=a-1);const o=this.getValueSize();this.times=n.slice(s,a),this.values=this.values.slice(s*o,a*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,r=this.values,s=n.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==s;o++){const l=n[o];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,l),e=!1;break}if(a!==null&&a>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,l,a),e=!1;break}a=l}if(r!==void 0&&oS(r))for(let o=0,l=r.length;o!==l;++o){const c=r[o];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),r=this.getInterpolation()===np,s=e.length-1;let a=1;for(let o=1;o0){e[a]=e[s];for(let o=s*n,l=a*n,c=0;c!==n;++c)t[l+c]=t[o+c];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=this.constructor,r=new n(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}}Hr.prototype.TimeBufferType=Float32Array;Hr.prototype.ValueBufferType=Float32Array;Hr.prototype.DefaultInterpolation=Ap;class ml extends Hr{constructor(e,t,n){super(e,t,n)}}ml.prototype.ValueTypeName="bool";ml.prototype.ValueBufferType=Array;ml.prototype.DefaultInterpolation=eu;ml.prototype.InterpolantFactoryMethodLinear=void 0;ml.prototype.InterpolantFactoryMethodSmooth=void 0;class lv extends Hr{}lv.prototype.ValueTypeName="color";class du extends Hr{}du.prototype.ValueTypeName="number";class uS extends hd{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=(n-t)/(r-t);let c=e*o;for(let h=c+o;c!==h;c+=4)gi.slerpFlat(s,0,a,c-o,a,c,l);return s}}class ud extends Hr{InterpolantFactoryMethodLinear(e){return new uS(this.times,this.values,this.getValueSize(),e)}}ud.prototype.ValueTypeName="quaternion";ud.prototype.InterpolantFactoryMethodSmooth=void 0;class gl extends Hr{constructor(e,t,n){super(e,t,n)}}gl.prototype.ValueTypeName="string";gl.prototype.ValueBufferType=Array;gl.prototype.DefaultInterpolation=eu;gl.prototype.InterpolantFactoryMethodLinear=void 0;gl.prototype.InterpolantFactoryMethodSmooth=void 0;class fu extends Hr{}fu.prototype.ValueTypeName="vector";class pu{constructor(e="",t=-1,n=[],r=Dm){this.name=e,this.tracks=n,this.duration=t,this.blendMode=r,this.uuid=hr(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,r=1/(e.fps||1);for(let a=0,o=n.length;a!==o;++a)t.push(P4(n[a]).scale(r));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){const t=[],n=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,a=n.length;s!==a;++s)t.push(Hr.toJSON(n[s]));return r}static CreateFromMorphTargetSequence(e,t,n,r){const s=t.length,a=[];for(let o=0;o1){const u=h[1];let d=r[u];d||(r[u]=d=[]),d.push(c)}}const a=[];for(const o in r)a.push(this.CreateFromMorphTargetSequence(o,r[o],t,n));return a}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(u,d,p,m,v){if(p.length!==0){const b=[],R=[];av(p,b,R,m),b.length!==0&&v.push(new u(d,b,R))}},r=[],s=e.name||"default",a=e.fps||30,o=e.blendMode;let l=e.length||-1;const c=e.hierarchy||[];for(let u=0;u{t&&t(s),this.manager.itemEnd(e)},0),s;if(Ss[e]!==void 0){Ss[e].push({onLoad:t,onProgress:n,onError:r});return}Ss[e]=[],Ss[e].push({onLoad:t,onProgress:n,onError:r});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,l=this.responseType;fetch(a).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const h=Ss[e],u=c.body.getReader(),d=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),p=d?parseInt(d):0,m=p!==0;let v=0;const b=new ReadableStream({start(R){L();function L(){u.read().then(({done:_,value:S})=>{if(_)R.close();else{v+=S.byteLength;const D=new ProgressEvent("progress",{lengthComputable:m,loaded:v,total:p});for(let T=0,x=h.length;T{R.error(_)})}}});return new Response(b)}else throw new I4(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(h=>new DOMParser().parseFromString(h,o));case"json":return c.json();default:if(o===void 0)return c.text();{const u=/charset="?([^;"\s]*)"?/i.exec(o),d=u&&u[1]?u[1].toLowerCase():void 0,p=new TextDecoder(d);return c.arrayBuffer().then(m=>p.decode(m))}}}).then(c=>{zs.add(e,c);const h=Ss[e];delete Ss[e];for(let u=0,d=h.length;u{const h=Ss[e];if(h===void 0)throw this.manager.itemError(e),c;delete Ss[e];for(let u=0,d=h.length;u{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class B4 extends Qi{constructor(e){super(e)}load(e,t,n,r){const s=this,a=new ta(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(o){try{t(s.parse(JSON.parse(o)))}catch(l){r?r(l):console.error(l),s.manager.itemError(e)}},n,r)}parse(e){const t=[];for(let n=0;n0:r.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const s in e.uniforms){const a=e.uniforms[s];switch(r.uniforms[s]={},a.type){case"t":r.uniforms[s].value=n(a.value);break;case"c":r.uniforms[s].value=new ht().setHex(a.value);break;case"v2":r.uniforms[s].value=new Ie().fromArray(a.value);break;case"v3":r.uniforms[s].value=new V().fromArray(a.value);break;case"v4":r.uniforms[s].value=new un().fromArray(a.value);break;case"m3":r.uniforms[s].value=new It().fromArray(a.value);break;case"m4":r.uniforms[s].value=new Mt().fromArray(a.value);break;default:r.uniforms[s].value=a.value}}if(e.defines!==void 0&&(r.defines=e.defines),e.vertexShader!==void 0&&(r.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(r.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(r.glslVersion=e.glslVersion),e.extensions!==void 0)for(const s in e.extensions)r.extensions[s]=e.extensions[s];if(e.lights!==void 0&&(r.lights=e.lights),e.clipping!==void 0&&(r.clipping=e.clipping),e.size!==void 0&&(r.size=e.size),e.sizeAttenuation!==void 0&&(r.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(r.map=n(e.map)),e.matcap!==void 0&&(r.matcap=n(e.matcap)),e.alphaMap!==void 0&&(r.alphaMap=n(e.alphaMap)),e.bumpMap!==void 0&&(r.bumpMap=n(e.bumpMap)),e.bumpScale!==void 0&&(r.bumpScale=e.bumpScale),e.normalMap!==void 0&&(r.normalMap=n(e.normalMap)),e.normalMapType!==void 0&&(r.normalMapType=e.normalMapType),e.normalScale!==void 0){let s=e.normalScale;Array.isArray(s)===!1&&(s=[s,s]),r.normalScale=new Ie().fromArray(s)}return e.displacementMap!==void 0&&(r.displacementMap=n(e.displacementMap)),e.displacementScale!==void 0&&(r.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(r.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(r.roughnessMap=n(e.roughnessMap)),e.metalnessMap!==void 0&&(r.metalnessMap=n(e.metalnessMap)),e.emissiveMap!==void 0&&(r.emissiveMap=n(e.emissiveMap)),e.emissiveIntensity!==void 0&&(r.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(r.specularMap=n(e.specularMap)),e.specularIntensityMap!==void 0&&(r.specularIntensityMap=n(e.specularIntensityMap)),e.specularColorMap!==void 0&&(r.specularColorMap=n(e.specularColorMap)),e.envMap!==void 0&&(r.envMap=n(e.envMap)),e.envMapRotation!==void 0&&r.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(r.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(r.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(r.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(r.lightMap=n(e.lightMap)),e.lightMapIntensity!==void 0&&(r.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(r.aoMap=n(e.aoMap)),e.aoMapIntensity!==void 0&&(r.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(r.gradientMap=n(e.gradientMap)),e.clearcoatMap!==void 0&&(r.clearcoatMap=n(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(r.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(r.clearcoatNormalMap=n(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(r.clearcoatNormalScale=new Ie().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(r.iridescenceMap=n(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(r.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(r.transmissionMap=n(e.transmissionMap)),e.thicknessMap!==void 0&&(r.thicknessMap=n(e.thicknessMap)),e.anisotropyMap!==void 0&&(r.anisotropyMap=n(e.anisotropyMap)),e.sheenColorMap!==void 0&&(r.sheenColorMap=n(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(r.sheenRoughnessMap=n(e.sheenRoughnessMap)),r}setTextures(e){return this.textures=e,this}static createMaterialFromType(e){const t={ShadowMaterial:JL,SpriteMaterial:$R,RawShaderMaterial:QL,ShaderMaterial:Nr,PointsMaterial:JR,MeshPhysicalMaterial:eS,MeshStandardMaterial:sv,MeshPhongMaterial:tS,MeshToonMaterial:nS,MeshNormalMaterial:iS,MeshLambertMaterial:rS,MeshDepthMaterial:jR,MeshDistanceMaterial:YR,MeshBasicMaterial:Ga,MeshMatcapMaterial:sS,LineDashedMaterial:aS,LineBasicMaterial:Ni,Material:Ai};return new t[e]}}class zx{static decodeText(e){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let n=0,r=e.length;n0){const l=new cv(t);s=new mu(l),s.setCrossOrigin(this.crossOrigin);for(let c=0,h=e.length;c0){r=new mu(this.manager),r.setCrossOrigin(this.crossOrigin);for(let a=0,o=e.length;a{const b=new Oi;b.min.fromArray(v.boxMin),b.max.fromArray(v.boxMax);const R=new Si;return R.radius=v.sphereRadius,R.center.fromArray(v.sphereCenter),{boxInitialized:v.boxInitialized,box:b,sphereInitialized:v.sphereInitialized,sphere:R}}),a._maxGeometryCount=e.maxGeometryCount,a._maxVertexCount=e.maxVertexCount,a._maxIndexCount=e.maxIndexCount,a._geometryInitialized=e.geometryInitialized,a._geometryCount=e.geometryCount,a._matricesTexture=c(e.matricesTexture.uuid),e.colorsTexture!==void 0&&(a._colorsTexture=c(e.colorsTexture.uuid));break;case"LOD":a=new BL;break;case"Line":a=new Na(o(e.geometry),l(e.material));break;case"LineLoop":a=new zL(o(e.geometry),l(e.material));break;case"LineSegments":a=new ds(o(e.geometry),l(e.material));break;case"PointCloud":case"Points":a=new VL(o(e.geometry),l(e.material));break;case"Sprite":a=new IL(l(e.material));break;case"Group":a=new nc;break;case"Bone":a=new KR;break;default:a=new rn}if(a.uuid=e.uuid,e.name!==void 0&&(a.name=e.name),e.matrix!==void 0?(a.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(a.matrixAutoUpdate=e.matrixAutoUpdate),a.matrixAutoUpdate&&a.matrix.decompose(a.position,a.quaternion,a.scale)):(e.position!==void 0&&a.position.fromArray(e.position),e.rotation!==void 0&&a.rotation.fromArray(e.rotation),e.quaternion!==void 0&&a.quaternion.fromArray(e.quaternion),e.scale!==void 0&&a.scale.fromArray(e.scale)),e.up!==void 0&&a.up.fromArray(e.up),e.castShadow!==void 0&&(a.castShadow=e.castShadow),e.receiveShadow!==void 0&&(a.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.bias!==void 0&&(a.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(a.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(a.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&a.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(a.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(a.visible=e.visible),e.frustumCulled!==void 0&&(a.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(a.renderOrder=e.renderOrder),e.userData!==void 0&&(a.userData=e.userData),e.layers!==void 0&&(a.layers.mask=e.layers),e.children!==void 0){const d=e.children;for(let p=0;p"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,n,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=zs.get(e);if(a!==void 0){if(s.manager.itemStart(e),a.then){a.then(c=>{t&&t(c),s.manager.itemEnd(e)}).catch(c=>{r&&r(c)});return}return setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader;const l=fetch(e,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(c){return zs.add(e,c),t&&t(c),s.manager.itemEnd(e),c}).catch(function(c){r&&r(c),zs.remove(e),s.manager.itemError(e),s.manager.itemEnd(e)});zs.add(e,l),s.manager.itemStart(e)}}let xf;class uv{static getContext(){return xf===void 0&&(xf=new(window.AudioContext||window.webkitAudioContext)),xf}static setContext(e){xf=e}}class X4 extends Qi{constructor(e){super(e)}load(e,t,n,r){const s=this,a=new ta(this.manager);a.setResponseType("arraybuffer"),a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(l){try{const c=l.slice(0);uv.getContext().decodeAudioData(c,function(u){t(u)}).catch(o)}catch(c){o(c)}},n,r);function o(l){r?r(l):console.error(l),s.manager.itemError(e)}}}const FU=new Mt,CU=new Mt,lo=new Mt;class j4{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new mi,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new mi,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,lo.copy(e.projectionMatrix);const r=t.eyeSep/2,s=r*t.near/t.focus,a=t.near*Math.tan(Yo*t.fov*.5)/t.zoom;let o,l;CU.elements[12]=-r,FU.elements[12]=r,o=-a*t.aspect+s,l=a*t.aspect+s,lo.elements[0]=2*t.near/(l-o),lo.elements[8]=(l+o)/(l-o),this.cameraL.projectionMatrix.copy(lo),o=-a*t.aspect-s,l=a*t.aspect-s,lo.elements[0]=2*t.near/(l-o),lo.elements[8]=(l+o)/(l-o),this.cameraR.projectionMatrix.copy(lo)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(CU),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(FU)}}class _S{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=DU(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=DU();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function DU(){return(typeof performance>"u"?Date:performance).now()}const co=new V,PU=new gi,Y4=new V,ho=new V;class $4 extends rn{constructor(){super(),this.type="AudioListener",this.context=uv.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new _S}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);const t=this.context.listener,n=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(co,PU,Y4),ho.set(0,0,-1).applyQuaternion(PU),t.positionX){const r=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(co.x,r),t.positionY.linearRampToValueAtTime(co.y,r),t.positionZ.linearRampToValueAtTime(co.z,r),t.forwardX.linearRampToValueAtTime(ho.x,r),t.forwardY.linearRampToValueAtTime(ho.y,r),t.forwardZ.linearRampToValueAtTime(ho.z,r),t.upX.linearRampToValueAtTime(n.x,r),t.upY.linearRampToValueAtTime(n.y,r),t.upZ.linearRampToValueAtTime(n.z,r)}else t.setPosition(co.x,co.y,co.z),t.setOrientation(ho.x,ho.y,ho.z,n.x,n.y,n.z)}}class LS extends rn{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){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(n,r,this._addIndex*t,1,t);for(let l=t,c=t+t;l!==c;++l)if(n[l]!==n[l+t]){o.setValue(n,r);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,r=n*this._origIndex;e.getValue(t,r);for(let s=n,a=r;s!==a;++s)t[s]=t[r+s%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n=.5)for(let a=0;a!==s;++a)e[t+a]=e[n+a]}_slerp(e,t,n,r){gi.slerpFlat(e,t,e,t,e,n,r)}_slerpAdditive(e,t,n,r,s){const a=this._workIndex*s;gi.multiplyQuaternionsFlat(e,a,e,t,e,n),gi.slerpFlat(e,t,e,t,e,a,r)}_lerp(e,t,n,r,s){const a=1-r;for(let o=0;o!==s;++o){const l=t+o;e[l]=e[l]*a+e[n+o]*r}}_lerpAdditive(e,t,n,r,s){for(let a=0;a!==s;++a){const o=t+a;e[o]=e[o]+e[n+a]*r}}}const dv="\\[\\]\\.:\\/",e5=new RegExp("["+dv+"]","g"),fv="[^"+dv+"]",t5="[^"+dv.replace("\\.","")+"]",n5=/((?:WC+[\/:])*)/.source.replace("WC",fv),i5=/(WCOD+)?/.source.replace("WCOD",t5),r5=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",fv),s5=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",fv),a5=new RegExp("^"+n5+i5+r5+s5+"$"),o5=["material","materials","bones","map"];class l5{constructor(e,t,n){const r=n||en.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,r=this._bindings[n];r!==void 0&&r.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=n.length;r!==s;++r)n[r].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class en{constructor(e,t,n){this.path=t,this.parsedPath=n||en.parseTrackName(t),this.node=en.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new en.Composite(e,t,n):new en(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(e5,"")}static parseTrackName(e){const t=a5.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=n.nodeName&&n.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){const s=n.nodeName.substring(r+1);o5.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(s){for(let a=0;a=s){const u=s++,d=e[u];t[d.uuid]=h,e[h]=d,t[c]=u,e[u]=l;for(let p=0,m=r;p!==m;++p){const v=n[p],b=v[u],R=v[h];v[h]=b,v[u]=R}}}this.nCachedObjects_=s}uncache(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,r=n.length;let s=this.nCachedObjects_,a=e.length;for(let o=0,l=arguments.length;o!==l;++o){const c=arguments[o],h=c.uuid,u=t[h];if(u!==void 0)if(delete t[h],u0&&(t[p.uuid]=u),e[u]=p,e.pop();for(let m=0,v=r;m!==v;++m){const b=n[m];b[u]=b[d],b.pop()}}}this.nCachedObjects_=s}subscribe_(e,t){const n=this._bindingsIndicesByPath;let r=n[e];const s=this._bindings;if(r!==void 0)return s[r];const a=this._paths,o=this._parsedPaths,l=this._objects,c=l.length,h=this.nCachedObjects_,u=new Array(c);r=s.length,n[e]=r,a.push(e),o.push(t),s.push(u);for(let d=h,p=l.length;d!==p;++d){const m=l[d];u[d]=new en(m,e,t)}return u}unsubscribe_(e){const t=this._bindingsIndicesByPath,n=t[e];if(n!==void 0){const r=this._paths,s=this._parsedPaths,a=this._bindings,o=a.length-1,l=a[o],c=e[o];t[c]=n,a[n]=l,a.pop(),s[n]=s[o],s.pop(),r[n]=r[o],r.pop()}}}class MS{constructor(e,t,n=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=r;const s=t.tracks,a=s.length,o=new Array(a),l={endingStart:wo,endingEnd:wo};for(let c=0;c!==a;++c){const h=s[c].createInterpolant(null);o[c]=h,h.settings=l}this._interpolantSettings=l,this._interpolants=o,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=rL,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n){if(e.fadeOut(t),this.fadeIn(t),n){const r=this._clip.duration,s=e._clip.duration,a=s/r,o=r/s;e.warp(1,a,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,n){return e.crossFadeFrom(this,t,n)}stopFading(){const 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,n){const r=this._mixer,s=r.time,a=this.timeScale;let o=this._timeScaleInterpolant;o===null&&(o=r._lendControlInterpolant(),this._timeScaleInterpolant=o);const l=o.parameterPositions,c=o.sampleValues;return l[0]=s,l[1]=s+n,c[0]=e/a,c[1]=t/a,this}stopWarping(){const 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,n,r){if(!this.enabled){this._updateWeight(e);return}const s=this._startTime;if(s!==null){const l=(e-s)*n;l<0||n===0?t=0:(this._startTime=null,t=n*l)}t*=this._updateTimeScale(e);const a=this._updateTime(t),o=this._updateWeight(e);if(o>0){const l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case NR:for(let h=0,u=l.length;h!==u;++h)l[h].evaluate(a),c[h].accumulateAdditive(o);break;case Dm:default:for(let h=0,u=l.length;h!==u;++h)l[h].evaluate(a),c[h].accumulate(r,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(n!==null){const r=n.evaluate(e)[0];t*=r,e>n.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;const n=this._timeScaleInterpolant;if(n!==null){const r=n.evaluate(e)[0];t*=r,e>n.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,n=this.loop;let r=this.time+e,s=this._loopCount;const a=n===sL;if(e===0)return s===-1?r:a&&(s&1)===1?t-r:r;if(n===iL){s===-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(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),r>=t||r<0){const o=Math.floor(r/t);r-=t*o,s+=Math.abs(o);const l=this.repetitions-s;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){const c=e<0;this._setEndings(c,!c,a)}else this._setEndings(!1,!1,a);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=r;if(a&&(s&1)===1)return t-r}return r}_setEndings(e,t,n){const r=this._interpolantSettings;n?(r.endingStart=Ao,r.endingEnd=Ao):(e?r.endingStart=this.zeroSlopeAtStart?Ao:wo:r.endingStart=tu,t?r.endingEnd=this.zeroSlopeAtEnd?Ao:wo:r.endingEnd=tu)}_scheduleFading(e,t,n){const r=this._mixer,s=r.time;let a=this._weightInterpolant;a===null&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);const o=a.parameterPositions,l=a.sampleValues;return o[0]=s,l[0]=t,o[1]=s+e,l[1]=n,this}}const h5=new Float32Array(1);class u5 extends sa{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const n=e._localRoot||this._root,r=e._clip.tracks,s=r.length,a=e._propertyBindings,o=e._interpolants,l=n.uuid,c=this._bindingsByRootAndName;let h=c[l];h===void 0&&(h={},c[l]=h);for(let u=0;u!==s;++u){const d=r[u],p=d.name;let m=h[p];if(m!==void 0)++m.referenceCount,a[u]=m;else{if(m=a[u],m!==void 0){m._cacheIndex===null&&(++m.referenceCount,this._addInactiveBinding(m,l,p));continue}const v=t&&t._propertyBindings[u].binding.parsedPath;m=new SS(en.create(n,p,v),d.ValueTypeName,d.getValueSize()),++m.referenceCount,this._addInactiveBinding(m,l,p),a[u]=m}o[u].resultBuffer=m.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const n=(e._localRoot||this._root).uuid,r=e._clip.uuid,s=this._actionsByClip[r];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,r,n)}const t=e._propertyBindings;for(let n=0,r=t.length;n!==r;++n){const s=t[n];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let n=0,r=t.length;n!==r;++n){const s=t[n];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const 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){const t=e._cacheIndex;return t!==null&&t=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;const t=this._actions,n=this._nActiveActions,r=this.time+=e,s=Math.sign(e),a=this._accuIndex^=1;for(let c=0;c!==n;++c)t[c]._update(r,e,s,a);const o=this._bindings,l=this._nActiveBindings;for(let c=0;c!==l;++c)o[c].apply(a);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.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.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,kU).distanceTo(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}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)}}const NU=new V,Rf=new V;class b5{constructor(e=new V,t=new V){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.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){NU.subVectors(e,this.start),Rf.subVectors(this.end,this.start);const n=Rf.dot(Rf);let s=Rf.dot(NU)/n;return t&&(s=Pn(s,0,1)),s}closestPointToPoint(e,t,n){const r=this.closestPointToPointParameter(e,t);return this.delta(n).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)}}const zU=new V;class U5 extends rn{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const n=new zt,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let a=0,o=1,l=32;a1)for(let u=0;u.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{ZU.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(ZU,t)}}setLength(e,t=e*.2,n=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class P5 extends ds{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new zt;r.setAttribute("position",new mt(t,3)),r.setAttribute("color",new mt(n,3));const s=new Ni({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}setColors(e,t,n){const r=new ht,s=this.geometry.attributes.color.array;return r.set(e),r.toArray(s,0),r.toArray(s,3),r.set(t),r.toArray(s,6),r.toArray(s,9),r.set(n),r.toArray(s,12),r.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class I5{constructor(){this.type="ShapePath",this.color=new ht,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new lu,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,r){return this.currentPath.quadraticCurveTo(e,t,n,r),this}bezierCurveTo(e,t,n,r,s,a){return this.currentPath.bezierCurveTo(e,t,n,r,s,a),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(R){const L=[];for(let _=0,S=R.length;_Number.EPSILON){if(E<0&&(x=L[T],A=-A,O=L[D],E=-E),R.yO.y)continue;if(R.y===x.y){if(R.x===x.x)return!0}else{const z=E*(R.x-x.x)-A*(R.y-x.y);if(z===0)return!0;if(z<0)continue;S=!S}}else{if(R.y!==x.y)continue;if(O.x<=R.x&&R.x<=x.x||x.x<=R.x&&R.x<=O.x)return!0}}return S}const r=os.isClockWise,s=this.subPaths;if(s.length===0)return[];let a,o,l;const c=[];if(s.length===1)return o=s[0],l=new $o,l.curves=o.curves,c.push(l),c;let h=!r(s[0].getPoints());h=e?!h:h;const u=[],d=[];let p=[],m=0,v;d[m]=void 0,p[m]=[];for(let R=0,L=s.length;R1){let R=!1,L=0;for(let _=0,S=d.length;_0&&R===!1&&(p=u)}let b;for(let R=0,L=d.length;R{try{const n=++Ad(this,sm)._,r=await i;n>P(this,Bu)&&(et(this,Bu,n),e(r))}catch(n){t(n)}})}},sm=new WeakMap,Bu=new WeakMap,l1),AS=0,Oo,fc,Bc,TS,ko,FS,pc,c1,ES=(c1=class{constructor(){Be(this,Bc);Be(this,Oo,new Set);Z(this,"lastSourceGeneration",0);Be(this,fc,new Set);Be(this,ko,!1);Be(this,pc,new Map)}canReuse(i,e){return i===e||this.canReuseValue(i,e)}canReuseValue(i,e){return!1}debugGetChildren(){return Array.from(P(this,Oo).values())}addChild(i){P(this,Oo).add(i)}removeChild(i){P(this,Oo).delete(i)}markStale(i){if(i.detail.generation!==AS)throw new Error("A TwistyProp was marked stale too late!");if(this.lastSourceGeneration!==i.detail.generation){this.lastSourceGeneration=i.detail.generation;for(const e of P(this,Oo))e.markStale(i);Yt(this,Bc,TS).call(this)}}addRawListener(i,e){P(this,fc).add(i),e!=null&&e.initial&&i()}removeRawListener(i){P(this,fc).delete(i)}addFreshListener(i){const e=new ag;let t=null;const n=async()=>{const r=await e.queue(this.get());t!==null&&this.canReuse(t,r)||(t=r,i(r))};P(this,pc).set(i,n),this.addRawListener(n,{initial:!0})}removeFreshListener(i){this.removeRawListener(P(this,pc).get(i)),P(this,pc).delete(i)}},Oo=new WeakMap,fc=new WeakMap,Bc=new WeakSet,TS=function(){P(this,ko)||(et(this,ko,!0),setTimeout(()=>Yt(this,Bc,FS).call(this),0))},ko=new WeakMap,FS=function(){if(!P(this,ko))throw new Error("Invalid dispatch state!");for(const i of P(this,fc))i();et(this,ko,!1)},pc=new WeakMap,c1),Qr,h1,Xa=(h1=class extends ES{constructor(e){super();Be(this,Qr);et(this,Qr,Em(()=>this.getDefaultValue())),e&&et(this,Qr,this.deriveFromPromiseOrValue(e,P(this,Qr)))}set(e){et(this,Qr,this.deriveFromPromiseOrValue(e,P(this,Qr)));const t={sourceProp:this,value:P(this,Qr),generation:++AS};this.markStale(new CustomEvent("stale",{detail:t}))}async get(){return P(this,Qr)}async deriveFromPromiseOrValue(e,t){return this.derive(await e,t)}},Qr=new WeakMap,h1),vn=class extends Xa{derive(i){return i}},gu=Symbol("no value"),Sa,Ou,mc,Oc,CS,DS,u1,_n=(u1=class extends ES{constructor(e,t){super();Be(this,Oc);Be(this,Sa);Be(this,Ou,null);Be(this,mc,null);this.userVisibleErrorTracker=t,et(this,Sa,e);for(const n of Object.values(e))n.addChild(this)}async get(){var n,r;const e=this.lastSourceGeneration;if(((n=P(this,mc))==null?void 0:n.generation)===e)return P(this,mc).output;const t={generation:e,output:Yt(this,Oc,DS).call(this,Yt(this,Oc,CS).call(this),e,P(this,Ou))};return et(this,mc,t),(r=this.userVisibleErrorTracker)==null||r.reset(),t.output}},Sa=new WeakMap,Ou=new WeakMap,mc=new WeakMap,Oc=new WeakSet,CS=async function(){const e={};for(const[n,r]of Object.entries(P(this,Sa)))e[n]=r.get();const t={};for(const n in P(this,Sa))t[n]=await e[n];return t},DS=async function(e,t,n=null){const r=await e,s=o=>(et(this,Ou,{inputs:r,output:Promise.resolve(o),generation:t}),o);if(!n)return s(await this.derive(r));const a=n.inputs;for(const o in P(this,Sa))if(!P(this,Sa)[o].canReuse(r[o],a[o]))return s(await this.derive(r));return n.output},u1),gc,d1,dd=(d1=class{constructor(){Be(this,gc,[])}addListener(i,e){let t=!1;const n=r=>{t||e(r)};i.addFreshListener(n),P(this,gc).push(()=>{i.removeFreshListener(n),t=!0})}addMultiListener3(i,e){this.addMultiListener(i,e)}addMultiListener(i,e){let t=!1,n=i.length-1;const r=async s=>{if(n>0){n--;return}if(t)return;const a=i.map(l=>l.get()),o=await Promise.all(a);e(o)};for(const s of i)s.addFreshListener(r);P(this,gc).push(()=>{for(const s of i)s.removeFreshListener(r);t=!0})}disconnect(){for(const i of P(this,gc))i()}},gc=new WeakMap,d1),Gc=class{constructor(i){Z(this,"animFrameID",null);Z(this,"animFrame",this.animFrameWrapper.bind(this));this.callback=i}requestIsPending(){return!!this.animFrameID}requestAnimFrame(){this.animFrameID||(this.animFrameID=requestAnimationFrame(this.animFrame))}cancelAnimFrame(){this.animFrameID&&(cancelAnimationFrame(this.animFrameID),this.animFrameID=0)}animFrameWrapper(i){this.animFrameID=0,this.callback(i)}},X9={floating:!0,none:!0},O5=class extends vn{getDefaultValue(){return"auto"}},k5=Math.PI*2,xu=360/k5,N5=class{},Ru;globalThis.HTMLElement?Ru=globalThis.HTMLElement:Ru=N5;var z5=class{define(){}},Mi;globalThis.customElements?Mi=globalThis.customElements:Mi=new z5;var ur,V5=class{replaceSync(){}};globalThis.CSSStyleSheet?ur=globalThis.CSSStyleSheet:ur=V5;var Lr=class extends Ru{constructor(e){super();Z(this,"shadow");Z(this,"contentWrapper");this.shadow=this.attachShadow({mode:(e==null?void 0:e.mode)??"closed"}),this.contentWrapper=document.createElement("div"),this.contentWrapper.classList.add("wrapper"),this.shadow.appendChild(this.contentWrapper)}addCSS(e){this.shadow.adoptedStyleSheets.push(e)}removeCSS(e){const t=this.shadow.adoptedStyleSheets.indexOf(e);typeof t<"u"&&this.shadow.adoptedStyleSheets.splice(t,t+1)}addElement(e){return this.contentWrapper.appendChild(e)}prependElement(e){this.contentWrapper.prepend(e)}removeElement(e){return this.contentWrapper.removeChild(e)}};Mi.define("twisty-managed-custom-element",Lr);var H5=null;async function PS(){return H5??(H5=an(()=>import("./twisty-dynamic-3d-HF7KVBOE-B1cVZzLL.js"),[]))}var ls=Em(async()=>(await PS()).T3I);function Hx(){return devicePixelRatio||1}var IS=new ur;IS.replaceSync(` +}`;class BP{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,n){if(this.texture===null){const r=new Bn,s=e.properties.get(r);s.__webglTexture=t.texture,(t.depthNear!=n.depthNear||t.depthFar!=n.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=r}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new Nr({vertexShader:PP,fragmentShader:IP,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new qn(new Vc(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}}class OP extends sa{constructor(e,t){super();const n=this;let r=null,s=1,a=null,o="local-floor",l=1,c=null,h=null,u=null,d=null,p=null,m=null;const v=new BP,b=t.getContextAttributes();let R=null,L=null;const _=[],S=[],D=new Ie;let T=null;const x=new mi;x.layers.enable(1),x.viewport=new un;const O=new mi;O.layers.enable(2),O.viewport=new un;const A=[x,O],E=new CL;E.layers.enable(1),E.layers.enable(2);let z=null,ie=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(X){let $=_[X];return $===void 0&&($=new n0,_[X]=$),$.getTargetRaySpace()},this.getControllerGrip=function(X){let $=_[X];return $===void 0&&($=new n0,_[X]=$),$.getGripSpace()},this.getHand=function(X){let $=_[X];return $===void 0&&($=new n0,_[X]=$),$.getHandSpace()};function J(X){const $=S.indexOf(X.inputSource);if($===-1)return;const De=_[$];De!==void 0&&(De.update(X.inputSource,X.frame,c||a),De.dispatchEvent({type:X.type,data:X.inputSource}))}function he(){r.removeEventListener("select",J),r.removeEventListener("selectstart",J),r.removeEventListener("selectend",J),r.removeEventListener("squeeze",J),r.removeEventListener("squeezestart",J),r.removeEventListener("squeezeend",J),r.removeEventListener("end",he),r.removeEventListener("inputsourceschange",me);for(let X=0;X<_.length;X++){const $=S[X];$!==null&&(S[X]=null,_[X].disconnect($))}z=null,ie=null,v.reset(),e.setRenderTarget(R),p=null,d=null,u=null,r=null,L=null,_e.stop(),n.isPresenting=!1,e.setPixelRatio(T),e.setSize(D.width,D.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(X){s=X,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(X){o=X,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(X){c=X},this.getBaseLayer=function(){return d!==null?d:p},this.getBinding=function(){return u},this.getFrame=function(){return m},this.getSession=function(){return r},this.setSession=async function(X){if(r=X,r!==null){if(R=e.getRenderTarget(),r.addEventListener("select",J),r.addEventListener("selectstart",J),r.addEventListener("selectend",J),r.addEventListener("squeeze",J),r.addEventListener("squeezestart",J),r.addEventListener("squeezeend",J),r.addEventListener("end",he),r.addEventListener("inputsourceschange",me),b.xrCompatible!==!0&&await t.makeXRCompatible(),T=e.getPixelRatio(),e.getSize(D),r.renderState.layers===void 0){const $={antialias:b.antialias,alpha:!0,depth:b.depth,stencil:b.stencil,framebufferScaleFactor:s};p=new XRWebGLLayer(r,t,$),r.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),L=new kr(p.framebufferWidth,p.framebufferHeight,{format:Ji,type:ea,colorSpace:e.outputColorSpace,stencilBuffer:b.stencil})}else{let $=null,De=null,Le=null;b.depth&&(Le=b.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,$=b.stencil?sl:jo,De=b.stencil?rl:il);const dt={colorFormat:t.RGBA8,depthFormat:Le,scaleFactor:s};u=new XRWebGLBinding(r,t),d=u.createProjectionLayer(dt),r.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),L=new kr(d.textureWidth,d.textureHeight,{format:Ji,type:ea,depthTexture:new XR(d.textureWidth,d.textureHeight,De,void 0,void 0,void 0,void 0,void 0,void 0,$),stencilBuffer:b.stencil,colorSpace:e.outputColorSpace,samples:b.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1})}L.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await r.requestReferenceSpace(o),_e.setContext(r),_e.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode};function me(X){for(let $=0;$=0&&(S[Le]=null,_[Le].disconnect(De))}for(let $=0;$=S.length){S.push(De),Le=at;break}else if(S[at]===null){S[at]=De,Le=at;break}if(Le===-1)break}const dt=_[Le];dt&&dt.connect(De)}}const oe=new V,Ue=new V;function ve(X,$,De){oe.setFromMatrixPosition($.matrixWorld),Ue.setFromMatrixPosition(De.matrixWorld);const Le=oe.distanceTo(Ue),dt=$.projectionMatrix.elements,at=De.projectionMatrix.elements,ut=dt[14]/(dt[10]-1),Y=dt[14]/(dt[10]+1),Te=(dt[9]+1)/dt[5],Se=(dt[9]-1)/dt[5],qe=(dt[8]-1)/dt[0],Ne=(at[8]+1)/at[0],ze=ut*qe,te=ut*Ne,Ye=Le/(-qe+Ne),Lt=Ye*-qe;$.matrixWorld.decompose(X.position,X.quaternion,X.scale),X.translateX(Lt),X.translateZ(Ye),X.matrixWorld.compose(X.position,X.quaternion,X.scale),X.matrixWorldInverse.copy(X.matrixWorld).invert();const H=ut+Ye,C=Y+Ye,de=ze-Lt,Pe=te+(Le-Lt),Ce=Te*Y/C*H,ue=Se*Y/C*H;X.projectionMatrix.makePerspective(de,Pe,Ce,ue,H,C),X.projectionMatrixInverse.copy(X.projectionMatrix).invert()}function We(X,$){$===null?X.matrixWorld.copy(X.matrix):X.matrixWorld.multiplyMatrices($.matrixWorld,X.matrix),X.matrixWorldInverse.copy(X.matrixWorld).invert()}this.updateCamera=function(X){if(r===null)return;v.texture!==null&&(X.near=v.depthNear,X.far=v.depthFar),E.near=O.near=x.near=X.near,E.far=O.far=x.far=X.far,(z!==E.near||ie!==E.far)&&(r.updateRenderState({depthNear:E.near,depthFar:E.far}),z=E.near,ie=E.far,x.near=z,x.far=ie,O.near=z,O.far=ie,x.updateProjectionMatrix(),O.updateProjectionMatrix(),X.updateProjectionMatrix());const $=X.parent,De=E.cameras;We(E,$);for(let Le=0;Le0&&(b.alphaTest.value=R.alphaTest);const L=e.get(R),_=L.envMap,S=L.envMapRotation;_&&(b.envMap.value=_,ao.copy(S),ao.x*=-1,ao.y*=-1,ao.z*=-1,_.isCubeTexture&&_.isRenderTargetTexture===!1&&(ao.y*=-1,ao.z*=-1),b.envMapRotation.value.setFromMatrix4(kP.makeRotationFromEuler(ao)),b.flipEnvMap.value=_.isCubeTexture&&_.isRenderTargetTexture===!1?-1:1,b.reflectivity.value=R.reflectivity,b.ior.value=R.ior,b.refractionRatio.value=R.refractionRatio),R.lightMap&&(b.lightMap.value=R.lightMap,b.lightMapIntensity.value=R.lightMapIntensity,t(R.lightMap,b.lightMapTransform)),R.aoMap&&(b.aoMap.value=R.aoMap,b.aoMapIntensity.value=R.aoMapIntensity,t(R.aoMap,b.aoMapTransform))}function a(b,R){b.diffuse.value.copy(R.color),b.opacity.value=R.opacity,R.map&&(b.map.value=R.map,t(R.map,b.mapTransform))}function o(b,R){b.dashSize.value=R.dashSize,b.totalSize.value=R.dashSize+R.gapSize,b.scale.value=R.scale}function l(b,R,L,_){b.diffuse.value.copy(R.color),b.opacity.value=R.opacity,b.size.value=R.size*L,b.scale.value=_*.5,R.map&&(b.map.value=R.map,t(R.map,b.uvTransform)),R.alphaMap&&(b.alphaMap.value=R.alphaMap,t(R.alphaMap,b.alphaMapTransform)),R.alphaTest>0&&(b.alphaTest.value=R.alphaTest)}function c(b,R){b.diffuse.value.copy(R.color),b.opacity.value=R.opacity,b.rotation.value=R.rotation,R.map&&(b.map.value=R.map,t(R.map,b.mapTransform)),R.alphaMap&&(b.alphaMap.value=R.alphaMap,t(R.alphaMap,b.alphaMapTransform)),R.alphaTest>0&&(b.alphaTest.value=R.alphaTest)}function h(b,R){b.specular.value.copy(R.specular),b.shininess.value=Math.max(R.shininess,1e-4)}function u(b,R){R.gradientMap&&(b.gradientMap.value=R.gradientMap)}function d(b,R){b.metalness.value=R.metalness,R.metalnessMap&&(b.metalnessMap.value=R.metalnessMap,t(R.metalnessMap,b.metalnessMapTransform)),b.roughness.value=R.roughness,R.roughnessMap&&(b.roughnessMap.value=R.roughnessMap,t(R.roughnessMap,b.roughnessMapTransform)),R.envMap&&(b.envMapIntensity.value=R.envMapIntensity)}function p(b,R,L){b.ior.value=R.ior,R.sheen>0&&(b.sheenColor.value.copy(R.sheenColor).multiplyScalar(R.sheen),b.sheenRoughness.value=R.sheenRoughness,R.sheenColorMap&&(b.sheenColorMap.value=R.sheenColorMap,t(R.sheenColorMap,b.sheenColorMapTransform)),R.sheenRoughnessMap&&(b.sheenRoughnessMap.value=R.sheenRoughnessMap,t(R.sheenRoughnessMap,b.sheenRoughnessMapTransform))),R.clearcoat>0&&(b.clearcoat.value=R.clearcoat,b.clearcoatRoughness.value=R.clearcoatRoughness,R.clearcoatMap&&(b.clearcoatMap.value=R.clearcoatMap,t(R.clearcoatMap,b.clearcoatMapTransform)),R.clearcoatRoughnessMap&&(b.clearcoatRoughnessMap.value=R.clearcoatRoughnessMap,t(R.clearcoatRoughnessMap,b.clearcoatRoughnessMapTransform)),R.clearcoatNormalMap&&(b.clearcoatNormalMap.value=R.clearcoatNormalMap,t(R.clearcoatNormalMap,b.clearcoatNormalMapTransform),b.clearcoatNormalScale.value.copy(R.clearcoatNormalScale),R.side===Bi&&b.clearcoatNormalScale.value.negate())),R.dispersion>0&&(b.dispersion.value=R.dispersion),R.iridescence>0&&(b.iridescence.value=R.iridescence,b.iridescenceIOR.value=R.iridescenceIOR,b.iridescenceThicknessMinimum.value=R.iridescenceThicknessRange[0],b.iridescenceThicknessMaximum.value=R.iridescenceThicknessRange[1],R.iridescenceMap&&(b.iridescenceMap.value=R.iridescenceMap,t(R.iridescenceMap,b.iridescenceMapTransform)),R.iridescenceThicknessMap&&(b.iridescenceThicknessMap.value=R.iridescenceThicknessMap,t(R.iridescenceThicknessMap,b.iridescenceThicknessMapTransform))),R.transmission>0&&(b.transmission.value=R.transmission,b.transmissionSamplerMap.value=L.texture,b.transmissionSamplerSize.value.set(L.width,L.height),R.transmissionMap&&(b.transmissionMap.value=R.transmissionMap,t(R.transmissionMap,b.transmissionMapTransform)),b.thickness.value=R.thickness,R.thicknessMap&&(b.thicknessMap.value=R.thicknessMap,t(R.thicknessMap,b.thicknessMapTransform)),b.attenuationDistance.value=R.attenuationDistance,b.attenuationColor.value.copy(R.attenuationColor)),R.anisotropy>0&&(b.anisotropyVector.value.set(R.anisotropy*Math.cos(R.anisotropyRotation),R.anisotropy*Math.sin(R.anisotropyRotation)),R.anisotropyMap&&(b.anisotropyMap.value=R.anisotropyMap,t(R.anisotropyMap,b.anisotropyMapTransform))),b.specularIntensity.value=R.specularIntensity,b.specularColor.value.copy(R.specularColor),R.specularColorMap&&(b.specularColorMap.value=R.specularColorMap,t(R.specularColorMap,b.specularColorMapTransform)),R.specularIntensityMap&&(b.specularIntensityMap.value=R.specularIntensityMap,t(R.specularIntensityMap,b.specularIntensityMapTransform))}function m(b,R){R.matcap&&(b.matcap.value=R.matcap)}function v(b,R){const L=e.get(R).light;b.referencePosition.value.setFromMatrixPosition(L.matrixWorld),b.nearDistance.value=L.shadow.camera.near,b.farDistance.value=L.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:r}}function zP(i,e,t,n){let r={},s={},a=[];const o=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function l(L,_){const S=_.program;n.uniformBlockBinding(L,S)}function c(L,_){let S=r[L.id];S===void 0&&(m(L),S=h(L),r[L.id]=S,L.addEventListener("dispose",b));const D=_.program;n.updateUBOMapping(L,D);const T=e.render.frame;s[L.id]!==T&&(d(L),s[L.id]=T)}function h(L){const _=u();L.__bindingPointIndex=_;const S=i.createBuffer(),D=L.__size,T=L.usage;return i.bindBuffer(i.UNIFORM_BUFFER,S),i.bufferData(i.UNIFORM_BUFFER,D,T),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,_,S),S}function u(){for(let L=0;L0&&(S+=D-T),L.__size=S,L.__cache={},this}function v(L){const _={boundary:0,storage:0};return typeof L=="number"||typeof L=="boolean"?(_.boundary=4,_.storage=4):L.isVector2?(_.boundary=8,_.storage=8):L.isVector3||L.isColor?(_.boundary=16,_.storage=12):L.isVector4?(_.boundary=16,_.storage=16):L.isMatrix3?(_.boundary=48,_.storage=48):L.isMatrix4?(_.boundary=64,_.storage=64):L.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",L),_}function b(L){const _=L.target;_.removeEventListener("dispose",b);const S=a.indexOf(_.__bindingPointIndex);a.splice(S,1),i.deleteBuffer(r[_.id]),delete r[_.id],delete s[_.id]}function R(){for(const L in r)i.deleteBuffer(r[L]);a=[],r={},s={}}return{bind:l,update:c,dispose:R}}class VP{constructor(e={}){const{canvas:t=xL(),context:n=null,depth:r=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1}=e;this.isWebGLRenderer=!0;let d;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");d=n.getContextAttributes().alpha}else d=a;const p=new Uint32Array(4),m=new Int32Array(4);let v=null,b=null;const R=[],L=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=vr,this.toneMapping=Xs,this.toneMappingExposure=1;const _=this;let S=!1,D=0,T=0,x=null,O=-1,A=null;const E=new un,z=new un;let ie=null;const J=new ht(0);let he=0,me=t.width,oe=t.height,Ue=1,ve=null,We=null;const je=new un(0,0,me,oe),q=new un(0,0,me,oe);let le=!1;const _e=new ad;let X=!1,$=!1;const De=new Mt,Le=new V,dt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let at=!1;function ut(){return x===null?Ue:1}let Y=n;function Te(B,ee){return t.getContext(B,ee)}try{const B={alpha:!0,depth:r,stencil:s,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Fm}`),t.addEventListener("webglcontextlost",st,!1),t.addEventListener("webglcontextrestored",Ae,!1),t.addEventListener("webglcontextcreationerror",Fe,!1),Y===null){const ee="webgl2";if(Y=Te(ee,B),Y===null)throw Te(ee)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(B){throw console.error("THREE.WebGLRenderer: "+B.message),B}let Se,qe,Ne,ze,te,Ye,Lt,H,C,de,Pe,Ce,ue,ot,$e,Oe,wt,Ve,rt,Tt,gt,Xe,At,Pt;function on(){Se=new QC(Y),Se.init(),Xe=new FL(Y,Se),qe=new XC(Y,Se,e,Xe),Ne=new FP(Y),ze=new nD(Y),te=new vP,Ye=new CP(Y,Se,Ne,te,qe,Xe,ze),Lt=new YC(_),H=new JC(_),C=new cT(Y),At=new ZC(Y,C),de=new eD(Y,C,ze,At),Pe=new rD(Y,de,C,ze),rt=new iD(Y,qe,Ye),Oe=new jC(te),Ce=new RP(_,Lt,H,Se,qe,At,Oe),ue=new NP(_,te),ot=new UP,$e=new wP(Se),Ve=new GC(_,Lt,H,Ne,Pe,d,l),wt=new TP(_,Pe,qe),Pt=new zP(Y,ze,qe,Ne),Tt=new qC(Y,Se,ze),gt=new tD(Y,Se,ze),ze.programs=Ce.programs,_.capabilities=qe,_.extensions=Se,_.properties=te,_.renderLists=ot,_.shadowMap=wt,_.state=Ne,_.info=ze}on();const K=new OP(_,Y);this.xr=K,this.getContext=function(){return Y},this.getContextAttributes=function(){return Y.getContextAttributes()},this.forceContextLoss=function(){const B=Se.get("WEBGL_lose_context");B&&B.loseContext()},this.forceContextRestore=function(){const B=Se.get("WEBGL_lose_context");B&&B.restoreContext()},this.getPixelRatio=function(){return Ue},this.setPixelRatio=function(B){B!==void 0&&(Ue=B,this.setSize(me,oe,!1))},this.getSize=function(B){return B.set(me,oe)},this.setSize=function(B,ee,pe=!0){if(K.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}me=B,oe=ee,t.width=Math.floor(B*Ue),t.height=Math.floor(ee*Ue),pe===!0&&(t.style.width=B+"px",t.style.height=ee+"px"),this.setViewport(0,0,B,ee)},this.getDrawingBufferSize=function(B){return B.set(me*Ue,oe*Ue).floor()},this.setDrawingBufferSize=function(B,ee,pe){me=B,oe=ee,Ue=pe,t.width=Math.floor(B*pe),t.height=Math.floor(ee*pe),this.setViewport(0,0,B,ee)},this.getCurrentViewport=function(B){return B.copy(E)},this.getViewport=function(B){return B.copy(je)},this.setViewport=function(B,ee,pe,Re){B.isVector4?je.set(B.x,B.y,B.z,B.w):je.set(B,ee,pe,Re),Ne.viewport(E.copy(je).multiplyScalar(Ue).round())},this.getScissor=function(B){return B.copy(q)},this.setScissor=function(B,ee,pe,Re){B.isVector4?q.set(B.x,B.y,B.z,B.w):q.set(B,ee,pe,Re),Ne.scissor(z.copy(q).multiplyScalar(Ue).round())},this.getScissorTest=function(){return le},this.setScissorTest=function(B){Ne.setScissorTest(le=B)},this.setOpaqueSort=function(B){ve=B},this.setTransparentSort=function(B){We=B},this.getClearColor=function(B){return B.copy(Ve.getClearColor())},this.setClearColor=function(){Ve.setClearColor.apply(Ve,arguments)},this.getClearAlpha=function(){return Ve.getClearAlpha()},this.setClearAlpha=function(){Ve.setClearAlpha.apply(Ve,arguments)},this.clear=function(B=!0,ee=!0,pe=!0){let Re=0;if(B){let ae=!1;if(x!==null){const He=x.texture.format;ae=He===kR||He===OR||He===BR}if(ae){const He=x.texture.type,tt=He===ea||He===il||He===Qh||He===rl||He===DR||He===PR,ft=Ve.getClearColor(),it=Ve.getClearAlpha(),Rt=ft.r,Ut=ft.g,vt=ft.b;tt?(p[0]=Rt,p[1]=Ut,p[2]=vt,p[3]=it,Y.clearBufferuiv(Y.COLOR,0,p)):(m[0]=Rt,m[1]=Ut,m[2]=vt,m[3]=it,Y.clearBufferiv(Y.COLOR,0,m))}else Re|=Y.COLOR_BUFFER_BIT}ee&&(Re|=Y.DEPTH_BUFFER_BIT),pe&&(Re|=Y.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),Y.clear(Re)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",st,!1),t.removeEventListener("webglcontextrestored",Ae,!1),t.removeEventListener("webglcontextcreationerror",Fe,!1),ot.dispose(),$e.dispose(),te.dispose(),Lt.dispose(),H.dispose(),Pe.dispose(),At.dispose(),Pt.dispose(),Ce.dispose(),K.dispose(),K.removeEventListener("sessionstart",ei),K.removeEventListener("sessionend",ti),Vn.stop()};function st(B){B.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),S=!0}function Ae(){console.log("THREE.WebGLRenderer: Context Restored."),S=!1;const B=ze.autoReset,ee=wt.enabled,pe=wt.autoUpdate,Re=wt.needsUpdate,ae=wt.type;on(),ze.autoReset=B,wt.enabled=ee,wt.autoUpdate=pe,wt.needsUpdate=Re,wt.type=ae}function Fe(B){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",B.statusMessage)}function Ze(B){const ee=B.target;ee.removeEventListener("dispose",Ze),bt(ee)}function bt(B){Ht(B),te.remove(B)}function Ht(B){const ee=te.get(B).programs;ee!==void 0&&(ee.forEach(function(pe){Ce.releaseProgram(pe)}),B.isShaderMaterial&&Ce.releaseShaderCache(B))}this.renderBufferDirect=function(B,ee,pe,Re,ae,He){ee===null&&(ee=dt);const tt=ae.isMesh&&ae.matrixWorld.determinant()<0,ft=ps(B,ee,pe,Re,ae);Ne.setMaterial(Re,tt);let it=pe.index,Rt=1;if(Re.wireframe===!0){if(it=de.getWireframeAttribute(pe),it===void 0)return;Rt=2}const Ut=pe.drawRange,vt=pe.attributes.position;let Kt=Ut.start*Rt,mn=(Ut.start+Ut.count)*Rt;He!==null&&(Kt=Math.max(Kt,He.start*Rt),mn=Math.min(mn,(He.start+He.count)*Rt)),it!==null?(Kt=Math.max(Kt,0),mn=Math.min(mn,it.count)):vt!=null&&(Kt=Math.max(Kt,0),mn=Math.min(mn,vt.count));const k=mn-Kt;if(k<0||k===1/0)return;At.setup(ae,Re,ft,pe,it);let G,se=Tt;if(it!==null&&(G=C.get(it),se=gt,se.setIndex(G)),ae.isMesh)Re.wireframe===!0?(Ne.setLineWidth(Re.wireframeLinewidth*ut()),se.setMode(Y.LINES)):se.setMode(Y.TRIANGLES);else if(ae.isLine){let re=Re.linewidth;re===void 0&&(re=1),Ne.setLineWidth(re*ut()),ae.isLineSegments?se.setMode(Y.LINES):ae.isLineLoop?se.setMode(Y.LINE_LOOP):se.setMode(Y.LINE_STRIP)}else ae.isPoints?se.setMode(Y.POINTS):ae.isSprite&&se.setMode(Y.TRIANGLES);if(ae.isBatchedMesh)ae._multiDrawInstances!==null?se.renderMultiDrawInstances(ae._multiDrawStarts,ae._multiDrawCounts,ae._multiDrawCount,ae._multiDrawInstances):se.renderMultiDraw(ae._multiDrawStarts,ae._multiDrawCounts,ae._multiDrawCount);else if(ae.isInstancedMesh)se.renderInstances(Kt,k,ae.count);else if(pe.isInstancedBufferGeometry){const re=pe._maxInstanceCount!==void 0?pe._maxInstanceCount:1/0,Me=Math.min(pe.instanceCount,re);se.renderInstances(Kt,k,Me)}else se.render(Kt,k)};function Vt(B,ee,pe){B.transparent===!0&&B.side===ns&&B.forceSinglePass===!1?(B.side=Bi,B.needsUpdate=!0,Gr(B,ee,pe),B.side=Js,B.needsUpdate=!0,Gr(B,ee,pe),B.side=ns):Gr(B,ee,pe)}this.compile=function(B,ee,pe=null){pe===null&&(pe=B),b=$e.get(pe),b.init(ee),L.push(b),pe.traverseVisible(function(ae){ae.isLight&&ae.layers.test(ee.layers)&&(b.pushLight(ae),ae.castShadow&&b.pushShadow(ae))}),B!==pe&&B.traverseVisible(function(ae){ae.isLight&&ae.layers.test(ee.layers)&&(b.pushLight(ae),ae.castShadow&&b.pushShadow(ae))}),b.setupLights();const Re=new Set;return B.traverse(function(ae){const He=ae.material;if(He)if(Array.isArray(He))for(let tt=0;tt{function He(){if(Re.forEach(function(tt){te.get(tt).currentProgram.isReady()&&Re.delete(tt)}),Re.size===0){ae(B);return}setTimeout(He,10)}Se.get("KHR_parallel_shader_compile")!==null?He():setTimeout(He,10)})};let Xt=null;function Wt(B){Xt&&Xt(B)}function ei(){Vn.stop()}function ti(){Vn.start()}const Vn=new SL;Vn.setAnimationLoop(Wt),typeof self<"u"&&Vn.setContext(self),this.setAnimationLoop=function(B){Xt=B,K.setAnimationLoop(B),B===null?Vn.stop():Vn.start()},K.addEventListener("sessionstart",ei),K.addEventListener("sessionend",ti),this.render=function(B,ee){if(ee!==void 0&&ee.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(S===!0)return;if(B.matrixWorldAutoUpdate===!0&&B.updateMatrixWorld(),ee.parent===null&&ee.matrixWorldAutoUpdate===!0&&ee.updateMatrixWorld(),K.enabled===!0&&K.isPresenting===!0&&(K.cameraAutoUpdate===!0&&K.updateCamera(ee),ee=K.getCamera()),B.isScene===!0&&B.onBeforeRender(_,B,ee,x),b=$e.get(B,L.length),b.init(ee),L.push(b),De.multiplyMatrices(ee.projectionMatrix,ee.matrixWorldInverse),_e.setFromProjectionMatrix(De),$=this.localClippingEnabled,X=Oe.init(this.clippingPlanes,$),v=ot.get(B,R.length),v.init(),R.push(v),K.enabled===!0&&K.isPresenting===!0){const He=_.xr.getDepthSensingMesh();He!==null&&Ei(He,ee,-1/0,_.sortObjects)}Ei(B,ee,0,_.sortObjects),v.finish(),_.sortObjects===!0&&v.sort(ve,We),at=K.enabled===!1||K.isPresenting===!1||K.hasDepthSensing()===!1,at&&Ve.addToRenderList(v,B),this.info.render.frame++,X===!0&&Oe.beginShadows();const pe=b.state.shadowsArray;wt.render(pe,B,ee),X===!0&&Oe.endShadows(),this.info.autoReset===!0&&this.info.reset();const Re=v.opaque,ae=v.transmissive;if(b.setupLights(),ee.isArrayCamera){const He=ee.cameras;if(ae.length>0)for(let tt=0,ft=He.length;tt0&&Vi(Re,ae,B,ee),at&&Ve.render(B),zi(v,B,ee);x!==null&&(Ye.updateMultisampleRenderTarget(x),Ye.updateRenderTargetMipmap(x)),B.isScene===!0&&B.onAfterRender(_,B,ee),At.resetDefaultState(),O=-1,A=null,L.pop(),L.length>0?(b=L[L.length-1],X===!0&&Oe.setGlobalState(_.clippingPlanes,b.state.camera)):b=null,R.pop(),R.length>0?v=R[R.length-1]:v=null};function Ei(B,ee,pe,Re){if(B.visible===!1)return;if(B.layers.test(ee.layers)){if(B.isGroup)pe=B.renderOrder;else if(B.isLOD)B.autoUpdate===!0&&B.update(ee);else if(B.isLight)b.pushLight(B),B.castShadow&&b.pushShadow(B);else if(B.isSprite){if(!B.frustumCulled||_e.intersectsSprite(B)){Re&&Le.setFromMatrixPosition(B.matrixWorld).applyMatrix4(De);const tt=Pe.update(B),ft=B.material;ft.visible&&v.push(B,tt,ft,pe,Le.z,null)}}else if((B.isMesh||B.isLine||B.isPoints)&&(!B.frustumCulled||_e.intersectsObject(B))){const tt=Pe.update(B),ft=B.material;if(Re&&(B.boundingSphere!==void 0?(B.boundingSphere===null&&B.computeBoundingSphere(),Le.copy(B.boundingSphere.center)):(tt.boundingSphere===null&&tt.computeBoundingSphere(),Le.copy(tt.boundingSphere.center)),Le.applyMatrix4(B.matrixWorld).applyMatrix4(De)),Array.isArray(ft)){const it=tt.groups;for(let Rt=0,Ut=it.length;Rt0&&er(ae,ee,pe),He.length>0&&er(He,ee,pe),tt.length>0&&er(tt,ee,pe),Ne.buffers.depth.setTest(!0),Ne.buffers.depth.setMask(!0),Ne.buffers.color.setMask(!0),Ne.setPolygonOffset(!1)}function Vi(B,ee,pe,Re){if((pe.isScene===!0?pe.overrideMaterial:null)!==null)return;b.state.transmissionRenderTarget[Re.id]===void 0&&(b.state.transmissionRenderTarget[Re.id]=new kr(1,1,{generateMipmaps:!0,type:Se.has("EXT_color_buffer_half_float")||Se.has("EXT_color_buffer_float")?id:ea,minFilter:rs,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:sn.workingColorSpace}));const He=b.state.transmissionRenderTarget[Re.id],tt=Re.viewport||E;He.setSize(tt.z,tt.w);const ft=_.getRenderTarget();_.setRenderTarget(He),_.getClearColor(J),he=_.getClearAlpha(),he<1&&_.setClearColor(16777215,.5),at?Ve.render(pe):_.clear();const it=_.toneMapping;_.toneMapping=Xs;const Rt=Re.viewport;if(Re.viewport!==void 0&&(Re.viewport=void 0),b.setupLightsView(Re),X===!0&&Oe.setGlobalState(_.clippingPlanes,Re),er(B,pe,Re),Ye.updateMultisampleRenderTarget(He),Ye.updateRenderTargetMipmap(He),Se.has("WEBGL_multisampled_render_to_texture")===!1){let Ut=!1;for(let vt=0,Kt=ee.length;vt0),vt=!!pe.morphAttributes.position,Kt=!!pe.morphAttributes.normal,mn=!!pe.morphAttributes.color;let k=Xs;Re.toneMapped&&(x===null||x.isXRRenderTarget===!0)&&(k=_.toneMapping);const G=pe.morphAttributes.position||pe.morphAttributes.normal||pe.morphAttributes.color,se=G!==void 0?G.length:0,re=te.get(Re),Me=b.state.lights;if(X===!0&&($===!0||B!==A)){const pn=B===A&&Re.id===O;Oe.setState(Re,B,pn)}let ge=!1;Re.version===re.__version?(re.needsLights&&re.lightsStateVersion!==Me.state.version||re.outputColorSpace!==ft||ae.isBatchedMesh&&re.batching===!1||!ae.isBatchedMesh&&re.batching===!0||ae.isBatchedMesh&&re.batchingColor===!0&&ae.colorTexture===null||ae.isBatchedMesh&&re.batchingColor===!1&&ae.colorTexture!==null||ae.isInstancedMesh&&re.instancing===!1||!ae.isInstancedMesh&&re.instancing===!0||ae.isSkinnedMesh&&re.skinning===!1||!ae.isSkinnedMesh&&re.skinning===!0||ae.isInstancedMesh&&re.instancingColor===!0&&ae.instanceColor===null||ae.isInstancedMesh&&re.instancingColor===!1&&ae.instanceColor!==null||ae.isInstancedMesh&&re.instancingMorph===!0&&ae.morphTexture===null||ae.isInstancedMesh&&re.instancingMorph===!1&&ae.morphTexture!==null||re.envMap!==it||Re.fog===!0&&re.fog!==He||re.numClippingPlanes!==void 0&&(re.numClippingPlanes!==Oe.numPlanes||re.numIntersection!==Oe.numIntersection)||re.vertexAlphas!==Rt||re.vertexTangents!==Ut||re.morphTargets!==vt||re.morphNormals!==Kt||re.morphColors!==mn||re.toneMapping!==k||re.morphTargetsCount!==se)&&(ge=!0):(ge=!0,re.__version=Re.version);let ke=re.currentProgram;ge===!0&&(ke=Gr(Re,ee,ae));let pt=!1,Ke=!1,_t=!1;const Ft=ke.getUniforms(),En=re.uniforms;if(Ne.useProgram(ke.program)&&(pt=!0,Ke=!0,_t=!0),Re.id!==O&&(O=Re.id,Ke=!0),pt||A!==B){Ft.setValue(Y,"projectionMatrix",B.projectionMatrix),Ft.setValue(Y,"viewMatrix",B.matrixWorldInverse);const pn=Ft.map.cameraPosition;pn!==void 0&&pn.setValue(Y,Le.setFromMatrixPosition(B.matrixWorld)),qe.logarithmicDepthBuffer&&Ft.setValue(Y,"logDepthBufFC",2/(Math.log(B.far+1)/Math.LN2)),(Re.isMeshPhongMaterial||Re.isMeshToonMaterial||Re.isMeshLambertMaterial||Re.isMeshBasicMaterial||Re.isMeshStandardMaterial||Re.isShaderMaterial)&&Ft.setValue(Y,"isOrthographic",B.isOrthographicCamera===!0),A!==B&&(A=B,Ke=!0,_t=!0)}if(ae.isSkinnedMesh){Ft.setOptional(Y,ae,"bindMatrix"),Ft.setOptional(Y,ae,"bindMatrixInverse");const pn=ae.skeleton;pn&&(pn.boneTexture===null&&pn.computeBoneTexture(),Ft.setValue(Y,"boneTexture",pn.boneTexture,Ye))}ae.isBatchedMesh&&(Ft.setOptional(Y,ae,"batchingTexture"),Ft.setValue(Y,"batchingTexture",ae._matricesTexture,Ye),Ft.setOptional(Y,ae,"batchingColorTexture"),ae._colorsTexture!==null&&Ft.setValue(Y,"batchingColorTexture",ae._colorsTexture,Ye));const Hn=pe.morphAttributes;if((Hn.position!==void 0||Hn.normal!==void 0||Hn.color!==void 0)&&rt.update(ae,pe,ke),(Ke||re.receiveShadow!==ae.receiveShadow)&&(re.receiveShadow=ae.receiveShadow,Ft.setValue(Y,"receiveShadow",ae.receiveShadow)),Re.isMeshGouraudMaterial&&Re.envMap!==null&&(En.envMap.value=it,En.flipEnvMap.value=it.isCubeTexture&&it.isRenderTargetTexture===!1?-1:1),Re.isMeshStandardMaterial&&Re.envMap===null&&ee.environment!==null&&(En.envMapIntensity.value=ee.environmentIntensity),Ke&&(Ft.setValue(Y,"toneMappingExposure",_.toneMappingExposure),re.needsLights&&Ya(En,_t),He&&Re.fog===!0&&ue.refreshFogUniforms(En,He),ue.refreshMaterialUniforms(En,Re,Ue,oe,b.state.transmissionRenderTarget[B.id]),ip.upload(Y,fs(re),En,Ye)),Re.isShaderMaterial&&Re.uniformsNeedUpdate===!0&&(ip.upload(Y,fs(re),En,Ye),Re.uniformsNeedUpdate=!1),Re.isSpriteMaterial&&Ft.setValue(Y,"center",ae.center),Ft.setValue(Y,"modelViewMatrix",ae.modelViewMatrix),Ft.setValue(Y,"normalMatrix",ae.normalMatrix),Ft.setValue(Y,"modelMatrix",ae.matrixWorld),Re.isShaderMaterial||Re.isRawShaderMaterial){const pn=Re.uniformsGroups;for(let Xn=0,xi=pn.length;Xn0&&Ye.useMultisampledRTT(B)===!1?ae=te.get(B).__webglMultisampledFramebuffer:Array.isArray(Ut)?ae=Ut[pe]:ae=Ut,E.copy(B.viewport),z.copy(B.scissor),ie=B.scissorTest}else E.copy(je).multiplyScalar(Ue).floor(),z.copy(q).multiplyScalar(Ue).floor(),ie=le;if(Ne.bindFramebuffer(Y.FRAMEBUFFER,ae)&&Re&&Ne.drawBuffers(B,ae),Ne.viewport(E),Ne.scissor(z),Ne.setScissorTest(ie),He){const it=te.get(B.texture);Y.framebufferTexture2D(Y.FRAMEBUFFER,Y.COLOR_ATTACHMENT0,Y.TEXTURE_CUBE_MAP_POSITIVE_X+ee,it.__webglTexture,pe)}else if(tt){const it=te.get(B.texture),Rt=ee||0;Y.framebufferTextureLayer(Y.FRAMEBUFFER,Y.COLOR_ATTACHMENT0,it.__webglTexture,pe||0,Rt)}O=-1},this.readRenderTargetPixels=function(B,ee,pe,Re,ae,He,tt){if(!(B&&B.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ft=te.get(B).__webglFramebuffer;if(B.isWebGLCubeRenderTarget&&tt!==void 0&&(ft=ft[tt]),ft){Ne.bindFramebuffer(Y.FRAMEBUFFER,ft);try{const it=B.texture,Rt=it.format,Ut=it.type;if(!qe.textureFormatReadable(Rt)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!qe.textureTypeReadable(Ut)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}ee>=0&&ee<=B.width-Re&&pe>=0&&pe<=B.height-ae&&Y.readPixels(ee,pe,Re,ae,Xe.convert(Rt),Xe.convert(Ut),He)}finally{const it=x!==null?te.get(x).__webglFramebuffer:null;Ne.bindFramebuffer(Y.FRAMEBUFFER,it)}}},this.readRenderTargetPixelsAsync=async function(B,ee,pe,Re,ae,He,tt){if(!(B&&B.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let ft=te.get(B).__webglFramebuffer;if(B.isWebGLCubeRenderTarget&&tt!==void 0&&(ft=ft[tt]),ft){Ne.bindFramebuffer(Y.FRAMEBUFFER,ft);try{const it=B.texture,Rt=it.format,Ut=it.type;if(!qe.textureFormatReadable(Rt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!qe.textureTypeReadable(Ut))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(ee>=0&&ee<=B.width-Re&&pe>=0&&pe<=B.height-ae){const vt=Y.createBuffer();Y.bindBuffer(Y.PIXEL_PACK_BUFFER,vt),Y.bufferData(Y.PIXEL_PACK_BUFFER,He.byteLength,Y.STREAM_READ),Y.readPixels(ee,pe,Re,ae,Xe.convert(Rt),Xe.convert(Ut),0),Y.flush();const Kt=Y.fenceSync(Y.SYNC_GPU_COMMANDS_COMPLETE,0);await PE(Y,Kt,4);try{Y.bindBuffer(Y.PIXEL_PACK_BUFFER,vt),Y.getBufferSubData(Y.PIXEL_PACK_BUFFER,0,He)}finally{Y.deleteBuffer(vt),Y.deleteSync(Kt)}return He}}finally{const it=x!==null?te.get(x).__webglFramebuffer:null;Ne.bindFramebuffer(Y.FRAMEBUFFER,it)}}},this.copyFramebufferToTexture=function(B,ee=null,pe=0){B.isTexture!==!0&&(console.warn("WebGLRenderer: copyFramebufferToTexture function signature has changed."),ee=arguments[0]||null,B=arguments[1]);const Re=Math.pow(2,-pe),ae=Math.floor(B.image.width*Re),He=Math.floor(B.image.height*Re),tt=ee!==null?ee.x:0,ft=ee!==null?ee.y:0;Ye.setTexture2D(B,0),Y.copyTexSubImage2D(Y.TEXTURE_2D,pe,0,0,tt,ft,ae,He),Ne.unbindTexture()},this.copyTextureToTexture=function(B,ee,pe=null,Re=null,ae=0){B.isTexture!==!0&&(console.warn("WebGLRenderer: copyTextureToTexture function signature has changed."),Re=arguments[0]||null,B=arguments[1],ee=arguments[2],ae=arguments[3]||0,pe=null);let He,tt,ft,it,Rt,Ut;pe!==null?(He=pe.max.x-pe.min.x,tt=pe.max.y-pe.min.y,ft=pe.min.x,it=pe.min.y):(He=B.image.width,tt=B.image.height,ft=0,it=0),Re!==null?(Rt=Re.x,Ut=Re.y):(Rt=0,Ut=0);const vt=Xe.convert(ee.format),Kt=Xe.convert(ee.type);Ye.setTexture2D(ee,0),Y.pixelStorei(Y.UNPACK_FLIP_Y_WEBGL,ee.flipY),Y.pixelStorei(Y.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ee.premultiplyAlpha),Y.pixelStorei(Y.UNPACK_ALIGNMENT,ee.unpackAlignment);const mn=Y.getParameter(Y.UNPACK_ROW_LENGTH),k=Y.getParameter(Y.UNPACK_IMAGE_HEIGHT),G=Y.getParameter(Y.UNPACK_SKIP_PIXELS),se=Y.getParameter(Y.UNPACK_SKIP_ROWS),re=Y.getParameter(Y.UNPACK_SKIP_IMAGES),Me=B.isCompressedTexture?B.mipmaps[ae]:B.image;Y.pixelStorei(Y.UNPACK_ROW_LENGTH,Me.width),Y.pixelStorei(Y.UNPACK_IMAGE_HEIGHT,Me.height),Y.pixelStorei(Y.UNPACK_SKIP_PIXELS,ft),Y.pixelStorei(Y.UNPACK_SKIP_ROWS,it),B.isDataTexture?Y.texSubImage2D(Y.TEXTURE_2D,ae,Rt,Ut,He,tt,vt,Kt,Me.data):B.isCompressedTexture?Y.compressedTexSubImage2D(Y.TEXTURE_2D,ae,Rt,Ut,Me.width,Me.height,vt,Me.data):Y.texSubImage2D(Y.TEXTURE_2D,ae,Rt,Ut,vt,Kt,Me),Y.pixelStorei(Y.UNPACK_ROW_LENGTH,mn),Y.pixelStorei(Y.UNPACK_IMAGE_HEIGHT,k),Y.pixelStorei(Y.UNPACK_SKIP_PIXELS,G),Y.pixelStorei(Y.UNPACK_SKIP_ROWS,se),Y.pixelStorei(Y.UNPACK_SKIP_IMAGES,re),ae===0&&ee.generateMipmaps&&Y.generateMipmap(Y.TEXTURE_2D),Ne.unbindTexture()},this.copyTextureToTexture3D=function(B,ee,pe=null,Re=null,ae=0){B.isTexture!==!0&&(console.warn("WebGLRenderer: copyTextureToTexture3D function signature has changed."),pe=arguments[0]||null,Re=arguments[1]||null,B=arguments[2],ee=arguments[3],ae=arguments[4]||0);let He,tt,ft,it,Rt,Ut,vt,Kt,mn;const k=B.isCompressedTexture?B.mipmaps[ae]:B.image;pe!==null?(He=pe.max.x-pe.min.x,tt=pe.max.y-pe.min.y,ft=pe.max.z-pe.min.z,it=pe.min.x,Rt=pe.min.y,Ut=pe.min.z):(He=k.width,tt=k.height,ft=k.depth,it=0,Rt=0,Ut=0),Re!==null?(vt=Re.x,Kt=Re.y,mn=Re.z):(vt=0,Kt=0,mn=0);const G=Xe.convert(ee.format),se=Xe.convert(ee.type);let re;if(ee.isData3DTexture)Ye.setTexture3D(ee,0),re=Y.TEXTURE_3D;else if(ee.isDataArrayTexture||ee.isCompressedArrayTexture)Ye.setTexture2DArray(ee,0),re=Y.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}Y.pixelStorei(Y.UNPACK_FLIP_Y_WEBGL,ee.flipY),Y.pixelStorei(Y.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ee.premultiplyAlpha),Y.pixelStorei(Y.UNPACK_ALIGNMENT,ee.unpackAlignment);const Me=Y.getParameter(Y.UNPACK_ROW_LENGTH),ge=Y.getParameter(Y.UNPACK_IMAGE_HEIGHT),ke=Y.getParameter(Y.UNPACK_SKIP_PIXELS),pt=Y.getParameter(Y.UNPACK_SKIP_ROWS),Ke=Y.getParameter(Y.UNPACK_SKIP_IMAGES);Y.pixelStorei(Y.UNPACK_ROW_LENGTH,k.width),Y.pixelStorei(Y.UNPACK_IMAGE_HEIGHT,k.height),Y.pixelStorei(Y.UNPACK_SKIP_PIXELS,it),Y.pixelStorei(Y.UNPACK_SKIP_ROWS,Rt),Y.pixelStorei(Y.UNPACK_SKIP_IMAGES,Ut),B.isDataTexture||B.isData3DTexture?Y.texSubImage3D(re,ae,vt,Kt,mn,He,tt,ft,G,se,k.data):ee.isCompressedArrayTexture?Y.compressedTexSubImage3D(re,ae,vt,Kt,mn,He,tt,ft,G,k.data):Y.texSubImage3D(re,ae,vt,Kt,mn,He,tt,ft,G,se,k),Y.pixelStorei(Y.UNPACK_ROW_LENGTH,Me),Y.pixelStorei(Y.UNPACK_IMAGE_HEIGHT,ge),Y.pixelStorei(Y.UNPACK_SKIP_PIXELS,ke),Y.pixelStorei(Y.UNPACK_SKIP_ROWS,pt),Y.pixelStorei(Y.UNPACK_SKIP_IMAGES,Ke),ae===0&&ee.generateMipmaps&&Y.generateMipmap(re),Ne.unbindTexture()},this.initRenderTarget=function(B){te.get(B).__webglFramebuffer===void 0&&Ye.setupRenderTarget(B)},this.initTexture=function(B){B.isCubeTexture?Ye.setTextureCube(B,0):B.isData3DTexture?Ye.setTexture3D(B,0):B.isDataArrayTexture||B.isCompressedArrayTexture?Ye.setTexture2DArray(B,0):Ye.setTexture2D(B,0),Ne.unbindTexture()},this.resetState=function(){D=0,T=0,x=null,Ne.reset(),At.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ss}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=e===Pm?"display-p3":"srgb",t.unpackColorSpace=sn.workingColorSpace===rd?"display-p3":"srgb"}}class zm{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new ht(e),this.density=t}clone(){return new zm(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class Vm{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new ht(e),this.near=t,this.far=n}clone(){return new Vm(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class DL extends rn{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new ki,this.environmentIntensity=1,this.environmentRotation=new ki,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__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()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class Hm{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=su,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=hr()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return HR("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,s=this.stride;re.far||t.push({distance:l,point:ih.clone(),uv:ar.getInterpolation(ih,Jd,sh,Qd,tU,i0,nU,new Ie),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function ef(i,e,t,n,r,s){Gl.subVectors(i,t).addScalar(.5).multiply(n),r!==void 0?(rh.x=s*Gl.x-r*Gl.y,rh.y=r*Gl.x+s*Gl.y):rh.copy(Gl),i.copy(e),i.x+=rh.x,i.y+=rh.y,i.applyMatrix4(PL)}const tf=new V,iU=new V;class BL extends rn{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);const t=e.levels;for(let n=0,r=t.length;n0){let n,r;for(n=1,r=t.length;n0){tf.setFromMatrixPosition(this.matrixWorld);const r=e.ray.origin.distanceTo(tf);this.getObjectForDistance(r).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){tf.setFromMatrixPosition(e.matrixWorld),iU.setFromMatrixPosition(this.matrixWorld);const n=tf.distanceTo(iU)/e.zoom;t[0].object.visible=!0;let r,s;for(r=1,s=t.length;r=a)t[r-1].object.visible=!1,t[r].object.visible=!0;else break}for(this._currentLevel=r-1;r=n.length&&n.push({start:-1,count:-1,z:-1});const s=n[this.index];r.push(s),this.index++,s.start=e.start,s.count=e.count,s.z=t}reset(){this.list.length=0,this.index=0}}const ql="batchId",va=new Mt,a0=new Mt,jP=new Mt,YP=new ht(1,1,1),dU=new Mt,o0=new ad,sf=new Oi,oo=new Si,lh=new V,fU=new V,$P=new V,l0=new XP,yi=new qn,af=[];function KP(i,e,t=0){const n=e.itemSize;if(i.isInterleavedBufferAttribute||i.array.constructor!==e.array.constructor){const r=i.count;for(let s=0;s65536?new Uint32Array(s):new Uint16Array(s);t.setIndex(new fn(o,1))}const a=r>65536?new Uint32Array(n):new Uint16Array(n);t.setAttribute(ql,new fn(a,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(ql))throw new Error(`BatchedMesh: Geometry cannot use attribute "${ql}"`);const t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('BatchedMesh: All geometries must consistently have "index".');for(const n in t.attributes){if(n===ql)continue;if(!e.hasAttribute(n))throw new Error(`BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);const r=e.getAttribute(n),s=t.getAttribute(n);if(r.itemSize!==s.itemSize||r.normalized!==s.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Oi);const e=this._geometryCount,t=this.boundingBox,n=this._active;t.makeEmpty();for(let r=0;r=this._maxGeometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");const r={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1};let s=null;const a=this._reservedRanges,o=this._drawRanges,l=this._bounds;this._geometryCount!==0&&(s=a[a.length-1]),t===-1?r.vertexCount=e.getAttribute("position").count:r.vertexCount=t,s===null?r.vertexStart=0:r.vertexStart=s.vertexStart+s.vertexCount;const c=e.getIndex(),h=c!==null;if(h&&(n===-1?r.indexCount=c.count:r.indexCount=n,s===null?r.indexStart=0:r.indexStart=s.indexStart+s.indexCount),r.indexStart!==-1&&r.indexStart+r.indexCount>this._maxIndexCount||r.vertexStart+r.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");const u=this._visibility,d=this._active,p=this._matricesTexture,m=this._matricesTexture.image.data,v=this._colorsTexture;u.push(!0),d.push(!0);const b=this._geometryCount;this._geometryCount++,jP.toArray(m,b*16),p.needsUpdate=!0,v!==null&&(YP.toArray(v.image.data,b*4),v.needsUpdate=!0),a.push(r),o.push({start:h?r.indexStart:r.vertexStart,count:-1}),l.push({boxInitialized:!1,box:new Oi,sphereInitialized:!1,sphere:new Si});const R=this.geometry.getAttribute(ql);for(let L=0;L=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const n=this.geometry,r=n.getIndex()!==null,s=n.getIndex(),a=t.getIndex(),o=this._reservedRanges[e];if(r&&a.count>o.indexCount||t.attributes.position.count>o.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const l=o.vertexStart,c=o.vertexCount;for(const p in n.attributes){if(p===ql)continue;const m=t.getAttribute(p),v=n.getAttribute(p);KP(m,v,l);const b=m.itemSize;for(let R=m.count,L=c;R=t.length||t[e]===!1?this:(t[e]=!1,this._visibilityChanged=!0,this)}getInstanceCountAt(e){return this._multiDrawInstances===null?null:this._multiDrawInstances[e]}setInstanceCountAt(e,t){return this._multiDrawInstances===null&&(this._multiDrawInstances=new Int32Array(this._maxGeometryCount).fill(1)),this._multiDrawInstances[e]=t,e}getBoundingBoxAt(e,t){if(this._active[e]===!1)return null;const r=this._bounds[e],s=r.box,a=this.geometry;if(r.boxInitialized===!1){s.makeEmpty();const o=a.index,l=a.attributes.position,c=this._drawRanges[e];for(let h=c.start,u=c.start+c.count;h=a||n[e]===!1?this:(t.toArray(s,e*16),r.needsUpdate=!0,this)}getMatrixAt(e,t){const n=this._active,r=this._matricesTexture.image.data,s=this._geometryCount;return e>=s||n[e]===!1?null:t.fromArray(r,e*16)}setColorAt(e,t){this._colorsTexture===null&&this._initColorsTexture();const n=this._active,r=this._colorsTexture,s=this._colorsTexture.image.data,a=this._geometryCount;return e>=a||n[e]===!1?this:(t.toArray(s,e*4),r.needsUpdate=!0,this)}getColorAt(e,t){const n=this._active,r=this._colorsTexture.image.data,s=this._geometryCount;return e>=s||n[e]===!1?null:t.fromArray(r,e*4)}setVisibleAt(e,t){const n=this._visibility,r=this._active,s=this._geometryCount;return e>=s||r[e]===!1||n[e]===t?this:(n[e]=t,this._visibilityChanged=!0,this)}getVisibleAt(e){const t=this._visibility,n=this._active,r=this._geometryCount;return e>=r||n[e]===!1?!1:t[e]}raycast(e,t){const n=this._visibility,r=this._active,s=this._drawRanges,a=this._geometryCount,o=this.matrixWorld,l=this.geometry;yi.material=this.material,yi.geometry.index=l.index,yi.geometry.attributes=l.attributes,yi.geometry.boundingBox===null&&(yi.geometry.boundingBox=new Oi),yi.geometry.boundingSphere===null&&(yi.geometry.boundingSphere=new Si);for(let c=0;c({...t})),this._reservedRanges=e._reservedRanges.map(t=>({...t})),this._visibility=e._visibility.slice(),this._active=e._active.slice(),this._bounds=e._bounds.map(t=>({boxInitialized:t.boxInitialized,box:t.box.clone(),sphereInitialized:t.sphereInitialized,sphere:t.sphere.clone()})),this._maxGeometryCount=e._maxGeometryCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.slice(),this._colorsTexture!==null&&(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.slice()),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null),this}onBeforeRender(e,t,n,r,s){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const a=r.getIndex(),o=a===null?1:a.array.BYTES_PER_ELEMENT,l=this._active,c=this._visibility,h=this._multiDrawStarts,u=this._multiDrawCounts,d=this._drawRanges,p=this.perObjectFrustumCulled;p&&(dU.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),o0.setFromProjectionMatrix(dU,e.coordinateSystem));let m=0;if(this.sortObjects){a0.copy(this.matrixWorld).invert(),lh.setFromMatrixPosition(n.matrixWorld).applyMatrix4(a0),fU.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(a0);for(let R=0,L=c.length;R0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;sn)return;c0.applyMatrix4(i.matrixWorld);const l=e.ray.origin.distanceTo(c0);if(!(le.far))return{distance:l,point:mU.clone().applyMatrix4(i.matrixWorld),index:r,face:null,faceIndex:null,object:i}}const gU=new V,xU=new V;class ds extends Na{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[];for(let r=0,s=t.count;r0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;sr.far)return;s.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,object:a})}}class JP extends Bn{constructor(e,t,n,r,s,a,o,l,c){super(e,t,n,r,s,a,o,l,c),this.isVideoTexture=!0,this.minFilter=a!==void 0?a:Zn,this.magFilter=s!==void 0?s:Zn,this.generateMipmaps=!1;const h=this;function u(){h.needsUpdate=!0,e.requestVideoFrameCallback(u)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(u)}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class QP extends Bn{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=li,this.minFilter=li,this.generateMipmaps=!1,this.needsUpdate=!0}}class Gm extends Bn{constructor(e,t,n,r,s,a,o,l,c,h,u,d){super(null,a,o,l,c,h,r,s,u,d),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class e4 extends Gm{constructor(e,t,n,r,s,a){super(e,t,n,s,a),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=Ur,this.layerUpdates=new Set}addLayerUpdates(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class t4 extends Gm{constructor(e,t,n){super(void 0,e[0].width,e[0].height,t,n,Qs),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class n4 extends Bn{constructor(e,t,n,r,s,a,o,l,c){super(e,t,n,r,s,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Vr{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,r=this.getPoint(0),s=0;t.push(0);for(let a=1;a<=e;a++)n=this.getPoint(a/e),s+=n.distanceTo(r),t.push(s),r=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const n=this.getLengths();let r=0;const s=n.length;let a;t?a=t:a=e*n[s-1];let o=0,l=s-1,c;for(;o<=l;)if(r=Math.floor(o+(l-o)/2),c=n[r]-a,c<0)o=r+1;else if(c>0)l=r-1;else{l=r;break}if(r=l,n[r]===a)return r/(s-1);const h=n[r],d=n[r+1]-h,p=(a-h)/d;return(r+p)/(s-1)}getTangent(e,t){let r=e-1e-4,s=e+1e-4;r<0&&(r=0),s>1&&(s=1);const a=this.getPoint(r),o=this.getPoint(s),l=t||(a.isVector2?new Ie:new V);return l.copy(o).sub(a).normalize(),l}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new V,r=[],s=[],a=[],o=new V,l=new Mt;for(let p=0;p<=e;p++){const m=p/e;r[p]=this.getTangentAt(m,new V)}s[0]=new V,a[0]=new V;let c=Number.MAX_VALUE;const h=Math.abs(r[0].x),u=Math.abs(r[0].y),d=Math.abs(r[0].z);h<=c&&(c=h,n.set(1,0,0)),u<=c&&(c=u,n.set(0,1,0)),d<=c&&n.set(0,0,1),o.crossVectors(r[0],n).normalize(),s[0].crossVectors(r[0],o),a[0].crossVectors(r[0],s[0]);for(let p=1;p<=e;p++){if(s[p]=s[p-1].clone(),a[p]=a[p-1].clone(),o.crossVectors(r[p-1],r[p]),o.length()>Number.EPSILON){o.normalize();const m=Math.acos(Pn(r[p-1].dot(r[p]),-1,1));s[p].applyMatrix4(l.makeRotationAxis(o,m))}a[p].crossVectors(r[p],s[p])}if(t===!0){let p=Math.acos(Pn(s[0].dot(s[e]),-1,1));p/=e,r[0].dot(o.crossVectors(s[0],s[e]))>0&&(p=-p);for(let m=1;m<=e;m++)s[m].applyMatrix4(l.makeRotationAxis(r[m],p*m)),a[m].crossVectors(r[m],s[m])}return{tangents:r,normals:s,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Zm extends Vr{constructor(e=0,t=0,n=1,r=1,s=0,a=Math.PI*2,o=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=a,this.aClockwise=o,this.aRotation=l}getPoint(e,t=new Ie){const n=t,r=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const a=Math.abs(s)r;)s-=r;s0?0:(Math.floor(Math.abs(o)/s)+1)*s:l===0&&o===s-1&&(o=s-2,l=1);let c,h;this.closed||o>0?c=r[(o-1)%s]:(uf.subVectors(r[0],r[1]).add(r[0]),c=uf);const u=r[o%s],d=r[(o+1)%s];if(this.closed||o+2r.length-2?r.length-1:a+1],u=r[a>r.length-3?r.length-1:a+2];return n.set(bU(o,l.x,c.x,h.x,u.x),bU(o,l.y,c.y,h.y,u.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t=n){const a=r[s]-n,o=this.curves[s],l=o.getLength(),c=l===0?0:1-a/l;return o.getPointAt(c,t)}s++}return null}getLength(){const 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;const e=[];let t=0;for(let n=0,r=this.curves.length;n1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t0){const u=c.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(c);const h=c.getPoint(1);return this.currentPoint.copy(h),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class od extends zt{constructor(e=[new Ie(0,-.5),new Ie(.5,0),new Ie(0,.5)],t=12,n=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:r},t=Math.floor(t),r=Pn(r,0,Math.PI*2);const s=[],a=[],o=[],l=[],c=[],h=1/t,u=new V,d=new Ie,p=new V,m=new V,v=new V;let b=0,R=0;for(let L=0;L<=e.length-1;L++)switch(L){case 0:b=e[L+1].x-e[L].x,R=e[L+1].y-e[L].y,p.x=R*1,p.y=-b,p.z=R*0,v.copy(p),p.normalize(),l.push(p.x,p.y,p.z);break;case e.length-1:l.push(v.x,v.y,v.z);break;default:b=e[L+1].x-e[L].x,R=e[L+1].y-e[L].y,p.x=R*1,p.y=-b,p.z=R*0,m.copy(p),p.x+=v.x,p.y+=v.y,p.z+=v.z,p.normalize(),l.push(p.x,p.y,p.z),v.copy(m)}for(let L=0;L<=t;L++){const _=n+L*h*r,S=Math.sin(_),D=Math.cos(_);for(let T=0;T<=e.length-1;T++){u.x=e[T].x*S,u.y=e[T].y,u.z=e[T].x*D,a.push(u.x,u.y,u.z),d.x=L/t,d.y=T/(e.length-1),o.push(d.x,d.y);const x=l[3*T+0]*S,O=l[3*T+1],A=l[3*T+0]*D;c.push(x,O,A)}}for(let L=0;L0&&_(!0),t>0&&_(!1)),this.setIndex(h),this.setAttribute("position",new mt(u,3)),this.setAttribute("normal",new mt(d,3)),this.setAttribute("uv",new mt(p,2));function L(){const S=new V,D=new V;let T=0;const x=(t-e)/n;for(let O=0;O<=s;O++){const A=[],E=O/s,z=E*(t-e)+e;for(let ie=0;ie<=r;ie++){const J=ie/r,he=J*l+o,me=Math.sin(he),oe=Math.cos(he);D.x=z*me,D.y=-E*n+b,D.z=z*oe,u.push(D.x,D.y,D.z),S.set(me,x,oe).normalize(),d.push(S.x,S.y,S.z),p.push(J,1-E),A.push(m++)}v.push(A)}for(let O=0;O.9&&x<.1&&(_<.2&&(a[L+0]+=1),S<.2&&(a[L+2]+=1),D<.2&&(a[L+4]+=1))}}function d(L){s.push(L.x,L.y,L.z)}function p(L,_){const S=L*3;_.x=e[S+0],_.y=e[S+1],_.z=e[S+2]}function m(){const L=new V,_=new V,S=new V,D=new V,T=new Ie,x=new Ie,O=new Ie;for(let A=0,E=0;A80*t){o=c=i[0],l=h=i[1];for(let m=t;mc&&(c=u),d>h&&(h=d);p=Math.max(c-o,h-l),p=p!==0?32767/p:0}return cu(s,a,t,o,l,p,0),a}};function jL(i,e,t,n,r){let s,a;if(r===M4(i,e,t,n)>0)for(s=e;s=e;s-=n)a=UU(s,i[s],i[s+1],a);return a&&$m(a,a.next)&&(uu(a),a=a.next),a}function ol(i,e){if(!i)return i;e||(e=i);let t=i,n;do if(n=!1,!t.steiner&&($m(t,t.next)||Fn(t.prev,t,t.next)===0)){if(uu(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function cu(i,e,t,n,r,s,a){if(!i)return;!a&&s&&b4(i,n,r,s);let o=i,l,c;for(;i.prev!==i.next;){if(l=i.prev,c=i.next,s?d4(i,n,r,s):u4(i)){e.push(l.i/t|0),e.push(i.i/t|0),e.push(c.i/t|0),uu(i),i=c.next,o=c.next;continue}if(i=c,i===o){a?a===1?(i=f4(ol(i),e,t),cu(i,e,t,n,r,s,2)):a===2&&p4(i,e,t,n,r,s):cu(ol(i),e,t,n,r,s,1);break}}}function u4(i){const e=i.prev,t=i,n=i.next;if(Fn(e,t,n)>=0)return!1;const r=e.x,s=t.x,a=n.x,o=e.y,l=t.y,c=n.y,h=rs?r>a?r:a:s>a?s:a,p=o>l?o>c?o:c:l>c?l:c;let m=n.next;for(;m!==e;){if(m.x>=h&&m.x<=d&&m.y>=u&&m.y<=p&&ic(r,o,s,l,a,c,m.x,m.y)&&Fn(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function d4(i,e,t,n){const r=i.prev,s=i,a=i.next;if(Fn(r,s,a)>=0)return!1;const o=r.x,l=s.x,c=a.x,h=r.y,u=s.y,d=a.y,p=ol?o>c?o:c:l>c?l:c,b=h>u?h>d?h:d:u>d?u:d,R=Ox(p,m,e,t,n),L=Ox(v,b,e,t,n);let _=i.prevZ,S=i.nextZ;for(;_&&_.z>=R&&S&&S.z<=L;){if(_.x>=p&&_.x<=v&&_.y>=m&&_.y<=b&&_!==r&&_!==a&&ic(o,h,l,u,c,d,_.x,_.y)&&Fn(_.prev,_,_.next)>=0||(_=_.prevZ,S.x>=p&&S.x<=v&&S.y>=m&&S.y<=b&&S!==r&&S!==a&&ic(o,h,l,u,c,d,S.x,S.y)&&Fn(S.prev,S,S.next)>=0))return!1;S=S.nextZ}for(;_&&_.z>=R;){if(_.x>=p&&_.x<=v&&_.y>=m&&_.y<=b&&_!==r&&_!==a&&ic(o,h,l,u,c,d,_.x,_.y)&&Fn(_.prev,_,_.next)>=0)return!1;_=_.prevZ}for(;S&&S.z<=L;){if(S.x>=p&&S.x<=v&&S.y>=m&&S.y<=b&&S!==r&&S!==a&&ic(o,h,l,u,c,d,S.x,S.y)&&Fn(S.prev,S,S.next)>=0)return!1;S=S.nextZ}return!0}function f4(i,e,t){let n=i;do{const r=n.prev,s=n.next.next;!$m(r,s)&&YL(r,n,n.next,s)&&hu(r,s)&&hu(s,r)&&(e.push(r.i/t|0),e.push(n.i/t|0),e.push(s.i/t|0),uu(n),uu(n.next),n=i=s),n=n.next}while(n!==i);return ol(n)}function p4(i,e,t,n,r,s){let a=i;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&_4(a,o)){let l=$L(a,o);a=ol(a,a.next),l=ol(l,l.next),cu(a,e,t,n,r,s,0),cu(l,e,t,n,r,s,0);return}o=o.next}a=a.next}while(a!==i)}function m4(i,e,t,n){const r=[];let s,a,o,l,c;for(s=0,a=e.length;s=t.next.y&&t.next.y!==t.y){const d=t.x+(a-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=s&&d>n&&(n=d,r=t.x=t.x&&t.x>=l&&s!==t.x&&ic(ar.x||t.x===r.x&&v4(r,t)))&&(r=t,h=u)),t=t.next;while(t!==o);return r}function v4(i,e){return Fn(i.prev,i,e.prev)<0&&Fn(e.next,i,i.next)<0}function b4(i,e,t,n){let r=i;do r.z===0&&(r.z=Ox(r.x,r.y,e,t,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,U4(r)}function U4(i){let e,t,n,r,s,a,o,l,c=1;do{for(t=i,i=null,s=null,a=0;t;){for(a++,n=t,o=0,e=0;e0||l>0&&n;)o!==0&&(l===0||!n||t.z<=n.z)?(r=t,t=t.nextZ,o--):(r=n,n=n.nextZ,l--),s?s.nextZ=r:i=r,r.prevZ=s,s=r;t=n}s.nextZ=null,c*=2}while(a>1);return i}function Ox(i,e,t,n,r){return i=(i-t)*r|0,e=(e-n)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,i|e<<1}function y4(i){let e=i,t=i;do(e.x=(i-a)*(s-o)&&(i-a)*(n-o)>=(t-a)*(e-o)&&(t-a)*(s-o)>=(r-a)*(n-o)}function _4(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!L4(i,e)&&(hu(i,e)&&hu(e,i)&&S4(i,e)&&(Fn(i.prev,i,e.prev)||Fn(i,e.prev,e))||$m(i,e)&&Fn(i.prev,i,i.next)>0&&Fn(e.prev,e,e.next)>0)}function Fn(i,e,t){return(e.y-i.y)*(t.x-e.x)-(e.x-i.x)*(t.y-e.y)}function $m(i,e){return i.x===e.x&&i.y===e.y}function YL(i,e,t,n){const r=gf(Fn(i,e,t)),s=gf(Fn(i,e,n)),a=gf(Fn(t,n,i)),o=gf(Fn(t,n,e));return!!(r!==s&&a!==o||r===0&&mf(i,t,e)||s===0&&mf(i,n,e)||a===0&&mf(t,i,n)||o===0&&mf(t,e,n))}function mf(i,e,t){return e.x<=Math.max(i.x,t.x)&&e.x>=Math.min(i.x,t.x)&&e.y<=Math.max(i.y,t.y)&&e.y>=Math.min(i.y,t.y)}function gf(i){return i>0?1:i<0?-1:0}function L4(i,e){let t=i;do{if(t.i!==i.i&&t.next.i!==i.i&&t.i!==e.i&&t.next.i!==e.i&&YL(t,t.next,i,e))return!0;t=t.next}while(t!==i);return!1}function hu(i,e){return Fn(i.prev,i,i.next)<0?Fn(i,e,i.next)>=0&&Fn(i,i.prev,e)>=0:Fn(i,e,i.prev)<0||Fn(i,i.next,e)<0}function S4(i,e){let t=i,n=!1;const r=(i.x+e.x)/2,s=(i.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==i);return n}function $L(i,e){const t=new kx(i.i,i.x,i.y),n=new kx(e.i,e.x,e.y),r=i.next,s=e.prev;return i.next=e,e.prev=i,t.next=r,r.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function UU(i,e,t,n){const r=new kx(i,e,t);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function uu(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function kx(i,e,t){this.i=i,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function M4(i,e,t,n){let r=0;for(let s=e,a=t-n;s2&&i[e-1].equals(i[0])&&i.pop()}function _U(i,e){for(let t=0;tNumber.EPSILON){const Ce=Math.sqrt(de),ue=Math.sqrt(H*H+C*C),ot=Se.x-Lt/Ce,$e=Se.y+Ye/Ce,Oe=qe.x-C/ue,wt=qe.y+H/ue,Ve=((Oe-ot)*C-(wt-$e)*H)/(Ye*C-Lt*H);Ne=ot+Ye*Ve-Te.x,ze=$e+Lt*Ve-Te.y;const rt=Ne*Ne+ze*ze;if(rt<=2)return new Ie(Ne,ze);te=Math.sqrt(rt/2)}else{let Ce=!1;Ye>Number.EPSILON?H>Number.EPSILON&&(Ce=!0):Ye<-Number.EPSILON?H<-Number.EPSILON&&(Ce=!0):Math.sign(Lt)===Math.sign(C)&&(Ce=!0),Ce?(Ne=-Lt,ze=Ye,te=Math.sqrt(de)):(Ne=Ye,ze=Lt,te=Math.sqrt(de/2))}return new Ie(Ne/te,ze/te)}const We=[];for(let Te=0,Se=he.length,qe=Se-1,Ne=Te+1;Te=0;Te--){const Se=Te/b,qe=p*Math.cos(Se*Math.PI/2),Ne=m*Math.sin(Se*Math.PI/2)+v;for(let ze=0,te=he.length;ze=0;){const Ne=qe;let ze=qe-1;ze<0&&(ze=Te.length-1);for(let te=0,Ye=h+b*2;te0)&&p.push(_,S,T),(R!==n-1||l0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class tS extends Ai{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new ht(16777215),this.specular=new ht(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ht(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Wa,this.normalScale=new Ie(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ki,this.combine=nd,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class nS extends Ai{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new ht(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ht(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Wa,this.normalScale=new Ie(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class iS extends Ai{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Wa,this.normalScale=new Ie(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class rS extends Ai{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new ht(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ht(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Wa,this.normalScale=new Ie(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ki,this.combine=nd,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class sS extends Ai{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new ht(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Wa,this.normalScale=new Ie(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class aS extends Ni{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function To(i,e,t){return!i||!t&&i.constructor===e?i:typeof e.BYTES_PER_ELEMENT=="number"?new e(i):Array.prototype.slice.call(i)}function oS(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function lS(i){function e(r,s){return i[r]-i[s]}const t=i.length,n=new Array(t);for(let r=0;r!==t;++r)n[r]=r;return n.sort(e),n}function Nx(i,e,t){const n=i.length,r=new i.constructor(n);for(let s=0,a=0;a!==n;++s){const o=t[s]*e;for(let l=0;l!==e;++l)r[a++]=i[o+l]}return r}function av(i,e,t,n){let r=1,s=i[0];for(;s!==void 0&&s[n]===void 0;)s=i[r++];if(s===void 0)return;let a=s[n];if(a!==void 0)if(Array.isArray(a))do a=s[n],a!==void 0&&(e.push(s.time),t.push.apply(t,a)),s=i[r++];while(s!==void 0);else if(a.toArray!==void 0)do a=s[n],a!==void 0&&(e.push(s.time),a.toArray(t,t.length)),s=i[r++];while(s!==void 0);else do a=s[n],a!==void 0&&(e.push(s.time),t.push(a)),s=i[r++];while(s!==void 0)}function T4(i,e,t,n,r=30){const s=i.clone();s.name=e;const a=[];for(let l=0;l=n)){u.push(c.times[p]);for(let v=0;vs.tracks[l].times[0]&&(o=s.tracks[l].times[0]);for(let l=0;l=o.times[m]){const R=m*u+h,L=R+u-h;v=o.values.slice(R,L)}else{const R=o.createInterpolant(),L=h,_=u-h;R.evaluate(s),v=R.resultBuffer.slice(L,_)}l==="quaternion"&&new gi().fromArray(v).normalize().conjugate().toArray(v);const b=c.times.length;for(let R=0;R=s)){const o=t[1];e=s)break t}a=n,n=0;break n}break e}for(;n>>1;et;)--a;if(++a,s!==0||a!==r){s>=a&&(a=Math.max(a,1),s=a-1);const o=this.getValueSize();this.times=n.slice(s,a),this.values=this.values.slice(s*o,a*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,r=this.values,s=n.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==s;o++){const l=n[o];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,l),e=!1;break}if(a!==null&&a>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,l,a),e=!1;break}a=l}if(r!==void 0&&oS(r))for(let o=0,l=r.length;o!==l;++o){const c=r[o];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),r=this.getInterpolation()===np,s=e.length-1;let a=1;for(let o=1;o0){e[a]=e[s];for(let o=s*n,l=a*n,c=0;c!==n;++c)t[l+c]=t[o+c];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=this.constructor,r=new n(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}}Hr.prototype.TimeBufferType=Float32Array;Hr.prototype.ValueBufferType=Float32Array;Hr.prototype.DefaultInterpolation=Ap;class ml extends Hr{constructor(e,t,n){super(e,t,n)}}ml.prototype.ValueTypeName="bool";ml.prototype.ValueBufferType=Array;ml.prototype.DefaultInterpolation=eu;ml.prototype.InterpolantFactoryMethodLinear=void 0;ml.prototype.InterpolantFactoryMethodSmooth=void 0;class lv extends Hr{}lv.prototype.ValueTypeName="color";class du extends Hr{}du.prototype.ValueTypeName="number";class uS extends hd{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=(n-t)/(r-t);let c=e*o;for(let h=c+o;c!==h;c+=4)gi.slerpFlat(s,0,a,c-o,a,c,l);return s}}class ud extends Hr{InterpolantFactoryMethodLinear(e){return new uS(this.times,this.values,this.getValueSize(),e)}}ud.prototype.ValueTypeName="quaternion";ud.prototype.InterpolantFactoryMethodSmooth=void 0;class gl extends Hr{constructor(e,t,n){super(e,t,n)}}gl.prototype.ValueTypeName="string";gl.prototype.ValueBufferType=Array;gl.prototype.DefaultInterpolation=eu;gl.prototype.InterpolantFactoryMethodLinear=void 0;gl.prototype.InterpolantFactoryMethodSmooth=void 0;class fu extends Hr{}fu.prototype.ValueTypeName="vector";class pu{constructor(e="",t=-1,n=[],r=Dm){this.name=e,this.tracks=n,this.duration=t,this.blendMode=r,this.uuid=hr(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,r=1/(e.fps||1);for(let a=0,o=n.length;a!==o;++a)t.push(P4(n[a]).scale(r));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){const t=[],n=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,a=n.length;s!==a;++s)t.push(Hr.toJSON(n[s]));return r}static CreateFromMorphTargetSequence(e,t,n,r){const s=t.length,a=[];for(let o=0;o1){const u=h[1];let d=r[u];d||(r[u]=d=[]),d.push(c)}}const a=[];for(const o in r)a.push(this.CreateFromMorphTargetSequence(o,r[o],t,n));return a}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(u,d,p,m,v){if(p.length!==0){const b=[],R=[];av(p,b,R,m),b.length!==0&&v.push(new u(d,b,R))}},r=[],s=e.name||"default",a=e.fps||30,o=e.blendMode;let l=e.length||-1;const c=e.hierarchy||[];for(let u=0;u{t&&t(s),this.manager.itemEnd(e)},0),s;if(Ss[e]!==void 0){Ss[e].push({onLoad:t,onProgress:n,onError:r});return}Ss[e]=[],Ss[e].push({onLoad:t,onProgress:n,onError:r});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,l=this.responseType;fetch(a).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const h=Ss[e],u=c.body.getReader(),d=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),p=d?parseInt(d):0,m=p!==0;let v=0;const b=new ReadableStream({start(R){L();function L(){u.read().then(({done:_,value:S})=>{if(_)R.close();else{v+=S.byteLength;const D=new ProgressEvent("progress",{lengthComputable:m,loaded:v,total:p});for(let T=0,x=h.length;T{R.error(_)})}}});return new Response(b)}else throw new I4(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(h=>new DOMParser().parseFromString(h,o));case"json":return c.json();default:if(o===void 0)return c.text();{const u=/charset="?([^;"\s]*)"?/i.exec(o),d=u&&u[1]?u[1].toLowerCase():void 0,p=new TextDecoder(d);return c.arrayBuffer().then(m=>p.decode(m))}}}).then(c=>{zs.add(e,c);const h=Ss[e];delete Ss[e];for(let u=0,d=h.length;u{const h=Ss[e];if(h===void 0)throw this.manager.itemError(e),c;delete Ss[e];for(let u=0,d=h.length;u{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class B4 extends Qi{constructor(e){super(e)}load(e,t,n,r){const s=this,a=new ta(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(o){try{t(s.parse(JSON.parse(o)))}catch(l){r?r(l):console.error(l),s.manager.itemError(e)}},n,r)}parse(e){const t=[];for(let n=0;n0:r.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const s in e.uniforms){const a=e.uniforms[s];switch(r.uniforms[s]={},a.type){case"t":r.uniforms[s].value=n(a.value);break;case"c":r.uniforms[s].value=new ht().setHex(a.value);break;case"v2":r.uniforms[s].value=new Ie().fromArray(a.value);break;case"v3":r.uniforms[s].value=new V().fromArray(a.value);break;case"v4":r.uniforms[s].value=new un().fromArray(a.value);break;case"m3":r.uniforms[s].value=new It().fromArray(a.value);break;case"m4":r.uniforms[s].value=new Mt().fromArray(a.value);break;default:r.uniforms[s].value=a.value}}if(e.defines!==void 0&&(r.defines=e.defines),e.vertexShader!==void 0&&(r.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(r.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(r.glslVersion=e.glslVersion),e.extensions!==void 0)for(const s in e.extensions)r.extensions[s]=e.extensions[s];if(e.lights!==void 0&&(r.lights=e.lights),e.clipping!==void 0&&(r.clipping=e.clipping),e.size!==void 0&&(r.size=e.size),e.sizeAttenuation!==void 0&&(r.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(r.map=n(e.map)),e.matcap!==void 0&&(r.matcap=n(e.matcap)),e.alphaMap!==void 0&&(r.alphaMap=n(e.alphaMap)),e.bumpMap!==void 0&&(r.bumpMap=n(e.bumpMap)),e.bumpScale!==void 0&&(r.bumpScale=e.bumpScale),e.normalMap!==void 0&&(r.normalMap=n(e.normalMap)),e.normalMapType!==void 0&&(r.normalMapType=e.normalMapType),e.normalScale!==void 0){let s=e.normalScale;Array.isArray(s)===!1&&(s=[s,s]),r.normalScale=new Ie().fromArray(s)}return e.displacementMap!==void 0&&(r.displacementMap=n(e.displacementMap)),e.displacementScale!==void 0&&(r.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(r.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(r.roughnessMap=n(e.roughnessMap)),e.metalnessMap!==void 0&&(r.metalnessMap=n(e.metalnessMap)),e.emissiveMap!==void 0&&(r.emissiveMap=n(e.emissiveMap)),e.emissiveIntensity!==void 0&&(r.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(r.specularMap=n(e.specularMap)),e.specularIntensityMap!==void 0&&(r.specularIntensityMap=n(e.specularIntensityMap)),e.specularColorMap!==void 0&&(r.specularColorMap=n(e.specularColorMap)),e.envMap!==void 0&&(r.envMap=n(e.envMap)),e.envMapRotation!==void 0&&r.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(r.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(r.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(r.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(r.lightMap=n(e.lightMap)),e.lightMapIntensity!==void 0&&(r.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(r.aoMap=n(e.aoMap)),e.aoMapIntensity!==void 0&&(r.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(r.gradientMap=n(e.gradientMap)),e.clearcoatMap!==void 0&&(r.clearcoatMap=n(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(r.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(r.clearcoatNormalMap=n(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(r.clearcoatNormalScale=new Ie().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(r.iridescenceMap=n(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(r.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(r.transmissionMap=n(e.transmissionMap)),e.thicknessMap!==void 0&&(r.thicknessMap=n(e.thicknessMap)),e.anisotropyMap!==void 0&&(r.anisotropyMap=n(e.anisotropyMap)),e.sheenColorMap!==void 0&&(r.sheenColorMap=n(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(r.sheenRoughnessMap=n(e.sheenRoughnessMap)),r}setTextures(e){return this.textures=e,this}static createMaterialFromType(e){const t={ShadowMaterial:JL,SpriteMaterial:$R,RawShaderMaterial:QL,ShaderMaterial:Nr,PointsMaterial:JR,MeshPhysicalMaterial:eS,MeshStandardMaterial:sv,MeshPhongMaterial:tS,MeshToonMaterial:nS,MeshNormalMaterial:iS,MeshLambertMaterial:rS,MeshDepthMaterial:jR,MeshDistanceMaterial:YR,MeshBasicMaterial:Ga,MeshMatcapMaterial:sS,LineDashedMaterial:aS,LineBasicMaterial:Ni,Material:Ai};return new t[e]}}class zx{static decodeText(e){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let n=0,r=e.length;n0){const l=new cv(t);s=new mu(l),s.setCrossOrigin(this.crossOrigin);for(let c=0,h=e.length;c0){r=new mu(this.manager),r.setCrossOrigin(this.crossOrigin);for(let a=0,o=e.length;a{const b=new Oi;b.min.fromArray(v.boxMin),b.max.fromArray(v.boxMax);const R=new Si;return R.radius=v.sphereRadius,R.center.fromArray(v.sphereCenter),{boxInitialized:v.boxInitialized,box:b,sphereInitialized:v.sphereInitialized,sphere:R}}),a._maxGeometryCount=e.maxGeometryCount,a._maxVertexCount=e.maxVertexCount,a._maxIndexCount=e.maxIndexCount,a._geometryInitialized=e.geometryInitialized,a._geometryCount=e.geometryCount,a._matricesTexture=c(e.matricesTexture.uuid),e.colorsTexture!==void 0&&(a._colorsTexture=c(e.colorsTexture.uuid));break;case"LOD":a=new BL;break;case"Line":a=new Na(o(e.geometry),l(e.material));break;case"LineLoop":a=new zL(o(e.geometry),l(e.material));break;case"LineSegments":a=new ds(o(e.geometry),l(e.material));break;case"PointCloud":case"Points":a=new VL(o(e.geometry),l(e.material));break;case"Sprite":a=new IL(l(e.material));break;case"Group":a=new nc;break;case"Bone":a=new KR;break;default:a=new rn}if(a.uuid=e.uuid,e.name!==void 0&&(a.name=e.name),e.matrix!==void 0?(a.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(a.matrixAutoUpdate=e.matrixAutoUpdate),a.matrixAutoUpdate&&a.matrix.decompose(a.position,a.quaternion,a.scale)):(e.position!==void 0&&a.position.fromArray(e.position),e.rotation!==void 0&&a.rotation.fromArray(e.rotation),e.quaternion!==void 0&&a.quaternion.fromArray(e.quaternion),e.scale!==void 0&&a.scale.fromArray(e.scale)),e.up!==void 0&&a.up.fromArray(e.up),e.castShadow!==void 0&&(a.castShadow=e.castShadow),e.receiveShadow!==void 0&&(a.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.bias!==void 0&&(a.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(a.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(a.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&a.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(a.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(a.visible=e.visible),e.frustumCulled!==void 0&&(a.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(a.renderOrder=e.renderOrder),e.userData!==void 0&&(a.userData=e.userData),e.layers!==void 0&&(a.layers.mask=e.layers),e.children!==void 0){const d=e.children;for(let p=0;p"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,n,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=zs.get(e);if(a!==void 0){if(s.manager.itemStart(e),a.then){a.then(c=>{t&&t(c),s.manager.itemEnd(e)}).catch(c=>{r&&r(c)});return}return setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader;const l=fetch(e,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(c){return zs.add(e,c),t&&t(c),s.manager.itemEnd(e),c}).catch(function(c){r&&r(c),zs.remove(e),s.manager.itemError(e),s.manager.itemEnd(e)});zs.add(e,l),s.manager.itemStart(e)}}let xf;class uv{static getContext(){return xf===void 0&&(xf=new(window.AudioContext||window.webkitAudioContext)),xf}static setContext(e){xf=e}}class X4 extends Qi{constructor(e){super(e)}load(e,t,n,r){const s=this,a=new ta(this.manager);a.setResponseType("arraybuffer"),a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(l){try{const c=l.slice(0);uv.getContext().decodeAudioData(c,function(u){t(u)}).catch(o)}catch(c){o(c)}},n,r);function o(l){r?r(l):console.error(l),s.manager.itemError(e)}}}const FU=new Mt,CU=new Mt,lo=new Mt;class j4{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new mi,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new mi,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,lo.copy(e.projectionMatrix);const r=t.eyeSep/2,s=r*t.near/t.focus,a=t.near*Math.tan(Yo*t.fov*.5)/t.zoom;let o,l;CU.elements[12]=-r,FU.elements[12]=r,o=-a*t.aspect+s,l=a*t.aspect+s,lo.elements[0]=2*t.near/(l-o),lo.elements[8]=(l+o)/(l-o),this.cameraL.projectionMatrix.copy(lo),o=-a*t.aspect-s,l=a*t.aspect-s,lo.elements[0]=2*t.near/(l-o),lo.elements[8]=(l+o)/(l-o),this.cameraR.projectionMatrix.copy(lo)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(CU),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(FU)}}class _S{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=DU(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=DU();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function DU(){return(typeof performance>"u"?Date:performance).now()}const co=new V,PU=new gi,Y4=new V,ho=new V;class $4 extends rn{constructor(){super(),this.type="AudioListener",this.context=uv.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new _S}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);const t=this.context.listener,n=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(co,PU,Y4),ho.set(0,0,-1).applyQuaternion(PU),t.positionX){const r=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(co.x,r),t.positionY.linearRampToValueAtTime(co.y,r),t.positionZ.linearRampToValueAtTime(co.z,r),t.forwardX.linearRampToValueAtTime(ho.x,r),t.forwardY.linearRampToValueAtTime(ho.y,r),t.forwardZ.linearRampToValueAtTime(ho.z,r),t.upX.linearRampToValueAtTime(n.x,r),t.upY.linearRampToValueAtTime(n.y,r),t.upZ.linearRampToValueAtTime(n.z,r)}else t.setPosition(co.x,co.y,co.z),t.setOrientation(ho.x,ho.y,ho.z,n.x,n.y,n.z)}}class LS extends rn{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){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(n,r,this._addIndex*t,1,t);for(let l=t,c=t+t;l!==c;++l)if(n[l]!==n[l+t]){o.setValue(n,r);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,r=n*this._origIndex;e.getValue(t,r);for(let s=n,a=r;s!==a;++s)t[s]=t[r+s%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n=.5)for(let a=0;a!==s;++a)e[t+a]=e[n+a]}_slerp(e,t,n,r){gi.slerpFlat(e,t,e,t,e,n,r)}_slerpAdditive(e,t,n,r,s){const a=this._workIndex*s;gi.multiplyQuaternionsFlat(e,a,e,t,e,n),gi.slerpFlat(e,t,e,t,e,a,r)}_lerp(e,t,n,r,s){const a=1-r;for(let o=0;o!==s;++o){const l=t+o;e[l]=e[l]*a+e[n+o]*r}}_lerpAdditive(e,t,n,r,s){for(let a=0;a!==s;++a){const o=t+a;e[o]=e[o]+e[n+a]*r}}}const dv="\\[\\]\\.:\\/",e5=new RegExp("["+dv+"]","g"),fv="[^"+dv+"]",t5="[^"+dv.replace("\\.","")+"]",n5=/((?:WC+[\/:])*)/.source.replace("WC",fv),i5=/(WCOD+)?/.source.replace("WCOD",t5),r5=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",fv),s5=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",fv),a5=new RegExp("^"+n5+i5+r5+s5+"$"),o5=["material","materials","bones","map"];class l5{constructor(e,t,n){const r=n||en.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,r=this._bindings[n];r!==void 0&&r.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=n.length;r!==s;++r)n[r].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class en{constructor(e,t,n){this.path=t,this.parsedPath=n||en.parseTrackName(t),this.node=en.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new en.Composite(e,t,n):new en(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(e5,"")}static parseTrackName(e){const t=a5.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=n.nodeName&&n.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){const s=n.nodeName.substring(r+1);o5.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(s){for(let a=0;a=s){const u=s++,d=e[u];t[d.uuid]=h,e[h]=d,t[c]=u,e[u]=l;for(let p=0,m=r;p!==m;++p){const v=n[p],b=v[u],R=v[h];v[h]=b,v[u]=R}}}this.nCachedObjects_=s}uncache(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,r=n.length;let s=this.nCachedObjects_,a=e.length;for(let o=0,l=arguments.length;o!==l;++o){const c=arguments[o],h=c.uuid,u=t[h];if(u!==void 0)if(delete t[h],u0&&(t[p.uuid]=u),e[u]=p,e.pop();for(let m=0,v=r;m!==v;++m){const b=n[m];b[u]=b[d],b.pop()}}}this.nCachedObjects_=s}subscribe_(e,t){const n=this._bindingsIndicesByPath;let r=n[e];const s=this._bindings;if(r!==void 0)return s[r];const a=this._paths,o=this._parsedPaths,l=this._objects,c=l.length,h=this.nCachedObjects_,u=new Array(c);r=s.length,n[e]=r,a.push(e),o.push(t),s.push(u);for(let d=h,p=l.length;d!==p;++d){const m=l[d];u[d]=new en(m,e,t)}return u}unsubscribe_(e){const t=this._bindingsIndicesByPath,n=t[e];if(n!==void 0){const r=this._paths,s=this._parsedPaths,a=this._bindings,o=a.length-1,l=a[o],c=e[o];t[c]=n,a[n]=l,a.pop(),s[n]=s[o],s.pop(),r[n]=r[o],r.pop()}}}class MS{constructor(e,t,n=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=r;const s=t.tracks,a=s.length,o=new Array(a),l={endingStart:wo,endingEnd:wo};for(let c=0;c!==a;++c){const h=s[c].createInterpolant(null);o[c]=h,h.settings=l}this._interpolantSettings=l,this._interpolants=o,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=rL,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n){if(e.fadeOut(t),this.fadeIn(t),n){const r=this._clip.duration,s=e._clip.duration,a=s/r,o=r/s;e.warp(1,a,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,n){return e.crossFadeFrom(this,t,n)}stopFading(){const 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,n){const r=this._mixer,s=r.time,a=this.timeScale;let o=this._timeScaleInterpolant;o===null&&(o=r._lendControlInterpolant(),this._timeScaleInterpolant=o);const l=o.parameterPositions,c=o.sampleValues;return l[0]=s,l[1]=s+n,c[0]=e/a,c[1]=t/a,this}stopWarping(){const 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,n,r){if(!this.enabled){this._updateWeight(e);return}const s=this._startTime;if(s!==null){const l=(e-s)*n;l<0||n===0?t=0:(this._startTime=null,t=n*l)}t*=this._updateTimeScale(e);const a=this._updateTime(t),o=this._updateWeight(e);if(o>0){const l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case NR:for(let h=0,u=l.length;h!==u;++h)l[h].evaluate(a),c[h].accumulateAdditive(o);break;case Dm:default:for(let h=0,u=l.length;h!==u;++h)l[h].evaluate(a),c[h].accumulate(r,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(n!==null){const r=n.evaluate(e)[0];t*=r,e>n.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;const n=this._timeScaleInterpolant;if(n!==null){const r=n.evaluate(e)[0];t*=r,e>n.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,n=this.loop;let r=this.time+e,s=this._loopCount;const a=n===sL;if(e===0)return s===-1?r:a&&(s&1)===1?t-r:r;if(n===iL){s===-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(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),r>=t||r<0){const o=Math.floor(r/t);r-=t*o,s+=Math.abs(o);const l=this.repetitions-s;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){const c=e<0;this._setEndings(c,!c,a)}else this._setEndings(!1,!1,a);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=r;if(a&&(s&1)===1)return t-r}return r}_setEndings(e,t,n){const r=this._interpolantSettings;n?(r.endingStart=Ao,r.endingEnd=Ao):(e?r.endingStart=this.zeroSlopeAtStart?Ao:wo:r.endingStart=tu,t?r.endingEnd=this.zeroSlopeAtEnd?Ao:wo:r.endingEnd=tu)}_scheduleFading(e,t,n){const r=this._mixer,s=r.time;let a=this._weightInterpolant;a===null&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);const o=a.parameterPositions,l=a.sampleValues;return o[0]=s,l[0]=t,o[1]=s+e,l[1]=n,this}}const h5=new Float32Array(1);class u5 extends sa{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const n=e._localRoot||this._root,r=e._clip.tracks,s=r.length,a=e._propertyBindings,o=e._interpolants,l=n.uuid,c=this._bindingsByRootAndName;let h=c[l];h===void 0&&(h={},c[l]=h);for(let u=0;u!==s;++u){const d=r[u],p=d.name;let m=h[p];if(m!==void 0)++m.referenceCount,a[u]=m;else{if(m=a[u],m!==void 0){m._cacheIndex===null&&(++m.referenceCount,this._addInactiveBinding(m,l,p));continue}const v=t&&t._propertyBindings[u].binding.parsedPath;m=new SS(en.create(n,p,v),d.ValueTypeName,d.getValueSize()),++m.referenceCount,this._addInactiveBinding(m,l,p),a[u]=m}o[u].resultBuffer=m.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const n=(e._localRoot||this._root).uuid,r=e._clip.uuid,s=this._actionsByClip[r];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,r,n)}const t=e._propertyBindings;for(let n=0,r=t.length;n!==r;++n){const s=t[n];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let n=0,r=t.length;n!==r;++n){const s=t[n];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const 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){const t=e._cacheIndex;return t!==null&&t=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;const t=this._actions,n=this._nActiveActions,r=this.time+=e,s=Math.sign(e),a=this._accuIndex^=1;for(let c=0;c!==n;++c)t[c]._update(r,e,s,a);const o=this._bindings,l=this._nActiveBindings;for(let c=0;c!==l;++c)o[c].apply(a);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.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.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,kU).distanceTo(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}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)}}const NU=new V,Rf=new V;class b5{constructor(e=new V,t=new V){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.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){NU.subVectors(e,this.start),Rf.subVectors(this.end,this.start);const n=Rf.dot(Rf);let s=Rf.dot(NU)/n;return t&&(s=Pn(s,0,1)),s}closestPointToPoint(e,t,n){const r=this.closestPointToPointParameter(e,t);return this.delta(n).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)}}const zU=new V;class U5 extends rn{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const n=new zt,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let a=0,o=1,l=32;a1)for(let u=0;u.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{ZU.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(ZU,t)}}setLength(e,t=e*.2,n=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class P5 extends ds{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new zt;r.setAttribute("position",new mt(t,3)),r.setAttribute("color",new mt(n,3));const s=new Ni({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}setColors(e,t,n){const r=new ht,s=this.geometry.attributes.color.array;return r.set(e),r.toArray(s,0),r.toArray(s,3),r.set(t),r.toArray(s,6),r.toArray(s,9),r.set(n),r.toArray(s,12),r.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class I5{constructor(){this.type="ShapePath",this.color=new ht,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new lu,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,r){return this.currentPath.quadraticCurveTo(e,t,n,r),this}bezierCurveTo(e,t,n,r,s,a){return this.currentPath.bezierCurveTo(e,t,n,r,s,a),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(R){const L=[];for(let _=0,S=R.length;_Number.EPSILON){if(E<0&&(x=L[T],A=-A,O=L[D],E=-E),R.yO.y)continue;if(R.y===x.y){if(R.x===x.x)return!0}else{const z=E*(R.x-x.x)-A*(R.y-x.y);if(z===0)return!0;if(z<0)continue;S=!S}}else{if(R.y!==x.y)continue;if(O.x<=R.x&&R.x<=x.x||x.x<=R.x&&R.x<=O.x)return!0}}return S}const r=os.isClockWise,s=this.subPaths;if(s.length===0)return[];let a,o,l;const c=[];if(s.length===1)return o=s[0],l=new $o,l.curves=o.curves,c.push(l),c;let h=!r(s[0].getPoints());h=e?!h:h;const u=[],d=[];let p=[],m=0,v;d[m]=void 0,p[m]=[];for(let R=0,L=s.length;R1){let R=!1,L=0;for(let _=0,S=d.length;_0&&R===!1&&(p=u)}let b;for(let R=0,L=d.length;R{try{const n=++Ad(this,sm)._,r=await i;n>P(this,Bu)&&(et(this,Bu,n),e(r))}catch(n){t(n)}})}},sm=new WeakMap,Bu=new WeakMap,l1),AS=0,Oo,fc,Bc,TS,ko,FS,pc,c1,ES=(c1=class{constructor(){Be(this,Bc);Be(this,Oo,new Set);Z(this,"lastSourceGeneration",0);Be(this,fc,new Set);Be(this,ko,!1);Be(this,pc,new Map)}canReuse(i,e){return i===e||this.canReuseValue(i,e)}canReuseValue(i,e){return!1}debugGetChildren(){return Array.from(P(this,Oo).values())}addChild(i){P(this,Oo).add(i)}removeChild(i){P(this,Oo).delete(i)}markStale(i){if(i.detail.generation!==AS)throw new Error("A TwistyProp was marked stale too late!");if(this.lastSourceGeneration!==i.detail.generation){this.lastSourceGeneration=i.detail.generation;for(const e of P(this,Oo))e.markStale(i);Yt(this,Bc,TS).call(this)}}addRawListener(i,e){P(this,fc).add(i),e!=null&&e.initial&&i()}removeRawListener(i){P(this,fc).delete(i)}addFreshListener(i){const e=new ag;let t=null;const n=async()=>{const r=await e.queue(this.get());t!==null&&this.canReuse(t,r)||(t=r,i(r))};P(this,pc).set(i,n),this.addRawListener(n,{initial:!0})}removeFreshListener(i){this.removeRawListener(P(this,pc).get(i)),P(this,pc).delete(i)}},Oo=new WeakMap,fc=new WeakMap,Bc=new WeakSet,TS=function(){P(this,ko)||(et(this,ko,!0),setTimeout(()=>Yt(this,Bc,FS).call(this),0))},ko=new WeakMap,FS=function(){if(!P(this,ko))throw new Error("Invalid dispatch state!");for(const i of P(this,fc))i();et(this,ko,!1)},pc=new WeakMap,c1),Qr,h1,Xa=(h1=class extends ES{constructor(e){super();Be(this,Qr);et(this,Qr,Em(()=>this.getDefaultValue())),e&&et(this,Qr,this.deriveFromPromiseOrValue(e,P(this,Qr)))}set(e){et(this,Qr,this.deriveFromPromiseOrValue(e,P(this,Qr)));const t={sourceProp:this,value:P(this,Qr),generation:++AS};this.markStale(new CustomEvent("stale",{detail:t}))}async get(){return P(this,Qr)}async deriveFromPromiseOrValue(e,t){return this.derive(await e,t)}},Qr=new WeakMap,h1),vn=class extends Xa{derive(i){return i}},gu=Symbol("no value"),Sa,Ou,mc,Oc,CS,DS,u1,_n=(u1=class extends ES{constructor(e,t){super();Be(this,Oc);Be(this,Sa);Be(this,Ou,null);Be(this,mc,null);this.userVisibleErrorTracker=t,et(this,Sa,e);for(const n of Object.values(e))n.addChild(this)}async get(){var n,r;const e=this.lastSourceGeneration;if(((n=P(this,mc))==null?void 0:n.generation)===e)return P(this,mc).output;const t={generation:e,output:Yt(this,Oc,DS).call(this,Yt(this,Oc,CS).call(this),e,P(this,Ou))};return et(this,mc,t),(r=this.userVisibleErrorTracker)==null||r.reset(),t.output}},Sa=new WeakMap,Ou=new WeakMap,mc=new WeakMap,Oc=new WeakSet,CS=async function(){const e={};for(const[n,r]of Object.entries(P(this,Sa)))e[n]=r.get();const t={};for(const n in P(this,Sa))t[n]=await e[n];return t},DS=async function(e,t,n=null){const r=await e,s=o=>(et(this,Ou,{inputs:r,output:Promise.resolve(o),generation:t}),o);if(!n)return s(await this.derive(r));const a=n.inputs;for(const o in P(this,Sa))if(!P(this,Sa)[o].canReuse(r[o],a[o]))return s(await this.derive(r));return n.output},u1),gc,d1,dd=(d1=class{constructor(){Be(this,gc,[])}addListener(i,e){let t=!1;const n=r=>{t||e(r)};i.addFreshListener(n),P(this,gc).push(()=>{i.removeFreshListener(n),t=!0})}addMultiListener3(i,e){this.addMultiListener(i,e)}addMultiListener(i,e){let t=!1,n=i.length-1;const r=async s=>{if(n>0){n--;return}if(t)return;const a=i.map(l=>l.get()),o=await Promise.all(a);e(o)};for(const s of i)s.addFreshListener(r);P(this,gc).push(()=>{for(const s of i)s.removeFreshListener(r);t=!0})}disconnect(){for(const i of P(this,gc))i()}},gc=new WeakMap,d1),Gc=class{constructor(i){Z(this,"animFrameID",null);Z(this,"animFrame",this.animFrameWrapper.bind(this));this.callback=i}requestIsPending(){return!!this.animFrameID}requestAnimFrame(){this.animFrameID||(this.animFrameID=requestAnimationFrame(this.animFrame))}cancelAnimFrame(){this.animFrameID&&(cancelAnimationFrame(this.animFrameID),this.animFrameID=0)}animFrameWrapper(i){this.animFrameID=0,this.callback(i)}},X9={floating:!0,none:!0},O5=class extends vn{getDefaultValue(){return"auto"}},k5=Math.PI*2,xu=360/k5,N5=class{},Ru;globalThis.HTMLElement?Ru=globalThis.HTMLElement:Ru=N5;var z5=class{define(){}},Mi;globalThis.customElements?Mi=globalThis.customElements:Mi=new z5;var ur,V5=class{replaceSync(){}};globalThis.CSSStyleSheet?ur=globalThis.CSSStyleSheet:ur=V5;var Lr=class extends Ru{constructor(e){super();Z(this,"shadow");Z(this,"contentWrapper");this.shadow=this.attachShadow({mode:(e==null?void 0:e.mode)??"closed"}),this.contentWrapper=document.createElement("div"),this.contentWrapper.classList.add("wrapper"),this.shadow.appendChild(this.contentWrapper)}addCSS(e){this.shadow.adoptedStyleSheets.push(e)}removeCSS(e){const t=this.shadow.adoptedStyleSheets.indexOf(e);typeof t<"u"&&this.shadow.adoptedStyleSheets.splice(t,t+1)}addElement(e){return this.contentWrapper.appendChild(e)}prependElement(e){this.contentWrapper.prepend(e)}removeElement(e){return this.contentWrapper.removeChild(e)}};Mi.define("twisty-managed-custom-element",Lr);var H5=null;async function PS(){return H5??(H5=an(()=>import("./twisty-dynamic-3d-HF7KVBOE-DN-8Df3y.js"),[]))}var ls=Em(async()=>(await PS()).T3I);function Hx(){return devicePixelRatio||1}var IS=new ur;IS.replaceSync(` :host { width: 384px; height: 256px; @@ -4455,11 +4455,11 @@ twisty-alg-viewer { • ${wf} count as 1 turn per quantum (e.g. M2 counts as 2) • ${Mf} count as 1 turn per quantum (e.g. R2 counts as 2) • rotations (e.g. x) count as 0 turns`,ETM:`ETM ("Execution Turn Metric"): -• all moves (including rotations) count as 1 turn`},OO={OBTM:"OB",OBQTM:"OBQ",RBTM:"RB",RBQTM:"RBQ",ETM:"E"},Ks,Qx,Am,Ea,Go,Qu,ap,F1,kO=(F1=class extends Lr{constructor(e){super({mode:"open"});Be(this,Ks);Z(this,"twistyPlayer",null);Z(this,"a",null);Be(this,Am);Be(this,Ea);Be(this,Go);Be(this,Qu);this.options=e}async connectedCallback(){var s,a,o,l,c;if(et(this,Go,this.addElement(document.createElement("div"))),P(this,Go).classList.add("responsive-wrapper"),((s=this.options)==null?void 0:s.colorScheme)==="dark"&&this.contentWrapper.classList.add("dark-mode"),this.addCSS(sp),(a=this.options)!=null&&a.cdnForumTweaks&&this.addCSS(MM),this.a=this.querySelector("a"),!this.a)return;const e=BO("",this.a.href),t=(o=this.a)==null?void 0:o.href,{hostname:n,pathname:r}=new URL(t);if(n!=="alpha.twizzle.net"){Yt(this,Ks,Qx).call(this);return}if(["/edit/","/explore/"].includes(r)){const h=r==="/explore/";if(e.puzzle&&!(e.puzzle in gv)){const p=(await an(async()=>{const{getPuzzleDescriptionString:m}=await import("./index-BSjPx7-K.js");return{getPuzzleDescriptionString:m}},[])).getPuzzleDescriptionString(e.puzzle);delete e.puzzle,e.experimentalPuzzleDescription=p}if(this.twistyPlayer=P(this,Go).appendChild(new Zc({background:(l=this.options)!=null&&l.cdnForumTweaks?"checkered-transparent":"checkered",colorScheme:((c=this.options)==null?void 0:c.colorScheme)==="dark"?"dark":"light",...e,viewerLink:h?"experimental-twizzle-explorer":"auto"})),this.twistyPlayer.fullscreenElement=this.contentWrapper,e.experimentalTitle&&(this.twistyPlayer.experimentalTitle=e.experimentalTitle),et(this,Ea,P(this,Go).appendChild(document.createElement("div"))),P(this,Ea).classList.add("scrollable-region"),e.experimentalTitle&&Yt(this,Ks,ap).call(this,e.experimentalTitle).classList.add("title"),e.experimentalSetupAlg){Yt(this,Ks,ap).call(this,"Setup",async()=>{var m,v;return((v=await((m=this.twistyPlayer)==null?void 0:m.experimentalModel.setupAlg.get()))==null?void 0:v.alg.toString())??null});const p=P(this,Ea).appendChild(document.createElement("div"));p.classList.add("setup-alg"),p.textContent=new Qe(e.experimentalSetupAlg).toString()}const u=Yt(this,Ks,ap).call(this,"Moves",async()=>{var p,m;return((m=await((p=this.twistyPlayer)==null?void 0:p.experimentalModel.alg.get()))==null?void 0:m.alg.toString())??null});et(this,Qu,u.appendChild(NO(this.twistyPlayer.experimentalModel))),P(this,Qu).classList.add("move-count"),P(this,Ea).appendChild(new yM({twistyPlayer:this.twistyPlayer})).part.add("twisty-alg-viewer")}else Yt(this,Ks,Qx).call(this)}},Ks=new WeakSet,Qx=function(){var t;if(this.contentWrapper.textContent="",this.a){const n=this.contentWrapper.appendChild(document.createElement("span"));n.textContent="❗️",n.title="Could not show a player for link",this.addElement(this.a)}this.removeCSS(sp);const e=this.shadow.adoptedStyleSheets.indexOf(sp);typeof e<"u"&&this.shadow.adoptedStyleSheets.splice(e,e+1),(t=P(this,Am))==null||t.remove()},Am=new WeakMap,Ea=new WeakMap,Go=new WeakMap,Qu=new WeakMap,ap=function(e,t){const n=P(this,Ea).appendChild(document.createElement("div"));n.classList.add("heading");const r=n.appendChild(document.createElement("span"));if(r.textContent=e,t){r.textContent+=" ";const s=r.appendChild(document.createElement("a"));s.textContent="📋",s.href="#",s.title="Copy to clipboard";async function a(o){s.textContent=o,await new Promise(l=>setTimeout(l,2e3)),s.textContent===o&&(s.textContent="📋")}s.addEventListener("click",async o=>{o.preventDefault(),s.textContent="📋…";const l=await t();if(l)try{await navigator.clipboard.writeText(l),a("📋✅")}catch(c){throw a("📋❌"),c}else a("📋❌")})}return n},F1);Mi.define("twizzle-link",kO);function NO(i,e=document.createElement("span")){async function t(){const[n,r]=await Promise.all([i.puzzleAlg.get(),i.puzzleLoader.get()]);if(n.issues.errors.length!==0){e.textContent="";return}let s=!0;function a(o){s?s=!1:e.append(")(");const l=e.appendChild(document.createElement("span")),c=oI(r,o,n.alg);l.append(`${OO[o]}: `);const h=l.appendChild(document.createElement("span"));h.textContent=c.toString(),h.classList.add("move-number"),l.setAttribute("data-before",m2[o]??""),l.setAttribute("title",m2[o]??"")}e.textContent="(",r.id==="3x3x3"?(a("OBTM"),a("OBQTM"),a("RBTM")):r.pg&&(a("RBTM"),a("RBQTM")),a("ETM"),e.append(")")}return i.puzzleAlg.addFreshListener(t),i.puzzleID.addFreshListener(t),e}var zO={expose:!0};function VO(i){const e=new WeakMap;return{postMessage:i.postMessage.bind(i),addEventListener:(t,n)=>{const r=s=>{"handleEvent"in n?n.handleEvent({data:s}):n({data:s})};i.on("message",r),e.set(n,r)},removeEventListener:(t,n)=>{const r=e.get(n);r&&(i.off("message",r),e.delete(n))},nodeWorker:i,terminate:()=>{i.terminate()}}}var HO=VO,wM=2**53,WO=2097152,GO=11,b0=new Uint32Array(2);function ZO(){globalThis.crypto.getRandomValues(b0);const i=b0[0],e=b0[1];return Math.floor(i*WO)+(e>>GO)}function qO(i){if(typeof i!="number"||i<0||Math.floor(i)!==i)throw new Error("randomUIntBelow() not called with a positive integer value.");if(i>wM)throw new Error(`Called randomUIntBelow() with max === ${i}, which is larger than JavaScript can handle with integer precision.`)}function XO(i){qO(i);for(var e,t,n;;)if(e=ZO(),t=Math.floor(e/i),n=t*i,n<=wM-i)return e-n}function AM(i){return i[XO(i.length)]}/** +• all moves (including rotations) count as 1 turn`},OO={OBTM:"OB",OBQTM:"OBQ",RBTM:"RB",RBQTM:"RBQ",ETM:"E"},Ks,Qx,Am,Ea,Go,Qu,ap,F1,kO=(F1=class extends Lr{constructor(e){super({mode:"open"});Be(this,Ks);Z(this,"twistyPlayer",null);Z(this,"a",null);Be(this,Am);Be(this,Ea);Be(this,Go);Be(this,Qu);this.options=e}async connectedCallback(){var s,a,o,l,c;if(et(this,Go,this.addElement(document.createElement("div"))),P(this,Go).classList.add("responsive-wrapper"),((s=this.options)==null?void 0:s.colorScheme)==="dark"&&this.contentWrapper.classList.add("dark-mode"),this.addCSS(sp),(a=this.options)!=null&&a.cdnForumTweaks&&this.addCSS(MM),this.a=this.querySelector("a"),!this.a)return;const e=BO("",this.a.href),t=(o=this.a)==null?void 0:o.href,{hostname:n,pathname:r}=new URL(t);if(n!=="alpha.twizzle.net"){Yt(this,Ks,Qx).call(this);return}if(["/edit/","/explore/"].includes(r)){const h=r==="/explore/";if(e.puzzle&&!(e.puzzle in gv)){const p=(await an(async()=>{const{getPuzzleDescriptionString:m}=await import("./index-Dti57iVT.js");return{getPuzzleDescriptionString:m}},[])).getPuzzleDescriptionString(e.puzzle);delete e.puzzle,e.experimentalPuzzleDescription=p}if(this.twistyPlayer=P(this,Go).appendChild(new Zc({background:(l=this.options)!=null&&l.cdnForumTweaks?"checkered-transparent":"checkered",colorScheme:((c=this.options)==null?void 0:c.colorScheme)==="dark"?"dark":"light",...e,viewerLink:h?"experimental-twizzle-explorer":"auto"})),this.twistyPlayer.fullscreenElement=this.contentWrapper,e.experimentalTitle&&(this.twistyPlayer.experimentalTitle=e.experimentalTitle),et(this,Ea,P(this,Go).appendChild(document.createElement("div"))),P(this,Ea).classList.add("scrollable-region"),e.experimentalTitle&&Yt(this,Ks,ap).call(this,e.experimentalTitle).classList.add("title"),e.experimentalSetupAlg){Yt(this,Ks,ap).call(this,"Setup",async()=>{var m,v;return((v=await((m=this.twistyPlayer)==null?void 0:m.experimentalModel.setupAlg.get()))==null?void 0:v.alg.toString())??null});const p=P(this,Ea).appendChild(document.createElement("div"));p.classList.add("setup-alg"),p.textContent=new Qe(e.experimentalSetupAlg).toString()}const u=Yt(this,Ks,ap).call(this,"Moves",async()=>{var p,m;return((m=await((p=this.twistyPlayer)==null?void 0:p.experimentalModel.alg.get()))==null?void 0:m.alg.toString())??null});et(this,Qu,u.appendChild(NO(this.twistyPlayer.experimentalModel))),P(this,Qu).classList.add("move-count"),P(this,Ea).appendChild(new yM({twistyPlayer:this.twistyPlayer})).part.add("twisty-alg-viewer")}else Yt(this,Ks,Qx).call(this)}},Ks=new WeakSet,Qx=function(){var t;if(this.contentWrapper.textContent="",this.a){const n=this.contentWrapper.appendChild(document.createElement("span"));n.textContent="❗️",n.title="Could not show a player for link",this.addElement(this.a)}this.removeCSS(sp);const e=this.shadow.adoptedStyleSheets.indexOf(sp);typeof e<"u"&&this.shadow.adoptedStyleSheets.splice(e,e+1),(t=P(this,Am))==null||t.remove()},Am=new WeakMap,Ea=new WeakMap,Go=new WeakMap,Qu=new WeakMap,ap=function(e,t){const n=P(this,Ea).appendChild(document.createElement("div"));n.classList.add("heading");const r=n.appendChild(document.createElement("span"));if(r.textContent=e,t){r.textContent+=" ";const s=r.appendChild(document.createElement("a"));s.textContent="📋",s.href="#",s.title="Copy to clipboard";async function a(o){s.textContent=o,await new Promise(l=>setTimeout(l,2e3)),s.textContent===o&&(s.textContent="📋")}s.addEventListener("click",async o=>{o.preventDefault(),s.textContent="📋…";const l=await t();if(l)try{await navigator.clipboard.writeText(l),a("📋✅")}catch(c){throw a("📋❌"),c}else a("📋❌")})}return n},F1);Mi.define("twizzle-link",kO);function NO(i,e=document.createElement("span")){async function t(){const[n,r]=await Promise.all([i.puzzleAlg.get(),i.puzzleLoader.get()]);if(n.issues.errors.length!==0){e.textContent="";return}let s=!0;function a(o){s?s=!1:e.append(")(");const l=e.appendChild(document.createElement("span")),c=oI(r,o,n.alg);l.append(`${OO[o]}: `);const h=l.appendChild(document.createElement("span"));h.textContent=c.toString(),h.classList.add("move-number"),l.setAttribute("data-before",m2[o]??""),l.setAttribute("title",m2[o]??"")}e.textContent="(",r.id==="3x3x3"?(a("OBTM"),a("OBQTM"),a("RBTM")):r.pg&&(a("RBTM"),a("RBQTM")),a("ETM"),e.append(")")}return i.puzzleAlg.addFreshListener(t),i.puzzleID.addFreshListener(t),e}var zO={expose:!0};function VO(i){const e=new WeakMap;return{postMessage:i.postMessage.bind(i),addEventListener:(t,n)=>{const r=s=>{"handleEvent"in n?n.handleEvent({data:s}):n({data:s})};i.on("message",r),e.set(n,r)},removeEventListener:(t,n)=>{const r=e.get(n);r&&(i.off("message",r),e.delete(n))},nodeWorker:i,terminate:()=>{i.terminate()}}}var HO=VO,wM=2**53,WO=2097152,GO=11,b0=new Uint32Array(2);function ZO(){globalThis.crypto.getRandomValues(b0);const i=b0[0],e=b0[1];return Math.floor(i*WO)+(e>>GO)}function qO(i){if(typeof i!="number"||i<0||Math.floor(i)!==i)throw new Error("randomUIntBelow() not called with a positive integer value.");if(i>wM)throw new Error(`Called randomUIntBelow() with max === ${i}, which is larger than JavaScript can handle with integer precision.`)}function XO(i){qO(i);for(var e,t,n;;)if(e=ZO(),t=Math.floor(e/i),n=t*i,n<=wM-i)return e-n}function AM(i){return i[XO(i.length)]}/** * @license * Copyright 2019 Google LLC * SPDX-License-Identifier: Apache-2.0 - */const EM=Symbol("Comlink.proxy"),jO=Symbol("Comlink.endpoint"),YO=Symbol("Comlink.releaseProxy"),U0=Symbol("Comlink.finalizer"),op=Symbol("Comlink.thrown"),TM=i=>typeof i=="object"&&i!==null||typeof i=="function",$O={canHandle:i=>TM(i)&&i[EM],serialize(i){const{port1:e,port2:t}=new MessageChannel;return CM(i,e),[t,[t]]},deserialize(i){return i.start(),PM(i)}},KO={canHandle:i=>TM(i)&&op in i,serialize({value:i}){let e;return i instanceof Error?e={isError:!0,value:{message:i.message,name:i.name,stack:i.stack}}:e={isError:!1,value:i},[e,[]]},deserialize(i){throw i.isError?Object.assign(new Error(i.value.message),i.value):i.value}},FM=new Map([["proxy",$O],["throw",KO]]);function JO(i,e){for(const t of i)if(e===t||t==="*"||t instanceof RegExp&&t.test(e))return!0;return!1}function CM(i,e=globalThis,t=["*"]){e.addEventListener("message",function n(r){if(!r||!r.data)return;if(!JO(t,r.origin)){console.warn(`Invalid origin '${r.origin}' for comlink proxy`);return}const{id:s,type:a,path:o}=Object.assign({path:[]},r.data),l=(r.data.argumentList||[]).map(Mo);let c;try{const h=o.slice(0,-1).reduce((d,p)=>d[p],i),u=o.reduce((d,p)=>d[p],i);switch(a){case"GET":c=u;break;case"SET":h[o.slice(-1)[0]]=Mo(r.data.value),c=!0;break;case"APPLY":c=u.apply(h,l);break;case"CONSTRUCT":{const d=new u(...l);c=rk(d)}break;case"ENDPOINT":{const{port1:d,port2:p}=new MessageChannel;CM(i,p),c=ik(d,[d])}break;case"RELEASE":c=void 0;break;default:return}}catch(h){c={value:h,[op]:0}}Promise.resolve(c).catch(h=>({value:h,[op]:0})).then(h=>{const[u,d]=Ip(h);e.postMessage(Object.assign(Object.assign({},u),{id:s}),d),a==="RELEASE"&&(e.removeEventListener("message",n),DM(e),U0 in i&&typeof i[U0]=="function"&&i[U0]())}).catch(h=>{const[u,d]=Ip({value:new TypeError("Unserializable return value"),[op]:0});e.postMessage(Object.assign(Object.assign({},u),{id:s}),d)})}),e.start&&e.start()}function QO(i){return i.constructor.name==="MessagePort"}function DM(i){QO(i)&&i.close()}function PM(i,e){return eR(i,[],e)}function Af(i){if(i)throw new Error("Proxy has been released and is not useable")}function IM(i){return Kl(i,{type:"RELEASE"}).then(()=>{DM(i)})}const Dp=new WeakMap,Pp="FinalizationRegistry"in globalThis&&new FinalizationRegistry(i=>{const e=(Dp.get(i)||0)-1;Dp.set(i,e),e===0&&IM(i)});function ek(i,e){const t=(Dp.get(e)||0)+1;Dp.set(e,t),Pp&&Pp.register(i,e,i)}function tk(i){Pp&&Pp.unregister(i)}function eR(i,e=[],t=function(){}){let n=!1;const r=new Proxy(t,{get(s,a){if(Af(n),a===YO)return()=>{tk(r),IM(i),n=!0};if(a==="then"){if(e.length===0)return{then:()=>r};const o=Kl(i,{type:"GET",path:e.map(l=>l.toString())}).then(Mo);return o.then.bind(o)}return eR(i,[...e,a])},set(s,a,o){Af(n);const[l,c]=Ip(o);return Kl(i,{type:"SET",path:[...e,a].map(h=>h.toString()),value:l},c).then(Mo)},apply(s,a,o){Af(n);const l=e[e.length-1];if(l===jO)return Kl(i,{type:"ENDPOINT"}).then(Mo);if(l==="bind")return eR(i,e.slice(0,-1));const[c,h]=g2(o);return Kl(i,{type:"APPLY",path:e.map(u=>u.toString()),argumentList:c},h).then(Mo)},construct(s,a){Af(n);const[o,l]=g2(a);return Kl(i,{type:"CONSTRUCT",path:e.map(c=>c.toString()),argumentList:o},l).then(Mo)}});return ek(r,i),r}function nk(i){return Array.prototype.concat.apply([],i)}function g2(i){const e=i.map(Ip);return[e.map(t=>t[0]),nk(e.map(t=>t[1]))]}const BM=new WeakMap;function ik(i,e){return BM.set(i,e),i}function rk(i){return Object.assign(i,{[EM]:!0})}function Ip(i){for(const[e,t]of FM)if(t.canHandle(i)){const[n,r]=t.serialize(i);return[{type:"HANDLER",name:e,value:n},r]}return[{type:"RAW",value:i},BM.get(i)||[]]}function Mo(i){switch(i.type){case"HANDLER":return FM.get(i.name).deserialize(i.value);case"RAW":return i.value}}function Kl(i,e,t){return new Promise(n=>{const r=sk();i.addEventListener("message",function s(a){!a.data||!a.data.id||a.data.id!==r||(i.removeEventListener("message",s),n(a.data))}),i.start&&i.start(),i.postMessage(Object.assign({id:r},e),t)})}function sk(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}var ak="node:w-orker-_threa-ds",ok=()=>ak.replace(/-/g,""),lk=typeof globalThis.Worker>"u"&&typeof globalThis.WorkerNavigator>"u";async function ck(i,e){const{Worker:t}=await import(ok()),n=new t(i,e);return n.unref(),HO(n)}async function hk(i,e){let t;if(lk)return ck(i,{eval:e==null?void 0:e.eval});if(e!=null&&e.eval){const n=new Blob([i],{type:"application/javascript"});i=URL.createObjectURL(n)}return t=new globalThis.Worker(i,{type:e?e.type:void 0}),t}async function uk(){return import.meta.resolve("./search-worker-entry.js")}function dk(){return new URL("data:text/javascript;base64,aW1wb3J0IHsKICBub2RlRW5kcG9pbnRQb3J0Cn0gZnJvbSAiLi9jaHVuay1QUDQ0UDZXSy5qcyI7CmltcG9ydCB7CiAgZXhwb3NlQVBJCn0gZnJvbSAiLi9jaHVuay03R1VMM09CUS5qcyI7CmltcG9ydCAiLi9jaHVuay1SRFNRUlczRy5qcyI7CgovLyBzcmMvY3ViaW5nL3NlYXJjaC93b3JrZXItd29ya2Fyb3VuZHMvc2VhcmNoLXdvcmtlci1lbnRyeS5qcwppZiAoZXhwb3NlQVBJLmV4cG9zZSkgewogIChhc3luYyAoKSA9PiB7CiAgICBhd2FpdCBpbXBvcnQoIi4vaW5zaWRlLVkyVVZKWk5KLmpzIik7CiAgICBjb25zdCBtZXNzYWdlUG9ydCA9IGdsb2JhbFRoaXMucG9zdE1lc3NhZ2UgPyBnbG9iYWxUaGlzIDogYXdhaXQgbm9kZUVuZHBvaW50UG9ydCgpOwogICAgbWVzc2FnZVBvcnQucG9zdE1lc3NhZ2UoImNvbWxpbmstZXhwb3NlZCIpOwogIH0pKCk7Cn0KdmFyIFdPUktFUl9FTlRSWV9GSUxFX1VSTCA9IGltcG9ydC5tZXRhLnVybDsKZXhwb3J0IHsKICBXT1JLRVJfRU5UUllfRklMRV9VUkwKfTsKLy8jIHNvdXJjZU1hcHBpbmdVUkw9c2VhcmNoLXdvcmtlci1lbnRyeS5qcy5tYXAK",import.meta.url)}async function fk(){return zO.expose=!1,(await an(async()=>{const{WORKER_ENTRY_FILE_URL:i}=await import("./search-worker-entry-CmpnuiQ5.js").then(e=>e.s);return{WORKER_ENTRY_FILE_URL:i}},[])).WORKER_ENTRY_FILE_URL}function pk(){return new Worker(new URL("/assets/search-worker-entry-DNPX3OpU.js",import.meta.url),{type:"module"})}function mk(i){var e;try{const t=(e=globalThis.location)==null?void 0:e.origin,n=i.origin;return!!t&&!!n&&t!==n}catch{return!1}}async function y0(i){const e=new URL(i,import.meta.url),t=mk(e);try{return x2(e,t)}catch{return x2(e,!t)}}async function x2(i,e){return new Promise(async(t,n)=>{var r;try{i||n(new Error("Could not get worker entry file URL."));let s=i;if(e){const c=`import ${JSON.stringify(i.toString())};`,h=new Blob([c],{type:"text/javascript"});s=new URL(URL.createObjectURL(h))}const a=await hk(s,{type:"module"});(r=a.unref)==null||r.call(a);const o=c=>{n(c)},l=c=>{c==="comlink-exposed"?t(OM(a)):n(new Error(`wrong module instantiation message ${c}`))};a.nodeWorker?a.nodeWorker.once("message",l):(a.addEventListener("error",o,{once:!0}),a.addEventListener("message",c=>l(c.data),{once:!0}))}catch(s){n(s)}})}async function gk(){return new Promise(async(i,e)=>{try{const t=pk(),n=s=>{e(s)},r=s=>{s==="comlink-exposed"?i(OM(t)):e(new Error(`wrong module instantiation message ${s}`))};t.addEventListener("error",n,{once:!0}),t.addEventListener("message",s=>r(s.data),{once:!0})}catch(t){e(t)}})}function OM(i){const e=PM(i),t=i.terminate.bind(i);return{insideAPI:e,outsideAPI:{terminate:t}}}async function xk(){const i=Rk(),{insideAPI:e}=await i;return e.setDebugMeasurePerf(tR.logPerf),e.setScramblePrefetchLevel(tR.scramblePrefetchLevel),i}async function Rk(){var t;((t=globalThis.location)==null?void 0:t.protocol)==="file:"&&console.warn("This current web page is loaded from the local filesystem (a URL that starts with `file://`). In this situation, `cubing.js` may be unable to generate scrambles or perform searches in some browsers. See: https://js.cubing.net/cubing/scramble/#file-server-required");function i(n){return`Module worker instantiation${n?` ${n}`:""} failed`}const e=[[async()=>y0(await uk()),"using `import.meta.resolve(…)",null],[gk,"using inline `new URL(…, import.meta.url)`","may"],[async()=>y0(dk()),"using `new URL(…, import.meta.url)`","will"],[async()=>y0(await fk()),"using the `esbuild` workaround","will"]];for(const[n,r,s]of e)try{const a=await n();return s&&tR.showWorkerInstantiationWarnings&&console.warn(`Module worker instantiation required ${r}. \`cubing.js\` ${s} not support this fallback in the future.`),a}catch{console.warn(`${i(r)}, falling back.`)}throw new Error(`${i()}. There are no more fallbacks available. If you are using Firefox, please update to version 114 or later.`)}var vk;function bk(){return vk??(vk=xk())}async function kM(i){const e=await bk();return Qe.fromString(await e.insideAPI.solve333ToString(i.patternData))}var tR={logPerf:!0,scramblePrefetchLevel:"auto",disableStringWorker:!1,forceNewWorkerForEveryScramble:!1,showWorkerInstantiationWarnings:!0},NM=!1;function $9(i){NM=i}function Uk(){if(!NM)throw new Error("Must be called from inside a worker, to avoid impact on page performance. Try importing from the top level of `cubing/solve`?")}function yk(i,e){const t=new yp;t.experimentalPushAlg(i);for(const n of e){const r=AM(n);r!==null&&t.push(ce.fromString(r))}return t.toAlg()}var zM=Em(()=>an(()=>import("./search-dynamic-solve-3x3x3-QHRLSVAC-6iYVGW9D.js"),[])),_k="UF UR UB UL DF DR DB DL FR FL BR BL".split(" "),Lk="UFR URB UBL ULF DRF DFL DLB DBR".split(" "),Sk="U L F R B D".split(" "),Mk=[[1,2,0],[0,2,0],[1,1,0],[0,3,0],[2,0,0],[0,1,0],[1,3,0],[0,0,0],[1,0,0],[1,0,2],[0,1,1],[1,1,1],[0,8,1],[2,3,0],[0,10,1],[1,4,1],[0,5,1],[1,7,2],[1,3,2],[0,0,1],[1,0,1],[0,9,0],[2,2,0],[0,8,0],[1,5,1],[0,4,1],[1,4,2],[1,5,0],[0,4,0],[1,4,0],[0,7,0],[2,5,0],[0,5,0],[1,6,0],[0,6,0],[1,7,0],[1,2,2],[0,3,1],[1,3,1],[0,11,1],[2,1,0],[0,9,1],[1,6,1],[0,7,1],[1,5,2],[1,1,2],[0,2,1],[1,2,1],[0,10,0],[2,4,0],[0,11,0],[1,7,1],[0,6,1],[1,6,2]];function R2(i,e){return i.slice(e)+i.slice(0,e)}function wk(i){const e=[[],[]];for(let t=0;t<6;t++)if(i.patternData.CENTERS.pieces[t]!==t)throw new Error("non-oriented puzzles are not supported");for(let t=0;t<12;t++)e[0].push(R2(_k[i.patternData.EDGES.pieces[t]],i.patternData.EDGES.orientation[t]));for(let t=0;t<8;t++)e[1].push(R2(Lk[i.patternData.CORNERS.pieces[t]],i.patternData.CORNERS.orientation[t]));return e.push(Sk),e}function Ak(i){const e=wk(i);return Mk.map(([t,n,r])=>e[t][n][r]).join("")}function v2(i,e){const t=new Lc(i.kpuzzle,{EDGES:i.patternData.EDGES,CORNERS:i.patternData.CORNERS,CENTERS:{pieces:i.patternData.CENTERS.pieces,orientation:new Array(6).fill(0)}}).experimentalToTransformation(),n=new Lc(e.kpuzzle,{EDGES:e.patternData.EDGES,CORNERS:e.patternData.CORNERS,CENTERS:{pieces:e.patternData.CENTERS.pieces,orientation:new Array(6).fill(0)}}).experimentalToTransformation();return t.isIdentical(n)}function Ek(i,e){if(v2(i.defaultPattern(),e))return!1;for(const t of"ULFRBD")for(let n=1;n<4;n++){const r=i.moveToTransformation(new ce(t,n)).toKPattern();if(v2(r,e))return!1}return!0}var Tk=[["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"]];async function VM(){const i=await gv["3x3x3"].kpuzzle();let e=i.defaultPattern();for(const t of Tk)e=e.applyAlg(Qe.fromString(AM(t)));return Ek(i,e)?e:VM()}async function Fk(i){return Uk(),Qe.fromString((await zM).solvePattern(Ak(i)))}async function Ck(){return Fk(await VM())}async function K9(){(await zM).initialize()}var Dk=[[null,"Rw","Rw2","Rw'","Fw","Fw'"],[null,"Dw","Dw2","Dw'"]];async function J9(){return yk(await Ck(),Dk)}var nR=function(){var i=2,e=20,t=7,n=13,r=2;function s(){this.move=[],this.moveSol=[],this.nodeUD=[],this.valid1=0,this.allowShorter=!1,this.cc=new te,this.urfCubieCube=[],this.urfCoordCube=[],this.phase1Cubie=[],this.preMoveCubes=[],this.preMoves=[],this.preMoveLen=0,this.maxPreMoves=0,this.isRec=!1;for(var k=0;k<21;k++)this.nodeUD[k]=new $e,this.phase1Cubie[k]=new te;for(var k=0;k<6;k++)this.urfCubieCube[k]=new te,this.urfCoordCube[k]=new $e;for(var k=0;k=ut?1:0)<>3]^=se<<(G<<2)}function Te(k,G){return k[G>>3]>>(G<<2)&15}function Se(k,G,se){return Math.min(k,G[se>>3]>>(se<<2)&15)}function qe(k){return(k-286331153&~k&2290649224)!=0}function Ne(k){return k^We>>((k&15)<<1)&3}function ze(k,G,se){var re=Xt[k];return se&&(re=Ne(re)),re&65520|Ve[re&15][G]}function te(){this.ca=[0,1,2,3,4,5,6,7],this.ea=[0,1,2,3,4,5,6,7,8,9,10,11]}function Ye(k,G,se){se--;for(var re=1985229328,Me=0;Me>ke&15;var pt=(1<>4&~pt)}k[se]=k[se]&240|re&15}function Lt(k,G){for(var se=0,re=1985229328,Me=0;Me>ge&15),re-=286331152<=0;--re){k[re]=k[re]&240|G%(se-re),G=~~(G/(se-re));for(var Me=re+1;Me=(k[re]&15)&&(k[Me]+=1)}}function C(k,G){for(var se=0,re=0;re=0;ge--){var ke=k[ge]&15;(ke&12)==G&&(re+=je[ge][Me--])}return re}function Pe(k,G,se){for(var re=k.length-1,Me=4,ge=re,ke=re;ke>=0;ke--)G>=je[ke][Me]?(G-=je[ke][Me--],k[ke]=k[ke]&240|Me|se):((ge&12)==se&&(ge-=4),k[ke]=k[ke]&240|ge--)}function Ce(k,G){for(var se=0,re=G-2;re>=0;re--)se^=k%(G-re),k=~~(k/(G-re));return se&1}te.EdgeMult=function(k,G,se){for(var re=0;re<12;re++)se.ea[re]=k.ea[G.ea[re]&15]^G.ea[re]&16},te.CornMult=function(k,G,se){for(var re=0;re<8;re++){var Me=((k.ca[G.ca[re]&15]>>4)+(G.ca[re]>>4))%3;se.ca[re]=k.ca[G.ca[re]&15]&15|Me<<4}},te.CornMultFull=function(k,G,se){for(var re=0;re<8;re++){var Me=k.ca[G.ca[re]&15]>>4,ge=G.ca[re]>>4,ke=Me+(Me<3?ge:6-ge);ke=ke%3+(Me<3==ge<3?0:3),se.ca[re]=k.ca[G.ca[re]&15]&15|ke<<4}},te.CornConjugate=function(k,G,se){for(var re=wt[rt[0][G]],Me=wt[G],ge=0;ge<8;ge++){var ke=re.ca[k.ca[Me.ca[ge]&15]&15]>>4,pt=k.ca[Me.ca[ge]&15]>>4,Ke=ke<3?pt:(3-pt)%3;se.ca[ge]=re.ca[k.ca[Me.ca[ge]&15]&15]&15|Ke<<4}},te.EdgeConjugate=function(k,G,se){for(var re=wt[rt[0][G]],Me=wt[G],ge=0;ge<12;ge++)se.ea[ge]=re.ea[k.ea[Me.ea[ge]&15]&15]^k.ea[Me.ea[ge]&15]&16^Me.ea[ge]&16},te.prototype.init=function(k,G){return this.ca=k.slice(),this.ea=G.slice(),this},te.prototype.initCoord=function(k,G,se,re){return Ye(this.ca,k,8),this.setTwst(G),H(this.ea,se,12),this.setFlip(re),this},te.prototype.isEqual=function(k){for(var G=0;G<8;G++)if(this.ca[G]!=k.ca[G])return!1;for(var G=0;G<12;G++)if(this.ea[G]!=k.ea[G])return!1;return!0},te.prototype.setFlip=function(k){for(var G=0,se=10;se>=0;se--,k>>=1)this.ea[se]=this.ea[se]&15|(k&1)<<4,G^=this.ea[se];this.ea[11]=this.ea[11]&15|G&16},te.prototype.getFlip=function(){for(var k=0,G=0;G<11;G++)k=k<<1|this.ea[G]>>4&1;return k},te.prototype.getFlipSym=function(){return Pt[this.getFlip()]},te.prototype.setTwst=function(k){for(var G=15,se=6;se>=0;se--,k=~~(k/3))this.ca[se]=this.ca[se]&15|k%3<<4,G-=this.ca[se]>>4;this.ca[7]=this.ca[7]&15|G%3<<4},te.prototype.getTwst=function(){for(var k=0,G=0;G<7;G++)k+=(k<<1)+(this.ca[G]>>4);return k},te.prototype.getTwstSym=function(){return Ae[this.getTwst()]},te.prototype.setCPerm=function(k){Ye(this.ca,k,8)},te.prototype.getCPerm=function(){return Lt(this.ca,8)},te.prototype.getCPermSym=function(){return Ne(bt[Lt(this.ca,8)])},te.prototype.setEPerm=function(k){Ye(this.ea,k,8)},te.prototype.getEPerm=function(){return Lt(this.ea,8)},te.prototype.getEPermSym=function(){return bt[Lt(this.ea,8)]},te.prototype.getSlice=function(){return 494-de(this.ea,8)},te.prototype.setSlice=function(k){Pe(this.ea,494-k,8)},te.prototype.getMPerm=function(){return C(this.ea,12)%24},te.prototype.setMPerm=function(k){H(this.ea,k,12)},te.prototype.getCComb=function(){return de(this.ca,0)},te.prototype.setCComb=function(k){Pe(this.ca,k,0)},te.prototype.URFConjugate=function(){var k=new te;te.CornMult(te.urf2,this,k),te.CornMult(k,te.urf1,this),te.EdgeMult(te.urf2,this,k),te.EdgeMult(k,te.urf1,this)};var ue=[[8,9,20],[6,18,38],[0,36,47],[2,45,11],[29,26,15],[27,44,24],[33,53,42],[35,17,51]],ot=[[5,10],[7,19],[3,37],[1,46],[32,16],[28,25],[30,43],[34,52],[23,12],[21,41],[50,39],[48,14]];te.prototype.toFaceCube=function(k,G){k=k||ue,G=G||ot;for(var se="URFDLB",re=[],Me=0;Me<54;Me++)re[Me]=se[~~(Me/9)];for(var ge=0;ge<8;ge++)for(var ke=this.ca[ge]&15,pt=this.ca[ge]>>4,Ke=0;Ke<3;Ke++)re[k[ge][(Ke+pt)%3]]=se[~~(k[ke][Ke]/9)];for(var _t=0;_t<12;_t++)for(var ke=this.ea[_t]&15,pt=this.ea[_t]>>4,Ke=0;Ke<2;Ke++)re[G[_t][(Ke+pt)%2]]=se[~~(G[ke][Ke]/9)];return re.join("")},te.prototype.invFrom=function(k){for(var G=0;G<12;G++)this.ea[k.ea[G]&15]=G&15|k.ea[G]&16;for(var se=0;se<8;se++)this.ca[k.ca[se]&15]=se|64>>(k.ca[se]>>4)&48;return this},te.prototype.fromFacelet=function(k,G,se){G=G||ue,se=se||ot;for(var re=0,Me=[],ge=k[4]+k[13]+k[22]+k[31]+k[40]+k[49],Ke=0;Ke<54;++Ke){if(Me[Ke]=ge.indexOf(k[Ke]),Me[Ke]==-1)return-1;re+=1<<(Me[Ke]<<2)}if(re!=10066329)return-1;var ke,pt,Ke,_t,Ft;for(Ke=0;Ke<8;++Ke){for(Ft=0;Ft<3&&!(Me[G[Ke][Ft]]==0||Me[G[Ke][Ft]]==3);++Ft);for(ke=Me[G[Ke][(Ft+1)%3]],pt=Me[G[Ke][(Ft+2)%3]],_t=0;_t<8;++_t)if(ke==~~(G[_t][1]/9)&&pt==~~(G[_t][2]/9)){this.ca[Ke]=_t|Ft%3<<4;break}}for(Ke=0;Ke<12;++Ke)for(_t=0;_t<12;++_t){if(Me[se[Ke][0]]==~~(se[_t][0]/9)&&Me[se[Ke][1]]==~~(se[_t][1]/9)){this.ea[Ke]=_t;break}if(Me[se[Ke][0]]==~~(se[_t][1]/9)&&Me[se[Ke][1]]==~~(se[_t][0]/9)){this.ea[Ke]=_t|16;break}}};function $e(){this.twst=0,this.flip=0,this.slice=0,this.prun=0,this.twstc=0,this.flipc=0}$e.prototype.set=function(k){this.twst=k.twst,this.flip=k.flip,this.slice=k.slice,this.prun=k.prun,this.twstc=k.twstc,this.flipc=k.flipc},$e.prototype.calcPruning=function(k){this.prun=Math.max(Se(ee,Ei,(this.twst>>3)*Ue+Vn[this.slice<<3|this.twst&7]),Se(pe,zi,(this.flip>>3)*Ue+Vn[this.slice<<3|this.flip&7]),Se(B,Vi,this.twstc>>3<<11|K[this.flipc^this.twstc&7]),Se(B,Vi,this.twst>>3<<11|K[this.flip^this.twst&7]))},$e.prototype.setWithPrun=function(k,G){if(this.twst=k.getTwstSym(),this.flip=k.getFlipSym(),this.prun=Se(B,Vi,this.twst>>3<<11|K[this.flip^this.twst&7]),this.prun>G||(this.slice=k.getSlice(),this.prun=Math.max(this.prun,Se(ee,Ei,(this.twst>>3)*Ue+Vn[this.slice<<3|this.twst&7]),Se(pe,zi,(this.flip>>3)*Ue+Vn[this.slice<<3|this.flip&7])),this.prun>G))return!1;{var se=new te;te.CornConjugate(k,1,se),te.EdgeConjugate(k,1,se),this.twstc=se.getTwstSym(),this.flipc=se.getFlipSym(),this.prun=Math.max(this.prun,Se(B,Vi,this.twstc>>3<<11|K[this.flipc^this.twstc&7]))}return this.prun<=G},$e.prototype.doMovePrun=function(k,G,se){return this.slice=ti[k.slice*O+G],this.flip=ei[(k.flip>>3)*O+Xe[G<<3|k.flip&7]]^k.flip&7,this.twst=Wt[(k.twst>>3)*O+Xe[G<<3|k.twst&7]]^k.twst&7,this.prun=Math.max(Se(ee,Ei,(this.twst>>3)*Ue+Vn[this.slice<<3|this.twst&7]),Se(pe,zi,(this.flip>>3)*Ue+Vn[this.slice<<3|this.flip&7]),Se(B,Vi,this.twst>>3<<11|K[this.flip^this.twst&7])),this.prun},$e.prototype.doMovePrunConj=function(k,G){return G=Tt[3][G],this.flipc=ei[(k.flipc>>3)*O+Xe[G<<3|k.flipc&7]]^k.flipc&7,this.twstc=Wt[(k.twstc>>3)*O+Xe[G<<3|k.twstc&7]]^k.twstc&7,Se(B,Vi,this.twstc>>3<<11|K[this.flipc^this.twstc&7])},s.prototype.solution=function(k,G,se,re,Me,ge,ke){vt();var pt=this.verify(k);if(pt!=0)return"Error "+Math.abs(pt);G===void 0&&(G=21),se===void 0&&(se=1e9),re===void 0&&(re=0),Me===void 0&&(Me=0),this.sol=G+1,this.probe=0,this.probeMax=se,this.probeMin=Math.min(re,se),this.verbose=Me,this.moveSol=null,this.isRec=!1,this.firstFilters=[0,0,0,0,0,0],this.lastFilters=[0,0,0,0,0,0];for(var Ke=0;Ke<3;Ke++)ge!==void 0&&(this.firstFilters[Ke]|=3591<<~~(De[(3-Ke)%3][ge*3]/3)*3,this.lastFilters[Ke+3]|=3591<<~~(De[(3-Ke)%3][ge*3]/3)*3),ke!==void 0&&(this.lastFilters[Ke]|=3591<<~~(De[(3-Ke)%3][ke*3]/3)*3,this.firstFilters[Ke+3]|=3591<<~~(De[(3-Ke)%3][ke*3]/3)*3);return this.initSearch(),this.search()},s.prototype.initSearch=function(){this.conjMask=0,this.maxPreMoves=this.conjMask>7?0:e;for(var k=0;k<6;k++)if(this.urfCubieCube[k].init(this.cc.ca,this.cc.ea),this.urfCoordCube[k].setWithPrun(this.urfCubieCube[k],20),this.cc.URFConjugate(),k%3==2){var G=new te().invFrom(this.cc);this.cc.init(G.ca,G.ea)}},s.prototype.next=function(k,G,se){return this.probe=0,this.probeMax=k,this.probeMin=Math.min(G,k),this.moveSol=null,this.isRec=!0,this.verbose=se,this.search()},s.prototype.verify=function(k){if(this.cc.fromFacelet(k)==-1)return-1;for(var G=0,se=0,re=0;re<12;re++)se|=1<<(this.cc.ea[re]&15),G^=this.cc.ea[re]>>4;if(se!=4095)return-2;if(G!=0)return-3;var Me=0;G=0;for(var ge=0;ge<8;ge++)Me|=1<<(this.cc.ca[ge]&15),G+=this.cc.ca[ge]>>4;return Me!=255?-4:G%3!=0?-5:Ce(C(this.cc.ea,12),12)^Ce(this.cc.getCPerm(),8)?-6:0},s.prototype.phase1PreMoves=function(k,G,se){if(k==this.maxPreMoves-1&&this.lastFilter>>G&1)return 1;if(this.preMoveLen=this.maxPreMoves-k,(this.isRec?this.depth1==this.length1-this.preMoveLen:this.preMoveLen==0||!(225207>>G&1))&&(this.depth1=this.length1-this.preMoveLen,this.phase1Cubie[0].init(se.ca,se.ea),this.allowShorter=this.depth1==t&&this.preMoveLen!=0,this.nodeUD[this.depth1+1].setWithPrun(se,this.depth1)&&this.phase1(this.nodeUD[this.depth1+1],this.depth1,-1)==0))return 0;if(k==0||this.preMoveLen+t>=this.length1)return 1;var re=0;(k==1||this.preMoveLen+1+t>=this.length1)&&(re|=225207),G=~~(G/3)*3;for(var Me=0;Me<18;Me++){if(Me==G||Me==G-9||Me==G+9){Me+=2;continue}if(!(this.isRec&&Me!=this.preMoves[this.maxPreMoves-k]||re&1<=(this.moveSol==null?this.probeMax:this.probeMin))return 0;++this.probe;for(var k=this.valid1;k>=4;var re=k.getEPermSym(),Me=re&15;re>>=4;var ge=k.getMPerm(),ke=Math.max(Se(ae,ms,re*ve+ps[(Vt[G]&255)<<4|rt[Me][se]]),Se(Re,Ya,G*oe+fs[ge<<4|se])),pt=Math.min(n,this.sol-this.length1);if(ke>=pt)return ke>pt?2:1;var Ke;for(Ke=pt-1;Ke>=ke;Ke--){var _t=this.phase2(re,Me,G,se,ge,Ke,this.depth1,10);if(_t<0)break;Ke-=_t,this.moveSol=[];for(var Ft=0;Ft=0;Ft--)this.appendSolMove(this.preMoves[Ft]);this.sol=this.moveSol.length,this.moveSol=this.solutionToString()}return Ke!=pt-1&&this.probe>=this.probeMin?0:1},s.prototype.phase1=function(k,G,se){if(G==this.depth1-1&&this.firstFilter>>se&1)return 1;if(k.prun==0&&G<5)if(this.allowShorter||G==0){this.depth1-=G;var re=this.initPhase2Pre();return this.depth1+=G,re}else return 1;for(var Me=0;Me<18;Me+=3)if(!(Me==se||Me==se-9))for(var ge=0;ge<3;ge++){var ke=Me+ge;if(!(this.isRec&&ke!=this.move[this.depth1-G])){var pt=this.nodeUD[G].doMovePrun(k,ke,!0);if(pt>G)break;if(pt==G)continue;{if(pt=this.nodeUD[G].doMovePrunConj(k,ke),pt>G)break;if(pt==G)continue}this.move[this.depth1-G]=ke,this.valid1=Math.min(this.valid1,this.depth1-G);var re=this.phase1(this.nodeUD[G],G-1,Me);if(re==0)return 0;if(re==2)break}}return 1},s.prototype.appendSolMove=function(k){if(this.moveSol.length==0){this.moveSol.push(k);return}var G=~~(k/3),se=~~(this.moveSol[this.moveSol.length-1]/3);if(G==se){var re=(k%3+this.moveSol[this.moveSol.length-1]%3+1)%4;re==3?this.moveSol.pop():this.moveSol[this.moveSol.length-1]=G*3+re;return}if(this.moveSol.length>1&&G%3==se%3&&G==~~(this.moveSol[this.moveSol.length-2]/3)){var re=(k%3+this.moveSol[this.moveSol.length-2]%3+1)%4;re==3?(this.moveSol[this.moveSol.length-2]=this.moveSol[this.moveSol.length-1],this.moveSol.pop()):this.moveSol[this.moveSol.length-2]=G*3+re;return}this.moveSol.push(k)},s.prototype.phase2=function(k,G,se,re,Me,ge,ke,pt){if(this.depth1==0&&ke==1&&this.firstFilter>>_e[pt]&1)return-1;if(k==0&&se==0&&Me==0&&(this.preMoveLen>0||!(this.lastFilter>>_e[pt]&1)))return ge;for(var Ke=$[pt],_t=0;_t<10;_t++){if(Ke>>_t&1){_t+=66>>_t&3;continue}var Ft=Gr[Me*A+_t],En=er[se*A+gt[re][_t]],Hn=Ve[En&15][re];if(En>>=4,!(Se(Re,Ya,En*oe+fs[Ft<<4|Hn])>=ge)){var pn=oa[k*A+gt[G][_t]],Xn=Ve[pn&15][G];if(pn>>=4,!(Se(ae,ms,pn*ve+ps[(Vt[En]&255)<<4|rt[Xn][Hn]])>=ge)){var xi=ze(pn,Xn,!1),ni=ze(En,Hn,!0);if(!(Se(ae,ms,(xi>>4)*ve+ps[(Vt[ni>>4]&255)<<4|rt[xi&15][ni&15]])>=ge)){var Ri=this.phase2(pn,Xn,En,Hn,Ft,ge-1,ke+1,_t);if(Ri>=0)return this.move[ke]=_e[_t],Ri}}}}return-1},s.prototype.solutionToString=function(){var k="",G=this.verbose&r?(this.urfIdx+3)%6:this.urfIdx;if(G<3)for(var se=0;se=0;--se)k+=le[De[G][this.moveSol[se]]]+" ";return k};var Oe=[],wt=[],Ve=[],rt=[],Tt=[],gt=[],Xe=[],At=[],Pt=[],on=[],K=[],st=[],Ae=[],Fe=[],Ze=[],bt=[],Ht=[],Vt=[],Xt=[],Wt=[],ei=[],ti=[],Vn=[],Ei=[],zi=[],Vi=[],er=[],oa=[],Gr=[],fs=[],la=[],ps=[],Ya=[],ms=[],B=15,ee=15,pe=15,Re=15,ae=15;{for(var Le=0;Le<18;Le++)Oe[Le]=new te;Oe[0].initCoord(15120,0,119750400,0),Oe[3].initCoord(21021,1494,323403417,0),Oe[6].initCoord(8064,1236,29441808,550),Oe[9].initCoord(9,0,5880,0),Oe[12].initCoord(1230,412,2949660,0),Oe[15].initCoord(224,137,328552,137);for(var He=0;He<18;He+=3)for(var tt=0;tt<2;tt++)te.EdgeMult(Oe[He+tt],Oe[He],Oe[He+tt+1]),te.CornMult(Oe[He+tt],Oe[He],Oe[He+tt+1]);te.urf1=new te().initCoord(2531,1373,67026819,1367),te.urf2=new te().initCoord(2089,1906,322752913,2040)}function ft(){for(var k=new te,G=new te,se=new te().initCoord(28783,0,259268407,0),re=new te().initCoord(15138,0,119765538,7),Me=new te().initCoord(5167,0,83473207,0),ge=0;ge<8;ge++)Me.ca[ge]|=48;for(var ge=0;ge<16;ge++)wt[ge]=new te().init(k.ca,k.ea),te.CornMultFull(k,re,G),te.EdgeMult(k,re,G),k.init(G.ca,G.ea),ge%4==3&&(te.CornMultFull(k,Me,G),te.EdgeMult(k,Me,G),k.init(G.ca,G.ea)),ge%8==7&&(te.CornMultFull(k,se,G),te.EdgeMult(k,se,G),k.init(G.ca,G.ea));for(var ge=0;ge<16;ge++)Ve[ge]=[],rt[ge]=[],Tt[ge]=[],Xe[ge]=[],gt[ge]=[];for(var ge=0;ge<16;ge++)for(var ke=0;ke<16;ke++)Ve[ge][ke]=ge^ke^84660>>ke&ge<<1&2,rt[Ve[ge][ke]][ke]=ge;k=new te;for(var pt=0;pt<16;pt++)for(var ke=0;ke<18;ke++){te.CornConjugate(Oe[ke],rt[0][pt],k);e:for(var Ke=0;Ke<18;Ke++){for(var _t=0;_t<8;_t++)if(Oe[Ke].ca[_t]!=k.ca[_t])continue e;Tt[pt][ke]=Ke,gt[pt][X[ke]]=X[Ke];break}pt%2==0&&(Xe[ke<<3|pt>>1]=Tt[pt][ke])}function Ft(pn,Xn,xi,ni,Ri,hi,Wn){for(var Ln=new te,Sr=new te,ui=0,Hi=Ri>=2?1:2,Mr=Ri!=1?te.EdgeConjugate:te.CornConjugate,tr=0;tr>1]=Wi),Wi==tr&&(ni[ui]|=1<>1]=G.getSlice()}for(var ge=0;ge>ke&1^~~(ge/70));for(var ke=0;ke<16;ke++)te.CornConjugate(k,rt[0][ke],G),ps[ge<<4|ke]=G.getCComb()+70*~~(ge/70)}}var it=-1;function Rt(k,G,se,re,Me,ge,ke,pt){var Ke=pt&15,_t=(pt>>4&1)==1?14540032:0,Ft=(pt>>5&1)==1,En=pt>>8&15,Hn=pt>>12&15,pn=pt>>16&15,Xn=(1<>3)+1;Ln++)k[Ln]=-1;Y(k,0,15),Wn=0}else Y(k,ni,15^Wn+1);for(var Sr=i>0?Math.min(Math.max(Wn+1,pn),Hn):Hn;WnEn,Hi=ui?15:Wn,Mr=Hi*286331153,tr=ui?Wn:15;Wn++,it++;for(var fr=Wn^15,Wi=0,Ln=0;Ln>=4){if(!(Ln&7)&&(Wi=k[Ln>>3],!qe(Wi^Mr))){Ln+=7;continue}if((Wi&15)==Hi){var qc=Ln%G,Xc=~~(Ln/G),$a=0,Rl=0;xi&&($a=Pt[qc],Rl=$a&7,$a>>=3);for(var gs=0;gs>=Ke;var yd=xs*G+Ka,vl=Te(k,yd);if(vl!=tr){vl>gs&3);continue}if(ui){Y(k,Ln,fr);break}Y(k,yd,fr);for(var bl=1,_d=ke[xs];(_d>>=1)!=0;bl++)if((_d&1)==1){var Ul=xs*G;xi?Ul+=K[Pt[Ka]^bl]:Ul+=Me[Ka<>(bl<<1)&3],Te(k,Ul)==tr&&Y(k,Ul,fr)}}}}}return Y(k,ni,Wn+1^15),Wn+1}function Ut(k){B=Rt(Vi,E,J,null,null,Wt,Fe,103939),!(it>k)&&(ee=Rt(Ei,Ue,J,ti,Vn,Wt,Fe,431619),!(it>k)&&(pe=Rt(zi,Ue,z,ti,Vn,ei,on,431619),!(it>k)&&(Re=Rt(Ya,24,me,Gr,fs,er,Ht,584244),!(it>k)&&(ae=Rt(ms,ve,me,la,ps,oa,Ht,514084)))))}function vt(){if(it<0&&(ft(),it=0),it==0)Ut(99);else if(it<54)Ut(it);else return!0;return!1}function Kt(){var k,G,se=~~(Math.random()*2048),re=~~(Math.random()*2187);do k=~~(Math.random()*q[12]),G=~~(Math.random()*q[8]);while(Ce(G,8)!=Ce(k,12));var Me=new te().initCoord(G,re,k,se);return Me.toFaceCube()}function mn(k){for(var G=-1,se=new te,re=new te,Me=0;Me. See LICENSE.txt. */(function(i,e){(function(t){function n(q){return parseInt(q)===q}function r(q){if(!n(q.length))return!1;for(var le=0;le255)return!1;return!0}function s(q,le){if(q.buffer&&q.name==="Uint8Array")return le&&(q.slice?q=q.slice():q=Array.prototype.slice.call(q)),q;if(Array.isArray(q)){if(!r(q))throw new Error("Array contains invalid value: "+q);return new Uint8Array(q)}if(n(q.length)&&r(q))return new Uint8Array(q);throw new Error("unsupported array-like object")}function a(q){return new Uint8Array(q)}function o(q,le,_e,X,$){(X!=null||$!=null)&&(q.slice?q=q.slice(X,$):q=Array.prototype.slice.call(q,X,$)),le.set(q,_e)}var l=function(){function q(_e){var X=[],$=0;for(_e=encodeURI(_e);$<_e.length;){var De=_e.charCodeAt($++);De===37?(X.push(parseInt(_e.substr($,2),16)),$+=2):X.push(De)}return s(X)}function le(_e){for(var X=[],$=0;$<_e.length;){var De=_e[$];De<128?(X.push(String.fromCharCode(De)),$++):De>191&&De<224?(X.push(String.fromCharCode((De&31)<<6|_e[$+1]&63)),$+=2):(X.push(String.fromCharCode((De&15)<<12|(_e[$+1]&63)<<6|_e[$+2]&63)),$+=3)}return X.join("")}return{toBytes:q,fromBytes:le}}(),c=function(){function q(X){for(var $=[],De=0;De>4]+le[Le&15])}return $.join("")}return{toBytes:q,fromBytes:_e}}(),h={16:10,24:12,32:14},u=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145],d=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],p=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],m=[3328402341,4168907908,4000806809,4135287693,4294111757,3597364157,3731845041,2445657428,1613770832,33620227,3462883241,1445669757,3892248089,3050821474,1303096294,3967186586,2412431941,528646813,2311702848,4202528135,4026202645,2992200171,2387036105,4226871307,1101901292,3017069671,1604494077,1169141738,597466303,1403299063,3832705686,2613100635,1974974402,3791519004,1033081774,1277568618,1815492186,2118074177,4126668546,2211236943,1748251740,1369810420,3521504564,4193382664,3799085459,2883115123,1647391059,706024767,134480908,2512897874,1176707941,2646852446,806885416,932615841,168101135,798661301,235341577,605164086,461406363,3756188221,3454790438,1311188841,2142417613,3933566367,302582043,495158174,1479289972,874125870,907746093,3698224818,3025820398,1537253627,2756858614,1983593293,3084310113,2108928974,1378429307,3722699582,1580150641,327451799,2790478837,3117535592,0,3253595436,1075847264,3825007647,2041688520,3059440621,3563743934,2378943302,1740553945,1916352843,2487896798,2555137236,2958579944,2244988746,3151024235,3320835882,1336584933,3992714006,2252555205,2588757463,1714631509,293963156,2319795663,3925473552,67240454,4269768577,2689618160,2017213508,631218106,1269344483,2723238387,1571005438,2151694528,93294474,1066570413,563977660,1882732616,4059428100,1673313503,2008463041,2950355573,1109467491,537923632,3858759450,4260623118,3218264685,2177748300,403442708,638784309,3287084079,3193921505,899127202,2286175436,773265209,2479146071,1437050866,4236148354,2050833735,3362022572,3126681063,840505643,3866325909,3227541664,427917720,2655997905,2749160575,1143087718,1412049534,999329963,193497219,2353415882,3354324521,1807268051,672404540,2816401017,3160301282,369822493,2916866934,3688947771,1681011286,1949973070,336202270,2454276571,201721354,1210328172,3093060836,2680341085,3184776046,1135389935,3294782118,965841320,831886756,3554993207,4068047243,3588745010,2345191491,1849112409,3664604599,26054028,2983581028,2622377682,1235855840,3630984372,2891339514,4092916743,3488279077,3395642799,4101667470,1202630377,268961816,1874508501,4034427016,1243948399,1546530418,941366308,1470539505,1941222599,2546386513,3421038627,2715671932,3899946140,1042226977,2521517021,1639824860,227249030,260737669,3765465232,2084453954,1907733956,3429263018,2420656344,100860677,4160157185,470683154,3261161891,1781871967,2924959737,1773779408,394692241,2579611992,974986535,664706745,3655459128,3958962195,731420851,571543859,3530123707,2849626480,126783113,865375399,765172662,1008606754,361203602,3387549984,2278477385,2857719295,1344809080,2782912378,59542671,1503764984,160008576,437062935,1707065306,3622233649,2218934982,3496503480,2185314755,697932208,1512910199,504303377,2075177163,2824099068,1841019862,739644986],v=[2781242211,2230877308,2582542199,2381740923,234877682,3184946027,2984144751,1418839493,1348481072,50462977,2848876391,2102799147,434634494,1656084439,3863849899,2599188086,1167051466,2636087938,1082771913,2281340285,368048890,3954334041,3381544775,201060592,3963727277,1739838676,4250903202,3930435503,3206782108,4149453988,2531553906,1536934080,3262494647,484572669,2923271059,1783375398,1517041206,1098792767,49674231,1334037708,1550332980,4098991525,886171109,150598129,2481090929,1940642008,1398944049,1059722517,201851908,1385547719,1699095331,1587397571,674240536,2704774806,252314885,3039795866,151914247,908333586,2602270848,1038082786,651029483,1766729511,3447698098,2682942837,454166793,2652734339,1951935532,775166490,758520603,3000790638,4004797018,4217086112,4137964114,1299594043,1639438038,3464344499,2068982057,1054729187,1901997871,2534638724,4121318227,1757008337,0,750906861,1614815264,535035132,3363418545,3988151131,3201591914,1183697867,3647454910,1265776953,3734260298,3566750796,3903871064,1250283471,1807470800,717615087,3847203498,384695291,3313910595,3617213773,1432761139,2484176261,3481945413,283769337,100925954,2180939647,4037038160,1148730428,3123027871,3813386408,4087501137,4267549603,3229630528,2315620239,2906624658,3156319645,1215313976,82966005,3747855548,3245848246,1974459098,1665278241,807407632,451280895,251524083,1841287890,1283575245,337120268,891687699,801369324,3787349855,2721421207,3431482436,959321879,1469301956,4065699751,2197585534,1199193405,2898814052,3887750493,724703513,2514908019,2696962144,2551808385,3516813135,2141445340,1715741218,2119445034,2872807568,2198571144,3398190662,700968686,3547052216,1009259540,2041044702,3803995742,487983883,1991105499,1004265696,1449407026,1316239930,504629770,3683797321,168560134,1816667172,3837287516,1570751170,1857934291,4014189740,2797888098,2822345105,2754712981,936633572,2347923833,852879335,1133234376,1500395319,3084545389,2348912013,1689376213,3533459022,3762923945,3034082412,4205598294,133428468,634383082,2949277029,2398386810,3913789102,403703816,3580869306,2297460856,1867130149,1918643758,607656988,4049053350,3346248884,1368901318,600565992,2090982877,2632479860,557719327,3717614411,3697393085,2249034635,2232388234,2430627952,1115438654,3295786421,2865522278,3633334344,84280067,33027830,303828494,2747425121,1600795957,4188952407,3496589753,2434238086,1486471617,658119965,3106381470,953803233,334231800,3005978776,857870609,3151128937,1890179545,2298973838,2805175444,3056442267,574365214,2450884487,550103529,1233637070,4289353045,2018519080,2057691103,2399374476,4166623649,2148108681,387583245,3664101311,836232934,3330556482,3100665960,3280093505,2955516313,2002398509,287182607,3413881008,4238890068,3597515707,975967766],b=[1671808611,2089089148,2006576759,2072901243,4061003762,1807603307,1873927791,3310653893,810573872,16974337,1739181671,729634347,4263110654,3613570519,2883997099,1989864566,3393556426,2191335298,3376449993,2106063485,4195741690,1508618841,1204391495,4027317232,2917941677,3563566036,2734514082,2951366063,2629772188,2767672228,1922491506,3227229120,3082974647,4246528509,2477669779,644500518,911895606,1061256767,4144166391,3427763148,878471220,2784252325,3845444069,4043897329,1905517169,3631459288,827548209,356461077,67897348,3344078279,593839651,3277757891,405286936,2527147926,84871685,2595565466,118033927,305538066,2157648768,3795705826,3945188843,661212711,2999812018,1973414517,152769033,2208177539,745822252,439235610,455947803,1857215598,1525593178,2700827552,1391895634,994932283,3596728278,3016654259,695947817,3812548067,795958831,2224493444,1408607827,3513301457,0,3979133421,543178784,4229948412,2982705585,1542305371,1790891114,3410398667,3201918910,961245753,1256100938,1289001036,1491644504,3477767631,3496721360,4012557807,2867154858,4212583931,1137018435,1305975373,861234739,2241073541,1171229253,4178635257,33948674,2139225727,1357946960,1011120188,2679776671,2833468328,1374921297,2751356323,1086357568,2408187279,2460827538,2646352285,944271416,4110742005,3168756668,3066132406,3665145818,560153121,271589392,4279952895,4077846003,3530407890,3444343245,202643468,322250259,3962553324,1608629855,2543990167,1154254916,389623319,3294073796,2817676711,2122513534,1028094525,1689045092,1575467613,422261273,1939203699,1621147744,2174228865,1339137615,3699352540,577127458,712922154,2427141008,2290289544,1187679302,3995715566,3100863416,339486740,3732514782,1591917662,186455563,3681988059,3762019296,844522546,978220090,169743370,1239126601,101321734,611076132,1558493276,3260915650,3547250131,2901361580,1655096418,2443721105,2510565781,3828863972,2039214713,3878868455,3359869896,928607799,1840765549,2374762893,3580146133,1322425422,2850048425,1823791212,1459268694,4094161908,3928346602,1706019429,2056189050,2934523822,135794696,3134549946,2022240376,628050469,779246638,472135708,2800834470,3032970164,3327236038,3894660072,3715932637,1956440180,522272287,1272813131,3185336765,2340818315,2323976074,1888542832,1044544574,3049550261,1722469478,1222152264,50660867,4127324150,236067854,1638122081,895445557,1475980887,3117443513,2257655686,3243809217,489110045,2662934430,3778599393,4162055160,2561878936,288563729,1773916777,3648039385,2391345038,2493985684,2612407707,505560094,2274497927,3911240169,3460925390,1442818645,678973480,3749357023,2358182796,2717407649,2306869641,219617805,3218761151,3862026214,1120306242,1756942440,1103331905,2578459033,762796589,252780047,2966125488,1425844308,3151392187,372911126],R=[1667474886,2088535288,2004326894,2071694838,4075949567,1802223062,1869591006,3318043793,808472672,16843522,1734846926,724270422,4278065639,3621216949,2880169549,1987484396,3402253711,2189597983,3385409673,2105378810,4210693615,1499065266,1195886990,4042263547,2913856577,3570689971,2728590687,2947541573,2627518243,2762274643,1920112356,3233831835,3082273397,4261223649,2475929149,640051788,909531756,1061110142,4160160501,3435941763,875846760,2779116625,3857003729,4059105529,1903268834,3638064043,825316194,353713962,67374088,3351728789,589522246,3284360861,404236336,2526454071,84217610,2593830191,117901582,303183396,2155911963,3806477791,3958056653,656894286,2998062463,1970642922,151591698,2206440989,741110872,437923380,454765878,1852748508,1515908788,2694904667,1381168804,993742198,3604373943,3014905469,690584402,3823320797,791638366,2223281939,1398011302,3520161977,0,3991743681,538992704,4244381667,2981218425,1532751286,1785380564,3419096717,3200178535,960056178,1246420628,1280103576,1482221744,3486468741,3503319995,4025428677,2863326543,4227536621,1128514950,1296947098,859002214,2240123921,1162203018,4193849577,33687044,2139062782,1347481760,1010582648,2678045221,2829640523,1364325282,2745433693,1077985408,2408548869,2459086143,2644360225,943212656,4126475505,3166494563,3065430391,3671750063,555836226,269496352,4294908645,4092792573,3537006015,3452783745,202118168,320025894,3974901699,1600119230,2543297077,1145359496,387397934,3301201811,2812801621,2122220284,1027426170,1684319432,1566435258,421079858,1936954854,1616945344,2172753945,1330631070,3705438115,572679748,707427924,2425400123,2290647819,1179044492,4008585671,3099120491,336870440,3739122087,1583276732,185277718,3688593069,3772791771,842159716,976899700,168435220,1229577106,101059084,606366792,1549591736,3267517855,3553849021,2897014595,1650632388,2442242105,2509612081,3840161747,2038008818,3890688725,3368567691,926374254,1835907034,2374863873,3587531953,1313788572,2846482505,1819063512,1448540844,4109633523,3941213647,1701162954,2054852340,2930698567,134748176,3132806511,2021165296,623210314,774795868,471606328,2795958615,3031746419,3334885783,3907527627,3722280097,1953799400,522133822,1263263126,3183336545,2341176845,2324333839,1886425312,1044267644,3048588401,1718004428,1212733584,50529542,4143317495,235803164,1633788866,892690282,1465383342,3115962473,2256965911,3250673817,488449850,2661202215,3789633753,4177007595,2560144171,286339874,1768537042,3654906025,2391705863,2492770099,2610673197,505291324,2273808917,3924369609,3469625735,1431699370,673740880,3755965093,2358021891,2711746649,2307489801,218961690,3217021541,3873845719,1111672452,1751693520,1094828930,2576986153,757954394,252645662,2964376443,1414855848,3149649517,370555436],L=[1374988112,2118214995,437757123,975658646,1001089995,530400753,2902087851,1273168787,540080725,2910219766,2295101073,4110568485,1340463100,3307916247,641025152,3043140495,3736164937,632953703,1172967064,1576976609,3274667266,2169303058,2370213795,1809054150,59727847,361929877,3211623147,2505202138,3569255213,1484005843,1239443753,2395588676,1975683434,4102977912,2572697195,666464733,3202437046,4035489047,3374361702,2110667444,1675577880,3843699074,2538681184,1649639237,2976151520,3144396420,4269907996,4178062228,1883793496,2403728665,2497604743,1383856311,2876494627,1917518562,3810496343,1716890410,3001755655,800440835,2261089178,3543599269,807962610,599762354,33778362,3977675356,2328828971,2809771154,4077384432,1315562145,1708848333,101039829,3509871135,3299278474,875451293,2733856160,92987698,2767645557,193195065,1080094634,1584504582,3178106961,1042385657,2531067453,3711829422,1306967366,2438237621,1908694277,67556463,1615861247,429456164,3602770327,2302690252,1742315127,2968011453,126454664,3877198648,2043211483,2709260871,2084704233,4169408201,0,159417987,841739592,504459436,1817866830,4245618683,260388950,1034867998,908933415,168810852,1750902305,2606453969,607530554,202008497,2472011535,3035535058,463180190,2160117071,1641816226,1517767529,470948374,3801332234,3231722213,1008918595,303765277,235474187,4069246893,766945465,337553864,1475418501,2943682380,4003061179,2743034109,4144047775,1551037884,1147550661,1543208500,2336434550,3408119516,3069049960,3102011747,3610369226,1113818384,328671808,2227573024,2236228733,3535486456,2935566865,3341394285,496906059,3702665459,226906860,2009195472,733156972,2842737049,294930682,1206477858,2835123396,2700099354,1451044056,573804783,2269728455,3644379585,2362090238,2564033334,2801107407,2776292904,3669462566,1068351396,742039012,1350078989,1784663195,1417561698,4136440770,2430122216,775550814,2193862645,2673705150,1775276924,1876241833,3475313331,3366754619,270040487,3902563182,3678124923,3441850377,1851332852,3969562369,2203032232,3868552805,2868897406,566021896,4011190502,3135740889,1248802510,3936291284,699432150,832877231,708780849,3332740144,899835584,1951317047,4236429990,3767586992,866637845,4043610186,1106041591,2144161806,395441711,1984812685,1139781709,3433712980,3835036895,2664543715,1282050075,3240894392,1181045119,2640243204,25965917,4203181171,4211818798,3009879386,2463879762,3910161971,1842759443,2597806476,933301370,1509430414,3943906441,3467192302,3076639029,3776767469,2051518780,2631065433,1441952575,404016761,1942435775,1408749034,1610459739,3745345300,2017778566,3400528769,3110650942,941896748,3265478751,371049330,3168937228,675039627,4279080257,967311729,135050206,3635733660,1683407248,2076935265,3576870512,1215061108,3501741890],_=[1347548327,1400783205,3273267108,2520393566,3409685355,4045380933,2880240216,2471224067,1428173050,4138563181,2441661558,636813900,4233094615,3620022987,2149987652,2411029155,1239331162,1730525723,2554718734,3781033664,46346101,310463728,2743944855,3328955385,3875770207,2501218972,3955191162,3667219033,768917123,3545789473,692707433,1150208456,1786102409,2029293177,1805211710,3710368113,3065962831,401639597,1724457132,3028143674,409198410,2196052529,1620529459,1164071807,3769721975,2226875310,486441376,2499348523,1483753576,428819965,2274680428,3075636216,598438867,3799141122,1474502543,711349675,129166120,53458370,2592523643,2782082824,4063242375,2988687269,3120694122,1559041666,730517276,2460449204,4042459122,2706270690,3446004468,3573941694,533804130,2328143614,2637442643,2695033685,839224033,1973745387,957055980,2856345839,106852767,1371368976,4181598602,1033297158,2933734917,1179510461,3046200461,91341917,1862534868,4284502037,605657339,2547432937,3431546947,2003294622,3182487618,2282195339,954669403,3682191598,1201765386,3917234703,3388507166,0,2198438022,1211247597,2887651696,1315723890,4227665663,1443857720,507358933,657861945,1678381017,560487590,3516619604,975451694,2970356327,261314535,3535072918,2652609425,1333838021,2724322336,1767536459,370938394,182621114,3854606378,1128014560,487725847,185469197,2918353863,3106780840,3356761769,2237133081,1286567175,3152976349,4255350624,2683765030,3160175349,3309594171,878443390,1988838185,3704300486,1756818940,1673061617,3403100636,272786309,1075025698,545572369,2105887268,4174560061,296679730,1841768865,1260232239,4091327024,3960309330,3497509347,1814803222,2578018489,4195456072,575138148,3299409036,446754879,3629546796,4011996048,3347532110,3252238545,4270639778,915985419,3483825537,681933534,651868046,2755636671,3828103837,223377554,2607439820,1649704518,3270937875,3901806776,1580087799,4118987695,3198115200,2087309459,2842678573,3016697106,1003007129,2802849917,1860738147,2077965243,164439672,4100872472,32283319,2827177882,1709610350,2125135846,136428751,3874428392,3652904859,3460984630,3572145929,3593056380,2939266226,824852259,818324884,3224740454,930369212,2801566410,2967507152,355706840,1257309336,4148292826,243256656,790073846,2373340630,1296297904,1422699085,3756299780,3818836405,457992840,3099667487,2135319889,77422314,1560382517,1945798516,788204353,1521706781,1385356242,870912086,325965383,2358957921,2050466060,2388260884,2313884476,4006521127,901210569,3990953189,1014646705,1503449823,1062597235,2031621326,3212035895,3931371469,1533017514,350174575,2256028891,2177544179,1052338372,741876788,1606591296,1914052035,213705253,2334669897,1107234197,1899603969,3725069491,2631447780,2422494913,1635502980,1893020342,1950903388,1120974935],S=[2807058932,1699970625,2764249623,1586903591,1808481195,1173430173,1487645946,59984867,4199882800,1844882806,1989249228,1277555970,3623636965,3419915562,1149249077,2744104290,1514790577,459744698,244860394,3235995134,1963115311,4027744588,2544078150,4190530515,1608975247,2627016082,2062270317,1507497298,2200818878,567498868,1764313568,3359936201,2305455554,2037970062,1047239e3,1910319033,1337376481,2904027272,2892417312,984907214,1243112415,830661914,861968209,2135253587,2011214180,2927934315,2686254721,731183368,1750626376,4246310725,1820824798,4172763771,3542330227,48394827,2404901663,2871682645,671593195,3254988725,2073724613,145085239,2280796200,2779915199,1790575107,2187128086,472615631,3029510009,4075877127,3802222185,4107101658,3201631749,1646252340,4270507174,1402811438,1436590835,3778151818,3950355702,3963161475,4020912224,2667994737,273792366,2331590177,104699613,95345982,3175501286,2377486676,1560637892,3564045318,369057872,4213447064,3919042237,1137477952,2658625497,1119727848,2340947849,1530455833,4007360968,172466556,266959938,516552836,0,2256734592,3980931627,1890328081,1917742170,4294704398,945164165,3575528878,958871085,3647212047,2787207260,1423022939,775562294,1739656202,3876557655,2530391278,2443058075,3310321856,547512796,1265195639,437656594,3121275539,719700128,3762502690,387781147,218828297,3350065803,2830708150,2848461854,428169201,122466165,3720081049,1627235199,648017665,4122762354,1002783846,2117360635,695634755,3336358691,4234721005,4049844452,3704280881,2232435299,574624663,287343814,612205898,1039717051,840019705,2708326185,793451934,821288114,1391201670,3822090177,376187827,3113855344,1224348052,1679968233,2361698556,1058709744,752375421,2431590963,1321699145,3519142200,2734591178,188127444,2177869557,3727205754,2384911031,3215212461,2648976442,2450346104,3432737375,1180849278,331544205,3102249176,4150144569,2952102595,2159976285,2474404304,766078933,313773861,2570832044,2108100632,1668212892,3145456443,2013908262,418672217,3070356634,2594734927,1852171925,3867060991,3473416636,3907448597,2614737639,919489135,164948639,2094410160,2997825956,590424639,2486224549,1723872674,3157750862,3399941250,3501252752,3625268135,2555048196,3673637356,1343127501,4130281361,3599595085,2957853679,1297403050,81781910,3051593425,2283490410,532201772,1367295589,3926170974,895287692,1953757831,1093597963,492483431,3528626907,1446242576,1192455638,1636604631,209336225,344873464,1015671571,669961897,3375740769,3857572124,2973530695,3747192018,1933530610,3464042516,935293895,3454686199,2858115069,1863638845,3683022916,4085369519,3292445032,875313188,1080017571,3279033885,621591778,1233856572,2504130317,24197544,3017672716,3835484340,3247465558,2220981195,3060847922,1551124588,1463996600],D=[4104605777,1097159550,396673818,660510266,2875968315,2638606623,4200115116,3808662347,821712160,1986918061,3430322568,38544885,3856137295,718002117,893681702,1654886325,2975484382,3122358053,3926825029,4274053469,796197571,1290801793,1184342925,3556361835,2405426947,2459735317,1836772287,1381620373,3196267988,1948373848,3764988233,3385345166,3263785589,2390325492,1480485785,3111247143,3780097726,2293045232,548169417,3459953789,3746175075,439452389,1362321559,1400849762,1685577905,1806599355,2174754046,137073913,1214797936,1174215055,3731654548,2079897426,1943217067,1258480242,529487843,1437280870,3945269170,3049390895,3313212038,923313619,679998e3,3215307299,57326082,377642221,3474729866,2041877159,133361907,1776460110,3673476453,96392454,878845905,2801699524,777231668,4082475170,2330014213,4142626212,2213296395,1626319424,1906247262,1846563261,562755902,3708173718,1040559837,3871163981,1418573201,3294430577,114585348,1343618912,2566595609,3186202582,1078185097,3651041127,3896688048,2307622919,425408743,3371096953,2081048481,1108339068,2216610296,0,2156299017,736970802,292596766,1517440620,251657213,2235061775,2933202493,758720310,265905162,1554391400,1532285339,908999204,174567692,1474760595,4002861748,2610011675,3234156416,3693126241,2001430874,303699484,2478443234,2687165888,585122620,454499602,151849742,2345119218,3064510765,514443284,4044981591,1963412655,2581445614,2137062819,19308535,1928707164,1715193156,4219352155,1126790795,600235211,3992742070,3841024952,836553431,1669664834,2535604243,3323011204,1243905413,3141400786,4180808110,698445255,2653899549,2989552604,2253581325,3252932727,3004591147,1891211689,2487810577,3915653703,4237083816,4030667424,2100090966,865136418,1229899655,953270745,3399679628,3557504664,4118925222,2061379749,3079546586,2915017791,983426092,2022837584,1607244650,2118541908,2366882550,3635996816,972512814,3283088770,1568718495,3499326569,3576539503,621982671,2895723464,410887952,2623762152,1002142683,645401037,1494807662,2595684844,1335535747,2507040230,4293295786,3167684641,367585007,3885750714,1865862730,2668221674,2960971305,2763173681,1059270954,2777952454,2724642869,1320957812,2194319100,2429595872,2815956275,77089521,3973773121,3444575871,2448830231,1305906550,4021308739,2857194700,2516901860,3518358430,1787304780,740276417,1699839814,1592394909,2352307457,2272556026,188821243,1729977011,3687994002,274084841,3594982253,3613494426,2701949495,4162096729,322734571,2837966542,1640576439,484830689,1202797690,3537852828,4067639125,349075736,3342319475,4157467219,4255800159,1030690015,1155237496,2951971274,1757691577,607398968,2738905026,499347990,3794078908,1011452712,227885567,2818666809,213114376,3034881240,1455525988,3414450555,850817237,1817998408,3092726480],T=[0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795],x=[0,185469197,370938394,487725847,741876788,657861945,975451694,824852259,1483753576,1400783205,1315723890,1164071807,1950903388,2135319889,1649704518,1767536459,2967507152,3152976349,2801566410,2918353863,2631447780,2547432937,2328143614,2177544179,3901806776,3818836405,4270639778,4118987695,3299409036,3483825537,3535072918,3652904859,2077965243,1893020342,1841768865,1724457132,1474502543,1559041666,1107234197,1257309336,598438867,681933534,901210569,1052338372,261314535,77422314,428819965,310463728,3409685355,3224740454,3710368113,3593056380,3875770207,3960309330,4045380933,4195456072,2471224067,2554718734,2237133081,2388260884,3212035895,3028143674,2842678573,2724322336,4138563181,4255350624,3769721975,3955191162,3667219033,3516619604,3431546947,3347532110,2933734917,2782082824,3099667487,3016697106,2196052529,2313884476,2499348523,2683765030,1179510461,1296297904,1347548327,1533017514,1786102409,1635502980,2087309459,2003294622,507358933,355706840,136428751,53458370,839224033,957055980,605657339,790073846,2373340630,2256028891,2607439820,2422494913,2706270690,2856345839,3075636216,3160175349,3573941694,3725069491,3273267108,3356761769,4181598602,4063242375,4011996048,3828103837,1033297158,915985419,730517276,545572369,296679730,446754879,129166120,213705253,1709610350,1860738147,1945798516,2029293177,1239331162,1120974935,1606591296,1422699085,4148292826,4233094615,3781033664,3931371469,3682191598,3497509347,3446004468,3328955385,2939266226,2755636671,3106780840,2988687269,2198438022,2282195339,2501218972,2652609425,1201765386,1286567175,1371368976,1521706781,1805211710,1620529459,2105887268,1988838185,533804130,350174575,164439672,46346101,870912086,954669403,636813900,788204353,2358957921,2274680428,2592523643,2441661558,2695033685,2880240216,3065962831,3182487618,3572145929,3756299780,3270937875,3388507166,4174560061,4091327024,4006521127,3854606378,1014646705,930369212,711349675,560487590,272786309,457992840,106852767,223377554,1678381017,1862534868,1914052035,2031621326,1211247597,1128014560,1580087799,1428173050,32283319,182621114,401639597,486441376,768917123,651868046,1003007129,818324884,1503449823,1385356242,1333838021,1150208456,1973745387,2125135846,1673061617,1756818940,2970356327,3120694122,2802849917,2887651696,2637442643,2520393566,2334669897,2149987652,3917234703,3799141122,4284502037,4100872472,3309594171,3460984630,3545789473,3629546796,2050466060,1899603969,1814803222,1730525723,1443857720,1560382517,1075025698,1260232239,575138148,692707433,878443390,1062597235,243256656,91341917,409198410,325965383,3403100636,3252238545,3704300486,3620022987,3874428392,3990953189,4042459122,4227665663,2460449204,2578018489,2226875310,2411029155,3198115200,3046200461,2827177882,2743944855],O=[0,218828297,437656594,387781147,875313188,958871085,775562294,590424639,1750626376,1699970625,1917742170,2135253587,1551124588,1367295589,1180849278,1265195639,3501252752,3720081049,3399941250,3350065803,3835484340,3919042237,4270507174,4085369519,3102249176,3051593425,2734591178,2952102595,2361698556,2177869557,2530391278,2614737639,3145456443,3060847922,2708326185,2892417312,2404901663,2187128086,2504130317,2555048196,3542330227,3727205754,3375740769,3292445032,3876557655,3926170974,4246310725,4027744588,1808481195,1723872674,1910319033,2094410160,1608975247,1391201670,1173430173,1224348052,59984867,244860394,428169201,344873464,935293895,984907214,766078933,547512796,1844882806,1627235199,2011214180,2062270317,1507497298,1423022939,1137477952,1321699145,95345982,145085239,532201772,313773861,830661914,1015671571,731183368,648017665,3175501286,2957853679,2807058932,2858115069,2305455554,2220981195,2474404304,2658625497,3575528878,3625268135,3473416636,3254988725,3778151818,3963161475,4213447064,4130281361,3599595085,3683022916,3432737375,3247465558,3802222185,4020912224,4172763771,4122762354,3201631749,3017672716,2764249623,2848461854,2331590177,2280796200,2431590963,2648976442,104699613,188127444,472615631,287343814,840019705,1058709744,671593195,621591778,1852171925,1668212892,1953757831,2037970062,1514790577,1463996600,1080017571,1297403050,3673637356,3623636965,3235995134,3454686199,4007360968,3822090177,4107101658,4190530515,2997825956,3215212461,2830708150,2779915199,2256734592,2340947849,2627016082,2443058075,172466556,122466165,273792366,492483431,1047239e3,861968209,612205898,695634755,1646252340,1863638845,2013908262,1963115311,1446242576,1530455833,1277555970,1093597963,1636604631,1820824798,2073724613,1989249228,1436590835,1487645946,1337376481,1119727848,164948639,81781910,331544205,516552836,1039717051,821288114,669961897,719700128,2973530695,3157750862,2871682645,2787207260,2232435299,2283490410,2667994737,2450346104,3647212047,3564045318,3279033885,3464042516,3980931627,3762502690,4150144569,4199882800,3070356634,3121275539,2904027272,2686254721,2200818878,2384911031,2570832044,2486224549,3747192018,3528626907,3310321856,3359936201,3950355702,3867060991,4049844452,4234721005,1739656202,1790575107,2108100632,1890328081,1402811438,1586903591,1233856572,1149249077,266959938,48394827,369057872,418672217,1002783846,919489135,567498868,752375421,209336225,24197544,376187827,459744698,945164165,895287692,574624663,793451934,1679968233,1764313568,2117360635,1933530610,1343127501,1560637892,1243112415,1192455638,3704280881,3519142200,3336358691,3419915562,3907448597,3857572124,4075877127,4294704398,3029510009,3113855344,2927934315,2744104290,2159976285,2377486676,2594734927,2544078150],A=[0,151849742,303699484,454499602,607398968,758720310,908999204,1059270954,1214797936,1097159550,1517440620,1400849762,1817998408,1699839814,2118541908,2001430874,2429595872,2581445614,2194319100,2345119218,3034881240,3186202582,2801699524,2951971274,3635996816,3518358430,3399679628,3283088770,4237083816,4118925222,4002861748,3885750714,1002142683,850817237,698445255,548169417,529487843,377642221,227885567,77089521,1943217067,2061379749,1640576439,1757691577,1474760595,1592394909,1174215055,1290801793,2875968315,2724642869,3111247143,2960971305,2405426947,2253581325,2638606623,2487810577,3808662347,3926825029,4044981591,4162096729,3342319475,3459953789,3576539503,3693126241,1986918061,2137062819,1685577905,1836772287,1381620373,1532285339,1078185097,1229899655,1040559837,923313619,740276417,621982671,439452389,322734571,137073913,19308535,3871163981,4021308739,4104605777,4255800159,3263785589,3414450555,3499326569,3651041127,2933202493,2815956275,3167684641,3049390895,2330014213,2213296395,2566595609,2448830231,1305906550,1155237496,1607244650,1455525988,1776460110,1626319424,2079897426,1928707164,96392454,213114376,396673818,514443284,562755902,679998e3,865136418,983426092,3708173718,3557504664,3474729866,3323011204,4180808110,4030667424,3945269170,3794078908,2507040230,2623762152,2272556026,2390325492,2975484382,3092726480,2738905026,2857194700,3973773121,3856137295,4274053469,4157467219,3371096953,3252932727,3673476453,3556361835,2763173681,2915017791,3064510765,3215307299,2156299017,2307622919,2459735317,2610011675,2081048481,1963412655,1846563261,1729977011,1480485785,1362321559,1243905413,1126790795,878845905,1030690015,645401037,796197571,274084841,425408743,38544885,188821243,3613494426,3731654548,3313212038,3430322568,4082475170,4200115116,3780097726,3896688048,2668221674,2516901860,2366882550,2216610296,3141400786,2989552604,2837966542,2687165888,1202797690,1320957812,1437280870,1554391400,1669664834,1787304780,1906247262,2022837584,265905162,114585348,499347990,349075736,736970802,585122620,972512814,821712160,2595684844,2478443234,2293045232,2174754046,3196267988,3079546586,2895723464,2777952454,3537852828,3687994002,3234156416,3385345166,4142626212,4293295786,3841024952,3992742070,174567692,57326082,410887952,292596766,777231668,660510266,1011452712,893681702,1108339068,1258480242,1343618912,1494807662,1715193156,1865862730,1948373848,2100090966,2701949495,2818666809,3004591147,3122358053,2235061775,2352307457,2535604243,2653899549,3915653703,3764988233,4219352155,4067639125,3444575871,3294430577,3746175075,3594982253,836553431,953270745,600235211,718002117,367585007,484830689,133361907,251657213,2041877159,1891211689,1806599355,1654886325,1568718495,1418573201,1335535747,1184342925];function E(q){for(var le=[],_e=0;_e>2,this._Ke[De][le%4]=$[le],this._Kd[q-De][le%4]=$[le];for(var Le=0,dt=X,at;dt<_e;){if(at=$[X-1],$[0]^=d[at>>16&255]<<24^d[at>>8&255]<<16^d[at&255]<<8^d[at>>24&255]^u[Le]<<24,Le+=1,X!=8)for(var le=1;le>8&255]<<8^d[at>>16&255]<<16^d[at>>24&255]<<24;for(var le=X/2+1;le>2,Y=dt%4,this._Ke[ut][Y]=$[le],this._Kd[q-ut][Y]=$[le++],dt++}for(var ut=1;ut>24&255]^x[at>>16&255]^O[at>>8&255]^A[at&255]},z.prototype.encrypt=function(q){if(q.length!=16)throw new Error("invalid plaintext size (must be 16 bytes)");for(var le=this._Ke.length-1,_e=[0,0,0,0],X=E(q),$=0;$<4;$++)X[$]^=this._Ke[0][$];for(var De=1;De>24&255]^v[X[($+1)%4]>>16&255]^b[X[($+2)%4]>>8&255]^R[X[($+3)%4]&255]^this._Ke[De][$];X=_e.slice()}for(var Le=a(16),dt,$=0;$<4;$++)dt=this._Ke[le][$],Le[4*$]=(d[X[$]>>24&255]^dt>>24)&255,Le[4*$+1]=(d[X[($+1)%4]>>16&255]^dt>>16)&255,Le[4*$+2]=(d[X[($+2)%4]>>8&255]^dt>>8)&255,Le[4*$+3]=(d[X[($+3)%4]&255]^dt)&255;return Le},z.prototype.decrypt=function(q){if(q.length!=16)throw new Error("invalid ciphertext size (must be 16 bytes)");for(var le=this._Kd.length-1,_e=[0,0,0,0],X=E(q),$=0;$<4;$++)X[$]^=this._Kd[0][$];for(var De=1;De>24&255]^_[X[($+3)%4]>>16&255]^S[X[($+2)%4]>>8&255]^D[X[($+1)%4]&255]^this._Kd[De][$];X=_e.slice()}for(var Le=a(16),dt,$=0;$<4;$++)dt=this._Kd[le][$],Le[4*$]=(p[X[$]>>24&255]^dt>>24)&255,Le[4*$+1]=(p[X[($+3)%4]>>16&255]^dt>>16)&255,Le[4*$+2]=(p[X[($+2)%4]>>8&255]^dt>>8)&255,Le[4*$+3]=(p[X[($+1)%4]&255]^dt)&255;return Le};var ie=function(q){if(!(this instanceof ie))throw Error("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=new z(q)};ie.prototype.encrypt=function(q){if(q=s(q),q.length%16!==0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var le=a(q.length),_e=a(16),X=0;XNumber.MAX_SAFE_INTEGER)throw new Error("integer value out of safe range");for(var le=15;le>=0;--le)this._counter[le]=q%256,q=parseInt(q/256)},oe.prototype.setBytes=function(q){if(q=s(q,!0),q.length!=16)throw new Error("invalid counter bytes size (must be 16 bytes)");this._counter=q},oe.prototype.increment=function(){for(var q=15;q>=0;q--)if(this._counter[q]===255)this._counter[q]=0;else{this._counter[q]++;break}};var Ue=function(q,le){if(!(this instanceof Ue))throw Error("AES must be instanitated with `new`");this.description="Counter",this.name="ctr",le instanceof oe||(le=new oe(le)),this._counter=le,this._remainingCounter=null,this._remainingCounterIndex=16,this._aes=new z(q)};Ue.prototype.encrypt=function(q){for(var le=s(q,!0),_e=0;_e16)throw new Error("PKCS#7 padding byte out of range");for(var _e=q.length-le,X=0;X`${i.toString(10)}:${e.toString(10).padStart(2,"0")}.${t.toString(10).padStart(3,"0")}`}}function ac(i){var e=Math.trunc(i/6e4),t=Math.trunc(i%6e4/1e3),n=Math.trunc(i%1e3);return Pk(e,t,n)}const y2="6e400001-b5a3-f393-e0a9-e50e24dc4179",Ik="28be4a4a-cd67-11e9-a32f-2a2ae2dbcce4",Bk="28be4cb6-cd67-11e9-a32f-2a2ae2dbcce4",_2="8653000a-43e6-47b7-9cb0-5fc21d4ae340",Ok="8653000c-43e6-47b7-9cb0-5fc21d4ae340",kk="8653000b-43e6-47b7-9cb0-5fc21d4ae340",L2="00000010-0000-fff7-fff6-fff5fff4fff0",Nk="0000fff5-0000-1000-8000-00805f9b34fb",zk="0000fff6-0000-1000-8000-00805f9b34fb",WM=Array(256).fill(void 0).map((i,e)=>e<<8|1),Ef=[{key:[1,2,66,40,49,145,22,7,32,5,24,84,66,17,18,83],iv:[17,3,50,40,33,1,118,39,32,149,120,20,50,18,2,67]},{key:[5,18,2,69,2,1,41,86,18,120,18,118,129,1,8,3],iv:[1,68,40,6,134,33,34,40,81,5,8,49,130,2,33,6]}];class Rv{constructor(e,t,n){if(e.length!=16)throw new Error("Key must be 16 bytes (128-bit) long");if(t.length!=16)throw new Error("Iv must be 16 bytes (128-bit) long");if(n.length!=6)throw new Error("Salt must be 6 bytes (48-bit) long");this._key=new Uint8Array(e),this._iv=new Uint8Array(t);for(let r=0;r<6;r++)this._key[r]=(e[r]+n[r])%255,this._iv[r]=(t[r]+n[r])%255}encryptChunk(e,t){var n=new b2.ModeOfOperation.cbc(this._key,this._iv),r=n.encrypt(e.subarray(t,t+16));e.set(r,t)}decryptChunk(e,t){var n=new b2.ModeOfOperation.cbc(this._key,this._iv),r=n.decrypt(e.subarray(t,t+16));e.set(r,t)}encrypt(e){if(e.length<16)throw Error("Data must be at least 16 bytes long");var t=new Uint8Array(e);return this.encryptChunk(t,0),t.length>16&&this.encryptChunk(t,t.length-16),t}decrypt(e){if(e.length<16)throw Error("Data must be at least 16 bytes long");var t=new Uint8Array(e);return t.length>16&&this.decryptChunk(t,t.length-16),this.decryptChunk(t,0),t}}class Vk extends Rv{}class Hk extends Rv{}var C1,D1;const Ec=typeof window<"u"&&typeof((C1=window.performance)==null?void 0:C1.now)=="function"?()=>Math.floor(window.performance.now()):typeof process<"u"&&typeof((D1=process.hrtime)==null?void 0:D1.bigint)=="function"?()=>Number(process.hrtime.bigint()/1000000n):()=>Date.now();function GM(i,e){for(var t=0,n=0,r=0,s=0,a=0,o=0;o=2){for(let s=i.length-1;s>0;s--)i[s].cubeTimestamp!=null&&i[s-1].cubeTimestamp==null&&(i[s-1].cubeTimestamp=i[s].cubeTimestamp-50);for(let s=0;s0){var[t,n]=GM(i.map(s=>s.cubeTimestamp),i.map(s=>s.localTimestamp)),r=Math.round(t*i[0].cubeTimestamp+n);i.forEach(s=>{e.push({face:s.face,direction:s.direction,move:s.move,localTimestamp:s.localTimestamp,cubeTimestamp:Math.round(t*s.cubeTimestamp+n)-r})})}return e}function Gk(i){if(!i.length)return 0;var[e]=GM(i.map(t=>t.localTimestamp),i.map(t=>t.cubeTimestamp));return Math.round((e-1)*1e5)/1e3}const S2=[[8,9,20],[6,18,38],[0,36,47],[2,45,11],[29,26,15],[27,44,24],[33,53,42],[35,17,51]],M2=[[5,10],[7,19],[3,37],[1,46],[32,16],[28,25],[30,43],[34,52],[23,12],[21,41],[50,39],[48,14]];function vv(i,e,t,n){var r="URFDLB",s=[];for(let a=0;a<54;a++)s[a]=r[~~(a/9)];for(let a=0;a<8;a++)for(let o=0;o<3;o++)s[S2[a][(o+e[a])%3]]=r[~~(S2[i[a]][o]/9)];for(let a=0;a<12;a++)for(let o=0;o<2;o++)s[M2[a][(o+n[a])%2]]=r[~~(M2[t[a]][o]/9)];return s.join("")}const yr=i=>i.reduce((e,t)=>e+t,0);class Dh{constructor(e,t,n,r,s){this.onStateUpdate=async a=>{var o=a.target,l=o.value;if(l&&l.byteLength>=16){var c=this.encrypter.decrypt(new Uint8Array(l.buffer)),h=await this.driver.handleStateEvent(this,c);h.forEach(u=>this.events$.next(u))}},this.onDisconnect=async()=>(this.device.removeEventListener("gattserverdisconnected",this.onDisconnect),this.stateCharacteristic.removeEventListener("characteristicvaluechanged",this.onStateUpdate),this.events$.next({timestamp:Ec(),type:"DISCONNECT"}),this.events$.unsubscribe(),this.stateCharacteristic.stopNotifications().catch(()=>{})),this.device=e,this.commandCharacteristic=t,this.stateCharacteristic=n,this.encrypter=r,this.driver=s,this.events$=new z1}static async create(e,t,n,r,s){var a=new Dh(e,t,n,r,s);return a.device.addEventListener("gattserverdisconnected",a.onDisconnect),a.stateCharacteristic.addEventListener("characteristicvaluechanged",a.onStateUpdate),await a.stateCharacteristic.startNotifications(),a}get deviceName(){return this.device.name||"GAN-XXXX"}get deviceMAC(){return this.device.mac||"00:00:00:00:00:00"}async sendCommandMessage(e){var t=this.encrypter.encrypt(e);return this.commandCharacteristic.writeValue(t)}async sendCubeCommand(e){var t=this.driver.createCommandMessage(e);if(t)return this.sendCommandMessage(t)}async disconnect(){var e,t;await this.onDisconnect(),(e=this.device.gatt)!=null&&e.connected&&((t=this.device.gatt)==null||t.disconnect())}}class bv{constructor(e){this.bits=Array.from(e).map(t=>(t+256).toString(2).slice(1)).join("")}getBitWord(e,t,n=!1){if(t<=8)return parseInt(this.bits.slice(e,e+t),2);if(t==16||t==32){let r=new Uint8Array(t/8);for(let a=0;a>15)*2)*(c&32767)/32767,y:(1-(h>>15)*2)*(h&32767)/32767,z:(1-(u>>15)*2)*(u&32767)/32767,w:(1-(l>>15)*2)*(l&32767)/32767},velocity:{x:(1-(d>>3)*2)*(d&7),y:(1-(p>>3)*2)*(p&7),z:(1-(m>>3)*2)*(m&7)}})}else if(a==2){if(this.lastSerial!=-1){let l=s.getBitWord(4,8),c=Math.min(l-this.lastSerial&255,7);if(this.lastSerial=l,c>0){for(let h=c-1;h>=0;h--){let u=s.getBitWord(12+5*h,4),d=s.getBitWord(16+5*h,1),p="URFDLB".charAt(u)+" '".charAt(d),m=s.getBitWord(47+16*h,16);m==0&&(m=n-this.lastMoveTimestamp),this.cubeTimestamp+=m,r.push({type:"MOVE",serial:l-h&255,timestamp:n,localTimestamp:h==0?n:null,cubeTimestamp:this.cubeTimestamp,face:u,direction:d,move:p.trim()})}this.lastMoveTimestamp=n}}}else if(a==4){let l=s.getBitWord(4,8);this.lastSerial==-1&&(this.lastSerial=l);let c=[],h=[],u=[],d=[];for(let p=0;p<7;p++)c.push(s.getBitWord(12+p*3,3)),h.push(s.getBitWord(33+p*2,2));c.push(28-yr(c)),h.push((3-yr(h)%3)%3);for(let p=0;p<11;p++)u.push(s.getBitWord(47+p*4,4)),d.push(s.getBitWord(91+p,1));u.push(66-yr(u)),d.push((2-yr(d)%2)%2),r.push({type:"FACELETS",serial:l,timestamp:n,facelets:vv(c,h,u,d),state:{CP:c,CO:h,EP:u,EO:d}})}else if(a==5){let l=s.getBitWord(8,8),c=s.getBitWord(16,8),h=s.getBitWord(24,8),u=s.getBitWord(32,8),d=s.getBitWord(104,1),p="";for(var o=0;o<8;o++)p+=String.fromCharCode(s.getBitWord(o*8+40,8));r.push({type:"HARDWARE",timestamp:n,hardwareName:p,hardwareVersion:`${l}.${c}`,softwareVersion:`${h}.${u}`,gyroSupported:!!d})}else if(a==9){let l=s.getBitWord(8,8);r.push({type:"BATTERY",timestamp:n,batteryLevel:Math.min(l,100)})}else a==13&&e.disconnect();return r}}class qk{constructor(){this.serial=-1,this.lastSerial=-1,this.lastLocalTimestamp=null,this.moveBuffer=[]}createCommandMessage(e){var t=new Uint8Array(16).fill(0);switch(e.type){case"REQUEST_FACELETS":t.set([104,1]);break;case"REQUEST_HARDWARE":t.set([104,4]);break;case"REQUEST_BATTERY":t.set([104,7]);break;case"REQUEST_RESET":t.set([104,5,5,57,119,0,0,1,35,69,103,137,171,0,0,0]);break;default:t=void 0}return t}async requestMoveHistory(e,t,n){var r=new Uint8Array(16).fill(0);return t%2==0&&(t=t-1&255),n%2==1&&n++,n=Math.min(n,t+1),r.set([104,3,t,0,n,0]),e.sendCommandMessage(r).catch(()=>{})}async evictMoveBuffer(e){for(var t=[];this.moveBuffer.length>0;){let n=this.moveBuffer[0],r=this.lastSerial==-1?1:n.serial-this.lastSerial&255;if(r>1){e&&await this.requestMoveHistory(e,n.serial,r);break}else t.push(this.moveBuffer.shift()),this.lastSerial=n.serial}return e&&this.moveBuffer.length>16&&e.disconnect(),t}isSerialInRange(e,t,n,r=!1,s=!1){return(t-e&255)>=(n-e&255)&&(r||(e-n&255)>0)&&(s||(t-n&255)>0)}injectMissedMoveToBuffer(e){if(e.type=="MOVE")if(this.moveBuffer.length>0){var t=this.moveBuffer[0];if(this.moveBuffer.some(n=>n.type=="MOVE"&&n.serial==e.serial)||!this.isSerialInRange(this.lastSerial,t.serial,e.serial))return;e.serial==(t.serial-1&255)&&this.moveBuffer.unshift(e)}else this.isSerialInRange(this.lastSerial,this.serial,e.serial,!1,!0)&&this.moveBuffer.unshift(e)}async checkIfMoveMissed(e){let t=this.serial-this.lastSerial&255;if(t>0&&this.serial!=0){let n=this.moveBuffer[0],r=n?n.serial:this.serial+1&255;await this.requestMoveHistory(e,r,t+1)}}async handleStateEvent(e,t){var n=Ec(),r=[],s=new bv(t),a=s.getBitWord(0,8),o=s.getBitWord(8,8),l=s.getBitWord(16,8);if(a==85&&l>0)if(o==1){if(this.lastSerial!=-1){this.lastLocalTimestamp=n;let h=s.getBitWord(24,32,!0),u=this.serial=s.getBitWord(56,16,!0),d=s.getBitWord(72,2),p=[2,32,8,1,16,4].indexOf(s.getBitWord(74,6)),m="URFDLB".charAt(p)+" '".charAt(d);p>=0&&this.moveBuffer.push({type:"MOVE",serial:u,timestamp:n,localTimestamp:n,cubeTimestamp:h,face:p,direction:d,move:m.trim()}),r=await this.evictMoveBuffer(e)}}else if(o==6){let h=s.getBitWord(24,8),u=(l-1)*2;for(let d=0;d=0){let v="URFDLB".charAt(p)+" '".charAt(m);this.injectMissedMoveToBuffer({type:"MOVE",serial:h-d&255,timestamp:n,localTimestamp:null,cubeTimestamp:null,face:p,direction:m,move:v.trim()})}}r=await this.evictMoveBuffer()}else if(o==2){let h=this.serial=s.getBitWord(24,16,!0);this.lastSerial!=-1&&this.lastLocalTimestamp!=null&&n-this.lastLocalTimestamp>500&&await this.checkIfMoveMissed(e),this.lastSerial==-1&&(this.lastSerial=h);let u=[],d=[],p=[],m=[];for(let v=0;v<7;v++)u.push(s.getBitWord(40+v*3,3)),d.push(s.getBitWord(61+v*2,2));u.push(28-yr(u)),d.push((3-yr(d)%3)%3);for(let v=0;v<11;v++)p.push(s.getBitWord(77+v*4,4)),m.push(s.getBitWord(121+v,1));p.push(66-yr(p)),m.push((2-yr(m)%2)%2),r.push({type:"FACELETS",serial:h,timestamp:n,facelets:vv(u,d,p,m),state:{CP:u,CO:d,EP:p,EO:m}})}else if(o==7){let h=s.getBitWord(72,4),u=s.getBitWord(76,4),d=s.getBitWord(80,4),p=s.getBitWord(84,4),m="";for(var c=0;c<5;c++)m+=String.fromCharCode(s.getBitWord(c*8+32,8));r.push({type:"HARDWARE",timestamp:n,hardwareName:m,hardwareVersion:`${d}.${p}`,softwareVersion:`${h}.${u}`,gyroSupported:!1})}else if(o==16){let h=s.getBitWord(24,8);r.push({type:"BATTERY",timestamp:n,batteryLevel:Math.min(h,100)})}else o==17&&e.disconnect();return r}}class Xk{constructor(){this.serial=-1,this.lastSerial=-1,this.lastLocalTimestamp=null,this.moveBuffer=[],this.hwInfo={}}createCommandMessage(e){var t=new Uint8Array(20).fill(0);switch(e.type){case"REQUEST_FACELETS":t.set([221,4,0,237,0,0]);break;case"REQUEST_HARDWARE":this.hwInfo={},t.set([223,3,0,0,0]);break;case"REQUEST_BATTERY":t.set([221,4,0,239,0,0]);break;case"REQUEST_RESET":t.set([210,13,5,57,119,0,0,1,35,69,103,137,171,0,0,0]);break;default:t=void 0}return t}async requestMoveHistory(e,t,n){var r=new Uint8Array(20).fill(0);return t%2==0&&(t=t-1&255),n%2==1&&n++,n=Math.min(n,t+1),r.set([209,4,t,0,n,0]),e.sendCommandMessage(r).catch(()=>{})}async evictMoveBuffer(e){for(var t=[];this.moveBuffer.length>0;){let n=this.moveBuffer[0],r=this.lastSerial==-1?1:n.serial-this.lastSerial&255;if(r>1){e&&await this.requestMoveHistory(e,n.serial,r);break}else t.push(this.moveBuffer.shift()),this.lastSerial=n.serial}return e&&this.moveBuffer.length>16&&e.disconnect(),t}isSerialInRange(e,t,n,r=!1,s=!1){return(t-e&255)>=(n-e&255)&&(r||(e-n&255)>0)&&(s||(t-n&255)>0)}injectMissedMoveToBuffer(e){if(e.type=="MOVE")if(this.moveBuffer.length>0){var t=this.moveBuffer[0];if(this.moveBuffer.some(n=>n.type=="MOVE"&&n.serial==e.serial)||!this.isSerialInRange(this.lastSerial,t.serial,e.serial))return;e.serial==(t.serial-1&255)&&this.moveBuffer.unshift(e)}else this.isSerialInRange(this.lastSerial,this.serial,e.serial,!1,!0)&&this.moveBuffer.unshift(e)}async checkIfMoveMissed(e){let t=this.serial-this.lastSerial&255;if(t>0&&this.serial!=0){let n=this.moveBuffer[0],r=n?n.serial:this.serial+1&255;await this.requestMoveHistory(e,r,t+1)}}async handleStateEvent(e,t){var n=Ec(),r=[],s=new bv(t),a=s.getBitWord(0,8),o=s.getBitWord(8,8);if(a==1){if(this.lastSerial!=-1){this.lastLocalTimestamp=n;let c=s.getBitWord(16,32,!0),h=this.serial=s.getBitWord(48,16,!0),u=s.getBitWord(64,2),d=[2,32,8,1,16,4].indexOf(s.getBitWord(66,6)),p="URFDLB".charAt(d)+" '".charAt(u);d>=0&&this.moveBuffer.push({type:"MOVE",serial:h,timestamp:n,localTimestamp:n,cubeTimestamp:c,face:d,direction:u,move:p.trim()}),r=await this.evictMoveBuffer(e)}}else if(a==209){let c=s.getBitWord(16,8),h=(o-1)*2;for(let u=0;u=0){let m="URFDLB".charAt(d)+" '".charAt(p);this.injectMissedMoveToBuffer({type:"MOVE",serial:c-u&255,timestamp:n,localTimestamp:null,cubeTimestamp:null,face:d,direction:p,move:m.trim()})}}r=await this.evictMoveBuffer()}else if(a==237){let c=this.serial=s.getBitWord(16,16,!0);this.lastSerial!=-1&&this.lastLocalTimestamp!=null&&n-this.lastLocalTimestamp>500&&await this.checkIfMoveMissed(e),this.lastSerial==-1&&(this.lastSerial=c);let h=[],u=[],d=[],p=[];for(let m=0;m<7;m++)h.push(s.getBitWord(32+m*3,3)),u.push(s.getBitWord(53+m*2,2));h.push(28-yr(h)),u.push((3-yr(u)%3)%3);for(let m=0;m<11;m++)d.push(s.getBitWord(69+m*4,4)),p.push(s.getBitWord(113+m,1));d.push(66-yr(d)),p.push((2-yr(p)%2)%2),r.push({type:"FACELETS",serial:c,timestamp:n,facelets:vv(h,u,d,p),state:{CP:h,CO:u,EP:d,EO:p}})}else if(a>=250&&a<=254){switch(a){case 250:let c=s.getBitWord(24,16,!0),h=s.getBitWord(40,8),u=s.getBitWord(48,8);this.hwInfo[a]=`${c.toString().padStart(4,"0")}-${h.toString().padStart(2,"0")}-${u.toString().padStart(2,"0")}`;break;case 252:this.hwInfo[a]="";for(var l=0;l>15)*2)*(h&32767)/32767,y:(1-(u>>15)*2)*(u&32767)/32767,z:(1-(d>>15)*2)*(d&32767)/32767,w:(1-(c>>15)*2)*(c&32767)/32767},velocity:{x:(1-(p>>3)*2)*(p&7),y:(1-(m>>3)*2)*(m&7),z:(1-(v>>3)*2)*(v&7)}})}else if(a==239){let c=s.getBitWord(8+o*8,8);r.push({type:"BATTERY",timestamp:n,batteryLevel:Math.min(c,100)})}else a==234&&e.disconnect();return r}}function jk(i){if(i instanceof DataView)return new DataView(i.buffer.slice(2,11));for(var e of WM)if(i.has(e))return new DataView(i.get(e).buffer.slice(0,9))}function Yk(i){var e=[],t=jk(i);if(t&&t.byteLength>=6)for(let n=1;n<=6;n++)e.push(t.getUint8(t.byteLength-n).toString(16).toUpperCase().padStart(2,"0"));return e.join(":")}async function $k(i){return new Promise(e=>{typeof i.watchAdvertisements!="function"&&e(null);var t=new AbortController,n=s=>{i.removeEventListener("advertisementreceived",n),t.abort();var a=Yk(s.manufacturerData);e(a||null)},r=()=>{i.removeEventListener("advertisementreceived",n),t.abort(),e(null)};i.addEventListener("advertisementreceived",n),i.watchAdvertisements({signal:t.signal}).catch(r),setTimeout(r,1e4)})}async function Kk(i){var o;var e=await navigator.bluetooth.requestDevice({filters:[{namePrefix:"GAN"},{namePrefix:"MG"},{namePrefix:"AiCube"}],optionalServices:[y2,_2,L2],optionalManufacturerData:WM}),t=i&&await i(e,!1)||await $k(e)||i&&await i(e,!0);if(!t)throw new Error("Unable to determine cube MAC address, connection is not possible!");e.mac=t;var n=new Uint8Array(e.mac.split(/[:-\s]+/).map(l=>parseInt(l,16)).reverse()),r=await e.gatt.connect(),s=await r.getPrimaryServices(),a=null;for(let l of s){let c=l.uuid.toLowerCase();if(c==y2){let h=await l.getCharacteristic(Ik),u=await l.getCharacteristic(Bk),d=(o=e.name)!=null&&o.startsWith("AiCube")?Ef[1]:Ef[0],p=new Rv(new Uint8Array(d.key),new Uint8Array(d.iv),n),m=new Zk;a=await Dh.create(e,h,u,p,m);break}else if(c==_2){let h=await l.getCharacteristic(Ok),u=await l.getCharacteristic(kk),d=Ef[0],p=new Vk(new Uint8Array(d.key),new Uint8Array(d.iv),n),m=new qk;a=await Dh.create(e,h,u,p,m);break}else if(c==L2){let h=await l.getCharacteristic(Nk),u=await l.getCharacteristic(zk),d=Ef[0],p=new Hk(new Uint8Array(d.key),new Uint8Array(d.iv),n),m=new Xk;a=await Dh.create(e,h,u,p,m);break}}if(!a)throw new Error("Can't find target BLE services - wrong or unsupported cube device model");return a}var ZM;na.kpuzzle().then(i=>ZM=i);const qM="UF UR UB UL DF DR DB DL FR FL BR BL".split(" "),XM="UFR URB UBL ULF DRF DFL DLB DBR".split(" "),Jk="U L F R B D".split(" "),Qk=[[1,2,0],[0,2,0],[1,1,0],[0,3,0],[2,0,0],[0,1,0],[1,3,0],[0,0,0],[1,0,0],[1,0,2],[0,1,1],[1,1,1],[0,8,1],[2,3,0],[0,10,1],[1,4,1],[0,5,1],[1,7,2],[1,3,2],[0,0,1],[1,0,1],[0,9,0],[2,2,0],[0,8,0],[1,5,1],[0,4,1],[1,4,2],[1,5,0],[0,4,0],[1,4,0],[0,7,0],[2,5,0],[0,5,0],[1,6,0],[0,6,0],[1,7,0],[1,2,2],[0,3,1],[1,3,1],[0,11,1],[2,1,0],[0,9,1],[1,6,1],[0,7,1],[1,5,2],[1,1,2],[0,2,1],[1,2,1],[0,10,0],[2,4,0],[0,11,0],[1,7,1],[0,6,1],[1,6,2]],e6=[[0,21,15],[5,13,47],[7,45,39],[2,37,23],[29,10,16],[31,18,32],[26,34,40],[24,42,8]],t6=[[1,22],[3,14],[6,46],[4,38],[30,17],[27,9],[25,41],[28,33],[19,12],[20,35],[44,11],[43,36]],_0="URFDLB",Bp={};qM.forEach((i,e)=>{for(let t=0;t<2;t++)Bp[Op(i,t)]={piece:e,orientation:t}});XM.forEach((i,e)=>{for(let t=0;t<3;t++)Bp[Op(i,t)]={piece:e,orientation:t}});function Op(i,e){return i.slice(e)+i.slice(0,e)}function n6(i){const e=[[],[]];for(let t=0;t<6;t++)if(i.patternData.CENTERS.pieces[t]!==t)throw new Error("non-oriented puzzles are not supported");for(let t=0;t<12;t++)e[0].push(Op(qM[i.patternData.EDGES.pieces[t]],i.patternData.EDGES.orientation[t]));for(let t=0;t<8;t++)e[1].push(Op(XM[i.patternData.CORNERS.pieces[t]],i.patternData.CORNERS.orientation[t]));return e.push(Jk),e}function kp(i){const e=n6(i);return Qk.map(([t,n,r])=>e[t][n][r]).join("")}function lg(i){var n;const e=[];(n=i.match(/.{9}/g))==null||n.forEach(r=>{r.split("").reverse().forEach((s,a)=>{a!=4&&e.push(_0.indexOf(s))})});const t={CORNERS:{pieces:[],orientation:[]},EDGES:{pieces:[],orientation:[]},CENTERS:{pieces:[0,1,2,3,4,5],orientation:[0,0,0,0,0,0],orientationMod:[1,1,1,1,1,1]}};for(const r of e6){const s=Bp[r.map(a=>_0[e[a]]).join("")];t.CORNERS.pieces.push(s.piece),t.CORNERS.orientation.push(s.orientation)}for(const r of t6){const s=Bp[r.map(a=>_0[e[a]]).join("")];t.EDGES.pieces.push(s.piece),t.EDGES.orientation.push(s.orientation)}return new Lc(ZM,t)}/*! + */const EM=Symbol("Comlink.proxy"),jO=Symbol("Comlink.endpoint"),YO=Symbol("Comlink.releaseProxy"),U0=Symbol("Comlink.finalizer"),op=Symbol("Comlink.thrown"),TM=i=>typeof i=="object"&&i!==null||typeof i=="function",$O={canHandle:i=>TM(i)&&i[EM],serialize(i){const{port1:e,port2:t}=new MessageChannel;return CM(i,e),[t,[t]]},deserialize(i){return i.start(),PM(i)}},KO={canHandle:i=>TM(i)&&op in i,serialize({value:i}){let e;return i instanceof Error?e={isError:!0,value:{message:i.message,name:i.name,stack:i.stack}}:e={isError:!1,value:i},[e,[]]},deserialize(i){throw i.isError?Object.assign(new Error(i.value.message),i.value):i.value}},FM=new Map([["proxy",$O],["throw",KO]]);function JO(i,e){for(const t of i)if(e===t||t==="*"||t instanceof RegExp&&t.test(e))return!0;return!1}function CM(i,e=globalThis,t=["*"]){e.addEventListener("message",function n(r){if(!r||!r.data)return;if(!JO(t,r.origin)){console.warn(`Invalid origin '${r.origin}' for comlink proxy`);return}const{id:s,type:a,path:o}=Object.assign({path:[]},r.data),l=(r.data.argumentList||[]).map(Mo);let c;try{const h=o.slice(0,-1).reduce((d,p)=>d[p],i),u=o.reduce((d,p)=>d[p],i);switch(a){case"GET":c=u;break;case"SET":h[o.slice(-1)[0]]=Mo(r.data.value),c=!0;break;case"APPLY":c=u.apply(h,l);break;case"CONSTRUCT":{const d=new u(...l);c=rk(d)}break;case"ENDPOINT":{const{port1:d,port2:p}=new MessageChannel;CM(i,p),c=ik(d,[d])}break;case"RELEASE":c=void 0;break;default:return}}catch(h){c={value:h,[op]:0}}Promise.resolve(c).catch(h=>({value:h,[op]:0})).then(h=>{const[u,d]=Ip(h);e.postMessage(Object.assign(Object.assign({},u),{id:s}),d),a==="RELEASE"&&(e.removeEventListener("message",n),DM(e),U0 in i&&typeof i[U0]=="function"&&i[U0]())}).catch(h=>{const[u,d]=Ip({value:new TypeError("Unserializable return value"),[op]:0});e.postMessage(Object.assign(Object.assign({},u),{id:s}),d)})}),e.start&&e.start()}function QO(i){return i.constructor.name==="MessagePort"}function DM(i){QO(i)&&i.close()}function PM(i,e){return eR(i,[],e)}function Af(i){if(i)throw new Error("Proxy has been released and is not useable")}function IM(i){return Kl(i,{type:"RELEASE"}).then(()=>{DM(i)})}const Dp=new WeakMap,Pp="FinalizationRegistry"in globalThis&&new FinalizationRegistry(i=>{const e=(Dp.get(i)||0)-1;Dp.set(i,e),e===0&&IM(i)});function ek(i,e){const t=(Dp.get(e)||0)+1;Dp.set(e,t),Pp&&Pp.register(i,e,i)}function tk(i){Pp&&Pp.unregister(i)}function eR(i,e=[],t=function(){}){let n=!1;const r=new Proxy(t,{get(s,a){if(Af(n),a===YO)return()=>{tk(r),IM(i),n=!0};if(a==="then"){if(e.length===0)return{then:()=>r};const o=Kl(i,{type:"GET",path:e.map(l=>l.toString())}).then(Mo);return o.then.bind(o)}return eR(i,[...e,a])},set(s,a,o){Af(n);const[l,c]=Ip(o);return Kl(i,{type:"SET",path:[...e,a].map(h=>h.toString()),value:l},c).then(Mo)},apply(s,a,o){Af(n);const l=e[e.length-1];if(l===jO)return Kl(i,{type:"ENDPOINT"}).then(Mo);if(l==="bind")return eR(i,e.slice(0,-1));const[c,h]=g2(o);return Kl(i,{type:"APPLY",path:e.map(u=>u.toString()),argumentList:c},h).then(Mo)},construct(s,a){Af(n);const[o,l]=g2(a);return Kl(i,{type:"CONSTRUCT",path:e.map(c=>c.toString()),argumentList:o},l).then(Mo)}});return ek(r,i),r}function nk(i){return Array.prototype.concat.apply([],i)}function g2(i){const e=i.map(Ip);return[e.map(t=>t[0]),nk(e.map(t=>t[1]))]}const BM=new WeakMap;function ik(i,e){return BM.set(i,e),i}function rk(i){return Object.assign(i,{[EM]:!0})}function Ip(i){for(const[e,t]of FM)if(t.canHandle(i)){const[n,r]=t.serialize(i);return[{type:"HANDLER",name:e,value:n},r]}return[{type:"RAW",value:i},BM.get(i)||[]]}function Mo(i){switch(i.type){case"HANDLER":return FM.get(i.name).deserialize(i.value);case"RAW":return i.value}}function Kl(i,e,t){return new Promise(n=>{const r=sk();i.addEventListener("message",function s(a){!a.data||!a.data.id||a.data.id!==r||(i.removeEventListener("message",s),n(a.data))}),i.start&&i.start(),i.postMessage(Object.assign({id:r},e),t)})}function sk(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}var ak="node:w-orker-_threa-ds",ok=()=>ak.replace(/-/g,""),lk=typeof globalThis.Worker>"u"&&typeof globalThis.WorkerNavigator>"u";async function ck(i,e){const{Worker:t}=await import(ok()),n=new t(i,e);return n.unref(),HO(n)}async function hk(i,e){let t;if(lk)return ck(i,{eval:e==null?void 0:e.eval});if(e!=null&&e.eval){const n=new Blob([i],{type:"application/javascript"});i=URL.createObjectURL(n)}return t=new globalThis.Worker(i,{type:e?e.type:void 0}),t}async function uk(){return import.meta.resolve("./search-worker-entry.js")}function dk(){return new URL("data:text/javascript;base64,aW1wb3J0IHsKICBub2RlRW5kcG9pbnRQb3J0Cn0gZnJvbSAiLi9jaHVuay1QUDQ0UDZXSy5qcyI7CmltcG9ydCB7CiAgZXhwb3NlQVBJCn0gZnJvbSAiLi9jaHVuay03R1VMM09CUS5qcyI7CmltcG9ydCAiLi9jaHVuay1SRFNRUlczRy5qcyI7CgovLyBzcmMvY3ViaW5nL3NlYXJjaC93b3JrZXItd29ya2Fyb3VuZHMvc2VhcmNoLXdvcmtlci1lbnRyeS5qcwppZiAoZXhwb3NlQVBJLmV4cG9zZSkgewogIChhc3luYyAoKSA9PiB7CiAgICBhd2FpdCBpbXBvcnQoIi4vaW5zaWRlLVkyVVZKWk5KLmpzIik7CiAgICBjb25zdCBtZXNzYWdlUG9ydCA9IGdsb2JhbFRoaXMucG9zdE1lc3NhZ2UgPyBnbG9iYWxUaGlzIDogYXdhaXQgbm9kZUVuZHBvaW50UG9ydCgpOwogICAgbWVzc2FnZVBvcnQucG9zdE1lc3NhZ2UoImNvbWxpbmstZXhwb3NlZCIpOwogIH0pKCk7Cn0KdmFyIFdPUktFUl9FTlRSWV9GSUxFX1VSTCA9IGltcG9ydC5tZXRhLnVybDsKZXhwb3J0IHsKICBXT1JLRVJfRU5UUllfRklMRV9VUkwKfTsKLy8jIHNvdXJjZU1hcHBpbmdVUkw9c2VhcmNoLXdvcmtlci1lbnRyeS5qcy5tYXAK",import.meta.url)}async function fk(){return zO.expose=!1,(await an(async()=>{const{WORKER_ENTRY_FILE_URL:i}=await import("./search-worker-entry-C63kClJR.js").then(e=>e.s);return{WORKER_ENTRY_FILE_URL:i}},[])).WORKER_ENTRY_FILE_URL}function pk(){return new Worker(new URL("/assets/search-worker-entry-DNPX3OpU.js",import.meta.url),{type:"module"})}function mk(i){var e;try{const t=(e=globalThis.location)==null?void 0:e.origin,n=i.origin;return!!t&&!!n&&t!==n}catch{return!1}}async function y0(i){const e=new URL(i,import.meta.url),t=mk(e);try{return x2(e,t)}catch{return x2(e,!t)}}async function x2(i,e){return new Promise(async(t,n)=>{var r;try{i||n(new Error("Could not get worker entry file URL."));let s=i;if(e){const c=`import ${JSON.stringify(i.toString())};`,h=new Blob([c],{type:"text/javascript"});s=new URL(URL.createObjectURL(h))}const a=await hk(s,{type:"module"});(r=a.unref)==null||r.call(a);const o=c=>{n(c)},l=c=>{c==="comlink-exposed"?t(OM(a)):n(new Error(`wrong module instantiation message ${c}`))};a.nodeWorker?a.nodeWorker.once("message",l):(a.addEventListener("error",o,{once:!0}),a.addEventListener("message",c=>l(c.data),{once:!0}))}catch(s){n(s)}})}async function gk(){return new Promise(async(i,e)=>{try{const t=pk(),n=s=>{e(s)},r=s=>{s==="comlink-exposed"?i(OM(t)):e(new Error(`wrong module instantiation message ${s}`))};t.addEventListener("error",n,{once:!0}),t.addEventListener("message",s=>r(s.data),{once:!0})}catch(t){e(t)}})}function OM(i){const e=PM(i),t=i.terminate.bind(i);return{insideAPI:e,outsideAPI:{terminate:t}}}async function xk(){const i=Rk(),{insideAPI:e}=await i;return e.setDebugMeasurePerf(tR.logPerf),e.setScramblePrefetchLevel(tR.scramblePrefetchLevel),i}async function Rk(){var t;((t=globalThis.location)==null?void 0:t.protocol)==="file:"&&console.warn("This current web page is loaded from the local filesystem (a URL that starts with `file://`). In this situation, `cubing.js` may be unable to generate scrambles or perform searches in some browsers. See: https://js.cubing.net/cubing/scramble/#file-server-required");function i(n){return`Module worker instantiation${n?` ${n}`:""} failed`}const e=[[async()=>y0(await uk()),"using `import.meta.resolve(…)",null],[gk,"using inline `new URL(…, import.meta.url)`","may"],[async()=>y0(dk()),"using `new URL(…, import.meta.url)`","will"],[async()=>y0(await fk()),"using the `esbuild` workaround","will"]];for(const[n,r,s]of e)try{const a=await n();return s&&tR.showWorkerInstantiationWarnings&&console.warn(`Module worker instantiation required ${r}. \`cubing.js\` ${s} not support this fallback in the future.`),a}catch{console.warn(`${i(r)}, falling back.`)}throw new Error(`${i()}. There are no more fallbacks available. If you are using Firefox, please update to version 114 or later.`)}var vk;function bk(){return vk??(vk=xk())}async function kM(i){const e=await bk();return Qe.fromString(await e.insideAPI.solve333ToString(i.patternData))}var tR={logPerf:!0,scramblePrefetchLevel:"auto",disableStringWorker:!1,forceNewWorkerForEveryScramble:!1,showWorkerInstantiationWarnings:!0},NM=!1;function $9(i){NM=i}function Uk(){if(!NM)throw new Error("Must be called from inside a worker, to avoid impact on page performance. Try importing from the top level of `cubing/solve`?")}function yk(i,e){const t=new yp;t.experimentalPushAlg(i);for(const n of e){const r=AM(n);r!==null&&t.push(ce.fromString(r))}return t.toAlg()}var zM=Em(()=>an(()=>import("./search-dynamic-solve-3x3x3-QHRLSVAC-6iYVGW9D.js"),[])),_k="UF UR UB UL DF DR DB DL FR FL BR BL".split(" "),Lk="UFR URB UBL ULF DRF DFL DLB DBR".split(" "),Sk="U L F R B D".split(" "),Mk=[[1,2,0],[0,2,0],[1,1,0],[0,3,0],[2,0,0],[0,1,0],[1,3,0],[0,0,0],[1,0,0],[1,0,2],[0,1,1],[1,1,1],[0,8,1],[2,3,0],[0,10,1],[1,4,1],[0,5,1],[1,7,2],[1,3,2],[0,0,1],[1,0,1],[0,9,0],[2,2,0],[0,8,0],[1,5,1],[0,4,1],[1,4,2],[1,5,0],[0,4,0],[1,4,0],[0,7,0],[2,5,0],[0,5,0],[1,6,0],[0,6,0],[1,7,0],[1,2,2],[0,3,1],[1,3,1],[0,11,1],[2,1,0],[0,9,1],[1,6,1],[0,7,1],[1,5,2],[1,1,2],[0,2,1],[1,2,1],[0,10,0],[2,4,0],[0,11,0],[1,7,1],[0,6,1],[1,6,2]];function R2(i,e){return i.slice(e)+i.slice(0,e)}function wk(i){const e=[[],[]];for(let t=0;t<6;t++)if(i.patternData.CENTERS.pieces[t]!==t)throw new Error("non-oriented puzzles are not supported");for(let t=0;t<12;t++)e[0].push(R2(_k[i.patternData.EDGES.pieces[t]],i.patternData.EDGES.orientation[t]));for(let t=0;t<8;t++)e[1].push(R2(Lk[i.patternData.CORNERS.pieces[t]],i.patternData.CORNERS.orientation[t]));return e.push(Sk),e}function Ak(i){const e=wk(i);return Mk.map(([t,n,r])=>e[t][n][r]).join("")}function v2(i,e){const t=new Lc(i.kpuzzle,{EDGES:i.patternData.EDGES,CORNERS:i.patternData.CORNERS,CENTERS:{pieces:i.patternData.CENTERS.pieces,orientation:new Array(6).fill(0)}}).experimentalToTransformation(),n=new Lc(e.kpuzzle,{EDGES:e.patternData.EDGES,CORNERS:e.patternData.CORNERS,CENTERS:{pieces:e.patternData.CENTERS.pieces,orientation:new Array(6).fill(0)}}).experimentalToTransformation();return t.isIdentical(n)}function Ek(i,e){if(v2(i.defaultPattern(),e))return!1;for(const t of"ULFRBD")for(let n=1;n<4;n++){const r=i.moveToTransformation(new ce(t,n)).toKPattern();if(v2(r,e))return!1}return!0}var Tk=[["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"]];async function VM(){const i=await gv["3x3x3"].kpuzzle();let e=i.defaultPattern();for(const t of Tk)e=e.applyAlg(Qe.fromString(AM(t)));return Ek(i,e)?e:VM()}async function Fk(i){return Uk(),Qe.fromString((await zM).solvePattern(Ak(i)))}async function Ck(){return Fk(await VM())}async function K9(){(await zM).initialize()}var Dk=[[null,"Rw","Rw2","Rw'","Fw","Fw'"],[null,"Dw","Dw2","Dw'"]];async function J9(){return yk(await Ck(),Dk)}var nR=function(){var i=2,e=20,t=7,n=13,r=2;function s(){this.move=[],this.moveSol=[],this.nodeUD=[],this.valid1=0,this.allowShorter=!1,this.cc=new te,this.urfCubieCube=[],this.urfCoordCube=[],this.phase1Cubie=[],this.preMoveCubes=[],this.preMoves=[],this.preMoveLen=0,this.maxPreMoves=0,this.isRec=!1;for(var k=0;k<21;k++)this.nodeUD[k]=new $e,this.phase1Cubie[k]=new te;for(var k=0;k<6;k++)this.urfCubieCube[k]=new te,this.urfCoordCube[k]=new $e;for(var k=0;k=ut?1:0)<>3]^=se<<(G<<2)}function Te(k,G){return k[G>>3]>>(G<<2)&15}function Se(k,G,se){return Math.min(k,G[se>>3]>>(se<<2)&15)}function qe(k){return(k-286331153&~k&2290649224)!=0}function Ne(k){return k^We>>((k&15)<<1)&3}function ze(k,G,se){var re=Xt[k];return se&&(re=Ne(re)),re&65520|Ve[re&15][G]}function te(){this.ca=[0,1,2,3,4,5,6,7],this.ea=[0,1,2,3,4,5,6,7,8,9,10,11]}function Ye(k,G,se){se--;for(var re=1985229328,Me=0;Me>ke&15;var pt=(1<>4&~pt)}k[se]=k[se]&240|re&15}function Lt(k,G){for(var se=0,re=1985229328,Me=0;Me>ge&15),re-=286331152<=0;--re){k[re]=k[re]&240|G%(se-re),G=~~(G/(se-re));for(var Me=re+1;Me=(k[re]&15)&&(k[Me]+=1)}}function C(k,G){for(var se=0,re=0;re=0;ge--){var ke=k[ge]&15;(ke&12)==G&&(re+=je[ge][Me--])}return re}function Pe(k,G,se){for(var re=k.length-1,Me=4,ge=re,ke=re;ke>=0;ke--)G>=je[ke][Me]?(G-=je[ke][Me--],k[ke]=k[ke]&240|Me|se):((ge&12)==se&&(ge-=4),k[ke]=k[ke]&240|ge--)}function Ce(k,G){for(var se=0,re=G-2;re>=0;re--)se^=k%(G-re),k=~~(k/(G-re));return se&1}te.EdgeMult=function(k,G,se){for(var re=0;re<12;re++)se.ea[re]=k.ea[G.ea[re]&15]^G.ea[re]&16},te.CornMult=function(k,G,se){for(var re=0;re<8;re++){var Me=((k.ca[G.ca[re]&15]>>4)+(G.ca[re]>>4))%3;se.ca[re]=k.ca[G.ca[re]&15]&15|Me<<4}},te.CornMultFull=function(k,G,se){for(var re=0;re<8;re++){var Me=k.ca[G.ca[re]&15]>>4,ge=G.ca[re]>>4,ke=Me+(Me<3?ge:6-ge);ke=ke%3+(Me<3==ge<3?0:3),se.ca[re]=k.ca[G.ca[re]&15]&15|ke<<4}},te.CornConjugate=function(k,G,se){for(var re=wt[rt[0][G]],Me=wt[G],ge=0;ge<8;ge++){var ke=re.ca[k.ca[Me.ca[ge]&15]&15]>>4,pt=k.ca[Me.ca[ge]&15]>>4,Ke=ke<3?pt:(3-pt)%3;se.ca[ge]=re.ca[k.ca[Me.ca[ge]&15]&15]&15|Ke<<4}},te.EdgeConjugate=function(k,G,se){for(var re=wt[rt[0][G]],Me=wt[G],ge=0;ge<12;ge++)se.ea[ge]=re.ea[k.ea[Me.ea[ge]&15]&15]^k.ea[Me.ea[ge]&15]&16^Me.ea[ge]&16},te.prototype.init=function(k,G){return this.ca=k.slice(),this.ea=G.slice(),this},te.prototype.initCoord=function(k,G,se,re){return Ye(this.ca,k,8),this.setTwst(G),H(this.ea,se,12),this.setFlip(re),this},te.prototype.isEqual=function(k){for(var G=0;G<8;G++)if(this.ca[G]!=k.ca[G])return!1;for(var G=0;G<12;G++)if(this.ea[G]!=k.ea[G])return!1;return!0},te.prototype.setFlip=function(k){for(var G=0,se=10;se>=0;se--,k>>=1)this.ea[se]=this.ea[se]&15|(k&1)<<4,G^=this.ea[se];this.ea[11]=this.ea[11]&15|G&16},te.prototype.getFlip=function(){for(var k=0,G=0;G<11;G++)k=k<<1|this.ea[G]>>4&1;return k},te.prototype.getFlipSym=function(){return Pt[this.getFlip()]},te.prototype.setTwst=function(k){for(var G=15,se=6;se>=0;se--,k=~~(k/3))this.ca[se]=this.ca[se]&15|k%3<<4,G-=this.ca[se]>>4;this.ca[7]=this.ca[7]&15|G%3<<4},te.prototype.getTwst=function(){for(var k=0,G=0;G<7;G++)k+=(k<<1)+(this.ca[G]>>4);return k},te.prototype.getTwstSym=function(){return Ae[this.getTwst()]},te.prototype.setCPerm=function(k){Ye(this.ca,k,8)},te.prototype.getCPerm=function(){return Lt(this.ca,8)},te.prototype.getCPermSym=function(){return Ne(bt[Lt(this.ca,8)])},te.prototype.setEPerm=function(k){Ye(this.ea,k,8)},te.prototype.getEPerm=function(){return Lt(this.ea,8)},te.prototype.getEPermSym=function(){return bt[Lt(this.ea,8)]},te.prototype.getSlice=function(){return 494-de(this.ea,8)},te.prototype.setSlice=function(k){Pe(this.ea,494-k,8)},te.prototype.getMPerm=function(){return C(this.ea,12)%24},te.prototype.setMPerm=function(k){H(this.ea,k,12)},te.prototype.getCComb=function(){return de(this.ca,0)},te.prototype.setCComb=function(k){Pe(this.ca,k,0)},te.prototype.URFConjugate=function(){var k=new te;te.CornMult(te.urf2,this,k),te.CornMult(k,te.urf1,this),te.EdgeMult(te.urf2,this,k),te.EdgeMult(k,te.urf1,this)};var ue=[[8,9,20],[6,18,38],[0,36,47],[2,45,11],[29,26,15],[27,44,24],[33,53,42],[35,17,51]],ot=[[5,10],[7,19],[3,37],[1,46],[32,16],[28,25],[30,43],[34,52],[23,12],[21,41],[50,39],[48,14]];te.prototype.toFaceCube=function(k,G){k=k||ue,G=G||ot;for(var se="URFDLB",re=[],Me=0;Me<54;Me++)re[Me]=se[~~(Me/9)];for(var ge=0;ge<8;ge++)for(var ke=this.ca[ge]&15,pt=this.ca[ge]>>4,Ke=0;Ke<3;Ke++)re[k[ge][(Ke+pt)%3]]=se[~~(k[ke][Ke]/9)];for(var _t=0;_t<12;_t++)for(var ke=this.ea[_t]&15,pt=this.ea[_t]>>4,Ke=0;Ke<2;Ke++)re[G[_t][(Ke+pt)%2]]=se[~~(G[ke][Ke]/9)];return re.join("")},te.prototype.invFrom=function(k){for(var G=0;G<12;G++)this.ea[k.ea[G]&15]=G&15|k.ea[G]&16;for(var se=0;se<8;se++)this.ca[k.ca[se]&15]=se|64>>(k.ca[se]>>4)&48;return this},te.prototype.fromFacelet=function(k,G,se){G=G||ue,se=se||ot;for(var re=0,Me=[],ge=k[4]+k[13]+k[22]+k[31]+k[40]+k[49],Ke=0;Ke<54;++Ke){if(Me[Ke]=ge.indexOf(k[Ke]),Me[Ke]==-1)return-1;re+=1<<(Me[Ke]<<2)}if(re!=10066329)return-1;var ke,pt,Ke,_t,Ft;for(Ke=0;Ke<8;++Ke){for(Ft=0;Ft<3&&!(Me[G[Ke][Ft]]==0||Me[G[Ke][Ft]]==3);++Ft);for(ke=Me[G[Ke][(Ft+1)%3]],pt=Me[G[Ke][(Ft+2)%3]],_t=0;_t<8;++_t)if(ke==~~(G[_t][1]/9)&&pt==~~(G[_t][2]/9)){this.ca[Ke]=_t|Ft%3<<4;break}}for(Ke=0;Ke<12;++Ke)for(_t=0;_t<12;++_t){if(Me[se[Ke][0]]==~~(se[_t][0]/9)&&Me[se[Ke][1]]==~~(se[_t][1]/9)){this.ea[Ke]=_t;break}if(Me[se[Ke][0]]==~~(se[_t][1]/9)&&Me[se[Ke][1]]==~~(se[_t][0]/9)){this.ea[Ke]=_t|16;break}}};function $e(){this.twst=0,this.flip=0,this.slice=0,this.prun=0,this.twstc=0,this.flipc=0}$e.prototype.set=function(k){this.twst=k.twst,this.flip=k.flip,this.slice=k.slice,this.prun=k.prun,this.twstc=k.twstc,this.flipc=k.flipc},$e.prototype.calcPruning=function(k){this.prun=Math.max(Se(ee,Ei,(this.twst>>3)*Ue+Vn[this.slice<<3|this.twst&7]),Se(pe,zi,(this.flip>>3)*Ue+Vn[this.slice<<3|this.flip&7]),Se(B,Vi,this.twstc>>3<<11|K[this.flipc^this.twstc&7]),Se(B,Vi,this.twst>>3<<11|K[this.flip^this.twst&7]))},$e.prototype.setWithPrun=function(k,G){if(this.twst=k.getTwstSym(),this.flip=k.getFlipSym(),this.prun=Se(B,Vi,this.twst>>3<<11|K[this.flip^this.twst&7]),this.prun>G||(this.slice=k.getSlice(),this.prun=Math.max(this.prun,Se(ee,Ei,(this.twst>>3)*Ue+Vn[this.slice<<3|this.twst&7]),Se(pe,zi,(this.flip>>3)*Ue+Vn[this.slice<<3|this.flip&7])),this.prun>G))return!1;{var se=new te;te.CornConjugate(k,1,se),te.EdgeConjugate(k,1,se),this.twstc=se.getTwstSym(),this.flipc=se.getFlipSym(),this.prun=Math.max(this.prun,Se(B,Vi,this.twstc>>3<<11|K[this.flipc^this.twstc&7]))}return this.prun<=G},$e.prototype.doMovePrun=function(k,G,se){return this.slice=ti[k.slice*O+G],this.flip=ei[(k.flip>>3)*O+Xe[G<<3|k.flip&7]]^k.flip&7,this.twst=Wt[(k.twst>>3)*O+Xe[G<<3|k.twst&7]]^k.twst&7,this.prun=Math.max(Se(ee,Ei,(this.twst>>3)*Ue+Vn[this.slice<<3|this.twst&7]),Se(pe,zi,(this.flip>>3)*Ue+Vn[this.slice<<3|this.flip&7]),Se(B,Vi,this.twst>>3<<11|K[this.flip^this.twst&7])),this.prun},$e.prototype.doMovePrunConj=function(k,G){return G=Tt[3][G],this.flipc=ei[(k.flipc>>3)*O+Xe[G<<3|k.flipc&7]]^k.flipc&7,this.twstc=Wt[(k.twstc>>3)*O+Xe[G<<3|k.twstc&7]]^k.twstc&7,Se(B,Vi,this.twstc>>3<<11|K[this.flipc^this.twstc&7])},s.prototype.solution=function(k,G,se,re,Me,ge,ke){vt();var pt=this.verify(k);if(pt!=0)return"Error "+Math.abs(pt);G===void 0&&(G=21),se===void 0&&(se=1e9),re===void 0&&(re=0),Me===void 0&&(Me=0),this.sol=G+1,this.probe=0,this.probeMax=se,this.probeMin=Math.min(re,se),this.verbose=Me,this.moveSol=null,this.isRec=!1,this.firstFilters=[0,0,0,0,0,0],this.lastFilters=[0,0,0,0,0,0];for(var Ke=0;Ke<3;Ke++)ge!==void 0&&(this.firstFilters[Ke]|=3591<<~~(De[(3-Ke)%3][ge*3]/3)*3,this.lastFilters[Ke+3]|=3591<<~~(De[(3-Ke)%3][ge*3]/3)*3),ke!==void 0&&(this.lastFilters[Ke]|=3591<<~~(De[(3-Ke)%3][ke*3]/3)*3,this.firstFilters[Ke+3]|=3591<<~~(De[(3-Ke)%3][ke*3]/3)*3);return this.initSearch(),this.search()},s.prototype.initSearch=function(){this.conjMask=0,this.maxPreMoves=this.conjMask>7?0:e;for(var k=0;k<6;k++)if(this.urfCubieCube[k].init(this.cc.ca,this.cc.ea),this.urfCoordCube[k].setWithPrun(this.urfCubieCube[k],20),this.cc.URFConjugate(),k%3==2){var G=new te().invFrom(this.cc);this.cc.init(G.ca,G.ea)}},s.prototype.next=function(k,G,se){return this.probe=0,this.probeMax=k,this.probeMin=Math.min(G,k),this.moveSol=null,this.isRec=!0,this.verbose=se,this.search()},s.prototype.verify=function(k){if(this.cc.fromFacelet(k)==-1)return-1;for(var G=0,se=0,re=0;re<12;re++)se|=1<<(this.cc.ea[re]&15),G^=this.cc.ea[re]>>4;if(se!=4095)return-2;if(G!=0)return-3;var Me=0;G=0;for(var ge=0;ge<8;ge++)Me|=1<<(this.cc.ca[ge]&15),G+=this.cc.ca[ge]>>4;return Me!=255?-4:G%3!=0?-5:Ce(C(this.cc.ea,12),12)^Ce(this.cc.getCPerm(),8)?-6:0},s.prototype.phase1PreMoves=function(k,G,se){if(k==this.maxPreMoves-1&&this.lastFilter>>G&1)return 1;if(this.preMoveLen=this.maxPreMoves-k,(this.isRec?this.depth1==this.length1-this.preMoveLen:this.preMoveLen==0||!(225207>>G&1))&&(this.depth1=this.length1-this.preMoveLen,this.phase1Cubie[0].init(se.ca,se.ea),this.allowShorter=this.depth1==t&&this.preMoveLen!=0,this.nodeUD[this.depth1+1].setWithPrun(se,this.depth1)&&this.phase1(this.nodeUD[this.depth1+1],this.depth1,-1)==0))return 0;if(k==0||this.preMoveLen+t>=this.length1)return 1;var re=0;(k==1||this.preMoveLen+1+t>=this.length1)&&(re|=225207),G=~~(G/3)*3;for(var Me=0;Me<18;Me++){if(Me==G||Me==G-9||Me==G+9){Me+=2;continue}if(!(this.isRec&&Me!=this.preMoves[this.maxPreMoves-k]||re&1<=(this.moveSol==null?this.probeMax:this.probeMin))return 0;++this.probe;for(var k=this.valid1;k>=4;var re=k.getEPermSym(),Me=re&15;re>>=4;var ge=k.getMPerm(),ke=Math.max(Se(ae,ms,re*ve+ps[(Vt[G]&255)<<4|rt[Me][se]]),Se(Re,Ya,G*oe+fs[ge<<4|se])),pt=Math.min(n,this.sol-this.length1);if(ke>=pt)return ke>pt?2:1;var Ke;for(Ke=pt-1;Ke>=ke;Ke--){var _t=this.phase2(re,Me,G,se,ge,Ke,this.depth1,10);if(_t<0)break;Ke-=_t,this.moveSol=[];for(var Ft=0;Ft=0;Ft--)this.appendSolMove(this.preMoves[Ft]);this.sol=this.moveSol.length,this.moveSol=this.solutionToString()}return Ke!=pt-1&&this.probe>=this.probeMin?0:1},s.prototype.phase1=function(k,G,se){if(G==this.depth1-1&&this.firstFilter>>se&1)return 1;if(k.prun==0&&G<5)if(this.allowShorter||G==0){this.depth1-=G;var re=this.initPhase2Pre();return this.depth1+=G,re}else return 1;for(var Me=0;Me<18;Me+=3)if(!(Me==se||Me==se-9))for(var ge=0;ge<3;ge++){var ke=Me+ge;if(!(this.isRec&&ke!=this.move[this.depth1-G])){var pt=this.nodeUD[G].doMovePrun(k,ke,!0);if(pt>G)break;if(pt==G)continue;{if(pt=this.nodeUD[G].doMovePrunConj(k,ke),pt>G)break;if(pt==G)continue}this.move[this.depth1-G]=ke,this.valid1=Math.min(this.valid1,this.depth1-G);var re=this.phase1(this.nodeUD[G],G-1,Me);if(re==0)return 0;if(re==2)break}}return 1},s.prototype.appendSolMove=function(k){if(this.moveSol.length==0){this.moveSol.push(k);return}var G=~~(k/3),se=~~(this.moveSol[this.moveSol.length-1]/3);if(G==se){var re=(k%3+this.moveSol[this.moveSol.length-1]%3+1)%4;re==3?this.moveSol.pop():this.moveSol[this.moveSol.length-1]=G*3+re;return}if(this.moveSol.length>1&&G%3==se%3&&G==~~(this.moveSol[this.moveSol.length-2]/3)){var re=(k%3+this.moveSol[this.moveSol.length-2]%3+1)%4;re==3?(this.moveSol[this.moveSol.length-2]=this.moveSol[this.moveSol.length-1],this.moveSol.pop()):this.moveSol[this.moveSol.length-2]=G*3+re;return}this.moveSol.push(k)},s.prototype.phase2=function(k,G,se,re,Me,ge,ke,pt){if(this.depth1==0&&ke==1&&this.firstFilter>>_e[pt]&1)return-1;if(k==0&&se==0&&Me==0&&(this.preMoveLen>0||!(this.lastFilter>>_e[pt]&1)))return ge;for(var Ke=$[pt],_t=0;_t<10;_t++){if(Ke>>_t&1){_t+=66>>_t&3;continue}var Ft=Gr[Me*A+_t],En=er[se*A+gt[re][_t]],Hn=Ve[En&15][re];if(En>>=4,!(Se(Re,Ya,En*oe+fs[Ft<<4|Hn])>=ge)){var pn=oa[k*A+gt[G][_t]],Xn=Ve[pn&15][G];if(pn>>=4,!(Se(ae,ms,pn*ve+ps[(Vt[En]&255)<<4|rt[Xn][Hn]])>=ge)){var xi=ze(pn,Xn,!1),ni=ze(En,Hn,!0);if(!(Se(ae,ms,(xi>>4)*ve+ps[(Vt[ni>>4]&255)<<4|rt[xi&15][ni&15]])>=ge)){var Ri=this.phase2(pn,Xn,En,Hn,Ft,ge-1,ke+1,_t);if(Ri>=0)return this.move[ke]=_e[_t],Ri}}}}return-1},s.prototype.solutionToString=function(){var k="",G=this.verbose&r?(this.urfIdx+3)%6:this.urfIdx;if(G<3)for(var se=0;se=0;--se)k+=le[De[G][this.moveSol[se]]]+" ";return k};var Oe=[],wt=[],Ve=[],rt=[],Tt=[],gt=[],Xe=[],At=[],Pt=[],on=[],K=[],st=[],Ae=[],Fe=[],Ze=[],bt=[],Ht=[],Vt=[],Xt=[],Wt=[],ei=[],ti=[],Vn=[],Ei=[],zi=[],Vi=[],er=[],oa=[],Gr=[],fs=[],la=[],ps=[],Ya=[],ms=[],B=15,ee=15,pe=15,Re=15,ae=15;{for(var Le=0;Le<18;Le++)Oe[Le]=new te;Oe[0].initCoord(15120,0,119750400,0),Oe[3].initCoord(21021,1494,323403417,0),Oe[6].initCoord(8064,1236,29441808,550),Oe[9].initCoord(9,0,5880,0),Oe[12].initCoord(1230,412,2949660,0),Oe[15].initCoord(224,137,328552,137);for(var He=0;He<18;He+=3)for(var tt=0;tt<2;tt++)te.EdgeMult(Oe[He+tt],Oe[He],Oe[He+tt+1]),te.CornMult(Oe[He+tt],Oe[He],Oe[He+tt+1]);te.urf1=new te().initCoord(2531,1373,67026819,1367),te.urf2=new te().initCoord(2089,1906,322752913,2040)}function ft(){for(var k=new te,G=new te,se=new te().initCoord(28783,0,259268407,0),re=new te().initCoord(15138,0,119765538,7),Me=new te().initCoord(5167,0,83473207,0),ge=0;ge<8;ge++)Me.ca[ge]|=48;for(var ge=0;ge<16;ge++)wt[ge]=new te().init(k.ca,k.ea),te.CornMultFull(k,re,G),te.EdgeMult(k,re,G),k.init(G.ca,G.ea),ge%4==3&&(te.CornMultFull(k,Me,G),te.EdgeMult(k,Me,G),k.init(G.ca,G.ea)),ge%8==7&&(te.CornMultFull(k,se,G),te.EdgeMult(k,se,G),k.init(G.ca,G.ea));for(var ge=0;ge<16;ge++)Ve[ge]=[],rt[ge]=[],Tt[ge]=[],Xe[ge]=[],gt[ge]=[];for(var ge=0;ge<16;ge++)for(var ke=0;ke<16;ke++)Ve[ge][ke]=ge^ke^84660>>ke&ge<<1&2,rt[Ve[ge][ke]][ke]=ge;k=new te;for(var pt=0;pt<16;pt++)for(var ke=0;ke<18;ke++){te.CornConjugate(Oe[ke],rt[0][pt],k);e:for(var Ke=0;Ke<18;Ke++){for(var _t=0;_t<8;_t++)if(Oe[Ke].ca[_t]!=k.ca[_t])continue e;Tt[pt][ke]=Ke,gt[pt][X[ke]]=X[Ke];break}pt%2==0&&(Xe[ke<<3|pt>>1]=Tt[pt][ke])}function Ft(pn,Xn,xi,ni,Ri,hi,Wn){for(var Ln=new te,Sr=new te,ui=0,Hi=Ri>=2?1:2,Mr=Ri!=1?te.EdgeConjugate:te.CornConjugate,tr=0;tr>1]=Wi),Wi==tr&&(ni[ui]|=1<>1]=G.getSlice()}for(var ge=0;ge>ke&1^~~(ge/70));for(var ke=0;ke<16;ke++)te.CornConjugate(k,rt[0][ke],G),ps[ge<<4|ke]=G.getCComb()+70*~~(ge/70)}}var it=-1;function Rt(k,G,se,re,Me,ge,ke,pt){var Ke=pt&15,_t=(pt>>4&1)==1?14540032:0,Ft=(pt>>5&1)==1,En=pt>>8&15,Hn=pt>>12&15,pn=pt>>16&15,Xn=(1<>3)+1;Ln++)k[Ln]=-1;Y(k,0,15),Wn=0}else Y(k,ni,15^Wn+1);for(var Sr=i>0?Math.min(Math.max(Wn+1,pn),Hn):Hn;WnEn,Hi=ui?15:Wn,Mr=Hi*286331153,tr=ui?Wn:15;Wn++,it++;for(var fr=Wn^15,Wi=0,Ln=0;Ln>=4){if(!(Ln&7)&&(Wi=k[Ln>>3],!qe(Wi^Mr))){Ln+=7;continue}if((Wi&15)==Hi){var qc=Ln%G,Xc=~~(Ln/G),$a=0,Rl=0;xi&&($a=Pt[qc],Rl=$a&7,$a>>=3);for(var gs=0;gs>=Ke;var yd=xs*G+Ka,vl=Te(k,yd);if(vl!=tr){vl>gs&3);continue}if(ui){Y(k,Ln,fr);break}Y(k,yd,fr);for(var bl=1,_d=ke[xs];(_d>>=1)!=0;bl++)if((_d&1)==1){var Ul=xs*G;xi?Ul+=K[Pt[Ka]^bl]:Ul+=Me[Ka<>(bl<<1)&3],Te(k,Ul)==tr&&Y(k,Ul,fr)}}}}}return Y(k,ni,Wn+1^15),Wn+1}function Ut(k){B=Rt(Vi,E,J,null,null,Wt,Fe,103939),!(it>k)&&(ee=Rt(Ei,Ue,J,ti,Vn,Wt,Fe,431619),!(it>k)&&(pe=Rt(zi,Ue,z,ti,Vn,ei,on,431619),!(it>k)&&(Re=Rt(Ya,24,me,Gr,fs,er,Ht,584244),!(it>k)&&(ae=Rt(ms,ve,me,la,ps,oa,Ht,514084)))))}function vt(){if(it<0&&(ft(),it=0),it==0)Ut(99);else if(it<54)Ut(it);else return!0;return!1}function Kt(){var k,G,se=~~(Math.random()*2048),re=~~(Math.random()*2187);do k=~~(Math.random()*q[12]),G=~~(Math.random()*q[8]);while(Ce(G,8)!=Ce(k,12));var Me=new te().initCoord(G,re,k,se);return Me.toFaceCube()}function mn(k){for(var G=-1,se=new te,re=new te,Me=0;Me. See LICENSE.txt. */(function(i,e){(function(t){function n(q){return parseInt(q)===q}function r(q){if(!n(q.length))return!1;for(var le=0;le255)return!1;return!0}function s(q,le){if(q.buffer&&q.name==="Uint8Array")return le&&(q.slice?q=q.slice():q=Array.prototype.slice.call(q)),q;if(Array.isArray(q)){if(!r(q))throw new Error("Array contains invalid value: "+q);return new Uint8Array(q)}if(n(q.length)&&r(q))return new Uint8Array(q);throw new Error("unsupported array-like object")}function a(q){return new Uint8Array(q)}function o(q,le,_e,X,$){(X!=null||$!=null)&&(q.slice?q=q.slice(X,$):q=Array.prototype.slice.call(q,X,$)),le.set(q,_e)}var l=function(){function q(_e){var X=[],$=0;for(_e=encodeURI(_e);$<_e.length;){var De=_e.charCodeAt($++);De===37?(X.push(parseInt(_e.substr($,2),16)),$+=2):X.push(De)}return s(X)}function le(_e){for(var X=[],$=0;$<_e.length;){var De=_e[$];De<128?(X.push(String.fromCharCode(De)),$++):De>191&&De<224?(X.push(String.fromCharCode((De&31)<<6|_e[$+1]&63)),$+=2):(X.push(String.fromCharCode((De&15)<<12|(_e[$+1]&63)<<6|_e[$+2]&63)),$+=3)}return X.join("")}return{toBytes:q,fromBytes:le}}(),c=function(){function q(X){for(var $=[],De=0;De>4]+le[Le&15])}return $.join("")}return{toBytes:q,fromBytes:_e}}(),h={16:10,24:12,32:14},u=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145],d=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],p=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],m=[3328402341,4168907908,4000806809,4135287693,4294111757,3597364157,3731845041,2445657428,1613770832,33620227,3462883241,1445669757,3892248089,3050821474,1303096294,3967186586,2412431941,528646813,2311702848,4202528135,4026202645,2992200171,2387036105,4226871307,1101901292,3017069671,1604494077,1169141738,597466303,1403299063,3832705686,2613100635,1974974402,3791519004,1033081774,1277568618,1815492186,2118074177,4126668546,2211236943,1748251740,1369810420,3521504564,4193382664,3799085459,2883115123,1647391059,706024767,134480908,2512897874,1176707941,2646852446,806885416,932615841,168101135,798661301,235341577,605164086,461406363,3756188221,3454790438,1311188841,2142417613,3933566367,302582043,495158174,1479289972,874125870,907746093,3698224818,3025820398,1537253627,2756858614,1983593293,3084310113,2108928974,1378429307,3722699582,1580150641,327451799,2790478837,3117535592,0,3253595436,1075847264,3825007647,2041688520,3059440621,3563743934,2378943302,1740553945,1916352843,2487896798,2555137236,2958579944,2244988746,3151024235,3320835882,1336584933,3992714006,2252555205,2588757463,1714631509,293963156,2319795663,3925473552,67240454,4269768577,2689618160,2017213508,631218106,1269344483,2723238387,1571005438,2151694528,93294474,1066570413,563977660,1882732616,4059428100,1673313503,2008463041,2950355573,1109467491,537923632,3858759450,4260623118,3218264685,2177748300,403442708,638784309,3287084079,3193921505,899127202,2286175436,773265209,2479146071,1437050866,4236148354,2050833735,3362022572,3126681063,840505643,3866325909,3227541664,427917720,2655997905,2749160575,1143087718,1412049534,999329963,193497219,2353415882,3354324521,1807268051,672404540,2816401017,3160301282,369822493,2916866934,3688947771,1681011286,1949973070,336202270,2454276571,201721354,1210328172,3093060836,2680341085,3184776046,1135389935,3294782118,965841320,831886756,3554993207,4068047243,3588745010,2345191491,1849112409,3664604599,26054028,2983581028,2622377682,1235855840,3630984372,2891339514,4092916743,3488279077,3395642799,4101667470,1202630377,268961816,1874508501,4034427016,1243948399,1546530418,941366308,1470539505,1941222599,2546386513,3421038627,2715671932,3899946140,1042226977,2521517021,1639824860,227249030,260737669,3765465232,2084453954,1907733956,3429263018,2420656344,100860677,4160157185,470683154,3261161891,1781871967,2924959737,1773779408,394692241,2579611992,974986535,664706745,3655459128,3958962195,731420851,571543859,3530123707,2849626480,126783113,865375399,765172662,1008606754,361203602,3387549984,2278477385,2857719295,1344809080,2782912378,59542671,1503764984,160008576,437062935,1707065306,3622233649,2218934982,3496503480,2185314755,697932208,1512910199,504303377,2075177163,2824099068,1841019862,739644986],v=[2781242211,2230877308,2582542199,2381740923,234877682,3184946027,2984144751,1418839493,1348481072,50462977,2848876391,2102799147,434634494,1656084439,3863849899,2599188086,1167051466,2636087938,1082771913,2281340285,368048890,3954334041,3381544775,201060592,3963727277,1739838676,4250903202,3930435503,3206782108,4149453988,2531553906,1536934080,3262494647,484572669,2923271059,1783375398,1517041206,1098792767,49674231,1334037708,1550332980,4098991525,886171109,150598129,2481090929,1940642008,1398944049,1059722517,201851908,1385547719,1699095331,1587397571,674240536,2704774806,252314885,3039795866,151914247,908333586,2602270848,1038082786,651029483,1766729511,3447698098,2682942837,454166793,2652734339,1951935532,775166490,758520603,3000790638,4004797018,4217086112,4137964114,1299594043,1639438038,3464344499,2068982057,1054729187,1901997871,2534638724,4121318227,1757008337,0,750906861,1614815264,535035132,3363418545,3988151131,3201591914,1183697867,3647454910,1265776953,3734260298,3566750796,3903871064,1250283471,1807470800,717615087,3847203498,384695291,3313910595,3617213773,1432761139,2484176261,3481945413,283769337,100925954,2180939647,4037038160,1148730428,3123027871,3813386408,4087501137,4267549603,3229630528,2315620239,2906624658,3156319645,1215313976,82966005,3747855548,3245848246,1974459098,1665278241,807407632,451280895,251524083,1841287890,1283575245,337120268,891687699,801369324,3787349855,2721421207,3431482436,959321879,1469301956,4065699751,2197585534,1199193405,2898814052,3887750493,724703513,2514908019,2696962144,2551808385,3516813135,2141445340,1715741218,2119445034,2872807568,2198571144,3398190662,700968686,3547052216,1009259540,2041044702,3803995742,487983883,1991105499,1004265696,1449407026,1316239930,504629770,3683797321,168560134,1816667172,3837287516,1570751170,1857934291,4014189740,2797888098,2822345105,2754712981,936633572,2347923833,852879335,1133234376,1500395319,3084545389,2348912013,1689376213,3533459022,3762923945,3034082412,4205598294,133428468,634383082,2949277029,2398386810,3913789102,403703816,3580869306,2297460856,1867130149,1918643758,607656988,4049053350,3346248884,1368901318,600565992,2090982877,2632479860,557719327,3717614411,3697393085,2249034635,2232388234,2430627952,1115438654,3295786421,2865522278,3633334344,84280067,33027830,303828494,2747425121,1600795957,4188952407,3496589753,2434238086,1486471617,658119965,3106381470,953803233,334231800,3005978776,857870609,3151128937,1890179545,2298973838,2805175444,3056442267,574365214,2450884487,550103529,1233637070,4289353045,2018519080,2057691103,2399374476,4166623649,2148108681,387583245,3664101311,836232934,3330556482,3100665960,3280093505,2955516313,2002398509,287182607,3413881008,4238890068,3597515707,975967766],b=[1671808611,2089089148,2006576759,2072901243,4061003762,1807603307,1873927791,3310653893,810573872,16974337,1739181671,729634347,4263110654,3613570519,2883997099,1989864566,3393556426,2191335298,3376449993,2106063485,4195741690,1508618841,1204391495,4027317232,2917941677,3563566036,2734514082,2951366063,2629772188,2767672228,1922491506,3227229120,3082974647,4246528509,2477669779,644500518,911895606,1061256767,4144166391,3427763148,878471220,2784252325,3845444069,4043897329,1905517169,3631459288,827548209,356461077,67897348,3344078279,593839651,3277757891,405286936,2527147926,84871685,2595565466,118033927,305538066,2157648768,3795705826,3945188843,661212711,2999812018,1973414517,152769033,2208177539,745822252,439235610,455947803,1857215598,1525593178,2700827552,1391895634,994932283,3596728278,3016654259,695947817,3812548067,795958831,2224493444,1408607827,3513301457,0,3979133421,543178784,4229948412,2982705585,1542305371,1790891114,3410398667,3201918910,961245753,1256100938,1289001036,1491644504,3477767631,3496721360,4012557807,2867154858,4212583931,1137018435,1305975373,861234739,2241073541,1171229253,4178635257,33948674,2139225727,1357946960,1011120188,2679776671,2833468328,1374921297,2751356323,1086357568,2408187279,2460827538,2646352285,944271416,4110742005,3168756668,3066132406,3665145818,560153121,271589392,4279952895,4077846003,3530407890,3444343245,202643468,322250259,3962553324,1608629855,2543990167,1154254916,389623319,3294073796,2817676711,2122513534,1028094525,1689045092,1575467613,422261273,1939203699,1621147744,2174228865,1339137615,3699352540,577127458,712922154,2427141008,2290289544,1187679302,3995715566,3100863416,339486740,3732514782,1591917662,186455563,3681988059,3762019296,844522546,978220090,169743370,1239126601,101321734,611076132,1558493276,3260915650,3547250131,2901361580,1655096418,2443721105,2510565781,3828863972,2039214713,3878868455,3359869896,928607799,1840765549,2374762893,3580146133,1322425422,2850048425,1823791212,1459268694,4094161908,3928346602,1706019429,2056189050,2934523822,135794696,3134549946,2022240376,628050469,779246638,472135708,2800834470,3032970164,3327236038,3894660072,3715932637,1956440180,522272287,1272813131,3185336765,2340818315,2323976074,1888542832,1044544574,3049550261,1722469478,1222152264,50660867,4127324150,236067854,1638122081,895445557,1475980887,3117443513,2257655686,3243809217,489110045,2662934430,3778599393,4162055160,2561878936,288563729,1773916777,3648039385,2391345038,2493985684,2612407707,505560094,2274497927,3911240169,3460925390,1442818645,678973480,3749357023,2358182796,2717407649,2306869641,219617805,3218761151,3862026214,1120306242,1756942440,1103331905,2578459033,762796589,252780047,2966125488,1425844308,3151392187,372911126],R=[1667474886,2088535288,2004326894,2071694838,4075949567,1802223062,1869591006,3318043793,808472672,16843522,1734846926,724270422,4278065639,3621216949,2880169549,1987484396,3402253711,2189597983,3385409673,2105378810,4210693615,1499065266,1195886990,4042263547,2913856577,3570689971,2728590687,2947541573,2627518243,2762274643,1920112356,3233831835,3082273397,4261223649,2475929149,640051788,909531756,1061110142,4160160501,3435941763,875846760,2779116625,3857003729,4059105529,1903268834,3638064043,825316194,353713962,67374088,3351728789,589522246,3284360861,404236336,2526454071,84217610,2593830191,117901582,303183396,2155911963,3806477791,3958056653,656894286,2998062463,1970642922,151591698,2206440989,741110872,437923380,454765878,1852748508,1515908788,2694904667,1381168804,993742198,3604373943,3014905469,690584402,3823320797,791638366,2223281939,1398011302,3520161977,0,3991743681,538992704,4244381667,2981218425,1532751286,1785380564,3419096717,3200178535,960056178,1246420628,1280103576,1482221744,3486468741,3503319995,4025428677,2863326543,4227536621,1128514950,1296947098,859002214,2240123921,1162203018,4193849577,33687044,2139062782,1347481760,1010582648,2678045221,2829640523,1364325282,2745433693,1077985408,2408548869,2459086143,2644360225,943212656,4126475505,3166494563,3065430391,3671750063,555836226,269496352,4294908645,4092792573,3537006015,3452783745,202118168,320025894,3974901699,1600119230,2543297077,1145359496,387397934,3301201811,2812801621,2122220284,1027426170,1684319432,1566435258,421079858,1936954854,1616945344,2172753945,1330631070,3705438115,572679748,707427924,2425400123,2290647819,1179044492,4008585671,3099120491,336870440,3739122087,1583276732,185277718,3688593069,3772791771,842159716,976899700,168435220,1229577106,101059084,606366792,1549591736,3267517855,3553849021,2897014595,1650632388,2442242105,2509612081,3840161747,2038008818,3890688725,3368567691,926374254,1835907034,2374863873,3587531953,1313788572,2846482505,1819063512,1448540844,4109633523,3941213647,1701162954,2054852340,2930698567,134748176,3132806511,2021165296,623210314,774795868,471606328,2795958615,3031746419,3334885783,3907527627,3722280097,1953799400,522133822,1263263126,3183336545,2341176845,2324333839,1886425312,1044267644,3048588401,1718004428,1212733584,50529542,4143317495,235803164,1633788866,892690282,1465383342,3115962473,2256965911,3250673817,488449850,2661202215,3789633753,4177007595,2560144171,286339874,1768537042,3654906025,2391705863,2492770099,2610673197,505291324,2273808917,3924369609,3469625735,1431699370,673740880,3755965093,2358021891,2711746649,2307489801,218961690,3217021541,3873845719,1111672452,1751693520,1094828930,2576986153,757954394,252645662,2964376443,1414855848,3149649517,370555436],L=[1374988112,2118214995,437757123,975658646,1001089995,530400753,2902087851,1273168787,540080725,2910219766,2295101073,4110568485,1340463100,3307916247,641025152,3043140495,3736164937,632953703,1172967064,1576976609,3274667266,2169303058,2370213795,1809054150,59727847,361929877,3211623147,2505202138,3569255213,1484005843,1239443753,2395588676,1975683434,4102977912,2572697195,666464733,3202437046,4035489047,3374361702,2110667444,1675577880,3843699074,2538681184,1649639237,2976151520,3144396420,4269907996,4178062228,1883793496,2403728665,2497604743,1383856311,2876494627,1917518562,3810496343,1716890410,3001755655,800440835,2261089178,3543599269,807962610,599762354,33778362,3977675356,2328828971,2809771154,4077384432,1315562145,1708848333,101039829,3509871135,3299278474,875451293,2733856160,92987698,2767645557,193195065,1080094634,1584504582,3178106961,1042385657,2531067453,3711829422,1306967366,2438237621,1908694277,67556463,1615861247,429456164,3602770327,2302690252,1742315127,2968011453,126454664,3877198648,2043211483,2709260871,2084704233,4169408201,0,159417987,841739592,504459436,1817866830,4245618683,260388950,1034867998,908933415,168810852,1750902305,2606453969,607530554,202008497,2472011535,3035535058,463180190,2160117071,1641816226,1517767529,470948374,3801332234,3231722213,1008918595,303765277,235474187,4069246893,766945465,337553864,1475418501,2943682380,4003061179,2743034109,4144047775,1551037884,1147550661,1543208500,2336434550,3408119516,3069049960,3102011747,3610369226,1113818384,328671808,2227573024,2236228733,3535486456,2935566865,3341394285,496906059,3702665459,226906860,2009195472,733156972,2842737049,294930682,1206477858,2835123396,2700099354,1451044056,573804783,2269728455,3644379585,2362090238,2564033334,2801107407,2776292904,3669462566,1068351396,742039012,1350078989,1784663195,1417561698,4136440770,2430122216,775550814,2193862645,2673705150,1775276924,1876241833,3475313331,3366754619,270040487,3902563182,3678124923,3441850377,1851332852,3969562369,2203032232,3868552805,2868897406,566021896,4011190502,3135740889,1248802510,3936291284,699432150,832877231,708780849,3332740144,899835584,1951317047,4236429990,3767586992,866637845,4043610186,1106041591,2144161806,395441711,1984812685,1139781709,3433712980,3835036895,2664543715,1282050075,3240894392,1181045119,2640243204,25965917,4203181171,4211818798,3009879386,2463879762,3910161971,1842759443,2597806476,933301370,1509430414,3943906441,3467192302,3076639029,3776767469,2051518780,2631065433,1441952575,404016761,1942435775,1408749034,1610459739,3745345300,2017778566,3400528769,3110650942,941896748,3265478751,371049330,3168937228,675039627,4279080257,967311729,135050206,3635733660,1683407248,2076935265,3576870512,1215061108,3501741890],_=[1347548327,1400783205,3273267108,2520393566,3409685355,4045380933,2880240216,2471224067,1428173050,4138563181,2441661558,636813900,4233094615,3620022987,2149987652,2411029155,1239331162,1730525723,2554718734,3781033664,46346101,310463728,2743944855,3328955385,3875770207,2501218972,3955191162,3667219033,768917123,3545789473,692707433,1150208456,1786102409,2029293177,1805211710,3710368113,3065962831,401639597,1724457132,3028143674,409198410,2196052529,1620529459,1164071807,3769721975,2226875310,486441376,2499348523,1483753576,428819965,2274680428,3075636216,598438867,3799141122,1474502543,711349675,129166120,53458370,2592523643,2782082824,4063242375,2988687269,3120694122,1559041666,730517276,2460449204,4042459122,2706270690,3446004468,3573941694,533804130,2328143614,2637442643,2695033685,839224033,1973745387,957055980,2856345839,106852767,1371368976,4181598602,1033297158,2933734917,1179510461,3046200461,91341917,1862534868,4284502037,605657339,2547432937,3431546947,2003294622,3182487618,2282195339,954669403,3682191598,1201765386,3917234703,3388507166,0,2198438022,1211247597,2887651696,1315723890,4227665663,1443857720,507358933,657861945,1678381017,560487590,3516619604,975451694,2970356327,261314535,3535072918,2652609425,1333838021,2724322336,1767536459,370938394,182621114,3854606378,1128014560,487725847,185469197,2918353863,3106780840,3356761769,2237133081,1286567175,3152976349,4255350624,2683765030,3160175349,3309594171,878443390,1988838185,3704300486,1756818940,1673061617,3403100636,272786309,1075025698,545572369,2105887268,4174560061,296679730,1841768865,1260232239,4091327024,3960309330,3497509347,1814803222,2578018489,4195456072,575138148,3299409036,446754879,3629546796,4011996048,3347532110,3252238545,4270639778,915985419,3483825537,681933534,651868046,2755636671,3828103837,223377554,2607439820,1649704518,3270937875,3901806776,1580087799,4118987695,3198115200,2087309459,2842678573,3016697106,1003007129,2802849917,1860738147,2077965243,164439672,4100872472,32283319,2827177882,1709610350,2125135846,136428751,3874428392,3652904859,3460984630,3572145929,3593056380,2939266226,824852259,818324884,3224740454,930369212,2801566410,2967507152,355706840,1257309336,4148292826,243256656,790073846,2373340630,1296297904,1422699085,3756299780,3818836405,457992840,3099667487,2135319889,77422314,1560382517,1945798516,788204353,1521706781,1385356242,870912086,325965383,2358957921,2050466060,2388260884,2313884476,4006521127,901210569,3990953189,1014646705,1503449823,1062597235,2031621326,3212035895,3931371469,1533017514,350174575,2256028891,2177544179,1052338372,741876788,1606591296,1914052035,213705253,2334669897,1107234197,1899603969,3725069491,2631447780,2422494913,1635502980,1893020342,1950903388,1120974935],S=[2807058932,1699970625,2764249623,1586903591,1808481195,1173430173,1487645946,59984867,4199882800,1844882806,1989249228,1277555970,3623636965,3419915562,1149249077,2744104290,1514790577,459744698,244860394,3235995134,1963115311,4027744588,2544078150,4190530515,1608975247,2627016082,2062270317,1507497298,2200818878,567498868,1764313568,3359936201,2305455554,2037970062,1047239e3,1910319033,1337376481,2904027272,2892417312,984907214,1243112415,830661914,861968209,2135253587,2011214180,2927934315,2686254721,731183368,1750626376,4246310725,1820824798,4172763771,3542330227,48394827,2404901663,2871682645,671593195,3254988725,2073724613,145085239,2280796200,2779915199,1790575107,2187128086,472615631,3029510009,4075877127,3802222185,4107101658,3201631749,1646252340,4270507174,1402811438,1436590835,3778151818,3950355702,3963161475,4020912224,2667994737,273792366,2331590177,104699613,95345982,3175501286,2377486676,1560637892,3564045318,369057872,4213447064,3919042237,1137477952,2658625497,1119727848,2340947849,1530455833,4007360968,172466556,266959938,516552836,0,2256734592,3980931627,1890328081,1917742170,4294704398,945164165,3575528878,958871085,3647212047,2787207260,1423022939,775562294,1739656202,3876557655,2530391278,2443058075,3310321856,547512796,1265195639,437656594,3121275539,719700128,3762502690,387781147,218828297,3350065803,2830708150,2848461854,428169201,122466165,3720081049,1627235199,648017665,4122762354,1002783846,2117360635,695634755,3336358691,4234721005,4049844452,3704280881,2232435299,574624663,287343814,612205898,1039717051,840019705,2708326185,793451934,821288114,1391201670,3822090177,376187827,3113855344,1224348052,1679968233,2361698556,1058709744,752375421,2431590963,1321699145,3519142200,2734591178,188127444,2177869557,3727205754,2384911031,3215212461,2648976442,2450346104,3432737375,1180849278,331544205,3102249176,4150144569,2952102595,2159976285,2474404304,766078933,313773861,2570832044,2108100632,1668212892,3145456443,2013908262,418672217,3070356634,2594734927,1852171925,3867060991,3473416636,3907448597,2614737639,919489135,164948639,2094410160,2997825956,590424639,2486224549,1723872674,3157750862,3399941250,3501252752,3625268135,2555048196,3673637356,1343127501,4130281361,3599595085,2957853679,1297403050,81781910,3051593425,2283490410,532201772,1367295589,3926170974,895287692,1953757831,1093597963,492483431,3528626907,1446242576,1192455638,1636604631,209336225,344873464,1015671571,669961897,3375740769,3857572124,2973530695,3747192018,1933530610,3464042516,935293895,3454686199,2858115069,1863638845,3683022916,4085369519,3292445032,875313188,1080017571,3279033885,621591778,1233856572,2504130317,24197544,3017672716,3835484340,3247465558,2220981195,3060847922,1551124588,1463996600],D=[4104605777,1097159550,396673818,660510266,2875968315,2638606623,4200115116,3808662347,821712160,1986918061,3430322568,38544885,3856137295,718002117,893681702,1654886325,2975484382,3122358053,3926825029,4274053469,796197571,1290801793,1184342925,3556361835,2405426947,2459735317,1836772287,1381620373,3196267988,1948373848,3764988233,3385345166,3263785589,2390325492,1480485785,3111247143,3780097726,2293045232,548169417,3459953789,3746175075,439452389,1362321559,1400849762,1685577905,1806599355,2174754046,137073913,1214797936,1174215055,3731654548,2079897426,1943217067,1258480242,529487843,1437280870,3945269170,3049390895,3313212038,923313619,679998e3,3215307299,57326082,377642221,3474729866,2041877159,133361907,1776460110,3673476453,96392454,878845905,2801699524,777231668,4082475170,2330014213,4142626212,2213296395,1626319424,1906247262,1846563261,562755902,3708173718,1040559837,3871163981,1418573201,3294430577,114585348,1343618912,2566595609,3186202582,1078185097,3651041127,3896688048,2307622919,425408743,3371096953,2081048481,1108339068,2216610296,0,2156299017,736970802,292596766,1517440620,251657213,2235061775,2933202493,758720310,265905162,1554391400,1532285339,908999204,174567692,1474760595,4002861748,2610011675,3234156416,3693126241,2001430874,303699484,2478443234,2687165888,585122620,454499602,151849742,2345119218,3064510765,514443284,4044981591,1963412655,2581445614,2137062819,19308535,1928707164,1715193156,4219352155,1126790795,600235211,3992742070,3841024952,836553431,1669664834,2535604243,3323011204,1243905413,3141400786,4180808110,698445255,2653899549,2989552604,2253581325,3252932727,3004591147,1891211689,2487810577,3915653703,4237083816,4030667424,2100090966,865136418,1229899655,953270745,3399679628,3557504664,4118925222,2061379749,3079546586,2915017791,983426092,2022837584,1607244650,2118541908,2366882550,3635996816,972512814,3283088770,1568718495,3499326569,3576539503,621982671,2895723464,410887952,2623762152,1002142683,645401037,1494807662,2595684844,1335535747,2507040230,4293295786,3167684641,367585007,3885750714,1865862730,2668221674,2960971305,2763173681,1059270954,2777952454,2724642869,1320957812,2194319100,2429595872,2815956275,77089521,3973773121,3444575871,2448830231,1305906550,4021308739,2857194700,2516901860,3518358430,1787304780,740276417,1699839814,1592394909,2352307457,2272556026,188821243,1729977011,3687994002,274084841,3594982253,3613494426,2701949495,4162096729,322734571,2837966542,1640576439,484830689,1202797690,3537852828,4067639125,349075736,3342319475,4157467219,4255800159,1030690015,1155237496,2951971274,1757691577,607398968,2738905026,499347990,3794078908,1011452712,227885567,2818666809,213114376,3034881240,1455525988,3414450555,850817237,1817998408,3092726480],T=[0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795],x=[0,185469197,370938394,487725847,741876788,657861945,975451694,824852259,1483753576,1400783205,1315723890,1164071807,1950903388,2135319889,1649704518,1767536459,2967507152,3152976349,2801566410,2918353863,2631447780,2547432937,2328143614,2177544179,3901806776,3818836405,4270639778,4118987695,3299409036,3483825537,3535072918,3652904859,2077965243,1893020342,1841768865,1724457132,1474502543,1559041666,1107234197,1257309336,598438867,681933534,901210569,1052338372,261314535,77422314,428819965,310463728,3409685355,3224740454,3710368113,3593056380,3875770207,3960309330,4045380933,4195456072,2471224067,2554718734,2237133081,2388260884,3212035895,3028143674,2842678573,2724322336,4138563181,4255350624,3769721975,3955191162,3667219033,3516619604,3431546947,3347532110,2933734917,2782082824,3099667487,3016697106,2196052529,2313884476,2499348523,2683765030,1179510461,1296297904,1347548327,1533017514,1786102409,1635502980,2087309459,2003294622,507358933,355706840,136428751,53458370,839224033,957055980,605657339,790073846,2373340630,2256028891,2607439820,2422494913,2706270690,2856345839,3075636216,3160175349,3573941694,3725069491,3273267108,3356761769,4181598602,4063242375,4011996048,3828103837,1033297158,915985419,730517276,545572369,296679730,446754879,129166120,213705253,1709610350,1860738147,1945798516,2029293177,1239331162,1120974935,1606591296,1422699085,4148292826,4233094615,3781033664,3931371469,3682191598,3497509347,3446004468,3328955385,2939266226,2755636671,3106780840,2988687269,2198438022,2282195339,2501218972,2652609425,1201765386,1286567175,1371368976,1521706781,1805211710,1620529459,2105887268,1988838185,533804130,350174575,164439672,46346101,870912086,954669403,636813900,788204353,2358957921,2274680428,2592523643,2441661558,2695033685,2880240216,3065962831,3182487618,3572145929,3756299780,3270937875,3388507166,4174560061,4091327024,4006521127,3854606378,1014646705,930369212,711349675,560487590,272786309,457992840,106852767,223377554,1678381017,1862534868,1914052035,2031621326,1211247597,1128014560,1580087799,1428173050,32283319,182621114,401639597,486441376,768917123,651868046,1003007129,818324884,1503449823,1385356242,1333838021,1150208456,1973745387,2125135846,1673061617,1756818940,2970356327,3120694122,2802849917,2887651696,2637442643,2520393566,2334669897,2149987652,3917234703,3799141122,4284502037,4100872472,3309594171,3460984630,3545789473,3629546796,2050466060,1899603969,1814803222,1730525723,1443857720,1560382517,1075025698,1260232239,575138148,692707433,878443390,1062597235,243256656,91341917,409198410,325965383,3403100636,3252238545,3704300486,3620022987,3874428392,3990953189,4042459122,4227665663,2460449204,2578018489,2226875310,2411029155,3198115200,3046200461,2827177882,2743944855],O=[0,218828297,437656594,387781147,875313188,958871085,775562294,590424639,1750626376,1699970625,1917742170,2135253587,1551124588,1367295589,1180849278,1265195639,3501252752,3720081049,3399941250,3350065803,3835484340,3919042237,4270507174,4085369519,3102249176,3051593425,2734591178,2952102595,2361698556,2177869557,2530391278,2614737639,3145456443,3060847922,2708326185,2892417312,2404901663,2187128086,2504130317,2555048196,3542330227,3727205754,3375740769,3292445032,3876557655,3926170974,4246310725,4027744588,1808481195,1723872674,1910319033,2094410160,1608975247,1391201670,1173430173,1224348052,59984867,244860394,428169201,344873464,935293895,984907214,766078933,547512796,1844882806,1627235199,2011214180,2062270317,1507497298,1423022939,1137477952,1321699145,95345982,145085239,532201772,313773861,830661914,1015671571,731183368,648017665,3175501286,2957853679,2807058932,2858115069,2305455554,2220981195,2474404304,2658625497,3575528878,3625268135,3473416636,3254988725,3778151818,3963161475,4213447064,4130281361,3599595085,3683022916,3432737375,3247465558,3802222185,4020912224,4172763771,4122762354,3201631749,3017672716,2764249623,2848461854,2331590177,2280796200,2431590963,2648976442,104699613,188127444,472615631,287343814,840019705,1058709744,671593195,621591778,1852171925,1668212892,1953757831,2037970062,1514790577,1463996600,1080017571,1297403050,3673637356,3623636965,3235995134,3454686199,4007360968,3822090177,4107101658,4190530515,2997825956,3215212461,2830708150,2779915199,2256734592,2340947849,2627016082,2443058075,172466556,122466165,273792366,492483431,1047239e3,861968209,612205898,695634755,1646252340,1863638845,2013908262,1963115311,1446242576,1530455833,1277555970,1093597963,1636604631,1820824798,2073724613,1989249228,1436590835,1487645946,1337376481,1119727848,164948639,81781910,331544205,516552836,1039717051,821288114,669961897,719700128,2973530695,3157750862,2871682645,2787207260,2232435299,2283490410,2667994737,2450346104,3647212047,3564045318,3279033885,3464042516,3980931627,3762502690,4150144569,4199882800,3070356634,3121275539,2904027272,2686254721,2200818878,2384911031,2570832044,2486224549,3747192018,3528626907,3310321856,3359936201,3950355702,3867060991,4049844452,4234721005,1739656202,1790575107,2108100632,1890328081,1402811438,1586903591,1233856572,1149249077,266959938,48394827,369057872,418672217,1002783846,919489135,567498868,752375421,209336225,24197544,376187827,459744698,945164165,895287692,574624663,793451934,1679968233,1764313568,2117360635,1933530610,1343127501,1560637892,1243112415,1192455638,3704280881,3519142200,3336358691,3419915562,3907448597,3857572124,4075877127,4294704398,3029510009,3113855344,2927934315,2744104290,2159976285,2377486676,2594734927,2544078150],A=[0,151849742,303699484,454499602,607398968,758720310,908999204,1059270954,1214797936,1097159550,1517440620,1400849762,1817998408,1699839814,2118541908,2001430874,2429595872,2581445614,2194319100,2345119218,3034881240,3186202582,2801699524,2951971274,3635996816,3518358430,3399679628,3283088770,4237083816,4118925222,4002861748,3885750714,1002142683,850817237,698445255,548169417,529487843,377642221,227885567,77089521,1943217067,2061379749,1640576439,1757691577,1474760595,1592394909,1174215055,1290801793,2875968315,2724642869,3111247143,2960971305,2405426947,2253581325,2638606623,2487810577,3808662347,3926825029,4044981591,4162096729,3342319475,3459953789,3576539503,3693126241,1986918061,2137062819,1685577905,1836772287,1381620373,1532285339,1078185097,1229899655,1040559837,923313619,740276417,621982671,439452389,322734571,137073913,19308535,3871163981,4021308739,4104605777,4255800159,3263785589,3414450555,3499326569,3651041127,2933202493,2815956275,3167684641,3049390895,2330014213,2213296395,2566595609,2448830231,1305906550,1155237496,1607244650,1455525988,1776460110,1626319424,2079897426,1928707164,96392454,213114376,396673818,514443284,562755902,679998e3,865136418,983426092,3708173718,3557504664,3474729866,3323011204,4180808110,4030667424,3945269170,3794078908,2507040230,2623762152,2272556026,2390325492,2975484382,3092726480,2738905026,2857194700,3973773121,3856137295,4274053469,4157467219,3371096953,3252932727,3673476453,3556361835,2763173681,2915017791,3064510765,3215307299,2156299017,2307622919,2459735317,2610011675,2081048481,1963412655,1846563261,1729977011,1480485785,1362321559,1243905413,1126790795,878845905,1030690015,645401037,796197571,274084841,425408743,38544885,188821243,3613494426,3731654548,3313212038,3430322568,4082475170,4200115116,3780097726,3896688048,2668221674,2516901860,2366882550,2216610296,3141400786,2989552604,2837966542,2687165888,1202797690,1320957812,1437280870,1554391400,1669664834,1787304780,1906247262,2022837584,265905162,114585348,499347990,349075736,736970802,585122620,972512814,821712160,2595684844,2478443234,2293045232,2174754046,3196267988,3079546586,2895723464,2777952454,3537852828,3687994002,3234156416,3385345166,4142626212,4293295786,3841024952,3992742070,174567692,57326082,410887952,292596766,777231668,660510266,1011452712,893681702,1108339068,1258480242,1343618912,1494807662,1715193156,1865862730,1948373848,2100090966,2701949495,2818666809,3004591147,3122358053,2235061775,2352307457,2535604243,2653899549,3915653703,3764988233,4219352155,4067639125,3444575871,3294430577,3746175075,3594982253,836553431,953270745,600235211,718002117,367585007,484830689,133361907,251657213,2041877159,1891211689,1806599355,1654886325,1568718495,1418573201,1335535747,1184342925];function E(q){for(var le=[],_e=0;_e>2,this._Ke[De][le%4]=$[le],this._Kd[q-De][le%4]=$[le];for(var Le=0,dt=X,at;dt<_e;){if(at=$[X-1],$[0]^=d[at>>16&255]<<24^d[at>>8&255]<<16^d[at&255]<<8^d[at>>24&255]^u[Le]<<24,Le+=1,X!=8)for(var le=1;le>8&255]<<8^d[at>>16&255]<<16^d[at>>24&255]<<24;for(var le=X/2+1;le>2,Y=dt%4,this._Ke[ut][Y]=$[le],this._Kd[q-ut][Y]=$[le++],dt++}for(var ut=1;ut>24&255]^x[at>>16&255]^O[at>>8&255]^A[at&255]},z.prototype.encrypt=function(q){if(q.length!=16)throw new Error("invalid plaintext size (must be 16 bytes)");for(var le=this._Ke.length-1,_e=[0,0,0,0],X=E(q),$=0;$<4;$++)X[$]^=this._Ke[0][$];for(var De=1;De>24&255]^v[X[($+1)%4]>>16&255]^b[X[($+2)%4]>>8&255]^R[X[($+3)%4]&255]^this._Ke[De][$];X=_e.slice()}for(var Le=a(16),dt,$=0;$<4;$++)dt=this._Ke[le][$],Le[4*$]=(d[X[$]>>24&255]^dt>>24)&255,Le[4*$+1]=(d[X[($+1)%4]>>16&255]^dt>>16)&255,Le[4*$+2]=(d[X[($+2)%4]>>8&255]^dt>>8)&255,Le[4*$+3]=(d[X[($+3)%4]&255]^dt)&255;return Le},z.prototype.decrypt=function(q){if(q.length!=16)throw new Error("invalid ciphertext size (must be 16 bytes)");for(var le=this._Kd.length-1,_e=[0,0,0,0],X=E(q),$=0;$<4;$++)X[$]^=this._Kd[0][$];for(var De=1;De>24&255]^_[X[($+3)%4]>>16&255]^S[X[($+2)%4]>>8&255]^D[X[($+1)%4]&255]^this._Kd[De][$];X=_e.slice()}for(var Le=a(16),dt,$=0;$<4;$++)dt=this._Kd[le][$],Le[4*$]=(p[X[$]>>24&255]^dt>>24)&255,Le[4*$+1]=(p[X[($+3)%4]>>16&255]^dt>>16)&255,Le[4*$+2]=(p[X[($+2)%4]>>8&255]^dt>>8)&255,Le[4*$+3]=(p[X[($+1)%4]&255]^dt)&255;return Le};var ie=function(q){if(!(this instanceof ie))throw Error("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=new z(q)};ie.prototype.encrypt=function(q){if(q=s(q),q.length%16!==0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var le=a(q.length),_e=a(16),X=0;XNumber.MAX_SAFE_INTEGER)throw new Error("integer value out of safe range");for(var le=15;le>=0;--le)this._counter[le]=q%256,q=parseInt(q/256)},oe.prototype.setBytes=function(q){if(q=s(q,!0),q.length!=16)throw new Error("invalid counter bytes size (must be 16 bytes)");this._counter=q},oe.prototype.increment=function(){for(var q=15;q>=0;q--)if(this._counter[q]===255)this._counter[q]=0;else{this._counter[q]++;break}};var Ue=function(q,le){if(!(this instanceof Ue))throw Error("AES must be instanitated with `new`");this.description="Counter",this.name="ctr",le instanceof oe||(le=new oe(le)),this._counter=le,this._remainingCounter=null,this._remainingCounterIndex=16,this._aes=new z(q)};Ue.prototype.encrypt=function(q){for(var le=s(q,!0),_e=0;_e16)throw new Error("PKCS#7 padding byte out of range");for(var _e=q.length-le,X=0;X`${i.toString(10)}:${e.toString(10).padStart(2,"0")}.${t.toString(10).padStart(3,"0")}`}}function ac(i){var e=Math.trunc(i/6e4),t=Math.trunc(i%6e4/1e3),n=Math.trunc(i%1e3);return Pk(e,t,n)}const y2="6e400001-b5a3-f393-e0a9-e50e24dc4179",Ik="28be4a4a-cd67-11e9-a32f-2a2ae2dbcce4",Bk="28be4cb6-cd67-11e9-a32f-2a2ae2dbcce4",_2="8653000a-43e6-47b7-9cb0-5fc21d4ae340",Ok="8653000c-43e6-47b7-9cb0-5fc21d4ae340",kk="8653000b-43e6-47b7-9cb0-5fc21d4ae340",L2="00000010-0000-fff7-fff6-fff5fff4fff0",Nk="0000fff5-0000-1000-8000-00805f9b34fb",zk="0000fff6-0000-1000-8000-00805f9b34fb",WM=Array(256).fill(void 0).map((i,e)=>e<<8|1),Ef=[{key:[1,2,66,40,49,145,22,7,32,5,24,84,66,17,18,83],iv:[17,3,50,40,33,1,118,39,32,149,120,20,50,18,2,67]},{key:[5,18,2,69,2,1,41,86,18,120,18,118,129,1,8,3],iv:[1,68,40,6,134,33,34,40,81,5,8,49,130,2,33,6]}];class Rv{constructor(e,t,n){if(e.length!=16)throw new Error("Key must be 16 bytes (128-bit) long");if(t.length!=16)throw new Error("Iv must be 16 bytes (128-bit) long");if(n.length!=6)throw new Error("Salt must be 6 bytes (48-bit) long");this._key=new Uint8Array(e),this._iv=new Uint8Array(t);for(let r=0;r<6;r++)this._key[r]=(e[r]+n[r])%255,this._iv[r]=(t[r]+n[r])%255}encryptChunk(e,t){var n=new b2.ModeOfOperation.cbc(this._key,this._iv),r=n.encrypt(e.subarray(t,t+16));e.set(r,t)}decryptChunk(e,t){var n=new b2.ModeOfOperation.cbc(this._key,this._iv),r=n.decrypt(e.subarray(t,t+16));e.set(r,t)}encrypt(e){if(e.length<16)throw Error("Data must be at least 16 bytes long");var t=new Uint8Array(e);return this.encryptChunk(t,0),t.length>16&&this.encryptChunk(t,t.length-16),t}decrypt(e){if(e.length<16)throw Error("Data must be at least 16 bytes long");var t=new Uint8Array(e);return t.length>16&&this.decryptChunk(t,t.length-16),this.decryptChunk(t,0),t}}class Vk extends Rv{}class Hk extends Rv{}var C1,D1;const Ec=typeof window<"u"&&typeof((C1=window.performance)==null?void 0:C1.now)=="function"?()=>Math.floor(window.performance.now()):typeof process<"u"&&typeof((D1=process.hrtime)==null?void 0:D1.bigint)=="function"?()=>Number(process.hrtime.bigint()/1000000n):()=>Date.now();function GM(i,e){for(var t=0,n=0,r=0,s=0,a=0,o=0;o=2){for(let s=i.length-1;s>0;s--)i[s].cubeTimestamp!=null&&i[s-1].cubeTimestamp==null&&(i[s-1].cubeTimestamp=i[s].cubeTimestamp-50);for(let s=0;s0){var[t,n]=GM(i.map(s=>s.cubeTimestamp),i.map(s=>s.localTimestamp)),r=Math.round(t*i[0].cubeTimestamp+n);i.forEach(s=>{e.push({face:s.face,direction:s.direction,move:s.move,localTimestamp:s.localTimestamp,cubeTimestamp:Math.round(t*s.cubeTimestamp+n)-r})})}return e}function Gk(i){if(!i.length)return 0;var[e]=GM(i.map(t=>t.localTimestamp),i.map(t=>t.cubeTimestamp));return Math.round((e-1)*1e5)/1e3}const S2=[[8,9,20],[6,18,38],[0,36,47],[2,45,11],[29,26,15],[27,44,24],[33,53,42],[35,17,51]],M2=[[5,10],[7,19],[3,37],[1,46],[32,16],[28,25],[30,43],[34,52],[23,12],[21,41],[50,39],[48,14]];function vv(i,e,t,n){var r="URFDLB",s=[];for(let a=0;a<54;a++)s[a]=r[~~(a/9)];for(let a=0;a<8;a++)for(let o=0;o<3;o++)s[S2[a][(o+e[a])%3]]=r[~~(S2[i[a]][o]/9)];for(let a=0;a<12;a++)for(let o=0;o<2;o++)s[M2[a][(o+n[a])%2]]=r[~~(M2[t[a]][o]/9)];return s.join("")}const yr=i=>i.reduce((e,t)=>e+t,0);class Dh{constructor(e,t,n,r,s){this.onStateUpdate=async a=>{var o=a.target,l=o.value;if(l&&l.byteLength>=16){var c=this.encrypter.decrypt(new Uint8Array(l.buffer)),h=await this.driver.handleStateEvent(this,c);h.forEach(u=>this.events$.next(u))}},this.onDisconnect=async()=>(this.device.removeEventListener("gattserverdisconnected",this.onDisconnect),this.stateCharacteristic.removeEventListener("characteristicvaluechanged",this.onStateUpdate),this.events$.next({timestamp:Ec(),type:"DISCONNECT"}),this.events$.unsubscribe(),this.stateCharacteristic.stopNotifications().catch(()=>{})),this.device=e,this.commandCharacteristic=t,this.stateCharacteristic=n,this.encrypter=r,this.driver=s,this.events$=new z1}static async create(e,t,n,r,s){var a=new Dh(e,t,n,r,s);return a.device.addEventListener("gattserverdisconnected",a.onDisconnect),a.stateCharacteristic.addEventListener("characteristicvaluechanged",a.onStateUpdate),await a.stateCharacteristic.startNotifications(),a}get deviceName(){return this.device.name||"GAN-XXXX"}get deviceMAC(){return this.device.mac||"00:00:00:00:00:00"}async sendCommandMessage(e){var t=this.encrypter.encrypt(e);return this.commandCharacteristic.writeValue(t)}async sendCubeCommand(e){var t=this.driver.createCommandMessage(e);if(t)return this.sendCommandMessage(t)}async disconnect(){var e,t;await this.onDisconnect(),(e=this.device.gatt)!=null&&e.connected&&((t=this.device.gatt)==null||t.disconnect())}}class bv{constructor(e){this.bits=Array.from(e).map(t=>(t+256).toString(2).slice(1)).join("")}getBitWord(e,t,n=!1){if(t<=8)return parseInt(this.bits.slice(e,e+t),2);if(t==16||t==32){let r=new Uint8Array(t/8);for(let a=0;a>15)*2)*(c&32767)/32767,y:(1-(h>>15)*2)*(h&32767)/32767,z:(1-(u>>15)*2)*(u&32767)/32767,w:(1-(l>>15)*2)*(l&32767)/32767},velocity:{x:(1-(d>>3)*2)*(d&7),y:(1-(p>>3)*2)*(p&7),z:(1-(m>>3)*2)*(m&7)}})}else if(a==2){if(this.lastSerial!=-1){let l=s.getBitWord(4,8),c=Math.min(l-this.lastSerial&255,7);if(this.lastSerial=l,c>0){for(let h=c-1;h>=0;h--){let u=s.getBitWord(12+5*h,4),d=s.getBitWord(16+5*h,1),p="URFDLB".charAt(u)+" '".charAt(d),m=s.getBitWord(47+16*h,16);m==0&&(m=n-this.lastMoveTimestamp),this.cubeTimestamp+=m,r.push({type:"MOVE",serial:l-h&255,timestamp:n,localTimestamp:h==0?n:null,cubeTimestamp:this.cubeTimestamp,face:u,direction:d,move:p.trim()})}this.lastMoveTimestamp=n}}}else if(a==4){let l=s.getBitWord(4,8);this.lastSerial==-1&&(this.lastSerial=l);let c=[],h=[],u=[],d=[];for(let p=0;p<7;p++)c.push(s.getBitWord(12+p*3,3)),h.push(s.getBitWord(33+p*2,2));c.push(28-yr(c)),h.push((3-yr(h)%3)%3);for(let p=0;p<11;p++)u.push(s.getBitWord(47+p*4,4)),d.push(s.getBitWord(91+p,1));u.push(66-yr(u)),d.push((2-yr(d)%2)%2),r.push({type:"FACELETS",serial:l,timestamp:n,facelets:vv(c,h,u,d),state:{CP:c,CO:h,EP:u,EO:d}})}else if(a==5){let l=s.getBitWord(8,8),c=s.getBitWord(16,8),h=s.getBitWord(24,8),u=s.getBitWord(32,8),d=s.getBitWord(104,1),p="";for(var o=0;o<8;o++)p+=String.fromCharCode(s.getBitWord(o*8+40,8));r.push({type:"HARDWARE",timestamp:n,hardwareName:p,hardwareVersion:`${l}.${c}`,softwareVersion:`${h}.${u}`,gyroSupported:!!d})}else if(a==9){let l=s.getBitWord(8,8);r.push({type:"BATTERY",timestamp:n,batteryLevel:Math.min(l,100)})}else a==13&&e.disconnect();return r}}class qk{constructor(){this.serial=-1,this.lastSerial=-1,this.lastLocalTimestamp=null,this.moveBuffer=[]}createCommandMessage(e){var t=new Uint8Array(16).fill(0);switch(e.type){case"REQUEST_FACELETS":t.set([104,1]);break;case"REQUEST_HARDWARE":t.set([104,4]);break;case"REQUEST_BATTERY":t.set([104,7]);break;case"REQUEST_RESET":t.set([104,5,5,57,119,0,0,1,35,69,103,137,171,0,0,0]);break;default:t=void 0}return t}async requestMoveHistory(e,t,n){var r=new Uint8Array(16).fill(0);return t%2==0&&(t=t-1&255),n%2==1&&n++,n=Math.min(n,t+1),r.set([104,3,t,0,n,0]),e.sendCommandMessage(r).catch(()=>{})}async evictMoveBuffer(e){for(var t=[];this.moveBuffer.length>0;){let n=this.moveBuffer[0],r=this.lastSerial==-1?1:n.serial-this.lastSerial&255;if(r>1){e&&await this.requestMoveHistory(e,n.serial,r);break}else t.push(this.moveBuffer.shift()),this.lastSerial=n.serial}return e&&this.moveBuffer.length>16&&e.disconnect(),t}isSerialInRange(e,t,n,r=!1,s=!1){return(t-e&255)>=(n-e&255)&&(r||(e-n&255)>0)&&(s||(t-n&255)>0)}injectMissedMoveToBuffer(e){if(e.type=="MOVE")if(this.moveBuffer.length>0){var t=this.moveBuffer[0];if(this.moveBuffer.some(n=>n.type=="MOVE"&&n.serial==e.serial)||!this.isSerialInRange(this.lastSerial,t.serial,e.serial))return;e.serial==(t.serial-1&255)&&this.moveBuffer.unshift(e)}else this.isSerialInRange(this.lastSerial,this.serial,e.serial,!1,!0)&&this.moveBuffer.unshift(e)}async checkIfMoveMissed(e){let t=this.serial-this.lastSerial&255;if(t>0&&this.serial!=0){let n=this.moveBuffer[0],r=n?n.serial:this.serial+1&255;await this.requestMoveHistory(e,r,t+1)}}async handleStateEvent(e,t){var n=Ec(),r=[],s=new bv(t),a=s.getBitWord(0,8),o=s.getBitWord(8,8),l=s.getBitWord(16,8);if(a==85&&l>0)if(o==1){if(this.lastSerial!=-1){this.lastLocalTimestamp=n;let h=s.getBitWord(24,32,!0),u=this.serial=s.getBitWord(56,16,!0),d=s.getBitWord(72,2),p=[2,32,8,1,16,4].indexOf(s.getBitWord(74,6)),m="URFDLB".charAt(p)+" '".charAt(d);p>=0&&this.moveBuffer.push({type:"MOVE",serial:u,timestamp:n,localTimestamp:n,cubeTimestamp:h,face:p,direction:d,move:m.trim()}),r=await this.evictMoveBuffer(e)}}else if(o==6){let h=s.getBitWord(24,8),u=(l-1)*2;for(let d=0;d=0){let v="URFDLB".charAt(p)+" '".charAt(m);this.injectMissedMoveToBuffer({type:"MOVE",serial:h-d&255,timestamp:n,localTimestamp:null,cubeTimestamp:null,face:p,direction:m,move:v.trim()})}}r=await this.evictMoveBuffer()}else if(o==2){let h=this.serial=s.getBitWord(24,16,!0);this.lastSerial!=-1&&this.lastLocalTimestamp!=null&&n-this.lastLocalTimestamp>500&&await this.checkIfMoveMissed(e),this.lastSerial==-1&&(this.lastSerial=h);let u=[],d=[],p=[],m=[];for(let v=0;v<7;v++)u.push(s.getBitWord(40+v*3,3)),d.push(s.getBitWord(61+v*2,2));u.push(28-yr(u)),d.push((3-yr(d)%3)%3);for(let v=0;v<11;v++)p.push(s.getBitWord(77+v*4,4)),m.push(s.getBitWord(121+v,1));p.push(66-yr(p)),m.push((2-yr(m)%2)%2),r.push({type:"FACELETS",serial:h,timestamp:n,facelets:vv(u,d,p,m),state:{CP:u,CO:d,EP:p,EO:m}})}else if(o==7){let h=s.getBitWord(72,4),u=s.getBitWord(76,4),d=s.getBitWord(80,4),p=s.getBitWord(84,4),m="";for(var c=0;c<5;c++)m+=String.fromCharCode(s.getBitWord(c*8+32,8));r.push({type:"HARDWARE",timestamp:n,hardwareName:m,hardwareVersion:`${d}.${p}`,softwareVersion:`${h}.${u}`,gyroSupported:!1})}else if(o==16){let h=s.getBitWord(24,8);r.push({type:"BATTERY",timestamp:n,batteryLevel:Math.min(h,100)})}else o==17&&e.disconnect();return r}}class Xk{constructor(){this.serial=-1,this.lastSerial=-1,this.lastLocalTimestamp=null,this.moveBuffer=[],this.hwInfo={}}createCommandMessage(e){var t=new Uint8Array(20).fill(0);switch(e.type){case"REQUEST_FACELETS":t.set([221,4,0,237,0,0]);break;case"REQUEST_HARDWARE":this.hwInfo={},t.set([223,3,0,0,0]);break;case"REQUEST_BATTERY":t.set([221,4,0,239,0,0]);break;case"REQUEST_RESET":t.set([210,13,5,57,119,0,0,1,35,69,103,137,171,0,0,0]);break;default:t=void 0}return t}async requestMoveHistory(e,t,n){var r=new Uint8Array(20).fill(0);return t%2==0&&(t=t-1&255),n%2==1&&n++,n=Math.min(n,t+1),r.set([209,4,t,0,n,0]),e.sendCommandMessage(r).catch(()=>{})}async evictMoveBuffer(e){for(var t=[];this.moveBuffer.length>0;){let n=this.moveBuffer[0],r=this.lastSerial==-1?1:n.serial-this.lastSerial&255;if(r>1){e&&await this.requestMoveHistory(e,n.serial,r);break}else t.push(this.moveBuffer.shift()),this.lastSerial=n.serial}return e&&this.moveBuffer.length>16&&e.disconnect(),t}isSerialInRange(e,t,n,r=!1,s=!1){return(t-e&255)>=(n-e&255)&&(r||(e-n&255)>0)&&(s||(t-n&255)>0)}injectMissedMoveToBuffer(e){if(e.type=="MOVE")if(this.moveBuffer.length>0){var t=this.moveBuffer[0];if(this.moveBuffer.some(n=>n.type=="MOVE"&&n.serial==e.serial)||!this.isSerialInRange(this.lastSerial,t.serial,e.serial))return;e.serial==(t.serial-1&255)&&this.moveBuffer.unshift(e)}else this.isSerialInRange(this.lastSerial,this.serial,e.serial,!1,!0)&&this.moveBuffer.unshift(e)}async checkIfMoveMissed(e){let t=this.serial-this.lastSerial&255;if(t>0&&this.serial!=0){let n=this.moveBuffer[0],r=n?n.serial:this.serial+1&255;await this.requestMoveHistory(e,r,t+1)}}async handleStateEvent(e,t){var n=Ec(),r=[],s=new bv(t),a=s.getBitWord(0,8),o=s.getBitWord(8,8);if(a==1){if(this.lastSerial!=-1){this.lastLocalTimestamp=n;let c=s.getBitWord(16,32,!0),h=this.serial=s.getBitWord(48,16,!0),u=s.getBitWord(64,2),d=[2,32,8,1,16,4].indexOf(s.getBitWord(66,6)),p="URFDLB".charAt(d)+" '".charAt(u);d>=0&&this.moveBuffer.push({type:"MOVE",serial:h,timestamp:n,localTimestamp:n,cubeTimestamp:c,face:d,direction:u,move:p.trim()}),r=await this.evictMoveBuffer(e)}}else if(a==209){let c=s.getBitWord(16,8),h=(o-1)*2;for(let u=0;u=0){let m="URFDLB".charAt(d)+" '".charAt(p);this.injectMissedMoveToBuffer({type:"MOVE",serial:c-u&255,timestamp:n,localTimestamp:null,cubeTimestamp:null,face:d,direction:p,move:m.trim()})}}r=await this.evictMoveBuffer()}else if(a==237){let c=this.serial=s.getBitWord(16,16,!0);this.lastSerial!=-1&&this.lastLocalTimestamp!=null&&n-this.lastLocalTimestamp>500&&await this.checkIfMoveMissed(e),this.lastSerial==-1&&(this.lastSerial=c);let h=[],u=[],d=[],p=[];for(let m=0;m<7;m++)h.push(s.getBitWord(32+m*3,3)),u.push(s.getBitWord(53+m*2,2));h.push(28-yr(h)),u.push((3-yr(u)%3)%3);for(let m=0;m<11;m++)d.push(s.getBitWord(69+m*4,4)),p.push(s.getBitWord(113+m,1));d.push(66-yr(d)),p.push((2-yr(p)%2)%2),r.push({type:"FACELETS",serial:c,timestamp:n,facelets:vv(h,u,d,p),state:{CP:h,CO:u,EP:d,EO:p}})}else if(a>=250&&a<=254){switch(a){case 250:let c=s.getBitWord(24,16,!0),h=s.getBitWord(40,8),u=s.getBitWord(48,8);this.hwInfo[a]=`${c.toString().padStart(4,"0")}-${h.toString().padStart(2,"0")}-${u.toString().padStart(2,"0")}`;break;case 252:this.hwInfo[a]="";for(var l=0;l>15)*2)*(h&32767)/32767,y:(1-(u>>15)*2)*(u&32767)/32767,z:(1-(d>>15)*2)*(d&32767)/32767,w:(1-(c>>15)*2)*(c&32767)/32767},velocity:{x:(1-(p>>3)*2)*(p&7),y:(1-(m>>3)*2)*(m&7),z:(1-(v>>3)*2)*(v&7)}})}else if(a==239){let c=s.getBitWord(8+o*8,8);r.push({type:"BATTERY",timestamp:n,batteryLevel:Math.min(c,100)})}else a==234&&e.disconnect();return r}}function jk(i){if(i instanceof DataView)return new DataView(i.buffer.slice(2,11));for(var e of WM)if(i.has(e))return new DataView(i.get(e).buffer.slice(0,9))}function Yk(i){var e=[],t=jk(i);if(t&&t.byteLength>=6)for(let n=1;n<=6;n++)e.push(t.getUint8(t.byteLength-n).toString(16).toUpperCase().padStart(2,"0"));return e.join(":")}async function $k(i){return new Promise(e=>{typeof i.watchAdvertisements!="function"&&e(null);var t=new AbortController,n=s=>{i.removeEventListener("advertisementreceived",n),t.abort();var a=Yk(s.manufacturerData);e(a||null)},r=()=>{i.removeEventListener("advertisementreceived",n),t.abort(),e(null)};i.addEventListener("advertisementreceived",n),i.watchAdvertisements({signal:t.signal}).catch(r),setTimeout(r,1e4)})}async function Kk(i){var o;var e=await navigator.bluetooth.requestDevice({filters:[{namePrefix:"GAN"},{namePrefix:"MG"},{namePrefix:"AiCube"}],optionalServices:[y2,_2,L2],optionalManufacturerData:WM}),t=i&&await i(e,!1)||await $k(e)||i&&await i(e,!0);if(!t)throw new Error("Unable to determine cube MAC address, connection is not possible!");e.mac=t;var n=new Uint8Array(e.mac.split(/[:-\s]+/).map(l=>parseInt(l,16)).reverse()),r=await e.gatt.connect(),s=await r.getPrimaryServices(),a=null;for(let l of s){let c=l.uuid.toLowerCase();if(c==y2){let h=await l.getCharacteristic(Ik),u=await l.getCharacteristic(Bk),d=(o=e.name)!=null&&o.startsWith("AiCube")?Ef[1]:Ef[0],p=new Rv(new Uint8Array(d.key),new Uint8Array(d.iv),n),m=new Zk;a=await Dh.create(e,h,u,p,m);break}else if(c==_2){let h=await l.getCharacteristic(Ok),u=await l.getCharacteristic(kk),d=Ef[0],p=new Vk(new Uint8Array(d.key),new Uint8Array(d.iv),n),m=new qk;a=await Dh.create(e,h,u,p,m);break}else if(c==L2){let h=await l.getCharacteristic(Nk),u=await l.getCharacteristic(zk),d=Ef[0],p=new Hk(new Uint8Array(d.key),new Uint8Array(d.iv),n),m=new Xk;a=await Dh.create(e,h,u,p,m);break}}if(!a)throw new Error("Can't find target BLE services - wrong or unsupported cube device model");return a}var ZM;na.kpuzzle().then(i=>ZM=i);const qM="UF UR UB UL DF DR DB DL FR FL BR BL".split(" "),XM="UFR URB UBL ULF DRF DFL DLB DBR".split(" "),Jk="U L F R B D".split(" "),Qk=[[1,2,0],[0,2,0],[1,1,0],[0,3,0],[2,0,0],[0,1,0],[1,3,0],[0,0,0],[1,0,0],[1,0,2],[0,1,1],[1,1,1],[0,8,1],[2,3,0],[0,10,1],[1,4,1],[0,5,1],[1,7,2],[1,3,2],[0,0,1],[1,0,1],[0,9,0],[2,2,0],[0,8,0],[1,5,1],[0,4,1],[1,4,2],[1,5,0],[0,4,0],[1,4,0],[0,7,0],[2,5,0],[0,5,0],[1,6,0],[0,6,0],[1,7,0],[1,2,2],[0,3,1],[1,3,1],[0,11,1],[2,1,0],[0,9,1],[1,6,1],[0,7,1],[1,5,2],[1,1,2],[0,2,1],[1,2,1],[0,10,0],[2,4,0],[0,11,0],[1,7,1],[0,6,1],[1,6,2]],e6=[[0,21,15],[5,13,47],[7,45,39],[2,37,23],[29,10,16],[31,18,32],[26,34,40],[24,42,8]],t6=[[1,22],[3,14],[6,46],[4,38],[30,17],[27,9],[25,41],[28,33],[19,12],[20,35],[44,11],[43,36]],_0="URFDLB",Bp={};qM.forEach((i,e)=>{for(let t=0;t<2;t++)Bp[Op(i,t)]={piece:e,orientation:t}});XM.forEach((i,e)=>{for(let t=0;t<3;t++)Bp[Op(i,t)]={piece:e,orientation:t}});function Op(i,e){return i.slice(e)+i.slice(0,e)}function n6(i){const e=[[],[]];for(let t=0;t<6;t++)if(i.patternData.CENTERS.pieces[t]!==t)throw new Error("non-oriented puzzles are not supported");for(let t=0;t<12;t++)e[0].push(Op(qM[i.patternData.EDGES.pieces[t]],i.patternData.EDGES.orientation[t]));for(let t=0;t<8;t++)e[1].push(Op(XM[i.patternData.CORNERS.pieces[t]],i.patternData.CORNERS.orientation[t]));return e.push(Jk),e}function kp(i){const e=n6(i);return Qk.map(([t,n,r])=>e[t][n][r]).join("")}function lg(i){var n;const e=[];(n=i.match(/.{9}/g))==null||n.forEach(r=>{r.split("").reverse().forEach((s,a)=>{a!=4&&e.push(_0.indexOf(s))})});const t={CORNERS:{pieces:[],orientation:[]},EDGES:{pieces:[],orientation:[]},CENTERS:{pieces:[0,1,2,3,4,5],orientation:[0,0,0,0,0,0],orientationMod:[1,1,1,1,1,1]}};for(const r of e6){const s=Bp[r.map(a=>_0[e[a]]).join("")];t.CORNERS.pieces.push(s.piece),t.CORNERS.orientation.push(s.orientation)}for(const r of t6){const s=Bp[r.map(a=>_0[e[a]]).join("")];t.EDGES.pieces.push(s.piece),t.EDGES.orientation.push(s.orientation)}return new Lc(ZM,t)}/*! * @kurkle/color v0.3.2 * https://github.com/kurkle/color#readme * (c) 2023 Jukka Kurkela @@ -4485,10 +4485,10 @@ Your old categories which did not include subsets have been prefixed with "old-" `)}),Pc(i)}function Pc(i){const e=JSON.parse(localStorage.getItem("savedAlgorithms")||"{}"),t=I("#alg-cases");if(t.empty(),i&&e[i]){let n=qw(i),r="3D";i.toLowerCase().includes("ll")&&(r="experimental-2D-LL"),I("#subset-checkboxes input:checked").map(function(){return I(this).val()}).get().forEach(a=>{const o=e[i].find(l=>l.subset===a);if(o){let l=0;o.algorithms.forEach(c=>{c.algorithm=Dc(c.algorithm);let h=zr(c.algorithm),u=l%2==0?"bg-gray-400":"bg-gray-50",d=l%2==0?"bg-gray-800":"bg-gray-600";const p=jw(h);t.append(`
-
${c.name}
+
${c.name}
-
- `),l++})}})}}document.addEventListener("click",i=>{const e=i.target;if(e.closest('button[id^="bookmark-"]')){const t=e.closest("button"),n=t.id.replace("bookmark-","");let r=Ic(n);r=(r+1)%3,localStorage.setItem("Learned-"+n,r.toString()),t.innerHTML=`${Xw(r)}`}});function zr(i){let e=i==null?void 0:i.trim().replace(/\s+/g,"-").replace(/[']/g,"p").replace(/[(]/g,"o").replace(/[)]/g,"c");return(e==null||e.length==0)&&(e="default-alg-id"),e}function Xw(i){const e='',t='',n='';return i===1?n:i===2?t:e}function Ic(i){const e=localStorage.getItem("Learned-"+i);return e?Number(e):0}function jw(i){const e=localStorage.getItem("Best-"+i);return e?Number(e):null}function Nv(i){if(!i)return"-";const e=ac(i);return`${e.seconds.toString(10)}.${e.milliseconds.toString(10).padStart(3,"0")}`}function Yw(i){const e=localStorage.getItem(`LastTimes-${i}`);if(!e)return null;const t=e.split(",").slice(-5).map(n=>Number(n.trim()));return t.length==5?t.reduce((n,r)=>n+r,0)/5:null}function zv(i){if(!i)return"-";const e=ac(i);return`${e.seconds.toString(10)}.${e.milliseconds.toString(10).padStart(3,"0")}`}function k0(i,e){if(i.length!==e.length)return!1;for(let t=0;ta===t?"rgba(75, 192, 192, 0.2)":"rgba(54, 162, 235, 0.2)"),r=i.map(a=>a===t?"rgba(75, 192, 192, 1)":"rgba(54, 162, 235, 1)"),s=i.map(a=>a/1e3);N0=new ts(e,{type:"bar",data:{labels:i.map((a,o)=>`${o+1}`),datasets:[{label:"Seconds",data:s,backgroundColor:n,borderColor:r,borderWidth:1}]},options:{responsive:!0,animation:!1,maintainAspectRatio:!0,aspectRatio:1,plugins:{legend:{display:!1},title:{display:!1}},scales:{y:{beginAtZero:!0}}}})}}function E9(i){return qS(Qe.fromString(i))}function $w(){const i=I("#times-display"),e=I("#graph-display");i.is(":visible")?(i.hide(),e.css("display","flex").show(),I("#toggle-display").html('')):(i.show(),e.hide(),I("#toggle-display").html(''))}I("#toggle-display").on("click",$w);I("#alg-name-display").on("click",$w);function T9(i){const e=document.getElementById("statsGraph");if(z0&&z0.destroy(),e){const t=i.map(s=>s/1e3),n=Yy(t,5,3),r=Yy(t,12,10);z0=new ts(e,{type:"line",data:{labels:i.map((s,a)=>`${a+1}`),datasets:[{label:"Single",data:t,backgroundColor:"rgba(54, 162, 235, 1)",borderColor:"rgba(54, 162, 235, 1)",borderWidth:1,fill:{target:"origin",above:"rgba(54, 162, 235, 0.2)",below:"rgba(54, 162, 235, 0.1)"}},{label:"Average of 5",data:n,backgroundColor:"rgba(255, 159, 64, 1)",borderColor:"rgba(255, 159, 64, 1)",borderWidth:1,fill:!1},{label:"Average of 12",data:r,backgroundColor:"rgba(75, 192, 192, 1)",borderColor:"rgba(75, 192, 192, 1)",borderWidth:1,fill:!1}]},options:{elements:{point:{pointStyle:"circle"}},animation:!1,responsive:!0,maintainAspectRatio:!0,aspectRatio:1.25,plugins:{legend:{display:!0},title:{display:!1}},scales:{y:{beginAtZero:!0}}}})}}function Yy(i,e,t){const n=[];for(let r=0;rc-h).slice(1,-1).reduce((c,h)=>c+h,0)/t;n.push(l)}return n}nR.initFull();const Vv="UUUUUUUUURRRRRRRRRFFFFFFFFFDDDDDDDDDLLLLLLLLLBBBBBBBBB";var dn=new Zc({puzzle:"3x3x3",visualization:"PG3D",alg:"",experimentalSetupAnchor:"start",background:"none",controlPanel:"none",viewerLink:"none",hintFacelets:"floating",experimentalDragInput:"auto",cameraLatitude:0,cameraLongitude:0,tempoScale:5,experimentalStickering:"full"}),Ia=new Zc({puzzle:"3x3x3",visualization:"PG3D",alg:"",experimentalSetupAnchor:"start",background:"none",controlPanel:"none",hintFacelets:"none",experimentalDragInput:"none",cameraLatitude:0,cameraLongitude:0,cameraLatitudeLimit:0,tempoScale:5});I("#cube").append(dn);var Tn,bn=[],vR=[],V0,Gf;const F9=new gi().setFromEuler(new ki(15*Math.PI/180,-20*Math.PI/180,0));var Kw=new gi().setFromEuler(new ki(30*Math.PI/180,-30*Math.PI/180,0));async function pg(){if(Fu){if(!V0||!Gf||Zh){var i=await dn.experimentalCurrentVantages();Gf=[...i][0],V0=await Gf.scene.scene(),Zh&&(Zh=!1)}V0.quaternion.slerp(Kw,.25),Gf.render(),requestAnimationFrame(pg)}}requestAnimationFrame(pg);var xp;async function C9(i){if(i.type=="GYRO"){let{x:e,y:t,z:n,w:r}=i.quaternion,s=new gi(e,n,-t,r).normalize();if(xp||(xp=s.clone().conjugate()),Kw.copy(s.premultiply(xp).premultiply(F9)),I("#quaternion").val(`x: ${e.toFixed(3)}, y: ${t.toFixed(3)}, z: ${n.toFixed(3)}, w: ${r.toFixed(3)}`),i.velocity){let{x:a,y:o,z:l}=i.velocity;I("#velocity").val(`x: ${a}, y: ${o}, z: ${l}`)}}}var cn=[],Hv=[],rc=[],Yn=[],Cr=[],bR=[],$n=0,Wr=!0,ul=!1;function Rd(){$n=-1,Yn=[],vd()}I("#train-alg").on("click",()=>{var e,t,n;const i=(e=I("#alg-input").val())==null?void 0:e.toString().trim();i?(Wr=!1,cn=Dc(i).split(/\s+/),SR=((t=qt[0])==null?void 0:t.name)||"",I("#alg-display").text(cn.join(" ")),I("#alg-display-container").show(),I("#timer").show(),I("#alg-input").hide(),I("#save-container").hide(),vd(),ul&&!Qo&&(I("#alg-scramble").hide(),ul=!1),_R=!1,Cr=[],bR=[],Jw(),Ba("READY"),bd(),rc=[],Qo&&I("#scramble-to").trigger("click"),I("#toggle-display").css("display","inline-flex"),I("#left-side-inner").show(),I("#alg-stats").css("display","flex")):(I("#alg-input").show(),I("#alg-stats").hide(),I("#left-side-inner").hide(),(n=I("#alg-input").get(0))==null||n.focus()),Rd(),I("#alg-display").text()!==""&&mg()});function Jw(){Qw(),jp?jp=!1:Eu=Cr.length===0?_a:Cr[Cr.length-1],cn.forEach((i,e)=>{i=i.replace(/[()]/g,""),e===0?Cr[e]=Eu.applyMove(i):Cr[e]=bR[e-1].applyMove(i),bR[e]=Cr[e],Cr[e]=v9(Cr[e])})}function Qw(){var i;if(Hv=[...cn],Jp&&rc.length===0){let e=["U","U'","U2",""],t=e[Math.floor(Math.random()*e.length)];if(t.length>0){let n=lg(Vv),r=Qe.fromString("U "+cn.join(" ")),s=n.applyAlg(r),a=Qe.fromString(cn.join(" ")+" U'"),o=n.applyAlg(a),l=Qe.fromString("U2 "+cn.join(" ")),c=n.applyAlg(l),h=Qe.fromString(cn.join(" ")+" U2'"),u=n.applyAlg(h),d=(i=I("#category-select").val())==null?void 0:i.toString().toLowerCase(),p=d==null?void 0:d.includes("oll"),m=!s.isIdentical(o)&&!c.isIdentical(u);if(d!=null&&d.includes("pll")||d!=null&&d.includes("zbll")){let v=e[Math.floor(Math.random()*e.length)];v.length>0&&cn.push(v)}(m&&!p||p&&!w9(cn.join(" ")))&&(cn.unshift(t),cn=Qe.fromString(cn.join(" ")).experimentalSimplify({cancel:!0,puzzleLoader:na}).toString().split(/\s+/),I("#alg-display").text(cn.join(" ")))}}Jp&&rc.length>0&&(cn=[...rc],I("#alg-display").text(cn.join(" ")),rc=[]),dn.alg=Qe.fromString(cn.join(" ")).invert().toString()}var UR;let yR=!1,_R=!1;function D9(i){i.length>0?(I("#alg-fix").html(i),clearTimeout(UR),UR=setTimeout(function(){if(I("#alg-fix").show(),yR||(Wv("red",300),yR=!0),qt.length>0&&(i3&&!Ii.includes(qt[0])&&Ii.push(qt[0]),qt[0].algorithm)){let e=zr(qt[0].algorithm);if(e&&!_R){I("#"+e).removeClass("bg-gray-50 bg-gray-400 dark:bg-gray-600 dark:bg-gray-800"),I("#"+e).addClass("bg-red-400 dark:bg-red-400");let t=parseInt(I("#"+e).data("failed"))||0;I("#"+e).data("failed",t+1),_R=!0}}},300)):vd()}function vd(){clearTimeout(UR),I("#alg-fix").hide(),I("#alg-fix").html(""),yR=!1}function mg(){let i="",e="",t="",n=[],r="";if(Yn.length>0){for(let c=0;c{var R,L;e=Ys.checked?"white":"black",h<=$n?e="green":h<1+$n+n.length&&(e="red"),h===$n+1&&e!=="red"&&(e="white");let u=c.replace(/[()']/g,"").trim();if(h===0&&$n===-1&&Jp&&n.length===1&&n[0][0]==="U"&&u.length>0&&u[0].charAt(0)==="U"&&(e="blue",l=!0),h===$n+1&&u.length>1){const _=n.length===1,S=n.length===2,D=n.length===3,T=/[MESudlrbfxyz]/.test(cn.slice(0,$n+1).join(" "));(_&&n[0][0]===u[0]||_&&T||S&&"MES".includes(u[0])||D&&"MES".includes(u[0]))&&(e="blue",a=!0)}let d=Xp(n[0]),p=(R=cn[h])==null?void 0:R.replace(/[()']/g,"");if(h===$n+1&&n.length===1){let _=b9(d==null?void 0:d.replace(/[()'2]/g,"")),S=(L=cn[h+1])==null?void 0:L.replace(/[()]/g,"");(d===S||(d==null?void 0:d.charAt(0))===(S==null?void 0:S.charAt(0))&&(S==null?void 0:S.charAt(1))=="2")&&(_===p||_===(p==null?void 0:p.charAt(0))&&(p==null?void 0:p.charAt(1))=="2")&&(e="white",o=!0)}h===$n+2&&o&&(e=c.endsWith("2")&&d!=p?"blue":"green"),(t==="blue"||t!=="blue"&&e!=="blue"&&a)&&(e=Ys.checked?"white":"black");let m="",v="",b="";for(let _ of c)_==="("?v+=`${_}`:_===")"?b+=`${_}`:m+=`${_}`;h===$n+1?i+=`${v}${m}${b} `:i+=`${v}${m}${b} `,t=e}),I("#alg-display").html(i),(a||l||o)&&(r=""),r.length>0?D9(r):vd(),$n===cn.length-1&&($n=0)}let jp=!1,$y="",Zf=!1;async function P9(i){if(i.type==="MOVE"){if(dn.experimentalAddMove(i.move,{cancel:!1}),Ia.experimentalAddMove(i.move,{cancel:!1}),ul){const n=await Ia.experimentalModel.currentPattern.get();let r=n3(cn.join(" "),n);const s=I("#alg-scramble").text(),a=r.split(" "),o=s.split(" "),l=o[0],c=l.charAt(1)==="2";a.length>=o.length&&a.length>2&&(i.move===l||i.move.charAt(0)===l.charAt(0)&&c)&&(r=o.slice(1).join(" "),c&&(r=i.move+" "+r)),a.length===o.length-1&&a.length>2&&i.move===l&&(r=o.slice(1).join(" ")),I("#alg-scramble").text(r),r.length===0&&(I("#alg-scramble").hide(),ul=!1,Eu=n,jp=!0,I("#train-alg").trigger("click"));return}if(_r==="READY"&&Ba("RUNNING"),_r==="STOPPED"&&Ba("RUNNING"),bn.push(i),_r==="RUNNING"&&vR.push(i),bn.length>256&&(bn=bn.slice(-256)),bn.length>10){var e=Gk(bn);I("#skew").val(e+"%")}if(kp(_a)===$y&&!Zf&&(_a=await Ia.experimentalModel.currentPattern.get(),Zf=!0),$y=kp(_a),Wr){I("#alg-input").val(function(n,r){return Qe.fromString(r+" "+bn[bn.length-1].move).experimentalSimplify({cancel:!0,puzzleLoader:na}).toString()});return}var t=!1;Cr.forEach((n,r)=>{if(_a.applyMove(i.move).isIdentical(n)||Zf&&_a.isIdentical(n)){if(Zf=!1,$n=r,t=!0,Yn=[],$n===cn.length-1){Ba("STOPPED"),Rd(),Jw(),$n=cn.length-1,e3(),Eu=n,jp=!0,qt.length>0&&I("#alg-input").val(qt[0].algorithm),I("#train-alg").trigger("click");return}return}}),t||(Yn.push(i.move),$n===0&&Yn.length===1&&bn[bn.length-1].move===Xp(cn[$n].replace(/[()]/g,""))?($n--,Yn.pop()):bn[bn.length-1].move===Xp(Yn[Yn.length-2])?(Yn.pop(),Yn.pop()):Yn.length>3&&bn.length>3&&bn[bn.length-1].move===bn[bn.length-2].move&&bn[bn.length-2].move===bn[bn.length-3].move&&bn[bn.length-3].move===bn[bn.length-4].move&&(Yn.pop(),Yn.pop(),Yn.pop(),Yn.pop())),mg()}}function Wv(i,e){const t=document.getElementById("flashing-indicator");t&&$p&&(t.style.backgroundColor=i,t.classList.remove("hidden"),setTimeout(()=>{t.classList.add("hidden")},e))}function e3(){if(Wv("green",200),qt.length+Ii.length>1){const i=qt.shift();qt.length===0&&(qt=[...Ii],Ii=[],Pu&&qt.sort((e,t)=>t.bestTime-e.bestTime)),Kp&&qt.sort(()=>Math.random()-.5),i&&Ii.push(i)}}var Ky=!1;async function I9(i){if(i.type=="FACELETS"&&!Ky){if(i.facelets!=Vv){var e=lg(i.facelets),t=await kM(e),n=t.invert();Ia.alg=n,dn.alg=n}else Ia.alg="",dn.alg="";Ky=!0,console.log("Initial cube state is applied successfully",i.facelets)}}function B9(i){i.type=="GYRO"?C9(i):i.type=="MOVE"?P9(i):i.type=="FACELETS"?I9(i):i.type=="HARDWARE"?(I("#hardwareName").val(i.hardwareName||"- n/a -"),I("#hardwareVersion").val(i.hardwareVersion||"- n/a -"),I("#softwareVersion").val(i.softwareVersion||"- n/a -"),I("#productDate").val(i.productDate||"- n/a -"),I("#gyroSupported").val(i.gyroSupported?"YES":"NO")):i.type=="BATTERY"?(I("#batteryLevel").val(i.batteryLevel+"%"),I("#bluetooth-indicator").hide(),I("#battery-indicator").attr("title",i.batteryLevel+"%"),i.batteryLevel>=75?(I("#battery-indicator").html(''),I("#battery-indicator").css("color","green")):i.batteryLevel>=50?(I("#battery-indicator").html(''),I("#battery-indicator").css("color","yellow")):i.batteryLevel>=20?(I("#battery-indicator").html(''),I("#battery-indicator").css("color","orange")):i.batteryLevel<20&&(I("#battery-indicator").html(''),I("#battery-indicator").css("color","red"))):i.type=="DISCONNECT"&&t3()}const O9=async(i,e)=>{const t=localStorage.getItem("lastConnectedDeviceMAC")||"";return e?prompt(`Unable to determine cube MAC address! + `),l++})}})}}document.addEventListener("click",i=>{const e=i.target;if(e.closest('button[id^="bookmark-"]')){const t=e.closest("button"),n=t.id.replace("bookmark-","");let r=Ic(n);r=(r+1)%3,localStorage.setItem("Learned-"+n,r.toString()),t.innerHTML=`${Xw(r)}`}});function zr(i){let e=i==null?void 0:i.trim().replace(/\s+/g,"-").replace(/[']/g,"p").replace(/[(]/g,"o").replace(/[)]/g,"c");return(e==null||e.length==0)&&(e="default-alg-id"),e}function Xw(i){const e='',t='',n='';return i===1?n:i===2?t:e}function Ic(i){const e=localStorage.getItem("Learned-"+i);return e?Number(e):0}function jw(i){const e=localStorage.getItem("Best-"+i);return e?Number(e):null}function Nv(i){if(!i)return"-";const e=ac(i);return`${e.seconds.toString(10)}.${e.milliseconds.toString(10).padStart(3,"0")}`}function Yw(i){const e=localStorage.getItem(`LastTimes-${i}`);if(!e)return null;const t=e.split(",").slice(-5).map(n=>Number(n.trim()));return t.length==5?t.reduce((n,r)=>n+r,0)/5:null}function zv(i){if(!i)return"-";const e=ac(i);return`${e.seconds.toString(10)}.${e.milliseconds.toString(10).padStart(3,"0")}`}function k0(i,e){if(i.length!==e.length)return!1;for(let t=0;ta===t?"rgba(75, 192, 192, 0.2)":"rgba(54, 162, 235, 0.2)"),r=i.map(a=>a===t?"rgba(75, 192, 192, 1)":"rgba(54, 162, 235, 1)"),s=i.map(a=>a/1e3);N0=new ts(e,{type:"bar",data:{labels:i.map((a,o)=>`${o+1}`),datasets:[{label:"Seconds",data:s,backgroundColor:n,borderColor:r,borderWidth:1}]},options:{responsive:!0,animation:!1,maintainAspectRatio:!0,aspectRatio:1,plugins:{legend:{display:!1},title:{display:!1}},scales:{y:{beginAtZero:!0}}}})}}function E9(i){return qS(Qe.fromString(i))}function $w(){const i=I("#times-display"),e=I("#graph-display");i.is(":visible")?(i.hide(),e.css("display","flex").show(),I("#toggle-display").html('')):(i.show(),e.hide(),I("#toggle-display").html(''))}I("#toggle-display").on("click",$w);I("#alg-name-display").on("click",$w);function T9(i){const e=document.getElementById("statsGraph");if(z0&&z0.destroy(),e){const t=i.map(s=>s/1e3),n=Yy(t,5,3),r=Yy(t,12,10);z0=new ts(e,{type:"line",data:{labels:i.map((s,a)=>`${a+1}`),datasets:[{label:"Single",data:t,backgroundColor:"rgba(54, 162, 235, 1)",borderColor:"rgba(54, 162, 235, 1)",borderWidth:1,fill:{target:"origin",above:"rgba(54, 162, 235, 0.2)",below:"rgba(54, 162, 235, 0.1)"}},{label:"Ao5",data:n,backgroundColor:"rgba(255, 159, 64, 1)",borderColor:"rgba(255, 159, 64, 1)",borderWidth:1,fill:!1},{label:"Ao12",data:r,backgroundColor:"rgba(75, 192, 192, 1)",borderColor:"rgba(75, 192, 192, 1)",borderWidth:1,fill:!1}]},options:{elements:{point:{pointStyle:"circle"}},animation:!1,responsive:!0,maintainAspectRatio:!1,aspectRatio:1.25,plugins:{legend:{display:!0},title:{display:!1}},scales:{y:{beginAtZero:!0}}}})}}function Yy(i,e,t){const n=[];for(let r=0;rc-h).slice(1,-1).reduce((c,h)=>c+h,0)/t;n.push(l)}return n}nR.initFull();const Vv="UUUUUUUUURRRRRRRRRFFFFFFFFFDDDDDDDDDLLLLLLLLLBBBBBBBBB";var dn=new Zc({puzzle:"3x3x3",visualization:"PG3D",alg:"",experimentalSetupAnchor:"start",background:"none",controlPanel:"none",viewerLink:"none",hintFacelets:"floating",experimentalDragInput:"auto",cameraLatitude:0,cameraLongitude:0,tempoScale:5,experimentalStickering:"full"}),Ia=new Zc({puzzle:"3x3x3",visualization:"PG3D",alg:"",experimentalSetupAnchor:"start",background:"none",controlPanel:"none",hintFacelets:"none",experimentalDragInput:"none",cameraLatitude:0,cameraLongitude:0,cameraLatitudeLimit:0,tempoScale:5});I("#cube").append(dn);var Tn,bn=[],vR=[],V0,Gf;const F9=new gi().setFromEuler(new ki(15*Math.PI/180,-20*Math.PI/180,0));var Kw=new gi().setFromEuler(new ki(30*Math.PI/180,-30*Math.PI/180,0));async function pg(){if(Fu){if(!V0||!Gf||Zh){var i=await dn.experimentalCurrentVantages();Gf=[...i][0],V0=await Gf.scene.scene(),Zh&&(Zh=!1)}V0.quaternion.slerp(Kw,.25),Gf.render(),requestAnimationFrame(pg)}}requestAnimationFrame(pg);var xp;async function C9(i){if(i.type=="GYRO"){let{x:e,y:t,z:n,w:r}=i.quaternion,s=new gi(e,n,-t,r).normalize();if(xp||(xp=s.clone().conjugate()),Kw.copy(s.premultiply(xp).premultiply(F9)),I("#quaternion").val(`x: ${e.toFixed(3)}, y: ${t.toFixed(3)}, z: ${n.toFixed(3)}, w: ${r.toFixed(3)}`),i.velocity){let{x:a,y:o,z:l}=i.velocity;I("#velocity").val(`x: ${a}, y: ${o}, z: ${l}`)}}}var cn=[],Hv=[],rc=[],Yn=[],Cr=[],bR=[],$n=0,Wr=!0,ul=!1;function Rd(){$n=-1,Yn=[],vd()}I("#train-alg").on("click",()=>{var e,t,n;const i=(e=I("#alg-input").val())==null?void 0:e.toString().trim();i?(Wr=!1,cn=Dc(i).split(/\s+/),SR=((t=qt[0])==null?void 0:t.name)||"",I("#alg-display").text(cn.join(" ")),I("#alg-display-container").show(),I("#timer").show(),I("#alg-input").hide(),I("#save-container").hide(),vd(),ul&&!Qo&&(I("#alg-scramble").hide(),ul=!1),_R=!1,Cr=[],bR=[],Jw(),Ba("READY"),bd(),rc=[],Qo&&I("#scramble-to").trigger("click"),I("#toggle-display").css("display","inline-flex"),I("#left-side-inner").show(),I("#alg-stats").css("display","flex")):(I("#alg-input").show(),I("#alg-stats").hide(),I("#left-side-inner").hide(),(n=I("#alg-input").get(0))==null||n.focus()),Rd(),I("#alg-display").text()!==""&&mg()});function Jw(){Qw(),jp?jp=!1:Eu=Cr.length===0?_a:Cr[Cr.length-1],cn.forEach((i,e)=>{i=i.replace(/[()]/g,""),e===0?Cr[e]=Eu.applyMove(i):Cr[e]=bR[e-1].applyMove(i),bR[e]=Cr[e],Cr[e]=v9(Cr[e])})}function Qw(){var i;if(Hv=[...cn],Jp&&rc.length===0){let e=["U","U'","U2",""],t=e[Math.floor(Math.random()*e.length)];if(t.length>0){let n=lg(Vv),r=Qe.fromString("U "+cn.join(" ")),s=n.applyAlg(r),a=Qe.fromString(cn.join(" ")+" U'"),o=n.applyAlg(a),l=Qe.fromString("U2 "+cn.join(" ")),c=n.applyAlg(l),h=Qe.fromString(cn.join(" ")+" U2'"),u=n.applyAlg(h),d=(i=I("#category-select").val())==null?void 0:i.toString().toLowerCase(),p=d==null?void 0:d.includes("oll"),m=!s.isIdentical(o)&&!c.isIdentical(u);if(d!=null&&d.includes("pll")||d!=null&&d.includes("zbll")){let v=e[Math.floor(Math.random()*e.length)];v.length>0&&cn.push(v)}(m&&!p||p&&!w9(cn.join(" ")))&&(cn.unshift(t),cn=Qe.fromString(cn.join(" ")).experimentalSimplify({cancel:!0,puzzleLoader:na}).toString().split(/\s+/),I("#alg-display").text(cn.join(" ")))}}Jp&&rc.length>0&&(cn=[...rc],I("#alg-display").text(cn.join(" ")),rc=[]),dn.alg=Qe.fromString(cn.join(" ")).invert().toString()}var UR;let yR=!1,_R=!1;function D9(i){i.length>0?(I("#alg-fix").html(i),clearTimeout(UR),UR=setTimeout(function(){if(I("#alg-fix").show(),yR||(Wv("red",300),yR=!0),qt.length>0&&(i3&&!Ii.includes(qt[0])&&Ii.push(qt[0]),qt[0].algorithm)){let e=zr(qt[0].algorithm);if(e&&!_R){I("#"+e).removeClass("bg-gray-50 bg-gray-400 dark:bg-gray-600 dark:bg-gray-800"),I("#"+e).addClass("bg-red-400 dark:bg-red-400");let t=parseInt(I("#"+e).data("failed"))||0;I("#"+e).data("failed",t+1),_R=!0}}},300)):vd()}function vd(){clearTimeout(UR),I("#alg-fix").hide(),I("#alg-fix").html(""),yR=!1}function mg(){let i="",e="",t="",n=[],r="";if(Yn.length>0){for(let c=0;c{var R,L;e=Ys.checked?"white":"black",h<=$n?e="green":h<1+$n+n.length&&(e="red"),h===$n+1&&e!=="red"&&(e="white");let u=c.replace(/[()']/g,"").trim();if(h===0&&$n===-1&&Jp&&n.length===1&&n[0][0]==="U"&&u.length>0&&u[0].charAt(0)==="U"&&(e="blue",l=!0),h===$n+1&&u.length>1){const _=n.length===1,S=n.length===2,D=n.length===3,T=/[MESudlrbfxyz]/.test(cn.slice(0,$n+1).join(" "));(_&&n[0][0]===u[0]||_&&T||S&&"MES".includes(u[0])||D&&"MES".includes(u[0]))&&(e="blue",a=!0)}let d=Xp(n[0]),p=(R=cn[h])==null?void 0:R.replace(/[()']/g,"");if(h===$n+1&&n.length===1){let _=b9(d==null?void 0:d.replace(/[()'2]/g,"")),S=(L=cn[h+1])==null?void 0:L.replace(/[()]/g,"");(d===S||(d==null?void 0:d.charAt(0))===(S==null?void 0:S.charAt(0))&&(S==null?void 0:S.charAt(1))=="2")&&(_===p||_===(p==null?void 0:p.charAt(0))&&(p==null?void 0:p.charAt(1))=="2")&&(e="white",o=!0)}h===$n+2&&o&&(e=c.endsWith("2")&&d!=p?"blue":"green"),(t==="blue"||t!=="blue"&&e!=="blue"&&a)&&(e=Ys.checked?"white":"black");let m="",v="",b="";for(let _ of c)_==="("?v+=`${_}`:_===")"?b+=`${_}`:m+=`${_}`;h===$n+1?i+=`${v}${m}${b} `:i+=`${v}${m}${b} `,t=e}),I("#alg-display").html(i),(a||l||o)&&(r=""),r.length>0?D9(r):vd(),$n===cn.length-1&&($n=0)}let jp=!1,$y="",Zf=!1;async function P9(i){if(i.type==="MOVE"){if(dn.experimentalAddMove(i.move,{cancel:!1}),Ia.experimentalAddMove(i.move,{cancel:!1}),ul){const n=await Ia.experimentalModel.currentPattern.get();let r=n3(cn.join(" "),n);const s=I("#alg-scramble").text(),a=r.split(" "),o=s.split(" "),l=o[0],c=l.charAt(1)==="2";a.length>=o.length&&a.length>2&&(i.move===l||i.move.charAt(0)===l.charAt(0)&&c)&&(r=o.slice(1).join(" "),c&&(r=i.move+" "+r)),a.length===o.length-1&&a.length>2&&i.move===l&&(r=o.slice(1).join(" ")),I("#alg-scramble").text(r),r.length===0&&(I("#alg-scramble").hide(),ul=!1,Eu=n,jp=!0,I("#train-alg").trigger("click"));return}if(_r==="READY"&&Ba("RUNNING"),_r==="STOPPED"&&Ba("RUNNING"),bn.push(i),_r==="RUNNING"&&vR.push(i),bn.length>256&&(bn=bn.slice(-256)),bn.length>10){var e=Gk(bn);I("#skew").val(e+"%")}if(kp(_a)===$y&&!Zf&&(_a=await Ia.experimentalModel.currentPattern.get(),Zf=!0),$y=kp(_a),Wr){I("#alg-input").val(function(n,r){return Qe.fromString(r+" "+bn[bn.length-1].move).experimentalSimplify({cancel:!0,puzzleLoader:na}).toString()});return}var t=!1;Cr.forEach((n,r)=>{if(_a.applyMove(i.move).isIdentical(n)||Zf&&_a.isIdentical(n)){if(Zf=!1,$n=r,t=!0,Yn=[],$n===cn.length-1){Ba("STOPPED"),Rd(),Jw(),$n=cn.length-1,e3(),Eu=n,jp=!0,qt.length>0&&I("#alg-input").val(qt[0].algorithm),I("#train-alg").trigger("click");return}return}}),t||(Yn.push(i.move),$n===0&&Yn.length===1&&bn[bn.length-1].move===Xp(cn[$n].replace(/[()]/g,""))?($n--,Yn.pop()):bn[bn.length-1].move===Xp(Yn[Yn.length-2])?(Yn.pop(),Yn.pop()):Yn.length>3&&bn.length>3&&bn[bn.length-1].move===bn[bn.length-2].move&&bn[bn.length-2].move===bn[bn.length-3].move&&bn[bn.length-3].move===bn[bn.length-4].move&&(Yn.pop(),Yn.pop(),Yn.pop(),Yn.pop())),mg()}}function Wv(i,e){const t=document.getElementById("flashing-indicator");t&&$p&&(t.style.backgroundColor=i,t.classList.remove("hidden"),setTimeout(()=>{t.classList.add("hidden")},e))}function e3(){if(Wv("green",200),qt.length+Ii.length>1){const i=qt.shift();qt.length===0&&(qt=[...Ii],Ii=[],Pu&&qt.sort((e,t)=>t.bestTime-e.bestTime)),Kp&&qt.sort(()=>Math.random()-.5),i&&Ii.push(i)}}var Ky=!1;async function I9(i){if(i.type=="FACELETS"&&!Ky){if(i.facelets!=Vv){var e=lg(i.facelets),t=await kM(e),n=t.invert();Ia.alg=n,dn.alg=n}else Ia.alg="",dn.alg="";Ky=!0,console.log("Initial cube state is applied successfully",i.facelets)}}function B9(i){i.type=="GYRO"?C9(i):i.type=="MOVE"?P9(i):i.type=="FACELETS"?I9(i):i.type=="HARDWARE"?(I("#hardwareName").val(i.hardwareName||"- n/a -"),I("#hardwareVersion").val(i.hardwareVersion||"- n/a -"),I("#softwareVersion").val(i.softwareVersion||"- n/a -"),I("#productDate").val(i.productDate||"- n/a -"),I("#gyroSupported").val(i.gyroSupported?"YES":"NO")):i.type=="BATTERY"?(I("#batteryLevel").val(i.batteryLevel+"%"),I("#bluetooth-indicator").hide(),I("#battery-indicator").attr("title",i.batteryLevel+"%"),i.batteryLevel>=75?(I("#battery-indicator").html(''),I("#battery-indicator").css("color","green")):i.batteryLevel>=50?(I("#battery-indicator").html(''),I("#battery-indicator").css("color","yellow")):i.batteryLevel>=20?(I("#battery-indicator").html(''),I("#battery-indicator").css("color","orange")):i.batteryLevel<20&&(I("#battery-indicator").html(''),I("#battery-indicator").css("color","red"))):i.type=="DISCONNECT"&&t3()}const O9=async(i,e)=>{const t=localStorage.getItem("lastConnectedDeviceMAC")||"";return e?prompt(`Unable to determine cube MAC address! Please enter MAC address manually:`,t):typeof i.watchAdvertisements=="function"?null:prompt(`Seems like your browser does not support Web Bluetooth watchAdvertisements() API. Enable following flag in Chrome: chrome://flags/#enable-experimental-web-platform-features diff --git a/docs/assets/index-BSjPx7-K.js b/docs/assets/index-Dti57iVT.js similarity index 99% rename from docs/assets/index-BSjPx7-K.js rename to docs/assets/index-Dti57iVT.js index ff322d8..5efdf85 100644 --- a/docs/assets/index-BSjPx7-K.js +++ b/docs/assets/index-Dti57iVT.js @@ -1,4 +1,4 @@ -var Xt=Object.defineProperty;var qt=(e,t,s)=>t in e?Xt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var b=(e,t,s)=>qt(e,typeof t!="symbol"?t+"":t,s);import{Q as $,M as k}from"./index-lVaISq9J.js";var pt=class{constructor(e,t){b(this,"prefixFree",!0);b(this,"gripnames",[]);this.facenames=e,t&&(this.gripnames=t);for(let s=0;this.prefixFree&&s0&&sthis.facenames[i].length)&&(i=n);if(i>=0)t.push(i),s+=this.facenames[i].length;else throw new Error(`Could not split ${e} into face names.`)}return t}joinByFaceIndices(e){let t="";const s=[];for(let i=0;i0&&t[t.length-1]==="v"&&(t=t.substring(0,t.length-1)),this.sw.spinmatch(t,"FLUR")?new k(new $("T",e.innerLayer,e.outerLayer),e.amount):this.child.notationToExternal(e)}},Rt=class{constructor(e,t){this.internalNames=e,this.externalNames=t}convertString(e,t,s){let i="";(e.endsWith("v")||e.endsWith("v"))&&e<="_"&&(i=e.slice(e.length-1),e=e.slice(0,e.length-1));const n=e.toUpperCase();let o=!1;return e!==n&&(o=!0,e=n),e=s.joinByFaceIndices(t.splitByFaceNames(e)),o&&(e=e.toLowerCase()),e+i}convert(e,t,s){const i=e.family,n=this.convertString(i,t,s);return i===n?e:new k(new $(n,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)}},te=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 $("L",3,2),-2*e.amount);if(e.family==="R--")return new k(new $("L",3,2),2*e.amount);if(e.family==="D++")return new k(new $("U",3,2),-2*e.amount);if(e.family==="D--")return new k(new $("U",3,2),2*e.amount);if(e.family==="R_PLUSPLUS_")return new k(new $("L",3,2),-2*e.amount);if(e.family==="D_PLUSPLUS_")return new k(new $("U",3,2),-2*e.amount)}if(e.family==="y")return new k("Uv",e.amount);if(e.family==="x"&&Math.abs(e.amount)===2)return new k("ERv",e.amount/2)}return this.child.notationToInternal(e)}notationToExternal(e){return e.family==="ERv"&&Math.abs(e.amount)===1?new k(new $("x",e.innerLayer,e.outerLayer),e.amount*2):e.family==="ILv"&&Math.abs(e.amount)===1?new k(new $("x",e.innerLayer,e.outerLayer),-e.amount*2):e.family==="Uv"?new k(new $("y",e.innerLayer,e.outerLayer),e.amount):e.family==="Dv"?new k("y",-e.amount):this.child.notationToExternal(e)}},ee=class{constructor(e){this.slices=e}notationToInternal(e){const 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 $("D",(this.slices+1)/2),e.amount):t==="M"?e=new k(new $("L",(this.slices+1)/2),e.amount):t==="S"&&(e=new k(new $("F",(this.slices+1)/2),e.amount))),this.slices>2&&(t==="e"?e=new k(new $("D",this.slices-1,2),e.amount):t==="m"?e=new k(new $("L",this.slices-1,2),e.amount):t==="s"&&(e=new k(new $("F",this.slices-1,2),e.amount)))),e}notationToExternal(e){const 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}},se={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"},ie={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",d:"d",f:"f",bl:"l",br:"r"},Dt={U:"FRL",L:"FLD",R:"FDR",B:"DLR"},kt=new $("y"),Et=new $("Dv"),Tt=class{constructor(e){b(this,"wcaHack",!1);b(this,"map",se);this.child=e}notationToInternal(e){if(this.wcaHack&&e.innerLayer===2&&e.outerLayer===null){const s=Dt[e.family];if(s)return new k(new $(s,e.innerLayer,e.outerLayer),e.amount)}const t=this.map[e.family];return t?new k(new $(t,e.innerLayer,e.outerLayer),e.amount):kt.isIdentical(e.quantum)?new k(Et,-e.amount):null}notationToExternal(e){if(this.wcaHack&&e.innerLayer===2&&e.outerLayer===null){for(const[t,s]of Object.entries(Dt))if(this.child.spinmatch(e.family,s))return new k(new $(t,e.innerLayer,e.outerLayer),e.amount)}for(const[t,s]of Object.entries(this.map))if(this.child.spinmatch(e.family,s))return new k(new $(t,e.innerLayer,e.outerLayer),e.amount);return Et.isIdentical(e.quantum)?new k(kt,-e.amount):null}},ne=class extends Tt{constructor(t){super(t);b(this,"wcaHack",!0);this.map=ie}},jt={U:"UBL",UL:"ULF",F:"UFR",UR:"URB",B:"DBL",D:"DFR",L:"DLF",R:"DRB",Uv:"UBLv",ULv:"ULFv",Fv:"UFRv",URv:"URBv",Bv:"DBLv",Dv:"DFRv",Lv:"DLFv",Rv:"DRBv"},dt=new $("x"),Ct=new $("Rv"),oe=new $("Lv"),gt=new $("y"),Ut=new $("Uv"),re=new $("Dv"),bt=new $("z"),Pt=new $("Fv"),ae=new $("Bv"),le=class{constructor(e){this.child=e}notationToInternal(e){if(e.innerLayer||e.outerLayer)return null;const t=jt[e.family];return t?new k(new $(t,e.outerLayer,e.innerLayer),e.amount):dt.isIdentical(e.quantum)?new k(Ct,e.amount):gt.isIdentical(e.quantum)?new k(Ut,e.amount):bt.isIdentical(e.quantum)?new k(Pt,e.amount):null}notationToExternal(e){for(const[t,s]of Object.entries(jt))if(this.child.spinmatchv(e.family,s))return new k(new $(t,e.innerLayer,e.outerLayer),e.amount);return Ct.isIdentical(e.quantum)?new k(dt,e.amount):oe.isIdentical(e.quantum)?new k(dt,-e.amount):Ut.isIdentical(e.quantum)?new k(gt,e.amount):re.isIdentical(e.quantum)?new k(gt,-e.amount):Pt.isIdentical(e.quantum)?new k(bt,e.amount):ae.isIdentical(e.quantum)?new k(bt,-e.amount):null}};function he(e,t){const s={...e,moves:{}};for(const[i,n]of Object.entries(e.moves)){let o=i,r="";["v","w"].includes(i.at(-1))&&(o=i.slice(0,-1),r=i.slice(-1));const u=t.notationToExternal(k.fromString(o));if(!u)continue;const l=u+r;if(!l)throw new Error(`Missing external move name for: ${i.toString()}`);s.moves[l.toString()]=n}return s}function Se(e){let t=0;const s={};for(;t1;)t*=BigInt(e),e--;return t}function me(e,t){if(e>t){const s=e;e=t,t=s}for(;e>0;){const s=t%e;t=e,e=s}return t}function Nt(e,t){return e/me(e,t)*t}var at=class ht{constructor(t){b(this,"n");b(this,"p");this.n=t.length,this.p=t}toString(){return`Perm[${this.p.join(" ")}]`}mul(t){const s=Array(this.n);for(let i=0;i1){w=!1;const m=new Ot(this.orbitdefs[o].size*r);for(let a=0;anew Qt(o)),this.isRotation,this.forcenames)}scramble(t){this.solved=this.solved.mul(this.getScrambleTransformation(t))}getScrambleTransformation(t){t<100&&(t=100);const s=[];for(let n=0;no+1).join(" ")),!this.zeroOris()))if(i){const o=new Array(this.ori.length);for(let r=0;rr*i+t));t+=i*s.perm.length}return e}order(){let e=1;for(const t of this.orbits)e=Nt(e,t.order());return e}},Qt=class ct extends Kt{mul(t){return new ct(this.internalMul(t))}mulScalar(t){if(t===0)return this.e();let s=this;for(t<0&&(s=s.inv(),t=-t);!(t&1);)s=s.mul(s),t>>=1;if(t===1)return s;let i=s,n=this.e();for(;t>0;)t&1&&(n=n.mul(i)),t>1&&(i=i.mul(i)),t>>=1;return n}inv(){return new ct(this.internalInv())}e(){return new ct(this.orbits.map(t=>ot.e(t.perm.length,t.orimod)))}},Ht=class Zt extends Kt{mul(t){return new Zt(this.internalMul(t))}},Ot=class{constructor(e){b(this,"heads");this.n=e,this.heads=new Array(e);for(let t=0;ti&&(this.heads[s]=i)}};function de(e,t){const s=e.moveops.length;if(s>30)throw new Error("Canon info too big for bitmask");const i=[],n=[];for(let r=0;r>m&1)&&!(d&n[m]&(1<0&&r>i[o].a||i[o].a<0&&rs.rotatepoint(this))}intersect3(t,s){const i=this.det3x3(this.b,this.c,this.d,t.b,t.c,t.d,s.b,s.c,s.d);return Math.abs(i)it?1:t<-it?-1:0}cutface(t){const s=this.a;let i=0,n=null;for(let o=0;othis.side(r.dot(this)-s));for(let r=-1;r<=1;r+=2){const u=[];for(let l=0;l1&&(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}};function Be(e,t){const s=e[0].p.length,i=fe(s);let n=[],o=[],r=[],u=[],l=[];function h(m){for(let a=m.p.length-1;a>=0;a--){const f=m.p[a];if(f!==a){if(!n[a][f])return!1;m=m.mul(o[a][f])}}return!0}function w(m,a,f){u[m].push(a),l[m].push(f);for(let y=0;y1&&g.multiply(R);const Z=S/R;L+=Z}t(`${f}: sz ${a} T ${y} sol ${L} none ${m} mults ${g.toString()}`)}return a}return v()}var Ft=class Bt{constructor(t){b(this,"coords");b(this,"length");this.coords=new Array(t.length*3);for(let s=0;s0&&(o=String(t[1]+1));else if(t[0]===0)n=n.toLowerCase(),t[1]>1&&(o=String(t[1]+1));else throw new Error(`We only support slice and outer block moves right now. ${t}`);return[o+n,i]}function Pe(e,t){const s=[];let i=0;for(;i0&&in.length&&(n=o[1]);if(n!=="")s.push(n),i+=n.length;else throw new Error(`Could not split ${e} into face names.`)}return s}function ft(e,t){return[e.b/t,-e.c/t,e.d/t]}function xt(e,t){const s=[],i=e.length;for(let n=0;n0&&console.log(this.header("# ")),this.create(e)}create(e){const{shape:t,cuts:s}=e;this.moveplanes=[],this.moveplanes2=[],this.faces=[],this.cubies=[];let i=null;switch(t){case"c":{i=be();break}case"o":{i=xe();break}case"i":{i=ye();break}case"t":{i=we();break}case"d":{i=ve();break}default:throw new Error(`Bad shape argument: ${t}`)}this.rotations=Le(i),this.options.verbosity&&console.log(`# Rotations: ${this.rotations.length}`);const n=i[0];this.baseplanerot=$t(n,this.rotations);const o=this.baseplanerot.map(c=>n.rotateplane(c));this.baseplanes=o,this.baseFaceCount=o.length;const r=De()[o.length];this.net=r,this.colors=ke()[o.length],this.options.verbosity>0&&console.log(`# Base planes: ${o.length}`);const u=It(o),l=new G(0,0,0,0);this.options.verbosity>0&&console.log(`# Face vertices: ${u.length}`);const h=o[0].makenormal(),w=u[0].sum(u[1]).makenormal(),d=u[0].makenormal(),v=new G(1,h.b,h.c,h.d);this.options.verbosity>0&&console.log(`# Boundary is ${v}`);const a=$t(v,this.rotations).map(c=>v.rotateplane(c)),f=It(a);this.edgedistance=f[0].sum(f[1]).smul(.5).dist(l),this.vertexdistance=f[0].dist(l);const y=[],L=[];let g=!1,M=!1,R=!1;for(const c of s){let x=null,C=0;switch(c.cutType){case"f":{x=h,C=1,g=!0;break}case"v":{x=d,C=this.vertexdistance,R=!0;break}case"e":{x=w,C=this.edgedistance,M=!0;break}default:throw new Error(`Bad cut argument: ${c.cutType}`)}y.push(x.makecut(c.distance)),L.push(c.distancec[1]));const j=this.swizzler.prefixFree?"":"_",T=Ee[this.baseFaceCount],P=[];for(let c=0;c1&&(console.log(`# Face names: ${S.map(c=>c[1]).join(" ")}`),console.log(`# Edge names: ${p.map(c=>c[1]).join(" ")}`),console.log(`# Vertex names: ${I.map(c=>c[1]).join(" ")}`));const A=[];for(const c of Z)A.push([c[0].makenormal(),c[1],"f"]);for(const c of p)A.push([c[0].makenormal(),c[1],"e"]);for(const c of I)A.push([c[0].makenormal(),c[1],"v"]);this.facenames=S,this.faceplanes=Z,this.edgenames=p,this.vertexnames=I,this.geonormals=A;const X=A.map(c=>c[1]);this.swizzler.setGripNames(X),this.options.verbosity>0&&console.log(`# Distances: face 1 edge ${this.edgedistance} vertex ${this.vertexdistance}`);for(let c=0;c0&&console.log(`# Faces is now ${Y.length}`),this.stickersperface=Y.length;const rt=[],tt=yt(f);for(const c of this.rotations){const x=c.rotateface(f);tt.dist(yt(x))c[0]-x[0]);for(let c=0;cK);N++){const H=Q[N][2];if(!et[H]&&O.dist(Q[N][1])0&&console.log(`# Short edge is ${this.shortedge}`),t==="c"&&g&&!M&&!R&&(this.addNotationMapper="NxNxNCubeMapper",this.setReidOrder=!0),t==="c"&&R&&!g&&!M&&(this.addNotationMapper="SkewbMapper"),t==="t"&&(R||g)&&!M&&(this.addNotationMapper="PyraminxOrTetraminxMapper"),t==="o"&&g&&(this.notationMapper=new Rt(this.swizzler,new pt(["F","D","L","BL","R","U","BR","B"])),M||R||(this.addNotationMapper="FTOMapper")),t==="d"&&g&&(this.addNotationMapper="MegaminxMapper",this.notationMapper=new Rt(this.swizzler,new pt(["U","F","L","BL","BR","R","FR","FL","DL","B","DR","D"])))}keyface(e){return this.keyface2(e.centermass())}keyface2(e){let t="";const s=String.fromCharCode;for(const i of this.moveplanesets)if(i.length>0){const n=e.dot(i[0]);let o=0,r=1;for(;r*2<=i.length;)r*=2;for(;r>0;r>>=1)o+r<=i.length&&n>i[o+r-1].a&&(o+=r);if(o<47)t=t+s(33+o);else if(o<47+47*47)t=t+s(80+Math.floor(o/47)-1)+s(33+o%47);else if(o<47+47*47+47*47*47)t=t+s(80+Math.floor((o-47)/(47*47)-1))+s(80+Math.floor((o-47)/47)%47)+s(33+o%47);else throw Error("Too many slices for cubie encoding")}return t}keyface3(e){const t=e.centermass(),s=[];for(const i of this.moveplanesets)if(i.length>0){const n=t.dot(i[0]);let o=0,r=1;for(;r*2<=i.length;)r*=2;for(;r>0;r>>=1)o+r<=i.length&&n>i[o+r-1].a&&(o+=r);s.push(o)}return s}findface(e){const t=this.keyface2(e),s=this.facelisthash.get(t);if(s.length===1)return s[0];for(let i=0;i+10&&console.log(`# Total stickers is now ${this.faces.length}`),this.facecentermass=new Array(this.faces.length);for(let p=0;pE.normalizeplane()),U=t[p];for(let E=0;EK&&(B[E]=B[E].smul(-1));B.sort((E,F)=>E.a-F.a),e[p]=B}this.moveplanesets=e,this.moveplanenormals=t;const s=e.map(p=>p.length);this.options.verbosity>0&&console.log(`# Move plane sets: ${s}`);const i=[];for(let p=0;pK&&(B[E]=B[E].smul(-1));B.sort((E,F)=>E.angle()-F.angle()),i[p][0].dot(t[p])<0&&B.reverse()}const n=i.map(p=>1+p.length);this.movesetorders=n;const o=[];let r="?";for(let p=0;p0&&console.log("# Splitting core.");for(let F=0;F0&&console.log(`# Cubies: ${u.size}`);const h=[],w=[],d=[];for(const p of u.values())if(p.length!==this.baseFaceCount){if(p.length>1){const B=p.map(j=>l[j].centermass()),U=yt(B);for(let j=0;p.length>2;j++){let T=!1;for(let P=0;P1e3)throw new Error("Bad epsilon math; too close to border")}let E=0;for(const j of p)E|=1<h[p].map(B=>this.getfaceindex(B)).join(" "),I=[];for(let p=0;p1||U[X]===void 0)&&(U[X]=E++),S[A]=U[X],g[A]=L,I[L].push(A),M[A]=R[L]++,T.length2||this.options.fixedPieceType==="e"&&h[p].length===2||this.options.fixedPieceType==="f"&&h[p].length===1){this.fixedCubie=p;break}if(this.fixedCubie<0)throw new Error(`Could not find a cubie of type ${this.options.fixedPieceType} to fix.`)}this.options.verbosity>0&&console.log(`# Cubie orbit sizes ${R}`)}unswizzle(e){const t=this.notationMapper.notationToInternal(e);return t===null?null:t.modified({family:this.swizzler.unswizzle(t.family)})}stringToBlockMove(e){const t=/^(([0-9]+)-)?([0-9]+)?([^0-9]+)([0-9]+'?)?$/,s=e.match(t);if(s===null)throw new Error(`Bad move passed ${e}`);const i=s[4];let n,o;if(s[2]!==void 0){if(s[3]===void 0)throw new Error("Missing second number in range");n=parseInt(s[2],10)}s[3]!==void 0&&(o=parseInt(s[3],10));let r="1",u=1;return s[5]!==void 0&&(r=s[5],r[0]==="'"&&(r=`-${r.substring(1)}`),u=parseInt(r,10)),new k(new $(i,o,n),u)}parseMove(e){const t=this.notationMapper.notationToInternal(e);if(t===null)throw new Error(`Bad move ${e.family}`);e=t;let s=e.family,i=!1;if(s.endsWith("v")&&s[0]<="Z"){if(e.innerLayer!==void 0||e.outerLayer!==void 0)throw new Error("Cannot use a prefix with full cube rotations");s=s.slice(0,-1),i=!0}s.endsWith("w")&&s[0]<="Z"&&(s=s.slice(0,-1).toLowerCase());let n,o=-1;const r=this.swizzler.unswizzle(s);let u=!1;for(let w=0;wthis.moveplanesets[o].length||h<0||h>this.moveplanesets[o].length)throw new Error(`Bad slice spec ${l} ${h} vs ${this.moveplanesets[o].length}`);if(l===0&&h===this.moveplanesets[o].length&&!i)throw new Error("! full puzzle rotations must be specified with v suffix.");return[void 0,o,l,h,u,e.amount]}parsemove(e){const t=this.parseMove(this.stringToBlockMove(e));return t[0]=e,t}genperms(){if(this.cmovesbyslice.length>0)return;const e=[];if(this.options.orientCenters){for(let t=0;tl&&(l=a,h=v)}const w=(h+1)%this.faces[s].length;if(Math.abs(u.dot(this.faces[s].get(w).sub(n))-l)0){const w=this.facecentermass[l].dot(s[0]);for(let d=o;d>0;d>>=1)h+d<=s.length&&w>s[h+d-1].a&&(h+=d);h=s.length-h}for(i.push(h);n.length<=h;)n.push(0);n[h]++}const r=new Array(n.length);for(let l=0;l2&&this.options.orientCenters&&(this.cubies[h[0]].length===1||this.duplicatedCubies[h[0]]>1)&&this.facecentermass[l].dist(this.basefaces[this.getfaceindex(l)].centermass())0?h.push(h[0],f):h.push(h[0],(this.movesetorders[t]-f)%this.movesetorders[t])}if(h.length>2&&!u[h[0]]){if(h.length!==2*this.movesetorders[t])throw new Error("Bad length in perm gen");for(const a of h)r[m].push(a)}for(let a=0;at?s.push([i,t]):s.push([0,i]):s.push([i,i]),s.push(1));if(this.fixedCubie>=0){const i=this.keyface3(this.faces[this.cubies[this.fixedCubie][0]])[e],n=[];for(let o=0;o=r[0]&&i<=r[1])if(r[0]===0)r=[r[1]+1,t];else if(t===r[1])r=[0,r[0]-1];else throw Error("fixed cubie option would disconnect move");let u=!1;for(let l=0;l2&&(this.options.grayCorners||!this.options.includeCornerOrbits)}skipbyori(e){let t=this.cubies[e].length;return this.duplicatedCubies[e]&&(t=1),t===1&&!this.options.includeCenterOrbits||t===2&&!this.options.includeEdgeOrbits||t>2&&!this.options.includeCornerOrbits}skipcubie(e){return this.skipbyori(e)}header(e){return`${e+Re} +var Xt=Object.defineProperty;var qt=(e,t,s)=>t in e?Xt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var b=(e,t,s)=>qt(e,typeof t!="symbol"?t+"":t,s);import{Q as $,M as k}from"./index-BA4_IlXs.js";var pt=class{constructor(e,t){b(this,"prefixFree",!0);b(this,"gripnames",[]);this.facenames=e,t&&(this.gripnames=t);for(let s=0;this.prefixFree&&s0&&sthis.facenames[i].length)&&(i=n);if(i>=0)t.push(i),s+=this.facenames[i].length;else throw new Error(`Could not split ${e} into face names.`)}return t}joinByFaceIndices(e){let t="";const s=[];for(let i=0;i0&&t[t.length-1]==="v"&&(t=t.substring(0,t.length-1)),this.sw.spinmatch(t,"FLUR")?new k(new $("T",e.innerLayer,e.outerLayer),e.amount):this.child.notationToExternal(e)}},Rt=class{constructor(e,t){this.internalNames=e,this.externalNames=t}convertString(e,t,s){let i="";(e.endsWith("v")||e.endsWith("v"))&&e<="_"&&(i=e.slice(e.length-1),e=e.slice(0,e.length-1));const n=e.toUpperCase();let o=!1;return e!==n&&(o=!0,e=n),e=s.joinByFaceIndices(t.splitByFaceNames(e)),o&&(e=e.toLowerCase()),e+i}convert(e,t,s){const i=e.family,n=this.convertString(i,t,s);return i===n?e:new k(new $(n,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)}},te=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 $("L",3,2),-2*e.amount);if(e.family==="R--")return new k(new $("L",3,2),2*e.amount);if(e.family==="D++")return new k(new $("U",3,2),-2*e.amount);if(e.family==="D--")return new k(new $("U",3,2),2*e.amount);if(e.family==="R_PLUSPLUS_")return new k(new $("L",3,2),-2*e.amount);if(e.family==="D_PLUSPLUS_")return new k(new $("U",3,2),-2*e.amount)}if(e.family==="y")return new k("Uv",e.amount);if(e.family==="x"&&Math.abs(e.amount)===2)return new k("ERv",e.amount/2)}return this.child.notationToInternal(e)}notationToExternal(e){return e.family==="ERv"&&Math.abs(e.amount)===1?new k(new $("x",e.innerLayer,e.outerLayer),e.amount*2):e.family==="ILv"&&Math.abs(e.amount)===1?new k(new $("x",e.innerLayer,e.outerLayer),-e.amount*2):e.family==="Uv"?new k(new $("y",e.innerLayer,e.outerLayer),e.amount):e.family==="Dv"?new k("y",-e.amount):this.child.notationToExternal(e)}},ee=class{constructor(e){this.slices=e}notationToInternal(e){const 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 $("D",(this.slices+1)/2),e.amount):t==="M"?e=new k(new $("L",(this.slices+1)/2),e.amount):t==="S"&&(e=new k(new $("F",(this.slices+1)/2),e.amount))),this.slices>2&&(t==="e"?e=new k(new $("D",this.slices-1,2),e.amount):t==="m"?e=new k(new $("L",this.slices-1,2),e.amount):t==="s"&&(e=new k(new $("F",this.slices-1,2),e.amount)))),e}notationToExternal(e){const 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}},se={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"},ie={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",d:"d",f:"f",bl:"l",br:"r"},Dt={U:"FRL",L:"FLD",R:"FDR",B:"DLR"},kt=new $("y"),Et=new $("Dv"),Tt=class{constructor(e){b(this,"wcaHack",!1);b(this,"map",se);this.child=e}notationToInternal(e){if(this.wcaHack&&e.innerLayer===2&&e.outerLayer===null){const s=Dt[e.family];if(s)return new k(new $(s,e.innerLayer,e.outerLayer),e.amount)}const t=this.map[e.family];return t?new k(new $(t,e.innerLayer,e.outerLayer),e.amount):kt.isIdentical(e.quantum)?new k(Et,-e.amount):null}notationToExternal(e){if(this.wcaHack&&e.innerLayer===2&&e.outerLayer===null){for(const[t,s]of Object.entries(Dt))if(this.child.spinmatch(e.family,s))return new k(new $(t,e.innerLayer,e.outerLayer),e.amount)}for(const[t,s]of Object.entries(this.map))if(this.child.spinmatch(e.family,s))return new k(new $(t,e.innerLayer,e.outerLayer),e.amount);return Et.isIdentical(e.quantum)?new k(kt,-e.amount):null}},ne=class extends Tt{constructor(t){super(t);b(this,"wcaHack",!0);this.map=ie}},jt={U:"UBL",UL:"ULF",F:"UFR",UR:"URB",B:"DBL",D:"DFR",L:"DLF",R:"DRB",Uv:"UBLv",ULv:"ULFv",Fv:"UFRv",URv:"URBv",Bv:"DBLv",Dv:"DFRv",Lv:"DLFv",Rv:"DRBv"},dt=new $("x"),Ct=new $("Rv"),oe=new $("Lv"),gt=new $("y"),Ut=new $("Uv"),re=new $("Dv"),bt=new $("z"),Pt=new $("Fv"),ae=new $("Bv"),le=class{constructor(e){this.child=e}notationToInternal(e){if(e.innerLayer||e.outerLayer)return null;const t=jt[e.family];return t?new k(new $(t,e.outerLayer,e.innerLayer),e.amount):dt.isIdentical(e.quantum)?new k(Ct,e.amount):gt.isIdentical(e.quantum)?new k(Ut,e.amount):bt.isIdentical(e.quantum)?new k(Pt,e.amount):null}notationToExternal(e){for(const[t,s]of Object.entries(jt))if(this.child.spinmatchv(e.family,s))return new k(new $(t,e.innerLayer,e.outerLayer),e.amount);return Ct.isIdentical(e.quantum)?new k(dt,e.amount):oe.isIdentical(e.quantum)?new k(dt,-e.amount):Ut.isIdentical(e.quantum)?new k(gt,e.amount):re.isIdentical(e.quantum)?new k(gt,-e.amount):Pt.isIdentical(e.quantum)?new k(bt,e.amount):ae.isIdentical(e.quantum)?new k(bt,-e.amount):null}};function he(e,t){const s={...e,moves:{}};for(const[i,n]of Object.entries(e.moves)){let o=i,r="";["v","w"].includes(i.at(-1))&&(o=i.slice(0,-1),r=i.slice(-1));const u=t.notationToExternal(k.fromString(o));if(!u)continue;const l=u+r;if(!l)throw new Error(`Missing external move name for: ${i.toString()}`);s.moves[l.toString()]=n}return s}function Se(e){let t=0;const s={};for(;t1;)t*=BigInt(e),e--;return t}function me(e,t){if(e>t){const s=e;e=t,t=s}for(;e>0;){const s=t%e;t=e,e=s}return t}function Nt(e,t){return e/me(e,t)*t}var at=class ht{constructor(t){b(this,"n");b(this,"p");this.n=t.length,this.p=t}toString(){return`Perm[${this.p.join(" ")}]`}mul(t){const s=Array(this.n);for(let i=0;i1){w=!1;const m=new Ot(this.orbitdefs[o].size*r);for(let a=0;anew Qt(o)),this.isRotation,this.forcenames)}scramble(t){this.solved=this.solved.mul(this.getScrambleTransformation(t))}getScrambleTransformation(t){t<100&&(t=100);const s=[];for(let n=0;no+1).join(" ")),!this.zeroOris()))if(i){const o=new Array(this.ori.length);for(let r=0;rr*i+t));t+=i*s.perm.length}return e}order(){let e=1;for(const t of this.orbits)e=Nt(e,t.order());return e}},Qt=class ct extends Kt{mul(t){return new ct(this.internalMul(t))}mulScalar(t){if(t===0)return this.e();let s=this;for(t<0&&(s=s.inv(),t=-t);!(t&1);)s=s.mul(s),t>>=1;if(t===1)return s;let i=s,n=this.e();for(;t>0;)t&1&&(n=n.mul(i)),t>1&&(i=i.mul(i)),t>>=1;return n}inv(){return new ct(this.internalInv())}e(){return new ct(this.orbits.map(t=>ot.e(t.perm.length,t.orimod)))}},Ht=class Zt extends Kt{mul(t){return new Zt(this.internalMul(t))}},Ot=class{constructor(e){b(this,"heads");this.n=e,this.heads=new Array(e);for(let t=0;ti&&(this.heads[s]=i)}};function de(e,t){const s=e.moveops.length;if(s>30)throw new Error("Canon info too big for bitmask");const i=[],n=[];for(let r=0;r>m&1)&&!(d&n[m]&(1<0&&r>i[o].a||i[o].a<0&&rs.rotatepoint(this))}intersect3(t,s){const i=this.det3x3(this.b,this.c,this.d,t.b,t.c,t.d,s.b,s.c,s.d);return Math.abs(i)it?1:t<-it?-1:0}cutface(t){const s=this.a;let i=0,n=null;for(let o=0;othis.side(r.dot(this)-s));for(let r=-1;r<=1;r+=2){const u=[];for(let l=0;l1&&(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}};function Be(e,t){const s=e[0].p.length,i=fe(s);let n=[],o=[],r=[],u=[],l=[];function h(m){for(let a=m.p.length-1;a>=0;a--){const f=m.p[a];if(f!==a){if(!n[a][f])return!1;m=m.mul(o[a][f])}}return!0}function w(m,a,f){u[m].push(a),l[m].push(f);for(let y=0;y1&&g.multiply(R);const Z=S/R;L+=Z}t(`${f}: sz ${a} T ${y} sol ${L} none ${m} mults ${g.toString()}`)}return a}return v()}var Ft=class Bt{constructor(t){b(this,"coords");b(this,"length");this.coords=new Array(t.length*3);for(let s=0;s0&&(o=String(t[1]+1));else if(t[0]===0)n=n.toLowerCase(),t[1]>1&&(o=String(t[1]+1));else throw new Error(`We only support slice and outer block moves right now. ${t}`);return[o+n,i]}function Pe(e,t){const s=[];let i=0;for(;i0&&in.length&&(n=o[1]);if(n!=="")s.push(n),i+=n.length;else throw new Error(`Could not split ${e} into face names.`)}return s}function ft(e,t){return[e.b/t,-e.c/t,e.d/t]}function xt(e,t){const s=[],i=e.length;for(let n=0;n0&&console.log(this.header("# ")),this.create(e)}create(e){const{shape:t,cuts:s}=e;this.moveplanes=[],this.moveplanes2=[],this.faces=[],this.cubies=[];let i=null;switch(t){case"c":{i=be();break}case"o":{i=xe();break}case"i":{i=ye();break}case"t":{i=we();break}case"d":{i=ve();break}default:throw new Error(`Bad shape argument: ${t}`)}this.rotations=Le(i),this.options.verbosity&&console.log(`# Rotations: ${this.rotations.length}`);const n=i[0];this.baseplanerot=$t(n,this.rotations);const o=this.baseplanerot.map(c=>n.rotateplane(c));this.baseplanes=o,this.baseFaceCount=o.length;const r=De()[o.length];this.net=r,this.colors=ke()[o.length],this.options.verbosity>0&&console.log(`# Base planes: ${o.length}`);const u=It(o),l=new G(0,0,0,0);this.options.verbosity>0&&console.log(`# Face vertices: ${u.length}`);const h=o[0].makenormal(),w=u[0].sum(u[1]).makenormal(),d=u[0].makenormal(),v=new G(1,h.b,h.c,h.d);this.options.verbosity>0&&console.log(`# Boundary is ${v}`);const a=$t(v,this.rotations).map(c=>v.rotateplane(c)),f=It(a);this.edgedistance=f[0].sum(f[1]).smul(.5).dist(l),this.vertexdistance=f[0].dist(l);const y=[],L=[];let g=!1,M=!1,R=!1;for(const c of s){let x=null,C=0;switch(c.cutType){case"f":{x=h,C=1,g=!0;break}case"v":{x=d,C=this.vertexdistance,R=!0;break}case"e":{x=w,C=this.edgedistance,M=!0;break}default:throw new Error(`Bad cut argument: ${c.cutType}`)}y.push(x.makecut(c.distance)),L.push(c.distancec[1]));const j=this.swizzler.prefixFree?"":"_",T=Ee[this.baseFaceCount],P=[];for(let c=0;c1&&(console.log(`# Face names: ${S.map(c=>c[1]).join(" ")}`),console.log(`# Edge names: ${p.map(c=>c[1]).join(" ")}`),console.log(`# Vertex names: ${I.map(c=>c[1]).join(" ")}`));const A=[];for(const c of Z)A.push([c[0].makenormal(),c[1],"f"]);for(const c of p)A.push([c[0].makenormal(),c[1],"e"]);for(const c of I)A.push([c[0].makenormal(),c[1],"v"]);this.facenames=S,this.faceplanes=Z,this.edgenames=p,this.vertexnames=I,this.geonormals=A;const X=A.map(c=>c[1]);this.swizzler.setGripNames(X),this.options.verbosity>0&&console.log(`# Distances: face 1 edge ${this.edgedistance} vertex ${this.vertexdistance}`);for(let c=0;c0&&console.log(`# Faces is now ${Y.length}`),this.stickersperface=Y.length;const rt=[],tt=yt(f);for(const c of this.rotations){const x=c.rotateface(f);tt.dist(yt(x))c[0]-x[0]);for(let c=0;cK);N++){const H=Q[N][2];if(!et[H]&&O.dist(Q[N][1])0&&console.log(`# Short edge is ${this.shortedge}`),t==="c"&&g&&!M&&!R&&(this.addNotationMapper="NxNxNCubeMapper",this.setReidOrder=!0),t==="c"&&R&&!g&&!M&&(this.addNotationMapper="SkewbMapper"),t==="t"&&(R||g)&&!M&&(this.addNotationMapper="PyraminxOrTetraminxMapper"),t==="o"&&g&&(this.notationMapper=new Rt(this.swizzler,new pt(["F","D","L","BL","R","U","BR","B"])),M||R||(this.addNotationMapper="FTOMapper")),t==="d"&&g&&(this.addNotationMapper="MegaminxMapper",this.notationMapper=new Rt(this.swizzler,new pt(["U","F","L","BL","BR","R","FR","FL","DL","B","DR","D"])))}keyface(e){return this.keyface2(e.centermass())}keyface2(e){let t="";const s=String.fromCharCode;for(const i of this.moveplanesets)if(i.length>0){const n=e.dot(i[0]);let o=0,r=1;for(;r*2<=i.length;)r*=2;for(;r>0;r>>=1)o+r<=i.length&&n>i[o+r-1].a&&(o+=r);if(o<47)t=t+s(33+o);else if(o<47+47*47)t=t+s(80+Math.floor(o/47)-1)+s(33+o%47);else if(o<47+47*47+47*47*47)t=t+s(80+Math.floor((o-47)/(47*47)-1))+s(80+Math.floor((o-47)/47)%47)+s(33+o%47);else throw Error("Too many slices for cubie encoding")}return t}keyface3(e){const t=e.centermass(),s=[];for(const i of this.moveplanesets)if(i.length>0){const n=t.dot(i[0]);let o=0,r=1;for(;r*2<=i.length;)r*=2;for(;r>0;r>>=1)o+r<=i.length&&n>i[o+r-1].a&&(o+=r);s.push(o)}return s}findface(e){const t=this.keyface2(e),s=this.facelisthash.get(t);if(s.length===1)return s[0];for(let i=0;i+10&&console.log(`# Total stickers is now ${this.faces.length}`),this.facecentermass=new Array(this.faces.length);for(let p=0;pE.normalizeplane()),U=t[p];for(let E=0;EK&&(B[E]=B[E].smul(-1));B.sort((E,F)=>E.a-F.a),e[p]=B}this.moveplanesets=e,this.moveplanenormals=t;const s=e.map(p=>p.length);this.options.verbosity>0&&console.log(`# Move plane sets: ${s}`);const i=[];for(let p=0;pK&&(B[E]=B[E].smul(-1));B.sort((E,F)=>E.angle()-F.angle()),i[p][0].dot(t[p])<0&&B.reverse()}const n=i.map(p=>1+p.length);this.movesetorders=n;const o=[];let r="?";for(let p=0;p0&&console.log("# Splitting core.");for(let F=0;F0&&console.log(`# Cubies: ${u.size}`);const h=[],w=[],d=[];for(const p of u.values())if(p.length!==this.baseFaceCount){if(p.length>1){const B=p.map(j=>l[j].centermass()),U=yt(B);for(let j=0;p.length>2;j++){let T=!1;for(let P=0;P1e3)throw new Error("Bad epsilon math; too close to border")}let E=0;for(const j of p)E|=1<h[p].map(B=>this.getfaceindex(B)).join(" "),I=[];for(let p=0;p1||U[X]===void 0)&&(U[X]=E++),S[A]=U[X],g[A]=L,I[L].push(A),M[A]=R[L]++,T.length2||this.options.fixedPieceType==="e"&&h[p].length===2||this.options.fixedPieceType==="f"&&h[p].length===1){this.fixedCubie=p;break}if(this.fixedCubie<0)throw new Error(`Could not find a cubie of type ${this.options.fixedPieceType} to fix.`)}this.options.verbosity>0&&console.log(`# Cubie orbit sizes ${R}`)}unswizzle(e){const t=this.notationMapper.notationToInternal(e);return t===null?null:t.modified({family:this.swizzler.unswizzle(t.family)})}stringToBlockMove(e){const t=/^(([0-9]+)-)?([0-9]+)?([^0-9]+)([0-9]+'?)?$/,s=e.match(t);if(s===null)throw new Error(`Bad move passed ${e}`);const i=s[4];let n,o;if(s[2]!==void 0){if(s[3]===void 0)throw new Error("Missing second number in range");n=parseInt(s[2],10)}s[3]!==void 0&&(o=parseInt(s[3],10));let r="1",u=1;return s[5]!==void 0&&(r=s[5],r[0]==="'"&&(r=`-${r.substring(1)}`),u=parseInt(r,10)),new k(new $(i,o,n),u)}parseMove(e){const t=this.notationMapper.notationToInternal(e);if(t===null)throw new Error(`Bad move ${e.family}`);e=t;let s=e.family,i=!1;if(s.endsWith("v")&&s[0]<="Z"){if(e.innerLayer!==void 0||e.outerLayer!==void 0)throw new Error("Cannot use a prefix with full cube rotations");s=s.slice(0,-1),i=!0}s.endsWith("w")&&s[0]<="Z"&&(s=s.slice(0,-1).toLowerCase());let n,o=-1;const r=this.swizzler.unswizzle(s);let u=!1;for(let w=0;wthis.moveplanesets[o].length||h<0||h>this.moveplanesets[o].length)throw new Error(`Bad slice spec ${l} ${h} vs ${this.moveplanesets[o].length}`);if(l===0&&h===this.moveplanesets[o].length&&!i)throw new Error("! full puzzle rotations must be specified with v suffix.");return[void 0,o,l,h,u,e.amount]}parsemove(e){const t=this.parseMove(this.stringToBlockMove(e));return t[0]=e,t}genperms(){if(this.cmovesbyslice.length>0)return;const e=[];if(this.options.orientCenters){for(let t=0;tl&&(l=a,h=v)}const w=(h+1)%this.faces[s].length;if(Math.abs(u.dot(this.faces[s].get(w).sub(n))-l)0){const w=this.facecentermass[l].dot(s[0]);for(let d=o;d>0;d>>=1)h+d<=s.length&&w>s[h+d-1].a&&(h+=d);h=s.length-h}for(i.push(h);n.length<=h;)n.push(0);n[h]++}const r=new Array(n.length);for(let l=0;l2&&this.options.orientCenters&&(this.cubies[h[0]].length===1||this.duplicatedCubies[h[0]]>1)&&this.facecentermass[l].dist(this.basefaces[this.getfaceindex(l)].centermass())0?h.push(h[0],f):h.push(h[0],(this.movesetorders[t]-f)%this.movesetorders[t])}if(h.length>2&&!u[h[0]]){if(h.length!==2*this.movesetorders[t])throw new Error("Bad length in perm gen");for(const a of h)r[m].push(a)}for(let a=0;at?s.push([i,t]):s.push([0,i]):s.push([i,i]),s.push(1));if(this.fixedCubie>=0){const i=this.keyface3(this.faces[this.cubies[this.fixedCubie][0]])[e],n=[];for(let o=0;o=r[0]&&i<=r[1])if(r[0]===0)r=[r[1]+1,t];else if(t===r[1])r=[0,r[0]-1];else throw Error("fixed cubie option would disconnect move");let u=!1;for(let l=0;l2&&(this.options.grayCorners||!this.options.includeCornerOrbits)}skipbyori(e){let t=this.cubies[e].length;return this.duplicatedCubies[e]&&(t=1),t===1&&!this.options.includeCenterOrbits||t===2&&!this.options.includeEdgeOrbits||t>2&&!this.options.includeCornerOrbits}skipcubie(e){return this.skipbyori(e)}header(e){return`${e+Re} ${e} `}writegap(){const e=this.getOrbitsDef(!1),t=[],s=[];for(let n=0;n`[${n.map(o=>o+1).join(",")}]`).join(",")}];`),t.push("# Size(Group(Gen));"),t.push("# Size(Stabilizer(Group(Gen), ip, OnTuplesSets));"),t.push(""),this.header("# ")+t.join(` `)}writemathematica(){const e=this.getOrbitsDef(!1),t=[],s=[];t.push(`(* ${this.header("").trim()} *)`);for(let i=0;ii.map(i=>d[i]); -var B=Object.defineProperty;var K=(e,a,r)=>a in e?B(e,a,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[a]=r;var P=(e,a,r)=>K(e,typeof a!="symbol"?a+"":a,r);import{r as f,_ as d,K as h,s as b,u as U,v as W,w,x as V,y as q,z as $,A as G,H,I as j,J as g,M as J,L as Q,N as X,P as Y}from"./index-lVaISq9J.js";import{e as Z}from"./search-worker-entry-CmpnuiQ5.js";var ee=2;function ae(e,a){const r=[];for(const t of a){const n=new J(t);if(n.amount!==1)throw new Error("SGS cannot handle def moves with an amount other than 1 yet.");let i=e.identityTransformation();for(let S=1;i=i.applyMove(n),!i.isIdentityTransformation();S++)r.push({move:n.modified({amount:S}),transformation:i})}return r}var T=class{constructor(e,a,r){P(this,"searchMoves");this.kpuzzle=e,this.sgs=a,this.searchMoves=ae(this.kpuzzle,r??Object.keys(this.kpuzzle.definition.moves))}async solve(e,a=ee,r){const t=e.experimentalToTransformation();if(!t)throw new Error("distinguishable pieces are not supported in tremble solver yt");let n=null,i=1e6;const S=(m,y,s)=>{if(y===0){const c=this.sgsPhaseSolve(m,i);if(!c)return;const v=s.concat(c).experimentalSimplify({cancel:{directional:"any-direction",puzzleSpecificModWrap:"canonical-centered"},puzzleSpecificSimplifyOptions:{quantumMoveOrder:r}}),u=Q(v);(n===null||u=a)return null;t=t.applyTransformation(y.transformation);for(let s=0;sd(()=>import("./twsearch-MRZGOB6T-BaM7-RH2.js"),__vite__mapDeps([0,1,2])));async function L(e,a,r){const{wasmTwsearch:t}=await k;return t(e,a,r)}async function te(e){const{wasmRandomScrambleForEvent:a}=await k;return a(e)}var l=f(()=>d(()=>import("./search-dynamic-sgs-side-events-RPVZU2YB-BhBJcWeZ.js"),__vite__mapDeps([3,1,2,4]))),z=null;async function ne(){return z||(z=(async()=>{const e=await(await l).cachedData222();return new T(await b["2x2x2"].kpuzzle(),e,"URFLBD".split(""))})())}async function ie(){await ne()}async function oe(e){return w(),L((await V.kpuzzle()).definition,e,{generatorMoves:"UFLR".split("")})}var A=f(()=>d(()=>import("./search-dynamic-solve-4x4x4-V5D7RQND-BmfxzsMX.js"),__vite__mapDeps([5,1,2]))),ce=[[null,"x","x2","x'","z","z'"],[null,"y","y2","y'"]];async function se(){return(await A).initialize()}async function F(){return w(),(await A).random444Scramble()}async function le(){return j(await F(),ce)}var me=f(()=>d(()=>import("./search-dynamic-solve-fto-UOKDYVD5-Cz8FofTn.js"),__vite__mapDeps([6,1,2])));f(()=>d(()=>import("./search-dynamic-sgs-unofficial-2TYKOUM4-C9bPN2pc.js"),__vite__mapDeps([7,4,1,2])));async function ue(){return w(),new g(await(await me).getRandomFTOScramble())}var fe=f(()=>d(()=>import("./search-dynamic-solve-kilominx-RAZM75GA-bDKRH7RV.js"),__vite__mapDeps([8,1,2])));async function de(){return w(),(await fe).getRandomKilominxScramble()}var we=f(()=>d(()=>import("./search-dynamic-solve-master_tetraminx-3D4MBF3V-CmCoI0eZ.js"),__vite__mapDeps([9,1,2])));async function Se(){return w(),new g(await(await we).randomMasterTetraminxScrambleString())}var ve=2,x=null;async function he(){return x||(x=(async()=>{const e=await(await l).cachedSGSDataMegaminx();return new T(await(await l).cachedMegaminxKPuzzleWithoutMO(),e,["U","R","F","L","BR","BL","FR","FL","DR","DL","B","D"])})())}async function be(e){w();const a=await he(),r=structuredClone(e.patternData);r.CENTERS.orientation=new Array(12).fill(0);const t=new h(await(await l).cachedMegaminxKPuzzleWithoutMO(),r);return await a.solve(t,ve,()=>5)}var ye=3,R=null;async function ge(){return R||(R=(async()=>{const e=await(await l).sgsDataPyraminx();return new T(await b.pyraminx.kpuzzle(),e,"RLUB".split(""))})())}async function Te(e){return w(),await(await ge()).solve(e,ye,()=>3)}var Ee=f(()=>d(()=>import("./search-dynamic-sgs-unofficial-2TYKOUM4-C9bPN2pc.js"),__vite__mapDeps([7,4,1,2])));async function _e(){return w(),(await Ee).getRandomRediCubeScramble()}var pe=3,M=null;async function Pe(){return M||(M=(async()=>{const e=await(await l).sgsDataSkewb();return new T(await(await l).skewbKPuzzleWithoutMOCached(),e,"RLUB".split(""))})())}async function ze(e){return new h(await(await l).skewbKPuzzleWithoutMOCached(),{CORNERS:e.patternData.CORNERS,CENTERS:{pieces:e.patternData.CENTERS.pieces,orientation:new Array(6).fill(0)}})}async function C(e){return w(),await(await Pe()).solve(await ze(e),pe,t=>t.family==="y"?4:3)}async function xe(){return re(await(await l).skewbKPuzzleWithoutMOCached(),await(await l).sgsDataSkewbFixedCorner())}async function Re(){return C(await xe())}var Me=f(()=>d(()=>import("./search-dynamic-solve-sq1-YESVPPLF-C4f7Do9l.js"),__vite__mapDeps([10,1,2])));async function Oe(){return g.fromString(await(await Me).getRandomSquare1ScrambleString())}var De=1e3;q(!0);var I=!0;function ke(e){I=e}function O(){return(typeof performance>"u"?Date:performance).now()}async function o(e,a,r){if(!I)return a();const t=O(),n=a();n!=null&&n.then&&await n;const i=O();return console.warn(`${e}${r!=null&&r.isPrefetch?" (prefetched)":""}: ${Math.round(i-t)}ms`),n}var E=new Map,_=null;async function D(e,a){function r(){return o(`wasmRandomScrambleForEvent(${JSON.stringify(e)})`,()=>te(e),{isPrefetch:a==null?void 0:a.isPrefetch})}switch(e){case"222":return(await r()).experimentalSimplify({puzzleSpecificSimplifyOptions:{quantumMoveOrder:()=>4}});case"555":case"666":case"777":case"333fm":case"minx":case"pyram":case"555bf":return r();case"333":case"333oh":case"333ft":return o("random333Scramble",G,{isPrefetch:a==null?void 0:a.isPrefetch});case"333bf":case"333mbf":return o("random333OrientedScramble",$);case"444":return o("random444Scramble",F,{isPrefetch:a==null?void 0:a.isPrefetch});case"444bf":return o("random444OrientedScramble",le);case"skewb":return o("randomSkewbFixedCornerScramble",Re);case"sq1":return o("getRandomSquare1Scramble",Oe,{isPrefetch:a==null?void 0:a.isPrefetch});case"fto":return o("randomFTOScramble",ue,{isPrefetch:a==null?void 0:a.isPrefetch});case"master_tetraminx":return o("randomMasterTetraminxScramble",Se);case"kilominx":return o("randomKilominxScramble",de,{isPrefetch:a==null?void 0:a.isPrefetch});case"redi_cube":return o("randomRediCubeScramble",_e,{isPrefetch:a==null?void 0:a.isPrefetch});default:throw new Error(`unsupported event: ${e}`)}}var p="auto",N={initialize:async e=>{switch(e){case"222":return o("preInitialize222",ie);case"333":case"333oh":case"333ft":return o("initialize333",H);case"444":return o("initialize444",se);default:throw new Error(`unsupported event: ${e}`)}},setScramblePrefetchLevel(e){p=e},randomScrambleForEvent:async e=>{let a=E.get(e);return a?E.delete(e):a=D(e),p!=="none"&&a.then(()=>{_&&clearTimeout(_),_=setTimeout(()=>{E.set(e,D(e,{isPrefetch:!0}))},p==="immediate"?0:De)}),a},randomScrambleStringForEvent:async e=>(await N.randomScrambleForEvent(e)).toString(),solve333ToString:async e=>{const a=new h(await b["3x3x3"].kpuzzle(),e);return(await U(a)).toString()},solve222ToString:async e=>{const a=new h(await b["2x2x2"].kpuzzle(),e);return(await oe(a)).toString()},solveSkewbToString:async e=>{const a=new h(await b.skewb.kpuzzle(),e);return(await C(a)).toString()},solvePyraminxToString:async e=>{const a=new h(await b.pyraminx.kpuzzle(),e);return(await Te(a)).toString()},solveMegaminxToString:async e=>{const a=new h(await b.megaminx.kpuzzle(),e);return(await be(a)).toString()},setDebugMeasurePerf:async e=>{ke(e)},solveTwsearchToString:async(e,a,r)=>{const t=new W(e),n=new h(t,a);return(await L(e,n,r)).toString()}};Z(N); +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/twsearch-MRZGOB6T-CZQF4Gzo.js","assets/index-BA4_IlXs.js","assets/index-BF6G450p.css","assets/search-dynamic-sgs-side-events-RPVZU2YB-Dj74dEZl.js","assets/chunk-Y3BVWVFU-DzU6t54e.js","assets/search-dynamic-solve-4x4x4-V5D7RQND-C3wJm6SW.js","assets/search-dynamic-solve-fto-UOKDYVD5-Chq8lrUA.js","assets/search-dynamic-sgs-unofficial-2TYKOUM4-BXlOlhbf.js","assets/search-dynamic-solve-kilominx-RAZM75GA-DEBgiDDF.js","assets/search-dynamic-solve-master_tetraminx-3D4MBF3V-Di9QKO1e.js","assets/search-dynamic-solve-sq1-YESVPPLF-DwfB-f2O.js"])))=>i.map(i=>d[i]); +var B=Object.defineProperty;var K=(e,a,r)=>a in e?B(e,a,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[a]=r;var P=(e,a,r)=>K(e,typeof a!="symbol"?a+"":a,r);import{r as f,_ as d,K as h,s as b,u as U,v as W,w,x as V,y as q,z as $,A as G,H,I as j,J as g,M as J,L as Q,N as X,P as Y}from"./index-BA4_IlXs.js";import{e as Z}from"./search-worker-entry-C63kClJR.js";var ee=2;function ae(e,a){const r=[];for(const t of a){const n=new J(t);if(n.amount!==1)throw new Error("SGS cannot handle def moves with an amount other than 1 yet.");let i=e.identityTransformation();for(let S=1;i=i.applyMove(n),!i.isIdentityTransformation();S++)r.push({move:n.modified({amount:S}),transformation:i})}return r}var T=class{constructor(e,a,r){P(this,"searchMoves");this.kpuzzle=e,this.sgs=a,this.searchMoves=ae(this.kpuzzle,r??Object.keys(this.kpuzzle.definition.moves))}async solve(e,a=ee,r){const t=e.experimentalToTransformation();if(!t)throw new Error("distinguishable pieces are not supported in tremble solver yt");let n=null,i=1e6;const S=(m,y,s)=>{if(y===0){const c=this.sgsPhaseSolve(m,i);if(!c)return;const v=s.concat(c).experimentalSimplify({cancel:{directional:"any-direction",puzzleSpecificModWrap:"canonical-centered"},puzzleSpecificSimplifyOptions:{quantumMoveOrder:r}}),u=Q(v);(n===null||u=a)return null;t=t.applyTransformation(y.transformation);for(let s=0;sd(()=>import("./twsearch-MRZGOB6T-CZQF4Gzo.js"),__vite__mapDeps([0,1,2])));async function L(e,a,r){const{wasmTwsearch:t}=await k;return t(e,a,r)}async function te(e){const{wasmRandomScrambleForEvent:a}=await k;return a(e)}var l=f(()=>d(()=>import("./search-dynamic-sgs-side-events-RPVZU2YB-Dj74dEZl.js"),__vite__mapDeps([3,1,2,4]))),z=null;async function ne(){return z||(z=(async()=>{const e=await(await l).cachedData222();return new T(await b["2x2x2"].kpuzzle(),e,"URFLBD".split(""))})())}async function ie(){await ne()}async function oe(e){return w(),L((await V.kpuzzle()).definition,e,{generatorMoves:"UFLR".split("")})}var A=f(()=>d(()=>import("./search-dynamic-solve-4x4x4-V5D7RQND-C3wJm6SW.js"),__vite__mapDeps([5,1,2]))),ce=[[null,"x","x2","x'","z","z'"],[null,"y","y2","y'"]];async function se(){return(await A).initialize()}async function F(){return w(),(await A).random444Scramble()}async function le(){return j(await F(),ce)}var me=f(()=>d(()=>import("./search-dynamic-solve-fto-UOKDYVD5-Chq8lrUA.js"),__vite__mapDeps([6,1,2])));f(()=>d(()=>import("./search-dynamic-sgs-unofficial-2TYKOUM4-BXlOlhbf.js"),__vite__mapDeps([7,4,1,2])));async function ue(){return w(),new g(await(await me).getRandomFTOScramble())}var fe=f(()=>d(()=>import("./search-dynamic-solve-kilominx-RAZM75GA-DEBgiDDF.js"),__vite__mapDeps([8,1,2])));async function de(){return w(),(await fe).getRandomKilominxScramble()}var we=f(()=>d(()=>import("./search-dynamic-solve-master_tetraminx-3D4MBF3V-Di9QKO1e.js"),__vite__mapDeps([9,1,2])));async function Se(){return w(),new g(await(await we).randomMasterTetraminxScrambleString())}var ve=2,x=null;async function he(){return x||(x=(async()=>{const e=await(await l).cachedSGSDataMegaminx();return new T(await(await l).cachedMegaminxKPuzzleWithoutMO(),e,["U","R","F","L","BR","BL","FR","FL","DR","DL","B","D"])})())}async function be(e){w();const a=await he(),r=structuredClone(e.patternData);r.CENTERS.orientation=new Array(12).fill(0);const t=new h(await(await l).cachedMegaminxKPuzzleWithoutMO(),r);return await a.solve(t,ve,()=>5)}var ye=3,R=null;async function ge(){return R||(R=(async()=>{const e=await(await l).sgsDataPyraminx();return new T(await b.pyraminx.kpuzzle(),e,"RLUB".split(""))})())}async function Te(e){return w(),await(await ge()).solve(e,ye,()=>3)}var Ee=f(()=>d(()=>import("./search-dynamic-sgs-unofficial-2TYKOUM4-BXlOlhbf.js"),__vite__mapDeps([7,4,1,2])));async function _e(){return w(),(await Ee).getRandomRediCubeScramble()}var pe=3,M=null;async function Pe(){return M||(M=(async()=>{const e=await(await l).sgsDataSkewb();return new T(await(await l).skewbKPuzzleWithoutMOCached(),e,"RLUB".split(""))})())}async function ze(e){return new h(await(await l).skewbKPuzzleWithoutMOCached(),{CORNERS:e.patternData.CORNERS,CENTERS:{pieces:e.patternData.CENTERS.pieces,orientation:new Array(6).fill(0)}})}async function C(e){return w(),await(await Pe()).solve(await ze(e),pe,t=>t.family==="y"?4:3)}async function xe(){return re(await(await l).skewbKPuzzleWithoutMOCached(),await(await l).sgsDataSkewbFixedCorner())}async function Re(){return C(await xe())}var Me=f(()=>d(()=>import("./search-dynamic-solve-sq1-YESVPPLF-DwfB-f2O.js"),__vite__mapDeps([10,1,2])));async function Oe(){return g.fromString(await(await Me).getRandomSquare1ScrambleString())}var De=1e3;q(!0);var I=!0;function ke(e){I=e}function O(){return(typeof performance>"u"?Date:performance).now()}async function o(e,a,r){if(!I)return a();const t=O(),n=a();n!=null&&n.then&&await n;const i=O();return console.warn(`${e}${r!=null&&r.isPrefetch?" (prefetched)":""}: ${Math.round(i-t)}ms`),n}var E=new Map,_=null;async function D(e,a){function r(){return o(`wasmRandomScrambleForEvent(${JSON.stringify(e)})`,()=>te(e),{isPrefetch:a==null?void 0:a.isPrefetch})}switch(e){case"222":return(await r()).experimentalSimplify({puzzleSpecificSimplifyOptions:{quantumMoveOrder:()=>4}});case"555":case"666":case"777":case"333fm":case"minx":case"pyram":case"555bf":return r();case"333":case"333oh":case"333ft":return o("random333Scramble",G,{isPrefetch:a==null?void 0:a.isPrefetch});case"333bf":case"333mbf":return o("random333OrientedScramble",$);case"444":return o("random444Scramble",F,{isPrefetch:a==null?void 0:a.isPrefetch});case"444bf":return o("random444OrientedScramble",le);case"skewb":return o("randomSkewbFixedCornerScramble",Re);case"sq1":return o("getRandomSquare1Scramble",Oe,{isPrefetch:a==null?void 0:a.isPrefetch});case"fto":return o("randomFTOScramble",ue,{isPrefetch:a==null?void 0:a.isPrefetch});case"master_tetraminx":return o("randomMasterTetraminxScramble",Se);case"kilominx":return o("randomKilominxScramble",de,{isPrefetch:a==null?void 0:a.isPrefetch});case"redi_cube":return o("randomRediCubeScramble",_e,{isPrefetch:a==null?void 0:a.isPrefetch});default:throw new Error(`unsupported event: ${e}`)}}var p="auto",N={initialize:async e=>{switch(e){case"222":return o("preInitialize222",ie);case"333":case"333oh":case"333ft":return o("initialize333",H);case"444":return o("initialize444",se);default:throw new Error(`unsupported event: ${e}`)}},setScramblePrefetchLevel(e){p=e},randomScrambleForEvent:async e=>{let a=E.get(e);return a?E.delete(e):a=D(e),p!=="none"&&a.then(()=>{_&&clearTimeout(_),_=setTimeout(()=>{E.set(e,D(e,{isPrefetch:!0}))},p==="immediate"?0:De)}),a},randomScrambleStringForEvent:async e=>(await N.randomScrambleForEvent(e)).toString(),solve333ToString:async e=>{const a=new h(await b["3x3x3"].kpuzzle(),e);return(await U(a)).toString()},solve222ToString:async e=>{const a=new h(await b["2x2x2"].kpuzzle(),e);return(await oe(a)).toString()},solveSkewbToString:async e=>{const a=new h(await b.skewb.kpuzzle(),e);return(await C(a)).toString()},solvePyraminxToString:async e=>{const a=new h(await b.pyraminx.kpuzzle(),e);return(await Te(a)).toString()},solveMegaminxToString:async e=>{const a=new h(await b.megaminx.kpuzzle(),e);return(await be(a)).toString()},setDebugMeasurePerf:async e=>{ke(e)},solveTwsearchToString:async(e,a,r)=>{const t=new W(e),n=new h(t,a);return(await L(e,n,r)).toString()}};Z(N); diff --git a/docs/assets/search-dynamic-sgs-side-events-RPVZU2YB-BhBJcWeZ.js b/docs/assets/search-dynamic-sgs-side-events-RPVZU2YB-Dj74dEZl.js similarity index 98% rename from docs/assets/search-dynamic-sgs-side-events-RPVZU2YB-BhBJcWeZ.js rename to docs/assets/search-dynamic-sgs-side-events-RPVZU2YB-Dj74dEZl.js index 6c843f3..450ce48 100644 --- a/docs/assets/search-dynamic-sgs-side-events-RPVZU2YB-BhBJcWeZ.js +++ b/docs/assets/search-dynamic-sgs-side-events-RPVZU2YB-Dj74dEZl.js @@ -1,5 +1,5 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BSjPx7-K.js","assets/index-lVaISq9J.js","assets/index-BF6G450p.css"])))=>i.map(i=>d[i]); -import{x as e,s as t,_ as B,v as D}from"./index-lVaISq9J.js";import{p as R}from"./chunk-Y3BVWVFU-t7GqMKda.js";var a=null;async function S(){return a??(a=n())}async function n(){return R(await e.kpuzzle(),`SubgroupSizes 24 21 18 15 12 9 6 +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-Dti57iVT.js","assets/index-BA4_IlXs.js","assets/index-BF6G450p.css"])))=>i.map(i=>d[i]); +import{x as e,s as t,_ as B,v as D}from"./index-BA4_IlXs.js";import{p as R}from"./chunk-Y3BVWVFU-DzU6t54e.js";var a=null;async function S(){return a??(a=n())}async function n(){return R(await e.kpuzzle(),`SubgroupSizes 24 21 18 15 12 9 6 Alg F Alg F2 @@ -98,7 +98,7 @@ Alg F D' F L' D F R2 U2 F' U' Alg F D' L D' L F D2 L2 B' R' Alg F L' D F R2 D2 L D F' U2 Alg F L' D F2 D' L F L2 F2 U -Alg F D F' D L2 F R' F' D' B2 U'`)}async function r(){const{getPuzzleGeometryByName:g,ExperimentalPGNotation:A}=await B(async()=>{const{getPuzzleGeometryByName:F,ExperimentalPGNotation:U}=await import("./index-BSjPx7-K.js");return{getPuzzleGeometryByName:F,ExperimentalPGNotation:U}},__vite__mapDeps([0,1,2])),L=g("megaminx",{allMoves:!0,addRotations:!0}),l=new D(L.getKPuzzleDefinition(!0),{experimentalPGNotation:new A(L,L.getOrbitsDef(!0))});return l.definition.name="megaminx",l}var i=null;async function u(){return i??(i=r())}var o=null;async function h(){return o??(o=c())}async function c(){return R(await u(),`SubgroupSizes 12 5 60 58 60 56 54 57 52 50 54 48 46 51 44 42 48 40 45 38 36 42 34 32 39 30 36 28 26 33 24 30 22 20 27 18 24 16 14 21 12 18 10 15 8 6 2 12 9 3 +Alg F D F' D L2 F R' F' D' B2 U'`)}async function r(){const{getPuzzleGeometryByName:g,ExperimentalPGNotation:A}=await B(async()=>{const{getPuzzleGeometryByName:F,ExperimentalPGNotation:U}=await import("./index-Dti57iVT.js");return{getPuzzleGeometryByName:F,ExperimentalPGNotation:U}},__vite__mapDeps([0,1,2])),L=g("megaminx",{allMoves:!0,addRotations:!0}),l=new D(L.getKPuzzleDefinition(!0),{experimentalPGNotation:new A(L,L.getOrbitsDef(!0))});return l.definition.name="megaminx",l}var i=null;async function u(){return i??(i=r())}var o=null;async function h(){return o??(o=c())}async function c(){return R(await u(),`SubgroupSizes 12 5 60 58 60 56 54 57 52 50 54 48 46 51 44 42 48 40 45 38 36 42 34 32 39 30 36 28 26 33 24 30 22 20 27 18 24 16 14 21 12 18 10 15 8 6 2 12 9 3 Alg Rv Alg Rv2 @@ -1695,7 +1695,7 @@ Alg r Alg r' Alg u -Alg u'`)}async function z(){const{getPuzzleGeometryByName:g,ExperimentalPGNotation:A}=await B(async()=>{const{getPuzzleGeometryByName:l,ExperimentalPGNotation:F}=await import("./index-BSjPx7-K.js");return{getPuzzleGeometryByName:l,ExperimentalPGNotation:F}},__vite__mapDeps([0,1,2])),L=g("skewb",{allMoves:!0,addRotations:!0});return new D(L.getKPuzzleDefinition(!0),{experimentalPGNotation:new A(L,L.getOrbitsDef(!0))})}var v=null;async function d(){return v??(v=z())}var p=null;async function f(){return p??(p=P())}async function G(){return{ordering:(await f()).ordering.slice(1)}}async function P(){return R(await d(),`SubgroupSizes 24 6 5 12 9 3 4 9 3 3 +Alg u'`)}async function z(){const{getPuzzleGeometryByName:g,ExperimentalPGNotation:A}=await B(async()=>{const{getPuzzleGeometryByName:l,ExperimentalPGNotation:F}=await import("./index-Dti57iVT.js");return{getPuzzleGeometryByName:l,ExperimentalPGNotation:F}},__vite__mapDeps([0,1,2])),L=g("skewb",{allMoves:!0,addRotations:!0});return new D(L.getKPuzzleDefinition(!0),{experimentalPGNotation:new A(L,L.getOrbitsDef(!0))})}var v=null;async function d(){return v??(v=z())}var p=null;async function f(){return p??(p=P())}async function G(){return{ordering:(await f()).ordering.slice(1)}}async function P(){return R(await d(),`SubgroupSizes 24 6 5 12 9 3 4 9 3 3 Alg y Alg y2 diff --git a/docs/assets/search-dynamic-sgs-unofficial-2TYKOUM4-C9bPN2pc.js b/docs/assets/search-dynamic-sgs-unofficial-2TYKOUM4-BXlOlhbf.js similarity index 99% rename from docs/assets/search-dynamic-sgs-unofficial-2TYKOUM4-C9bPN2pc.js rename to docs/assets/search-dynamic-sgs-unofficial-2TYKOUM4-BXlOlhbf.js index 27bcde3..9f3d27f 100644 --- a/docs/assets/search-dynamic-sgs-unofficial-2TYKOUM4-C9bPN2pc.js +++ b/docs/assets/search-dynamic-sgs-unofficial-2TYKOUM4-BXlOlhbf.js @@ -1,4 +1,4 @@ -import{p as H}from"./chunk-Y3BVWVFU-t7GqMKda.js";import{s as J,J as N,R as y}from"./index-lVaISq9J.js";var E=null;async function pB(){return E??(E=K())}async function K(){return H(await J.fto.kpuzzle(),`SubgroupSizes 24 12 11 12 12 11 10 9 11 8 10 9 7 8 10 10 6 9 8 5 7 6 5 4 4 8 7 3 6 6 360 +import{p as H}from"./chunk-Y3BVWVFU-DzU6t54e.js";import{s as J,J as N,R as y}from"./index-BA4_IlXs.js";var E=null;async function pB(){return E??(E=K())}async function K(){return H(await J.fto.kpuzzle(),`SubgroupSizes 24 12 11 12 12 11 10 9 11 8 10 9 7 8 10 10 6 9 8 5 7 6 5 4 4 8 7 3 6 6 360 Alg T Alg B diff --git a/docs/assets/search-dynamic-solve-4x4x4-V5D7RQND-BmfxzsMX.js b/docs/assets/search-dynamic-solve-4x4x4-V5D7RQND-C3wJm6SW.js similarity index 99% rename from docs/assets/search-dynamic-solve-4x4x4-V5D7RQND-BmfxzsMX.js rename to docs/assets/search-dynamic-solve-4x4x4-V5D7RQND-C3wJm6SW.js index 51e9091..2ea93cc 100644 --- a/docs/assets/search-dynamic-solve-4x4x4-V5D7RQND-BmfxzsMX.js +++ b/docs/assets/search-dynamic-solve-4x4x4-V5D7RQND-C3wJm6SW.js @@ -1 +1 @@ -import{J as Cr,A as ar,R as ze}from"./index-lVaISq9J.js";var y=[],Ie=[1];for(let e=0;e<32;++e){y[e]=[];for(let n=0;n<32;++n)y[e][n]=0}for(let e=0;e<32;++e){y[e][0]=y[e][e]=1,Ie[e+1]=Ie[e]*(e+1);for(let n=1;n0;l--)e[n[l]]=e[n[l-1]];return e[n[0]]=o,w}function Sr(e,n,r,o){r=(r||8)-1;let l=1985229328,p=0;o??(o=0),o<0&&(n<<=1);for(let u=0;u>d&7;const m=(1<>4&~m)}return o<0&&p&1?(e[r]=e[r-1],e[r-1]=l&7):e[r]=l&7,e}function _(e,n){const r=new Array(e);if(n!==void 0)for(let o=0;o=0;--n)e.ct[n]===1&&(r+=y[n][o--]);return r}function ye(e){let n,r;if(ne!==null)return ne[Fe(e)];for(r=0;r<48;++r){if(n=qr(Fe(e)),n!==-1)return n*64+r;k(e,0),r%2===1&&k(e,1),r%8===7&&k(e,2),r%16===15&&k(e,3)}}function E(e,n){const r=n%3;switch(n=~~(n/3),n){case 0:{f(e.ct,0,1,2,3,r);break}case 1:{f(e.ct,16,17,18,19,r);break}case 2:{f(e.ct,8,9,10,11,r);break}case 3:{f(e.ct,4,5,6,7,r);break}case 4:{f(e.ct,20,21,22,23,r);break}case 5:{f(e.ct,12,13,14,15,r);break}case 6:{f(e.ct,0,1,2,3,r),f(e.ct,8,20,12,16,r),f(e.ct,9,21,13,17,r);break}case 7:{f(e.ct,16,17,18,19,r),f(e.ct,1,15,5,9,r),f(e.ct,2,12,6,10,r);break}case 8:{f(e.ct,8,9,10,11,r),f(e.ct,2,19,4,21,r),f(e.ct,3,16,5,22,r);break}case 9:{f(e.ct,4,5,6,7,r),f(e.ct,10,18,14,22,r),f(e.ct,11,19,15,23,r);break}case 10:{f(e.ct,20,21,22,23,r),f(e.ct,0,8,4,14,r),f(e.ct,3,11,7,13,r);break}case 11:f(e.ct,12,13,14,15,r),f(e.ct,1,20,7,18,r),f(e.ct,0,23,6,17,r)}}function k(e,n){switch(n){case 0:{E(e,19),E(e,28);break}case 1:{E(e,21),E(e,32);break}case 2:{f(e.ct,0,3,1,2,1),f(e.ct,8,11,9,10,1),f(e.ct,4,7,5,6,1),f(e.ct,12,15,13,14,1),f(e.ct,16,19,21,22,1),f(e.ct,17,18,20,23,1);break}case 3:E(e,18),E(e,29),E(e,24),E(e,35)}}function y1(e,n){let r;for(r=0;r=0;--r)e.ct[r]=0,n>=y[r][o]&&(n-=y[r][o--],e.ct[r]=1)}function Ce(e,n){let r;for(r=0;r<24;++r)e.ct[r]=n.ct[r]}function ce(){let e;for(e1(this),e=0;e<8;++e)this.ct[e]=1;for(e=8;e<24;++e)this.ct[e]=0}function ae(e,n){let r;for(e1(this),r=0;r<24;++r)this.ct[r]=~~(e.ct[r]/2)===n?1:0}function ge(e){let n;for(e1(this),n=0;n<24;++n)this.ct[n]=e[n]}function Or(){let e,n;const r=new ce,o=new ce;for(e=0;e<15582;++e)for(r1(o,Ne[e]),n=0;n<36;++n)Ce(r,o),E(r,n),Pe[e][n]=ye(r)}function Ur(){let e,n,r,o,l,p,u,g;for(Xe(R),R[0]=0,n=0,r=1;r!==15582;)for(p=n>4,g=p?-1:n,e=p?n:-1,++n,o=0;o<15582;++o)if(R[o]===g){for(u=0;u<27;++u)if(l=~~Pe[o][u]>>>6,R[l]===e)if(++r,p){R[o]=n;break}else R[l]=n}}function Pr(e){let n,r,o;const l=new ge(e.ct);for(o=0;o<48;++o){for(n=!0,r=0;r<24;++r)if(l.ct[r]!==~~(r/4)){n=!1;break}if(n)return o;k(l,0),o%2===1&&k(l,1),o%8===7&&k(l,2),o%16===15&&k(l,3)}return-1}function Nr(){let e,n,r;const o=new ce;for(e=0;e<24;++e)o.ct[e]=e;const l=new ge(o.ct),p=new ge(o.ct),u=new ge(o.ct);for(e=0;e<48;++e){for(n=0;n<48;++n){for(r=0;r<48;++r)w1(o,l)&&(i[e][n]=r,r===0&&($[e]=n)),k(l,0),r%2===1&&k(l,1),r%8===7&&k(l,2),r%16===15&&k(l,3);k(o,0),n%2===1&&k(o,1),n%8===7&&k(o,2),n%16===15&&k(o,3)}k(o,0),e%2===1&&k(o,1),e%8===7&&k(o,2),e%16===15&&k(o,3)}for(e=0;e<48;++e)for(Ce(o,p),y1(o,$[e]),n=0;n<36;++n)for(Ce(l,o),E(l,n),y1(l,e),r=0;r<36;++r)if(Ce(u,p),E(u,r),w1(u,l)){T[e][n]=r;break}for(r1(o,0),e=0;e<48;++e)n1[$[e]]=Fe(o),k(o,0),e%2===1&&k(o,1),e%8===7&&k(o,2),e%16===15&&k(o,3)}function Vr(){let e,n,r,o;const l=new ce,p=_(22984);for(n=0;n<22984;n++)p[n]=0;for(e=0,n=0;n<735471;++n)if(!(p[~~n>>>5]&1<<(n&31))){for(r1(l,n),o=0;o<48;++o)r=Fe(l),p[~~r>>>5]|=1<<(r&31),ne!==null&&(ne[r]=e<<6|$[o]),k(l,0),o%2===1&&k(l,1),o%8===7&&k(l,2),o%16===15&&k(l,3);Ne[e++]=n}}function qr(e){const n=Ln(Ne,e);return n>=0?n:-1}L(153,1,G([R1]),ce,ae,ge);var R,Pe,n1,ne=null,Ne,$,T,i,C1=!1;function Hr(){C1||(C1=!0,Ee=_(70,28),Me=_(6435,28),X1=_(70,16),q1=_(6435,16),A=_(450450),H1=[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 je(e){let n,r,o;for(r=0,o=8,n=14;n>=0;--n)e.ct[n]!==e.ct[15]&&(r+=y[n][o--]);return r}function Be(e){let n,r,o;for(r=0,o=4,n=6;n>=0;--n)e.rl[n]!==e.rl[7]&&(r+=y[n][o--]);return r*2+e.parity}function t(e,n){e.parity^=H1[n];const r=n%3;switch(n=~~(n/3),n){case 0:{f(e.ct,0,1,2,3,r);break}case 1:{f(e.rl,0,1,2,3,r);break}case 2:{f(e.ct,8,9,10,11,r);break}case 3:{f(e.ct,4,5,6,7,r);break}case 4:{f(e.rl,4,5,6,7,r);break}case 5:{f(e.ct,12,13,14,15,r);break}case 6:{f(e.ct,0,1,2,3,r),f(e.rl,0,5,4,1,r),f(e.ct,8,9,12,13,r);break}case 7:{f(e.rl,0,1,2,3,r),f(e.ct,1,15,5,9,r),f(e.ct,2,12,6,10,r);break}case 8:{f(e.ct,8,9,10,11,r),f(e.rl,0,3,6,5,r),f(e.ct,3,2,5,4,r);break}case 9:{f(e.ct,4,5,6,7,r),f(e.rl,3,2,7,6,r),f(e.ct,11,10,15,14,r);break}case 10:{f(e.rl,4,5,6,7,r),f(e.ct,0,8,4,14,r),f(e.ct,3,11,7,13,r);break}case 11:f(e.ct,12,13,14,15,r),f(e.rl,1,4,7,2,r),f(e.ct,1,0,7,6,r)}}function Y(e,n){switch(n){case 0:{t(e,19),t(e,28);break}case 1:{t(e,21),t(e,32);break}case 2:f(e.ct,0,3,1,2,1),f(e.ct,8,11,9,10,1),f(e.ct,4,7,5,6,1),f(e.ct,12,15,13,14,1),f(e.rl,0,3,5,6,1),f(e.rl,1,2,4,7,1)}}function V1(e,n,r){let o;for(o=0;o<16;++o)e.ct[o]=~~(n.ct[o]/2);for(o=0;o<8;++o)e.rl[o]=n.ct[o+16];e.parity=r}function a1(e,n){let r,o;for(o=8,e.ct[15]=0,r=14;r>=0;--r)n>=y[r][o]?(n-=y[r][o--],e.ct[r]=1):e.ct[r]=0}function S1(e,n){let r,o;for(e.parity=n&1,n>>>=1,o=4,e.rl[7]=0,r=6;r>=0;--r)n>=y[r][o]?(n-=y[r][o--],e.rl[r]=1):e.rl[r]=0}function o1(){this.rl=_(8),this.ct=_(16)}function Xr(){let e,n,r,o,l,p,u,g,d,m;const v=new o1;for(l=0;l<70;++l)for(g=0;g<28;++g)S1(v,l),t(v,J[g]),Ee[l][g]=Be(v);for(l=0;l<70;++l)for(S1(v,l),u=0;u<16;++u)X1[l][u]=Be(v),Y(v,0),u%2===1&&Y(v,1),u%8===7&&Y(v,2);for(l=0;l<6435;++l)for(a1(v,l),u=0;u<16;++u)q1[l][u]=je(v)&65535,Y(v,0),u%2===1&&Y(v,1),u%8===7&&Y(v,2);for(l=0;l<6435;++l)for(g=0;g<28;++g)a1(v,l),t(v,J[g]),Me[l][g]=je(v)&65535;for(Xe(A),A[0]=A[18]=A[28]=A[46]=A[54]=A[56]=0,r=0,o=6;o!==450450;){const b=r>6,a=b?-1:r,z=b?r:-1;for(++r,l=0;l<450450;++l)if(A[l]===a){for(e=~~(l/70),d=l%70,g=0;g<23;++g)if(n=Me[e][g],m=Ee[d][g],p=n*70+m,A[p]===z)if(++o,b){A[l]=r;break}else A[p]=r}}}L(154,1,{},o1);c.parity=0;var Me,A,q1,H1,Ee,X1,x1=!1;function Gr(){x1||(x1=!0,_e=_(29400,20),W1=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1],q=_(29400),u1=[0,9,14,23,27,28,41,42,46,55,60,69],p1=_(70))}function l1(e){let n,r,o,l;for(r=0,l=4,n=6;n>=0;--n)e.ud[n]!==e.ud[7]&&(r+=y[n][l--]);for(r*=35,l=4,n=6;n>=0;--n)e.fb[n]!==e.fb[7]&&(r+=y[n][l--]);r*=12;const p=e.fb[7]^e.ud[7];for(o=0,l=4,n=7;n>=0;--n)e.rl[n]!==p&&(o+=y[n][l--]);return e.parity+2*(r+p1[o])}function Wr(e,n){switch(e.parity^=W1[n],n){case 0:case 1:case 2:{f(e.ud,0,1,2,3,n%3);break}case 3:{f(e.rl,0,1,2,3,1);break}case 4:case 5:case 6:{f(e.fb,0,1,2,3,(n-1)%3);break}case 7:case 8:case 9:{f(e.ud,4,5,6,7,(n-1)%3);break}case 10:{f(e.rl,4,5,6,7,1);break}case 11:case 12:case 13:{f(e.fb,4,5,6,7,(n+1)%3);break}case 14:{f(e.ud,0,1,2,3,1),f(e.rl,0,5,4,1,1),f(e.fb,0,5,4,1,1);break}case 15:{f(e.rl,0,1,2,3,1),f(e.fb,1,4,7,2,1),f(e.ud,1,6,5,2,1);break}case 16:{f(e.fb,0,1,2,3,1),f(e.ud,3,2,5,4,1),f(e.rl,0,3,6,5,1);break}case 17:{f(e.ud,4,5,6,7,1),f(e.rl,3,2,7,6,1),f(e.fb,3,2,7,6,1);break}case 18:{f(e.rl,4,5,6,7,1),f(e.fb,0,3,6,5,1),f(e.ud,0,3,4,7,1);break}case 19:f(e.fb,4,5,6,7,1),f(e.ud,0,7,6,1,1),f(e.rl,1,4,7,2,1)}}function G1(e,n,r){let o;const l=(n.ct[0]>n.ct[8]?1:0)^(n.ct[8]>n.ct[16]?1:0)^(n.ct[0]>n.ct[16]?1:0)?1:0;for(o=0;o<8;++o)e.ud[o]=n.ct[o]&1^1,e.fb[o]=n.ct[o+8]&1^1,e.rl[o]=n.ct[o+16]&1^1^l;e.parity=l^r}function Jr(e,n){let r,o,l,p;for(e.parity=n&1,n>>>=1,l=u1[n%12],n=~~(n/12),p=4,r=7;r>=0;--r)e.rl[r]=0,l>=y[r][p]&&(l-=y[r][p--],e.rl[r]=1);for(o=n%35,n=~~(n/35),p=4,e.fb[7]=0,r=6;r>=0;--r)o>=y[r][p]?(o-=y[r][p--],e.fb[r]=1):e.fb[r]=0;for(p=4,e.ud[7]=0,r=6;r>=0;--r)n>=y[r][p]?(n-=y[r][p--],e.ud[r]=1):e.ud[r]=0}function f1(){this.ud=_(8),this.rl=_(8),this.fb=_(8)}function Ir(){let e,n,r,o;for(r=0;r<12;++r)p1[u1[r]]=r;const l=new f1;for(r=0;r<29400;++r)for(o=0;o<20;++o)Jr(l,r),Wr(l,o),_e[r][o]=l1(l)&65535;for(Xe(q),q[0]=0,e=0,n=1;n!==29400;){for(r=0;r<29400;++r)if(q[r]===e)for(o=0;o<17;++o)q[_e[r][o]]===-1&&(q[_e[r][o]]=e+1,++n);++e}}L(155,1,{},f1);c.parity=0;var _e,W1,q,u1,p1;function Kr(e,n){let r;for(r=0;r<24;++r)e.ct[r]=n.ct[r]}function Yr(e,n){const r=n%3;switch(n=~~(n/3),n){case 0:{f(e.ct,0,1,2,3,r);break}case 1:{f(e.ct,16,17,18,19,r);break}case 2:{f(e.ct,8,9,10,11,r);break}case 3:{f(e.ct,4,5,6,7,r);break}case 4:{f(e.ct,20,21,22,23,r);break}case 5:{f(e.ct,12,13,14,15,r);break}case 6:{f(e.ct,0,1,2,3,r),f(e.ct,8,20,12,16,r),f(e.ct,9,21,13,17,r);break}case 7:{f(e.ct,16,17,18,19,r),f(e.ct,1,15,5,9,r),f(e.ct,2,12,6,10,r);break}case 8:{f(e.ct,8,9,10,11,r),f(e.ct,2,19,4,21,r),f(e.ct,3,16,5,22,r);break}case 9:{f(e.ct,4,5,6,7,r),f(e.ct,10,18,14,22,r),f(e.ct,11,19,15,23,r);break}case 10:{f(e.ct,20,21,22,23,r),f(e.ct,0,8,4,14,r),f(e.ct,3,11,7,13,r);break}case 11:f(e.ct,12,13,14,15,r),f(e.ct,1,20,7,18,r),f(e.ct,0,23,6,17,r)}}function g1(){let e;for(this.ct=_(24),e=0;e<24;++e)this.ct[e]=~~(e/4)}function J1(){let e,n,r;for(g1.call(this),e=0;e<23;++e)r=e+ze(24-e),this.ct[r]!==this.ct[e]&&(n=this.ct[e],this.ct[e]=this.ct[r],this.ct[r]=n)}L(156,1,{},g1,J1);var A1=!1;function Zr(){A1||(A1=!0,B=_(18),$r())}function I1(e){e.cp=[0,1,2,3,4,5,6,7],e.co=[0,0,0,0,0,0,0,0]}function K1(e,n){let r;for(r=0;r<8;++r)e.cp[r]=n.cp[r],e.co[r]=n.co[r]}function hr(e,n){!e.temps&&(e.temps=new Ve),Y1(e,B[n],e.temps),K1(e,e.temps)}function tr(e,n){let r,o;for(o=0,r=6;r>=0;--r)o+=e.co[r]=n%3,n=~~(n/3);e.co[7]=(15-o)%3}function Y1(e,n,r){let o,l,p,u;for(o=0;o<8;++o)r.cp[o]=e.cp[n.cp[o]],p=e.co[n.cp[o]],u=n.co[o],l=p,l=l+(p<3?u:6-u),l=l%3,(p>=3?1:0)^(u>=3?1:0)&&(l=l+3),r.co[o]=l}function Ve(){I1(this)}function V(e,n){I1(this),Sr(this.cp,e),tr(this,n)}function Z1(){V.call(this,ze(40320),ze(2187))}function $r(){let e,n;for(B[0]=new V(15120,0),B[3]=new V(21021,1494),B[6]=new V(8064,1236),B[9]=new V(9,0),B[12]=new V(1230,412),B[15]=new V(224,137),e=0;e<18;e+=3)for(n=0;n<2;++n)B[e+n+1]=new Ve,Y1(B[e+n],B[e],B[e+n+1])}L(157,1,G([Ar]),Ve,V,Z1);c.temps=null;var B,z1=!1;function ir(){z1||(z1=!0,Q=_(1937880),qe=_(1538),Re=_(1538),ue=_(11880),s1=[0,1,6,3,4,5,2,7],d1=_(160,12),v1=_(160,12),_1=[1,1,1,3,12,60,360,2520,20160,181440,1814400,19958400,239500800],Ze=[0,2,4,6,1,3,7,5,8,9,10,11])}function Z(e,n,r,o,l){const p=e.edgeo[l];e.edgeo[l]=e.edge[o],e.edge[o]=e.edgeo[r],e.edgeo[r]=e.edge[n],e.edge[n]=p}function oe(e,n){let r,o,l,p,u;for(e.isStd||$1(e),o=0,u=1985229328,p=47768,r=0;r=32?(o+=p>>l-32&15,p-=4368<>l&15,p-=4369,u-=286331152<>=3,Qe(e,o);const l=oe(e,10)%20160;return n*20160+l}function Te(e,n){switch(e.isStd=!1,n){case 0:{w(e.edge,0,4,1,5),w(e.edgeo,0,4,1,5);break}case 1:{C(e.edge,0,4,1,5),C(e.edgeo,0,4,1,5);break}case 2:{w(e.edge,0,5,1,4),w(e.edgeo,0,5,1,4);break}case 3:{C(e.edge,5,10,6,11),C(e.edgeo,5,10,6,11);break}case 4:{w(e.edge,0,11,3,8),w(e.edgeo,0,11,3,8);break}case 5:{C(e.edge,0,11,3,8),C(e.edgeo,0,11,3,8);break}case 6:{w(e.edge,0,8,3,11),w(e.edgeo,0,8,3,11);break}case 7:{w(e.edge,2,7,3,6),w(e.edgeo,2,7,3,6);break}case 8:{C(e.edge,2,7,3,6),C(e.edgeo,2,7,3,6);break}case 9:{w(e.edge,2,6,3,7),w(e.edgeo,2,6,3,7);break}case 10:{C(e.edge,4,8,7,9),C(e.edgeo,4,8,7,9);break}case 11:{w(e.edge,1,9,2,10),w(e.edgeo,1,9,2,10);break}case 12:{C(e.edge,1,9,2,10),C(e.edgeo,1,9,2,10);break}case 13:{w(e.edge,1,10,2,9),w(e.edgeo,1,10,2,9);break}case 14:{C(e.edge,0,4,1,5),C(e.edgeo,0,4,1,5),w(e.edge,9,11),w(e.edgeo,8,10);break}case 15:{C(e.edge,5,10,6,11),C(e.edgeo,5,10,6,11),w(e.edge,1,3),w(e.edgeo,0,2);break}case 16:{C(e.edge,0,11,3,8),C(e.edgeo,0,11,3,8),w(e.edge,5,7),w(e.edgeo,4,6);break}case 17:{C(e.edge,2,7,3,6),C(e.edgeo,2,7,3,6),w(e.edge,8,10),w(e.edgeo,9,11);break}case 18:{C(e.edge,4,8,7,9),C(e.edgeo,4,8,7,9),w(e.edge,0,2),w(e.edgeo,1,3);break}case 19:C(e.edge,1,9,2,10),C(e.edgeo,1,9,2,10),w(e.edge,4,6),w(e.edgeo,5,7)}}function s(e,n){switch(e.isStd=!1,n){case 0:{Te(e,14),Te(e,17);break}case 1:{Z(e,11,5,10,6),Z(e,5,10,6,11),Z(e,1,2,3,0),Z(e,4,9,7,8),Z(e,8,4,9,7),Z(e,0,1,2,3);break}case 2:j(e,4,5),j(e,5,4),j(e,11,8),j(e,8,11),j(e,7,6),j(e,6,7),j(e,9,10),j(e,10,9),j(e,1,1),j(e,0,0),j(e,3,3),j(e,2,2)}}function Qe(e,n){for(;n>=2;)n-=2,s(e,1),s(e,2);n!==0&&s(e,0)}function ke(e,n){let r,o,l,p,u,g;for(u=1985229328,g=47768,l=0,r=0;r<11;++r)if(o=_1[11-r],p=~~(n/o),n=n%o,l^=p,p<<=2,p>=32){p=p-32,e.edge[r]=g>>p&15;const d=(1<>4&~d)}else{e.edge[r]=u>>p&15;const d=(1<>>4&~d)+(g<<28),g=g>>4}for(l&1?(e.edge[11]=e.edge[10],e.edge[10]=u):e.edge[11]=u,r=0;r<12;++r)e.edgeo[r]=r;e.isStd=!0}function L1(e,n){let r;for(r=0;r<12;++r)e.edge[r]=n.edge[r],e.edgeo[r]=n.edgeo[r];e.isStd=n.isStd}function t1(e,n){let r,o,l,p;for(e.temp===null&&(e.temp=_(12)),r=0;r<12;++r)e.temp[r]=r,e.edge[r]=n.ep[Ze[r]+12]%12;for(o=1,r=0;r<12;++r)for(;e.edge[r]!==r;)p=e.edge[r],e.edge[r]=e.edge[p],e.edge[p]=p,l=e.temp[r],e.temp[r]=e.temp[p],e.temp[p]=l,o^=1;for(r=0;r<12;++r)e.edge[r]=e.temp[n.ep[Ze[r]]%12];return o}function $1(e){let n;for(e.temp===null&&(e.temp=_(12)),n=0;n<12;++n)e.temp[e.edgeo[n]]=n;for(n=0;n<12;++n)e.edge[n]=e.temp[e.edge[n]],e.edgeo[n]=n;e.isStd=!0}function C(e,n,r,o,l){let p;p=e[n],e[n]=e[o],e[o]=p,p=e[r],e[r]=e[l],e[l]=p}function j(e,n,r){const o=e.edge[n];e.edge[n]=e.edgeo[r],e.edgeo[r]=o}function O(){this.edge=_(12),this.edgeo=_(12)}function sr(){let e,n,r,o,l,p,u,g,d,m,v,b,a,z,S,D,F,M,I,x,U,K;const P=new O,N=new O,Ge=new O;for(Xe(Q),g=0,we=1,We(Q,0,0);we!==31006080&&(S=g>9,u=g%3,p=(g+1)%3,m=S?3:u,e=S?u:3,!(g>=9));){for(b=0;b<31006080;b+=16)if(K=Q[~~b>>4],!(!S&&K===-1)){for(v=b,d=b+16;v>=2)if((K&3)===m){for(I=~~(v/20160),n=qe[I],o=v%20160,ke(P,n*20160+o),F=0;F<17;++F)if(r=le(P.edge,F<<3,4),x=ue[r],U=x&7,x>>=3,l=le(P.edge,F<<3|U,10)%20160,a=x*20160+l,be(Q,a)===e){if(We(Q,S?v:a,p),++we,S)break;if(M=Re[x],M!==1)for(L1(N,P),Te(N,F),Qe(N,U),D=1;(M=~~M>>1&65535)!==0;++D)(M&1)===1&&(L1(Ge,N),Qe(Ge,D),z=x*20160+oe(Ge,10)%20160,be(Q,z)===e&&(We(Q,z,p),++we))}}}++g}}function be(e,n){return e[n>>4]>>((n&15)<<1)&3}function le(e,n,r){let o,l,p,u,g;const d=v1[n],m=d1[n];for(l=0,g=1985229328,u=47768,o=0;o=32?(l+=u>>p-32&15,u-=4368<>p&15,u-=4369,g-=286331152<>=3,l=le(a.edge,d<<3|b,10)%20160,g=v*20160+l,be(Q,g)===p){++u,e=g;break}return u}function en(e,n){const r=be(Q,e);return r===3?10:(1227133513<>n&3)+n-1}function rn(){let e,n,r;const o=new O;for(n=0;n<20;++n)for(r=0;r<8;++r){for(ke(o,0),Te(o,n),Qe(o,r),e=0;e<12;++e)d1[n<<3|r][e]=o.edge[e];for($1(o),e=0;e<12;++e)v1[n<<3|r][e]=o.temp[e]}}function nn(){let e,n,r,o;const l=new O,p=_(1485);for(n=0;n<1485;n++)p[n]=0;for(e=0,n=0;n<11880;++n)if(!(p[~~n>>>3]&1<<(n&7))){for(ke(l,n*_1[8]),o=0;o<8;++o)r=oe(l,4),r===n&&(Re[e]=(Re[e]|1<>3]=p[~~r>>3]|1<<(r&7),ue[r]=e<<3|s1[o],s(l,0),o%2===1&&(s(l,1),s(l,2));qe[e++]=n}}function We(e,n,r){e[n>>4]^=(3^r)<<((n&15)<<1)}L(158,1,G([zr]),O);c.isStd=!0;c.temp=null;var Ze,we=0,Q,_1,d1,v1,ue,qe,s1,Re;function on(e){let n,r,o;for(n=0,o=!1,r=0;r<12;++r)n|=1<=12;return n&=~~n>>12,n===0&&!o}function ln(e,n){let r;for(r=0;r<24;++r)e.ep[r]=n.ep[r]}function fn(e,n){const r=n%3;switch(n=~~(n/3),n){case 0:{f(e.ep,0,1,2,3,r),f(e.ep,12,13,14,15,r);break}case 1:{f(e.ep,11,15,10,19,r),f(e.ep,23,3,22,7,r);break}case 2:{f(e.ep,0,11,6,8,r),f(e.ep,12,23,18,20,r);break}case 3:{f(e.ep,4,5,6,7,r),f(e.ep,16,17,18,19,r);break}case 4:{f(e.ep,1,20,5,21,r),f(e.ep,13,8,17,9,r);break}case 5:{f(e.ep,2,9,4,10,r),f(e.ep,14,21,16,22,r);break}case 6:{f(e.ep,0,1,2,3,r),f(e.ep,12,13,14,15,r),f(e.ep,9,22,11,20,r);break}case 7:{f(e.ep,11,15,10,19,r),f(e.ep,23,3,22,7,r),f(e.ep,2,16,6,12,r);break}case 8:{f(e.ep,0,11,6,8,r),f(e.ep,12,23,18,20,r),f(e.ep,3,19,5,13,r);break}case 9:{f(e.ep,4,5,6,7,r),f(e.ep,16,17,18,19,r),f(e.ep,8,23,10,21,r);break}case 10:{f(e.ep,1,20,5,21,r),f(e.ep,13,8,17,9,r),f(e.ep,14,0,18,4,r);break}case 11:f(e.ep,2,9,4,10,r),f(e.ep,14,21,16,22,r),f(e.ep,7,15,1,17,r)}}function c1(){let e;for(this.ep=_(24),e=0;e<24;++e)this.ep[e]=e}function er(){let e,n,r;for(c1.call(this),e=0;e<23;++e)r=e+ze(24-e),r!==e&&(n=this.ep[e],this.ep[e]=this.ep[r],this.ep[r]=n)}L(159,1,{},c1,er);var F1=!1;function un(){F1||(F1=!0,he=[35,1,34,2,4,6,22,5,19])}function rr(e){e.moveBuffer=_(60)}function pn(e,n){return e.value-n.value}function fe(e,n){let r;for(ln(e.edge,n.edge),Kr(e.center,n.center),K1(e.corner,n.corner),e.value=n.value,e.add1=n.add1,e.length1=n.length1,e.length2=n.length2,e.length3=n.length3,e.sym=n.sym,r=0;r<60;++r)e.moveBuffer[r]=n.moveBuffer[r];e.moveLength=n.moveLength,e.edgeAvail=n.edgeAvail,e.centerAvail=n.centerAvail,e.cornerAvail=n.cornerAvail}function H(e){for(;e.centerAvail=27?(g[r++]=T[u][e.moveBuffer[n]]-9,l=he[T[u][e.moveBuffer[n]]-27],u=i[u][l]):g[r++]=T[u][e.moveBuffer[n]];const d=i[$[u]][Pr(H(e))];for(p="",u=d,n=r-1;n>=0;--n)o=g[n],o=~~(o/3)*3+(2-o%3),T[u][o]>=27?(p=`${p}${te[T[u][o]-9]} `,l=he[T[u][o]-27],u=i[u][l]):p=`${p}${te[T[u][o]]} `;return p}function W(e,n){e.moveBuffer[e.moveLength++]=n}function De(){rr(this),this.edge=new c1,this.center=new g1,this.corner=new Ve}function He(e){De.call(this),fe(this,e)}function or(){rr(this),this.edge=new er,this.center=new J1,this.corner=new Z1}L(160,1,G([D1,Fr]),De,He,or);c.compareTo$=function(n){return pn(this,n)};c.add1=!1;c.center=null;c.centerAvail=0;c.corner=null;c.cornerAvail=0;c.edge=null;c.edgeAvail=0;c.length1=0;c.length2=0;c.length3=0;c.moveLength=0;c.sym=0;c.value=0;var he;function _n(e,n){return n.value-e.value}function Oe(e,n){return _n(e,n)}function lr(){}L(161,1,{},lr);c.compare=function(n,r){return Oe(n,r)};var j1=!1;function dn(){if(j1)return;j1=!0;let e,n;for(te=["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'"],J=[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],pe=[0,1,2,4,6,7,8,9,10,11,13,15,16,17,19,22,25,28,31,34,36],B1=_(37),M1=_(37),h=_(37,36),Se=_(29,28),xe=_(21,20),Je=_(36),de=_(28),ee=_(20),e=0;e<29;++e)B1[J[e]]=e;for(e=0;e<21;++e)M1[pe[e]]=e;for(e=0;e<36;++e){for(n=0;n<36;++n)h[e][n]=~~(e/3)===~~(n/3)||~~(e/3)%3===~~(n/3)%3&&e>n;h[36][e]=!1}for(e=0;e<29;++e)for(n=0;n<28;++n)Se[e][n]=h[J[e]][J[n]];for(e=0;e<21;++e)for(n=0;n<20;++n)xe[e][n]=h[pe[e]][pe[n]];for(e=0;e<36;++e)for(Je[e]=36,n=e;n<36;++n)if(!h[e][n]){Je[e]=n-1;break}for(e=0;e<28;++e)for(de[e]=28,n=e;n<28;++n)if(!Se[e][n]){de[e]=n-1;break}for(e=0;e<20;++e)for(ee[e]=20,n=e;n<20;++n)if(!xe[e][n]){ee[e]=n-1;break}}var h,Se,xe,J,te,pe,Je,de,ee,B1,M1;function vn(e){let n,r,o,l,p,u,g,d,m,v,b,a;e.solution="";const z=ye(new ae(H(e.c),0)),S=ye(new ae(H(e.c),1)),D=ye(new ae(H(e.c),2)),F=R[~~z>>6],M=R[~~S>>6],I=R[~~D>>6];for(e.p1SolsCnt=0,e.arr2idx=0,an(e.p1sols.heap),e.length1=(F>>6,D&63,e.length1,-1,0)||F<=e.length1&&Ae(e,~~z>>>6,z&63,e.length1,-1,0)||M<=e.length1&&Ae(e,~~S>>>6,S&63,e.length1,-1,0));++e.length1);const x=Tn(e.p1sols,se(Rn,G([Lr,$e,ie]),D1,0,0));x.sort(function(P,N){return P.value-N.value}),n=9;do{e:for(d=x[0].value;d<100;++d)for(u=0;ud);++u)if(!(d-x[u].length1>n)&&(fe(e.c1,x[u]),V1(e.ct2,H(e.c1),Ue(me(e.c1).ep)),b=je(e.ct2),a=Be(e.ct2),e.length1=x[u].length1,e.length2=d-x[u].length1,fr(e,b,a,e.length2,28,0)))break e;++n}while(d===100);e.arr2.sort(function(P,N){return P.value-N.value}),g=0,r=13;do{e:for(m=e.arr2[0].value;m<100;++m)for(u=0;um);++u)if(!(m-e.arr2[u].length1-e.arr2[u].length2>r)&&(p=t1(e.e12,me(e.arr2[u])),G1(e.ct3,H(e.arr2[u]),p^Ue(nr(e.arr2[u]).cp)),o=l1(e.ct3),l=oe(e.e12,10),v=i1(h1(e.e12)),v<=m-e.arr2[u].length1-e.arr2[u].length2&&ur(e,l,o,v,m-e.arr2[u].length1-e.arr2[u].length2,20,0))){g=u;break e}++r}while(m===100);const U=new He(e.arr2[g]);e.length1=U.length1,e.length2=U.length2;const K=m-e.length1-e.length2;for(u=0;ue.c1.value&&fe(o,e.c1)),wn(e.p1sols,o),e.p1SolsCnt===1e4}function bn(e){let n;for(fe(e.c2,e.c1),n=0;n>>6],v>=o){if(v>o)break;continue}if(b=i[r][g&63],g>>>=6,e.move1[p]=d,Ae(e,g,b,o-1,u,p+1))return!0}return!1}function fr(e,n,r,o,l,p){let u,g,d,m;if(n===0&&A[r]===0)return o===0&&bn(e);for(g=0;g<23;++g){if(Se[l][g]){g=de[g];continue}if(u=Me[n][g],m=Ee[r][g],d=A[u*70+m],d>=o){d>o&&(g=de[g]);continue}if(e.move2[p]=J[g],fr(e,u,m,o-1,g,p+1))return!0}return!1}function ur(e,n,r,o,l,p,u){let g,d,m,v,b,a,z,S,D;if(l===0)return n===0&&r===0;for(ke(e.tempe[u],n),b=0;b<17;++b){if(xe[p][b]){b=ee[b];continue}if(m=_e[r][b],a=q[m],a>=l){a>l&&b<14&&(b=ee[b]);continue}if(v=le(e.tempe[u].edge,b<<3,10),g=~~(v/20160),S=ue[g],D=S&7,S>>=3,d=le(e.tempe[u].edge,b<<3|D,10)%20160,z=en(S*20160+d,o),z>=l){z>l&&b<14&&(b=ee[b]);continue}if(ur(e,v,m,z,l-1,b,u+1))return e.move3[u]=b,!0}return!1}function pr(){let e;for(this.p1sols=new mr(new lr),this.move1=_(15),this.move2=_(20),this.move3=_(20),this.c1=new De,this.c2=new De,this.ct2=new o1,this.ct3=new f1,this.e12=new O,this.tempe=_(20),this.arr2=_(100),e=0;e<20;++e)this.tempe[e]=new O}function gr(){E1||(Nr(),ne=_(735471),Vr(),Or(),ne=null,Ur(),Xr(),Ir(),rn(),nn(),sr(),E1=!0)}L(163,1,G([jr]),pr);c.add1=!1;c.arr2idx=0;c.c=null;c.length1=0;c.length2=0;c.p1SolsCnt=0;c.solution="";var E1=!1;function Ue(e){let n,r,o,l;for(l=0,n=0,o=e.length;ne[r]&&(l^=1);return l}function f(e,n,r,o,l,p){let u;switch(p){case 0:{u=e[l],e[l]=e[o],e[o]=e[r],e[r]=e[n],e[n]=u;return}case 1:{u=e[n],e[n]=e[o],e[o]=u,u=e[r],e[r]=e[l],e[l]=u;return}case 2:{u=e[n],e[n]=e[r],e[r]=e[o],e[o]=e[l],e[l]=u;return}}}function _r(){}function dr(e,n,r,o){const l=new _r;return l.typeName=e+n,cr(r!==0?-r:0)&&br(r!==0?-r:0,l),l.modifiers=4,l.superclass=b1,l.componentType=o,l}function vr(e,n,r,o){const l=new _r;return l.typeName=e+n,cr(r)&&br(r,l),l.superclass=o,l}function kn(e){const n=ve[e.seedId];return e=null,n}function cr(e){return typeof e=="number"&&e>0}function br(e,n){let r;if(n.seedId=e,e===2)r=String.prototype;else if(e>0){let o=kn(n);if(o)r=o.prototype;else{o=ve[e]=function(){},o.___clazz$=n;return}}else return;r.___clazz$=n}c.val$outerIter=null;function wn(e,n){if(Bn(e,n))return!0}function yn(e){e.array=se(kr,G([$e,ie]),Q1,0,0)}function Cn(e,n){return Le(e.array,e.size++,n),!0}function an(e){e.array=se(kr,G([$e,ie]),Q1,0,0),e.size=0}function X(e,n){return e.array[n]}function Sn(e,n){const r=e.array[n];return zn(e.array,n,1),--e.size,r}function re(e,n,r){const o=e.array[n];return Le(e.array,n,r),o}function xn(e,n){let r;for(n.lengthe.size&&Le(n,e.size,null),n}function An(){yn(this),this.array.length=500}function zn(e,n,r){e.splice(n,r)}c.size=0;function Ln(e,n){let r,o,l,p;for(o=0,r=e.length-1;o<=r;)if(l=o+(~~(r-o)>>1),p=e[l],pn)r=l-1;else return l;return-o-1}function Xe(e){Fn(e,e.length)}function Fn(e,n){let r;for(r=0;r0;){if(r=o,o=~~((o-1)/2),Oe(X(e.heap,o),n)<=0)return re(e.heap,r,n),!0;re(e.heap,r,X(e.heap,o))}return re(e.heap,o,n),!0}function Mn(e){if(e.heap.size===0)return null;const n=X(e.heap,0);return En(e),n}function En(e){const n=Sn(e.heap,e.heap.size-1);00;l--)e[n[l]]=e[n[l-1]];return e[n[0]]=o,w}function Sr(e,n,r,o){r=(r||8)-1;let l=1985229328,p=0;o??(o=0),o<0&&(n<<=1);for(let u=0;u>d&7;const m=(1<>4&~m)}return o<0&&p&1?(e[r]=e[r-1],e[r-1]=l&7):e[r]=l&7,e}function _(e,n){const r=new Array(e);if(n!==void 0)for(let o=0;o=0;--n)e.ct[n]===1&&(r+=y[n][o--]);return r}function ye(e){let n,r;if(ne!==null)return ne[Fe(e)];for(r=0;r<48;++r){if(n=qr(Fe(e)),n!==-1)return n*64+r;k(e,0),r%2===1&&k(e,1),r%8===7&&k(e,2),r%16===15&&k(e,3)}}function E(e,n){const r=n%3;switch(n=~~(n/3),n){case 0:{f(e.ct,0,1,2,3,r);break}case 1:{f(e.ct,16,17,18,19,r);break}case 2:{f(e.ct,8,9,10,11,r);break}case 3:{f(e.ct,4,5,6,7,r);break}case 4:{f(e.ct,20,21,22,23,r);break}case 5:{f(e.ct,12,13,14,15,r);break}case 6:{f(e.ct,0,1,2,3,r),f(e.ct,8,20,12,16,r),f(e.ct,9,21,13,17,r);break}case 7:{f(e.ct,16,17,18,19,r),f(e.ct,1,15,5,9,r),f(e.ct,2,12,6,10,r);break}case 8:{f(e.ct,8,9,10,11,r),f(e.ct,2,19,4,21,r),f(e.ct,3,16,5,22,r);break}case 9:{f(e.ct,4,5,6,7,r),f(e.ct,10,18,14,22,r),f(e.ct,11,19,15,23,r);break}case 10:{f(e.ct,20,21,22,23,r),f(e.ct,0,8,4,14,r),f(e.ct,3,11,7,13,r);break}case 11:f(e.ct,12,13,14,15,r),f(e.ct,1,20,7,18,r),f(e.ct,0,23,6,17,r)}}function k(e,n){switch(n){case 0:{E(e,19),E(e,28);break}case 1:{E(e,21),E(e,32);break}case 2:{f(e.ct,0,3,1,2,1),f(e.ct,8,11,9,10,1),f(e.ct,4,7,5,6,1),f(e.ct,12,15,13,14,1),f(e.ct,16,19,21,22,1),f(e.ct,17,18,20,23,1);break}case 3:E(e,18),E(e,29),E(e,24),E(e,35)}}function y1(e,n){let r;for(r=0;r=0;--r)e.ct[r]=0,n>=y[r][o]&&(n-=y[r][o--],e.ct[r]=1)}function Ce(e,n){let r;for(r=0;r<24;++r)e.ct[r]=n.ct[r]}function ce(){let e;for(e1(this),e=0;e<8;++e)this.ct[e]=1;for(e=8;e<24;++e)this.ct[e]=0}function ae(e,n){let r;for(e1(this),r=0;r<24;++r)this.ct[r]=~~(e.ct[r]/2)===n?1:0}function ge(e){let n;for(e1(this),n=0;n<24;++n)this.ct[n]=e[n]}function Or(){let e,n;const r=new ce,o=new ce;for(e=0;e<15582;++e)for(r1(o,Ne[e]),n=0;n<36;++n)Ce(r,o),E(r,n),Pe[e][n]=ye(r)}function Ur(){let e,n,r,o,l,p,u,g;for(Xe(R),R[0]=0,n=0,r=1;r!==15582;)for(p=n>4,g=p?-1:n,e=p?n:-1,++n,o=0;o<15582;++o)if(R[o]===g){for(u=0;u<27;++u)if(l=~~Pe[o][u]>>>6,R[l]===e)if(++r,p){R[o]=n;break}else R[l]=n}}function Pr(e){let n,r,o;const l=new ge(e.ct);for(o=0;o<48;++o){for(n=!0,r=0;r<24;++r)if(l.ct[r]!==~~(r/4)){n=!1;break}if(n)return o;k(l,0),o%2===1&&k(l,1),o%8===7&&k(l,2),o%16===15&&k(l,3)}return-1}function Nr(){let e,n,r;const o=new ce;for(e=0;e<24;++e)o.ct[e]=e;const l=new ge(o.ct),p=new ge(o.ct),u=new ge(o.ct);for(e=0;e<48;++e){for(n=0;n<48;++n){for(r=0;r<48;++r)w1(o,l)&&(i[e][n]=r,r===0&&($[e]=n)),k(l,0),r%2===1&&k(l,1),r%8===7&&k(l,2),r%16===15&&k(l,3);k(o,0),n%2===1&&k(o,1),n%8===7&&k(o,2),n%16===15&&k(o,3)}k(o,0),e%2===1&&k(o,1),e%8===7&&k(o,2),e%16===15&&k(o,3)}for(e=0;e<48;++e)for(Ce(o,p),y1(o,$[e]),n=0;n<36;++n)for(Ce(l,o),E(l,n),y1(l,e),r=0;r<36;++r)if(Ce(u,p),E(u,r),w1(u,l)){T[e][n]=r;break}for(r1(o,0),e=0;e<48;++e)n1[$[e]]=Fe(o),k(o,0),e%2===1&&k(o,1),e%8===7&&k(o,2),e%16===15&&k(o,3)}function Vr(){let e,n,r,o;const l=new ce,p=_(22984);for(n=0;n<22984;n++)p[n]=0;for(e=0,n=0;n<735471;++n)if(!(p[~~n>>>5]&1<<(n&31))){for(r1(l,n),o=0;o<48;++o)r=Fe(l),p[~~r>>>5]|=1<<(r&31),ne!==null&&(ne[r]=e<<6|$[o]),k(l,0),o%2===1&&k(l,1),o%8===7&&k(l,2),o%16===15&&k(l,3);Ne[e++]=n}}function qr(e){const n=Ln(Ne,e);return n>=0?n:-1}L(153,1,G([R1]),ce,ae,ge);var R,Pe,n1,ne=null,Ne,$,T,i,C1=!1;function Hr(){C1||(C1=!0,Ee=_(70,28),Me=_(6435,28),X1=_(70,16),q1=_(6435,16),A=_(450450),H1=[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 je(e){let n,r,o;for(r=0,o=8,n=14;n>=0;--n)e.ct[n]!==e.ct[15]&&(r+=y[n][o--]);return r}function Be(e){let n,r,o;for(r=0,o=4,n=6;n>=0;--n)e.rl[n]!==e.rl[7]&&(r+=y[n][o--]);return r*2+e.parity}function t(e,n){e.parity^=H1[n];const r=n%3;switch(n=~~(n/3),n){case 0:{f(e.ct,0,1,2,3,r);break}case 1:{f(e.rl,0,1,2,3,r);break}case 2:{f(e.ct,8,9,10,11,r);break}case 3:{f(e.ct,4,5,6,7,r);break}case 4:{f(e.rl,4,5,6,7,r);break}case 5:{f(e.ct,12,13,14,15,r);break}case 6:{f(e.ct,0,1,2,3,r),f(e.rl,0,5,4,1,r),f(e.ct,8,9,12,13,r);break}case 7:{f(e.rl,0,1,2,3,r),f(e.ct,1,15,5,9,r),f(e.ct,2,12,6,10,r);break}case 8:{f(e.ct,8,9,10,11,r),f(e.rl,0,3,6,5,r),f(e.ct,3,2,5,4,r);break}case 9:{f(e.ct,4,5,6,7,r),f(e.rl,3,2,7,6,r),f(e.ct,11,10,15,14,r);break}case 10:{f(e.rl,4,5,6,7,r),f(e.ct,0,8,4,14,r),f(e.ct,3,11,7,13,r);break}case 11:f(e.ct,12,13,14,15,r),f(e.rl,1,4,7,2,r),f(e.ct,1,0,7,6,r)}}function Y(e,n){switch(n){case 0:{t(e,19),t(e,28);break}case 1:{t(e,21),t(e,32);break}case 2:f(e.ct,0,3,1,2,1),f(e.ct,8,11,9,10,1),f(e.ct,4,7,5,6,1),f(e.ct,12,15,13,14,1),f(e.rl,0,3,5,6,1),f(e.rl,1,2,4,7,1)}}function V1(e,n,r){let o;for(o=0;o<16;++o)e.ct[o]=~~(n.ct[o]/2);for(o=0;o<8;++o)e.rl[o]=n.ct[o+16];e.parity=r}function a1(e,n){let r,o;for(o=8,e.ct[15]=0,r=14;r>=0;--r)n>=y[r][o]?(n-=y[r][o--],e.ct[r]=1):e.ct[r]=0}function S1(e,n){let r,o;for(e.parity=n&1,n>>>=1,o=4,e.rl[7]=0,r=6;r>=0;--r)n>=y[r][o]?(n-=y[r][o--],e.rl[r]=1):e.rl[r]=0}function o1(){this.rl=_(8),this.ct=_(16)}function Xr(){let e,n,r,o,l,p,u,g,d,m;const v=new o1;for(l=0;l<70;++l)for(g=0;g<28;++g)S1(v,l),t(v,J[g]),Ee[l][g]=Be(v);for(l=0;l<70;++l)for(S1(v,l),u=0;u<16;++u)X1[l][u]=Be(v),Y(v,0),u%2===1&&Y(v,1),u%8===7&&Y(v,2);for(l=0;l<6435;++l)for(a1(v,l),u=0;u<16;++u)q1[l][u]=je(v)&65535,Y(v,0),u%2===1&&Y(v,1),u%8===7&&Y(v,2);for(l=0;l<6435;++l)for(g=0;g<28;++g)a1(v,l),t(v,J[g]),Me[l][g]=je(v)&65535;for(Xe(A),A[0]=A[18]=A[28]=A[46]=A[54]=A[56]=0,r=0,o=6;o!==450450;){const b=r>6,a=b?-1:r,z=b?r:-1;for(++r,l=0;l<450450;++l)if(A[l]===a){for(e=~~(l/70),d=l%70,g=0;g<23;++g)if(n=Me[e][g],m=Ee[d][g],p=n*70+m,A[p]===z)if(++o,b){A[l]=r;break}else A[p]=r}}}L(154,1,{},o1);c.parity=0;var Me,A,q1,H1,Ee,X1,x1=!1;function Gr(){x1||(x1=!0,_e=_(29400,20),W1=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1],q=_(29400),u1=[0,9,14,23,27,28,41,42,46,55,60,69],p1=_(70))}function l1(e){let n,r,o,l;for(r=0,l=4,n=6;n>=0;--n)e.ud[n]!==e.ud[7]&&(r+=y[n][l--]);for(r*=35,l=4,n=6;n>=0;--n)e.fb[n]!==e.fb[7]&&(r+=y[n][l--]);r*=12;const p=e.fb[7]^e.ud[7];for(o=0,l=4,n=7;n>=0;--n)e.rl[n]!==p&&(o+=y[n][l--]);return e.parity+2*(r+p1[o])}function Wr(e,n){switch(e.parity^=W1[n],n){case 0:case 1:case 2:{f(e.ud,0,1,2,3,n%3);break}case 3:{f(e.rl,0,1,2,3,1);break}case 4:case 5:case 6:{f(e.fb,0,1,2,3,(n-1)%3);break}case 7:case 8:case 9:{f(e.ud,4,5,6,7,(n-1)%3);break}case 10:{f(e.rl,4,5,6,7,1);break}case 11:case 12:case 13:{f(e.fb,4,5,6,7,(n+1)%3);break}case 14:{f(e.ud,0,1,2,3,1),f(e.rl,0,5,4,1,1),f(e.fb,0,5,4,1,1);break}case 15:{f(e.rl,0,1,2,3,1),f(e.fb,1,4,7,2,1),f(e.ud,1,6,5,2,1);break}case 16:{f(e.fb,0,1,2,3,1),f(e.ud,3,2,5,4,1),f(e.rl,0,3,6,5,1);break}case 17:{f(e.ud,4,5,6,7,1),f(e.rl,3,2,7,6,1),f(e.fb,3,2,7,6,1);break}case 18:{f(e.rl,4,5,6,7,1),f(e.fb,0,3,6,5,1),f(e.ud,0,3,4,7,1);break}case 19:f(e.fb,4,5,6,7,1),f(e.ud,0,7,6,1,1),f(e.rl,1,4,7,2,1)}}function G1(e,n,r){let o;const l=(n.ct[0]>n.ct[8]?1:0)^(n.ct[8]>n.ct[16]?1:0)^(n.ct[0]>n.ct[16]?1:0)?1:0;for(o=0;o<8;++o)e.ud[o]=n.ct[o]&1^1,e.fb[o]=n.ct[o+8]&1^1,e.rl[o]=n.ct[o+16]&1^1^l;e.parity=l^r}function Jr(e,n){let r,o,l,p;for(e.parity=n&1,n>>>=1,l=u1[n%12],n=~~(n/12),p=4,r=7;r>=0;--r)e.rl[r]=0,l>=y[r][p]&&(l-=y[r][p--],e.rl[r]=1);for(o=n%35,n=~~(n/35),p=4,e.fb[7]=0,r=6;r>=0;--r)o>=y[r][p]?(o-=y[r][p--],e.fb[r]=1):e.fb[r]=0;for(p=4,e.ud[7]=0,r=6;r>=0;--r)n>=y[r][p]?(n-=y[r][p--],e.ud[r]=1):e.ud[r]=0}function f1(){this.ud=_(8),this.rl=_(8),this.fb=_(8)}function Ir(){let e,n,r,o;for(r=0;r<12;++r)p1[u1[r]]=r;const l=new f1;for(r=0;r<29400;++r)for(o=0;o<20;++o)Jr(l,r),Wr(l,o),_e[r][o]=l1(l)&65535;for(Xe(q),q[0]=0,e=0,n=1;n!==29400;){for(r=0;r<29400;++r)if(q[r]===e)for(o=0;o<17;++o)q[_e[r][o]]===-1&&(q[_e[r][o]]=e+1,++n);++e}}L(155,1,{},f1);c.parity=0;var _e,W1,q,u1,p1;function Kr(e,n){let r;for(r=0;r<24;++r)e.ct[r]=n.ct[r]}function Yr(e,n){const r=n%3;switch(n=~~(n/3),n){case 0:{f(e.ct,0,1,2,3,r);break}case 1:{f(e.ct,16,17,18,19,r);break}case 2:{f(e.ct,8,9,10,11,r);break}case 3:{f(e.ct,4,5,6,7,r);break}case 4:{f(e.ct,20,21,22,23,r);break}case 5:{f(e.ct,12,13,14,15,r);break}case 6:{f(e.ct,0,1,2,3,r),f(e.ct,8,20,12,16,r),f(e.ct,9,21,13,17,r);break}case 7:{f(e.ct,16,17,18,19,r),f(e.ct,1,15,5,9,r),f(e.ct,2,12,6,10,r);break}case 8:{f(e.ct,8,9,10,11,r),f(e.ct,2,19,4,21,r),f(e.ct,3,16,5,22,r);break}case 9:{f(e.ct,4,5,6,7,r),f(e.ct,10,18,14,22,r),f(e.ct,11,19,15,23,r);break}case 10:{f(e.ct,20,21,22,23,r),f(e.ct,0,8,4,14,r),f(e.ct,3,11,7,13,r);break}case 11:f(e.ct,12,13,14,15,r),f(e.ct,1,20,7,18,r),f(e.ct,0,23,6,17,r)}}function g1(){let e;for(this.ct=_(24),e=0;e<24;++e)this.ct[e]=~~(e/4)}function J1(){let e,n,r;for(g1.call(this),e=0;e<23;++e)r=e+ze(24-e),this.ct[r]!==this.ct[e]&&(n=this.ct[e],this.ct[e]=this.ct[r],this.ct[r]=n)}L(156,1,{},g1,J1);var A1=!1;function Zr(){A1||(A1=!0,B=_(18),$r())}function I1(e){e.cp=[0,1,2,3,4,5,6,7],e.co=[0,0,0,0,0,0,0,0]}function K1(e,n){let r;for(r=0;r<8;++r)e.cp[r]=n.cp[r],e.co[r]=n.co[r]}function hr(e,n){!e.temps&&(e.temps=new Ve),Y1(e,B[n],e.temps),K1(e,e.temps)}function tr(e,n){let r,o;for(o=0,r=6;r>=0;--r)o+=e.co[r]=n%3,n=~~(n/3);e.co[7]=(15-o)%3}function Y1(e,n,r){let o,l,p,u;for(o=0;o<8;++o)r.cp[o]=e.cp[n.cp[o]],p=e.co[n.cp[o]],u=n.co[o],l=p,l=l+(p<3?u:6-u),l=l%3,(p>=3?1:0)^(u>=3?1:0)&&(l=l+3),r.co[o]=l}function Ve(){I1(this)}function V(e,n){I1(this),Sr(this.cp,e),tr(this,n)}function Z1(){V.call(this,ze(40320),ze(2187))}function $r(){let e,n;for(B[0]=new V(15120,0),B[3]=new V(21021,1494),B[6]=new V(8064,1236),B[9]=new V(9,0),B[12]=new V(1230,412),B[15]=new V(224,137),e=0;e<18;e+=3)for(n=0;n<2;++n)B[e+n+1]=new Ve,Y1(B[e+n],B[e],B[e+n+1])}L(157,1,G([Ar]),Ve,V,Z1);c.temps=null;var B,z1=!1;function ir(){z1||(z1=!0,Q=_(1937880),qe=_(1538),Re=_(1538),ue=_(11880),s1=[0,1,6,3,4,5,2,7],d1=_(160,12),v1=_(160,12),_1=[1,1,1,3,12,60,360,2520,20160,181440,1814400,19958400,239500800],Ze=[0,2,4,6,1,3,7,5,8,9,10,11])}function Z(e,n,r,o,l){const p=e.edgeo[l];e.edgeo[l]=e.edge[o],e.edge[o]=e.edgeo[r],e.edgeo[r]=e.edge[n],e.edge[n]=p}function oe(e,n){let r,o,l,p,u;for(e.isStd||$1(e),o=0,u=1985229328,p=47768,r=0;r=32?(o+=p>>l-32&15,p-=4368<>l&15,p-=4369,u-=286331152<>=3,Qe(e,o);const l=oe(e,10)%20160;return n*20160+l}function Te(e,n){switch(e.isStd=!1,n){case 0:{w(e.edge,0,4,1,5),w(e.edgeo,0,4,1,5);break}case 1:{C(e.edge,0,4,1,5),C(e.edgeo,0,4,1,5);break}case 2:{w(e.edge,0,5,1,4),w(e.edgeo,0,5,1,4);break}case 3:{C(e.edge,5,10,6,11),C(e.edgeo,5,10,6,11);break}case 4:{w(e.edge,0,11,3,8),w(e.edgeo,0,11,3,8);break}case 5:{C(e.edge,0,11,3,8),C(e.edgeo,0,11,3,8);break}case 6:{w(e.edge,0,8,3,11),w(e.edgeo,0,8,3,11);break}case 7:{w(e.edge,2,7,3,6),w(e.edgeo,2,7,3,6);break}case 8:{C(e.edge,2,7,3,6),C(e.edgeo,2,7,3,6);break}case 9:{w(e.edge,2,6,3,7),w(e.edgeo,2,6,3,7);break}case 10:{C(e.edge,4,8,7,9),C(e.edgeo,4,8,7,9);break}case 11:{w(e.edge,1,9,2,10),w(e.edgeo,1,9,2,10);break}case 12:{C(e.edge,1,9,2,10),C(e.edgeo,1,9,2,10);break}case 13:{w(e.edge,1,10,2,9),w(e.edgeo,1,10,2,9);break}case 14:{C(e.edge,0,4,1,5),C(e.edgeo,0,4,1,5),w(e.edge,9,11),w(e.edgeo,8,10);break}case 15:{C(e.edge,5,10,6,11),C(e.edgeo,5,10,6,11),w(e.edge,1,3),w(e.edgeo,0,2);break}case 16:{C(e.edge,0,11,3,8),C(e.edgeo,0,11,3,8),w(e.edge,5,7),w(e.edgeo,4,6);break}case 17:{C(e.edge,2,7,3,6),C(e.edgeo,2,7,3,6),w(e.edge,8,10),w(e.edgeo,9,11);break}case 18:{C(e.edge,4,8,7,9),C(e.edgeo,4,8,7,9),w(e.edge,0,2),w(e.edgeo,1,3);break}case 19:C(e.edge,1,9,2,10),C(e.edgeo,1,9,2,10),w(e.edge,4,6),w(e.edgeo,5,7)}}function s(e,n){switch(e.isStd=!1,n){case 0:{Te(e,14),Te(e,17);break}case 1:{Z(e,11,5,10,6),Z(e,5,10,6,11),Z(e,1,2,3,0),Z(e,4,9,7,8),Z(e,8,4,9,7),Z(e,0,1,2,3);break}case 2:j(e,4,5),j(e,5,4),j(e,11,8),j(e,8,11),j(e,7,6),j(e,6,7),j(e,9,10),j(e,10,9),j(e,1,1),j(e,0,0),j(e,3,3),j(e,2,2)}}function Qe(e,n){for(;n>=2;)n-=2,s(e,1),s(e,2);n!==0&&s(e,0)}function ke(e,n){let r,o,l,p,u,g;for(u=1985229328,g=47768,l=0,r=0;r<11;++r)if(o=_1[11-r],p=~~(n/o),n=n%o,l^=p,p<<=2,p>=32){p=p-32,e.edge[r]=g>>p&15;const d=(1<>4&~d)}else{e.edge[r]=u>>p&15;const d=(1<>>4&~d)+(g<<28),g=g>>4}for(l&1?(e.edge[11]=e.edge[10],e.edge[10]=u):e.edge[11]=u,r=0;r<12;++r)e.edgeo[r]=r;e.isStd=!0}function L1(e,n){let r;for(r=0;r<12;++r)e.edge[r]=n.edge[r],e.edgeo[r]=n.edgeo[r];e.isStd=n.isStd}function t1(e,n){let r,o,l,p;for(e.temp===null&&(e.temp=_(12)),r=0;r<12;++r)e.temp[r]=r,e.edge[r]=n.ep[Ze[r]+12]%12;for(o=1,r=0;r<12;++r)for(;e.edge[r]!==r;)p=e.edge[r],e.edge[r]=e.edge[p],e.edge[p]=p,l=e.temp[r],e.temp[r]=e.temp[p],e.temp[p]=l,o^=1;for(r=0;r<12;++r)e.edge[r]=e.temp[n.ep[Ze[r]]%12];return o}function $1(e){let n;for(e.temp===null&&(e.temp=_(12)),n=0;n<12;++n)e.temp[e.edgeo[n]]=n;for(n=0;n<12;++n)e.edge[n]=e.temp[e.edge[n]],e.edgeo[n]=n;e.isStd=!0}function C(e,n,r,o,l){let p;p=e[n],e[n]=e[o],e[o]=p,p=e[r],e[r]=e[l],e[l]=p}function j(e,n,r){const o=e.edge[n];e.edge[n]=e.edgeo[r],e.edgeo[r]=o}function O(){this.edge=_(12),this.edgeo=_(12)}function sr(){let e,n,r,o,l,p,u,g,d,m,v,b,a,z,S,D,F,M,I,x,U,K;const P=new O,N=new O,Ge=new O;for(Xe(Q),g=0,we=1,We(Q,0,0);we!==31006080&&(S=g>9,u=g%3,p=(g+1)%3,m=S?3:u,e=S?u:3,!(g>=9));){for(b=0;b<31006080;b+=16)if(K=Q[~~b>>4],!(!S&&K===-1)){for(v=b,d=b+16;v>=2)if((K&3)===m){for(I=~~(v/20160),n=qe[I],o=v%20160,ke(P,n*20160+o),F=0;F<17;++F)if(r=le(P.edge,F<<3,4),x=ue[r],U=x&7,x>>=3,l=le(P.edge,F<<3|U,10)%20160,a=x*20160+l,be(Q,a)===e){if(We(Q,S?v:a,p),++we,S)break;if(M=Re[x],M!==1)for(L1(N,P),Te(N,F),Qe(N,U),D=1;(M=~~M>>1&65535)!==0;++D)(M&1)===1&&(L1(Ge,N),Qe(Ge,D),z=x*20160+oe(Ge,10)%20160,be(Q,z)===e&&(We(Q,z,p),++we))}}}++g}}function be(e,n){return e[n>>4]>>((n&15)<<1)&3}function le(e,n,r){let o,l,p,u,g;const d=v1[n],m=d1[n];for(l=0,g=1985229328,u=47768,o=0;o=32?(l+=u>>p-32&15,u-=4368<>p&15,u-=4369,g-=286331152<>=3,l=le(a.edge,d<<3|b,10)%20160,g=v*20160+l,be(Q,g)===p){++u,e=g;break}return u}function en(e,n){const r=be(Q,e);return r===3?10:(1227133513<>n&3)+n-1}function rn(){let e,n,r;const o=new O;for(n=0;n<20;++n)for(r=0;r<8;++r){for(ke(o,0),Te(o,n),Qe(o,r),e=0;e<12;++e)d1[n<<3|r][e]=o.edge[e];for($1(o),e=0;e<12;++e)v1[n<<3|r][e]=o.temp[e]}}function nn(){let e,n,r,o;const l=new O,p=_(1485);for(n=0;n<1485;n++)p[n]=0;for(e=0,n=0;n<11880;++n)if(!(p[~~n>>>3]&1<<(n&7))){for(ke(l,n*_1[8]),o=0;o<8;++o)r=oe(l,4),r===n&&(Re[e]=(Re[e]|1<>3]=p[~~r>>3]|1<<(r&7),ue[r]=e<<3|s1[o],s(l,0),o%2===1&&(s(l,1),s(l,2));qe[e++]=n}}function We(e,n,r){e[n>>4]^=(3^r)<<((n&15)<<1)}L(158,1,G([zr]),O);c.isStd=!0;c.temp=null;var Ze,we=0,Q,_1,d1,v1,ue,qe,s1,Re;function on(e){let n,r,o;for(n=0,o=!1,r=0;r<12;++r)n|=1<=12;return n&=~~n>>12,n===0&&!o}function ln(e,n){let r;for(r=0;r<24;++r)e.ep[r]=n.ep[r]}function fn(e,n){const r=n%3;switch(n=~~(n/3),n){case 0:{f(e.ep,0,1,2,3,r),f(e.ep,12,13,14,15,r);break}case 1:{f(e.ep,11,15,10,19,r),f(e.ep,23,3,22,7,r);break}case 2:{f(e.ep,0,11,6,8,r),f(e.ep,12,23,18,20,r);break}case 3:{f(e.ep,4,5,6,7,r),f(e.ep,16,17,18,19,r);break}case 4:{f(e.ep,1,20,5,21,r),f(e.ep,13,8,17,9,r);break}case 5:{f(e.ep,2,9,4,10,r),f(e.ep,14,21,16,22,r);break}case 6:{f(e.ep,0,1,2,3,r),f(e.ep,12,13,14,15,r),f(e.ep,9,22,11,20,r);break}case 7:{f(e.ep,11,15,10,19,r),f(e.ep,23,3,22,7,r),f(e.ep,2,16,6,12,r);break}case 8:{f(e.ep,0,11,6,8,r),f(e.ep,12,23,18,20,r),f(e.ep,3,19,5,13,r);break}case 9:{f(e.ep,4,5,6,7,r),f(e.ep,16,17,18,19,r),f(e.ep,8,23,10,21,r);break}case 10:{f(e.ep,1,20,5,21,r),f(e.ep,13,8,17,9,r),f(e.ep,14,0,18,4,r);break}case 11:f(e.ep,2,9,4,10,r),f(e.ep,14,21,16,22,r),f(e.ep,7,15,1,17,r)}}function c1(){let e;for(this.ep=_(24),e=0;e<24;++e)this.ep[e]=e}function er(){let e,n,r;for(c1.call(this),e=0;e<23;++e)r=e+ze(24-e),r!==e&&(n=this.ep[e],this.ep[e]=this.ep[r],this.ep[r]=n)}L(159,1,{},c1,er);var F1=!1;function un(){F1||(F1=!0,he=[35,1,34,2,4,6,22,5,19])}function rr(e){e.moveBuffer=_(60)}function pn(e,n){return e.value-n.value}function fe(e,n){let r;for(ln(e.edge,n.edge),Kr(e.center,n.center),K1(e.corner,n.corner),e.value=n.value,e.add1=n.add1,e.length1=n.length1,e.length2=n.length2,e.length3=n.length3,e.sym=n.sym,r=0;r<60;++r)e.moveBuffer[r]=n.moveBuffer[r];e.moveLength=n.moveLength,e.edgeAvail=n.edgeAvail,e.centerAvail=n.centerAvail,e.cornerAvail=n.cornerAvail}function H(e){for(;e.centerAvail=27?(g[r++]=T[u][e.moveBuffer[n]]-9,l=he[T[u][e.moveBuffer[n]]-27],u=i[u][l]):g[r++]=T[u][e.moveBuffer[n]];const d=i[$[u]][Pr(H(e))];for(p="",u=d,n=r-1;n>=0;--n)o=g[n],o=~~(o/3)*3+(2-o%3),T[u][o]>=27?(p=`${p}${te[T[u][o]-9]} `,l=he[T[u][o]-27],u=i[u][l]):p=`${p}${te[T[u][o]]} `;return p}function W(e,n){e.moveBuffer[e.moveLength++]=n}function De(){rr(this),this.edge=new c1,this.center=new g1,this.corner=new Ve}function He(e){De.call(this),fe(this,e)}function or(){rr(this),this.edge=new er,this.center=new J1,this.corner=new Z1}L(160,1,G([D1,Fr]),De,He,or);c.compareTo$=function(n){return pn(this,n)};c.add1=!1;c.center=null;c.centerAvail=0;c.corner=null;c.cornerAvail=0;c.edge=null;c.edgeAvail=0;c.length1=0;c.length2=0;c.length3=0;c.moveLength=0;c.sym=0;c.value=0;var he;function _n(e,n){return n.value-e.value}function Oe(e,n){return _n(e,n)}function lr(){}L(161,1,{},lr);c.compare=function(n,r){return Oe(n,r)};var j1=!1;function dn(){if(j1)return;j1=!0;let e,n;for(te=["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'"],J=[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],pe=[0,1,2,4,6,7,8,9,10,11,13,15,16,17,19,22,25,28,31,34,36],B1=_(37),M1=_(37),h=_(37,36),Se=_(29,28),xe=_(21,20),Je=_(36),de=_(28),ee=_(20),e=0;e<29;++e)B1[J[e]]=e;for(e=0;e<21;++e)M1[pe[e]]=e;for(e=0;e<36;++e){for(n=0;n<36;++n)h[e][n]=~~(e/3)===~~(n/3)||~~(e/3)%3===~~(n/3)%3&&e>n;h[36][e]=!1}for(e=0;e<29;++e)for(n=0;n<28;++n)Se[e][n]=h[J[e]][J[n]];for(e=0;e<21;++e)for(n=0;n<20;++n)xe[e][n]=h[pe[e]][pe[n]];for(e=0;e<36;++e)for(Je[e]=36,n=e;n<36;++n)if(!h[e][n]){Je[e]=n-1;break}for(e=0;e<28;++e)for(de[e]=28,n=e;n<28;++n)if(!Se[e][n]){de[e]=n-1;break}for(e=0;e<20;++e)for(ee[e]=20,n=e;n<20;++n)if(!xe[e][n]){ee[e]=n-1;break}}var h,Se,xe,J,te,pe,Je,de,ee,B1,M1;function vn(e){let n,r,o,l,p,u,g,d,m,v,b,a;e.solution="";const z=ye(new ae(H(e.c),0)),S=ye(new ae(H(e.c),1)),D=ye(new ae(H(e.c),2)),F=R[~~z>>6],M=R[~~S>>6],I=R[~~D>>6];for(e.p1SolsCnt=0,e.arr2idx=0,an(e.p1sols.heap),e.length1=(F>>6,D&63,e.length1,-1,0)||F<=e.length1&&Ae(e,~~z>>>6,z&63,e.length1,-1,0)||M<=e.length1&&Ae(e,~~S>>>6,S&63,e.length1,-1,0));++e.length1);const x=Tn(e.p1sols,se(Rn,G([Lr,$e,ie]),D1,0,0));x.sort(function(P,N){return P.value-N.value}),n=9;do{e:for(d=x[0].value;d<100;++d)for(u=0;ud);++u)if(!(d-x[u].length1>n)&&(fe(e.c1,x[u]),V1(e.ct2,H(e.c1),Ue(me(e.c1).ep)),b=je(e.ct2),a=Be(e.ct2),e.length1=x[u].length1,e.length2=d-x[u].length1,fr(e,b,a,e.length2,28,0)))break e;++n}while(d===100);e.arr2.sort(function(P,N){return P.value-N.value}),g=0,r=13;do{e:for(m=e.arr2[0].value;m<100;++m)for(u=0;um);++u)if(!(m-e.arr2[u].length1-e.arr2[u].length2>r)&&(p=t1(e.e12,me(e.arr2[u])),G1(e.ct3,H(e.arr2[u]),p^Ue(nr(e.arr2[u]).cp)),o=l1(e.ct3),l=oe(e.e12,10),v=i1(h1(e.e12)),v<=m-e.arr2[u].length1-e.arr2[u].length2&&ur(e,l,o,v,m-e.arr2[u].length1-e.arr2[u].length2,20,0))){g=u;break e}++r}while(m===100);const U=new He(e.arr2[g]);e.length1=U.length1,e.length2=U.length2;const K=m-e.length1-e.length2;for(u=0;ue.c1.value&&fe(o,e.c1)),wn(e.p1sols,o),e.p1SolsCnt===1e4}function bn(e){let n;for(fe(e.c2,e.c1),n=0;n>>6],v>=o){if(v>o)break;continue}if(b=i[r][g&63],g>>>=6,e.move1[p]=d,Ae(e,g,b,o-1,u,p+1))return!0}return!1}function fr(e,n,r,o,l,p){let u,g,d,m;if(n===0&&A[r]===0)return o===0&&bn(e);for(g=0;g<23;++g){if(Se[l][g]){g=de[g];continue}if(u=Me[n][g],m=Ee[r][g],d=A[u*70+m],d>=o){d>o&&(g=de[g]);continue}if(e.move2[p]=J[g],fr(e,u,m,o-1,g,p+1))return!0}return!1}function ur(e,n,r,o,l,p,u){let g,d,m,v,b,a,z,S,D;if(l===0)return n===0&&r===0;for(ke(e.tempe[u],n),b=0;b<17;++b){if(xe[p][b]){b=ee[b];continue}if(m=_e[r][b],a=q[m],a>=l){a>l&&b<14&&(b=ee[b]);continue}if(v=le(e.tempe[u].edge,b<<3,10),g=~~(v/20160),S=ue[g],D=S&7,S>>=3,d=le(e.tempe[u].edge,b<<3|D,10)%20160,z=en(S*20160+d,o),z>=l){z>l&&b<14&&(b=ee[b]);continue}if(ur(e,v,m,z,l-1,b,u+1))return e.move3[u]=b,!0}return!1}function pr(){let e;for(this.p1sols=new mr(new lr),this.move1=_(15),this.move2=_(20),this.move3=_(20),this.c1=new De,this.c2=new De,this.ct2=new o1,this.ct3=new f1,this.e12=new O,this.tempe=_(20),this.arr2=_(100),e=0;e<20;++e)this.tempe[e]=new O}function gr(){E1||(Nr(),ne=_(735471),Vr(),Or(),ne=null,Ur(),Xr(),Ir(),rn(),nn(),sr(),E1=!0)}L(163,1,G([jr]),pr);c.add1=!1;c.arr2idx=0;c.c=null;c.length1=0;c.length2=0;c.p1SolsCnt=0;c.solution="";var E1=!1;function Ue(e){let n,r,o,l;for(l=0,n=0,o=e.length;ne[r]&&(l^=1);return l}function f(e,n,r,o,l,p){let u;switch(p){case 0:{u=e[l],e[l]=e[o],e[o]=e[r],e[r]=e[n],e[n]=u;return}case 1:{u=e[n],e[n]=e[o],e[o]=u,u=e[r],e[r]=e[l],e[l]=u;return}case 2:{u=e[n],e[n]=e[r],e[r]=e[o],e[o]=e[l],e[l]=u;return}}}function _r(){}function dr(e,n,r,o){const l=new _r;return l.typeName=e+n,cr(r!==0?-r:0)&&br(r!==0?-r:0,l),l.modifiers=4,l.superclass=b1,l.componentType=o,l}function vr(e,n,r,o){const l=new _r;return l.typeName=e+n,cr(r)&&br(r,l),l.superclass=o,l}function kn(e){const n=ve[e.seedId];return e=null,n}function cr(e){return typeof e=="number"&&e>0}function br(e,n){let r;if(n.seedId=e,e===2)r=String.prototype;else if(e>0){let o=kn(n);if(o)r=o.prototype;else{o=ve[e]=function(){},o.___clazz$=n;return}}else return;r.___clazz$=n}c.val$outerIter=null;function wn(e,n){if(Bn(e,n))return!0}function yn(e){e.array=se(kr,G([$e,ie]),Q1,0,0)}function Cn(e,n){return Le(e.array,e.size++,n),!0}function an(e){e.array=se(kr,G([$e,ie]),Q1,0,0),e.size=0}function X(e,n){return e.array[n]}function Sn(e,n){const r=e.array[n];return zn(e.array,n,1),--e.size,r}function re(e,n,r){const o=e.array[n];return Le(e.array,n,r),o}function xn(e,n){let r;for(n.lengthe.size&&Le(n,e.size,null),n}function An(){yn(this),this.array.length=500}function zn(e,n,r){e.splice(n,r)}c.size=0;function Ln(e,n){let r,o,l,p;for(o=0,r=e.length-1;o<=r;)if(l=o+(~~(r-o)>>1),p=e[l],pn)r=l-1;else return l;return-o-1}function Xe(e){Fn(e,e.length)}function Fn(e,n){let r;for(r=0;r0;){if(r=o,o=~~((o-1)/2),Oe(X(e.heap,o),n)<=0)return re(e.heap,r,n),!0;re(e.heap,r,X(e.heap,o))}return re(e.heap,o,n),!0}function Mn(e){if(e.heap.size===0)return null;const n=X(e.heap,0);return En(e),n}function En(e){const n=Sn(e.heap,e.heap.size-1);01;c--)a[arguments[c]]=a[arguments[c-1]];return a[arguments[1]]=h,S}function L(a,v){return a[v>>3]>>((v&7)<<2)&15}function y(a,v,h,c){var l=0;if(c<0&&(v<<=1),h>=16){a[h-1]=0;for(var f=h-2;f>=0;f--){a[f]=v%(h-f),l^=a[f],v=~~(v/(h-f));for(var g=f+1;g=a[f]&&a[g]++}if(c<0&&l&1){var p=a[h-1];a[h-1]=a[h-2],a[h-2]=p}return a}for(var m=1985229328,b=4275878552,f=0;f=32){w=w-32,a[f]=b>>w&15;var k=(1<>4&~k)}else{a[f]=m>>w&15;var k=(1<>>4&~k)+(b<<28),b=b>>4}}return c<0&&l&1?(a[h-1]=a[h-2],a[h-2]=m&15):a[h-1]=m&15,a}function U(a,v,h){v=v||a.length;var c=0;if(v>=16){for(var l=0;l>1:c}for(var g=1985229328,p=4275878552,l=0;l=32?(c+=p>>m-32&15,p-=286331152<>m&15,p-=286331153,g-=286331152<>1:c}function I(a,v){var h,c;for(c=0,h=v-2;h>=0;--h)c^=a%(v-h),a=~~(a/(v-h));return c&1}function H(a,v,h){for(var c=Math.abs(h),l=h<0?0:a[0]%c,f=v-1;f>0;f--)l=l*c+a[f]%c;return l}function D(a,v,h,c){for(var l=Math.abs(c),f=l*h,g=1;g>1&1431655765,a=(a&858993459)+(a>>2&858993459),(a+(a>>4)&252645135)*16843009>>24}function lr(a,v,h,c){for(var l=-1,f=0,g=1,p=0;p>>3;b>3]^=15<<((v[b]&7)<<2);for(var w=0,k=0;k<=c;k++){var G=0,K=k>=p,W=k+1^15,Y=K?15:k,ur=K?k:15;r:for(var J=0;J>=4){if(!(J&7)&&(w=a[J>>3],!K&&w==-1)){J+=7;continue}if((w&15)==Y){for(var Z=0;Z>3]^=W<<((J&7)<<2);continue r}a[Q>>3]^=W<<((Q&7)<<2)}}}if(G==0)break}}function nr(a,v,h,c,l,f){this.isSolved=a||function(){return!0},this.getPrun=v,this.doMove=h,this.N_AXIS=c,this.N_POWER=l,this.ckmv=f||ar(c,function(g){return 1<v)return l>v+1?2:1;if(v==0)return this.isSolved(a)&&this.callback(c,this.sidx)?0:1;if(l==0&&this.isSolved(a)&&v==1)return 1;for(var f=0;f>f&1))for(var g=Array.isArray(a)?a.slice():a,p=0;p>1,i^=this.co[r];if(i!=0||F.getNParity(F.getNPerm(this.cp,6),6)!=0||F.getNParity(F.getNPerm(this.ep,12),12)!=0)return-1;for(var s=[3,3,3,3],r=0;r<12;r++){var M=n[vr[r]];if(!(s[M]>0))return-1;this.uf[r]=M*3+3-s[M],s[M]--}s=[3,3,3,3];for(var r=0;r<12;r++){var M=[0,1,3,2][n[fr[r]]-4];if(!(s[M]>0))return-1;this.rl[r]=M*3+3-s[M],s[M]--}if(F.getNParity(F.getNPerm(this.uf,12),12)!=0)for(var r=0;r<12;r++)this.uf[r]^=this.uf[r]<2?1:0;if(F.getNParity(F.getNPerm(this.rl,12),12)!=0)for(var r=0;r<12;r++)this.rl[r]^=this.rl[r]<2?1:0;return this},u.prototype.toString=function(t){var e=this.toFaceCube(t),n=` U8 U7 U6 U5 U4 B8 B7 B6 B5 B4 +import{J as zr,R as qr}from"./index-BA4_IlXs.js";var F=function(){for(var u=[1],P=0;P<32;++P)u[P+1]=u[P]*(P+1);function S(a){for(var v=arguments.length-1,h=a[arguments[v]],c=v;c>1;c--)a[arguments[c]]=a[arguments[c-1]];return a[arguments[1]]=h,S}function L(a,v){return a[v>>3]>>((v&7)<<2)&15}function y(a,v,h,c){var l=0;if(c<0&&(v<<=1),h>=16){a[h-1]=0;for(var f=h-2;f>=0;f--){a[f]=v%(h-f),l^=a[f],v=~~(v/(h-f));for(var g=f+1;g=a[f]&&a[g]++}if(c<0&&l&1){var p=a[h-1];a[h-1]=a[h-2],a[h-2]=p}return a}for(var m=1985229328,b=4275878552,f=0;f=32){w=w-32,a[f]=b>>w&15;var k=(1<>4&~k)}else{a[f]=m>>w&15;var k=(1<>>4&~k)+(b<<28),b=b>>4}}return c<0&&l&1?(a[h-1]=a[h-2],a[h-2]=m&15):a[h-1]=m&15,a}function U(a,v,h){v=v||a.length;var c=0;if(v>=16){for(var l=0;l>1:c}for(var g=1985229328,p=4275878552,l=0;l=32?(c+=p>>m-32&15,p-=286331152<>m&15,p-=286331153,g-=286331152<>1:c}function I(a,v){var h,c;for(c=0,h=v-2;h>=0;--h)c^=a%(v-h),a=~~(a/(v-h));return c&1}function H(a,v,h){for(var c=Math.abs(h),l=h<0?0:a[0]%c,f=v-1;f>0;f--)l=l*c+a[f]%c;return l}function D(a,v,h,c){for(var l=Math.abs(c),f=l*h,g=1;g>1&1431655765,a=(a&858993459)+(a>>2&858993459),(a+(a>>4)&252645135)*16843009>>24}function lr(a,v,h,c){for(var l=-1,f=0,g=1,p=0;p>>3;b>3]^=15<<((v[b]&7)<<2);for(var w=0,k=0;k<=c;k++){var G=0,K=k>=p,W=k+1^15,Y=K?15:k,ur=K?k:15;r:for(var J=0;J>=4){if(!(J&7)&&(w=a[J>>3],!K&&w==-1)){J+=7;continue}if((w&15)==Y){for(var Z=0;Z>3]^=W<<((J&7)<<2);continue r}a[Q>>3]^=W<<((Q&7)<<2)}}}if(G==0)break}}function nr(a,v,h,c,l,f){this.isSolved=a||function(){return!0},this.getPrun=v,this.doMove=h,this.N_AXIS=c,this.N_POWER=l,this.ckmv=f||ar(c,function(g){return 1<v)return l>v+1?2:1;if(v==0)return this.isSolved(a)&&this.callback(c,this.sidx)?0:1;if(l==0&&this.isSolved(a)&&v==1)return 1;for(var f=0;f>f&1))for(var g=Array.isArray(a)?a.slice():a,p=0;p>1,i^=this.co[r];if(i!=0||F.getNParity(F.getNPerm(this.cp,6),6)!=0||F.getNParity(F.getNPerm(this.ep,12),12)!=0)return-1;for(var s=[3,3,3,3],r=0;r<12;r++){var M=n[vr[r]];if(!(s[M]>0))return-1;this.uf[r]=M*3+3-s[M],s[M]--}s=[3,3,3,3];for(var r=0;r<12;r++){var M=[0,1,3,2][n[fr[r]]-4];if(!(s[M]>0))return-1;this.rl[r]=M*3+3-s[M],s[M]--}if(F.getNParity(F.getNPerm(this.uf,12),12)!=0)for(var r=0;r<12;r++)this.uf[r]^=this.uf[r]<2?1:0;if(F.getNParity(F.getNPerm(this.rl,12),12)!=0)for(var r=0;r<12;r++)this.rl[r]^=this.rl[r]<2?1:0;return this},u.prototype.toString=function(t){var e=this.toFaceCube(t),n=` U8 U7 U6 U5 U4 B8 B7 B6 B5 B4 L4 U3 U2 U1 R8 r4 B3 B2 B1 l8 L5 L1 U0 R3 R7 r5 r1 B0 l3 l7 L6 L2 L0 R0 R2 R6 r6 r2 r0 l0 l2 l6 diff --git a/docs/assets/search-dynamic-solve-kilominx-RAZM75GA-bDKRH7RV.js b/docs/assets/search-dynamic-solve-kilominx-RAZM75GA-DEBgiDDF.js similarity index 99% rename from docs/assets/search-dynamic-solve-kilominx-RAZM75GA-bDKRH7RV.js rename to docs/assets/search-dynamic-solve-kilominx-RAZM75GA-DEBgiDDF.js index ba23a51..ac1b4ee 100644 --- a/docs/assets/search-dynamic-solve-kilominx-RAZM75GA-bDKRH7RV.js +++ b/docs/assets/search-dynamic-solve-kilominx-RAZM75GA-DEBgiDDF.js @@ -1 +1 @@ -import{J as z,R as L}from"./index-lVaISq9J.js";var M=7;function O(e){if(e<2)return e;let t=1;for(let n=2;n<=e;n++)t*=n;return t}function b(e,t){if(t<0||t>e)return 0;if(t===0||t===e)return 1;let n=1;for(let r=0;r1;){t--;let l=e[0];r+=l*n;for(let o=0;ol)}n/=t}return r}function k(e){let t=e.length,n=0;for(let r=0;re[l]&&(n^=1);return n}function B(e){return N(e)>>1}var[D,K]=(()=>{let e=new Int8Array(10240),t=new Int8Array(1024*10);for(let l=0;l<1024;l++)for(let o=0,i=0;o<10;o++)l>>>o&1&&(e[o<<10|l]=i,t[i<<10|l]=o,i++);function n(l){let o=1023,i=181440,a=0;for(let f=0;f<8;f++){let u=l[f];a+=e[o|u<<10]*i,o&=~(1<0&&n>0&&t>1;i++)t--,e[i]===0?l=l*--r/t:(o+=l,l=l*n--/t);return o}function P(e,t,n){let r=n-t,l=b(n-1,t),o=[],i=n-1;for(let a=0;aW[r]+t[l]).join(" ")}function $(e,t){for(let[n,r]of t)for(let l=0;lo<15))return[];if(t.slice(0,5).every(o=>o<15))return[[6,1]];let n=t.map(o=>o>=15),r=0,l;for(;l===void 0;)r++,l=q(n,r,-1);return l.push([6,1]),l}function q(e,t,n){if(t===0)return e.slice(0,5).some(r=>r)?void 0:[];for(let r=0;r<6;r++)if(r!==n)for(let l=1;l<5;l++){let o=m(e,g[r][l][0]),i=q(o,t-1,r);if(i!==void 0)return[[r,l]].concat(i)}}function re(e){let t=e[0].slice(0,15),n=e[1],l=243*R(t.map(i=>+(i>=15)));for(let i=0,a=0;i<15;i++)t[i]<15||(l+=n[i]*Math.pow(3,a),a++);let o=0;for(let i=0;i<5;i++)o+=t.indexOf(15+i)*Math.pow(15,i);return[l,o]}function ne(e){let t=[y(),A()],n=[ue(),se()];return J(re(e),t,n).concat([[6,1]])}function le(e){let t=[5,6,7,8,14],n=e[0].slice(0,15),r=e[1],o=243*R(n.map(a=>+(t.indexOf(a)!==-1)));for(let a=0,f=0;a<15;a++)t.indexOf(n[a])!==-1&&(o+=r[a]*Math.pow(3,f),f++);let i=0;for(let a=0;a<5;a++)i+=n.indexOf(t[a])*Math.pow(15,a);return[o,i]}function oe(e){let t=[y(),A()],n=[pe(),_e()];return J(le(e),t,n)}function ie(e){let t=e[0].slice(0,14),n=e[1],r=0,l=[],o=0;for(let i of[0,1,2,3,4,9,10,11,12,13])i!==13&&(r+=n[i]*Math.pow(3,o)),l[o]=t[i]<5?t[i]:t[i]-4,o++;return[r,B(l)]}function ae(e){return de(ie(e))}function fe(e){let t=[];for(let n of[te,ne,oe,ae]){let r=n(e);e=$(e,r),t=t.concat(r)}return t}var p={};function y(){if(p.phase23om)return p.phase23om;const e=b(15,5),t=[1,3,9,27,81,243];let n=Array(b(15,5)*t[5]);p.phase23om=n;for(let r=0;rc<10),h=0;for(let c=0;c<5;c++)h+=s[c]%3*t[c];n[i+243*r][f]=h+243*o[f]}}}return n}function ue(){if(p.phase2op)return p.phase2op;let e=y();return p.phase2op=w(e,[243*3002])}function pe(){if(p.phase3op)return p.phase3op;let e=y();return p.phase3op=w(e,[243*246])}function A(){if(p.phase23pm)return p.phase23pm;const e=[1,15,225,Math.pow(15,3),Math.pow(15,4),Math.pow(15,5)];let t=Array(e[5]),n=Array(15);for(let l=0;l<15;l++){n[l]=Array(6);for(let o=0;o<6;o++)n[l][o]=d[o][0].indexOf(l)}let r=[0,0,0,0,0];for(let l=0;lr[o[0][f]]+o[1][f]),a=0;for(let f=0;f<9;f++)a+=i[f]%3*e[f];t[n][l]=a}}return p.phase4om=t}function H(){if(p.phase4pm)return p.phase4pm;const e=O(10)/2;let t=[0,1,2,3,4,-1,-1,-1,-1,5,6,7,8,9],n=[0,1,2,3,4,9,10,11,12,13],r=[m(t,m(T[0],n)),m(t,m(C[0],n)),m(t,m(I[0],n))],l=Array(e),o=Array(10);for(let i=0;ia-f);let o=[],i=-1;for(let a of r)a!==i&&o.push(i=a);return o.threshold=e,p.phase4np_list=o}function ve(e,t){let n=0,r=e.length-1;for(;r-n>1;){let l=n+r>>1;t>e[l]?n=l+1:r=l}return t===e[n]||t===e[r]}function w(e,t){let n=e.length,r=e[0].length,l=Array(n).fill(-1);for(let a of t)l[a]=0;let o=0,i=!1;for(;!i;){i=!0;for(let a=0;ar)){if(r===0||a===0)return[];for(let f=0;fe[h]!==u[h]);){let s=S(u,t,n,r-1,f);if(s!==void 0)return[[f,_]].concat(s);for(let h=0;ht)&&(f<=M&&!ve(a,e[0]+19683*e[1])&&(f=M+1),!(f>t))){if(t===0||f===0)return[];for(let u=0;u<3;u++){if(u===n)continue;let _=e.slice();for(let s=1;s<5;s++){_[0]=r[_[0]][u],_[1]=l[_[1]][u];let h=U(_,t-1,u,r,l,o,i,a);if(h!==void 0)return[[u,s]].concat(h)}}}}function we(){return new z(Z(ee()))}export{we as getRandomKilominxScramble}; +import{J as z,R as L}from"./index-BA4_IlXs.js";var M=7;function O(e){if(e<2)return e;let t=1;for(let n=2;n<=e;n++)t*=n;return t}function b(e,t){if(t<0||t>e)return 0;if(t===0||t===e)return 1;let n=1;for(let r=0;r1;){t--;let l=e[0];r+=l*n;for(let o=0;ol)}n/=t}return r}function k(e){let t=e.length,n=0;for(let r=0;re[l]&&(n^=1);return n}function B(e){return N(e)>>1}var[D,K]=(()=>{let e=new Int8Array(10240),t=new Int8Array(1024*10);for(let l=0;l<1024;l++)for(let o=0,i=0;o<10;o++)l>>>o&1&&(e[o<<10|l]=i,t[i<<10|l]=o,i++);function n(l){let o=1023,i=181440,a=0;for(let f=0;f<8;f++){let u=l[f];a+=e[o|u<<10]*i,o&=~(1<0&&n>0&&t>1;i++)t--,e[i]===0?l=l*--r/t:(o+=l,l=l*n--/t);return o}function P(e,t,n){let r=n-t,l=b(n-1,t),o=[],i=n-1;for(let a=0;aW[r]+t[l]).join(" ")}function $(e,t){for(let[n,r]of t)for(let l=0;lo<15))return[];if(t.slice(0,5).every(o=>o<15))return[[6,1]];let n=t.map(o=>o>=15),r=0,l;for(;l===void 0;)r++,l=q(n,r,-1);return l.push([6,1]),l}function q(e,t,n){if(t===0)return e.slice(0,5).some(r=>r)?void 0:[];for(let r=0;r<6;r++)if(r!==n)for(let l=1;l<5;l++){let o=m(e,g[r][l][0]),i=q(o,t-1,r);if(i!==void 0)return[[r,l]].concat(i)}}function re(e){let t=e[0].slice(0,15),n=e[1],l=243*R(t.map(i=>+(i>=15)));for(let i=0,a=0;i<15;i++)t[i]<15||(l+=n[i]*Math.pow(3,a),a++);let o=0;for(let i=0;i<5;i++)o+=t.indexOf(15+i)*Math.pow(15,i);return[l,o]}function ne(e){let t=[y(),A()],n=[ue(),se()];return J(re(e),t,n).concat([[6,1]])}function le(e){let t=[5,6,7,8,14],n=e[0].slice(0,15),r=e[1],o=243*R(n.map(a=>+(t.indexOf(a)!==-1)));for(let a=0,f=0;a<15;a++)t.indexOf(n[a])!==-1&&(o+=r[a]*Math.pow(3,f),f++);let i=0;for(let a=0;a<5;a++)i+=n.indexOf(t[a])*Math.pow(15,a);return[o,i]}function oe(e){let t=[y(),A()],n=[pe(),_e()];return J(le(e),t,n)}function ie(e){let t=e[0].slice(0,14),n=e[1],r=0,l=[],o=0;for(let i of[0,1,2,3,4,9,10,11,12,13])i!==13&&(r+=n[i]*Math.pow(3,o)),l[o]=t[i]<5?t[i]:t[i]-4,o++;return[r,B(l)]}function ae(e){return de(ie(e))}function fe(e){let t=[];for(let n of[te,ne,oe,ae]){let r=n(e);e=$(e,r),t=t.concat(r)}return t}var p={};function y(){if(p.phase23om)return p.phase23om;const e=b(15,5),t=[1,3,9,27,81,243];let n=Array(b(15,5)*t[5]);p.phase23om=n;for(let r=0;rc<10),h=0;for(let c=0;c<5;c++)h+=s[c]%3*t[c];n[i+243*r][f]=h+243*o[f]}}}return n}function ue(){if(p.phase2op)return p.phase2op;let e=y();return p.phase2op=w(e,[243*3002])}function pe(){if(p.phase3op)return p.phase3op;let e=y();return p.phase3op=w(e,[243*246])}function A(){if(p.phase23pm)return p.phase23pm;const e=[1,15,225,Math.pow(15,3),Math.pow(15,4),Math.pow(15,5)];let t=Array(e[5]),n=Array(15);for(let l=0;l<15;l++){n[l]=Array(6);for(let o=0;o<6;o++)n[l][o]=d[o][0].indexOf(l)}let r=[0,0,0,0,0];for(let l=0;lr[o[0][f]]+o[1][f]),a=0;for(let f=0;f<9;f++)a+=i[f]%3*e[f];t[n][l]=a}}return p.phase4om=t}function H(){if(p.phase4pm)return p.phase4pm;const e=O(10)/2;let t=[0,1,2,3,4,-1,-1,-1,-1,5,6,7,8,9],n=[0,1,2,3,4,9,10,11,12,13],r=[m(t,m(T[0],n)),m(t,m(C[0],n)),m(t,m(I[0],n))],l=Array(e),o=Array(10);for(let i=0;ia-f);let o=[],i=-1;for(let a of r)a!==i&&o.push(i=a);return o.threshold=e,p.phase4np_list=o}function ve(e,t){let n=0,r=e.length-1;for(;r-n>1;){let l=n+r>>1;t>e[l]?n=l+1:r=l}return t===e[n]||t===e[r]}function w(e,t){let n=e.length,r=e[0].length,l=Array(n).fill(-1);for(let a of t)l[a]=0;let o=0,i=!1;for(;!i;){i=!0;for(let a=0;ar)){if(r===0||a===0)return[];for(let f=0;fe[h]!==u[h]);){let s=S(u,t,n,r-1,f);if(s!==void 0)return[[f,_]].concat(s);for(let h=0;ht)&&(f<=M&&!ve(a,e[0]+19683*e[1])&&(f=M+1),!(f>t))){if(t===0||f===0)return[];for(let u=0;u<3;u++){if(u===n)continue;let _=e.slice();for(let s=1;s<5;s++){_[0]=r[_[0]][u],_[1]=l[_[1]][u];let h=U(_,t-1,u,r,l,o,i,a);if(h!==void 0)return[[u,s]].concat(h)}}}}function we(){return new z(Z(ee()))}export{we as getRandomKilominxScramble}; diff --git a/docs/assets/search-dynamic-solve-master_tetraminx-3D4MBF3V-CmCoI0eZ.js b/docs/assets/search-dynamic-solve-master_tetraminx-3D4MBF3V-Di9QKO1e.js similarity index 99% rename from docs/assets/search-dynamic-solve-master_tetraminx-3D4MBF3V-CmCoI0eZ.js rename to docs/assets/search-dynamic-solve-master_tetraminx-3D4MBF3V-Di9QKO1e.js index 872d957..72547ae 100644 --- a/docs/assets/search-dynamic-solve-master_tetraminx-3D4MBF3V-CmCoI0eZ.js +++ b/docs/assets/search-dynamic-solve-master_tetraminx-3D4MBF3V-Di9QKO1e.js @@ -1 +1 @@ -import{R as w}from"./index-lVaISq9J.js";function I(e){if(e<2)return e;let t=1;for(let r=2;r<=e;r++)t*=r;return t}function x(e){let t=Array(e);for(let r=0;r1;){t--;let o=e[0];n+=o*r;for(let i=0;io)}r/=t}return n}function b(e,t){let r=[],n=I(t-1)/2,o=0;for(let i=0;i=0;i--)for(let l=i+1;l=r[i]?r[l]++:o^=1;return o===1&&([r[t-2],r[t-1]]=[r[t-1],r[t-2]]),r}function V(e){return X(e)>>1}(()=>{let e=new Int8Array(49152),t=new Int8Array(4096*12);for(let o=0;o<4096;o++)for(let i=0,l=0;i<12;i++)o>>>i&1&&(e[i<<12|o]=l,t[l<<12|o]=i,l++);function r(o){let i=4095,l=19958400,a=0;for(let p=0;p<10;p++){let _=o[p];a+=e[i|_<<12]*l,i&=~(1<<_),l/=11-p}return a}function n(o,i){let l=4095,a=19958400,p=0;for(let _=0;_<10;_++){let c=o/a|0;o-=c*a,p^=c&1;let f=t[l|c<<12];i[_]=f,l&=~(1<$(r,t)).reduce(d)}function Y(e,t){let r=Array(4);for(let l=0;l<4;l++)r[l]=(e.co[l]+t.co[l])%3;let n=d(e.mp,t.mp),o=d(e.wp,t.wp),i=d(e.cp,t.cp);return{co:r,mp:n,wp:o,cp:i}}x(12),x(12);var Z={co:[2,0,0,0],mp:x(12),wp:$([1,9,11],12),cp:[0,1,2,3]},ee={co:[0,2,0,0],mp:x(12),wp:$([0,7,2],12),cp:[0,1,2,3]},te={co:[0,0,2,0],mp:x(12),wp:$([3,6,10],12),cp:[0,1,2,3]},re={co:[0,0,0,2],mp:x(12),wp:$([4,8,5],12),cp:[0,1,2,3]},ne={co:[2,0,0,0],mp:g([[1,9,11],[7,3,5]],12),wp:g([[1,9,11],[7,3,5]],12),cp:[0,2,3,1]},le={co:[0,2,0,0],mp:g([[0,7,2],[6,1,8]],12),wp:g([[0,7,2],[6,1,8]],12),cp:[3,1,0,2]},oe={co:[0,0,2,0],mp:g([[3,6,10],[9,0,4]],12),wp:g([[3,6,10],[9,0,4]],12),cp:[1,3,2,0]},ie={co:[0,0,0,2],mp:g([[4,8,5],[10,2,11]],12),wp:g([[4,8,5],[10,2,11]],12),cp:[2,0,1,3]},M=[ne,le,oe,ie,Z,ee,te,re],ae=["u","l","r","b","U","L","R","B"],y=8,j=4;function C(e,t){return e>=4&&t>=4?!0:e<4&&t<4?e===t:(e^t)===4}function fe(e){let t=["0","","'"];return e.map(([n,o])=>ae[n]+t[o]).join(" ")}function pe(){let e=Array(4);for(let o=0;o<4;o++)e[o]=w(3);let t=b(w(I(6)/2),6);for(let o=0,i=0;o<6;o++){let l=o===5?i:w(2);i^=l,t[o]+=l*6,t[o+6]=(t[o]+6)%12}let r=b(w(I(12)/2),12),n=b(w(I(4)/2),4);return{co:e,mp:t,wp:r,cp:n}}function ue(){return ce(pe())}function _e(e=!0,t=!1){let r=fe(ue());if(!e)return r;let n=["u","l","r","b"],o=["0","","'"];if(!t){for(let f=0;f<4;f++){let u=w(3);u!==0&&(r+=` ${n[f]}${o[u]}`)}return r.trim()}let i=[],l=[],a=[];for(let f=0;f<4;f++)i[f]=w(3),l[f]=w(3),a[f]=(i[f]-l[f]+3)%3;let p=f=>f.filter(u=>u!==0).length;for(;!(p(l)>=1&&p(a)>=1&&p(l)+p(a)>=4);)for(let f=0;f<4;f++)l[f]=w(3),a[f]=(i[f]-l[f]+3)%3;let _=l.map((f,u)=>f!==0?`${n[u]}${o[f]} `:"").join(""),c=a.map((f,u)=>f!==0?` ${n[u]}${o[f]}`:"").join("");return _+r+c}function ce(e){let t=se(e),r=[P(),T()],n=[ve(),de()],o=he(t),i,l=new Set,a=performance.now();for(let p=0;p<22;p++){let{value:_,done:c}=o.next(),f=e;for(let[S,k]of _)for(let A=0;A_.length+v.length)&&(i=_.concat(v)),performance.now()-a>300))break}return i}function me(e){return e[3^e.indexOf(3)]}function se(e){let t=d(N(e.mp),e.wp),r=(e.co.reduce((n,o)=>n+o)-me(e.cp)+3)%3;return[0,1,2,3,4,5].map(n=>n+6*t.indexOf(n)+72*t.indexOf(n+6)+864*r)}var D=[],R=[];for(let e=0;ep)){if(p===0){yield[];return}if(!(u===0&&p===1))for(let m=0;ml%6)),n=t.slice(0,5).map((l,a)=>(l>=6)*2**a).reduce((l,a)=>l+a),o=e.co.map((l,a)=>l*3**a).reduce((l,a)=>l+a),i=e.cp.indexOf(0);return[r+360*i,n+32*o]}var s={};function H(){if(s.phase1pm)return s.phase1pm;let e=Array(6*12*12).fill().map(()=>Array(y).fill(-1));for(let t=0;t<6;t++)for(let r=0;r<12;r++)for(let n=0;n<12;n++){if(r===n)continue;let o=t+6*r+72*n;for(let i=0;iArray(y).fill(-1));for(let r=0;ri+6*i+72*(i+6));for(let i=0;i<6;i++)for(let l=0;l<6;l++)i!==l&&(r[n[i]+864*n[l]]=0);let o=0;for(;;){let i=!1;for(let l=0;lArray(j));for(let t=0;t<360;t++){let r=b(t,6);for(let n=0;n<6;n++)r[n+6]=r[n]+6;for(let n=0;nl%6));for(let l=0;l<4;l++){let a=M[n].cp[l];e[t+360*a][n]=i+360*l}}}return s.phase2pm=e}function T(){if(s.phase2om)return s.phase2om;let e=Array(32*81).fill().map(()=>Array(j));for(let t=0;t<32;t++){let r=[0,1,2,3,4].map(o=>t>>o&1);r[5]=r.reduce((o,i)=>o^i);let n=[];for(let o=0;o<6;o++)n[o]=o+6*r[o],n[o+6]=o+6*(r[o]^1);for(let o=0;o<81;o++){let i=[0,1,2,3].map(l=>Math.floor(o/3**l)%3);for(let l=0;l+(u>=6)),_=0;for(let u=0;u<5;u++)_+=p[u]<(u+M[l].co[m])%3),f=0;for(let u=0;u<4;u++)f+=c[u]*3**u;e[t+32*o][l]=_+32*f}}}return s.phase2om=e}function ve(){return s.phase2pp?s.phase2pp:s.phase2pp=z(P(),[0])}function de(){return s.phase2op?s.phase2op:s.phase2op=z(T(),[0])}function z(e,t){let r=e.length,n=e[0].length,o=Array(r).fill(-1),i=t.slice(),l=[],a=0;for(;i.length>0;){l.length=0;for(let p of i)if(o[p]===-1){o[p]=a;for(let _=0;_n)){if(n===0){yield[];return}if(!(a===0&&n===1))for(let p=0;pe[u]!==_[u]);){let f=G(_,t,r,n-1,p);for(;;){let{value:u,done:m}=f.next();if(m)break;yield[[p,c]].concat(u)}for(let u=0;u1;){t--;let o=e[0];n+=o*r;for(let i=0;io)}r/=t}return n}function b(e,t){let r=[],n=I(t-1)/2,o=0;for(let i=0;i=0;i--)for(let l=i+1;l=r[i]?r[l]++:o^=1;return o===1&&([r[t-2],r[t-1]]=[r[t-1],r[t-2]]),r}function V(e){return X(e)>>1}(()=>{let e=new Int8Array(49152),t=new Int8Array(4096*12);for(let o=0;o<4096;o++)for(let i=0,l=0;i<12;i++)o>>>i&1&&(e[i<<12|o]=l,t[l<<12|o]=i,l++);function r(o){let i=4095,l=19958400,a=0;for(let p=0;p<10;p++){let _=o[p];a+=e[i|_<<12]*l,i&=~(1<<_),l/=11-p}return a}function n(o,i){let l=4095,a=19958400,p=0;for(let _=0;_<10;_++){let c=o/a|0;o-=c*a,p^=c&1;let f=t[l|c<<12];i[_]=f,l&=~(1<$(r,t)).reduce(d)}function Y(e,t){let r=Array(4);for(let l=0;l<4;l++)r[l]=(e.co[l]+t.co[l])%3;let n=d(e.mp,t.mp),o=d(e.wp,t.wp),i=d(e.cp,t.cp);return{co:r,mp:n,wp:o,cp:i}}x(12),x(12);var Z={co:[2,0,0,0],mp:x(12),wp:$([1,9,11],12),cp:[0,1,2,3]},ee={co:[0,2,0,0],mp:x(12),wp:$([0,7,2],12),cp:[0,1,2,3]},te={co:[0,0,2,0],mp:x(12),wp:$([3,6,10],12),cp:[0,1,2,3]},re={co:[0,0,0,2],mp:x(12),wp:$([4,8,5],12),cp:[0,1,2,3]},ne={co:[2,0,0,0],mp:g([[1,9,11],[7,3,5]],12),wp:g([[1,9,11],[7,3,5]],12),cp:[0,2,3,1]},le={co:[0,2,0,0],mp:g([[0,7,2],[6,1,8]],12),wp:g([[0,7,2],[6,1,8]],12),cp:[3,1,0,2]},oe={co:[0,0,2,0],mp:g([[3,6,10],[9,0,4]],12),wp:g([[3,6,10],[9,0,4]],12),cp:[1,3,2,0]},ie={co:[0,0,0,2],mp:g([[4,8,5],[10,2,11]],12),wp:g([[4,8,5],[10,2,11]],12),cp:[2,0,1,3]},M=[ne,le,oe,ie,Z,ee,te,re],ae=["u","l","r","b","U","L","R","B"],y=8,j=4;function C(e,t){return e>=4&&t>=4?!0:e<4&&t<4?e===t:(e^t)===4}function fe(e){let t=["0","","'"];return e.map(([n,o])=>ae[n]+t[o]).join(" ")}function pe(){let e=Array(4);for(let o=0;o<4;o++)e[o]=w(3);let t=b(w(I(6)/2),6);for(let o=0,i=0;o<6;o++){let l=o===5?i:w(2);i^=l,t[o]+=l*6,t[o+6]=(t[o]+6)%12}let r=b(w(I(12)/2),12),n=b(w(I(4)/2),4);return{co:e,mp:t,wp:r,cp:n}}function ue(){return ce(pe())}function _e(e=!0,t=!1){let r=fe(ue());if(!e)return r;let n=["u","l","r","b"],o=["0","","'"];if(!t){for(let f=0;f<4;f++){let u=w(3);u!==0&&(r+=` ${n[f]}${o[u]}`)}return r.trim()}let i=[],l=[],a=[];for(let f=0;f<4;f++)i[f]=w(3),l[f]=w(3),a[f]=(i[f]-l[f]+3)%3;let p=f=>f.filter(u=>u!==0).length;for(;!(p(l)>=1&&p(a)>=1&&p(l)+p(a)>=4);)for(let f=0;f<4;f++)l[f]=w(3),a[f]=(i[f]-l[f]+3)%3;let _=l.map((f,u)=>f!==0?`${n[u]}${o[f]} `:"").join(""),c=a.map((f,u)=>f!==0?` ${n[u]}${o[f]}`:"").join("");return _+r+c}function ce(e){let t=se(e),r=[P(),T()],n=[ve(),de()],o=he(t),i,l=new Set,a=performance.now();for(let p=0;p<22;p++){let{value:_,done:c}=o.next(),f=e;for(let[S,k]of _)for(let A=0;A_.length+v.length)&&(i=_.concat(v)),performance.now()-a>300))break}return i}function me(e){return e[3^e.indexOf(3)]}function se(e){let t=d(N(e.mp),e.wp),r=(e.co.reduce((n,o)=>n+o)-me(e.cp)+3)%3;return[0,1,2,3,4,5].map(n=>n+6*t.indexOf(n)+72*t.indexOf(n+6)+864*r)}var D=[],R=[];for(let e=0;ep)){if(p===0){yield[];return}if(!(u===0&&p===1))for(let m=0;ml%6)),n=t.slice(0,5).map((l,a)=>(l>=6)*2**a).reduce((l,a)=>l+a),o=e.co.map((l,a)=>l*3**a).reduce((l,a)=>l+a),i=e.cp.indexOf(0);return[r+360*i,n+32*o]}var s={};function H(){if(s.phase1pm)return s.phase1pm;let e=Array(6*12*12).fill().map(()=>Array(y).fill(-1));for(let t=0;t<6;t++)for(let r=0;r<12;r++)for(let n=0;n<12;n++){if(r===n)continue;let o=t+6*r+72*n;for(let i=0;iArray(y).fill(-1));for(let r=0;ri+6*i+72*(i+6));for(let i=0;i<6;i++)for(let l=0;l<6;l++)i!==l&&(r[n[i]+864*n[l]]=0);let o=0;for(;;){let i=!1;for(let l=0;lArray(j));for(let t=0;t<360;t++){let r=b(t,6);for(let n=0;n<6;n++)r[n+6]=r[n]+6;for(let n=0;nl%6));for(let l=0;l<4;l++){let a=M[n].cp[l];e[t+360*a][n]=i+360*l}}}return s.phase2pm=e}function T(){if(s.phase2om)return s.phase2om;let e=Array(32*81).fill().map(()=>Array(j));for(let t=0;t<32;t++){let r=[0,1,2,3,4].map(o=>t>>o&1);r[5]=r.reduce((o,i)=>o^i);let n=[];for(let o=0;o<6;o++)n[o]=o+6*r[o],n[o+6]=o+6*(r[o]^1);for(let o=0;o<81;o++){let i=[0,1,2,3].map(l=>Math.floor(o/3**l)%3);for(let l=0;l+(u>=6)),_=0;for(let u=0;u<5;u++)_+=p[u]<(u+M[l].co[m])%3),f=0;for(let u=0;u<4;u++)f+=c[u]*3**u;e[t+32*o][l]=_+32*f}}}return s.phase2om=e}function ve(){return s.phase2pp?s.phase2pp:s.phase2pp=z(P(),[0])}function de(){return s.phase2op?s.phase2op:s.phase2op=z(T(),[0])}function z(e,t){let r=e.length,n=e[0].length,o=Array(r).fill(-1),i=t.slice(),l=[],a=0;for(;i.length>0;){l.length=0;for(let p of i)if(o[p]===-1){o[p]=a;for(let _=0;_n)){if(n===0){yield[];return}if(!(a===0&&n===1))for(let p=0;pe[u]!==_[u]);){let f=G(_,t,r,n-1,p);for(;;){let{value:u,done:m}=f.next();if(m)break;yield[[p,c]].concat(u)}for(let u=0;u24?(e=48-e,a=r.ul,r.ul=(~~r.ul>>e|r.ur<<24-e)&16777215,r.ur=(~~r.ur>>e|a<<24-e)&16777215):e>0?(a=r.ul,r.ul=(r.ul<>24-e)&16777215,r.ur=(r.ur<>24-e)&16777215):e===0?(a=r.ur,r.ur=r.dl,r.dl=a,r.ml=1-r.ml):e>=-24?(e=-e,a=r.dl,r.dl=(r.dl<>24-e)&16777215,r.dr=(r.dr<>24-e)&16777215):e<-24&&(e=48+e,a=r.dl,r.dl=(~~r.dl>>e|r.dr<<24-e)&16777215,r.dr=(~~r.dr>>e|a<<24-e)&16777215)}function Z(r){var e,a,u,t,f;for(u=0,r.arr[0]=g(r,0),t=1;t<24;++t)g(r,t)!==r.arr[u]&&(r.arr[++u]=g(r,t));for(f=0,e=0;e<16;++e)for(a=e+1;a<16;++a)r.arr[e]>r.arr[a]&&(f^=1);return f}function x(r){var e,a,u,t;return t=r.ur&1118481,t|=~~t>>3,t|=~~t>>6,t=t&15|~~t>>12&48,u=r.ul&1118481,u|=~~u>>3,u|=~~u>>6,u=u&15|~~u>>12&48,a=r.dr&1118481,a|=~~a>>3,a|=~~a>>6,a=a&15|~~a>>12&48,e=r.dl&1118481,e|=~~e>>3,e|=~~e>>6,e=e&15|~~e>>12&48,M(Z(r)<<24|u<<18|t<<12|e<<6|a)}function b(r,e){var a,u;for(a=0;a<8;++a)r.prm[a]=~~(~~g(r,a*3+1)>>1<<24)>>24;for(e.cornperm=I(r.prm),e.topEdgeFirst=g(r,0)===g(r,1),a=e.topEdgeFirst?2:0,u=0;u<4;a+=3,++u)r.prm[u]=~~(~~g(r,a)>>1<<24)>>24;for(e.botEdgeFirst=g(r,12)===g(r,13),a=e.botEdgeFirst?14:12;u<8;a+=3,++u)r.prm[u]=~~(~~g(r,a)>>1<<24)>>24;e.edgeperm=I(r.prm),e.ml=r.ml}function g(r,e){var a;return e<6?a=~~r.ul>>(5-e<<2):e<12?a=~~r.ur>>(11-e<<2):e<18?a=~~r.dl>>(17-e<<2):a=~~r.dr>>(23-e<<2),~~((a&15)<<24)>>24}function E(r,e,a){e<6?(r.ul&=~(15<<(5-e<<2)),r.ul|=a<<(5-e<<2)):e<12?(r.ur&=~(15<<(11-e<<2)),r.ur|=a<<(11-e<<2)):e<18?(r.dl&=~(15<<(17-e<<2)),r.dl|=a<<(17-e<<2)):(r.dr&=~(15<<(23-e<<2)),r.dr|=a<<(23-e<<2))}function D(){this.arr=[],this.prm=[]}function j(){var r,e,a,u,t,f,n,i,v;for(r=new D,a=F[T(3678)],t=324508639,u=38177486,n=f=8,e=0;e<24;e++)a>>e&1?(i=T(n)<<2,E(r,23-e,t>>i&15),E(r,22-e,t>>i&15),v=(1<>4&~v),--n,++e):(i=T(f)<<2,E(r,23-e,u>>i&15),v=(1<>4&~v),--f);return r.ml=T(2),r}function rr(){}var p=D.prototype=rr.prototype;p.dl=10062778;p.dr=14536702;p.ml=0;p.ul=70195;p.ur=4544119;function er(r){var e,a,u,t,f,n;for(Y(r.Search_d,r.Search_c),u=0;u=0;f--){var n=r.Search_move[f];n>0?(n=12-n,u=n>6?n-12:n):n<0?(n=12+n,t=n>6?n-12:n):(u===0&&t===0?a+=" / ":a+=`(${u}, ${t}) / `,u=t=0)}return(u!==0||t!==0)&&(a+=`(${u}, ${t})`),a}function B(r,e,a,u,t,f){var n,i,v;if(a===0&&u<4)return u===0&&er(r);if(f!==0&&(v=z[e],i=s[v],i>4,n&=15,!(n>=12||(i=s[v],i>u));)if(i>4,n&=15,!(n>=6||(i=s[v],i>u));)if(i3?6:12)&&o<=n&&o<=n;){if(o>1],r.bottom=r.top&4095,r.top>>=12}function fr(r){var e,a;e=0,a=0;do r.top&2048?(e+=2,r.top=r.top<<2^12291):(e+=1,r.top=r.top<<1),a=1-a;while(C(r.top&63)&1);return!(C(r.top)&2)&&(r.Shape_parity^=a),e}function O(){}function M(r){var e;return e=X(F,r&16777215)<<1|~~r>>24,e}function cr(){var r,e,a,u,t,f,n,i,v,h,_,c,l,o,m,d;for(r=0,n=0;n<28561;++n)f=P[n%13],a=P[~~(n/13)%13],c=P[~~(~~(n/13)/13)%13],_=P[~~(~~(~~(n/13)/13)/13)],l=_<<18|c<<12|a<<6|f,C(l)===16&&(F[r++]=l);for(h=new O,n=0;n<7356;++n)L(h,n),$[n]=fr(h),$[n]|=V(h)<<4,L(h,n),k[n]=ir(h),k[n]|=V(h)<<4,L(h,n),d=h.top&63,o=C(d),m=C(h.bottom&4032),h.Shape_parity^=1&~~(o&m)>>1,h.top=h.top&4032|~~h.bottom>>6&63,h.bottom=h.bottom&63|d<<6,z[n]=V(h);for(n=0;n<7536;++n)s[n]=-1;for(s[M(14378715)]=0,s[M(31157686)]=0,s[M(23967451)]=0,s[M(7191990)]=0,u=4,t=0,e=-1;u!==t;)for(t=u,++e,n=0;n<7536;++n)if(s[n]===e){v=0,i=n;do i=$[i],v+=i&15,i>>=4,s[i]===-1&&(++u,s[i]=e+1);while(v!==12);v=0,i=n;do i=k[i],v+=i&15,i>>=4,s[i]===-1&&(++u,s[i]=e+1);while(v!==12);i=z[n],s[i]===-1&&(++u,s[i]=e+1)}}function vr(){}p=O.prototype=vr.prototype;p.bottom=0;p.Shape_parity=0;p.top=0;var k,F,s,$,z,P,K=!1;function hr(){if(!K){K=!0,S=[],R=[],y=[],w=[],W=[1,1,2,6,24,120,720,5040],q=[];for(var r=0;r<12;++r)q[r]=[];_r()}}function Q(){}function I(r){var e,a,u,t;for(a=0,t=1985229328,e=0;e<7;++e)u=r[e]<<2,a=(8-e)*a+(~~t>>u&7),t-=286331152<=11,u=i?-1:e,r=i?e:-1,++e;r:for(t=0;t<80640;++t)if(S[t]===u){if(f=~~t>>1,_=t&1,n=R[f]<<1|1-_,S[n]===r&&(++a,S[i?t:n]=~~(e<<24)>>24,i))continue r;for(n=f,h=0;h<4;++h)if(n=y[n],S[n<<1|_]===r&&(++a,S[i?t:n<<1|_]=~~(e<<24)>>24,i))continue r;for(h=0;h<4;++h)if(n=w[n],S[n<<1|_]===r&&(++a,S[i?t:n<<1|_]=~~(e<<24)>>24,i))continue r}}}function U(r,e){var a,u,t,f,n;for(n=1985229328,a=0;a<7;++a)t=W[7-a],f=~~(e/t),e-=f*t,f<<=2,r[a]=~~((~~n>>f&7)<<24)>>24,u=(1<>4&~u);r[7]=~~(n<<24)>>24}function lr(){}p=Q.prototype=lr.prototype;p.botEdgeFirst=!1;p.cornperm=0;p.edgeperm=0;p.ml=0;p.topEdgeFirst=!1;var w,q,S,y,R,W;function C(r){return r-=~~r>>1&1431655765,r=(~~r>>2&858993459)+(r&858993459),r=(~~r>>4)+r&252645135,r+=~~r>>8,r+=~~r>>16,r&63}function X(r,e){var a,u,t,f;for(u=0,a=r.length-1;u<=a;)if(t=u+(~~(a-u)>>1),f=r[t],fe)a=t-1;else return t;return-u-1}var A=!1,Sr=function(r,e,a){A||(ur(),hr()),A=!0},pr=function(){return A||Sr(),j()},sr=function(r){var e=new N;return tr(e,r)},or=function(){var r=pr(),e=sr(r);return{pattern:r,scramble_string:e}};function gr(){return or().scramble_string}export{gr as getRandomSquare1ScrambleString}; +import{R as T}from"./index-BA4_IlXs.js";function Y(r,e){r.ul=e.ul,r.ur=e.ur,r.dl=e.dl,r.dr=e.dr,r.ml=e.ml}function H(r,e){var a;e<<=2,e>24?(e=48-e,a=r.ul,r.ul=(~~r.ul>>e|r.ur<<24-e)&16777215,r.ur=(~~r.ur>>e|a<<24-e)&16777215):e>0?(a=r.ul,r.ul=(r.ul<>24-e)&16777215,r.ur=(r.ur<>24-e)&16777215):e===0?(a=r.ur,r.ur=r.dl,r.dl=a,r.ml=1-r.ml):e>=-24?(e=-e,a=r.dl,r.dl=(r.dl<>24-e)&16777215,r.dr=(r.dr<>24-e)&16777215):e<-24&&(e=48+e,a=r.dl,r.dl=(~~r.dl>>e|r.dr<<24-e)&16777215,r.dr=(~~r.dr>>e|a<<24-e)&16777215)}function Z(r){var e,a,u,t,f;for(u=0,r.arr[0]=g(r,0),t=1;t<24;++t)g(r,t)!==r.arr[u]&&(r.arr[++u]=g(r,t));for(f=0,e=0;e<16;++e)for(a=e+1;a<16;++a)r.arr[e]>r.arr[a]&&(f^=1);return f}function x(r){var e,a,u,t;return t=r.ur&1118481,t|=~~t>>3,t|=~~t>>6,t=t&15|~~t>>12&48,u=r.ul&1118481,u|=~~u>>3,u|=~~u>>6,u=u&15|~~u>>12&48,a=r.dr&1118481,a|=~~a>>3,a|=~~a>>6,a=a&15|~~a>>12&48,e=r.dl&1118481,e|=~~e>>3,e|=~~e>>6,e=e&15|~~e>>12&48,M(Z(r)<<24|u<<18|t<<12|e<<6|a)}function b(r,e){var a,u;for(a=0;a<8;++a)r.prm[a]=~~(~~g(r,a*3+1)>>1<<24)>>24;for(e.cornperm=I(r.prm),e.topEdgeFirst=g(r,0)===g(r,1),a=e.topEdgeFirst?2:0,u=0;u<4;a+=3,++u)r.prm[u]=~~(~~g(r,a)>>1<<24)>>24;for(e.botEdgeFirst=g(r,12)===g(r,13),a=e.botEdgeFirst?14:12;u<8;a+=3,++u)r.prm[u]=~~(~~g(r,a)>>1<<24)>>24;e.edgeperm=I(r.prm),e.ml=r.ml}function g(r,e){var a;return e<6?a=~~r.ul>>(5-e<<2):e<12?a=~~r.ur>>(11-e<<2):e<18?a=~~r.dl>>(17-e<<2):a=~~r.dr>>(23-e<<2),~~((a&15)<<24)>>24}function E(r,e,a){e<6?(r.ul&=~(15<<(5-e<<2)),r.ul|=a<<(5-e<<2)):e<12?(r.ur&=~(15<<(11-e<<2)),r.ur|=a<<(11-e<<2)):e<18?(r.dl&=~(15<<(17-e<<2)),r.dl|=a<<(17-e<<2)):(r.dr&=~(15<<(23-e<<2)),r.dr|=a<<(23-e<<2))}function D(){this.arr=[],this.prm=[]}function j(){var r,e,a,u,t,f,n,i,v;for(r=new D,a=F[T(3678)],t=324508639,u=38177486,n=f=8,e=0;e<24;e++)a>>e&1?(i=T(n)<<2,E(r,23-e,t>>i&15),E(r,22-e,t>>i&15),v=(1<>4&~v),--n,++e):(i=T(f)<<2,E(r,23-e,u>>i&15),v=(1<>4&~v),--f);return r.ml=T(2),r}function rr(){}var p=D.prototype=rr.prototype;p.dl=10062778;p.dr=14536702;p.ml=0;p.ul=70195;p.ur=4544119;function er(r){var e,a,u,t,f,n;for(Y(r.Search_d,r.Search_c),u=0;u=0;f--){var n=r.Search_move[f];n>0?(n=12-n,u=n>6?n-12:n):n<0?(n=12+n,t=n>6?n-12:n):(u===0&&t===0?a+=" / ":a+=`(${u}, ${t}) / `,u=t=0)}return(u!==0||t!==0)&&(a+=`(${u}, ${t})`),a}function B(r,e,a,u,t,f){var n,i,v;if(a===0&&u<4)return u===0&&er(r);if(f!==0&&(v=z[e],i=s[v],i>4,n&=15,!(n>=12||(i=s[v],i>u));)if(i>4,n&=15,!(n>=6||(i=s[v],i>u));)if(i3?6:12)&&o<=n&&o<=n;){if(o>1],r.bottom=r.top&4095,r.top>>=12}function fr(r){var e,a;e=0,a=0;do r.top&2048?(e+=2,r.top=r.top<<2^12291):(e+=1,r.top=r.top<<1),a=1-a;while(C(r.top&63)&1);return!(C(r.top)&2)&&(r.Shape_parity^=a),e}function O(){}function M(r){var e;return e=X(F,r&16777215)<<1|~~r>>24,e}function cr(){var r,e,a,u,t,f,n,i,v,h,_,c,l,o,m,d;for(r=0,n=0;n<28561;++n)f=P[n%13],a=P[~~(n/13)%13],c=P[~~(~~(n/13)/13)%13],_=P[~~(~~(~~(n/13)/13)/13)],l=_<<18|c<<12|a<<6|f,C(l)===16&&(F[r++]=l);for(h=new O,n=0;n<7356;++n)L(h,n),$[n]=fr(h),$[n]|=V(h)<<4,L(h,n),k[n]=ir(h),k[n]|=V(h)<<4,L(h,n),d=h.top&63,o=C(d),m=C(h.bottom&4032),h.Shape_parity^=1&~~(o&m)>>1,h.top=h.top&4032|~~h.bottom>>6&63,h.bottom=h.bottom&63|d<<6,z[n]=V(h);for(n=0;n<7536;++n)s[n]=-1;for(s[M(14378715)]=0,s[M(31157686)]=0,s[M(23967451)]=0,s[M(7191990)]=0,u=4,t=0,e=-1;u!==t;)for(t=u,++e,n=0;n<7536;++n)if(s[n]===e){v=0,i=n;do i=$[i],v+=i&15,i>>=4,s[i]===-1&&(++u,s[i]=e+1);while(v!==12);v=0,i=n;do i=k[i],v+=i&15,i>>=4,s[i]===-1&&(++u,s[i]=e+1);while(v!==12);i=z[n],s[i]===-1&&(++u,s[i]=e+1)}}function vr(){}p=O.prototype=vr.prototype;p.bottom=0;p.Shape_parity=0;p.top=0;var k,F,s,$,z,P,K=!1;function hr(){if(!K){K=!0,S=[],R=[],y=[],w=[],W=[1,1,2,6,24,120,720,5040],q=[];for(var r=0;r<12;++r)q[r]=[];_r()}}function Q(){}function I(r){var e,a,u,t;for(a=0,t=1985229328,e=0;e<7;++e)u=r[e]<<2,a=(8-e)*a+(~~t>>u&7),t-=286331152<=11,u=i?-1:e,r=i?e:-1,++e;r:for(t=0;t<80640;++t)if(S[t]===u){if(f=~~t>>1,_=t&1,n=R[f]<<1|1-_,S[n]===r&&(++a,S[i?t:n]=~~(e<<24)>>24,i))continue r;for(n=f,h=0;h<4;++h)if(n=y[n],S[n<<1|_]===r&&(++a,S[i?t:n<<1|_]=~~(e<<24)>>24,i))continue r;for(h=0;h<4;++h)if(n=w[n],S[n<<1|_]===r&&(++a,S[i?t:n<<1|_]=~~(e<<24)>>24,i))continue r}}}function U(r,e){var a,u,t,f,n;for(n=1985229328,a=0;a<7;++a)t=W[7-a],f=~~(e/t),e-=f*t,f<<=2,r[a]=~~((~~n>>f&7)<<24)>>24,u=(1<>4&~u);r[7]=~~(n<<24)>>24}function lr(){}p=Q.prototype=lr.prototype;p.botEdgeFirst=!1;p.cornperm=0;p.edgeperm=0;p.ml=0;p.topEdgeFirst=!1;var w,q,S,y,R,W;function C(r){return r-=~~r>>1&1431655765,r=(~~r>>2&858993459)+(r&858993459),r=(~~r>>4)+r&252645135,r+=~~r>>8,r+=~~r>>16,r&63}function X(r,e){var a,u,t,f;for(u=0,a=r.length-1;u<=a;)if(t=u+(~~(a-u)>>1),f=r[t],fe)a=t-1;else return t;return-u-1}var A=!1,Sr=function(r,e,a){A||(ur(),hr()),A=!0},pr=function(){return A||Sr(),j()},sr=function(r){var e=new N;return tr(e,r)},or=function(){var r=pr(),e=sr(r);return{pattern:r,scramble_string:e}};function gr(){return or().scramble_string}export{gr as getRandomSquare1ScrambleString}; diff --git a/docs/assets/search-worker-entry-CmpnuiQ5.js b/docs/assets/search-worker-entry-C63kClJR.js similarity index 76% rename from docs/assets/search-worker-entry-CmpnuiQ5.js rename to docs/assets/search-worker-entry-C63kClJR.js index 6a50838..584b484 100644 --- a/docs/assets/search-worker-entry-CmpnuiQ5.js +++ b/docs/assets/search-worker-entry-C63kClJR.js @@ -1,2 +1,2 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/inside-Y2UVJZNJ-Q0pN4g96.js","assets/index-lVaISq9J.js","assets/index-BF6G450p.css"])))=>i.map(i=>d[i]); -import{n as r,e as o,a as t,_ as s}from"./index-lVaISq9J.js";var n=typeof globalThis.Worker>"u"&&typeof globalThis.WorkerNavigator>"u",i="node:w-orker-_threa-ds",d=()=>i.replace(/-/g,"");async function a(){const{parentPort:e}=await import(d()).catch();return r(e)}function p(e){n?(async()=>o(e,await a()))():o(e)}t.expose&&(async()=>(await s(()=>import("./inside-Y2UVJZNJ-Q0pN4g96.js"),__vite__mapDeps([0,1,2])),(globalThis.postMessage?globalThis:await a()).postMessage("comlink-exposed")))();var _=import.meta.url;const c=Object.freeze(Object.defineProperty({__proto__:null,WORKER_ENTRY_FILE_URL:_},Symbol.toStringTag,{value:"Module"}));export{p as e,c as s}; +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/inside-Y2UVJZNJ-vMohPllh.js","assets/index-BA4_IlXs.js","assets/index-BF6G450p.css"])))=>i.map(i=>d[i]); +import{n as r,e as o,a as t,_ as s}from"./index-BA4_IlXs.js";var n=typeof globalThis.Worker>"u"&&typeof globalThis.WorkerNavigator>"u",i="node:w-orker-_threa-ds",d=()=>i.replace(/-/g,"");async function a(){const{parentPort:e}=await import(d()).catch();return r(e)}function p(e){n?(async()=>o(e,await a()))():o(e)}t.expose&&(async()=>(await s(()=>import("./inside-Y2UVJZNJ-vMohPllh.js"),__vite__mapDeps([0,1,2])),(globalThis.postMessage?globalThis:await a()).postMessage("comlink-exposed")))();var _=import.meta.url;const c=Object.freeze(Object.defineProperty({__proto__:null,WORKER_ENTRY_FILE_URL:_},Symbol.toStringTag,{value:"Module"}));export{p as e,c as s}; diff --git a/docs/assets/twisty-dynamic-3d-HF7KVBOE-B1cVZzLL.js b/docs/assets/twisty-dynamic-3d-HF7KVBOE-DN-8Df3y.js similarity index 99% rename from docs/assets/twisty-dynamic-3d-HF7KVBOE-B1cVZzLL.js rename to docs/assets/twisty-dynamic-3d-HF7KVBOE-DN-8Df3y.js index c56a82f..3a92967 100644 --- a/docs/assets/twisty-dynamic-3d-HF7KVBOE-B1cVZzLL.js +++ b/docs/assets/twisty-dynamic-3d-HF7KVBOE-DN-8Df3y.js @@ -1 +1 @@ -var Gt=Object.defineProperty;var St=e=>{throw TypeError(e)};var zt=(e,t,i)=>t in e?Gt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var c=(e,t,i)=>zt(e,typeof t!="symbol"?t+"":t,i),lt=(e,t,i)=>t.has(e)||St("Cannot "+i);var W=(e,t,i)=>(lt(e,t,"read from private field"),i?i.call(e):t.get(e)),$=(e,t,i)=>t.has(e)?St("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,i),_=(e,t,i,s)=>(lt(e,t,"write to private field"),s?s.call(e,i):t.set(e,i),i),V=(e,t,i)=>(lt(e,t,"access private method"),i);import{T as Bt,b as x,C as N,B as X,V as R,E as j,c as U,d as Q,O as Dt,h as Lt,f as Ot,G as Rt,g as tt,D as bt,i as wt,j as mt,k as Z,F as nt,l as Pt,m as It,o as Nt,p as Ht,q as et,M as jt}from"./index-lVaISq9J.js";import{t as Ee}from"./index-lVaISq9J.js";function Ft(e){return e*e*e*(10-e*(15-6*e))}var vt=new Bt,qt=new x({color:new N(6710886).convertLinearToSRGB()}),Wt=new x({color:new N(13421772).convertLinearToSRGB(),side:X,transparent:!0,opacity:.75}),ot=new x({visible:!1}),_t=new x({color:4513228}),Vt=new x({color:16776618}),Jt=new x({color:4513228,side:X,transparent:!0,opacity:.5}),Qt=new x({color:16775545,side:X,transparent:!0,opacity:.5}),J=class{constructor(e,t,i,s,r,n){c(this,"stickerMaterial");c(this,"hintStickerMaterial");this.vector=e,this.fromZ=t,this.color=i,this.dimColor=s,this.hintOpacityScale=r;const o=new N(i).convertLinearToSRGB(),a=new N(s).convertLinearToSRGB();this.stickerMaterial={regular:new x({color:o,side:nt}),dim:new x({color:a,side:nt}),oriented:_t,experimentalOriented2:Vt,ignored:qt,invisible:ot},this.hintStickerMaterial={regular:new x({color:new N((n==null?void 0:n.hintColor)??i).convertLinearToSRGB(),side:X,transparent:!0,opacity:.5*r}),dim:new x({color:new N((n==null?void 0:n.hintDimColor)??s).convertLinearToSRGB(),side:X,transparent:!0,opacity:.5*r}),oriented:Jt,experimentalOriented2:Qt,ignored:Wt,invisible:ot}}},z=[new J(new R(0,1,0),new j(-U/4,0,0),16777215,14540253,1.25),new J(new R(-1,0,0),new j(0,-U/4,0),16750848,8934656,1,{hintDimColor:8930304}),new J(new R(0,0,1),new j(0,0,0),65280,34816,1,{hintDimColor:39168}),new J(new R(1,0,0),new j(0,U/4,0),16711680,6684672,1,{hintDimColor:6684672}),new J(new R(0,0,-1),new j(0,U/2,0),2254591,1127304,.75,{hintDimColor:6246}),new J(new R(0,-1,0),new j(U/4,0,0),16776960,8947712,1.25,{hintDimColor:14540032})],m={U:0,L:1,F:2,R:3,B:4,D:5},Xt={U:m.U,u:m.U,Uw:m.U,Uv:m.U,y:m.U,L:m.L,l:m.L,Lw:m.L,Lv:m.L,M:m.L,F:m.F,f:m.F,Fw:m.F,Fv:m.F,S:m.F,z:m.F,R:m.R,r:m.R,Rw:m.R,Rv:m.R,x:m.R,B:m.B,b:m.B,Bw:m.B,Bv:m.B,D:m.D,d:m.D,Dw:m.D,Dv:m.D,E:m.D},q={stickerElevation:.503,foundationWidth:1,hintStickerElevation:1.45},Zt=2,$t={showMainStickers:!0,hintFacelets:"floating",showFoundation:!0,experimentalStickeringMask:void 0,foundationSprite:null,hintSprite:null,initialHintFaceletsAnimation:"auto",faceletScale:"auto"},Kt=.85;function ht(e){return typeof e.faceletScale>"u"||e.faceletScale==="auto"?Kt:e.faceletScale}var Yt=new x({color:0,opacity:1,transparent:!0}),te=new x({color:0,opacity:.3,transparent:!0}),M=class{constructor(e,t,i){c(this,"matrix");c(this,"stickerFaces");this.orbit=e;const s=typeof t=="string"?t.split(""):t;this.stickerFaces=s.map(r=>m[r]),this.matrix=new Q,this.matrix.setPosition(st[e]),this.matrix.premultiply(new Q().makeRotationFromQuaternion(i))}};function h(e,t){return new Nt().setFromAxisAngle(e,U*t/4)}var u={O:new R(0,0,0),U:new R(0,-1,0),L:new R(1,0,0),F:new R(0,0,-1),R:new R(-1,0,0),B:new R(0,0,1),D:new R(0,1,0)},st={EDGES:new R(0,1,1),CORNERS:new R(1,1,1),CENTERS:new R(0,1,0)},ee={EDGES:[0,1].map(e=>new Q().makeRotationAxis(st.EDGES.clone().normalize(),-e*U/2)),CORNERS:[0,1,2].map(e=>new Q().makeRotationAxis(st.CORNERS.clone().normalize(),-e*U/3)),CENTERS:[0,1,2,3].map(e=>new Q().makeRotationAxis(st.CENTERS.clone().normalize(),-e*U/4))},ut=[m.U,m.F,m.R],K={EDGES:[new M("EDGES","UF",h(u.O,0)),new M("EDGES","UR",h(u.U,3)),new M("EDGES","UB",h(u.U,2)),new M("EDGES","UL",h(u.U,1)),new M("EDGES","DF",h(u.F,2)),new M("EDGES","DR",h(u.F,2).premultiply(h(u.D,1))),new M("EDGES","DB",h(u.F,2).premultiply(h(u.D,2))),new M("EDGES","DL",h(u.F,2).premultiply(h(u.D,3))),new M("EDGES","FR",h(u.U,3).premultiply(h(u.R,3))),new M("EDGES","FL",h(u.U,1).premultiply(h(u.R,3))),new M("EDGES","BR",h(u.U,3).premultiply(h(u.R,1))),new M("EDGES","BL",h(u.U,1).premultiply(h(u.R,1)))],CORNERS:[new M("CORNERS","UFR",h(u.O,0)),new M("CORNERS","URB",h(u.U,3)),new M("CORNERS","UBL",h(u.U,2)),new M("CORNERS","ULF",h(u.U,1)),new M("CORNERS","DRF",h(u.F,2).premultiply(h(u.D,1))),new M("CORNERS","DFL",h(u.F,2).premultiply(h(u.D,0))),new M("CORNERS","DLB",h(u.F,2).premultiply(h(u.D,3))),new M("CORNERS","DBR",h(u.F,2).premultiply(h(u.D,2)))],CENTERS:[new M("CENTERS","U",h(u.O,0)),new M("CENTERS","L",h(u.R,3).premultiply(h(u.U,1))),new M("CENTERS","F",h(u.R,3)),new M("CENTERS","R",h(u.R,3).premultiply(h(u.D,1))),new M("CENTERS","B",h(u.R,3).premultiply(h(u.D,2))),new M("CENTERS","D",h(u.R,2))]},ft=1/3,it={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]],[[0,4,0],[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]]]},yt=null;function ie(){return yt??(yt=new Ht(q.foundationWidth,q.foundationWidth,q.foundationWidth))}function pt(){const e=new mt,t=.5;return e.setAttribute("position",new Z(new Float32Array([t,t,0,-t,t,0,t,-t,0,-t,t,0,-t,-t,0,t,-t,0]),3)),e.setAttribute("uv",new Z(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)),e}var gt=null;function se(){return gt??(gt=pt())}var at,H,rt,Ct,Et,re=(Et=class extends Dt{constructor(t,i,s={}){super();$(this,H);c(this,"kpuzzleFaceletInfo");c(this,"pieces",{});c(this,"options");c(this,"experimentalHintStickerMeshes",[]);c(this,"experimentalFoundationMeshes",[]);c(this,"setSpriteURL");c(this,"sprite",new Promise(t=>{this.setSpriteURL=i=>{vt.load(i,t)}}));c(this,"setHintSpriteURL");c(this,"hintSprite",new Promise(t=>{this.setHintSpriteURL=i=>{vt.load(i,t)}}));$(this,at,null);if(this.kpuzzle=t,this.scheduleRenderCallback=i,this.options={...$t},Object.assign(this.options,s),this.kpuzzle.name()!=="3x3x3")throw new Error(`Invalid puzzle for this Cube3D implementation: ${this.kpuzzle.name()}`);s.foundationSprite&&this.setSprite(s.foundationSprite),s.hintSprite&&this.setHintSprite(s.hintSprite),this.kpuzzleFaceletInfo={};for(const r in K){const n=[];this.kpuzzleFaceletInfo[r]=n,this.pieces[r]=K[r].map(this.createCubie.bind(this,r,n))}this.scale.set(ft,ft,ft),this.options.experimentalStickeringMask&&this.setStickeringMask(this.options.experimentalStickeringMask),V(this,H,Ct).call(this),this.options.faceletScale&&this.experimentalSetFaceletScale(this.options.faceletScale)}setSprite(t){this.sprite=t}setHintSprite(t){this.hintSprite=t}experimentalSetStickerSpriteURL(t){this.setSpriteURL(t)}experimentalSetHintStickerSpriteURL(t){this.setHintSpriteURL(t)}setStickeringMask(t){if(t.specialBehaviour==="picture"){for(const i of Object.values(this.kpuzzleFaceletInfo))for(const s of i)for(const r of s){r.facelet.material=ot;const{hintFacelet:n}=r;n&&(n.material=ot)}return}this.options.experimentalStickeringMask=t;for(const[i,s]of Object.entries(t.orbits))for(let r=0;r{const p=async C=>{const b=await(C?this.hintSprite:this.sprite),T=this.createSticker(z[ut[l]],z[s.stickerFaces[l]],C);T.material=new x({map:b,side:C?X:bt,transparent:!0});const G=v/12,L=(v+1)/12,F=g/9,O=(g+1)/9;let D=new et(G,F),y=new et(G,O),d=new et(L,O),S=new et(L,F);switch(E){case 1:{[D,y,d,S]=[y,d,S,D];break}case 2:{[D,y,d,S]=[d,S,D,y];break}case 3:{[D,y,d,S]=[S,D,y,d];break}}T.geometry.setAttribute("uv",new Z(new Float32Array([d.x,d.y,y.x,y.y,S.x,S.y,y.x,y.y,D.x,D.y,S.x,S.y]),2)),o.add(T)};p(!0),p(!1)})()}n.push(k)}return o.matrix.copy(s.matrix),o.matrixAutoUpdate=!1,this.add(o),o}createCubieFoundation(){var i;const t=ie();return new tt(t,((i=this.options.experimentalStickeringMask)==null?void 0:i.specialBehaviour)==="picture"?Yt:te)}createSticker(t,i,s){var o,a;const r=((o=this.options.experimentalStickeringMask)==null?void 0:o.specialBehaviour)==="picture"?pt():s?V(this,H,rt).call(this):se(),n=new tt(r,s?i.hintStickerMaterial.regular:i.stickerMaterial.regular);return n.setRotationFromEuler(t.fromZ),n.position.copy(t.vector),n.position.multiplyScalar(s?((a=this.options.experimentalStickeringMask)==null?void 0:a.specialBehaviour)==="picture"?Zt:q.hintStickerElevation:q.stickerElevation),n.scale.setScalar(ht(this.options)),n}experimentalSetFoundationOpacity(t){this.experimentalFoundationMeshes[0].material.opacity=t}experimentalSetFaceletScale(t){var i;this.options.faceletScale=t;for(const s of Object.values(this.kpuzzleFaceletInfo))for(const r of s)for(const n of r)n.facelet.scale.setScalar(ht(this.options)),(i=n.hintFacelet)==null||i.scale.setScalar(ht(this.options))}ease(t){return Ft(t)}},at=new WeakMap,H=new WeakSet,rt=function(){return W(this,at)??_(this,at,pt())},Ct=function(){if(this.options.initialHintFaceletsAnimation==="none"||this.options.initialHintFaceletsAnimation!=="always"&&Lt())return;const t=q.hintStickerElevation-q.stickerElevation;V(this,H,rt).call(this).translate(0,0,-t),setTimeout(()=>{const i=performance.now();let s=0;const r=1e3;function n(a){return a*(2-a)}const o=()=>{var f;const a=performance.now()-i,l=n(a/r)*t;V(this,H,rt).call(this).translate(0,0,l-s),s=l,a>16,this.colors[this.pos+1]=i>>8&255,this.colors[this.pos+2]=i&255,this.pos+=3}addUncolored(e,t){this.vertices[this.pos]=e[3*t+0],this.vertices[this.pos+1]=e[3*t+1],this.vertices[this.pos+2]=e[3*t+2],this.pos+=3}setind(e){this.ind[this.ipos++]=e}makePoly(e,t,i){const s=e;for(let r=1;3*(r+1)>16,e.colors[e.pos+s+1]=i>>8&255,e.colors[e.pos+s+2]=i&255;for(let s=9*this.hintStart;s<9*this.hintEnd;s+=3)e.colors[e.pos+s]=i>>16,e.colors[e.pos+s+1]=i>>8&255,e.colors[e.pos+s+2]=i&255;this.setHintStickers(e,t!=="invisible"&&!this.isDup)}addUVs(e){const t=e.uvs,i=e.vertices,s=new Array(3);for(let r=3*this.stickerStart;r<3*this.stickerEnd;r++){s[0]=i[3*r],s[1]=i[3*r+1],s[2]=i[3*r+2];const n=e.tm.getuv(this.faceNum,s);t[2*r]=n[0],t[2*r+1]=n[1]}for(let r=3*this.hintStart;r<3*this.hintEnd;r++){s[0]=i[3*r],s[1]=i[3*r+1],s[2]=i[3*r+2];const n=e.tm.getuv(this.faceNum,s);t[2*r]=n[0],t[2*r+1]=n[1]}}setTexture(e,t){if(this.texturePtr===t)return 0;this.texturePtr=t;const i=6*e.sz;return e.uvs.copyWithin(6*this.stickerStart,6*t.stickerStart+i,6*t.stickerEnd+i),e.uvs.copyWithin(6*this.hintStart,6*t.hintStart+i,6*t.hintEnd+i),1}setColor(e,t){const i=t.origColorStickeringMask;if(this.faceColor!==i){this.faceColor=i;const s=e.pos;return e.colors.copyWithin(9*this.stickerStart,9*t.stickerStart+s,9*t.stickerEnd+s),e.colors.copyWithin(9*this.hintStart,9*t.hintStart+s,9*t.hintEnd+s),1}else return 0}},fe=class{constructor(e,t,i){c(this,"cubie");c(this,"geo");this.cubie=new Rt;const s=e.coords,r=new Tt(s.length/3-2,t);for(let o=1;3*o+3a;switch(i.depth){case"secondSlice":{n=a=>a.modified({innerLayer:2});break}case"rotation":{n=a=>a.modified({family:`${a.family}v`});break}}for(const a of this.stickerDat.axis){const l=t.dot(new R(...a.coordinates));if(l>r){const f=this.stickerDat.notationMapper.notationToExternal(n(a.quantumMove));if(!f)continue;V(this,ct,At).call(this,f)&&(r=l,s=f)}}if(!s)return null;i.invert&&(s=s.invert());const o=this.kpuzzle.moveToTransformation(s).repetitionOrder();return{move:s,order:o}}setStickeringMask(t){if(this.params.stickeringMask=t,t.specialBehaviour!=="picture")for(const i of this.kpuzzle.definition.orbits){const{numPieces:s,numOrientations:r}=i;for(let n=0;nnew(await Pt).Scene)())}addRenderTarget(e){this.renderTargets.add(e)}scheduleRender(){for(const e of this.renderTargets)e.scheduleRender()}async addTwisty3DPuzzle(e){this.twisty3Ds.add(e),(await this.threeJSScene).add(e)}async removeTwisty3DPuzzle(e){this.twisty3Ds.delete(e),(await this.threeJSScene).remove(e)}async clearPuzzles(){for(const e of this.twisty3Ds)(await this.threeJSScene).remove(e);this.twisty3Ds.clear()}};async function ve(e,t){return new re(await It.kpuzzle(),e,t)}async function ye(e,t,i,s,r){return new me(e,await t.kpuzzle(),(await t.pg()).get3d({darkIgnoredOrbits:r}),!0,i==="floating",void 0,s)}export{re as Cube3D,me as PG3D,Ee as T3I,we as Twisty3DScene,ve as cube3DShim,ye as pg3dShim}; +var Gt=Object.defineProperty;var St=e=>{throw TypeError(e)};var zt=(e,t,i)=>t in e?Gt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var c=(e,t,i)=>zt(e,typeof t!="symbol"?t+"":t,i),lt=(e,t,i)=>t.has(e)||St("Cannot "+i);var W=(e,t,i)=>(lt(e,t,"read from private field"),i?i.call(e):t.get(e)),$=(e,t,i)=>t.has(e)?St("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,i),_=(e,t,i,s)=>(lt(e,t,"write to private field"),s?s.call(e,i):t.set(e,i),i),V=(e,t,i)=>(lt(e,t,"access private method"),i);import{T as Bt,b as x,C as N,B as X,V as R,E as j,c as U,d as Q,O as Dt,h as Lt,f as Ot,G as Rt,g as tt,D as bt,i as wt,j as mt,k as Z,F as nt,l as Pt,m as It,o as Nt,p as Ht,q as et,M as jt}from"./index-BA4_IlXs.js";import{t as Ee}from"./index-BA4_IlXs.js";function Ft(e){return e*e*e*(10-e*(15-6*e))}var vt=new Bt,qt=new x({color:new N(6710886).convertLinearToSRGB()}),Wt=new x({color:new N(13421772).convertLinearToSRGB(),side:X,transparent:!0,opacity:.75}),ot=new x({visible:!1}),_t=new x({color:4513228}),Vt=new x({color:16776618}),Jt=new x({color:4513228,side:X,transparent:!0,opacity:.5}),Qt=new x({color:16775545,side:X,transparent:!0,opacity:.5}),J=class{constructor(e,t,i,s,r,n){c(this,"stickerMaterial");c(this,"hintStickerMaterial");this.vector=e,this.fromZ=t,this.color=i,this.dimColor=s,this.hintOpacityScale=r;const o=new N(i).convertLinearToSRGB(),a=new N(s).convertLinearToSRGB();this.stickerMaterial={regular:new x({color:o,side:nt}),dim:new x({color:a,side:nt}),oriented:_t,experimentalOriented2:Vt,ignored:qt,invisible:ot},this.hintStickerMaterial={regular:new x({color:new N((n==null?void 0:n.hintColor)??i).convertLinearToSRGB(),side:X,transparent:!0,opacity:.5*r}),dim:new x({color:new N((n==null?void 0:n.hintDimColor)??s).convertLinearToSRGB(),side:X,transparent:!0,opacity:.5*r}),oriented:Jt,experimentalOriented2:Qt,ignored:Wt,invisible:ot}}},z=[new J(new R(0,1,0),new j(-U/4,0,0),16777215,14540253,1.25),new J(new R(-1,0,0),new j(0,-U/4,0),16750848,8934656,1,{hintDimColor:8930304}),new J(new R(0,0,1),new j(0,0,0),65280,34816,1,{hintDimColor:39168}),new J(new R(1,0,0),new j(0,U/4,0),16711680,6684672,1,{hintDimColor:6684672}),new J(new R(0,0,-1),new j(0,U/2,0),2254591,1127304,.75,{hintDimColor:6246}),new J(new R(0,-1,0),new j(U/4,0,0),16776960,8947712,1.25,{hintDimColor:14540032})],m={U:0,L:1,F:2,R:3,B:4,D:5},Xt={U:m.U,u:m.U,Uw:m.U,Uv:m.U,y:m.U,L:m.L,l:m.L,Lw:m.L,Lv:m.L,M:m.L,F:m.F,f:m.F,Fw:m.F,Fv:m.F,S:m.F,z:m.F,R:m.R,r:m.R,Rw:m.R,Rv:m.R,x:m.R,B:m.B,b:m.B,Bw:m.B,Bv:m.B,D:m.D,d:m.D,Dw:m.D,Dv:m.D,E:m.D},q={stickerElevation:.503,foundationWidth:1,hintStickerElevation:1.45},Zt=2,$t={showMainStickers:!0,hintFacelets:"floating",showFoundation:!0,experimentalStickeringMask:void 0,foundationSprite:null,hintSprite:null,initialHintFaceletsAnimation:"auto",faceletScale:"auto"},Kt=.85;function ht(e){return typeof e.faceletScale>"u"||e.faceletScale==="auto"?Kt:e.faceletScale}var Yt=new x({color:0,opacity:1,transparent:!0}),te=new x({color:0,opacity:.3,transparent:!0}),M=class{constructor(e,t,i){c(this,"matrix");c(this,"stickerFaces");this.orbit=e;const s=typeof t=="string"?t.split(""):t;this.stickerFaces=s.map(r=>m[r]),this.matrix=new Q,this.matrix.setPosition(st[e]),this.matrix.premultiply(new Q().makeRotationFromQuaternion(i))}};function h(e,t){return new Nt().setFromAxisAngle(e,U*t/4)}var u={O:new R(0,0,0),U:new R(0,-1,0),L:new R(1,0,0),F:new R(0,0,-1),R:new R(-1,0,0),B:new R(0,0,1),D:new R(0,1,0)},st={EDGES:new R(0,1,1),CORNERS:new R(1,1,1),CENTERS:new R(0,1,0)},ee={EDGES:[0,1].map(e=>new Q().makeRotationAxis(st.EDGES.clone().normalize(),-e*U/2)),CORNERS:[0,1,2].map(e=>new Q().makeRotationAxis(st.CORNERS.clone().normalize(),-e*U/3)),CENTERS:[0,1,2,3].map(e=>new Q().makeRotationAxis(st.CENTERS.clone().normalize(),-e*U/4))},ut=[m.U,m.F,m.R],K={EDGES:[new M("EDGES","UF",h(u.O,0)),new M("EDGES","UR",h(u.U,3)),new M("EDGES","UB",h(u.U,2)),new M("EDGES","UL",h(u.U,1)),new M("EDGES","DF",h(u.F,2)),new M("EDGES","DR",h(u.F,2).premultiply(h(u.D,1))),new M("EDGES","DB",h(u.F,2).premultiply(h(u.D,2))),new M("EDGES","DL",h(u.F,2).premultiply(h(u.D,3))),new M("EDGES","FR",h(u.U,3).premultiply(h(u.R,3))),new M("EDGES","FL",h(u.U,1).premultiply(h(u.R,3))),new M("EDGES","BR",h(u.U,3).premultiply(h(u.R,1))),new M("EDGES","BL",h(u.U,1).premultiply(h(u.R,1)))],CORNERS:[new M("CORNERS","UFR",h(u.O,0)),new M("CORNERS","URB",h(u.U,3)),new M("CORNERS","UBL",h(u.U,2)),new M("CORNERS","ULF",h(u.U,1)),new M("CORNERS","DRF",h(u.F,2).premultiply(h(u.D,1))),new M("CORNERS","DFL",h(u.F,2).premultiply(h(u.D,0))),new M("CORNERS","DLB",h(u.F,2).premultiply(h(u.D,3))),new M("CORNERS","DBR",h(u.F,2).premultiply(h(u.D,2)))],CENTERS:[new M("CENTERS","U",h(u.O,0)),new M("CENTERS","L",h(u.R,3).premultiply(h(u.U,1))),new M("CENTERS","F",h(u.R,3)),new M("CENTERS","R",h(u.R,3).premultiply(h(u.D,1))),new M("CENTERS","B",h(u.R,3).premultiply(h(u.D,2))),new M("CENTERS","D",h(u.R,2))]},ft=1/3,it={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]],[[0,4,0],[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]]]},yt=null;function ie(){return yt??(yt=new Ht(q.foundationWidth,q.foundationWidth,q.foundationWidth))}function pt(){const e=new mt,t=.5;return e.setAttribute("position",new Z(new Float32Array([t,t,0,-t,t,0,t,-t,0,-t,t,0,-t,-t,0,t,-t,0]),3)),e.setAttribute("uv",new Z(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)),e}var gt=null;function se(){return gt??(gt=pt())}var at,H,rt,Ct,Et,re=(Et=class extends Dt{constructor(t,i,s={}){super();$(this,H);c(this,"kpuzzleFaceletInfo");c(this,"pieces",{});c(this,"options");c(this,"experimentalHintStickerMeshes",[]);c(this,"experimentalFoundationMeshes",[]);c(this,"setSpriteURL");c(this,"sprite",new Promise(t=>{this.setSpriteURL=i=>{vt.load(i,t)}}));c(this,"setHintSpriteURL");c(this,"hintSprite",new Promise(t=>{this.setHintSpriteURL=i=>{vt.load(i,t)}}));$(this,at,null);if(this.kpuzzle=t,this.scheduleRenderCallback=i,this.options={...$t},Object.assign(this.options,s),this.kpuzzle.name()!=="3x3x3")throw new Error(`Invalid puzzle for this Cube3D implementation: ${this.kpuzzle.name()}`);s.foundationSprite&&this.setSprite(s.foundationSprite),s.hintSprite&&this.setHintSprite(s.hintSprite),this.kpuzzleFaceletInfo={};for(const r in K){const n=[];this.kpuzzleFaceletInfo[r]=n,this.pieces[r]=K[r].map(this.createCubie.bind(this,r,n))}this.scale.set(ft,ft,ft),this.options.experimentalStickeringMask&&this.setStickeringMask(this.options.experimentalStickeringMask),V(this,H,Ct).call(this),this.options.faceletScale&&this.experimentalSetFaceletScale(this.options.faceletScale)}setSprite(t){this.sprite=t}setHintSprite(t){this.hintSprite=t}experimentalSetStickerSpriteURL(t){this.setSpriteURL(t)}experimentalSetHintStickerSpriteURL(t){this.setHintSpriteURL(t)}setStickeringMask(t){if(t.specialBehaviour==="picture"){for(const i of Object.values(this.kpuzzleFaceletInfo))for(const s of i)for(const r of s){r.facelet.material=ot;const{hintFacelet:n}=r;n&&(n.material=ot)}return}this.options.experimentalStickeringMask=t;for(const[i,s]of Object.entries(t.orbits))for(let r=0;r{const p=async C=>{const b=await(C?this.hintSprite:this.sprite),T=this.createSticker(z[ut[l]],z[s.stickerFaces[l]],C);T.material=new x({map:b,side:C?X:bt,transparent:!0});const G=v/12,L=(v+1)/12,F=g/9,O=(g+1)/9;let D=new et(G,F),y=new et(G,O),d=new et(L,O),S=new et(L,F);switch(E){case 1:{[D,y,d,S]=[y,d,S,D];break}case 2:{[D,y,d,S]=[d,S,D,y];break}case 3:{[D,y,d,S]=[S,D,y,d];break}}T.geometry.setAttribute("uv",new Z(new Float32Array([d.x,d.y,y.x,y.y,S.x,S.y,y.x,y.y,D.x,D.y,S.x,S.y]),2)),o.add(T)};p(!0),p(!1)})()}n.push(k)}return o.matrix.copy(s.matrix),o.matrixAutoUpdate=!1,this.add(o),o}createCubieFoundation(){var i;const t=ie();return new tt(t,((i=this.options.experimentalStickeringMask)==null?void 0:i.specialBehaviour)==="picture"?Yt:te)}createSticker(t,i,s){var o,a;const r=((o=this.options.experimentalStickeringMask)==null?void 0:o.specialBehaviour)==="picture"?pt():s?V(this,H,rt).call(this):se(),n=new tt(r,s?i.hintStickerMaterial.regular:i.stickerMaterial.regular);return n.setRotationFromEuler(t.fromZ),n.position.copy(t.vector),n.position.multiplyScalar(s?((a=this.options.experimentalStickeringMask)==null?void 0:a.specialBehaviour)==="picture"?Zt:q.hintStickerElevation:q.stickerElevation),n.scale.setScalar(ht(this.options)),n}experimentalSetFoundationOpacity(t){this.experimentalFoundationMeshes[0].material.opacity=t}experimentalSetFaceletScale(t){var i;this.options.faceletScale=t;for(const s of Object.values(this.kpuzzleFaceletInfo))for(const r of s)for(const n of r)n.facelet.scale.setScalar(ht(this.options)),(i=n.hintFacelet)==null||i.scale.setScalar(ht(this.options))}ease(t){return Ft(t)}},at=new WeakMap,H=new WeakSet,rt=function(){return W(this,at)??_(this,at,pt())},Ct=function(){if(this.options.initialHintFaceletsAnimation==="none"||this.options.initialHintFaceletsAnimation!=="always"&&Lt())return;const t=q.hintStickerElevation-q.stickerElevation;V(this,H,rt).call(this).translate(0,0,-t),setTimeout(()=>{const i=performance.now();let s=0;const r=1e3;function n(a){return a*(2-a)}const o=()=>{var f;const a=performance.now()-i,l=n(a/r)*t;V(this,H,rt).call(this).translate(0,0,l-s),s=l,a>16,this.colors[this.pos+1]=i>>8&255,this.colors[this.pos+2]=i&255,this.pos+=3}addUncolored(e,t){this.vertices[this.pos]=e[3*t+0],this.vertices[this.pos+1]=e[3*t+1],this.vertices[this.pos+2]=e[3*t+2],this.pos+=3}setind(e){this.ind[this.ipos++]=e}makePoly(e,t,i){const s=e;for(let r=1;3*(r+1)>16,e.colors[e.pos+s+1]=i>>8&255,e.colors[e.pos+s+2]=i&255;for(let s=9*this.hintStart;s<9*this.hintEnd;s+=3)e.colors[e.pos+s]=i>>16,e.colors[e.pos+s+1]=i>>8&255,e.colors[e.pos+s+2]=i&255;this.setHintStickers(e,t!=="invisible"&&!this.isDup)}addUVs(e){const t=e.uvs,i=e.vertices,s=new Array(3);for(let r=3*this.stickerStart;r<3*this.stickerEnd;r++){s[0]=i[3*r],s[1]=i[3*r+1],s[2]=i[3*r+2];const n=e.tm.getuv(this.faceNum,s);t[2*r]=n[0],t[2*r+1]=n[1]}for(let r=3*this.hintStart;r<3*this.hintEnd;r++){s[0]=i[3*r],s[1]=i[3*r+1],s[2]=i[3*r+2];const n=e.tm.getuv(this.faceNum,s);t[2*r]=n[0],t[2*r+1]=n[1]}}setTexture(e,t){if(this.texturePtr===t)return 0;this.texturePtr=t;const i=6*e.sz;return e.uvs.copyWithin(6*this.stickerStart,6*t.stickerStart+i,6*t.stickerEnd+i),e.uvs.copyWithin(6*this.hintStart,6*t.hintStart+i,6*t.hintEnd+i),1}setColor(e,t){const i=t.origColorStickeringMask;if(this.faceColor!==i){this.faceColor=i;const s=e.pos;return e.colors.copyWithin(9*this.stickerStart,9*t.stickerStart+s,9*t.stickerEnd+s),e.colors.copyWithin(9*this.hintStart,9*t.hintStart+s,9*t.hintEnd+s),1}else return 0}},fe=class{constructor(e,t,i){c(this,"cubie");c(this,"geo");this.cubie=new Rt;const s=e.coords,r=new Tt(s.length/3-2,t);for(let o=1;3*o+3a;switch(i.depth){case"secondSlice":{n=a=>a.modified({innerLayer:2});break}case"rotation":{n=a=>a.modified({family:`${a.family}v`});break}}for(const a of this.stickerDat.axis){const l=t.dot(new R(...a.coordinates));if(l>r){const f=this.stickerDat.notationMapper.notationToExternal(n(a.quantumMove));if(!f)continue;V(this,ct,At).call(this,f)&&(r=l,s=f)}}if(!s)return null;i.invert&&(s=s.invert());const o=this.kpuzzle.moveToTransformation(s).repetitionOrder();return{move:s,order:o}}setStickeringMask(t){if(this.params.stickeringMask=t,t.specialBehaviour!=="picture")for(const i of this.kpuzzle.definition.orbits){const{numPieces:s,numOrientations:r}=i;for(let n=0;nnew(await Pt).Scene)())}addRenderTarget(e){this.renderTargets.add(e)}scheduleRender(){for(const e of this.renderTargets)e.scheduleRender()}async addTwisty3DPuzzle(e){this.twisty3Ds.add(e),(await this.threeJSScene).add(e)}async removeTwisty3DPuzzle(e){this.twisty3Ds.delete(e),(await this.threeJSScene).remove(e)}async clearPuzzles(){for(const e of this.twisty3Ds)(await this.threeJSScene).remove(e);this.twisty3Ds.clear()}};async function ve(e,t){return new re(await It.kpuzzle(),e,t)}async function ye(e,t,i,s,r){return new me(e,await t.kpuzzle(),(await t.pg()).get3d({darkIgnoredOrbits:r}),!0,i==="floating",void 0,s)}export{re as Cube3D,me as PG3D,Ee as T3I,we as Twisty3DScene,ve as cube3DShim,ye as pg3dShim}; diff --git a/docs/assets/twsearch-MRZGOB6T-BaM7-RH2.js b/docs/assets/twsearch-MRZGOB6T-CZQF4Gzo.js similarity index 99% rename from docs/assets/twsearch-MRZGOB6T-BaM7-RH2.js rename to docs/assets/twsearch-MRZGOB6T-CZQF4Gzo.js index eb3dd99..96c33e3 100644 --- a/docs/assets/twsearch-MRZGOB6T-BaM7-RH2.js +++ b/docs/assets/twsearch-MRZGOB6T-CZQF4Gzo.js @@ -1,2 +1,2 @@ -import{J as R,_ as $}from"./index-lVaISq9J.js";var J="node:-fs/pr-omises",L=()=>J.replace(/-/g,""),i,W=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&W.decode();var v=null;function T(){return(v===null||v.byteLength===0)&&(v=new Uint8Array(i.memory.buffer)),v}function y(e,n){return e=e>>>0,W.decode(T().subarray(e,e+n))}var g=new Array(128).fill(void 0);g.push(void 0,null,!0,!1);var S=g.length;function _(e){S===g.length&&g.push(g.length+1);const n=S;return S=g[n],g[n]=e,n}function c(e){return g[e]}function C(e){e<132||(g[e]=S,S=e)}function E(e){const n=c(e);return C(e),n}function O(e){const n=typeof e;if(n=="number"||n=="boolean"||e==null)return`${e}`;if(n=="string")return`"${e}"`;if(n=="symbol"){const o=e.description;return o==null?"Symbol":`Symbol(${o})`}if(n=="function"){const o=e.name;return typeof o=="string"&&o.length>0?`Function(${o})`:"Function"}if(Array.isArray(e)){const o=e.length;let f="[";o>0&&(f+=O(e[0]));for(let a=1;a1)r=t[1];else return toString.call(e);if(r=="Object")try{return"Object("+JSON.stringify(e)+")"}catch{return"Object"}return e instanceof Error?`${e.name}: ${e.message} +import{J as R,_ as $}from"./index-BA4_IlXs.js";var J="node:-fs/pr-omises",L=()=>J.replace(/-/g,""),i,W=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&W.decode();var v=null;function T(){return(v===null||v.byteLength===0)&&(v=new Uint8Array(i.memory.buffer)),v}function y(e,n){return e=e>>>0,W.decode(T().subarray(e,e+n))}var g=new Array(128).fill(void 0);g.push(void 0,null,!0,!1);var S=g.length;function _(e){S===g.length&&g.push(g.length+1);const n=S;return S=g[n],g[n]=e,n}function c(e){return g[e]}function C(e){e<132||(g[e]=S,S=e)}function E(e){const n=c(e);return C(e),n}function O(e){const n=typeof e;if(n=="number"||n=="boolean"||e==null)return`${e}`;if(n=="string")return`"${e}"`;if(n=="symbol"){const o=e.description;return o==null?"Symbol":`Symbol(${o})`}if(n=="function"){const o=e.name;return typeof o=="string"&&o.length>0?`Function(${o})`:"Function"}if(Array.isArray(e)){const o=e.length;let f="[";o>0&&(f+=O(e[0]));for(let a=1;a1)r=t[1];else return toString.call(e);if(r=="Object")try{return"Object("+JSON.stringify(e)+")"}catch{return"Object"}return e instanceof Error?`${e.name}: ${e.message} ${e.stack}`:r}var l=0,A=typeof TextEncoder<"u"?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},q=typeof A.encodeInto=="function"?function(e,n){return A.encodeInto(e,n)}:function(e,n){const t=A.encode(e);return n.set(t),{read:e.length,written:t.length}};function p(e,n,t){if(t===void 0){const s=A.encode(e),b=n(s.length,1)>>>0;return T().subarray(b,b+s.length).set(s),l=s.length,b}let r=e.length,o=n(r,1)>>>0;const f=T();let a=0;for(;a127)break;f[o+a]=s}if(a!==r){a!==0&&(e=e.slice(a)),o=t(o,r,r=a+e.length*3,1)>>>0;const s=T().subarray(o+a,o+r),b=q(e,s);a+=b.written}return l=a,o}var x=null;function u(){return(x===null||x.byteLength===0)&&(x=new Int32Array(i.memory.buffer)),x}function V(e,n,t){let r,o;try{const m=i.__wbindgen_add_to_stack_pointer(-16),k=p(e,i.__wbindgen_export_0,i.__wbindgen_export_1),I=l,M=p(n,i.__wbindgen_export_0,i.__wbindgen_export_1),U=l,D=p(t,i.__wbindgen_export_0,i.__wbindgen_export_1),N=l;i.wasmTwsearch(m,k,I,M,U,D,N);var f=u()[m/4+0],a=u()[m/4+1],s=u()[m/4+2],b=u()[m/4+3],d=f,h=a;if(b)throw d=0,h=0,E(s);return r=d,o=h,y(d,h)}finally{i.__wbindgen_add_to_stack_pointer(16),i.__wbindgen_export_2(r,o,1)}}function B(e){let n,t;try{const d=i.__wbindgen_add_to_stack_pointer(-16),h=p(e,i.__wbindgen_export_0,i.__wbindgen_export_1),m=l;i.wasmRandomScrambleForEvent(d,h,m);var r=u()[d/4+0],o=u()[d/4+1],f=u()[d/4+2],a=u()[d/4+3],s=r,b=o;if(a)throw s=0,b=0,E(f);return n=s,t=b,y(s,b)}finally{i.__wbindgen_add_to_stack_pointer(16),i.__wbindgen_export_2(n,t,1)}}function w(e,n){try{return e.apply(this,n)}catch(t){i.__wbindgen_export_3(_(t))}}async function P(e,n){if(typeof Response=="function"&&e instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(e,n)}catch(r){if(e.headers.get("Content-Type")!="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",r);else throw r}const t=await e.arrayBuffer();return await WebAssembly.instantiate(t,n)}else{const t=await WebAssembly.instantiate(e,n);return t instanceof WebAssembly.Instance?{instance:t,module:e}:t}}function z(){const e={};return e.wbg={},e.wbg.__wbindgen_string_new=function(n,t){const r=y(n,t);return _(r)},e.wbg.__wbg_new_abda76e883ba8a5f=function(){const n=new Error;return _(n)},e.wbg.__wbg_stack_658279fe44541cf6=function(n,t){const r=c(t).stack,o=p(r,i.__wbindgen_export_0,i.__wbindgen_export_1),f=l;u()[n/4+1]=f,u()[n/4+0]=o},e.wbg.__wbg_error_f851667af71bcfc6=function(n,t){let r,o;try{r=n,o=t,console.error(y(n,t))}finally{i.__wbindgen_export_2(r,o,1)}},e.wbg.__wbindgen_object_drop_ref=function(n){E(n)},e.wbg.__wbindgen_object_clone_ref=function(n){const t=c(n);return _(t)},e.wbg.__wbg_crypto_c48a774b022d20ac=function(n){const t=c(n).crypto;return _(t)},e.wbg.__wbindgen_is_object=function(n){const t=c(n);return typeof t=="object"&&t!==null},e.wbg.__wbg_process_298734cf255a885d=function(n){const t=c(n).process;return _(t)},e.wbg.__wbg_versions_e2e78e134e3e5d01=function(n){const t=c(n).versions;return _(t)},e.wbg.__wbg_node_1cd7a5d853dbea79=function(n){const t=c(n).node;return _(t)},e.wbg.__wbindgen_is_string=function(n){return typeof c(n)=="string"},e.wbg.__wbg_require_8f08ceecec0f4fee=function(){return w(function(){const n=module.require;return _(n)},arguments)},e.wbg.__wbindgen_is_function=function(n){return typeof c(n)=="function"},e.wbg.__wbg_call_01734de55d61e11d=function(){return w(function(n,t,r){const o=c(n).call(c(t),c(r));return _(o)},arguments)},e.wbg.__wbg_msCrypto_bcb970640f50a1e8=function(n){const t=c(n).msCrypto;return _(t)},e.wbg.__wbg_newwithlength_e5d69174d6984cd7=function(n){const t=new Uint8Array(n>>>0);return _(t)},e.wbg.__wbg_get_97b561fb56f034b5=function(){return w(function(n,t){const r=Reflect.get(c(n),c(t));return _(r)},arguments)},e.wbg.__wbg_now_0cfdc90c97d0c24b=function(n){return c(n).now()},e.wbg.__wbg_self_1ff1d729e9aae938=function(){return w(function(){const n=self.self;return _(n)},arguments)},e.wbg.__wbg_window_5f4faef6c12b79ec=function(){return w(function(){const n=window.window;return _(n)},arguments)},e.wbg.__wbg_globalThis_1d39714405582d3c=function(){return w(function(){const n=globalThis.globalThis;return _(n)},arguments)},e.wbg.__wbg_global_651f05c6a0944d1c=function(){return w(function(){const n=global.global;return _(n)},arguments)},e.wbg.__wbindgen_is_undefined=function(n){return c(n)===void 0},e.wbg.__wbg_newnoargs_581967eacc0e2604=function(n,t){const r=new Function(y(n,t));return _(r)},e.wbg.__wbg_call_cb65541d95d71282=function(){return w(function(n,t){const r=c(n).call(c(t));return _(r)},arguments)},e.wbg.__wbindgen_memory=function(){const n=i.memory;return _(n)},e.wbg.__wbg_buffer_085ec1f694018c4f=function(n){const t=c(n).buffer;return _(t)},e.wbg.__wbg_newwithbyteoffsetandlength_6da8e527659b86aa=function(n,t,r){const o=new Uint8Array(c(n),t>>>0,r>>>0);return _(o)},e.wbg.__wbg_randomFillSync_dc1e9a60c158336d=function(){return w(function(n,t){c(n).randomFillSync(E(t))},arguments)},e.wbg.__wbg_subarray_13db269f57aa838d=function(n,t,r){const o=c(n).subarray(t>>>0,r>>>0);return _(o)},e.wbg.__wbg_getRandomValues_37fa2ca9e4e07fab=function(){return w(function(n,t){c(n).getRandomValues(c(t))},arguments)},e.wbg.__wbg_new_8125e318e6245eed=function(n){const t=new Uint8Array(c(n));return _(t)},e.wbg.__wbg_set_5cf90238115182c3=function(n,t,r){c(n).set(c(t),r>>>0)},e.wbg.__wbindgen_debug_string=function(n,t){const r=O(c(t)),o=p(r,i.__wbindgen_export_0,i.__wbindgen_export_1),f=l;u()[n/4+1]=f,u()[n/4+0]=o},e.wbg.__wbindgen_throw=function(n,t){throw new Error(y(n,t))},e}function H(e,n){return i=e.exports,j.__wbindgen_wasm_module=n,x=null,v=null,i}async function j(e){if(i!==void 0)return i;if(typeof e>"u")throw new Error("Default `wasm-pack` WASM loading code path triggered! This is currently not supported for `twsearch` due to incompatibility with some bundlers.");const n=z();if(typeof e=="string"||typeof Request=="function"&&e instanceof Request||typeof URL=="function"&&e instanceof URL)try{e=await fetch(e)}catch(o){if(!(o instanceof TypeError))throw o;e=await(await import(L())).readFile(e)}const{instance:t,module:r}=await P(await e,n);return H(t,r)}var G=j,K;async function F(){await(K??(K=(async()=>{const e=(await $(async()=>{const{default:n}=await import("./twsearch_wasm_bg-V4F3SIUO-QGKWKUFY-iE1VAZwZ.js");return{default:n}},[])).default;await G(e.buffer)})()))}async function X(e){return await F(),new R(B(e))}async function Y(e,n,t){return await F(),new R(V(JSON.stringify(e),JSON.stringify(n.toJSON().patternData),JSON.stringify(t)))}export{X as wasmRandomScrambleForEvent,Y as wasmTwsearch}; diff --git a/docs/index.html b/docs/index.html index d8eb5ad..6df5c9c 100644 --- a/docs/index.html +++ b/docs/index.html @@ -25,7 +25,7 @@ - + @@ -255,7 +255,9 @@