cubing 0.63.5 → 0.63.7

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 (32) hide show
  1. package/dist/bin/chunks/{chunk-22VWCGBC.js → chunk-6YZ4AUWL.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/bluetooth/index.d.ts +2 -2
  8. package/dist/lib/cubing/chunks/{chunk-WMKAKGVZ.js → chunk-5KMTA6PX.js} +2 -2
  9. package/dist/lib/cubing/chunks/{chunk-WMKAKGVZ.js.map → chunk-5KMTA6PX.js.map} +1 -1
  10. package/dist/lib/cubing/chunks/{inside-LSPIPZY2.js → inside-JAJOK2MI.js} +2 -2
  11. package/dist/lib/cubing/chunks/{search-dynamic-solve-4x4x4-KIH4YATU.js → search-dynamic-solve-4x4x4-BGV4AJVT.js} +2 -2
  12. package/dist/lib/cubing/chunks/search-worker-entry.js +1 -1
  13. package/dist/lib/cubing/{index-BXHm_6gm.d.ts → index-B2leUGbW.d.ts} +2 -2
  14. package/dist/lib/cubing/{index-Cvk652Bd.d.ts → index-BLw2OxXo.d.ts} +1 -1
  15. package/dist/lib/cubing/kpuzzle/index.d.ts +1 -1
  16. package/dist/lib/cubing/notation/index.d.ts +1 -1
  17. package/dist/lib/cubing/{outside-C2ODxIX_.d.ts → outside-V6_PW1ZK.d.ts} +1 -1
  18. package/dist/lib/cubing/protocol/index.d.ts +1 -1
  19. package/dist/lib/cubing/puzzle-geometry/index.d.ts +1 -1
  20. package/dist/lib/cubing/puzzles/index.d.ts +1 -1
  21. package/dist/lib/cubing/scramble/index.d.ts +1 -1
  22. package/dist/lib/cubing/scramble/index.js +1 -1
  23. package/dist/lib/cubing/search/index.d.ts +1 -1
  24. package/dist/lib/cubing/search/index.js +1 -1
  25. package/dist/lib/cubing/stream/index.d.ts +1 -1
  26. package/dist/lib/cubing/twisty/index.d.ts +1 -1
  27. package/dist/lib/cubing/twisty/index.js +47 -28
  28. package/dist/lib/cubing/twisty/index.js.map +2 -2
  29. package/package.json +1 -1
  30. /package/dist/bin/chunks/{chunk-22VWCGBC.js.map → chunk-6YZ4AUWL.js.map} +0 -0
  31. /package/dist/lib/cubing/chunks/{inside-LSPIPZY2.js.map → inside-JAJOK2MI.js.map} +0 -0
  32. /package/dist/lib/cubing/chunks/{search-dynamic-solve-4x4x4-KIH4YATU.js.map → search-dynamic-solve-4x4x4-BGV4AJVT.js.map} +0 -0
@@ -4,10 +4,10 @@
4
4
  var packageVersion = (
5
5
  // biome-ignore lint/suspicious/noTsIgnore: This comment is stil present in the compiled file, where an error is *not* expected.
6
6
  /** @ts-ignore Populated by `esbuild` at compile time. */
7
- "0.63.5"
7
+ "0.63.7"
8
8
  );
9
9
 
10
10
  export {
11
11
  packageVersion
12
12
  };
13
- //# sourceMappingURL=chunk-22VWCGBC.js.map
13
+ //# sourceMappingURL=chunk-6YZ4AUWL.js.map
package/dist/bin/order.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env -S node --
2
2
  import {
3
3
  packageVersion
4
- } from "./chunks/chunk-22VWCGBC.js";
4
+ } from "./chunks/chunk-6YZ4AUWL.js";
5
5
 
6
6
  // src/bin/order.ts
7
7
  import { basename } from "node:path";
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env -S node --
2
2
  import {
3
3
  packageVersion
4
- } from "./chunks/chunk-22VWCGBC.js";
4
+ } from "./chunks/chunk-6YZ4AUWL.js";
5
5
 
6
6
  // src/bin/puzzle-geometry-bin.ts
7
7
  import { basename } from "node:path";
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env -S node --
2
2
  import {
3
3
  packageVersion
4
- } from "./chunks/chunk-22VWCGBC.js";
4
+ } from "./chunks/chunk-6YZ4AUWL.js";
5
5
 
6
6
  // src/bin/scramble.ts
7
7
  import { basename } from "node:path";
package/dist/bin/svg.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env -S node --
2
2
  import {
3
3
  packageVersion
4
- } from "./chunks/chunk-22VWCGBC.js";
4
+ } from "./chunks/chunk-6YZ4AUWL.js";
5
5
 
6
6
  // src/bin/svg.ts
7
7
  import { basename } from "node:path";
@@ -1,2 +1,2 @@
1
- import { At as Move, Ct as AlgLeaf, Dt as Grouping, Et as LineComment, Ft as ExperimentalNotationType, It as ExperimentalSerializationOptions, Mt as QuantumMove, Nt as Conjugate, Ot as GroupingModifications, Pt as Commutator, St as AlgBranch, Tt as Newline, _t as experimentalAppendMove, a as functionFromTraversal, bt as SimplifyOptions, f as Parsed, ft as experimentalIs, gt as Alg, ht as AlgBuilder, i as TraversalUp, jt as MoveModifications, kt as Pause, mt as setAlgDebug, n as experimentalAlgCubingNetLink, o as keyToMove, pt as Example, r as TraversalDownUp, t as AlgCubingNetOptions, vt as AppendCancelOptions, wt as AlgNode, xt as Unit, yt as PuzzleSpecificSimplifyOptions } from "../index-BXHm_6gm.js";
1
+ import { At as Move, Ct as AlgLeaf, Dt as Grouping, Et as LineComment, Ft as ExperimentalNotationType, It as ExperimentalSerializationOptions, Mt as QuantumMove, Nt as Conjugate, Ot as GroupingModifications, Pt as Commutator, St as AlgBranch, Tt as Newline, _t as experimentalAppendMove, a as functionFromTraversal, bt as SimplifyOptions, f as Parsed, ft as experimentalIs, gt as Alg, ht as AlgBuilder, i as TraversalUp, jt as MoveModifications, kt as Pause, mt as setAlgDebug, n as experimentalAlgCubingNetLink, o as keyToMove, pt as Example, r as TraversalDownUp, t as AlgCubingNetOptions, vt as AppendCancelOptions, wt as AlgNode, xt as Unit, yt as PuzzleSpecificSimplifyOptions } from "../index-B2leUGbW.js";
2
2
  export { Alg, AlgBranch, AlgBuilder, AlgCubingNetOptions, AlgLeaf, AlgNode, AppendCancelOptions, Commutator, Conjugate, Example, ExperimentalNotationType, Parsed as ExperimentalParsed, ExperimentalSerializationOptions, Grouping, GroupingModifications, LineComment, Move, MoveModifications, Newline, Pause, PuzzleSpecificSimplifyOptions, QuantumMove, SimplifyOptions, TraversalDownUp, TraversalUp, Unit, experimentalAlgCubingNetLink, experimentalAppendMove, experimentalIs, functionFromTraversal, keyToMove, setAlgDebug };
@@ -1,7 +1,7 @@
1
1
  /// <reference types="web-bluetooth" />
2
2
 
3
- import { At as Move, D as PuzzleID, I as MillisecondTimestamp, R as KPattern, c as PuzzleLoader, gt as Alg, s as KeyMapping } from "../index-BXHm_6gm.js";
4
- import { a as OrientationEvent, i as AlgLeafEvent } from "../index-Cvk652Bd.js";
3
+ import { At as Move, D as PuzzleID, I as MillisecondTimestamp, R as KPattern, c as PuzzleLoader, gt as Alg, s as KeyMapping } from "../index-B2leUGbW.js";
4
+ import { a as OrientationEvent, i as AlgLeafEvent } from "../index-BLw2OxXo.js";
5
5
 
6
6
  //#region src/cubing/bluetooth/debug.d.ts
7
7
  declare function enableDebugLogging(enable: boolean): void;
@@ -218,7 +218,7 @@ var searchOutsideDebugGlobals = {
218
218
  scramblePrefetchLevel: "auto",
219
219
  forceNewWorkerForEveryScramble: false,
220
220
  forceTwipsForScrambles: false,
221
- showWorkerInstantiationWarnings: true,
221
+ showWorkerInstantiationWarnings: false,
222
222
  prioritizeEsbuildWorkaroundForWorkerInstantiation: false,
223
223
  allowLegacyPatternsForWorkerInstantiation: true,
224
224
  allowDerivedScrambles: false
@@ -265,4 +265,4 @@ export {
265
265
  solveTwips,
266
266
  setSearchDebug
267
267
  };
268
- //# sourceMappingURL=chunk-WMKAKGVZ.js.map
268
+ //# sourceMappingURL=chunk-5KMTA6PX.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/cubing/search/worker-workarounds/index.ts", "../../../../src/cubing/search/instantiator.ts", "../../../../src/cubing/search/outside.ts"],
4
- "sourcesContent": ["import { exposeAPI } from \"./worker-guard\";\n\nexport function searchWorkerURLImportMetaResolve(): string {\n // Note:\n // - We have to hardcode the expected path of the entry file in the ESM build, due to lack of `esbuild` support: https://github.com/evanw/esbuild/issues/2866\n // - This URL is based on the assumption that the code from this file ends up in a shared chunk in the `esm` build. This is not guaranteed by `esbuild`, but it consistently happens for our codebase.\n // - We inline the value (instead of using a constant), to maximize compatibility for hardcoded syntax detection in bundlers.\n return import.meta.resolve(\"./search-worker-entry.js\");\n}\n\nexport function searchWorkerURLNewURLImportMetaURL(): URL {\n // Note:\n // - We have to hardcode the expected path of the entry file in the ESM build, due to lack of `esbuild` support: https://github.com/evanw/esbuild/issues/795\n // - This URL is based on the assumption that the code from this file ends up in a shared chunk in the `esm` build. This is not guaranteed by `esbuild`, but it consistently happens for our codebase.\n // - We inline the value (instead of using a constant), to maximize compatibility for hardcoded syntax detection in bundlers.\n return new URL(\"./search-worker-entry.js\", import.meta.url);\n}\n\n// Workaround for `esbuild`: https://github.com/evanw/esbuild/issues/312#issuecomment-1092195778\nexport async function searchWorkerURLEsbuildWorkaround(): Promise<string> {\n exposeAPI.expose = false;\n return (await import(\"./search-worker-entry.js\")).WORKER_ENTRY_FILE_URL;\n}\n\nexport function instantiateSearchWorkerURLNewURLImportMetaURL(): Worker {\n return new Worker(new URL(\"./search-worker-entry.js\", import.meta.url), {\n type: \"module\",\n });\n}\n", "import type { Worker as NodeWorker } from \"node:worker_threads\";\nimport { PortableWorker, wrap } from \"@cubing/comlink-everywhere\";\nimport type { WorkerAPI } from \"./inside/api\";\nimport { searchOutsideDebugGlobals } from \"./outside\";\nimport {\n searchWorkerURLEsbuildWorkaround,\n searchWorkerURLImportMetaResolve,\n searchWorkerURLNewURLImportMetaURL,\n} from \"./worker-workarounds\";\n\nfunction wrapAPI(worker: Worker | NodeWorker): WorkerAPI {\n return wrap<WorkerAPI>(worker);\n}\n\nasync function instantiateModuleWorker(\n workerEntryFileURL: string | URL,\n): Promise<WorkerAPI> {\n // biome-ignore lint/suspicious/noAsyncPromiseExecutor: TODO\n return new Promise<WorkerAPI>(async (resolve, reject) => {\n try {\n const worker = new PortableWorker(workerEntryFileURL);\n\n // TODO: Remove this once we can remove the workarounds for lack of `import.meta.resolve(\u2026)` support.\n const onFirstMessage = (messageData: string) => {\n if (messageData === \"comlink-exposed\") {\n // We need to clear the timeout so that we don't prevent `node` from exiting in the meantime.\n resolve(wrapAPI(worker));\n } else {\n reject(\n new Error(`wrong module instantiation message ${messageData}`),\n );\n }\n };\n\n const onError = (e: ErrorEvent) => {\n reject(e);\n };\n\n if (\"once\" in worker /* hack to detect `node` */) {\n // We have to use `once` so the `unref()` from `comlink-everywhere` allows the process to quit as expected.\n worker.once(\"message\", onFirstMessage);\n } else {\n worker.addEventListener(\"error\", onError, {\n once: true,\n });\n worker.addEventListener(\n \"message\",\n (e: MessageEvent) => onFirstMessage(e.data),\n {\n once: true,\n },\n );\n }\n } catch (e) {\n reject(e);\n }\n });\n}\n\nexport const allWorkerAPIPromises: Promise<WorkerAPI>[] = [];\n\nexport async function instantiateWorkerAPI(): Promise<WorkerAPI> {\n const workerAPIPromise = instantiateWorkerImplementation();\n allWorkerAPIPromises.push(workerAPIPromise);\n const insideAPI = await workerAPIPromise;\n insideAPI.setDebugMeasurePerf(searchOutsideDebugGlobals.logPerf);\n insideAPI.setDebugForceTwipsForScrambles(\n searchOutsideDebugGlobals.forceTwipsForScrambles,\n );\n insideAPI.setScramblePrefetchLevel(\n searchOutsideDebugGlobals.scramblePrefetchLevel,\n );\n return workerAPIPromise;\n}\n\ntype FallbackStrategyInfo = [\n fn: () => Promise<WorkerAPI>,\n description: string,\n warnOnSuccess: null | string,\n];\n\nfunction fallbackOrder(): FallbackStrategyInfo[] {\n const importMetaResolveStrategy: FallbackStrategyInfo = [\n async () => instantiateModuleWorker(searchWorkerURLImportMetaResolve()),\n \"using `import.meta.resolve(\u2026)\",\n null,\n ];\n const esbuildWorkaroundStrategy: FallbackStrategyInfo = [\n async () =>\n instantiateModuleWorker(await searchWorkerURLEsbuildWorkaround()),\n \"using the `esbuild` workaround\",\n // TODO: we will hopefully discontinue the `esbuild` workaround at some\n // point, but `esbuild` has been stuck for 3 years on this issue. Because\n // `esbuild` and Vite (which uses `esbuild`) are now dominating the\n // ecosystem, this just causes a warning for a lot of devs/users that they\n // can't do anything about. As frustrating as the situation is, the\n // workaround is semantically fine (even if it's convoluted) and is\n // preserved by `esbuild`-based flows in practice. So we suppress the\n // warning in the medium-term but maintain long-term hope that we can\n // remove it (and the other fallbacks as well).\n null,\n ];\n const newURLStrategy: FallbackStrategyInfo = [\n async () => instantiateModuleWorker(searchWorkerURLNewURLImportMetaURL()),\n \"using `new URL(\u2026, import.meta.url)`\",\n \"will\",\n ];\n\n if (!searchOutsideDebugGlobals.allowLegacyPatternsForWorkerInstantiation) {\n return [importMetaResolveStrategy];\n }\n if (\n searchOutsideDebugGlobals.prioritizeEsbuildWorkaroundForWorkerInstantiation\n ) {\n return [\n esbuildWorkaroundStrategy,\n importMetaResolveStrategy,\n newURLStrategy,\n ];\n }\n return [importMetaResolveStrategy, esbuildWorkaroundStrategy, newURLStrategy];\n}\n\nasync function instantiateWorkerImplementation(): Promise<WorkerAPI> {\n if (globalThis.location?.protocol === \"file:\") {\n console.warn(\n \"This current web page is loaded from the local filesystem (a URL that starts with `file://`). In this situation, `cubing.js` may be unable to generate scrambles or perform searches in some browsers. See: https://js.cubing.net/cubing/scramble/#file-server-required\",\n );\n }\n\n function failed(methodDescription?: string) {\n return `Module worker instantiation${\n methodDescription ? ` ${methodDescription}` : \"\"\n } failed`;\n }\n\n for (const [fn, description, warnOnSuccess] of fallbackOrder()) {\n try {\n const worker = await fn();\n if (warnOnSuccess) {\n if (searchOutsideDebugGlobals.showWorkerInstantiationWarnings) {\n console.warn(\n `Module worker instantiation required ${description}. \\`cubing.js\\` ${warnOnSuccess} not support this fallback in the future.`,\n );\n }\n }\n return worker;\n } catch (e) {\n if (searchOutsideDebugGlobals.showWorkerInstantiationWarnings) {\n console.warn(`${failed(description)}, falling back.`, e);\n }\n }\n }\n\n throw new Error(\n `Module worker instantiation failed. There are no more fallbacks available.`,\n );\n}\n", "import { Alg } from \"../alg\";\nimport type { KPuzzle } from \"../kpuzzle\";\n// import { preInitialize222 } from \"../implementations/2x2x2\";\nimport type { KPattern } from \"../kpuzzle/KPattern\";\nimport type { PrefetchLevel, WorkerAPI } from \"./inside/api\";\nimport type { TwipsOptions } from \"./inside/solve/twips\";\nimport { allWorkerAPIPromises, instantiateWorkerAPI } from \"./instantiator\";\n\nlet cachedWorkerInstance: Promise<WorkerAPI> | undefined;\nfunction getCachedWorkerInstance(): Promise<WorkerAPI> {\n return (cachedWorkerInstance ??= instantiateWorkerAPI());\n}\n\nexport async function mapToAllWorkers(\n f: (worker: WorkerAPI) => void,\n): Promise<void> {\n await Promise.all(\n allWorkerAPIPromises.map(async (worker) => {\n f(await worker);\n }),\n );\n}\n\n// Pre-initialize the scrambler for the given event. (Otherwise, an event is\n// initialized the first time you ask for a scramble for that event.)\n//\n// Some typical numbers for a fast computer:\n// - 3x3x3 initialization: 200ms\n// - Each 3x3x3 scramble: 50ms\n// - 4x4x4 initialization: 2500ms\n// - Each 4x4x4 scramble: 300ms to 800ms\n//\n// It is safe to immediately call for a scramble\n// any time after starting pre-initialization, or to call for them without\n// pre-initializing. Pre-initializing essentially gives the scramble worker a\n// head start in case a scramble doesn't get requested immediately.\n//\n// Note that events cannot be pre-initialized in parallel. Attempting to\n// pre-initialize multiple events will initialize them consecutively. Scrambles\n// for a given event cannot be computed while another event is being initialized.\nexport function _preInitializationHintForEvent(\n eventID: string,\n // callback?: () => void\n): void {\n switch (eventID) {\n case \"333oh\":\n _preInitializationHintForEvent(\"333\");\n return;\n }\n void (async () => {\n await (await getCachedWorkerInstance()).initialize(eventID);\n })();\n}\n\nexport async function randomScrambleForEvent(eventID: string): Promise<Alg> {\n const worker = searchOutsideDebugGlobals.forceNewWorkerForEveryScramble\n ? await instantiateWorkerAPI()\n : await getCachedWorkerInstance();\n const scrambleString = await worker.randomScrambleStringForEvent(eventID);\n\n return Alg.fromString(scrambleString);\n}\n\nexport async function deriveScrambleForEvent(\n derivationSeedHex: string,\n derivationSaltHierarchy: string[],\n eventID: string,\n): Promise<Alg> {\n if (!searchOutsideDebugGlobals.allowDerivedScrambles) {\n throw new Error(\"Derived scrambles are not allowed.\");\n }\n const worker = searchOutsideDebugGlobals.forceNewWorkerForEveryScramble\n ? await instantiateWorkerAPI()\n : await getCachedWorkerInstance();\n const scrambleString = await worker.deriveScrambleStringForEvent(\n derivationSeedHex,\n derivationSaltHierarchy,\n eventID,\n );\n return Alg.fromString(scrambleString);\n}\n\nexport async function experimentalSolve3x3x3IgnoringCenters(\n pattern: KPattern,\n): Promise<Alg> {\n const cwi = await getCachedWorkerInstance();\n return Alg.fromString(await cwi.solve333ToString(pattern.patternData));\n}\n\nexport async function experimentalSolve2x2x2(pattern: KPattern): Promise<Alg> {\n const cwi = await getCachedWorkerInstance();\n return Alg.fromString(await cwi.solve222ToString(pattern.patternData));\n}\n\nexport async function solveSkewb(pattern: KPattern): Promise<Alg> {\n const cwi = await getCachedWorkerInstance();\n return Alg.fromString(await cwi.solveSkewbToString(pattern.patternData));\n}\n\nexport async function solvePyraminx(pattern: KPattern): Promise<Alg> {\n const cwi = await getCachedWorkerInstance();\n return Alg.fromString(await cwi.solvePyraminxToString(pattern.patternData));\n}\n\nexport async function solveMegaminx(pattern: KPattern): Promise<Alg> {\n const cwi = await getCachedWorkerInstance();\n return Alg.fromString(await cwi.solveMegaminxToString(pattern.patternData));\n}\n\nexport interface SolveTwipsOptions {\n generatorMoves?: string[];\n targetPattern?: KPattern;\n minDepth?: number;\n maxDepth?: number;\n}\n\nexport async function solveTwips(\n kpuzzle: KPuzzle,\n pattern: KPattern,\n options?: SolveTwipsOptions,\n): Promise<Alg> {\n const { targetPattern, ...otherOptions } = options ?? {};\n const apiOptions: TwipsOptions = otherOptions;\n if (targetPattern) {\n apiOptions.targetPattern = targetPattern.patternData;\n }\n const { ...def } = kpuzzle.definition;\n delete def.experimentalIsPatternSolved;\n // delete def.derivedMoves;\n const dedicatedWorker = await instantiateWorkerAPI();\n try {\n return Alg.fromString(\n // TODO: unnecessary because we terminate the worker?\n await dedicatedWorker.solveTwipsToString(\n def,\n pattern.patternData,\n apiOptions,\n ),\n );\n } finally {\n console.log(\"Search ended, terminating dedicated `twips` worker.\");\n // TODO: support re-using the same worker for multiple searches..\n // dedicatedWorker.terminate?.(); // TODO\n }\n}\n\ninterface SearchOutsideDebugGlobals {\n logPerf: boolean;\n scramblePrefetchLevel: `${PrefetchLevel}`;\n forceNewWorkerForEveryScramble: boolean;\n showWorkerInstantiationWarnings: boolean;\n forceTwipsForScrambles: boolean;\n // Allow fallbacks from `import.meta.resolve(\u2026)`.\n allowLegacyPatternsForWorkerInstantiation: boolean;\n // This can prevent a request to `search-worker-entry.js` when it doesn't exist, if the library semantics have been mangled by `esbuild`.\n prioritizeEsbuildWorkaroundForWorkerInstantiation: boolean;\n allowDerivedScrambles: boolean;\n}\n\nexport const searchOutsideDebugGlobals: SearchOutsideDebugGlobals = {\n logPerf: true,\n scramblePrefetchLevel: \"auto\",\n forceNewWorkerForEveryScramble: false,\n forceTwipsForScrambles: false,\n showWorkerInstantiationWarnings: true,\n prioritizeEsbuildWorkaroundForWorkerInstantiation: false,\n allowLegacyPatternsForWorkerInstantiation: true,\n allowDerivedScrambles: false,\n};\n\nexport function setSearchDebug(\n options: Partial<SearchOutsideDebugGlobals>,\n): void {\n const { logPerf, forceTwipsForScrambles, scramblePrefetchLevel } = options;\n if (typeof logPerf !== \"undefined\") {\n searchOutsideDebugGlobals.logPerf = logPerf;\n void mapToAllWorkers((worker) => worker.setDebugMeasurePerf(logPerf));\n }\n if (typeof forceTwipsForScrambles !== \"undefined\") {\n searchOutsideDebugGlobals.forceTwipsForScrambles = forceTwipsForScrambles;\n void mapToAllWorkers((worker) =>\n worker.setDebugMeasurePerf(forceTwipsForScrambles),\n );\n }\n if (typeof scramblePrefetchLevel !== \"undefined\") {\n searchOutsideDebugGlobals.scramblePrefetchLevel = scramblePrefetchLevel;\n void mapToAllWorkers((worker) =>\n worker.setScramblePrefetchLevel(scramblePrefetchLevel as PrefetchLevel),\n );\n }\n for (const booleanField of [\n \"forceNewWorkerForEveryScramble\",\n \"showWorkerInstantiationWarnings\",\n \"prioritizeEsbuildWorkaroundForWorkerInstantiation\",\n \"allowLegacyPatternsForWorkerInstantiation\",\n \"allowDerivedScrambles\",\n ] as const) {\n if (booleanField in options) {\n searchOutsideDebugGlobals[booleanField] =\n options[booleanField] ?? searchOutsideDebugGlobals[booleanField];\n }\n }\n}\n"],
4
+ "sourcesContent": ["import { exposeAPI } from \"./worker-guard\";\n\nexport function searchWorkerURLImportMetaResolve(): string {\n // Note:\n // - We have to hardcode the expected path of the entry file in the ESM build, due to lack of `esbuild` support: https://github.com/evanw/esbuild/issues/2866\n // - This URL is based on the assumption that the code from this file ends up in a shared chunk in the `esm` build. This is not guaranteed by `esbuild`, but it consistently happens for our codebase.\n // - We inline the value (instead of using a constant), to maximize compatibility for hardcoded syntax detection in bundlers.\n return import.meta.resolve(\"./search-worker-entry.js\");\n}\n\nexport function searchWorkerURLNewURLImportMetaURL(): URL {\n // Note:\n // - We have to hardcode the expected path of the entry file in the ESM build, due to lack of `esbuild` support: https://github.com/evanw/esbuild/issues/795\n // - This URL is based on the assumption that the code from this file ends up in a shared chunk in the `esm` build. This is not guaranteed by `esbuild`, but it consistently happens for our codebase.\n // - We inline the value (instead of using a constant), to maximize compatibility for hardcoded syntax detection in bundlers.\n return new URL(\"./search-worker-entry.js\", import.meta.url);\n}\n\n// Workaround for `esbuild`: https://github.com/evanw/esbuild/issues/312#issuecomment-1092195778\nexport async function searchWorkerURLEsbuildWorkaround(): Promise<string> {\n exposeAPI.expose = false;\n return (await import(\"./search-worker-entry.js\")).WORKER_ENTRY_FILE_URL;\n}\n\nexport function instantiateSearchWorkerURLNewURLImportMetaURL(): Worker {\n return new Worker(new URL(\"./search-worker-entry.js\", import.meta.url), {\n type: \"module\",\n });\n}\n", "import type { Worker as NodeWorker } from \"node:worker_threads\";\nimport { PortableWorker, wrap } from \"@cubing/comlink-everywhere\";\nimport type { WorkerAPI } from \"./inside/api\";\nimport { searchOutsideDebugGlobals } from \"./outside\";\nimport {\n searchWorkerURLEsbuildWorkaround,\n searchWorkerURLImportMetaResolve,\n searchWorkerURLNewURLImportMetaURL,\n} from \"./worker-workarounds\";\n\nfunction wrapAPI(worker: Worker | NodeWorker): WorkerAPI {\n return wrap<WorkerAPI>(worker);\n}\n\nasync function instantiateModuleWorker(\n workerEntryFileURL: string | URL,\n): Promise<WorkerAPI> {\n // biome-ignore lint/suspicious/noAsyncPromiseExecutor: TODO\n return new Promise<WorkerAPI>(async (resolve, reject) => {\n try {\n const worker = new PortableWorker(workerEntryFileURL);\n\n // TODO: Remove this once we can remove the workarounds for lack of `import.meta.resolve(\u2026)` support.\n const onFirstMessage = (messageData: string) => {\n if (messageData === \"comlink-exposed\") {\n // We need to clear the timeout so that we don't prevent `node` from exiting in the meantime.\n resolve(wrapAPI(worker));\n } else {\n reject(\n new Error(`wrong module instantiation message ${messageData}`),\n );\n }\n };\n\n const onError = (e: ErrorEvent) => {\n reject(e);\n };\n\n if (\"once\" in worker /* hack to detect `node` */) {\n // We have to use `once` so the `unref()` from `comlink-everywhere` allows the process to quit as expected.\n worker.once(\"message\", onFirstMessage);\n } else {\n worker.addEventListener(\"error\", onError, {\n once: true,\n });\n worker.addEventListener(\n \"message\",\n (e: MessageEvent) => onFirstMessage(e.data),\n {\n once: true,\n },\n );\n }\n } catch (e) {\n reject(e);\n }\n });\n}\n\nexport const allWorkerAPIPromises: Promise<WorkerAPI>[] = [];\n\nexport async function instantiateWorkerAPI(): Promise<WorkerAPI> {\n const workerAPIPromise = instantiateWorkerImplementation();\n allWorkerAPIPromises.push(workerAPIPromise);\n const insideAPI = await workerAPIPromise;\n insideAPI.setDebugMeasurePerf(searchOutsideDebugGlobals.logPerf);\n insideAPI.setDebugForceTwipsForScrambles(\n searchOutsideDebugGlobals.forceTwipsForScrambles,\n );\n insideAPI.setScramblePrefetchLevel(\n searchOutsideDebugGlobals.scramblePrefetchLevel,\n );\n return workerAPIPromise;\n}\n\ntype FallbackStrategyInfo = [\n fn: () => Promise<WorkerAPI>,\n description: string,\n warnOnSuccess: null | string,\n];\n\nfunction fallbackOrder(): FallbackStrategyInfo[] {\n const importMetaResolveStrategy: FallbackStrategyInfo = [\n async () => instantiateModuleWorker(searchWorkerURLImportMetaResolve()),\n \"using `import.meta.resolve(\u2026)\",\n null,\n ];\n const esbuildWorkaroundStrategy: FallbackStrategyInfo = [\n async () =>\n instantiateModuleWorker(await searchWorkerURLEsbuildWorkaround()),\n \"using the `esbuild` workaround\",\n // TODO: we will hopefully discontinue the `esbuild` workaround at some\n // point, but `esbuild` has been stuck for 3 years on this issue. Because\n // `esbuild` and Vite (which uses `esbuild`) are now dominating the\n // ecosystem, this just causes a warning for a lot of devs/users that they\n // can't do anything about. As frustrating as the situation is, the\n // workaround is semantically fine (even if it's convoluted) and is\n // preserved by `esbuild`-based flows in practice. So we suppress the\n // warning in the medium-term but maintain long-term hope that we can\n // remove it (and the other fallbacks as well).\n null,\n ];\n const newURLStrategy: FallbackStrategyInfo = [\n async () => instantiateModuleWorker(searchWorkerURLNewURLImportMetaURL()),\n \"using `new URL(\u2026, import.meta.url)`\",\n \"will\",\n ];\n\n if (!searchOutsideDebugGlobals.allowLegacyPatternsForWorkerInstantiation) {\n return [importMetaResolveStrategy];\n }\n if (\n searchOutsideDebugGlobals.prioritizeEsbuildWorkaroundForWorkerInstantiation\n ) {\n return [\n esbuildWorkaroundStrategy,\n importMetaResolveStrategy,\n newURLStrategy,\n ];\n }\n return [importMetaResolveStrategy, esbuildWorkaroundStrategy, newURLStrategy];\n}\n\nasync function instantiateWorkerImplementation(): Promise<WorkerAPI> {\n if (globalThis.location?.protocol === \"file:\") {\n console.warn(\n \"This current web page is loaded from the local filesystem (a URL that starts with `file://`). In this situation, `cubing.js` may be unable to generate scrambles or perform searches in some browsers. See: https://js.cubing.net/cubing/scramble/#file-server-required\",\n );\n }\n\n function failed(methodDescription?: string) {\n return `Module worker instantiation${\n methodDescription ? ` ${methodDescription}` : \"\"\n } failed`;\n }\n\n for (const [fn, description, warnOnSuccess] of fallbackOrder()) {\n try {\n const worker = await fn();\n if (warnOnSuccess) {\n if (searchOutsideDebugGlobals.showWorkerInstantiationWarnings) {\n console.warn(\n `Module worker instantiation required ${description}. \\`cubing.js\\` ${warnOnSuccess} not support this fallback in the future.`,\n );\n }\n }\n return worker;\n } catch (e) {\n if (searchOutsideDebugGlobals.showWorkerInstantiationWarnings) {\n console.warn(`${failed(description)}, falling back.`, e);\n }\n }\n }\n\n throw new Error(\n `Module worker instantiation failed. There are no more fallbacks available.`,\n );\n}\n", "import { Alg } from \"../alg\";\nimport type { KPuzzle } from \"../kpuzzle\";\n// import { preInitialize222 } from \"../implementations/2x2x2\";\nimport type { KPattern } from \"../kpuzzle/KPattern\";\nimport type { PrefetchLevel, WorkerAPI } from \"./inside/api\";\nimport type { TwipsOptions } from \"./inside/solve/twips\";\nimport { allWorkerAPIPromises, instantiateWorkerAPI } from \"./instantiator\";\n\nlet cachedWorkerInstance: Promise<WorkerAPI> | undefined;\nfunction getCachedWorkerInstance(): Promise<WorkerAPI> {\n return (cachedWorkerInstance ??= instantiateWorkerAPI());\n}\n\nexport async function mapToAllWorkers(\n f: (worker: WorkerAPI) => void,\n): Promise<void> {\n await Promise.all(\n allWorkerAPIPromises.map(async (worker) => {\n f(await worker);\n }),\n );\n}\n\n// Pre-initialize the scrambler for the given event. (Otherwise, an event is\n// initialized the first time you ask for a scramble for that event.)\n//\n// Some typical numbers for a fast computer:\n// - 3x3x3 initialization: 200ms\n// - Each 3x3x3 scramble: 50ms\n// - 4x4x4 initialization: 2500ms\n// - Each 4x4x4 scramble: 300ms to 800ms\n//\n// It is safe to immediately call for a scramble\n// any time after starting pre-initialization, or to call for them without\n// pre-initializing. Pre-initializing essentially gives the scramble worker a\n// head start in case a scramble doesn't get requested immediately.\n//\n// Note that events cannot be pre-initialized in parallel. Attempting to\n// pre-initialize multiple events will initialize them consecutively. Scrambles\n// for a given event cannot be computed while another event is being initialized.\nexport function _preInitializationHintForEvent(\n eventID: string,\n // callback?: () => void\n): void {\n switch (eventID) {\n case \"333oh\":\n _preInitializationHintForEvent(\"333\");\n return;\n }\n void (async () => {\n await (await getCachedWorkerInstance()).initialize(eventID);\n })();\n}\n\nexport async function randomScrambleForEvent(eventID: string): Promise<Alg> {\n const worker = searchOutsideDebugGlobals.forceNewWorkerForEveryScramble\n ? await instantiateWorkerAPI()\n : await getCachedWorkerInstance();\n const scrambleString = await worker.randomScrambleStringForEvent(eventID);\n\n return Alg.fromString(scrambleString);\n}\n\nexport async function deriveScrambleForEvent(\n derivationSeedHex: string,\n derivationSaltHierarchy: string[],\n eventID: string,\n): Promise<Alg> {\n if (!searchOutsideDebugGlobals.allowDerivedScrambles) {\n throw new Error(\"Derived scrambles are not allowed.\");\n }\n const worker = searchOutsideDebugGlobals.forceNewWorkerForEveryScramble\n ? await instantiateWorkerAPI()\n : await getCachedWorkerInstance();\n const scrambleString = await worker.deriveScrambleStringForEvent(\n derivationSeedHex,\n derivationSaltHierarchy,\n eventID,\n );\n return Alg.fromString(scrambleString);\n}\n\nexport async function experimentalSolve3x3x3IgnoringCenters(\n pattern: KPattern,\n): Promise<Alg> {\n const cwi = await getCachedWorkerInstance();\n return Alg.fromString(await cwi.solve333ToString(pattern.patternData));\n}\n\nexport async function experimentalSolve2x2x2(pattern: KPattern): Promise<Alg> {\n const cwi = await getCachedWorkerInstance();\n return Alg.fromString(await cwi.solve222ToString(pattern.patternData));\n}\n\nexport async function solveSkewb(pattern: KPattern): Promise<Alg> {\n const cwi = await getCachedWorkerInstance();\n return Alg.fromString(await cwi.solveSkewbToString(pattern.patternData));\n}\n\nexport async function solvePyraminx(pattern: KPattern): Promise<Alg> {\n const cwi = await getCachedWorkerInstance();\n return Alg.fromString(await cwi.solvePyraminxToString(pattern.patternData));\n}\n\nexport async function solveMegaminx(pattern: KPattern): Promise<Alg> {\n const cwi = await getCachedWorkerInstance();\n return Alg.fromString(await cwi.solveMegaminxToString(pattern.patternData));\n}\n\nexport interface SolveTwipsOptions {\n generatorMoves?: string[];\n targetPattern?: KPattern;\n minDepth?: number;\n maxDepth?: number;\n}\n\nexport async function solveTwips(\n kpuzzle: KPuzzle,\n pattern: KPattern,\n options?: SolveTwipsOptions,\n): Promise<Alg> {\n const { targetPattern, ...otherOptions } = options ?? {};\n const apiOptions: TwipsOptions = otherOptions;\n if (targetPattern) {\n apiOptions.targetPattern = targetPattern.patternData;\n }\n const { ...def } = kpuzzle.definition;\n delete def.experimentalIsPatternSolved;\n // delete def.derivedMoves;\n const dedicatedWorker = await instantiateWorkerAPI();\n try {\n return Alg.fromString(\n // TODO: unnecessary because we terminate the worker?\n await dedicatedWorker.solveTwipsToString(\n def,\n pattern.patternData,\n apiOptions,\n ),\n );\n } finally {\n console.log(\"Search ended, terminating dedicated `twips` worker.\");\n // TODO: support re-using the same worker for multiple searches..\n // dedicatedWorker.terminate?.(); // TODO\n }\n}\n\ninterface SearchOutsideDebugGlobals {\n logPerf: boolean;\n scramblePrefetchLevel: `${PrefetchLevel}`;\n forceNewWorkerForEveryScramble: boolean;\n showWorkerInstantiationWarnings: boolean;\n forceTwipsForScrambles: boolean;\n // Allow fallbacks from `import.meta.resolve(\u2026)`.\n allowLegacyPatternsForWorkerInstantiation: boolean;\n // This can prevent a request to `search-worker-entry.js` when it doesn't exist, if the library semantics have been mangled by `esbuild`.\n prioritizeEsbuildWorkaroundForWorkerInstantiation: boolean;\n allowDerivedScrambles: boolean;\n}\n\nexport const searchOutsideDebugGlobals: SearchOutsideDebugGlobals = {\n logPerf: true,\n scramblePrefetchLevel: \"auto\",\n forceNewWorkerForEveryScramble: false,\n forceTwipsForScrambles: false,\n showWorkerInstantiationWarnings: false,\n prioritizeEsbuildWorkaroundForWorkerInstantiation: false,\n allowLegacyPatternsForWorkerInstantiation: true,\n allowDerivedScrambles: false,\n};\n\nexport function setSearchDebug(\n options: Partial<SearchOutsideDebugGlobals>,\n): void {\n const { logPerf, forceTwipsForScrambles, scramblePrefetchLevel } = options;\n if (typeof logPerf !== \"undefined\") {\n searchOutsideDebugGlobals.logPerf = logPerf;\n void mapToAllWorkers((worker) => worker.setDebugMeasurePerf(logPerf));\n }\n if (typeof forceTwipsForScrambles !== \"undefined\") {\n searchOutsideDebugGlobals.forceTwipsForScrambles = forceTwipsForScrambles;\n void mapToAllWorkers((worker) =>\n worker.setDebugMeasurePerf(forceTwipsForScrambles),\n );\n }\n if (typeof scramblePrefetchLevel !== \"undefined\") {\n searchOutsideDebugGlobals.scramblePrefetchLevel = scramblePrefetchLevel;\n void mapToAllWorkers((worker) =>\n worker.setScramblePrefetchLevel(scramblePrefetchLevel as PrefetchLevel),\n );\n }\n for (const booleanField of [\n \"forceNewWorkerForEveryScramble\",\n \"showWorkerInstantiationWarnings\",\n \"prioritizeEsbuildWorkaroundForWorkerInstantiation\",\n \"allowLegacyPatternsForWorkerInstantiation\",\n \"allowDerivedScrambles\",\n ] as const) {\n if (booleanField in options) {\n searchOutsideDebugGlobals[booleanField] =\n options[booleanField] ?? searchOutsideDebugGlobals[booleanField];\n }\n }\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;AAEO,SAAS,mCAA2C;AAKzD,SAAO,YAAY,QAAQ,0BAA0B;AACvD;AAEO,SAAS,qCAA0C;AAKxD,SAAO,IAAI,IAAI,4BAA4B,YAAY,GAAG;AAC5D;AAGA,eAAsB,mCAAoD;AACxE,YAAU,SAAS;AACnB,UAAQ,MAAM,OAAO,0BAA0B,GAAG;AACpD;;;ACZA,SAAS,QAAQ,QAAwC;AACvD,SAAO,KAAgB,MAAM;AAC/B;AAEA,eAAe,wBACb,oBACoB;AAEpB,SAAO,IAAI,QAAmB,OAAO,SAAS,WAAW;AACvD,QAAI;AACF,YAAM,SAAS,IA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qB;AACnD,MAAI;AACF,WAAO,IAAI;AAAA;AAAA,MAET,MAAM,gBAAgB;AAAA,QACpB;AAAA,QACA,QAAQ;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAAA,EACF,UAAE;AACA,YAAQ,IAAI,qDAAqD;AAAA,EAGnE;AACF;AAeO,IAAM,4BAAuD;AAAA,EAClE,SAAS;AAAA,EACT,uBAAuB;AAAA,EACvB,gCAAgC;AAAA,EAChC,wBAAwB;AAAA,EACxB,iCAAiC;AAAA,EACjC,mDAAmD;AAAA,EACnD,2CAA2C;AAAA,EAC3C,uBAAuB;AACzB;AAEO,SAAS,eACd,SACM;AACN,QAAM,EAAE,SAAS,wBAAwB,sBAAsB,IAAI;AACnE,MAAI,OAAO,YAAY,aAAa;AAClC,8BAA0B,UAAU;AACpC,SAAK,gBAAgB,CAAC,WAAW,OAAO,oBAAoB,OAAO,CAAC;AAAA,EACtE;AACA,MAAI,OAAO,2BAA2B,aAAa;AACjD,8BAA0B,yBAAyB;AACnD,SAAK;AAAA,MAAgB,CAAC,WACpB,OAAO,oBAAoB,sBAAsB;AAAA,IACnD;AAAA,EACF;AACA,MAAI,OAAO,0BAA0B,aAAa;AAChD,8BAA0B,wBAAwB;AAClD,SAAK;AAAA,MAAgB,CAAC,WACpB,OAAO,yBAAyB,qBAAsC;AAAA,IACxE;AAAA,EACF;AACA,aAAW,gBAAgB;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAAY;AACV,QAAI,gBAAgB,SAAS;AAC3B,gCAA0B,YAAY,IACpC,QAAQ,YAAY,KAAK,0BAA0B,YAAY;AAAA,IACnE;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
@@ -213,7 +213,7 @@ async function solve222(pattern) {
213
213
 
214
214
  // src/cubing/search/inside/solve/puzzles/dynamic/4x4x4/index.ts
215
215
  var dynamic4x4x4Solver = new LazyPromise(
216
- () => import("./search-dynamic-solve-4x4x4-KIH4YATU.js")
216
+ () => import("./search-dynamic-solve-4x4x4-BGV4AJVT.js")
217
217
  );
218
218
 
219
219
  // src/cubing/search/inside/solve/puzzles/4x4x4.ts
@@ -589,4 +589,4 @@ var insideAPI = {
589
589
 
590
590
  // src/cubing/search/inside/index.ts
591
591
  expose(insideAPI);
592
- //# sourceMappingURL=inside-LSPIPZY2.js.map
592
+ //# sourceMappingURL=inside-JAJOK2MI.js.map
@@ -1,5 +1,5 @@
1
1
  import "./chunk-NAPITA3L.js";
2
- import "./chunk-WMKAKGVZ.js";
2
+ import "./chunk-5KMTA6PX.js";
3
3
  import {
4
4
  random333Scramble
5
5
  } from "./chunk-H5KMIDAF.js";
@@ -2920,4 +2920,4 @@ export {
2920
2920
  initialize,
2921
2921
  random444Scramble
2922
2922
  };
2923
- //# sourceMappingURL=search-dynamic-solve-4x4x4-KIH4YATU.js.map
2923
+ //# sourceMappingURL=search-dynamic-solve-4x4x4-BGV4AJVT.js.map
@@ -4,7 +4,7 @@ import {
4
4
 
5
5
  // src/cubing/search/worker-workarounds/search-worker-entry.js
6
6
  if (exposeAPI.expose) {
7
- void import("./inside-LSPIPZY2.js").then(() => {
7
+ void import("./inside-JAJOK2MI.js").then(() => {
8
8
  if (globalThis.postMessage) {
9
9
  globalThis.postMessage("comlink-exposed");
10
10
  } else {
@@ -2488,7 +2488,7 @@ interface DataUp {
2488
2488
  moveCount: number;
2489
2489
  element: TwistyAlgWrapperElem | TwistyAlgLeafElem;
2490
2490
  }
2491
- declare class TwistyAlgLeafElem extends ManagedCustomElement {
2491
+ declare class TwistyAlgLeafElem extends HTMLElementShim {
2492
2492
  algOrAlgNode: Alg | AlgNode;
2493
2493
  constructor(className: string, text: string, dataDown: DataDown, algOrAlgNode: Alg | AlgNode, offsetIntoMove: boolean, clickable: boolean);
2494
2494
  pathToIndex(_index: number): (TwistyAlgWrapperElem | TwistyAlgLeafElem)[];
@@ -2510,7 +2510,7 @@ declare class MoveHighlighter {
2510
2510
  set(move: Parsed<Move> | null): void;
2511
2511
  }
2512
2512
  /** @category Other Custom Elements */
2513
- declare class TwistyAlgViewer extends HTMLElementShim {
2513
+ declare class TwistyAlgViewer extends ManagedCustomElement {
2514
2514
  #private;
2515
2515
  highlighter: MoveHighlighter;
2516
2516
  lastClickTimestamp: number | null;
@@ -1,4 +1,4 @@
1
- import { Ct as AlgLeaf, R as KPattern } from "./index-BXHm_6gm.js";
1
+ import { Ct as AlgLeaf, R as KPattern } from "./index-B2leUGbW.js";
2
2
 
3
3
  //#region src/cubing/stream/events.d.ts
4
4
  /** @category Smart Puzzles */
@@ -1,2 +1,2 @@
1
- import { B as KTransformation, G as KTransformationData, H as KPatternData, K as KTransformationOrbitData, R as KPattern, U as KPatternOrbitData, V as KPuzzleDefinition, W as KPuzzleOrbitDefinition, z as KPuzzle } from "../index-BXHm_6gm.js";
1
+ import { B as KTransformation, G as KTransformationData, H as KPatternData, K as KTransformationOrbitData, R as KPattern, U as KPatternOrbitData, V as KPuzzleDefinition, W as KPuzzleOrbitDefinition, z as KPuzzle } from "../index-B2leUGbW.js";
2
2
  export { KPattern, KPatternData, KPatternOrbitData, KPuzzle, KPuzzleDefinition, KPuzzleOrbitDefinition, KTransformation, KTransformationData, KTransformationOrbitData };
@@ -1,4 +1,4 @@
1
- import { M as LeafCount, c as PuzzleLoader, gt as Alg } from "../index-BXHm_6gm.js";
1
+ import { M as LeafCount, c as PuzzleLoader, gt as Alg } from "../index-B2leUGbW.js";
2
2
 
3
3
  //#region src/cubing/notation/CountAnimatedLeaves.d.ts
4
4
  declare const countAnimatedLeaves: (alg: Alg) => LeafCount;
@@ -1,4 +1,4 @@
1
- import { R as KPattern, gt as Alg, z as KPuzzle } from "./index-BXHm_6gm.js";
1
+ import { R as KPattern, gt as Alg, z as KPuzzle } from "./index-B2leUGbW.js";
2
2
  //#region src/cubing/search/inside/solve/puzzles/3x3x3/index.d.ts
3
3
  declare function random333Pattern(): Promise<KPattern>;
4
4
  //#endregion
@@ -1,4 +1,4 @@
1
- import { R as KPattern } from "../index-BXHm_6gm.js";
1
+ import { R as KPattern } from "../index-B2leUGbW.js";
2
2
 
3
3
  //#region src/cubing/protocol/binary/binary3x3x3.d.ts
4
4
  type Binary3x3x3Pattern = Uint8Array;
@@ -1,2 +1,2 @@
1
- import { $ as PuzzleDescription, J as PUZZLE_BASE_SHAPES, L as schreierSims, Q as PuzzleCutType, X as PuzzleBaseShape, Y as PUZZLE_CUT_TYPES, Z as PuzzleCutDescription, at as getPG3DNamedPuzzles, ct as getPuzzleGeometryByName, dt as PuzzleGeometryOptions, et as PuzzleGeometry, it as StickerDatSticker, lt as parsePuzzleDescription, nt as StickerDatAxis, ot as getPuzzleDescriptionString, q as PGNotation, rt as StickerDatFace, st as getPuzzleGeometryByDesc, tt as StickerDat, ut as Quat } from "../index-BXHm_6gm.js";
1
+ import { $ as PuzzleDescription, J as PUZZLE_BASE_SHAPES, L as schreierSims, Q as PuzzleCutType, X as PuzzleBaseShape, Y as PUZZLE_CUT_TYPES, Z as PuzzleCutDescription, at as getPG3DNamedPuzzles, ct as getPuzzleGeometryByName, dt as PuzzleGeometryOptions, et as PuzzleGeometry, it as StickerDatSticker, lt as parsePuzzleDescription, nt as StickerDatAxis, ot as getPuzzleDescriptionString, q as PGNotation, rt as StickerDatFace, st as getPuzzleGeometryByDesc, tt as StickerDat, ut as Quat } from "../index-B2leUGbW.js";
2
2
  export { PUZZLE_BASE_SHAPES as EXPERIMENTAL_PUZZLE_BASE_SHAPES, PUZZLE_CUT_TYPES as EXPERIMENTAL_PUZZLE_CUT_TYPES, PGNotation as ExperimentalPGNotation, PuzzleBaseShape as ExperimentalPuzzleBaseShape, PuzzleCutDescription as ExperimentalPuzzleCutDescription, PuzzleCutType as ExperimentalPuzzleCutType, PuzzleDescription as ExperimentalPuzzleDescription, PuzzleGeometryOptions as ExperimentalPuzzleGeometryOptions, PuzzleGeometry, Quat, StickerDat, StickerDatAxis, StickerDatFace, StickerDatSticker, getPG3DNamedPuzzles, getPuzzleDescriptionString, getPuzzleGeometryByDesc, getPuzzleGeometryByName, parsePuzzleDescription, schreierSims };
@@ -1,2 +1,2 @@
1
- import { _ as cube2x2x2, b as wcaEventInfo, c as PuzzleLoader, g as cube3x3x3, h as puzzles, v as eventInfo, x as wcaEvents, y as twizzleEvents } from "../index-BXHm_6gm.js";
1
+ import { _ as cube2x2x2, b as wcaEventInfo, c as PuzzleLoader, g as cube3x3x3, h as puzzles, v as eventInfo, x as wcaEvents, y as twizzleEvents } from "../index-B2leUGbW.js";
2
2
  export { PuzzleLoader, cube2x2x2, cube3x3x3, eventInfo, puzzles, twizzleEvents, wcaEventInfo, wcaEvents };
@@ -1,2 +1,2 @@
1
- import { i as randomScrambleForEvent, t as deriveScrambleForEvent } from "../outside-C2ODxIX_.js";
1
+ import { i as randomScrambleForEvent, t as deriveScrambleForEvent } from "../outside-V6_PW1ZK.js";
2
2
  export { deriveScrambleForEvent as experimentalDeriveScrambleForEvent, randomScrambleForEvent };
@@ -2,7 +2,7 @@ import "../chunks/chunk-NAPITA3L.js";
2
2
  import {
3
3
  deriveScrambleForEvent,
4
4
  randomScrambleForEvent
5
- } from "../chunks/chunk-WMKAKGVZ.js";
5
+ } from "../chunks/chunk-5KMTA6PX.js";
6
6
  import "../chunks/chunk-H5KMIDAF.js";
7
7
  import "../chunks/chunk-7GUL3OBQ.js";
8
8
  import "../chunks/chunk-FUAADKXE.js";
@@ -1,4 +1,4 @@
1
- import { a as setSearchDebug, c as solveSkewb, l as solveTwips, n as experimentalSolve2x2x2, o as solveMegaminx, r as experimentalSolve3x3x3IgnoringCenters, s as solvePyraminx, u as random333Pattern } from "../outside-C2ODxIX_.js";
1
+ import { a as setSearchDebug, c as solveSkewb, l as solveTwips, n as experimentalSolve2x2x2, o as solveMegaminx, r as experimentalSolve3x3x3IgnoringCenters, s as solvePyraminx, u as random333Pattern } from "../outside-V6_PW1ZK.js";
2
2
 
3
3
  //#region src/cubing/search/index.d.ts
4
4
  /** @deprecated */
@@ -6,7 +6,7 @@ import {
6
6
  solvePyraminx,
7
7
  solveSkewb,
8
8
  solveTwips
9
- } from "../chunks/chunk-WMKAKGVZ.js";
9
+ } from "../chunks/chunk-5KMTA6PX.js";
10
10
  import {
11
11
  random333Pattern
12
12
  } from "../chunks/chunk-H5KMIDAF.js";
@@ -1,2 +1,2 @@
1
- import { a as OrientationEvent, c as ProxyOrientationEvent, i as AlgLeafEvent, l as ProxyResetEvent, n as WebSocketProxySender, o as ProxyEvent, r as TwizzleStreamServer, s as ProxyMoveEvent, t as WebSocketProxyReceiver } from "../index-Cvk652Bd.js";
1
+ import { a as OrientationEvent, c as ProxyOrientationEvent, i as AlgLeafEvent, l as ProxyResetEvent, n as WebSocketProxySender, o as ProxyEvent, r as TwizzleStreamServer, s as ProxyMoveEvent, t as WebSocketProxyReceiver } from "../index-BLw2OxXo.js";
2
2
  export { AlgLeafEvent as ExperimentalAlgLeafEvent, OrientationEvent as ExperimentalOrientationEvent, ProxyEvent as ExperimentalProxyEvent, ProxyMoveEvent as ExperimentalProxyMoveEvent, ProxyOrientationEvent as ExperimentalProxyOrientationEvent, ProxyResetEvent as ExperimentalProxyResetEvent, TwizzleStreamServer as ExperimentalTwizzleStreamServer, WebSocketProxyReceiver as ExperimentalWebSocketProxyReceiver, WebSocketProxySender as ExperimentalWebSocketProxySender };
@@ -1,2 +1,2 @@
1
- import { A as SimpleAlgIndexer, C as VisualizationFormat, D as PuzzleID, E as ExperimentalStickering, F as MillisecondDuration, I as MillisecondTimestamp, M as LeafCount, N as LeafIndex, O as setTwistyDebug, P as NO_VALUE, S as TwistyAnimatedSVG, T as backViewLayouts, d as TwistyAlgEditor, j as AlgIndexer, k as TreeAlgIndexer, l as TwizzleLink, m as TwistyPlayerConfig, p as TwistyPlayer, u as TwistyAlgViewer, w as BackViewLayout } from "../index-BXHm_6gm.js";
1
+ import { A as SimpleAlgIndexer, C as VisualizationFormat, D as PuzzleID, E as ExperimentalStickering, F as MillisecondDuration, I as MillisecondTimestamp, M as LeafCount, N as LeafIndex, O as setTwistyDebug, P as NO_VALUE, S as TwistyAnimatedSVG, T as backViewLayouts, d as TwistyAlgEditor, j as AlgIndexer, k as TreeAlgIndexer, l as TwizzleLink, m as TwistyPlayerConfig, p as TwistyPlayer, u as TwistyAlgViewer, w as BackViewLayout } from "../index-B2leUGbW.js";
2
2
  export { AlgIndexer, BackViewLayout, NO_VALUE as EXPERIMENTAL_PROP_NO_VALUE, LeafCount as ExperimentalLeafCount, LeafIndex as ExperimentalLeafIndex, MillisecondDuration as ExperimentalMillisecondDuration, MillisecondTimestamp as ExperimentalMillisecondTimestamp, TwistyAnimatedSVG as ExperimentalSVGAnimator, ExperimentalStickering, PuzzleID, SimpleAlgIndexer, TreeAlgIndexer, TwistyAlgEditor, TwistyAlgViewer, TwistyPlayer, TwistyPlayerConfig, TwizzleLink, VisualizationFormat, backViewLayouts, setTwistyDebug };
@@ -5308,23 +5308,45 @@ twistyAlgViewerCSS.replaceSync(
5308
5308
  `
5309
5309
  :host {
5310
5310
  display: inline;
5311
+ --comment-shade: oklab(0.69 -0.19 0.14);
5312
+ --comment-opacity: 0.6;
5313
+ --active-background-shade: rgba(66, 133, 244);
5311
5314
  }
5312
5315
 
5313
5316
  .wrapper {
5314
5317
  display: inline;
5318
+ --current-color: currentColor
5315
5319
  }
5316
5320
 
5317
- a:not(:hover) {
5318
- color: inherit;
5319
- text-decoration: none;
5321
+ a {
5322
+ color: currentColor;
5323
+
5324
+ &:not(:hover) {
5325
+ text-decoration: none;
5326
+ }
5327
+
5328
+ &:hover {
5329
+ background: color-mix(in oklab, currentColor 20%, transparent);
5330
+ }
5331
+
5332
+ &:active {
5333
+ color: currentColor;
5334
+ animation: 1s linear flash;
5335
+ }
5336
+ }
5337
+
5338
+ @keyframes flash {
5339
+ from { opacity: 0.5; }
5340
+ to { opacity: 1; }
5320
5341
  }
5321
5342
 
5322
- twisty-alg-leaf-elem.twisty-alg-comment {
5323
- color: rgba(0, 0, 0, 0.4);
5343
+ twisty-alg-leaf-elem.twisty-alg-line-comment {
5344
+ color: color-mix(in oklab, var(--comment-shade) 75%, currentColor);
5345
+ opacity: var(--comment-opacity);
5324
5346
  }
5325
5347
 
5326
- .wrapper.current-move {
5327
- background: rgba(66, 133, 244, 0.3);
5348
+ .current-move {
5349
+ background: color-mix(in oklab, var(--active-background-shade) 30%, transparent);
5328
5350
  margin-left: -0.1em;
5329
5351
  margin-right: -0.1em;
5330
5352
  padding-left: 0.1em;
@@ -5336,16 +5358,13 @@ twisty-alg-leaf-elem.twisty-alg-comment {
5336
5358
 
5337
5359
  // src/cubing/twisty/views/TwistyAlgViewer.ts
5338
5360
  var DEFAULT_OFFSET_FRACTION = 0.25;
5339
- var TwistyAlgLeafElem = class extends ManagedCustomElement {
5361
+ var TwistyAlgLeafElem = class extends HTMLElementShim {
5340
5362
  constructor(className, text, dataDown, algOrAlgNode, offsetIntoMove, clickable) {
5341
- super({ mode: "open" });
5363
+ super();
5342
5364
  this.algOrAlgNode = algOrAlgNode;
5343
5365
  this.classList.add(className);
5344
- this.addCSS(twistyAlgViewerCSS);
5345
5366
  if (clickable) {
5346
- const anchor = this.contentWrapper.appendChild(
5347
- document.createElement("a")
5348
- );
5367
+ const anchor = this.appendChild(document.createElement("a"));
5349
5368
  anchor.href = "#";
5350
5369
  anchor.textContent = text;
5351
5370
  anchor.addEventListener("click", (e) => {
@@ -5356,9 +5375,7 @@ var TwistyAlgLeafElem = class extends ManagedCustomElement {
5356
5375
  );
5357
5376
  });
5358
5377
  } else {
5359
- this.contentWrapper.appendChild(
5360
- document.createElement("span")
5361
- ).textContent = text;
5378
+ this.appendChild(document.createElement("span")).textContent = text;
5362
5379
  }
5363
5380
  }
5364
5381
  algOrAlgNode;
@@ -5366,7 +5383,7 @@ var TwistyAlgLeafElem = class extends ManagedCustomElement {
5366
5383
  return [];
5367
5384
  }
5368
5385
  setCurrentMove(current) {
5369
- this.contentWrapper.classList.toggle("current-move", current);
5386
+ this.classList.toggle("current-move", current);
5370
5387
  }
5371
5388
  };
5372
5389
  customElementsShim.define("twisty-alg-leaf-elem", TwistyAlgLeafElem);
@@ -5379,7 +5396,9 @@ var TwistyAlgWrapperElem = class extends HTMLElementShim {
5379
5396
  algOrAlgNode;
5380
5397
  queue = [];
5381
5398
  addString(str) {
5382
- this.queue.push(document.createTextNode(str));
5399
+ const span = document.createElement("span");
5400
+ span.textContent = str;
5401
+ this.queue.push(span);
5383
5402
  }
5384
5403
  addElem(dataUp) {
5385
5404
  this.queue.push(dataUp.element);
@@ -5626,20 +5645,20 @@ var MoveHighlighter = class {
5626
5645
  if (this.currentElem === newElem) {
5627
5646
  return;
5628
5647
  }
5629
- this.currentElem?.classList.remove("twisty-alg-current-move");
5630
5648
  this.currentElem?.setCurrentMove(false);
5631
- newElem?.classList.add("twisty-alg-current-move");
5632
5649
  newElem?.setCurrentMove(true);
5633
5650
  this.currentElem = newElem;
5634
5651
  }
5635
5652
  };
5636
- var TwistyAlgViewer = class extends HTMLElementShim {
5653
+ var TwistyAlgViewer = class extends ManagedCustomElement {
5637
5654
  highlighter = new MoveHighlighter();
5638
5655
  #domTree;
5656
+ #domTreeAlg;
5639
5657
  #twistyPlayer = null;
5640
5658
  lastClickTimestamp = null;
5641
5659
  constructor(options) {
5642
- super();
5660
+ super({ mode: "open" });
5661
+ this.addCSS(twistyAlgViewerCSS);
5643
5662
  if (options?.twistyPlayer) {
5644
5663
  this.twistyPlayer = options?.twistyPlayer;
5645
5664
  }
@@ -5647,13 +5666,17 @@ var TwistyAlgViewer = class extends HTMLElementShim {
5647
5666
  connectedCallback() {
5648
5667
  }
5649
5668
  setAlg(alg) {
5669
+ if (this.#domTreeAlg?.isIdentical(alg)) {
5670
+ return;
5671
+ }
5650
5672
  this.#domTree = algToDOMTree(alg, {
5651
5673
  earliestMoveIndex: 0,
5652
5674
  twistyAlgViewer: this,
5653
5675
  direction: 1 /* Forwards */
5654
5676
  }).element;
5655
- this.textContent = "";
5656
- this.appendChild(this.#domTree);
5677
+ this.#domTreeAlg = alg;
5678
+ this.contentWrapper.textContent = "";
5679
+ this.contentWrapper.appendChild(this.#domTree);
5657
5680
  }
5658
5681
  get twistyPlayer() {
5659
5682
  return this.#twistyPlayer;
@@ -5675,9 +5698,6 @@ var TwistyAlgViewer = class extends HTMLElementShim {
5675
5698
  this.setAlg(algWithIssues.alg);
5676
5699
  }
5677
5700
  );
5678
- const sourceAlg = (await this.#twistyPlayer.experimentalModel.alg.get()).alg;
5679
- const parsedAlg = startCharIndexKey in sourceAlg ? sourceAlg : Alg.fromString(sourceAlg.toString());
5680
- this.setAlg(parsedAlg);
5681
5701
  twistyPlayer.experimentalModel.currentMoveInfo.addFreshListener(
5682
5702
  (currentMoveInfo) => {
5683
5703
  let moveInfo = currentMoveInfo.currentMoves[0];
@@ -5897,7 +5917,6 @@ twizzleLinkForumTweaksCSS.replaceSync(`
5897
5917
  background: #262626;
5898
5918
  --text-color: 142, 142, 142;
5899
5919
  border-color: #FFFFFF44;
5900
- color-scheme: dark;
5901
5920
  }
5902
5921
 
5903
5922
  .wrapper.dark-mode .heading:not(.title) {