-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchunk-OC2PKXON.js
More file actions
16 lines (16 loc) · 66.4 KB
/
chunk-OC2PKXON.js
File metadata and controls
16 lines (16 loc) · 66.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import{i as E,j as F}from"./chunk-Q4G5UL72.js";var oe=class{constructor(e,t){this.facenames=e;t&&(this.gripnames=t);for(let n=0;this.prefixFree&&n<e.length;n++)for(let i=0;this.prefixFree&&i<e.length;i++)n!==i&&e[n].startsWith(e[i])&&(this.prefixFree=!1)}prefixFree=!0;gripnames=[];setGripNames(e){this.gripnames=e}splitByFaceNames(e){let t=[],n=0;for(;n<e.length;){n>0&&n<e.length&&e[n]==="_"&&n++;let i=-1;for(let s=0;s<this.facenames.length;s++)e.substr(n).startsWith(this.facenames[s])&&(i<0||this.facenames[s].length>this.facenames[i].length)&&(i=s);if(i>=0)t.push(i),n+=this.facenames[i].length;else throw new Error(`Could not split ${e} into face names.`)}return t}joinByFaceIndices(e){let t="",n=[];for(let i=0;i<e.length;i++)n.push(t),n.push(this.facenames[e[i]]),this.prefixFree||(t="_");return n.join("")}spinmatch(e,t){if(e===t)return!0;try{let n=this.splitByFaceNames(e),i=this.splitByFaceNames(t);if(n.length!==i.length&&n.length<3)return!1;for(let s=0;s<n.length;s++){for(let r=0;r<s;r++)if(n[s]===n[r])return!1;let o=!1;for(let r=0;r<i.length;r++)if(n[s]===i[r]){o=!0;break}if(!o)return!1}return!0}catch{return!1}}spinmatchv(e,t){return e.endsWith("v")&&t.endsWith("v")?this.spinmatch(e.slice(0,e.length-1),t.slice(0,t.length-1)):this.spinmatch(e,t)}unswizzle(e){(e.endsWith("v")||e.endsWith("w"))&&e[0]<="Z"&&(e=e.slice(0,e.length-1));let t=e.toUpperCase();for(let n=0;n<this.gripnames.length;n++){let i=this.gripnames[n];if(this.spinmatch(t,i))return i}return e}};var se=class{notationToInternal(e){return e}notationToExternal(e){return e}};var ue=class{constructor(e,t){this.child=e;this.sw=t}notationToInternal(e){return e.family==="T"&&e.innerLayer===void 0&&e.outerLayer===void 0?new F(new E("FLRv",e.innerLayer,e.outerLayer),e.amount):this.child.notationToInternal(e)}notationToExternal(e){let t=e.family;return t.length>0&&t[t.length-1]==="v"&&(t=t.substring(0,t.length-1)),this.sw.spinmatch(t,"FLUR")?new F(new E("T",e.innerLayer,e.outerLayer),e.amount):this.child.notationToExternal(e)}};var re=class{constructor(e,t){this.internalNames=e;this.externalNames=t}convertString(e,t,n){let i="";(e.endsWith("v")||e.endsWith("v"))&&e<="_"&&(i=e.slice(e.length-1),e=e.slice(0,e.length-1));let s=e.toUpperCase(),o=!1;return e!==s&&(o=!0,e=s),e=n.joinByFaceIndices(t.splitByFaceNames(e)),o&&(e=e.toLowerCase()),e+i}convert(e,t,n){let i=e.family,s=this.convertString(i,t,n);return i===s?e:new F(new E(s,e.innerLayer,e.outerLayer),e.amount)}notationToInternal(e){return this.convert(e,this.externalNames,this.internalNames)}notationToExternal(e){return this.convert(e,this.internalNames,this.externalNames)}};var fe=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 F(new E("L",3,2),-2*e.amount);if(e.family==="R--")return new F(new E("L",3,2),2*e.amount);if(e.family==="D++")return new F(new E("U",3,2),-2*e.amount);if(e.family==="D--")return new F(new E("U",3,2),2*e.amount);if(e.family==="R_PLUSPLUS_")return new F(new E("L",3,2),-2*e.amount);if(e.family==="D_PLUSPLUS_")return new F(new E("U",3,2),-2*e.amount)}if(e.family==="y")return new F("Uv",e.amount);if(e.family==="x"&&Math.abs(e.amount)===2)return new F("ERv",e.amount/2)}return this.child.notationToInternal(e)}notationToExternal(e){return e.family==="ERv"&&Math.abs(e.amount)===1?new F(new E("x",e.innerLayer,e.outerLayer),e.amount*2):e.family==="ILv"&&Math.abs(e.amount)===1?new F(new E("x",e.innerLayer,e.outerLayer),-e.amount*2):e.family==="Uv"?new F(new E("y",e.innerLayer,e.outerLayer),e.amount):e.family==="Dv"?new F("y",-e.amount):this.child.notationToExternal(e)}};var he=class{constructor(e){this.slices=e}notationToInternal(e){let t=e.family;return e.innerLayer||e.outerLayer||(t==="x"?e=new F("Rv",e.amount):t==="y"?e=new F("Uv",e.amount):t==="z"&&(e=new F("Fv",e.amount)),(this.slices&1)===1&&(t==="E"?e=new F(new E("D",(this.slices+1)/2),e.amount):t==="M"?e=new F(new E("L",(this.slices+1)/2),e.amount):t==="S"&&(e=new F(new E("F",(this.slices+1)/2),e.amount))),this.slices>2&&(t==="e"?e=new F(new E("D",this.slices-1,2),e.amount):t==="m"?e=new F(new E("L",this.slices-1,2),e.amount):t==="s"&&(e=new F(new E("F",this.slices-1,2),e.amount)))),e}notationToExternal(e){let t=e.family;if(!(e.innerLayer||e.outerLayer)){if(t==="Rv")return new F("x",e.amount);if(t==="Uv")return new F("y",e.amount);if(t==="Fv")return new F("z",e.amount);if(t==="Lv")return new F("x",-e.amount);if(t==="Dv")return new F("y",-e.amount);if(t==="Bv")return new F("z",-e.amount)}return e}};var ft={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"},ht={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"},Ie={U:"FRL",L:"FLD",R:"FDR",B:"DLR"},Ke=new E("y"),Ze=new E("Dv"),ae=class{constructor(e){this.child=e}wcaHack=!1;map=ft;notationToInternal(e){if(this.wcaHack&&e.innerLayer===2&&e.outerLayer===null){let n=Ie[e.family];if(n)return new F(new E(n,e.innerLayer,e.outerLayer),e.amount)}let t=this.map[e.family];return t?new F(new E(t,e.innerLayer,e.outerLayer),e.amount):Ke.isIdentical(e.quantum)?new F(Ze,-e.amount):null}notationToExternal(e){if(this.wcaHack&&e.innerLayer===2&&e.outerLayer===null){for(let[t,n]of Object.entries(Ie))if(this.child.spinmatch(e.family,n))return new F(new E(t,e.innerLayer,e.outerLayer),e.amount)}for(let[t,n]of Object.entries(this.map))if(this.child.spinmatch(e.family,n))return new F(new E(t,e.innerLayer,e.outerLayer),e.amount);return Ze.isIdentical(e.quantum)?new F(Ke,-e.amount):null}},pe=class extends ae{wcaHack=!0;constructor(e){super(e),this.map=ht}};var He={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"},Re=new E("x"),We=new E("Rv"),pt=new E("Lv"),Oe=new E("y"),Ye=new E("Uv"),mt=new E("Dv"),Ce=new E("z"),Je=new E("Fv"),bt=new E("Bv"),me=class{constructor(e){this.child=e}notationToInternal(e){if(e.innerLayer||e.outerLayer)return null;let t=He[e.family];return t?new F(new E(t,e.outerLayer,e.innerLayer),e.amount):Re.isIdentical(e.quantum)?new F(We,e.amount):Oe.isIdentical(e.quantum)?new F(Ye,e.amount):Ce.isIdentical(e.quantum)?new F(Je,e.amount):null}notationToExternal(e){for(let[t,n]of Object.entries(He))if(this.child.spinmatchv(e.family,n))return new F(new E(t,e.innerLayer,e.outerLayer),e.amount);return We.isIdentical(e.quantum)?new F(Re,e.amount):pt.isIdentical(e.quantum)?new F(Re,-e.amount):Ye.isIdentical(e.quantum)?new F(Oe,e.amount):mt.isIdentical(e.quantum)?new F(Oe,-e.amount):Je.isIdentical(e.quantum)?new F(Ce,e.amount):bt.isIdentical(e.quantum)?new F(Ce,-e.amount):null}};function Ve(l,e){let t={...l,moves:{}};for(let[n,i]of Object.entries(l.moves)){let s=n,o="";["v","w"].includes(n.at(-1))&&(s=n.slice(0,-1),o=n.slice(-1));let r=e.notationToExternal(F.fromString(s));if(!r)continue;let g=r+o;if(!g)throw new Error(`Missing external move name for: ${n.toString()}`);t.moves[g.toString()]=i}return t}function dt(l){let e=0,t={};for(;e<l.length&&l[e][0]==="-";){let i=l[e++];if(i==="--rotations")t.addRotations=!0;else if(i==="--allmoves")t.allMoves=!0;else if(i==="--outerblockmoves")t.outerBlockMoves=!0;else if(i==="--vertexmoves")t.vertexMoves=!0;else if(i==="--nocorners")t.includeCornerOrbits=!1;else if(i==="--noedges")t.includeEdgeOrbits=!1;else if(i==="--noorientation")t.fixedOrientation=!0;else if(i==="--nocenters")t.includeCenterOrbits=!1;else if(i==="--omit")t.excludeOrbits=l[e].split(","),e++;else if(i==="--moves")t.moveList=l[e].split(","),e++;else if(i==="--optimize")t.optimizeOrbits=!0;else if(i==="--scramble")t.scrambleAmount=100;else if(i==="--fixcorner")t.fixedPieceType="v";else if(i==="--fixedge")t.fixedPieceType="e";else if(i==="--fixcenter")t.fixedPieceType="f";else if(i==="--orientcenters")t.orientCenters=!0;else if(i==="--puzzleorientation")t.puzzleOrientation=JSON.parse(l[e]),e++;else throw new Error(`Bad option: ${i}`)}return{puzzleDescription:ze(l.slice(e).join(" ")),options:t}}var ye=class{verbosity=0;allMoves=!1;outerBlockMoves;vertexMoves=!1;addRotations=!1;moveList=null;fixedOrientation=!1;fixedPieceType=null;orientCenters=!1;includeCornerOrbits=!0;includeCenterOrbits=!0;includeEdgeOrbits=!0;excludeOrbits=[];optimizeOrbits=!1;grayCorners=!1;grayCenters=!1;grayEdges=!1;puzzleOrientation=null;puzzleOrientations=null;scrambleAmount=0;constructor(e={}){Object.assign(this,e)}};var Ee=[],Ne=[];function _(l){if(!Ee[l]){let e=Array(l);for(let t=0;t<l;t++)e[t]=0;Ee[l]=e}return Ee[l]}function X(l){if(!Ne[l]){let e=Array(l);for(let t=0;t<l;t++)e[t]=t;Ne[l]=e}return Ne[l]}function Xe(l){return new q(X(l))}function qe(l){let e=BigInt(1);for(;l>1;)e*=BigInt(l),l--;return e}function gt(l,e){if(l>e){let t=l;l=e,e=t}for(;l>0;){let t=e%l;e=l,l=t}return e}function Se(l,e){return l/gt(l,e)*e}var q=class l{n;p;constructor(e){this.n=e.length,this.p=e}toString(){return`Perm[${this.p.join(" ")}]`}mul(e){let t=Array(this.n);for(let n=0;n<this.n;n++)t[n]=e.p[this.p[n]];return new l(t)}rmul(e){let t=Array(this.n);for(let n=0;n<this.n;n++)t[n]=this.p[e.p[n]];return new l(t)}inv(){let e=Array(this.n);for(let t=0;t<this.n;t++)e[this.p[t]]=t;return new l(e)}compareTo(e){for(let t=0;t<this.n;t++)if(this.p[t]!==e.p[t])return this.p[t]-e.p[t];return 0}toGap(){let e=new Array,t=new Array(this.n);for(let n=0;n<this.p.length;n++){if(t[n]||this.p[n]===n)continue;let i=new Array;for(let s=this.p[n];!t[s];s=this.p[s])i.push(1+s),t[s]=!0;e.push(`(${i.reverse().join(",")})`)}return e.join("")}toMathematica(){let e=new Array,t=new Array(this.n);for(let n=0;n<this.p.length;n++){if(t[n]||this.p[n]===n)continue;let i=new Array;for(let s=this.p[n];!t[s];s=this.p[s])i.push(1+s),t[s]=!0;e.push(`{${i.reverse().join(",")}}`)}return`Cycles[{${e.join(",")}}]`}order(){let e=1,t=new Array(this.n);for(let n=0;n<this.p.length;n++){if(t[n]||this.p[n]===n)continue;let i=0;for(let s=n;!t[s];s=this.p[s])i++,t[s]=!0;e=Se(e,i)}return e}};var le=class{constructor(e,t){this.size=e;this.mod=t}reassemblySize(){return qe(this.size)*BigInt(this.mod)**BigInt(this.size)}},vt=0;function be(l,e){let t=F.fromString(e),n=l.notationToExternal(t);return n===null||t===n?e:n.toString()}var de=class l{constructor(e,t,n,i,s,o,r){this.orbitnames=e;this.orbitdefs=t;this.solved=n;this.movenames=i;this.moveops=s;this.isRotation=o;this.forcenames=r}toKTransformationData(e){let t={};for(let n=0;n<this.orbitnames.length;n++)t[this.orbitnames[n]]=e.orbits[n].toKTransformationOrbitData();return t}toKPatternData(e){let t={};for(let n=0;n<this.orbitnames.length;n++)t[this.orbitnames[n]]=e.orbits[n].toKPatternOrbitData();return t}static transformToKTransformationData(e,t){let n={};for(let i=0;i<e.length;i++)n[e[i]]=t.orbits[i].toKTransformationOrbitData();return n}describeSet(e,t,n){let i=this.orbitdefs[e].size,s=new Array(i);for(let o=0;o<i;o++)s[o]=[];for(let o=0;o<this.movenames.length;o++){if(this.isRotation[o])continue;let r=this.movenames[o];this.forcenames[o]||(r=be(n,r),r[r.length-1]==="'"&&(r=r.substring(0,r.length-1)));let g=this.moveops[o].orbits[e];for(let f=0;f<i;f++)(g.perm[f]!==f||g.ori[f]!==0)&&s[f].push(r)}for(let o=0;o<i;o++)t.push(`# ${o+1} ${s[o].join(" ")}`)}toKsolve(e,t=new se){let n=[];n.push(`Name ${e}`),n.push("");for(let i=0;i<this.orbitnames.length;i++)n.push(`Set ${this.orbitnames[i]} ${this.orbitdefs[i].size} ${this.orbitdefs[i].mod}`),this.describeSet(i,n,t);n.push(""),n.push("Solved");for(let i=0;i<this.orbitnames.length;i++)this.solved.orbits[i].appendDefinition(n,this.orbitnames[i],!1,!1);n.push("End");for(let i=0;i<this.movenames.length;i++){n.push("");let s=this.movenames[i];this.forcenames[i]||(s=be(t,this.movenames[i]));let o=!1;s[s.length-1]==="'"&&(o=!0,s=s.substring(0,s.length-1)),n.push(`Move ${s}`);for(let r=0;r<this.orbitnames.length;r++)o?this.moveops[i].orbits[r].inv().appendDefinition(n,this.orbitnames[r],!0):this.moveops[i].orbits[r].appendDefinition(n,this.orbitnames[r],!0);n.push("End")}return n}toKPuzzleDefinition(e){let t=[],n={};for(let s=0;s<this.orbitnames.length;s++){t.push({orbitName:this.orbitnames[s],numPieces:this.orbitdefs[s].size,numOrientations:this.orbitdefs[s].mod});let o=this.solved.orbits[s].toKTransformationOrbitData();n[this.orbitnames[s]]={pieces:o.permutation,orientation:o.orientationDelta}}let i={};if(e)for(let s=0;s<this.movenames.length;s++)i[this.movenames[s]]=this.toKTransformationData(this.moveops[s]);return{name:`PG3D #${++vt}`,orbits:t,defaultPattern:n,moves:i}}optimize(){let e=[],t=[],n=[],i=[];for(let s=0;s<this.moveops.length;s++)i.push([]);for(let s=0;s<this.orbitdefs.length;s++){let o=this.orbitdefs[s].mod,r=this.orbitdefs[s].size,g=new Me(r),f=new Array(this.orbitdefs[s].size);for(let u=0;u<r;u++)f[u]=!1;for(let u=0;u<this.moveops.length;u++)for(let p=0;p<r;p++)(this.moveops[u].orbits[s].perm[p]!==p||this.moveops[u].orbits[s].ori[p]!==0)&&(this.isRotation[u]||(f[p]=!0),g.union(p,this.moveops[u].orbits[s].perm[p]));let m=!0;if(o>1){m=!1;let u=new Me(this.orbitdefs[s].size*o);for(let p=0;p<this.moveops.length;p++)for(let a=0;a<r;a++)if(this.moveops[p].orbits[s].perm[a]!==a||this.moveops[p].orbits[s].ori[a]!==0)for(let h=0;h<o;h++)u.union(a*o+h,this.moveops[p].orbits[s].perm[a]*o+(h+this.moveops[p].orbits[s].ori[a])%o);for(let p=0;!m&&p<r;p++)for(let a=1;a<o;a++)u.find(p*o)===u.find(p*o+a)&&(m=!0);for(let p=0;!m&&p<r;p++)for(let a=0;a<p;a++)this.solved.orbits[s].perm[p]===this.solved.orbits[s].perm[a]&&(m=!0)}let b=-1,v=!1;for(let u=0;u<this.orbitdefs[s].size;u++)if(f[u]){let p=g.find(u);b<0?b=p:b!==p&&(v=!0)}for(let u=0;u<this.orbitdefs[s].size;u++){if(!f[u]||g.find(u)!==u)continue;let a=[],h=[],P=0;for(let M=0;M<this.orbitdefs[s].size;M++)g.find(M)===u&&(a[P]=M,h[M]=P,P++);if(v?e.push(`${this.orbitnames[s]}_p${u}`):e.push(this.orbitnames[s]),m){t.push(new le(P,this.orbitdefs[s].mod)),n.push(this.solved.orbits[s].remapVS(a,P));for(let M=0;M<this.moveops.length;M++)i[M].push(this.moveops[M].orbits[s].remap(a,h,P))}else{t.push(new le(P,1)),n.push(this.solved.orbits[s].remapVS(a,P).killOri());for(let M=0;M<this.moveops.length;M++)i[M].push(this.moveops[M].orbits[s].remap(a,h,P).killOri())}}}return new l(e,t,new ve(n),this.movenames,i.map(s=>new ge(s)),this.isRotation,this.forcenames)}scramble(e){this.solved=this.solved.mul(this.getScrambleTransformation(e))}getScrambleTransformation(e){e<100&&(e=100);let t=[];for(let i=0;i<this.moveops.length;i++)t[i]=this.moveops[i];for(let i=0;i<t.length;i++){let s=Math.floor(Math.random()*t.length),o=t[i];t[i]=t[s],t[s]=o}e<t.length&&(e=t.length);for(let i=0;i<e;i++){let s=Math.floor(Math.random()*t.length),o=Math.floor(Math.random()*t.length),r=Math.floor(Math.random()*this.moveops.length);t[s]=t[s].mul(t[o]).mul(this.moveops[r]),Math.random()<.1&&(t[s]=t[s].mul(this.moveops[r]))}let n=t[0];for(let i=1;i<t.length;i++)n=n.mul(t[i]);return n}reassemblySize(){let e=BigInt(1);for(let t=0;t<this.orbitdefs.length;t++)e*=this.orbitdefs[t].reassemblySize();return e}},ee=class l{constructor(e,t,n){this.perm=e;this.ori=t;this.orimod=n}static ktransformationCache=[];static e(e,t){return new l(X(e),_(e),t)}mul(e){let t=this.perm.length,n=new Array(t);if(this.orimod===1){for(let i=0;i<t;i++)n[i]=this.perm[e.perm[i]];return new l(n,this.ori,this.orimod)}else{let i=new Array(t);for(let s=0;s<t;s++)n[s]=this.perm[e.perm[s]],i[s]=(this.ori[e.perm[s]]+e.ori[s])%this.orimod;return new l(n,i,this.orimod)}}inv(){let e=this.perm.length,t=new Array(e),n=new Array(e);for(let i=0;i<e;i++)t[this.perm[i]]=i,n[this.perm[i]]=(this.orimod-this.ori[i])%this.orimod;return new l(t,n,this.orimod)}equal(e){let t=this.perm.length;for(let n=0;n<t;n++)if(this.perm[n]!==e.perm[n]||this.ori[n]!==e.ori[n])return!1;return!0}killOri(){let e=this.perm.length;for(let t=0;t<e;t++)this.ori[t]=0;return this.orimod=1,this}toPerm(){let e=this.orimod;if(e===1)return new q(this.perm);let t=this.perm.length,n=new Array(t*e);for(let i=0;i<t;i++)for(let s=0;s<e;s++)n[i*e+s]=e*this.perm[i]+(this.ori[i]+s)%e;return new q(n)}identicalPieces(){let e=[],t=this.perm.length,n=[];for(let i=0;i<t;i++){let s=this.perm[i];if(e[s]===void 0){let o=[i];e[s]=!0;for(let r=i+1;r<t;r++)this.perm[r]===s&&o.push(r);n.push(o)}}return n}order(){return this.toPerm().order()}isIdentity(){let e=this.perm.length;if(this.perm===X(e)&&this.ori===_(e))return!0;for(let t=0;t<e;t++)if(this.perm[t]!==t||this.ori[t]!==0)return!1;return!0}zeroOris(){let e=this.perm.length;if(this.ori===_(e))return!0;for(let t=0;t<e;t++)if(this.ori[t]!==0)return!1;return!0}remap(e,t,n){let i=new Array(n),s=new Array(n);for(let o=0;o<n;o++)i[o]=t[this.perm[e[o]]],s[o]=this.ori[e[o]];return new l(i,s,this.orimod)}remapVS(e,t){let n=new Array(t),i=new Array(t),s=0,o=[];for(let r=0;r<t;r++){let g=this.perm[e[r]];o[g]===void 0&&(o[g]=s++),n[r]=o[g],i[r]=this.ori[e[r]]}return new l(n,i,this.orimod)}appendDefinition(e,t,n,i=!0){if(!(i&&this.isIdentity())&&(e.push(t),e.push(this.perm.map(s=>s+1).join(" ")),!this.zeroOris()))if(n){let s=new Array(this.ori.length);for(let o=0;o<s.length;o++)s[this.perm[o]]=this.ori[o];e.push(s.join(" "))}else e.push(this.ori.join(" "))}toKTransformationOrbitData(){let e=this.perm.length;return this.isIdentity()?(l.ktransformationCache[e]||(l.ktransformationCache[e]={permutation:X(e),orientationDelta:_(e)}),l.ktransformationCache[e]):{permutation:this.perm,orientationDelta:this.ori}}toKPatternOrbitData(){let e=this.perm.length;return{pieces:this.perm,orientation:this.ori,orientationMod:_(e)}}},xe=class{constructor(e){this.orbits=e}internalMul(e){let t=[];for(let n=0;n<this.orbits.length;n++)t.push(this.orbits[n].mul(e.orbits[n]));return t}internalInv(){let e=[];for(let t of this.orbits)e.push(t.inv());return e}equal(e){for(let t=0;t<this.orbits.length;t++)if(!this.orbits[t].equal(e.orbits[t]))return!1;return!0}killOri(){for(let e of this.orbits)e.killOri();return this}toPerm(){let e=new Array,t=0;for(let i of this.orbits){let s=i.toPerm();e.push(s),t+=s.n}let n=new Array(t);t=0;for(let i of e){for(let s=0;s<i.n;s++)n[t+s]=t+i.p[s];t+=i.n}return new q(n)}identicalPieces(){let e=[],t=0;for(let n of this.orbits){let i=n.orimod,s=n.identicalPieces();for(let o=0;o<s.length;o++)e.push(s[o].map(r=>r*i+t));t+=i*n.perm.length}return e}order(){let e=1;for(let t of this.orbits)e=Se(e,t.order());return e}},ge=class l extends xe{mul(e){return new l(this.internalMul(e))}mulScalar(e){if(e===0)return this.e();let t=this;for(e<0&&(t=t.inv(),e=-e);!(e&1);)t=t.mul(t),e>>=1;if(e===1)return t;let n=t,i=this.e();for(;e>0;)e&1&&(i=i.mul(n)),e>1&&(n=n.mul(n)),e>>=1;return i}inv(){return new l(this.internalInv())}e(){return new l(this.orbits.map(e=>ee.e(e.perm.length,e.orimod)))}},ve=class l extends xe{mul(e){return new l(this.internalMul(e))}},Me=class{constructor(e){this.n=e;this.heads=new Array(e);for(let t=0;t<e;t++)this.heads[t]=t}heads;find(e){let t=this.heads[e];return this.heads[t]===t||(t=this.find(this.heads[t]),this.heads[e]=t),t}union(e,t){let n=this.find(e),i=this.find(t);n<i?this.heads[i]=n:n>i&&(this.heads[n]=i)}};function _e(l,e){let t=l.moveops.length;if(t>30)throw new Error("Canon info too big for bitmask");let n=[],i=[];for(let o=0;o<t;o++){let r=l.moveops[o];n.push(r.order());let g=0;for(let f=0;f<t;f++){if(f===o)continue;let m=l.moveops[f];r.mul(m).equal(m.mul(r))&&(g|=1<<f)}i.push(g)}let s={};s[0]=1;for(let o=0;o<100;o++){let r=0,g={},f=0;for(let m in s){let b=+m,v=s[b];r+=v,f++;for(let u=0;u<n.length;u++)if(!(b>>u&1)&&!(b&i[u]&(1<<u)-1)){let p=b&i[u]|1<<u;g[p]===void 0&&(g[p]=0),g[p]+=(n[u]-1)*v}}e(`${o}: canonseq ${r} states ${f}`),s=g}}var Pe={"2x2x2":"c f 0","3x3x3":"c f 0.333333333333333","4x4x4":"c f 0.5 f 0","5x5x5":"c f 0.6 f 0.2","6x6x6":"c f 0.666666666666667 f 0.333333333333333 f 0","7x7x7":"c f 0.714285714285714 f 0.428571428571429 f 0.142857142857143","8x8x8":"c f 0.75 f 0.5 f 0.25 f 0","9x9x9":"c f 0.777777777777778 f 0.555555555555556 f 0.333333333333333 f 0.111111111111111","10x10x10":"c f 0.8 f 0.6 f 0.4 f 0.2 f 0","11x11x11":"c f 0.818181818181818 f 0.636363636363636 f 0.454545454545455 f 0.272727272727273 f 0.0909090909090909","12x12x12":"c f 0.833333333333333 f 0.666666666666667 f 0.5 f 0.333333333333333 f 0.166666666666667 f 0","13x13x13":"c f 0.846153846153846 f 0.692307692307692 f 0.538461538461538 f 0.384615384615385 f 0.230769230769231 f 0.0769230769230769","20x20x20":"c f 0 f .1 f .2 f .3 f .4 f .5 f .6 f .7 f .8 f .9","30x30x30":"c f 0 f .066667 f .133333 f .2 f .266667 f .333333 f .4 f .466667 f .533333 f .6 f .666667 f .733333 f .8 f .866667 f .933333","40x40x40":"c f 0 f .05 f .1 f .15 f .2 f .25 f .3 f .35 f .4 f .45 f .5 f .55 f .6 f .65 f .7 f .75 f .8 f .85 f .9 f .95",skewb:"c v 0","master skewb":"c v 0.275","professor skewb":"c v 0 v 0.38","compy cube":"c v 0.915641442663986",helicopter:"c e 0.707106781186547","curvy copter":"c e 0.83",dino:"c v 0.577350269189626","little chop":"c e 0",pyramorphix:"t e 0",mastermorphix:"t e 0.346184634065199",pyraminx:"t v 0.333333333333333 v 1.66666666666667",tetraminx:"t v 0.333333333333333","master pyraminx":"t v 0 v 1 v 2","master tetraminx":"t v 0 v 1","professor pyraminx":"t v -0.2 v 0.6 v 1.4 v 2.2","professor tetraminx":"t v -0.2 v 0.6 v 1.4","Jing pyraminx":"t f 0","master pyramorphix":"t e 0.866025403784437",megaminx:"d f 0.7",gigaminx:"d f 0.64 f 0.82",teraminx:"d f 0.64 f 0.76 f 0.88",petaminx:"d f 0.64 f 0.73 f 0.82 f 0.91",examinx:"d f 0.64 f 0.712 f 0.784 f 0.856 f 0.928",zetaminx:"d f 0.64 f 0.7 f 0.76 f 0.82 f 0.88 f 0.94",yottaminx:"d f 0.64 f 0.6914 f 0.7429 f 0.7943 f 0.8457 f 0.8971 f 0.9486",pentultimate:"d f 0","master pentultimate":"d f 0.1","elite pentultimate":"d f 0 f 0.145905",starminx:"d v 0.937962370425399","starminx 2":"d f 0.23606797749979","pyraminx crystal":"d f 0.447213595499989",chopasaurus:"d v 0","big chop":"d e 0","skewb diamond":"o f 0",FTO:"o f 0.333333333333333","master FTO":"o f 0.5 f 0","Christopher's jewel":"o v 0.577350269189626",octastar:"o e 0","Trajber's octahedron":"o v 0.433012701892219","radio chop":"i f 0",icosamate:"i v 0","icosahedron 2":"i v 0.18759247376021","icosahedron 3":"i v 0.18759247376021 e 0","icosahedron static faces":"i v 0.84","icosahedron moving faces":"i v 0.73","Eitan's star":"i f 0.61803398874989","2x2x2 + dino":"c f 0 v 0.577350269189626","2x2x2 + little chop":"c f 0 e 0","dino + little chop":"c v 0.577350269189626 e 0","2x2x2 + dino + little chop":"c f 0 v 0.577350269189626 e 0","megaminx + chopasaurus":"d f 0.61803398875 v 0","starminx combo":"d f 0.23606797749979 v 0.937962370425399"};function De(l){let e=new $(0,0,0,0);for(let t=0;t<l.length;t++)e=e.sum(l[t]);return e.smul(1/l.length)}function et(l,e,t,n){let i=n[l].intersect3(n[e],n[t]);if(!i)return i;for(let s=0;s<n.length;s++)if(s!==l&&s!==e&&s!==t){let o=n[s].b*i.b+n[s].c*i.c+n[s].d*i.d;if(n[s].a>0&&o>n[s].a||n[s].a<0&&o<n[s].a)return!1}return i}var $=class l{constructor(e,t,n,i){this.a=e;this.b=t;this.c=n;this.d=i}mul(e){return new l(this.a*e.a-this.b*e.b-this.c*e.c-this.d*e.d,this.a*e.b+this.b*e.a+this.c*e.d-this.d*e.c,this.a*e.c-this.b*e.d+this.c*e.a+this.d*e.b,this.a*e.d+this.b*e.c-this.c*e.b+this.d*e.a)}toString(){return`Q[${this.a},${this.b},${this.c},${this.d}]`}dist(e){return Math.hypot(this.a-e.a,this.b-e.b,this.c-e.c,this.d-e.d)}len(){return Math.hypot(this.a,this.b,this.c,this.d)}cross(e){return new l(0,this.c*e.d-this.d*e.c,this.d*e.b-this.b*e.d,this.b*e.c-this.c*e.b)}dot(e){return this.b*e.b+this.c*e.c+this.d*e.d}normalize(){let e=Math.sqrt(this.dot(this));return new l(this.a/e,this.b/e,this.c/e,this.d/e)}makenormal(){return new l(0,this.b,this.c,this.d).normalize()}normalizeplane(){let e=Math.hypot(this.b,this.c,this.d);return new l(this.a/e,this.b/e,this.c/e,this.d/e)}smul(e){return new l(this.a*e,this.b*e,this.c*e,this.d*e)}sum(e){return new l(this.a+e.a,this.b+e.b,this.c+e.c,this.d+e.d)}sub(e){return new l(this.a-e.a,this.b-e.b,this.c-e.c,this.d-e.d)}angle(){return 2*Math.acos(this.a)}invrot(){return new l(this.a,-this.b,-this.c,-this.d)}det3x3(e,t,n,i,s,o,r,g,f){return e*(s*f-o*g)+t*(o*r-i*f)+n*(i*g-s*r)}rotateplane(e){let t=e.mul(new l(0,this.b,this.c,this.d)).mul(e.invrot());return t.a=this.a,t}orthogonal(){let e=Math.abs(this.b),t=Math.abs(this.c),n=Math.abs(this.d);return e<t&&e<n?this.cross(new l(0,1,0,0)).normalize():t<e&&t<n?this.cross(new l(0,0,1,0)).normalize():this.cross(new l(0,0,0,1)).normalize()}pointrotation(e){let t=this.normalize();if(e=e.normalize(),t.sub(e).len()<1e-9)return new l(1,0,0,0);let n=t.sum(e);n.len()<1e-9?n=n.orthogonal():n=n.normalize();let i=t.cross(n);return i.a=t.dot(n),i}unproject(e){return this.sum(e.smul(-this.dot(e)/(this.len()*e.len())))}rotatepoint(e){return e.mul(this).mul(e.invrot())}rotateface(e){return e.map(t=>t.rotatepoint(this))}intersect3(e,t){let n=this.det3x3(this.b,this.c,this.d,e.b,e.c,e.d,t.b,t.c,t.d);return Math.abs(n)<1e-9?!1:new l(0,this.det3x3(this.a,this.c,this.d,e.a,e.c,e.d,t.a,t.c,t.d)/n,this.det3x3(this.b,this.a,this.d,e.b,e.a,e.d,t.b,t.a,t.d)/n,this.det3x3(this.b,this.c,this.a,e.b,e.c,e.a,t.b,t.c,t.a)/n)}side(e){return e>1e-9?1:e<-1e-9?-1:0}cutface(e){let t=this.a,n=0,i=null;for(let s=0;s<e.length;s++)n|=1<<this.side(e[s].dot(this)-t)+1;if((n&5)===5){i=[];let s=e.map(o=>this.side(o.dot(this)-t));for(let o=-1;o<=1;o+=2){let r=[];for(let g=0;g<e.length;g++){(s[g]===o||s[g]===0)&&r.push(e[g]);let f=(g+1)%e.length;if(s[g]+s[f]===0&&s[g]!==0){let m=e[g].dot(this)-t,b=e[f].dot(this)-t,v=m/(m-b),u=e[g].smul(1-v).sum(e[f].smul(v));r.push(u)}}i.push(r)}}return i}cutfaces(e){let t=[];for(let n=0;n<e.length;n++){let i=e[n],s=this.cutface(i);s?(t.push(s[0]),t.push(s[1])):t.push(i)}return t}faceside(e){let t=this.a;for(let n=0;n<e.length;n++){let i=this.side(e[n].dot(this)-t);if(i!==0)return i}throw new Error("Could not determine side of plane in faceside")}sameplane(e){let t=this.normalize(),n=e.normalize();return t.dist(n)<1e-9||t.dist(n.smul(-1))<1e-9}makecut(e){return new l(e,this.b,this.c,this.d)}};var Fe=1e-9;function tt(){let l=Math.sqrt(.5);return[new $(l,l,0,0),new $(l,0,l,0)]}function nt(){return[new $(.5,.5,.5,.5),new $(.5,.5,.5,-.5)]}function it(){let l=2*Math.PI/10,e=.5+.3*Math.sqrt(5),t=.5+.1*Math.sqrt(5),n=Math.sqrt(e*e+t*t);return e/=n,t/=n,[new $(Math.cos(l),e*Math.sin(l),t*Math.sin(l),0),new $(.5,.5,.5,.5)]}function st(){let l=.16666666666666666+Math.sqrt(5)/6,e=2/3+Math.sqrt(5)/3,t=Math.sqrt(l*l+e*e);l/=t,e/=t;let n=2*Math.PI/6;return[new $(Math.cos(n),l*Math.sin(n),e*Math.sin(n),0),new $(Math.cos(n),-l*Math.sin(n),e*Math.sin(n),0)]}function ot(){let l=Math.sqrt(.5);return[new $(.5,.5,.5,.5),new $(l,0,0,l)]}function rt(l){let e=[new $(1,0,0,0)];for(let t=0;t<e.length;t++)for(let n=0;n<l.length;n++){let i=l[n].mul(e[t]),s=i.smul(-1),o=!1;for(let r=0;r<e.length;r++)if(i.dist(e[r])<Fe||s.dist(e[r])<Fe){o=!0;break}o||e.push(i)}return e}function Qe(l,e){let t=[],n=[];for(let i=0;i<e.length;i++){let s=l.rotateplane(e[i]),o=!1;for(let r=0;r<t.length;r++)if(s.dist(t[r])<Fe){o=!0;break}o||(t.push(s),n.push(e[i]))}return n}function je(l){let e=[];for(let t=1;t<l.length;t++)for(let n=t+1;n<l.length;n++){let i=et(0,t,n,l);if(i){let s=!1;for(let o=0;o<e.length;o++)if(i.dist(e[o])<Fe){s=!0;break}s||e.push(i)}}for(;;){let t=!1;for(let n=0;n<e.length;n++){let i=(n+1)%e.length;if(l[0].dot(e[n].cross(e[i]))<0){let s=e[n];e[n]=e[i],e[i]=s,t=!0}}if(!t)break}return e}var Ge=class{mult;constructor(){this.mult=[]}multiply(e){for(let t=2;t*t<=e;t++)for(;e%t===0;)this.mult[t]!==void 0?this.mult[t]++:this.mult[t]=1,e/=t;e>1&&(this.mult[e]!==void 0?this.mult[e]++:this.mult[e]=1)}toString(){let e="";for(let t=0;t<this.mult.length;t++)this.mult[t]!==void 0&&(e!==""&&(e+="*"),e+=t,this.mult[t]>1&&(e+=`^${this.mult[t]}`));return e}};function Te(l,e){let t=l[0].p.length,n=Xe(t),i=[],s=[],o=[],r=[],g=[];function f(u){for(let p=u.p.length-1;p>=0;p--){let a=u.p[p];if(a!==p){if(!i[p][a])return!1;u=u.mul(s[p][a])}}return!0}function m(u,p,a){r[u].push(p),g[u].push(a);for(let h=0;h<i[u].length;h++)i[u][h]&&b(u,i[u][h].mul(p),a+o[u][h])}function b(u,p,a){let h=p.p[u];if(!i[u][h]){i[u][h]=p,s[u][h]=p.inv(),o[u][h]=a;for(let M=0;M<r[u].length;M++)b(u,p.mul(r[u][M]),a+g[u][M]);return}let P=p.mul(s[u][h]);f(P)||m(u-1,P,a+o[u][h])}function v(){i=[],s=[],r=[],o=[],g=[];for(let a=0;a<t;a++)i.push([]),s.push([]),o.push([]),r.push([]),g.push([]),i[a][a]=n,s[a][a]=n,o[a][a]=0;let u=0,p=BigInt(1);for(let a=0;a<l.length;a++){m(t-1,l[a],1),p=BigInt(1);let h=0,P=0,M=[],y=new Ge;for(let D=0;D<t;D++){let B=0,G=0;for(let T=0;T<t;T++)i[D][T]&&(B++,G+=o[D][T],D!==T&&u++);h+=r[D].length,p*=BigInt(B),B>1&&y.multiply(B);let Z=G/B;M.push(Z),P+=Z}e(`${a}: sz ${p} T ${h} sol ${P} none ${u} mults ${y.toString()}`)}return p}return v()}var we=class l{coords;length;constructor(e){this.coords=new Array(e.length*3);for(let t=0;t<e.length;t++)this.coords[3*t]=e[t].b,this.coords[3*t+1]=e[t].c,this.coords[3*t+2]=e[t].d;this.length=e.length}get(e){return new $(0,this.coords[3*e],this.coords[3*e+1],this.coords[3*e+2])}centermass(){let e=0,t=0,n=0;for(let i=0;i<this.length;i++)e+=this.coords[3*i],t+=this.coords[3*i+1],n+=this.coords[3*i+2];return new $(0,e/this.length,t/this.length,n/this.length)}rotate(e){let t=[];for(let n=0;n<this.length;n++)t.push(this.get(n).rotatepoint(e));return new l(t)}rotateforward(){let e=[];for(let t=1;t<this.length;t++)e.push(this.get(t));return e.push(this.get(0)),new l(e)}},$e=class l{constructor(e,t,n){this.face=e;this.left=t;this.right=n}split(e){let t=e.cutface(this.face);return t!==null&&(this.left===void 0?(this.left=new l(t[0]),this.right=new l(t[1])):(this.left=this.left?.split(e),this.right=this.right?.split(e))),this}collect(e,t){return this.left===void 0?e.push(new we(this.face)):t?(this.left?.collect(e,!1),this.right?.collect(e,!0)):(this.right?.collect(e,!1),this.left?.collect(e,!0)),e}};function wt(l,e){let t=[];for(let n of l)for(let i of e)t.push(i.rotate(n));return t}var I=1e-9,yt="PuzzleGeometry 0.1 Copyright 2018 Tomas Rokicki.",zt=!1;function xt(){return{4:[["F","D","L","R"]],6:[["F","D","L","U","R"],["R","F","","B",""]],8:[["F","D","L","R"],["D","F","BR",""],["BR","D","","BB"],["BB","BR","U","BL"]],12:[["U","F","","","",""],["F","U","R","C","A","L"],["R","F","","","E",""],["E","R","","BF","",""],["BF","E","BR","BL","I","D"]],20:[["R","C","F","E"],["F","R","L","U"],["L","F","A",""],["E","R","G","I"],["I","E","S","H"],["S","I","J","B"],["B","S","K","D"],["K","B","M","O"],["O","K","P","N"],["P","O","Q",""]]}}function Mt(){return{4:{F:"#44ee00",D:"#ffff00",L:"#ff0000",R:"#2266ff"},6:{U:"#ffffff",F:"#44ee00",R:"#ff0000",D:"#ffff00",B:"#2266ff",L:"#ff8000"},8:{U:"#ffffff",F:"#ff0000",R:"#44ee00",D:"#ffff00",BB:"#2266ff",L:"#8800dd",BL:"#ff8000",BR:"#aaaaaa"},12:{U:"#ffffff",F:"#008800",R:"#ff0000",C:"#ffffd0",A:"#3399ff",L:"#8800dd",E:"#ff66cc",BF:"#99ff00",BR:"#0000ff",BL:"#ffff00",I:"#ff8000",D:"#aaaaaa"},20:{R:"#db69f0",C:"#178fde",F:"#23238b",E:"#9cc726",L:"#2c212d",U:"#177fa7",A:"#e0de7f",G:"#2b57c0",I:"#41126b",S:"#4b8c28",H:"#7c098d",J:"#7fe7b4",B:"#85fb74",K:"#3f4bc3",D:"#0ff555",M:"#f1c2c8",O:"#58d340",P:"#c514f2",N:"#14494e",Q:"#8b1be1"}}}var Pt={4:{v:["DFR","DLF","DRL","FLR"],e:["FR","LF","DF","DL","RD","RL"],c:["DF","FD","RL","LR"]},6:{v:["URF","UBR","ULB","UFL","DFR","DRB","DBL","DLF"],e:["UF","UR","UB","UL","DF","DR","DB","DL","FR","FL","BR","BL"],c:["UB","LU","FU","RU","BU","DF"]},8:{v:["UBBBRR","URFL","ULBLBB","DBRBBBL","DBLLF","DFRBR"],e:["UL","UBB","UR","BRD","BLD","FD","BRR","FR","FL","BLL","BLBB","BRBB"],c:["BBU","LU","RU","BRD","FD","BLD","DF","UBB"]},12:{v:["URF","UFL","ULBL","UBLBR","UBRR","DEBF","DBFI","DIA","DAC","DCE","LAI","ALF","FCA","CFR","REC","ERBR","BRBFE","BFBRBL","BLIBF","IBLL"],e:["UF","UR","UBR","UBL","UL","ER","EBR","EBF","ED","EC","IBF","IBL","IL","IA","ID","AC","CF","FA","BFBR","BRBL","BLBF","CD","AD","AL","FL","FR","CR","BFD","BRR","BLL"],c:["UF","FU","DBF","BFD","AD","CD","BRU","BLU","LA","RA","EBR","IBL"]},20:{v:["FLPQU","FUGER","FRCAL","HCREI","ISBDH","JSIEG","BSJMK","MQPOK","ONDBK","NOPLA","UQMJG","DNACH"],e:["FU","FL","FR","EG","ER","EI","SJ","SI","SB","KM","KB","KO","PQ","PO","PL","UG","JG","MQ","UQ","HC","HD","ND","NA","JM","CA","AL","CR","HI","DB","NO"],c:["FU","UF","GE","EG","JS","SJ","MK","KM","QP","PQ","LA","AL","RC","CR","IH","HI","BD","DB","ON","NO"]}};function Dt(){return{4:[["FLR",[0,1,0]],["F",[0,0,1]]],6:[["U",[0,1,0]],["F",[0,0,1]]],8:[["U",[0,1,0]],["F",[0,0,1]]],12:[["U",[0,1,0]],["F",[0,0,1]]],20:[["GUQMJ",[0,1,0]],["F",[0,0,1]]]}}function Be(l,e){for(let t=0;t<l.length;t++)if(l[t][0].dist(e)<I)return t;throw new Error("Element not found")}function Ft(){return Pe}function Bt(l){return Pe[l]}var Lt=["c","t","o","d","i"],kt=["f","v","e"];function ze(l){let e=l.split(/ /).filter(Boolean);if(e.length%2===0)return null;let t=e[0];if(t!=="o"&&t!=="c"&&t!=="i"&&t!=="d"&&t!=="t")return null;let n=[];for(let i=1;i<e.length;i+=2){if(e[i]!=="f"&&e[i]!=="v"&&e[i]!=="e")return null;n.push({cutType:e[i],distance:parseFloat(e[i+1])})}return{shape:t,cuts:n}}function at(l,e={}){let t=ze(l);if(t===null)throw new Error("Could not parse the puzzle description");let n=new ke(t,Object.assign({},{allMoves:!0},e));return n.allstickers(),n.genperms(),n}function Rt(l,e){return at(Pe[l],e)}function Ot(l,e,t){let n=!1;t-e[1]<e[0]&&(l=[l[2],l[3],l[0],l[1]],e=[t-e[1],t-e[0]],n=!0);let i=l[0],s="";if(e[0]===0&&e[1]===t)i=`${i}v`;else if(e[0]===e[1])e[1]>0&&(s=String(e[1]+1));else if(e[0]===0)i=i.toLowerCase(),e[1]>1&&(s=String(e[1]+1));else throw new Error(`We only support slice and outer block moves right now. ${e}`);return[s+i,n]}function Ct(l,e){let t=[],n=0;for(;n<l.length;){n>0&&n<l.length&&l[n]==="_"&&n++;let i="";for(let s of e)l.substr(n).startsWith(s[1])&&s[1].length>i.length&&(i=s[1]);if(i!=="")t.push(i),n+=i.length;else throw new Error(`Could not split ${l} into face names.`)}return t}function Le(l,e){return[l.b/e,-l.c/e,l.d/e]}function Ue(l,e){let t=[],n=l.length;for(let i=0;i<n;i++){let s=Le(l.get(n-i-1),e);t[3*i]=s[0],t[3*i+1]=s[1],t[3*i+2]=s[2]}return t}var ke=class{constructor(e,t){this.puzzleDescription=e;let n="genperms";this.options=new ye(t),this.options.verbosity>0&&console.log(this.header("# ")),this.create(e)}rotations;baseplanerot;baseplanes;facenames;faceplanes;edgenames;vertexnames;geonormals;moveplanes;moveplanes2;moveplanesets;moveplanenormals;movesetorders;movesetgeos;basefaces;faces;facecentermass;baseFaceCount;stickersperface;shortedge;markedface;cubies;vertexdistance;edgedistance;facetocubie;facetoord;moverotations;facelisthash;cubiesetnames;cubieords;cubiesetnums;cubieordnums;orbitoris;cubievaluemap;cubiesetcubies;cmovesbyslice=[];parsedmovelist;duplicatedFaces=[];duplicatedCubies=[];fixedCubie=-1;net=[];colors=[];swizzler;notationMapper=new se;addNotationMapper="";setReidOrder=!1;options;create(e){let{shape:t,cuts:n}=e;this.moveplanes=[],this.moveplanes2=[],this.faces=[],this.cubies=[];let i=null;switch(t){case"c":{i=tt();break}case"o":{i=ot();break}case"i":{i=st();break}case"t":{i=nt();break}case"d":{i=it();break}default:throw new Error(`Bad shape argument: ${t}`)}this.rotations=rt(i),this.options.verbosity&&console.log(`# Rotations: ${this.rotations.length}`);let s=i[0];this.baseplanerot=Qe(s,this.rotations);let o=this.baseplanerot.map(c=>s.rotateplane(c));this.baseplanes=o,this.baseFaceCount=o.length;let r=xt()[o.length];this.net=r,this.colors=Mt()[o.length],this.options.verbosity>0&&console.log(`# Base planes: ${o.length}`);let g=je(o),f=new $(0,0,0,0);this.options.verbosity>0&&console.log(`# Face vertices: ${g.length}`);let m=o[0].makenormal(),b=g[0].sum(g[1]).makenormal(),v=g[0].makenormal(),u=new $(1,m.b,m.c,m.d);this.options.verbosity>0&&console.log(`# Boundary is ${u}`);let a=Qe(u,this.rotations).map(c=>u.rotateplane(c)),h=je(a);this.edgedistance=h[0].sum(h[1]).smul(.5).dist(f),this.vertexdistance=h[0].dist(f);let P=[],M=[],y=!1,D=!1,B=!1;for(let c of n){let x=null,O=0;switch(c.cutType){case"f":{x=m,O=1,y=!0;break}case"v":{x=v,O=this.vertexdistance,B=!0;break}case"e":{x=b,O=this.edgedistance,D=!0;break}default:throw new Error(`Bad cut argument: ${c.cutType}`)}P.push(x.makecut(c.distance)),M.push(c.distance<O)}this.options.addRotations&&(y||P.push(m.makecut(10)),B||P.push(v.makecut(10)),D||P.push(b.makecut(10))),this.basefaces=[];for(let c of this.baseplanerot){let x=c.rotateface(h);this.basefaces.push(new we(x))}let G=[],Z=[],T=[],Q=[],d=h.length;function L(c,x,O){for(let k of c)if(k[0].dist(x)<I){k.push(O);return}c.push([x,O])}for(let c=0;c<this.baseplanerot.length;c++){let x=this.baseplanerot[c].rotateface(h);for(let O=0;O<x.length;O++){let k=(O+1)%x.length,j=x[O].sum(x[k]).smul(.5);L(Q,j,c)}}let C=[];for(let c=0;c<this.baseplanerot.length;c++){let x=this.baseplanerot[c].rotateface(h),O=[];for(let k=0;k<x.length;k++){let j=(k+1)%x.length,U=x[k].sum(x[j]).smul(.5),Y=Q[Be(Q,U)];if(c===Y[1])O.push(Y[2]);else if(c===Y[2])O.push(Y[1]);else throw new Error("Could not find edge")}C.push(O)}let w={},z=[];z.push(r[0][0]),w[r[0][0]]=0,z[C[0][0]]=r[0][1],w[r[0][1]]=C[0][0];for(let c of r){let x=c[0],O=w[x];if(O===void 0)throw new Error("Bad edge description; first edge not connected");let k=-1;for(let j=0;j<C[O].length;j++){let U=z[C[O][j]];if(U!==void 0&&U===c[1]){k=j;break}}if(k<0)throw new Error("First element of a net not known");for(let j=2;j<c.length;j++){if(c[j]==="")continue;let U=C[O][(j+k-1)%d],Y=z[U];if(Y!==void 0&&Y!==c[j])throw new Error("Face mismatch in net");z[U]=c[j],w[c[j]]=U}}for(let c=0;c<this.baseplanerot.length;c++){let x=this.baseplanerot[c].rotateface(h),O=u.rotateplane(this.baseplanerot[c]),k=z[c];G.push([x,k]),Z.push([O,k])}for(let c=0;c<this.baseplanerot.length;c++){let x=this.baseplanerot[c].rotateface(h),O=z[c];for(let k=0;k<x.length;k++){let j=(k+1)%x.length,U=x[k].sum(x[j]).smul(.5),Y=(k+2)%x.length,lt=x[j].sum(x[Y]).smul(.5),ct=Be(Q,U),ut=Be(Q,lt);L(T,x[j],[O,ut,ct])}}this.swizzler=new oe(G.map(c=>c[1]));let R=this.swizzler.prefixFree?"":"_",N=Pt[this.baseFaceCount],S=[];for(let c=0;c<this.baseFaceCount;c++)S[1<<c]=c;{let c=N.v;for(let x of c){let O=this.swizzler.splitByFaceNames(x),k=0;for(let j of O)k|=1<<j;S[k]=O[0]}}{let c=N.e;for(let x of c){let O=this.swizzler.splitByFaceNames(x),k=0;for(let j of O)k|=1<<j;S[k]=O[0]}}{let c=N.c;for(let x of c){let O=this.swizzler.splitByFaceNames(x),k=1<<O[0]|1<<this.baseFaceCount;S[k]=O[1]}}for(let c=0;c<Q.length;c++){if(Q[c].length!==3)throw new Error(`Bad length in edge names ${Q[c]}`);let x=Q[c][1],O=Q[c][2],k=z[x],j=z[O],U=1<<x|1<<O;S[U]===x?k=k+R+j:k=j+R+k,Q[c]=[Q[c][0],k]}for(let c=0;c<T.length;c++){let x=0;if(T[c].length<4)throw new Error("Bad length in vertex names");for(let U=1;U<T[c].length;U++)x|=1<<w[T[c][U][0]];let O=S[x],k=-1;for(let U=1;U<T[c].length;U++)O===w[T[c][U][0]]&&(k=U);if(k<0)throw new Error("Internal error; couldn't find face name when fixing corners");let j="";for(let U=1;U<T[c].length;U++){U===1?j=T[c][k][0]:j=j+R+T[c][k][0];for(let Y=1;Y<T[c].length;Y++)if(T[c][k][1]===T[c][Y][2]){k=Y;break}}T[c]=[T[c][0],j]}this.markedface=S,this.options.verbosity>1&&(console.log(`# Face names: ${G.map(c=>c[1]).join(" ")}`),console.log(`# Edge names: ${Q.map(c=>c[1]).join(" ")}`),console.log(`# Vertex names: ${T.map(c=>c[1]).join(" ")}`));let A=[];for(let c of Z)A.push([c[0].makenormal(),c[1],"f"]);for(let c of Q)A.push([c[0].makenormal(),c[1],"e"]);for(let c of T)A.push([c[0].makenormal(),c[1],"v"]);this.facenames=G,this.faceplanes=Z,this.edgenames=Q,this.vertexnames=T,this.geonormals=A;let K=A.map(c=>c[1]);this.swizzler.setGripNames(K),this.options.verbosity>0&&console.log(`# Distances: face 1 edge ${this.edgedistance} vertex ${this.vertexdistance}`);for(let c=0;c<P.length;c++)for(let x of this.rotations){let O=P[c].rotateplane(x),k=!1;for(let j of this.moveplanes)if(O.sameplane(j)){k=!0;break}k||(this.moveplanes.push(O),M[c]&&this.moveplanes2.push(O))}let J=new $e(h),V=this.moveplanes2.slice(),ie=31;for(let c=0;c<V.length;c++){let x=c+Math.floor((V.length-c)*(ie/65536));J=J.split(V[x]),V[x]=V[c],ie=(ie*1657+101)%65536}let W=J.collect([],!0);this.faces=W,this.options.verbosity>0&&console.log(`# Faces is now ${W.length}`),this.stickersperface=W.length;let ce=[],te=De(h);for(let c of this.rotations){let x=c.rotateface(h);te.dist(De(x))<I&&ce.push(c)}let ne=new Array(W.length),H=[];for(let c=0;c<W.length;c++){let x=W[c].centermass();H.push([te.dist(x),x,c])}H.sort((c,x)=>c[0]-x[0]);for(let c=0;c<W.length;c++){let x=H[c][2];if(!ne[x]){ne[x]=!0;for(let O of ce){let k=W[x].rotate(O),j=k.centermass();for(let U=c+1;U<W.length&&!(H[U][0]-H[c][0]>I);U++){let Y=H[U][2];if(!ne[Y]&&j.dist(H[U][1])<I){ne[Y]=!0,W[Y]=k;break}}}}}this.shortedge=1e99;for(let c of W)for(let x=0;x<c.length;x++){let O=(x+1)%c.length,k=c.get(x).dist(c.get(O));k<this.shortedge&&(this.shortedge=k)}this.options.verbosity>0&&console.log(`# Short edge is ${this.shortedge}`),t==="c"&&y&&!D&&!B&&(this.addNotationMapper="NxNxNCubeMapper",this.setReidOrder=!0),t==="c"&&B&&!y&&!D&&(this.addNotationMapper="SkewbMapper"),t==="t"&&(B||y)&&!D&&(this.addNotationMapper="PyraminxOrTetraminxMapper"),t==="o"&&y&&(this.notationMapper=new re(this.swizzler,new oe(["F","D","L","BL","R","U","BR","B"])),D||B||(this.addNotationMapper="FTOMapper")),t==="d"&&y&&(this.addNotationMapper="MegaminxMapper",this.notationMapper=new re(this.swizzler,new oe(["U","F","L","BL","BR","R","FR","FL","DL","B","DR","D"])))}keyface(e){return this.keyface2(e.centermass())}keyface2(e){let t="",n=String.fromCharCode;for(let i of this.moveplanesets)if(i.length>0){let s=e.dot(i[0]),o=0,r=1;for(;r*2<=i.length;)r*=2;for(;r>0;r>>=1)o+r<=i.length&&s>i[o+r-1].a&&(o+=r);if(o<47)t=t+n(33+o);else if(o<47+47*47)t=t+n(33+47+Math.floor(o/47)-1)+n(33+o%47);else if(o<47+47*47+47*47*47)t=t+n(33+47+Math.floor((o-47)/(47*47)-1))+n(33+47+Math.floor((o-47)/47)%47)+n(33+o%47);else throw Error("Too many slices for cubie encoding")}return t}keyface3(e){let t=e.centermass(),n=[];for(let i of this.moveplanesets)if(i.length>0){let s=t.dot(i[0]),o=0,r=1;for(;r*2<=i.length;)r*=2;for(;r>0;r>>=1)o+r<=i.length&&s>i[o+r-1].a&&(o+=r);n.push(o)}return n}findface(e){let t=this.keyface2(e),n=this.facelisthash.get(t);if(n.length===1)return n[0];for(let i=0;i+1<n.length;i++){let s=this.facelisthash.get(t)[i];if(Math.abs(e.dist(this.facecentermass[s]))<I)return s}return n[n.length-1]}project2d(e,t,n){let i=this.facenames[e][0],s=(t+1)%i.length,o=this.baseplanes[e],r=i[s].sub(i[t]),g=r.len();r=r.normalize();let f=r.cross(o).normalize(),m=n[1].sub(n[0]),b=m.len()/g;m=m.normalize();let v=m.b,u=m.c,p=r.smul(v).sub(f.smul(u)).smul(b),a=f.smul(v).sum(r.smul(u)).smul(b),h=new $(0,n[0].b-p.dot(i[t]),n[0].c-a.dot(i[t]),0);return[p,a,h]}allstickers(){let e="allstickers";this.faces=wt(this.baseplanerot,this.faces),this.options.verbosity>0&&console.log(`# Total stickers is now ${this.faces.length}`),this.facecentermass=new Array(this.faces.length);for(let d=0;d<this.faces.length;d++)this.facecentermass[d]=this.faces[d].centermass();let t=[],n=[];for(let d of this.moveplanes){let L=d.makenormal(),C=!1;for(let w of n)L.sameplane(w.makenormal())&&(C=!0);C||(n.push(L),t.push([]))}for(let d of this.moveplanes2){let L=d.makenormal();for(let C=0;C<n.length;C++)if(L.sameplane(n[C])){t[C].push(d);break}}for(let d=0;d<t.length;d++){let L=t[d].map(w=>w.normalizeplane()),C=n[d];for(let w=0;w<L.length;w++)L[w].makenormal().dist(C)>I&&(L[w]=L[w].smul(-1));L.sort((w,z)=>w.a-z.a),t[d]=L}this.moveplanesets=t,this.moveplanenormals=n;let i=t.map(d=>d.length);this.options.verbosity>0&&console.log(`# Move plane sets: ${i}`);let s=[];for(let d=0;d<t.length;d++)s.push([]);for(let d of this.rotations){if(Math.abs(Math.abs(d.a)-1)<I)continue;let L=d.makenormal();for(let C=0;C<t.length;C++)if(L.sameplane(n[C])){s[C].push(d);break}}this.moverotations=s;for(let d=0;d<s.length;d++){let L=s[d],C=L[0].makenormal();for(let w=0;w<L.length;w++)C.dist(L[w].makenormal())>I&&(L[w]=L[w].smul(-1));L.sort((w,z)=>w.angle()-z.angle()),s[d][0].dot(n[d])<0&&L.reverse()}let o=s.map(d=>1+d.length);this.movesetorders=o;let r=[],g="?";for(let d=0;d<t.length;d++){let L=n[d],C=null,w=null;for(let z of this.geonormals){let R=L.dot(z[0]);Math.abs(R-1)<I?(w=[z[1],z[2]],g=z[2]):Math.abs(R+1)<I&&(C=[z[1],z[2]],g=z[2])}if(w===null||C===null)throw new Error("Saw positive or negative sides as null");r.push([w[0],w[1],C[0],C[1],1+t[d].length]),this.addNotationMapper==="NxNxNCubeMapper"&&g==="f"&&(this.notationMapper=new he(1+t[d].length),this.addNotationMapper=""),this.addNotationMapper==="SkewbMapper"&&t[0].length===1&&(this.notationMapper=new me(this.swizzler),this.addNotationMapper=""),this.addNotationMapper==="PyraminxOrTetraminxMapper"&&(t[0].length===2&&t[0][0].a===.333333333333333&&t[0][1].a===1.66666666666667?(this.notationMapper=new ae(this.swizzler),this.addNotationMapper=""):(this.notationMapper=new pe(this.swizzler),this.addNotationMapper="")),this.addNotationMapper==="MegaminxMapper"&&g==="f"&&(1+t[d].length===3&&(this.notationMapper=new fe(this.notationMapper)),this.addNotationMapper=""),this.addNotationMapper==="FTOMapper"&&g==="f"&&(1+t[d].length===3&&(this.notationMapper=new ue(this.notationMapper,this.swizzler)),this.addNotationMapper="")}this.movesetgeos=r;let f=new Map,m=this.faces;for(let d=0;d<m.length;d++){let L=m[d],C=this.keyface(L);if(!f.get(C))f.set(C,[d]);else{let w=f.get(C);if(w.push(d),w.length===this.baseFaceCount){this.options.verbosity>0&&console.log("# Splitting core.");for(let z=0;z<w.length;z++){let R=`${C} ${z}`;f.set(R,[w[z]])}}}}this.facelisthash=f,this.options.verbosity>0&&console.log(`# Cubies: ${f.size}`);let b=[],v=[],u=[];for(let d of f.values())if(d.length!==this.baseFaceCount){if(d.length>1){let L=d.map(N=>m[N].centermass()),C=De(L);for(let N=0;d.length>2;N++){let S=!1;for(let A=0;A<d.length;A++){let K=(A+1)%d.length;if(C.dot(L[A].cross(L[K]))<0){let J=L[A];L[A]=L[K],L[K]=J;let V=d[A];d[A]=d[K],d[K]=V,S=!0}}if(!S)break;if(N>1e3)throw new Error("Bad epsilon math; too close to border")}let w=0;for(let N of d)w|=1<<Math.floor(N/this.stickersperface);let z=this.markedface[w],R=-1;for(let N=0;N<d.length;N++)Math.floor(d[N]/this.stickersperface)===z&&(R=N);if(R<0)throw new Error("Could not find marked face in list");if(R!==0){let N=d.slice();for(let S=0;S<d.length;S++)d[S]=N[(R+S)%d.length]}}for(let L=0;L<d.length;L++){let C=d[L];v[C]=b.length,u[C]=L}b.push(d)}this.cubies=b,this.facetocubie=v,this.facetoord=u;let p=["?","CENTERS","EDGES","CORNERS","C4RNER","C5RNER"],a=[],h=[0,0,0,0,0,0],P=[],M=[],y=0,D=[],B=[],G=[],Z=[],T=d=>b[d].map(L=>this.getfaceindex(L)).join(" "),Q=[];for(let d=0;d<b.length;d++){let L=b[d];if(L.length===0||M[d])continue;let C={},w=0;G.push(0),Q.push([]);let z=L.length,R=h[z]++,N=p[z];(N===void 0||z===this.baseFaceCount)&&(N="CORE"),N=N+(R===0?"":R+1),a[y]=N,P[y]=z;let S=[d],A=0;for(M[d]=!0;A<S.length;){let K=S[A++],J=T(K);if((L.length>1||C[J]===void 0)&&(C[J]=w++),Z[K]=C[J],D[K]=y,Q[y].push(K),B[K]=G[y]++,S.length<this.rotations.length){let V=this.facecentermass[b[K][0]];for(let ie of s){let W=this.facetocubie[this.findface(V.rotatepoint(ie[0]))];M[W]||(S.push(W),M[W]=!0)}}}y++}if(this.setReidOrder&&4<=this.stickersperface&&this.stickersperface<=9){let d=[["UF","UR","UB","UL","DF","DR","DB","DL","FR","FL","BR","BL"],["UFR","URB","UBL","ULF","DRF","DFL","DLB","DBR"],["U","L","F","R","B","D"]],L={};for(let C of d)for(let w=0;w<C.length;w++){let z=0;for(let R=0;R<C[w].length;R++)z|=1<<C[w].charCodeAt(R)-65;L[z]=w}for(let C of Q)for(let w of C){let z=0;for(let R of b[w])z|=1<<this.facenames[this.getfaceindex(R)][1].charCodeAt(0)-65;B[w]=L[z]}}if(this.cubiesetnums=D,this.cubieordnums=B,this.cubiesetnames=a,this.cubieords=G,this.orbitoris=P,this.cubievaluemap=Z,this.cubiesetcubies=Q,this.options.fixedPieceType!==null){for(let d=0;d<b.length;d++)if(this.options.fixedPieceType==="v"&&b[d].length>2||this.options.fixedPieceType==="e"&&b[d].length===2||this.options.fixedPieceType==="f"&&b[d].length===1){this.fixedCubie=d;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 ${G}`)}unswizzle(e){let t=this.notationMapper.notationToInternal(e);return t===null?null:t.modified({family:this.swizzler.unswizzle(t.family)})}stringToBlockMove(e){let t=RegExp("^(([0-9]+)-)?([0-9]+)?([^0-9]+)([0-9]+'?)?$"),n=e.match(t);if(n===null)throw new Error(`Bad move passed ${e}`);let i=n[4],s,o;if(n[2]!==void 0){if(n[3]===void 0)throw new Error("Missing second number in range");s=parseInt(n[2],10)}n[3]!==void 0&&(o=parseInt(n[3],10));let r="1",g=1;return n[5]!==void 0&&(r=n[5],r[0]==="'"&&(r=`-${r.substring(1)}`),g=parseInt(r,10)),new F(new E(i,o,s),g)}parseMove(e){let t=this.notationMapper.notationToInternal(e);if(t===null)throw new Error(`Bad move ${e.family}`);e=t;let n=e.family,i=!1;if(n.endsWith("v")&&n[0]<="Z"){if(e.innerLayer!==void 0||e.outerLayer!==void 0)throw new Error("Cannot use a prefix with full cube rotations");n=n.slice(0,-1),i=!0}n.endsWith("w")&&n[0]<="Z"&&(n=n.slice(0,-1).toLowerCase());let s,o=-1,r=this.swizzler.unswizzle(n),g=!1;for(let b=0;b<this.movesetgeos.length;b++){let v=this.movesetgeos[b];r===v[0]&&(g=!0,s=v,o=b),r===v[2]&&(g=!1,s=v,o=b)}let f=1,m=1;if(n.toUpperCase()!==n&&(m=2),s===void 0)throw new Error(`Bad grip in move ${e.family}`);if(e.outerLayer!==void 0&&(f=e.outerLayer),e.innerLayer!==void 0&&(e.outerLayer===void 0?(m=e.innerLayer,n<="Z"?f=m:f=1):m=e.innerLayer),f--,m--,i&&(f=0,m=this.moveplanesets[o].length),f<0||f>this.moveplanesets[o].length||m<0||m>this.moveplanesets[o].length)throw new Error(`Bad slice spec ${f} ${m} vs ${this.moveplanesets[o].length}`);if(!zt&&f===0&&m===this.moveplanesets[o].length&&!i)throw new Error("! full puzzle rotations must be specified with v suffix.");return[void 0,o,f,m,g,e.amount]}parsemove(e){let t=this.parseMove(this.stringToBlockMove(e));return t[0]=e,t}genperms(){let e="genperms";if(this.cmovesbyslice.length>0)return;let t=[];if(this.options.orientCenters){for(let n=0;n<this.cubies.length;n++)if(this.cubies[n].length===1){let i=this.cubies[n][0],s=this.getfaceindex(i),o=this.basefaces[s].centermass();if(o.dist(this.facecentermass[i])<I){let r=1<<s|1<<this.baseFaceCount,g=this.markedface[r],f=this.baseplanes[g].makenormal(),m=-1,b=-1;for(let p=0;p<this.faces[i].length;p++){let a=this.faces[i].get(p),h=f.dot(a.sub(o));h>m&&(m=h,b=p)}let v=(b+1)%this.faces[i].length;if(Math.abs(f.dot(this.faces[i].get(v).sub(o))-m)<I&&(b=v),b!==0){let p=[];for(let a=0;a<this.faces[i].length;a++)p.push(this.faces[i].get((a+b)%this.faces[i].length));this.faces[i]=new we(p)}let u=this.basefaces[s].length;for(let p=1;p<u;p++)this.cubies[n].push(this.cubies[n][p-1]);this.duplicatedFaces[i]=u,this.duplicatedCubies[n]=u,this.orbitoris[this.cubiesetnums[n]]=u}}}for(let n=0;n<this.moveplanesets.length;n++){let i=this.moveplanesets[n],s=[],o=[i.length+1,0],r=1;for(;r*2<=i.length;)r*=2;for(let m=0;m<this.faces.length;m++){let b=0;if(i.length>0){let v=this.facecentermass[m].dot(i[0]);for(let u=r;u>0;u>>=1)b+u<=i.length&&v>i[b+u-1].a&&(b+=u);b=i.length-b}for(s.push(b);o.length<=b;)o.push(0);o[b]++}let g=new Array(o.length);for(let m=0;m<o.length;m++)g[m]=[];let f=[];for(let m=0;m<this.faces.length;m++){if(s[m]<0)continue;let b=[this.facetocubie[m],this.facetoord[m]],v=this.facecentermass[m],u=v,p=m,a=s[p];for(;;){s[p]=-1;let h=v.rotatepoint(this.moverotations[n][0]);if(h.dist(u)<I)break;p=this.findface(h),b.push(this.facetocubie[p],this.facetoord[p]),v=h}if(b.length>2&&this.options.orientCenters&&(this.cubies[b[0]].length===1||this.duplicatedCubies[b[0]]>1)&&this.facecentermass[m].dist(this.basefaces[this.getfaceindex(m)].centermass())<I){let h=this.faces[this.cubies[b[0]][0]];for(let P=0;P<b.length;P+=2){let M=this.faces[this.cubies[b[P]][0]],y=-1;for(let D=0;D<h.length;D++)if(M.get(D).dist(h.get(0))<I){y=D;break}if(y<0)throw new Error("Couldn't find rotation of center faces; ignoring for now.");b[P+1]=y,h=h.rotate(this.moverotations[n][0])}}if(b.length===2&&this.options.orientCenters)for(let h=1;h<this.movesetorders[n];h++)a===0?b.push(b[0],h):b.push(b[0],(this.movesetorders[n]-h)%this.movesetorders[n]);if(b.length>2&&!f[b[0]]){if(b.length!==2*this.movesetorders[n])throw new Error("Bad length in perm gen");for(let h of b)g[a].push(h)}for(let h=0;h<b.length;h+=2)f[b[h]]=!0}for(let m=0;m<g.length;m++)g[m]=g[m].slice();t.push(g)}if(this.cmovesbyslice=t,this.options.moveList){let n=[];for(let i of this.options.moveList)n.push(this.parsemove(i));this.parsedmovelist=n}this.facelisthash.clear(),this.facecentermass=[]}getboundarygeometry(){return{baseplanes:this.baseplanes,facenames:this.facenames,faceplanes:this.faceplanes,vertexnames:this.vertexnames,edgenames:this.edgenames,geonormals:this.geonormals}}getmovesets(e){let t=this.moveplanesets[e].length,n=[];if(this.parsedmovelist!==void 0)for(let i of this.parsedmovelist)i[1]===e&&(i[4]?n.push([i[2],i[3]]):n.push([t-i[3],t-i[2]]),n.push(i[5]));else if(this.options.vertexMoves&&!this.options.allMoves){let i=this.movesetgeos[e];if(i[1]!==i[3])for(let s=0;s<t;s++)i[1]!=="v"?(this.options.outerBlockMoves?n.push([s+1,t]):n.push([s+1]),n.push(1)):(this.options.outerBlockMoves?n.push([0,s]):n.push([s,s]),n.push(1))}else for(let i=0;i<=t;i++)!this.options.allMoves&&i+i===t||(this.options.outerBlockMoves?i+i>t?n.push([i,t]):n.push([0,i]):n.push([i,i]),n.push(1));if(this.fixedCubie>=0){let i=this.keyface3(this.faces[this.cubies[this.fixedCubie][0]])[e],s=[];for(let o=0;o<n.length;o+=2){let r=n[o];if(i>=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 g=!1;for(let f=0;f<s.length;f+=2)if(s[f][0]===r[0]&&s[f][1]===r[1]&&s[f+1]===n[o+1]){g=!0;break}g||(s.push(r),s.push(n[o+1]))}n=s}return n}graybyori(e){let t=this.cubies[e].length;return this.duplicatedCubies[e]&&(t=1),t===1&&(this.options.grayCenters||!this.options.includeCenterOrbits)||t===2&&(this.options.grayEdges||!this.options.includeEdgeOrbits)||t>2&&(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+yt}
${e}
`}writegap(){let e=this.getOrbitsDef(!1),t=[],n=[];for(let s=0;s<e.moveops.length;s++){let o=`M_${be(this.notationMapper,e.movenames[s])}`,r=!1;o[o.length-1]==="'"&&(o=o.substring(0,o.length-1),r=!0),n.push(o),r?t.push(`${o}:=${e.moveops[s].toPerm().inv().toGap()};`):t.push(`${o}:=${e.moveops[s].toPerm().toGap()};`)}t.push("Gen:=["),t.push(n.join(",")),t.push("];");let i=e.solved.identicalPieces();return t.push(`ip:=[${i.map(s=>`[${s.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(){let e=this.getOrbitsDef(!1),t=[],n=[];t.push(`(* ${this.header("").trim()} *)`);for(let i=0;i<e.moveops.length;i++){let s=`m${be(this.notationMapper,e.movenames[i])}`,o=!1;s[s.length-1]==="'"&&(s=s.substring(0,s.length-1),o=!0),n.push(s),o?t.push(`${s}=${e.moveops[i].toPerm().inv().toMathematica()};`):t.push(`${s}=${e.moveops[i].toPerm().toMathematica()};`)}return t.push(`gen={${n.join(",")}};`),t.join(`
`)}writeksolve(e="PuzzleGeometryPuzzle"){let t=this.getOrbitsDef(!1);return this.header("# ")+t.toKsolve(e,this.notationMapper).join(`
`)}getKPuzzleDefinition(e=!0,t=!0){let i=this.getOrbitsDef(e,t).toKPuzzleDefinition(t);if(i.experimentalPuzzleDescription=this.puzzleDescription,!i)throw new Error("Missing definition!");return i}getMoveFromBits(e,t,n,i,s,o){let r=[],g=[],f=[];for(let v of this.cubieords)g.push(X(v)),f.push(_(v));for(let v=e[0];v<=e[1];v++){let u=i[v];for(let p=0;p<u.length;p+=2*o){let a=u.slice(p,p+2*o),h=this.cubiesetnums[a[0]];for(let y=0;y<a.length;y+=2)a[y]=this.cubieordnums[a[y]];let P=2,M=3;n&&(P=a.length-2,M=a.length-1),g[h]===X(this.cubieords[h])&&(g[h]=g[h].slice(),this.orbitoris[h]>1&&!this.options.fixedOrientation&&(f[h]=f[h].slice()));for(let y=0;y<a.length;y+=2)g[h][a[(y+P)%a.length]]=a[y],this.orbitoris[h]>1&&!this.options.fixedOrientation&&(f[h][a[y]]=(a[(y+M)%a.length]-a[(y+1)%a.length]+2*this.orbitoris[h])%this.orbitoris[h])}}let m=new ee(X(24),_(24),1);for(let v=0;v<this.cubiesetnames.length;v++)if(!(s&&!s[v]))if(this.orbitoris[v]===1||this.options.fixedOrientation)g[v]===X(m.perm.length)?(g[v]!==m.perm&&(m=new ee(g[v],f[v],1)),r.push(m)):r.push(new ee(g[v],f[v],1));else{let u=new Array(f[v].length);for(let p=0;p<g[v].length;p++)u[p]=f[v][g[v][p]];r.push(new ee(g[v],u,this.orbitoris[v]))}let b=new ge(r);return t!==1&&(b=b.mulScalar(t)),b}omitSet(e){for(let t of this.options.excludeOrbits)if(t===e)return!0;return!1}diffmvsets(e,t,n,i){for(let s=0;s<e.length;s+=2){let o=!1;for(let r=0;!o&&r<t.length;r+=2)i?e[s][0]+t[r][1]===n&&e[s][1]+t[r][0]===n&&e[s+1]===t[r+1]&&(o=!0):e[s][0]===t[r][0]&&e[s][1]===t[r][1]&&e[s+1]===t[r+1]&&(o=!0);if(!o)return!0}return!1}getOrbitsDef(e,t=!0){let n=[];if(e)for(let a=0;a<this.cubiesetnames.length;a++)n.push(1);let i=[],s=[],o=[],r=[];for(let a=0;a<this.moveplanesets.length;a++){let h=this.getmovesets(a);o.push(h),this.options.addRotations?r.push(1):r.push(0)}let g=[];for(let a=0;a<this.moveplanesets.length;a++){let h=this.moveplanesets[a].length,P=!1,M=o[a];for(let y=0;y<M.length;y+=2)M[y][0]===0&&M[y][1]===h&&(P=!0);g[a]=P}if(this.options.addRotations&&(this.options.moveList||this.options.fixedPieceType!==null)){for(let a=0;a<this.moverotations.length;a++)r[a]=0;for(let a=0;a<this.moveplanesets.length;a++){if(g[a]){r[a]=3;continue}for(let h=0;h<this.moverotations.length;h++){let P=this.moveplanenormals[a];for(let M=1;M*2<=this.movesetorders[h];M++){if(P=P.rotatepoint(this.moverotations[h][0]),r[h]&M)continue;let y=-1,D=!1;for(let G=0;G<this.moveplanenormals.length;G++)if(P.dist(this.moveplanenormals[G])<I){y=G;break}else if(P.dist(this.moveplanenormals[G].smul(-1))<I){y=G,D=!0;break}if(y<0)throw new Error("Could not find rotation");let B=o[y];(B.length!==o[a].length||this.moveplanesets[a].length!==this.moveplanesets[y].length||this.diffmvsets(B,o[a],this.moveplanesets[y].length,D))&&(r[h]|=M)}}}for(let a=0;a<this.moverotations.length;a++)if(r[a]===0)r[a]=1;else if(r[a]===1)this.movesetorders[a]>3?r[a]=2:r[a]=0;else if(r[a]===3)r[a]=0;else throw new Error("Impossible addrot val")}for(let a=0;a<this.moveplanesets.length;a++)r[a]!==0&&!g[a]&&(o[a].push([0,this.moveplanesets[a].length]),o[a].push(r[a]));for(let a=0;a<this.moveplanesets.length;a++){let h=o[a],P=this.movesetorders[a];for(let D=0;D<h.length;D+=2)for(let B=0;B<D;B+=2)if(h[D][0]===h[B][0]&&h[D][1]===h[B][1])throw new Error("Redundant moves in moveset.");let M=[];for(let D=0;D<h.length;D+=2)for(let B=h[D][0];B<=h[D][1];B++)M[B]=1;let y=this.cmovesbyslice[a];for(let D=0;D<y.length;D++){if(M[D]!==1)continue;let B=y[D];for(let G=0;G<B.length;G+=2*P){if(this.skipcubie(B[G]))continue;let Z=this.cubiesetnums[B[G]];n[Z]=1}}}for(let a=0;a<this.cubiesetnames.length;a++)if(n[a]){if(this.omitSet(this.cubiesetnames[a])){n[a]=0;continue}i.push(this.cubiesetnames[a]),s.push(new le(this.cubieords[a],this.options.fixedOrientation?1:this.orbitoris[a]))}let f=[];for(let a=0;a<this.cubiesetnames.length;a++){if(!n[a]||this.omitSet(this.cubiesetnames[a]))continue;let h=[],P=[];for(let M=0;M<this.cubieords[a];M++){if(e)h.push(M);else{let y=this.cubiesetcubies[a][M];h.push(this.cubievaluemap[y])}P.push(0)}f.push(new ee(h,P,this.options.fixedOrientation?1:this.orbitoris[a]))}let m=[],b=[],v=[],u=[];if(t)for(let a=0;a<this.moveplanesets.length;a++){let P=this.moveplanesets[a].length,M=o[a],y=this.movesetgeos[a];for(let D=0;D<M.length;D+=2){let B=M[D],G,Z=!1;if(this.parsedmovelist!==void 0)for(let Q of this.parsedmovelist){if(Q[1]!==a)continue;let d=[];Q[4]?d=[Q[2],Q[3]]:d=[P-Q[3],P-Q[2]],d[0]===B[0]&&d[1]===B[1]&&(G=Q[0],Z=!Q[4])}if(G)m.push(G),b.push(!0);else{let Q=Ot(y,B,P);Z=Q[1];let d=Q[0];M[D+1]===1?m.push(d):m.push(d+M[D+1]),b.push(!1)}u.push(B[0]===0&&B[1]===P);let T=this.getMoveFromBits(B,M[D+1],Z,this.cmovesbyslice[a],n,this.movesetorders[a]);v.push(T)}}let p=new de(i,s,new ve(f),m,v,u,b);return this.options.optimizeOrbits&&(p=p.optimize()),this.options.scrambleAmount!==0&&p.scramble(this.options.scrambleAmount),p}getScramble(e=0){let t=this.getOrbitsDef(!1);return t.toKTransformationData(t.getScrambleTransformation(e))}getMovesAsPerms(){return this.getOrbitsDef(!1).moveops.map(e=>e.toPerm())}showcanon(e){_e(this.getOrbitsDef(!1),e)}getsolved(){let e=[];for(let t=0;t<this.baseFaceCount;t++)for(let n=0;n<this.stickersperface;n++)e.push(t);return new q(e)}getOrientationRotation(e){let[t,[n,i,s]]=e[0],o=new $(0,n,-i,s),[r,[g,f,m]]=e[1],b=new $(0,g,-f,m),v=null,u=null,p=this.swizzler.unswizzle(t),a=this.swizzler.unswizzle(r);for(let y of this.geonormals)p===y[1]&&(v=y[0]),a===y[1]&&(u=y[0]);if(!v)throw new Error(`Could not find feature ${t}`);if(!u)throw new Error(`Could not find feature ${r}`);let h=v.pointrotation(o);return u.rotatepoint(h).unproject(o).pointrotation(b.unproject(o)).mul(h)}getInitial3DRotation(){let e=this.baseFaceCount,t=null;if(this.options.puzzleOrientation?t=this.options.puzzleOrientation:this.options.puzzleOrientations&&(t=this.options.puzzleOrientations[e]),t||(t=Dt()[e]),!t)throw new Error("No default orientation?");return this.getOrientationRotation(t)}generate2dmapping(e=800,t=500,n=10,i=!1,s=.92){e-=2*n,t-=2*n;function o(w,z){let R=w[1][0]-w[0][0],N=w[1][1]-w[0][1],S=2*Math.PI/z,A=Math.cos(S),K=Math.sin(S);for(let J=2;J<z;J++){let V=R*A+N*K;N=N*A-R*K,R=V,w.push([w[J-1][0]+R,w[J-1][1]+N])}}this.genperms();let f=this.getboundarygeometry().facenames[0][0].length,m=this.net;if(m===null)throw new Error("No net?");let b={},v=0,u=0,p=1,a=0;b[m[0][0]]=[[1,0],[0,0]],o(b[m[0][0]],f);for(let w of m){let z=w[0];if(!b[z])throw new Error("Bad edge description; first edge not connected.");for(let R=1;R<w.length;R++){let N=w[R];N===""||b[N]||(b[N]=[b[z][R%f],b[z][(R+f-1)%f]],o(b[N],f))}}for(let w in b){let z=b[w];for(let R of z)v=Math.min(v,R[0]),p=Math.max(p,R[0]),u=Math.min(u,R[1]),a=Math.max(a,R[1])}let h=Math.min(e/(p-v),t/(a-u)),P=.5*(e-h*(p+v)),M=.5*(t-h*(a+u)),y={},D=this.getboundarygeometry(),B={},G=[[h+P,M],[P,M]];B[m[0][0]]=G,o(B[m[0][0]],f),y[this.facenames[0][1]]=this.project2d(0,0,[new $(0,G[0][0],G[0][1],0),new $(0,G[1][0],G[1][1],0)]);let Z=[];Z[0]=0;for(let w of m){let z=w[0];if(!B[z])throw new Error("Bad edge description; first edge not connected.");let R=-1;for(let S=0;S<D.facenames.length;S++)if(z===D.facenames[S][1]){R=S;break}if(R<0)throw new Error(`Could not find first face name ${z}`);let N=D.facenames[R][0];for(let S=1;S<w.length;S++){let A=w[S];if(A===""||B[A])continue;B[A]=[B[z][S%f],B[z][(S+f-1)%f]],o(B[A],f);let K=Z[R],J=N[(K+S)%f].sum(N[(K+S+f-1)%f]).smul(.5),V=Be(D.edgenames,J),ie=D.edgenames[V][1],W=Ct(ie,this.facenames),ce=W[z===W[0]?1:0],te=-1;for(let H=0;H<D.facenames.length;H++)if(ce===D.facenames[H][1]){te=H;break}if(te<0)throw new Error("Could not find second face name");let ne=D.facenames[te][0];for(let H=0;H<ne.length;H++)if(ne[H].sum(ne[(H+1)%f]).smul(.5).dist(J)<=I){let x=B[z][(S+f-1)%f],O=B[z][S%f];Z[te]=H,y[ce]=this.project2d(te,H,[new $(0,O[0],O[1],0),new $(0,x[0],x[1],0)]);break}}}let T=0,Q=0,d=this.getInitial3DRotation();for(let w of this.faces){i&&(w=w.rotate(d));for(let z=0;z<w.length;z++)T=Math.max(T,Math.abs(w.get(z).b)),Q=Math.max(Q,Math.abs(w.get(z).c))}let L=Math.min(t/Q/2,(e-n)/T/4);return(w,z)=>{if(i){z=z.rotatepoint(d);let R=.5*n+.25*e,N=this.baseplanes[w].rotateplane(d).d<0?1:-1;return[n+e*.5+N*(R-z.b*L),n+t*.5+z.c*L]}else{let R=y[this.facenames[w][1]];return[n+s*z.dot(R[0])+R[2].b,n+t-s*z.dot(R[1])-R[2].c]}}}generatesvg(e=800,t=500,n=10,i=!1){let s=this.generate2dmapping(e,t,n,i);function o(v,u,p){return`<polygon id="${v}" class="sticker" style="fill: ${p}" points="${u.map(a=>`${a[0]} ${a[1]}`).join(" ")}"/>
`}let r=this.getsolved(),g=[],f=[];for(let v=0;v<this.baseFaceCount;v++)g[v]=this.colors[this.facenames[v][1]];for(let v=0;v<this.faces.length;v++){let u=this.faces[v],p=Math.floor(v/this.stickersperface),a=[];for(let h=0;h<u.length;h++)a.push(s(p,u.get(h)));f.push(a)}let m=[];for(let v=0;v<this.baseFaceCount;v++){m.push("<g>"),m.push(`<title>${this.facenames[v][1]}</title>
`);for(let u=0;u<this.stickersperface;u++){let p=v*this.stickersperface+u,a=this.facetocubie[p],h=this.facetoord[p],P=this.cubiesetnums[a],M=this.cubieordnums[a],y=this.graybyori(a)?"#808080":g[r.p[p]],D=`${this.cubiesetnames[P]}-l${M}-o${h}`;if(m.push(o(D,f[p],y)),this.duplicatedFaces[p])for(let B=1;B<this.duplicatedFaces[p];B++)D=`${this.cubiesetnames[P]}-l${M}-o${B}`,m.push(o(D,f[p],y))}m.push("</g>")}return`<svg id="svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 800 500">
<style type="text/css"><![CDATA[.sticker { stroke: #000000; stroke-width: 1px; }]]></style>
${m.join("")}</svg>`}get3d(e){let t=[],n=this.getInitial3DRotation(),i=[],s=.52*this.basefaces[0].get(0).len();for(let f=0;f<this.basefaces.length;f++){let m=this.basefaces[f].rotate(n),b=this.facenames[f][1];i.push({coords:Ue(m,s),name:b})}for(let f=0;f<this.faces.length;f++){let m=Math.floor(f/this.stickersperface),b=this.facetocubie[f],v=this.facetoord[f],u=this.cubiesetnums[b],p=this.cubieordnums[b],a=this.graybyori(b)?e?.darkIgnoredOrbits?"#222222":"#808080":this.colors[this.facenames[m][1]];e?.stickerColors&&(a=e.stickerColors[f]);let h=this.faces[f].rotate(n);t.push({coords:Ue(h,s),color:a,orbit:this.cubiesetnames[u],ord:p,ori:v,face:m});let P=h;if(this.duplicatedFaces[f]){let M=P.length/this.duplicatedFaces[f];for(let y=1;y<this.duplicatedFaces[f];y++){for(let D=0;D<M;D++)P=P.rotateforward();t.push({coords:Ue(P,s),color:a,orbit:this.cubiesetnames[u],ord:p,ori:y,face:m,isDup:!0})}}}let o=[];for(let f=0;f<this.movesetgeos.length;f++){let m=this.movesetgeos[f],b=this.movesetorders[f];for(let v of this.geonormals)m[0]===v[1]&&m[1]===v[2]&&(o.push({coordinates:Le(v[0].rotatepoint(n),1),quantumMove:new F(m[0]),order:b}),o.push({coordinates:Le(v[0].rotatepoint(n).smul(-1),1),quantumMove:new F(m[2]),order:b}))}let r=this.generate2dmapping(2880,2160,0,!1,1),g=function(){let f=n.invrot();return function(m,b){let v=new $(0,b[0]*s,-b[1]*s,b[2]*s);v=v.rotatepoint(f);let u=r(m,v);return u[0]/=2880,u[1]=1-u[1]/2160,u}}().bind(this);return{stickers:t,faces:i,axis:o,unswizzle:this.unswizzle.bind(this),notationMapper:this.notationMapper,textureMapper:{getuv:g}}}getGeoNormal(e){let t=this.getInitial3DRotation(),n=this.swizzler.unswizzle(e);for(let i of this.geonormals)if(n===i[1]){let s=Le(i[0].rotatepoint(t),1);return Math.abs(s[0])<I&&Math.abs(s[2])<I&&(s[0]=0,s[2]=1e-6),s}}getfaceindex(e){let t=this.stickersperface;return Math.floor(e/t)}textForTwizzleExplorer(){return`Faces ${this.baseplanerot.length}
Stickers per face ${this.stickersperface}
Short edge ${this.shortedge}
Cubies ${this.cubies.length}
Edge distance ${this.edgedistance}
Vertex distance ${this.vertexdistance}`}writeSchreierSims(e){let n=this.getOrbitsDef(!1).reassemblySize();e(`Reassembly size is ${n}`);let i=Te(this.getMovesAsPerms(),e),s=n/i;e(`Ratio is ${s}`)}},Ae=class{constructor(e,t){this.pg=e;this.orbitNames=t.orbitnames}orbitNames;lookupMove(e){let t=this.pg.parseMove(e);if(this.pg.parsedmovelist){let o=!1;for(let r of this.pg.parsedmovelist)r[1]===t[1]&&r[2]===t[2]&&r[3]===t[3]&&r[4]===t[4]&&(o=!0);if(!o)return null}let n=[t[2],t[3]];if(!t[4]){let o=this.pg.moveplanesets[t[1]].length;n=[o-t[3],o-t[2]]}let i=this.pg.getMoveFromBits(n,t[5],!t[4],this.pg.cmovesbyslice[t[1]],void 0,this.pg.movesetorders[t[1]]);return de.transformToKTransformationData(this.orbitNames,i)}remapKPuzzleDefinition(e){return Ve(e,this.pg.notationMapper)}};export{dt as a,$ as b,Te as c,Ft as d,Bt as e,Lt as f,kt as g,ze as h,at as i,Rt as j,ke as k,Ae as l};
//# sourceMappingURL=chunk-OC2PKXON.js.map