@kumix/ui 0.4.4 → 0.5.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.
Files changed (89) hide show
  1. package/README.md +14 -12
  2. package/dist/components/agents/approval-card/index.js +0 -1
  3. package/dist/components/agents/approval-card/index.js.map +1 -1
  4. package/dist/components/agents/prompt-input.js +0 -1
  5. package/dist/components/agents/prompt-input.js.map +1 -1
  6. package/dist/components/charts/bar-chart/context.d.ts.map +1 -1
  7. package/dist/components/charts/line-chart/context.d.ts.map +1 -1
  8. package/dist/components/charts/returns-calendar.d.ts.map +1 -1
  9. package/dist/components/charts/treemap.d.ts.map +1 -1
  10. package/dist/components/motion/bouncy-accordion.d.ts.map +1 -1
  11. package/dist/components/motion/bouncy-accordion.js +20 -34
  12. package/dist/components/motion/bouncy-accordion.js.map +1 -1
  13. package/dist/components/motion/crash/crash-balloon.d.ts +9 -0
  14. package/dist/components/motion/crash/crash-balloon.d.ts.map +1 -0
  15. package/dist/components/motion/crash/crash-balloon.js +829 -0
  16. package/dist/components/motion/crash/crash-balloon.js.map +1 -0
  17. package/dist/components/motion/crash/crash-parts.d.ts +59 -0
  18. package/dist/components/motion/crash/crash-parts.d.ts.map +1 -0
  19. package/dist/components/motion/crash/crash-parts.js +2 -0
  20. package/dist/components/motion/crash/crash-tower.d.ts +9 -0
  21. package/dist/components/motion/crash/crash-tower.d.ts.map +1 -0
  22. package/dist/components/motion/crash/crash-tower.js +370 -0
  23. package/dist/components/motion/crash/crash-tower.js.map +1 -0
  24. package/dist/components/motion/crash.d.ts +9 -0
  25. package/dist/components/motion/crash.d.ts.map +1 -0
  26. package/dist/components/motion/crash.js +590 -0
  27. package/dist/components/motion/crash.js.map +1 -0
  28. package/dist/components/motion/feedback-widget.js +0 -1
  29. package/dist/components/motion/feedback-widget.js.map +1 -1
  30. package/dist/components/motion/liquid.js +2 -2
  31. package/dist/components/motion/liquid.js.map +1 -1
  32. package/dist/components/motion/mines.d.ts +41 -0
  33. package/dist/components/motion/mines.d.ts.map +1 -0
  34. package/dist/components/motion/mines.js +762 -0
  35. package/dist/components/motion/mines.js.map +1 -0
  36. package/dist/components/motion/plinko.d.ts +59 -0
  37. package/dist/components/motion/plinko.d.ts.map +1 -0
  38. package/dist/components/motion/plinko.js +385 -0
  39. package/dist/components/motion/plinko.js.map +1 -0
  40. package/dist/components/motion/signup-form.js +0 -1
  41. package/dist/components/motion/signup-form.js.map +1 -1
  42. package/dist/components/motion/swap.d.ts +1 -1
  43. package/dist/components/motion/tooltip.d.ts +2 -2
  44. package/dist/components/motion/tooltip.d.ts.map +1 -1
  45. package/dist/components/motion/wallet-card/index.js +0 -1
  46. package/dist/components/motion/wallet-card/index.js.map +1 -1
  47. package/dist/components/reui/alert.d.ts +1 -1
  48. package/dist/components/reui/badge.d.ts +1 -1
  49. package/dist/components/reui/code-block/code-block.d.ts +1 -0
  50. package/dist/components/reui/code-block/code-block.d.ts.map +1 -1
  51. package/dist/components/reui/data-grid/data-grid-table.d.ts +1 -1
  52. package/dist/components/reui/data-grid/data-grid-table.d.ts.map +1 -1
  53. package/dist/components/reui/frame.d.ts +1 -1
  54. package/dist/components/reui/icon-tile.d.ts +1 -1
  55. package/dist/components/reui/tree.d.ts +1 -0
  56. package/dist/components/reui/tree.d.ts.map +1 -1
  57. package/dist/components/ui/badge.d.ts +1 -1
  58. package/dist/components/ui/bubble.d.ts +1 -1
  59. package/dist/components/ui/button.d.ts +2 -2
  60. package/dist/components/ui/empty.d.ts +1 -1
  61. package/dist/components/ui/item.d.ts +1 -1
  62. package/dist/components/ui/marker.d.ts +1 -1
  63. package/dist/components/ui/tabs.d.ts +1 -1
  64. package/dist/crash-parts-CUv5gFYQ.js +1053 -0
  65. package/dist/crash-parts-CUv5gFYQ.js.map +1 -0
  66. package/dist/{ease-CHhXKlG3.d.ts → ease-DjhlGGZO.d.ts} +4 -2
  67. package/dist/ease-DjhlGGZO.d.ts.map +1 -0
  68. package/dist/hooks/use-highlighted-code.d.ts +1 -1
  69. package/dist/hooks/use-highlighted-code.d.ts.map +1 -1
  70. package/dist/lib/audio-context.d.ts +11 -0
  71. package/dist/lib/audio-context.d.ts.map +1 -0
  72. package/dist/lib/audio-context.js +37 -0
  73. package/dist/lib/audio-context.js.map +1 -0
  74. package/dist/lib/ease.d.ts +2 -2
  75. package/dist/lib/ease.js +8 -1
  76. package/dist/lib/ease.js.map +1 -1
  77. package/dist/lib/game-sounds.d.ts +18 -0
  78. package/dist/lib/game-sounds.d.ts.map +1 -0
  79. package/dist/lib/game-sounds.js +142 -0
  80. package/dist/lib/game-sounds.js.map +1 -0
  81. package/dist/lib/tick-sound.d.ts +4 -3
  82. package/dist/lib/tick-sound.d.ts.map +1 -1
  83. package/dist/lib/tick-sound.js +30 -37
  84. package/dist/lib/tick-sound.js.map +1 -1
  85. package/dist/tooltip-CNEYdIX3.d.ts.map +1 -1
  86. package/dist/use-crash-game-B3RHxFkm.d.ts +108 -0
  87. package/dist/use-crash-game-B3RHxFkm.d.ts.map +1 -0
  88. package/package.json +7 -7
  89. package/dist/ease-CHhXKlG3.d.ts.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crash-balloon.js","names":[],"sources":["../../../../src/components/motion/crash/crash-balloon.tsx"],"sourcesContent":["\"use client\";\n\nimport { useId } from \"react\";\nimport { AnimatePresence, cubicBezier, motion, type Transition } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_IN, EASE_IN_OUT, EASE_OUT } from \"../../../lib/ease\";\nimport {\n CHUTE,\n type CrashMiniatureProps,\n CrashShell,\n clamp01,\n MINI,\n MINI_REPLAY,\n niceAtLeast,\n Parachute,\n PRIMARY_TEXT,\n STAGE_LABEL,\n STAGE_W,\n wrap,\n} from \"./crash-parts\";\nimport {\n BURST,\n type CrashProps,\n EXIT,\n formatShort,\n growth,\n PULSE,\n SWAP,\n timeAt,\n useCrashGame,\n} from \"./use-crash-game\";\n\nexport { type CrashProps, type CrashReveal, crashPoint, formatMultiplier } from \"./use-crash-game\";\n\n// Stage geometry in SVG units; the stage scales to its container's width.\nconst W = STAGE_W;\nconst H = 280;\n// The balloon sits centre right, clear of the readout; the tape runs down the right edge.\nconst BX = 262;\nconst TAPE_X = 348;\n// The balloon's envelope centre once aloft, and the tape caret beside it.\nconst LEVEL = 112;\n// The highest a target mark sits, so its flag stays on the stage.\nconst TARGET_PIN = 14;\nconst GROUND_Y = H - 24;\n// The basket's bottom is 51 units under the envelope centre.\nconst PARKED = GROUND_Y - 51;\n// Tape units per unit of ln(multiplier): 1× to 2× spans about 166 units.\nconst PX = 240;\n// Clouds stop speeding up past 100×.\nconst CLOUD_CAP = PX * Math.log(100);\n// The lift-off takes this long before the balloon holds and the world scrolls.\nconst LIFT = 1.2;\nconst rise = cubicBezier(...EASE_IN_OUT);\n\n/**\n * Crash, drawn as a hot-air balloon on an altimeter: the multiplier is the\n * altitude. The balloon lifts off and holds while the tape and clouds scroll\n * past; cash out to bail before the envelope pops.\n */\nexport function CrashBalloon({\n \"aria-label\": ariaLabel = \"Crash\",\n className,\n ...options\n}: CrashProps) {\n const game = useCrashGame(options);\n return (\n <CrashShell\n game={game}\n aria-label={ariaLabel}\n className={className}\n miniature={(props) => <MiniAltitude {...props} />}\n >\n <Stage\n t={game.t}\n cashed={game.cashed}\n crashed={game.crashed}\n lost={game.lost}\n round={game.round}\n pulse={game.pulse}\n target={game.target}\n ghost={game.ghost}\n reduce={game.reduce}\n skipping={game.skipping}\n />\n </CrashShell>\n );\n}\n\ninterface StageProps {\n t: number;\n cashed: number | null;\n crashed: boolean;\n lost: boolean;\n round: number;\n pulse: number;\n target: number | null;\n ghost: number | null;\n reduce: boolean;\n skipping: boolean;\n}\n\nfunction Stage({\n t,\n cashed,\n crashed,\n lost,\n round,\n pulse,\n target,\n ghost,\n reduce,\n skipping,\n}: StageProps) {\n const id = `crash-balloon-${useId().replace(/:/g, \"\")}`;\n const m = growth(t);\n // Everything that scrolls derives from ln(m), so a skip just scrolls faster.\n const climb = PX * Math.log(m);\n const lift = t <= 0 ? 0 : reduce ? 1 : rise(Math.min(1, t / LIFT));\n const by = PARKED + (LEVEL - PARKED) * lift;\n // Sway eases in with the lift and freezes at the crash with the clock.\n const sway = reduce ? 0 : lift;\n const tilt = Math.sin(t * 1.6) * 2 * sway;\n const drift = Math.sin(t * 1.1 + 0.6) * 2 * sway;\n // Clouds speed up as the climb goes on, up to 100×, then hold that speed\n // so a very long climb can't strobe them.\n const eased = Math.min(climb, CLOUD_CAP);\n const travel = reduce ? 0 : climb + eased ** 2 / 600 + (eased / 300) * (climb - eased);\n const tone = lost ? \"text-rose-500\" : cashed !== null ? \"text-muted-foreground\" : \"text-primary\";\n // The basket falls clear of the stage, or stays put if it never left the ground.\n const fall = (H + 10 - (by + 42)) * lift;\n // Where an altitude sits on screen: the tape, its markers and the landmarks share it.\n const at = (value: number) => LEVEL - (Math.log(value) - Math.log(m)) * PX;\n const flagY = cashed === null ? null : at(cashed);\n\n return (\n <svg aria-hidden=\"true\" viewBox={`0 0 ${W} ${H}`} className=\"block w-full\">\n <defs>\n {/* The tape fades out at its ends like a drum turning away. */}\n <linearGradient id={`${id}-fade`} x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n <stop offset=\"0\" stopColor=\"white\" stopOpacity={0} />\n <stop offset=\"0.18\" stopColor=\"white\" stopOpacity={1} />\n <stop offset=\"0.82\" stopColor=\"white\" stopOpacity={1} />\n <stop offset=\"1\" stopColor=\"white\" stopOpacity={0} />\n </linearGradient>\n <mask id={`${id}-tape`} maskUnits=\"userSpaceOnUse\" x={0} y={0} width={W} height={H}>\n <rect width={W} height={H} fill={`url(#${id}-fade)`} />\n </mask>\n </defs>\n\n {/* Clouds and sights stream with t, so a skip would only flicker them:\n they fade out while it runs. Reduced motion keeps the clouds still\n and leaves the sights out, since they would still scroll. */}\n <g className={cn(\"transition-opacity duration-200\", skipping ? \"opacity-0\" : \"opacity-100\")}>\n {CLOUDS.map((cloud) => (\n <g\n key={cloud.id}\n transform={`translate(${cloud.x},${wrap(cloud.y + travel * cloud.speed, SPAN) - 20}) scale(${cloud.size})`}\n opacity={cloud.opacity}\n className=\"fill-foreground\"\n >\n <rect x={-18} y={-4} width={36} height={10} rx={5} />\n <circle cx={-5} cy={-4} r={8} />\n <circle cx={7} cy={-2} r={6} />\n </g>\n ))}\n\n <g\n transform={`translate(0,${reduce ? 0 : climb.toFixed(2)})`}\n className={cn(\n \"transition-opacity duration-200\",\n reduce && t > 0 ? \"opacity-0\" : \"opacity-100\",\n )}\n >\n <rect y={GROUND_Y} width={W} height={H - GROUND_Y} className=\"fill-foreground/[0.05]\" />\n <line x1={0} x2={W} y1={GROUND_Y} y2={GROUND_Y} className=\"stroke-border\" />\n <ellipse\n cx={BX}\n cy={GROUND_Y + 3}\n rx={14}\n ry={2.5}\n opacity={1 - lift}\n className=\"fill-foreground/10\"\n />\n </g>\n\n {reduce ? null : <Landmarks t={t} at={at} />}\n </g>\n\n {/* Ties the balloon to its reading on the tape once it holds altitude. */}\n <line\n x1={BX + 34}\n x2={TAPE_X - 10}\n y1={LEVEL}\n y2={LEVEL}\n strokeDasharray=\"2 4\"\n opacity={lift}\n className=\"stroke-foreground/15\"\n />\n\n <Tape m={m} mask={`url(#${id}-tape)`} />\n\n {ghost !== null ? (\n // Last round's crash point, a quiet trace to climb past.\n <g\n transform={`translate(${TAPE_X},${at(ghost).toFixed(2)})`}\n className=\"text-muted-foreground/60\"\n >\n <motion.g key={ghost} initial={{ opacity: 0 }} animate={{ opacity: 1 }} transition={SWAP}>\n <line x2={12} stroke=\"currentColor\" strokeDasharray=\"2 2\" />\n <path\n d=\"M-8.5,-2.5L-3.5,2.5M-3.5,-2.5L-8.5,2.5\"\n stroke=\"currentColor\"\n strokeWidth={1.25}\n />\n {/* Dropped when it would print over the target's label. */}\n {target !== null &&\n Math.abs(at(ghost) - Math.max(at(target), TARGET_PIN)) < 12 ? null : (\n <text\n x={-12}\n dy=\"0.32em\"\n textAnchor=\"end\"\n className={cn(STAGE_LABEL, \"fill-muted-foreground tabular-nums\")}\n >\n {formatShort(ghost)}\n </text>\n )}\n </motion.g>\n </g>\n ) : null}\n\n <AnimatePresence initial={false}>\n {target !== null ? (\n // The auto target. On the frame it pays it fades and the cash-out\n // flag takes over; the exiting copy keeps its last position.\n <motion.g\n key=\"target\"\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0, transition: EXIT }}\n transition={SWAP}\n className=\"text-primary\"\n >\n {/* The marks stay quiet; the label keeps full contrast. A target\n above the view pins to the top with an arrow, like the plane's. */}\n <g transform={`translate(${TAPE_X},${Math.max(at(target), TARGET_PIN).toFixed(2)})`}>\n {at(target) < TARGET_PIN ? null : (\n <line\n x2={W - TAPE_X}\n stroke=\"currentColor\"\n strokeDasharray=\"3 3\"\n strokeWidth={1.25}\n opacity={0.7}\n />\n )}\n <path\n d=\"M0,0V-10L8,-7L0,-4\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeLinejoin=\"round\"\n opacity={0.7}\n />\n <text\n x={-12}\n dy=\"0.32em\"\n textAnchor=\"end\"\n className={cn(\"fill-current\", STAGE_LABEL, PRIMARY_TEXT)}\n >\n {at(target) < TARGET_PIN ? `target ${formatShort(target)} ↑` : \"target\"}\n </text>\n </g>\n </motion.g>\n ) : null}\n </AnimatePresence>\n\n {flagY !== null ? (\n <g transform={`translate(${TAPE_X},${flagY.toFixed(2)})`} className=\"text-primary\">\n <motion.g\n key={round}\n initial={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.25 }}\n animate={{ opacity: 1, scale: 1 }}\n transition={SWAP}\n >\n <line x1={0} x2={14} y1={0} y2={0} stroke=\"currentColor\" strokeWidth={1.5} />\n <path d=\"M0,0V-10L8,-7L0,-4Z\" fill=\"currentColor\" />\n </motion.g>\n </g>\n ) : null}\n\n <g\n transform={`translate(${TAPE_X},${LEVEL})`}\n className={cn(\"transition-colors duration-150\", lost ? \"text-rose-500\" : \"text-primary\")}\n >\n <line x1={0} x2={W - TAPE_X} opacity={0.5} stroke=\"currentColor\" />\n <motion.g\n key={pulse}\n initial={pulse > 0 && !reduce ? { scale: 1.5 } : false}\n animate={{ scale: 1 }}\n transition={PULSE}\n >\n <path d=\"M-9,-4.5L-2,0L-9,4.5Z\" fill=\"currentColor\" />\n </motion.g>\n </g>\n\n {cashed !== null && !reduce && timeAt(cashed) >= LIFT ? (\n // The player bails out from the basket and drifts down under a chute,\n // once the balloon is aloft; a cash out on the ground has no drop.\n <g transform={`translate(${BX + 8},${(by + 48).toFixed(2)})`}>\n <motion.g\n key={round}\n style={{ transformBox: \"fill-box\", transformOrigin: \"50% 0%\" }}\n initial={{ y: 0, rotate: -10, opacity: 0 }}\n animate={{ y: 96, rotate: [-10, 8, -5, 3, 0], opacity: [0, 1, 1, 0] }}\n transition={CHUTE}\n >\n <motion.g initial={{ scale: 0.5 }} animate={{ scale: 1 }} transition={SWAP}>\n <Parachute />\n </motion.g>\n </motion.g>\n </g>\n ) : null}\n\n <g\n transform={`translate(${BX},${by.toFixed(2)})`}\n className={cn(\"transition-colors duration-150\", tone)}\n >\n {crashed && !reduce ? (\n <g key={`burst-${round}`}>\n <motion.circle\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={2}\n vectorEffect=\"non-scaling-stroke\"\n r={48}\n initial={{ scale: 12 / 48, opacity: 0.7 }}\n animate={{ scale: 1, opacity: 0 }}\n transition={BURST}\n />\n {SHARDS.map((shard) => (\n <motion.path\n key={shard.id}\n d=\"M-3,-2Q0,-4 3,-2L2,2Q0,1 -2,2Z\"\n fill=\"currentColor\"\n initial={{ x: shard.x0, y: shard.y0, rotate: 0, opacity: 1 }}\n animate={{ x: shard.x, y: shard.y, rotate: shard.spin, opacity: 0 }}\n transition={BURST}\n />\n ))}\n </g>\n ) : null}\n {/* Remounts per round, so a new balloon fades in where the last one popped. */}\n <motion.g\n key={round}\n initial={round > 0 ? { opacity: 0 } : false}\n animate={{ opacity: crashed && reduce ? 0 : 1 }}\n transition={{ duration: 0.2, ease: EASE_OUT }}\n >\n <g transform={`translate(${drift.toFixed(2)},0) rotate(${tilt.toFixed(2)})`}>\n <motion.g\n initial={false}\n animate={crashed && !reduce ? { y: fall, rotate: 14 } : { y: 0, rotate: 0 }}\n transition={crashed && !reduce ? DROP : { duration: 0 }}\n >\n <path\n d=\"M-6,31L-5,42M6,31L5,42\"\n stroke=\"currentColor\"\n strokeWidth={0.75}\n opacity={0.6}\n />\n <rect x={-6} y={42} width={12} height={9} rx={1.5} className=\"fill-foreground/60\" />\n <line\n x1={-6.5}\n x2={6.5}\n y1={42.5}\n y2={42.5}\n strokeWidth={1.5}\n className=\"stroke-foreground/70\"\n />\n </motion.g>\n <motion.g\n initial={false}\n animate={crashed && !reduce ? { scale: 1.15, opacity: 0 } : { scale: 1, opacity: 1 }}\n transition={crashed && !reduce ? EXIT : { duration: 0 }}\n >\n <Envelope />\n </motion.g>\n </g>\n </motion.g>\n </g>\n </svg>\n );\n}\n\n/** The altimeter: ticks for the multipliers in view, scrolling down on a log scale as the balloon climbs. */\nfunction Tape({ m, mask }: { m: number; mask: string }) {\n // Multipliers at the top and bottom edges of the stage.\n const top = m * Math.exp(LEVEL / PX);\n const bottom = Math.max(1, m * Math.exp((LEVEL - H) / PX));\n // The finest step still 8 units apart where ticks sit widest; denser ticks\n // further up fade out by spacing, so steps hand over without a jump.\n const base = niceAtLeast((bottom * 8) / PX);\n const ticks: { value: number; y: number; tick: number; label: number }[] = [];\n for (let k = Math.ceil(bottom / base - 1e-9); k * base <= top; k++) {\n const value = Number((k * base).toPrecision(12));\n // A tick's weight is the coarsest step it lands on.\n let level = base;\n for (let step = base; step <= value; step = nextStep(step)) {\n if (Math.abs(value / step - Math.round(value / step)) < 1e-6) level = step;\n }\n const gap = PX * Math.log1p(level / value);\n const tick = clamp01((gap - 8) / 10);\n if (tick === 0) continue;\n ticks.push({\n value,\n y: LEVEL - (Math.log(value) - Math.log(m)) * PX,\n tick,\n label: clamp01((gap - 56) / 16),\n });\n }\n\n return (\n <g mask={mask} className={cn(STAGE_LABEL, \"text-muted-foreground tabular-nums\")}>\n <rect x={TAPE_X} width={W - TAPE_X} height={H} className=\"fill-foreground/[0.03]\" />\n <line x1={TAPE_X} x2={TAPE_X} y1={0} y2={H} className=\"stroke-border\" />\n {ticks.map(({ value, y, tick, label }) => (\n <g key={value} transform={`translate(${TAPE_X},${y.toFixed(2)})`}>\n <line x2={5 + 7 * label} opacity={tick} className=\"stroke-foreground/30\" />\n {/* Right-aligned, so a label grown for a narrow stage stays on it. */}\n {label > 0 ? (\n <text\n x={W - TAPE_X - 2}\n dy=\"0.32em\"\n textAnchor=\"end\"\n opacity={label}\n className=\"fill-current\"\n >\n {formatShort(value)}\n </text>\n ) : null}\n </g>\n ))}\n </g>\n );\n}\n\n// Fixed-altitude sights in the column between the readout and the balloon.\nconst JET_T = timeAt(10);\nconst FLOCK = [\n { id: 0, x: 0, y: 0, phase: 0 },\n { id: 1, x: -11, y: 7, phase: 1.3 },\n { id: 2, x: 10, y: 9, phase: 2.6 },\n];\n\n/** A flock at 3×, a jet at 10× and a satellite at 100×, each brightening as the balloon passes it. */\nfunction Landmarks({ t, at }: { t: number; at: (value: number) => number }) {\n const sights = [\n // Close to the balloon, clear of the readout on narrow stages.\n { value: 3, x: 208 },\n // The jet crosses the column slowly, nose left.\n { value: 10, x: 204 - (t - JET_T) * 2.5 },\n { value: 100, x: 210 },\n ];\n return (\n <g className=\"text-foreground\">\n {sights.map(({ value, x }) => {\n const y = at(value);\n if (y < -30 || y > H + 30) return null;\n // 0.4 at rest, peaking at 0.8 level with the balloon.\n const near =\n Math.abs(y - LEVEL) < 40 ? 0.5 + 0.5 * Math.cos((Math.PI * (y - LEVEL)) / 40) : 0;\n return (\n <g\n key={value}\n transform={`translate(${x.toFixed(2)},${y.toFixed(2)})`}\n opacity={0.4 + 0.4 * near}\n >\n {value === 3 ? (\n FLOCK.map((bird) => {\n const flap = Math.sin(t * 9 + bird.phase) * 2.5;\n const tip = (bird.y - flap).toFixed(2);\n return (\n <path\n key={bird.id}\n d={`M${bird.x - 4},${tip}L${bird.x},${bird.y}L${bird.x + 4},${tip}`}\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={1.25}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n );\n })\n ) : value === 10 ? (\n <g>\n <line\n x1={9}\n x2={30}\n stroke=\"currentColor\"\n strokeWidth={1.5}\n strokeLinecap=\"round\"\n opacity={0.35}\n />\n <path d=\"M-7,0L-4,-1.5H7L9,-4.5H10L9.5,0Z\" fill=\"currentColor\" />\n <path d=\"M-1,-0.5L4,4.5H5.5L3.5,-0.5Z\" fill=\"currentColor\" />\n </g>\n ) : (\n <g>\n <rect x={-3} y={-2.5} width={6} height={5} rx={1} fill=\"currentColor\" />\n <rect x={-13} y={-2} width={8} height={4} fill=\"none\" stroke=\"currentColor\" />\n <rect x={5} y={-2} width={8} height={4} fill=\"none\" stroke=\"currentColor\" />\n <path d=\"M-5,0H-3M3,0H5M0,-2.5V-6\" stroke=\"currentColor\" />\n <circle\n cy={-7}\n r={1.25}\n opacity={Math.sin(t * 5) > 0.2 ? 1 : 0.15}\n className=\"fill-primary\"\n />\n </g>\n )}\n </g>\n );\n })}\n </g>\n );\n}\n\n// The basket drops out of the sky, accelerating.\nconst DROP: Transition = { duration: 0.6, ease: EASE_IN };\n\n// Fabric torn from the envelope, thrown round it and pulled down a little.\nconst SHARDS = Array.from({ length: 8 }, (_, i) => {\n const angle = ((i * 45 + (i % 2) * 12) * Math.PI) / 180;\n const reach = 30 + (i % 3) * 9;\n return {\n id: i,\n x0: Math.cos(angle) * 12,\n y0: Math.sin(angle) * 12,\n x: Math.cos(angle) * reach,\n y: Math.sin(angle) * reach + 14,\n spin: (i % 2 ? 1 : -1) * (120 + i * 25),\n };\n});\n\n// Two depths: far clouds are small, faint and slow; near ones bigger and quicker.\nconst CLOUDS = [\n { id: 0, x: 60, y: 40, size: 0.7, speed: 0.45, opacity: 0.04 },\n { id: 1, x: 200, y: 150, size: 0.6, speed: 0.45, opacity: 0.04 },\n { id: 2, x: 310, y: 250, size: 0.75, speed: 0.45, opacity: 0.04 },\n { id: 3, x: 150, y: 90, size: 1.1, speed: 1.4, opacity: 0.07 },\n { id: 4, x: 290, y: 20, size: 1.2, speed: 1.4, opacity: 0.07 },\n { id: 5, x: 90, y: 220, size: 1, speed: 1.4, opacity: 0.07 },\n];\nconst SPAN = H + 40;\n\n/** The next step up the 1, 2, 5 ladder. */\nfunction nextStep(step: number) {\n const unit = Math.round(step / 10 ** Math.floor(Math.log10(step) + 1e-9));\n return Number((step * (unit === 2 ? 2.5 : 2)).toPrecision(12));\n}\n\n/** The envelope, centred on the origin: a teardrop with a lighter middle gore and a throat. */\nfunction Envelope() {\n return (\n <g>\n <path\n d=\"M0,-26C16,-26 26,-14 26,-2C26,12 12,20 7,28L-7,28C-12,20 -26,12 -26,-2C-26,-14 -16,-26 0,-26Z\"\n fill=\"currentColor\"\n />\n <path d=\"M0,-26C10,-12 10,14 4,28L-4,28C-10,14 -10,-12 0,-26Z\" className=\"fill-card/25\" />\n <rect x={-6} y={28} width={12} height={3} rx={1} fill=\"currentColor\" opacity={0.7} />\n </g>\n );\n}\n\n/**\n * The round as a tiny altimeter, on its own log scale so a skip to a huge\n * crash still reads: the climb rises up the tape, a parachute hangs where you\n * bailed out, the balloon pops at the crash height, and a missed target is a\n * dashed line above it.\n */\nfunction MiniAltitude({ crash, cashed, target, reduce }: CrashMiniatureProps) {\n const top = Math.max(crash, target ?? 1, 1.01);\n // Room above the top level for the popped balloon.\n const y = (value: number) =>\n MINI.height - 4 - (Math.log(value) / Math.log(top)) * (MINI.height - 14);\n const tape = 12;\n const won = cashed !== null;\n const reach = won ? cashed : crash;\n const after = (extra: number) => (reduce ? 0 : MINI_REPLAY.delay + extra);\n const pop = {\n initial: reduce ? { opacity: 0 } : { opacity: 0, scale: 0.25 },\n animate: { opacity: 1, scale: 1 },\n style: { transformBox: \"fill-box\", transformOrigin: \"center\" } as const,\n };\n return (\n <svg\n aria-hidden=\"true\"\n viewBox={`0 0 ${MINI.width} ${MINI.height}`}\n width={MINI.width}\n height={MINI.height}\n className=\"shrink-0 overflow-visible\"\n >\n <line x1={tape} x2={tape} y1={4} y2={MINI.height - 4} className=\"stroke-border\" />\n <line\n x1={tape - 3}\n x2={tape + 3}\n y1={MINI.height - 4}\n y2={MINI.height - 4}\n className=\"stroke-border\"\n />\n {target !== null ? (\n <line\n x1={tape}\n x2={MINI.width - 4}\n y1={y(target)}\n y2={y(target)}\n strokeDasharray=\"2 3\"\n className=\"stroke-muted-foreground/60\"\n />\n ) : null}\n {/* The climb up the tape, replayed. */}\n <motion.line\n x1={tape}\n x2={tape}\n y1={y(1)}\n y2={y(reach)}\n strokeWidth={2.5}\n strokeLinecap=\"round\"\n className={won ? \"stroke-primary\" : \"stroke-rose-500\"}\n initial={{ pathLength: reduce ? 1 : 0 }}\n animate={{ pathLength: 1 }}\n transition={{ ...MINI_REPLAY, delay: after(0) }}\n />\n {won ? (\n <>\n <motion.line\n x1={tape}\n x2={tape}\n y1={y(cashed)}\n y2={y(crash)}\n strokeWidth={1.5}\n strokeDasharray=\"2 3\"\n className=\"stroke-muted-foreground/60\"\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n transition={{ duration: 0.25, ease: EASE_OUT, delay: after(0.5) }}\n />\n <line\n x1={tape}\n x2={34}\n y1={y(cashed)}\n y2={y(cashed)}\n strokeDasharray=\"1 2\"\n className=\"stroke-primary/50\"\n />\n <g transform={`translate(40,${(y(cashed) - 5).toFixed(2)}) scale(0.6)`}>\n <motion.g {...pop} transition={{ ...SWAP, delay: after(0.45) }}>\n <Parachute />\n </motion.g>\n </g>\n </>\n ) : null}\n <line\n x1={tape}\n x2={56}\n y1={y(crash)}\n y2={y(crash)}\n strokeDasharray=\"1 2\"\n className=\"stroke-muted-foreground/50\"\n />\n <g transform={`translate(64,${y(crash).toFixed(2)})`}>\n <motion.g {...pop} transition={{ ...SWAP, delay: after(0.55) }}>\n {/* The popped balloon, faded, with the crash's cross over it. */}\n <g\n transform=\"scale(0.26)\"\n opacity={0.45}\n className={won ? \"text-muted-foreground\" : \"text-rose-500\"}\n >\n <Envelope />\n </g>\n <path\n d=\"M-3,-3L3,3M3,-3L-3,3\"\n strokeWidth={1.75}\n strokeLinecap=\"round\"\n className=\"stroke-rose-500\"\n />\n </motion.g>\n </g>\n </svg>\n );\n}\n"],"mappings":";;;;;;;;AAoCA,MAAM,IAAA;AACN,MAAM,IAAI;AAEV,MAAM,KAAK;AACX,MAAM,SAAS;AAEf,MAAM,QAAQ;AAEd,MAAM,aAAa;AACnB,MAAM,WAAW;AAEjB,MAAM,SAAS;AAEf,MAAM,KAAK;AAEX,MAAM,YAAY,KAAK,KAAK,IAAI,GAAG;AAEnC,MAAM,OAAO;AACb,MAAM,OAAO,YAAY,GAAG,WAAW;;;;;;AAOvC,SAAgB,aAAa,EAC3B,cAAc,YAAY,SAC1B,WACA,GAAG,WACU;CACb,MAAM,OAAO,aAAa,OAAO;CACjC,OACE,oBAAC,YAAD;EACQ;EACN,cAAY;EACD;EACX,YAAY,UAAU,oBAAC,cAAD,EAAc,GAAI,MAAQ,CAAA;EAEhD,UAAA,oBAAC,OAAD;GACE,GAAG,KAAK;GACR,QAAQ,KAAK;GACb,SAAS,KAAK;GACd,MAAM,KAAK;GACX,OAAO,KAAK;GACZ,OAAO,KAAK;GACZ,QAAQ,KAAK;GACb,OAAO,KAAK;GACZ,QAAQ,KAAK;GACb,UAAU,KAAK;EAChB,CAAA;CACS,CAAA;AAEhB;AAeA,SAAS,MAAM,EACb,GACA,QACA,SACA,MACA,OACA,OACA,QACA,OACA,QACA,YACa;CACb,MAAM,KAAK,iBAAiB,MAAM,CAAC,CAAC,QAAQ,MAAM,EAAE;CACpD,MAAM,IAAI,OAAO,CAAC;CAElB,MAAM,QAAQ,KAAK,KAAK,IAAI,CAAC;CAC7B,MAAM,OAAO,KAAK,IAAI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,KAAK;KACX,aAAa;KACb,iBAAgB;KAChB,WAAU;KACV,SAAS,EAAE,SAAS,EAAE;KACtB,SAAS,EAAE,SAAS,EAAE;KACtB,YAAY;MAAE,UAAU;MAAM,MAAM;MAAU,OAAO,MAAM,EAAG;KAAE;IACjE,CAAA;IACD,oBAAC,QAAD;KACE,IAAI;KACJ,IAAI;KACJ,IAAI,EAAE,MAAM;KACZ,IAAI,EAAE,MAAM;KACZ,iBAAgB;KAChB,WAAU;IACX,CAAA;IACD,oBAAC,KAAD;KAAG,WAAW,iBAAiB,EAAE,MAAM,IAAI,EAAA,CAAG,QAAQ,CAAC,EAAE;KACvD,UAAA,oBAAC,OAAO,GAAR;MAAU,GAAI;MAAK,YAAY;OAAE,GAAG;OAAM,OAAO,MAAM,GAAI;MAAE;MAC3D,UAAA,oBAAC,WAAD,CAAY,CAAA;KACJ,CAAA;IACT,CAAA;GACH,EAAA,CAAA,IACA;GACJ,oBAAC,QAAD;IACE,IAAI;IACJ,IAAI;IACJ,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,KAAK;IACX,iBAAgB;IAChB,WAAU;GACX,CAAA;GACD,oBAAC,KAAD;IAAG,WAAW,gBAAgB,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,EAAE;IAChD,UAAA,qBAAC,OAAO,GAAR;KAAU,GAAI;KAAK,YAAY;MAAE,GAAG;MAAM,OAAO,MAAM,GAAI;KAAE;KAA7D,UAAA,CAEE,oBAAC,KAAD;MACE,WAAU;MACV,SAAS;MACT,WAAW,MAAM,0BAA0B;MAE3C,UAAA,oBAAC,UAAD,CAAW,CAAA;KACV,CAAA,GACH,oBAAC,QAAD;MACE,GAAE;MACF,aAAa;MACb,eAAc;MACd,WAAU;KACX,CAAA,CACO;;GACT,CAAA;EACA;;AAET"}
@@ -0,0 +1,59 @@
1
+ import { t as CrashGame } from "../../../use-crash-game-B3RHxFkm.js";
2
+ import { ReactNode } from "react";
3
+ import { Transition } from "motion/react";
4
+ /**
5
+ * Primary for small text: a shade darker on light surfaces and lighter on
6
+ * dark ones, so 10-12px labels keep 4.5:1. Large text and marks use plain
7
+ * primary.
8
+ */
9
+ export declare const PRIMARY_TEXT = "text-[color:color-mix(in_oklab,var(--color-primary)_75%,black)] dark:text-[color:color-mix(in_oklab,var(--color-primary)_80%,white)]";
10
+ /** The width of the viewBox an SVG stage draws in. */
11
+ export declare const STAGE_W = 400;
12
+ /**
13
+ * SVG stage labels: 10px on screen however narrow the card. A viewBox scales
14
+ * its text with the stage, so the shell sets --crash-label in viewBox units.
15
+ * The server render has no width to go on and draws them at 10 units.
16
+ */
17
+ export declare const STAGE_LABEL = "text-[length:var(--crash-label,10px)]";
18
+ /**
19
+ * The frame every design sits in: one card holding the recent rounds and
20
+ * sound, the stage with the readout pinned top left, and the controls. Each
21
+ * design draws only its stage, which must keep the top-left corner clear.
22
+ */
23
+ export declare function CrashShell({ game, "aria-label": ariaLabel, className, children, miniature }: {
24
+ game: CrashGame;
25
+ "aria-label": string;
26
+ className?: string;
27
+ children: ReactNode;
28
+ /** The design's own replay of the round on the result ticket. */
29
+ miniature?: (props: CrashMiniatureProps) => ReactNode;
30
+ }): import("react").JSX.Element;
31
+ /** What a design's ticket miniature replays: the round's crash, your cash out and a missed target. */
32
+ export interface CrashMiniatureProps {
33
+ crash: number;
34
+ cashed: number | null;
35
+ /** Seconds into the flight at the cash out, for designs that count steps. */
36
+ cashedT: number | null;
37
+ /** The auto target, only when the round crashed short of it. */
38
+ target: number | null;
39
+ reduce: boolean;
40
+ }
41
+ export declare const CHUTE: Transition;
42
+ export declare const clamp01: (value: number) => number;
43
+ /** Wraps scenery that streams past into a loop `span` long. */
44
+ export declare const wrap: (value: number, span: number) => number;
45
+ /** A tick step of 1, 2 or 5 times a power of ten, at least `min`. */
46
+ export declare function niceAtLeast(min: number): number;
47
+ /** The parachute that opens at a cash out: a scalloped canopy, three lines and the player. */
48
+ export declare function Parachute(): import("react").JSX.Element;
49
+ /** Every miniature is 88 × 48, like Mines' mini map. */
50
+ export declare const MINI: {
51
+ readonly width: 88;
52
+ readonly height: 48;
53
+ };
54
+ export declare const MINI_REPLAY: {
55
+ readonly delay: 0.3;
56
+ readonly duration: 0.6;
57
+ readonly ease: readonly [0.16, 1, 0.3, 1];
58
+ };
59
+ //# sourceMappingURL=crash-parts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crash-parts.d.ts","names":[],"sources":["../../../../src/components/motion/crash/crash-parts.tsx"],"mappings":";;;;;;;;qBA0Ca;;qBAgBA;;;;;;qBAMA;;;;;;wBAOG,aACd,oBACc,WACd,WACA,UACA;EAEA,MAAM;EACN;EACA;EACA,UAAU;;EAEV,aAAa,OAAO,wBAAwB;oBAC7C,IAAA;;iBA0TgB;EACf;EACA;;EAEA;;EAEA;EACA;;qBAKW,OAAO;qBAMP,UAAW;;qBAGX,OAAQ,eAAe;;wBAGpB,YAAY;;wBASZ,6BAAS,IAAA;;qBAiBZ;;;;qBAEA"}
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ export { t as CHUTE, n as CrashShell, r as MINI, i as MINI_REPLAY, a as PRIMARY_TEXT, o as Parachute, s as STAGE_LABEL, c as STAGE_W, l as clamp01, u as niceAtLeast, d as wrap } from "../../../crash-parts-CUv5gFYQ.js";
@@ -0,0 +1,9 @@
1
+ import { a as formatMultiplier, i as crashPoint, n as CrashProps, r as CrashReveal } from "../../../use-crash-game-B3RHxFkm.js";
2
+ /**
3
+ * A crash game drawn as a tower: a block stacks on at every +8% and the tower
4
+ * sways harder the taller it gets, until the crash topples it. Cash out before
5
+ * it does; your block keeps a flag as the tower carries on without you.
6
+ */
7
+ export declare function CrashTower({ "aria-label": ariaLabel, className, ...options }: CrashProps): import("react").JSX.Element;
8
+ export { type CrashProps, type CrashReveal, crashPoint, formatMultiplier };
9
+ //# sourceMappingURL=crash-tower.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crash-tower.d.ts","names":[],"sources":["../../../../src/components/motion/crash/crash-tower.tsx"],"mappings":";;;;;;wBAuDgB,2BACA,WACd,cACG,WACF,6BAAU,IAAA"}
@@ -0,0 +1,370 @@
1
+ "use client";
2
+ import { EASE_IN, EASE_OUT } from "../../../lib/ease.js";
3
+ import { S as useCrashGame, _ as crashPoint, a as PRIMARY_TEXT, g as SWAP, i as MINI_REPLAY, l as clamp01, m as GROWTH, n as CrashShell, p as EXIT, r as MINI, v as formatMultiplier, y as formatShort } from "../../../crash-parts-CUv5gFYQ.js";
4
+ import { useLayoutEffect, useRef, useState } from "react";
5
+ import { cn } from "@kumix/utils";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
7
+ import { AnimatePresence, motion } from "motion/react";
8
+ // src/components/motion/crash/crash-tower.tsx
9
+ const STEP = 1.08;
10
+ const PER_SECOND = GROWTH / Math.log(STEP);
11
+ const BLOCK_H = 13;
12
+ const PITCH = 16;
13
+ const BASE = 28;
14
+ const TOP_ROOM = 24;
15
+ const MIN_STAGE_H = 200;
16
+ const followFor = (stageH) => Math.max(4, Math.floor((stageH - BASE - TOP_ROOM - BLOCK_H) / PITCH));
17
+ const MAX_SWAY = 4;
18
+ const SWAY_RATE = 2.2;
19
+ const DROP = {
20
+ type: "spring",
21
+ duration: .35,
22
+ bounce: .25
23
+ };
24
+ /**
25
+ * A crash game drawn as a tower: a block stacks on at every +8% and the tower
26
+ * sways harder the taller it gets, until the crash topples it. Cash out before
27
+ * it does; your block keeps a flag as the tower carries on without you.
28
+ */
29
+ function CrashTower({ "aria-label": ariaLabel = "Crash", className, ...options }) {
30
+ const game = useCrashGame(options);
31
+ return /* @__PURE__ */ jsx(CrashShell, {
32
+ game,
33
+ "aria-label": ariaLabel,
34
+ className,
35
+ miniature: (props) => /* @__PURE__ */ jsx(MiniTower, { ...props }),
36
+ children: /* @__PURE__ */ jsx(Tower, { game })
37
+ });
38
+ }
39
+ const width = (k) => 60 + k * 7 % 4 * 4;
40
+ const offset = (k) => (k % 2 ? 1 : -1) * (2 + k * 5 % 3);
41
+ const crack = (k) => {
42
+ const x = 18 + k * 29 % 60;
43
+ const lean = k % 2 ? 6 : -6;
44
+ return k % 3 ? `M${x},0L${x + lean},6L${x - lean / 2},13` : `M${x},0L${x + lean},4L${x - lean},9L${x + lean / 2},13`;
45
+ };
46
+ const blockOf = (m) => Math.floor(Math.log(m) / Math.log(STEP) + 1e-9);
47
+ const blockAt = (t) => Math.floor(t * PER_SECOND + 1e-9);
48
+ const markRise = (m, cam) => (blockOf(m) - cam) * PITCH + BLOCK_H;
49
+ /** The stack, derived from t each frame: count, camera, sway and cracks. */
50
+ function Tower({ game }) {
51
+ const { t, crashed, lost, cashedT, round, reduce, target, ghost } = game;
52
+ const stage = useRef(null);
53
+ const [stageH, setStageH] = useState(MIN_STAGE_H);
54
+ useLayoutEffect(() => {
55
+ const node = stage.current;
56
+ if (!node) return;
57
+ const measure = () => setStageH(node.clientHeight);
58
+ measure();
59
+ const observer = new ResizeObserver(measure);
60
+ observer.observe(node);
61
+ return () => observer.disconnect();
62
+ }, []);
63
+ const follow = followFor(stageH);
64
+ const b = t * PER_SECOND;
65
+ const top = Math.floor(b + 1e-9);
66
+ const cam = Math.max(0, b - follow);
67
+ const lowest = Math.max(0, Math.floor(cam) - 3);
68
+ const strain = clamp01((b - 8) / 12);
69
+ const amp = reduce ? 0 : Math.min(MAX_SWAY, b * .22);
70
+ const phase = t * SWAY_RATE;
71
+ const angle = amp * (.8 * Math.sin(phase) + .2 * Math.sin(phase * 1.7 + 1));
72
+ const bend = amp * 1.5 * Math.sin(phase - .9);
73
+ const cashK = cashedT === null ? null : blockAt(cashedT);
74
+ const marked = [ghost, target].flatMap((m) => m === null ? [] : [blockOf(m)]);
75
+ const breakK = Math.max(0, top - 4 - round % 3);
76
+ const dir = angle < 0 ? -1 : 1;
77
+ const blocks = Array.from({ length: top - lowest + 1 }, (_, i) => lowest + i);
78
+ const ceiling = stageH - BASE - 10;
79
+ return /* @__PURE__ */ jsxs("div", {
80
+ ref: stage,
81
+ "aria-hidden": "true",
82
+ className: "absolute inset-0 overflow-hidden",
83
+ children: [
84
+ /* @__PURE__ */ jsxs("div", {
85
+ className: "absolute inset-x-0 bottom-0",
86
+ style: {
87
+ height: BASE,
88
+ transform: `translateY(${(cam * PITCH).toFixed(2)}px)`
89
+ },
90
+ children: [/* @__PURE__ */ jsx("div", { className: "border-border absolute inset-x-0 top-2 border-t" }), /* @__PURE__ */ jsx("div", { className: "bg-foreground/20 absolute top-0 left-[72%] h-2 w-28 -translate-x-1/2 rounded-[3px]" })]
91
+ }),
92
+ /* @__PURE__ */ jsxs(AnimatePresence, {
93
+ initial: false,
94
+ children: [ghost !== null && (target === null || Math.abs(Math.min(markRise(ghost, cam), ceiling) - Math.min(markRise(target, cam), ceiling)) >= 12) ? /* @__PURE__ */ jsx(Mark, {
95
+ rise: markRise(ghost, cam),
96
+ ceiling,
97
+ label: `Last ${formatShort(ghost)}`,
98
+ className: "border-muted-foreground/30 text-muted-foreground"
99
+ }, "ghost") : null, target !== null ? /* @__PURE__ */ jsx(Mark, {
100
+ rise: markRise(target, cam),
101
+ ceiling,
102
+ label: `Target ${formatShort(target)}`,
103
+ className: cn("border-primary/70", PRIMARY_TEXT)
104
+ }, "target") : null]
105
+ }),
106
+ /* @__PURE__ */ jsx("div", {
107
+ className: "absolute left-[72%]",
108
+ style: {
109
+ bottom: BASE,
110
+ transform: `rotate(${angle.toFixed(3)}deg)`
111
+ },
112
+ children: blocks.map((k) => {
113
+ const rise = k - cam;
114
+ const lift = rise / follow;
115
+ const w = width(k);
116
+ const x = offset(k) + bend * lift * lift - w / 2;
117
+ const y = -rise * PITCH - BLOCK_H;
118
+ const falling = crashed && k >= breakK;
119
+ const n = k - breakK;
120
+ const load = clamp01((top - k - 4) / 10) * strain;
121
+ return /* @__PURE__ */ jsx("div", {
122
+ className: "absolute top-0 left-0",
123
+ style: {
124
+ width: w,
125
+ height: BLOCK_H,
126
+ transform: `translate(${x.toFixed(2)}px,${y.toFixed(2)}px)`
127
+ },
128
+ children: /* @__PURE__ */ jsxs(motion.div, {
129
+ className: cn("relative size-full rounded-[4px] transition-colors duration-150", k === cashK ? "bg-primary" : falling ? lost ? "bg-rose-500" : "bg-muted-foreground/40" : k % 2 ? "bg-foreground/15" : "bg-foreground/10"),
130
+ initial: round === 0 || game.skipping ? false : reduce ? { opacity: 0 } : {
131
+ opacity: 0,
132
+ y: -24
133
+ },
134
+ animate: falling && !reduce ? {
135
+ x: dir * (20 + n * 12),
136
+ y: 160 + n * 6,
137
+ rotate: dir * (50 + n * 18 + k % 3 * 12),
138
+ opacity: [
139
+ 1,
140
+ 1,
141
+ 0
142
+ ]
143
+ } : {
144
+ x: 0,
145
+ y: 0,
146
+ rotate: 0,
147
+ opacity: falling ? .35 : 1
148
+ },
149
+ transition: falling && !reduce ? {
150
+ duration: .6,
151
+ ease: EASE_IN,
152
+ delay: (top - k) * .025,
153
+ opacity: {
154
+ duration: .6,
155
+ times: [
156
+ 0,
157
+ .7,
158
+ 1
159
+ ],
160
+ delay: (top - k) * .025
161
+ }
162
+ } : reduce ? {
163
+ duration: .15,
164
+ ease: EASE_OUT
165
+ } : DROP,
166
+ children: [
167
+ load > 0 ? /* @__PURE__ */ jsx("svg", {
168
+ "aria-hidden": "true",
169
+ viewBox: "0 0 100 13",
170
+ preserveAspectRatio: "none",
171
+ className: "absolute inset-0 size-full",
172
+ style: { opacity: load },
173
+ children: /* @__PURE__ */ jsx("path", {
174
+ d: crack(k),
175
+ fill: "none",
176
+ strokeWidth: 1,
177
+ vectorEffect: "non-scaling-stroke",
178
+ strokeLinejoin: "round",
179
+ className: "stroke-foreground/35"
180
+ })
181
+ }) : null,
182
+ k > 0 && k % 5 === 0 && !marked.some((g) => k === g || k === g + 1) ? /* @__PURE__ */ jsx("span", {
183
+ className: cn("text-muted-foreground absolute top-1/2 left-full -translate-y-1/2 text-[10px] leading-none tabular-nums", k === cashK ? "ml-6" : "ml-2"),
184
+ children: formatShort(STEP ** k)
185
+ }) : null,
186
+ k === cashK ? /* @__PURE__ */ jsx(motion.span, {
187
+ className: "bg-primary absolute top-1/2 left-full ml-0.5 h-2.5 w-3.5 origin-left -translate-y-1/2 [clip-path:polygon(0_0,0_100%,100%_50%)]",
188
+ initial: reduce ? { opacity: 0 } : {
189
+ opacity: 0,
190
+ scale: .25
191
+ },
192
+ animate: {
193
+ opacity: 1,
194
+ scale: 1
195
+ },
196
+ transition: SWAP
197
+ }, `flag-${round}`) : null
198
+ ]
199
+ })
200
+ }, `${round}-${k}`);
201
+ })
202
+ })
203
+ ]
204
+ });
205
+ }
206
+ /** A dashed height line across the tower column; it sinks with the camera and fades out. */
207
+ function Mark({ rise, ceiling, label, className }) {
208
+ const pinned = rise > ceiling;
209
+ return /* @__PURE__ */ jsx(motion.div, {
210
+ className: cn("absolute right-3 left-[calc(72%-3.5rem)] border-t border-dashed", className),
211
+ style: {
212
+ bottom: BASE,
213
+ y: -Math.min(rise, ceiling)
214
+ },
215
+ initial: { opacity: 0 },
216
+ animate: { opacity: 1 },
217
+ exit: {
218
+ opacity: 0,
219
+ transition: EXIT
220
+ },
221
+ transition: {
222
+ duration: .15,
223
+ ease: EASE_OUT
224
+ },
225
+ children: /* @__PURE__ */ jsxs("span", {
226
+ className: "absolute right-0 bottom-0.5 text-[10px] leading-none font-medium tabular-nums",
227
+ children: [pinned ? "↑ " : "", label]
228
+ })
229
+ });
230
+ }
231
+ const MINI_LAND = {
232
+ type: "spring",
233
+ duration: .3,
234
+ bounce: .3
235
+ };
236
+ const MINI_ROWS = 10;
237
+ /**
238
+ * The round as a tiny tower, rebuilt row by row: a row stands for one or more
239
+ * blocks so any height fits, your cash-out row is blue with a pennant, a
240
+ * missed target is a dashed line, and the top rows topple off at the crash.
241
+ */
242
+ function MiniTower({ crash, cashed, cashedT, target, reduce }) {
243
+ const blocks = blockOf(crash) + 1;
244
+ const per = Math.ceil(blocks / MINI_ROWS);
245
+ const rows = Math.ceil(blocks / per);
246
+ const rowOf = (block) => Math.min(rows - 1, Math.floor(block / per));
247
+ const cashRow = cashedT === null ? null : rowOf(blockAt(cashedT));
248
+ const fallen = rows > 1 ? Math.min(3, rows - 1) : 0;
249
+ const base = MINI.height - 4;
250
+ const rowY = (r) => base - 4 * (r + 1);
251
+ const cx = 40;
252
+ const step = Math.min(.05, .5 / rows);
253
+ const built = reduce ? 0 : MINI_REPLAY.delay + rows * step;
254
+ const lost = cashed === null;
255
+ return /* @__PURE__ */ jsxs("svg", {
256
+ "aria-hidden": "true",
257
+ viewBox: `0 0 ${MINI.width} ${MINI.height}`,
258
+ width: MINI.width,
259
+ height: MINI.height,
260
+ className: "shrink-0 overflow-visible",
261
+ children: [
262
+ /* @__PURE__ */ jsx("rect", {
263
+ x: 24,
264
+ y: base,
265
+ width: 32,
266
+ height: 2,
267
+ rx: 1,
268
+ className: "fill-foreground/30"
269
+ }),
270
+ target !== null ? /* @__PURE__ */ jsx("line", {
271
+ x1: 6,
272
+ x2: MINI.width - 6,
273
+ y1: Math.max(2, Math.min(rowY(Math.floor(blockOf(target) / per)), rowY(rows - 1) - 3)),
274
+ y2: Math.max(2, Math.min(rowY(Math.floor(blockOf(target) / per)), rowY(rows - 1) - 3)),
275
+ strokeDasharray: "2 3",
276
+ className: "stroke-muted-foreground/60"
277
+ }) : null,
278
+ Array.from({ length: rows }, (_, r) => {
279
+ const w = width(r) / 72 * 28;
280
+ const x = cx + offset(r) * .4 - w / 2;
281
+ const topple = r >= rows - fallen;
282
+ const pile = r - (rows - fallen);
283
+ const isCash = r === cashRow;
284
+ return /* @__PURE__ */ jsx("g", { children: /* @__PURE__ */ jsxs(motion.g, {
285
+ style: {
286
+ transformBox: "fill-box",
287
+ transformOrigin: "center"
288
+ },
289
+ initial: reduce ? { opacity: 0 } : {
290
+ opacity: 0,
291
+ y: -4
292
+ },
293
+ animate: topple && !reduce ? {
294
+ opacity: [
295
+ 0,
296
+ 1,
297
+ 1,
298
+ .7
299
+ ],
300
+ y: [
301
+ -4,
302
+ 0,
303
+ 0,
304
+ base - 3 - pile * 3.5 - rowY(r)
305
+ ],
306
+ x: [
307
+ 0,
308
+ 0,
309
+ 0,
310
+ 33 + pile * 2
311
+ ],
312
+ rotate: [
313
+ 0,
314
+ 0,
315
+ 0,
316
+ pile % 2 ? -3 : 4
317
+ ]
318
+ } : {
319
+ opacity: 1,
320
+ y: 0
321
+ },
322
+ transition: topple && !reduce ? {
323
+ duration: .75,
324
+ times: [
325
+ 0,
326
+ .4,
327
+ .5,
328
+ 1
329
+ ],
330
+ ease: EASE_IN,
331
+ delay: MINI_REPLAY.delay + r * step
332
+ } : {
333
+ ...MINI_LAND,
334
+ delay: reduce ? 0 : MINI_REPLAY.delay + r * step
335
+ },
336
+ children: [/* @__PURE__ */ jsx("rect", {
337
+ x,
338
+ y: rowY(r),
339
+ width: w,
340
+ height: 3,
341
+ rx: 1,
342
+ className: cn(isCash ? "fill-primary" : topple ? lost ? "fill-rose-500" : "fill-muted-foreground/60" : "fill-foreground/25")
343
+ }), isCash ? /* @__PURE__ */ jsx(motion.path, {
344
+ d: `M${x - 1},${rowY(r) + 1.5}l-6,-3v6z`,
345
+ className: "fill-primary",
346
+ initial: reduce ? { opacity: 0 } : {
347
+ opacity: 0,
348
+ scale: .25
349
+ },
350
+ animate: {
351
+ opacity: 1,
352
+ scale: 1
353
+ },
354
+ style: {
355
+ transformBox: "fill-box",
356
+ transformOrigin: "right center"
357
+ },
358
+ transition: {
359
+ ...SWAP,
360
+ delay: built
361
+ }
362
+ }) : null]
363
+ }) }, r);
364
+ })
365
+ ]
366
+ });
367
+ }
368
+ export { CrashTower, crashPoint, formatMultiplier };
369
+
370
+ //# sourceMappingURL=crash-tower.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crash-tower.js","names":[],"sources":["../../../../src/components/motion/crash/crash-tower.tsx"],"sourcesContent":["\"use client\";\n\nimport { useLayoutEffect, useRef, useState } from \"react\";\nimport { AnimatePresence, motion, type Transition } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_IN, EASE_OUT } from \"../../../lib/ease\";\nimport {\n type CrashMiniatureProps,\n CrashShell,\n clamp01,\n MINI,\n MINI_REPLAY,\n PRIMARY_TEXT,\n} from \"./crash-parts\";\nimport {\n type CrashGame,\n type CrashProps,\n EXIT,\n formatShort,\n GROWTH,\n SWAP,\n useCrashGame,\n} from \"./use-crash-game\";\n\nexport { type CrashProps, type CrashReveal, crashPoint, formatMultiplier } from \"./use-crash-game\";\n\n// One block per +8% on the multiplier, so block k lands at exactly 1.08^k:\n// one every 0.64s, while the readout keeps accelerating.\nconst STEP = 1.08;\nconst PER_SECOND = GROWTH / Math.log(STEP);\n// Block geometry in px. The baseline is the slab's top, measured from the stage bottom.\nconst BLOCK_H = 13;\nconst PITCH = 16;\nconst BASE = 28;\n// The stage is 10:7, so its height scales with width (up to about 297px, under 200px on narrow cards).\n// The camera follow threshold comes from the measured height, keeping the top\n// block 24px under the stage edge. Before measuring it assumes the smallest\n// stage, so the server render never pokes out of the top.\nconst TOP_ROOM = 24;\nconst MIN_STAGE_H = 200;\nconst followFor = (stageH: number) =>\n Math.max(4, Math.floor((stageH - BASE - TOP_ROOM - BLOCK_H) / PITCH));\n// Sway grows with height up to this many degrees.\nconst MAX_SWAY = 4;\nconst SWAY_RATE = 2.2;\n\n// A block lands with a little give, which reads as stacked by hand.\nconst DROP: Transition = { type: \"spring\", duration: 0.35, bounce: 0.25 };\n\n/**\n * A crash game drawn as a tower: a block stacks on at every +8% and the tower\n * sways harder the taller it gets, until the crash topples it. Cash out before\n * it does; your block keeps a flag as the tower carries on without you.\n */\nexport function CrashTower({\n \"aria-label\": ariaLabel = \"Crash\",\n className,\n ...options\n}: CrashProps) {\n const game = useCrashGame(options);\n // The tower stands at 72% across with its labels and pennant on its right, so\n // nothing reaches back under the shell's readout, even on a narrow stage.\n return (\n <CrashShell\n game={game}\n aria-label={ariaLabel}\n className={className}\n miniature={(props) => <MiniTower {...props} />}\n >\n <Tower game={game} />\n </CrashShell>\n );\n}\n\n// Slightly varied widths and alternating offsets, fixed per index, so it reads as hand-stacked.\nconst width = (k: number) => 60 + ((k * 7) % 4) * 4;\nconst offset = (k: number) => (k % 2 ? 1 : -1) * (2 + ((k * 5) % 3));\n// A fixed jagged crack per block, 2 or 3 segments, in a 100x13 box stretched to the block.\nconst crack = (k: number) => {\n const x = 18 + ((k * 29) % 60);\n const lean = k % 2 ? 6 : -6;\n return k % 3\n ? `M${x},0L${x + lean},6L${x - lean / 2},13`\n : `M${x},0L${x + lean},4L${x - lean},9L${x + lean / 2},13`;\n};\n// The top surface of the block on top when the multiplier reaches m, in px over the baseline.\nconst blockOf = (m: number) => Math.floor(Math.log(m) / Math.log(STEP) + 1e-9);\n// The block on top at a time into the flight.\nconst blockAt = (t: number) => Math.floor(t * PER_SECOND + 1e-9);\nconst markRise = (m: number, cam: number) => (blockOf(m) - cam) * PITCH + BLOCK_H;\n\n/** The stack, derived from t each frame: count, camera, sway and cracks. */\nfunction Tower({ game }: { game: CrashGame }) {\n const { t, crashed, lost, cashedT, round, reduce, target, ghost } = game;\n const stage = useRef<HTMLDivElement>(null);\n const [stageH, setStageH] = useState(MIN_STAGE_H);\n useLayoutEffect(() => {\n const node = stage.current;\n if (!node) return;\n const measure = () => setStageH(node.clientHeight);\n measure();\n const observer = new ResizeObserver(measure);\n observer.observe(node);\n return () => observer.disconnect();\n }, []);\n const follow = followFor(stageH);\n\n const b = t * PER_SECOND;\n const top = Math.floor(b + 1e-9);\n // Continuous, so the stack sinks smoothly between landings.\n const cam = Math.max(0, b - follow);\n // Blocks below this are past the stage bottom.\n const lowest = Math.max(0, Math.floor(cam) - 3);\n // Cracks need some height first, then spread up from the base.\n const strain = clamp01((b - 8) / 12);\n\n const amp = reduce ? 0 : Math.min(MAX_SWAY, b * 0.22);\n const phase = t * SWAY_RATE;\n const angle = amp * (0.8 * Math.sin(phase) + 0.2 * Math.sin(phase * 1.7 + 1));\n // The upper blocks lag the sway a little, so the tower bends rather than pivots.\n const bend = amp * 1.5 * Math.sin(phase - 0.9);\n\n // From the cash-out time, not the value: the value is floored to two\n // decimals and can fall just below the block that was on top.\n const cashK = cashedT === null ? null : blockAt(cashedT);\n // A mark's line sits on top of its block, so the labels of that block and\n // the next would print over the mark's own.\n const marked = [ghost, target].flatMap((m) => (m === null ? [] : [blockOf(m)]));\n // The crash breaks the top few blocks off, tipping the way the tower leans.\n const breakK = Math.max(0, top - 4 - (round % 3));\n const dir = angle < 0 ? -1 : 1;\n\n const blocks = Array.from({ length: top - lowest + 1 }, (_, i) => lowest + i);\n // Marks above the view pin to the top edge with a caret, so a far target stays readable.\n const ceiling = stageH - BASE - 10;\n\n return (\n <div ref={stage} aria-hidden=\"true\" className=\"absolute inset-0 overflow-hidden\">\n {/* Ground and slab sink with the camera but never sway. */}\n <div\n className=\"absolute inset-x-0 bottom-0\"\n style={{ height: BASE, transform: `translateY(${(cam * PITCH).toFixed(2)}px)` }}\n >\n <div className=\"border-border absolute inset-x-0 top-2 border-t\" />\n <div className=\"bg-foreground/20 absolute top-0 left-[72%] h-2 w-28 -translate-x-1/2 rounded-[3px]\" />\n </div>\n\n <AnimatePresence initial={false}>\n {ghost !== null &&\n // Dropped when it would print over the target's label (both pinned\n // at the top, or within 12px).\n (target === null ||\n Math.abs(\n Math.min(markRise(ghost, cam), ceiling) - Math.min(markRise(target, cam), ceiling),\n ) >= 12) ? (\n <Mark\n key=\"ghost\"\n rise={markRise(ghost, cam)}\n ceiling={ceiling}\n label={`Last ${formatShort(ghost)}`}\n className=\"border-muted-foreground/30 text-muted-foreground\"\n />\n ) : null}\n {target !== null ? (\n <Mark\n key=\"target\"\n rise={markRise(target, cam)}\n ceiling={ceiling}\n label={`Target ${formatShort(target)}`}\n className={cn(\"border-primary/70\", PRIMARY_TEXT)}\n />\n ) : null}\n </AnimatePresence>\n\n {/* A zero-size anchor on the baseline, so the sway pivots there. */}\n <div\n className=\"absolute left-[72%]\"\n style={{ bottom: BASE, transform: `rotate(${angle.toFixed(3)}deg)` }}\n >\n {blocks.map((k) => {\n const rise = k - cam;\n const lift = rise / follow;\n const w = width(k);\n const x = offset(k) + bend * lift * lift - w / 2;\n const y = -rise * PITCH - BLOCK_H;\n const falling = crashed && k >= breakK;\n const n = k - breakK;\n const load = clamp01((top - k - 4) / 10) * strain;\n return (\n <div\n key={`${round}-${k}`}\n className=\"absolute top-0 left-0\"\n style={{\n width: w,\n height: BLOCK_H,\n transform: `translate(${x.toFixed(2)}px,${y.toFixed(2)}px)`,\n }}\n >\n <motion.div\n className={cn(\n \"relative size-full rounded-[4px] transition-colors duration-150\",\n k === cashK\n ? \"bg-primary\"\n : falling\n ? lost\n ? \"bg-rose-500\"\n : \"bg-muted-foreground/40\"\n : k % 2\n ? \"bg-foreground/15\"\n : \"bg-foreground/10\",\n )}\n // The idle block is already standing on first paint. A skip lays\n // several blocks a frame that scroll off before a drop could\n // finish, so they land at once.\n initial={\n round === 0 || game.skipping\n ? false\n : reduce\n ? { opacity: 0 }\n : { opacity: 0, y: -24 }\n }\n animate={\n falling && !reduce\n ? {\n x: dir * (20 + n * 12),\n y: 160 + n * 6,\n rotate: dir * (50 + n * 18 + (k % 3) * 12),\n opacity: [1, 1, 0],\n }\n : // Under reduced motion the broken top fades instead of falling.\n { x: 0, y: 0, rotate: 0, opacity: falling ? 0.35 : 1 }\n }\n transition={\n falling && !reduce\n ? {\n duration: 0.6,\n ease: EASE_IN,\n // The top lets go first.\n delay: (top - k) * 0.025,\n opacity: { duration: 0.6, times: [0, 0.7, 1], delay: (top - k) * 0.025 },\n }\n : reduce\n ? { duration: 0.15, ease: EASE_OUT }\n : DROP\n }\n >\n {load > 0 ? (\n // The load on this block, read straight from the height: no motion of its own.\n <svg\n aria-hidden=\"true\"\n viewBox=\"0 0 100 13\"\n preserveAspectRatio=\"none\"\n className=\"absolute inset-0 size-full\"\n style={{ opacity: load }}\n >\n <path\n d={crack(k)}\n fill=\"none\"\n strokeWidth={1}\n vectorEffect=\"non-scaling-stroke\"\n strokeLinejoin=\"round\"\n className=\"stroke-foreground/35\"\n />\n </svg>\n ) : null}\n {k > 0 && k % 5 === 0 && !marked.some((g) => k === g || k === g + 1) ? (\n <span\n className={cn(\n \"text-muted-foreground absolute top-1/2 left-full -translate-y-1/2 text-[10px] leading-none tabular-nums\",\n k === cashK ? \"ml-6\" : \"ml-2\",\n )}\n >\n {formatShort(STEP ** k)}\n </span>\n ) : null}\n {k === cashK ? (\n // Where you bailed: a pennant off your block's right side, clear of the blocks above.\n <motion.span\n key={`flag-${round}`}\n className=\"bg-primary absolute top-1/2 left-full ml-0.5 h-2.5 w-3.5 origin-left -translate-y-1/2 [clip-path:polygon(0_0,0_100%,100%_50%)]\"\n initial={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.25 }}\n animate={{ opacity: 1, scale: 1 }}\n transition={SWAP}\n />\n ) : null}\n </motion.div>\n </div>\n );\n })}\n </div>\n </div>\n );\n}\n\n/** A dashed height line across the tower column; it sinks with the camera and fades out. */\nfunction Mark({\n rise,\n ceiling,\n label,\n className,\n}: {\n rise: number;\n ceiling: number;\n label: string;\n className: string;\n}) {\n const pinned = rise > ceiling;\n return (\n <motion.div\n className={cn(\"absolute right-3 left-[calc(72%-3.5rem)] border-t border-dashed\", className)}\n // `y` is a transform, so the per-frame sink never touches layout.\n style={{ bottom: BASE, y: -Math.min(rise, ceiling) }}\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0, transition: EXIT }}\n transition={{ duration: 0.15, ease: EASE_OUT }}\n >\n <span className=\"absolute right-0 bottom-0.5 text-[10px] leading-none font-medium tabular-nums\">\n {pinned ? \"↑ \" : \"\"}\n {label}\n </span>\n </motion.div>\n );\n}\n\n// The mini stack's rows pop on with a small overshoot, like Mines' mini map\n// cells: each is 3px tall, so a bounce reads as a block landing.\nconst MINI_LAND: Transition = { type: \"spring\", duration: 0.3, bounce: 0.3 };\nconst MINI_ROWS = 10;\n\n/**\n * The round as a tiny tower, rebuilt row by row: a row stands for one or more\n * blocks so any height fits, your cash-out row is blue with a pennant, a\n * missed target is a dashed line, and the top rows topple off at the crash.\n */\nfunction MiniTower({ crash, cashed, cashedT, target, reduce }: CrashMiniatureProps) {\n const blocks = blockOf(crash) + 1;\n const per = Math.ceil(blocks / MINI_ROWS);\n const rows = Math.ceil(blocks / per);\n const rowOf = (block: number) => Math.min(rows - 1, Math.floor(block / per));\n const cashRow = cashedT === null ? null : rowOf(blockAt(cashedT));\n const fallen = rows > 1 ? Math.min(3, rows - 1) : 0;\n const base = MINI.height - 4;\n const rowY = (r: number) => base - 4 * (r + 1);\n const cx = 40;\n // Rows land over at most 0.5s however tall the tower got.\n const step = Math.min(0.05, 0.5 / rows);\n const built = reduce ? 0 : MINI_REPLAY.delay + rows * step;\n const lost = cashed === null;\n return (\n <svg\n aria-hidden=\"true\"\n viewBox={`0 0 ${MINI.width} ${MINI.height}`}\n width={MINI.width}\n height={MINI.height}\n className=\"shrink-0 overflow-visible\"\n >\n <rect x={cx - 16} y={base} width={32} height={2} rx={1} className=\"fill-foreground/30\" />\n {target !== null ? (\n // A missed target sits above the top row even when it falls in that\n // row's blocks, and one far above the tower pins to the top edge.\n <line\n x1={6}\n x2={MINI.width - 6}\n y1={Math.max(2, Math.min(rowY(Math.floor(blockOf(target) / per)), rowY(rows - 1) - 3))}\n y2={Math.max(2, Math.min(rowY(Math.floor(blockOf(target) / per)), rowY(rows - 1) - 3))}\n strokeDasharray=\"2 3\"\n className=\"stroke-muted-foreground/60\"\n />\n ) : null}\n {Array.from({ length: rows }, (_, r) => {\n const w = (width(r) / 72) * 28;\n const x = cx + offset(r) * 0.4 - w / 2;\n const topple = r >= rows - fallen;\n // Fallen rows land in a pile beside the tower: the lowest falls\n // first and lies at the bottom.\n const pile = r - (rows - fallen);\n const isCash = r === cashRow;\n return (\n <g key={r}>\n <motion.g\n style={{ transformBox: \"fill-box\", transformOrigin: \"center\" }}\n initial={reduce ? { opacity: 0 } : { opacity: 0, y: -4 }}\n animate={\n topple && !reduce\n ? {\n opacity: [0, 1, 1, 0.7],\n y: [-4, 0, 0, base - 3 - pile * 3.5 - rowY(r)],\n x: [0, 0, 0, 33 + pile * 2],\n rotate: [0, 0, 0, pile % 2 ? -3 : 4],\n }\n : { opacity: 1, y: 0 }\n }\n transition={\n topple && !reduce\n ? {\n duration: 0.3 + 0.45,\n times: [0, 0.4, 0.5, 1],\n ease: EASE_IN,\n delay: MINI_REPLAY.delay + r * step,\n }\n : { ...MINI_LAND, delay: reduce ? 0 : MINI_REPLAY.delay + r * step }\n }\n >\n <rect\n x={x}\n y={rowY(r)}\n width={w}\n height={3}\n rx={1}\n // Your cash-out row stays blue even when it is among the rows\n // that topple, as it does on the big tower.\n className={cn(\n isCash\n ? \"fill-primary\"\n : topple\n ? lost\n ? \"fill-rose-500\"\n : \"fill-muted-foreground/60\"\n : \"fill-foreground/25\",\n )}\n />\n {isCash ? (\n // Inside the row's group, so the pennant falls with it.\n <motion.path\n d={`M${x - 1},${rowY(r) + 1.5}l-6,-3v6z`}\n className=\"fill-primary\"\n initial={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.25 }}\n animate={{ opacity: 1, scale: 1 }}\n style={{ transformBox: \"fill-box\", transformOrigin: \"right center\" }}\n transition={{ ...SWAP, delay: built }}\n />\n ) : null}\n </motion.g>\n </g>\n );\n })}\n </svg>\n );\n}\n"],"mappings":";;;;;;;;AA6BA,MAAM,OAAO;AACb,MAAM,aAAa,SAAS,KAAK,IAAI,IAAI;AAEzC,MAAM,UAAU;AAChB,MAAM,QAAQ;AACd,MAAM,OAAO;AAKb,MAAM,WAAW;AACjB,MAAM,cAAc;AACpB,MAAM,aAAa,WACjB,KAAK,IAAI,GAAG,KAAK,OAAO,SAAS,OAAO,WAAW,WAAW,KAAK,CAAC;AAEtE,MAAM,WAAW;AACjB,MAAM,YAAY;AAGlB,MAAM,OAAmB;CAAE,MAAM;CAAU,UAAU;CAAM,QAAQ;AAAK;;;;;;AAOxE,SAAgB,WAAW,EACzB,cAAc,YAAY,SAC1B,WACA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N,OAAO,YAAY,QAAQ,IAAI;KACjC,IACA;MAAE,GAAG;MAAW,OAAO,SAAS,IAAI,YAAY,QAAQ,IAAI;KAAK;KArBzE,UAAA,CAwBE,oBAAC,QAAD;MACK;MACH,GAAG,KAAK,CAAC;MACT,OAAO;MACP,QAAQ;MACR,IAAI;MAGJ,WAAW,GACT,SACI,iBACA,SACE,OACE,kBACA,6BACF,oBACR;KACD,CAAA,GACA,SAEC,oBAAC,OAAO,MAAR;MACE,GAAG,IAAI,IAAI,EAAE,GAAG,KAAK,CAAC,IAAI,IAAI;MAC9B,WAAU;MACV,SAAS,SAAS,EAAE,SAAS,EAAE,IAAI;OAAE,SAAS;OAAG,OAAO;MAAK;MAC7D,SAAS;OAAE,SAAS;OAAG,OAAO;MAAE;MAChC,OAAO;OAAE,cAAc;OAAY,iBAAiB;MAAe;MACnE,YAAY;OAAE,GAAG;OAAM,OAAO;MAAM;KACrC,CAAA,IACC,IACI;IACT,CAAA,EAAA,GAvDK,CAuDL;GAEP,CAAC;EACE;;AAET"}
@@ -0,0 +1,9 @@
1
+ import { a as formatMultiplier, i as crashPoint, n as CrashProps, r as CrashReveal } from "../../use-crash-game-B3RHxFkm.js";
2
+ /**
3
+ * A crash game: a paper plane flies the multiplier up a curve until it
4
+ * crashes at a random point. Cash out before it does. After a cash out the
5
+ * flight keeps going, so the player sees what they left on the table.
6
+ */
7
+ export declare function Crash({ "aria-label": ariaLabel, className, ...options }: CrashProps): import("react").JSX.Element;
8
+ export { type CrashProps, type CrashReveal, crashPoint, formatMultiplier };
9
+ //# sourceMappingURL=crash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crash.d.ts","names":[],"sources":["../../../src/components/motion/crash.tsx"],"mappings":";;;;;;wBA0DgB,sBAAsB,WAAqB,cAAc,WAAW,6BAAU,IAAA"}