@harmonics/lattice-ui 0.5.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,30 +2,30 @@ var e = {
2
2
  width: 76.21,
3
3
  height: 132,
4
4
  half: 38.11
5
- }, t = {
5
+ }, t = "M 38.11 0 L 76.21 22 L 76.21 66 L 38.11 88 L 0 66 L 0 22 Z", n = {
6
6
  sky: "M 76.21 66.00 L 38.11 88.00 L -0.00 66.00 L 0.00 22.00 L 38.11 0.00 L 76.21 22.00 Z M 38.11 132.00 L 0.00 154.00 L -38.11 132.00 L -38.11 88.00 L -0.00 66.00 L 38.11 88.00 Z M 114.32 132.00 L 76.21 154.00 L 38.11 132.00 L 38.11 88.00 L 76.21 66.00 L 114.32 88.00 Z",
7
7
  earth: "M 76.21 66.00 L 38.11 88.00 L -0.00 66.00 L 0.00 22.00 L 38.11 0.00 L 76.21 22.00 Z M 38.11 44.00 L 76.21 66.00 M 57.16 55.00 L 57.16 77.00 L 38.11 66.00 Z M 38.11 44.00 L 38.11 88.00 M 38.11 66.00 L 19.05 77.00 L 19.05 55.00 Z M 38.11 44.00 L -0.00 66.00 M 19.05 55.00 L -0.00 44.00 L 19.05 33.00 Z M 38.11 44.00 L 0.00 22.00 M 19.05 33.00 L 19.05 11.00 L 38.11 22.00 Z M 38.11 44.00 L 38.11 0.00 M 38.11 22.00 L 57.16 11.00 L 57.16 33.00 Z M 38.11 44.00 L 76.21 22.00 M 57.16 33.00 L 76.21 44.00 L 57.16 55.00 Z M 38.11 132.00 L 0.00 154.00 L -38.11 132.00 L -38.11 88.00 L -0.00 66.00 L 38.11 88.00 Z M 0.00 110.00 L 38.11 132.00 M 19.05 121.00 L 19.05 143.00 L 0.00 132.00 Z M 0.00 110.00 L 0.00 154.00 M 0.00 132.00 L -19.05 143.00 L -19.05 121.00 Z M 0.00 110.00 L -38.11 132.00 M -19.05 121.00 L -38.11 110.00 L -19.05 99.00 Z M 0.00 110.00 L -38.11 88.00 M -19.05 99.00 L -19.05 77.00 L -0.00 88.00 Z M 0.00 110.00 L -0.00 66.00 M -0.00 88.00 L 19.05 77.00 L 19.05 99.00 Z M 0.00 110.00 L 38.11 88.00 M 19.05 99.00 L 38.11 110.00 L 19.05 121.00 Z M 114.32 132.00 L 76.21 154.00 L 38.11 132.00 L 38.11 88.00 L 76.21 66.00 L 114.32 88.00 Z M 76.21 110.00 L 114.32 132.00 M 95.26 121.00 L 95.26 143.00 L 76.21 132.00 Z M 76.21 110.00 L 76.21 154.00 M 76.21 132.00 L 57.16 143.00 L 57.16 121.00 Z M 76.21 110.00 L 38.11 132.00 M 57.16 121.00 L 38.11 110.00 L 57.16 99.00 Z M 76.21 110.00 L 38.11 88.00 M 57.16 99.00 L 57.16 77.00 L 76.21 88.00 Z M 76.21 110.00 L 76.21 66.00 M 76.21 88.00 L 95.26 77.00 L 95.26 99.00 Z M 76.21 110.00 L 114.32 88.00 M 95.26 99.00 L 114.32 110.00 L 95.26 121.00 Z"
8
- }, n = 44, { width: r } = e, i = r / 2;
9
- function a(e) {
8
+ }, r = 44, { width: i } = e, a = i / 2;
9
+ function o(e) {
10
10
  return {
11
- x: r * (e.q + e.r / 2),
11
+ x: i * (e.q + e.r / 2),
12
12
  y: 66 * e.r
13
13
  };
14
14
  }
15
- function o(e) {
15
+ function s(e) {
16
16
  return {
17
- x: i * e.j,
18
- y: n * e.i + 22 * e.j
17
+ x: a * e.j,
18
+ y: r * e.i + 22 * e.j
19
19
  };
20
20
  }
21
- function s(e) {
22
- let t = o(e);
21
+ function c(e) {
22
+ let t = s(e);
23
23
  return {
24
24
  x: t.x,
25
25
  y: 22 + t.y
26
26
  };
27
27
  }
28
- function c(e) {
28
+ function l(e) {
29
29
  let { i: t, j: n } = e;
30
30
  return e.k === 0 ? [
31
31
  {
@@ -55,27 +55,27 @@ function c(e) {
55
55
  }
56
56
  ];
57
57
  }
58
- function l(e, t) {
59
- let r = e - i, a = 2 / 3 * ((t - 44) / n), o = Math.sqrt(3) / 3 * (r / n) - a / 2, s = -o - a, c = Math.round(o), l = Math.round(a), u = Math.round(s), d = Math.abs(c - o), f = Math.abs(l - a), p = Math.abs(u - s);
58
+ function u(e, t) {
59
+ let n = e - a, i = 2 / 3 * ((t - 44) / r), o = Math.sqrt(3) / 3 * (n / r) - i / 2, s = -o - i, c = Math.round(o), l = Math.round(i), u = Math.round(s), d = Math.abs(c - o), f = Math.abs(l - i), p = Math.abs(u - s);
60
60
  return d > f && d > p ? c = -l - u : f > p && (l = -c - u), {
61
61
  q: c + 0,
62
62
  r: l + 0
63
63
  };
64
64
  }
65
- function u(e, t) {
66
- let r = Math.round(e / i);
65
+ function d(e, t) {
66
+ let n = Math.round(e / a);
67
67
  return {
68
- i: Math.round((t - 22 - 22 * r) / n) + 0,
69
- j: r + 0
68
+ i: Math.round((t - 22 - 22 * n) / r) + 0,
69
+ j: n + 0
70
70
  };
71
71
  }
72
- function d(e) {
72
+ function f(e) {
73
73
  return {
74
74
  i: e.r - e.q,
75
75
  j: 1 + 2 * e.q + e.r
76
76
  };
77
77
  }
78
- function f(e) {
78
+ function p(e) {
79
79
  let t = e.j - 1 - e.i;
80
80
  if (t % 3 != 0) return;
81
81
  let n = t / 3;
@@ -84,8 +84,8 @@ function f(e) {
84
84
  r: e.i + n + 0
85
85
  };
86
86
  }
87
- function p(e) {
88
- let { i: t, j: n } = d(e);
87
+ function m(e) {
88
+ let { i: t, j: n } = f(e);
89
89
  return [
90
90
  {
91
91
  i: t,
@@ -119,7 +119,7 @@ function p(e) {
119
119
  }
120
120
  ];
121
121
  }
122
- function m(e) {
122
+ function h(e) {
123
123
  let { i: t, j: n } = e;
124
124
  return e.k === 0 ? [
125
125
  {
@@ -155,39 +155,43 @@ function m(e) {
155
155
  }
156
156
  ];
157
157
  }
158
- var h = (e) => `${e.i},${e.j},${e.k}`, g = (e) => `${e.i},${e.j}`, _ = (e, t) => ({
158
+ var g = (e) => `${e.i},${e.j},${e.k}`, _ = (e) => `${e.i},${e.j}`, v = (e, t) => ({
159
159
  left: 0,
160
160
  top: 0,
161
161
  right: e,
162
162
  bottom: t
163
- }), v = (e, t) => t.x >= e.left && t.y >= e.top && t.x <= e.right && t.y <= e.bottom, y = (e) => e.kind === "cell" ? p(e.at) : [e.at], b = /* @__PURE__ */ new WeakMap(), x = /* @__PURE__ */ new WeakMap();
164
- function S(e) {
165
- let t = b.get(e);
166
- return t || (t = e.parts.flatMap(y), b.set(e, t)), t;
167
- }
168
- function C(e) {
163
+ }), y = (e, t) => t.x >= e.left && t.y >= e.top && t.x <= e.right && t.y <= e.bottom, b = (e) => e.kind === "cell" ? m(e.at) : [e.at], x = /* @__PURE__ */ new WeakMap(), S = /* @__PURE__ */ new WeakMap(), C = /* @__PURE__ */ new WeakMap();
164
+ function w(e) {
169
165
  let t = x.get(e);
170
- return t || (t = new Set(S(e).map(h)), x.set(e, t)), t;
166
+ return t || (t = e.parts.flatMap(b), x.set(e, t)), t;
171
167
  }
172
- function w(e, t) {
173
- let n = new Set(e.flatMap(p).map(h)), r = t.map(C);
168
+ function T(e) {
169
+ let t = S.get(e);
170
+ return t || (t = new Set(w(e).map(g)), S.set(e, t)), t;
171
+ }
172
+ function E(e) {
173
+ let t = C.get(e);
174
+ return t === void 0 && (t = w(e).reduce((e, t) => Math.max(e, ...l(t).map((e) => c(e).y)), -Infinity), C.set(e, t)), t;
175
+ }
176
+ function D(e, t) {
177
+ let n = new Set(e.flatMap(m).map(g)), r = t.map(T);
174
178
  return (e) => {
175
- let t = h(e);
179
+ let t = g(e);
176
180
  return n.has(t) || r.some((e) => e.has(t));
177
181
  };
178
182
  }
179
- function T(e, t, n, r = []) {
180
- let i = w(r, t.filter((t) => t.id !== e.id));
181
- return S(e).every((e) => c(e).every((e) => v(n, s(e))) && !i(e));
183
+ function O(e, t, n, r = []) {
184
+ let i = D(r, t.filter((t) => t.id !== e.id));
185
+ return w(e).every((e) => l(e).every((e) => y(n, c(e))) && !i(e));
182
186
  }
183
- var E = (e) => e.parts.some((e) => e.kind === "cell");
184
- function D(e, t) {
187
+ var k = (e) => e.parts.some((e) => e.kind === "cell");
188
+ function A(e, t) {
185
189
  if (t.i === 0 && t.j === 0) return e;
186
190
  let n = (e) => ({
187
191
  i: e.i + t.i,
188
192
  j: e.j + t.j
189
193
  });
190
- if (E(e) && (t.j - t.i) % 3 != 0) throw Error("a piece with a cell moves a whole cell at a time");
194
+ if (k(e) && (t.j - t.i) % 3 != 0) throw Error("a piece with a cell moves a whole cell at a time");
191
195
  let r = e.parts.map((e) => e.kind === "tri" ? {
192
196
  ...e,
193
197
  at: {
@@ -196,13 +200,13 @@ function D(e, t) {
196
200
  }
197
201
  } : {
198
202
  ...e,
199
- at: f(n(d(e.at)))
203
+ at: p(n(f(e.at)))
200
204
  }), i = {
201
205
  ...e,
202
206
  parts: r,
203
207
  pivot: n(e.pivot)
204
- }, a = O.get(e);
205
- return O.set(i, a ? {
208
+ }, a = j.get(e);
209
+ return j.set(i, a ? {
206
210
  from: a.from,
207
211
  by: {
208
212
  i: a.by.i + t.i,
@@ -213,9 +217,9 @@ function D(e, t) {
213
217
  by: t
214
218
  }), i;
215
219
  }
216
- var O = /* @__PURE__ */ new WeakMap();
217
- function k(e, t) {
218
- let n = d(l(e + i, t + 44)), r = d({
220
+ var j = /* @__PURE__ */ new WeakMap();
221
+ function M(e, t) {
222
+ let n = f(u(e + a, t + 44)), r = f({
219
223
  q: 0,
220
224
  r: 0
221
225
  });
@@ -224,18 +228,18 @@ function k(e, t) {
224
228
  j: n.j - r.j
225
229
  };
226
230
  }
227
- function A(e, t, n) {
228
- return E(e) ? k(t, n) : u(t, n + 22);
231
+ function N(e, t, n) {
232
+ return k(e) ? M(t, n) : d(t, n + 22);
229
233
  }
230
- var j = {
234
+ var P = {
231
235
  reach: .5,
232
236
  capture: .3,
233
237
  release: .5,
234
238
  lean: .6
235
239
  };
236
- function M(e, t, n) {
237
- let r = A(e, t, n);
238
- if (E(e)) return r;
240
+ function F(e, t, n) {
241
+ let r = N(e, t, n);
242
+ if (k(e)) return r;
239
243
  let i = [r, ...[
240
244
  [1, 0],
241
245
  [-1, 0],
@@ -247,17 +251,17 @@ function M(e, t, n) {
247
251
  i: r.i + e,
248
252
  j: r.j + t
249
253
  }))], a = (e) => {
250
- let r = o(e);
254
+ let r = s(e);
251
255
  return Math.hypot(t - r.x, n - r.y);
252
256
  };
253
257
  return i.reduce((e, t) => a(t) < a(e) ? t : e);
254
258
  }
255
259
  var ee = (e) => e * e * (3 - 2 * e);
256
- function te(e, t, i, a) {
257
- let s = (E(e) ? r : n) * j.reach;
260
+ function te(e, t, n, a) {
261
+ let o = (k(e) ? i : r) * P.reach;
258
262
  if (a) {
259
- let e = o(a);
260
- if (Math.hypot(t - e.x, i - e.y) <= s * j.release) return {
263
+ let e = s(a);
264
+ if (Math.hypot(t - e.x, n - e.y) <= o * P.release) return {
261
265
  step: a,
262
266
  x: e.x,
263
267
  y: e.y,
@@ -265,7 +269,7 @@ function te(e, t, i, a) {
265
269
  held: a
266
270
  };
267
271
  }
268
- let c = M(e, t, i), l = o(c), u = Math.hypot(t - l.x, i - l.y), d = s * j.capture;
272
+ let c = F(e, t, n), l = s(c), u = Math.hypot(t - l.x, n - l.y), d = o * P.capture;
269
273
  if (u <= d) return {
270
274
  step: c,
271
275
  x: l.x,
@@ -273,16 +277,16 @@ function te(e, t, i, a) {
273
277
  pull: 1,
274
278
  held: c
275
279
  };
276
- let f = u >= s ? 0 : 1 - ee((u - d) / (s - d)), p = f * j.lean;
280
+ let f = u >= o ? 0 : 1 - ee((u - d) / (o - d)), p = f * P.lean;
277
281
  return {
278
282
  step: c,
279
283
  x: t + (l.x - t) * p,
280
- y: i + (l.y - i) * p,
284
+ y: n + (l.y - n) * p,
281
285
  pull: f,
282
286
  held: void 0
283
287
  };
284
288
  }
285
- function N(e, t = .12) {
289
+ function ne(e, t = .12) {
286
290
  let n = (t) => `translate(${e.x * t}px, ${e.y * t}px)`;
287
291
  return [
288
292
  {
@@ -306,8 +310,8 @@ function N(e, t = .12) {
306
310
  }
307
311
  ];
308
312
  }
309
- function P(e, t) {
310
- return (E(e) ? {
313
+ function re(e, t) {
314
+ return (k(e) ? {
311
315
  ArrowRight: {
312
316
  i: -1,
313
317
  j: 2
@@ -343,11 +347,11 @@ function P(e, t) {
343
347
  }
344
348
  })[t];
345
349
  }
346
- var F = (e) => ({
350
+ var I = (e) => ({
347
351
  i: e.i + e.j,
348
352
  j: -e.i + 0
349
353
  });
350
- function I(e) {
354
+ function L(e) {
351
355
  let t = Math.min(...e.map((e) => e.i)), n = e.filter((e) => e.i === t);
352
356
  return n.length === 2 ? {
353
357
  i: t,
@@ -359,103 +363,103 @@ function I(e) {
359
363
  k: 1
360
364
  };
361
365
  }
362
- function L(e, t) {
366
+ function R(e, t) {
363
367
  let n = (t % 6 + 6) % 6, r = e.pivot, i = (e) => {
364
368
  let t = {
365
369
  i: e.i - r.i,
366
370
  j: e.j - r.j
367
371
  };
368
- for (let e = 0; e < n; e++) t = F(t);
372
+ for (let e = 0; e < n; e++) t = I(t);
369
373
  return {
370
374
  i: t.i + r.i,
371
375
  j: t.j + r.j
372
376
  };
373
377
  }, a = e.parts.map((e) => e.kind === "tri" ? {
374
378
  ...e,
375
- at: I(c(e.at).map(i))
379
+ at: L(l(e.at).map(i))
376
380
  } : {
377
381
  ...e,
378
- at: f(i(d(e.at)))
382
+ at: p(i(f(e.at)))
379
383
  });
380
384
  return {
381
385
  ...e,
382
386
  parts: a
383
387
  };
384
388
  }
385
- var R = (e) => s(e.pivot);
386
- function z(e) {
387
- let t = e.flatMap(y).flatMap((e) => c(e).map(s)), n = {
389
+ var z = (e) => c(e.pivot);
390
+ function B(e) {
391
+ let t = e.flatMap(b).flatMap((e) => l(e).map(c)), n = {
388
392
  x: t.reduce((e, t) => e + t.x, 0) / t.length,
389
393
  y: t.reduce((e, t) => e + t.y, 0) / t.length
390
394
  };
391
- return e.some((e) => e.kind === "cell") ? d(l(n.x, n.y)) : u(n.x, n.y);
395
+ return e.some((e) => e.kind === "cell") ? f(u(n.x, n.y)) : d(n.x, n.y);
392
396
  }
393
- var B = (e, t) => ({
397
+ var V = (e, t) => ({
394
398
  id: e,
395
399
  parts: t,
396
- pivot: z(t)
400
+ pivot: B(t)
397
401
  });
398
- function V(e, t) {
399
- let n = t instanceof Set ? t : new Set(t.map(h));
400
- return e.some((e) => m(e).some((e) => n.has(h(e))));
401
- }
402
- var H = (e, t) => S(e).length <= S(t).length ? V(S(e), C(t)) : V(S(t), C(e));
403
- function U(e, t) {
404
- let n = C(t), r = [];
405
- for (let t of S(e)) for (let e of m(t)) {
406
- if (!n.has(h(e))) continue;
407
- let i = new Set(c(t).map(g)), a = c(e).filter((e) => i.has(g(e)));
408
- a.length === 2 && r.push([s(a[0]), s(a[1])]);
402
+ function H(e, t) {
403
+ let n = t instanceof Set ? t : new Set(t.map(g));
404
+ return e.some((e) => h(e).some((e) => n.has(g(e))));
405
+ }
406
+ var U = (e, t) => w(e).length <= w(t).length ? H(w(e), T(t)) : H(w(t), T(e));
407
+ function W(e, t) {
408
+ let n = T(t), r = [];
409
+ for (let t of w(e)) for (let e of h(t)) {
410
+ if (!n.has(g(e))) continue;
411
+ let i = new Set(l(t).map(_)), a = l(e).filter((e) => i.has(_(e)));
412
+ a.length === 2 && r.push([c(a[0]), c(a[1])]);
409
413
  }
410
414
  return r;
411
415
  }
412
- function W(e) {
416
+ function G(e) {
413
417
  let t = /* @__PURE__ */ new Map();
414
418
  e.parts.forEach((e, n) => {
415
- for (let r of y(e)) t.set(h(r), n);
419
+ for (let r of b(e)) t.set(g(r), n);
416
420
  });
417
421
  let n = [];
418
422
  for (let [e, r] of t) {
419
- let [i, a, o] = e.split(",").map(Number), l = {
423
+ let [i, a, o] = e.split(",").map(Number), s = {
420
424
  i,
421
425
  j: a,
422
426
  k: o
423
427
  };
424
- for (let e of m(l)) {
425
- let i = t.get(h(e));
428
+ for (let e of h(s)) {
429
+ let i = t.get(g(e));
426
430
  if (i === void 0 || i <= r) continue;
427
- let a = new Set(c(l).map(g)), o = c(e).filter((e) => a.has(g(e)));
428
- o.length === 2 && n.push([s(o[0]), s(o[1])]);
431
+ let a = new Set(l(s).map(_)), o = l(e).filter((e) => a.has(_(e)));
432
+ o.length === 2 && n.push([c(o[0]), c(o[1])]);
429
433
  }
430
434
  }
431
435
  return n;
432
436
  }
433
- function G(e, t) {
434
- let n = t.filter((t) => t.id !== e.id && H(e, t)), r = [...e.parts, ...n.flatMap((e) => e.parts)];
437
+ function K(e, t) {
438
+ let n = t.filter((t) => t.id !== e.id && U(e, t)), r = [...e.parts, ...n.flatMap((e) => e.parts)];
435
439
  return {
436
- piece: B(e.id, r),
440
+ piece: V(e.id, r),
437
441
  absorbed: n.map((e) => e.id)
438
442
  };
439
443
  }
440
- function K(e, t) {
444
+ function q(e, t) {
441
445
  let n = [...e], r = [];
442
446
  for (; n.length > 0;) {
443
447
  let e = [n.shift()];
444
448
  for (let t = 0; t < e.length; t++) {
445
- let r = y(e[t]);
446
- for (let t = n.length - 1; t >= 0; t--) V(r, y(n[t])) && e.push(...n.splice(t, 1));
449
+ let r = b(e[t]);
450
+ for (let t = n.length - 1; t >= 0; t--) H(r, b(n[t])) && e.push(...n.splice(t, 1));
447
451
  }
448
- r.push(B(t(), e));
452
+ r.push(V(t(), e));
449
453
  }
450
454
  return r;
451
455
  }
452
- function q(e, t, n) {
456
+ function J(e, t, n) {
453
457
  let r = e.parts[t], i = e.parts.filter((e, n) => n !== t);
454
- return [B(n(), [r]), ...K(i, n)];
458
+ return [V(n(), [r]), ...q(i, n)];
455
459
  }
456
- var J = (e, t) => e.parts.map((e) => B(t(), [e]));
457
- function Y(e) {
458
- return E(e) ? [
460
+ var Y = (e, t) => e.parts.map((e) => V(t(), [e]));
461
+ function ie(e) {
462
+ return k(e) ? [
459
463
  {
460
464
  i: -1,
461
465
  j: 2
@@ -508,47 +512,80 @@ function Y(e) {
508
512
  ];
509
513
  }
510
514
  function X(e, t, n, r = [], i = 6, a = () => !0) {
511
- let s = Y(e), c = /* @__PURE__ */ new Set(["0,0"]), l = [{
515
+ let o = ie(e), c = /* @__PURE__ */ new Set(["0,0"]), l = [{
512
516
  i: 0,
513
517
  j: 0
514
518
  }];
515
519
  for (let u = 0; u <= i; u++) {
516
520
  let i = l.map((t) => ({
517
521
  d: t,
518
- at: D(e, t),
519
- far: Math.hypot(o(t).x, o(t).y)
520
- })).filter((e) => T(e.at, t, n, r) && a(e.at)).sort((e, t) => e.far - t.far);
522
+ at: A(e, t),
523
+ far: Math.hypot(s(t).x, s(t).y)
524
+ })).filter((e) => O(e.at, t, n, r) && a(e.at)).sort((e, t) => e.far - t.far);
521
525
  if (i[0]) return i[0].at;
522
526
  let u = [];
523
- for (let e of l) for (let t of s) {
527
+ for (let e of l) for (let t of o) {
524
528
  let n = {
525
529
  i: e.i + t.i,
526
530
  j: e.j + t.j
527
- }, r = g(n);
531
+ }, r = _(n);
528
532
  c.has(r) || (c.add(r), u.push(n));
529
533
  }
530
534
  l = u;
531
535
  }
532
536
  }
533
- var Z = (e) => o(e);
534
- function ne(e) {
535
- let t = new Set(S(e).map(h)), n = [];
536
- for (let r of S(e)) for (let e of m(r)) {
537
- if (t.has(h(e))) continue;
538
- let i = new Set(c(r).map(g)), a = c(e).filter((e) => i.has(g(e)));
539
- a.length === 2 && n.push([s(a[0]), s(a[1])]);
537
+ var ae = (e) => s(e);
538
+ function oe(e, t, n, r = []) {
539
+ let i = D(r, t.filter((t) => t.id !== e.id)), a = /* @__PURE__ */ new Set();
540
+ return e.parts.forEach((e, t) => {
541
+ b(e).some((e) => i(e) || l(e).some((e) => !y(n, c(e)))) && a.add(t);
542
+ }), a;
543
+ }
544
+ function se(e) {
545
+ let t = new Set(w(e).map(g)), n = [];
546
+ for (let r of w(e)) for (let e of h(r)) {
547
+ if (t.has(g(e))) continue;
548
+ let i = new Set(l(r).map(_)), a = l(e).filter((e) => i.has(_(e)));
549
+ a.length === 2 && n.push([c(a[0]), c(a[1])]);
540
550
  }
541
551
  return n;
542
552
  }
543
- function re(e, t, n, r, i) {
544
- let a = l(t, n);
545
- if (e === "cell") return B(i, [{
553
+ function ce(e, t, n = [], r = []) {
554
+ let i = [...e], o = [];
555
+ for (; i.length > 0;) {
556
+ let e = [i.shift()];
557
+ for (let t = 0; t < e.length; t++) for (let n = i.length - 1; n >= 0; n--) U(e[t], i[n]) && e.push(...i.splice(n, 1));
558
+ o.push(e);
559
+ }
560
+ let s = (e) => e.reduce((e, t) => e + t.parts.length, 0);
561
+ o.sort((e, t) => s(t) - s(e));
562
+ let u = /* @__PURE__ */ new Map(), d = [...r];
563
+ for (let e of o) {
564
+ let r = V("group", e.flatMap((e) => e.parts)), i = (e) => d.every((t) => !U(e, t)), o = r;
565
+ if (!O(r, d, t, n) || !i(r)) {
566
+ let e = w(r).flatMap((e) => l(e).map(c)), s = Math.min(...e.map((e) => e.x)), u = Math.max(...e.map((e) => e.x)), f = Math.min(...e.map((e) => e.y)), p = Math.max(...e.map((e) => e.y)), m = A(r, N(r, s < t.left ? t.left - s + a : u > t.right ? t.right - u - a : 0, f < t.top ? t.top - f + 33 : p > t.bottom ? t.bottom - p - 33 : 0));
567
+ o = (O(m, d, t, n) && i(m) ? m : X(m, d, t, n, 12, i) ?? X(m, d, t, n, 12)) ?? r;
568
+ }
569
+ let s = {
570
+ i: o.pivot.i - r.pivot.i,
571
+ j: o.pivot.j - r.pivot.j
572
+ };
573
+ for (let t of e) u.set(t.id, s), d.push(A(t, s));
574
+ }
575
+ return e.map((e) => A(e, u.get(e.id) ?? {
576
+ i: 0,
577
+ j: 0
578
+ }));
579
+ }
580
+ function Z(e, t, n, r, i) {
581
+ let a = u(t, n);
582
+ if (e === "cell") return V(i, [{
546
583
  kind: e,
547
584
  at: a,
548
585
  tone: r
549
586
  }]);
550
- let { i: o, j: s } = d(a);
551
- return B(i, [{
587
+ let { i: o, j: s } = f(a);
588
+ return V(i, [{
552
589
  kind: e,
553
590
  at: {
554
591
  i: o - 1,
@@ -558,8 +595,8 @@ function re(e, t, n, r, i) {
558
595
  tone: r
559
596
  }]);
560
597
  }
561
- function ie(e, t) {
562
- let n = (e) => Math.round(e * 100) / 100, o = (e) => `M${e.map((e) => `${n(e.x)} ${n(e.y)}`).join("L")}Z`, l = (e) => ({
598
+ function le(e, t) {
599
+ let n = (e) => Math.round(e * 100) / 100, r = (e) => `M${e.map((e) => `${n(e.x)} ${n(e.y)}`).join("L")}Z`, s = (e) => ({
563
600
  x: e.x,
564
601
  y: e.y - t
565
602
  }), u = /* @__PURE__ */ new Map(), d = (e, t, n) => {
@@ -571,40 +608,40 @@ function ie(e, t) {
571
608
  i.d.push(n), u.set(r, i);
572
609
  };
573
610
  for (let t of e.parts) if (t.kind === "cell") {
574
- let { x: e, y: n } = a(t.at), s = (t, r) => ({
611
+ let { x: e, y: n } = o(t.at), c = (t, r) => ({
575
612
  x: e + t,
576
613
  y: n + r
577
- }), [c, u, f] = [
578
- s(0, 66),
579
- s(i, 88),
580
- s(r, 66)
614
+ }), [l, u, f] = [
615
+ c(0, 66),
616
+ c(a, 88),
617
+ c(i, 66)
581
618
  ];
582
- d("shade", t.tone, o([
583
- c,
619
+ d("shade", t.tone, r([
620
+ l,
584
621
  u,
585
- l(u),
586
- l(c)
587
- ])), d("shadow", t.tone, o([
622
+ s(u),
623
+ s(l)
624
+ ])), d("shadow", t.tone, r([
588
625
  u,
589
626
  f,
590
- l(f),
591
- l(u)
592
- ])), d("top", t.tone, o([
593
- s(i, 0),
594
- s(r, 22),
595
- s(r, 66),
596
- s(i, 88),
597
- s(0, 66),
598
- s(0, 22)
599
- ].map(l)));
627
+ s(f),
628
+ s(u)
629
+ ])), d("top", t.tone, r([
630
+ c(a, 0),
631
+ c(i, 22),
632
+ c(i, 66),
633
+ c(a, 88),
634
+ c(0, 66),
635
+ c(0, 22)
636
+ ].map(s)));
600
637
  } else {
601
- let e = c(t.at).map(s), n = e[2], r = e[1];
602
- d(t.at.k === 0 ? "shadow" : "shade", t.tone, o([
638
+ let e = l(t.at).map(c), n = e[2], i = e[1];
639
+ d(t.at.k === 0 ? "shadow" : "shade", t.tone, r([
603
640
  n,
604
- r,
605
- l(r),
606
- l(n)
607
- ])), d("top", t.tone, o(e.map(l)));
641
+ i,
642
+ s(i),
643
+ s(n)
644
+ ])), d("top", t.tone, r(e.map(s)));
608
645
  }
609
646
  let f = [
610
647
  "shade",
@@ -617,7 +654,7 @@ function ie(e, t) {
617
654
  kind: e.kind,
618
655
  d: e.d.join("")
619
656
  })),
620
- seams: W(e).map(([e, r]) => `M${n(e.x)} ${n(e.y - t)}L${n(r.x)} ${n(r.y - t)}`).join("")
657
+ seams: G(e).map(([e, r]) => `M${n(e.x)} ${n(e.y - t)}L${n(r.x)} ${n(r.y - t)}`).join("")
621
658
  };
622
659
  }
623
660
  function Q(e, t, n, r) {
@@ -633,38 +670,38 @@ function $(e, t) {
633
670
  }
634
671
  return !1;
635
672
  }
636
- function ae(e, t, n = 0) {
637
- let { x: o, y: s } = a(t);
673
+ function ue(e, t, n = 0) {
674
+ let { x: r, y: s } = o(t);
638
675
  return $(e, [
639
676
  {
640
- x: o + i,
677
+ x: r + a,
641
678
  y: s - n
642
679
  },
643
680
  {
644
- x: o + r,
681
+ x: r + i,
645
682
  y: s + 22 - n
646
683
  },
647
684
  {
648
- x: o + r,
685
+ x: r + i,
649
686
  y: s + 66 - n
650
687
  },
651
688
  {
652
- x: o + i,
689
+ x: r + a,
653
690
  y: s + 88 - n
654
691
  },
655
692
  {
656
- x: o,
693
+ x: r,
657
694
  y: s + 66 - n
658
695
  },
659
696
  {
660
- x: o,
697
+ x: r,
661
698
  y: s + 22 - n
662
699
  }
663
700
  ]);
664
701
  }
665
- function oe(e, t) {
702
+ function de(e, t) {
666
703
  for (let n = 1; n < e.length; n++) for (let r = 1; r < t.length; r++) if (Q(e[n - 1], e[n], t[r - 1], t[r])) return !0;
667
704
  return !1;
668
705
  }
669
706
  //#endregion
670
- export { p as A, W as C, P as D, N as E, re as M, e as N, Z as O, t as P, _ as S, A as T, X as _, s as a, R as b, ae as c, T as d, ie as f, D as g, te as h, u as i, L as j, H as k, oe as l, l as m, J as n, c as o, G as p, a as r, S as s, j as t, $ as u, ne as v, U as w, q as x, B as y };
707
+ export { re as A, z as C, W as D, G as E, R as F, Z as I, e as L, U as M, m as N, N as O, b as P, t as R, V as S, v as T, ce as _, o as a, X as b, l as c, de as d, $ as f, u as g, K as h, E as i, ae as j, ne as k, w as l, le as m, Y as n, d as o, O as p, oe as r, c as s, P as t, ue as u, te as v, J as w, se as x, A as y, n as z };
package/dist/hexes.js CHANGED
@@ -1 +1 @@
1
- export { t as MAGNET, n as apart, r as boxOf, i as cornerAt, a as cornerOf, o as cornersOf, s as covered, c as crossesCell, l as crossesLine, u as crossesRing, d as fits, p as glued, m as hexAt, h as magnetOf, g as moved, _ as nearestFit, v as outlineOf, y as pieceOf, b as pivotPoint, x as pulledOff, S as screenArea, C as seamsOf, w as sharedSides, T as snapDelta, E as snapFrames, D as stepFor, O as stepOnScreen, k as touching, A as trisOf, j as turned, M as unitAt } from "./hexes-B4uCADpF.js";
1
+ export { t as MAGNET, n as apart, a as boxOf, o as cornerAt, s as cornerOf, c as cornersOf, l as covered, u as crossesCell, d as crossesLine, f as crossesRing, p as fits, h as glued, g as hexAt, v as magnetOf, y as moved, b as nearestFit, x as outlineOf, S as pieceOf, C as pivotPoint, w as pulledOff, T as screenArea, E as seamsOf, D as sharedSides, O as snapDelta, k as snapFrames, A as stepFor, j as stepOnScreen, M as touching, N as trisOf, F as turned, I as unitAt } from "./hexes-DwdbCYSF.js";
package/dist/index.js CHANGED
@@ -1 +1,3 @@
1
- export { x as FACES, _ as FACE_TAG, n as HexSky, p as ICON_NAMES, m as ICON_TAG, v as LatticeFace, h as LatticeIcon, c as LatticeShape, y as MOODS, d as SHAPE_NAMES, l as SHAPE_TAG, a as SHEARS_TAG, r as SKY_TAG, o as ShearsPadElement, f as TONES, i as defineHexSky, t as defineLatticeElements, b as defineLatticeFace, g as defineLatticeIcon, u as defineLatticeShape, s as defineShearsPad } from "./elements-Ka2LbDpP.js";
1
+ import { i as e, r as t } from "./woods-C8W11GkD.js";
2
+ import { _ as n, a as r, c as i, d as a, f as o, g as s, h as c, i as l, l as u, m as d, n as f, o as p, p as m, r as h, s as g, t as _, u as v, v as y, y as b } from "./elements-DdyLdkzr.js";
3
+ export { b as FACES, c as FACE_TAG, f as HexSky, a as ICON_NAMES, o as ICON_TAG, s as LatticeFace, m as LatticeIcon, i as LatticeShape, n as MOODS, t as SHAPE_NAMES, u as SHAPE_TAG, r as SHEARS_TAG, h as SKY_TAG, p as ShearsPadElement, e as TONES, l as defineHexSky, _ as defineLatticeElements, y as defineLatticeFace, d as defineLatticeIcon, v as defineLatticeShape, g as defineShearsPad };