@digilogiclabs/saas-factory-ui 2.8.2 → 2.9.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.
@@ -30227,6 +30227,7 @@ function TiltCard({
30227
30227
  import {
30228
30228
  useCallback as useCallback41,
30229
30229
  useEffect as useEffect51,
30230
+ useId as useId3,
30230
30231
  useMemo as useMemo26,
30231
30232
  useRef as useRef40,
30232
30233
  useState as useState66
@@ -30366,17 +30367,192 @@ function d6LandingRotation(value) {
30366
30367
  y: Math.abs(p.y) === 180 ? 180 : -p.y || 0
30367
30368
  };
30368
30369
  }
30369
- var POLY_SHAPES = {
30370
- 4: { points: "50,8 93,86 7,86", textY: 62, fontScale: 0.3 },
30371
- 8: { points: "50,4 96,50 50,96 4,50", textY: 51, fontScale: 0.33 },
30372
- 10: { points: "50,4 93,44 50,96 7,44", textY: 47, fontScale: 0.3 },
30373
- 12: { points: "50,4 95,37 78,93 22,93 5,37", textY: 54, fontScale: 0.33 },
30374
- 20: {
30375
- points: "50,3 91,26 91,74 50,97 9,74 9,26",
30376
- textY: 51,
30377
- fontScale: 0.33
30370
+ var PHI = (1 + Math.sqrt(5)) / 2;
30371
+ var dot3 = (a, b) => a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
30372
+ var cross3 = (a, b) => [
30373
+ a[1] * b[2] - a[2] * b[1],
30374
+ a[2] * b[0] - a[0] * b[2],
30375
+ a[0] * b[1] - a[1] * b[0]
30376
+ ];
30377
+ var sub3 = (a, b) => [
30378
+ a[0] - b[0],
30379
+ a[1] - b[1],
30380
+ a[2] - b[2]
30381
+ ];
30382
+ var scale3 = (a, s) => [a[0] * s, a[1] * s, a[2] * s];
30383
+ var len3 = (a) => Math.hypot(a[0], a[1], a[2]);
30384
+ var norm3 = (a) => scale3(a, 1 / len3(a));
30385
+ function rotateAround(p, axis, angle) {
30386
+ const cosA = Math.cos(angle);
30387
+ const sinA = Math.sin(angle);
30388
+ const t1 = scale3(p, cosA);
30389
+ const t2 = scale3(cross3(axis, p), sinA);
30390
+ const t3 = scale3(axis, dot3(axis, p) * (1 - cosA));
30391
+ return [t1[0] + t2[0] + t3[0], t1[1] + t2[1] + t3[1], t1[2] + t2[2] + t3[2]];
30392
+ }
30393
+ function rotationTo(from, to) {
30394
+ const c = dot3(from, to);
30395
+ if (c > 1 - 1e-9) return (p) => p;
30396
+ const axis = c < -1 + 1e-9 ? norm3(
30397
+ Math.abs(from[0]) < 0.9 ? cross3(from, [1, 0, 0]) : cross3(from, [0, 1, 0])
30398
+ ) : norm3(cross3(from, to));
30399
+ const angle = Math.acos(Math.max(-1, Math.min(1, c)));
30400
+ return (p) => rotateAround(p, axis, angle);
30401
+ }
30402
+ function solidVertices(sides) {
30403
+ switch (sides) {
30404
+ case 4:
30405
+ return [
30406
+ [1, 1, 1],
30407
+ [1, -1, -1],
30408
+ [-1, 1, -1],
30409
+ [-1, -1, 1]
30410
+ ];
30411
+ case 8:
30412
+ return [
30413
+ [1, 0, 0],
30414
+ [-1, 0, 0],
30415
+ [0, 1, 0],
30416
+ [0, -1, 0],
30417
+ [0, 0, 1],
30418
+ [0, 0, -1]
30419
+ ];
30420
+ case 10: {
30421
+ const h = 0.15;
30422
+ const cos36 = Math.cos(Math.PI / 5);
30423
+ const zApex = 2 * h / (1 - cos36) * cos36 + h;
30424
+ const verts = [
30425
+ [0, 0, zApex],
30426
+ [0, 0, -zApex]
30427
+ ];
30428
+ for (let k = 0; k < 10; k++) {
30429
+ const a = k * Math.PI / 5;
30430
+ verts.push([Math.cos(a), Math.sin(a), k % 2 === 0 ? h : -h]);
30431
+ }
30432
+ return verts;
30433
+ }
30434
+ case 12: {
30435
+ const v = [];
30436
+ for (const sx of [1, -1])
30437
+ for (const sy of [1, -1])
30438
+ for (const sz of [1, -1]) v.push([sx, sy, sz]);
30439
+ const b = 1 / PHI;
30440
+ for (const s1 of [1, -1])
30441
+ for (const s2 of [1, -1]) {
30442
+ v.push([0, s1 * b, s2 * PHI]);
30443
+ v.push([s1 * b, s2 * PHI, 0]);
30444
+ v.push([s2 * PHI, 0, s1 * b]);
30445
+ }
30446
+ return v;
30447
+ }
30448
+ case 20: {
30449
+ const v = [];
30450
+ for (const s1 of [1, -1])
30451
+ for (const s2 of [1, -1]) {
30452
+ v.push([0, s1, s2 * PHI]);
30453
+ v.push([s1, s2 * PHI, 0]);
30454
+ v.push([s2 * PHI, 0, s1]);
30455
+ }
30456
+ return v;
30457
+ }
30378
30458
  }
30379
- };
30459
+ }
30460
+ function computeFaces(verts) {
30461
+ const faces = [];
30462
+ const seen = /* @__PURE__ */ new Set();
30463
+ for (let i = 0; i < verts.length; i++)
30464
+ for (let j = i + 1; j < verts.length; j++)
30465
+ for (let k = j + 1; k < verts.length; k++) {
30466
+ let n = cross3(sub3(verts[j], verts[i]), sub3(verts[k], verts[i]));
30467
+ if (len3(n) < 1e-9) continue;
30468
+ n = norm3(n);
30469
+ let d = dot3(n, verts[i]);
30470
+ if (d < 0) {
30471
+ n = scale3(n, -1);
30472
+ d = -d;
30473
+ }
30474
+ if (verts.some((p) => dot3(n, p) > d + 1e-4)) continue;
30475
+ const ids = verts.flatMap(
30476
+ (p, idx) => Math.abs(dot3(n, p) - d) < 1e-4 ? [idx] : []
30477
+ );
30478
+ const key = ids.join(",");
30479
+ if (seen.has(key)) continue;
30480
+ seen.add(key);
30481
+ faces.push({ normal: n, ids });
30482
+ }
30483
+ return faces;
30484
+ }
30485
+ var polyhedronCache = /* @__PURE__ */ new Map();
30486
+ function buildPolyhedron(sides) {
30487
+ const cached = polyhedronCache.get(sides);
30488
+ if (cached) return cached;
30489
+ let verts = solidVertices(sides);
30490
+ const rough = computeFaces(verts);
30491
+ const front = rough.reduce(
30492
+ (best, f) => f.normal[2] > best.normal[2] + 1e-9 ? f : best
30493
+ );
30494
+ const rot = rotationTo(front.normal, [0, 0, 1]);
30495
+ verts = verts.map(rot);
30496
+ const rMax = Math.max(...verts.map(len3));
30497
+ verts = verts.map((p) => scale3(p, 1 / rMax));
30498
+ const raw = computeFaces(verts);
30499
+ const built = raw.map((f) => {
30500
+ const faceVerts = f.ids.map((i) => verts[i]);
30501
+ const centroid = scale3(
30502
+ faceVerts.reduce((a, b) => [a[0] + b[0], a[1] + b[1], a[2] + b[2]]),
30503
+ 1 / faceVerts.length
30504
+ );
30505
+ const w = f.normal;
30506
+ let vRaw = sub3([0, 1, 0], scale3(w, w[1]));
30507
+ if (len3(vRaw) < 1e-6) vRaw = sub3([0, 0, 1], scale3(w, w[2]));
30508
+ const v = norm3(vRaw);
30509
+ const u = cross3(v, w);
30510
+ const pts = faceVerts.map((p) => [
30511
+ dot3(sub3(p, centroid), u),
30512
+ dot3(sub3(p, centroid), v)
30513
+ ]).sort((a, b) => Math.atan2(a[1], a[0]) - Math.atan2(b[1], b[0]));
30514
+ return { normal: w, centroid, u, v, pts, value: 0 };
30515
+ });
30516
+ built.sort((a, b) => b.normal[2] - a.normal[2]);
30517
+ const oppOf = (i) => built.findIndex((g) => dot3(built[i].normal, g.normal) < -0.9999);
30518
+ const pool = [];
30519
+ for (let v2 = 1; v2 < sides; v2++) pool.push(v2);
30520
+ built[0].value = sides;
30521
+ const opp0 = oppOf(0);
30522
+ if (opp0 >= 0) {
30523
+ built[opp0].value = 1;
30524
+ pool.splice(pool.indexOf(1), 1);
30525
+ }
30526
+ for (let i = 1; i < built.length; i++) {
30527
+ if (built[i].value !== 0) continue;
30528
+ const v2 = pool.shift();
30529
+ built[i].value = v2;
30530
+ const j = oppOf(i);
30531
+ if (j >= 0 && built[j].value === 0) {
30532
+ built[j].value = sides + 1 - v2;
30533
+ pool.splice(pool.indexOf(sides + 1 - v2), 1);
30534
+ }
30535
+ }
30536
+ const faceRadius = Math.max(
30537
+ ...built.flatMap((f) => f.pts.map(([x, y]) => Math.hypot(x, y)))
30538
+ );
30539
+ const edgeDist = (pts) => Math.min(
30540
+ ...pts.map((p1, i2) => {
30541
+ const p2 = pts[(i2 + 1) % pts.length];
30542
+ const dx = p2[0] - p1[0];
30543
+ const dy = p2[1] - p1[1];
30544
+ const t = Math.max(
30545
+ 0,
30546
+ Math.min(1, -(p1[0] * dx + p1[1] * dy) / (dx * dx + dy * dy))
30547
+ );
30548
+ return Math.hypot(p1[0] + t * dx, p1[1] + t * dy);
30549
+ })
30550
+ );
30551
+ const faceInradius = Math.min(...built.map((f) => edgeDist(f.pts)));
30552
+ const result = { faces: built, faceRadius, faceInradius };
30553
+ polyhedronCache.set(sides, result);
30554
+ return result;
30555
+ }
30380
30556
  function formatDieValue(v, sides) {
30381
30557
  return sides > 8 && (v === 6 || v === 9) ? `${v}.` : String(v);
30382
30558
  }
@@ -30601,6 +30777,7 @@ function DiceRoller({
30601
30777
  }
30602
30778
  return numeralSetters.current[i];
30603
30779
  };
30780
+ const sheenGradientId = useId3();
30604
30781
  const timersRef = useRef40([]);
30605
30782
  const rafHandleRef = useRef40(null);
30606
30783
  const arenaRef = useRef40(null);
@@ -30986,99 +31163,97 @@ function DiceRoller({
30986
31163
  },
30987
31164
  val
30988
31165
  )) : (() => {
30989
- const shape = POLY_SHAPES[sides];
31166
+ const geo = buildPolyhedron(sides);
31167
+ const R = effectiveSize / 2;
31168
+ const S = Math.ceil(geo.faceRadius * R * 2) + 6;
31169
+ const fontSize = geo.faceInradius * R * 1.15;
30990
31170
  const shown = results?.[d] ?? sides;
30991
- const depth = effectiveSize * 0.18;
30992
- const edgeLayers = 16;
30993
- const cardFaceStyle = {
30994
- position: "absolute",
30995
- inset: 0,
30996
- display: "block",
30997
- overflow: "visible",
30998
- backfaceVisibility: "hidden"
30999
- };
31000
- return /* @__PURE__ */ jsxs86(Fragment30, { children: [
31001
- Array.from({ length: edgeLayers }, (_2, li) => {
31002
- const z = -depth / 2 + depth * (li + 0.5) / edgeLayers;
31003
- return /* @__PURE__ */ jsxs86(
31004
- "svg",
31005
- {
31006
- viewBox: "0 0 100 100",
31007
- width: "100%",
31008
- height: "100%",
31009
- style: {
31010
- position: "absolute",
31011
- inset: 0,
31012
- display: "block",
31013
- overflow: "visible",
31014
- transform: `translateZ(${z}px)`
31015
- },
31016
- "aria-hidden": "true",
31017
- children: [
31018
- /* @__PURE__ */ jsx113(
31019
- "polygon",
31020
- {
31021
- points: shape.points,
31022
- fill: colors.face
31023
- }
31024
- ),
31025
- /* @__PURE__ */ jsx113(
31026
- "polygon",
31027
- {
31028
- points: shape.points,
31029
- fill: "#000",
31030
- opacity: 0.22
31031
- }
31032
- )
31033
- ]
31034
- },
31035
- li
31036
- );
31037
- }),
31038
- /* @__PURE__ */ jsxs86(
31171
+ return /* @__PURE__ */ jsx113(Fragment30, { children: geo.faces.map((f, fi) => {
31172
+ const m = `matrix3d(${f.u[0]},${f.u[1]},${f.u[2]},0,${f.v[0]},${f.v[1]},${f.v[2]},0,${f.normal[0]},${f.normal[1]},${f.normal[2]},0,${f.centroid[0] * R},${f.centroid[1] * R},${f.centroid[2] * R},1)`;
31173
+ const gid = `${sheenGradientId}-${d}-${fi}`;
31174
+ const pts = f.pts.map(
31175
+ ([x, y]) => `${(x * R + S / 2).toFixed(2)},${(y * R + S / 2).toFixed(2)}`
31176
+ ).join(" ");
31177
+ return /* @__PURE__ */ jsxs86(
31039
31178
  "svg",
31040
31179
  {
31041
- viewBox: "0 0 100 100",
31042
- width: "100%",
31043
- height: "100%",
31180
+ width: S,
31181
+ height: S,
31182
+ viewBox: `0 0 ${S} ${S}`,
31044
31183
  style: {
31045
- ...cardFaceStyle,
31046
- transform: `translateZ(${depth / 2}px)`
31184
+ position: "absolute",
31185
+ left: "50%",
31186
+ top: "50%",
31187
+ marginLeft: -S / 2,
31188
+ marginTop: -S / 2,
31189
+ overflow: "visible",
31190
+ transform: m,
31191
+ // Convex solid: a face is either front-
31192
+ // facing or hidden behind nearer faces,
31193
+ // so hiding backfaces is both correct
31194
+ // and the mirrored-numeral guard.
31195
+ backfaceVisibility: "hidden"
31047
31196
  },
31048
31197
  "aria-hidden": "true",
31049
31198
  children: [
31050
- /* @__PURE__ */ jsx113(
31051
- "polygon",
31199
+ /* @__PURE__ */ jsx113("defs", { children: /* @__PURE__ */ jsxs86(
31200
+ "radialGradient",
31052
31201
  {
31053
- points: shape.points,
31054
- fill: colors.face,
31055
- stroke: colors.faceBorder,
31056
- strokeWidth: 2.5,
31057
- strokeLinejoin: "round",
31058
- style: { transition: "fill 0.3s, stroke 0.3s" }
31202
+ id: gid,
31203
+ cx: "32%",
31204
+ cy: "26%",
31205
+ r: "80%",
31206
+ children: [
31207
+ /* @__PURE__ */ jsx113(
31208
+ "stop",
31209
+ {
31210
+ offset: "0%",
31211
+ stopColor: "#fff",
31212
+ stopOpacity: "0.38"
31213
+ }
31214
+ ),
31215
+ /* @__PURE__ */ jsx113(
31216
+ "stop",
31217
+ {
31218
+ offset: "55%",
31219
+ stopColor: "#fff",
31220
+ stopOpacity: "0.08"
31221
+ }
31222
+ ),
31223
+ /* @__PURE__ */ jsx113(
31224
+ "stop",
31225
+ {
31226
+ offset: "100%",
31227
+ stopColor: "#fff",
31228
+ stopOpacity: "0"
31229
+ }
31230
+ )
31231
+ ]
31059
31232
  }
31060
- ),
31233
+ ) }),
31061
31234
  /* @__PURE__ */ jsx113(
31062
31235
  "polygon",
31063
31236
  {
31064
- points: shape.points,
31065
- fill: "none",
31237
+ points: pts,
31238
+ fill: colors.face,
31066
31239
  stroke: colors.faceBorder,
31067
31240
  strokeWidth: 1.5,
31068
31241
  strokeLinejoin: "round",
31069
- opacity: 0.55,
31070
- transform: "translate(50 50) scale(0.76) translate(-50 -50)"
31242
+ style: {
31243
+ transition: "fill 0.3s, stroke 0.3s"
31244
+ }
31071
31245
  }
31072
31246
  ),
31247
+ /* @__PURE__ */ jsx113("polygon", { points: pts, fill: `url(#${gid})` }),
31073
31248
  /* @__PURE__ */ jsx113(
31074
31249
  "text",
31075
31250
  {
31076
- ref: getNumeralSetter(d),
31077
- x: 50,
31078
- y: shape.textY,
31251
+ ref: fi === 0 ? getNumeralSetter(d) : void 0,
31252
+ x: S / 2,
31253
+ y: S / 2,
31079
31254
  textAnchor: "middle",
31080
31255
  dominantBaseline: "central",
31081
- fontSize: 100 * shape.fontScale,
31256
+ fontSize,
31082
31257
  fontWeight: 800,
31083
31258
  fill: colors.pip,
31084
31259
  style: {
@@ -31086,59 +31261,17 @@ function DiceRoller({
31086
31261
  transition: "fill 0.3s",
31087
31262
  userSelect: "none"
31088
31263
  },
31089
- children: formatDieValue(shown, sides)
31264
+ children: formatDieValue(
31265
+ fi === 0 ? shown : f.value,
31266
+ sides
31267
+ )
31090
31268
  }
31091
31269
  )
31092
31270
  ]
31093
- }
31094
- ),
31095
- /* @__PURE__ */ jsxs86(
31096
- "svg",
31097
- {
31098
- viewBox: "0 0 100 100",
31099
- width: "100%",
31100
- height: "100%",
31101
- style: {
31102
- ...cardFaceStyle,
31103
- transform: `rotateY(180deg) translateZ(${depth / 2}px)`
31104
- },
31105
- "aria-hidden": "true",
31106
- children: [
31107
- /* @__PURE__ */ jsx113(
31108
- "polygon",
31109
- {
31110
- points: shape.points,
31111
- fill: colors.face,
31112
- stroke: colors.faceBorder,
31113
- strokeWidth: 2.5,
31114
- strokeLinejoin: "round",
31115
- style: { transition: "fill 0.3s, stroke 0.3s" }
31116
- }
31117
- ),
31118
- /* @__PURE__ */ jsx113(
31119
- "polygon",
31120
- {
31121
- points: shape.points,
31122
- fill: "none",
31123
- stroke: colors.faceBorder,
31124
- strokeWidth: 1.5,
31125
- strokeLinejoin: "round",
31126
- opacity: 0.55,
31127
- transform: "translate(50 50) scale(0.76) translate(-50 -50)"
31128
- }
31129
- ),
31130
- /* @__PURE__ */ jsx113(
31131
- "polygon",
31132
- {
31133
- points: shape.points,
31134
- fill: "#000",
31135
- opacity: 0.14
31136
- }
31137
- )
31138
- ]
31139
- }
31140
- )
31141
- ] });
31271
+ },
31272
+ fi
31273
+ );
31274
+ }) });
31142
31275
  })()
31143
31276
  }
31144
31277
  )
@@ -44118,6 +44251,7 @@ export {
44118
44251
  audioAppTabs,
44119
44252
  audioPlayerVariants,
44120
44253
  breadcrumbsVariants,
44254
+ buildPolyhedron,
44121
44255
  cn,
44122
44256
  commonValidators,
44123
44257
  containerVariants2 as containerVariants,