cubing 0.65.2 → 0.66.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/dist/bin/chunks/{chunk-Z5QOJAME.js → chunk-HS7R54XN.js} +2 -2
  2. package/dist/bin/order.js +1 -1
  3. package/dist/bin/puzzle-geometry-bin.js +1 -1
  4. package/dist/bin/scramble.js +1 -1
  5. package/dist/bin/svg.js +1 -1
  6. package/dist/lib/cubing/alg/index.d.ts +1 -1
  7. package/dist/lib/cubing/alg/index.js +1 -2
  8. package/dist/lib/cubing/bluetooth/index.d.ts +2 -2
  9. package/dist/lib/cubing/bluetooth/index.js +5 -6
  10. package/dist/lib/cubing/chunks/{big-puzzle-orientation-7WHPJCCO.js → big-puzzle-orientation-KJL4OFV2.js} +1 -2
  11. package/dist/lib/cubing/chunks/{chunk-2IA2R7XV.js → chunk-6R47S6MP.js} +24 -25
  12. package/dist/lib/cubing/chunks/{chunk-YSAQ6DRT.js → chunk-7LEVC3YR.js} +1 -2
  13. package/dist/lib/cubing/chunks/{chunk-7GUL3OBQ.js → chunk-BHVTDDUY.js} +0 -1
  14. package/dist/lib/cubing/chunks/{chunk-5FXQPBXH.js → chunk-IIJFVP3K.js} +6 -7
  15. package/dist/lib/cubing/chunks/{chunk-IRY6MBI2.js → chunk-KH2MQ7KY.js} +2 -3
  16. package/dist/lib/cubing/chunks/{chunk-BQPY6252.js → chunk-LBER75W4.js} +1 -2
  17. package/dist/lib/cubing/chunks/{chunk-MFKLAFPQ.js → chunk-NJ66FRKF.js} +3 -4
  18. package/dist/lib/cubing/chunks/{chunk-2BVL5OQE.js → chunk-QOLD6GH2.js} +5 -6
  19. package/dist/lib/cubing/chunks/{chunk-UP5VP7GL.js → chunk-QZK3M7IM.js} +0 -20
  20. package/dist/lib/cubing/chunks/chunk-RDKH6CDA.js +0 -0
  21. package/dist/lib/cubing/chunks/{chunk-6K433TB5.js → chunk-T5M3DY5P.js} +2 -3
  22. package/dist/lib/cubing/chunks/{chunk-MIHF623Z.js → chunk-UKAXYOG2.js} +2 -3
  23. package/dist/lib/cubing/chunks/{chunk-GHFBZYSV.js → chunk-YJH5LHFN.js} +0 -1
  24. package/dist/lib/cubing/chunks/{inside-N5WSMI7I.js → inside-UWSZBO4Y.js} +14 -15
  25. package/dist/lib/cubing/chunks/{puzzles-dynamic-3x3x3-FYXD7SIU.js → puzzles-dynamic-3x3x3-CMH2HHH5.js} +0 -1
  26. package/dist/lib/cubing/chunks/{puzzles-dynamic-4x4x4-AIGABOAR.js → puzzles-dynamic-4x4x4-UFAQS3QG.js} +0 -1
  27. package/dist/lib/cubing/chunks/{puzzles-dynamic-megaminx-2LVHIDL4.js → puzzles-dynamic-megaminx-EFR4GQFA.js} +0 -1
  28. package/dist/lib/cubing/chunks/{puzzles-dynamic-side-events-653A7JCM.js → puzzles-dynamic-side-events-KF3PEOJN.js} +0 -1
  29. package/dist/lib/cubing/chunks/{puzzles-dynamic-unofficial-2CY6GVZ4.js → puzzles-dynamic-unofficial-6BF3EWTI.js} +0 -1
  30. package/dist/lib/cubing/chunks/{search-dynamic-sgs-side-events-5EIXNDVI.js → search-dynamic-sgs-side-events-5GQDHSJR.js} +5 -6
  31. package/dist/lib/cubing/chunks/{search-dynamic-sgs-unofficial-Y7SIOVIX.js → search-dynamic-sgs-unofficial-YM23KVCN.js} +90 -78
  32. package/dist/lib/cubing/chunks/{search-dynamic-solve-3x3x3-B2L4IN34.js → search-dynamic-solve-3x3x3-6UMZH4WB.js} +3 -6
  33. package/dist/lib/cubing/chunks/{search-dynamic-solve-4x4x4-FRAX3IPQ.js → search-dynamic-solve-4x4x4-KNSBAM7Q.js} +14 -17
  34. package/dist/lib/cubing/chunks/{search-dynamic-solve-fto-TI4TFL6X.js → search-dynamic-solve-fto-CSXJYISF.js} +200 -90
  35. package/dist/lib/cubing/chunks/{search-dynamic-solve-kilominx-UKFT6I42.js → search-dynamic-solve-kilominx-EHAUQJXS.js} +105 -113
  36. package/dist/lib/cubing/chunks/{search-dynamic-solve-master_tetraminx-GIS7T5B7.js → search-dynamic-solve-master_tetraminx-ZQ25QK7E.js} +99 -100
  37. package/dist/lib/cubing/chunks/search-worker-entry.js +2 -3
  38. package/dist/lib/cubing/chunks/{twips-UCWWA2WI.js → twips-IMF5RNH5.js} +3 -4
  39. package/dist/lib/cubing/chunks/{twips_wasm_bg-TJNYGA2C-AP2O4LGG.js → twips_wasm_bg-TJNYGA2C-4JIZWC6Q.js} +1 -2
  40. package/dist/lib/cubing/chunks/{twisty-dynamic-3d-O5TGOSAO.js → twisty-dynamic-3d-HSYJR5CM.js} +5 -6
  41. package/dist/lib/cubing/{index-COSxNAgV.d.ts → index-lAUL_nRN.d.ts} +1 -1
  42. package/dist/lib/cubing/{index-BQdS3h4z.d.ts → index-nWspzjVK.d.ts} +43 -43
  43. package/dist/lib/cubing/kpuzzle/index.d.ts +1 -1
  44. package/dist/lib/cubing/kpuzzle/index.js +2 -3
  45. package/dist/lib/cubing/notation/index.d.ts +1 -1
  46. package/dist/lib/cubing/notation/index.js +4 -5
  47. package/dist/lib/cubing/{outside-BRtF0DA2.d.ts → outside-CD19aDjE.d.ts} +1 -1
  48. package/dist/lib/cubing/protocol/index.d.ts +1 -1
  49. package/dist/lib/cubing/protocol/index.js +4 -5
  50. package/dist/lib/cubing/puzzle-geometry/index.d.ts +1 -1
  51. package/dist/lib/cubing/puzzle-geometry/index.js +375 -375
  52. package/dist/lib/cubing/puzzles/index.d.ts +1 -1
  53. package/dist/lib/cubing/puzzles/index.js +4 -5
  54. package/dist/lib/cubing/scramble/index.d.ts +1 -1
  55. package/dist/lib/cubing/scramble/index.js +8 -9
  56. package/dist/lib/cubing/search/index.d.ts +1 -1
  57. package/dist/lib/cubing/search/index.js +7 -8
  58. package/dist/lib/cubing/stream/index.d.ts +1 -1
  59. package/dist/lib/cubing/stream/index.js +1 -2
  60. package/dist/lib/cubing/twisty/index.d.ts +1 -1
  61. package/dist/lib/cubing/twisty/index.js +6 -7
  62. package/package.json +1 -1
  63. package/dist/lib/cubing/alg/index.js.map +0 -7
  64. package/dist/lib/cubing/bluetooth/index.js.map +0 -7
  65. package/dist/lib/cubing/chunks/big-puzzle-orientation-7WHPJCCO.js.map +0 -7
  66. package/dist/lib/cubing/chunks/chunk-2BVL5OQE.js.map +0 -7
  67. package/dist/lib/cubing/chunks/chunk-2IA2R7XV.js.map +0 -7
  68. package/dist/lib/cubing/chunks/chunk-5FXQPBXH.js.map +0 -7
  69. package/dist/lib/cubing/chunks/chunk-6K433TB5.js.map +0 -7
  70. package/dist/lib/cubing/chunks/chunk-7GUL3OBQ.js.map +0 -7
  71. package/dist/lib/cubing/chunks/chunk-BQPY6252.js.map +0 -7
  72. package/dist/lib/cubing/chunks/chunk-GHFBZYSV.js.map +0 -7
  73. package/dist/lib/cubing/chunks/chunk-IRY6MBI2.js.map +0 -7
  74. package/dist/lib/cubing/chunks/chunk-MFKLAFPQ.js.map +0 -7
  75. package/dist/lib/cubing/chunks/chunk-MIHF623Z.js.map +0 -7
  76. package/dist/lib/cubing/chunks/chunk-NAPITA3L.js +0 -1
  77. package/dist/lib/cubing/chunks/chunk-NAPITA3L.js.map +0 -7
  78. package/dist/lib/cubing/chunks/chunk-UP5VP7GL.js.map +0 -7
  79. package/dist/lib/cubing/chunks/chunk-YSAQ6DRT.js.map +0 -7
  80. package/dist/lib/cubing/chunks/inside-N5WSMI7I.js.map +0 -7
  81. package/dist/lib/cubing/chunks/puzzles-dynamic-3x3x3-FYXD7SIU.js.map +0 -7
  82. package/dist/lib/cubing/chunks/puzzles-dynamic-4x4x4-AIGABOAR.js.map +0 -7
  83. package/dist/lib/cubing/chunks/puzzles-dynamic-megaminx-2LVHIDL4.js.map +0 -7
  84. package/dist/lib/cubing/chunks/puzzles-dynamic-side-events-653A7JCM.js.map +0 -7
  85. package/dist/lib/cubing/chunks/puzzles-dynamic-unofficial-2CY6GVZ4.js.map +0 -7
  86. package/dist/lib/cubing/chunks/search-dynamic-sgs-side-events-5EIXNDVI.js.map +0 -7
  87. package/dist/lib/cubing/chunks/search-dynamic-sgs-unofficial-Y7SIOVIX.js.map +0 -7
  88. package/dist/lib/cubing/chunks/search-dynamic-solve-3x3x3-B2L4IN34.js.map +0 -7
  89. package/dist/lib/cubing/chunks/search-dynamic-solve-4x4x4-FRAX3IPQ.js.map +0 -7
  90. package/dist/lib/cubing/chunks/search-dynamic-solve-fto-TI4TFL6X.js.map +0 -7
  91. package/dist/lib/cubing/chunks/search-dynamic-solve-kilominx-UKFT6I42.js.map +0 -7
  92. package/dist/lib/cubing/chunks/search-dynamic-solve-master_tetraminx-GIS7T5B7.js.map +0 -7
  93. package/dist/lib/cubing/chunks/search-worker-entry.js.map +0 -7
  94. package/dist/lib/cubing/chunks/twips-UCWWA2WI.js.map +0 -7
  95. package/dist/lib/cubing/chunks/twips_wasm_bg-TJNYGA2C-AP2O4LGG.js.map +0 -7
  96. package/dist/lib/cubing/chunks/twisty-dynamic-3d-O5TGOSAO.js.map +0 -7
  97. package/dist/lib/cubing/kpuzzle/index.js.map +0 -7
  98. package/dist/lib/cubing/notation/index.js.map +0 -7
  99. package/dist/lib/cubing/protocol/index.js.map +0 -7
  100. package/dist/lib/cubing/puzzle-geometry/index.js.map +0 -7
  101. package/dist/lib/cubing/puzzles/index.js.map +0 -7
  102. package/dist/lib/cubing/scramble/index.js.map +0 -7
  103. package/dist/lib/cubing/search/index.js.map +0 -7
  104. package/dist/lib/cubing/stream/index.js.map +0 -7
  105. package/dist/lib/cubing/twisty/index.js.map +0 -7
  106. /package/dist/bin/chunks/{chunk-Z5QOJAME.js.map → chunk-HS7R54XN.js.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Move,
3
3
  QuantumMove
4
- } from "../chunks/chunk-UP5VP7GL.js";
4
+ } from "../chunks/chunk-QZK3M7IM.js";
5
5
 
6
6
  // src/cubing/puzzle-geometry/colors.ts
7
7
  var PGColors = {
@@ -690,13 +690,13 @@ function remapKPuzzleDefinition(internalDefinition, notationMapper) {
690
690
  if (!externalPrefix) {
691
691
  continue;
692
692
  }
693
- const externalMoveName = externalPrefix + suffix;
694
- if (!externalMoveName) {
693
+ const externalMoveName2 = externalPrefix + suffix;
694
+ if (!externalMoveName2) {
695
695
  throw new Error(
696
696
  `Missing external move name for: ${internalMoveName.toString()}`
697
697
  );
698
698
  }
699
- externalDefinition.moves[externalMoveName.toString()] = transformationData;
699
+ externalDefinition.moves[externalMoveName2.toString()] = transformationData;
700
700
  }
701
701
  return externalDefinition;
702
702
  }
@@ -755,39 +755,25 @@ var PuzzleGeometryFullOptions = class {
755
755
  }
756
756
  };
757
757
 
758
- // src/cubing/puzzle-geometry/Perm.ts
758
+ // src/cubing/puzzle-geometry/Permutation.ts
759
759
  var zeroCache = [];
760
- var iotaCache = [];
760
+ var rangeCache = [];
761
761
  function zeros(n) {
762
- if (!zeroCache[n]) {
763
- const c = Array(n);
764
- for (let i = 0; i < n; i++) {
765
- c[i] = 0;
766
- }
767
- zeroCache[n] = c;
768
- }
769
- return zeroCache[n];
762
+ return zeroCache[n] ??= new Array(n).fill(0);
770
763
  }
771
- function iota(n) {
772
- if (!iotaCache[n]) {
773
- const c = Array(n);
774
- for (let i = 0; i < n; i++) {
775
- c[i] = i;
776
- }
777
- iotaCache[n] = c;
778
- }
779
- return iotaCache[n];
764
+ function range(n) {
765
+ return rangeCache[n] ??= zeros(n).map((_, i) => i);
780
766
  }
781
767
  function identity(n) {
782
- return new Perm(iota(n));
768
+ return new Permutation(range(n));
783
769
  }
784
- function factorial(a) {
785
- let r = BigInt(1);
786
- while (a > 1) {
787
- r *= BigInt(a);
788
- a--;
770
+ function factorial(n) {
771
+ let output = BigInt(1);
772
+ while (n > 1) {
773
+ output *= BigInt(n);
774
+ n--;
789
775
  }
790
- return r;
776
+ return output;
791
777
  }
792
778
  function gcd(a, b) {
793
779
  if (a > b) {
@@ -805,56 +791,56 @@ function gcd(a, b) {
805
791
  function lcm(a, b) {
806
792
  return a / gcd(a, b) * b;
807
793
  }
808
- var Perm = class _Perm {
809
- n;
810
- // length
811
- p;
794
+ var Permutation = class _Permutation {
795
+ permutation;
812
796
  // The permutation itself
813
797
  constructor(a) {
814
- this.n = a.length;
815
- this.p = a;
798
+ this.permutation = a;
799
+ }
800
+ get length() {
801
+ return this.permutation.length;
816
802
  }
817
803
  toString() {
818
- return `Perm[${this.p.join(" ")}]`;
804
+ return `Perm[${this.permutation.join(" ")}]`;
819
805
  }
820
- mul(p2) {
821
- const c = Array(this.n);
822
- for (let i = 0; i < this.n; i++) {
823
- c[i] = p2.p[this.p[i]];
806
+ multiply(p2) {
807
+ const c = Array(this.length);
808
+ for (let i = 0; i < this.length; i++) {
809
+ c[i] = p2.permutation[this.permutation[i]];
824
810
  }
825
- return new _Perm(c);
811
+ return new _Permutation(c);
826
812
  }
827
- rmul(p2) {
828
- const c = Array(this.n);
829
- for (let i = 0; i < this.n; i++) {
830
- c[i] = this.p[p2.p[i]];
813
+ rightMultiply(p2) {
814
+ const c = Array(this.length);
815
+ for (let i = 0; i < this.length; i++) {
816
+ c[i] = this.permutation[p2.permutation[i]];
831
817
  }
832
- return new _Perm(c);
818
+ return new _Permutation(c);
833
819
  }
834
- inv() {
835
- const c = Array(this.n);
836
- for (let i = 0; i < this.n; i++) {
837
- c[this.p[i]] = i;
820
+ invert() {
821
+ const c = Array(this.length);
822
+ for (let i = 0; i < this.length; i++) {
823
+ c[this.permutation[i]] = i;
838
824
  }
839
- return new _Perm(c);
825
+ return new _Permutation(c);
840
826
  }
841
- compareTo(p2) {
842
- for (let i = 0; i < this.n; i++) {
843
- if (this.p[i] !== p2.p[i]) {
844
- return this.p[i] - p2.p[i];
827
+ compare(p2) {
828
+ for (let i = 0; i < this.length; i++) {
829
+ if (this.permutation[i] !== p2.permutation[i]) {
830
+ return this.permutation[i] - p2.permutation[i];
845
831
  }
846
832
  }
847
833
  return 0;
848
834
  }
849
835
  toGap() {
850
836
  const cyc = [];
851
- const seen = new Array(this.n);
852
- for (let i = 0; i < this.p.length; i++) {
853
- if (seen[i] || this.p[i] === i) {
837
+ const seen = new Array(this.length);
838
+ for (let i = 0; i < this.permutation.length; i++) {
839
+ if (seen[i] || this.permutation[i] === i) {
854
840
  continue;
855
841
  }
856
842
  const incyc = [];
857
- for (let j = this.p[i]; !seen[j]; j = this.p[j]) {
843
+ for (let j = this.permutation[i]; !seen[j]; j = this.permutation[j]) {
858
844
  incyc.push(1 + j);
859
845
  seen[j] = true;
860
846
  }
@@ -864,13 +850,13 @@ var Perm = class _Perm {
864
850
  }
865
851
  toMathematica() {
866
852
  const cyc = [];
867
- const seen = new Array(this.n);
868
- for (let i = 0; i < this.p.length; i++) {
869
- if (seen[i] || this.p[i] === i) {
853
+ const seen = new Array(this.length);
854
+ for (let i = 0; i < this.permutation.length; i++) {
855
+ if (seen[i] || this.permutation[i] === i) {
870
856
  continue;
871
857
  }
872
858
  const incyc = [];
873
- for (let j = this.p[i]; !seen[j]; j = this.p[j]) {
859
+ for (let j = this.permutation[i]; !seen[j]; j = this.permutation[j]) {
874
860
  incyc.push(1 + j);
875
861
  seen[j] = true;
876
862
  }
@@ -879,72 +865,72 @@ var Perm = class _Perm {
879
865
  return `Cycles[{${cyc.join(",")}}]`;
880
866
  }
881
867
  order() {
882
- let r = 1;
883
- const seen = new Array(this.n);
884
- for (let i = 0; i < this.p.length; i++) {
885
- if (seen[i] || this.p[i] === i) {
868
+ let output = 1;
869
+ const seen = new Array(this.length);
870
+ for (let i = 0; i < this.permutation.length; i++) {
871
+ if (seen[i] || this.permutation[i] === i) {
886
872
  continue;
887
873
  }
888
- let cs = 0;
889
- for (let j = i; !seen[j]; j = this.p[j]) {
890
- cs++;
874
+ let cycleLength = 0;
875
+ for (let j = i; !seen[j]; j = this.permutation[j]) {
876
+ cycleLength++;
891
877
  seen[j] = true;
892
878
  }
893
- r = lcm(r, cs);
879
+ output = lcm(output, cycleLength);
894
880
  }
895
- return r;
881
+ return output;
896
882
  }
897
883
  };
898
884
 
899
- // src/cubing/puzzle-geometry/PermOriSet.ts
885
+ // src/cubing/puzzle-geometry/PGOrbit.ts
900
886
  var PGOrbitDef = class {
901
- size;
902
- mod;
887
+ numPieces;
888
+ numOrientations;
903
889
  constructor(size, mod) {
904
- this.size = size;
905
- this.mod = mod;
890
+ this.numPieces = size;
891
+ this.numOrientations = mod;
906
892
  }
907
893
  reassemblySize() {
908
- return factorial(this.size) * BigInt(this.mod) ** BigInt(this.size);
894
+ return factorial(this.numPieces) * BigInt(this.numOrientations) ** BigInt(this.numPieces);
909
895
  }
910
896
  };
911
897
  var lastGlobalDefinitionCounter = 0;
912
- function externalName(mapper, moveString) {
913
- const mv = Move.fromString(moveString);
914
- const mv2 = mapper.notationToExternal(mv);
915
- if (mv2 === null || mv === mv2) {
898
+ function externalMoveName(mapper, moveString) {
899
+ const internalMove = Move.fromString(moveString);
900
+ const externalMove = mapper.notationToExternal(internalMove);
901
+ if (externalMove === null || internalMove === externalMove) {
916
902
  return moveString;
917
903
  }
918
- return mv2.toString();
904
+ return externalMove.toString();
919
905
  }
920
906
  var PGOrbitsDef = class _PGOrbitsDef {
921
- orbitnames;
922
- orbitdefs;
907
+ orbitNames;
908
+ orbitDefs;
923
909
  solved;
924
- movenames;
925
- moveops;
910
+ moveNames;
911
+ moveOps;
926
912
  isRotation;
927
- forcenames;
928
- constructor(orbitnames, orbitdefs, solved, movenames, moveops, isRotation, forcenames) {
929
- this.orbitnames = orbitnames;
930
- this.orbitdefs = orbitdefs;
913
+ forceNames;
914
+ constructor(orbitNames, orbitDefs, solved, moveNames, moveOps, isRotation, forceNames) {
915
+ this.orbitNames = orbitNames;
916
+ this.orbitDefs = orbitDefs;
931
917
  this.solved = solved;
932
- this.movenames = movenames;
933
- this.moveops = moveops;
918
+ this.moveNames = moveNames;
919
+ this.moveOps = moveOps;
934
920
  this.isRotation = isRotation;
935
- this.forcenames = forcenames;
921
+ this.forceNames = forceNames;
936
922
  }
937
923
  toKTransformationData(t) {
938
924
  const ktransformationData = {};
939
- for (let i = 0; i < this.orbitnames.length; i++) {
940
- ktransformationData[this.orbitnames[i]] = t.orbits[i].toKTransformationOrbitData();
925
+ for (let i = 0; i < this.orbitNames.length; i++) {
926
+ ktransformationData[this.orbitNames[i]] = t.orbits[i].toKTransformationOrbitData();
941
927
  }
942
928
  return ktransformationData;
943
929
  }
944
930
  toKPatternData(t) {
945
931
  const kpatternData = {};
946
- for (let i = 0; i < this.orbitnames.length; i++) {
947
- kpatternData[this.orbitnames[i]] = t.orbits[i].toKPatternOrbitData();
932
+ for (let i = 0; i < this.orbitNames.length; i++) {
933
+ kpatternData[this.orbitNames[i]] = t.orbits[i].toKPatternOrbitData();
948
934
  }
949
935
  return kpatternData;
950
936
  }
@@ -957,54 +943,54 @@ var PGOrbitsDef = class _PGOrbitsDef {
957
943
  return mp;
958
944
  }
959
945
  describeSet(s, r, mapper) {
960
- const n = this.orbitdefs[s].size;
961
- const m = new Array(n);
962
- for (let i = 0; i < n; i++) {
963
- m[i] = [];
946
+ const { numPieces } = this.orbitDefs[s];
947
+ const moveNames = new Array(numPieces);
948
+ for (let i = 0; i < numPieces; i++) {
949
+ moveNames[i] = [];
964
950
  }
965
- for (let i = 0; i < this.movenames.length; i++) {
951
+ for (let i = 0; i < this.moveNames.length; i++) {
966
952
  if (this.isRotation[i]) {
967
953
  continue;
968
954
  }
969
- let mvname = this.movenames[i];
970
- if (!this.forcenames[i]) {
971
- mvname = externalName(mapper, mvname);
972
- if (mvname[mvname.length - 1] === "'") {
973
- mvname = mvname.substring(0, mvname.length - 1);
955
+ let moveName = this.moveNames[i];
956
+ if (!this.forceNames[i]) {
957
+ moveName = externalMoveName(mapper, moveName);
958
+ if (moveName[moveName.length - 1] === "'") {
959
+ moveName = moveName.substring(0, moveName.length - 1);
974
960
  }
975
961
  }
976
- const pd = this.moveops[i].orbits[s];
977
- for (let j = 0; j < n; j++) {
978
- if (pd.perm[j] !== j || pd.ori[j] !== 0) {
979
- m[j].push(mvname);
962
+ const pd = this.moveOps[i].orbits[s];
963
+ for (let j = 0; j < numPieces; j++) {
964
+ if (pd.permutation[j] !== j || pd.orientationDelta[j] !== 0) {
965
+ moveNames[j].push(moveName);
980
966
  }
981
967
  }
982
968
  }
983
- for (let j = 0; j < n; j++) {
984
- r.push(`# ${j + 1} ${m[j].join(" ")}`);
969
+ for (let j = 0; j < numPieces; j++) {
970
+ r.push(`# ${j + 1} ${moveNames[j].join(" ")}`);
985
971
  }
986
972
  }
987
973
  toKsolve(name, mapper = new NullMapper()) {
988
974
  const result = [];
989
975
  result.push(`Name ${name}`);
990
976
  result.push("");
991
- for (let i = 0; i < this.orbitnames.length; i++) {
977
+ for (let i = 0; i < this.orbitNames.length; i++) {
992
978
  result.push(
993
- `Set ${this.orbitnames[i]} ${this.orbitdefs[i].size} ${this.orbitdefs[i].mod}`
979
+ `Set ${this.orbitNames[i]} ${this.orbitDefs[i].numPieces} ${this.orbitDefs[i].numOrientations}`
994
980
  );
995
981
  this.describeSet(i, result, mapper);
996
982
  }
997
983
  result.push("");
998
984
  result.push("Solved");
999
- for (let i = 0; i < this.orbitnames.length; i++) {
1000
- this.solved.orbits[i].renumberPieces().appendDefinition(result, this.orbitnames[i], false, false);
985
+ for (let i = 0; i < this.orbitNames.length; i++) {
986
+ this.solved.orbits[i].renumberPieces().appendDefinition(result, this.orbitNames[i], false, false);
1001
987
  }
1002
988
  result.push("End");
1003
- for (let i = 0; i < this.movenames.length; i++) {
989
+ for (let i = 0; i < this.moveNames.length; i++) {
1004
990
  result.push("");
1005
- let name2 = this.movenames[i];
1006
- if (!this.forcenames[i]) {
1007
- name2 = externalName(mapper, this.movenames[i]);
991
+ let name2 = this.moveNames[i];
992
+ if (!this.forceNames[i]) {
993
+ name2 = externalMoveName(mapper, this.moveNames[i]);
1008
994
  }
1009
995
  let doinv = false;
1010
996
  if (name2[name2.length - 1] === "'") {
@@ -1012,13 +998,13 @@ var PGOrbitsDef = class _PGOrbitsDef {
1012
998
  name2 = name2.substring(0, name2.length - 1);
1013
999
  }
1014
1000
  result.push(`Move ${name2}`);
1015
- for (let j = 0; j < this.orbitnames.length; j++) {
1001
+ for (let j = 0; j < this.orbitNames.length; j++) {
1016
1002
  if (doinv) {
1017
- this.moveops[i].orbits[j].inv().appendDefinition(result, this.orbitnames[j], true);
1003
+ this.moveOps[i].orbits[j].invert().appendDefinition(result, this.orbitNames[j], true);
1018
1004
  } else {
1019
- this.moveops[i].orbits[j].appendDefinition(
1005
+ this.moveOps[i].orbits[j].appendDefinition(
1020
1006
  result,
1021
- this.orbitnames[j],
1007
+ this.orbitNames[j],
1022
1008
  true
1023
1009
  );
1024
1010
  }
@@ -1031,22 +1017,22 @@ var PGOrbitsDef = class _PGOrbitsDef {
1031
1017
  toKPuzzleDefinition(includemoves) {
1032
1018
  const orbits = [];
1033
1019
  const defaultPatternData = {};
1034
- for (let i = 0; i < this.orbitnames.length; i++) {
1020
+ for (let i = 0; i < this.orbitNames.length; i++) {
1035
1021
  orbits.push({
1036
- orbitName: this.orbitnames[i],
1037
- numPieces: this.orbitdefs[i].size,
1038
- numOrientations: this.orbitdefs[i].mod
1022
+ orbitName: this.orbitNames[i],
1023
+ numPieces: this.orbitDefs[i].numPieces,
1024
+ numOrientations: this.orbitDefs[i].numOrientations
1039
1025
  });
1040
1026
  const defaultPatternFrom = this.solved.orbits[i].toKTransformationOrbitData();
1041
- defaultPatternData[this.orbitnames[i]] = {
1027
+ defaultPatternData[this.orbitNames[i]] = {
1042
1028
  pieces: defaultPatternFrom.permutation,
1043
1029
  orientation: defaultPatternFrom.orientationDelta
1044
1030
  };
1045
1031
  }
1046
1032
  const moves = {};
1047
1033
  if (includemoves) {
1048
- for (let i = 0; i < this.movenames.length; i++) {
1049
- moves[this.movenames[i]] = this.toKTransformationData(this.moveops[i]);
1034
+ for (let i = 0; i < this.moveNames.length; i++) {
1035
+ moves[this.moveNames[i]] = this.toKTransformationData(this.moveOps[i]);
1050
1036
  }
1051
1037
  }
1052
1038
  return {
@@ -1057,127 +1043,134 @@ var PGOrbitsDef = class _PGOrbitsDef {
1057
1043
  };
1058
1044
  }
1059
1045
  optimize() {
1060
- const neworbitnames = [];
1061
- const neworbitdefs = [];
1062
- const newsolved = [];
1063
- const newmoveops = [];
1064
- for (let j = 0; j < this.moveops.length; j++) {
1065
- newmoveops.push([]);
1066
- }
1067
- for (let i = 0; i < this.orbitdefs.length; i++) {
1068
- const om = this.orbitdefs[i].mod;
1069
- const n = this.orbitdefs[i].size;
1070
- const du = new DisjointUnion(n);
1071
- const changed = new Array(this.orbitdefs[i].size);
1072
- for (let k = 0; k < n; k++) {
1046
+ const newOrbitNames = [];
1047
+ const newOrbitDefs = [];
1048
+ const newSolved = [];
1049
+ const newMoveOps = this.moveOps.map(() => []);
1050
+ for (let j = 0; j < this.moveOps.length; j++) {
1051
+ newMoveOps.push([]);
1052
+ }
1053
+ for (let i = 0; i < this.orbitDefs.length; i++) {
1054
+ const { numPieces, numOrientations } = this.orbitDefs[i];
1055
+ const disjointUion = new DisjointUnion(numPieces);
1056
+ const changed = new Array(this.orbitDefs[i].numPieces);
1057
+ for (let k = 0; k < numPieces; k++) {
1073
1058
  changed[k] = false;
1074
1059
  }
1075
- for (let j = 0; j < this.moveops.length; j++) {
1076
- for (let k = 0; k < n; k++) {
1077
- if (this.moveops[j].orbits[i].perm[k] !== k || this.moveops[j].orbits[i].ori[k] !== 0) {
1060
+ for (let j = 0; j < this.moveOps.length; j++) {
1061
+ for (let k = 0; k < numPieces; k++) {
1062
+ if (this.moveOps[j].orbits[i].permutation[k] !== k || this.moveOps[j].orbits[i].orientationDelta[k] !== 0) {
1078
1063
  if (!this.isRotation[j]) {
1079
1064
  changed[k] = true;
1080
1065
  }
1081
- du.union(k, this.moveops[j].orbits[i].perm[k]);
1066
+ disjointUion.union(k, this.moveOps[j].orbits[i].permutation[k]);
1082
1067
  }
1083
1068
  }
1084
1069
  }
1085
- let keepori = true;
1086
- if (om > 1) {
1087
- keepori = false;
1088
- const duo = new DisjointUnion(this.orbitdefs[i].size * om);
1089
- for (let j = 0; j < this.moveops.length; j++) {
1090
- for (let k = 0; k < n; k++) {
1091
- if (this.moveops[j].orbits[i].perm[k] !== k || this.moveops[j].orbits[i].ori[k] !== 0) {
1092
- for (let o = 0; o < om; o++) {
1093
- duo.union(
1094
- k * om + o,
1095
- this.moveops[j].orbits[i].perm[k] * om + (o + this.moveops[j].orbits[i].ori[k]) % om
1070
+ let keepOrientation = true;
1071
+ if (numOrientations > 1) {
1072
+ keepOrientation = false;
1073
+ const disjointUnion = new DisjointUnion(
1074
+ this.orbitDefs[i].numPieces * numOrientations
1075
+ );
1076
+ for (let j = 0; j < this.moveOps.length; j++) {
1077
+ for (let k = 0; k < numPieces; k++) {
1078
+ if (this.moveOps[j].orbits[i].permutation[k] !== k || this.moveOps[j].orbits[i].orientationDelta[k] !== 0) {
1079
+ for (let o = 0; o < numOrientations; o++) {
1080
+ disjointUnion.union(
1081
+ k * numOrientations + o,
1082
+ this.moveOps[j].orbits[i].permutation[k] * numOrientations + (o + this.moveOps[j].orbits[i].orientationDelta[k]) % numOrientations
1096
1083
  );
1097
1084
  }
1098
1085
  }
1099
1086
  }
1100
1087
  }
1101
- for (let j = 0; !keepori && j < n; j++) {
1102
- for (let o = 1; o < om; o++) {
1103
- if (duo.find(j * om) === duo.find(j * om + o)) {
1104
- keepori = true;
1088
+ for (let j = 0; !keepOrientation && j < numPieces; j++) {
1089
+ for (let o = 1; o < numOrientations; o++) {
1090
+ if (disjointUnion.find(j * numOrientations) === disjointUnion.find(j * numOrientations + o)) {
1091
+ keepOrientation = true;
1105
1092
  }
1106
1093
  }
1107
1094
  }
1108
- for (let j = 0; !keepori && j < n; j++) {
1095
+ for (let j = 0; !keepOrientation && j < numPieces; j++) {
1109
1096
  for (let k = 0; k < j; k++) {
1110
- if (this.solved.orbits[i].perm[j] === this.solved.orbits[i].perm[k]) {
1111
- keepori = true;
1097
+ if (this.solved.orbits[i].permutation[j] === this.solved.orbits[i].permutation[k]) {
1098
+ keepOrientation = true;
1112
1099
  }
1113
1100
  }
1114
1101
  }
1115
1102
  }
1116
- let nontriv = -1;
1103
+ let nontrivial = -1;
1117
1104
  let multiple = false;
1118
- for (let j = 0; j < this.orbitdefs[i].size; j++) {
1105
+ for (let j = 0; j < this.orbitDefs[i].numPieces; j++) {
1119
1106
  if (changed[j]) {
1120
- const h = du.find(j);
1121
- if (nontriv < 0) {
1122
- nontriv = h;
1123
- } else if (nontriv !== h) {
1107
+ const h = disjointUion.find(j);
1108
+ if (nontrivial < 0) {
1109
+ nontrivial = h;
1110
+ } else if (nontrivial !== h) {
1124
1111
  multiple = true;
1125
1112
  }
1126
1113
  }
1127
1114
  }
1128
- for (let j = 0; j < this.orbitdefs[i].size; j++) {
1115
+ for (let j = 0; j < this.orbitDefs[i].numPieces; j++) {
1129
1116
  if (!changed[j]) {
1130
1117
  continue;
1131
1118
  }
1132
- const h = du.find(j);
1119
+ const h = disjointUion.find(j);
1133
1120
  if (h !== j) {
1134
1121
  continue;
1135
1122
  }
1136
1123
  const no = [];
1137
1124
  const on = [];
1138
1125
  let nv = 0;
1139
- for (let k = 0; k < this.orbitdefs[i].size; k++) {
1140
- if (du.find(k) === j) {
1126
+ for (let k = 0; k < this.orbitDefs[i].numPieces; k++) {
1127
+ if (disjointUion.find(k) === j) {
1141
1128
  no[nv] = k;
1142
1129
  on[k] = nv;
1143
1130
  nv++;
1144
1131
  }
1145
1132
  }
1146
1133
  if (multiple) {
1147
- neworbitnames.push(`${this.orbitnames[i]}_p${j}`);
1134
+ newOrbitNames.push(`${this.orbitNames[i]}_p${j}`);
1148
1135
  } else {
1149
- neworbitnames.push(this.orbitnames[i]);
1136
+ newOrbitNames.push(this.orbitNames[i]);
1150
1137
  }
1151
- if (keepori) {
1152
- neworbitdefs.push(new PGOrbitDef(nv, this.orbitdefs[i].mod));
1153
- newsolved.push(this.solved.orbits[i].remapVS(no, nv));
1154
- for (let k = 0; k < this.moveops.length; k++) {
1155
- newmoveops[k].push(this.moveops[k].orbits[i].remap(no, on, nv));
1138
+ if (keepOrientation) {
1139
+ newOrbitDefs.push(
1140
+ new PGOrbitDef(nv, this.orbitDefs[i].numOrientations)
1141
+ );
1142
+ newSolved.push(this.solved.orbits[i].remapVS(no, nv));
1143
+ for (let k = 0; k < this.moveOps.length; k++) {
1144
+ newMoveOps[k].push(this.moveOps[k].orbits[i].remap(no, on, nv));
1156
1145
  }
1157
1146
  } else {
1158
- neworbitdefs.push(new PGOrbitDef(nv, 1));
1159
- newsolved.push(this.solved.orbits[i].remapVS(no, nv).killOri());
1160
- for (let k = 0; k < this.moveops.length; k++) {
1161
- newmoveops[k].push(
1162
- this.moveops[k].orbits[i].remap(no, on, nv).killOri()
1147
+ newOrbitDefs.push(new PGOrbitDef(nv, 1));
1148
+ newSolved.push(
1149
+ this.solved.orbits[i].remapVS(no, nv).forgetOrientations()
1150
+ );
1151
+ for (let k = 0; k < this.moveOps.length; k++) {
1152
+ newMoveOps[k].push(
1153
+ this.moveOps[k].orbits[i].remap(no, on, nv).forgetOrientations()
1163
1154
  );
1164
1155
  }
1165
1156
  }
1166
1157
  }
1167
1158
  }
1168
1159
  return new _PGOrbitsDef(
1169
- neworbitnames,
1170
- neworbitdefs,
1171
- new VisibleState(newsolved),
1172
- this.movenames,
1173
- newmoveops.map((_) => new PGTransform(_)),
1160
+ newOrbitNames,
1161
+ newOrbitDefs,
1162
+ new VisibleState(newSolved),
1163
+ this.moveNames,
1164
+ newMoveOps.map((_) => new PGTransform(_)),
1174
1165
  this.isRotation,
1175
- this.forcenames
1166
+ this.forceNames
1176
1167
  );
1177
1168
  }
1178
1169
  // replace the solved state with a new scrambled state.
1179
1170
  scramble(n) {
1180
- this.solved = this.solved.mul(this.getScrambleTransformation(n));
1171
+ this.solved = this.solved.applyTransformation(
1172
+ this.getScrambleTransformation(n)
1173
+ );
1181
1174
  }
1182
1175
  // generate a new "random" position based on an entropy pool
1183
1176
  // this should be significantly faster and more random than just
@@ -1187,8 +1180,8 @@ var PGOrbitsDef = class _PGOrbitsDef {
1187
1180
  n = 100;
1188
1181
  }
1189
1182
  const pool = [];
1190
- for (let i = 0; i < this.moveops.length; i++) {
1191
- pool[i] = this.moveops[i];
1183
+ for (let i = 0; i < this.moveOps.length; i++) {
1184
+ pool[i] = this.moveOps[i];
1192
1185
  }
1193
1186
  for (let i = 0; i < pool.length; i++) {
1194
1187
  const j = Math.floor(Math.random() * pool.length);
@@ -1202,167 +1195,167 @@ var PGOrbitsDef = class _PGOrbitsDef {
1202
1195
  for (let i = 0; i < n; i++) {
1203
1196
  const ri = Math.floor(Math.random() * pool.length);
1204
1197
  const rj = Math.floor(Math.random() * pool.length);
1205
- const rm = Math.floor(Math.random() * this.moveops.length);
1206
- pool[ri] = pool[ri].mul(pool[rj]).mul(this.moveops[rm]);
1198
+ const rm = Math.floor(Math.random() * this.moveOps.length);
1199
+ pool[ri] = pool[ri].compose(pool[rj]).compose(this.moveOps[rm]);
1207
1200
  if (Math.random() < 0.1) {
1208
- pool[ri] = pool[ri].mul(this.moveops[rm]);
1201
+ pool[ri] = pool[ri].compose(this.moveOps[rm]);
1209
1202
  }
1210
1203
  }
1211
1204
  let s = pool[0];
1212
1205
  for (let i = 1; i < pool.length; i++) {
1213
- s = s.mul(pool[i]);
1206
+ s = s.compose(pool[i]);
1214
1207
  }
1215
1208
  return s;
1216
1209
  }
1217
1210
  reassemblySize() {
1218
1211
  let n = BigInt(1);
1219
- for (let i = 0; i < this.orbitdefs.length; i++) {
1220
- n *= this.orbitdefs[i].reassemblySize();
1212
+ for (let i = 0; i < this.orbitDefs.length; i++) {
1213
+ n *= this.orbitDefs[i].reassemblySize();
1221
1214
  }
1222
1215
  return n;
1223
1216
  }
1224
1217
  };
1225
1218
  var PGOrbit = class _PGOrbit {
1226
1219
  static ktransformationCache = [];
1227
- static e(n, mod) {
1228
- return new _PGOrbit(iota(n), zeros(n), mod);
1229
- }
1230
- perm;
1231
- ori;
1232
- orimod;
1233
- constructor(perm, ori, orimod) {
1234
- this.perm = perm;
1235
- this.ori = ori;
1236
- this.orimod = orimod;
1237
- }
1238
- mul(b) {
1239
- const n = this.perm.length;
1240
- const newPerm = new Array(n);
1241
- if (this.orimod === 1) {
1220
+ static identity(numPieces, numOrientations) {
1221
+ return new _PGOrbit(range(numPieces), zeros(numPieces), numOrientations);
1222
+ }
1223
+ permutation;
1224
+ orientationDelta;
1225
+ numOrientations;
1226
+ constructor(permutation, orientationDelta, numOrientations) {
1227
+ this.permutation = permutation;
1228
+ this.orientationDelta = orientationDelta;
1229
+ this.numOrientations = numOrientations;
1230
+ }
1231
+ applyTransformation(b) {
1232
+ const n = this.permutation.length;
1233
+ const newPermutation = new Array(n);
1234
+ if (this.numOrientations === 1) {
1242
1235
  for (let i = 0; i < n; i++) {
1243
- newPerm[i] = this.perm[b.perm[i]];
1236
+ newPermutation[i] = this.permutation[b.permutation[i]];
1244
1237
  }
1245
- return new _PGOrbit(newPerm, this.ori, this.orimod);
1238
+ return new _PGOrbit(
1239
+ newPermutation,
1240
+ this.orientationDelta,
1241
+ this.numOrientations
1242
+ );
1246
1243
  } else {
1247
- const newOri = new Array(n);
1244
+ const newOrientationDelta = new Array(n);
1248
1245
  for (let i = 0; i < n; i++) {
1249
- newPerm[i] = this.perm[b.perm[i]];
1250
- newOri[i] = (this.ori[b.perm[i]] + b.ori[i]) % this.orimod;
1246
+ newPermutation[i] = this.permutation[b.permutation[i]];
1247
+ newOrientationDelta[i] = (this.orientationDelta[b.permutation[i]] + b.orientationDelta[i]) % this.numOrientations;
1251
1248
  }
1252
- return new _PGOrbit(newPerm, newOri, this.orimod);
1249
+ return new _PGOrbit(
1250
+ newPermutation,
1251
+ newOrientationDelta,
1252
+ this.numOrientations
1253
+ );
1253
1254
  }
1254
1255
  }
1255
- inv() {
1256
- const n = this.perm.length;
1256
+ invert() {
1257
+ const n = this.permutation.length;
1257
1258
  const newPerm = new Array(n);
1258
1259
  const newOri = new Array(n);
1259
1260
  for (let i = 0; i < n; i++) {
1260
- newPerm[this.perm[i]] = i;
1261
- newOri[this.perm[i]] = (this.orimod - this.ori[i]) % this.orimod;
1261
+ newPerm[this.permutation[i]] = i;
1262
+ newOri[this.permutation[i]] = (this.numOrientations - this.orientationDelta[i]) % this.numOrientations;
1262
1263
  }
1263
- return new _PGOrbit(newPerm, newOri, this.orimod);
1264
+ return new _PGOrbit(newPerm, newOri, this.numOrientations);
1264
1265
  }
1265
1266
  equal(b) {
1266
- const n = this.perm.length;
1267
+ const n = this.permutation.length;
1267
1268
  for (let i = 0; i < n; i++) {
1268
- if (this.perm[i] !== b.perm[i] || this.ori[i] !== b.ori[i]) {
1269
+ if (this.permutation[i] !== b.permutation[i] || this.orientationDelta[i] !== b.orientationDelta[i]) {
1269
1270
  return false;
1270
1271
  }
1271
1272
  }
1272
1273
  return true;
1273
1274
  }
1274
- // in-place mutator
1275
- killOri() {
1276
- const n = this.perm.length;
1275
+ /**
1276
+ * Set the number of orientations to 1, so that orientations are effectively
1277
+ * no longer tracked for this orbit.
1278
+ */
1279
+ forgetOrientations() {
1280
+ const n = this.permutation.length;
1277
1281
  for (let i = 0; i < n; i++) {
1278
- this.ori[i] = 0;
1282
+ this.orientationDelta[i] = 0;
1279
1283
  }
1280
- this.orimod = 1;
1284
+ this.numOrientations = 1;
1281
1285
  return this;
1282
1286
  }
1283
- toPerm() {
1284
- const o = this.orimod;
1285
- if (o === 1) {
1286
- return new Perm(this.perm);
1287
+ toPermutation() {
1288
+ const { numOrientations } = this;
1289
+ if (numOrientations === 1) {
1290
+ return new Permutation(this.permutation);
1287
1291
  }
1288
- const n = this.perm.length;
1289
- const newPerm = new Array(n * o);
1292
+ const n = this.permutation.length;
1293
+ const newPerm = new Array(n * numOrientations);
1290
1294
  for (let i = 0; i < n; i++) {
1291
- for (let j = 0; j < o; j++) {
1292
- newPerm[i * o + j] = o * this.perm[i] + (this.ori[i] + j) % o;
1295
+ for (let j = 0; j < numOrientations; j++) {
1296
+ newPerm[i * numOrientations + j] = numOrientations * this.permutation[i] + (this.orientationDelta[i] + j) % numOrientations;
1293
1297
  }
1294
1298
  }
1295
- return new Perm(newPerm);
1299
+ return new Permutation(newPerm);
1296
1300
  }
1297
1301
  // number the pieces in order.
1298
1302
  renumberPieces() {
1299
- const seen = new Array(this.perm.length);
1300
- const newPerm = new Array(this.perm.length);
1303
+ const seen = new Array(this.permutation.length);
1304
+ const newPerm = new Array(this.permutation.length);
1301
1305
  let id = 0;
1302
- for (let i = 0; i < this.perm.length; i++) {
1303
- const v = this.perm[i];
1306
+ for (let i = 0; i < this.permutation.length; i++) {
1307
+ const v = this.permutation[i];
1304
1308
  if (seen[v] === void 0) {
1305
1309
  seen[v] = id++;
1306
1310
  }
1307
1311
  newPerm[i] = seen[v];
1308
1312
  }
1309
- return new _PGOrbit(newPerm, this.ori, this.orimod);
1313
+ return new _PGOrbit(newPerm, this.orientationDelta, this.numOrientations);
1310
1314
  }
1311
- // returns tuple of sets of identical pieces in this orbit
1315
+ // returns tuple of arrays of indices identical pieces in this orbit
1312
1316
  identicalPieces() {
1313
- const done = [];
1314
- const n = this.perm.length;
1315
- const r = [];
1316
- for (let i = 0; i < n; i++) {
1317
- const v = this.perm[i];
1318
- if (done[v] === void 0) {
1319
- const s = [i];
1320
- done[v] = true;
1321
- for (let j = i + 1; j < n; j++) {
1322
- if (this.perm[j] === v) {
1323
- s.push(j);
1324
- }
1325
- }
1326
- r.push(s);
1327
- }
1317
+ const output = {};
1318
+ for (let i = 0; i < this.permutation.length; i++) {
1319
+ const pieceNumber = this.permutation[i];
1320
+ (output[pieceNumber] ??= []).push(i);
1328
1321
  }
1329
- return r;
1322
+ return output;
1330
1323
  }
1331
1324
  order() {
1332
- return this.toPerm().order();
1325
+ return this.toPermutation().order();
1333
1326
  }
1334
1327
  isIdentity() {
1335
- const n = this.perm.length;
1336
- if (this.perm === iota(n) && this.ori === zeros(n)) {
1328
+ const n = this.permutation.length;
1329
+ if (this.permutation === range(n) && this.orientationDelta === zeros(n)) {
1337
1330
  return true;
1338
1331
  }
1339
1332
  for (let i = 0; i < n; i++) {
1340
- if (this.perm[i] !== i || this.ori[i] !== 0) {
1333
+ if (this.permutation[i] !== i || this.orientationDelta[i] !== 0) {
1341
1334
  return false;
1342
1335
  }
1343
1336
  }
1344
1337
  return true;
1345
1338
  }
1346
1339
  zeroOris() {
1347
- const n = this.perm.length;
1348
- if (this.ori === zeros(n)) {
1340
+ const n = this.permutation.length;
1341
+ if (this.orientationDelta === zeros(n)) {
1349
1342
  return true;
1350
1343
  }
1351
1344
  for (let i = 0; i < n; i++) {
1352
- if (this.ori[i] !== 0) {
1345
+ if (this.orientationDelta[i] !== 0) {
1353
1346
  return false;
1354
1347
  }
1355
1348
  }
1356
1349
  return true;
1357
1350
  }
1358
1351
  remap(no, on, nv) {
1359
- const newPerm = new Array(nv);
1360
- const newOri = new Array(nv);
1352
+ const newPermutation = new Array(nv);
1353
+ const newOrientation = new Array(nv);
1361
1354
  for (let i = 0; i < nv; i++) {
1362
- newPerm[i] = on[this.perm[no[i]]];
1363
- newOri[i] = this.ori[no[i]];
1355
+ newPermutation[i] = on[this.permutation[no[i]]];
1356
+ newOrientation[i] = this.orientationDelta[no[i]];
1364
1357
  }
1365
- return new _PGOrbit(newPerm, newOri, this.orimod);
1358
+ return new _PGOrbit(newPermutation, newOrientation, this.numOrientations);
1366
1359
  }
1367
1360
  remapVS(no, nv) {
1368
1361
  const newPerm = new Array(nv);
@@ -1370,52 +1363,55 @@ var PGOrbit = class _PGOrbit {
1370
1363
  let nextNew = 0;
1371
1364
  const reassign = [];
1372
1365
  for (let i = 0; i < nv; i++) {
1373
- const ov = this.perm[no[i]];
1366
+ const ov = this.permutation[no[i]];
1374
1367
  if (reassign[ov] === void 0) {
1375
1368
  reassign[ov] = nextNew++;
1376
1369
  }
1377
1370
  newPerm[i] = reassign[ov];
1378
- newOri[i] = this.ori[no[i]];
1371
+ newOri[i] = this.orientationDelta[no[i]];
1379
1372
  }
1380
- return new _PGOrbit(newPerm, newOri, this.orimod);
1373
+ return new _PGOrbit(newPerm, newOri, this.numOrientations);
1381
1374
  }
1382
1375
  appendDefinition(result, name, useVS, concise = true) {
1383
1376
  if (concise && this.isIdentity()) {
1384
1377
  return;
1385
1378
  }
1386
1379
  result.push(name);
1387
- result.push(this.perm.map((_) => _ + 1).join(" "));
1380
+ result.push(this.permutation.map((_) => _ + 1).join(" "));
1388
1381
  if (!this.zeroOris()) {
1389
1382
  if (useVS) {
1390
- const newori = new Array(this.ori.length);
1383
+ const newori = new Array(this.orientationDelta.length);
1391
1384
  for (let i = 0; i < newori.length; i++) {
1392
- newori[this.perm[i]] = this.ori[i];
1385
+ newori[this.permutation[i]] = this.orientationDelta[i];
1393
1386
  }
1394
1387
  result.push(newori.join(" "));
1395
1388
  } else {
1396
- result.push(this.ori.join(" "));
1389
+ result.push(this.orientationDelta.join(" "));
1397
1390
  }
1398
1391
  }
1399
1392
  }
1400
1393
  toKTransformationOrbitData() {
1401
- const n = this.perm.length;
1394
+ const n = this.permutation.length;
1402
1395
  if (this.isIdentity()) {
1403
1396
  if (!_PGOrbit.ktransformationCache[n]) {
1404
1397
  _PGOrbit.ktransformationCache[n] = {
1405
- permutation: iota(n),
1398
+ permutation: range(n),
1406
1399
  orientationDelta: zeros(n)
1407
1400
  };
1408
1401
  }
1409
1402
  return _PGOrbit.ktransformationCache[n];
1410
1403
  } else {
1411
- return { permutation: this.perm, orientationDelta: this.ori };
1404
+ return {
1405
+ permutation: this.permutation,
1406
+ orientationDelta: this.orientationDelta
1407
+ };
1412
1408
  }
1413
1409
  }
1414
1410
  toKPatternOrbitData() {
1415
- const n = this.perm.length;
1411
+ const n = this.permutation.length;
1416
1412
  return {
1417
- pieces: this.perm,
1418
- orientation: this.ori,
1413
+ pieces: this.permutation,
1414
+ orientation: this.orientationDelta,
1419
1415
  orientationMod: zeros(n)
1420
1416
  };
1421
1417
  }
@@ -1425,17 +1421,17 @@ var PGTransformBase = class {
1425
1421
  constructor(orbits) {
1426
1422
  this.orbits = orbits;
1427
1423
  }
1428
- internalMul(b) {
1424
+ internalApplyTransformation(b) {
1429
1425
  const newOrbits = [];
1430
1426
  for (let i = 0; i < this.orbits.length; i++) {
1431
- newOrbits.push(this.orbits[i].mul(b.orbits[i]));
1427
+ newOrbits.push(this.orbits[i].applyTransformation(b.orbits[i]));
1432
1428
  }
1433
1429
  return newOrbits;
1434
1430
  }
1435
- internalInv() {
1431
+ internalInvert() {
1436
1432
  const newOrbits = [];
1437
1433
  for (const orbit of this.orbits) {
1438
- newOrbits.push(orbit.inv());
1434
+ newOrbits.push(orbit.invert());
1439
1435
  }
1440
1436
  return newOrbits;
1441
1437
  }
@@ -1447,40 +1443,39 @@ var PGTransformBase = class {
1447
1443
  }
1448
1444
  return true;
1449
1445
  }
1450
- killOri() {
1446
+ forgetOrientations() {
1451
1447
  for (const orbit of this.orbits) {
1452
- orbit.killOri();
1448
+ orbit.forgetOrientations();
1453
1449
  }
1454
1450
  return this;
1455
1451
  }
1456
- toPerm() {
1452
+ toPermutation() {
1457
1453
  const perms = [];
1458
1454
  let n = 0;
1459
1455
  for (const orbit of this.orbits) {
1460
- const p = orbit.toPerm();
1456
+ const p = orbit.toPermutation();
1461
1457
  perms.push(p);
1462
- n += p.n;
1458
+ n += p.length;
1463
1459
  }
1464
1460
  const newPerm = new Array(n);
1465
1461
  n = 0;
1466
1462
  for (const p of perms) {
1467
- for (let j = 0; j < p.n; j++) {
1468
- newPerm[n + j] = n + p.p[j];
1463
+ for (let j = 0; j < p.length; j++) {
1464
+ newPerm[n + j] = n + p.permutation[j];
1469
1465
  }
1470
- n += p.n;
1466
+ n += p.length;
1471
1467
  }
1472
- return new Perm(newPerm);
1468
+ return new Permutation(newPerm);
1473
1469
  }
1474
1470
  identicalPieces() {
1475
1471
  const r = [];
1476
1472
  let n = 0;
1477
1473
  for (const orbit of this.orbits) {
1478
- const o = orbit.orimod;
1479
- const s = orbit.identicalPieces();
1480
- for (let j = 0; j < s.length; j++) {
1481
- r.push(s[j].map((_) => _ * o + n));
1474
+ const o = orbit.numOrientations;
1475
+ for (const occurences of Object.values(orbit.identicalPieces())) {
1476
+ r.push(occurences.map((i) => i * o + n));
1482
1477
  }
1483
- n += o * orbit.perm.length;
1478
+ n += o * orbit.permutation.length;
1484
1479
  }
1485
1480
  return r;
1486
1481
  }
@@ -1493,50 +1488,52 @@ var PGTransformBase = class {
1493
1488
  }
1494
1489
  };
1495
1490
  var PGTransform = class _PGTransform extends PGTransformBase {
1496
- mul(b) {
1497
- return new _PGTransform(this.internalMul(b));
1491
+ compose(b) {
1492
+ return new _PGTransform(this.internalApplyTransformation(b));
1498
1493
  }
1499
- mulScalar(n) {
1500
- if (n === 0) {
1501
- return this.e();
1494
+ multiplyByScalar(s) {
1495
+ if (s === 0) {
1496
+ return this.identity();
1502
1497
  }
1503
1498
  let t = this;
1504
- if (n < 0) {
1505
- t = t.inv();
1506
- n = -n;
1499
+ if (s < 0) {
1500
+ t = t.inverrt();
1501
+ s = -s;
1507
1502
  }
1508
- while ((n & 1) === 0) {
1509
- t = t.mul(t);
1510
- n >>= 1;
1503
+ while ((s & 1) === 0) {
1504
+ t = t.compose(t);
1505
+ s >>= 1;
1511
1506
  }
1512
- if (n === 1) {
1507
+ if (s === 1) {
1513
1508
  return t;
1514
1509
  }
1515
- let s = t;
1516
- let r = this.e();
1517
- while (n > 0) {
1518
- if (n & 1) {
1519
- r = r.mul(s);
1510
+ let transform = t;
1511
+ let r = this.identity();
1512
+ while (s > 0) {
1513
+ if (s & 1) {
1514
+ r = r.compose(transform);
1520
1515
  }
1521
- if (n > 1) {
1522
- s = s.mul(s);
1516
+ if (s > 1) {
1517
+ transform = transform.compose(transform);
1523
1518
  }
1524
- n >>= 1;
1519
+ s >>= 1;
1525
1520
  }
1526
1521
  return r;
1527
1522
  }
1528
- inv() {
1529
- return new _PGTransform(this.internalInv());
1523
+ inverrt() {
1524
+ return new _PGTransform(this.internalInvert());
1530
1525
  }
1531
- e() {
1526
+ identity() {
1532
1527
  return new _PGTransform(
1533
- this.orbits.map((_) => PGOrbit.e(_.perm.length, _.orimod))
1528
+ this.orbits.map(
1529
+ (orbit) => PGOrbit.identity(orbit.permutation.length, orbit.numOrientations)
1530
+ )
1534
1531
  );
1535
1532
  }
1536
1533
  };
1537
1534
  var VisibleState = class _VisibleState extends PGTransformBase {
1538
- mul(b) {
1539
- return new _VisibleState(this.internalMul(b));
1535
+ applyTransformation(b) {
1536
+ return new _VisibleState(this.internalApplyTransformation(b));
1540
1537
  }
1541
1538
  };
1542
1539
  var DisjointUnion = class {
@@ -1568,23 +1565,23 @@ var DisjointUnion = class {
1568
1565
  }
1569
1566
  }
1570
1567
  };
1571
- function showcanon(g, disp) {
1572
- const n = g.moveops.length;
1568
+ function showCanonical(g, disp) {
1569
+ const n = g.moveOps.length;
1573
1570
  if (n > 30) {
1574
1571
  throw new Error("Canon info too big for bitmask");
1575
1572
  }
1576
1573
  const orders = [];
1577
1574
  const commutes = [];
1578
1575
  for (let i = 0; i < n; i++) {
1579
- const permA = g.moveops[i];
1576
+ const permA = g.moveOps[i];
1580
1577
  orders.push(permA.order());
1581
1578
  let bits = 0;
1582
1579
  for (let j = 0; j < n; j++) {
1583
1580
  if (j === i) {
1584
1581
  continue;
1585
1582
  }
1586
- const permB = g.moveops[j];
1587
- if (permA.mul(permB).equal(permB.mul(permA))) {
1583
+ const permB = g.moveOps[j];
1584
+ if (permA.compose(permB).equal(permB.compose(permA))) {
1588
1585
  bits |= 1 << j;
1589
1586
  }
1590
1587
  }
@@ -2089,7 +2086,7 @@ var FactoredNumber = class {
2089
2086
  }
2090
2087
  };
2091
2088
  function schreierSims(g, disp) {
2092
- const n = g[0].p.length;
2089
+ const n = g[0].permutation.length;
2093
2090
  const e = identity(n);
2094
2091
  let sgs = [];
2095
2092
  let sgsi = [];
@@ -2097,13 +2094,13 @@ function schreierSims(g, disp) {
2097
2094
  let Tk = [];
2098
2095
  let Tklen = [];
2099
2096
  function resolve(p) {
2100
- for (let i = p.p.length - 1; i >= 0; i--) {
2101
- const j = p.p[i];
2097
+ for (let i = p.permutation.length - 1; i >= 0; i--) {
2098
+ const j = p.permutation[i];
2102
2099
  if (j !== i) {
2103
2100
  if (!sgs[i][j]) {
2104
2101
  return false;
2105
2102
  }
2106
- p = p.mul(sgsi[i][j]);
2103
+ p = p.multiply(sgsi[i][j]);
2107
2104
  }
2108
2105
  }
2109
2106
  return true;
@@ -2113,22 +2110,22 @@ function schreierSims(g, disp) {
2113
2110
  Tklen[k].push(len);
2114
2111
  for (let i = 0; i < sgs[k].length; i++) {
2115
2112
  if (sgs[k][i]) {
2116
- knuthb(k, sgs[k][i].mul(p), len + sgslen[k][i]);
2113
+ knuthb(k, sgs[k][i].multiply(p), len + sgslen[k][i]);
2117
2114
  }
2118
2115
  }
2119
2116
  }
2120
2117
  function knuthb(k, p, len) {
2121
- const j = p.p[k];
2118
+ const j = p.permutation[k];
2122
2119
  if (!sgs[k][j]) {
2123
2120
  sgs[k][j] = p;
2124
- sgsi[k][j] = p.inv();
2121
+ sgsi[k][j] = p.invert();
2125
2122
  sgslen[k][j] = len;
2126
2123
  for (let i = 0; i < Tk[k].length; i++) {
2127
- knuthb(k, p.mul(Tk[k][i]), len + Tklen[k][i]);
2124
+ knuthb(k, p.multiply(Tk[k][i]), len + Tklen[k][i]);
2128
2125
  }
2129
2126
  return;
2130
2127
  }
2131
- const p2 = p.mul(sgsi[k][j]);
2128
+ const p2 = p.multiply(sgsi[k][j]);
2132
2129
  if (!resolve(p2)) {
2133
2130
  knutha(k - 1, p2, len + sgslen[k][j]);
2134
2131
  }
@@ -4168,10 +4165,10 @@ ${comment}
4168
4165
  const os = this.getOrbitsDef(false);
4169
4166
  const r = [];
4170
4167
  const mvs = [];
4171
- for (let i = 0; i < os.moveops.length; i++) {
4172
- let movename = os.movenames[i];
4173
- if (!os.forcenames[i]) {
4174
- movename = `M_${externalName(this.notationMapper, movename)}`;
4168
+ for (let i = 0; i < os.moveOps.length; i++) {
4169
+ let movename = os.moveNames[i];
4170
+ if (!os.forceNames[i]) {
4171
+ movename = `M_${externalMoveName(this.notationMapper, movename)}`;
4175
4172
  }
4176
4173
  movename = `M_${movename}`;
4177
4174
  let doinv = false;
@@ -4181,9 +4178,11 @@ ${comment}
4181
4178
  }
4182
4179
  mvs.push(movename);
4183
4180
  if (doinv) {
4184
- r.push(`${movename}:=${os.moveops[i].toPerm().inv().toGap()};`);
4181
+ r.push(
4182
+ `${movename}:=${os.moveOps[i].toPermutation().invert().toGap()};`
4183
+ );
4185
4184
  } else {
4186
- r.push(`${movename}:=${os.moveops[i].toPerm().toGap()};`);
4185
+ r.push(`${movename}:=${os.moveOps[i].toPermutation().toGap()};`);
4187
4186
  }
4188
4187
  }
4189
4188
  r.push("Gen:=[");
@@ -4203,8 +4202,8 @@ ${comment}
4203
4202
  const r = [];
4204
4203
  const mvs = [];
4205
4204
  r.push(`(* ${this.header("").trim()} *)`);
4206
- for (let i = 0; i < os.moveops.length; i++) {
4207
- let movename = `m${externalName(this.notationMapper, os.movenames[i])}`;
4205
+ for (let i = 0; i < os.moveOps.length; i++) {
4206
+ let movename = `m${externalMoveName(this.notationMapper, os.moveNames[i])}`;
4208
4207
  let doinv = false;
4209
4208
  if (movename[movename.length - 1] === "'") {
4210
4209
  movename = movename.substring(0, movename.length - 1);
@@ -4212,9 +4211,11 @@ ${comment}
4212
4211
  }
4213
4212
  mvs.push(movename);
4214
4213
  if (doinv) {
4215
- r.push(`${movename}=${os.moveops[i].toPerm().inv().toMathematica()};`);
4214
+ r.push(
4215
+ `${movename}=${os.moveOps[i].toPermutation().invert().toMathematica()};`
4216
+ );
4216
4217
  } else {
4217
- r.push(`${movename}=${os.moveops[i].toPerm().toMathematica()};`);
4218
+ r.push(`${movename}=${os.moveOps[i].toPermutation().toMathematica()};`);
4218
4219
  }
4219
4220
  }
4220
4221
  r.push(`gen={${mvs.join(",")}};`);
@@ -4238,7 +4239,7 @@ ${comment}
4238
4239
  const perms = [];
4239
4240
  const oris = [];
4240
4241
  for (const len of this.cubieOrbitSizes) {
4241
- perms.push(iota(len));
4242
+ perms.push(range(len));
4242
4243
  oris.push(zeros(len));
4243
4244
  }
4244
4245
  for (let m = moverange[0]; m <= moverange[1]; m++) {
@@ -4255,7 +4256,7 @@ ${comment}
4255
4256
  inc = mperm.length - 2;
4256
4257
  oinc = mperm.length - 1;
4257
4258
  }
4258
- if (perms[setnum] === iota(this.cubieOrbitSizes[setnum])) {
4259
+ if (perms[setnum] === range(this.cubieOrbitSizes[setnum])) {
4259
4260
  perms[setnum] = perms[setnum].slice();
4260
4261
  if (this.orbitOrientations[setnum] > 1 && // TODO: refactor to avoid non-null-assertion
4261
4262
  !this.options.fixedOrientation) {
@@ -4272,14 +4273,14 @@ ${comment}
4272
4273
  }
4273
4274
  }
4274
4275
  }
4275
- let lastId = new PGOrbit(iota(24), zeros(24), 1);
4276
+ let lastId = new PGOrbit(range(24), zeros(24), 1);
4276
4277
  for (let ii = 0; ii < this.cubieSetNames.length; ii++) {
4277
4278
  if (setmoves && !setmoves[ii]) {
4278
4279
  continue;
4279
4280
  }
4280
4281
  if (this.orbitOrientations[ii] === 1 || this.options.fixedOrientation) {
4281
- if (perms[ii] === iota(lastId.perm.length)) {
4282
- if (perms[ii] !== lastId.perm) {
4282
+ if (perms[ii] === range(lastId.permutation.length)) {
4283
+ if (perms[ii] !== lastId.permutation) {
4283
4284
  lastId = new PGOrbit(perms[ii], oris[ii], 1);
4284
4285
  }
4285
4286
  moveorbits.push(lastId);
@@ -4298,7 +4299,7 @@ ${comment}
4298
4299
  }
4299
4300
  let mv = new PGTransform(moveorbits);
4300
4301
  if (amount !== 1) {
4301
- mv = mv.mulScalar(amount);
4302
+ mv = mv.multiplyByScalar(amount);
4302
4303
  }
4303
4304
  return mv;
4304
4305
  }
@@ -4589,10 +4590,10 @@ ${comment}
4589
4590
  return od.toKTransformationData(od.getScrambleTransformation(n));
4590
4591
  }
4591
4592
  getMovesAsPerms() {
4592
- return this.getOrbitsDef(false).moveops.map((_) => _.toPerm());
4593
+ return this.getOrbitsDef(false).moveOps.map((_) => _.toPermutation());
4593
4594
  }
4594
4595
  showcanon(disp) {
4595
- showcanon(this.getOrbitsDef(false), disp);
4596
+ showCanonical(this.getOrbitsDef(false), disp);
4596
4597
  }
4597
4598
  getsolved() {
4598
4599
  const r = [];
@@ -4601,7 +4602,7 @@ ${comment}
4601
4602
  r.push(i);
4602
4603
  }
4603
4604
  }
4604
- return new Perm(r);
4605
+ return new Permutation(r);
4605
4606
  }
4606
4607
  // Given a rotation description that says to align feature1
4607
4608
  // with a given vector, and then as much as possible feature2
@@ -4908,7 +4909,7 @@ ${comment}
4908
4909
  const cubieori = this.faceToCubieOrd[i];
4909
4910
  const cubiesetnum = this.cubieSetNums[cubie];
4910
4911
  const cubieord = this.cubieOrdNums[cubie];
4911
- const color = this.graybyori(cubie) ? "#808080" : colormap[pos.p[i]];
4912
+ const color = this.graybyori(cubie) ? "#808080" : colormap[pos.permutation[i]];
4912
4913
  let id = `${this.cubieSetNames[cubiesetnum]}-l${cubieord}-o${cubieori}`;
4913
4914
  svg.push(drawedges(id, facegeo[i], color));
4914
4915
  if (this.duplicatedFaces[i]) {
@@ -5072,7 +5073,7 @@ var PGNotation = class {
5072
5073
  pg;
5073
5074
  constructor(pg, od) {
5074
5075
  this.pg = pg;
5075
- this.orbitNames = od.orbitnames;
5076
+ this.orbitNames = od.orbitNames;
5076
5077
  }
5077
5078
  lookupMove(move) {
5078
5079
  const mv = this.pg.parseMove(move);
@@ -5121,4 +5122,3 @@ export {
5121
5122
  parsePuzzleDescription,
5122
5123
  schreierSims
5123
5124
  };
5124
- //# sourceMappingURL=index.js.map