@logic-pad/core 0.1.1 → 0.1.2

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 (190) hide show
  1. package/assets/logic-core.global.d.ts +1272 -1269
  2. package/dist/data/config.d.ts +3 -3
  3. package/dist/data/config.js +1 -1
  4. package/dist/data/configurable.d.ts +1 -1
  5. package/dist/data/configurable.js +1 -1
  6. package/dist/data/dataHelper.d.ts +1 -1
  7. package/dist/data/dataHelper.js +1 -1
  8. package/dist/data/events/onFinalValidation.d.ts +3 -3
  9. package/dist/data/events/onFinalValidation.js +1 -1
  10. package/dist/data/events/onGridChange.d.ts +2 -2
  11. package/dist/data/events/onGridChange.js +1 -1
  12. package/dist/data/events/onGridResize.d.ts +2 -2
  13. package/dist/data/events/onGridResize.js +1 -1
  14. package/dist/data/events/onSetGrid.d.ts +2 -2
  15. package/dist/data/events/onSetGrid.js +1 -1
  16. package/dist/data/events/onSymbolValidation.d.ts +4 -4
  17. package/dist/data/events/onSymbolValidation.js +1 -1
  18. package/dist/data/grid.d.ts +5 -5
  19. package/dist/data/grid.js +7 -7
  20. package/dist/data/gridConnections.d.ts +2 -2
  21. package/dist/data/gridConnections.js +1 -1
  22. package/dist/data/instruction.d.ts +2 -2
  23. package/dist/data/instruction.js +1 -1
  24. package/dist/data/puzzle.d.ts +1 -1
  25. package/dist/data/puzzle.js +1 -1
  26. package/dist/data/rules/banPatternRule.d.ts +5 -5
  27. package/dist/data/rules/banPatternRule.js +6 -6
  28. package/dist/data/rules/cellCountRule.d.ts +4 -4
  29. package/dist/data/rules/cellCountRule.js +5 -5
  30. package/dist/data/rules/completePatternRule.d.ts +3 -3
  31. package/dist/data/rules/completePatternRule.js +3 -3
  32. package/dist/data/rules/connectAllRule.d.ts +4 -4
  33. package/dist/data/rules/connectAllRule.js +5 -5
  34. package/dist/data/rules/customRule.d.ts +4 -4
  35. package/dist/data/rules/customRule.js +4 -4
  36. package/dist/data/rules/foresightRule.d.ts +4 -4
  37. package/dist/data/rules/foresightRule.js +5 -5
  38. package/dist/data/rules/index.d.ts +1 -1
  39. package/dist/data/rules/index.js +1 -1
  40. package/dist/data/rules/musicControlLine.d.ts +2 -2
  41. package/dist/data/rules/musicControlLine.js +2 -2
  42. package/dist/data/rules/musicGridRule.d.ts +8 -8
  43. package/dist/data/rules/musicGridRule.js +7 -7
  44. package/dist/data/rules/mysteryRule.d.ts +7 -7
  45. package/dist/data/rules/mysteryRule.js +6 -6
  46. package/dist/data/rules/offByXRule.d.ts +6 -6
  47. package/dist/data/rules/offByXRule.js +6 -6
  48. package/dist/data/rules/regionAreaRule.d.ts +4 -4
  49. package/dist/data/rules/regionAreaRule.js +6 -6
  50. package/dist/data/rules/regionShapeRule.d.ts +4 -4
  51. package/dist/data/rules/regionShapeRule.js +4 -4
  52. package/dist/data/rules/rule.d.ts +3 -3
  53. package/dist/data/rules/rule.js +1 -1
  54. package/dist/data/rules/rules.gen.d.ts +14 -14
  55. package/dist/data/rules/rules.gen.js +14 -14
  56. package/dist/data/rules/sameShapeRule.d.ts +5 -5
  57. package/dist/data/rules/sameShapeRule.js +5 -5
  58. package/dist/data/rules/symbolsPerRegionRule.d.ts +4 -4
  59. package/dist/data/rules/symbolsPerRegionRule.js +7 -7
  60. package/dist/data/rules/undercluedRule.d.ts +3 -3
  61. package/dist/data/rules/undercluedRule.js +5 -5
  62. package/dist/data/rules/uniqueShapeRule.d.ts +5 -5
  63. package/dist/data/rules/uniqueShapeRule.js +4 -4
  64. package/dist/data/serializer/allSerializers.d.ts +4 -4
  65. package/dist/data/serializer/allSerializers.js +1 -1
  66. package/dist/data/serializer/compressor/allCompressors.d.ts +1 -1
  67. package/dist/data/serializer/compressor/allCompressors.js +4 -4
  68. package/dist/data/serializer/compressor/deflateCompressor.d.ts +1 -1
  69. package/dist/data/serializer/compressor/deflateCompressor.js +1 -1
  70. package/dist/data/serializer/compressor/gzipCompressor.d.ts +1 -1
  71. package/dist/data/serializer/compressor/gzipCompressor.js +1 -1
  72. package/dist/data/serializer/compressor/streamCompressor.d.ts +1 -1
  73. package/dist/data/serializer/compressor/streamCompressor.js +2 -2
  74. package/dist/data/serializer/serializerBase.d.ts +6 -6
  75. package/dist/data/serializer/serializer_v0.d.ts +10 -10
  76. package/dist/data/serializer/serializer_v0.js +10 -10
  77. package/dist/data/shapes.d.ts +2 -2
  78. package/dist/data/shapes.js +1 -1
  79. package/dist/data/solver/allSolvers.d.ts +1 -1
  80. package/dist/data/solver/allSolvers.js +3 -3
  81. package/dist/data/solver/backtrack/backtrackSolver.d.ts +2 -2
  82. package/dist/data/solver/backtrack/backtrackSolver.js +19 -19
  83. package/dist/data/solver/backtrack/backtrackWorker.js +35 -35
  84. package/dist/data/solver/backtrack/data.d.ts +1 -1
  85. package/dist/data/solver/backtrack/data.js +1 -1
  86. package/dist/data/solver/backtrack/rules/banPattern.d.ts +3 -3
  87. package/dist/data/solver/backtrack/rules/banPattern.js +1 -1
  88. package/dist/data/solver/backtrack/rules/cellCount.d.ts +2 -2
  89. package/dist/data/solver/backtrack/rules/cellCount.js +1 -1
  90. package/dist/data/solver/backtrack/rules/connectAll.d.ts +2 -2
  91. package/dist/data/solver/backtrack/rules/connectAll.js +1 -1
  92. package/dist/data/solver/backtrack/rules/regionArea.d.ts +2 -2
  93. package/dist/data/solver/backtrack/rules/regionArea.js +1 -1
  94. package/dist/data/solver/backtrack/rules/regionShape.d.ts +2 -2
  95. package/dist/data/solver/backtrack/rules/regionShape.js +2 -2
  96. package/dist/data/solver/backtrack/rules/sameShape.d.ts +3 -3
  97. package/dist/data/solver/backtrack/rules/sameShape.js +1 -1
  98. package/dist/data/solver/backtrack/rules/symbolsPerRegion.d.ts +3 -3
  99. package/dist/data/solver/backtrack/rules/symbolsPerRegion.js +2 -2
  100. package/dist/data/solver/backtrack/rules/uniqueShape.d.ts +3 -3
  101. package/dist/data/solver/backtrack/rules/uniqueShape.js +1 -1
  102. package/dist/data/solver/backtrack/symbols/areaNumber.d.ts +3 -3
  103. package/dist/data/solver/backtrack/symbols/areaNumber.js +1 -1
  104. package/dist/data/solver/backtrack/symbols/dart.d.ts +2 -2
  105. package/dist/data/solver/backtrack/symbols/dart.js +2 -2
  106. package/dist/data/solver/backtrack/symbols/directionLinker.d.ts +3 -3
  107. package/dist/data/solver/backtrack/symbols/directionLinker.js +1 -1
  108. package/dist/data/solver/backtrack/symbols/galaxy.d.ts +4 -4
  109. package/dist/data/solver/backtrack/symbols/galaxy.js +1 -1
  110. package/dist/data/solver/backtrack/symbols/letter.d.ts +2 -2
  111. package/dist/data/solver/backtrack/symbols/letter.js +1 -1
  112. package/dist/data/solver/backtrack/symbols/lotus.d.ts +4 -4
  113. package/dist/data/solver/backtrack/symbols/lotus.js +2 -2
  114. package/dist/data/solver/backtrack/symbols/minesweeper.d.ts +2 -2
  115. package/dist/data/solver/backtrack/symbols/minesweeper.js +1 -1
  116. package/dist/data/solver/backtrack/symbols/myopia.d.ts +2 -2
  117. package/dist/data/solver/backtrack/symbols/myopia.js +3 -3
  118. package/dist/data/solver/backtrack/symbols/viewpoint.d.ts +2 -2
  119. package/dist/data/solver/backtrack/symbols/viewpoint.js +1 -1
  120. package/dist/data/solver/solver.d.ts +1 -1
  121. package/dist/data/solver/solver.js +2 -2
  122. package/dist/data/solver/underclued/undercluedSolver.d.ts +2 -2
  123. package/dist/data/solver/underclued/undercluedSolver.js +4 -4
  124. package/dist/data/solver/underclued/undercluedWorker.js +3 -3
  125. package/dist/data/solver/z3/modules/areaNumberModule.d.ts +3 -3
  126. package/dist/data/solver/z3/modules/areaNumberModule.js +2 -2
  127. package/dist/data/solver/z3/modules/cellCountModule.d.ts +3 -3
  128. package/dist/data/solver/z3/modules/cellCountModule.js +3 -3
  129. package/dist/data/solver/z3/modules/connectAllModule.d.ts +3 -3
  130. package/dist/data/solver/z3/modules/connectAllModule.js +2 -2
  131. package/dist/data/solver/z3/modules/dartModule.d.ts +3 -3
  132. package/dist/data/solver/z3/modules/dartModule.js +5 -5
  133. package/dist/data/solver/z3/modules/index.d.ts +1 -1
  134. package/dist/data/solver/z3/modules/index.js +1 -1
  135. package/dist/data/solver/z3/modules/letterModule.d.ts +3 -3
  136. package/dist/data/solver/z3/modules/letterModule.js +2 -2
  137. package/dist/data/solver/z3/modules/modules.gen.d.ts +8 -8
  138. package/dist/data/solver/z3/modules/modules.gen.js +8 -8
  139. package/dist/data/solver/z3/modules/myopiaModule.d.ts +3 -3
  140. package/dist/data/solver/z3/modules/myopiaModule.js +5 -5
  141. package/dist/data/solver/z3/modules/regionAreaModule.d.ts +3 -3
  142. package/dist/data/solver/z3/modules/regionAreaModule.js +2 -2
  143. package/dist/data/solver/z3/modules/viewpointModule.d.ts +3 -3
  144. package/dist/data/solver/z3/modules/viewpointModule.js +5 -5
  145. package/dist/data/solver/z3/modules/z3Module.d.ts +2 -2
  146. package/dist/data/solver/z3/utils.d.ts +1 -1
  147. package/dist/data/solver/z3/utils.js +1 -1
  148. package/dist/data/solver/z3/z3Solver.d.ts +2 -2
  149. package/dist/data/solver/z3/z3Solver.js +5 -5
  150. package/dist/data/symbols/areaNumberSymbol.d.ts +3 -3
  151. package/dist/data/symbols/areaNumberSymbol.js +4 -4
  152. package/dist/data/symbols/customIconSymbol.d.ts +7 -9
  153. package/dist/data/symbols/customIconSymbol.js +3 -3
  154. package/dist/data/symbols/customSymbol.d.ts +3 -3
  155. package/dist/data/symbols/customSymbol.js +2 -2
  156. package/dist/data/symbols/customTextSymbol.d.ts +3 -3
  157. package/dist/data/symbols/customTextSymbol.js +3 -3
  158. package/dist/data/symbols/dartSymbol.d.ts +4 -4
  159. package/dist/data/symbols/dartSymbol.js +4 -4
  160. package/dist/data/symbols/directionLinkerSymbol.d.ts +4 -4
  161. package/dist/data/symbols/directionLinkerSymbol.js +4 -4
  162. package/dist/data/symbols/galaxySymbol.d.ts +4 -4
  163. package/dist/data/symbols/galaxySymbol.js +4 -4
  164. package/dist/data/symbols/index.d.ts +1 -1
  165. package/dist/data/symbols/index.js +1 -1
  166. package/dist/data/symbols/letterSymbol.d.ts +4 -4
  167. package/dist/data/symbols/letterSymbol.js +5 -5
  168. package/dist/data/symbols/lotusSymbol.d.ts +4 -4
  169. package/dist/data/symbols/lotusSymbol.js +4 -4
  170. package/dist/data/symbols/minesweeperSymbol.d.ts +3 -3
  171. package/dist/data/symbols/minesweeperSymbol.js +4 -4
  172. package/dist/data/symbols/multiEntrySymbol.d.ts +2 -2
  173. package/dist/data/symbols/multiEntrySymbol.js +1 -1
  174. package/dist/data/symbols/myopiaSymbol.d.ts +4 -4
  175. package/dist/data/symbols/myopiaSymbol.js +4 -4
  176. package/dist/data/symbols/numberSymbol.d.ts +3 -3
  177. package/dist/data/symbols/numberSymbol.js +2 -2
  178. package/dist/data/symbols/symbol.d.ts +4 -4
  179. package/dist/data/symbols/symbol.js +1 -1
  180. package/dist/data/symbols/symbols.gen.d.ts +10 -10
  181. package/dist/data/symbols/symbols.gen.js +10 -10
  182. package/dist/data/symbols/viewpointSymbol.d.ts +3 -3
  183. package/dist/data/symbols/viewpointSymbol.js +5 -5
  184. package/dist/data/tile.d.ts +1 -1
  185. package/dist/data/tile.js +1 -1
  186. package/dist/data/validate.d.ts +2 -2
  187. package/dist/data/validate.js +3 -3
  188. package/dist/index.d.ts +95 -95
  189. package/dist/index.js +95 -96
  190. package/package.json +5 -5
@@ -6,140 +6,166 @@
6
6
 
7
7
  // noinspection JSUnusedGlobalSymbols
8
8
  declare global {
9
- // Generated by dts-bundle v0.7.3
10
- // Dependencies for this module:
11
- // ../../../zod
12
- // ../../../z3-solver
13
- // ../../../grilops
14
- // ../../../react-icons/md
9
+ // Generated by dts-bundle-generator v9.5.1
15
10
 
16
- import { z } from 'zod';
17
- import { Solver, Optimize } from 'z3-solver';
18
11
  import { RegionConstrainer, SymbolGrid } from 'grilops';
19
- import { Optimize, Solver } from 'z3-solver';
20
- import type Md from 'react-icons/md';
12
+ import { Optimize, Solver as Solver$1 } from 'z3-solver';
13
+ import { z } from 'zod';
21
14
 
22
- export enum ConfigType {
23
- Boolean = 'boolean',
24
- NullableBoolean = 'nullableBoolean',
25
- Number = 'number',
26
- NullableNumber = 'nullableNumber',
27
- String = 'string',
28
- Color = 'color',
29
- Comparison = 'comparison',
30
- Direction = 'direction',
31
- DirectionToggle = 'directionToggle',
32
- Orientation = 'orientation',
33
- OrientationToggle = 'orientationToggle',
34
- Tile = 'tile',
35
- Grid = 'grid',
36
- NullableGrid = 'nullableGrid',
37
- Icon = 'icon',
38
- ControlLines = 'controlLines',
39
- NullableNote = 'nullableNote',
40
- }
41
- export interface Config<T> {
42
- readonly type: ConfigType;
43
- readonly field: string;
44
- readonly description: string;
45
- readonly default: T;
46
- readonly configurable: boolean;
47
- }
48
- export interface BooleanConfig extends Config<boolean> {
49
- readonly type: ConfigType.Boolean;
50
- }
51
- export interface NullableBooleanConfig extends Config<boolean | null> {
52
- readonly type: ConfigType.NullableBoolean;
53
- }
54
- export interface NumberConfig extends Config<number> {
55
- readonly type: ConfigType.Number;
56
- readonly min?: number;
57
- readonly max?: number;
58
- readonly step?: number;
59
- }
60
- export interface NullableNumberConfig extends Config<number | null> {
61
- readonly type: ConfigType.NullableNumber;
62
- readonly min?: number;
63
- readonly max?: number;
64
- readonly step?: number;
65
- }
66
- export interface StringConfig extends Config<string> {
67
- readonly type: ConfigType.String;
68
- readonly maxLength?: number;
69
- readonly placeholder?: string;
70
- }
71
- export interface ColorConfig extends Config<Color> {
72
- readonly type: ConfigType.Color;
73
- readonly allowGray: boolean;
74
- }
75
- export interface ComparisonConfig extends Config<Comparison> {
76
- readonly type: ConfigType.Comparison;
15
+ interface Position$1 {
16
+ readonly x: number;
17
+ readonly y: number;
77
18
  }
78
- export interface DirectionConfig extends Config<Direction> {
79
- readonly type: ConfigType.Direction;
19
+ export interface Edge {
20
+ readonly x1: number;
21
+ readonly y1: number;
22
+ readonly x2: number;
23
+ readonly y2: number;
80
24
  }
81
- export interface DirectionToggleConfig extends Config<DirectionToggle> {
82
- readonly type: ConfigType.DirectionToggle;
25
+ export declare enum State {
26
+ Error = 'error',
27
+ Satisfied = 'satisfied',
28
+ Incomplete = 'incomplete',
83
29
  }
84
- export interface OrientationConfig extends Config<Orientation> {
85
- readonly type: ConfigType.Orientation;
30
+ export type RuleState =
31
+ | {
32
+ readonly state: State.Error;
33
+ readonly positions: readonly Position$1[];
34
+ }
35
+ | {
36
+ readonly state: State.Satisfied;
37
+ }
38
+ | {
39
+ readonly state: State.Incomplete;
40
+ };
41
+ export interface GridState {
42
+ final: State;
43
+ rules: readonly RuleState[];
44
+ symbols: ReadonlyMap<string, State[]>;
86
45
  }
87
- export interface OrientationToggleConfig extends Config<OrientationToggle> {
88
- readonly type: ConfigType.OrientationToggle;
46
+ export declare enum Color {
47
+ Dark = 'dark',
48
+ Light = 'light',
49
+ Gray = 'gray',
89
50
  }
90
- export interface TileConfig extends Config<GridData> {
91
- readonly type: ConfigType.Tile;
92
- readonly resizable: boolean;
51
+ export declare enum Comparison {
52
+ Equal = 'eq',
53
+ AtLeast = 'ge',
54
+ AtMost = 'le',
93
55
  }
94
- export interface GridConfig extends Config<GridData> {
95
- readonly type: ConfigType.Grid;
56
+ export declare const COMPARISONS: readonly Comparison[];
57
+ export declare enum Direction {
58
+ Up = 'up',
59
+ Down = 'down',
60
+ Left = 'left',
61
+ Right = 'right',
96
62
  }
97
- export interface NullableGridConfig extends Config<GridData | null> {
98
- readonly type: ConfigType.NullableGrid;
99
- readonly nonNullDefault: GridData;
63
+ export declare const DIRECTIONS: readonly Direction[];
64
+ export type DirectionMap<T> = {
65
+ [key in Direction]: T;
66
+ };
67
+ export type DirectionToggle = Readonly<DirectionMap<boolean>>;
68
+ export declare function directionToggle(
69
+ ...directions: readonly Direction[]
70
+ ): {
71
+ up: boolean;
72
+ down: boolean;
73
+ left: boolean;
74
+ right: boolean;
75
+ };
76
+ export declare enum Orientation {
77
+ Up = 'up',
78
+ UpRight = 'up-right',
79
+ Right = 'right',
80
+ DownRight = 'down-right',
81
+ Down = 'down',
82
+ DownLeft = 'down-left',
83
+ Left = 'left',
84
+ UpLeft = 'up-left',
100
85
  }
101
- export interface IconConfig extends Config<string> {
102
- readonly type: ConfigType.Icon;
86
+ export declare const ORIENTATIONS: readonly Orientation[];
87
+ export type OrientationMap<T> = {
88
+ [key in Orientation]: T;
89
+ };
90
+ export type OrientationToggle = Readonly<OrientationMap<boolean>>;
91
+ export declare function orientationToggle(
92
+ ...orientations: readonly Orientation[]
93
+ ): {
94
+ up: boolean;
95
+ 'up-right': boolean;
96
+ right: boolean;
97
+ 'down-right': boolean;
98
+ down: boolean;
99
+ 'down-left': boolean;
100
+ left: boolean;
101
+ 'up-left': boolean;
102
+ };
103
+ export declare enum Mode {
104
+ Create = 'create',
105
+ Solve = 'solve',
103
106
  }
104
- export interface ControlLinesConfig extends Config<ControlLine[]> {
105
- readonly type: ConfigType.ControlLines;
107
+ export declare class TileConnections {
108
+ [y: number]: {
109
+ [x: number]: boolean;
110
+ };
111
+ constructor();
112
+ get topLeft(): boolean;
113
+ set topLeft(value: boolean);
114
+ get top(): boolean;
115
+ set top(value: boolean);
116
+ get topRight(): boolean;
117
+ set topRight(value: boolean);
118
+ get left(): boolean;
119
+ set left(value: boolean);
120
+ get center(): boolean;
121
+ set center(value: boolean);
122
+ get right(): boolean;
123
+ set right(value: boolean);
124
+ get bottomLeft(): boolean;
125
+ set bottomLeft(value: boolean);
126
+ get bottom(): boolean;
127
+ set bottom(value: boolean);
128
+ get bottomRight(): boolean;
129
+ set bottomRight(value: boolean);
130
+ equals(other: TileConnections): boolean;
106
131
  }
107
- export interface NullableNoteConfig extends Config<string | null> {
108
- readonly type: ConfigType.NullableNote;
132
+ export declare class GridConnections {
133
+ readonly edges: readonly Edge[];
134
+ constructor(edges?: readonly Edge[]);
135
+ addEdge(edge: Edge): GridConnections;
136
+ removeEdge(edge: Edge): GridConnections;
137
+ isConnected(edge: Edge): boolean;
138
+ getConnectionsAt({ x, y }: Position$1): readonly Edge[];
139
+ getForTile({ x, y }: Position$1): TileConnections;
140
+ getConnectedTiles({ x, y }: Position$1): readonly Position$1[];
141
+ /**
142
+ * Create new GridConnections from a string array.
143
+ *
144
+ * - Use `.` for cells that don't connect to anything.
145
+ * - Use any other character for cells that connect to the same character.
146
+ *
147
+ * @param array - The string array to create the connections from.
148
+ * @returns The created connections. You can apply this to a GridData object using GridData.withConnections.
149
+ */
150
+ static create(array: string[]): GridConnections;
151
+ /**
152
+ * Check if two GridConnections objects are equal.
153
+ * @param other The other GridConnections object to compare to.
154
+ * @returns Whether the two objects are equal.
155
+ */
156
+ equals(other: GridConnections): boolean;
157
+ /**
158
+ * Deduplicate an array of edges.
159
+ * @param edges The array of edges to deduplicate.
160
+ * @returns The deduplicated array of edges.
161
+ */
162
+ static deduplicateEdges(edges: readonly Edge[]): readonly Edge[];
163
+ insertColumn(index: number): GridConnections;
164
+ insertRow(index: number): GridConnections;
165
+ removeColumn(index: number): GridConnections;
166
+ removeRow(index: number): GridConnections;
109
167
  }
110
- export type AnyConfig =
111
- | BooleanConfig
112
- | NullableBooleanConfig
113
- | NumberConfig
114
- | NullableNumberConfig
115
- | StringConfig
116
- | ColorConfig
117
- | ComparisonConfig
118
- | DirectionConfig
119
- | DirectionToggleConfig
120
- | OrientationConfig
121
- | OrientationToggleConfig
122
- | TileConfig
123
- | GridConfig
124
- | NullableGridConfig
125
- | IconConfig
126
- | ControlLinesConfig
127
- | NullableNoteConfig;
128
- /**
129
- * Compare two config values for equality, using an appropriate method for the config type.
130
- *
131
- * @param type The type of the config.
132
- * @param a The first value to compare.
133
- * @param b The second value to compare.
134
- * @returns Whether the two values are equal.
135
- */
136
- export function configEquals<C extends AnyConfig>(
137
- type: C['type'],
138
- a: C['default'],
139
- b: C['default']
140
- ): boolean;
141
-
142
- export abstract class Configurable {
168
+ export declare abstract class Configurable {
143
169
  get configs(): readonly AnyConfig[] | null;
144
170
  abstract copyWith(props: Record<string, unknown>): this;
145
171
  /**
@@ -150,135 +176,37 @@ declare global {
150
176
  */
151
177
  equals(other: Configurable): boolean;
152
178
  }
153
-
154
- /**
155
- * Offset the given position by a given step in the given direction.
156
- * @param position The position to offset.
157
- * @param direction The direction to offset in.
158
- * @param step The distance to offset by.
159
- * @returns The offset position.
160
- */
161
- export function move(
162
- position: Position,
163
- direction: Direction | Orientation,
164
- step?: number
165
- ): {
166
- x: number;
167
- y: number;
168
- };
169
- /**
170
- * Convert the given direction to a rotation in degrees.
171
- * @param direction The direction to convert.
172
- * @returns The rotation in degrees.
173
- */
174
- export function directionToRotation(direction: Direction): 0 | 270 | 90 | 180;
175
- /**
176
- * Convert the given orientation to a rotation in degrees.
177
- * @param orientation The orientation to convert.
178
- * @returns The rotation in degrees.
179
- */
180
- export function orientationToRotation(
181
- orientation: Orientation
182
- ): 0 | 270 | 90 | 180 | 225 | 125 | 315 | 45;
183
- /**
184
- * Create a new 2D array with the given dimensions and values.
185
- * @param width The width of the array.
186
- * @param height The height of the array.
187
- * @param value A function that returns the value for each x,y coordinate.
188
- * @returns The 2D array.
189
- */
190
- export function array<T>(
191
- width: number,
192
- height: number,
193
- value: (x: number, y: number) => T
194
- ): T[][];
195
- /**
196
- * Resize the given array to the new size, cutting off or padding with the default value.
197
- * @param array The array to resize.
198
- * @param newSize The new size of the array.
199
- * @param defaultValue A function that returns the default value for each new element.
200
- * @returns The resized array.
201
- */
202
- export function resize<T>(
203
- array: T[],
204
- newSize: number,
205
- defaultValue: () => T
206
- ): T[];
207
- export function resize<T>(
208
- array: readonly T[],
209
- newSize: number,
210
- defaultValue: () => T
211
- ): readonly T[];
212
- /**
213
- * Check if all the given values are equal.
214
- * @param values The values to compare.
215
- * @returns Whether all the values are equal.
216
- */
217
- export function allEqual<T>(...values: T[]): boolean;
218
- /**
219
- * Return the first element of the array which has the minimum mapped value.
220
- *
221
- * @param values The array of values.
222
- * @param mapper The function to map each value to a number.
223
- * @returns The first element with the minimum mapped value.
224
- */
225
- export function minBy<T>(
226
- values: readonly T[],
227
- mapper: (element: T) => number
228
- ): T | undefined;
229
- /**
230
- * Return the first element of the array which has the maximum mapped value.
231
- *
232
- * @param values The array of values.
233
- * @param mapper The function to map each value to a number.
234
- * @returns The first element with the maximum mapped value.
235
- */
236
- export function maxBy<T>(
237
- values: readonly T[],
238
- mapper: (element: T) => number
239
- ): T | undefined;
240
- /**
241
- * Escape the given text by replacing the specified characters with HTML escape sequences.
242
- * @param text The text to escape.
243
- * @param escapeCharacters The characters to escape.
244
- * @returns The escaped text.
245
- */
246
- export function escape(text: string, escapeCharacters?: string): string;
247
- /**
248
- * Unescape the given text by replacing HTML escape sequences with the corresponding characters.
249
- * @param text The text to unescape.
250
- * @param escapeCharacters The characters to unescape. This should match the characters escaped by the `escape` function.
251
- * @returns The unescaped text.
252
- */
253
- export function unescape(text: string, escapeCharacters?: string): string;
254
-
255
- export function isEventHandler<T>(val: unknown, event: string): val is T;
256
-
257
- export interface FinalValidationHandler {
179
+ export declare abstract class Instruction extends Configurable {
180
+ abstract get id(): string;
181
+ abstract get explanation(): string;
182
+ abstract createExampleGrid(): GridData;
258
183
  /**
259
- * Edits the final grid state after all rules and symbols have been validated.
184
+ * Indicates that validation by logic is not available and the solution must be used for validation
185
+ */
186
+ get validateWithSolution(): boolean;
187
+ get necessaryForCompletion(): boolean;
188
+ /**
189
+ * Check if this instruction is equal to another instruction by comparing their IDs and configs.
260
190
  *
261
- * @param grid The grid that is being validated.
262
- * @param solution The solution grid, or null if the solution is not available.
263
- * @param state The current state of the grid.
191
+ * @param other The other instruction to compare to.
192
+ * @returns Whether the two instructions are equal.
264
193
  */
265
- onFinalValidation(
266
- grid: GridData,
267
- solution: GridData | null,
268
- state: GridState
269
- ): GridState;
194
+ equals(other: Instruction): boolean;
270
195
  }
271
- export function handlesFinalValidation<T extends Instruction>(
272
- val: T
273
- ): val is T & FinalValidationHandler;
274
-
275
- export interface GridChangeHandler {
276
- onGridChange(newGrid: GridData): this;
196
+ export interface SearchVariant {
197
+ description: string;
198
+ rule: Rule;
199
+ }
200
+ export declare abstract class Rule extends Instruction {
201
+ abstract validateGrid(grid: GridData): RuleState;
202
+ abstract get searchVariants(): SearchVariant[];
203
+ searchVariant(): SearchVariant;
204
+ get visibleWhenSolving(): boolean;
205
+ /**
206
+ * Whether only one instance of this rule is allowed in a grid.
207
+ */
208
+ get isSingleton(): boolean;
277
209
  }
278
- export function handlesGridChange<T extends Instruction>(
279
- val: T
280
- ): val is T & GridChangeHandler;
281
-
282
210
  export interface GridResizeHandler {
283
211
  /**
284
212
  * Update itself when the grid is resized.
@@ -290,44 +218,63 @@ declare global {
290
218
  index: number
291
219
  ): this | null;
292
220
  }
293
- export function handlesGridResize<T extends Instruction>(
221
+ export declare function handlesGridResize<T extends Instruction>(
294
222
  val: T
295
223
  ): val is T & GridResizeHandler;
296
-
297
- export interface SetGridHandler {
298
- onSetGrid(oldGrid: GridData, newGrid: GridData): GridData;
224
+ declare abstract class Symbol$1
225
+ extends Instruction
226
+ implements GridResizeHandler
227
+ {
228
+ readonly x: number;
229
+ readonly y: number;
230
+ constructor(x: number, y: number);
231
+ abstract validateSymbol(grid: GridData): State;
232
+ onGridResize(
233
+ _grid: GridData,
234
+ mode: 'insert' | 'remove',
235
+ direction: 'row' | 'column',
236
+ index: number
237
+ ): this | null;
238
+ get placementStep(): number;
239
+ withX(x: number): this;
240
+ withY(y: number): this;
241
+ withPosition(x: number, y: number): this;
299
242
  }
300
- export function handlesSetGrid<T extends Instruction>(
301
- val: T
302
- ): val is T & SetGridHandler;
303
-
304
- export interface SymbolValidationHandler {
243
+ export declare class TileData {
244
+ readonly exists: boolean;
245
+ readonly fixed: boolean;
246
+ readonly color: Color;
247
+ constructor(exists: boolean, fixed: boolean, color: Color);
305
248
  /**
306
- * Overrides the validation of symbols.
307
- *
308
- * You can return a different validation result, or call the original validation logic with a modified grid.
309
- *
310
- * @param grid - The grid to validate.
311
- * @param _symbol - The symbol to validate.
312
- * @param validator - The original validation logic for the symbol.
313
- * @returns The state of the symbol after validation.
249
+ * Create a gray tile.
314
250
  */
315
- onSymbolValidation(
316
- grid: GridData,
317
- symbol: Symbol,
318
- validator: (grid: GridData) => State
319
- ): State | undefined;
251
+ static empty(): TileData;
252
+ /**
253
+ * Create a non-existent tile.
254
+ */
255
+ static doesNotExist(): TileData;
256
+ copyWith({
257
+ exists,
258
+ fixed,
259
+ color,
260
+ }: {
261
+ exists?: boolean;
262
+ fixed?: boolean;
263
+ color?: Color;
264
+ }): this;
265
+ withExists(exists: boolean): this;
266
+ withFixed(fixed: boolean): this;
267
+ withColor(color: Color): this;
268
+ get isFixed(): boolean;
269
+ equals(other: TileData): boolean;
270
+ static create(char: string): TileData;
320
271
  }
321
- export function handlesSymbolValidation<T extends Rule>(
322
- val: T
323
- ): val is T & SymbolValidationHandler;
324
-
325
- export class GridData {
272
+ export declare class GridData {
326
273
  readonly width: number;
327
274
  readonly height: number;
328
275
  readonly tiles: readonly (readonly TileData[])[];
329
276
  readonly connections: GridConnections;
330
- readonly symbols: ReadonlyMap<string, readonly Symbol[]>;
277
+ readonly symbols: ReadonlyMap<string, readonly Symbol$1[]>;
331
278
  readonly rules: readonly Rule[];
332
279
  /**
333
280
  * Create a new grid with tiles, connections, symbols and rules.
@@ -343,7 +290,7 @@ declare global {
343
290
  height: number,
344
291
  tiles?: readonly (readonly TileData[])[],
345
292
  connections?: GridConnections,
346
- symbols?: ReadonlyMap<string, readonly Symbol[]>,
293
+ symbols?: ReadonlyMap<string, readonly Symbol$1[]>,
347
294
  rules?: readonly Rule[]
348
295
  );
349
296
  /**
@@ -363,7 +310,7 @@ declare global {
363
310
  height?: number;
364
311
  tiles?: readonly (readonly TileData[])[];
365
312
  connections?: GridConnections;
366
- symbols?: ReadonlyMap<string, readonly Symbol[]>;
313
+ symbols?: ReadonlyMap<string, readonly Symbol$1[]>;
367
314
  rules?: readonly Rule[];
368
315
  }): GridData;
369
316
  isPositionValid(x: number, y: number): boolean;
@@ -417,43 +364,43 @@ declare global {
417
364
  */
418
365
  withSymbols(
419
366
  symbols:
420
- | readonly Symbol[]
421
- | ReadonlyMap<string, readonly Symbol[]>
367
+ | readonly Symbol$1[]
368
+ | ReadonlyMap<string, readonly Symbol$1[]>
422
369
  | ((
423
- value: Map<string, readonly Symbol[]>
424
- ) => ReadonlyMap<string, readonly Symbol[]>)
370
+ value: Map<string, readonly Symbol$1[]>
371
+ ) => ReadonlyMap<string, readonly Symbol$1[]>)
425
372
  ): GridData;
426
373
  /**
427
374
  * Add a new symbol to the grid.
428
375
  * @param symbol The symbol to add.
429
376
  * @returns The new grid with the new symbol.
430
377
  */
431
- addSymbol(symbol: Symbol): GridData;
378
+ addSymbol(symbol: Symbol$1): GridData;
432
379
  /**
433
380
  * Remove an instance of the symbol from the grid.
434
381
  * @param symbol The symbol to remove.
435
382
  * @returns The new grid with the symbol removed.
436
383
  */
437
- removeSymbol(symbol: Symbol): GridData;
384
+ removeSymbol(symbol: Symbol$1): GridData;
438
385
  /**
439
386
  * Remove all symbols that satisfy the predicate.
440
387
  * @param predicate The predicate to test each symbol with.
441
388
  * @returns The new grid with the symbols removed.
442
389
  */
443
- removeSymbolIf(predicate: (symbol: Symbol) => boolean): GridData;
390
+ removeSymbolIf(predicate: (symbol: Symbol$1) => boolean): GridData;
444
391
  /**
445
392
  * Find the first symbol that satisfies the predicate.
446
393
  * @param predicate The predicate to test each symbol with.
447
394
  * @returns The first symbol that satisfies the predicate, or undefined if no symbol is found.
448
395
  */
449
- findSymbol(predicate: (symbol: Symbol) => boolean): Symbol | undefined;
396
+ findSymbol(predicate: (symbol: Symbol$1) => boolean): Symbol$1 | undefined;
450
397
  /**
451
398
  * Replace an existing symbol with a new symbol.
452
399
  * @param oldSymbol The symbol to replace.
453
400
  * @param newSymbol The new symbol to replace with.
454
401
  * @returns The new grid with the symbol replaced.
455
402
  */
456
- replaceSymbol(oldSymbol: Symbol, newSymbol: Symbol): GridData;
403
+ replaceSymbol(oldSymbol: Symbol$1, newSymbol: Symbol$1): GridData;
457
404
  /**
458
405
  * Add or modify the rules in the grid.
459
406
  * @param rules The new rules to add or modify.
@@ -554,7 +501,7 @@ declare global {
554
501
  */
555
502
  find(
556
503
  predicate: (tile: TileData, x: number, y: number) => boolean
557
- ): Position | undefined;
504
+ ): Position$1 | undefined;
558
505
  /**
559
506
  * Iterate over all tiles in the same region as the given position that satisfy the predicate.
560
507
  * The iteration stops when the callback returns a value that is not undefined.
@@ -566,7 +513,7 @@ declare global {
566
513
  * @returns The value returned by the callback that stopped the iteration, or undefined if the iteration completed.
567
514
  */
568
515
  iterateArea<T>(
569
- position: Position,
516
+ position: Position$1,
570
517
  predicate: (tile: TileData) => boolean,
571
518
  callback: (tile: TileData, x: number, y: number) => undefined | T
572
519
  ): T | undefined;
@@ -582,7 +529,7 @@ declare global {
582
529
  * @returns The value returned by the callback that stopped the iteration, or undefined if the iteration completed.
583
530
  */
584
531
  iterateDirection<T>(
585
- position: Position,
532
+ position: Position$1,
586
533
  direction: Direction | Orientation,
587
534
  predicate: (tile: TileData) => boolean,
588
535
  callback: (tile: TileData, x: number, y: number) => T | undefined
@@ -599,7 +546,7 @@ declare global {
599
546
  * @returns The value returned by the callback that stopped the iteration, or undefined if the iteration completed.
600
547
  */
601
548
  iterateDirectionAll<T>(
602
- position: Position,
549
+ position: Position$1,
603
550
  direction: Direction | Orientation,
604
551
  predicate: (tile: TileData) => boolean,
605
552
  callback: (tile: TileData, x: number, y: number) => T | undefined
@@ -630,7 +577,7 @@ declare global {
630
577
  * @returns The new grid with the region filled with the new color.
631
578
  */
632
579
  floodFill(
633
- position: Position,
580
+ position: Position$1,
634
581
  from: Color,
635
582
  to: Color,
636
583
  allowFixed: boolean
@@ -665,7 +612,7 @@ declare global {
665
612
  * @param height The height of the region to copy.
666
613
  * @returns The new grid with the copied tiles.
667
614
  */
668
- copyTiles(origin: Position, width: number, height: number): GridData;
615
+ copyTiles(origin: Position$1, width: number, height: number): GridData;
669
616
  /**
670
617
  * Paste the tiles from the given grid to the current grid at the given position.
671
618
  * All connections, symbols, and rules are merged.
@@ -674,7 +621,7 @@ declare global {
674
621
  * @param grid The grid to paste the tiles from.
675
622
  * @returns The new grid with the pasted tiles.
676
623
  */
677
- pasteTiles(origin: Position, grid: GridData): GridData;
624
+ pasteTiles(origin: Position$1, grid: GridData): GridData;
678
625
  /**
679
626
  * Paste the tiles from the given array to the current grid at the given position.
680
627
  *
@@ -683,7 +630,7 @@ declare global {
683
630
  * @returns The new grid with the pasted tiles.
684
631
  */
685
632
  pasteTiles(
686
- origin: Position,
633
+ origin: Position$1,
687
634
  tile: readonly (readonly TileData[])[]
688
635
  ): GridData;
689
636
  /**
@@ -743,154 +690,360 @@ declare global {
743
690
  * @returns The deduplicated map of symbols.
744
691
  */
745
692
  static deduplicateSymbols(
746
- symbols: ReadonlyMap<string, readonly Symbol[]>
747
- ): Map<string, Symbol[]>;
693
+ symbols: ReadonlyMap<string, readonly Symbol$1[]>
694
+ ): Map<string, Symbol$1[]>;
748
695
  }
749
-
750
- export class GridConnections {
751
- readonly edges: readonly Edge[];
752
- constructor(edges?: readonly Edge[]);
753
- addEdge(edge: Edge): GridConnections;
754
- removeEdge(edge: Edge): GridConnections;
755
- isConnected(edge: Edge): boolean;
756
- getConnectionsAt({ x, y }: Position): readonly Edge[];
757
- getForTile({ x, y }: Position): TileConnections;
758
- getConnectedTiles({ x, y }: Position): readonly Position[];
759
- /**
760
- * Create new GridConnections from a string array.
761
- *
762
- * - Use `.` for cells that don't connect to anything.
763
- * - Use any other character for cells that connect to the same character.
764
- *
765
- * @param array - The string array to create the connections from.
766
- * @returns The created connections. You can apply this to a GridData object using GridData.withConnections.
767
- */
768
- static create(array: string[]): GridConnections;
696
+ export declare class Row extends Configurable {
769
697
  /**
770
- * Check if two GridConnections objects are equal.
771
- * @param other The other GridConnections object to compare to.
772
- * @returns Whether the two objects are equal.
698
+ * The note to play at this row, or null to keep the current note from the previous control line.
699
+ * If this is null from the first control line, the note will be silent.
773
700
  */
774
- equals(other: GridConnections): boolean;
701
+ readonly note: string | null;
775
702
  /**
776
- * Deduplicate an array of edges.
777
- * @param edges The array of edges to deduplicate.
778
- * @returns The deduplicated array of edges.
703
+ * The velocity to play the note at, or null to keep the current velocity from the previous control line.
704
+ * Ranges from 0 to 1
779
705
  */
780
- static deduplicateEdges(edges: readonly Edge[]): readonly Edge[];
781
- insertColumn(index: number): GridConnections;
782
- insertRow(index: number): GridConnections;
783
- removeColumn(index: number): GridConnections;
784
- removeRow(index: number): GridConnections;
706
+ readonly velocity: number | null;
707
+ private static readonly CONFIGS;
708
+ constructor(
709
+ /**
710
+ * The note to play at this row, or null to keep the current note from the previous control line.
711
+ * If this is null from the first control line, the note will be silent.
712
+ */
713
+ note: string | null,
714
+ /**
715
+ * The velocity to play the note at, or null to keep the current velocity from the previous control line.
716
+ * Ranges from 0 to 1
717
+ */
718
+ velocity: number | null
719
+ );
720
+ get configs(): readonly AnyConfig[] | null;
721
+ copyWith({
722
+ note,
723
+ velocity,
724
+ }: {
725
+ note?: string | null;
726
+ velocity?: number | null;
727
+ }): this;
785
728
  }
786
-
787
- export abstract class Instruction extends Configurable {
788
- abstract get id(): string;
789
- abstract get explanation(): string;
790
- abstract createExampleGrid(): GridData;
791
- /**
792
- * Indicates that validation by logic is not available and the solution must be used for validation
793
- */
794
- get validateWithSolution(): boolean;
795
- get necessaryForCompletion(): boolean;
729
+ export declare class ControlLine extends Configurable {
730
+ readonly column: number;
731
+ readonly bpm: number | null;
732
+ readonly pedal: boolean | null;
733
+ readonly checkpoint: boolean;
734
+ readonly rows: readonly Row[];
735
+ private static readonly CONFIGS;
796
736
  /**
797
- * Check if this instruction is equal to another instruction by comparing their IDs and configs.
798
- *
799
- * @param other The other instruction to compare to.
800
- * @returns Whether the two instructions are equal.
737
+ * Configure playback settings, taking effect at the given column (inclusive)
738
+ * @param column The column at which the settings take effect
739
+ * @param bpm The new beats per minute, or null to keep the current value from the previous control line
740
+ * @param pedal Whether the pedal is pressed, or null to keep the current value from the previous control line
741
+ * @param checkpoint Whether this control line is a checkpoint
742
+ * @param rows The notes to play at each row. This list is automatically resized to match the height of the grid. You may pass in an empty list if none of the rows need to be changed.
801
743
  */
802
- equals(other: Instruction): boolean;
803
- }
804
-
805
- export interface Position {
806
- readonly x: number;
807
- readonly y: number;
808
- }
809
- export interface Edge {
810
- readonly x1: number;
811
- readonly y1: number;
812
- readonly x2: number;
813
- readonly y2: number;
744
+ constructor(
745
+ column: number,
746
+ bpm: number | null,
747
+ pedal: boolean | null,
748
+ checkpoint: boolean,
749
+ rows: readonly Row[]
750
+ );
751
+ get configs(): readonly AnyConfig[] | null;
752
+ copyWith({
753
+ column,
754
+ bpm,
755
+ pedal,
756
+ checkpoint,
757
+ rows,
758
+ }: {
759
+ column?: number;
760
+ bpm?: number | null;
761
+ pedal?: boolean | null;
762
+ checkpoint?: boolean;
763
+ rows?: readonly Row[];
764
+ }): this;
765
+ withColumn(column: number): this;
766
+ withBpm(bpm: number | null): this;
767
+ withPedal(pedal: boolean | null): this;
768
+ withCheckpoint(checkpoint: boolean): this;
769
+ withRows(rows: readonly Row[]): this;
770
+ equals(other: ControlLine): boolean;
771
+ get isEmpty(): boolean;
814
772
  }
815
- export enum State {
816
- Error = 'error',
817
- Satisfied = 'satisfied',
818
- Incomplete = 'incomplete',
773
+ export declare enum ConfigType {
774
+ Boolean = 'boolean',
775
+ NullableBoolean = 'nullableBoolean',
776
+ Number = 'number',
777
+ NullableNumber = 'nullableNumber',
778
+ String = 'string',
779
+ Color = 'color',
780
+ Comparison = 'comparison',
781
+ Direction = 'direction',
782
+ DirectionToggle = 'directionToggle',
783
+ Orientation = 'orientation',
784
+ OrientationToggle = 'orientationToggle',
785
+ Tile = 'tile',
786
+ Grid = 'grid',
787
+ NullableGrid = 'nullableGrid',
788
+ Icon = 'icon',
789
+ ControlLines = 'controlLines',
790
+ NullableNote = 'nullableNote',
819
791
  }
820
- export type RuleState =
821
- | {
822
- readonly state: State.Error;
823
- readonly positions: readonly Position[];
824
- }
825
- | {
826
- readonly state: State.Satisfied;
827
- }
828
- | {
829
- readonly state: State.Incomplete;
830
- };
831
- export interface GridState {
832
- final: State;
833
- rules: readonly RuleState[];
834
- symbols: ReadonlyMap<string, State[]>;
792
+ export interface Config<T> {
793
+ readonly type: ConfigType;
794
+ readonly field: string;
795
+ readonly description: string;
796
+ readonly default: T;
797
+ readonly configurable: boolean;
835
798
  }
836
- export enum Color {
837
- Dark = 'dark',
838
- Light = 'light',
839
- Gray = 'gray',
799
+ export interface BooleanConfig extends Config<boolean> {
800
+ readonly type: ConfigType.Boolean;
840
801
  }
841
- export enum Comparison {
842
- Equal = 'eq',
843
- AtLeast = 'ge',
844
- AtMost = 'le',
802
+ export interface NullableBooleanConfig extends Config<boolean | null> {
803
+ readonly type: ConfigType.NullableBoolean;
845
804
  }
846
- export const COMPARISONS: readonly Comparison[];
847
- export enum Direction {
848
- Up = 'up',
849
- Down = 'down',
850
- Left = 'left',
851
- Right = 'right',
805
+ export interface NumberConfig extends Config<number> {
806
+ readonly type: ConfigType.Number;
807
+ readonly min?: number;
808
+ readonly max?: number;
809
+ readonly step?: number;
852
810
  }
853
- export const DIRECTIONS: readonly Direction[];
854
- export type DirectionMap<T> = {
855
- [key in Direction]: T;
856
- };
857
- export type DirectionToggle = Readonly<DirectionMap<boolean>>;
858
- export function directionToggle(...directions: readonly Direction[]): {
859
- up: boolean;
860
- down: boolean;
861
- left: boolean;
862
- right: boolean;
863
- };
864
- export enum Orientation {
865
- Up = 'up',
866
- UpRight = 'up-right',
867
- Right = 'right',
868
- DownRight = 'down-right',
869
- Down = 'down',
870
- DownLeft = 'down-left',
871
- Left = 'left',
872
- UpLeft = 'up-left',
811
+ export interface NullableNumberConfig extends Config<number | null> {
812
+ readonly type: ConfigType.NullableNumber;
813
+ readonly min?: number;
814
+ readonly max?: number;
815
+ readonly step?: number;
873
816
  }
874
- export const ORIENTATIONS: readonly Orientation[];
875
- export type OrientationMap<T> = {
876
- [key in Orientation]: T;
877
- };
878
- export type OrientationToggle = Readonly<OrientationMap<boolean>>;
879
- export function orientationToggle(...orientations: readonly Orientation[]): {
880
- up: boolean;
881
- 'up-right': boolean;
882
- right: boolean;
883
- 'down-right': boolean;
884
- down: boolean;
885
- 'down-left': boolean;
886
- left: boolean;
887
- 'up-left': boolean;
817
+ export interface StringConfig extends Config<string> {
818
+ readonly type: ConfigType.String;
819
+ readonly maxLength?: number;
820
+ readonly placeholder?: string;
821
+ }
822
+ export interface ColorConfig extends Config<Color> {
823
+ readonly type: ConfigType.Color;
824
+ readonly allowGray: boolean;
825
+ }
826
+ export interface ComparisonConfig extends Config<Comparison> {
827
+ readonly type: ConfigType.Comparison;
828
+ }
829
+ export interface DirectionConfig extends Config<Direction> {
830
+ readonly type: ConfigType.Direction;
831
+ }
832
+ export interface DirectionToggleConfig extends Config<DirectionToggle> {
833
+ readonly type: ConfigType.DirectionToggle;
834
+ }
835
+ export interface OrientationConfig extends Config<Orientation> {
836
+ readonly type: ConfigType.Orientation;
837
+ }
838
+ export interface OrientationToggleConfig extends Config<OrientationToggle> {
839
+ readonly type: ConfigType.OrientationToggle;
840
+ }
841
+ export interface TileConfig extends Config<GridData> {
842
+ readonly type: ConfigType.Tile;
843
+ readonly resizable: boolean;
844
+ }
845
+ export interface GridConfig extends Config<GridData> {
846
+ readonly type: ConfigType.Grid;
847
+ }
848
+ export interface NullableGridConfig extends Config<GridData | null> {
849
+ readonly type: ConfigType.NullableGrid;
850
+ readonly nonNullDefault: GridData;
851
+ }
852
+ export interface IconConfig extends Config<string> {
853
+ readonly type: ConfigType.Icon;
854
+ }
855
+ export interface ControlLinesConfig extends Config<ControlLine[]> {
856
+ readonly type: ConfigType.ControlLines;
857
+ }
858
+ export interface NullableNoteConfig extends Config<string | null> {
859
+ readonly type: ConfigType.NullableNote;
860
+ }
861
+ export type AnyConfig =
862
+ | BooleanConfig
863
+ | NullableBooleanConfig
864
+ | NumberConfig
865
+ | NullableNumberConfig
866
+ | StringConfig
867
+ | ColorConfig
868
+ | ComparisonConfig
869
+ | DirectionConfig
870
+ | DirectionToggleConfig
871
+ | OrientationConfig
872
+ | OrientationToggleConfig
873
+ | TileConfig
874
+ | GridConfig
875
+ | NullableGridConfig
876
+ | IconConfig
877
+ | ControlLinesConfig
878
+ | NullableNoteConfig;
879
+ /**
880
+ * Compare two config values for equality, using an appropriate method for the config type.
881
+ *
882
+ * @param type The type of the config.
883
+ * @param a The first value to compare.
884
+ * @param b The second value to compare.
885
+ * @returns Whether the two values are equal.
886
+ */
887
+ export declare function configEquals<C extends AnyConfig>(
888
+ type: C['type'],
889
+ a: C['default'],
890
+ b: C['default']
891
+ ): boolean;
892
+ /**
893
+ * Offset the given position by a given step in the given direction.
894
+ * @param position The position to offset.
895
+ * @param direction The direction to offset in.
896
+ * @param step The distance to offset by.
897
+ * @returns The offset position.
898
+ */
899
+ export declare function move(
900
+ position: Position$1,
901
+ direction: Direction | Orientation,
902
+ step?: number
903
+ ): {
904
+ x: number;
905
+ y: number;
888
906
  };
889
- export enum Mode {
890
- Create = 'create',
891
- Solve = 'solve',
907
+ /**
908
+ * Convert the given direction to a rotation in degrees.
909
+ * @param direction The direction to convert.
910
+ * @returns The rotation in degrees.
911
+ */
912
+ export declare function directionToRotation(
913
+ direction: Direction
914
+ ): 0 | 270 | 90 | 180;
915
+ /**
916
+ * Convert the given orientation to a rotation in degrees.
917
+ * @param orientation The orientation to convert.
918
+ * @returns The rotation in degrees.
919
+ */
920
+ export declare function orientationToRotation(
921
+ orientation: Orientation
922
+ ): 0 | 270 | 90 | 180 | 225 | 125 | 315 | 45;
923
+ /**
924
+ * Create a new 2D array with the given dimensions and values.
925
+ * @param width The width of the array.
926
+ * @param height The height of the array.
927
+ * @param value A function that returns the value for each x,y coordinate.
928
+ * @returns The 2D array.
929
+ */
930
+ export declare function array<T>(
931
+ width: number,
932
+ height: number,
933
+ value: (x: number, y: number) => T
934
+ ): T[][];
935
+ /**
936
+ * Resize the given array to the new size, cutting off or padding with the default value.
937
+ * @param array The array to resize.
938
+ * @param newSize The new size of the array.
939
+ * @param defaultValue A function that returns the default value for each new element.
940
+ * @returns The resized array.
941
+ */
942
+ export declare function resize<T>(
943
+ array: T[],
944
+ newSize: number,
945
+ defaultValue: () => T
946
+ ): T[];
947
+ export declare function resize<T>(
948
+ array: readonly T[],
949
+ newSize: number,
950
+ defaultValue: () => T
951
+ ): readonly T[];
952
+ /**
953
+ * Check if all the given values are equal.
954
+ * @param values The values to compare.
955
+ * @returns Whether all the values are equal.
956
+ */
957
+ export declare function allEqual<T>(...values: T[]): boolean;
958
+ /**
959
+ * Return the first element of the array which has the minimum mapped value.
960
+ *
961
+ * @param values The array of values.
962
+ * @param mapper The function to map each value to a number.
963
+ * @returns The first element with the minimum mapped value.
964
+ */
965
+ export declare function minBy<T>(
966
+ values: readonly T[],
967
+ mapper: (element: T) => number
968
+ ): T | undefined;
969
+ /**
970
+ * Return the first element of the array which has the maximum mapped value.
971
+ *
972
+ * @param values The array of values.
973
+ * @param mapper The function to map each value to a number.
974
+ * @returns The first element with the maximum mapped value.
975
+ */
976
+ export declare function maxBy<T>(
977
+ values: readonly T[],
978
+ mapper: (element: T) => number
979
+ ): T | undefined;
980
+ /**
981
+ * Escape the given text by replacing the specified characters with HTML escape sequences.
982
+ * @param text The text to escape.
983
+ * @param escapeCharacters The characters to escape.
984
+ * @returns The escaped text.
985
+ */
986
+ declare function escape$1(text: string, escapeCharacters?: string): string;
987
+ /**
988
+ * Unescape the given text by replacing HTML escape sequences with the corresponding characters.
989
+ * @param text The text to unescape.
990
+ * @param escapeCharacters The characters to unescape. This should match the characters escaped by the `escape` function.
991
+ * @returns The unescaped text.
992
+ */
993
+ declare function unescape$1(text: string, escapeCharacters?: string): string;
994
+ export declare function isEventHandler<T>(
995
+ val: unknown,
996
+ event: string
997
+ ): val is T;
998
+ export interface FinalValidationHandler {
999
+ /**
1000
+ * Edits the final grid state after all rules and symbols have been validated.
1001
+ *
1002
+ * @param grid The grid that is being validated.
1003
+ * @param solution The solution grid, or null if the solution is not available.
1004
+ * @param state The current state of the grid.
1005
+ */
1006
+ onFinalValidation(
1007
+ grid: GridData,
1008
+ solution: GridData | null,
1009
+ state: GridState
1010
+ ): GridState;
892
1011
  }
893
-
1012
+ export declare function handlesFinalValidation<T extends Instruction>(
1013
+ val: T
1014
+ ): val is T & FinalValidationHandler;
1015
+ export interface GridChangeHandler {
1016
+ onGridChange(newGrid: GridData): this;
1017
+ }
1018
+ export declare function handlesGridChange<T extends Instruction>(
1019
+ val: T
1020
+ ): val is T & GridChangeHandler;
1021
+ export interface SetGridHandler {
1022
+ onSetGrid(oldGrid: GridData, newGrid: GridData): GridData;
1023
+ }
1024
+ export declare function handlesSetGrid<T extends Instruction>(
1025
+ val: T
1026
+ ): val is T & SetGridHandler;
1027
+ export interface SymbolValidationHandler {
1028
+ /**
1029
+ * Overrides the validation of symbols.
1030
+ *
1031
+ * You can return a different validation result, or call the original validation logic with a modified grid.
1032
+ *
1033
+ * @param grid - The grid to validate.
1034
+ * @param _symbol - The symbol to validate.
1035
+ * @param validator - The original validation logic for the symbol.
1036
+ * @returns The state of the symbol after validation.
1037
+ */
1038
+ onSymbolValidation(
1039
+ grid: GridData,
1040
+ symbol: Symbol$1,
1041
+ validator: (grid: GridData) => State
1042
+ ): State | undefined;
1043
+ }
1044
+ export declare function handlesSymbolValidation<T extends Rule>(
1045
+ val: T
1046
+ ): val is T & SymbolValidationHandler;
894
1047
  export type PuzzleMetadata = {
895
1048
  /**
896
1049
  * The title of the puzzle. (required)
@@ -915,7 +1068,7 @@ declare global {
915
1068
  */
916
1069
  difficulty: number;
917
1070
  };
918
- export const MetadataSchema: z.ZodObject<
1071
+ export declare const MetadataSchema: z.ZodObject<
919
1072
  {
920
1073
  title: z.ZodString;
921
1074
  author: z.ZodString;
@@ -940,7 +1093,7 @@ declare global {
940
1093
  difficulty: number;
941
1094
  }
942
1095
  >;
943
- export const PuzzleSchema: z.ZodObject<
1096
+ export declare const PuzzleSchema: z.ZodObject<
944
1097
  {
945
1098
  title: z.ZodString;
946
1099
  author: z.ZodString;
@@ -987,8 +1140,30 @@ declare global {
987
1140
  */
988
1141
  solution: GridData | null;
989
1142
  };
990
-
991
- export class BanPatternRule extends Rule {
1143
+ export interface ShapeElement {
1144
+ x: number;
1145
+ y: number;
1146
+ color: Color;
1147
+ }
1148
+ export interface Shape {
1149
+ width: number;
1150
+ height: number;
1151
+ elements: ShapeElement[];
1152
+ }
1153
+ export declare function shapeEquals(a: Shape, b: Shape): boolean;
1154
+ export declare function tilesToShape(
1155
+ tiles: readonly (readonly TileData[])[]
1156
+ ): Shape;
1157
+ export declare function positionsToShape(
1158
+ positions: Position$1[],
1159
+ color: Color
1160
+ ): Shape;
1161
+ export declare function getShapeVariants(shape: Shape): Shape[];
1162
+ export declare function normalizeShape(shape: Shape): Shape;
1163
+ export declare class BanPatternRule extends Rule {
1164
+ private static readonly EXAMPLE_GRID;
1165
+ private static readonly CONFIGS;
1166
+ private static readonly SEARCH_VARIANTS;
992
1167
  readonly pattern: GridData;
993
1168
  readonly cache: Shape[];
994
1169
  /**
@@ -1006,10 +1181,13 @@ declare global {
1006
1181
  copyWith({ pattern }: { pattern?: GridData }): this;
1007
1182
  withPattern(pattern: GridData): this;
1008
1183
  }
1009
-
1010
- export class CellCountRule extends Rule {
1184
+ export declare class CellCountRule extends Rule {
1011
1185
  readonly color: Color;
1012
1186
  readonly count: number;
1187
+ private static readonly CONFIGS;
1188
+ private static readonly EXAMPLE_GRID_LIGHT;
1189
+ private static readonly EXAMPLE_GRID_DARK;
1190
+ private static readonly SEARCH_VARIANTS;
1013
1191
  /**
1014
1192
  * **There are &lt;count&gt; &lt;color&gt; cells in total**
1015
1193
  *
@@ -1027,8 +1205,9 @@ declare global {
1027
1205
  withColor(color: Color): this;
1028
1206
  withCount(count: number): this;
1029
1207
  }
1030
-
1031
- export class CompletePatternRule extends Rule {
1208
+ export declare class CompletePatternRule extends Rule {
1209
+ private static readonly EXAMPLE_GRID;
1210
+ private static readonly SEARCH_VARIANTS;
1032
1211
  /**
1033
1212
  * **Complete the pattern**
1034
1213
  *
@@ -1044,9 +1223,12 @@ declare global {
1044
1223
  get validateWithSolution(): boolean;
1045
1224
  get isSingleton(): boolean;
1046
1225
  }
1047
-
1048
- export class ConnectAllRule extends Rule {
1226
+ export declare class ConnectAllRule extends Rule {
1049
1227
  readonly color: Color;
1228
+ private static readonly CONFIGS;
1229
+ private static readonly EXAMPLE_GRID_LIGHT;
1230
+ private static readonly EXAMPLE_GRID_DARK;
1231
+ private static readonly SEARCH_VARIANTS;
1050
1232
  /**
1051
1233
  * **Connect all &lt;color&gt; cells**
1052
1234
  *
@@ -1062,11 +1244,12 @@ declare global {
1062
1244
  copyWith({ color }: { color?: Color }): this;
1063
1245
  withColor(color: Color): this;
1064
1246
  }
1065
-
1066
- export class CustomRule extends Rule {
1247
+ export declare class CustomRule extends Rule {
1067
1248
  readonly description: string;
1068
1249
  readonly grid: GridData;
1250
+ private static readonly EXAMPLE_GRID;
1069
1251
  static readonly configs: readonly AnyConfig[];
1252
+ private static readonly SEARCH_VARIANTS;
1070
1253
  /**
1071
1254
  * A custom rule with a description and thumbnail grid.
1072
1255
  *
@@ -1091,11 +1274,13 @@ declare global {
1091
1274
  }): this;
1092
1275
  get validateWithSolution(): boolean;
1093
1276
  }
1094
-
1095
- export class ForesightRule extends Rule {
1277
+ export declare class ForesightRule extends Rule {
1096
1278
  readonly count: number;
1097
1279
  readonly regenInterval: number;
1098
1280
  readonly startFull: boolean;
1281
+ private static readonly EXAMPLE_GRID;
1282
+ private static readonly CONFIGS;
1283
+ private static readonly SEARCH_VARIANTS;
1099
1284
  /**
1100
1285
  * **Foresight: Show hints**
1101
1286
  */
@@ -1118,92 +1303,16 @@ declare global {
1118
1303
  startFull?: boolean;
1119
1304
  }): this;
1120
1305
  }
1121
-
1122
- const allRules: Map<string, Rule>;
1123
- export { allRules };
1124
-
1125
- export class Row extends Configurable {
1126
- /**
1127
- * The note to play at this row, or null to keep the current note from the previous control line.
1128
- * If this is null from the first control line, the note will be silent.
1129
- */
1130
- readonly note: string | null;
1131
- /**
1132
- * The velocity to play the note at, or null to keep the current velocity from the previous control line.
1133
- * Ranges from 0 to 1
1134
- */
1135
- readonly velocity: number | null;
1136
- constructor(
1137
- /**
1138
- * The note to play at this row, or null to keep the current note from the previous control line.
1139
- * If this is null from the first control line, the note will be silent.
1140
- */
1141
- note: string | null,
1142
- /**
1143
- * The velocity to play the note at, or null to keep the current velocity from the previous control line.
1144
- * Ranges from 0 to 1
1145
- */
1146
- velocity: number | null
1147
- );
1148
- get configs(): readonly AnyConfig[] | null;
1149
- copyWith({
1150
- note,
1151
- velocity,
1152
- }: {
1153
- note?: string | null;
1154
- velocity?: number | null;
1155
- }): this;
1156
- }
1157
- export class ControlLine extends Configurable {
1158
- readonly column: number;
1159
- readonly bpm: number | null;
1160
- readonly pedal: boolean | null;
1161
- readonly checkpoint: boolean;
1162
- readonly rows: readonly Row[];
1163
- /**
1164
- * Configure playback settings, taking effect at the given column (inclusive)
1165
- * @param column The column at which the settings take effect
1166
- * @param bpm The new beats per minute, or null to keep the current value from the previous control line
1167
- * @param pedal Whether the pedal is pressed, or null to keep the current value from the previous control line
1168
- * @param checkpoint Whether this control line is a checkpoint
1169
- * @param rows The notes to play at each row. This list is automatically resized to match the height of the grid. You may pass in an empty list if none of the rows need to be changed.
1170
- */
1171
- constructor(
1172
- column: number,
1173
- bpm: number | null,
1174
- pedal: boolean | null,
1175
- checkpoint: boolean,
1176
- rows: readonly Row[]
1177
- );
1178
- get configs(): readonly AnyConfig[] | null;
1179
- copyWith({
1180
- column,
1181
- bpm,
1182
- pedal,
1183
- checkpoint,
1184
- rows,
1185
- }: {
1186
- column?: number;
1187
- bpm?: number | null;
1188
- pedal?: boolean | null;
1189
- checkpoint?: boolean;
1190
- rows?: readonly Row[];
1191
- }): this;
1192
- withColumn(column: number): this;
1193
- withBpm(bpm: number | null): this;
1194
- withPedal(pedal: boolean | null): this;
1195
- withCheckpoint(checkpoint: boolean): this;
1196
- withRows(rows: readonly Row[]): this;
1197
- equals(other: ControlLine): boolean;
1198
- get isEmpty(): boolean;
1199
- }
1200
-
1201
- export class MusicGridRule
1306
+ export declare const allRules: Map<string, Rule>;
1307
+ export declare class MusicGridRule
1202
1308
  extends Rule
1203
1309
  implements GridChangeHandler, SetGridHandler, GridResizeHandler
1204
1310
  {
1205
1311
  readonly controlLines: readonly ControlLine[];
1206
1312
  readonly track: GridData | null;
1313
+ private static readonly EXAMPLE_GRID;
1314
+ private static readonly CONFIGS;
1315
+ private static readonly SEARCH_VARIANTS;
1207
1316
  /**
1208
1317
  * **Music Grid: Listen to the solution**
1209
1318
  * @param controlLines Denote changes in the playback settings. At least one control line at column 0 should be present to enable playback.
@@ -1245,13 +1354,15 @@ declare global {
1245
1354
  lines: readonly ControlLine[]
1246
1355
  ): ControlLine[];
1247
1356
  }
1248
-
1249
- export class MysteryRule
1357
+ export declare class MysteryRule
1250
1358
  extends Rule
1251
1359
  implements FinalValidationHandler, GridChangeHandler, GridResizeHandler
1252
1360
  {
1253
1361
  readonly solution: GridData;
1254
1362
  readonly visible: boolean;
1363
+ private static readonly EXAMPLE_GRID;
1364
+ private static readonly CONFIGS;
1365
+ private static readonly SEARCH_VARIANTS;
1255
1366
  /**
1256
1367
  * **Mystery: alternate solution**
1257
1368
  */
@@ -1287,9 +1398,14 @@ declare global {
1287
1398
  withVisible(visible: boolean): this;
1288
1399
  static cleanSolution(solution: GridData, baseGrid?: GridData): GridData;
1289
1400
  }
1290
-
1291
- export class OffByXRule extends Rule implements SymbolValidationHandler {
1401
+ export declare class OffByXRule
1402
+ extends Rule
1403
+ implements SymbolValidationHandler
1404
+ {
1292
1405
  readonly number: number;
1406
+ private static readonly CONFIGS;
1407
+ private static readonly EXAMPLE_GRID;
1408
+ private static readonly SEARCH_VARIANTS;
1293
1409
  /**
1294
1410
  * **All numbers are off by &lt;number&gt;**
1295
1411
  *
@@ -1304,16 +1420,20 @@ declare global {
1304
1420
  validateGrid(_grid: GridData): RuleState;
1305
1421
  onSymbolValidation(
1306
1422
  grid: GridData,
1307
- symbol: Symbol,
1423
+ symbol: Symbol$1,
1308
1424
  _validator: (grid: GridData) => State
1309
1425
  ): State | undefined;
1310
1426
  copyWith({ number }: { number?: number }): this;
1311
1427
  withNumber(number: number): this;
1312
1428
  }
1313
-
1314
- export class RegionAreaRule extends Rule {
1429
+ export declare class RegionAreaRule extends Rule {
1315
1430
  readonly color: Color;
1316
1431
  readonly size: number;
1432
+ private static readonly CONFIGS;
1433
+ private static readonly EXAMPLE_GRID_DARK;
1434
+ private static readonly EXAMPLE_GRID_LIGHT;
1435
+ private static readonly EXAMPLE_GRID_GRAY;
1436
+ private static readonly SEARCH_VARIANTS;
1317
1437
  /**
1318
1438
  * **All &lt;color&gt; regions have area &lt;size&gt;**
1319
1439
  *
@@ -1331,16 +1451,15 @@ declare global {
1331
1451
  withColor(color: Color): this;
1332
1452
  withSize(size: number): this;
1333
1453
  }
1334
-
1335
1454
  export type ShapeRegions = {
1336
1455
  regions: {
1337
- positions: Position[];
1456
+ positions: Position$1[];
1338
1457
  shape: Shape;
1339
1458
  count: number;
1340
1459
  }[];
1341
1460
  complete: boolean;
1342
1461
  };
1343
- export abstract class RegionShapeRule extends Rule {
1462
+ export declare abstract class RegionShapeRule extends Rule {
1344
1463
  readonly color: Color;
1345
1464
  /**
1346
1465
  * @param color - The color of the regions to compare.
@@ -1349,23 +1468,11 @@ declare global {
1349
1468
  protected getShapeRegions(grid: GridData): ShapeRegions;
1350
1469
  withColor(color: Color): this;
1351
1470
  }
1352
-
1353
- export interface SearchVariant {
1354
- description: string;
1355
- rule: Rule;
1356
- }
1357
- export abstract class Rule extends Instruction {
1358
- abstract validateGrid(grid: GridData): RuleState;
1359
- abstract get searchVariants(): SearchVariant[];
1360
- searchVariant(): SearchVariant;
1361
- get visibleWhenSolving(): boolean;
1362
- /**
1363
- * Whether only one instance of this rule is allowed in a grid.
1364
- */
1365
- get isSingleton(): boolean;
1366
- }
1367
-
1368
- export class SameShapeRule extends RegionShapeRule {
1471
+ export declare class SameShapeRule extends RegionShapeRule {
1472
+ private static readonly CONFIGS;
1473
+ private static readonly EXAMPLE_GRID_LIGHT;
1474
+ private static readonly EXAMPLE_GRID_DARK;
1475
+ private static readonly SEARCH_VARIANTS;
1369
1476
  /**
1370
1477
  * **All &lt;color&gt; areas have the same shape and size**
1371
1478
  *
@@ -1380,11 +1487,14 @@ declare global {
1380
1487
  validateGrid(grid: GridData): RuleState;
1381
1488
  copyWith({ color }: { color?: Color }): this;
1382
1489
  }
1383
-
1384
- export class SymbolsPerRegionRule extends Rule {
1490
+ export declare class SymbolsPerRegionRule extends Rule {
1385
1491
  readonly color: Color;
1386
1492
  readonly count: number;
1387
1493
  readonly comparison: Comparison;
1494
+ private static readonly SYMBOL_POSITIONS;
1495
+ private static readonly CONFIGS;
1496
+ private static readonly EXAMPLE_GRIDS;
1497
+ private static readonly SEARCH_VARIANTS;
1388
1498
  /**
1389
1499
  * **Exactly &lt;count&gt; symbols per &lt;color&gt; area**
1390
1500
  *
@@ -1411,9 +1521,11 @@ declare global {
1411
1521
  withColor(color: Color): this;
1412
1522
  withCount(count: number): this;
1413
1523
  withComparison(comparison: Comparison): this;
1524
+ private static countAllSymbolsOfPosition;
1414
1525
  }
1415
-
1416
- export class UndercluedRule extends Rule {
1526
+ export declare class UndercluedRule extends Rule {
1527
+ private static readonly EXAMPLE_GRID;
1528
+ private static readonly SEARCH_VARIANTS;
1417
1529
  /**
1418
1530
  * **Underclued Grid: Mark only what is definitely true**
1419
1531
  *
@@ -1429,8 +1541,11 @@ declare global {
1429
1541
  get validateWithSolution(): boolean;
1430
1542
  get isSingleton(): boolean;
1431
1543
  }
1432
-
1433
- export class UniqueShapeRule extends RegionShapeRule {
1544
+ export declare class UniqueShapeRule extends RegionShapeRule {
1545
+ private static readonly CONFIGS;
1546
+ private static readonly EXAMPLE_GRID_LIGHT;
1547
+ private static readonly EXAMPLE_GRID_DARK;
1548
+ private static readonly SEARCH_VARIANTS;
1434
1549
  /**
1435
1550
  * **No two &lt;color&gt; areas have the same shape and size**
1436
1551
  *
@@ -1445,17 +1560,16 @@ declare global {
1445
1560
  validateGrid(grid: GridData): RuleState;
1446
1561
  copyWith({ color }: { color?: Color }): this;
1447
1562
  }
1448
-
1449
1563
  /**
1450
1564
  * The master serializer for puzzles.
1451
1565
  *
1452
1566
  * It uses the default serializer when stringifying puzzles, and select the correct deserializer when parsing puzzles.
1453
1567
  */
1454
- const Serializer: {
1568
+ export declare const Serializer: {
1455
1569
  stringifyRule(rule: Rule): string;
1456
1570
  parseRule(input: string): Rule;
1457
- stringifySymbol(symbol: Symbol): string;
1458
- parseSymbol(input: string): Symbol;
1571
+ stringifySymbol(symbol: Symbol$1): string;
1572
+ parseSymbol(input: string): Symbol$1;
1459
1573
  stringifyGrid(grid: GridData): string;
1460
1574
  parseGrid(input: string): GridData;
1461
1575
  /**
@@ -1471,23 +1585,7 @@ declare global {
1471
1585
  */
1472
1586
  parsePuzzle(input: string): Puzzle;
1473
1587
  };
1474
- export { Serializer };
1475
-
1476
- /**
1477
- * The master compressor for compressing and decompressing strings.
1478
- *
1479
- * It compares the output of multiple compressors and selects the one with the smallest size (slow),
1480
- * and selects the correct decompressor when decompressing.
1481
- */
1482
- class MasterCompressor extends CompressorBase {
1483
- get id(): string;
1484
- compress(input: string): Promise<string>;
1485
- decompress(input: string): Promise<string>;
1486
- }
1487
- const Compressor: MasterCompressor;
1488
- export { Compressor };
1489
-
1490
- export abstract class CompressorBase {
1588
+ export declare abstract class CompressorBase {
1491
1589
  /**
1492
1590
  * The unique identifier for this compressor.
1493
1591
  */
@@ -1503,26 +1601,51 @@ declare global {
1503
1601
  */
1504
1602
  abstract decompress(input: string): Promise<string>;
1505
1603
  }
1506
-
1507
- export class DeflateCompressor extends StreamCompressor {
1604
+ declare class MasterCompressor extends CompressorBase {
1508
1605
  get id(): string;
1509
- protected get algorithm(): CompressionFormat;
1510
1606
  compress(input: string): Promise<string>;
1511
1607
  decompress(input: string): Promise<string>;
1512
1608
  }
1513
-
1514
- export class GzipCompressor extends StreamCompressor {
1609
+ export declare const Compressor: MasterCompressor;
1610
+ export declare abstract class StreamCompressor extends CompressorBase {
1611
+ protected abstract get algorithm(): CompressionFormat;
1612
+ compress(input: string): Promise<string>;
1613
+ decompress(input: string): Promise<string>;
1614
+ }
1615
+ export declare class DeflateCompressor extends StreamCompressor {
1515
1616
  get id(): string;
1516
1617
  protected get algorithm(): CompressionFormat;
1517
- }
1518
-
1519
- export abstract class StreamCompressor extends CompressorBase {
1520
- protected abstract get algorithm(): CompressionFormat;
1521
1618
  compress(input: string): Promise<string>;
1522
1619
  decompress(input: string): Promise<string>;
1523
1620
  }
1524
-
1525
- export class SerializerV0 extends SerializerBase {
1621
+ export declare class GzipCompressor extends StreamCompressor {
1622
+ get id(): string;
1623
+ protected get algorithm(): CompressionFormat;
1624
+ }
1625
+ export declare abstract class SerializerBase {
1626
+ abstract get version(): number;
1627
+ abstract stringifyTile(tile: TileData): string;
1628
+ abstract parseTile(str: string): TileData;
1629
+ abstract stringifyRule(rule: Rule): string;
1630
+ abstract stringifySymbol(symbol: Symbol$1): string;
1631
+ abstract parseRule(str: string): Rule;
1632
+ abstract parseSymbol(str: string): Symbol$1;
1633
+ abstract stringifyConnections(connections: GridConnections): string;
1634
+ abstract parseConnections(input: string): GridConnections;
1635
+ abstract stringifyTiles(tiles: readonly (readonly TileData[])[]): string;
1636
+ abstract parseTiles(input: string): TileData[][];
1637
+ abstract stringifyRules(rules: readonly Rule[]): string;
1638
+ abstract parseRules(input: string): Rule[];
1639
+ abstract stringifySymbols(
1640
+ symbols: ReadonlyMap<string, readonly Symbol$1[]>
1641
+ ): string;
1642
+ abstract parseSymbols(input: string): Map<string, Symbol$1[]>;
1643
+ abstract stringifyGrid(grid: GridData): string;
1644
+ abstract parseGrid(input: string): GridData;
1645
+ abstract stringifyPuzzle(puzzle: Puzzle): string;
1646
+ abstract parsePuzzle(input: string): Puzzle;
1647
+ }
1648
+ export declare class SerializerV0 extends SerializerBase {
1526
1649
  readonly version = 0;
1527
1650
  stringifyTile(tile: TileData): string;
1528
1651
  parseTile(str: string): TileData;
@@ -1535,93 +1658,107 @@ declare global {
1535
1658
  ): [string, unknown];
1536
1659
  stringifyInstruction(instruction: Instruction): string;
1537
1660
  stringifyRule(rule: Rule): string;
1538
- stringifySymbol(symbol: Symbol): string;
1661
+ stringifySymbol(symbol: Symbol$1): string;
1539
1662
  parseRule(str: string): Rule;
1540
- parseSymbol(str: string): Symbol;
1663
+ parseSymbol(str: string): Symbol$1;
1541
1664
  stringifyConnections(connections: GridConnections): string;
1542
1665
  parseConnections(input: string): GridConnections;
1543
1666
  stringifyTiles(tiles: readonly (readonly TileData[])[]): string;
1544
1667
  parseTiles(input: string): TileData[][];
1545
1668
  stringifyRules(rules: readonly Rule[]): string;
1546
1669
  parseRules(input: string): Rule[];
1547
- stringifySymbols(symbols: ReadonlyMap<string, readonly Symbol[]>): string;
1548
- parseSymbols(input: string): Map<string, Symbol[]>;
1670
+ stringifySymbols(symbols: ReadonlyMap<string, readonly Symbol$1[]>): string;
1671
+ parseSymbols(input: string): Map<string, Symbol$1[]>;
1549
1672
  stringifyGrid(grid: GridData): string;
1550
1673
  parseGrid(input: string): GridData;
1551
1674
  stringifyPuzzle(puzzle: Puzzle): string;
1552
1675
  parsePuzzle(input: string): Puzzle;
1553
1676
  }
1554
-
1555
- export abstract class SerializerBase {
1556
- abstract get version(): number;
1557
- abstract stringifyTile(tile: TileData): string;
1558
- abstract parseTile(str: string): TileData;
1559
- abstract stringifyRule(rule: Rule): string;
1560
- abstract stringifySymbol(symbol: Symbol): string;
1561
- abstract parseRule(str: string): Rule;
1562
- abstract parseSymbol(str: string): Symbol;
1563
- abstract stringifyConnections(connections: GridConnections): string;
1564
- abstract parseConnections(input: string): GridConnections;
1565
- abstract stringifyTiles(tiles: readonly (readonly TileData[])[]): string;
1566
- abstract parseTiles(input: string): TileData[][];
1567
- abstract stringifyRules(rules: readonly Rule[]): string;
1568
- abstract parseRules(input: string): Rule[];
1569
- abstract stringifySymbols(
1570
- symbols: ReadonlyMap<string, readonly Symbol[]>
1571
- ): string;
1572
- abstract parseSymbols(input: string): Map<string, Symbol[]>;
1573
- abstract stringifyGrid(grid: GridData): string;
1574
- abstract parseGrid(input: string): GridData;
1575
- abstract stringifyPuzzle(puzzle: Puzzle): string;
1576
- abstract parsePuzzle(input: string): Puzzle;
1577
- }
1578
-
1579
- export interface ShapeElement {
1580
- x: number;
1581
- y: number;
1582
- color: Color;
1583
- }
1584
- export interface Shape {
1585
- width: number;
1586
- height: number;
1587
- elements: ShapeElement[];
1677
+ /**
1678
+ * Base class that all solvers must extend.
1679
+ */
1680
+ export declare abstract class Solver {
1681
+ /**
1682
+ * The unique identifier of the solver.
1683
+ *
1684
+ * This is also displayed to the user when selecting a solver.
1685
+ */
1686
+ abstract get id(): string;
1687
+ /**
1688
+ * A short paragraph describing when the user should use this solver.
1689
+ */
1690
+ abstract get description(): string;
1691
+ /**
1692
+ * Solve the given grid. The implementation should delegate long-running tasks to a worker thread and yield solutions
1693
+ * asynchronously.
1694
+ *
1695
+ * The solver must yield at least once, otherwise the UI will not update.
1696
+ *
1697
+ * If the solver finds no solution other than those already yielded, it should yield `null`. Yielding `null` on the
1698
+ * first iteration indicates that the grid is unsolvable. Yielding `null` on the second iteration indicates that the
1699
+ * solution is unique.
1700
+ *
1701
+ * In the current UI implementation, the solver will be terminated after yielding `null`, or after 2 iterations if
1702
+ * `null` is never yielded. The solver should perform any necessary cleanup in the `finally` block of the generator.
1703
+ *
1704
+ * @param grid The grid to solve. The provided grid is guaranteed to be supported by the solver. Some tiles in the
1705
+ * grid may already be filled by the user. It is up to the solver to decide whether to respect these tiles or not.
1706
+ */
1707
+ abstract solve(grid: GridData): AsyncGenerator<GridData | null>;
1708
+ /**
1709
+ * Check if the solver supports the current browser environment. This method is called once when the user first clicks
1710
+ * the "Solve" button, and the result is cached for the duration of the editor session.
1711
+ *
1712
+ * The `solve` method will not be called if this method returns `false`, and a message will be displayed to the user
1713
+ * indicating that the solver is not supported.
1714
+ *
1715
+ * @returns A promise that resolves to `true` if the environment is supported, or `false` otherwise.
1716
+ */
1717
+ isEnvironmentSupported(): Promise<boolean>;
1718
+ /**
1719
+ * Check if the solver supports the given instruction. This is used to render a small indication in the UI for each
1720
+ * instruction in the editor.
1721
+ *
1722
+ * @param instructionId The unique identifier of the instruction.
1723
+ */
1724
+ isInstructionSupported(instructionId: string): boolean;
1725
+ /**
1726
+ * Check if the solver supports the given grid. This methid is frequently called when the user changes the grid, and
1727
+ * the result is used to enable or disable the "Solve" button.
1728
+ *
1729
+ * The `solve` method will not be called if this method returns `false`, and a message will be displayed to the user
1730
+ * indicating that the grid is not supported by this solver.
1731
+ *
1732
+ * @param grid The grid to check.
1733
+ * @returns `true` if the grid is supported, or `false` otherwise.
1734
+ */
1735
+ isGridSupported(grid: GridData): boolean;
1588
1736
  }
1589
- export function shapeEquals(a: Shape, b: Shape): boolean;
1590
- export function tilesToShape(tiles: readonly (readonly TileData[])[]): Shape;
1591
- export function positionsToShape(positions: Position[], color: Color): Shape;
1592
- export function getShapeVariants(shape: Shape): Shape[];
1593
- export function normalizeShape(shape: Shape): Shape;
1594
-
1595
- const allSolvers: Map<string, Solver>;
1596
- export { allSolvers };
1597
-
1598
- export class BacktrackSolver extends Solver {
1737
+ export declare const allSolvers: Map<string, Solver>;
1738
+ export declare class BacktrackSolver extends Solver {
1739
+ private static readonly supportedInstrs;
1599
1740
  readonly id = 'backtrack';
1600
1741
  readonly description =
1601
1742
  'Solves puzzles using backtracking with optimizations (blazingly fast). Support most rules and symbols (including underclued).';
1602
1743
  solve(grid: GridData): AsyncGenerator<GridData | null>;
1603
1744
  isInstructionSupported(instructionId: string): boolean;
1604
1745
  }
1605
-
1606
- const _default: null;
1607
- export const _default;
1608
-
1609
- export enum BTTile {
1746
+ export declare enum BTTile {
1610
1747
  Empty = 0,
1611
1748
  Dark = 1,
1612
1749
  Light = 2,
1613
1750
  NonExist = 3,
1614
1751
  }
1615
1752
  export type BTColor = BTTile.Dark | BTTile.Light;
1616
- export class BTGridData {
1753
+ export declare class BTGridData {
1617
1754
  readonly tiles: BTTile[][];
1618
- readonly connections: Position[][][];
1755
+ readonly connections: Position$1[][][];
1619
1756
  readonly modules: BTModule[];
1620
1757
  readonly width: number;
1621
1758
  readonly height: number;
1622
1759
  constructor(
1623
1760
  tiles: BTTile[][],
1624
- connections: Position[][][],
1761
+ connections: Position$1[][][],
1625
1762
  modules: BTModule[],
1626
1763
  width: number,
1627
1764
  height: number
@@ -1629,12 +1766,14 @@ declare global {
1629
1766
  getTile(x: number, y: number): BTTile;
1630
1767
  setTileWithConnection(x: number, y: number, tile: BTTile): void;
1631
1768
  isInBound(x: number, y: number): boolean;
1632
- getEdges(pos: Position): Position[];
1769
+ getEdges(pos: Position$1): Position$1[];
1633
1770
  clone(): BTGridData;
1634
1771
  }
1635
- export class IntArray2D {
1772
+ export declare class IntArray2D {
1773
+ private readonly array;
1636
1774
  readonly width: number;
1637
1775
  readonly height: number;
1776
+ private constructor();
1638
1777
  static create(width: number, height: number): IntArray2D;
1639
1778
  set(x: number, y: number, value: number): void;
1640
1779
  get(x: number, y: number): number;
@@ -1645,89 +1784,195 @@ declare global {
1645
1784
  ratings: Rating[] | null;
1646
1785
  }
1647
1786
  export interface Rating {
1648
- pos: Position;
1787
+ pos: Position$1;
1649
1788
  score: number;
1650
1789
  }
1651
- export abstract class BTModule {
1790
+ export declare abstract class BTModule {
1652
1791
  abstract checkGlobal(grid: BTGridData): CheckResult | false;
1653
- checkLocal(grid: BTGridData, _: Position[]): CheckResult | boolean;
1792
+ checkLocal(grid: BTGridData, _: Position$1[]): CheckResult | boolean;
1654
1793
  }
1655
- export function getOppositeColor(color: BTColor): BTColor;
1656
- export function colorToBTTile(color: Color): BTTile;
1657
- export function createOneTileResult(
1794
+ export declare function getOppositeColor(color: BTColor): BTColor;
1795
+ export declare function colorToBTTile(color: Color): BTTile;
1796
+ export declare function createOneTileResult(
1658
1797
  grid: BTGridData,
1659
- pos: Position,
1798
+ pos: Position$1,
1660
1799
  score?: number | undefined
1661
1800
  ): CheckResult;
1662
-
1663
- export class BanPatternBTModule extends BTModule {
1801
+ export declare class BanPatternBTModule extends BTModule {
1664
1802
  instr: BanPatternRule;
1665
1803
  constructor(instr: BanPatternRule);
1666
1804
  checkGlobal(_: BTGridData): CheckResult | false;
1667
- checkLocal(grid: BTGridData, positions: Position[]): CheckResult | false;
1805
+ checkLocal(grid: BTGridData, positions: Position$1[]): CheckResult | false;
1668
1806
  }
1669
-
1670
- export class CellCountBTModule extends BTModule {
1807
+ export declare class CellCountBTModule extends BTModule {
1671
1808
  instr: CellCountRule;
1672
1809
  constructor(instr: CellCountRule);
1673
1810
  checkGlobal(grid: BTGridData): CheckResult | false;
1674
1811
  }
1675
-
1676
- export class ConnectAllBTModule extends BTModule {
1812
+ export declare class ConnectAllBTModule extends BTModule {
1677
1813
  instr: ConnectAllRule;
1678
1814
  constructor(instr: ConnectAllRule);
1679
1815
  checkGlobal(grid: BTGridData): CheckResult | false;
1680
1816
  }
1681
-
1682
- export class RegionAreaBTModule extends BTModule {
1817
+ export declare class RegionAreaBTModule extends BTModule {
1683
1818
  instr: RegionAreaRule;
1684
1819
  constructor(instr: RegionAreaRule);
1685
1820
  checkGlobal(grid: BTGridData): CheckResult | false;
1821
+ private visitArea;
1686
1822
  }
1687
-
1688
- export abstract class RegionShapeBTModule extends BTModule {
1823
+ export declare abstract class RegionShapeBTModule extends BTModule {
1689
1824
  instr: RegionShapeRule;
1690
1825
  constructor(instr: RegionShapeRule);
1691
1826
  protected getShapeRegions(grid: BTGridData): ShapeRegions['regions'];
1827
+ private visitArea;
1692
1828
  }
1693
-
1694
- export class SameShapeBTModule extends RegionShapeBTModule {
1829
+ export declare class SameShapeBTModule extends RegionShapeBTModule {
1695
1830
  instr: SameShapeRule;
1696
1831
  constructor(instr: SameShapeRule);
1697
1832
  checkGlobal(grid: BTGridData): CheckResult | false;
1698
1833
  }
1699
-
1700
- export class SymbolsPerRegionBTModule extends BTModule {
1834
+ export declare class SymbolsPerRegionBTModule extends BTModule {
1701
1835
  instr: SymbolsPerRegionRule;
1836
+ private symbolCount;
1702
1837
  constructor(
1703
1838
  instr: SymbolsPerRegionRule,
1704
1839
  width: number,
1705
1840
  height: number,
1706
- allSymbols: Symbol[]
1841
+ allSymbols: Symbol$1[]
1707
1842
  );
1708
1843
  checkGlobal(grid: BTGridData): CheckResult | false;
1844
+ private visitArea;
1709
1845
  }
1710
-
1711
- export class UniqueShapeBTModule extends RegionShapeBTModule {
1846
+ export declare class UniqueShapeBTModule extends RegionShapeBTModule {
1712
1847
  instr: UniqueShapeRule;
1713
1848
  constructor(instr: UniqueShapeRule);
1714
1849
  checkGlobal(grid: BTGridData): CheckResult | false;
1715
1850
  }
1716
-
1717
- export class AreaNumberBTModule extends BTModule {
1851
+ /**
1852
+ * All symbols which contain a number should extend this class to be compatible with off by X rules.
1853
+ */
1854
+ export declare abstract class NumberSymbol extends Symbol$1 {
1855
+ readonly x: number;
1856
+ readonly y: number;
1857
+ readonly number: number;
1858
+ constructor(x: number, y: number, number: number);
1859
+ abstract countTiles(grid: GridData): {
1860
+ completed: number;
1861
+ possible: number;
1862
+ };
1863
+ validateSymbol(grid: GridData): State;
1864
+ withNumber(number: number): this;
1865
+ }
1866
+ export declare class AreaNumberSymbol extends NumberSymbol {
1867
+ private static readonly CONFIGS;
1868
+ private static readonly EXAMPLE_GRID;
1869
+ /**
1870
+ * **Area Numbers must equal region sizes**
1871
+ *
1872
+ * @param x - The x-coordinate of the symbol.
1873
+ * @param y - The y-coordinate of the symbol.
1874
+ * @param number - The area number.
1875
+ */
1876
+ constructor(x: number, y: number, number: number);
1877
+ get id(): string;
1878
+ get explanation(): string;
1879
+ get configs(): readonly AnyConfig[] | null;
1880
+ createExampleGrid(): GridData;
1881
+ countTiles(grid: GridData): {
1882
+ completed: number;
1883
+ possible: number;
1884
+ };
1885
+ copyWith({
1886
+ x,
1887
+ y,
1888
+ number,
1889
+ }: {
1890
+ x?: number;
1891
+ y?: number;
1892
+ number?: number;
1893
+ }): this;
1894
+ withNumber(number: number): this;
1895
+ }
1896
+ export declare class AreaNumberBTModule extends BTModule {
1718
1897
  instr: AreaNumberSymbol;
1719
1898
  constructor(instr: AreaNumberSymbol);
1720
1899
  checkGlobal(grid: BTGridData): CheckResult | false;
1721
- checkLocal(grid: BTGridData, positions: Position[]): CheckResult | boolean;
1900
+ checkLocal(
1901
+ grid: BTGridData,
1902
+ positions: Position$1[]
1903
+ ): CheckResult | boolean;
1722
1904
  }
1723
-
1724
- export class DartBTModule extends BTModule {
1905
+ export declare class DartSymbol extends NumberSymbol {
1906
+ readonly orientation: Orientation;
1907
+ private static readonly CONFIGS;
1908
+ private static readonly EXAMPLE_GRID;
1909
+ /**
1910
+ * **Darts count opposite color cells in that direction**
1911
+ *
1912
+ * @param x - The x-coordinate of the symbol.
1913
+ * @param y - The y-coordinate of the symbol.
1914
+ * @param number - The number of cells seen by the symbol.
1915
+ * @param orientation - The orientation of the symbol.
1916
+ */
1917
+ constructor(x: number, y: number, number: number, orientation: Orientation);
1918
+ get id(): string;
1919
+ get placementStep(): number;
1920
+ get explanation(): string;
1921
+ get configs(): readonly AnyConfig[] | null;
1922
+ createExampleGrid(): GridData;
1923
+ countTiles(grid: GridData): {
1924
+ completed: number;
1925
+ possible: number;
1926
+ };
1927
+ copyWith({
1928
+ x,
1929
+ y,
1930
+ number,
1931
+ orientation,
1932
+ }: {
1933
+ x?: number;
1934
+ y?: number;
1935
+ number?: number;
1936
+ orientation?: Orientation;
1937
+ }): this;
1938
+ withNumber(number: number): this;
1939
+ }
1940
+ export declare class DartBTModule extends BTModule {
1725
1941
  instr: DartSymbol;
1942
+ private cachedCheckResult?;
1726
1943
  constructor(instr: DartSymbol);
1727
1944
  checkGlobal(grid: BTGridData): CheckResult | false;
1945
+ private buildCheckAndRating;
1728
1946
  }
1729
-
1730
- export abstract class DirectionLinkerBTModule extends BTModule {
1947
+ export type DirectionLinkerMap = {
1948
+ [key in Direction]: Direction;
1949
+ };
1950
+ export declare class DirectionLinkerSymbol extends Symbol$1 {
1951
+ readonly x: number;
1952
+ readonly y: number;
1953
+ private static readonly CONFIGS;
1954
+ private static readonly EXAMPLE_GRID;
1955
+ private static readonly directionDeltas;
1956
+ private linkedDirections;
1957
+ /**
1958
+ * **Darts count opposite color cells in that direction**
1959
+ *
1960
+ * @param x - The x-coordinate of the symbol.
1961
+ * @param y - The y-coordinate of the symbol.
1962
+ */
1963
+ constructor(x: number, y: number);
1964
+ changeDirections(linkedDirections: DirectionLinkerMap): this;
1965
+ get id(): string;
1966
+ get explanation(): string;
1967
+ get configs(): readonly AnyConfig[] | null;
1968
+ createExampleGrid(): GridData;
1969
+ private getColor;
1970
+ private deltaCoordinate;
1971
+ validateSymbol(grid: GridData): State;
1972
+ copyWith({ x, y }: { x?: number; y?: number }): this;
1973
+ private getInitialCheckedCouples;
1974
+ }
1975
+ export declare abstract class DirectionLinkerBTModule extends BTModule {
1731
1976
  instr: DirectionLinkerSymbol;
1732
1977
  constructor(instr: DirectionLinkerSymbol);
1733
1978
  checkGlobal(grid: BTGridData): CheckResult | false;
@@ -1735,212 +1980,250 @@ declare global {
1735
1980
  grid: BTGridData,
1736
1981
  x: number,
1737
1982
  y: number
1738
- ): Position | null;
1983
+ ): Position$1 | null;
1739
1984
  }
1740
-
1741
- export class GalaxyBTModule extends DirectionLinkerBTModule {
1985
+ export declare class GalaxySymbol extends DirectionLinkerSymbol {
1986
+ readonly x: number;
1987
+ readonly y: number;
1988
+ private static readonly linkedDirections;
1989
+ /**
1990
+ * **Galaxies are centers of rotational symmetry**
1991
+ *
1992
+ * @param x - The x-coordinate of the symbol.
1993
+ * @param y - The y-coordinate of the symbol.
1994
+ */
1995
+ constructor(x: number, y: number);
1996
+ get id(): string;
1997
+ get explanation(): string;
1998
+ get configs(): readonly AnyConfig[] | null;
1999
+ createExampleGrid(): GridData;
2000
+ validateSymbol(grid: GridData): State;
2001
+ copyWith({ x, y }: { x?: number; y?: number }): this;
2002
+ }
2003
+ export declare class GalaxyBTModule extends DirectionLinkerBTModule {
1742
2004
  instr: GalaxySymbol;
1743
2005
  constructor(instr: GalaxySymbol);
1744
- protected movePos(grid: BTGridData, x: number, y: number): Position | null;
2006
+ protected movePos(
2007
+ grid: BTGridData,
2008
+ x: number,
2009
+ y: number
2010
+ ): Position$1 | null;
2011
+ }
2012
+ export declare class LetterSymbol extends Symbol$1 {
2013
+ readonly x: number;
2014
+ readonly y: number;
2015
+ readonly letter: string;
2016
+ private static readonly CONFIGS;
2017
+ private static readonly EXAMPLE_GRID;
2018
+ /**
2019
+ * **Letters must be sorted into one type per area**
2020
+ *
2021
+ * @param x - The x-coordinate of the symbol.
2022
+ * @param y - The y-coordinate of the symbol.
2023
+ * @param letter - The letter of the symbol.
2024
+ */
2025
+ constructor(x: number, y: number, letter: string);
2026
+ get id(): string;
2027
+ get explanation(): string;
2028
+ get configs(): readonly AnyConfig[] | null;
2029
+ createExampleGrid(): GridData;
2030
+ validateSymbol(grid: GridData): State;
2031
+ copyWith({
2032
+ x,
2033
+ y,
2034
+ letter,
2035
+ }: {
2036
+ x?: number;
2037
+ y?: number;
2038
+ letter?: string;
2039
+ }): this;
2040
+ withLetter(letter: string): this;
1745
2041
  }
1746
-
1747
- export class LetterBTModule extends BTModule {
2042
+ export declare class LetterBTModule extends BTModule {
2043
+ private letters;
2044
+ private letterGrid;
1748
2045
  constructor(instrs: LetterSymbol[], width: number, height: number);
1749
2046
  checkGlobal(grid: BTGridData): CheckResult | false;
2047
+ private visitArea;
1750
2048
  }
1751
-
1752
- export class LotusBTModule extends DirectionLinkerBTModule {
2049
+ export declare class LotusSymbol extends DirectionLinkerSymbol {
2050
+ readonly x: number;
2051
+ readonly y: number;
2052
+ readonly orientation: Orientation;
2053
+ private static readonly linkedDirectionsFromOrientation;
2054
+ /**
2055
+ * **Areas containing this symbol must be symmetrical**
2056
+ *
2057
+ * @param x - The x-coordinate of the symbol.
2058
+ * @param y - The y-coordinate of the symbol.
2059
+ * @param orientation - The orientation of the symbol.
2060
+ */
2061
+ constructor(x: number, y: number, orientation: Orientation);
2062
+ get id(): string;
2063
+ get explanation(): string;
2064
+ get configs(): readonly AnyConfig[] | null;
2065
+ createExampleGrid(): GridData;
2066
+ validateSymbol(grid: GridData): State;
2067
+ copyWith({
2068
+ x,
2069
+ y,
2070
+ orientation,
2071
+ }: {
2072
+ x?: number;
2073
+ y?: number;
2074
+ orientation?: Orientation;
2075
+ }): this;
2076
+ }
2077
+ export declare class LotusBTModule extends DirectionLinkerBTModule {
1753
2078
  instr: LotusSymbol;
1754
2079
  constructor(instr: LotusSymbol);
1755
- protected movePos(grid: BTGridData, x: number, y: number): Position | null;
2080
+ protected movePos(
2081
+ grid: BTGridData,
2082
+ x: number,
2083
+ y: number
2084
+ ): Position$1 | null;
1756
2085
  }
1757
-
1758
- export class MinesweeperBTModule extends BTModule {
2086
+ export declare class MinesweeperSymbol extends NumberSymbol {
2087
+ private static readonly CONFIGS;
2088
+ private static readonly EXAMPLE_GRID;
2089
+ /**
2090
+ * **Minesweeper numbers count opposite cells in 8 adjacent spaces**
2091
+ *
2092
+ * @param x - The x-coordinate of the symbol.
2093
+ * @param y - The y-coordinate of the symbol.
2094
+ * @param number - The number of cells seen by the symbol.
2095
+ */
2096
+ constructor(x: number, y: number, number: number);
2097
+ get id(): string;
2098
+ get placementStep(): number;
2099
+ get explanation(): string;
2100
+ get configs(): readonly AnyConfig[] | null;
2101
+ createExampleGrid(): GridData;
2102
+ countTiles(grid: GridData): {
2103
+ completed: number;
2104
+ possible: number;
2105
+ };
2106
+ copyWith({
2107
+ x,
2108
+ y,
2109
+ number,
2110
+ }: {
2111
+ x?: number;
2112
+ y?: number;
2113
+ number?: number;
2114
+ }): this;
2115
+ withNumber(number: number): this;
2116
+ }
2117
+ export declare class MinesweeperBTModule extends BTModule {
1759
2118
  instr: MinesweeperSymbol;
2119
+ private cachedCheckResult?;
1760
2120
  constructor(instr: MinesweeperSymbol);
1761
2121
  checkGlobal(grid: BTGridData): CheckResult | false;
2122
+ private buildCheckAndRating;
1762
2123
  }
1763
-
1764
- export class MyopiaBTModule extends BTModule {
1765
- instr: MyopiaSymbol;
1766
- constructor(instr: MyopiaSymbol);
1767
- checkGlobal(grid: BTGridData): CheckResult | false;
1768
- }
1769
-
1770
- export class ViewpointBTModule extends BTModule {
1771
- instr: ViewpointSymbol;
1772
- constructor(instr: ViewpointSymbol);
1773
- checkGlobal(grid: BTGridData): CheckResult | false;
1774
- }
1775
-
1776
- /**
1777
- * Base class that all solvers must extend.
1778
- */
1779
- export abstract class Solver {
1780
- /**
1781
- * The unique identifier of the solver.
1782
- *
1783
- * This is also displayed to the user when selecting a solver.
1784
- */
1785
- abstract get id(): string;
1786
- /**
1787
- * A short paragraph describing when the user should use this solver.
1788
- */
1789
- abstract get description(): string;
1790
- /**
1791
- * Solve the given grid. The implementation should delegate long-running tasks to a worker thread and yield solutions
1792
- * asynchronously.
1793
- *
1794
- * The solver must yield at least once, otherwise the UI will not update.
1795
- *
1796
- * If the solver finds no solution other than those already yielded, it should yield `null`. Yielding `null` on the
1797
- * first iteration indicates that the grid is unsolvable. Yielding `null` on the second iteration indicates that the
1798
- * solution is unique.
1799
- *
1800
- * In the current UI implementation, the solver will be terminated after yielding `null`, or after 2 iterations if
1801
- * `null` is never yielded. The solver should perform any necessary cleanup in the `finally` block of the generator.
1802
- *
1803
- * @param grid The grid to solve. The provided grid is guaranteed to be supported by the solver. Some tiles in the
1804
- * grid may already be filled by the user. It is up to the solver to decide whether to respect these tiles or not.
1805
- */
1806
- abstract solve(grid: GridData): AsyncGenerator<GridData | null>;
1807
- /**
1808
- * Check if the solver supports the current browser environment. This method is called once when the user first clicks
1809
- * the "Solve" button, and the result is cached for the duration of the editor session.
1810
- *
1811
- * The `solve` method will not be called if this method returns `false`, and a message will be displayed to the user
1812
- * indicating that the solver is not supported.
1813
- *
1814
- * @returns A promise that resolves to `true` if the environment is supported, or `false` otherwise.
1815
- */
1816
- isEnvironmentSupported(): Promise<boolean>;
2124
+ export declare abstract class MultiEntrySymbol extends Symbol$1 {
1817
2125
  /**
1818
- * Check if the solver supports the given instruction. This is used to render a small indication in the UI for each
1819
- * instruction in the editor.
1820
- *
1821
- * @param instructionId The unique identifier of the instruction.
2126
+ * Determines if the description of two MultiEntrySymbols can be merged when displayed in the UI.
2127
+ * @param other - The other MultiEntrySymbol to compare to.
2128
+ * @returns Whether the two MultiEntrySymbols have the same description.
1822
2129
  */
1823
- isInstructionSupported(instructionId: string): boolean;
2130
+ descriptionEquals(other: Instruction): boolean;
2131
+ }
2132
+ export declare class MyopiaSymbol extends MultiEntrySymbol {
2133
+ readonly diagonals: boolean;
2134
+ readonly directions: OrientationToggle;
2135
+ private static readonly CONFIGS;
2136
+ private static readonly EXAMPLE_GRID;
2137
+ private static readonly EXAMPLE_DIAGONAL_GRID;
1824
2138
  /**
1825
- * Check if the solver supports the given grid. This methid is frequently called when the user changes the grid, and
1826
- * the result is used to enable or disable the "Solve" button.
1827
- *
1828
- * The `solve` method will not be called if this method returns `false`, and a message will be displayed to the user
1829
- * indicating that the grid is not supported by this solver.
1830
- *
1831
- * @param grid The grid to check.
1832
- * @returns `true` if the grid is supported, or `false` otherwise.
2139
+ * **Viewpoint Numbers count visible cells in the four directions**
2140
+ * @param x - The x-coordinate of the symbol.
2141
+ * @param y - The y-coordinate of the symbol.
2142
+ * @param diagonals - Whether the symbol should consider diagonal directions.
2143
+ * @param directions - The directions in which an arrow is pointing.
1833
2144
  */
1834
- isGridSupported(grid: GridData): boolean;
1835
- }
1836
-
1837
- export class UndercluedSolver extends Solver {
1838
- readonly id = 'underclued';
1839
- readonly description =
1840
- 'Solves every puzzle as if it were underclued. Supports all rules and symbols and is decently fast for small puzzles. Very slow for large puzzles.';
1841
- solve(grid: GridData): AsyncGenerator<GridData | null>;
1842
- isInstructionSupported(instructionId: string): boolean;
1843
- }
1844
-
1845
- const _default: null;
1846
- export const _default;
1847
-
1848
- export class AreaNumberModule extends Z3Module {
1849
- readonly id: string;
1850
- encode<Name extends string>(
1851
- grid: GridData,
1852
- ctx: Z3SolverContext<Name, Solver<Name> | Optimize<Name>>
1853
- ): void;
1854
- }
1855
-
1856
- export class CellCountModule extends Z3Module {
1857
- readonly id: string;
1858
- encode<Name extends string>(
1859
- grid: GridData,
1860
- ctx: Z3SolverContext<Name, Solver<Name> | Optimize<Name>>
1861
- ): void;
1862
- }
1863
-
1864
- export class ConnectAllModule extends Z3Module {
1865
- readonly id: string;
1866
- encode<Name extends string>(
1867
- grid: GridData,
1868
- ctx: Z3SolverContext<Name, Solver<Name> | Optimize<Name>>
1869
- ): void;
1870
- }
1871
-
1872
- export class DartModule extends Z3Module {
1873
- readonly id: string;
1874
- encode<Name extends string>(
1875
- grid: GridData,
1876
- ctx: Z3SolverContext<Name, Solver<Name> | Optimize<Name>>
1877
- ): void;
1878
- }
1879
-
1880
- const allZ3Modules: Map<string, Z3Module>;
1881
- export { allZ3Modules };
1882
-
1883
- export class LetterModule extends Z3Module {
1884
- readonly id: string;
1885
- encode<Name extends string>(
1886
- grid: GridData,
1887
- ctx: Z3SolverContext<Name, Solver<Name> | Optimize<Name>>
1888
- ): void;
1889
- }
1890
-
1891
- export class MyopiaModule extends Z3Module {
1892
- readonly id: string;
1893
- encode<Name extends string>(
1894
- grid: GridData,
1895
- ctx: Z3SolverContext<Name, Solver<Name> | Optimize<Name>>
1896
- ): void;
1897
- }
1898
-
1899
- export class RegionAreaModule extends Z3Module {
1900
- readonly id: string;
1901
- encode<Name extends string>(
1902
- grid: GridData,
1903
- ctx: Z3SolverContext<Name, Solver<Name> | Optimize<Name>>
1904
- ): void;
2145
+ constructor(
2146
+ x: number,
2147
+ y: number,
2148
+ diagonals: boolean,
2149
+ directions: OrientationToggle
2150
+ );
2151
+ get id(): string;
2152
+ get placementStep(): number;
2153
+ get explanation(): string;
2154
+ get configs(): readonly AnyConfig[] | null;
2155
+ createExampleGrid(): GridData;
2156
+ validateSymbol(grid: GridData): State;
2157
+ copyWith({
2158
+ x,
2159
+ y,
2160
+ diagonals,
2161
+ directions,
2162
+ }: {
2163
+ x?: number;
2164
+ y?: number;
2165
+ diagonals?: boolean;
2166
+ directions?: OrientationToggle;
2167
+ }): this;
2168
+ withDirections(directions: OrientationToggle): this;
2169
+ withDiagonals(diagonals: boolean): this;
1905
2170
  }
1906
-
1907
- export class ViewpointModule extends Z3Module {
1908
- readonly id: string;
1909
- encode<Name extends string>(
1910
- grid: GridData,
1911
- ctx: Z3SolverContext<Name, Solver<Name> | Optimize<Name>>
1912
- ): void;
2171
+ export declare class MyopiaBTModule extends BTModule {
2172
+ instr: MyopiaSymbol;
2173
+ constructor(instr: MyopiaSymbol);
2174
+ checkGlobal(grid: BTGridData): CheckResult | false;
1913
2175
  }
1914
-
1915
- export abstract class Z3Module {
1916
- abstract get id(): string;
1917
- abstract encode<Name extends string>(
1918
- grid: GridData,
1919
- ctx: Z3SolverContext<Name>
1920
- ): void;
2176
+ export declare class ViewpointSymbol extends NumberSymbol {
2177
+ private static readonly CONFIGS;
2178
+ private static readonly EXAMPLE_GRID;
2179
+ /**
2180
+ * **Viewpoint Numbers count visible cells in the four directions**
2181
+ * @param x - The x-coordinate of the symbol.
2182
+ * @param y - The y-coordinate of the symbol.
2183
+ * @param number - The viewpoint number.
2184
+ */
2185
+ constructor(x: number, y: number, number: number);
2186
+ get id(): string;
2187
+ get placementStep(): number;
2188
+ get explanation(): string;
2189
+ get configs(): readonly AnyConfig[] | null;
2190
+ createExampleGrid(): GridData;
2191
+ private countForColor;
2192
+ countTiles(grid: GridData): {
2193
+ completed: number;
2194
+ possible: number;
2195
+ };
2196
+ copyWith({
2197
+ x,
2198
+ y,
2199
+ number,
2200
+ }: {
2201
+ x?: number;
2202
+ y?: number;
2203
+ number?: number;
2204
+ }): this;
2205
+ withNumber(number: number): this;
1921
2206
  }
1922
-
1923
- export function convertDirection(
1924
- direction: Orientation | Direction
1925
- ): import('grilops').Direction;
1926
-
1927
- export class Z3Solver extends Solver {
1928
- readonly id = 'z3';
2207
+ export declare class ViewpointBTModule extends BTModule {
2208
+ instr: ViewpointSymbol;
2209
+ constructor(instr: ViewpointSymbol);
2210
+ checkGlobal(grid: BTGridData): CheckResult | false;
2211
+ }
2212
+ export declare class UndercluedSolver extends Solver {
2213
+ readonly id = 'underclued';
1929
2214
  readonly description =
1930
- 'Good for confirming that a solution is unique, especially for larger puzzles. It is otherwise slower than most solvers in small to medium-sized puzzles.';
1931
- isEnvironmentSupported(): Promise<boolean>;
2215
+ 'Solves every puzzle as if it were underclued. Supports all rules and symbols and is decently fast for small puzzles. Very slow for large puzzles.';
1932
2216
  solve(grid: GridData): AsyncGenerator<GridData | null>;
1933
2217
  isInstructionSupported(instructionId: string): boolean;
1934
- isGridSupported(grid: GridData): boolean;
1935
2218
  }
1936
-
1937
- export class Z3SolverContext<
2219
+ export declare class Z3SolverContext<
1938
2220
  Name extends string,
1939
- const Core extends Solver<Name> | Optimize<Name> =
1940
- | Solver<Name>
2221
+ const Core extends Solver$1<Name> | Optimize<Name> =
2222
+ | Solver$1<Name>
1941
2223
  | Optimize<Name>,
1942
2224
  > {
1943
2225
  readonly grid: SymbolGrid<Name, Core>;
2226
+ private _regionConstrainer;
1944
2227
  constructor(grid: SymbolGrid<Name, Core>);
1945
2228
  get solver(): Core;
1946
2229
  get lattice(): import('grilops').Lattice;
@@ -5377,478 +5660,194 @@ declare global {
5377
5660
  };
5378
5661
  get regionConstrainer(): RegionConstrainer<Name, Core>;
5379
5662
  }
5380
-
5381
- export class AreaNumberSymbol extends NumberSymbol {
5382
- /**
5383
- * **Area Numbers must equal region sizes**
5384
- *
5385
- * @param x - The x-coordinate of the symbol.
5386
- * @param y - The y-coordinate of the symbol.
5387
- * @param number - The area number.
5388
- */
5389
- constructor(x: number, y: number, number: number);
5390
- get id(): string;
5391
- get explanation(): string;
5392
- get configs(): readonly AnyConfig[] | null;
5393
- createExampleGrid(): GridData;
5394
- countTiles(grid: GridData): {
5395
- completed: number;
5396
- possible: number;
5397
- };
5398
- copyWith({
5399
- x,
5400
- y,
5401
- number,
5402
- }: {
5403
- x?: number;
5404
- y?: number;
5405
- number?: number;
5406
- }): this;
5407
- withNumber(number: number): this;
5408
- }
5409
-
5410
- export type IconString = keyof typeof Md;
5411
- export class CustomIconSymbol extends CustomSymbol {
5412
- readonly icon: IconString;
5413
- readonly rotation: number;
5414
- /**
5415
- * **A custom icon symbol**
5416
- *
5417
- * @param description - The description of the symbol. Leave this empty to hide the description.
5418
- * @param grid - The thumbnail grid of the rule, preferably 5x4 in size.
5419
- * @param x - The x-coordinate of the symbol.
5420
- * @param y - The y-coordinate of the symbol.
5421
- * @param icon - The icon to display. All available icons can be found at https://react-icons.github.io/react-icons/icons/md/
5422
- * @param rotation - The rotation of the icon in degrees.
5423
- */
5424
- constructor(
5425
- description: string,
5663
+ export declare abstract class Z3Module {
5664
+ abstract get id(): string;
5665
+ abstract encode<Name extends string>(
5426
5666
  grid: GridData,
5427
- x: number,
5428
- y: number,
5429
- icon: IconString,
5430
- rotation?: number
5431
- );
5432
- get id(): string;
5433
- get configs(): readonly AnyConfig[] | null;
5434
- copyWith({
5435
- description,
5436
- grid,
5437
- x,
5438
- y,
5439
- icon,
5440
- rotation,
5441
- }: {
5442
- description?: string;
5443
- grid?: GridData;
5444
- x?: number;
5445
- y?: number;
5446
- icon?: IconString;
5447
- rotation?: number;
5448
- }): this;
5449
- withIcon(icon: IconString): this;
5450
- withRotation(rotation: number): this;
5451
- }
5452
-
5453
- export abstract class CustomSymbol extends MultiEntrySymbol {
5454
- readonly description: string;
5455
- readonly grid: GridData;
5456
- /**
5457
- * **A custom symbol**
5458
- *
5459
- * @param description - The description of the symbol. Leave this empty to hide the description.
5460
- * @param grid - The thumbnail grid of the rule, preferably 5x4 in size.
5461
- * @param x - The x-coordinate of the symbol.
5462
- * @param y - The y-coordinate of the symbol.
5463
- */
5464
- constructor(description: string, grid: GridData, x: number, y: number);
5465
- get explanation(): string;
5466
- createExampleGrid(): GridData;
5467
- validateSymbol(_grid: GridData): State;
5468
- get validateWithSolution(): boolean;
5469
- withDescription(description: string): this;
5470
- withGrid(grid: GridData): this;
5667
+ ctx: Z3SolverContext<Name>
5668
+ ): void;
5471
5669
  }
5472
-
5473
- export class CustomTextSymbol extends CustomSymbol {
5474
- readonly text: string;
5475
- readonly rotation: number;
5476
- /**
5477
- * **A custom text symbol**
5478
- *
5479
- * @param description - The description of the symbol. Leave this empty to hide the description.
5480
- * @param grid - The thumbnail grid of the rule, preferably 5x4 in size.
5481
- * @param x - The x-coordinate of the symbol.
5482
- * @param y - The y-coordinate of the symbol.
5483
- * @param text - The text to display.
5484
- * @param rotation - The rotation of the text in degrees.
5485
- */
5486
- constructor(
5487
- description: string,
5670
+ export declare class AreaNumberModule extends Z3Module {
5671
+ readonly id: string;
5672
+ encode<Name extends string>(
5488
5673
  grid: GridData,
5489
- x: number,
5490
- y: number,
5491
- text: string,
5492
- rotation?: number
5493
- );
5494
- get id(): string;
5495
- get configs(): readonly AnyConfig[] | null;
5496
- copyWith({
5497
- description,
5498
- grid,
5499
- x,
5500
- y,
5501
- text,
5502
- rotation,
5503
- }: {
5504
- description?: string;
5505
- grid?: GridData;
5506
- x?: number;
5507
- y?: number;
5508
- text?: string;
5509
- rotation?: number;
5510
- }): this;
5511
- withText(text: string): this;
5512
- withRotation(rotation: number): this;
5674
+ ctx: Z3SolverContext<Name, Solver$1<Name> | Optimize<Name>>
5675
+ ): void;
5513
5676
  }
5514
-
5515
- export class DartSymbol extends NumberSymbol {
5516
- readonly orientation: Orientation;
5517
- /**
5518
- * **Darts count opposite color cells in that direction**
5519
- *
5520
- * @param x - The x-coordinate of the symbol.
5521
- * @param y - The y-coordinate of the symbol.
5522
- * @param number - The number of cells seen by the symbol.
5523
- * @param orientation - The orientation of the symbol.
5524
- */
5525
- constructor(x: number, y: number, number: number, orientation: Orientation);
5526
- get id(): string;
5527
- get placementStep(): number;
5528
- get explanation(): string;
5529
- get configs(): readonly AnyConfig[] | null;
5530
- createExampleGrid(): GridData;
5531
- countTiles(grid: GridData): {
5532
- completed: number;
5533
- possible: number;
5534
- };
5535
- copyWith({
5536
- x,
5537
- y,
5538
- number,
5539
- orientation,
5540
- }: {
5541
- x?: number;
5542
- y?: number;
5543
- number?: number;
5544
- orientation?: Orientation;
5545
- }): this;
5546
- withNumber(number: number): this;
5677
+ export declare class CellCountModule extends Z3Module {
5678
+ readonly id: string;
5679
+ encode<Name extends string>(
5680
+ grid: GridData,
5681
+ ctx: Z3SolverContext<Name, Solver$1<Name> | Optimize<Name>>
5682
+ ): void;
5547
5683
  }
5548
-
5549
- export type DirectionLinkerMap = {
5550
- [key in Direction]: Direction;
5551
- };
5552
- export class DirectionLinkerSymbol extends Symbol {
5553
- readonly x: number;
5554
- readonly y: number;
5555
- /**
5556
- * **Darts count opposite color cells in that direction**
5557
- *
5558
- * @param x - The x-coordinate of the symbol.
5559
- * @param y - The y-coordinate of the symbol.
5560
- */
5561
- constructor(x: number, y: number);
5562
- changeDirections(linkedDirections: DirectionLinkerMap): this;
5563
- get id(): string;
5564
- get explanation(): string;
5565
- get configs(): readonly AnyConfig[] | null;
5566
- createExampleGrid(): GridData;
5567
- validateSymbol(grid: GridData): State;
5568
- copyWith({ x, y }: { x?: number; y?: number }): this;
5684
+ export declare class ConnectAllModule extends Z3Module {
5685
+ readonly id: string;
5686
+ encode<Name extends string>(
5687
+ grid: GridData,
5688
+ ctx: Z3SolverContext<Name, Solver$1<Name> | Optimize<Name>>
5689
+ ): void;
5569
5690
  }
5570
-
5571
- export class GalaxySymbol extends DirectionLinkerSymbol {
5572
- readonly x: number;
5573
- readonly y: number;
5574
- /**
5575
- * **Galaxies are centers of rotational symmetry**
5576
- *
5577
- * @param x - The x-coordinate of the symbol.
5578
- * @param y - The y-coordinate of the symbol.
5579
- */
5580
- constructor(x: number, y: number);
5581
- get id(): string;
5582
- get explanation(): string;
5583
- get configs(): readonly AnyConfig[] | null;
5584
- createExampleGrid(): GridData;
5585
- validateSymbol(grid: GridData): State;
5586
- copyWith({ x, y }: { x?: number; y?: number }): this;
5691
+ export declare class DartModule extends Z3Module {
5692
+ readonly id: string;
5693
+ encode<Name extends string>(
5694
+ grid: GridData,
5695
+ ctx: Z3SolverContext<Name, Solver$1<Name> | Optimize<Name>>
5696
+ ): void;
5587
5697
  }
5588
-
5589
- const allSymbols: Map<string, Symbol>;
5590
- export { allSymbols };
5591
-
5592
- export class LetterSymbol extends Symbol {
5593
- readonly x: number;
5594
- readonly y: number;
5595
- readonly letter: string;
5596
- /**
5597
- * **Letters must be sorted into one type per area**
5598
- *
5599
- * @param x - The x-coordinate of the symbol.
5600
- * @param y - The y-coordinate of the symbol.
5601
- * @param letter - The letter of the symbol.
5602
- */
5603
- constructor(x: number, y: number, letter: string);
5604
- get id(): string;
5605
- get explanation(): string;
5606
- get configs(): readonly AnyConfig[] | null;
5607
- createExampleGrid(): GridData;
5608
- validateSymbol(grid: GridData): State;
5609
- copyWith({
5610
- x,
5611
- y,
5612
- letter,
5613
- }: {
5614
- x?: number;
5615
- y?: number;
5616
- letter?: string;
5617
- }): this;
5618
- withLetter(letter: string): this;
5698
+ export declare const allZ3Modules: Map<string, Z3Module>;
5699
+ export declare class LetterModule extends Z3Module {
5700
+ readonly id: string;
5701
+ encode<Name extends string>(
5702
+ grid: GridData,
5703
+ ctx: Z3SolverContext<Name, Solver$1<Name> | Optimize<Name>>
5704
+ ): void;
5619
5705
  }
5620
-
5621
- export class LotusSymbol extends DirectionLinkerSymbol {
5622
- readonly x: number;
5623
- readonly y: number;
5624
- readonly orientation: Orientation;
5625
- /**
5626
- * **Areas containing this symbol must be symmetrical**
5627
- *
5628
- * @param x - The x-coordinate of the symbol.
5629
- * @param y - The y-coordinate of the symbol.
5630
- * @param orientation - The orientation of the symbol.
5631
- */
5632
- constructor(x: number, y: number, orientation: Orientation);
5633
- get id(): string;
5634
- get explanation(): string;
5635
- get configs(): readonly AnyConfig[] | null;
5636
- createExampleGrid(): GridData;
5637
- validateSymbol(grid: GridData): State;
5638
- copyWith({
5639
- x,
5640
- y,
5641
- orientation,
5642
- }: {
5643
- x?: number;
5644
- y?: number;
5645
- orientation?: Orientation;
5646
- }): this;
5706
+ export declare class MyopiaModule extends Z3Module {
5707
+ readonly id: string;
5708
+ encode<Name extends string>(
5709
+ grid: GridData,
5710
+ ctx: Z3SolverContext<Name, Solver$1<Name> | Optimize<Name>>
5711
+ ): void;
5647
5712
  }
5648
-
5649
- export class MinesweeperSymbol extends NumberSymbol {
5713
+ export declare class RegionAreaModule extends Z3Module {
5714
+ readonly id: string;
5715
+ encode<Name extends string>(
5716
+ grid: GridData,
5717
+ ctx: Z3SolverContext<Name, Solver$1<Name> | Optimize<Name>>
5718
+ ): void;
5719
+ }
5720
+ export declare class ViewpointModule extends Z3Module {
5721
+ readonly id: string;
5722
+ encode<Name extends string>(
5723
+ grid: GridData,
5724
+ ctx: Z3SolverContext<Name, Solver$1<Name> | Optimize<Name>>
5725
+ ): void;
5726
+ }
5727
+ export declare function convertDirection(
5728
+ direction: Orientation | Direction
5729
+ ): import('grilops').Direction;
5730
+ export declare class Z3Solver extends Solver {
5731
+ readonly id = 'z3';
5732
+ readonly description =
5733
+ 'Good for confirming that a solution is unique, especially for larger puzzles. It is otherwise slower than most solvers in small to medium-sized puzzles.';
5734
+ isEnvironmentSupported(): Promise<boolean>;
5735
+ solve(grid: GridData): AsyncGenerator<GridData | null>;
5736
+ isInstructionSupported(instructionId: string): boolean;
5737
+ isGridSupported(grid: GridData): boolean;
5738
+ }
5739
+ export declare abstract class CustomSymbol extends MultiEntrySymbol {
5740
+ readonly description: string;
5741
+ readonly grid: GridData;
5650
5742
  /**
5651
- * **Minesweeper numbers count opposite cells in 8 adjacent spaces**
5743
+ * **A custom symbol**
5652
5744
  *
5745
+ * @param description - The description of the symbol. Leave this empty to hide the description.
5746
+ * @param grid - The thumbnail grid of the rule, preferably 5x4 in size.
5653
5747
  * @param x - The x-coordinate of the symbol.
5654
5748
  * @param y - The y-coordinate of the symbol.
5655
- * @param number - The number of cells seen by the symbol.
5656
5749
  */
5657
- constructor(x: number, y: number, number: number);
5658
- get id(): string;
5659
- get placementStep(): number;
5750
+ constructor(description: string, grid: GridData, x: number, y: number);
5660
5751
  get explanation(): string;
5661
- get configs(): readonly AnyConfig[] | null;
5662
5752
  createExampleGrid(): GridData;
5663
- countTiles(grid: GridData): {
5664
- completed: number;
5665
- possible: number;
5666
- };
5667
- copyWith({
5668
- x,
5669
- y,
5670
- number,
5671
- }: {
5672
- x?: number;
5673
- y?: number;
5674
- number?: number;
5675
- }): this;
5676
- withNumber(number: number): this;
5677
- }
5678
-
5679
- export abstract class MultiEntrySymbol extends Symbol {
5680
- /**
5681
- * Determines if the description of two MultiEntrySymbols can be merged when displayed in the UI.
5682
- * @param other - The other MultiEntrySymbol to compare to.
5683
- * @returns Whether the two MultiEntrySymbols have the same description.
5684
- */
5685
- descriptionEquals(other: Instruction): boolean;
5753
+ validateSymbol(_grid: GridData): State;
5754
+ get validateWithSolution(): boolean;
5755
+ withDescription(description: string): this;
5756
+ withGrid(grid: GridData): this;
5686
5757
  }
5687
-
5688
- export class MyopiaSymbol extends MultiEntrySymbol {
5689
- readonly diagonals: boolean;
5690
- readonly directions: OrientationToggle;
5758
+ export declare class CustomIconSymbol extends CustomSymbol {
5759
+ readonly icon: string;
5760
+ readonly rotation: number;
5761
+ private static readonly EXAMPLE_GRID;
5762
+ private static readonly CONFIGS;
5691
5763
  /**
5692
- * **Viewpoint Numbers count visible cells in the four directions**
5764
+ * **A custom icon symbol**
5765
+ *
5766
+ * @param description - The description of the symbol. Leave this empty to hide the description.
5767
+ * @param grid - The thumbnail grid of the rule, preferably 5x4 in size.
5693
5768
  * @param x - The x-coordinate of the symbol.
5694
5769
  * @param y - The y-coordinate of the symbol.
5695
- * @param diagonals - Whether the symbol should consider diagonal directions.
5696
- * @param directions - The directions in which an arrow is pointing.
5770
+ * @param icon - The icon to display. All available icons can be found at https://react-icons.github.io/react-icons/icons/md/
5771
+ * @param rotation - The rotation of the icon in degrees.
5697
5772
  */
5698
5773
  constructor(
5774
+ description: string,
5775
+ grid: GridData,
5699
5776
  x: number,
5700
5777
  y: number,
5701
- diagonals: boolean,
5702
- directions: OrientationToggle
5778
+ icon: string,
5779
+ rotation?: number
5703
5780
  );
5704
5781
  get id(): string;
5705
- get placementStep(): number;
5706
- get explanation(): string;
5707
5782
  get configs(): readonly AnyConfig[] | null;
5708
- createExampleGrid(): GridData;
5709
- validateSymbol(grid: GridData): State;
5710
5783
  copyWith({
5784
+ description,
5785
+ grid,
5711
5786
  x,
5712
5787
  y,
5713
- diagonals,
5714
- directions,
5788
+ icon,
5789
+ rotation,
5715
5790
  }: {
5791
+ description?: string;
5792
+ grid?: GridData;
5716
5793
  x?: number;
5717
5794
  y?: number;
5718
- diagonals?: boolean;
5719
- directions?: OrientationToggle;
5795
+ icon?: string;
5796
+ rotation?: number;
5720
5797
  }): this;
5721
- withDirections(directions: OrientationToggle): this;
5722
- withDiagonals(diagonals: boolean): this;
5723
- }
5724
-
5725
- /**
5726
- * All symbols which contain a number should extend this class to be compatible with off by X rules.
5727
- */
5728
- export abstract class NumberSymbol extends Symbol {
5729
- readonly x: number;
5730
- readonly y: number;
5731
- readonly number: number;
5732
- constructor(x: number, y: number, number: number);
5733
- abstract countTiles(grid: GridData): {
5734
- completed: number;
5735
- possible: number;
5736
- };
5737
- validateSymbol(grid: GridData): State;
5738
- withNumber(number: number): this;
5739
- }
5740
-
5741
- export abstract class Symbol
5742
- extends Instruction
5743
- implements GridResizeHandler
5744
- {
5745
- readonly x: number;
5746
- readonly y: number;
5747
- constructor(x: number, y: number);
5748
- abstract validateSymbol(grid: GridData): State;
5749
- onGridResize(
5750
- _grid: GridData,
5751
- mode: 'insert' | 'remove',
5752
- direction: 'row' | 'column',
5753
- index: number
5754
- ): this | null;
5755
- get placementStep(): number;
5756
- withX(x: number): this;
5757
- withY(y: number): this;
5758
- withPosition(x: number, y: number): this;
5798
+ withIcon(icon: string): this;
5799
+ withRotation(rotation: number): this;
5759
5800
  }
5760
-
5761
- export class ViewpointSymbol extends NumberSymbol {
5801
+ export declare class CustomTextSymbol extends CustomSymbol {
5802
+ readonly text: string;
5803
+ readonly rotation: number;
5804
+ private static readonly EXAMPLE_GRID;
5805
+ private static readonly CONFIGS;
5762
5806
  /**
5763
- * **Viewpoint Numbers count visible cells in the four directions**
5807
+ * **A custom text symbol**
5808
+ *
5809
+ * @param description - The description of the symbol. Leave this empty to hide the description.
5810
+ * @param grid - The thumbnail grid of the rule, preferably 5x4 in size.
5764
5811
  * @param x - The x-coordinate of the symbol.
5765
5812
  * @param y - The y-coordinate of the symbol.
5766
- * @param number - The viewpoint number.
5813
+ * @param text - The text to display.
5814
+ * @param rotation - The rotation of the text in degrees.
5767
5815
  */
5768
- constructor(x: number, y: number, number: number);
5816
+ constructor(
5817
+ description: string,
5818
+ grid: GridData,
5819
+ x: number,
5820
+ y: number,
5821
+ text: string,
5822
+ rotation?: number
5823
+ );
5769
5824
  get id(): string;
5770
- get placementStep(): number;
5771
- get explanation(): string;
5772
5825
  get configs(): readonly AnyConfig[] | null;
5773
- createExampleGrid(): GridData;
5774
- countTiles(grid: GridData): {
5775
- completed: number;
5776
- possible: number;
5777
- };
5778
5826
  copyWith({
5827
+ description,
5828
+ grid,
5779
5829
  x,
5780
5830
  y,
5781
- number,
5831
+ text,
5832
+ rotation,
5782
5833
  }: {
5834
+ description?: string;
5835
+ grid?: GridData;
5783
5836
  x?: number;
5784
5837
  y?: number;
5785
- number?: number;
5786
- }): this;
5787
- withNumber(number: number): this;
5788
- }
5789
-
5790
- export class TileData {
5791
- readonly exists: boolean;
5792
- readonly fixed: boolean;
5793
- readonly color: Color;
5794
- constructor(exists: boolean, fixed: boolean, color: Color);
5795
- /**
5796
- * Create a gray tile.
5797
- */
5798
- static empty(): TileData;
5799
- /**
5800
- * Create a non-existent tile.
5801
- */
5802
- static doesNotExist(): TileData;
5803
- copyWith({
5804
- exists,
5805
- fixed,
5806
- color,
5807
- }: {
5808
- exists?: boolean;
5809
- fixed?: boolean;
5810
- color?: Color;
5838
+ text?: string;
5839
+ rotation?: number;
5811
5840
  }): this;
5812
- withExists(exists: boolean): this;
5813
- withFixed(fixed: boolean): this;
5814
- withColor(color: Color): this;
5815
- get isFixed(): boolean;
5816
- equals(other: TileData): boolean;
5817
- static create(char: string): TileData;
5818
- }
5819
-
5820
- export class TileConnections {
5821
- [y: number]: {
5822
- [x: number]: boolean;
5823
- };
5824
- constructor();
5825
- get topLeft(): boolean;
5826
- set topLeft(value: boolean);
5827
- get top(): boolean;
5828
- set top(value: boolean);
5829
- get topRight(): boolean;
5830
- set topRight(value: boolean);
5831
- get left(): boolean;
5832
- set left(value: boolean);
5833
- get center(): boolean;
5834
- set center(value: boolean);
5835
- get right(): boolean;
5836
- set right(value: boolean);
5837
- get bottomLeft(): boolean;
5838
- set bottomLeft(value: boolean);
5839
- get bottom(): boolean;
5840
- set bottom(value: boolean);
5841
- get bottomRight(): boolean;
5842
- set bottomRight(value: boolean);
5843
- equals(other: TileConnections): boolean;
5841
+ withText(text: string): this;
5842
+ withRotation(rotation: number): this;
5844
5843
  }
5845
-
5846
- export function aggregateState(
5844
+ export declare const allSymbols: Map<string, Symbol$1>;
5845
+ export declare function aggregateState(
5847
5846
  rules: RuleState[],
5848
5847
  grid: GridData,
5849
5848
  symbols: Map<string, State[]>
5850
5849
  ): State;
5851
- export function applyFinalOverrides(
5850
+ export declare function applyFinalOverrides(
5852
5851
  grid: GridData,
5853
5852
  solution: GridData | null,
5854
5853
  state: GridState
@@ -5858,7 +5857,11 @@ declare global {
5858
5857
  solution: GridData | null
5859
5858
  ): GridState;
5860
5859
 
5861
- export { Symbol as _Symbol };
5860
+ export { Symbol$1 as Symbol, escape$1 as escape, unescape$1 as unescape };
5861
+
5862
+ export {};
5863
+
5864
+ export { Symbol$1 as _Symbol };
5862
5865
  }
5863
5866
  export {};
5864
5867