cubing 0.28.1 → 0.29.0
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.
- package/README.md +2 -0
- package/dist/esm/alg/index.js +2 -2
- package/dist/esm/bluetooth/index.js +222 -86
- package/dist/esm/bluetooth/index.js.map +3 -3
- package/dist/esm/{chunk-F4WWCPVE.js → chunk-2IZUSAXQ.js} +2 -2
- package/dist/esm/{chunk-F4WWCPVE.js.map → chunk-2IZUSAXQ.js.map} +1 -1
- package/dist/esm/{chunk-YSVFZVG4.js → chunk-DZGFGBKT.js} +183 -76
- package/dist/esm/chunk-DZGFGBKT.js.map +7 -0
- package/dist/esm/{chunk-7D7LW3WQ.js → chunk-GW4FGG42.js} +8 -4
- package/dist/esm/{chunk-7D7LW3WQ.js.map → chunk-GW4FGG42.js.map} +1 -1
- package/dist/esm/{chunk-32FWPPTW.js → chunk-LSCTPPWV.js} +22 -8
- package/dist/esm/{chunk-32FWPPTW.js.map → chunk-LSCTPPWV.js.map} +1 -1
- package/dist/esm/{chunk-LSVR2HCG.js → chunk-LV7IKG36.js} +389 -363
- package/dist/esm/{chunk-LSVR2HCG.js.map → chunk-LV7IKG36.js.map} +1 -1
- package/dist/esm/{chunk-CSBUJ64Q.js → chunk-NI7U4XAZ.js} +373 -238
- package/dist/esm/chunk-NI7U4XAZ.js.map +7 -0
- package/dist/esm/{chunk-GVPTO3OF.js → chunk-OX6O2ZO5.js} +1 -1
- package/dist/esm/{chunk-GVPTO3OF.js.map → chunk-OX6O2ZO5.js.map} +1 -1
- package/dist/esm/{chunk-67VJZGH2.js → chunk-PYWGREIP.js} +44 -13
- package/dist/esm/chunk-PYWGREIP.js.map +7 -0
- package/dist/esm/{chunk-WAL36PO3.js → chunk-Q4W5ZR4U.js} +28 -12
- package/dist/esm/{chunk-WAL36PO3.js.map → chunk-Q4W5ZR4U.js.map} +1 -1
- package/dist/esm/{chunk-MGJA5U5O.js → chunk-SBZRVSPK.js} +1 -12
- package/dist/esm/{chunk-MGJA5U5O.js.map → chunk-SBZRVSPK.js.map} +0 -0
- package/dist/esm/{chunk-MWKALF6W.js → chunk-TGPS3CXW.js} +22 -13
- package/dist/esm/chunk-TGPS3CXW.js.map +7 -0
- package/dist/esm/{chunk-V55YSWJY.js → chunk-WXCNEGW3.js} +10 -4
- package/dist/esm/{chunk-V55YSWJY.js.map → chunk-WXCNEGW3.js.map} +1 -1
- package/dist/esm/{chunk-ZY3RTFFS.js → chunk-XU5ILFX5.js} +137 -66
- package/dist/esm/{chunk-ZY3RTFFS.js.map → chunk-XU5ILFX5.js.map} +3 -3
- package/dist/esm/{chunk-ALBEW4DJ.js → chunk-ZB3P5AZN.js} +1 -1
- package/dist/esm/{chunk-ALBEW4DJ.js.map → chunk-ZB3P5AZN.js.map} +1 -1
- package/dist/esm/{chunk-NPHUBFZ6.js → chunk-ZNAYJGVL.js} +2 -2
- package/dist/esm/{chunk-NPHUBFZ6.js.map → chunk-ZNAYJGVL.js.map} +1 -1
- package/dist/esm/kpuzzle/index.js +3 -3
- package/dist/esm/notation/index.js +3 -3
- package/dist/esm/protocol/index.js +5 -5
- package/dist/esm/puzzle-geometry/index.js +271 -71
- package/dist/esm/puzzle-geometry/index.js.map +2 -2
- package/dist/esm/puzzles/index.js +5 -5
- package/dist/esm/{puzzles-dynamic-3x3x3-NB2PEZTV.js → puzzles-dynamic-3x3x3-KIG5A6QR.js} +2 -2
- package/dist/esm/{puzzles-dynamic-3x3x3-NB2PEZTV.js.map → puzzles-dynamic-3x3x3-KIG5A6QR.js.map} +0 -0
- package/dist/esm/puzzles-dynamic-4x4x4-PEDAPUZK.js +126 -0
- package/dist/esm/puzzles-dynamic-4x4x4-PEDAPUZK.js.map +7 -0
- package/dist/esm/{puzzles-dynamic-side-events-WZI4Y3N6.js → puzzles-dynamic-side-events-5C7LMBWX.js} +2 -2
- package/dist/esm/{puzzles-dynamic-side-events-WZI4Y3N6.js.map → puzzles-dynamic-side-events-5C7LMBWX.js.map} +0 -0
- package/dist/esm/{puzzles-dynamic-unofficial-FUG3JBMH.js → puzzles-dynamic-unofficial-WWJ4NJMX.js} +2 -2
- package/dist/esm/{puzzles-dynamic-unofficial-FUG3JBMH.js.map → puzzles-dynamic-unofficial-WWJ4NJMX.js.map} +0 -0
- package/dist/esm/scramble/index.js +5 -5
- package/dist/esm/search/index.js +10 -10
- package/dist/esm/{search-dynamic-sgs-side-events-R3HDJ5XQ.js → search-dynamic-sgs-side-events-AYX7MZO7.js} +35 -17
- package/dist/esm/{search-dynamic-sgs-side-events-R3HDJ5XQ.js.map → search-dynamic-sgs-side-events-AYX7MZO7.js.map} +2 -2
- package/dist/esm/{search-dynamic-sgs-unofficial-FQNKGHVO.js → search-dynamic-sgs-unofficial-DLJOJFJL.js} +35 -14
- package/dist/esm/{search-dynamic-sgs-unofficial-FQNKGHVO.js.map → search-dynamic-sgs-unofficial-DLJOJFJL.js.map} +2 -2
- package/dist/esm/{search-dynamic-solve-3x3x3-K42IWMQV.js → search-dynamic-solve-3x3x3-7XZTYQMO.js} +795 -142
- package/dist/esm/{search-dynamic-solve-3x3x3-K42IWMQV.js.map → search-dynamic-solve-3x3x3-7XZTYQMO.js.map} +1 -1
- package/dist/esm/{search-dynamic-solve-4x4x4-XRV4NBMQ.js → search-dynamic-solve-4x4x4-CWWTFKMR.js} +135 -29
- package/dist/esm/{search-dynamic-solve-4x4x4-XRV4NBMQ.js.map → search-dynamic-solve-4x4x4-CWWTFKMR.js.map} +1 -1
- package/dist/esm/{search-dynamic-solve-fto-O6UXF7EC.js → search-dynamic-solve-fto-4LI23P6K.js} +253 -69
- package/dist/esm/{search-dynamic-solve-fto-O6UXF7EC.js.map → search-dynamic-solve-fto-4LI23P6K.js.map} +2 -2
- package/dist/esm/{search-dynamic-solve-kilominx-G4MLGWNS.js → search-dynamic-solve-kilominx-3HEVQ4MC.js} +32 -8
- package/dist/esm/{search-dynamic-solve-kilominx-G4MLGWNS.js.map → search-dynamic-solve-kilominx-3HEVQ4MC.js.map} +2 -2
- package/dist/esm/{search-dynamic-solve-master_tetraminx-3RKD3IAN.js → search-dynamic-solve-master_tetraminx-UB32C7MM.js} +111 -42
- package/dist/esm/{search-dynamic-solve-master_tetraminx-3RKD3IAN.js.map → search-dynamic-solve-master_tetraminx-UB32C7MM.js.map} +2 -2
- package/dist/esm/{search-dynamic-solve-sq1-WIJEGVLP.js → search-dynamic-solve-sq1-HA72TYF2.js} +54 -9
- package/dist/esm/{search-dynamic-solve-sq1-WIJEGVLP.js.map → search-dynamic-solve-sq1-HA72TYF2.js.map} +2 -2
- package/dist/esm/{search-worker-inside-generated-string-IZCKWXUA.js → search-worker-inside-generated-string-AMEXYCKK.js} +146 -28
- package/dist/esm/search-worker-inside-generated-string-AMEXYCKK.js.map +7 -0
- package/dist/esm/{search-worker-js-entry-WBEKNBB7.js → search-worker-js-entry-TP2T3NUL.js} +147 -53
- package/dist/esm/{search-worker-js-entry-WBEKNBB7.js.map → search-worker-js-entry-TP2T3NUL.js.map} +2 -2
- package/dist/esm/{search-worker-ts-entry-XQWMEOC4.js → search-worker-ts-entry-NEH77S4I.js} +5 -5
- package/dist/esm/{search-worker-ts-entry-XQWMEOC4.js.map → search-worker-ts-entry-NEH77S4I.js.map} +1 -1
- package/dist/esm/stream/index.js +12 -8
- package/dist/esm/stream/index.js.map +1 -1
- package/dist/esm/twisty/index.js +1154 -762
- package/dist/esm/twisty/index.js.map +3 -3
- package/dist/esm/{twisty-dynamic-3d-QOX7IEXC.js → twisty-dynamic-3d-D3ZDBJUH.js} +352 -175
- package/dist/esm/{twisty-dynamic-3d-QOX7IEXC.js.map → twisty-dynamic-3d-D3ZDBJUH.js.map} +2 -2
- package/dist/types/{Alg-e2a80975.d.ts → Alg-137fb0d5.d.ts} +19 -16
- package/dist/types/{KState-a2f0e651.d.ts → KState-a73111d7.d.ts} +1 -9
- package/dist/types/{TwizzleLink-dcf51446.d.ts → TwizzleLink-bef52ecd.d.ts} +46 -10
- package/dist/types/alg/index.d.ts +4 -4
- package/dist/types/bluetooth/index.d.ts +4 -4
- package/dist/types/{bluetooth-puzzle-3670a6a1.d.ts → bluetooth-puzzle-8a678993.d.ts} +9 -9
- package/dist/types/kpuzzle/index.d.ts +2 -2
- package/dist/types/notation/index.d.ts +1 -1
- package/dist/types/{outside-0ce1b145.d.ts → outside-e55f28a0.d.ts} +2 -2
- package/dist/types/{parseAlg-db0dec6c.d.ts → parseAlg-a28f7568.d.ts} +1 -1
- package/dist/types/protocol/index.d.ts +2 -2
- package/dist/types/puzzle-geometry/index.d.ts +3 -3
- package/dist/types/puzzles/index.d.ts +5 -5
- package/dist/types/scramble/index.d.ts +3 -3
- package/dist/types/search/index.d.ts +3 -3
- package/dist/types/stream/index.d.ts +5 -5
- package/dist/types/twisty/index.d.ts +5 -5
- package/package.json +47 -41
- package/dist/esm/chunk-67VJZGH2.js.map +0 -7
- package/dist/esm/chunk-CSBUJ64Q.js.map +0 -7
- package/dist/esm/chunk-MWKALF6W.js.map +0 -7
- package/dist/esm/chunk-YSVFZVG4.js.map +0 -7
- package/dist/esm/search-worker-inside-generated-string-IZCKWXUA.js.map +0 -7
|
@@ -2,9 +2,8 @@ import {
|
|
|
2
2
|
__privateAdd,
|
|
3
3
|
__privateGet,
|
|
4
4
|
__privateMethod,
|
|
5
|
-
__privateSet
|
|
6
|
-
|
|
7
|
-
} from "./chunk-MGJA5U5O.js";
|
|
5
|
+
__privateSet
|
|
6
|
+
} from "./chunk-SBZRVSPK.js";
|
|
8
7
|
|
|
9
8
|
// src/cubing/alg/common.ts
|
|
10
9
|
var writeAlgDebugField = false;
|
|
@@ -65,13 +64,10 @@ var MAX_INT_DESCRIPTION = "2^31 - 1";
|
|
|
65
64
|
var MIN_INT = -2147483648;
|
|
66
65
|
|
|
67
66
|
// src/cubing/alg/AlgBuilder.ts
|
|
68
|
-
var _algNode;
|
|
69
67
|
var AlgBuilder = class {
|
|
70
|
-
|
|
71
|
-
__privateAdd(this, _algNode, []);
|
|
72
|
-
}
|
|
68
|
+
#algNode = [];
|
|
73
69
|
push(u) {
|
|
74
|
-
|
|
70
|
+
this.#algNode.push(u);
|
|
75
71
|
}
|
|
76
72
|
experimentalPushAlg(alg) {
|
|
77
73
|
for (const u of alg.childAlgNodes()) {
|
|
@@ -79,16 +75,15 @@ var AlgBuilder = class {
|
|
|
79
75
|
}
|
|
80
76
|
}
|
|
81
77
|
experimentalNumAlgNodes() {
|
|
82
|
-
return
|
|
78
|
+
return this.#algNode.length;
|
|
83
79
|
}
|
|
84
80
|
toAlg() {
|
|
85
|
-
return new Alg(
|
|
81
|
+
return new Alg(this.#algNode);
|
|
86
82
|
}
|
|
87
83
|
reset() {
|
|
88
|
-
|
|
84
|
+
this.#algNode = [];
|
|
89
85
|
}
|
|
90
86
|
};
|
|
91
|
-
_algNode = new WeakMap();
|
|
92
87
|
|
|
93
88
|
// src/cubing/alg/debug.ts
|
|
94
89
|
var algDebugGlobals = {
|
|
@@ -101,27 +96,26 @@ function setAlgDebug(options) {
|
|
|
101
96
|
}
|
|
102
97
|
|
|
103
98
|
// src/cubing/alg/alg-nodes/containers/Commutator.ts
|
|
104
|
-
var
|
|
105
|
-
|
|
99
|
+
var Commutator = class extends AlgCommon {
|
|
100
|
+
#A;
|
|
101
|
+
#B;
|
|
106
102
|
constructor(aSource, bSource) {
|
|
107
103
|
super();
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
__privateSet(this, _A, experimentalEnsureAlg(aSource));
|
|
111
|
-
__privateSet(this, _B, experimentalEnsureAlg(bSource));
|
|
104
|
+
this.#A = experimentalEnsureAlg(aSource);
|
|
105
|
+
this.#B = experimentalEnsureAlg(bSource);
|
|
112
106
|
}
|
|
113
107
|
get A() {
|
|
114
|
-
return
|
|
108
|
+
return this.#A;
|
|
115
109
|
}
|
|
116
110
|
get B() {
|
|
117
|
-
return
|
|
111
|
+
return this.#B;
|
|
118
112
|
}
|
|
119
113
|
isIdentical(other) {
|
|
120
|
-
const otherAsCommutator = other.as(
|
|
114
|
+
const otherAsCommutator = other.as(Commutator);
|
|
121
115
|
return !!(otherAsCommutator?.A.isIdentical(this.A) && otherAsCommutator?.B.isIdentical(this.B));
|
|
122
116
|
}
|
|
123
117
|
invert() {
|
|
124
|
-
return new
|
|
118
|
+
return new Commutator(this.#B, this.#A);
|
|
125
119
|
}
|
|
126
120
|
*experimentalExpand(iterDir = 1 /* Forwards */, depth) {
|
|
127
121
|
depth ?? (depth = Infinity);
|
|
@@ -129,48 +123,68 @@ var _Commutator = class extends AlgCommon {
|
|
|
129
123
|
yield iterDir === 1 /* Forwards */ ? this : this.invert();
|
|
130
124
|
} else {
|
|
131
125
|
if (iterDir === 1 /* Forwards */) {
|
|
132
|
-
yield* this.A.experimentalExpand(
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
126
|
+
yield* this.A.experimentalExpand(
|
|
127
|
+
1 /* Forwards */,
|
|
128
|
+
depth - 1
|
|
129
|
+
);
|
|
130
|
+
yield* this.B.experimentalExpand(
|
|
131
|
+
1 /* Forwards */,
|
|
132
|
+
depth - 1
|
|
133
|
+
);
|
|
134
|
+
yield* this.A.experimentalExpand(
|
|
135
|
+
-1 /* Backwards */,
|
|
136
|
+
depth - 1
|
|
137
|
+
);
|
|
138
|
+
yield* this.B.experimentalExpand(
|
|
139
|
+
-1 /* Backwards */,
|
|
140
|
+
depth - 1
|
|
141
|
+
);
|
|
136
142
|
} else {
|
|
137
|
-
yield* this.B.experimentalExpand(
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
143
|
+
yield* this.B.experimentalExpand(
|
|
144
|
+
1 /* Forwards */,
|
|
145
|
+
depth - 1
|
|
146
|
+
);
|
|
147
|
+
yield* this.A.experimentalExpand(
|
|
148
|
+
1 /* Forwards */,
|
|
149
|
+
depth - 1
|
|
150
|
+
);
|
|
151
|
+
yield* this.B.experimentalExpand(
|
|
152
|
+
-1 /* Backwards */,
|
|
153
|
+
depth - 1
|
|
154
|
+
);
|
|
155
|
+
yield* this.A.experimentalExpand(
|
|
156
|
+
-1 /* Backwards */,
|
|
157
|
+
depth - 1
|
|
158
|
+
);
|
|
141
159
|
}
|
|
142
160
|
}
|
|
143
161
|
}
|
|
144
162
|
toString() {
|
|
145
|
-
return `[${
|
|
163
|
+
return `[${this.#A.toString()}, ${this.#B.toString()}]`;
|
|
146
164
|
}
|
|
147
165
|
};
|
|
148
|
-
var Commutator = _Commutator;
|
|
149
|
-
_A = new WeakMap();
|
|
150
|
-
_B = new WeakMap();
|
|
151
166
|
|
|
152
167
|
// src/cubing/alg/alg-nodes/containers/Conjugate.ts
|
|
153
|
-
var
|
|
154
|
-
|
|
168
|
+
var Conjugate = class extends AlgCommon {
|
|
169
|
+
#A;
|
|
170
|
+
#B;
|
|
155
171
|
constructor(aSource, bSource) {
|
|
156
172
|
super();
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
__privateSet(this, _A2, experimentalEnsureAlg(aSource));
|
|
160
|
-
__privateSet(this, _B2, experimentalEnsureAlg(bSource));
|
|
173
|
+
this.#A = experimentalEnsureAlg(aSource);
|
|
174
|
+
this.#B = experimentalEnsureAlg(bSource);
|
|
161
175
|
}
|
|
162
176
|
get A() {
|
|
163
|
-
return
|
|
177
|
+
return this.#A;
|
|
164
178
|
}
|
|
165
179
|
get B() {
|
|
166
|
-
return
|
|
180
|
+
return this.#B;
|
|
167
181
|
}
|
|
168
182
|
isIdentical(other) {
|
|
169
|
-
const otherAsConjugate = other.as(
|
|
183
|
+
const otherAsConjugate = other.as(Conjugate);
|
|
170
184
|
return !!(otherAsConjugate?.A.isIdentical(this.A) && otherAsConjugate?.B.isIdentical(this.B));
|
|
171
185
|
}
|
|
172
186
|
invert() {
|
|
173
|
-
return new
|
|
187
|
+
return new Conjugate(this.#A, this.#B.invert());
|
|
174
188
|
}
|
|
175
189
|
*experimentalExpand(iterDir, depth) {
|
|
176
190
|
depth ?? (depth = Infinity);
|
|
@@ -186,27 +200,23 @@ var _Conjugate = class extends AlgCommon {
|
|
|
186
200
|
return `[${this.A}: ${this.B}]`;
|
|
187
201
|
}
|
|
188
202
|
};
|
|
189
|
-
var Conjugate = _Conjugate;
|
|
190
|
-
_A2 = new WeakMap();
|
|
191
|
-
_B2 = new WeakMap();
|
|
192
203
|
|
|
193
204
|
// src/cubing/alg/alg-nodes/leaves/LineComment.ts
|
|
194
|
-
var
|
|
195
|
-
|
|
205
|
+
var LineComment = class extends AlgCommon {
|
|
206
|
+
#text;
|
|
196
207
|
constructor(commentText) {
|
|
197
208
|
super();
|
|
198
|
-
__privateAdd(this, _text, void 0);
|
|
199
209
|
if (commentText.includes("\n") || commentText.includes("\r")) {
|
|
200
210
|
throw new Error("LineComment cannot contain newline");
|
|
201
211
|
}
|
|
202
|
-
|
|
212
|
+
this.#text = commentText;
|
|
203
213
|
}
|
|
204
214
|
get text() {
|
|
205
|
-
return
|
|
215
|
+
return this.#text;
|
|
206
216
|
}
|
|
207
217
|
isIdentical(other) {
|
|
208
218
|
const otherAsLineComment = other;
|
|
209
|
-
return other.is(
|
|
219
|
+
return other.is(LineComment) && this.#text === otherAsLineComment.#text;
|
|
210
220
|
}
|
|
211
221
|
invert() {
|
|
212
222
|
return this;
|
|
@@ -215,11 +225,9 @@ var _LineComment = class extends AlgCommon {
|
|
|
215
225
|
yield this;
|
|
216
226
|
}
|
|
217
227
|
toString() {
|
|
218
|
-
return `//${
|
|
228
|
+
return `//${this.#text}`;
|
|
219
229
|
}
|
|
220
230
|
};
|
|
221
|
-
var LineComment = _LineComment;
|
|
222
|
-
_text = new WeakMap();
|
|
223
231
|
|
|
224
232
|
// src/cubing/alg/alg-nodes/leaves/Newline.ts
|
|
225
233
|
var Newline = class extends AlgCommon {
|
|
@@ -288,21 +296,18 @@ function transferCharIndex(from, to) {
|
|
|
288
296
|
}
|
|
289
297
|
return to;
|
|
290
298
|
}
|
|
291
|
-
var _input, _idx, _nissQueue;
|
|
292
299
|
var AlgParser = class {
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
__privateAdd(this, _nissQueue, []);
|
|
297
|
-
}
|
|
300
|
+
#input = "";
|
|
301
|
+
#idx = 0;
|
|
302
|
+
#nissQueue = [];
|
|
298
303
|
parseAlg(input) {
|
|
299
|
-
|
|
300
|
-
|
|
304
|
+
this.#input = input;
|
|
305
|
+
this.#idx = 0;
|
|
301
306
|
const alg = this.parseAlgWithStopping([]);
|
|
302
307
|
this.mustBeAtEndOfInput();
|
|
303
308
|
const algNodes = Array.from(alg.childAlgNodes());
|
|
304
|
-
if (
|
|
305
|
-
for (const nissGrouping of
|
|
309
|
+
if (this.#nissQueue.length > 0) {
|
|
310
|
+
for (const nissGrouping of this.#nissQueue.reverse()) {
|
|
306
311
|
algNodes.push(nissGrouping);
|
|
307
312
|
}
|
|
308
313
|
}
|
|
@@ -312,79 +317,103 @@ var AlgParser = class {
|
|
|
312
317
|
return newAlg;
|
|
313
318
|
}
|
|
314
319
|
parseMove(input) {
|
|
315
|
-
|
|
316
|
-
|
|
320
|
+
this.#input = input;
|
|
321
|
+
this.#idx = 0;
|
|
317
322
|
const move = this.parseMoveImpl();
|
|
318
323
|
this.mustBeAtEndOfInput();
|
|
319
324
|
return move;
|
|
320
325
|
}
|
|
321
326
|
parseQuantumMove(input) {
|
|
322
|
-
|
|
323
|
-
|
|
327
|
+
this.#input = input;
|
|
328
|
+
this.#idx = 0;
|
|
324
329
|
const quantumMove = this.parseQuantumMoveImpl();
|
|
325
330
|
this.mustBeAtEndOfInput();
|
|
326
331
|
return quantumMove;
|
|
327
332
|
}
|
|
328
333
|
mustBeAtEndOfInput() {
|
|
329
|
-
if (
|
|
334
|
+
if (this.#idx !== this.#input.length) {
|
|
330
335
|
throw new Error("parsing unexpectedly ended early");
|
|
331
336
|
}
|
|
332
337
|
}
|
|
333
338
|
parseAlgWithStopping(stopBefore) {
|
|
334
|
-
let algStartIdx =
|
|
335
|
-
let algEndIdx =
|
|
339
|
+
let algStartIdx = this.#idx;
|
|
340
|
+
let algEndIdx = this.#idx;
|
|
336
341
|
const algBuilder = new AlgBuilder();
|
|
337
342
|
let crowded = false;
|
|
338
343
|
const mustNotBeCrowded = (idx) => {
|
|
339
344
|
if (crowded) {
|
|
340
|
-
throw new Error(
|
|
345
|
+
throw new Error(
|
|
346
|
+
`Unexpected character at index ${idx}. Are you missing a space?`
|
|
347
|
+
);
|
|
341
348
|
}
|
|
342
349
|
};
|
|
343
350
|
mainLoop:
|
|
344
|
-
while (
|
|
345
|
-
const savedCharIndex =
|
|
346
|
-
if (stopBefore.includes(
|
|
351
|
+
while (this.#idx < this.#input.length) {
|
|
352
|
+
const savedCharIndex = this.#idx;
|
|
353
|
+
if (stopBefore.includes(this.#input[this.#idx])) {
|
|
347
354
|
return addCharIndices(algBuilder.toAlg(), algStartIdx, algEndIdx);
|
|
348
355
|
}
|
|
349
356
|
if (this.tryConsumeNext(" ")) {
|
|
350
357
|
crowded = false;
|
|
351
358
|
if (algBuilder.experimentalNumAlgNodes() === 0) {
|
|
352
|
-
algStartIdx =
|
|
359
|
+
algStartIdx = this.#idx;
|
|
353
360
|
}
|
|
354
361
|
continue mainLoop;
|
|
355
|
-
} else if (MOVE_START_REGEX.test(
|
|
362
|
+
} else if (MOVE_START_REGEX.test(this.#input[this.#idx])) {
|
|
356
363
|
mustNotBeCrowded(savedCharIndex);
|
|
357
364
|
const move = this.parseMoveImpl();
|
|
358
365
|
algBuilder.push(move);
|
|
359
366
|
crowded = true;
|
|
360
|
-
algEndIdx =
|
|
367
|
+
algEndIdx = this.#idx;
|
|
361
368
|
continue mainLoop;
|
|
362
369
|
} else if (this.tryConsumeNext("(")) {
|
|
363
370
|
mustNotBeCrowded(savedCharIndex);
|
|
364
371
|
const sq1PairStartMatch = this.tryRegex(SQUARE1_PAIR_START_REGEX);
|
|
365
372
|
if (sq1PairStartMatch) {
|
|
366
373
|
const topAmountString = sq1PairStartMatch[1];
|
|
367
|
-
const savedCharIndexD =
|
|
374
|
+
const savedCharIndexD = this.#idx;
|
|
368
375
|
const sq1PairEndMatch = this.parseRegex(SQUARE1_PAIR_END_REGEX);
|
|
369
|
-
const uMove = addCharIndices(
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
376
|
+
const uMove = addCharIndices(
|
|
377
|
+
new Move(new QuantumMove("U_SQ_"), parseInt(topAmountString)),
|
|
378
|
+
savedCharIndex + 1,
|
|
379
|
+
savedCharIndex + 1 + topAmountString.length
|
|
380
|
+
);
|
|
381
|
+
const dMove = addCharIndices(
|
|
382
|
+
new Move(new QuantumMove("D_SQ_"), parseInt(sq1PairEndMatch[1])),
|
|
383
|
+
savedCharIndexD,
|
|
384
|
+
this.#idx - 1
|
|
385
|
+
);
|
|
386
|
+
const alg = addCharIndices(
|
|
387
|
+
new Alg([uMove, dMove]),
|
|
388
|
+
savedCharIndex + 1,
|
|
389
|
+
this.#idx - 1
|
|
390
|
+
);
|
|
391
|
+
algBuilder.push(
|
|
392
|
+
addCharIndices(new Grouping(alg), savedCharIndex, this.#idx)
|
|
393
|
+
);
|
|
373
394
|
crowded = true;
|
|
374
|
-
algEndIdx =
|
|
395
|
+
algEndIdx = this.#idx;
|
|
375
396
|
continue mainLoop;
|
|
376
397
|
} else {
|
|
377
398
|
const alg = this.parseAlgWithStopping([")"]);
|
|
378
399
|
this.mustConsumeNext(")");
|
|
379
400
|
const amount = this.parseAmount();
|
|
380
|
-
algBuilder.push(
|
|
401
|
+
algBuilder.push(
|
|
402
|
+
addCharIndices(
|
|
403
|
+
new Grouping(alg, amount),
|
|
404
|
+
savedCharIndex,
|
|
405
|
+
this.#idx
|
|
406
|
+
)
|
|
407
|
+
);
|
|
381
408
|
crowded = true;
|
|
382
|
-
algEndIdx =
|
|
409
|
+
algEndIdx = this.#idx;
|
|
383
410
|
continue mainLoop;
|
|
384
411
|
}
|
|
385
412
|
} else if (this.tryConsumeNext("^")) {
|
|
386
413
|
if (!algDebugGlobals.caratNISSNotationEnabled) {
|
|
387
|
-
throw new Error(
|
|
414
|
+
throw new Error(
|
|
415
|
+
"Alg contained a carat but carat NISS notation is not enabled."
|
|
416
|
+
);
|
|
388
417
|
}
|
|
389
418
|
this.mustConsumeNext("(");
|
|
390
419
|
const alg = this.parseAlgWithStopping([")"]);
|
|
@@ -393,7 +422,7 @@ var AlgParser = class {
|
|
|
393
422
|
const placeholder = new Pause();
|
|
394
423
|
grouping.experimentalNISSPlaceholder = placeholder;
|
|
395
424
|
placeholder.experimentalNISSGrouping = grouping;
|
|
396
|
-
|
|
425
|
+
this.#nissQueue.push(grouping);
|
|
397
426
|
algBuilder.push(placeholder);
|
|
398
427
|
} else if (this.tryConsumeNext("[")) {
|
|
399
428
|
mustNotBeCrowded(savedCharIndex);
|
|
@@ -403,48 +432,58 @@ var AlgParser = class {
|
|
|
403
432
|
this.mustConsumeNext("]");
|
|
404
433
|
switch (separator) {
|
|
405
434
|
case ":":
|
|
406
|
-
algBuilder.push(
|
|
435
|
+
algBuilder.push(
|
|
436
|
+
addCharIndices(new Conjugate(A, B), savedCharIndex, this.#idx)
|
|
437
|
+
);
|
|
407
438
|
crowded = true;
|
|
408
|
-
algEndIdx =
|
|
439
|
+
algEndIdx = this.#idx;
|
|
409
440
|
continue mainLoop;
|
|
410
441
|
case ",":
|
|
411
|
-
algBuilder.push(
|
|
442
|
+
algBuilder.push(
|
|
443
|
+
addCharIndices(new Commutator(A, B), savedCharIndex, this.#idx)
|
|
444
|
+
);
|
|
412
445
|
crowded = true;
|
|
413
|
-
algEndIdx =
|
|
446
|
+
algEndIdx = this.#idx;
|
|
414
447
|
continue mainLoop;
|
|
415
448
|
default:
|
|
416
449
|
throw new Error("unexpected parsing error");
|
|
417
450
|
}
|
|
418
451
|
} else if (this.tryConsumeNext("\n")) {
|
|
419
|
-
algBuilder.push(
|
|
452
|
+
algBuilder.push(
|
|
453
|
+
addCharIndices(new Newline(), savedCharIndex, this.#idx)
|
|
454
|
+
);
|
|
420
455
|
crowded = false;
|
|
421
|
-
algEndIdx =
|
|
456
|
+
algEndIdx = this.#idx;
|
|
422
457
|
continue mainLoop;
|
|
423
458
|
} else if (this.tryConsumeNext("/")) {
|
|
424
459
|
if (this.tryConsumeNext("/")) {
|
|
425
460
|
mustNotBeCrowded(savedCharIndex);
|
|
426
461
|
const [text] = this.parseRegex(COMMENT_TEXT_REGEX);
|
|
427
|
-
algBuilder.push(
|
|
462
|
+
algBuilder.push(
|
|
463
|
+
addCharIndices(new LineComment(text), savedCharIndex, this.#idx)
|
|
464
|
+
);
|
|
428
465
|
crowded = false;
|
|
429
|
-
algEndIdx =
|
|
466
|
+
algEndIdx = this.#idx;
|
|
430
467
|
continue mainLoop;
|
|
431
468
|
} else {
|
|
432
|
-
algBuilder.push(
|
|
469
|
+
algBuilder.push(
|
|
470
|
+
addCharIndices(new Move("_SLASH_"), savedCharIndex, this.#idx)
|
|
471
|
+
);
|
|
433
472
|
crowded = true;
|
|
434
|
-
algEndIdx =
|
|
473
|
+
algEndIdx = this.#idx;
|
|
435
474
|
continue mainLoop;
|
|
436
475
|
}
|
|
437
476
|
} else if (this.tryConsumeNext(".")) {
|
|
438
477
|
mustNotBeCrowded(savedCharIndex);
|
|
439
|
-
algBuilder.push(addCharIndices(new Pause(), savedCharIndex,
|
|
478
|
+
algBuilder.push(addCharIndices(new Pause(), savedCharIndex, this.#idx));
|
|
440
479
|
crowded = true;
|
|
441
|
-
algEndIdx =
|
|
480
|
+
algEndIdx = this.#idx;
|
|
442
481
|
continue mainLoop;
|
|
443
482
|
} else {
|
|
444
483
|
throw new Error(`Unexpected character: ${this.popNext()}`);
|
|
445
484
|
}
|
|
446
485
|
}
|
|
447
|
-
if (
|
|
486
|
+
if (this.#idx !== this.#input.length) {
|
|
448
487
|
throw new Error("did not finish parsing?");
|
|
449
488
|
}
|
|
450
489
|
if (stopBefore.length > 0) {
|
|
@@ -454,12 +493,16 @@ var AlgParser = class {
|
|
|
454
493
|
}
|
|
455
494
|
parseQuantumMoveImpl() {
|
|
456
495
|
const [, , , outerLayerStr, innerLayerStr, family] = this.parseRegex(QUANTUM_MOVE_REGEX);
|
|
457
|
-
return new QuantumMove(
|
|
496
|
+
return new QuantumMove(
|
|
497
|
+
family,
|
|
498
|
+
parseIntWithEmptyFallback(innerLayerStr, void 0),
|
|
499
|
+
parseIntWithEmptyFallback(outerLayerStr, void 0)
|
|
500
|
+
);
|
|
458
501
|
}
|
|
459
502
|
parseMoveImpl() {
|
|
460
|
-
const savedCharIndex =
|
|
503
|
+
const savedCharIndex = this.#idx;
|
|
461
504
|
if (this.tryConsumeNext("/")) {
|
|
462
|
-
return addCharIndices(new Move("_SLASH_"), savedCharIndex,
|
|
505
|
+
return addCharIndices(new Move("_SLASH_"), savedCharIndex, this.#idx);
|
|
463
506
|
}
|
|
464
507
|
let quantumMove = this.parseQuantumMoveImpl();
|
|
465
508
|
let [amount, hadEmptyAbsAmount] = this.parseAmountAndTrackEmptyAbsAmount();
|
|
@@ -469,13 +512,19 @@ var AlgParser = class {
|
|
|
469
512
|
throw new Error("uh-oh");
|
|
470
513
|
}
|
|
471
514
|
if ((suffix === "++" || suffix === "--") && amount !== 1) {
|
|
472
|
-
throw new Error(
|
|
515
|
+
throw new Error(
|
|
516
|
+
"Pochmann ++ or -- moves cannot have an amount other than 1."
|
|
517
|
+
);
|
|
473
518
|
}
|
|
474
519
|
if ((suffix === "++" || suffix === "--") && !hadEmptyAbsAmount) {
|
|
475
|
-
throw new Error(
|
|
520
|
+
throw new Error(
|
|
521
|
+
"Pochmann ++ or -- moves cannot have an amount written as a number."
|
|
522
|
+
);
|
|
476
523
|
}
|
|
477
524
|
if ((suffix === "+" || suffix === "-") && hadEmptyAbsAmount) {
|
|
478
|
-
throw new Error(
|
|
525
|
+
throw new Error(
|
|
526
|
+
"Clock dial moves must have an amount written as a natural number followed by + or -."
|
|
527
|
+
);
|
|
479
528
|
}
|
|
480
529
|
if (suffix.startsWith("+")) {
|
|
481
530
|
quantumMove = quantumMove.modified({
|
|
@@ -489,7 +538,11 @@ var AlgParser = class {
|
|
|
489
538
|
amount *= -1;
|
|
490
539
|
}
|
|
491
540
|
}
|
|
492
|
-
const move = addCharIndices(
|
|
541
|
+
const move = addCharIndices(
|
|
542
|
+
new Move(quantumMove, amount),
|
|
543
|
+
savedCharIndex,
|
|
544
|
+
this.#idx
|
|
545
|
+
);
|
|
493
546
|
return move;
|
|
494
547
|
}
|
|
495
548
|
parseMoveSuffix() {
|
|
@@ -508,10 +561,12 @@ var AlgParser = class {
|
|
|
508
561
|
return null;
|
|
509
562
|
}
|
|
510
563
|
parseAmountAndTrackEmptyAbsAmount() {
|
|
511
|
-
const savedIdx =
|
|
564
|
+
const savedIdx = this.#idx;
|
|
512
565
|
const [, absAmountStr, primeStr] = this.parseRegex(AMOUNT_REGEX);
|
|
513
566
|
if (absAmountStr?.startsWith("0") && absAmountStr !== "0") {
|
|
514
|
-
throw new Error(
|
|
567
|
+
throw new Error(
|
|
568
|
+
`Error at char index ${savedIdx}: An amount can only start with 0 if it's exactly the digit 0.`
|
|
569
|
+
);
|
|
515
570
|
}
|
|
516
571
|
return [
|
|
517
572
|
parseIntWithEmptyFallback(absAmountStr, 1) * (primeStr === "'" ? -1 : 1),
|
|
@@ -519,10 +574,12 @@ var AlgParser = class {
|
|
|
519
574
|
];
|
|
520
575
|
}
|
|
521
576
|
parseAmount() {
|
|
522
|
-
const savedIdx =
|
|
577
|
+
const savedIdx = this.#idx;
|
|
523
578
|
const [, absAmountStr, primeStr] = this.parseRegex(AMOUNT_REGEX);
|
|
524
579
|
if (absAmountStr?.startsWith("0") && absAmountStr !== "0") {
|
|
525
|
-
throw new Error(
|
|
580
|
+
throw new Error(
|
|
581
|
+
`Error at char index ${savedIdx}: An amount number can only start with 0 if it's exactly the digit 0.`
|
|
582
|
+
);
|
|
526
583
|
}
|
|
527
584
|
return parseIntWithEmptyFallback(absAmountStr, 1) * (primeStr === "'" ? -1 : 1);
|
|
528
585
|
}
|
|
@@ -531,7 +588,7 @@ var AlgParser = class {
|
|
|
531
588
|
if (arr === null) {
|
|
532
589
|
throw new Error("internal parsing error");
|
|
533
590
|
}
|
|
534
|
-
|
|
591
|
+
this.#idx += arr[0].length;
|
|
535
592
|
return arr;
|
|
536
593
|
}
|
|
537
594
|
tryRegex(regex) {
|
|
@@ -539,20 +596,20 @@ var AlgParser = class {
|
|
|
539
596
|
if (arr === null) {
|
|
540
597
|
return null;
|
|
541
598
|
}
|
|
542
|
-
|
|
599
|
+
this.#idx += arr[0].length;
|
|
543
600
|
return arr;
|
|
544
601
|
}
|
|
545
602
|
remaining() {
|
|
546
|
-
return
|
|
603
|
+
return this.#input.slice(this.#idx);
|
|
547
604
|
}
|
|
548
605
|
popNext() {
|
|
549
|
-
const next =
|
|
550
|
-
|
|
606
|
+
const next = this.#input[this.#idx];
|
|
607
|
+
this.#idx++;
|
|
551
608
|
return next;
|
|
552
609
|
}
|
|
553
610
|
tryConsumeNext(expected) {
|
|
554
|
-
if (
|
|
555
|
-
|
|
611
|
+
if (this.#input[this.#idx] === expected) {
|
|
612
|
+
this.#idx++;
|
|
556
613
|
return true;
|
|
557
614
|
}
|
|
558
615
|
return false;
|
|
@@ -560,14 +617,13 @@ var AlgParser = class {
|
|
|
560
617
|
mustConsumeNext(expected) {
|
|
561
618
|
const next = this.popNext();
|
|
562
619
|
if (next !== expected) {
|
|
563
|
-
throw new Error(
|
|
620
|
+
throw new Error(
|
|
621
|
+
`expected \`${expected}\` while parsing, encountered ${next}`
|
|
622
|
+
);
|
|
564
623
|
}
|
|
565
624
|
return next;
|
|
566
625
|
}
|
|
567
626
|
};
|
|
568
|
-
_input = new WeakMap();
|
|
569
|
-
_idx = new WeakMap();
|
|
570
|
-
_nissQueue = new WeakMap();
|
|
571
627
|
|
|
572
628
|
// src/cubing/alg/warnOnce.ts
|
|
573
629
|
var warned = /* @__PURE__ */ new Set();
|
|
@@ -584,7 +640,9 @@ var QuantumWithAmount = class {
|
|
|
584
640
|
this.quantum = quantum;
|
|
585
641
|
this.amount = amount;
|
|
586
642
|
if (!Number.isInteger(this.amount) || this.amount < MIN_INT || this.amount > MAX_INT) {
|
|
587
|
-
throw new Error(
|
|
643
|
+
throw new Error(
|
|
644
|
+
`AlgNode amount absolute value must be a non-negative integer below ${MAX_INT_DESCRIPTION}.`
|
|
645
|
+
);
|
|
588
646
|
}
|
|
589
647
|
}
|
|
590
648
|
suffix() {
|
|
@@ -611,88 +669,105 @@ var QuantumWithAmount = class {
|
|
|
611
669
|
};
|
|
612
670
|
|
|
613
671
|
// src/cubing/alg/alg-nodes/leaves/Move.ts
|
|
614
|
-
var
|
|
615
|
-
|
|
672
|
+
var QuantumMove = class extends Comparable {
|
|
673
|
+
#family;
|
|
674
|
+
#innerLayer;
|
|
675
|
+
#outerLayer;
|
|
616
676
|
constructor(family, innerLayer, outerLayer) {
|
|
617
677
|
super();
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
__privateSet(this, _family, family);
|
|
622
|
-
__privateSet(this, _innerLayer, innerLayer ?? null);
|
|
623
|
-
__privateSet(this, _outerLayer, outerLayer ?? null);
|
|
678
|
+
this.#family = family;
|
|
679
|
+
this.#innerLayer = innerLayer ?? null;
|
|
680
|
+
this.#outerLayer = outerLayer ?? null;
|
|
624
681
|
Object.freeze(this);
|
|
625
|
-
if (
|
|
626
|
-
throw new Error(
|
|
682
|
+
if (this.#innerLayer !== null && (!Number.isInteger(this.#innerLayer) || this.#innerLayer < 1 || this.#innerLayer > MAX_INT)) {
|
|
683
|
+
throw new Error(
|
|
684
|
+
`QuantumMove inner layer must be a positive integer below ${MAX_INT_DESCRIPTION}.`
|
|
685
|
+
);
|
|
627
686
|
}
|
|
628
|
-
if (
|
|
629
|
-
throw new Error(
|
|
687
|
+
if (this.#outerLayer !== null && (!Number.isInteger(this.#outerLayer) || this.#outerLayer < 1 || this.#outerLayer > MAX_INT)) {
|
|
688
|
+
throw new Error(
|
|
689
|
+
`QuantumMove outer layer must be a positive integer below ${MAX_INT_DESCRIPTION}.`
|
|
690
|
+
);
|
|
630
691
|
}
|
|
631
|
-
if (
|
|
632
|
-
throw new Error(
|
|
692
|
+
if (this.#outerLayer !== null && this.#innerLayer !== null && this.#innerLayer <= this.#outerLayer) {
|
|
693
|
+
throw new Error(
|
|
694
|
+
"QuantumMove outer layer must be smaller than inner layer."
|
|
695
|
+
);
|
|
633
696
|
}
|
|
634
|
-
if (
|
|
635
|
-
throw new Error(
|
|
697
|
+
if (this.#outerLayer !== null && this.#innerLayer === null) {
|
|
698
|
+
throw new Error(
|
|
699
|
+
"QuantumMove with an outer layer must have an inner layer"
|
|
700
|
+
);
|
|
636
701
|
}
|
|
637
702
|
}
|
|
638
703
|
static fromString(s) {
|
|
639
704
|
return parseQuantumMove(s);
|
|
640
705
|
}
|
|
641
706
|
modified(modifications) {
|
|
642
|
-
return new
|
|
707
|
+
return new QuantumMove(
|
|
708
|
+
modifications.family ?? this.#family,
|
|
709
|
+
modifications.innerLayer ?? this.#innerLayer,
|
|
710
|
+
modifications.outerLayer ?? this.#outerLayer
|
|
711
|
+
);
|
|
643
712
|
}
|
|
644
713
|
isIdentical(other) {
|
|
645
714
|
const otherAsQuantumMove = other;
|
|
646
|
-
return other.is(
|
|
715
|
+
return other.is(QuantumMove) && this.#family === otherAsQuantumMove.#family && this.#innerLayer === otherAsQuantumMove.#innerLayer && this.#outerLayer === otherAsQuantumMove.#outerLayer;
|
|
647
716
|
}
|
|
648
717
|
get family() {
|
|
649
|
-
return
|
|
718
|
+
return this.#family;
|
|
650
719
|
}
|
|
651
720
|
get outerLayer() {
|
|
652
|
-
return
|
|
721
|
+
return this.#outerLayer;
|
|
653
722
|
}
|
|
654
723
|
get innerLayer() {
|
|
655
|
-
return
|
|
724
|
+
return this.#innerLayer;
|
|
656
725
|
}
|
|
657
726
|
experimentalExpand() {
|
|
658
|
-
throw new Error(
|
|
727
|
+
throw new Error(
|
|
728
|
+
"experimentalExpand() cannot be called on a `QuantumMove` directly."
|
|
729
|
+
);
|
|
659
730
|
}
|
|
660
731
|
toString() {
|
|
661
|
-
let s =
|
|
662
|
-
if (
|
|
663
|
-
s = String(
|
|
664
|
-
if (
|
|
665
|
-
s = String(
|
|
732
|
+
let s = this.#family;
|
|
733
|
+
if (this.#innerLayer !== null) {
|
|
734
|
+
s = String(this.#innerLayer) + s;
|
|
735
|
+
if (this.#outerLayer !== null) {
|
|
736
|
+
s = String(this.#outerLayer) + "-" + s;
|
|
666
737
|
}
|
|
667
738
|
}
|
|
668
739
|
return s;
|
|
669
740
|
}
|
|
670
741
|
};
|
|
671
|
-
var
|
|
672
|
-
|
|
673
|
-
_innerLayer = new WeakMap();
|
|
674
|
-
_outerLayer = new WeakMap();
|
|
675
|
-
var _quantumWithAmount;
|
|
676
|
-
var _Move = class extends AlgCommon {
|
|
742
|
+
var Move = class extends AlgCommon {
|
|
743
|
+
#quantumWithAmount;
|
|
677
744
|
constructor(...args) {
|
|
678
745
|
super();
|
|
679
|
-
__privateAdd(this, _quantumWithAmount, void 0);
|
|
680
746
|
if (typeof args[0] === "string") {
|
|
681
747
|
if (args[1] ?? null) {
|
|
682
|
-
|
|
748
|
+
this.#quantumWithAmount = new QuantumWithAmount(
|
|
749
|
+
QuantumMove.fromString(args[0]),
|
|
750
|
+
args[1]
|
|
751
|
+
);
|
|
683
752
|
return;
|
|
684
753
|
} else {
|
|
685
|
-
return
|
|
754
|
+
return Move.fromString(args[0]);
|
|
686
755
|
}
|
|
687
756
|
}
|
|
688
|
-
|
|
757
|
+
this.#quantumWithAmount = new QuantumWithAmount(
|
|
758
|
+
args[0],
|
|
759
|
+
args[1]
|
|
760
|
+
);
|
|
689
761
|
}
|
|
690
762
|
isIdentical(other) {
|
|
691
|
-
const otherAsMove = other.as(
|
|
692
|
-
return !!otherAsMove &&
|
|
763
|
+
const otherAsMove = other.as(Move);
|
|
764
|
+
return !!otherAsMove && this.#quantumWithAmount.isIdentical(otherAsMove.#quantumWithAmount);
|
|
693
765
|
}
|
|
694
766
|
invert() {
|
|
695
|
-
return transferCharIndex(
|
|
767
|
+
return transferCharIndex(
|
|
768
|
+
this,
|
|
769
|
+
new Move(this.#quantumWithAmount.quantum, -this.amount)
|
|
770
|
+
);
|
|
696
771
|
}
|
|
697
772
|
*experimentalExpand(iterDir = 1 /* Forwards */) {
|
|
698
773
|
if (iterDir === 1 /* Forwards */) {
|
|
@@ -704,46 +779,47 @@ var _Move = class extends AlgCommon {
|
|
|
704
779
|
}
|
|
705
780
|
}
|
|
706
781
|
get quantum() {
|
|
707
|
-
return
|
|
782
|
+
return this.#quantumWithAmount.quantum;
|
|
708
783
|
}
|
|
709
784
|
modified(modifications) {
|
|
710
|
-
return new
|
|
785
|
+
return new Move(
|
|
786
|
+
this.#quantumWithAmount.quantum.modified(modifications),
|
|
787
|
+
modifications.amount ?? this.amount
|
|
788
|
+
);
|
|
711
789
|
}
|
|
712
790
|
static fromString(s) {
|
|
713
791
|
return parseMove(s);
|
|
714
792
|
}
|
|
715
793
|
get amount() {
|
|
716
|
-
return
|
|
794
|
+
return this.#quantumWithAmount.amount;
|
|
717
795
|
}
|
|
718
796
|
get type() {
|
|
719
797
|
warnOnce("deprecated: type");
|
|
720
798
|
return "blockMove";
|
|
721
799
|
}
|
|
722
800
|
get family() {
|
|
723
|
-
return
|
|
801
|
+
return this.#quantumWithAmount.quantum.family ?? void 0;
|
|
724
802
|
}
|
|
725
803
|
get outerLayer() {
|
|
726
|
-
return
|
|
804
|
+
return this.#quantumWithAmount.quantum.outerLayer ?? void 0;
|
|
727
805
|
}
|
|
728
806
|
get innerLayer() {
|
|
729
|
-
return
|
|
807
|
+
return this.#quantumWithAmount.quantum.innerLayer ?? void 0;
|
|
730
808
|
}
|
|
731
809
|
toString() {
|
|
732
810
|
if (this.family === "_SLASH_") {
|
|
733
811
|
return "/";
|
|
734
812
|
}
|
|
735
813
|
if (this.family.endsWith("_PLUS_")) {
|
|
736
|
-
return
|
|
814
|
+
return this.#quantumWithAmount.quantum.toString().slice(0, -6) + Math.abs(this.amount) + (this.amount < 0 ? "-" : "+");
|
|
737
815
|
}
|
|
738
816
|
if (this.family.endsWith("_PLUSPLUS_")) {
|
|
739
817
|
const absAmount = Math.abs(this.amount);
|
|
740
|
-
return
|
|
818
|
+
return this.#quantumWithAmount.quantum.toString().slice(0, -10) + (absAmount === 1 ? "" : absAmount) + (this.amount < 0 ? "--" : "++");
|
|
741
819
|
}
|
|
742
|
-
return
|
|
820
|
+
return this.#quantumWithAmount.quantum.toString() + this.#quantumWithAmount.suffix();
|
|
743
821
|
}
|
|
744
822
|
};
|
|
745
|
-
var Move = _Move;
|
|
746
|
-
_quantumWithAmount = new WeakMap();
|
|
747
823
|
|
|
748
824
|
// src/cubing/alg/alg-nodes/containers/Grouping.ts
|
|
749
825
|
var Square1TupleFormatter = class {
|
|
@@ -766,7 +842,9 @@ var Square1TupleFormatter = class {
|
|
|
766
842
|
const [U, D] = quantumAlg.childAlgNodes();
|
|
767
843
|
if (U.as(Move)?.quantum.isIdentical(this.quantumU_SQ_) && D.as(Move)?.quantum.isIdentical(this.quantumD_SQ_)) {
|
|
768
844
|
if (grouping.amount !== 1) {
|
|
769
|
-
throw new Error(
|
|
845
|
+
throw new Error(
|
|
846
|
+
"Square-1 tuples cannot have an amount other than 1."
|
|
847
|
+
);
|
|
770
848
|
}
|
|
771
849
|
return [U, D];
|
|
772
850
|
}
|
|
@@ -775,50 +853,50 @@ var Square1TupleFormatter = class {
|
|
|
775
853
|
}
|
|
776
854
|
};
|
|
777
855
|
var square1TupleFormatterInstance = new Square1TupleFormatter();
|
|
778
|
-
var
|
|
779
|
-
var _Grouping = class extends AlgCommon {
|
|
856
|
+
var Grouping = class extends AlgCommon {
|
|
780
857
|
constructor(algSource, amount) {
|
|
781
858
|
super();
|
|
782
|
-
__privateAdd(this, _quantumWithAmount2, void 0);
|
|
783
859
|
const alg = experimentalEnsureAlg(algSource);
|
|
784
|
-
|
|
860
|
+
this.#quantumWithAmount = new QuantumWithAmount(alg, amount);
|
|
785
861
|
}
|
|
862
|
+
#quantumWithAmount;
|
|
786
863
|
isIdentical(other) {
|
|
787
864
|
const otherAsGrouping = other;
|
|
788
|
-
return other.is(
|
|
865
|
+
return other.is(Grouping) && this.#quantumWithAmount.isIdentical(otherAsGrouping.#quantumWithAmount);
|
|
789
866
|
}
|
|
790
867
|
get alg() {
|
|
791
|
-
return
|
|
868
|
+
return this.#quantumWithAmount.quantum;
|
|
792
869
|
}
|
|
793
870
|
get amount() {
|
|
794
|
-
return
|
|
871
|
+
return this.#quantumWithAmount.amount;
|
|
795
872
|
}
|
|
796
873
|
get experimentalRepetitionSuffix() {
|
|
797
|
-
return
|
|
874
|
+
return this.#quantumWithAmount.suffix();
|
|
798
875
|
}
|
|
799
876
|
invert() {
|
|
800
|
-
return new
|
|
877
|
+
return new Grouping(
|
|
878
|
+
this.#quantumWithAmount.quantum,
|
|
879
|
+
-this.#quantumWithAmount.amount
|
|
880
|
+
);
|
|
801
881
|
}
|
|
802
882
|
*experimentalExpand(iterDir = 1 /* Forwards */, depth) {
|
|
803
883
|
depth ?? (depth = Infinity);
|
|
804
884
|
if (depth === 0) {
|
|
805
885
|
yield iterDir === 1 /* Forwards */ ? this : this.invert();
|
|
806
886
|
} else {
|
|
807
|
-
yield*
|
|
887
|
+
yield* this.#quantumWithAmount.experimentalExpand(iterDir, depth - 1);
|
|
808
888
|
}
|
|
809
889
|
}
|
|
810
890
|
static fromString() {
|
|
811
891
|
throw new Error("unimplemented");
|
|
812
892
|
}
|
|
813
893
|
toString() {
|
|
814
|
-
return square1TupleFormatterInstance.format(this) ?? `(${
|
|
894
|
+
return square1TupleFormatterInstance.format(this) ?? `(${this.#quantumWithAmount.quantum.toString()})${this.#quantumWithAmount.suffix()}`;
|
|
815
895
|
}
|
|
816
896
|
experimentalAsSquare1Tuple() {
|
|
817
897
|
return square1TupleFormatterInstance.tuple(this);
|
|
818
898
|
}
|
|
819
899
|
};
|
|
820
|
-
var Grouping = _Grouping;
|
|
821
|
-
_quantumWithAmount2 = new WeakMap();
|
|
822
900
|
|
|
823
901
|
// src/cubing/alg/is.ts
|
|
824
902
|
function experimentalIs(v, c) {
|
|
@@ -869,7 +947,11 @@ var TraversalDownUp = class {
|
|
|
869
947
|
};
|
|
870
948
|
var TraversalUp = class extends TraversalDownUp {
|
|
871
949
|
traverseAlgNode(algNode) {
|
|
872
|
-
return dispatch(
|
|
950
|
+
return dispatch(
|
|
951
|
+
this,
|
|
952
|
+
algNode,
|
|
953
|
+
void 0
|
|
954
|
+
);
|
|
873
955
|
}
|
|
874
956
|
traverseIntoAlgNode(algNode) {
|
|
875
957
|
return mustBeAlgNode(this.traverseAlgNode(algNode));
|
|
@@ -904,7 +986,10 @@ var _Simplify = class extends TraversalDownUp {
|
|
|
904
986
|
function appendCollapsed(newAlgNode) {
|
|
905
987
|
if (collapseMoves && lastAlgNode?.is(Move) && newAlgNode.is(Move) && lastAlgNode.quantum.isIdentical(newAlgNode.quantum)) {
|
|
906
988
|
newAlgNodes.pop();
|
|
907
|
-
if (!appendMoveWithNewAmount(
|
|
989
|
+
if (!appendMoveWithNewAmount(
|
|
990
|
+
lastAlgNode,
|
|
991
|
+
newAlgNode.amount
|
|
992
|
+
)) {
|
|
908
993
|
lastAlgNode = newAlgNodes.slice(-1)[0];
|
|
909
994
|
}
|
|
910
995
|
} else {
|
|
@@ -936,7 +1021,10 @@ var _Simplify = class extends TraversalDownUp {
|
|
|
936
1021
|
const newOptions = {
|
|
937
1022
|
depth: options.depth ? options.depth - 1 : null
|
|
938
1023
|
};
|
|
939
|
-
const newGrouping = new Grouping(
|
|
1024
|
+
const newGrouping = new Grouping(
|
|
1025
|
+
this.traverseAlg(grouping.alg, newOptions),
|
|
1026
|
+
grouping.amount
|
|
1027
|
+
);
|
|
940
1028
|
const newPlaceholder = __privateMethod(this, _newPlaceholderAssociations, newPlaceholderAssociations_fn).call(this).get(grouping);
|
|
941
1029
|
if (newPlaceholder) {
|
|
942
1030
|
newGrouping.experimentalNISSPlaceholder = newPlaceholder;
|
|
@@ -955,7 +1043,10 @@ var _Simplify = class extends TraversalDownUp {
|
|
|
955
1043
|
const newOptions = {
|
|
956
1044
|
depth: options.depth ? options.depth - 1 : null
|
|
957
1045
|
};
|
|
958
|
-
yield new Commutator(
|
|
1046
|
+
yield new Commutator(
|
|
1047
|
+
this.traverseAlg(commutator.A, newOptions),
|
|
1048
|
+
this.traverseAlg(commutator.B, newOptions)
|
|
1049
|
+
);
|
|
959
1050
|
}
|
|
960
1051
|
*traverseConjugate(conjugate, options) {
|
|
961
1052
|
if (options.depth === 0) {
|
|
@@ -965,12 +1056,18 @@ var _Simplify = class extends TraversalDownUp {
|
|
|
965
1056
|
const newOptions = {
|
|
966
1057
|
depth: options.depth ? options.depth - 1 : null
|
|
967
1058
|
};
|
|
968
|
-
yield new Conjugate(
|
|
1059
|
+
yield new Conjugate(
|
|
1060
|
+
this.traverseAlg(conjugate.A, newOptions),
|
|
1061
|
+
this.traverseAlg(conjugate.B, newOptions)
|
|
1062
|
+
);
|
|
969
1063
|
}
|
|
970
1064
|
*traversePause(pause, _options) {
|
|
971
1065
|
if (pause.experimentalNISSGrouping) {
|
|
972
1066
|
const newPause = new Pause();
|
|
973
|
-
__privateMethod(this, _newPlaceholderAssociations, newPlaceholderAssociations_fn).call(this).set(
|
|
1067
|
+
__privateMethod(this, _newPlaceholderAssociations, newPlaceholderAssociations_fn).call(this).set(
|
|
1068
|
+
pause.experimentalNISSGrouping,
|
|
1069
|
+
newPause
|
|
1070
|
+
);
|
|
974
1071
|
yield newPause;
|
|
975
1072
|
} else {
|
|
976
1073
|
yield pause;
|
|
@@ -1026,13 +1123,12 @@ function experimentalEnsureAlg(alg) {
|
|
|
1026
1123
|
}
|
|
1027
1124
|
return new Alg(alg);
|
|
1028
1125
|
}
|
|
1029
|
-
var
|
|
1030
|
-
|
|
1126
|
+
var Alg = class extends AlgCommon {
|
|
1127
|
+
#algNodes;
|
|
1031
1128
|
constructor(alg) {
|
|
1032
1129
|
super();
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
for (const algNode of __privateGet(this, _algNodes)) {
|
|
1130
|
+
this.#algNodes = Array.from(toIterable(alg));
|
|
1131
|
+
for (const algNode of this.#algNodes) {
|
|
1036
1132
|
if (!experimentalIsAlgNode(algNode)) {
|
|
1037
1133
|
throw new Error("An alg can only contain alg nodes.");
|
|
1038
1134
|
}
|
|
@@ -1040,11 +1136,11 @@ var _Alg = class extends AlgCommon {
|
|
|
1040
1136
|
}
|
|
1041
1137
|
isIdentical(other) {
|
|
1042
1138
|
const otherAsAlg = other;
|
|
1043
|
-
if (!other.is(
|
|
1139
|
+
if (!other.is(Alg)) {
|
|
1044
1140
|
return false;
|
|
1045
1141
|
}
|
|
1046
|
-
const l1 = Array.from(
|
|
1047
|
-
const l2 = Array.from(
|
|
1142
|
+
const l1 = Array.from(this.#algNodes);
|
|
1143
|
+
const l2 = Array.from(otherAsAlg.#algNodes);
|
|
1048
1144
|
if (l1.length !== l2.length) {
|
|
1049
1145
|
return false;
|
|
1050
1146
|
}
|
|
@@ -1056,16 +1152,21 @@ var _Alg = class extends AlgCommon {
|
|
|
1056
1152
|
return true;
|
|
1057
1153
|
}
|
|
1058
1154
|
invert() {
|
|
1059
|
-
return new
|
|
1155
|
+
return new Alg(reverse(Array.from(this.#algNodes).map((u) => u.invert())));
|
|
1060
1156
|
}
|
|
1061
1157
|
*experimentalExpand(iterDir = 1 /* Forwards */, depth) {
|
|
1062
1158
|
depth ?? (depth = Infinity);
|
|
1063
|
-
for (const algNode of direct(
|
|
1159
|
+
for (const algNode of direct(this.#algNodes, iterDir)) {
|
|
1064
1160
|
yield* algNode.experimentalExpand(iterDir, depth);
|
|
1065
1161
|
}
|
|
1066
1162
|
}
|
|
1067
1163
|
expand(options) {
|
|
1068
|
-
return new
|
|
1164
|
+
return new Alg(
|
|
1165
|
+
this.experimentalExpand(
|
|
1166
|
+
1 /* Forwards */,
|
|
1167
|
+
options?.depth ?? Infinity
|
|
1168
|
+
)
|
|
1169
|
+
);
|
|
1069
1170
|
}
|
|
1070
1171
|
*experimentalLeafMoves() {
|
|
1071
1172
|
for (const leaf of this.experimentalExpand()) {
|
|
@@ -1075,10 +1176,12 @@ var _Alg = class extends AlgCommon {
|
|
|
1075
1176
|
}
|
|
1076
1177
|
}
|
|
1077
1178
|
concat(input) {
|
|
1078
|
-
return new
|
|
1179
|
+
return new Alg(
|
|
1180
|
+
Array.from(this.#algNodes).concat(Array.from(toIterable(input)))
|
|
1181
|
+
);
|
|
1079
1182
|
}
|
|
1080
1183
|
experimentalIsEmpty() {
|
|
1081
|
-
for (const _ of
|
|
1184
|
+
for (const _ of this.#algNodes) {
|
|
1082
1185
|
return false;
|
|
1083
1186
|
}
|
|
1084
1187
|
return true;
|
|
@@ -1090,7 +1193,7 @@ var _Alg = class extends AlgCommon {
|
|
|
1090
1193
|
return this.childAlgNodes();
|
|
1091
1194
|
}
|
|
1092
1195
|
*childAlgNodes() {
|
|
1093
|
-
for (const algNode of
|
|
1196
|
+
for (const algNode of this.#algNodes) {
|
|
1094
1197
|
yield algNode;
|
|
1095
1198
|
}
|
|
1096
1199
|
}
|
|
@@ -1098,7 +1201,7 @@ var _Alg = class extends AlgCommon {
|
|
|
1098
1201
|
return this.experimentalNumChildAlgNodes();
|
|
1099
1202
|
}
|
|
1100
1203
|
experimentalNumChildAlgNodes() {
|
|
1101
|
-
return Array.from(
|
|
1204
|
+
return Array.from(this.#algNodes).length;
|
|
1102
1205
|
}
|
|
1103
1206
|
get type() {
|
|
1104
1207
|
warnOnce("deprecated: type");
|
|
@@ -1107,7 +1210,7 @@ var _Alg = class extends AlgCommon {
|
|
|
1107
1210
|
toString() {
|
|
1108
1211
|
let output = "";
|
|
1109
1212
|
let previousVisibleAlgNode = null;
|
|
1110
|
-
for (const algNode of
|
|
1213
|
+
for (const algNode of this.#algNodes) {
|
|
1111
1214
|
if (previousVisibleAlgNode) {
|
|
1112
1215
|
output += spaceBetween(previousVisibleAlgNode, algNode);
|
|
1113
1216
|
}
|
|
@@ -1126,11 +1229,9 @@ var _Alg = class extends AlgCommon {
|
|
|
1126
1229
|
return output;
|
|
1127
1230
|
}
|
|
1128
1231
|
simplify(options) {
|
|
1129
|
-
return new
|
|
1232
|
+
return new Alg(simplify(this, options ?? {}));
|
|
1130
1233
|
}
|
|
1131
1234
|
};
|
|
1132
|
-
var Alg = _Alg;
|
|
1133
|
-
_algNodes = new WeakMap();
|
|
1134
1235
|
function spaceBetween(u1, u2) {
|
|
1135
1236
|
if (u1.is(Newline) || u2.is(Newline)) {
|
|
1136
1237
|
return "";
|
|
@@ -1165,9 +1266,12 @@ var Example = {
|
|
|
1165
1266
|
new Move("R", -1)
|
|
1166
1267
|
]),
|
|
1167
1268
|
SuneCommutator: new Alg([
|
|
1168
|
-
new Commutator(
|
|
1169
|
-
new
|
|
1170
|
-
|
|
1269
|
+
new Commutator(
|
|
1270
|
+
new Alg([new Move("R", 1), new Move("U", 1), new Move("R", -2)]),
|
|
1271
|
+
new Alg([
|
|
1272
|
+
new Conjugate(new Alg([new Move("R", 1)]), new Alg([new Move("U", 1)]))
|
|
1273
|
+
])
|
|
1274
|
+
)
|
|
1171
1275
|
]),
|
|
1172
1276
|
Niklas: new Alg([
|
|
1173
1277
|
new Move("R", 1),
|
|
@@ -1181,23 +1285,44 @@ var Example = {
|
|
|
1181
1285
|
]),
|
|
1182
1286
|
EPerm: new Alg([
|
|
1183
1287
|
new Move("x", -1),
|
|
1184
|
-
new Commutator(
|
|
1185
|
-
new
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1288
|
+
new Commutator(
|
|
1289
|
+
new Alg([
|
|
1290
|
+
new Conjugate(
|
|
1291
|
+
new Alg([new Move("R", 1)]),
|
|
1292
|
+
new Alg([new Move("U", -1)])
|
|
1293
|
+
)
|
|
1294
|
+
]),
|
|
1295
|
+
new Alg([new Move("D", 1)])
|
|
1296
|
+
),
|
|
1297
|
+
new Commutator(
|
|
1298
|
+
new Alg([
|
|
1299
|
+
new Conjugate(new Alg([new Move("R", 1)]), new Alg([new Move("U", 1)]))
|
|
1300
|
+
]),
|
|
1301
|
+
new Alg([new Move("D", 1)])
|
|
1302
|
+
),
|
|
1190
1303
|
new Move("x", 1)
|
|
1191
1304
|
]),
|
|
1192
1305
|
FURURFCompact: new Alg([
|
|
1193
|
-
new Conjugate(
|
|
1194
|
-
new
|
|
1195
|
-
|
|
1306
|
+
new Conjugate(
|
|
1307
|
+
new Alg([new Move("F", 1)]),
|
|
1308
|
+
new Alg([
|
|
1309
|
+
new Commutator(
|
|
1310
|
+
new Alg([new Move("U", 1)]),
|
|
1311
|
+
new Alg([new Move("R", 1)])
|
|
1312
|
+
)
|
|
1313
|
+
])
|
|
1314
|
+
)
|
|
1196
1315
|
]),
|
|
1197
1316
|
APermCompact: new Alg([
|
|
1198
|
-
new Conjugate(
|
|
1199
|
-
new
|
|
1200
|
-
|
|
1317
|
+
new Conjugate(
|
|
1318
|
+
new Alg([new Move("R", 2)]),
|
|
1319
|
+
new Alg([
|
|
1320
|
+
new Commutator(
|
|
1321
|
+
new Alg([new Move("F", 2)]),
|
|
1322
|
+
new Alg([new Move("R", -1), new Move("B", -1), new Move("R", 1)])
|
|
1323
|
+
)
|
|
1324
|
+
])
|
|
1325
|
+
)
|
|
1201
1326
|
]),
|
|
1202
1327
|
FURURFMoves: new Alg([
|
|
1203
1328
|
new Move("F", 1),
|
|
@@ -1224,11 +1349,20 @@ var Example = {
|
|
|
1224
1349
|
new Move("F", -1)
|
|
1225
1350
|
]),
|
|
1226
1351
|
HeadlightSwaps: new Alg([
|
|
1227
|
-
new Conjugate(
|
|
1228
|
-
new
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1352
|
+
new Conjugate(
|
|
1353
|
+
new Alg([new Move("F", 1)]),
|
|
1354
|
+
new Alg([
|
|
1355
|
+
new Grouping(
|
|
1356
|
+
new Alg([
|
|
1357
|
+
new Commutator(
|
|
1358
|
+
new Alg([new Move("R", 1)]),
|
|
1359
|
+
new Alg([new Move("U", 1)])
|
|
1360
|
+
)
|
|
1361
|
+
]),
|
|
1362
|
+
3
|
|
1363
|
+
)
|
|
1364
|
+
])
|
|
1365
|
+
)
|
|
1232
1366
|
]),
|
|
1233
1367
|
TriplePause: new Alg([new Pause(), new Pause(), new Pause()])
|
|
1234
1368
|
};
|
|
@@ -1263,7 +1397,8 @@ var cubeKeyMapping = {
|
|
|
1263
1397
|
80: new Move("z"),
|
|
1264
1398
|
81: new Move("z'"),
|
|
1265
1399
|
90: new Move("M'"),
|
|
1266
|
-
190: new Move("M'")
|
|
1400
|
+
190: new Move("M'"),
|
|
1401
|
+
192: new Pause()
|
|
1267
1402
|
};
|
|
1268
1403
|
function keyToMove(e) {
|
|
1269
1404
|
if (e.altKey || e.ctrlKey) {
|
|
@@ -1400,4 +1535,4 @@ export {
|
|
|
1400
1535
|
experimentalAlgCubingNetLink,
|
|
1401
1536
|
experimentalAppendMove
|
|
1402
1537
|
};
|
|
1403
|
-
//# sourceMappingURL=chunk-
|
|
1538
|
+
//# sourceMappingURL=chunk-NI7U4XAZ.js.map
|