ponzu 1.77.0 → 1.78.1

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/dist/index.js CHANGED
@@ -15560,6 +15560,13 @@ var BLOCKED_TAGS = new Set([
15560
15560
  ]);
15561
15561
  var URL_ATTRS = new Set(["href", "src", "xlink:href", "action", "formaction", "poster", "data"]);
15562
15562
  var RAW_TEXT = new Set(["style"]);
15563
+ var ACT_SCRIPT_TYPE = "ponzu/act";
15564
+ function isActScript(el) {
15565
+ if (el.tagName.toLowerCase() !== "script")
15566
+ return false;
15567
+ const type = el.attrs.find((a) => !a.prefix && a.name.toLowerCase() === "type")?.value;
15568
+ return type?.trim().toLowerCase() === ACT_SCRIPT_TYPE;
15569
+ }
15563
15570
  function parseHtml(html, opts = {}) {
15564
15571
  const dropped = [];
15565
15572
  const context = opts.parent ? foreignContext(opts.parent) : null;
@@ -15616,7 +15623,7 @@ function convertChildren(list, path, ids, dropped) {
15616
15623
  continue;
15617
15624
  const el = child;
15618
15625
  const tag = el.tagName;
15619
- if (BLOCKED_TAGS.has(tag.toLowerCase())) {
15626
+ if (BLOCKED_TAGS.has(tag.toLowerCase()) && !isActScript(el)) {
15620
15627
  dropped.push({ what: `<${tag}>` });
15621
15628
  continue;
15622
15629
  }
@@ -15655,6 +15662,22 @@ function convertElement(el, path, ids, dropped) {
15655
15662
  if (!id || ids.seen.has(id))
15656
15663
  id = makeUpId(ids, path);
15657
15664
  ids.seen.add(id);
15665
+ if (el.tagName === "script") {
15666
+ for (const k of Object.keys(attrs)) {
15667
+ if (k.toLowerCase() === "type")
15668
+ continue;
15669
+ dropped.push({ what: `${k} on <script>` });
15670
+ delete attrs[k];
15671
+ }
15672
+ attrs.type = ACT_SCRIPT_TYPE;
15673
+ const text = el.childNodes.map((c) => c.nodeName === "#text" ? c.value : "").join("");
15674
+ const node = { kind: "el", id, tag: "script", attrs, style: {}, children: [] };
15675
+ if (name !== undefined)
15676
+ node.name = name;
15677
+ if (text)
15678
+ node.children.push({ kind: "text", value: text });
15679
+ return node;
15680
+ }
15658
15681
  const ns = el.namespaceURI === NS_SVG ? "svg" : el.namespaceURI === NS_MATH ? "math" : undefined;
15659
15682
  const node = { kind: "el", id, tag: el.tagName, attrs, style, children: [] };
15660
15683
  if (ns)
@@ -15689,6 +15712,8 @@ function serializeNodes(nodes, opts = {}) {
15689
15712
  function serializeNode(node, opts = {}, rawText = false, inForeign) {
15690
15713
  if (node.kind === "text")
15691
15714
  return rawText ? node.value : escapeText(node.value);
15715
+ if (node.tag === "script" && !node.ns)
15716
+ return serializeActScript(node, opts);
15692
15717
  let out = `<${node.tag}`;
15693
15718
  if (!opts.omitIds)
15694
15719
  out += ` data-id="${node.id}"`;
@@ -15723,6 +15748,18 @@ function serializeNode(node, opts = {}, rawText = false, inForeign) {
15723
15748
  }
15724
15749
  return `${out}</${node.tag}>`;
15725
15750
  }
15751
+ function serializeActScript(node, opts) {
15752
+ let out = "<script";
15753
+ if (!opts.omitIds)
15754
+ out += ` data-id="${node.id}"`;
15755
+ if (node.name !== undefined)
15756
+ out += ` data-name="${escapeAttr(node.name)}"`;
15757
+ out += ` type="${ACT_SCRIPT_TYPE}">`;
15758
+ for (const c of node.children)
15759
+ if (c.kind === "text")
15760
+ out += c.value.replace(/<(\/script|!--)/gi, "<\\$1");
15761
+ return `${out}</script>`;
15762
+ }
15726
15763
  var SVG_HTML_INTEGRATION = new Set(["foreignObject", "desc", "title"]);
15727
15764
  var MATHML_TEXT_INTEGRATION = new Set(["mi", "mo", "mn", "ms", "mtext"]);
15728
15765
  function childrenAreForeign(node) {
@@ -33216,6 +33253,285 @@ var converseTools = [
33216
33253
  })
33217
33254
  ];
33218
33255
 
33256
+ // packages/tools/src/product.ts
33257
+ var PRODUCT_GUIDE = `# Product shots
33258
+
33259
+ Faux product UI: a believable interface, framed the way a launch page frames it, as a still or a short scene in which one thing happens. Heroes beside copy, feature cards, bento grids, cursor walkthroughs. The viewer recognizes the screen and sees the thing happen. (Adapted from Stageshow by Benji Taylor.)
33260
+
33261
+ The one idea: it reads as a real product, simplified to what the viewer needs, framed with intent, and every motion has a cause. It fails five ways:
33262
+ - Too much: real text in every row, numbers everywhere. The more detail, the more it looks generated.
33263
+ - Wireframe: two gray blobs and a button. Built too small, or stripped of what made it recognizable.
33264
+ - Boxed: a whole window shrunk into a card with even margins. A screenshot pasted in, not a product shot.
33265
+ - Flat: every object the same weight in the same bordered card. The eye has nowhere to land.
33266
+ - Bland: a gray window with a cursor, whatever the brief said. The brief's look and energy (glass over color, a blueprint, a mascot) are the point: build them in full, to these rules.
33267
+ The fix: a full, structured screen in quiet grays, real words only on what the story is about, placeholder bars for the rest, room to breathe, and a crop that puts the eye where the story is. Simplify the words, not the context.
33268
+
33269
+ Press hard. Build it the way a product designer builds a launch page they'll be judged on, then look at it as the most exacting designer you know would: the one who screenshots the single wrong thing (a dot off its avatar, a unit on its own line, copy touching a card) and sends it back with "what is this?". If you can picture that screenshot, it's the next fix.
33270
+
33271
+ ## Workflow
33272
+ 1. Plan before any HTML, in a note beside the work: where it sits on the page, the focal object, the action, the payoff, what to leave out.
33273
+ 2. Make the artboard the size it's shown, 1:1: about 720\xD7340 for a hero beside copy, 960\u20131100 wide for a full-width hero, 400\xD7300 for a card or tile, 358 wide for a phone column (a redesign for that width, not a squeeze). Never under about 320 wide for a demo.
33274
+ 3. The look. With the product's code or site to hand, take its tokens, icons, chrome and words. Otherwise light, one accent, a style if the brief names one. Put it in tokens.
33275
+ 4. Pick a layout (below) and build the screen from get_guide('kit'): its stage, window, phone, rows and bars are at real geometry. Count the real strings first.
33276
+ 5. Frame it. screenshot at scale 1 and hold it to the framing rules. If it's emptier, flatter or more boxed than it should be, fix the frame before any motion.
33277
+ 6. Tell the story with a scene (get_guide('act')): three to five beats and a payoff.
33278
+ 7. Rehearse: screenshot (the poster, the frame most people see), record (the storyboard), then review it as a stranger would (Review, below). Fix the largest fault first and film again.
33279
+
33280
+ ## Framing
33281
+ 1. One hero object, and at most one or two satellites (a receipt, a phone, a detail card) that carry the point.
33282
+ 2. Keep what identifies the product: a title, its real chrome, the rows that give the action a reason. Logo and nav aren't required; crop around the story.
33283
+ 3. Crop only filler. The payoff, the action, what the cursor touches and every real word stay whole. A button, chip or shadow sliced by the edge is the usual fault. If the story doesn't fit, change the size or the layout.
33284
+ 4. Crop 10 to 40% of the hero off the stage. The window or phone fills at least two thirds of the width and runs off an edge. Shapes that read when cut (a card, a list, a row of avatars) run off by a third or more.
33285
+ 5. The stage masks everything: the picture goes in a stage that clips (kit). One gutter: the hero's inset from the edge, and every other edge distance in the frame matches it. A full gutter or well past: never a few pixels short of an edge, never crossing it by under 24px.
33286
+ 6. Satellites straddle the hero's edge, about half outside, over its chrome, sidebar or margin, never its content. Two satellites are two kinds and sizes (a card and a notification), never a stack of two cards.
33287
+ 7. Anchored UI (a menu, a popover, a toast) isn't a satellite: it sits where the product puts it.
33288
+ 8. Depth from distinct shadows: the hero's, a satellite's, a lone surface's (kit). Start flat and frontal; a tilt earns its place against the straight version.
33289
+ 9. A window keeps its shape: whole, 1.25:1 or wider; cropped, what shows is at least square.
33290
+ 10. What the story opens stays in frame, a gutter from every edge, on every frame: place the trigger so the menu has room.
33291
+ 11. On a white or dark page, the page is the ground: no tinted plate behind the window, and no whole window floating with air on four sides. On a colored ground the hero is inset 8\u201320% from the sides and runs off the bottom.
33292
+ 12. No dead corners, at rest or anywhere in the loop.
33293
+
33294
+ ## Layouts
33295
+ | Layout | Hero | Satellite | For |
33296
+ |---|---|---|---|
33297
+ | Corner bleed | inset 10% top and left (one gutter), 15\u201335% past right and bottom | straddling the left or bottom edge | a hero beside copy |
33298
+ | Pinned, bottom bleed | inset 8\u201312% left, right and top; 15\u201335% past the bottom; centered | optional, straddling a side | feature cards, bento tiles |
33299
+ | Stage with gutters | inset 8\u201320% each side on a colored ground, off the bottom | straddling one side | brand moments |
33300
+ | Satellite focus | cropped hard, mostly context | large, 30\u201340% of the hero's width, carrying the story | one small thing: a notification, a receipt, a diff |
33301
+ | Wide hero | a 900\u20131100px window at 1:1, inset top, off the bottom; realistic content | a card on its lower edge | full-width homepage heroes |
33302
+ | Device pair | desktop inset top-left, 75\u201380% wide, off the bottom | a phone straddling the right edge, a third outside | one event across devices |
33303
+ | Many of one | a grid of one thing off every edge; one in focus by depth, the only one with words | none | templates, deploys, sessions |
33304
+ | Close-up | the window scaled 1.3\u20131.6\xD7, chrome and all, off the bottom; the subject row whole | none | a card about one control |
33305
+ | Panel over product | product inset top-left, off the bottom | a settings panel over its margin, one leader to what it changed | a setting and its effect |
33306
+ | Stacked cards | two components at one width, 12px apart, the lower one off the bottom | none | a setting over what it drives |
33307
+ | Opposite corners | copy bottom-left at the tile's inset; the product hung off the top-right corner | none | bento tiles with a line of copy |
33308
+ | Tilted stack | three same-size cards at -6\xB0, 4\xB0, -2\xB0, offset 12\u201320px; the straightest on top, the only one with words | none | paper: receipts, tickets |
33309
+
33310
+ ## The screen
33311
+ - Count the real strings: the title, the thing acted on, what's typed, the result. Usually 3 to 7; the rest are placeholder bars. It's a budget for words, not elements: a calendar still needs a populated week, a search a collection.
33312
+ - Words where the eye lands, bars at the edges. Bar widths vary row to row (60, 45, 70, 52%). Label and value match: both words or both bars.
33313
+ - In a small surface (a popover, a card, a tile) a row is one line: avatar, name, value.
33314
+ - One number gets to be big. Say each thing once: one clear signal for the feature, not in the header, the satellite and every row.
33315
+ - Keep the domain's signature content: album art, thumbnails, avatars. Named avatars take their own muted color; gray discs are filler.
33316
+ - Real sizes: 11\u201315px UI text, line height at least 1.3, one family (the product's or the system's), sentence case, hierarchy from spacing and one weight step. A faux app's title is a div, never an h1: the demo lives in someone's page outline.
33317
+ - Spacing: words keep 12px from any window, card or row edge; rows pad 12px (8 dense); a button keeps 8px from what's above it; text never touches a neighbor. No near-tangents: edges 1\u20133px apart read as accidents, so line them up or part them by 8px or more. A title sits closer to its subtitle (4\u20136px) than to the next record.
33318
+ - A centered amount centers its digits: the currency sign hangs off the left, outside the centering.
33319
+ - Icons come from a set chosen on purpose (the product's own; else Phosphor, Tabler, Radix, Heroicons, Material Symbols; Lucide deliberately), one size and weight per scene, filled at 14px and under, one opaque color. Never drawn by hand. Emoji are content, never icons.
33320
+ - AI features get no sparkle, wand or star, and no purple as the AI color. Show what the AI does.
33321
+ - No invented logo: a letter in a colored square isn't a mark. Use the real one, or a plain text wordmark. Other companies' marks come from their own assets, in their proportions.
33322
+ - Color: one neutral family, five inks and one accent; status colors mean status. A filled button under the pointer steps its own color, never a gray swap. The hero isn't outlined to point at it. Nothing translucent overlaps. On dark themes depth comes from lighter surfaces, not shadow.
33323
+ - Platform chrome is never drawn from memory: windows and phones from the kit, at their real geometry. Nothing sits under the island; a phone is lit from its first frame.
33324
+
33325
+ ## The story
33326
+ - Pick its shape from what the product is valued for. How it feels to use: one gesture, the result under the hand. A flow: a few screens told as one object, the payoff last. What the system does: the consequence lands somewhere else, usually with no cursor at all (no stand-in focus ring walking between controls either).
33327
+ - Open on a finished screen that works as a still: real content on screen before the first beat.
33328
+ - Three to five beats building to a payoff; a hero loop runs 10\u201316s. No cursor move you can't explain; between beats it rests on empty surface near its next move. Between a richer story and a calmer frame, choose the frame.
33329
+ - The payoff is visible at the shown size, arrives full, and holds about 2s. Nothing sits still longer than 3s.
33330
+ - UI feedback is as quick as the real product's; only storytelling slows down. Related changes overlap, 40\u201380ms apart in reading order; the result still follows its cause.
33331
+ - Every change moves: numbers roll, text types or streams, a new row opens its height and carries the rows below. Nothing pops in or snaps out. Solid things (windows, phones, cards) arrive by moving, opaque; they don't fade through.
33332
+ - The poster tells the story on its own: after the action, with the result still on screen, never mid-change. Cover the motion and ask what happened; if the poster can't answer, choose another beat.
33333
+ - Loops: a reset removes what the scene added as one thing, with a cause where one exists (a close, an undo, a clear). Data never rewinds in view. A navigation never plays backwards. Within a second of the reset, the next action has begun.
33334
+
33335
+ ## Bento grids
33336
+ A grid is one picture made of tiles, not five demos side by side. Plan the tile list in a note first: span, kind, the one thing, the words.
33337
+ 1. About a third to a half of the tiles show UI. The rest are other kinds: a stat (one real number at 48\u201372px, a short lead, a one-line label, never "10x" filler), a statement in large type, an object, a diagram, a collection of marks bleeding off, a real photo (never a scene drawn in CSS to stand in for one).
33338
+ 2. One hero tile, bigger (two columns or two rows), with the richest picture. Window chrome appears at most once in a grid, on the hero.
33339
+ 3. A UI tile shows one component at real size or larger, cropped by the tile, not a shrunken window.
33340
+ 4. Neighbors contrast, across and down: a picture beside a number, dense beside calm. Two window crops never sit side by side.
33341
+ 5. Copy is short and outside the picture: one to four words or one sentence, at page size (17\u201324px). A bold lead with a gray continuation reads well.
33342
+ 6. Tiles share radius, gap, padding and where the copy sits; the variety is inside them. Say each thing once across the set.
33343
+ 7. Motion has one place to lead: one tile tells a short story, or each does one small thing once, staggered 80\u2013120ms in reading order.
33344
+
33345
+ ## Review
33346
+ Before handing it over, look at the poster and the storyboard as a stranger would, and answer from the frames, not the code:
33347
+ - Does this composition answer this product, or could it be any product in its category?
33348
+ - What does the eye land on first, and is it the result? Is one object clearly leading?
33349
+ - Anything floating with even margins on four sides? A plate behind a window on a white page? A dead corner? A void under a list?
33350
+ - Gray bars where the eye lands? Busy rows? Uneven insets? Words touching an edge?
33351
+ - Anything cut by the edge that isn't filler? Anything the story opens outside the frame?
33352
+ - The cursor covering the words it clicks? Content that swaps instead of moving? A reset with no cause?
33353
+ Fix the largest fault first: framing, then hierarchy and density, then motion, then polish. Put a "Note: \u2026" beside the work naming the layout and what you'd check next.`;
33354
+ var ACT_GUIDE = `# Scene scripts
33355
+
33356
+ A scene plays an artboard as a product demo: the cursor moves, clicks and types, things appear, a total rolls. Write it as one <script type="ponzu/act"> inside the artboard, a beat per line. It never runs as code: Ponzu measures the board and turns the beats into animations, so screenshot shows the scene's poster, record films it beat by beat, and the person's canvas plays it on a loop.
33357
+
33358
+ The HTML is the cast. Build the whole screen first, every piece in place and in its finished look: the email already in its field, the toast where it lands, the new total. The scene says when each piece appears and how it gets there. Without the scene, the artboard is the finished picture.
33359
+
33360
+ \`\`\`html
33361
+ <script type="ponzu/act">
33362
+ wait 700
33363
+ click @Field
33364
+ type @Email placeholder=@Placeholder
33365
+ click @Invite
33366
+ show @"New member" grow
33367
+ & show @Toast rise
33368
+ count @Seats from 4
33369
+ poster
33370
+ wait 2000
33371
+ hide @Toast
33372
+ reset
33373
+ </script>
33374
+ \`\`\`
33375
+
33376
+ ## Targets
33377
+ - @Name is the element with that data-name; quote names with spaces: @"New member". Any CSS selector works too: .row, [data-name="Plan"] .price.
33378
+ - The cursor aims at the first match. show, hide, set, unset and count take every match.
33379
+ - x,y in artboard px, or 80%,60%, is a point with nothing in particular under it.
33380
+
33381
+ ## Timing
33382
+ - Beats run one after another. & at the start of a line starts it with the beat before it, and the next beat waits for both. After a click, tap or drag, & starts at the press, not when the cursor sets off: \`click @Send\` then \`& show @Sent\` shows it as the button goes down.
33383
+ - On any beat: delay=200 starts it later, dur=600 changes how long it takes, ease= takes a curve (house, settle, enter, trip, camera, out, in, inout) or any CSS easing.
33384
+ - wait 800 holds. A hold is a beat too: give the payoff about 2s.
33385
+ - A scene loops. End it with reset: everything it changed eases back over 700ms (reset 400 for another length), and what's hidden by then snaps back unseen. Write \`once\` on its own line to play it once and hold the end.
33386
+ - poster marks the frame that tells the story: screenshot shows it, the canvas's picture of the board shows it, and reduced motion holds it. Put it after the result lands, never mid-change. Without one: where reset begins, or the end.
33387
+
33388
+ ## The cursor
33389
+ - move @X travels in a hand's shallow arc, quicker over short hops. The first pointer beat brings the cursor in from the nearest edge; enter @X does that again later.
33390
+ - click @X moves there, then presses: the cursor dips and the element takes its :active styles. click alone presses where it is. double, right. tap is the same.
33391
+ - While over something, its :hover rules apply, as if a real pointer were there; they change as the path crosses edges.
33392
+ - It aims inside the target and off its words: just past the end of a label, toward the right of a wide field. at=0.5,0.5 aims at the center, at=0.9,0.5 near the right edge.
33393
+ - Its shape comes from what it's over: cursor: pointer shows the hand, text the I-beam, grab the open hand, grabbing the closed one, crosshair, ns-resize and the rest. data-cursor="hand" on an element overrides. A native app's buttons keep the arrow: don't give them cursor: pointer.
33394
+ - drag @Card to @Done carry presses, closes the hand, travels and lets go; carry moves @Card with it from where it was grabbed (carry=@Other carries something else). While carried it has data-act-dragging: give it a lift with [data-act-dragging] { box-shadow: \u2026 }.
33395
+ - cursor mac (macOS cursors, the default), cursor arrow (a solid illustrated arrowhead, an I-beam over text), cursor touch (a finger on a phone: a soft dot only while it touches). cursor at @X puts it there before the first move. cursor hide, cursor show. cursor ripple rings each click. cursor size=1.5 for a small artboard shown large.
33396
+ - A cursor that rests 4s steps out of the shot and comes back when it moves.
33397
+
33398
+ ## Text and numbers
33399
+ - type @Email reveals the element's own text a character at a time with a caret, and focuses it: :focus and :focus-within rules apply. placeholder=@Hint hides a placeholder on the first character. speed=50 is ms per character; nocaret drops the caret. The caret blinks until focus moves on.
33400
+ - stream @Answer reveals words in place, across lines, the way a model answers. Nothing reflows, so the space is its final height from the start. A card's own background and border stay; only its words are uncovered.
33401
+ - count @Total from $1,180 rolls the digits that changed, from the old value to the one in the HTML, last digit first. The element holds just the number: put a unit in its own span.
33402
+ - key cmd+k shows keycaps (at=top for the top) for a keyboard story. Names: cmd, shift, opt, ctrl, enter, tab, esc, space, backspace, up, down, left, right, and single keys.
33403
+
33404
+ ## Things appearing, moving and changing
33405
+ - show @Toast rise: hidden until this beat, then in. fade (the default), rise, drop, pop, blur, from-left, from-right keep the element's space; grow opens its height from nothing so what follows moves down with it, for a row joining a list or a message joining a thread. hide reverses any of them.
33406
+ - Several matches stagger 60ms in document order; stagger=100 changes it.
33407
+ - set @Row data-done turns on a state: a class (.done), a data-* or aria-* attribute (data-open, aria-selected=true), or open, hidden, disabled, checked, selected, inert. unset turns it off. The element changes as your CSS says, with its transitions. A state is a look: handlers, URLs and styles can't be set.
33408
+ - focus @Field and blur move focus without typing.
33409
+ - slide @Card to @Slot (or by 0,-48) moves an element by translate, on the house curve.
33410
+ - zoom @Scene to @Card [scale=1.5] pushes in on part of the picture; zoom @Scene out comes back. @Scene is a wrapper inside the stage.
33411
+ - scroll @List to @Row12 (or to 320) scrolls a list by moving its content up inside its parent, which needs overflow: hidden and a fixed height. The cursor moves over the list first.
33412
+
33413
+ ## States are your CSS
33414
+ - Write states in the artboard's <style>, with the transition on the base rule so it eases both ways: .send { transition: background-color .15s } .send:hover { \u2026 } .send:active { scale: .97 } .field:focus-within { \u2026 } .row[data-done] { \u2026 }.
33415
+ - The scene plays your transitions. A state without one snaps: fine for a focus ring, rarely for anything else.
33416
+ - Inline styles beat <style> rules: a state that changes something set inline needs !important.
33417
+ - @keyframes on a state rule don't play in a scene: use transitions there, and show or count for entrances.
33418
+
33419
+ ## Check it
33420
+ 1. screenshot shows the poster. It should tell the story on its own. Lint lists beats that can't play: a name nothing matches, a target that's off screen when the cursor goes for it, a loop with no reset.
33421
+ 2. record films a storyboard by default: one frame where each beat lands, labeled with the beat. Pass frames (12\u201316), or from and to, to film evenly instead and watch a fast stretch: a press, a grow, the reset.
33422
+ 3. Read the storyboard as a stranger: does each beat have a cause, does the payoff hold, does the loop end where it began?`;
33423
+ var KIT_GUIDE = `# Product shot kit
33424
+
33425
+ Parts at real geometry to start a product shot from. Paste them, then restyle to the product: its tokens, radius, type, accent and icons. Keep the geometry. Values here are a quiet light look; put them in tokens.
33426
+
33427
+ ## Tokens
33428
+ \`\`\`css
33429
+ --color-canvas: #f6f5f4; --color-chrome: #fbfbfa; --color-surface: #fff; --color-well: #efeeec;
33430
+ --color-line: rgba(0,0,0,.07);
33431
+ --ink-1: rgba(0,0,0,.04); --ink-2: rgba(0,0,0,.06); --ink-3: rgba(0,0,0,.08); --ink-4: rgba(0,0,0,.1); --ink-5: rgba(0,0,0,.15);
33432
+ --text-strong: #1d1d1f; --text: #3c3c43; --text-faint: #8a8a8e;
33433
+ --color-accent: #3b5bfd; --color-accent-press: #2f4ae6; --color-accent-soft: #eef1ff;
33434
+ --shadow-window: 0 0 0 1px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.08);
33435
+ --shadow-hero: 0 0 0 1px rgba(0,0,0,.06), 0 30px 60px -12px rgba(50,50,93,.25), 0 18px 36px -18px rgba(0,0,0,.3);
33436
+ --shadow-satellite: 0 0 0 1px rgba(0,0,0,.04), 0 14px 32px -8px rgba(50,50,93,.24), 0 4px 10px -4px rgba(0,0,0,.1);
33437
+ --shadow-ground: 0 0 0 1px rgba(50,50,93,.06), 0 24px 48px -24px rgba(50,50,93,.18);
33438
+ --radius-sm: 6px; --radius-md: 8px; --radius-lg: 10px; --radius-window: 12px;
33439
+ \`\`\`
33440
+ Dark: canvas #111113, surface #1a1a1d, inks rgba(255,255,255,.05 \u2026 .2), hero shadow 0 0 0 1px rgba(255,255,255,.08), 0 30px 60px -12px rgba(0,0,0,.6). Depth from lighter surfaces.
33441
+ The hero window takes --shadow-hero, a card sitting on it --shadow-satellite, a lone surface --shadow-ground. Radii nest: outer = inner + padding.
33442
+
33443
+ ## The stage
33444
+ The picture goes inside a stage that fills the artboard and clips, so the hero can run off its edges without the artboard growing:
33445
+ \`\`\`html
33446
+ <div data-name="Stage" style="position:absolute;inset:0;overflow:hidden">
33447
+ \u2026 the window, at position:absolute, past the right and bottom edges \u2026
33448
+ </div>
33449
+ \`\`\`
33450
+
33451
+ ## A macOS window
33452
+ A 38px title bar; the lights are 9px, 6px apart, their centers 19px from the top and the left.
33453
+ \`\`\`html
33454
+ <div data-name="Window" style="position:absolute;left:96px;top:96px;width:1080px;height:640px;display:flex;flex-direction:column;overflow:hidden;background:var(--color-surface);border-radius:var(--radius-window);box-shadow:var(--shadow-hero)">
33455
+ <div data-name="Title bar" style="display:flex;align-items:center;gap:6px;height:38px;flex:none;padding:0 14.5px;background:var(--color-chrome);border-bottom:1px solid var(--color-line)">
33456
+ <span style="width:9px;height:9px;border-radius:50%;background:#ff5f57;box-shadow:inset 0 0 0 .5px rgba(0,0,0,.12)"></span>
33457
+ <span style="width:9px;height:9px;border-radius:50%;background:#febc2e;box-shadow:inset 0 0 0 .5px rgba(0,0,0,.12)"></span>
33458
+ <span style="width:9px;height:9px;border-radius:50%;background:#28c840;box-shadow:inset 0 0 0 .5px rgba(0,0,0,.12)"></span>
33459
+ <div data-name="Title" style="flex:1;margin-right:36px;text-align:center;font-size:13px;font-weight:600;color:var(--text-strong)">Northwind</div>
33460
+ </div>
33461
+ <div data-name="Body" style="position:relative;flex:1;min-height:0">\u2026</div>
33462
+ </div>
33463
+ \`\`\`
33464
+ - A browser: in place of the title, an address field: \`<div style="flex:1;margin-left:8px;padding:4px 10px;border-radius:6px;background:var(--ink-1);font-size:10.5px;line-height:1.4;color:var(--text-faint);white-space:nowrap">dashboard.northwind.co</div>\`. Current Safari and Chrome draw it as a centered pill (border-radius 999px, about 40% wide). Browser chrome only when the browser is part of the picture.
33465
+ - A sidebar app (Mail, Linear, Slack): the window is a row; a 180\u2013220px sidebar on the canvas color runs the full height and holds the lights at the top (the same 38px row, no title bar over the content); the content column is the surface, its heading at the column's 16\u201332px inset.
33466
+ - A terminal: one dark surface (#161618), dim centered title (\`northwind \u2014 zsh\`), monospace 12\u201313px lines, a prompt, status marks in color sparingly.
33467
+
33468
+ ## An iPhone
33469
+ The screen is 402\xD7874 points with 64pt corners; the status bar is 54 tall, the island 95\xD737 at 14 from the top, the home indicator 144\xD75 at 8 from the bottom. Draw it at true points so its type stays iOS size (body 17, secondary 15), and scale the whole phone with transform; let it run off the stage rather than shrink it.
33470
+ \`\`\`html
33471
+ <div data-name="Phone" style="position:absolute;left:0;top:0;width:422px;height:894px;padding:10px;border-radius:74px;background:#1c1c1e;box-shadow:inset 0 0 0 1.5px #48484a, 0 30px 60px -12px rgba(0,0,0,.35);transform:scale(.85);transform-origin:top left">
33472
+ <div data-name="Screen" style="position:relative;width:402px;height:874px;border-radius:64px;overflow:hidden;background:#fff;font-family:-apple-system,system-ui,sans-serif">
33473
+ <div data-name="Status bar" style="position:absolute;left:0;right:0;top:0;height:54px;display:flex;align-items:center;justify-content:space-between;padding:0 34px 0 52px;font-size:17px;font-weight:600;color:#000">
33474
+ <span>9:41</span>
33475
+ <span style="display:flex;align-items:center;gap:7px">
33476
+ <svg width="18" height="12" viewBox="0 0 18 12" fill="#000"><rect x="0" y="7.5" width="3" height="4.5" rx="1"/><rect x="5" y="5" width="3" height="7" rx="1"/><rect x="10" y="2.5" width="3" height="9.5" rx="1"/><rect x="15" y="0" width="3" height="12" rx="1"/></svg>
33477
+ <svg width="16" height="12" viewBox="0 0 16 12" fill="#000"><path d="M8 2.6c2.2 0 4.2.8 5.7 2.2l1.1-1.1A9.7 9.7 0 0 0 8 1 9.7 9.7 0 0 0 1.2 3.7l1.1 1.1A8.1 8.1 0 0 1 8 2.6Zm0 3.2c1.3 0 2.5.5 3.4 1.3l1.1-1.1A6.4 6.4 0 0 0 8 4.2 6.4 6.4 0 0 0 3.5 6l1.1 1.1A4.8 4.8 0 0 1 8 5.8Zm0 3.2c.5 0 .9.2 1.2.5L8 10.7 6.8 9.5c.3-.3.7-.5 1.2-.5Z"/></svg>
33478
+ <svg width="27" height="13" viewBox="0 0 27 13" fill="none"><rect x=".5" y=".5" width="23" height="12" rx="3.5" stroke="#000" opacity=".35"/><rect x="2" y="2" width="20" height="9" rx="2" fill="#000"/><path d="M25 4.5v4c.8-.3 1.3-1.1 1.3-2s-.5-1.7-1.3-2Z" fill="#000" opacity=".4"/></svg>
33479
+ </span>
33480
+ </div>
33481
+ <div data-name="Island" style="position:absolute;top:14px;left:153.5px;width:95px;height:37px;border-radius:18.5px;background:#000"></div>
33482
+ <div data-name="App" style="position:absolute;left:0;right:0;top:54px;bottom:0">\u2026</div>
33483
+ <div data-name="Home indicator" style="position:absolute;bottom:8px;left:129px;width:144px;height:5px;border-radius:3px;background:#000"></div>
33484
+ </div>
33485
+ </div>
33486
+ \`\`\`
33487
+ - Nothing sits under the island; a sheet starts below the status bar. On a dark screen the status bar, island ring and indicator turn white.
33488
+ - A notification banner: inset 18 from the screen's sides, 14 17 14 14 padding, 23 radius, a 38\xD738 app icon (9 radius) 13 from 15pt text on 18pt lines, the title bold over its message; frosted rgba(252,252,253,.76) with backdrop-filter: blur(30px). On an unlocked phone it sits 56 from the top, under the island. Always true size: the phone is sized around it.
33489
+ - Messages keep Messages' conventions unless the brief gives a look: blue sent bubbles, gray received, reactions on the bubble.
33490
+ - On a phone use cursor touch, or no cursor: never a macOS arrow.
33491
+
33492
+ ## Rows and filler
33493
+ A list is rows; real words only on the rows the story touches.
33494
+ \`\`\`html
33495
+ <div data-name="Row" style="display:flex;align-items:center;gap:12px;height:56px;padding:0 12px;border-bottom:1px solid var(--color-line)">
33496
+ <span style="display:grid;place-items:center;width:32px;height:32px;border-radius:50%;background:#e9d8c4;color:#7a5530;font-size:12px;font-weight:600">MC</span>
33497
+ <div style="display:flex;flex-direction:column;gap:3px;flex:1;min-width:0">
33498
+ <span style="font-size:14px;font-weight:500;line-height:1.3">Maya Chen</span>
33499
+ <span style="font-size:12px;line-height:1.3;color:var(--text-faint)">maya@northwind.co</span>
33500
+ </div>
33501
+ <span style="font-size:12px;color:var(--text-faint)">Admin</span>
33502
+ </div>
33503
+ <div data-name="Filler row" style="display:flex;align-items:center;gap:12px;height:56px;padding:0 12px;border-bottom:1px solid var(--color-line)">
33504
+ <span style="width:32px;height:32px;border-radius:50%;background:var(--ink-3)"></span>
33505
+ <div style="display:flex;flex-direction:column;gap:7px;flex:1"><span style="width:120px;height:7px;border-radius:4px;background:var(--ink-4)"></span><span style="width:164px;height:6px;border-radius:3px;background:var(--ink-2)"></span></div>
33506
+ <span style="width:44px;height:6px;border-radius:3px;background:var(--ink-2)"></span>
33507
+ </div>
33508
+ \`\`\`
33509
+ - A bar replaces a line of text in the same line box: 7px for a title, 6px for secondary, rounded, var(--ink-3)/(--ink-4) on white. Widths vary row to row.
33510
+ - Named avatars take their own muted color with initials; filler avatars are plain discs.
33511
+ - A sidebar's filler nav items: a 14px rounded square and a 6px bar, 30px rows; the selected item is real, on an --ink-2 pill.
33512
+
33513
+ ## Controls
33514
+ \`\`\`html
33515
+ <div class="field" data-name="Field" style="position:relative;display:flex;align-items:center;height:40px;padding:0 12px;border-radius:var(--radius-md);background:var(--color-surface);box-shadow:0 0 0 1px var(--ink-4)">
33516
+ <span data-name="Placeholder" style="position:absolute;left:12px;font-size:14px;color:var(--text-faint)">name@company.com</span>
33517
+ <span data-name="Value" style="font-size:14px">maya@northwind.co</span>
33518
+ </div>
33519
+ <div class="button" data-name="Send" style="display:flex;align-items:center;height:40px;padding:0 18px;border-radius:var(--radius-md);background:var(--color-accent);color:#fff;font-size:14px;font-weight:600">Send invite</div>
33520
+ \`\`\`
33521
+ \`\`\`css
33522
+ .field { transition: box-shadow .2s ease; cursor: text }
33523
+ .field:focus-within { box-shadow: 0 0 0 1px var(--color-accent), 0 0 0 4px rgba(59,91,253,.16) !important }
33524
+ .button { transition: background-color .15s ease, scale .15s ease; cursor: pointer }
33525
+ .button:hover { background-color: var(--color-accent-press) !important }
33526
+ .button:active { scale: .97 }
33527
+ \`\`\`
33528
+ - A toast: a dark pill, 10px radius, 13px medium text with a 16px status glyph, --shadow-satellite, where the product puts it.
33529
+ - A popover or menu: a surface with 4px padding, --radius-lg, --shadow-satellite, 28\u201332px rows with 6px-radius highlights inset from its edge; it opens from its trigger's side and stays a gutter from every edge of the stage.
33530
+ - A pill or badge: 3px 8px padding, 999px radius, 12px medium text in a status color on its soft fill.
33531
+
33532
+ ## Icons
33533
+ Paste SVGs from one set (Phosphor, Tabler, Radix, Heroicons, Material Symbols, or the product's own) at one size, 14\u201316px, in one opaque color; filled at 14px and under. The cursor, caret and keycaps come with the scene: never draw them.`;
33534
+
33219
33535
  // packages/tools/src/guides.ts
33220
33536
  var ICON_LIST = Object.entries(PAGE_ICON_GROUPS).map(([group, names]) => ` ${group}: ${names.join(", ")}`).join(`
33221
33537
  `);
@@ -33282,7 +33598,7 @@ HTML and CSS
33282
33598
  - Images: https URLs, data URLs, or files in assets/ referenced as assets/name.png.
33283
33599
  - SVG for icons and logos. Transforms work.
33284
33600
  - Animation is real: @keyframes, transitions, animation-timeline. Screenshots show the settled page; record shows the motion. get_guide('motion') has the details.
33285
- - No scripts and no on* handlers; they're stripped. The result tells you what was removed.
33601
+ - No scripts and no on* handlers; they're stripped. The result tells you what was removed. The one exception is a scene, a <script type="ponzu/act"> that plays the artboard as a product demo and never runs as code (get_guide('act')).
33286
33602
  - Name meaningful layers with data-name="Hero". Names make get_tree readable and survive into implementation.
33287
33603
 
33288
33604
  Light and dark
@@ -33370,6 +33686,7 @@ The .design folder is the spec. Read it directly from disk; don't screenshot and
33370
33686
  - Open comment threads may hold requirements ("this should collapse on mobile"). Read comments.json.
33371
33687
  - notes/ has the brief and decisions. Read them before you start.
33372
33688
  - "Note: \u2026" artboards explain the screens beside them. Read them alongside the screens they sit next to.
33689
+ - A <script type="ponzu/act"> is a scene: a scripted demo of the screen, not the product's behavior. Read it for intent and build real interactions.
33373
33690
  - When something can't be built as drawn, leave a comment on the node explaining what you did instead.`,
33374
33691
  format: `# The .design format
33375
33692
 
@@ -33400,7 +33717,7 @@ ${FORMAT_EXAMPLE["pages/flow/cart.html"]}
33400
33717
  - Size goes in style, as width and height in px. data-x and data-y only place the artboard on its page. Without a width or height it's 1440\xD7900; height: fit-content grows with the content.
33401
33718
  - Give the section a data-id (ab_\u2026) so comments and tools can point at it. Elements inside don't need one: they get stable ids from their position.
33402
33719
  - data-name is the name people see, for the artboard and for layers.
33403
- - Same HTML and CSS rules as write_html (get_guide('basics')): inline styles, var(--token), no scripts.
33720
+ - Same HTML and CSS rules as write_html (get_guide('basics')): inline styles, var(--token), no scripts but a scene (get_guide('act')).
33404
33721
 
33405
33722
  comments.json
33406
33723
  \`\`\`json
@@ -33413,7 +33730,7 @@ ${FORMAT_EXAMPLE["comments.json"]}
33413
33730
  - A thread missing any of this isn't shown. get_basic_info says which thread and what it needs; the file keeps it until you fix it.`,
33414
33731
  motion: `# Motion and states
33415
33732
 
33416
- Designs have no scripts, so motion is CSS (@keyframes, transitions, animation-timeline) and SVG <animate>. Ponzu pauses it and seeks to exact times, so frames are the same every time and cost no real waiting.
33733
+ Designs run no scripts, so motion is CSS (@keyframes, transitions, animation-timeline), SVG <animate>, and scenes: a product demo written as beats (click, type, show, count) that Ponzu turns into animations (get_guide('act')). Ponzu pauses all of it and seeks to exact times, so frames are the same every time and cost no real waiting.
33417
33734
 
33418
33735
  See it
33419
33736
  - screenshot shows the settled page: every finite animation has finished. at: 0 shows the first frame; any other at shows that moment.
@@ -33444,6 +33761,9 @@ Check
33444
33761
  3. record hover/focus/press on every interactive element you styled. A state without a transition snaps; that's fine for focus rings, rarely for hover.
33445
33762
  4. Read the motion list: delays and durations should add up to the rhythm you meant.
33446
33763
  5. A finite load the person should judge needs a looping copy beside it; they can't replay the original.`,
33764
+ product: PRODUCT_GUIDE,
33765
+ act: ACT_GUIDE,
33766
+ kit: KIT_GUIDE,
33447
33767
  mobile: `# Mobile
33448
33768
 
33449
33769
  - 390\xD7844 artboards. Include a status bar (time, signal, battery) as a 54px row at the top; make it a duplicated component across screens.
@@ -33459,6 +33779,8 @@ Once you've put work on the canvas for the person to react to, or you're designi
33459
33779
 
33460
33780
  Start every session with get_basic_info, then read_notes, then get_guide('basics') if you haven't read it. When the person says "this", look for the comment they pinned to it.
33461
33781
 
33782
+ For a product shot (faux product UI for a launch page: a hero, a feature card, a bento grid, a cursor walking through a flow), read get_guide('product') first.
33783
+
33462
33784
  Build in small pieces, screenshot often, and fix what lint reports. Screenshots show the theme the person's canvas is in; a design with both themes uses light-dark() tokens for every color. record shows animation and hover states frame by frame. Put design decisions in tokens and notes. Variations go next to the original, never over it. The canvas shows which artboards you're changing; set_status tells the person what you're doing, and its intent, set once per request, says what they asked for.
33463
33785
 
33464
33786
  The canvas is yours to annotate: a "Note: \u2026" artboard beside the work carries rationale, labels and what to compare. Comments carry what needs the person: a question, a choice, something you couldn't do.
@@ -33688,7 +34010,7 @@ ${notes[n]}`).join(`
33688
34010
  title: "Get guide",
33689
34011
  group: "listen",
33690
34012
  readOnly: true,
33691
- description: "House rules and workflows for designing in Ponzu. Read 'basics' once per session before writing. Topics: basics, layout, typography, watch (the comment loop), variations, implement, format (writing the files directly), motion, mobile.",
34013
+ description: "House rules and workflows for designing in Ponzu. Read 'basics' once per session before writing. Topics: basics, layout, typography, watch (the comment loop), variations, implement, format (writing the files directly), motion, product (product shots: faux UI heroes, feature cards, bento grids, demos), act (scene scripts: a cursor that clicks and types, things that appear, totals that roll), kit (windows, phones and rows at real geometry), mobile.",
33692
34014
  input: { topic: _enum(Object.keys(GUIDES)) },
33693
34015
  handler({ topic }) {
33694
34016
  return { text: GUIDES[topic] };
@@ -34373,13 +34695,13 @@ var seeTools = [
34373
34695
  title: "Screenshot",
34374
34696
  group: "see",
34375
34697
  readOnly: true,
34376
- description: "Render an artboard or node and look at it. Shows the settled state: every finite animation has finished, the way a person sees the page after it loads. Pass `at` for a moment mid-animation, and hover, focus or press to see a state. Comes with a lint pass that reports clipped text, overflow (with the height the artboard needs), charts and images spilling over their neighbors, short labels wrapping in a row, zero-size and off-artboard elements, artboards overlapping each other on the canvas, broken images, tiny text, missing @keyframes, elements left invisible after an animation, more animating at once than the canvas can keep smooth, and states with no styles. Lists what animates. Use scale 1 for layout checks and 2 only to read small text. Check your work after every few edits; use record to watch motion. A render that stalls stops within a minute and says which step it stalled on; if only the image fails, lint still comes back.",
34698
+ description: "Render an artboard or node and look at it. Shows the settled state: every finite animation has finished, the way a person sees the page after it loads. Pass `at` for a moment mid-animation, and hover, focus or press to see a state. Comes with a lint pass that reports clipped text, overflow (with the height the artboard needs), charts and images spilling over their neighbors, short labels wrapping in a row, zero-size and off-artboard elements, artboards overlapping each other on the canvas, broken images, tiny text, missing @keyframes, elements left invisible after an animation, more animating at once than the canvas can keep smooth, and states with no styles. Lists what animates. An artboard with a scene script (get_guide('act')) shows its poster frame, and lint lists beats that can't play. Use scale 1 for layout checks and 2 only to read small text. Check your work after every few edits; use record to watch motion. A render that stalls stops within a minute and says which step it stalled on; if only the image fails, lint still comes back.",
34377
34699
  input: {
34378
34700
  file: fileArg,
34379
34701
  id: string2().describe("Artboard or node id."),
34380
34702
  scale: number2().min(0.25).max(3).optional(),
34381
34703
  colorScheme: colorSchemeArg,
34382
- at: number2().min(0).optional().describe("Milliseconds into the animation timeline. Default: settled. 0 is the first frame. With hover, focus or press, counts from that moment."),
34704
+ at: number2().min(0).optional().describe("Milliseconds into the animation timeline. Default: settled, or a scene's poster. 0 is the first frame. With hover, focus or press, counts from that moment."),
34383
34705
  ...interactionArgs
34384
34706
  },
34385
34707
  async handler(args, ctx) {
@@ -34444,7 +34766,7 @@ ${lint}`,
34444
34766
  if (!nodeId && ab.root.style.height === "fit-content")
34445
34767
  lines.push(`Content height: ${out.contentHeight}px.`);
34446
34768
  lines.push(lint);
34447
- if (out.motion?.animations.length)
34769
+ if (out.motion?.animations.length || out.motion?.act)
34448
34770
  lines.push(motionText(out.motion));
34449
34771
  if (remindToWatch(ctx))
34450
34772
  lines.push(WATCH_REMINDER);
@@ -34461,13 +34783,13 @@ ${lint}`,
34461
34783
  title: "Record",
34462
34784
  group: "see",
34463
34785
  readOnly: true,
34464
- description: "Watch an animation. Steps through the timeline frame by frame (paused and seeked, so frames are exact and repeatable) and returns one contact sheet with every frame labeled by its time, plus what animates: node, keyframes, duration, delay, easing, iterations. By default it covers the whole page load once, or one cycle of anything that loops. Use hover, focus or press to watch a transition into that state, and scroll to step through a scroll container for scroll-driven animation. Lint runs on the last frame. Use it after writing @keyframes, transitions or hover styles, and check easing, overlap and the end state. The person's canvas plays the load once when the artboard appears and then holds the end; hovering doesn't replay it.",
34786
+ description: "Watch an animation. Steps through the timeline frame by frame (paused and seeked, so frames are exact and repeatable) and returns one contact sheet with every frame labeled by its time, plus what animates: node, keyframes, duration, delay, easing, iterations. By default it covers the whole page load once, or one cycle of anything that loops; an artboard with a scene script (get_guide('act')) is filmed as a storyboard, one frame where each beat lands, labeled with the beat. Use hover, focus or press to watch a transition into that state, and scroll to step through a scroll container for scroll-driven animation. Lint runs on the last frame. Use it after writing @keyframes, transitions or hover styles, and check easing, overlap and the end state. The person's canvas plays the load once when the artboard appears and then holds the end; hovering doesn't replay it.",
34465
34787
  input: {
34466
34788
  file: fileArg,
34467
34789
  id: string2().describe("Artboard or node id. Frames show this area."),
34468
- frames: number2().int().min(2).max(24).optional().describe("How many frames, evenly spaced. Default 9; 12\u201316 for fast or detailed motion."),
34790
+ frames: number2().int().min(2).max(24).optional().describe("How many frames, evenly spaced. Default 9 (a scene: one per beat); 12\u201316 for fast or detailed motion."),
34469
34791
  from: number2().min(0).optional().describe("Start, in ms. Default 0."),
34470
- to: number2().min(0).max(60000).optional().describe("End, in ms. Default: when everything has settled, plus one cycle of any loop (capped at 10s)."),
34792
+ to: number2().min(0).max(60000).optional().describe("End, in ms. Default: when everything has settled, plus one cycle of any loop (capped at 10s, or a scene's length)."),
34471
34793
  scroll: string2().optional().describe("Id of a scroll container (fixed height, overflow: auto). Steps through its scroll range instead of time, for animation-timeline: scroll() or view()."),
34472
34794
  ...interactionArgs,
34473
34795
  colorScheme: colorSchemeArg
@@ -34522,11 +34844,11 @@ ${lint}`,
34522
34844
  lines.push(theme.line);
34523
34845
  if (out.assetsTimedOut)
34524
34846
  lines.push(ASSETS_LATE);
34525
- if (!args.scroll && !m.animations.some((a) => a.timeline === "time" && !a.paused))
34847
+ if (!args.scroll && !m.act && !m.animations.some((a) => a.timeline === "time" && !a.paused))
34526
34848
  lines.push(m.trigger === "load" ? "Nothing animates over time on load, so every frame is the same." : `Nothing animates on ${m.trigger}: it has no transition or animation. A state change without one snaps.`);
34527
34849
  if (args.scroll && !m.animations.some((a) => a.timeline !== "time"))
34528
34850
  lines.push("No scroll-driven animations: frames only show the content scrolling. Use animation-timeline: scroll() or view() to tie motion to it.");
34529
- if (m.animations.length)
34851
+ if (m.animations.length || m.act)
34530
34852
  lines.push(motionText(m));
34531
34853
  const at = `Lint at the end${m.trigger === "load" ? "" : ` (${m.trigger})`}`;
34532
34854
  if (out.issues.length)
@@ -34617,6 +34939,8 @@ function interaction(args) {
34617
34939
  function moment(m, at) {
34618
34940
  const after = m.trigger === "load" ? "" : ` after ${m.trigger}`;
34619
34941
  if (at === undefined) {
34942
+ if (m.act)
34943
+ return `at the scene's poster, ${ms(m.act.poster)} into ${ms(m.act.duration)}`;
34620
34944
  if (!m.animations.length)
34621
34945
  return m.trigger === "load" ? "static" : `${m.trigger}, no motion`;
34622
34946
  return `settled at ${ms(m.settled)}${after}`;
@@ -34630,9 +34954,15 @@ function motionText(m) {
34630
34954
  const rows = m.animations.slice(0, 20).map((a) => ` ${animationLine(a)}`);
34631
34955
  if (m.animations.length > 20)
34632
34956
  rows.push(` \u2026and ${m.animations.length - 20} more`);
34957
+ if (m.act)
34958
+ rows.unshift(` ${sceneLine(m.act)}`);
34633
34959
  return [head, ...rows].join(`
34634
34960
  `);
34635
34961
  }
34962
+ function sceneLine(a) {
34963
+ const how = a.loop ? "loops" : "plays once";
34964
+ return `scene: ${ms(a.duration)}, ${how}; poster at ${ms(a.poster)}; ${a.beats.length} beats as ${a.animations} animations`;
34965
+ }
34636
34966
  function animationLine(a) {
34637
34967
  const who = `${a.id || "?"}${a.pseudo ?? ""}`;
34638
34968
  if (a.kind === "video")
@@ -36888,6 +37218,23 @@ Read get_guide('basics'). Write the brief and your direction to a note, set toke
36888
37218
  }
36889
37219
  ]
36890
37220
  }));
37221
+ server.registerPrompt("product-shot", {
37222
+ title: "Make a product shot",
37223
+ description: "Faux product UI for a launch page, as a still or a demo that plays: a hero, a feature card, a bento grid, a cursor walking through a flow.",
37224
+ argsSchema: { brief: string2() }
37225
+ }, ({ brief }) => ({
37226
+ messages: [
37227
+ {
37228
+ role: "user",
37229
+ content: {
37230
+ type: "text",
37231
+ text: `Make a product shot in Ponzu: ${brief}
37232
+
37233
+ Read get_guide('product'), get_guide('kit') and get_guide('act'). Plan it in a note first: where it sits, the focal object, the action, the payoff. Build the screen at the size it's shown, frame it, then tell the story with a scene. Screenshot the poster, record the storyboard, review it as a stranger would and fix the largest fault, then watch the canvas for my comments (get_guide('watch')).`
37234
+ }
37235
+ }
37236
+ ]
37237
+ }));
36891
37238
  return server;
36892
37239
  }
36893
37240
  function toMcp(r, session, tool) {
@@ -37356,6 +37703,1832 @@ function neverArrived(err) {
37356
37703
  return [e?.code, e?.cause?.code].some((c) => c === "ConnectionRefused" || c === "ECONNREFUSED");
37357
37704
  }
37358
37705
 
37706
+ // packages/render/src/act.ts
37707
+ function actCore() {
37708
+ const CURVES = {
37709
+ house: "cubic-bezier(0.65, 0, 0.1, 1)",
37710
+ through: "cubic-bezier(0.8, 0, 0.1, 1)",
37711
+ settle: "cubic-bezier(0.05, 0.85, 0.3, 1)",
37712
+ enter: "cubic-bezier(0.1, 0.8, 0.3, 0.95)",
37713
+ trip: "cubic-bezier(0.78, 0, 0.17, 1)",
37714
+ camera: "cubic-bezier(0.45, 0, 0.1, 1)",
37715
+ out: "cubic-bezier(0.22, 1, 0.36, 1)",
37716
+ in: "cubic-bezier(0.55, 0, 1, 0.45)",
37717
+ inout: "cubic-bezier(0.65, 0, 0.35, 1)"
37718
+ };
37719
+ const NAMED = {
37720
+ ease: [0.25, 0.1, 0.25, 1],
37721
+ "ease-in": [0.42, 0, 1, 1],
37722
+ "ease-out": [0, 0, 0.58, 1],
37723
+ "ease-in-out": [0.42, 0, 0.58, 1]
37724
+ };
37725
+ const VERBS = new Set([
37726
+ "loop",
37727
+ "once",
37728
+ "cursor",
37729
+ "move",
37730
+ "hover",
37731
+ "enter",
37732
+ "click",
37733
+ "tap",
37734
+ "drag",
37735
+ "swipe",
37736
+ "type",
37737
+ "stream",
37738
+ "key",
37739
+ "show",
37740
+ "hide",
37741
+ "set",
37742
+ "unset",
37743
+ "focus",
37744
+ "blur",
37745
+ "count",
37746
+ "slide",
37747
+ "zoom",
37748
+ "scroll",
37749
+ "wait",
37750
+ "poster",
37751
+ "reset"
37752
+ ]);
37753
+ function curve(name, fallback) {
37754
+ if (!name)
37755
+ return fallback;
37756
+ return CURVES[name] ?? name;
37757
+ }
37758
+ function ms(v) {
37759
+ if (v === undefined)
37760
+ return null;
37761
+ const m = /^(-?\d*\.?\d+)(ms|s)?$/.exec(v.trim());
37762
+ if (!m)
37763
+ return null;
37764
+ return m[2] === "s" ? Number(m[1]) * 1000 : Number(m[1]);
37765
+ }
37766
+ function easer(css) {
37767
+ let p = NAMED[css.trim()];
37768
+ const m = /^cubic-bezier\(([^)]+)\)$/.exec(css.trim());
37769
+ if (m) {
37770
+ const n = m[1].split(",").map(Number);
37771
+ if (n.length === 4 && n.every(Number.isFinite))
37772
+ p = n;
37773
+ }
37774
+ if (!p)
37775
+ return (t) => t;
37776
+ const [x1, y1, x2, y2] = p;
37777
+ const cx = 3 * x1;
37778
+ const bx = 3 * (x2 - x1) - cx;
37779
+ const ax = 1 - cx - bx;
37780
+ const cy = 3 * y1;
37781
+ const by = 3 * (y2 - y1) - cy;
37782
+ const ay = 1 - cy - by;
37783
+ const x = (u) => ((ax * u + bx) * u + cx) * u;
37784
+ const dx = (u) => (3 * ax * u + 2 * bx) * u + cx;
37785
+ return (t) => {
37786
+ if (t <= 0)
37787
+ return 0;
37788
+ if (t >= 1)
37789
+ return 1;
37790
+ let u = t;
37791
+ for (let i = 0;i < 8; i++) {
37792
+ const d = dx(u);
37793
+ if (Math.abs(d) < 0.000001)
37794
+ break;
37795
+ const next = u - (x(u) - t) / d;
37796
+ if (next < 0 || next > 1)
37797
+ break;
37798
+ u = next;
37799
+ }
37800
+ if (Math.abs(x(u) - t) > 0.000001) {
37801
+ let lo = 0;
37802
+ let hi = 1;
37803
+ for (let i = 0;i < 40; i++) {
37804
+ u = (lo + hi) / 2;
37805
+ if (x(u) < t)
37806
+ lo = u;
37807
+ else
37808
+ hi = u;
37809
+ }
37810
+ }
37811
+ return ((ay * u + by) * u + cy) * u;
37812
+ };
37813
+ }
37814
+ function words(line) {
37815
+ const out = [];
37816
+ let i = 0;
37817
+ const n = line.length;
37818
+ while (i < n) {
37819
+ while (i < n && /\s/.test(line[i]))
37820
+ i++;
37821
+ if (i >= n || line.startsWith("//", i))
37822
+ break;
37823
+ let tok = "";
37824
+ let depth = 0;
37825
+ while (i < n && (depth > 0 || !/\s/.test(line[i]))) {
37826
+ const c = line[i];
37827
+ if (c === '"' || c === "'") {
37828
+ const close = line.indexOf(c, i + 1);
37829
+ const end = close < 0 ? n : close;
37830
+ tok += depth > 0 ? line.slice(i, end + 1) : line.slice(i + 1, end);
37831
+ i = end + 1;
37832
+ continue;
37833
+ }
37834
+ if (c === "[" || c === "(")
37835
+ depth++;
37836
+ else if ((c === "]" || c === ")") && depth > 0)
37837
+ depth--;
37838
+ tok += c;
37839
+ i++;
37840
+ }
37841
+ out.push(tok);
37842
+ }
37843
+ return out;
37844
+ }
37845
+ function parse(text) {
37846
+ const lines = [];
37847
+ const issues = [];
37848
+ let loop = true;
37849
+ const rows = text.split(/\r?\n/);
37850
+ for (let i = 0;i < rows.length; i++) {
37851
+ const raw = rows[i].trim();
37852
+ if (!raw || raw.startsWith("//"))
37853
+ continue;
37854
+ let ws = words(raw);
37855
+ let together = false;
37856
+ if (ws[0] === "&") {
37857
+ together = true;
37858
+ ws = ws.slice(1);
37859
+ } else if (ws[0]?.startsWith("&")) {
37860
+ together = true;
37861
+ ws[0] = ws[0].slice(1);
37862
+ }
37863
+ const verb = (ws[0] ?? "").toLowerCase();
37864
+ if (!verb)
37865
+ continue;
37866
+ if (!VERBS.has(verb)) {
37867
+ issues.push({ line: i + 1, message: `"${ws[0]}" isn't a beat` });
37868
+ continue;
37869
+ }
37870
+ if (verb === "loop" || verb === "once") {
37871
+ loop = verb === "loop";
37872
+ continue;
37873
+ }
37874
+ const args = [];
37875
+ const opts = {};
37876
+ for (const w of ws.slice(1)) {
37877
+ const m = /^([a-z][\w-]*)=(.*)$/i.exec(w);
37878
+ if (m)
37879
+ opts[m[1].toLowerCase()] = m[2];
37880
+ else
37881
+ args.push(w);
37882
+ }
37883
+ lines.push({
37884
+ line: i + 1,
37885
+ text: raw.replace(/\s+\/\/.*$/, ""),
37886
+ verb,
37887
+ args,
37888
+ opts,
37889
+ with: together
37890
+ });
37891
+ }
37892
+ return { loop, lines, issues };
37893
+ }
37894
+ function random(seed) {
37895
+ let h = 1779033703 ^ seed.length;
37896
+ for (let i = 0;i < seed.length; i++) {
37897
+ h = Math.imul(h ^ seed.charCodeAt(i), 3432918353);
37898
+ h = h << 13 | h >>> 19;
37899
+ }
37900
+ let a = h >>> 0;
37901
+ return () => {
37902
+ a = a + 1831565813 >>> 0;
37903
+ let t = a;
37904
+ t = Math.imul(t ^ t >>> 15, t | 1);
37905
+ t ^= t + Math.imul(t ^ t >>> 7, t | 61);
37906
+ return ((t ^ t >>> 14) >>> 0) / 4294967296;
37907
+ };
37908
+ }
37909
+ function cadence(units, each, seed) {
37910
+ const r = random(seed);
37911
+ const out = [];
37912
+ let t = 0;
37913
+ for (let i = 0;i < units.length; i++) {
37914
+ out.push(Math.round(t));
37915
+ const u = units[i];
37916
+ const pause = /[.!?,;:]\s*$/.test(u) ? 2.6 : /\s$/.test(u) ? 1.4 : 1;
37917
+ t += each * pause * (0.6 + r() * 0.8);
37918
+ }
37919
+ return out;
37920
+ }
37921
+ function arc(a, b, ease, bow, samples) {
37922
+ const e = easer(ease);
37923
+ const dist = Math.hypot(b.x - a.x, b.y - a.y) || 1;
37924
+ const nx = -(b.y - a.y) / dist;
37925
+ const ny = (b.x - a.x) / dist;
37926
+ const out = [];
37927
+ for (let i = 0;i <= samples; i++) {
37928
+ const t = i / samples;
37929
+ const p = e(t);
37930
+ const lift = Math.sin(Math.PI * p) * bow;
37931
+ out.push({ t, x: a.x + (b.x - a.x) * p + nx * lift, y: a.y + (b.y - a.y) * p + ny * lift });
37932
+ }
37933
+ return out;
37934
+ }
37935
+ function columns(from, to) {
37936
+ const a = [...from];
37937
+ const b = [...to];
37938
+ const n = Math.max(a.length, b.length);
37939
+ return Array.from({ length: n }, (_, i) => ({
37940
+ from: a[a.length - n + i] ?? "",
37941
+ to: b[b.length - n + i] ?? ""
37942
+ }));
37943
+ }
37944
+ function caps(combo) {
37945
+ const GLYPHS = {
37946
+ cmd: "\u2318",
37947
+ command: "\u2318",
37948
+ meta: "\u2318",
37949
+ shift: "\u21E7",
37950
+ opt: "\u2325",
37951
+ option: "\u2325",
37952
+ alt: "\u2325",
37953
+ ctrl: "\u2303",
37954
+ control: "\u2303",
37955
+ enter: "\u21A9",
37956
+ return: "\u21A9",
37957
+ tab: "\u21E5",
37958
+ esc: "esc",
37959
+ escape: "esc",
37960
+ space: "space",
37961
+ backspace: "\u232B",
37962
+ delete: "\u232B",
37963
+ up: "\u2191",
37964
+ down: "\u2193",
37965
+ left: "\u2190",
37966
+ right: "\u2192"
37967
+ };
37968
+ return combo.split("+").filter(Boolean).map((k) => GLYPHS[k.toLowerCase()] ?? (k.length === 1 ? k.toUpperCase() : k));
37969
+ }
37970
+ function frames(initial, segs, total) {
37971
+ const out = [{ offset: 0, value: initial, easing: "linear" }];
37972
+ const at = (t) => Math.min(1, Math.max(out[out.length - 1].offset, t / total));
37973
+ const push = (offset, value, easing) => {
37974
+ const last = out[out.length - 1];
37975
+ if (last.offset === offset && last.value === value) {
37976
+ last.easing = easing;
37977
+ return;
37978
+ }
37979
+ out.push({ offset, value, easing });
37980
+ };
37981
+ let last = initial;
37982
+ for (const s of segs) {
37983
+ const o0 = at(s.t0);
37984
+ if (s.from !== last)
37985
+ push(o0, last, "linear");
37986
+ push(o0, s.from, s.ease);
37987
+ push(at(s.t1), s.to, "linear");
37988
+ last = s.to;
37989
+ }
37990
+ if (out[out.length - 1].offset < 1)
37991
+ push(1, last, "linear");
37992
+ return out;
37993
+ }
37994
+ return { CURVES, curve, ms, easer, words, parse, random, cadence, arc, columns, caps, frames };
37995
+ }
37996
+ function actRuntime(core) {
37997
+ const w = window;
37998
+ if (w.__ponzuAct)
37999
+ return;
38000
+ const STATE_BOOLEANS = "open, hidden, disabled, checked, selected or inert";
38001
+ const STATE_ATTR = /^(\.[A-Za-z_][\w-]*|data-(?!id$|artboard$)[\w-]+|aria-[\w-]+|open|hidden|disabled|checked|selected|inert)$/;
38002
+ const ID = "ponzu-act";
38003
+ const handles = new WeakMap;
38004
+ const rewrittenRules = new WeakSet;
38005
+ let order = 0;
38006
+ const SVG = (body, size, box = "0 0 32 32") => `<svg width="${size}" height="${size}" viewBox="${box}" fill="none" xmlns="http://www.w3.org/2000/svg">${body}</svg>`;
38007
+ const RESIZE_TIP = "M0-8.4 2.55-3.65H-2.55ZM0 8.4 2.55 3.65H-2.55Z";
38008
+ const resize = (turn) => SVG(`<g transform="rotate(${turn})" stroke-linejoin="round"><path d="${RESIZE_TIP}" fill="#fff" stroke="#fff" stroke-width="3.2"/><path d="${RESIZE_TIP}" fill="#000" stroke="#000" stroke-width="1.2"/></g>`, 21, "-14 -14 28 28");
38009
+ const GLYPHS = {
38010
+ arrow: {
38011
+ svg: SVG('<g transform="translate(10 7)"><path d="m6.148 18.473 1.863-1.003 1.615-.839-2.568-4.816h4.332l-11.379-11.408v16.015l3.316-3.221z" fill="#fff"/><path d="m6.431 17 1.765-.941-2.775-5.202h3.604l-8.025-8.043v11.188l2.53-2.442z" fill="#000"/></g>', 24),
38012
+ hot: { x: 7.5, y: 5.25 }
38013
+ },
38014
+ hand: {
38015
+ svg: SVG('<path d="M10.6 6a1.7 1.7 0 0 1 3.4 0v6.6a1.3 1.3 0 0 1 2.6 0v.7a1.3 1.3 0 0 1 2.6 0v.7a1.3 1.3 0 0 1 2.6 0V19c0 3.1-2 5.6-5 5.6h-2.6c-2 0-3.3-.9-4.4-2.4l-3.1-4.1c-.6-.9-.4-2 .5-2.5.8-.4 1.7-.2 2.3.5l1.1 1.4V6Z" fill="#fff" stroke="#000" stroke-width="1.1" stroke-linejoin="round"/><path d="M14 12.6v3.6M16.6 13.3v3M19.2 14v2.6" stroke="#000" stroke-width="1" stroke-linecap="round"/>', 26),
38016
+ hot: { x: 9.75, y: 3.25 }
38017
+ },
38018
+ ibeam: {
38019
+ svg: `<svg width="10" height="16" viewBox="0 0 10 16" fill="none" overflow="visible" xmlns="http://www.w3.org/2000/svg"><path d="M3 1H7M3 15H7M5 1V15" stroke="#fff" stroke-width="2.6" stroke-linecap="round"/><path d="M3 1H7M3 15H7M5 1V15" stroke="#000" stroke-width="1" stroke-linecap="round"/></svg>`,
38020
+ hot: { x: 5, y: 8 }
38021
+ },
38022
+ crosshair: {
38023
+ svg: `<svg width="17" height="17" viewBox="0 0 17 17" fill="none" overflow="visible" xmlns="http://www.w3.org/2000/svg"><path d="M8.5 0V17M0 8.5H17" stroke="#fff" stroke-width="2.6"/><path d="M8.5 0V17M0 8.5H17" stroke="#000" stroke-width="1"/></svg>`,
38024
+ hot: { x: 8.5, y: 8.5 }
38025
+ },
38026
+ open: {
38027
+ svg: SVG('<path d="M11 15.5V8.4a1.4 1.4 0 0 1 2.8 0v5.4V6.9a1.4 1.4 0 0 1 2.8 0v6.9V7.6a1.4 1.4 0 0 1 2.8 0v6.6V9.9a1.4 1.4 0 0 1 2.8 0v8.4c0 3.6-2.4 6.2-5.8 6.2h-1.7c-2.1 0-3.5-.8-4.7-2.4l-3.4-4.5c-.6-.8-.5-1.9.3-2.4.8-.5 1.8-.3 2.4.4l2 2.3" fill="#fff" stroke="#000" stroke-width="1.1" stroke-linejoin="round" stroke-linecap="round"/>', 26),
38028
+ hot: { x: 11.7, y: 10.4 }
38029
+ },
38030
+ grab: {
38031
+ svg: SVG('<path d="M11.2 13.3c0-1 .7-1.6 1.5-1.6s1.4.6 1.4 1.4v-.6c0-.9.6-1.5 1.4-1.5s1.4.6 1.4 1.5v.4c0-.9.6-1.5 1.4-1.5s1.4.6 1.4 1.5v.6c0-.8.6-1.4 1.4-1.4s1.3.6 1.3 1.4v4.6c0 3.3-2.3 5.8-5.6 5.8h-1.9c-2 0-3.3-.8-4.4-2.3l-1.6-2.3c-.5-.8-.4-1.8.4-2.3.7-.4 1.6-.3 2.1.4l.5.7Z" fill="#fff" stroke="#000" stroke-width="1.1" stroke-linejoin="round"/><path d="M14.1 13.2v2.2M16.9 13v2.4M19.7 13.2v2.2" stroke="#000" stroke-width="1" stroke-linecap="round"/>', 30),
38032
+ hot: { x: 15, y: 15 }
38033
+ },
38034
+ "resize-ns": { svg: resize(0), hot: { x: 10.5, y: 10.5 } },
38035
+ "resize-ew": { svg: resize(90), hot: { x: 10.5, y: 10.5 } },
38036
+ "resize-nwse": { svg: resize(-45), hot: { x: 10.5, y: 10.5 } },
38037
+ "resize-nesw": { svg: resize(45), hot: { x: 10.5, y: 10.5 } },
38038
+ solid: {
38039
+ svg: `<svg width="22" height="22" viewBox="0 0 22 22" xmlns="http://www.w3.org/2000/svg"><path d="M4 3 18.5 9.6 11.8 11.8 9.6 18.5Z" fill="#111" stroke="#fff" stroke-width="1.6" stroke-linejoin="round" paint-order="stroke"/></svg>`,
38040
+ hot: { x: 4, y: 3 }
38041
+ }
38042
+ };
38043
+ const LAYER_CSS = `
38044
+ [data-act-layer]{position:absolute;inset:0;pointer-events:none;z-index:2147483000;overflow:visible;color-scheme:light}
38045
+ [data-act-cursor]{position:absolute;left:0;top:0;width:0;height:0;--act-size:1;transition:opacity .25s ease}
38046
+ [data-act-cursor][data-act-off]{opacity:0}
38047
+ [data-act-dip]{position:absolute;left:0;top:0;transform-origin:0 0;scale:var(--act-size);transition:transform .26s cubic-bezier(.22,1,.36,1)}
38048
+ [data-act-cursor][data-act-pressed] [data-act-dip]{transform:scale(.9);transition:transform .08s ease-out}
38049
+ [data-act-glyph]{position:absolute;display:block;opacity:0;scale:.5;filter:drop-shadow(0 1px 1.5px rgba(0,0,0,.28));transition:opacity .16s ease,scale .2s cubic-bezier(.22,1,.36,1)}
38050
+ [data-act-glyph] svg{display:block}
38051
+ ${Object.keys(GLYPHS).filter((k) => k !== "solid").map((k) => `[data-act-cursor][data-act-style=mac][data-act-kind=${k}] [data-act-glyph=${k}]{opacity:1;scale:1}`).join(`
38052
+ `)}
38053
+ [data-act-cursor][data-act-style=arrow]:not([data-act-kind=ibeam]) [data-act-glyph=solid]{opacity:1;scale:1}
38054
+ [data-act-cursor][data-act-style=arrow][data-act-kind=ibeam] [data-act-glyph=ibeam]{opacity:1;scale:1}
38055
+ [data-act-cursor][data-act-kind=grab] [data-act-glyph=open],[data-act-cursor][data-act-kind=open] [data-act-glyph=grab]{transition:opacity .08s linear}
38056
+ [data-act-dot]{position:absolute;left:-17px;top:-17px;width:34px;height:34px;border-radius:50%;background:rgba(118,118,128,.16);box-shadow:inset 0 0 0 1px rgba(255,255,255,.35),0 2px 10px rgba(0,0,0,.1);opacity:0;scale:.7;transition:opacity .4s ease,scale .45s cubic-bezier(.22,1,.36,1),background-color .1s ease}
38057
+ [data-act-cursor][data-act-style=touch][data-act-touching] [data-act-dot]{opacity:1;scale:1;transition:opacity .14s ease,scale .16s cubic-bezier(.22,1,.36,1)}
38058
+ [data-act-cursor][data-act-style=touch][data-act-pressed] [data-act-dot]{background-color:rgba(118,118,128,.26);scale:.84;transition:background-color .08s ease,scale .1s ease-out}
38059
+ [data-act-ripple]{position:absolute;left:-14px;top:-14px;width:28px;height:28px;border-radius:50%;border:2px solid rgba(70,110,255,.55);opacity:0}
38060
+ [data-act-caret]{position:absolute;left:0;top:0;width:2px;border-radius:1px;opacity:0}
38061
+ [data-act-keys]{position:absolute;left:0;right:0;display:flex;justify-content:center;gap:6px;opacity:0}
38062
+ [data-act-keys][data-at=bottom]{bottom:22px}
38063
+ [data-act-keys][data-at=top]{top:22px}
38064
+ [data-act-cap]{min-width:34px;height:34px;padding:0 10px;border-radius:9px;background:#fff;color:#1d1d1f;font:500 15px/34px -apple-system,BlinkMacSystemFont,"Segoe UI",system-ui,sans-serif;text-align:center;box-shadow:0 0 0 .5px rgba(0,0,0,.14),0 1px 0 rgba(0,0,0,.1),0 6px 18px rgba(0,0,0,.14)}
38065
+ `;
38066
+ const camel = (p) => p.startsWith("--") ? p : p === "float" ? "cssFloat" : p === "offset" ? "cssOffset" : p.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
38067
+ const idOf = (el) => el?.closest("[data-id]")?.getAttribute("data-id") ?? "";
38068
+ const round = (n) => Math.round(n * 10) / 10;
38069
+ const px = (n) => `${round(n)}px`;
38070
+ function splitTop(s) {
38071
+ const out = [];
38072
+ let depth = 0;
38073
+ let cur = "";
38074
+ for (const c of s) {
38075
+ if (c === "(")
38076
+ depth++;
38077
+ else if (c === ")")
38078
+ depth--;
38079
+ if (c === "," && depth === 0) {
38080
+ out.push(cur.trim());
38081
+ cur = "";
38082
+ } else
38083
+ cur += c;
38084
+ }
38085
+ if (cur.trim())
38086
+ out.push(cur.trim());
38087
+ return out;
38088
+ }
38089
+ function rulesOf(scope) {
38090
+ const out = [];
38091
+ const walk = (rules) => {
38092
+ for (const r of [...rules]) {
38093
+ if (r instanceof CSSStyleRule)
38094
+ out.push(r);
38095
+ if ("cssRules" in r && r.cssRules)
38096
+ walk(r.cssRules);
38097
+ }
38098
+ };
38099
+ for (const sheet of [...scope.styleSheets]) {
38100
+ try {
38101
+ walk(sheet.cssRules);
38102
+ } catch {}
38103
+ }
38104
+ return out;
38105
+ }
38106
+ function rewriteStates(scope) {
38107
+ const pattern = /:(hover|active|focus-visible|focus-within|focus)(?![\w-])/g;
38108
+ const alt = {
38109
+ hover: "[data-act-hover]",
38110
+ active: "[data-act-pressed]",
38111
+ focus: "[data-act-focus]",
38112
+ "focus-visible": "[data-act-focus]",
38113
+ "focus-within": "[data-act-focus],:has([data-act-focus])"
38114
+ };
38115
+ for (const rule of rulesOf(scope)) {
38116
+ if (rewrittenRules.has(rule))
38117
+ continue;
38118
+ rewrittenRules.add(rule);
38119
+ if (!pattern.test(rule.selectorText))
38120
+ continue;
38121
+ pattern.lastIndex = 0;
38122
+ rule.selectorText = rule.selectorText.replace(pattern, (_, s) => `:is(:${s},${alt[s]})`);
38123
+ pattern.lastIndex = 0;
38124
+ }
38125
+ }
38126
+ function kindOf(el, style) {
38127
+ if (!el)
38128
+ return "arrow";
38129
+ const named = el.closest("[data-cursor]")?.getAttribute("data-cursor");
38130
+ const css = named ?? getComputedStyle(el).cursor;
38131
+ const map = {
38132
+ pointer: "hand",
38133
+ hand: "hand",
38134
+ text: "ibeam",
38135
+ "vertical-text": "ibeam",
38136
+ ibeam: "ibeam",
38137
+ grab: "open",
38138
+ open: "open",
38139
+ grabbing: "grab",
38140
+ move: "open",
38141
+ crosshair: "crosshair",
38142
+ "ns-resize": "resize-ns",
38143
+ "row-resize": "resize-ns",
38144
+ "n-resize": "resize-ns",
38145
+ "s-resize": "resize-ns",
38146
+ "ew-resize": "resize-ew",
38147
+ "col-resize": "resize-ew",
38148
+ "e-resize": "resize-ew",
38149
+ "w-resize": "resize-ew",
38150
+ "nwse-resize": "resize-nwse",
38151
+ "nesw-resize": "resize-nesw"
38152
+ };
38153
+ const kind = map[css] ?? (GLYPHS[css] ? css : "arrow");
38154
+ return style === "arrow" && kind !== "ibeam" ? "arrow" : kind;
38155
+ }
38156
+ function find(section, target) {
38157
+ let sel = target;
38158
+ if (target.startsWith("@"))
38159
+ sel = `[data-name="${CSS.escape(target.slice(1))}"]`;
38160
+ try {
38161
+ const all = [...section.querySelectorAll(sel)];
38162
+ return section.matches(sel) ? [section, ...all] : all;
38163
+ } catch {
38164
+ return [];
38165
+ }
38166
+ }
38167
+ function mount(section) {
38168
+ handles.get(section)?.cancel();
38169
+ handles.delete(section);
38170
+ const script = section.querySelector('script[type="ponzu/act"]');
38171
+ if (!script)
38172
+ return null;
38173
+ let current = compile(section, script.textContent ?? "");
38174
+ const handle = {
38175
+ get animations() {
38176
+ return current.animations;
38177
+ },
38178
+ get summary() {
38179
+ return current.summary;
38180
+ },
38181
+ get issues() {
38182
+ return current.issues;
38183
+ },
38184
+ cancel() {
38185
+ for (const a of current.animations)
38186
+ a.cancel();
38187
+ current.animations = [];
38188
+ if (handles.get(section) === handle)
38189
+ handles.delete(section);
38190
+ },
38191
+ rebuild() {
38192
+ const was = current.animations[0];
38193
+ const time = was ? Number(was.currentTime ?? 0) : 0;
38194
+ const paused = was ? was.playState === "paused" : false;
38195
+ const rate = was ? was.playbackRate : 1;
38196
+ for (const a of current.animations)
38197
+ a.cancel();
38198
+ current = compile(section, script.textContent ?? "");
38199
+ for (const a of current.animations) {
38200
+ a.currentTime = time;
38201
+ a.playbackRate = rate;
38202
+ if (paused)
38203
+ a.pause();
38204
+ }
38205
+ }
38206
+ };
38207
+ handles.set(section, handle);
38208
+ return handle;
38209
+ }
38210
+ function compile(section, text) {
38211
+ const script = core.parse(text);
38212
+ const issues = [];
38213
+ const scriptId = idOf(section.querySelector('script[type="ponzu/act"]'));
38214
+ const issue = (line, message) => issues.push({ id: scriptId, kind: "act", message: `line ${line}: ${message}` });
38215
+ for (const i of script.issues)
38216
+ issue(i.line, i.message);
38217
+ const scope = section.getRootNode();
38218
+ rewriteStates(scope);
38219
+ const bases = new Map;
38220
+ const memo = new Map;
38221
+ const first = schedule(section, script, null, bases, memo, () => {});
38222
+ const draft = build(finish(section, scope, first), first, true);
38223
+ const plan = schedule(section, script, draft, bases, memo, issue);
38224
+ for (const a of draft)
38225
+ a.cancel();
38226
+ const animations = build(finish(section, scope, plan), plan, false);
38227
+ return {
38228
+ animations,
38229
+ issues,
38230
+ summary: {
38231
+ duration: plan.total,
38232
+ loop: plan.loop,
38233
+ poster: plan.poster,
38234
+ beats: plan.beats,
38235
+ animations: animations.length
38236
+ }
38237
+ };
38238
+ }
38239
+ function layer(section) {
38240
+ let el = section.querySelector(":scope > [data-act-layer]");
38241
+ if (el)
38242
+ return el;
38243
+ el = document.createElement("div");
38244
+ el.setAttribute("data-act-layer", "");
38245
+ el.setAttribute("aria-hidden", "true");
38246
+ const style = document.createElement("style");
38247
+ style.textContent = LAYER_CSS;
38248
+ el.appendChild(style);
38249
+ section.appendChild(el);
38250
+ return el;
38251
+ }
38252
+ function cursorEl(section) {
38253
+ const host = layer(section);
38254
+ let el = host.querySelector("[data-act-cursor]");
38255
+ if (el)
38256
+ return el;
38257
+ el = document.createElement("div");
38258
+ el.setAttribute("data-act-cursor", "");
38259
+ el.setAttribute("data-act-style", "mac");
38260
+ el.setAttribute("data-act-kind", "arrow");
38261
+ const dip = document.createElement("div");
38262
+ dip.setAttribute("data-act-dip", "");
38263
+ for (const [name, g] of Object.entries(GLYPHS)) {
38264
+ const span = document.createElement("span");
38265
+ span.setAttribute("data-act-glyph", name);
38266
+ span.style.left = `${-g.hot.x}px`;
38267
+ span.style.top = `${-g.hot.y}px`;
38268
+ span.style.transformOrigin = `${g.hot.x}px ${g.hot.y}px`;
38269
+ span.innerHTML = g.svg;
38270
+ dip.appendChild(span);
38271
+ }
38272
+ const dot = document.createElement("span");
38273
+ dot.setAttribute("data-act-dot", "");
38274
+ dip.appendChild(dot);
38275
+ el.appendChild(dip);
38276
+ host.appendChild(el);
38277
+ return el;
38278
+ }
38279
+ function helper(section, key, make) {
38280
+ const host = layer(section);
38281
+ const found = [...host.children].find((c) => c.getAttribute("data-act-key") === key);
38282
+ if (found)
38283
+ return found;
38284
+ const el = make();
38285
+ el.setAttribute("data-act-key", key);
38286
+ host.appendChild(el);
38287
+ return el;
38288
+ }
38289
+ function schedule(section, script, draft, bases, memo, issue) {
38290
+ const tracks = new Map;
38291
+ const states = [];
38292
+ const beats = [];
38293
+ const k = section.getBoundingClientRect().width / (section.offsetWidth || 1) || 1;
38294
+ const W = section.clientWidth;
38295
+ const H = section.clientHeight;
38296
+ const CURVE_INOUT = core.CURVES.inout;
38297
+ let presses = 0;
38298
+ const at = (t) => {
38299
+ if (draft)
38300
+ for (const a of draft)
38301
+ a.currentTime = t;
38302
+ };
38303
+ const box = (el, t) => {
38304
+ at(t);
38305
+ const r = el.getBoundingClientRect();
38306
+ const s = section.getBoundingClientRect();
38307
+ return {
38308
+ x: (r.left - s.left) / k - section.clientLeft,
38309
+ y: (r.top - s.top) / k - section.clientTop,
38310
+ width: r.width / k,
38311
+ height: r.height / k
38312
+ };
38313
+ };
38314
+ const inside = (p, b) => !!b && p.x >= b.x && p.x <= b.x + b.width && p.y >= b.y && p.y <= b.y + b.height;
38315
+ const key = (el, pseudo, prop) => {
38316
+ let id = el.__actKey;
38317
+ if (id === undefined) {
38318
+ id = ++order;
38319
+ el.__actKey = id;
38320
+ }
38321
+ return `${id}|${pseudo}|${prop}`;
38322
+ };
38323
+ const base = (el, prop, pseudo = "") => {
38324
+ const k_ = key(el, pseudo, prop);
38325
+ let v = bases.get(k_);
38326
+ if (v === undefined) {
38327
+ v = getComputedStyle(el, pseudo || null).getPropertyValue(prop);
38328
+ bases.set(k_, v);
38329
+ }
38330
+ return v;
38331
+ };
38332
+ const naturalHeight = (el) => {
38333
+ const k_ = key(el, "", "act:height");
38334
+ let v = bases.get(k_);
38335
+ if (v === undefined) {
38336
+ v = String(draft ? box(el, 0).height : el.getBoundingClientRect().height / k);
38337
+ bases.set(k_, v);
38338
+ }
38339
+ return Number(v);
38340
+ };
38341
+ const now_ = (el, prop, t) => {
38342
+ at(t);
38343
+ return getComputedStyle(el).getPropertyValue(prop);
38344
+ };
38345
+ const change = (el, prop, t0, t1, to, ease = "linear", from, pseudo = "") => {
38346
+ const k_ = key(el, pseudo, prop);
38347
+ let tr = tracks.get(k_);
38348
+ if (!tr) {
38349
+ tr = { el, pseudo, prop, initial: null, segs: [] };
38350
+ tracks.set(k_, tr);
38351
+ }
38352
+ tr.segs.push({ t0, t1: Math.max(t0, t1), to, from, ease, order: ++order });
38353
+ };
38354
+ const state = (t, el, attr, value) => states.push({ t, el, attr, value, order: ++order });
38355
+ const translateOf = (el, t) => {
38356
+ const v = now_(el, "translate", t).trim();
38357
+ if (!v || v === "none")
38358
+ return { x: 0, y: 0 };
38359
+ const [x, y] = v.split(/\s+/).map((s) => Number.parseFloat(s) || 0);
38360
+ return { x: x ?? 0, y: y ?? 0 };
38361
+ };
38362
+ let cursor = null;
38363
+ let style = "mac";
38364
+ let pos = null;
38365
+ let kind = "arrow";
38366
+ let hovered = [];
38367
+ let hoverTarget = null;
38368
+ let focused = null;
38369
+ let ripple = false;
38370
+ let caret = null;
38371
+ let keys = null;
38372
+ let rested = null;
38373
+ let idle = false;
38374
+ const IDLE_MS = 4000;
38375
+ const wake = (t) => {
38376
+ if (rested !== null && !idle && t - rested > IDLE_MS && cursor) {
38377
+ state(rested + IDLE_MS, cursor, "data-act-off", "");
38378
+ idle = true;
38379
+ }
38380
+ if (idle && cursor)
38381
+ state(t, cursor, "data-act-off", null);
38382
+ idle = false;
38383
+ };
38384
+ const getCursor = () => {
38385
+ if (!cursor) {
38386
+ cursor = cursorEl(section);
38387
+ state(0, cursor, "data-act-style", style);
38388
+ state(0, cursor, "data-act-kind", "arrow");
38389
+ }
38390
+ return cursor;
38391
+ };
38392
+ const chain = (el) => {
38393
+ const out = [];
38394
+ for (let n = el;n; n = n === section ? null : n.parentElement)
38395
+ out.push(n);
38396
+ return out;
38397
+ };
38398
+ const place = (p, t) => {
38399
+ const v = `${px(p.x)} ${px(p.y)}`;
38400
+ change(getCursor(), "translate", t, t, v, "linear", v);
38401
+ pos = p;
38402
+ };
38403
+ const setKind = (next, t) => {
38404
+ if (next === kind)
38405
+ return;
38406
+ kind = next;
38407
+ state(t, getCursor(), "data-act-kind", next);
38408
+ };
38409
+ const hover = (el, t) => {
38410
+ const next = chain(el);
38411
+ for (const n of hovered)
38412
+ if (!next.includes(n))
38413
+ state(t, n, "data-act-hover", null);
38414
+ for (const n of next)
38415
+ if (!hovered.includes(n))
38416
+ state(t, n, "data-act-hover", "");
38417
+ hovered = next;
38418
+ hoverTarget = el;
38419
+ };
38420
+ const focus = (el, t) => {
38421
+ if (focused === el)
38422
+ return;
38423
+ if (focused)
38424
+ state(t, focused, "data-act-focus", null);
38425
+ if (el)
38426
+ state(t, el, "data-act-focus", "");
38427
+ focused = el;
38428
+ closeCaret(t);
38429
+ };
38430
+ const closeCaret = (t) => {
38431
+ if (!caret)
38432
+ return;
38433
+ const c = caret;
38434
+ caret = null;
38435
+ for (let s = c.from + 530;s < t; s += 1060) {
38436
+ change(c.el, "opacity", s, s, "0");
38437
+ if (s + 530 < t)
38438
+ change(c.el, "opacity", s + 530, s + 530, "1");
38439
+ }
38440
+ change(c.el, "opacity", t, t, "0");
38441
+ };
38442
+ const point = (target, opts, t, line) => {
38443
+ if (!target)
38444
+ return null;
38445
+ const xy = /^(-?\d*\.?\d+)(%?),(-?\d*\.?\d+)(%?)$/.exec(target);
38446
+ if (xy) {
38447
+ const x = Number(xy[1]) * (xy[2] ? W / 100 : 1);
38448
+ const y = Number(xy[3]) * (xy[4] ? H / 100 : 1);
38449
+ return { p: { x, y }, el: null };
38450
+ }
38451
+ const el = find(section, target)[0];
38452
+ if (!el) {
38453
+ issue(line, `nothing matches ${target}`);
38454
+ return null;
38455
+ }
38456
+ const b = box(el, t);
38457
+ if (!b.width && !b.height)
38458
+ issue(line, `${target} isn't on screen at ${Math.round(t)}ms`);
38459
+ if (opts.at) {
38460
+ const [fx, fy] = opts.at.split(",").map(Number);
38461
+ return { p: { x: b.x + b.width * (fx ?? 0.5), y: b.y + b.height * (fy ?? 0.5) }, el };
38462
+ }
38463
+ if (b.width < 48 || b.height > 72)
38464
+ return { p: { x: b.x + b.width / 2, y: b.y + b.height / 2 }, el };
38465
+ const words = document.createRange();
38466
+ words.selectNodeContents(el);
38467
+ const w_ = words.getBoundingClientRect();
38468
+ const s = section.getBoundingClientRect();
38469
+ const right = (w_.right - s.left) / k - section.clientLeft;
38470
+ const mid = (w_.top + w_.height / 2 - s.top) / k - section.clientTop;
38471
+ if (w_.width / k > b.width * 0.5 && right + 3 < b.x + b.width - 4)
38472
+ return { p: { x: right + 3, y: mid + 2 }, el };
38473
+ return { p: { x: b.x + b.width * 0.78, y: b.y + b.height * 0.62 }, el };
38474
+ };
38475
+ const travel = (to, t, opts, drag) => {
38476
+ getCursor();
38477
+ const toBox = to.el ? box(to.el, t) : null;
38478
+ let from = pos;
38479
+ let ease = core.curve(opts.ease, CURVE_INOUT);
38480
+ let dur;
38481
+ let bow;
38482
+ if (!from) {
38483
+ const out = 40;
38484
+ const gaps = [to.p.x, W - to.p.x, to.p.y, H - to.p.y];
38485
+ const side = gaps.indexOf(Math.min(...gaps));
38486
+ from = side === 0 ? { x: -out, y: to.p.y + H * 0.12 } : side === 1 ? { x: W + out, y: to.p.y + H * 0.12 } : side === 2 ? { x: to.p.x - W * 0.06, y: -out } : { x: to.p.x + W * 0.06, y: H + out };
38487
+ place(from, t);
38488
+ ease = core.curve(opts.ease, core.CURVES.enter);
38489
+ dur = core.ms(opts.dur) ?? 700;
38490
+ bow = 0;
38491
+ } else {
38492
+ const dist = Math.hypot(to.p.x - from.x, to.p.y - from.y);
38493
+ if (dist < 0.5) {
38494
+ if (!drag) {
38495
+ hover(to.el ?? hoverTarget, t);
38496
+ if (to.el)
38497
+ setKind(kindOf(to.el, style), t);
38498
+ }
38499
+ return t;
38500
+ }
38501
+ dur = core.ms(opts.dur) ?? (drag ? Math.min(900, Math.max(450, 360 + dist * 1.1)) : Math.min(650, Math.max(300, 260 + dist * 0.9)));
38502
+ bow = Math.min(dist * (drag ? 0.06 : 0.08), drag ? 18 : 24);
38503
+ }
38504
+ const fromBox = hoverTarget ? box(hoverTarget, t) : null;
38505
+ const samples = Math.max(8, Math.round(dur / 28));
38506
+ const path = core.arc(from, to.p, ease, bow, samples);
38507
+ const cur = getCursor();
38508
+ let entered = false;
38509
+ let left = !fromBox;
38510
+ if (!drag && !left && toBox && hoverTarget && to.el && hoverTarget.contains(to.el))
38511
+ left = true;
38512
+ for (const s of path) {
38513
+ const ts = t + s.t * dur;
38514
+ if (s.t > 0)
38515
+ change(cur, "translate", ts - dur / samples, ts, `${px(s.x)} ${px(s.y)}`);
38516
+ if (drag?.carry) {
38517
+ change(drag.carry, "translate", ts - (s.t > 0 ? dur / samples : 0), ts, `${px(drag.offset.x + s.x - drag.grip.x)} ${px(drag.offset.y + s.y - drag.grip.y)}`);
38518
+ }
38519
+ if (drag)
38520
+ continue;
38521
+ if (!left && !inside(s, fromBox)) {
38522
+ left = true;
38523
+ hover(to.el && inside(s, toBox) ? to.el : null, ts);
38524
+ if (kind !== "arrow" && !inside(s, toBox))
38525
+ setKind("arrow", ts);
38526
+ }
38527
+ if (!entered && to.el && inside(s, toBox)) {
38528
+ entered = true;
38529
+ hover(to.el, ts);
38530
+ setKind(kindOf(to.el, style), ts);
38531
+ }
38532
+ }
38533
+ const end = t + dur;
38534
+ if (!drag) {
38535
+ if (!entered) {
38536
+ hover(to.el ?? null, end);
38537
+ setKind(to.el ? kindOf(to.el, style) : "arrow", end);
38538
+ }
38539
+ }
38540
+ pos = to.p;
38541
+ return end;
38542
+ };
38543
+ const press = (t, hold, el, right = false) => {
38544
+ const cur = getCursor();
38545
+ const touch = style === "touch";
38546
+ if (touch)
38547
+ state(t - 140, cur, "data-act-touching", "");
38548
+ state(t, cur, "data-act-pressed", "");
38549
+ const pressed = chain(el);
38550
+ for (const n of pressed)
38551
+ state(t, n, "data-act-pressed", right ? "right" : "");
38552
+ state(t + hold, cur, "data-act-pressed", null);
38553
+ for (const n of pressed)
38554
+ state(t + hold, n, "data-act-pressed", null);
38555
+ if (touch)
38556
+ state(t + hold + 60, cur, "data-act-touching", null);
38557
+ if (ripple && pos) {
38558
+ const p = pos;
38559
+ const ring = helper(section, `ripple:${++presses}`, () => {
38560
+ const r = document.createElement("span");
38561
+ r.setAttribute("data-act-ripple", "");
38562
+ return r;
38563
+ });
38564
+ change(ring, "translate", t, t, `${px(p.x)} ${px(p.y)}`);
38565
+ change(ring, "opacity", t, t, "0.9");
38566
+ change(ring, "scale", t, t, "0.4");
38567
+ change(ring, "scale", t, t + 520, "1.7", core.CURVES.out);
38568
+ change(ring, "opacity", t + 80, t + 520, "0", "ease-out");
38569
+ }
38570
+ };
38571
+ const reveal = (el, byWord) => {
38572
+ const known = memo.get(el);
38573
+ if (known && known.byWord === byWord)
38574
+ return known;
38575
+ const out = measureText(el, byWord);
38576
+ memo.set(el, out);
38577
+ return out;
38578
+ };
38579
+ const measureText = (target, byWord) => {
38580
+ const el = textHost(target);
38581
+ const own = el.getBoundingClientRect();
38582
+ const steps = [];
38583
+ const walker = document.createTreeWalker(el, NodeFilter.SHOW_TEXT);
38584
+ const range = document.createRange();
38585
+ for (let n = walker.nextNode();n; n = walker.nextNode()) {
38586
+ const s = n.data;
38587
+ const parts = byWord ? s.match(/\S+\s*|\s+/g) ?? [] : [...s];
38588
+ let i = 0;
38589
+ for (const part of parts) {
38590
+ const start = i;
38591
+ i += part.length;
38592
+ if (!part.trim()) {
38593
+ if (steps.length)
38594
+ steps[steps.length - 1].text += part;
38595
+ continue;
38596
+ }
38597
+ const end = start + part.trimEnd().length;
38598
+ range.setStart(n, end - 1);
38599
+ range.setEnd(n, end);
38600
+ const r = [...range.getClientRects()].pop();
38601
+ if (!r)
38602
+ continue;
38603
+ steps.push({
38604
+ x: (r.right - own.left) / k,
38605
+ top: (r.top - own.top) / k,
38606
+ bottom: (r.bottom - own.top) / k,
38607
+ glyphTop: (r.top - own.top) / k,
38608
+ glyphBottom: (r.bottom - own.top) / k,
38609
+ text: part
38610
+ });
38611
+ }
38612
+ }
38613
+ const lines = [...new Set(steps.map((s) => Math.round(s.top)))].sort((a, b) => a - b);
38614
+ const bottoms = new Map;
38615
+ for (const s of steps) {
38616
+ const l = Math.round(s.top);
38617
+ bottoms.set(l, Math.max(bottoms.get(l) ?? s.bottom, s.bottom));
38618
+ }
38619
+ for (const s of steps) {
38620
+ const i = lines.indexOf(Math.round(s.top));
38621
+ const prev = lines[i - 1];
38622
+ const next = lines[i + 1];
38623
+ const bottom = bottoms.get(lines[i]);
38624
+ s.top = prev === undefined ? s.top - 12 : (bottoms.get(prev) + s.top) / 2;
38625
+ s.bottom = next === undefined ? bottom + 12 : (bottom + next) / 2;
38626
+ }
38627
+ return { host: el, steps, width: own.width / k, height: own.height / k, byWord };
38628
+ };
38629
+ const clipTo = (s, width) => {
38630
+ const P = 12;
38631
+ return `polygon(${-P}px ${-P}px, ${px(width + P)} ${-P}px, ${px(width + P)} ${px(s.top)}, ${px(s.x)} ${px(s.top)}, ${px(s.x)} ${px(s.bottom)}, ${-P}px ${px(s.bottom)})`;
38632
+ };
38633
+ const HIDDEN_CLIP = "polygon(0px 0px, 0px 0px, 0px 0px, 0px 0px, 0px 0px, 0px 0px)";
38634
+ const PRESETS = {
38635
+ fade: 240,
38636
+ rise: 420,
38637
+ drop: 380,
38638
+ pop: 320,
38639
+ grow: 420,
38640
+ blur: 380,
38641
+ "from-left": 420,
38642
+ "from-right": 420
38643
+ };
38644
+ const appear = (el, show, preset, t, dur, ease) => {
38645
+ const opacity = base(el, "opacity") || "1";
38646
+ const t1 = t + dur;
38647
+ const fade = (fadeDur) => {
38648
+ if (show)
38649
+ change(el, "opacity", t, t + fadeDur, opacity, ease, "0");
38650
+ else
38651
+ change(el, "opacity", t, t + fadeDur, "0", ease);
38652
+ };
38653
+ if (preset === "grow") {
38654
+ const h = naturalHeight(el);
38655
+ const parent = el.parentElement;
38656
+ const pcs = parent ? getComputedStyle(parent) : null;
38657
+ const gap = pcs && /flex|grid/.test(pcs.display) ? Number.parseFloat(pcs.rowGap) || 0 : 0;
38658
+ const lead = gap && el.previousElementSibling ? -gap : 0;
38659
+ const props = [
38660
+ ["height", "0px", px(h)],
38661
+ ["padding-top", "0px", base(el, "padding-top")],
38662
+ ["padding-bottom", "0px", base(el, "padding-bottom")],
38663
+ ["margin-top", px(lead), base(el, "margin-top")],
38664
+ ["margin-bottom", "0px", base(el, "margin-bottom")]
38665
+ ];
38666
+ const display = base(el, "display");
38667
+ if (show) {
38668
+ change(el, "display", t, t, display, "linear", "none");
38669
+ change(el, "overflow", t, t, "clip", "linear", base(el, "overflow"));
38670
+ for (const [p, hid, shown] of props)
38671
+ change(el, p, t, t1, shown, ease, hid);
38672
+ change(el, "overflow", t1, t1, base(el, "overflow"));
38673
+ change(el, "opacity", t + dur * 0.25, t1, opacity, ease, "0");
38674
+ } else {
38675
+ change(el, "overflow", t, t, "clip");
38676
+ change(el, "opacity", t, t + dur * 0.6, "0", ease);
38677
+ for (const [p, hid] of props)
38678
+ change(el, p, t, t1, hid, ease, p === "height" ? px(h) : undefined);
38679
+ change(el, "display", t1, t1, "none");
38680
+ }
38681
+ return;
38682
+ }
38683
+ const tr = translateOf(el, t);
38684
+ const shift = {
38685
+ rise: { x: 0, y: 10 },
38686
+ drop: { x: 0, y: -8 },
38687
+ "from-left": { x: -16, y: 0 },
38688
+ "from-right": { x: 16, y: 0 }
38689
+ };
38690
+ const d = shift[preset];
38691
+ if (d) {
38692
+ const hid = `${px(tr.x + d.x)} ${px(tr.y + d.y)}`;
38693
+ const here = `${px(tr.x)} ${px(tr.y)}`;
38694
+ if (show)
38695
+ change(el, "translate", t, t1, here, ease, hid);
38696
+ else
38697
+ change(el, "translate", t, t1, hid, ease);
38698
+ }
38699
+ if (preset === "pop") {
38700
+ const s = base(el, "scale");
38701
+ const shown = s && s !== "none" ? s : "1";
38702
+ if (show)
38703
+ change(el, "scale", t, t1, shown, ease, "0.94");
38704
+ else
38705
+ change(el, "scale", t, t1, "0.96", ease);
38706
+ }
38707
+ if (preset === "blur") {
38708
+ const f = base(el, "filter");
38709
+ const shown = f && f !== "none" ? f : "blur(0px)";
38710
+ if (show)
38711
+ change(el, "filter", t, t1, shown, ease, "blur(6px)");
38712
+ else
38713
+ change(el, "filter", t, t1, "blur(6px)", ease);
38714
+ }
38715
+ fade(preset === "fade" ? dur : Math.min(dur, 260));
38716
+ };
38717
+ let now = 0;
38718
+ let lastStart = 0;
38719
+ let poster = null;
38720
+ let reset = null;
38721
+ const POINTER = new Set(["move", "hover", "enter", "click", "tap", "drag", "swipe", "scroll"]);
38722
+ for (const line of script.lines) {
38723
+ const { verb, args, opts } = line;
38724
+ const start = (line.with ? lastStart : now) + (core.ms(opts.delay) ?? 0);
38725
+ let end = start;
38726
+ let anchor = start;
38727
+ if (POINTER.has(verb) && pos)
38728
+ wake(start);
38729
+ const ease = (fallback) => core.curve(opts.ease, fallback);
38730
+ const targets = (i = 0) => {
38731
+ const t = args[i];
38732
+ if (!t) {
38733
+ issue(line.line, `${verb} needs a target`);
38734
+ return [];
38735
+ }
38736
+ const els = find(section, t);
38737
+ if (!els.length)
38738
+ issue(line.line, `nothing matches ${t}`);
38739
+ return els;
38740
+ };
38741
+ switch (verb) {
38742
+ case "cursor": {
38743
+ const cur = getCursor();
38744
+ for (const a of args) {
38745
+ if (a === "mac" || a === "arrow" || a === "touch") {
38746
+ style = a;
38747
+ state(start, cur, "data-act-style", a);
38748
+ } else if (a === "hide")
38749
+ state(start, cur, "data-act-off", "");
38750
+ else if (a === "show")
38751
+ state(start, cur, "data-act-off", null);
38752
+ else if (a === "ripple")
38753
+ ripple = true;
38754
+ }
38755
+ if (opts.size)
38756
+ cur.style.setProperty("--act-size", opts.size);
38757
+ const i = args.indexOf("at");
38758
+ if (i >= 0) {
38759
+ const to = point(args[i + 1], opts, start, line.line);
38760
+ if (to) {
38761
+ place(to.p, start);
38762
+ hover(to.el, start);
38763
+ setKind(kindOf(to.el, style), start);
38764
+ }
38765
+ }
38766
+ break;
38767
+ }
38768
+ case "move":
38769
+ case "hover":
38770
+ case "enter": {
38771
+ const to = point(args[0], opts, start, line.line);
38772
+ if (!to)
38773
+ break;
38774
+ if (verb === "enter")
38775
+ pos = null;
38776
+ const guess = travelTime(to.p);
38777
+ const there = point(args[0], opts, start + guess, line.line) ?? to;
38778
+ end = travel(there, start, opts);
38779
+ break;
38780
+ }
38781
+ case "click":
38782
+ case "tap": {
38783
+ let t = start;
38784
+ let el = hoverTarget;
38785
+ if (args[0]) {
38786
+ const to = point(args[0], opts, start, line.line);
38787
+ if (to) {
38788
+ const there = point(args[0], opts, start + travelTime(to.p), line.line) ?? to;
38789
+ const arrived = travel(there, start, opts);
38790
+ t = arrived > start ? arrived + 120 : start;
38791
+ el = to.el ?? hoverTarget;
38792
+ }
38793
+ }
38794
+ if (focused && el && !chain(el).includes(focused))
38795
+ focus(null, t);
38796
+ anchor = t;
38797
+ const double = args.includes("double");
38798
+ const right = args.includes("right");
38799
+ press(t, double ? 80 : 100, el, right);
38800
+ end = t + (double ? 80 : 100);
38801
+ if (double) {
38802
+ press(end + 70, 80, el, right);
38803
+ end += 150;
38804
+ }
38805
+ break;
38806
+ }
38807
+ case "drag":
38808
+ case "swipe": {
38809
+ const toAt = args.indexOf("to");
38810
+ const fromT = toAt > 0 ? args[0] : undefined;
38811
+ const toT = toAt >= 0 ? args[toAt + 1] : args[0];
38812
+ let t = start;
38813
+ if (fromT) {
38814
+ const from = point(fromT, {}, start, line.line);
38815
+ if (from) {
38816
+ const arrived = travel(from, start, {});
38817
+ t = arrived > start ? arrived + 120 : start;
38818
+ }
38819
+ }
38820
+ const carrySel = opts.carry ?? (args.includes("carry") ? fromT : undefined);
38821
+ const carry = carrySel ? find(section, carrySel)[0] ?? null : null;
38822
+ if (carrySel && !carry)
38823
+ issue(line.line, `nothing matches ${carrySel}`);
38824
+ const to = point(toT, opts, t, line.line);
38825
+ if (!to || !pos)
38826
+ break;
38827
+ const grip = pos;
38828
+ anchor = t;
38829
+ const offset = carry ? translateOf(carry, t) : { x: 0, y: 0 };
38830
+ const before = kind;
38831
+ const closes = before !== "ibeam" && before !== "crosshair" && !before.startsWith("resize");
38832
+ const cur = getCursor();
38833
+ if (style === "touch")
38834
+ state(t - 140, cur, "data-act-touching", "");
38835
+ state(t, cur, "data-act-pressed", "");
38836
+ state(t + 90, cur, "data-act-pressed", null);
38837
+ if (closes)
38838
+ setKind("grab", t + 60);
38839
+ if (carry)
38840
+ state(t + 60, carry, "data-act-dragging", "");
38841
+ const pressed = chain(hoverTarget);
38842
+ for (const n of pressed)
38843
+ state(t, n, "data-act-pressed", "");
38844
+ const landed = travel(to, t + 110, opts, { carry, grip, offset });
38845
+ for (const n of pressed)
38846
+ state(landed, n, "data-act-pressed", null);
38847
+ if (carry)
38848
+ state(landed, carry, "data-act-dragging", null);
38849
+ if (style === "touch")
38850
+ state(landed + 60, cur, "data-act-touching", null);
38851
+ hover(to.el, landed);
38852
+ setKind(to.el ? kindOf(to.el, style) : closes ? "open" : before, landed);
38853
+ end = landed;
38854
+ break;
38855
+ }
38856
+ case "type":
38857
+ case "stream": {
38858
+ const el = targets()[0];
38859
+ if (!el)
38860
+ break;
38861
+ const word = verb === "stream";
38862
+ const { host, steps, width } = reveal(el, word);
38863
+ if (!steps.length) {
38864
+ issue(line.line, `${args[0]} has no text to ${verb}`);
38865
+ break;
38866
+ }
38867
+ const each = core.ms(opts.speed) ?? (word ? 45 : 38);
38868
+ const times = core.cadence(steps.map((s) => s.text), each, `${line.line}:${el.textContent}`).map((t) => t + (word ? 0 : each));
38869
+ if (opts.placeholder)
38870
+ for (const p of find(section, opts.placeholder)) {
38871
+ const at = start + times[0];
38872
+ change(p, "opacity", at, at, "0");
38873
+ }
38874
+ closeCaret(start);
38875
+ if (!word)
38876
+ focus(el, start);
38877
+ const t0 = start + times[0];
38878
+ change(host, "clip-path", start, start, HIDDEN_CLIP, "linear", HIDDEN_CLIP);
38879
+ change(host, "clip-path", t0, t0, clipTo(steps[0], width));
38880
+ for (let i = 1;i < steps.length; i++) {
38881
+ const ts = start + times[i];
38882
+ change(host, "clip-path", ts, ts, clipTo(steps[i], width));
38883
+ }
38884
+ const last = start + times[times.length - 1];
38885
+ change(host, "clip-path", last + each, last + each, "none");
38886
+ end = last + each;
38887
+ if (!word && !args.includes("nocaret")) {
38888
+ const color = getComputedStyle(el).color;
38889
+ const c = helper(section, `caret:${line.line}`, () => {
38890
+ const s = document.createElement("span");
38891
+ s.setAttribute("data-act-caret", "");
38892
+ return s;
38893
+ });
38894
+ c.style.background = color;
38895
+ const origin = box(host, start);
38896
+ const lineH = steps[0].glyphBottom - steps[0].glyphTop;
38897
+ c.style.height = px(lineH);
38898
+ change(c, "opacity", start, start, "1");
38899
+ change(c, "translate", start, start, `${px(origin.x)} ${px(origin.y + steps[0].glyphTop)}`);
38900
+ for (let i = 0;i < steps.length; i++) {
38901
+ const s = steps[i];
38902
+ const ts = start + times[i];
38903
+ change(c, "translate", ts, ts, `${px(origin.x + s.x + 1)} ${px(origin.y + s.glyphTop)}`);
38904
+ }
38905
+ caret = { el: c, from: end, color };
38906
+ }
38907
+ break;
38908
+ }
38909
+ case "key": {
38910
+ const combo = args[0];
38911
+ if (!combo) {
38912
+ issue(line.line, "key needs keys, like cmd+k");
38913
+ break;
38914
+ }
38915
+ const where = opts.at === "top" ? "top" : "bottom";
38916
+ const group = helper(section, `keys:${line.line}`, () => {
38917
+ const g = document.createElement("div");
38918
+ g.setAttribute("data-act-keys", "");
38919
+ for (const cap of core.caps(combo)) {
38920
+ const c = document.createElement("span");
38921
+ c.setAttribute("data-act-cap", "");
38922
+ c.textContent = cap;
38923
+ g.appendChild(c);
38924
+ }
38925
+ return g;
38926
+ });
38927
+ group.setAttribute("data-at", where);
38928
+ if (keys && keys.hide > start) {
38929
+ change(keys.el, "opacity", start, start + 120, "0", "ease-in");
38930
+ }
38931
+ change(group, "opacity", start, start + 180, "1", core.CURVES.out, "0");
38932
+ change(group, "translate", start, start + 180, "0px 0px", core.CURVES.out, "0px 6px");
38933
+ change(group, "scale", start + 180, start + 240, "0.94", "ease-out", "1");
38934
+ change(group, "scale", start + 320, start + 460, "1", core.CURVES.out);
38935
+ change(group, "opacity", start + 1100, start + 1300, "0", "ease-in");
38936
+ keys = { el: group, hide: start + 1100 };
38937
+ end = start + 320;
38938
+ break;
38939
+ }
38940
+ case "show":
38941
+ case "hide": {
38942
+ const els = targets();
38943
+ const preset = args.slice(1).find((a) => (a in PRESETS)) ?? "fade";
38944
+ const dur = core.ms(opts.dur) ?? PRESETS[preset];
38945
+ const gap = core.ms(opts.stagger) ?? (els.length > 1 ? 60 : 0);
38946
+ const curveFor = verb === "show" ? core.CURVES.out : preset === "grow" ? CURVE_INOUT : "ease-in";
38947
+ els.forEach((el, i) => {
38948
+ appear(el, verb === "show", preset, start + i * gap, dur, ease(curveFor));
38949
+ });
38950
+ end = start + Math.max(0, els.length - 1) * gap + dur;
38951
+ break;
38952
+ }
38953
+ case "set":
38954
+ case "unset": {
38955
+ const els = targets();
38956
+ const names = args.slice(1);
38957
+ const asked = names.map((n) => [n, ""]);
38958
+ for (const [kk, v] of Object.entries(opts))
38959
+ if (!["dur", "delay", "ease", "stagger"].includes(kk))
38960
+ asked.push([kk, v]);
38961
+ const values = asked.filter(([name]) => {
38962
+ if (STATE_ATTR.test(name))
38963
+ return true;
38964
+ issue(line.line, `${name} isn't a state; set takes a .class, data-*, aria-* or ${STATE_BOOLEANS}`);
38965
+ return false;
38966
+ });
38967
+ if (!asked.length)
38968
+ issue(line.line, `${verb} needs an attribute or .class`);
38969
+ const gap = core.ms(opts.stagger) ?? 0;
38970
+ els.forEach((el, i) => {
38971
+ for (const [name, v] of values)
38972
+ state(start + i * gap, el, name, verb === "set" ? v ?? "" : null);
38973
+ });
38974
+ end = start + Math.max(0, els.length - 1) * gap + (core.ms(opts.dur) ?? 0);
38975
+ break;
38976
+ }
38977
+ case "focus": {
38978
+ const el = targets()[0];
38979
+ if (el)
38980
+ focus(el, start);
38981
+ break;
38982
+ }
38983
+ case "blur":
38984
+ focus(null, start);
38985
+ break;
38986
+ case "count": {
38987
+ const els = targets();
38988
+ const fromAt = args.indexOf("from");
38989
+ const old = fromAt >= 0 ? args[fromAt + 1] : undefined;
38990
+ if (old === undefined) {
38991
+ issue(line.line, "count needs from <old value>, like count .total from $1,180");
38992
+ break;
38993
+ }
38994
+ const dur = core.ms(opts.dur) ?? 600;
38995
+ const gap = core.ms(opts.stagger) ?? 50;
38996
+ let last = start;
38997
+ for (const el of els) {
38998
+ const rolls = rollColumns(el, old);
38999
+ let n = 0;
39000
+ for (let i = rolls.length - 1;i >= 0; i--) {
39001
+ const r = rolls[i];
39002
+ if (!r)
39003
+ continue;
39004
+ const t0 = start + n * gap;
39005
+ if (Math.abs(r.from - r.to) > 0.5)
39006
+ change(r.col, "width", t0, t0 + dur, px(r.to), ease(core.CURVES.house), px(r.from));
39007
+ change(r.strip, "translate", t0, t0 + dur, `0px ${px(-r.h)}`, ease(core.CURVES.house), "0px 0px");
39008
+ last = Math.max(last, t0 + dur);
39009
+ n++;
39010
+ }
39011
+ }
39012
+ end = last;
39013
+ break;
39014
+ }
39015
+ case "slide": {
39016
+ const els = targets();
39017
+ const toAt = args.indexOf("to");
39018
+ const byAt = args.indexOf("by");
39019
+ const dur = core.ms(opts.dur) ?? 520;
39020
+ const gap = core.ms(opts.stagger) ?? 0;
39021
+ els.forEach((el, i) => {
39022
+ const t = start + i * gap;
39023
+ const tr = translateOf(el, t);
39024
+ let d = null;
39025
+ if (byAt >= 0) {
39026
+ const [dx, dy] = (args[byAt + 1] ?? "").split(",").map(Number);
39027
+ d = { x: dx || 0, y: dy || 0 };
39028
+ } else if (toAt >= 0) {
39029
+ const dest = point(args[toAt + 1], opts, t, line.line);
39030
+ const b = box(el, t);
39031
+ if (dest)
39032
+ d = { x: dest.p.x - (b.x + b.width / 2), y: dest.p.y - (b.y + b.height / 2) };
39033
+ } else
39034
+ issue(line.line, "slide needs to <target> or by dx,dy");
39035
+ if (d)
39036
+ change(el, "translate", t, t + dur, `${px(tr.x + d.x)} ${px(tr.y + d.y)}`, ease(core.CURVES.house));
39037
+ });
39038
+ end = start + Math.max(0, els.length - 1) * gap + dur;
39039
+ break;
39040
+ }
39041
+ case "zoom": {
39042
+ const scene = targets()[0];
39043
+ if (!scene)
39044
+ break;
39045
+ const dur = core.ms(opts.dur) ?? 900;
39046
+ const out = args[1] === "out";
39047
+ let to = base(scene, "transform") || "none";
39048
+ if (!out) {
39049
+ const target = args[1] === "to" || args[1] === "on" ? args[2] : args[1];
39050
+ const el = target ? find(section, target)[0] : undefined;
39051
+ if (!el) {
39052
+ issue(line.line, `zoom needs to <target> or out`);
39053
+ break;
39054
+ }
39055
+ const sb = box(scene, start);
39056
+ const tb = box(el, start);
39057
+ const s = Number(opts.scale) || Math.min(2.2, Math.max(1.1, 0.7 * Math.min(sb.width / tb.width, sb.height / tb.height)));
39058
+ const qx = tb.x + tb.width / 2 - (sb.x + sb.width / 2);
39059
+ const qy = tb.y + tb.height / 2 - (sb.y + sb.height / 2);
39060
+ to = `translate(${px(-s * qx)}, ${px(-s * qy)}) scale(${round(s * 100) / 100})`;
39061
+ }
39062
+ change(scene, "transform", start, start + dur, to, ease(core.CURVES.camera));
39063
+ end = start + dur;
39064
+ break;
39065
+ }
39066
+ case "scroll": {
39067
+ const content = targets()[0];
39068
+ if (!content)
39069
+ break;
39070
+ const viewport = content.parentElement ?? section;
39071
+ const toAt = args.indexOf("to");
39072
+ const where = toAt >= 0 ? args[toAt + 1] : args[1];
39073
+ const tr = translateOf(content, start);
39074
+ const vb = box(viewport, start);
39075
+ const cb = box(content, start);
39076
+ let delta = 0;
39077
+ const n = Number(where);
39078
+ if (where !== undefined && Number.isFinite(n))
39079
+ delta = n - -tr.y;
39080
+ else if (where) {
39081
+ const el = find(section, where)[0];
39082
+ if (!el)
39083
+ issue(line.line, `nothing matches ${where}`);
39084
+ else
39085
+ delta = box(el, start).y - vb.y - (core.ms(opts.offset) ?? 0);
39086
+ }
39087
+ const max = Math.max(0, cb.height - vb.height);
39088
+ const y = Math.min(max, Math.max(0, -tr.y + delta));
39089
+ let t = start;
39090
+ if (pos && !inside(pos, { x: vb.x + 8, y: vb.y + 8, width: vb.width - 16, height: vb.height - 16 })) {
39091
+ t = travel({ p: { x: vb.x + vb.width * 0.6, y: vb.y + vb.height * 0.55 }, el: viewport }, start, {}) + 120;
39092
+ }
39093
+ const dur = core.ms(opts.dur) ?? Math.min(1400, Math.max(500, 420 + Math.abs(y + tr.y) * 1.2));
39094
+ change(content, "translate", t, t + dur, `${px(tr.x)} ${px(-y)}`, ease(CURVE_INOUT));
39095
+ end = t + dur;
39096
+ break;
39097
+ }
39098
+ case "wait":
39099
+ end = start + (core.ms(args[0]) ?? 0);
39100
+ if (core.ms(args[0]) === null)
39101
+ issue(line.line, `wait needs a time, like wait 600`);
39102
+ break;
39103
+ case "poster":
39104
+ poster = start;
39105
+ break;
39106
+ case "reset": {
39107
+ const dur = core.ms(args[0]) ?? core.ms(opts.dur) ?? 700;
39108
+ closeCaret(start);
39109
+ reset = { at: start, dur };
39110
+ end = start + dur;
39111
+ break;
39112
+ }
39113
+ }
39114
+ if (POINTER.has(verb) && pos)
39115
+ rested = end;
39116
+ beats.push({ line: line.line, text: line.text, start: round(start), end: round(end) });
39117
+ if (!line.with)
39118
+ lastStart = anchor;
39119
+ now = Math.max(now, end);
39120
+ }
39121
+ const total = Math.max(1, Math.round(reset ? reset.at + reset.dur : now));
39122
+ if (rested !== null && cursor && !idle && (reset ? reset.at : total) - rested > IDLE_MS)
39123
+ state(rested + IDLE_MS, cursor, "data-act-off", "");
39124
+ closeCaret(reset ? reset.at : total);
39125
+ if (cursor && !pos)
39126
+ state(0, cursor, "data-act-off", "");
39127
+ const loop = script.loop;
39128
+ if (loop && !reset && script.lines.length)
39129
+ issue(script.lines[script.lines.length - 1].line, "the scene loops without a reset, so it snaps back to the start; end it with reset (or say once)");
39130
+ const posterAt = poster ?? (reset ? reset.at : loop ? Math.max(0, total - 1) : total);
39131
+ return { tracks, states, total, loop, poster: round(posterAt), reset, beats };
39132
+ function travelTime(p) {
39133
+ if (!pos)
39134
+ return 700;
39135
+ const dist = Math.hypot(p.x - pos.x, p.y - pos.y);
39136
+ return Math.min(650, Math.max(300, 260 + dist * 0.9));
39137
+ }
39138
+ }
39139
+ function textHost(el) {
39140
+ const made = el.__actHost;
39141
+ if (made?.parentElement === el)
39142
+ return made;
39143
+ const cs = getComputedStyle(el);
39144
+ const paints = !/^(rgba\(0, 0, 0, 0\)|transparent)$/.test(cs.backgroundColor) || cs.backgroundImage !== "none" || cs.boxShadow !== "none" || ["Top", "Right", "Bottom", "Left"].some((s) => Number.parseFloat(cs[`border${s}Width`]) > 0 && cs[`border${s}Style`] !== "none");
39145
+ if (!paints)
39146
+ return el;
39147
+ const wrap = document.createElement("span");
39148
+ wrap.setAttribute("data-act-text", "");
39149
+ wrap.style.display = cs.display === "inline" ? "inline-block" : "block";
39150
+ while (el.firstChild)
39151
+ wrap.appendChild(el.firstChild);
39152
+ el.appendChild(wrap);
39153
+ el.__actHost = wrap;
39154
+ return wrap;
39155
+ }
39156
+ function rollColumns(el, old) {
39157
+ const cached = el.__actRoll;
39158
+ if (cached && cached.old === old)
39159
+ return cached.cols;
39160
+ const next = el.__actText ?? el.textContent ?? "";
39161
+ el.__actText = next;
39162
+ const lineH = el.getBoundingClientRect().height || 16;
39163
+ const k = el.getBoundingClientRect().width / (el.offsetWidth || 1) || 1;
39164
+ const h = lineH / k;
39165
+ const probe = document.createElement("span");
39166
+ probe.style.whiteSpace = "pre";
39167
+ el.textContent = "";
39168
+ el.appendChild(probe);
39169
+ const widthOf = (ch) => {
39170
+ if (!ch)
39171
+ return 0;
39172
+ probe.textContent = ch;
39173
+ return probe.getBoundingClientRect().width / k;
39174
+ };
39175
+ const pairs = core.columns(old, next).map((c) => ({ ...c, from_w: widthOf(c.from), to_w: widthOf(c.to) }));
39176
+ probe.remove();
39177
+ const cols = pairs.map((c) => {
39178
+ if (c.from === c.to) {
39179
+ el.appendChild(document.createTextNode(c.to));
39180
+ return null;
39181
+ }
39182
+ const col = document.createElement("span");
39183
+ col.setAttribute("data-act-roll", "");
39184
+ col.style.cssText = `display:inline-block;vertical-align:top;overflow:hidden;height:${h}px`;
39185
+ const strip = document.createElement("span");
39186
+ strip.style.cssText = "display:flex;flex-direction:column";
39187
+ for (const ch of [c.from, c.to]) {
39188
+ const s = document.createElement("span");
39189
+ s.style.height = `${h}px`;
39190
+ s.style.lineHeight = `${h}px`;
39191
+ s.style.whiteSpace = "pre";
39192
+ s.textContent = ch;
39193
+ strip.appendChild(s);
39194
+ }
39195
+ col.appendChild(strip);
39196
+ el.appendChild(col);
39197
+ return { col, strip, h, from: c.from_w, to: c.to_w };
39198
+ });
39199
+ el.__actRoll = { old, cols };
39200
+ return cols;
39201
+ }
39202
+ function finish(section, scope, plan) {
39203
+ const tracks = plan.tracks;
39204
+ stateTracks(section, scope, plan);
39205
+ const all = [...tracks.values()];
39206
+ for (const tr of all) {
39207
+ if (tr.initial === null) {
39208
+ const first = [...tr.segs].sort((a, b) => a.t0 - b.t0 || a.order - b.order)[0];
39209
+ tr.initial = first?.from ?? tr.stateInitial ?? getComputedStyle(tr.el, tr.pseudo || null).getPropertyValue(tr.prop);
39210
+ }
39211
+ }
39212
+ for (const tr of all)
39213
+ settle(tr);
39214
+ if (plan.reset) {
39215
+ const { at, dur } = plan.reset;
39216
+ const hidden = new Set;
39217
+ for (const tr of all) {
39218
+ const v = valueAt(tr, at).trim();
39219
+ if (tr.prop === "opacity" && Number(v) === 0 || tr.prop === "display" && v === "none")
39220
+ hidden.add(tr.el);
39221
+ }
39222
+ for (const tr of all) {
39223
+ const snap = hidden.has(tr.el) && tr.prop !== "opacity";
39224
+ tr.segs.push({
39225
+ t0: at,
39226
+ t1: snap ? at : at + dur,
39227
+ to: tr.initial,
39228
+ ease: core.CURVES.inout,
39229
+ order: ++order
39230
+ });
39231
+ settle(tr);
39232
+ }
39233
+ }
39234
+ return all;
39235
+ }
39236
+ function valueAt(tr, t) {
39237
+ let v = tr.initial;
39238
+ for (const s of tr.segs) {
39239
+ if (s.t0 > t)
39240
+ break;
39241
+ v = s.to;
39242
+ }
39243
+ return v;
39244
+ }
39245
+ function settle(tr) {
39246
+ tr.segs.sort((a, b) => a.t0 - b.t0 || a.order - b.order);
39247
+ let cur = tr.initial;
39248
+ let prev = null;
39249
+ const out = [];
39250
+ for (const s of tr.segs) {
39251
+ if (prev && s.t0 < prev.t1) {
39252
+ const p = (s.t0 - prev.t0) / (prev.t1 - prev.t0 || 1);
39253
+ cur = sample(tr, prev.from, prev.to, prev.ease, p);
39254
+ prev.t1 = s.t0;
39255
+ prev.to = cur;
39256
+ }
39257
+ const seg = { ...s, from: s.from ?? cur };
39258
+ out.push(seg);
39259
+ cur = seg.to;
39260
+ prev = seg;
39261
+ }
39262
+ tr.segs = out;
39263
+ }
39264
+ function sample(tr, from, to, ease, p) {
39265
+ const prop = camel(tr.prop);
39266
+ try {
39267
+ const a = tr.el.animate([{ [prop]: from }, { [prop]: to }], {
39268
+ duration: 1000,
39269
+ easing: ease,
39270
+ fill: "both",
39271
+ pseudoElement: tr.pseudo || undefined
39272
+ });
39273
+ a.pause();
39274
+ a.currentTime = Math.max(0, Math.min(1, p)) * 1000;
39275
+ const v = getComputedStyle(tr.el, tr.pseudo || null).getPropertyValue(tr.prop);
39276
+ a.cancel();
39277
+ return v;
39278
+ } catch {
39279
+ return p < 0.5 ? from : to;
39280
+ }
39281
+ }
39282
+ function stateTracks(section, scope, plan) {
39283
+ if (!plan.states.length)
39284
+ return;
39285
+ const names = new Set(plan.states.map((s) => s.attr));
39286
+ const markers = [...names].map((n) => n.startsWith(".") ? new RegExp(`\\.${CSS.escape(n.slice(1))}(?![\\w-])`) : n);
39287
+ const rules = rulesOf(scope).filter((r) => r.selectorText.includes("data-act-") || markers.some((m) => typeof m === "string" ? r.selectorText.includes(`[${m}`) : m.test(r.selectorText)));
39288
+ if (!rules.length)
39289
+ return;
39290
+ const ALWAYS = [
39291
+ "opacity",
39292
+ "transform",
39293
+ "translate",
39294
+ "scale",
39295
+ "rotate",
39296
+ "color",
39297
+ "background-color",
39298
+ "border-top-color",
39299
+ "border-right-color",
39300
+ "border-bottom-color",
39301
+ "border-left-color",
39302
+ "box-shadow",
39303
+ "filter",
39304
+ "visibility",
39305
+ "display",
39306
+ "outline-color",
39307
+ "outline-style"
39308
+ ];
39309
+ const targets = rules.map((r) => {
39310
+ const parts = splitTop(r.selectorText);
39311
+ return parts.map((sel) => {
39312
+ const pseudo = /::(before|after)\b/.exec(sel)?.[0] ?? "";
39313
+ const clean = sel.replace(/::?(before|after|marker|placeholder|selection)(?![\w-])/g, "");
39314
+ const props = new Set;
39315
+ for (let i = 0;i < r.style.length; i++) {
39316
+ const p = r.style[i];
39317
+ if (!/^(transition|animation)/.test(p))
39318
+ props.add(p);
39319
+ }
39320
+ return { sel: clean || "*", pseudo, props };
39321
+ });
39322
+ });
39323
+ const events = [...plan.states].sort((a, b) => a.t - b.t || a.order - b.order);
39324
+ const moments = [{ t: 0, events: [] }];
39325
+ for (const e of events) {
39326
+ const last = moments[moments.length - 1];
39327
+ if (e.t <= 0.5)
39328
+ moments[0].events.push(e);
39329
+ else if (Math.abs(last.t - e.t) < 0.5)
39330
+ last.events.push(e);
39331
+ else
39332
+ moments.push({ t: e.t, events: [e] });
39333
+ }
39334
+ const original = new Map;
39335
+ const apply = (e) => {
39336
+ let saved = original.get(e.el);
39337
+ if (!saved) {
39338
+ saved = new Map;
39339
+ original.set(e.el, saved);
39340
+ }
39341
+ if (e.attr.startsWith(".")) {
39342
+ const cls = e.attr.slice(1);
39343
+ if (!saved.has(e.attr))
39344
+ saved.set(e.attr, e.el.classList.contains(cls) ? "" : null);
39345
+ e.el.classList.toggle(cls, e.value !== null);
39346
+ return;
39347
+ }
39348
+ if (!saved.has(e.attr))
39349
+ saved.set(e.attr, e.el.getAttribute(e.attr));
39350
+ if (e.value === null)
39351
+ e.el.removeAttribute(e.attr);
39352
+ else
39353
+ e.el.setAttribute(e.attr, e.value);
39354
+ };
39355
+ const restore = () => {
39356
+ for (const [el, saved] of original) {
39357
+ for (const [attr, v] of saved) {
39358
+ if (attr.startsWith("."))
39359
+ el.classList.toggle(attr.slice(1), v !== null);
39360
+ else if (v === null)
39361
+ el.removeAttribute(attr);
39362
+ else
39363
+ el.setAttribute(attr, v);
39364
+ }
39365
+ }
39366
+ };
39367
+ const watched = new Map;
39368
+ const look = () => {
39369
+ targets.forEach((parts) => {
39370
+ for (const part of parts) {
39371
+ let els;
39372
+ try {
39373
+ els = [...section.querySelectorAll(part.sel)];
39374
+ if (section.matches(part.sel))
39375
+ els.push(section);
39376
+ } catch {
39377
+ continue;
39378
+ }
39379
+ for (const el of els) {
39380
+ if (watched.size >= 600)
39381
+ return;
39382
+ if (el.__actKey === undefined)
39383
+ el.__actKey = ++order;
39384
+ const id = `${el.__actKey}|${part.pseudo}`;
39385
+ let w_ = watched.get(id);
39386
+ if (!w_) {
39387
+ w_ = { el, pseudo: part.pseudo, props: new Set(part.pseudo ? [] : ALWAYS) };
39388
+ watched.set(id, w_);
39389
+ }
39390
+ for (const p of part.props)
39391
+ w_.props.add(p);
39392
+ }
39393
+ }
39394
+ });
39395
+ };
39396
+ for (const m of moments) {
39397
+ for (const e of m.events)
39398
+ apply(e);
39399
+ look();
39400
+ }
39401
+ restore();
39402
+ const list = [...watched.values()];
39403
+ const reads = [];
39404
+ for (const m of moments) {
39405
+ for (const e of m.events)
39406
+ apply(e);
39407
+ reads.push(list.map((wt) => {
39408
+ const cs = getComputedStyle(wt.el, wt.pseudo || null);
39409
+ return {
39410
+ values: [],
39411
+ transition: [
39412
+ cs.transitionProperty,
39413
+ cs.transitionDuration,
39414
+ cs.transitionDelay,
39415
+ cs.transitionTimingFunction
39416
+ ]
39417
+ };
39418
+ }));
39419
+ }
39420
+ restore();
39421
+ const still = document.createElement("style");
39422
+ still.textContent = "*,*::before,*::after{transition:none!important}";
39423
+ (scope instanceof Document ? scope.head : scope).appendChild(still);
39424
+ moments.forEach((m, mi) => {
39425
+ for (const e of m.events)
39426
+ apply(e);
39427
+ list.forEach((wt, i) => {
39428
+ const cs = getComputedStyle(wt.el, wt.pseudo || null);
39429
+ reads[mi][i].values = [...wt.props].map((p) => cs.getPropertyValue(p));
39430
+ });
39431
+ });
39432
+ restore();
39433
+ for (const e of moments[0].events)
39434
+ apply(e);
39435
+ section.offsetHeight;
39436
+ still.remove();
39437
+ for (const a of scope.getAnimations ? scope.getAnimations() : document.getAnimations()) {
39438
+ if ("transitionProperty" in a) {
39439
+ const t = a.effect?.target;
39440
+ if (t && section.contains(t))
39441
+ a.cancel();
39442
+ }
39443
+ }
39444
+ list.forEach((wt, i) => {
39445
+ const props = [...wt.props];
39446
+ props.forEach((prop, j) => {
39447
+ const first = reads[0][i].values[j];
39448
+ let last = first;
39449
+ const segs = [];
39450
+ for (let m = 1;m < moments.length; m++) {
39451
+ const v = reads[m][i].values[j];
39452
+ if (v === last)
39453
+ continue;
39454
+ const [tp, td, tdl, tf] = reads[m][i].transition;
39455
+ const timing = transitionFor(prop, tp, td, tdl, tf);
39456
+ const t0 = moments[m].t + timing.delay;
39457
+ segs.push({ t0, t1: t0 + timing.duration, to: v, ease: timing.ease });
39458
+ last = v;
39459
+ }
39460
+ if (!segs.length)
39461
+ return;
39462
+ const key = `${wt.el.__actKey}|${wt.pseudo}|${prop}`;
39463
+ let tr = plan.tracks.get(key);
39464
+ if (!tr) {
39465
+ tr = { el: wt.el, pseudo: wt.pseudo, prop, initial: null, segs: [] };
39466
+ plan.tracks.set(key, tr);
39467
+ }
39468
+ tr.stateInitial = first;
39469
+ for (const s of segs)
39470
+ tr.segs.push({ ...s, order: ++order });
39471
+ });
39472
+ });
39473
+ }
39474
+ function transitionFor(prop, props, durs, delays, eases) {
39475
+ const ps = splitTop(props);
39476
+ const ds = splitTop(durs);
39477
+ const dl = splitTop(delays);
39478
+ const es = splitTop(eases);
39479
+ const toMs = (v) => {
39480
+ if (!v)
39481
+ return 0;
39482
+ const n = Number.parseFloat(v);
39483
+ return v.trim().endsWith("ms") ? n : n * 1000;
39484
+ };
39485
+ for (let i = ps.length - 1;i >= 0; i--) {
39486
+ const p = ps[i];
39487
+ const sides = /^border-(color|width|style)$/.exec(p);
39488
+ const matches = p === "all" || p === prop || prop.startsWith(`${p}-`) || sides && new RegExp(`^border-(top|right|bottom|left)-${sides[1]}$`).test(prop) || p === "inset" && /^(top|right|bottom|left)$/.test(prop);
39489
+ if (!matches)
39490
+ continue;
39491
+ return {
39492
+ duration: toMs(ds[i % ds.length]),
39493
+ delay: toMs(dl[i % dl.length]),
39494
+ ease: es[i % es.length] ?? "ease"
39495
+ };
39496
+ }
39497
+ return { duration: 0, delay: 0, ease: "linear" };
39498
+ }
39499
+ function build(tracks, plan, paused) {
39500
+ const out = [];
39501
+ for (const tr of tracks) {
39502
+ if (!tr.segs.length)
39503
+ continue;
39504
+ const kf = core.frames(tr.initial, tr.segs, plan.total);
39505
+ if (kf.every((f) => f.value === kf[0].value))
39506
+ continue;
39507
+ const prop = camel(tr.prop);
39508
+ try {
39509
+ const a = tr.el.animate(kf.map((f) => ({ offset: f.offset, easing: f.easing, [prop]: f.value })), {
39510
+ duration: plan.total,
39511
+ iterations: plan.loop ? Number.POSITIVE_INFINITY : 1,
39512
+ fill: "both",
39513
+ pseudoElement: tr.pseudo || undefined
39514
+ });
39515
+ a.id = ID;
39516
+ if (paused) {
39517
+ a.pause();
39518
+ a.currentTime = 0;
39519
+ }
39520
+ out.push(a);
39521
+ } catch {}
39522
+ }
39523
+ return out;
39524
+ }
39525
+ w.__ponzuAct = {
39526
+ mount,
39527
+ get: (section) => handles.get(section) ?? null,
39528
+ isAct: (a) => a.id === ID
39529
+ };
39530
+ }
39531
+ var ACT_SCRIPT = `(${actRuntime.toString()})((${actCore.toString()})())`;
37359
39532
  // packages/render/src/capture.ts
37360
39533
  var MIN_SCALE = 0.25;
37361
39534
  var MAX_SCALE = 4;
@@ -39965,6 +42138,8 @@ function motionRuntime() {
39965
42138
  let scroller = null;
39966
42139
  let rewritten = null;
39967
42140
  const issues = [];
42141
+ let act = null;
42142
+ const isAct = (a) => a.id === "ponzu-act";
39968
42143
  const frame = () => new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(() => r())));
39969
42144
  const round = (n) => Math.round(n * 10) / 10;
39970
42145
  const idOf = (el) => el?.closest("[data-id]")?.getAttribute("data-id") ?? "";
@@ -40073,10 +42248,10 @@ function motionRuntime() {
40073
42248
  timeline: "time"
40074
42249
  };
40075
42250
  }
40076
- function list() {
42251
+ function list(scene = true) {
40077
42252
  const out = [];
40078
42253
  for (const e of entries) {
40079
- if (e.trigger !== trigger)
42254
+ if (e.trigger !== trigger || !scene && isAct(e.anim))
40080
42255
  continue;
40081
42256
  const d = describe(e);
40082
42257
  if (d)
@@ -40147,9 +42322,9 @@ function motionRuntime() {
40147
42322
  loopEnd = Math.max(loopEnd, a.delay + one);
40148
42323
  }
40149
42324
  }
40150
- return {
42325
+ const out = {
40151
42326
  trigger,
40152
- animations: animations.slice(0, 60),
42327
+ animations: (act ? list(false) : animations).slice(0, 60),
40153
42328
  settled: round(settled),
40154
42329
  loops,
40155
42330
  cycle: round(cycle),
@@ -40157,6 +42332,9 @@ function motionRuntime() {
40157
42332
  end: round(Math.max(settled, loopEnd)),
40158
42333
  at: round(now)
40159
42334
  };
42335
+ if (act && trigger === "load")
42336
+ out.act = act.summary;
42337
+ return out;
40160
42338
  }
40161
42339
  function setTime(t) {
40162
42340
  now = t;
@@ -40194,6 +42372,7 @@ function motionRuntime() {
40194
42372
  parent.removeChild(root);
40195
42373
  document.body.offsetHeight;
40196
42374
  parent.insertBefore(root, next);
42375
+ act = w.__ponzuAct?.mount(root) ?? null;
40197
42376
  entries = [];
40198
42377
  adopt(document.getAnimations(), "load");
40199
42378
  for (const s of svgs()) {
@@ -40388,9 +42567,12 @@ function motionRuntime() {
40388
42567
  if ("error" in r)
40389
42568
  return r;
40390
42569
  }
40391
- await seek(opts.at ?? info().settled);
42570
+ await seek(opts.at ?? rest());
40392
42571
  return info();
40393
42572
  }
42573
+ function rest() {
42574
+ return act && trigger === "load" ? act.summary.poster : info().settled;
42575
+ }
40394
42576
  function plan(spec) {
40395
42577
  const n = Math.max(1, Math.min(24, Math.round(spec.frames ?? 9)));
40396
42578
  const spread = (from, to) => n === 1 || to <= from ? [from] : Array.from({ length: n }, (_, i) => round(from + (to - from) * i / (n - 1)));
@@ -40414,8 +42596,25 @@ function motionRuntime() {
40414
42596
  };
40415
42597
  }
40416
42598
  const i = info();
42599
+ const story = act && trigger === "load" && !spec.frames && spec.from === undefined && spec.to === undefined;
42600
+ if (story) {
42601
+ const s = act.summary;
42602
+ const last = s.loop ? s.duration - 1 : s.duration;
42603
+ const beats = s.beats.filter((b) => b.end > b.start || /^(poster|reset)/.test(b.text));
42604
+ const picks = beats.length > 23 ? Array.from({ length: 23 }, (_, k) => beats[Math.round(k * (beats.length - 1) / 22)]) : beats;
42605
+ const steps = [{ t: 0, label: "0ms start" }];
42606
+ for (const b of picks) {
42607
+ const t = round(Math.min(last, /^reset/.test(b.text) ? b.start : b.end));
42608
+ if (steps.some((x) => x.t === t))
42609
+ continue;
42610
+ const text = b.text.length > 34 ? `${b.text.slice(0, 33)}\u2026` : b.text;
42611
+ steps.push({ t, label: `${Math.round(t)}ms ${text}` });
42612
+ }
42613
+ steps.sort((a, b) => a.t - b.t);
42614
+ return { steps };
42615
+ }
40417
42616
  const from = spec.from ?? 0;
40418
- const to = spec.to ?? Math.min(i.end, 1e4);
42617
+ const to = spec.to ?? Math.min(i.end, act ? Math.max(1e4, act.summary.duration) : 1e4);
40419
42618
  return {
40420
42619
  steps: spread(from, Math.max(from, to)).map((t) => ({
40421
42620
  t,
@@ -40467,10 +42666,10 @@ function motionRuntime() {
40467
42666
  }
40468
42667
  async function settle() {
40469
42668
  scrollTo(0);
40470
- await seek(info().settled);
42669
+ await seek(rest());
40471
42670
  }
40472
42671
  function lint() {
40473
- const out = [...issues];
42672
+ const out = [...issues, ...act?.issues ?? []];
40474
42673
  if (!root)
40475
42674
  return out;
40476
42675
  const defined = new Set;
@@ -40625,7 +42824,7 @@ img{display:block;background:repeating-conic-gradient(#fff 0 25%,#f4f4f4 0 50%)
40625
42824
  }
40626
42825
  var FULL_LINT_SCRIPT = `[...${FONT_LINT_SCRIPT}, ...${LINT_SCRIPT}, ...(window.__ponzuMotion ? ${motionCall("lint")} : []), ...${THEME_LINT_SCRIPT}].slice(0, 30)`;
40627
42826
  function prepareScript(opts) {
40628
- return `(${MOTION_SCRIPT}, ${motionCall("prepare", opts)})`;
42827
+ return `(${ACT_SCRIPT}, ${MOTION_SCRIPT}, ${motionCall("prepare", opts)})`;
40629
42828
  }
40630
42829
  async function recordFrames(page, opts) {
40631
42830
  const prepared = await page.evaluate(prepareScript({ interact: opts.interact, at: opts.scroll ? undefined : 0 }));
@@ -47739,7 +49938,7 @@ function remoteUpdater(endpoint, token) {
47739
49938
  // apps/cli/package.json
47740
49939
  var package_default = {
47741
49940
  name: "ponzu",
47742
- version: "1.77.0",
49941
+ version: "1.78.1",
47743
49942
  description: "The open source canvas your agent draws on in HTML and CSS.",
47744
49943
  type: "module",
47745
49944
  license: "MIT",