@spintax/dice-lite 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,41 @@ All notable changes to `@spintax/dice-lite`. The version is the contract: same (
4
4
  options) → identical bytes within a minor version; any change to the output bytes is a minor
5
5
  bump.
6
6
 
7
+ ## 0.3.0 — 2026-11-17
8
+
9
+ Every change below alters output bytes; unpinned throws of `dice: 2–4` change only by the
10
+ removed contact shadow.
11
+
12
+ - **Trim:** a neutral colour listed beside chromatic ones (a white, a black, a grey) no
13
+ longer turns the brass to chrome; chrome is for an all-neutral brand only (ADR 004
14
+ addendum).
15
+ - **Results complete the pins:** under `lucky7` a die whose pair partner is pinned shows its
16
+ complement to seven; under `matched` every unpinned die shows the first pinned value. A pin
17
+ is never overwritten (ADR 003 addendum).
18
+ - **`dice: 5`:** the fifth die moves from the centre, where it stood half inside the pair, to
19
+ front-right on a landscape felt; every pair of slots is one cube edge apart on the ground
20
+ (ADR 002 addendum). `dice` still appends.
21
+ - **Shadows:** the contact shadow is drawn only under a glass body — a paper body hid every
22
+ pixel of it (raster subtraction); ~98 B less per paper die. `die()` loses an empty
23
+ `translate(0 0)` wrapper (0 pixels changed).
24
+ - **Docs:** `precision` governs the table and the viewBox, the dice are always one decimal;
25
+ `brand` reads `#hex`/`rgb()` only; output sizes re-measured (ADR 006 addendum).
26
+ - **Gate:** the `pins ignored` mutation was silently skipped since the rail modes; it is
27
+ re-anchored, three mutations and two checks are added, and the precision test can fail now.
28
+ - Library 8572 B gzipped, budget 8704.
29
+
30
+ ## 0.2.0 — 2026-11-16
31
+
32
+ - The seams finish where the corner rounding starts. Both ends are trimmed — at the nose by
33
+ the tangent rule on each adjacent wedge, at the silhouette by intersection with the
34
+ rounded-corner Q-curve, the crossing chosen on the segment nearest the corner — and every
35
+ nose corner closes through a small arc, one per face, so every corner of every face reads
36
+ rounded alike. Each seam end stops one stroke-width short of the outline: an edge meets
37
+ the boundary and stops (ADR 007 addenda).
38
+ - `body` is part of the id key: paper and glass on one page never share an id.
39
+ - An arbitrary CSS colour pin on `die` frosts the glass verbatim, like `dieUnder` in paper.
40
+ - Library 8536 B gzipped, budget 8704 (ADR 006 addenda).
41
+
7
42
  ## 0.1.0 — 2026-11-16
8
43
 
9
44
  - First release. A throw of dice on a table as an SVG string: the projected rounded cube
@@ -15,5 +50,7 @@ bump.
15
50
  `'brand'` the leftover brand colour, `'felt'` no edge, any colour pins it (ADR 004 addendum).
16
51
  The dice gained edges: cut seams in quiet ink on the paper body, and `body: 'glass'` draws
17
52
  frosted acrylic — silhouette fill at 55%, outline seams, solid pips, no gradients emitted
18
- (ADR 007; the alpha measured by raster subtraction). Library 7596 B gzipped (budget raised
19
- to 7680, ADR 006 addendum); a `dice: 3` throw averages 9347 B raw / 2345 B gzip over 60 seeds.
53
+ (ADR 007; the alpha measured by raster subtraction). The seams were then trimmed to stop
54
+ where the corner rounding starts — nose and silhouette alike — after the square-front-corner
55
+ defect was caught on the cover image (ADR 007 addendum). Library 8536 B gzipped (budget
56
+ 8704, ADR 006 addendum); a `dice: 3` throw averages 9347 B raw / 2345 B gzip over 60 seeds.
package/README.md CHANGED
@@ -8,7 +8,7 @@ they show), **`brand`** colours the table.
8
8
  The dice are the classic ones — paper bodies, black pips, values one to six — each a rounded
9
9
  cube projected at runtime from its own seeded orientation: three visible faces, exact
10
10
  projected pips, opposite sides summing to seven by construction. A result such as a lucky
11
- seven is a named preset that places values; nothing is ever scored. Zero dependencies, ~7 KB
11
+ seven is a named preset that places values; nothing is ever scored. Zero dependencies, ~8.5 KB
12
12
  minified and gzipped.
13
13
 
14
14
  [![npm](https://img.shields.io/npm/v/@spintax/dice-lite.svg)](https://www.npmjs.com/package/@spintax/dice-lite)
package/dice.d.ts CHANGED
@@ -16,7 +16,7 @@ declare namespace Dice {
16
16
  interface Common {
17
17
  /** A string (a domain name is fine) or a number taken as a 32-bit unsigned integer. */
18
18
  seed?: number | string;
19
- /** hex or hex[]; default the spintax triad. */
19
+ /** `#rgb`/`#rrggbb` or `rgb()` — one or a list; default the spintax triad. Anything else (a named colour, `var()`) reads as white. */
20
20
  brand?: string | string[];
21
21
  /** derived colours only. */
22
22
  theme?: 'dark' | 'light';
@@ -35,7 +35,7 @@ declare namespace Dice {
35
35
  outline?: Pin;
36
36
  /** width; the height follows the viewBox. */
37
37
  size?: number;
38
- /** decimals for coordinates. */
38
+ /** decimals for the table's coordinates and the viewBox; the dice are always one decimal. */
39
39
  precision?: number;
40
40
  /** extra entropy for ids — the same picture twice on one page. */
41
41
  salt?: string;
package/dice.js CHANGED
@@ -16,10 +16,8 @@
16
16
 
17
17
  var NS = 'http://www.w3.org/2000/svg';
18
18
  var DEFAULT_BRAND = ['#00abf3', '#d6af3c', '#a91455'];
19
- // machine space: origin at the centre of the table, y down (spec: Machine space). The
20
- // constants are provisional — looked at on screen at M1/M2 and kept or changed there.
21
- // machine space: origin at the centre of the table, y down. The die is a rounded cube,
22
- // orthographic-baked (ADR 002 addendum); constants tuned to the reference at M1.
19
+ // machine space: origin at the centre of the table, y down (spec: Machine space). The die is
20
+ // a rounded cube, orthographic-baked (ADR 002 addendum); constants tuned to the reference at M1.
23
21
  var H = 100; // the die's half-edge — the cube is 2H on a side
24
22
  var PITCH = 0.91; // camera elevation ≈ 52°
25
23
  var RS = 44, RF = 9; // silhouette rounding / face-quad rounding (projection units)
@@ -186,7 +184,7 @@
186
184
  return { colors: stops, accent: accent, hot: hot, background: bg, halo: halo };
187
185
  }
188
186
 
189
- // ── colour: a casino table from the brand (ADR 004, provisional until M1) ──
187
+ // ── colour: a casino table from the brand (ADR 004 and its addenda) ─────
190
188
 
191
189
  // Dice claim almost no classic hues — the subject is paper and black — so the brand colours
192
190
  // go where a casino table puts them: the felt takes the first chromatic brand colour, the
@@ -217,7 +215,9 @@
217
215
  }
218
216
  if (goldD > 30) goldI = -1; // the window is ±30° around the gold centre
219
217
  var gold = goldI >= 0 ? chrom[goldI].lch : null;
220
- var trim = lch2rgb(66, grey || !chrom.length ? 0 : gold ? gold[1] * 0.5 : 25, gold ? gold[2] : 85);
218
+ // chrome only for an all-neutral brand: a neutral listed beside chromatic colours is
219
+ // ignored here, never a reason to drop the brass (ADR 004 addendum)
220
+ var trim = lch2rgb(66, !chrom.length ? 0 : gold ? gold[1] * 0.5 : 25, gold ? gold[2] : 85);
221
221
  // the dice are the classic: paper in both themes, near-black pips and shadows (cards'
222
222
  // stock/spade/ink formulas, the paper as their contrast reference)
223
223
  var die = lch2rgb(96.5, Math.min(bC * 0.08, 4), bH);
@@ -290,7 +290,7 @@
290
290
  // salt remains for the same picture twice.
291
291
  for (var k in r) key += k === 'stroke' ? '' : c.col(k);
292
292
  // normalised, so passing a default ('auto', '', []) is byte-identical to leaving it out
293
- key += c.cab + c.w + c.p + (o.lattice || 'auto');
293
+ key += c.cab + c.w + c.p + (o.lattice || 'auto') + (o.body === 'glass' ? 'g' : '');
294
294
  c.key = key;
295
295
  c.tk = tokens(S, (o.salt || '') + key);
296
296
  c.add = function (k, make) {
@@ -466,7 +466,12 @@
466
466
  el('filter', ['id', b5, 'x', '-60%', 'y', '-60%', 'width', '220%', 'height', '220%'], el('feGaussianBlur', ['stdDeviation', 5]));
467
467
  // a glass body draws no gradients: the frost is a flat fill, the pips solid — only
468
468
  // the shadows' blurs come out of the defs (ADR 007)
469
- if (glass) { c.dieGlass = colMix(die, 6); return blur; }
469
+ if (glass) {
470
+ // an arbitrary CSS pin is the frost verbatim, like dieUnder in paper — only a
471
+ // parseable colour can be lightened (spec: Pins)
472
+ c.dieGlass = t ? die : colMix(die, 6);
473
+ return blur;
474
+ }
470
475
  return g(gt, stops, ['.25', 0], ['.6', 1]) + g(gl, sl, ['.2', 0], ['.7', 1]) + g(gr, sr, ['.2', 0], ['.7', 1]) +
471
476
  el('radialGradient', ['id', gp, 'cx', '.31', 'cy', '.27', 'r', '.78'],
472
477
  el('stop', ['offset', 0, 'stop-color', esc(ps[0])]) + el('stop', ['offset', '.1', 'stop-color', esc(ps[1])]) +
@@ -536,19 +541,110 @@
536
541
  faces += face; // face and its pips stay one unit, far-to-near
537
542
  }
538
543
  var sid = c.tk(), cid = c.tk();
539
- // the seams: each pair of visible faces shares one cube edge — two matching true corners.
540
- // Open segments painted over the faces, each clipped to the silhouette, which cuts both
541
- // rounded ends. In paper they sit in their own clipped group above the airbrush; in
542
- // glass they ride the faces' clip
544
+ // the seams: each pair of visible faces shares one cube edge — two matching true corners
545
+ // (the drawn quads use HG = H + 2 and overlap on purpose, so they cannot serve). Open
546
+ // segments over the faces, both ends stopping where the corner rounding starts: a rounded
547
+ // cube's edges never reach the vertex, and lines that do make the front face read square
548
+ // against the rounded silhouette corners (the cover-image defect, ADR 007 addendum).
549
+ // At the nose the trim is rquad2's own tangent length on each adjacent wedge; at the
550
+ // silhouette the seam ends where it meets the rounded-corner Q-curve
551
+ var SP = [];
543
552
  for (i = 0; i < SEAMC.length; i++) for (var j2 = i + 1; j2 < SEAMC.length; j2++) {
544
553
  var A = SEAMC[i], B = SEAMC[j2], P = [];
545
554
  for (var a2 = 0; a2 < 4; a2++) for (var b2 = 0; b2 < 4; b2++) {
546
555
  var d2 = A[a2][0] - B[b2][0], d3 = A[a2][1] - B[b2][1];
547
556
  if (d2 * d2 + d3 * d3 < 0.01) { P.push(A[a2]); break; }
548
557
  }
549
- if (P.length === 2) seams += el('path', ['clip-path', glass ? null : 'url(#' + cid + ')',
550
- 'd', 'M' + n(P[0][0], 1) + ' ' + n(P[0][1], 1) +
551
- 'L' + n(P[1][0], 1) + ' ' + n(P[1][1], 1), 'fill', 'none',
558
+ if (P.length === 2) SP.push(P);
559
+ }
560
+ var nose = null;
561
+ if (SP.length === 3) for (var e0 = 0; e0 < 2 && !nose; e0++) {
562
+ var hits = 0;
563
+ for (var s0 = 0; s0 < 3; s0++) for (var e1 = 0; e1 < 2; e1++) {
564
+ var qx = SP[s0][e1][0] - SP[0][e0][0], qy = SP[s0][e1][1] - SP[0][e0][1];
565
+ if (qx * qx + qy * qy < 0.01) hits++;
566
+ }
567
+ if (hits === 3) nose = SP[0][e0];
568
+ }
569
+ var hp = hull2(corners), stops = [];
570
+ for (i = 0; i < SP.length; i++) {
571
+ var W = SP[i][0], V = SP[i][1];
572
+ if (nose) {
573
+ if (Math.abs(W[0] - nose[0]) + Math.abs(W[1] - nose[1]) > 0.1) { var sw = W; W = V; V = sw; }
574
+ var ux = V[0] - W[0], uy = V[1] - W[1], luv = Math.sqrt(ux * ux + uy * uy);
575
+ if (luv > 1e-6) {
576
+ var tn = Math.min(luv, RS);
577
+ for (var s1 = 0; s1 < 3; s1++) if (s1 !== i) {
578
+ var O = Math.abs(SP[s1][0][0] - W[0]) + Math.abs(SP[s1][0][1] - W[1]) < 0.1 ? SP[s1][1] : SP[s1][0];
579
+ var vx = O[0] - W[0], vy = O[1] - W[1];
580
+ var lw = Math.min(luv, Math.sqrt(vx * vx + vy * vy)) / 3;
581
+ if (lw < tn) tn = lw;
582
+ }
583
+ W = [W[0] + ux / luv * tn, W[1] + uy / luv * tn];
584
+ }
585
+ stops.push(W);
586
+ }
587
+ // the silhouette end: meet the rounded-corner Q-curve at V (rquad2's construction)
588
+ var vi = -1;
589
+ for (var h0 = 0; h0 < hp.length; h0++) {
590
+ var hx = hp[h0][0] - V[0], hy = hp[h0][1] - V[1];
591
+ if (hx * hx + hy * hy < 0.01) { vi = h0; break; }
592
+ }
593
+ if (vi >= 0) {
594
+ var pv = hp[(vi - 1 + hp.length) % hp.length], nx2 = hp[(vi + 1) % hp.length];
595
+ var ex = V[0] - pv[0], ey = V[1] - pv[1], fx = nx2[0] - V[0], fy = nx2[1] - V[1];
596
+ var le = Math.sqrt(ex * ex + ey * ey), lf = Math.sqrt(fx * fx + fy * fy);
597
+ var Dx = V[0] - W[0], Dy = V[1] - W[1], d2n = Dx * Dx + Dy * Dy;
598
+ if (le > 1e-6 && lf > 1e-6 && d2n > 1e-6) {
599
+ var kk = Math.min(RS, le / 3, lf / 3);
600
+ var m0 = [V[0] - ex / le * kk, V[1] - ey / le * kk], m1 = [V[0] + fx / lf * kk, V[1] + fy / lf * kk];
601
+ var c1 = m0[0], c2 = 2 * (V[0] - m0[0]), c3 = m0[0] - 2 * V[0] + m1[0];
602
+ var c4 = m0[1], c5 = 2 * (V[1] - m0[1]), c6 = m0[1] - 2 * V[1] + m1[1];
603
+ var qa = c3 * Dy - c6 * Dx, qb = c2 * Dy - c5 * Dx, qc = (c1 - W[0]) * Dy - (c4 - W[1]) * Dx;
604
+ var cand = [];
605
+ if (Math.abs(qa) < 1e-9) { if (Math.abs(qb) > 1e-9) { var t0 = -qc / qb; if (t0 > 0 && t0 < 1) cand.push(t0); } }
606
+ else {
607
+ var disc = qb * qb - 4 * qa * qc;
608
+ if (disc >= 0) {
609
+ var sq2 = Math.sqrt(disc);
610
+ for (var sg = -1; sg <= 1; sg += 2) {
611
+ var t1 = (-qb + sg * sq2) / (2 * qa);
612
+ if (t1 > 0 && t1 < 1) cand.push(t1);
613
+ }
614
+ }
615
+ }
616
+ // the crossing must lie ON the seam segment (s in 0..1 measured from W),
617
+ // and the exit nearest the corner wins — the other root sits on the line's
618
+ // extension, outside the silhouette
619
+ var best = null;
620
+ for (var ci = 0; ci < cand.length; ci++) {
621
+ var t2 = cand[ci];
622
+ var bx = c1 + t2 * c2 + t2 * t2 * c3 - W[0], by = c4 + t2 * c5 + t2 * t2 * c6 - W[1];
623
+ var ss = (bx * Dx + by * Dy) / d2n;
624
+ if (ss > 0 && ss < 1 && (best == null || ss > best)) best = ss;
625
+ }
626
+ // pull the end one stroke-width back inside the silhouette: a hairline gap
627
+ // reads as "the edge meets the boundary" and never merges into the outline
628
+ // — which matters most in glass, where bold seams cross overlapping dice
629
+ if (best != null) {
630
+ var gs = (glass ? 2.2 : 1.4) * c.w / Math.sqrt(d2n);
631
+ V = [W[0] + Dx * (best - gs), W[1] + Dy * (best - gs)];
632
+ }
633
+ }
634
+ }
635
+ seams += el('path', ['clip-path', glass ? null : 'url(#' + cid + ')',
636
+ 'd', 'M' + n(W[0], 1) + ' ' + n(W[1], 1) + 'L' + n(V[0], 1) + ' ' + n(V[1], 1), 'fill', 'none',
637
+ 'stroke', glass ? c.col('outline') : c.col('ink'),
638
+ 'stroke-opacity', glass ? null : '.15',
639
+ 'stroke-width', n((glass ? 2.2 : 1.4) * c.w, 1), 'stroke-linecap', 'round']);
640
+ }
641
+ // the nose corners: bare stops read as a ragged triple point, each face's corner still
642
+ // skewed — so every pair of stops joins through a small Q-arc, control at the nose
643
+ // (rquad2's own corner construction: tangent to both seams at any stop distance)
644
+ if (nose && stops.length === 3) for (i = 0; i < 3; i++) for (var j3 = i + 1; j3 < 3; j3++) {
645
+ seams += el('path', ['clip-path', glass ? null : 'url(#' + cid + ')',
646
+ 'd', 'M' + n(stops[i][0], 1) + ' ' + n(stops[i][1], 1) + 'Q' + n(nose[0], 1) + ' ' + n(nose[1], 1) +
647
+ ' ' + n(stops[j3][0], 1) + ' ' + n(stops[j3][1], 1), 'fill', 'none',
552
648
  'stroke', glass ? c.col('outline') : c.col('ink'),
553
649
  'stroke-opacity', glass ? null : '.15',
554
650
  'stroke-width', n((glass ? 2.2 : 1.4) * c.w, 1), 'stroke-linecap', 'round']);
@@ -558,10 +654,12 @@
558
654
  // own every paint, and its d is computed from the yaw, keeping zero-d honest
559
655
  c.defs += el('path', ['id', sid, 'd', sil]) + el('clipPath', ['id', cid], el('use', ['href', '#' + sid]));
560
656
  return {
657
+ // the contact shadow sits wholly under the body: a paper die hides every pixel of it
658
+ // (raster subtraction, 0.3.0), so only the see-through glass draws it
561
659
  shadow: el('ellipse', ['cx', 0, 'cy', 118, 'rx', 132, 'ry', 24, 'fill', c.col('ink'), 'fill-opacity', '.16', 'filter', 'url(#' + d.b14 + ')']) +
562
- el('ellipse', ['cx', 0, 'cy', 112, 'rx', 62, 'ry', 11, 'fill', c.col('ink'), 'fill-opacity', '.18', 'filter', 'url(#' + d.b5 + ')']),
660
+ (glass ? el('ellipse', ['cx', 0, 'cy', 112, 'rx', 62, 'ry', 11, 'fill', c.col('ink'), 'fill-opacity', '.18', 'filter', 'url(#' + d.b5 + ')']) : ''),
563
661
  content: glass
564
- ? el('use', ['href', '#' + sid, 'fill', c.dieGlass, 'fill-opacity', '.55', 'stroke', c.col('outline'), 'stroke-width', n(2.6 * c.w, 1)]) +
662
+ ? el('use', ['href', '#' + sid, 'fill', esc(c.dieGlass), 'fill-opacity', '.55', 'stroke', c.col('outline'), 'stroke-width', n(2.6 * c.w, 1)]) +
565
663
  el('g', ['clip-path', 'url(#' + cid + ')'], faces + seams)
566
664
  : el('use', ['href', '#' + sid, 'fill', esc(c.dieUnder)]) +
567
665
  el('g', ['clip-path', 'url(#' + cid + ')', 'filter', 'url(#' + d.sf + ')'], faces) +
@@ -575,17 +673,22 @@
575
673
 
576
674
  // The canonical slots: one nested list — count k takes the first k, so `dice` appends
577
675
  // without moving a die already on the table (values, yaws and placements all hold). The
578
- // pair is the constant core; the triangle, the diamond and the quincunx grow from it.
579
- var SLOTS = [[-1, 0], [1, 0], [0, -1], [0, 1], [0, 0]];
676
+ // pair is the constant core; the triangle and the diamond grow from it, and the fifth die
677
+ // stands front-right — never at the centre, where it stood half inside the pair (ADR 002
678
+ // addendum: every slot is at least one cube edge from the others on the ground)
679
+ var SLOTS = [[-1, 0], [1, 0], [0, -1], [0, 1], [1.65, 1.15]];
580
680
  var RESULTS = ['lucky7', 'snake', 'boxcars', 'matched', 'mixed'];
581
681
  var BELT7 = [[1, 6], [2, 5], [3, 4]];
582
682
 
583
683
  // Results are data (ADR 003): a name places values, nothing is scored. Each result reads
584
- // its own streams; dice it does not name keep the seed's values.
585
- function resultValue(r, i, S, used) {
684
+ // its own streams; dice it does not name keep the seed's values. `vals` holds the pins and
685
+ // the values placed so far: a result completes them, never overwrites them (ADR 003 addendum)
686
+ function resultValue(r, i, S, used, vals) {
586
687
  if (r === 'snake') return i < 2 ? 1 : 0;
587
688
  if (r === 'boxcars') return i < 2 ? 6 : 0;
588
689
  if (r === 'lucky7' && i < 2) {
690
+ // a placed partner — pinned, or drawn just before — is answered by its complement
691
+ if (vals[1 - i]) return 7 - vals[1 - i];
589
692
  // one pair draw for the throw, one swap draw — both dice name it
590
693
  if (!used.l7) {
591
694
  var p = BELT7[Math.floor(S('result:lucky7')() * 3)];
@@ -593,7 +696,11 @@
593
696
  }
594
697
  return used.l7[i];
595
698
  }
596
- if (r === 'matched') return 1 + Math.floor(S('result:matched')() * 6);
699
+ if (r === 'matched') {
700
+ // the first placed value — a pin anywhere, or the first die's draw — is the match
701
+ for (var m = 0; m < vals.length; m++) if (vals[m]) return vals[m];
702
+ return 1 + Math.floor(S('result:matched')() * 6);
703
+ }
597
704
  if (r === 'mixed') {
598
705
  var avail = [];
599
706
  for (var v = 1; v <= 6; v++) if (!used[v]) avail.push(v);
@@ -634,7 +741,7 @@
634
741
  }
635
742
  for (i = 0; i < k; i++) {
636
743
  if (values[i] != null) continue;
637
- if (res) { var rv = resultValue(res, i, S, used); values[i] = rv || seeded(i); }
744
+ if (res) { var rv = resultValue(res, i, S, used, values); values[i] = rv || seeded(i); }
638
745
  else values[i] = seeded(i);
639
746
  }
640
747
  // the roll (ADR 005 + addendum): a settle, off by default. Names from a stream of their
@@ -698,7 +805,7 @@
698
805
  var value = Math.round(o.value) >= 1 && Math.round(o.value) <= 6 ? Math.round(o.value) : 1 + Math.floor(S('die:0:value')() * 6);
699
806
  var yaw = (S('die:0:orient')() < 0.5 ? -1 : 1) * (YAW[0] + YAW[1] * S('die:0:orient:yaw')());
700
807
  var d = die(c, value, yaw);
701
- return wrap(o, c, [-HX, -HY, 2 * HX, 2 * HY + 42], el('g', ['transform', 'translate(0 0)'], d.shadow + d.content));
808
+ return wrap(o, c, [-HX, -HY, 2 * HX, 2 * HY + 42], d.shadow + d.content);
702
809
  }
703
810
 
704
811
  // Browser convenience: draw a throw into an element and keep it drawn. Options merge
package/dice.min.js CHANGED
@@ -7,4 +7,4 @@
7
7
  * The colour engine and the seed machinery are the family's, ported unchanged from cards-lite
8
8
  * (by way of slots-lite); a fixture test pins that they agree.
9
9
  */
10
- !function(t){var r=function(){"use strict";var t="http://www.w3.org/2000/svg",r=["#00abf3","#d6af3c","#a91455"],n=100,e=.91,a=44,o=9,i=19,l=n+2,u=[.36,.08],f=Math.sqrt(3),c=(2-Math.SQRT2)/2,s=[90,64],h=[22,34],d=126,v=.06,p=145,M=176;function g(t,r){var n=Math.pow(10,r||0),e=Math.round(t*n)/n;return String(0===e?0:e)}function m(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function y(t,r,n){for(var e="<"+t,a=0;a<r.length;a+=2)null!=r[a+1]&&(e+=" "+r[a]+'="'+r[a+1]+'"');return null==n?e+"/>":e+">"+n+"</"+t+">"}function k(t){for(var r=2166136261,n=0;n<t.length;n++)r=Math.imul(r^t.charCodeAt(n),16777619);return r>>>0}function x(t){return t=Math.imul(t^t>>>16,2246822507),((t=Math.imul(t^t>>>13,3266489909))^t>>>16)>>>0}function b(t){return function(){t=t+1831565813>>>0;var r=Math.imul(t^t>>>15,1|t);return(((r=r+Math.imul(r^r>>>7,61|r)^r)^r>>>14)>>>0)/4294967296}}function w(t){var r="number"==typeof t?t>>>0:k(String(t));return function(t){return b(x(r^Math.imul(k(t),2654435769)))}}function S(t){if("#"===(t=String(t).trim()).charAt(0)){var r=t.slice(1);3===r.length&&(r=r[0]+r[0]+r[1]+r[1]+r[2]+r[2]);var n=parseInt(r,16);return[n>>16&255,n>>8&255,255&n]}var e=t.match(/rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/);return e?[+e[1],+e[2],+e[3]]:[255,255,255]}function q(t){return"#"+((1<<24)+(t[0]<<16)+(t[1]<<8)+(0|t[2])).toString(16).slice(1)}function P(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function I(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function z(t){return t>216/24389?Math.pow(t,1/3):(24389/27*t+16)/116}function G(t){var r=t*t*t;return r>216/24389?r:27*(116*t-16)/24389}function j(t){var r=P(t[0]),n=P(t[1]),e=P(t[2]),a=.21267*r+.71515*n+.07218*e,o=(.01933*r+.11919*n+.9503*e)/1.08883,i=z((.41246*r+.35758*n+.18044*e)/.95047),l=z(a),u=500*(i-l),f=200*(l-z(o));return[116*l-16,Math.sqrt(u*u+f*f),(180*Math.atan2(f,u)/Math.PI+360)%360]}function L(t,r,n){var e=r*Math.cos(n*Math.PI/180),a=(t+16)/116,o=a-r*Math.sin(n*Math.PI/180)/200,i=.95047*G(a+e/500),l=G(a),u=1.08883*G(o);return[3.24045*i-1.53714*l-.49853*u,-.96927*i+1.87601*l+.04156*u,.05564*i-.20403*l+1.05723*u]}function O(t,r,n){var e,a=L(t,r,n),o=0,i=r;if(!A(a)){for(e=0;e<20;e++){var l=(o+i)/2;A(a=L(t,l,n))?o=l:i=l}a=L(t,o,n)}return[B(I(a[0])),B(I(a[1])),B(I(a[2]))]}function A(t){for(var r=0;r<3;r++)if(t[r]<-5e-4||t[r]>1.0005)return!1;return!0}function B(t){return Math.max(0,Math.min(255,Math.round(t)))}function D(t){return.2126*P(t[0])+.7152*P(t[1])+.0722*P(t[2])}function T(t,r){var n=D(t),e=D(r);return(Math.max(n,e)+.05)/(Math.min(n,e)+.05)}function U(t,r,n,e){if(T(t,r)>=n)return t;for(var a=j(t),o=a[0];o>=2&&o<=98;o+=2*e){var i=O(o,a[1],a[2]);if(T(i,r)>=n)return i}return t}function H(t,r){for(var n=("string"==typeof t?[t]:t).map(function(t){return j(S(t))}),e=[],a=0;a<n.length;a++)n[a][1]>=12&&e.push(n[a]);var o=0===e.length,i=o?[50,0,0]:e[0],l=e.length>1?e[1]:[0,i[1],(i[2]+40)%360],u=(e.length>2?e[2]:i)[2],f=i[1],c=i[2],s="light"===r,h=s?O(97,o?0:3,c):O(6,Math.min(.2*f,10),c),d=s?O(92,Math.min(.2*f,8),c):O(12,Math.min(.3*f,15),c),v=s?[72,52,32]:[32,58,82],p=s?-1:1;return{colors:[U(O(v[0],.9*f,c),h,1.5,p),U(O(v[1],f,c),h,2.5,p),U(O(v[2],.55*f,c),h,5,p)],accent:U(O(s?45:70,l[1],l[2]),h,3,p),hot:U(O(s?28:92,o?0:s?24:12,u),h,7,p),background:h,halo:d}}function Q(t,n,e){var a,o=null==t?r:"string"==typeof t?[t]:t,i=[],l=null;for(a=0;a<o.length;a++){var u=j(S(o[a]));u[1]>=12?i.push({lch:u,hex:o[a]}):l||(l=o[a])}var f="light"===n?"light":"dark",c=i.length?i[0].hex:l||"#00abf3",s=j(S(c)),h=s[1],d=s[2],v=H(c,f),p=-1,M=1/0;for(a=1;a<i.length;a++){var g=Math.abs(i[a].lch[2]-85)%360;(g=Math.min(g,360-g))<M&&(M=g,p=a)}M>30&&(p=-1);var m=p>=0?i[p].lch:null,y=O(66,l||!i.length?0:m?.5*m[1]:25,m?m[2]:85),k=O(96.5,Math.min(.08*h,4),d),x=U(O(14,Math.min(.15*h,6),d),k,7,-1),b=U(O(34,Math.min(.25*h,10),d),k,3,-1),w=null;for(a=1;a<i.length;a++)if(a!==p){w=i[a].hex;break}var q="brand"===e?w?S(w):v.colors["light"===f?2:0]:"felt"===e?S(c):x,P=H(o,f);return{felt:S(c),rail:q,trim:y,die:k,pip:x,ink:b,outline:v.colors[1],stroke:P.colors,background:P.background,halo:P.halo}}function C(t,r){var n=r&&r.rail,e=Q(t,r&&r.theme,n),a={};for(var o in e)a[o]="stroke"===o?e[o].map(q):q(e[o]);return null!=n&&"auto"!==n&&"brand"!==n&&"felt"!==n&&(a.rail=n),a}function R(t,r){var n=t("ids"+(r||"")),e={},a="abcdefghijklmnopqrstuvwxyz",o=a+"0123456789";return function(){var t;do{t=a.charAt(Math.floor(26*n()));for(var r=0;r<5;r++)t+=o.charAt(Math.floor(36*n()))}while(e[t]);return e[t]=1,t}}function Y(t,r){var n=w(null==t.seed?1:t.seed),e=Q(t.brand,t.theme,t.rail),a={},o=r,i={o:t,S:n,defs:"",p:null==t.precision?0:t.precision,w:null==t.weight?1:t.weight,cab:t.style?"line"!==t.style:"light"!==t.theme,col:function(r){var n=t[r];return null!=n&&"auto"!==n&&("rail"!==r||"brand"!==n&&"felt"!==n)?m(n):q(e[r])}};for(var l in e)o+="stroke"===l?"":i.col(l);return o+=i.cab+i.w+i.p+(t.lattice||"auto"),i.key=o,i.tk=R(n,(t.salt||"")+o),i.add=function(t,r){if(!a[t]){var n,e=i.tk();a[t]=e,n=r(),i.defs+=n.replace('"%"','"'+e+'"')}return a[t]},i}function Z(r,n,e,a){var o=r.title?["role","img","aria-label",m(r.title)]:["aria-hidden","true"],i=e.map(function(t){return g(t,n.p)}).join(" ");return y("svg",["xmlns",t,"viewBox",i,"width",null==r.size?null:g(r.size),"height",null==r.size?null:g(r.size*e[3]/e[2])].concat(o),(n.defs?y("defs",[],n.defs):"")+a)}function $(t,r,n){var e=[],a=function(t){return Math.round(1e3*t)/1e3},o=function(t,r,o,i){e.push(n?"M"+a(r)+" "+a(t)+"L"+a(i)+" "+a(o):"M"+a(t)+" "+a(r)+"L"+a(o)+" "+a(i))};if("trigon"===t)o(0,0,r,0),o(0,r,r,r),o(0,0,0,r),o(r,0,r,r),o(r,0,0,r);else if("octagon"===t){var i=c*r;o(i,0,r-i,0),o(i,r,r-i,r),o(0,i,0,r-i),o(r,i,r,r-i),o(r-i,0,r,i),o(r,r-i,r-i,r),o(i,r,0,r-i),o(0,i,i,0)}else{var l=r/f;(function(t,r,n){for(var e=f/2*n,a=[[t,r-n],[t+e,r-n/2],[t+e,r+n/2],[t,r+n],[t-e,r+n/2],[t-e,r-n/2]],i=0;i<6;i++)o(a[i][0],a[i][1],a[(i+1)%6][0],a[(i+1)%6][1])})(r/2,l,l),o(r/2,2*l,r/2,3*l)}return e.join("")}var E=["trigon","octagon","hex"];function F(t,r,n){var e=t.S,a=t.o;if("none"===a.lattice)return["fill","none"];var o=E.indexOf(a.lattice)>=0?a.lattice:E[Math.floor(3*e("table:lattice")())],i=22+22*e("table:pitch")(),l="hex"===o&&e("table:orient")()<.5,u="hex"===o?i/f*3:i;return["fill","url(#"+t.add("tile"+r+n,function(){return y("pattern",["id","%","patternUnits","userSpaceOnUse","width",g(l?u:i,2),"height",g(l?i:u,2),"patternTransform","translate("+g(i*e("table:phase")(),2)+" "+g(i*e("table:phase2")(),2)+") rotate("+g(90*e("table:turn")(),2)+")"],y("path",["d",$(o,i,l),"fill","none","stroke",r,"stroke-width",g((1+1.4*e("table:weight")())*t.w,2),"stroke-opacity",n]))})+")"]}var J=function(t,r){var n=Math.cos(r),e=Math.sin(r);return[t[0]*n+t[2]*e,t[1],-t[0]*e+t[2]*n]},K=function(t,r){var n=Math.cos(r),e=Math.sin(r);return[t[0],t[1]*n-t[2]*e,t[1]*e+t[2]*n]},N=function(t,r,n){return[t[0]+r[0]*(null==n?1:n),t[1]+r[1]*(null==n?1:n),t[2]+r[2]*(null==n?1:n)]},V=function(t,r){return[t[1]*r[2]-t[2]*r[1],t[2]*r[0]-t[0]*r[2],t[0]*r[1]-t[1]*r[0]]},W=function(t){var r=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2])||1;return[t[0]/r,t[1]/r,t[2]/r]},X=[{n:[0,1,0],c:[0,n,0],u:[1,0,0],v:[0,0,1],val:1},{n:[0,-1,0],c:[0,-n,0],u:[1,0,0],v:[0,0,-1],val:6},{n:[0,0,1],c:[0,0,n],u:[1,0,0],v:[0,1,0],val:2},{n:[0,0,-1],c:[0,0,-n],u:[-1,0,0],v:[0,1,0],val:5},{n:[1,0,0],c:[n,0,0],u:[0,0,-1],v:[0,1,0],val:3},{n:[-1,0,0],c:[-n,0,0],u:[0,0,1],v:[0,1,0],val:4}],_=function(t,r){var n=Math.cos(r),e=Math.sin(r);return[t[0]*n-t[1]*e,t[0]*e+t[1]*n,t[2]]},tt={1:function(t){return t},6:function(t){return K(t,Math.PI)},2:function(t){return K(t,-Math.PI/2)},5:function(t){return K(t,Math.PI/2)},3:function(t){return _(t,Math.PI/2)},4:function(t){return _(t,-Math.PI/2)}},rt={1:[[0,0]],2:[[-1,-1],[1,1]],3:[[-1,-1],[0,0],[1,1]],4:[[-1,-1],[1,-1],[-1,1],[1,1]],5:[[-1,-1],[1,-1],[0,0],[-1,1],[1,1]],6:[[-1,-1.25],[1,-1.25],[-1,0],[1,0],[-1,1.25],[1,1.25]]};function nt(t){var r,n=t.slice().sort(function(t,r){return t[0]-r[0]||t[1]-r[1]}),e=[],a=[],o=function(t,r,n){return(r[0]-t[0])*(n[1]-t[1])-(r[1]-t[1])*(n[0]-t[0])};for(r=0;r<n.length;r++){for(;e.length>=2&&o(e[e.length-2],e[e.length-1],n[r])<=1e-8;)e.pop();e.push(n[r])}for(r=n.length-1;r>=0;r--){for(;a.length>=2&&o(a[a.length-2],a[a.length-1],n[r])<=1e-8;)a.pop();a.push(n[r])}return e.slice(0,-1).concat(a.slice(0,-1))}function et(t,r){var n,e="";for(n=0;n<t.length;n++){var a=t[(n-1+t.length)%t.length],o=t[n],i=t[(n+1)%t.length],l=Math.sqrt((o[0]-a[0])*(o[0]-a[0])+(o[1]-a[1])*(o[1]-a[1])),u=Math.sqrt((i[0]-o[0])*(i[0]-o[0])+(i[1]-o[1])*(i[1]-o[1]));if(!(l<1e-6||u<1e-6)){var f=Math.min(r,l/3,u/3),c=[o[0]-(o[0]-a[0])/l*f,o[1]-(o[1]-a[1])/l*f],s=[o[0]+(i[0]-o[0])/u*f,o[1]+(i[1]-o[1])/u*f];e+=(n?"L"+g(c[0],1)+" "+g(c[1],1):"M"+g(c[0],1)+" "+g(c[1],1))+"Q"+g(o[0],1)+" "+g(o[1],1)+" "+g(s[0],1)+" "+g(s[1],1)}}return e+"Z"}function at(t){var r=function(t,r){var n=j(S(t));return q(O(Math.max(2,Math.min(99,n[0]+r)),n[1],n[2]))},n=function(t){return/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i.test(t)||/^rgba?\(\s*[\d.]+[\s,]+[\d.]+[\s,]+[\d.]+/i.test(t)},e=t.o.die&&"auto"!==t.o.die?t.o.die:t.col("die"),a=t.o.pip&&"auto"!==t.o.pip?t.o.pip:t.col("pip"),o=!n(e),i=!n(a),l=o?[e,e,e]:[r(e,14),r(e,5),e],u=o?[e,e,e]:[r(e,4),e,r(e,-11)],f=o?[e,e,e]:[e,r(e,-13),r(e,-21)],c=i?[a,a,a,a]:[r(a,24),r(a,9),a,r(a,-9)],s=function(t,r,n,e){var a,o="";for(a=0;a<r.length;a++)o+=y("stop",["offset",0===a?0:g(a/(r.length-1),2),"stop-color",m(r[a])]);return y("linearGradient",["id",t,"x1",n[0],"y1",n[1],"x2",e[0],"y2",e[1]],o)},h="glass"===t.o.body;return t.add("dice:defs",function(){var n=t.tk(),a=t.tk(),i=t.tk(),d=t.tk(),v=t.tk(),p=t.tk(),M=t.tk(),g=t.tk();t.die={t:n,l:a,r:i,p:d,a:v,b14:p,b5:M,sf:g},t.dieUnder=o?e:r(e,-20);var k=y("filter",["id",p,"x","-60%","y","-60%","width","220%","height","220%"],y("feGaussianBlur",["stdDeviation",14]))+y("filter",["id",M,"x","-60%","y","-60%","width","220%","height","220%"],y("feGaussianBlur",["stdDeviation",5]));return h?(t.dieGlass=r(e,6),k):s(n,l,[".25",0],[".6",1])+s(a,u,[".2",0],[".7",1])+s(i,f,[".2",0],[".7",1])+y("radialGradient",["id",d,"cx",".31","cy",".27","r",".78"],y("stop",["offset",0,"stop-color",m(c[0])])+y("stop",["offset",".1","stop-color",m(c[1])])+y("stop",["offset",".35","stop-color",m(c[2])])+y("stop",["offset",1,"stop-color",m(c[3])]))+y("radialGradient",["id",v,"cx",".34","cy",".24","r",".88"],y("stop",["offset",0,"stop-color","#fff","stop-opacity",".22"])+y("stop",["offset",".48","stop-color","#fff","stop-opacity",".04"])+y("stop",["offset",".72","stop-color","#000","stop-opacity",0])+y("stop",["offset",1,"stop-color","#000","stop-opacity",".09"]))+k+y("filter",["id",g,"x","-20%","y","-20%","width","140%","height","140%"],y("feGaussianBlur",["stdDeviation",1.4]))})}function ot(t,r,u){var f,c=tt[r],s=[],h="glass"===t.o.body;for(f=0;f<6;f++){var d=X[f];s.push({c:c(d.c),u:c(d.u),v:c(d.v),n:c(d.n),val:d.val})}var v=function(t){var r=K(J(t,u),e);return[r[0],-r[1]]},p=function(t){var r=K(t,e);return[r[0],-r[1]]},M=[];for(f=0;f<8;f++)M.push(v(c([1&f?n:-n,2&f?n:-n,4&f?n:-n])));var k=et(nt(M),a),x=t.die,b=[];for(f=0;f<6;f++){var w=K(J(s[f].n,u),e);w[2]>.02&&b.push({f:s[f],rn:w,z:w[2]})}b.sort(function(t,r){return t.z-r.z});var S=[0,Math.sin(e),Math.cos(e)],q="",P="",I="",z=[];for(f=0;f<b.length;f++){var G,j=b[f].f,L=[],O=[];for(G=0;G<4;G++){var A=1===G||2===G?1:-1,B=G>=2?1:-1;L.push(v(N(N(j.c,j.u,A*l),j.v,B*l))),O.push(v(N(N(j.c,j.u,A*n),j.v,B*n)))}z.push(O),P=h?"":y("path",["d",et(L,o),"fill","url(#"+(b[f].rn[1]>.4?x.t:b[f].rn[0]>0?x.r:x.l)+")"]);var D=J(j.n,u),T=W(V(D,S)),U=W(V(D,T)),H=rt[j.val];for(G=0;G<H.length;G++){var Q=J(N(N(j.c,j.u,H[G][0]*n/3),j.v,H[G][1]*n/3),u),C=p(Q),R=p(N(Q,T,i)),Y=p(N(Q,U,i)),Z=[R[0]-C[0],R[1]-C[1]];P+=y("ellipse",["cx",g(C[0],1),"cy",g(C[1],1),"rx",g(Math.sqrt(Z[0]*Z[0]+Z[1]*Z[1]),1),"ry",g(Math.sqrt((Y[0]-C[0])*(Y[0]-C[0])+(Y[1]-C[1])*(Y[1]-C[1])),1),"transform","rotate("+g(180*Math.atan2(Z[1],Z[0])/Math.PI,1)+" "+g(C[0],1)+" "+g(C[1],1)+")","fill",h?t.col("pip"):"url(#"+x.p+")"])}q+=P}var $=t.tk(),E=t.tk();for(f=0;f<z.length;f++)for(var F=f+1;F<z.length;F++){for(var _=z[f],at=z[F],ot=[],it=0;it<4;it++)for(var lt=0;lt<4;lt++){var ut=_[it][0]-at[lt][0],ft=_[it][1]-at[lt][1];if(ut*ut+ft*ft<.01){ot.push(_[it]);break}}2===ot.length&&(I+=y("path",["clip-path",h?null:"url(#"+E+")","d","M"+g(ot[0][0],1)+" "+g(ot[0][1],1)+"L"+g(ot[1][0],1)+" "+g(ot[1][1],1),"fill","none","stroke",h?t.col("outline"):t.col("ink"),"stroke-opacity",h?null:".15","stroke-width",g((h?2.2:1.4)*t.w,1),"stroke-linecap","round"]))}return t.defs+=y("path",["id",$,"d",k])+y("clipPath",["id",E],y("use",["href","#"+$])),{shadow:y("ellipse",["cx",0,"cy",118,"rx",132,"ry",24,"fill",t.col("ink"),"fill-opacity",".16","filter","url(#"+x.b14+")"])+y("ellipse",["cx",0,"cy",112,"rx",62,"ry",11,"fill",t.col("ink"),"fill-opacity",".18","filter","url(#"+x.b5+")"]),content:h?y("use",["href","#"+$,"fill",t.dieGlass,"fill-opacity",".55","stroke",t.col("outline"),"stroke-width",g(2.6*t.w,1)])+y("g",["clip-path","url(#"+E+")"],q+I):y("use",["href","#"+$,"fill",m(t.dieUnder)])+y("g",["clip-path","url(#"+E+")","filter","url(#"+x.sf+")"],q)+y("use",["href","#"+$,"fill","url(#"+x.a+")"])+y("use",["href","#"+$,"fill","none","stroke","#00000010","stroke-width",2])+I}}var it=[[-1,0],[1,0],[0,-1],[0,1],[0,0]],lt=["lucky7","snake","boxcars","matched","mixed"],ut=[[1,6],[2,5],[3,4]];function ft(t,r,n,e){if("snake"===t)return r<2?1:0;if("boxcars"===t)return r<2?6:0;if("lucky7"===t&&r<2){if(!e.l7){var a=ut[Math.floor(3*n("result:lucky7")())];e.l7=n("result:lucky7:swap")()<.5?a:[a[1],a[0]]}return e.l7[r]}if("matched"===t)return 1+Math.floor(6*n("result:matched")());if("mixed"===t){for(var o=[],i=1;i<=6;i++)e[i]||o.push(i);var l=o[Math.floor(n("result:mixed:"+r)()*o.length)];return e[l]=1,l}return 0}function ct(t){var r,n=t||{},e=Math.max(2,Math.min(5,Math.round(n.dice)||3)),a=Y(n,"table"+e),o=a.p,i=a.S;at(a);var l=0,f=0;for(r=0;r<e;r++)l=Math.max(l,Math.abs(it[r][0])),f=Math.max(f,Math.abs(it[r][1]));var c=l*d+p,m=f*d+M,k=h[0]+(h[1]-h[0])*i("table:rail")(),x=28+40*i("table:corner")(),b=a.cab,w=a.col("outline"),S=a.col("trim"),q=g(4*a.w,2),P=function(t){return b?["fill",t]:["fill","none","stroke",w,"stroke-width",q]},I=function(t,r,n,e,a,i){return y("rect",["x",g(t,o),"y",g(r,o),"width",g(n,o),"height",g(e,o),"rx",a?g(a,o):null].concat(i))},z=n.values||[],G=lt.indexOf(n.result)>=0?n.result:"",j={},L=function(t){return 1+Math.floor(6*i("die:"+t+":value")())},O=[];for(r=0;r<e;r++){var A=Math.round(z[r]);A>=1&&A<=6&&(O[r]=A,j[A]=1)}for(r=0;r<e;r++)if(null==O[r])if(G){var B=ft(G,r,i,j);O[r]=B||L(r)}else O[r]=L(r);var D=null==n.speed?1:n.speed,T=!!n.motion&&D>0,U="",H=null;T&&(H=R(i,"motion"+(n.salt||"")+a.key+D));var Q=[];for(r=0;r<e;r++){var C=(i("die:"+r+":orient")()<.5?-1:1)*(u[0]+u[1]*i("die:"+r+":orient:yaw")()),$=it[r][0]*d+2*(i("die:"+r+":place")()-.5)*v*d,E=it[r][1]*d+2*(i("die:"+r+":place:v")()-.5)*v*d,J=.9+.1*(it[r][1]+1)/2,K="translate("+g($,1)+" "+g(E,1)+")"+(1!==J?" scale("+J+")":""),N=ot(a,O[r],C),V=N.content,W=null;if(T){var X=H(),_=30+40*i("die:"+r+":drop")();W=H(),U+="@keyframes "+X+"{from{transform:translateY("+g(-_,1)+"px)}}."+W+"{animation:"+X+" "+g((.8+.3*r)/D,2)+"s cubic-bezier(.2,.7,.3,1.08)}",V=y("g",["class",W],V)}Q.push({x:$,y:E,cls:W,shadow:y("g",["transform",K],N.shadow),body:y("g",["transform",K],V)})}Q.sort(function(t,r){return t.y-r.y});var tt="",rt="";for(r=0;r<e;r++)tt+=Q[r].shadow,rt+=Q[r].body;for(r=0;r<e;r++)for(var nt=r+1;nt<e;nt++){var et=Q[r].x-Q[nt].x,ut=Q[r].y-Q[nt].y;Math.sqrt(et*et+ut*ut)<240&&(tt+=y("ellipse",["cx",g((Q[r].x+Q[nt].x)/2,1),"cy",g((Q[r].y+Q[nt].y)/2+54,1),"rx",36,"ry",9,"fill",a.col("ink"),"fill-opacity",".14","filter","url(#"+a.die.b5+")"]))}var ct="";if(T){var st=[];for(r=0;r<e;r++)Q[r].cls&&st.push("."+Q[r].cls);ct=y("style",[],U+"@media(prefers-reduced-motion:reduce){"+st.join(",")+"{animation:none}}")}return ct+=I(-c-k,-m-k,2*(c+k),2*(m+k),x,P(a.col("rail"))),ct+=I(-c,-m,2*c,2*m,Math.max(0,x-k),P(a.col("felt"))),ct+=I(-c,-m,2*c,2*m,Math.max(0,x-k),F(a,S,".25")),ct+=tt+rt,Z(n,a,[-c-s[0],-m-s[1],2*(c+s[0]),2*(m+s[1])],ct)}function st(t){var r=t||{},n=Y(r,"die"),e=n.S;at(n);var a=ot(n,Math.round(r.value)>=1&&Math.round(r.value)<=6?Math.round(r.value):1+Math.floor(6*e("die:0:value")()),(e("die:0:orient")()<.5?-1:1)*(u[0]+u[1]*e("die:0:orient:yaw")()));return Z(r,n,[-p,-M,2*p,2*M+42],y("g",["transform","translate(0 0)"],a.shadow+a.content))}function ht(t,r){var n="string"==typeof t?document.querySelector(t):t,e={};if(!n)return null;var a=function(t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);n.innerHTML=ct(e)};return a(r||{}),{el:n,get:function(){var t={};for(var r in e)t[r]=e[r];return t},set:a,destroy:function(){n.innerHTML=""}}}return{toss:ct,die:st,palette:C,init:ht}}();"object"==typeof module&&module.exports?module.exports=r:t.Dice=r}("undefined"!=typeof self?self:this);
10
+ !function(t){var r=function(){"use strict";var t="http://www.w3.org/2000/svg",r=["#00abf3","#d6af3c","#a91455"],n=100,e=.91,a=44,o=9,i=19,l=n+2,u=[.36,.08],f=Math.sqrt(3),h=(2-Math.SQRT2)/2,s=[90,64],c=[22,34],v=126,d=.06,p=145,M=176;function g(t,r){var n=Math.pow(10,r||0),e=Math.round(t*n)/n;return String(0===e?0:e)}function m(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function y(t,r,n){for(var e="<"+t,a=0;a<r.length;a+=2)null!=r[a+1]&&(e+=" "+r[a]+'="'+r[a+1]+'"');return null==n?e+"/>":e+">"+n+"</"+t+">"}function b(t){for(var r=2166136261,n=0;n<t.length;n++)r=Math.imul(r^t.charCodeAt(n),16777619);return r>>>0}function k(t){return t=Math.imul(t^t>>>16,2246822507),((t=Math.imul(t^t>>>13,3266489909))^t>>>16)>>>0}function x(t){return function(){t=t+1831565813>>>0;var r=Math.imul(t^t>>>15,1|t);return(((r=r+Math.imul(r^r>>>7,61|r)^r)^r>>>14)>>>0)/4294967296}}function w(t){var r="number"==typeof t?t>>>0:b(String(t));return function(t){return x(k(r^Math.imul(b(t),2654435769)))}}function q(t){if("#"===(t=String(t).trim()).charAt(0)){var r=t.slice(1);3===r.length&&(r=r[0]+r[0]+r[1]+r[1]+r[2]+r[2]);var n=parseInt(r,16);return[n>>16&255,n>>8&255,255&n]}var e=t.match(/rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/);return e?[+e[1],+e[2],+e[3]]:[255,255,255]}function S(t){return"#"+((1<<24)+(t[0]<<16)+(t[1]<<8)+(0|t[2])).toString(16).slice(1)}function P(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function I(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function z(t){return t>216/24389?Math.pow(t,1/3):(24389/27*t+16)/116}function G(t){var r=t*t*t;return r>216/24389?r:27*(116*t-16)/24389}function j(t){var r=P(t[0]),n=P(t[1]),e=P(t[2]),a=.21267*r+.71515*n+.07218*e,o=(.01933*r+.11919*n+.9503*e)/1.08883,i=z((.41246*r+.35758*n+.18044*e)/.95047),l=z(a),u=500*(i-l),f=200*(l-z(o));return[116*l-16,Math.sqrt(u*u+f*f),(180*Math.atan2(f,u)/Math.PI+360)%360]}function L(t,r,n){var e=r*Math.cos(n*Math.PI/180),a=(t+16)/116,o=a-r*Math.sin(n*Math.PI/180)/200,i=.95047*G(a+e/500),l=G(a),u=1.08883*G(o);return[3.24045*i-1.53714*l-.49853*u,-.96927*i+1.87601*l+.04156*u,.05564*i-.20403*l+1.05723*u]}function O(t,r,n){var e,a=L(t,r,n),o=0,i=r;if(!A(a)){for(e=0;e<20;e++){var l=(o+i)/2;A(a=L(t,l,n))?o=l:i=l}a=L(t,o,n)}return[B(I(a[0])),B(I(a[1])),B(I(a[2]))]}function A(t){for(var r=0;r<3;r++)if(t[r]<-5e-4||t[r]>1.0005)return!1;return!0}function B(t){return Math.max(0,Math.min(255,Math.round(t)))}function D(t){return.2126*P(t[0])+.7152*P(t[1])+.0722*P(t[2])}function T(t,r){var n=D(t),e=D(r);return(Math.max(n,e)+.05)/(Math.min(n,e)+.05)}function U(t,r,n,e){if(T(t,r)>=n)return t;for(var a=j(t),o=a[0];o>=2&&o<=98;o+=2*e){var i=O(o,a[1],a[2]);if(T(i,r)>=n)return i}return t}function Q(t,r){for(var n=("string"==typeof t?[t]:t).map(function(t){return j(q(t))}),e=[],a=0;a<n.length;a++)n[a][1]>=12&&e.push(n[a]);var o=0===e.length,i=o?[50,0,0]:e[0],l=e.length>1?e[1]:[0,i[1],(i[2]+40)%360],u=(e.length>2?e[2]:i)[2],f=i[1],h=i[2],s="light"===r,c=s?O(97,o?0:3,h):O(6,Math.min(.2*f,10),h),v=s?O(92,Math.min(.2*f,8),h):O(12,Math.min(.3*f,15),h),d=s?[72,52,32]:[32,58,82],p=s?-1:1;return{colors:[U(O(d[0],.9*f,h),c,1.5,p),U(O(d[1],f,h),c,2.5,p),U(O(d[2],.55*f,h),c,5,p)],accent:U(O(s?45:70,l[1],l[2]),c,3,p),hot:U(O(s?28:92,o?0:s?24:12,u),c,7,p),background:c,halo:v}}function H(t,n,e){var a,o=null==t?r:"string"==typeof t?[t]:t,i=[],l=null;for(a=0;a<o.length;a++){var u=j(q(o[a]));u[1]>=12?i.push({lch:u,hex:o[a]}):l||(l=o[a])}var f="light"===n?"light":"dark",h=i.length?i[0].hex:l||"#00abf3",s=j(q(h)),c=s[1],v=s[2],d=Q(h,f),p=-1,M=1/0;for(a=1;a<i.length;a++){var g=Math.abs(i[a].lch[2]-85)%360;(g=Math.min(g,360-g))<M&&(M=g,p=a)}M>30&&(p=-1);var m=p>=0?i[p].lch:null,y=O(66,i.length?m?.5*m[1]:25:0,m?m[2]:85),b=O(96.5,Math.min(.08*c,4),v),k=U(O(14,Math.min(.15*c,6),v),b,7,-1),x=U(O(34,Math.min(.25*c,10),v),b,3,-1),w=null;for(a=1;a<i.length;a++)if(a!==p){w=i[a].hex;break}var S="brand"===e?w?q(w):d.colors["light"===f?2:0]:"felt"===e?q(h):k,P=Q(o,f);return{felt:q(h),rail:S,trim:y,die:b,pip:k,ink:x,outline:d.colors[1],stroke:P.colors,background:P.background,halo:P.halo}}function C(t,r){var n=r&&r.rail,e=H(t,r&&r.theme,n),a={};for(var o in e)a[o]="stroke"===o?e[o].map(S):S(e[o]);return null!=n&&"auto"!==n&&"brand"!==n&&"felt"!==n&&(a.rail=n),a}function R(t,r){var n=t("ids"+(r||"")),e={},a="abcdefghijklmnopqrstuvwxyz",o=a+"0123456789";return function(){var t;do{t=a.charAt(Math.floor(26*n()));for(var r=0;r<5;r++)t+=o.charAt(Math.floor(36*n()))}while(e[t]);return e[t]=1,t}}function Y(t,r){var n=w(null==t.seed?1:t.seed),e=H(t.brand,t.theme,t.rail),a={},o=r,i={o:t,S:n,defs:"",p:null==t.precision?0:t.precision,w:null==t.weight?1:t.weight,cab:t.style?"line"!==t.style:"light"!==t.theme,col:function(r){var n=t[r];return null!=n&&"auto"!==n&&("rail"!==r||"brand"!==n&&"felt"!==n)?m(n):S(e[r])}};for(var l in e)o+="stroke"===l?"":i.col(l);return o+=i.cab+i.w+i.p+(t.lattice||"auto")+("glass"===t.body?"g":""),i.key=o,i.tk=R(n,(t.salt||"")+o),i.add=function(t,r){if(!a[t]){var n,e=i.tk();a[t]=e,n=r(),i.defs+=n.replace('"%"','"'+e+'"')}return a[t]},i}function Z(r,n,e,a){var o=r.title?["role","img","aria-label",m(r.title)]:["aria-hidden","true"],i=e.map(function(t){return g(t,n.p)}).join(" ");return y("svg",["xmlns",t,"viewBox",i,"width",null==r.size?null:g(r.size),"height",null==r.size?null:g(r.size*e[3]/e[2])].concat(o),(n.defs?y("defs",[],n.defs):"")+a)}function $(t,r,n){var e=[],a=function(t){return Math.round(1e3*t)/1e3},o=function(t,r,o,i){e.push(n?"M"+a(r)+" "+a(t)+"L"+a(i)+" "+a(o):"M"+a(t)+" "+a(r)+"L"+a(o)+" "+a(i))};if("trigon"===t)o(0,0,r,0),o(0,r,r,r),o(0,0,0,r),o(r,0,r,r),o(r,0,0,r);else if("octagon"===t){var i=h*r;o(i,0,r-i,0),o(i,r,r-i,r),o(0,i,0,r-i),o(r,i,r,r-i),o(r-i,0,r,i),o(r,r-i,r-i,r),o(i,r,0,r-i),o(0,i,i,0)}else{var l=r/f;(function(t,r,n){for(var e=f/2*n,a=[[t,r-n],[t+e,r-n/2],[t+e,r+n/2],[t,r+n],[t-e,r+n/2],[t-e,r-n/2]],i=0;i<6;i++)o(a[i][0],a[i][1],a[(i+1)%6][0],a[(i+1)%6][1])})(r/2,l,l),o(r/2,2*l,r/2,3*l)}return e.join("")}var E=["trigon","octagon","hex"];function F(t,r,n){var e=t.S,a=t.o;if("none"===a.lattice)return["fill","none"];var o=E.indexOf(a.lattice)>=0?a.lattice:E[Math.floor(3*e("table:lattice")())],i=22+22*e("table:pitch")(),l="hex"===o&&e("table:orient")()<.5,u="hex"===o?i/f*3:i;return["fill","url(#"+t.add("tile"+r+n,function(){return y("pattern",["id","%","patternUnits","userSpaceOnUse","width",g(l?u:i,2),"height",g(l?i:u,2),"patternTransform","translate("+g(i*e("table:phase")(),2)+" "+g(i*e("table:phase2")(),2)+") rotate("+g(90*e("table:turn")(),2)+")"],y("path",["d",$(o,i,l),"fill","none","stroke",r,"stroke-width",g((1+1.4*e("table:weight")())*t.w,2),"stroke-opacity",n]))})+")"]}var J=function(t,r){var n=Math.cos(r),e=Math.sin(r);return[t[0]*n+t[2]*e,t[1],-t[0]*e+t[2]*n]},K=function(t,r){var n=Math.cos(r),e=Math.sin(r);return[t[0],t[1]*n-t[2]*e,t[1]*e+t[2]*n]},N=function(t,r,n){return[t[0]+r[0]*(null==n?1:n),t[1]+r[1]*(null==n?1:n),t[2]+r[2]*(null==n?1:n)]},V=function(t,r){return[t[1]*r[2]-t[2]*r[1],t[2]*r[0]-t[0]*r[2],t[0]*r[1]-t[1]*r[0]]},W=function(t){var r=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2])||1;return[t[0]/r,t[1]/r,t[2]/r]},X=[{n:[0,1,0],c:[0,n,0],u:[1,0,0],v:[0,0,1],val:1},{n:[0,-1,0],c:[0,-n,0],u:[1,0,0],v:[0,0,-1],val:6},{n:[0,0,1],c:[0,0,n],u:[1,0,0],v:[0,1,0],val:2},{n:[0,0,-1],c:[0,0,-n],u:[-1,0,0],v:[0,1,0],val:5},{n:[1,0,0],c:[n,0,0],u:[0,0,-1],v:[0,1,0],val:3},{n:[-1,0,0],c:[-n,0,0],u:[0,0,1],v:[0,1,0],val:4}],_=function(t,r){var n=Math.cos(r),e=Math.sin(r);return[t[0]*n-t[1]*e,t[0]*e+t[1]*n,t[2]]},tt={1:function(t){return t},6:function(t){return K(t,Math.PI)},2:function(t){return K(t,-Math.PI/2)},5:function(t){return K(t,Math.PI/2)},3:function(t){return _(t,Math.PI/2)},4:function(t){return _(t,-Math.PI/2)}},rt={1:[[0,0]],2:[[-1,-1],[1,1]],3:[[-1,-1],[0,0],[1,1]],4:[[-1,-1],[1,-1],[-1,1],[1,1]],5:[[-1,-1],[1,-1],[0,0],[-1,1],[1,1]],6:[[-1,-1.25],[1,-1.25],[-1,0],[1,0],[-1,1.25],[1,1.25]]};function nt(t){var r,n=t.slice().sort(function(t,r){return t[0]-r[0]||t[1]-r[1]}),e=[],a=[],o=function(t,r,n){return(r[0]-t[0])*(n[1]-t[1])-(r[1]-t[1])*(n[0]-t[0])};for(r=0;r<n.length;r++){for(;e.length>=2&&o(e[e.length-2],e[e.length-1],n[r])<=1e-8;)e.pop();e.push(n[r])}for(r=n.length-1;r>=0;r--){for(;a.length>=2&&o(a[a.length-2],a[a.length-1],n[r])<=1e-8;)a.pop();a.push(n[r])}return e.slice(0,-1).concat(a.slice(0,-1))}function et(t,r){var n,e="";for(n=0;n<t.length;n++){var a=t[(n-1+t.length)%t.length],o=t[n],i=t[(n+1)%t.length],l=Math.sqrt((o[0]-a[0])*(o[0]-a[0])+(o[1]-a[1])*(o[1]-a[1])),u=Math.sqrt((i[0]-o[0])*(i[0]-o[0])+(i[1]-o[1])*(i[1]-o[1]));if(!(l<1e-6||u<1e-6)){var f=Math.min(r,l/3,u/3),h=[o[0]-(o[0]-a[0])/l*f,o[1]-(o[1]-a[1])/l*f],s=[o[0]+(i[0]-o[0])/u*f,o[1]+(i[1]-o[1])/u*f];e+=(n?"L"+g(h[0],1)+" "+g(h[1],1):"M"+g(h[0],1)+" "+g(h[1],1))+"Q"+g(o[0],1)+" "+g(o[1],1)+" "+g(s[0],1)+" "+g(s[1],1)}}return e+"Z"}function at(t){var r=function(t,r){var n=j(q(t));return S(O(Math.max(2,Math.min(99,n[0]+r)),n[1],n[2]))},n=function(t){return/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i.test(t)||/^rgba?\(\s*[\d.]+[\s,]+[\d.]+[\s,]+[\d.]+/i.test(t)},e=t.o.die&&"auto"!==t.o.die?t.o.die:t.col("die"),a=t.o.pip&&"auto"!==t.o.pip?t.o.pip:t.col("pip"),o=!n(e),i=!n(a),l=o?[e,e,e]:[r(e,14),r(e,5),e],u=o?[e,e,e]:[r(e,4),e,r(e,-11)],f=o?[e,e,e]:[e,r(e,-13),r(e,-21)],h=i?[a,a,a,a]:[r(a,24),r(a,9),a,r(a,-9)],s=function(t,r,n,e){var a,o="";for(a=0;a<r.length;a++)o+=y("stop",["offset",0===a?0:g(a/(r.length-1),2),"stop-color",m(r[a])]);return y("linearGradient",["id",t,"x1",n[0],"y1",n[1],"x2",e[0],"y2",e[1]],o)},c="glass"===t.o.body;return t.add("dice:defs",function(){var n=t.tk(),a=t.tk(),i=t.tk(),v=t.tk(),d=t.tk(),p=t.tk(),M=t.tk(),g=t.tk();t.die={t:n,l:a,r:i,p:v,a:d,b14:p,b5:M,sf:g},t.dieUnder=o?e:r(e,-20);var b=y("filter",["id",p,"x","-60%","y","-60%","width","220%","height","220%"],y("feGaussianBlur",["stdDeviation",14]))+y("filter",["id",M,"x","-60%","y","-60%","width","220%","height","220%"],y("feGaussianBlur",["stdDeviation",5]));return c?(t.dieGlass=o?e:r(e,6),b):s(n,l,[".25",0],[".6",1])+s(a,u,[".2",0],[".7",1])+s(i,f,[".2",0],[".7",1])+y("radialGradient",["id",v,"cx",".31","cy",".27","r",".78"],y("stop",["offset",0,"stop-color",m(h[0])])+y("stop",["offset",".1","stop-color",m(h[1])])+y("stop",["offset",".35","stop-color",m(h[2])])+y("stop",["offset",1,"stop-color",m(h[3])]))+y("radialGradient",["id",d,"cx",".34","cy",".24","r",".88"],y("stop",["offset",0,"stop-color","#fff","stop-opacity",".22"])+y("stop",["offset",".48","stop-color","#fff","stop-opacity",".04"])+y("stop",["offset",".72","stop-color","#000","stop-opacity",0])+y("stop",["offset",1,"stop-color","#000","stop-opacity",".09"]))+b+y("filter",["id",g,"x","-20%","y","-20%","width","140%","height","140%"],y("feGaussianBlur",["stdDeviation",1.4]))})}function ot(t,r,u){var f,h=tt[r],s=[],c="glass"===t.o.body;for(f=0;f<6;f++){var v=X[f];s.push({c:h(v.c),u:h(v.u),v:h(v.v),n:h(v.n),val:v.val})}var d=function(t){var r=K(J(t,u),e);return[r[0],-r[1]]},p=function(t){var r=K(t,e);return[r[0],-r[1]]},M=[];for(f=0;f<8;f++)M.push(d(h([1&f?n:-n,2&f?n:-n,4&f?n:-n])));var b=et(nt(M),a),k=t.die,x=[];for(f=0;f<6;f++){var w=K(J(s[f].n,u),e);w[2]>.02&&x.push({f:s[f],rn:w,z:w[2]})}x.sort(function(t,r){return t.z-r.z});var q=[0,Math.sin(e),Math.cos(e)],S="",P="",I="",z=[];for(f=0;f<x.length;f++){var G,j=x[f].f,L=[],O=[];for(G=0;G<4;G++){var A=1===G||2===G?1:-1,B=G>=2?1:-1;L.push(d(N(N(j.c,j.u,A*l),j.v,B*l))),O.push(d(N(N(j.c,j.u,A*n),j.v,B*n)))}z.push(O),P=c?"":y("path",["d",et(L,o),"fill","url(#"+(x[f].rn[1]>.4?k.t:x[f].rn[0]>0?k.r:k.l)+")"]);var D=J(j.n,u),T=W(V(D,q)),U=W(V(D,T)),Q=rt[j.val];for(G=0;G<Q.length;G++){var H=J(N(N(j.c,j.u,Q[G][0]*n/3),j.v,Q[G][1]*n/3),u),C=p(H),R=p(N(H,T,i)),Y=p(N(H,U,i)),Z=[R[0]-C[0],R[1]-C[1]];P+=y("ellipse",["cx",g(C[0],1),"cy",g(C[1],1),"rx",g(Math.sqrt(Z[0]*Z[0]+Z[1]*Z[1]),1),"ry",g(Math.sqrt((Y[0]-C[0])*(Y[0]-C[0])+(Y[1]-C[1])*(Y[1]-C[1])),1),"transform","rotate("+g(180*Math.atan2(Z[1],Z[0])/Math.PI,1)+" "+g(C[0],1)+" "+g(C[1],1)+")","fill",c?t.col("pip"):"url(#"+k.p+")"])}S+=P}var $=t.tk(),E=t.tk(),F=[];for(f=0;f<z.length;f++)for(var _=f+1;_<z.length;_++){for(var at=z[f],ot=z[_],it=[],lt=0;lt<4;lt++)for(var ut=0;ut<4;ut++){var ft=at[lt][0]-ot[ut][0],ht=at[lt][1]-ot[ut][1];if(ft*ft+ht*ht<.01){it.push(at[lt]);break}}2===it.length&&F.push(it)}var st=null;if(3===F.length)for(var ct=0;ct<2&&!st;ct++){for(var vt=0,dt=0;dt<3;dt++)for(var pt=0;pt<2;pt++){var Mt=F[dt][pt][0]-F[0][ct][0],gt=F[dt][pt][1]-F[0][ct][1];Mt*Mt+gt*gt<.01&&vt++}3===vt&&(st=F[0][ct])}var mt=nt(M),yt=[];for(f=0;f<F.length;f++){var bt=F[f][0],kt=F[f][1];if(st){if(Math.abs(bt[0]-st[0])+Math.abs(bt[1]-st[1])>.1){var xt=bt;bt=kt,kt=xt}var wt=kt[0]-bt[0],qt=kt[1]-bt[1],St=Math.sqrt(wt*wt+qt*qt);if(St>1e-6){for(var Pt=Math.min(St,a),It=0;It<3;It++)if(It!==f){var zt=Math.abs(F[It][0][0]-bt[0])+Math.abs(F[It][0][1]-bt[1])<.1?F[It][1]:F[It][0],Gt=zt[0]-bt[0],jt=zt[1]-bt[1],Lt=Math.min(St,Math.sqrt(Gt*Gt+jt*jt))/3;Lt<Pt&&(Pt=Lt)}bt=[bt[0]+wt/St*Pt,bt[1]+qt/St*Pt]}yt.push(bt)}for(var Ot=-1,At=0;At<mt.length;At++){var Bt=mt[At][0]-kt[0],Dt=mt[At][1]-kt[1];if(Bt*Bt+Dt*Dt<.01){Ot=At;break}}if(Ot>=0){var Tt=mt[(Ot-1+mt.length)%mt.length],Ut=mt[(Ot+1)%mt.length],Qt=kt[0]-Tt[0],Ht=kt[1]-Tt[1],Ct=Ut[0]-kt[0],Rt=Ut[1]-kt[1],Yt=Math.sqrt(Qt*Qt+Ht*Ht),Zt=Math.sqrt(Ct*Ct+Rt*Rt),$t=kt[0]-bt[0],Et=kt[1]-bt[1],Ft=$t*$t+Et*Et;if(Yt>1e-6&&Zt>1e-6&&Ft>1e-6){var Jt=Math.min(a,Yt/3,Zt/3),Kt=[kt[0]-Qt/Yt*Jt,kt[1]-Ht/Yt*Jt],Nt=[kt[0]+Ct/Zt*Jt,kt[1]+Rt/Zt*Jt],Vt=Kt[0],Wt=2*(kt[0]-Kt[0]),Xt=Kt[0]-2*kt[0]+Nt[0],_t=Kt[1],tr=2*(kt[1]-Kt[1]),rr=Kt[1]-2*kt[1]+Nt[1],nr=Xt*Et-rr*$t,er=Wt*Et-tr*$t,ar=(Vt-bt[0])*Et-(_t-bt[1])*$t,or=[];if(Math.abs(nr)<1e-9){if(Math.abs(er)>1e-9){var ir=-ar/er;ir>0&&ir<1&&or.push(ir)}}else{var lr=er*er-4*nr*ar;if(lr>=0)for(var ur=Math.sqrt(lr),fr=-1;fr<=1;fr+=2){var hr=(fr*ur-er)/(2*nr);hr>0&&hr<1&&or.push(hr)}}for(var sr=null,cr=0;cr<or.length;cr++){var vr=or[cr],dr=((Vt+vr*Wt+vr*vr*Xt-bt[0])*$t+(_t+vr*tr+vr*vr*rr-bt[1])*Et)/Ft;dr>0&&dr<1&&(null==sr||dr>sr)&&(sr=dr)}if(null!=sr){var pr=(c?2.2:1.4)*t.w/Math.sqrt(Ft);kt=[bt[0]+$t*(sr-pr),bt[1]+Et*(sr-pr)]}}}I+=y("path",["clip-path",c?null:"url(#"+E+")","d","M"+g(bt[0],1)+" "+g(bt[1],1)+"L"+g(kt[0],1)+" "+g(kt[1],1),"fill","none","stroke",c?t.col("outline"):t.col("ink"),"stroke-opacity",c?null:".15","stroke-width",g((c?2.2:1.4)*t.w,1),"stroke-linecap","round"])}if(st&&3===yt.length)for(f=0;f<3;f++)for(var Mr=f+1;Mr<3;Mr++)I+=y("path",["clip-path",c?null:"url(#"+E+")","d","M"+g(yt[f][0],1)+" "+g(yt[f][1],1)+"Q"+g(st[0],1)+" "+g(st[1],1)+" "+g(yt[Mr][0],1)+" "+g(yt[Mr][1],1),"fill","none","stroke",c?t.col("outline"):t.col("ink"),"stroke-opacity",c?null:".15","stroke-width",g((c?2.2:1.4)*t.w,1),"stroke-linecap","round"]);return t.defs+=y("path",["id",$,"d",b])+y("clipPath",["id",E],y("use",["href","#"+$])),{shadow:y("ellipse",["cx",0,"cy",118,"rx",132,"ry",24,"fill",t.col("ink"),"fill-opacity",".16","filter","url(#"+k.b14+")"])+(c?y("ellipse",["cx",0,"cy",112,"rx",62,"ry",11,"fill",t.col("ink"),"fill-opacity",".18","filter","url(#"+k.b5+")"]):""),content:c?y("use",["href","#"+$,"fill",m(t.dieGlass),"fill-opacity",".55","stroke",t.col("outline"),"stroke-width",g(2.6*t.w,1)])+y("g",["clip-path","url(#"+E+")"],S+I):y("use",["href","#"+$,"fill",m(t.dieUnder)])+y("g",["clip-path","url(#"+E+")","filter","url(#"+k.sf+")"],S)+y("use",["href","#"+$,"fill","url(#"+k.a+")"])+y("use",["href","#"+$,"fill","none","stroke","#00000010","stroke-width",2])+I}}var it=[[-1,0],[1,0],[0,-1],[0,1],[1.65,1.15]],lt=["lucky7","snake","boxcars","matched","mixed"],ut=[[1,6],[2,5],[3,4]];function ft(t,r,n,e,a){if("snake"===t)return r<2?1:0;if("boxcars"===t)return r<2?6:0;if("lucky7"===t&&r<2){if(a[1-r])return 7-a[1-r];if(!e.l7){var o=ut[Math.floor(3*n("result:lucky7")())];e.l7=n("result:lucky7:swap")()<.5?o:[o[1],o[0]]}return e.l7[r]}if("matched"===t){for(var i=0;i<a.length;i++)if(a[i])return a[i];return 1+Math.floor(6*n("result:matched")())}if("mixed"===t){for(var l=[],u=1;u<=6;u++)e[u]||l.push(u);var f=l[Math.floor(n("result:mixed:"+r)()*l.length)];return e[f]=1,f}return 0}function ht(t){var r,n=t||{},e=Math.max(2,Math.min(5,Math.round(n.dice)||3)),a=Y(n,"table"+e),o=a.p,i=a.S;at(a);var l=0,f=0;for(r=0;r<e;r++)l=Math.max(l,Math.abs(it[r][0])),f=Math.max(f,Math.abs(it[r][1]));var h=l*v+p,m=f*v+M,b=c[0]+(c[1]-c[0])*i("table:rail")(),k=28+40*i("table:corner")(),x=a.cab,w=a.col("outline"),q=a.col("trim"),S=g(4*a.w,2),P=function(t){return x?["fill",t]:["fill","none","stroke",w,"stroke-width",S]},I=function(t,r,n,e,a,i){return y("rect",["x",g(t,o),"y",g(r,o),"width",g(n,o),"height",g(e,o),"rx",a?g(a,o):null].concat(i))},z=n.values||[],G=lt.indexOf(n.result)>=0?n.result:"",j={},L=function(t){return 1+Math.floor(6*i("die:"+t+":value")())},O=[];for(r=0;r<e;r++){var A=Math.round(z[r]);A>=1&&A<=6&&(O[r]=A,j[A]=1)}for(r=0;r<e;r++)if(null==O[r])if(G){var B=ft(G,r,i,j,O);O[r]=B||L(r)}else O[r]=L(r);var D=null==n.speed?1:n.speed,T=!!n.motion&&D>0,U="",Q=null;T&&(Q=R(i,"motion"+(n.salt||"")+a.key+D));var H=[];for(r=0;r<e;r++){var C=(i("die:"+r+":orient")()<.5?-1:1)*(u[0]+u[1]*i("die:"+r+":orient:yaw")()),$=it[r][0]*v+2*(i("die:"+r+":place")()-.5)*d*v,E=it[r][1]*v+2*(i("die:"+r+":place:v")()-.5)*d*v,J=.9+.1*(it[r][1]+1)/2,K="translate("+g($,1)+" "+g(E,1)+")"+(1!==J?" scale("+J+")":""),N=ot(a,O[r],C),V=N.content,W=null;if(T){var X=Q(),_=30+40*i("die:"+r+":drop")();W=Q(),U+="@keyframes "+X+"{from{transform:translateY("+g(-_,1)+"px)}}."+W+"{animation:"+X+" "+g((.8+.3*r)/D,2)+"s cubic-bezier(.2,.7,.3,1.08)}",V=y("g",["class",W],V)}H.push({x:$,y:E,cls:W,shadow:y("g",["transform",K],N.shadow),body:y("g",["transform",K],V)})}H.sort(function(t,r){return t.y-r.y});var tt="",rt="";for(r=0;r<e;r++)tt+=H[r].shadow,rt+=H[r].body;for(r=0;r<e;r++)for(var nt=r+1;nt<e;nt++){var et=H[r].x-H[nt].x,ut=H[r].y-H[nt].y;Math.sqrt(et*et+ut*ut)<240&&(tt+=y("ellipse",["cx",g((H[r].x+H[nt].x)/2,1),"cy",g((H[r].y+H[nt].y)/2+54,1),"rx",36,"ry",9,"fill",a.col("ink"),"fill-opacity",".14","filter","url(#"+a.die.b5+")"]))}var ht="";if(T){var st=[];for(r=0;r<e;r++)H[r].cls&&st.push("."+H[r].cls);ht=y("style",[],U+"@media(prefers-reduced-motion:reduce){"+st.join(",")+"{animation:none}}")}return ht+=I(-h-b,-m-b,2*(h+b),2*(m+b),k,P(a.col("rail"))),ht+=I(-h,-m,2*h,2*m,Math.max(0,k-b),P(a.col("felt"))),ht+=I(-h,-m,2*h,2*m,Math.max(0,k-b),F(a,q,".25")),ht+=tt+rt,Z(n,a,[-h-s[0],-m-s[1],2*(h+s[0]),2*(m+s[1])],ht)}function st(t){var r=t||{},n=Y(r,"die"),e=n.S;at(n);var a=ot(n,Math.round(r.value)>=1&&Math.round(r.value)<=6?Math.round(r.value):1+Math.floor(6*e("die:0:value")()),(e("die:0:orient")()<.5?-1:1)*(u[0]+u[1]*e("die:0:orient:yaw")()));return Z(r,n,[-p,-M,2*p,2*M+42],a.shadow+a.content)}function ct(t,r){var n="string"==typeof t?document.querySelector(t):t,e={};if(!n)return null;var a=function(t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);n.innerHTML=ht(e)};return a(r||{}),{el:n,get:function(){var t={};for(var r in e)t[r]=e[r];return t},set:a,destroy:function(){n.innerHTML=""}}}return{toss:ht,die:st,palette:C,init:ct}}();"object"==typeof module&&module.exports?module.exports=r:t.Dice=r}("undefined"!=typeof self?self:this);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spintax/dice-lite",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "A procedural throw of dice as an SVG string. Seeded placement and values, brand-aware table palette, paper or frosted-glass bodies, an optional CSS roll. Zero dependencies; runs in Node at build time and in the browser.",
5
5
  "main": "dice.js",
6
6
  "types": "dice.d.ts",
@@ -19,7 +19,7 @@
19
19
  "gate:browser": "node scripts/browser-gate.mjs"
20
20
  },
21
21
  "config": {
22
- "sizeBudget": 7680
22
+ "sizeBudget": 8704
23
23
  },
24
24
  "keywords": [
25
25
  "dice",