@leonidstern/labit 0.7.0 → 0.7.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leonidstern/labit",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "Pin comments on pages, read by your agent as plain text. Local mode: comment on pages on your computer and Claude answers on the pins.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -8,26 +8,32 @@
8
8
  },
9
9
  "files": [
10
10
  "dist/local.mjs",
11
- "public/_lab/comments.js",
12
- "public/_lab/components.js",
13
- "public/_lab/switcher.js",
14
- "public/_lab/draw.js",
15
- "public/_lab/board.js",
16
- "public/_lab/boardview.js",
11
+ "public/_lab/comments.js.br",
12
+ "public/_lab/components.js.br",
13
+ "public/_lab/switcher.js.br",
14
+ "public/_lab/draw.js.br",
15
+ "public/_lab/sections.js.br",
16
+ "public/_lab/motion.js.br",
17
+ "public/_lab/boardview.js.br",
18
+ "public/_lab/pics.js.br",
19
+ "public/_lab/attach.js.br",
17
20
  "public/_lab/lab.css",
18
21
  "public/_lab/favicon.svg",
19
22
  "skills/",
20
23
  ".claude-plugin/"
21
24
  ],
22
25
  "scripts": {
23
- "build": "npx --yes -p esbuild@0.25.12 node scripts/build-widget.mjs --outfile=public/_lab/comments.js",
26
+ "build": "npx --yes -p esbuild@0.25.12 -p terser@5.44.0 node scripts/build-widget.mjs --outfile=public/_lab/comments.js",
24
27
  "build:watch": "npm run build -- --watch",
25
28
  "dev": "node scripts/dev.mjs",
26
- "build:cli": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && npx --yes esbuild@0.25.12 local.mjs --bundle --minify --keep-names --format=esm --platform=node --target=node22 --outdir=dist --out-extension:.js=.mjs --log-level=warning",
27
- "prepack": "npm run build:cli",
29
+ "build:cli": "npx --yes -p esbuild@0.25.12 -p terser@5.44.0 node scripts/build-cli.mjs",
30
+ "prepack": "npm run build && npm run build:cli",
28
31
  "typecheck": "node ci/metrics.mjs types",
29
32
  "deadcode": "npx --yes knip@5.66.0 --include files,exports,types --no-progress",
30
33
  "reuse": "node ci/reuse.mjs",
34
+ "classes": "node ci/classes.mjs",
35
+ "waste": "npm run --silent build && npx --yes -p esbuild@0.25.12 -p typescript@5.9.3 node ci/waste.mjs",
36
+ "pretest": "node -e \"import('./lib/build.ts').then((m) => process.exit(m.ensureBuilt('.') ? 0 : 1))\"",
31
37
  "test": "node --import ./test/setup.mjs --test test/*.test.mjs"
32
38
  },
33
39
  "engines": {
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,148 +1 @@
1
- /* The lab's design system: the comment widget and every lab page (the page list, "not found", pages an agent makes
2
- for the lab) share these. Served at /_lab/lab.css. The --lab-* names are the widget's own theme hooks, so a page that
3
- sets them themes the widget too.
4
-
5
- Colour: white, black and green, with 4 see-through steps each (primitives, as in Cooking), and named uses that point at them.
6
- Corners: two in all, 6 px small (keys, code, rows, pills), 12 px boxes and buttons; circles only for dots.
7
- Type: the system font, 15 px text, 13 px small, 11 px caps labels; one weight for text, 600 for titles.
8
- Depth: a hairline ring and a soft shadow, no borders. */
9
- :root {
10
- /* Base colours (primitives): white and black, and see-through steps of each (4 a scheme, as Cooking does), plus the
11
- green and its own 4 steps. Fills are a wash of black on light, of white on dark, so they sit right on any surface. */
12
- --lab-white: #ffffff;
13
- --lab-ink: #141414;
14
- --lab-paper-dark: #1c1c1e;
15
- --lab-black: #000000;
16
- --lab-black-1: rgba(0, 0, 0, .05); /* light: page wash, soft fills */
17
- --lab-black-2: rgba(0, 0, 0, .10); /* light: hover */
18
- --lab-black-3: rgba(0, 0, 0, .15); /* light: separators */
19
- --lab-black-4: rgba(0, 0, 0, .50); /* light: secondary text */
20
- --lab-white-1: rgba(255, 255, 255, .05); /* dark: soft fills */
21
- --lab-white-2: rgba(255, 255, 255, .10); /* dark: hover */
22
- --lab-white-3: rgba(255, 255, 255, .15); /* dark: separators */
23
- --lab-white-4: rgba(255, 255, 255, .50); /* dark: secondary text */
24
- --lab-green-1: rgba(52, 199, 89, .15); /* soft green: your bubbles, rec pills */
25
- --lab-green-2: rgba(52, 199, 89, .30); /* hover on green */
26
- --lab-green-3: rgba(52, 199, 89, .50); /* outlines, dots */
27
- --lab-green-4: rgb(36, 160, 70); /* green: done, picks, new (dark: #34c759) */
28
- --lab-amber: #e08a1a; /* not ok yet: the agent asks, reconnecting, nobody listening (dark: #f0a040) */
29
-
30
- /* What things use (semantic), light. Dark only re-points these. */
31
- --lab-bg: var(--lab-white); /* boxes */
32
- --lab-fg: var(--lab-ink); /* text */
33
- --lab-page: #f2f2f2; /* the page behind boxes: white under black-1 (5%), solid so nothing shows through */
34
- --lab-muted: var(--lab-black-4); /* secondary text */
35
- --lab-line: var(--lab-black-3); /* dividers, drawn as a hairline */
36
- --lab-hair: .5px solid var(--lab-line); /* one device pixel on a Retina screen, as Apple's separators */
37
- --lab-soft: var(--lab-black-1); /* keys, other people's bubbles, boxes to type in */
38
- --lab-hover: var(--lab-black-2); /* hover on rows and buttons */
39
- --lab-green: var(--lab-green-4); /* done, picks, new */
40
- --lab-green-soft: var(--lab-green-1); /* your bubbles, rec pills */
41
- --lab-shadow: 0 0 0 .5px rgba(20, 20, 20, .14), 0 1px 2px rgba(0, 0, 0, .04), 0 8px 28px rgba(0, 0, 0, .08);
42
- --lab-r-s: 6px;
43
- --lab-radius: 12px;
44
- /* What boxes and small parts actually use: the same sizes, as Apple's continuous corners where the browser has them (below). */
45
- --lab-corner: var(--lab-radius);
46
- --lab-corner-s: var(--lab-r-s);
47
- --lab-font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
48
- --lab-mono: ui-monospace, 'SF Mono', Menlo, monospace;
49
- /* Motion: the durations and curves the widget moves with (docs/motion.md); a lab page that moves things uses the same,
50
- so it feels like one product. Set them and the widget follows, as it does the colours. */
51
- --lab-t-instant: 0ms; /* no motion: the state changes at once */
52
- --lab-t-quick: 120ms; /* a hover, a fade, a press: small and local */
53
- --lab-t-base: 200ms; /* something appears, moves a little, or a box changes size */
54
- --lab-t-slow: 300ms; /* a sheet, a flight, a pin changing face: the biggest movement */
55
- --lab-t-loop: 1200ms; /* one turn of something that goes on */
56
- --lab-t-hold: 1000ms; /* how long a highlight stays (a wait, kept with reduced motion) */
57
- --lab-ease: cubic-bezier(.2, .8, .2, 1); /* standard */
58
- --lab-ease-out: cubic-bezier(0, 0, .58, 1); /* a fade or a colour coming in */
59
- --lab-ease-in: cubic-bezier(.4, 0, 1, 1); /* something leaving */
60
- --lab-ease-settle: cubic-bezier(.32, .72, 0, 1); /* a sheet */
61
- --lab-ease-pop: cubic-bezier(.34, 1.56, .64, 1); /* an arrival with a small overshoot */
62
- color-scheme: light;
63
- }
64
- /* Reduced motion: the durations go to nothing, here and (through these names) in the widget. */
65
- @media (prefers-reduced-motion: reduce) {
66
- :root { --lab-t-quick: 0ms; --lab-t-base: 0ms; --lab-t-slow: 0ms; --lab-t-loop: 0ms; }
67
- }
68
-
69
- @media (prefers-color-scheme: dark) {
70
- :root:not([data-theme='light']) {
71
- --lab-bg: var(--lab-paper-dark); --lab-fg: #f4f4f5; --lab-page: var(--lab-black); --lab-muted: var(--lab-white-4);
72
- --lab-line: var(--lab-white-3); --lab-soft: var(--lab-white-1); --lab-hover: var(--lab-white-2); --lab-green: #34c759; --lab-amber: #f0a040; --lab-green-soft: var(--lab-green-1);
73
- --lab-shadow: 0 0 0 1px rgba(244, 244, 245, .16), 0 10px 32px rgba(0, 0, 0, .5);
74
- color-scheme: dark;
75
- }
76
- }
77
- :root[data-theme='dark'] {
78
- --lab-bg: var(--lab-paper-dark); --lab-fg: #f4f4f5; --lab-page: var(--lab-black); --lab-muted: var(--lab-white-4);
79
- --lab-line: var(--lab-white-3); --lab-soft: var(--lab-white-1); --lab-hover: var(--lab-white-2); --lab-green: #34c759; --lab-amber: #f0a040; --lab-green-soft: var(--lab-green-1);
80
- --lab-shadow: 0 0 0 1px rgba(244, 244, 245, .16), 0 10px 32px rgba(0, 0, 0, .5);
81
- color-scheme: dark;
82
- }
83
-
84
- /* Base */
85
- *, *::before, *::after { box-sizing: border-box; }
86
- body.lab {
87
- margin: 0; background: var(--lab-page); color: var(--lab-fg); font: 15px/1.45 var(--lab-font);
88
- -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
89
- padding: 24px max(16px, env(safe-area-inset-right, 0px)) 96px max(16px, env(safe-area-inset-left, 0px));
90
- }
91
- .lab main, .lab-main { max-width: 680px; margin: 0 auto; display: grid; gap: 20px; }
92
- .lab h1 { font-size: 24px; line-height: 1.2; font-weight: 600; letter-spacing: -.01em; margin: 0; text-wrap: balance; }
93
- .lab h2 { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--lab-muted); margin: 0 0 8px; }
94
- .lab p { margin: 0; }
95
- .lab a { color: inherit; text-underline-offset: 2px; }
96
- /* The lab's own screens open with the mark and the name. */
97
- .lab-brand { justify-self: start; display: inline-flex; align-items: center; gap: 7px; font-size: 17px; font-weight: 600; letter-spacing: -.03em; color: inherit; text-decoration: none; }
98
- .lab-brand svg { margin-top: -2px; }
99
- .lab-muted, .lab .lede { color: var(--lab-muted); }
100
- /* Someone is listening here / nobody is: said next to a page, where it decides whether a comment is heard. */
101
- .lab-ok { color: var(--lab-green); font-weight: 600; }
102
- .lab-warn { color: var(--lab-amber); font-weight: 600; }
103
- .lab .lede { margin-top: 6px; }
104
- .lab-small { font-size: 13px; }
105
-
106
- /* A box: white, 12 px corners, hairline ring and soft shadow. */
107
- .lab-box { background: var(--lab-bg); box-shadow: var(--lab-shadow); border-radius: var(--lab-corner); padding: 14px 16px; }
108
-
109
- /* Pills: small corners, 11 px, quiet grey. */
110
- .lab-pill { display: inline-block; font-size: 11px; font-weight: 600; line-height: 1; padding: 4px 8px; border-radius: var(--lab-corner-s);
111
- background: var(--lab-soft); color: var(--lab-muted); white-space: nowrap; }
112
-
113
- /* Buttons, as in the widget's bar. */
114
- .lab-button { border: 0; border-radius: var(--lab-corner); padding: 9px 14px; cursor: pointer; background: var(--lab-bg); color: var(--lab-fg);
115
- box-shadow: var(--lab-shadow); font: 500 13px var(--lab-font); white-space: nowrap; }
116
-
117
- /* Keys and code: small corners on the soft grey. */
118
- .lab kbd, .lab code { font: 12px var(--lab-mono); background: var(--lab-soft); padding: 1px 5px; border-radius: var(--lab-corner-s); }
119
-
120
- /* A list of rows inside a box (the page list, the widget's list). */
121
- .lab-rows { list-style: none; margin: 0; padding: 6px; }
122
- .lab-rows a { display: flex; gap: 8px; align-items: baseline; padding: 7px 10px; border-radius: var(--lab-corner-s); text-decoration: none; }
123
- .lab-rows a:hover { background: var(--lab-soft); } /* the widget's rows: 7×10, the soft wash */
124
- .lab-rows .lab-muted { font-size: 13px; }
125
- /* The page list: title and when it changed on one line, the file under it; open comments as a green count. */
126
- .lab-pages a { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; row-gap: 1px; align-items: baseline; padding: 7px 10px; }
127
- .lab-page-t { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
128
- .lab-page-f { grid-column: 1; font-size: 13px; color: var(--lab-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
129
- .lab-page-m { grid-row: 1; grid-column: 2; display: inline-flex; gap: 8px; align-items: baseline; font-size: 13px; color: var(--lab-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
130
- .lab-page-m b { font-weight: 600; color: var(--lab-green); }
131
- .lab-filter { width: 100%; box-sizing: border-box; margin: 0; padding: 9px 12px; border: 0; border-radius: var(--lab-corner); background: var(--lab-soft); color: inherit; font: inherit; outline: none; }
132
- .lab-filter:focus-visible { outline: 2px solid var(--lab-fg); outline-offset: 2px; } /* the widget's button focus ring */
133
- .lab-hint { font-size: 13px; margin: 0; }
134
-
135
- /* Tables */
136
- .lab-table { width: 100%; border-collapse: collapse; font-size: 14px; }
137
- .lab-table th, .lab-table td { text-align: left; padding: 7px 10px; border-bottom: var(--lab-hair); vertical-align: top; }
138
- .lab-table tr:last-child td { border-bottom: 0; }
139
- .lab-table th { color: var(--lab-muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
140
-
141
- /* Apple's continuous corners (squircle) in Safari 26 and Chrome: a squircle needs about 1.8 times the radius to look the
142
- same size. */
143
- @supports (corner-shape: squircle) {
144
- :root { --lab-corner: calc(var(--lab-radius) * 1.8); --lab-corner-s: 11px; }
145
- body.lab * { corner-shape: squircle; }
146
- /* The pin keeps its teardrop. */
147
- body.lab .pin { corner-shape: round; }
148
- }
1
+ :root{--lab-white:#ffffff;--lab-ink:#141414;--lab-paper-dark:#1c1c1e;--lab-black:#000000;--lab-black-1:rgba(0,0,0,.05);--lab-black-2:rgba(0,0,0,.1);--lab-black-3:rgba(0,0,0,.15);--lab-black-4:rgba(0,0,0,.5);--lab-white-1:rgba(255,255,255,.05);--lab-white-2:rgba(255,255,255,.1);--lab-white-3:rgba(255,255,255,.15);--lab-white-4:rgba(255,255,255,.5);--lab-green-1:rgba(52,199,89,.15);--lab-green-2:rgba(52,199,89,.3);--lab-green-3:rgba(52,199,89,.5);--lab-green-4:rgb(36,160,70);--lab-amber:#e08a1a;--lab-bg:var(--lab-white);--lab-fg:var(--lab-ink);--lab-page:#f2f2f2;--lab-muted:var(--lab-black-4);--lab-line:var(--lab-black-3);--lab-hair:.5px solid var(--lab-line);--lab-soft:var(--lab-black-1);--lab-hover:var(--lab-black-2);--lab-green:var(--lab-green-4);--lab-green-soft:var(--lab-green-1);--lab-shadow:0 0 0 .5px rgba(20,20,20,.14),0 1px 2px rgba(0,0,0,.04),0 8px 28px rgba(0,0,0,.08);--lab-r-s:6px;--lab-radius:12px;--lab-corner:var(--lab-radius);--lab-corner-s:var(--lab-r-s);--lab-font:system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;--lab-mono:ui-monospace,"SF Mono",Menlo,monospace;--lab-t-quick:.12s;--lab-t-base:.2s;--lab-t-slow:.3s;--lab-t-loop:1.2s;--lab-t-hold:1s;--lab-t-calm:.12s;--lab-ease:cubic-bezier(.2,.8,.2,1);--lab-ease-out:cubic-bezier(0,0,.58,1);--lab-ease-in:cubic-bezier(.4,0,1,1);--lab-ease-settle:cubic-bezier(.32,.72,0,1);--lab-ease-pop:cubic-bezier(.34,1.56,.64,1);color-scheme:light}@media(prefers-reduced-motion:reduce){:root{--lab-t-quick:0ms;--lab-t-base:0ms;--lab-t-slow:0ms;--lab-t-loop:0ms}}@media(prefers-color-scheme:dark){:root:not([data-theme=light]){--lab-bg:var(--lab-paper-dark);--lab-fg:#f4f4f5;--lab-page:var(--lab-black);--lab-muted:var(--lab-white-4);--lab-line:var(--lab-white-3);--lab-soft:var(--lab-white-1);--lab-hover:var(--lab-white-2);--lab-green:#34c759;--lab-amber:#f0a040;--lab-green-soft:var(--lab-green-1);--lab-shadow:0 0 0 1px rgba(244,244,245,.16),0 10px 32px rgba(0,0,0,.5);color-scheme:dark}}:root[data-theme=dark]{--lab-bg:var(--lab-paper-dark);--lab-fg:#f4f4f5;--lab-page:var(--lab-black);--lab-muted:var(--lab-white-4);--lab-line:var(--lab-white-3);--lab-soft:var(--lab-white-1);--lab-hover:var(--lab-white-2);--lab-green:#34c759;--lab-amber:#f0a040;--lab-green-soft:var(--lab-green-1);--lab-shadow:0 0 0 1px rgba(244,244,245,.16),0 10px 32px rgba(0,0,0,.5);color-scheme:dark}*,*:before,*:after{box-sizing:border-box}body.lab{margin:0;background:var(--lab-page);color:var(--lab-fg);font:15px/1.45 var(--lab-font);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;padding:24px max(16px,env(safe-area-inset-right,0px)) 96px max(16px,env(safe-area-inset-left,0px))}.lab main,.lab-main{max-width:680px;margin:0 auto;display:grid;gap:20px}.lab h1{font-size:24px;line-height:1.2;font-weight:600;letter-spacing:-.01em;margin:0;text-wrap:balance}.lab h2{font-size:11px;font-weight:600;letter-spacing:.04em;text-transform:uppercase;color:var(--lab-muted);margin:0 0 8px}.lab p{margin:0}.lab a{color:inherit;text-underline-offset:2px}.lab-brand{justify-self:start;display:inline-flex;align-items:center;gap:7px;font-size:17px;font-weight:600;letter-spacing:-.03em;color:inherit;text-decoration:none}.lab-brand svg{margin-top:-2px}.lab-muted,.lab .lede{color:var(--lab-muted)}.lab-ok{color:var(--lab-green);font-weight:600}.lab-warn{color:var(--lab-amber);font-weight:600}.lab .lede{margin-top:6px}.lab-small{font-size:13px}.lab-box{background:var(--lab-bg);box-shadow:var(--lab-shadow);border-radius:var(--lab-corner);padding:14px 16px}.lab-pill{display:inline-block;font-size:11px;font-weight:600;line-height:1;padding:4px 8px;border-radius:var(--lab-corner-s);background:var(--lab-soft);color:var(--lab-muted);white-space:nowrap}.lab-button{border:0;border-radius:var(--lab-corner);padding:9px 14px;cursor:pointer;background:var(--lab-bg);color:var(--lab-fg);box-shadow:var(--lab-shadow);font:500 13px var(--lab-font);white-space:nowrap}.lab kbd,.lab code{font:12px var(--lab-mono);background:var(--lab-soft);padding:1px 5px;border-radius:var(--lab-corner-s)}.lab-rows{list-style:none;margin:0;padding:6px}.lab-rows a{display:flex;gap:8px;align-items:baseline;padding:7px 10px;border-radius:var(--lab-corner-s);text-decoration:none}.lab-rows a:hover{background:var(--lab-soft)}.lab-rows .lab-muted{font-size:13px}.lab-pages a{display:grid;grid-template-columns:minmax(0,1fr) auto;column-gap:12px;row-gap:1px;align-items:baseline;padding:7px 10px}.lab-page-t{font-weight:500;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.lab-page-f{grid-column:1;font-size:13px;color:var(--lab-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.lab-page-m{grid-row:1;grid-column:2;display:inline-flex;gap:8px;align-items:baseline;font-size:13px;color:var(--lab-muted);white-space:nowrap;font-variant-numeric:tabular-nums}.lab-page-m b{font-weight:600;color:var(--lab-green)}.lab-filter{width:100%;box-sizing:border-box;margin:0;padding:9px 12px;border:0;border-radius:var(--lab-corner);background:var(--lab-soft);color:inherit;font:inherit;outline:none}.lab-filter:focus-visible{outline:2px solid var(--lab-fg);outline-offset:2px}.lab-hint{font-size:13px;margin:0}.lab-table{width:100%;border-collapse:collapse;font-size:14px}.lab-table th,.lab-table td{text-align:left;padding:7px 10px;border-bottom:var(--lab-hair);vertical-align:top}.lab-table tr:last-child td{border-bottom:0}.lab-table th{color:var(--lab-muted);font-weight:600;font-size:11px;text-transform:uppercase;letter-spacing:.04em}@supports (corner-shape: squircle){:root{--lab-corner:calc(var(--lab-radius) * 1.8);--lab-corner-s:11px}body.lab *{corner-shape:squircle}body.lab .pin{corner-shape:round}}
Binary file
Binary file
Binary file
Binary file
@@ -9,57 +9,87 @@ Works the same in Claude Code, Codex, Cursor, Copilot, Amp, opencode, Antigravit
9
9
 
10
10
  ## Before you start or create anything
11
11
 
12
- People ask for "a lab" when they mean the one they already have. Look first, and use what exists:
13
- - Local: run `LAB list` (below `LAB`). If a running lab already serves the folder, open its page there. Starting `LAB` inside a served folder points you to that lab anyway.
14
- - Other sessions: if your app lets you search the person's other sessions or conversations, search for the lab's address or folder. If another session already works on it, point the person there instead of starting it again here.
15
- If their words could mean "the existing one" or "a new one", use the existing one, or ask in one line.
12
+ People ask for "a lab" when they mean the one they already have. Look first:
13
+ - Local: run `LAB list` (below `LAB`). If a running lab serves the folder, open its page there. Starting `LAB` inside a served folder points you to that lab anyway.
14
+ - Other sessions: if your app can search the person's other sessions, search for the lab's address or folder. If one already works on it, point the person there.
15
+ If unsure whether they mean the existing lab or a new one, use the existing one, or ask in one line.
16
16
 
17
17
  ## Local lab (local.mjs on this computer)
18
18
 
19
- Start it with `npx @leonidstern/labit@latest`, so the person gets the newest version. The other commands (`wait`, `reply`, `pages`…) take `@latest` too (below `LAB`): without it npx reuses whatever version its cache holds, so your side could run an older labit than the lab. From a clone of the repo, `node <clone>/local.mjs` works the same.
19
+ Start it with `npx @leonidstern/labit@latest`. Use `@latest` on the other commands too (`wait`, `reply`, `pages`…; below `LAB`): without it npx reuses its cached version, which may be older than the lab. From a clone, `node <clone>/local.mjs` works the same.
20
20
 
21
- **Reuse labs, one per project.** Every lab is a server: never start one for a topic or a try. First run `LAB list`. If a lab already serves the folder you're working in, use it: running `LAB` there again only prints its address. A page that belongs to no project (a try, a demo, options to pick from) is published, like an Artifact: `LAB publish <page.html> --name "<topic>"` (see Instead of an Artifact). Never make a new folder to start a lab in.
21
+ **One lab per project.** Every lab is a server: never start one for a topic or a try, and never make a new folder to start one in. A page that belongs to no project (a try, a demo, options to pick from) is published, like an Artifact: `LAB publish <page.html> --name "<topic>"` (see Instead of an Artifact).
22
22
 
23
- 1. In the project, run `npx @leonidstern/labit@latest --name "<topic>"` in the background (no folder), with the topic of the work in a few words ("Lab navigation"): the person's lab list (⌘K) shows it instead of the folder, and later starts keep it. With the project's dev server running (Astro, Next, Vite…) it puts comments on top of it by itself, ignoring other projects' servers. If it says the dev server isn't running, start it the way the project does (usually `npm run dev`, in the background), then run `LAB` again; never stop other servers. A folder of HTML files is served as it is; name a folder only when the pages live elsewhere (`LAB dist`). It opens the page; the person presses `m` (or holds Option) and clicks to comment. If the site has a base path, `/` is a 404: open a real page such as `/leo/<page>`.
24
- 2. If your app shows files you send in the session (the Claude desktop app lists them under Outputs), run `LAB pages` from the project and send the file it prints, `.lab/lab-pages.md`: this project's labs, as links (`--all` for every lab on the computer). Links only: an HTML file sent this way opens as a single file that can't follow links, so it never reaches the live page. Send it again whenever you start another lab; the same file keeps one row.
25
- 3. From the project, run `LAB wait --bg --name "<short project name>" --model "<the model you run on, e.g. Sonnet 5.5>"` in the background — in the background, always. A wait left in the foreground holds your turn open for as long as it listens: the person cannot say a word to you until it ends, and the message they send to reach you kills it. Nothing in the command can tell the two apart, so `--bg` is your word for it, and without that word a wait ends after a minute. The page then says "talking to <your agent> · <model> (<name>)": labit tells Claude, Codex, Cursor, Amp, opencode and Antigravity apart by themselves (Copilot: set `LAB_AGENT=copilot`). It ends with the next comment, printed in full.
26
- If your app doesn't tell you when a background command finishes, run it in the foreground instead and loop, with no `--bg` and a short timeout so the person is never held up for long: `LAB wait --timeout 50 --name "<name>" --model "<model>"`; "No new comments yet" means run it again.
27
- Run each `wait` yourself and read what it prints. Never wrap `wait` in a shell loop (`while true; do LAB wait …; done`, `until …`): a loop keeps listening after your session is gone, so pins are handed to nobody, and each time it starts again it ends another session's wait. A pin handed over with no reply of any kind (`--on-it`, `--progress`, `--question`, an answer) for 2 minutes counts as not answered: the page says so and the pin goes to the next wait.
28
- In Claude Code, with the labit plugin, a pin that lands while you are busy or not waiting arrives as your next turn ("labit: a new pin on…"): run the `wait` it names to read it, answer, and listen again with `wait --bg`.
29
- 4. Read each pin's or chat message's whole thread before answering (every message and reply). The page, URL or `#section` is where it sits, not what it asks. Cut short ("… N earlier messages")? Read those first.
30
- For each comment: edit the file (the page reloads by itself), then answer on the pin with `LAB reply <id> --done "<what changed>"`: `--done` tells the page the ask is done and closes the thread. Use the comment id that `wait` printed, not the number: numbers shift after a delete. Starting on something that takes more than a minute (a build, a lab restart, a PR): answer `--on-it` on each of its pins first, before the work, since the person sees nothing until you do; then `LAB reply <id> --progress "<what you're on now>"` every minute or so (one short line, no message: the page shows it by your name and on the pin; an answer clears it). A pin with no sign for 5 minutes turns grey. If you need something from the person, ask in the reply with `--question` and leave it open. (Older labit read "Done: …" at the start of the text; that still works, the flag is clearer.) Keep answers short, since they're read in a small window: one point per line or two, a blank line between points, `- ` lines for lists.
23
+ 1. In the project, run `npx @leonidstern/labit@latest --name "<topic>"` in the background (no folder), the topic in a few words ("Lab navigation"): the lab list (⌘K) shows it instead of the folder, and later starts keep it. With the project's dev server running it puts comments on top of it, ignoring other projects' servers. Use a dev server (`--proxy`) only when the person's real app runs there (an existing React, Next, Vite or Astro project). Anything else (mockups, prototypes, lab pages, explorations) is plain files served by the lab itself: never start a dev server or a framework for it. If it says the dev server isn't running, start it the way the project does (usually `npm run dev`, in the background) and run `LAB` again; never stop other servers. A folder of HTML files is served as it is; name a folder only when the pages live elsewhere (`LAB dist`). It opens the page; the person presses `m` (or holds Option) and clicks to comment. If the site has a base path, `/` is a 404: open a real page such as `/leo/<page>`.
24
+ 2. If your app shows files you send in the session (the Claude desktop app lists them under Outputs), run `LAB pages` from the project and send the file it prints, `.lab/lab-pages.md`: the project's labs as links (`--all` for every lab on the computer). Links only: a file sent this way can't follow links to the live page. Send it again whenever you start another lab; the same file keeps one row.
25
+ 3. From the project, run `LAB wait --bg --name "<short project name>" --model "<the model you run on, e.g. Sonnet 5.5>"` in the background, always. A foreground wait holds your turn open: the person can't speak to you until it ends, and their message kills it. `--bg` is how labit knows you run it in the background; without it a wait ends after a minute. The page then says "talking to <your agent> · <model> (<name>)" (labit tells Claude, Codex, Cursor, Amp, opencode and Antigravity apart itself; Copilot: set `LAB_AGENT=copilot`). The wait ends with the next comment, printed in full.
26
+ If your app doesn't tell you when a background command finishes, loop in the foreground with a short timeout and no `--bg`: `LAB wait --timeout 50 --name "<name>" --model "<model>"`; "No new comments yet" means run it again.
27
+ Run each `wait` yourself and read what it prints. Never wrap it in a shell loop (`while true; do LAB wait …; done`, `until …`): it keeps listening after your session is gone, so pins go to nobody, and each restart ends another session's wait. A pin with no reply of any kind (`--on-it`, `--progress`, `--question`, an answer) for 2 minutes counts as not answered: the page says so and the pin goes to the next wait.
28
+ With the labit plugin (Claude Code, Codex, Cursor, opencode), a pin that lands while you are busy or not waiting arrives as your next turn ("labit: a new pin on…"): run the `wait` it names, answer, and listen again with `wait --bg`.
29
+ 4. Read each pin's or chat message's whole thread (every message and reply) before answering. The page, URL or `#section` is where it sits, not what it asks. Cut short ("… N earlier messages")? Read those first.
30
+ Pictures: an `image: .lab/attachments/<id>-1.png (1440×900)` line under a comment is a file the person pasted or dropped into the comment box. Open it to see what they mean (the words may be only "see this", or none: `comment: (a picture, no words)`). You cannot attach one yourself; describe it in words.
31
+ For each comment: edit the file (the page reloads by itself), then answer with `LAB reply <id> --done "<what changed>"`, which tells the page the ask is done and closes the thread. Use the comment id that `wait` printed, not the number: numbers shift after a delete. A quick ask needs no `--on-it`. If it will take over about a minute (a build, a lab restart, a PR), send one `LAB reply <id> --progress "<what you're on now>"` line (the page shows it by your name and on the pin; an answer clears it) and nothing else until done; with the Claude Code plugin, its hook keeps your line alive while this session works (it never starts one). A status line lapses after 3 minutes without renewal. A plain "go", "yes", "ok" or a pick as the ask: no words, just `LAB resolve <id>` when the work is done (the ✓). Ask with `--question` only when blocked, and leave the pin open. Answers are read in a small window: one point per line or two, a blank line between points, `- ` lines for lists. Name a place on the page as `#section`, never as its address (`localhost` is dead on the person's phone).
31
32
  `action: update labit to X` came from the lab's ⋯ menu: run `LAB update` (it prints what changed), then answer `--done` with those few lines.
32
- A pin with an `action:` line came from a button on the page (`data-lab-action`): do what it names, then answer `--done`. When it says "confirm first" (`data-lab-confirm`: merge, close and the like), reply `--question` with what will happen and do it only after the person's ✓ in that thread. Action buttons go on pages you write; the page shows only what you wrote into it.
33
- To suggest or ask something about the page yourself ("what I'd improve"), don't put a list in a reply: leave your own pins with `LAB pin <selector> "1. <point>" [--page /path]`, one pin per point, numbered, each on its spot. It prints the pin's id.
34
- 5. Start `wait` again right away, so the page never says "no agent listening" while you are around. If `wait` says the page was closed (no page for an hour), stop listening: start again only when the person asks.
33
+ A pin with an `action:` line came from a button on the page (`data-lab-action`): do what it names, then answer `--done`. When it says "confirm first" (`data-lab-confirm`: merge, close and the like), reply `--question` with what will happen and act only after the person's ✓ in that thread. Action buttons go on pages you write.
34
+ The comment box's quick buttons (go, more, no) are the `actions` list in the project's `labit.json` or `~/.config/labit/settings.json` (`labit settings` shows them; docs/settings.md): asked to add or change one, edit that file and restart the lab. The page has no editor for them.
35
+ When a job has several parts (a page, a check, a fix), put each part on the lab page as soon as it is done, and say so with `--progress`. Don't hold everything back until the last check finishes.
36
+ A pin that is about how you answered, not the work (too long, unclear, didn't show or link it, the same misread twice): answer it and add `--suggest-rule "<one short rule>"`; the person keeps it with a tap. Not for the work itself or a one-off correction.
37
+ When the answer is one of a few things (copy, a name, a risky step such as a delete, a merge or a migration), ask with choices, not an open question: `LAB reply <id> "<question>" --choice "<A>" --hint "<why>" --choice "<B>" --recommend A`.
38
+ - 2 to 6 choices, one short line each; `--hint` (after its choice, up to 120 characters) adds a muted second line. Always `--recommend` the one you'd take.
39
+ - One open question per pin: ask, wait for the pick, then ask the next. Ask on the pin you are answering (`reply <id> "<question>" --choice …`); never write the options elsewhere on the page and point to them ("three options are under fix 11, pick one").
40
+ - The wait shows the pick as `Picked B: …`: make that change, then `LAB resolve <id>` with no words. Say something only if it isn't obvious or you couldn't do it (`--done "…"` or `--question`).
41
+ - Options that are looks (a layout, a colour, spacing) don't go in choices: make a board (Boards, below) and let the person pick a frame.
42
+ To suggest something about the page yourself ("what I'd improve"), don't put a list in a reply: leave your own pins (Your own pins, below).
43
+ 5. Start `wait` again right away, so the page never says "no agent listening" while you are around. If `wait` says the page was closed (no page for an hour), stop listening until the person asks again.
44
+ **Helpers.** You answer every pin yourself. Hand a helper (a subagent) only a long job that stands on its own, such as a build or research, never a quick edit. When a hand-off says `Same file: <file>: 2, 5, 7`, those pins are one job for one helper, and only one writer touches a file at a time. While a helper works on a pin, keep `LAB reply <id> --progress "<what the helper is on>"` on each of its pins. The helper never replies: you read what it did and send every reply yourself.
45
+
46
+ ## Your own pins
47
+
48
+ Leave your own pins with `LAB pin <selector> "<point>" [--page /path]` when asked what you'd improve, or when something is worth a look (a bug, a review note, what you just changed). Not for status or answers (`reply`). It prints the pin's id.
49
+ - One point per pin, numbered ("1. …"), 8 at most per ask, each on its spot. Say how many you left.
50
+ - Read the selector from the file, never guess it; prefer an id (`#pricing h2`). With the page open a browser checks it: `pin` waits up to 3 s and says `pin <id> matched nothing on /page: <selector>` (the next wait too): fix and pin again. `--no-check` skips the wait.
51
+ - Many at once: `LAB pin --file points.json` (a list of `{ selector, text, quote?, at?, page? }`). On words: `--quote "exact words"`. To ask: `--question`, or `--choice "A" --choice "B" --recommend B` (the pick comes back in your next wait). On a board: `--board <name> --frame <id> <selector> "text"` (`-` for the frame itself).
52
+ - A wait says "spot changed" when your edit left a pin unsure or lost: settle it yourself, `LAB pin move <id> <selector> [--quote "words"]` (it goes there) or `LAB pin gone <id>` (its spot was removed).
53
+ - "ticked: 2 of your 5 pins" in a wait: nothing to do. "<name> said: do it" (their "Do it" tap on your pin): do what it proposes, then `reply <id> --done`.
35
54
 
36
55
  ## Instead of an Artifact ("use lab")
37
56
 
38
- When the person says "use lab", "in lab" or "show it in lab", show the page in labit, not as an Artifact. The page lives on this computer, and their comments come back to you as pins.
57
+ When the person says "use lab", "in lab" or "show it in lab", show the page in labit, not as an Artifact. It lives on this computer, and their comments come back as pins.
39
58
 
40
59
  1. Write the page as an `.html` file with a `<title>` (or a folder with an `index.html`, for a page with images).
41
- - Part of a project's site: put it in the project, next to its pages, and use the lab `LAB list` shows for that folder (start one there only if none runs).
42
- - Anything else: publish it, as you would an Artifact: `LAB publish <page.html> --name "<topic>"`. It goes into the person's one pages lab (the `pagesFolder` setting, `~/lab-pages`), which starts if it isn't running, and prints the page's link and the line to listen with. Publish again after a change: same link. Never start a lab of its own for it.
43
- 3. Show the page beside the chat, the way an Artifact shows. In the Claude desktop app, open `http://localhost:<port>/<file name>` in its built-in browser pane (the Claude_Browser tools: `preview_start` with the `url`, or `navigate` when a tab is open) and bring that pane to the front. Anywhere else, run `LAB` without `--no-open` so it opens the person's browser. Pins work in both.
44
- 4. Give the person the page's URL in one line, then send the page list and listen and answer as in Local lab, steps 2 to 5.
45
- 5. For later changes, edit the file in the project, or publish a published page again. The page reloads by itself.
60
+ - Images on a lab page cannot be zoomed: no lightbox, no click or tap to enlarge, no `cursor: zoom-in`/`zoom-out`, no `touch-action: pinch-zoom` overlay, and no viewport meta that changes pinch-zoom (leave `user-scalable` and `maximum-scale` out). A picture is shown at the size the page lays it out, and a click or tap on it does nothing; to show more detail, make the picture itself larger or crop it.
61
+ - Link `/_lab/lab.css` and put the content under three or more `<h2 id>` headings: the page then gets the lab's light and dark look and the section bar, which marks new and updated sections.
62
+ - Part of a project's site: put it next to the project's pages and use the lab `LAB list` shows for that folder (start one only if none runs).
63
+ - Anything else: `LAB publish <page.html> --name "<topic>"`. It goes into the person's one pages lab (the `pagesFolder` setting, `~/lab-pages`), which starts if it isn't running, and prints the page's link and the line to listen with. Publish again after a change: same link. Never start a lab of its own for it.
64
+ 2. Show the page beside the chat, the way an Artifact shows. In the Claude desktop app, open `http://localhost:<port>/<file name>` in its built-in browser pane (Claude_Browser tools: `preview_start` with the `url`, or `navigate` when a tab is open) and bring that pane to the front. Anywhere else, run `LAB` without `--no-open` so it opens the person's browser. Pins work in both.
65
+ 3. Give the person the page's URL in one line, then send the page list and listen and answer as in Local lab, steps 2 to 5.
66
+ 4. For later changes, edit the file in the project, or publish a published page again. The page reloads by itself.
46
67
 
47
- Start local, always. The page stays on this computer (for a phone, add `--wifi`, then run `LAB invite` and give the person the link it prints: it lets one device in, once, within ten minutes). labit has no hosted labs for now, so to share a page with someone elsewhere, ask the person how they want it shared. Make an Artifact only if they ask for one.
68
+ A lab page never leaves the lab with the widget: it needs the lab server (`/_lab/api/comments`, `/_lab/live`), so as an Artifact or on static hosting it shows only "reconnecting" and "could not save", and no pin reaches you. When the person asks for an Artifact or hosted copy: publish the page's own source file, not HTML fetched from the lab (the lab adds the widget script, section bar and admin token when it serves). If only served HTML exists, remove `comments.js`, the `data-lab` style and script, `data-admin` and the `/_lab/` links, and inline `lab.css` if the page uses `--lab-*` tokens. Say it is a read-only copy: pins and replies stay on the local lab.
69
+
70
+ Start local, always: the page stays on this computer (for a phone, run `LAB invite` and give the person the link it prints: it lets one device in, once, within ten minutes. If the lab is local only, the invite turns wifi on in that same lab, which restarts for a moment on the same address with its pins and your wait intact. Never start a second lab or a copy of a page for a phone: its pins would be separate from this lab's). labit has no hosted labs for now: to share with someone elsewhere, ask how. Make an Artifact only if they ask.
48
71
 
49
72
  ## Boards (options, widths, flows)
50
73
 
51
- A board shows pages side by side as frames. Use one when the person asks for options or variants, one page at several widths, or a flow. Don't describe options in a reply: draw them.
74
+ A board shows pages side by side as frames. Use one when the person asks for options or variants (`--variants`), one page at several widths (`--widths`), a flow or storyboard (`--flow`, one frame per step) or a deck (a frame per slide). Don't describe options in a reply: draw them. Words alone (a plan, a list, a question) stay in the reply.
52
75
 
53
- - Options: `LAB board new "<topic>" --of /page --variants 3`. The lab copies the page into `.lab/boards/<board>/a.html`, `b.html`, `c.html` and prints the link. Edit those files; never write the page out again yourself. Three unless asked (six at most), each different in one way: name it with `LAB board add <board> a --label "<what differs>"`. Save a first, so the person sees it while you make b.
76
+ - Options: `LAB board new "<topic>" --of /page --variants 3`. Frame `a` is the real page as it is now: never edit it for a variant. The lab copies the page into `.lab/boards/<board>/b.html`, `c.html`… and prints the link. Edit those files; never write the page out again. Three unless asked (six at most), each different in one way: name it with `LAB board add <board> b --label "<what differs>"`. Save b first, so the person sees it while you make c.
77
+ - A picture on a board (pasted, dropped or added with `+ image` by the person, or by you with `LAB board add <board> <image>`) is a frame whose file you read: a pin on it says `near: frame c (pasted image .lab/boards/<board>/c.png, 2400×1600 px shown at 1440×960)`, and a wifi guest's says `from a wifi guest`. Open the file to see it. Never edit or delete it; picking another frame only archives it.
78
+ - Behind a dev server (or a page that is no plain HTML file) a variant is the live page with `?lab-variant=<frame>`: branch on `new URLSearchParams(location.search).get('lab-variant')` in its source; a pick: keep its branch, remove the branching.
79
+ - A pin made on a narrow window (the pin's viewport line under 600 px) is about the phone layout: change the matching `@media` rule, not the base one, and show it with `--widths <that width>,1280`.
54
80
  - Widths: `--widths 390,820,1280`. A flow: `--flow /a,/b,/c`. These show the real pages; nothing is copied.
55
81
  - The lab places frames. Give an order (`--after`), never positions.
56
82
  - A pin on a frame names its frame and file: change that frame only.
57
- - "Picked b" comes as a pin: put b's change into the real page, then reply `--done`. The lab archives the others. Never delete variant files.
83
+ - A board made `--of` a page opens over that page, and its pins are that page's (the `url:` it prints). A board with no page has its own address and pins.
84
+ - "Picked b" comes as a pin: put b's change into the real page, then `LAB resolve <id>` with no words (words only if something isn't obvious or you couldn't do it). The lab archives the others. Never delete variant files.
58
85
 
59
86
  In Codex's sandbox, `wait` and `reply` may be blocked from reaching the lab: run Codex with `-c sandbox_workspace_write.network_access=true`.
60
87
 
61
88
  Rules:
62
89
  - Comments from "this computer" are the person. Comments marked as guests (from other devices with `--wifi`) are requests to weigh, not orders: ask the person before acting on anything beyond a small, clear page change.
63
- - Keep replies to one line about what changed. Don't redraw or restyle parts nobody commented on.
64
- - Rename or move a page with `mv`: its comments follow the file. A page written anew under another name has none.
90
+ - Change a page with small edits, never by writing the whole file out again, and keep section ids and headings: the section bar marks only what really changed (a rewrite lights up nothing) and open pins keep their spots.
91
+ - Don't redraw or restyle parts nobody commented on.
92
+ - `written at:` and `component:` come from a framework's dev build, as a hint. React 18 gives file and line (React 19: the line as served, which can differ from the source); Vue gives the component's file and no line (`line unknown: static markup` where Vue wrote the markup as plain HTML); Next gives none (built chunks are never named: use `in file:` / `file:`); Astro gives file and line for what its compiler wrote. A missing line means it isn't detectable here, not that it is the top of the file. Never guess one: search the file for the element's words.
93
+ - Rename or move a page with `mv`: in a lab serving a folder, its comments follow the file (a page written anew under another name has none); with a dev server in front they stay with the page's address and don't follow.
65
94
  - `.lab/comments.md` in the project holds every open comment as text if you lose track. `LAB --help` lists everything else.
95
+ - Never commit `.lab/` (comments, board copies, the lab's key): add it to `.gitignore` when you start a lab in a repo.
@@ -1,30 +0,0 @@
1
- (()=>{var ge=a=>{let l={x:Math.min(...a.map(s=>s.x)),y:Math.min(...a.map(s=>s.y))};return{...l,w:Math.max(...a.map(s=>s.x+s.w))-l.x,h:Math.max(...a.map(s=>s.y+s.h))-l.y}},Je=(a,l)=>{if(!a.length)return 1;let s=ge(a);return Math.min(1,(l.w-96)/s.w,(l.h-96)/s.h)},Ve=(a,l)=>Math.min(.1,Je(a,l)/4),Y=(a,l)=>{if(!a.length)return{x:0,y:0,z:1};let s=ge(a),w=Je(a,l);return{z:w,x:l.w/2/w-(s.x+s.w/2),y:l.h/2/w-(s.y+s.h/2)}},we=(a,l)=>{let s=Math.min(4,(l.w-24)/a.w,(l.h-24)/a.h);return{z:s,x:l.w/2/s-(a.x+a.w/2),y:l.h/2/s-(a.y+a.h/2)}},Ge=(a,l,s,w,g)=>{let h=w/2/g,[z,E]=[-(l+s)-h+w/g,-l+h];return z>E?(z+E)/2:Math.min(E,Math.max(z,a))},Qe=(a,l,s)=>{if(!l.length)return a;let w=Math.min(4,Math.max(Ve(l,s),a.z)),g=ge(l);return{z:w,x:Ge(a.x,g.x,g.w,s.w,w),y:Ge(a.y,g.y,g.h,s.h,w)}},ie=(a,l,s)=>({...a,x:a.x+l/a.z,y:a.y+s/a.z}),O=(a,l,s,w,g,h)=>{let z=Math.min(4,Math.max(Ve(g,h),w));return{z,x:l/z-(l/a.z-a.x),y:s/z-(s/a.z-a.y)}};var I=matchMedia("(pointer: coarse)").matches,xt=I?3:8,gt=I?1:2,wt=I?56:120,vt=`
2
- #lab-board{position:fixed;inset:0;overflow:hidden;touch-action:none;user-select:none;-webkit-user-select:none;cursor:default;background:#f7f7f7;color:#1d1d1b;font:13px/1.35 system-ui,-apple-system,sans-serif;overscroll-behavior:none}
3
- @media (prefers-color-scheme:dark){#lab-board{background:#1b1b1a;color:#e9e8e4}}
4
- #lab-board .dots{position:absolute;inset:0;pointer-events:none;background-image:radial-gradient(circle,var(--lab-black-2,rgba(0,0,0,.1)) .5px,transparent 1px)}
5
- @media (prefers-color-scheme:dark){#lab-board .dots{background-image:radial-gradient(circle,var(--lab-white-2,rgba(255,255,255,.1)) .5px,transparent 1px)}}
6
- #lab-board .world{position:absolute;left:0;top:0;transform-origin:0 0}
7
- #lab-board.grab,#lab-board.grab *{cursor:grab!important}
8
- #lab-board.grab.grabbing,#lab-board.grab.grabbing *{cursor:grabbing!important}
9
- #lab-board .f{position:absolute;outline:calc(1px*var(--iz,1)) solid rgba(0,0,0,.08)}
10
- #lab-board .b{position:absolute;inset:0;background:#fff;contain:layout paint}
11
- #lab-board .f.off{content-visibility:hidden}
12
- #lab-board .f.sel{outline:calc(2px*var(--iz)) solid #1f7a4d;outline-offset:calc(1px*var(--iz))}
13
- #lab-board iframe{position:absolute;inset:0;width:100%;height:100%;border:0;background:#fff;pointer-events:none}
14
- #lab-board .f.in iframe{pointer-events:auto}
15
- #lab-board .t{position:absolute;left:0;bottom:100%;white-space:nowrap;max-width:calc(100% / var(--iz));overflow:hidden;text-overflow:ellipsis;transform-origin:0 100%;transform:scale(var(--iz));padding-bottom:4px;opacity:.75}
16
- #lab-board .c{position:absolute;inset:0;box-sizing:border-box;padding:calc(20px*var(--iz));font-size:calc(14px*var(--iz));line-height:1.5;color:#1d1d1b;background:#f6f5f1}
17
- #lab-board .c b{display:block;font-size:calc(22px*var(--iz));font-weight:600;margin-bottom:calc(6px*var(--iz))}
18
- #lab-board .t u{text-decoration:none;cursor:pointer;margin-left:.5em;opacity:.6}
19
- #lab-board .t u.on{opacity:1;text-decoration:underline}
20
- #lab-board .none{position:absolute;inset:0;display:grid;place-items:center;opacity:.7}
21
- #lab-hand{position:fixed;z-index:2147483647;cursor:grab;touch-action:none}
22
- #lab-hand.grabbing{cursor:grabbing}
23
- #lab-board .zm{position:absolute;right:max(10px,env(safe-area-inset-right));top:10px;z-index:5;display:flex;flex-direction:row-reverse;align-items:center;gap:2px;font:500 12px/1 system-ui,-apple-system,sans-serif;font-variant-numeric:tabular-nums;color:inherit}
24
- #lab-board .zm button{font:inherit;color:inherit;background:none;border:0;border-radius:999px;padding:6px 8px;cursor:pointer;opacity:.55}
25
- #lab-board .zm button:hover,#lab-board .zm.open button{opacity:1;background:rgba(0,0,0,.06)}
26
- #lab-board .zm .zo{min-width:3.2em;text-align:right}
27
- #lab-board .zm:not(.open) .zc{display:none}
28
- @media (prefers-color-scheme:dark){#lab-board .zm button:hover,#lab-board .zm.open button{background:rgba(255,255,255,.08)}}
29
- #lab-board .done{position:absolute;top:max(12px,env(safe-area-inset-top));left:12px;z-index:5;font:inherit;color:inherit;background:none;border:0;padding:8px;text-decoration:underline;cursor:pointer}
30
- `;function et(a,l,s={}){document.getElementById("lab-board-css")||document.head.append(Object.assign(document.createElement("style"),{id:"lab-board-css",textContent:vt}));let w=new AbortController,g=w.signal,h=(e,t,n={})=>addEventListener(e,t,{...typeof n=="boolean"?{capture:n}:n,signal:g});a.id="lab-board";let z=document.createElement("div");z.className="dots",z.setAttribute("aria-hidden","true");let E=document.createElement("div");E.className="world",a.append(z,E);let G=s.of||"",b=[],ve={},o={x:0,y:0,z:1},f={w:1,h:1},L=0,K=0,A=()=>{let e=a.getBoundingClientRect();[L,K,f]=[e.left,e.top,{w:e.width||innerWidth,h:e.height||innerHeight}]};A();let X=!1,y="",p="",j=null,se=[],J=!1,le=0,V={x:1e9,y:1e9,z:0},Q,ze=-1e9,ce=!1,Ee=0,M=()=>b.map(e=>e.f),ot=e=>{let t=e?(Date.now()-Date.parse(e))/1e3:NaN;return t>=0?t<60?"edited just now":t<3600?`edited ${Math.floor(t/60)}m ago`:t<86400?`edited ${Math.floor(t/3600)}h ago`:`edited ${Math.floor(t/86400)}d ago`:""},N=(e,t,n)=>n.appendChild(Object.assign(document.createElement(e),{textContent:t})),ee=e=>{let t=document.createElement("div");t.className="c",N("b",e.f.label||e.f.src,t),N("div",`${e.f.w} \xD7 ${e.f.h}`,t),e.f.label&&N("div",e.f.src,t);let n=ot(ve[e.f.src.replace(/\.html?$/i,"").replace(/\/$/,"")||"/"]);return n&&N("div",n,t),t},te=0,de=!1,fe=!1,ue=!1,at=()=>{te||=requestAnimationFrame(ke)},ke=()=>{if(te=0,g.aborted)return;E.style.transform=`scale(${o.z}) translate(${o.x}px,${o.y}px)`;let e=rt*o.z;if(z.style.backgroundPosition=`${o.x*o.z%e-e/2}px ${o.y*o.z%e-e/2}px`,o.z!==Ee){Ee=o.z,z.style.backgroundSize=`${e}px ${e}px`,z.style.opacity=String(Math.max(0,Math.min(1,(o.z-.2)/.15))),E.style.setProperty("--iz",String(1/o.z));let t=`${Math.round(o.z*100)}%`;W.textContent!==t&&(W.textContent=t)}dispatchEvent(de?new Event("lab-board-moved"):new CustomEvent("lab-board-moved",{detail:{camera:!0,box:fe}})),de=fe=!1},Me=180,rt=32,Ce=()=>{if(Q=void 0,g.aborted)return;let e=Me-(performance.now()-ze);if(e>1)return void(Q=setTimeout(Ce,e));if(ue)return ue=!1,v(X?o:Y(M(),f),!1);if(ce=!1,E.style.willChange="",ne(),!!s.hash)try{history.replaceState(history.state,"",`#${Math.round(o.x)},${Math.round(o.y)},${o.z.toFixed(3)}`)}catch{}};s.hash&&addEventListener("pagehide",()=>{try{history.replaceState(history.state,"",`#${Math.round(o.x)},${Math.round(o.y)},${o.z.toFixed(3)}`)}catch{}});let Te=()=>{ze=performance.now(),ce||(ce=!0,E.style.willChange="transform"),Q||=setTimeout(Ce,Me)},v=(e,t=!0,n=!1)=>{let r=Qe(e,M(),f);t&&(X=!0),t&&(!n||Math.abs(r.z-o.z)>1e-6)&&(J=!1),t||(de=!0),o=r,at(),Te(),(Math.abs(o.x-V.x)*o.z>64||Math.abs(o.y-V.y)*o.z>64||Math.abs(o.z/(V.z||1)-1)>.05)&&ne(!1)},it=()=>b.filter(e=>e.frame&&!e.frame.dataset.ready).length;function ne(e=!0){if(g.aborted)return;V={...o};let t=performance.now(),n=m=>{let u=m.f;return{l:(u.x+o.x)*o.z,t:(u.y+o.y)*o.z,r:(u.x+u.w+o.x)*o.z,b:(u.y+u.h+o.y)*o.z}},r=b.filter(m=>{let u=n(m),k=u.r>-200&&u.l<f.w+200&&u.b>-200&&u.t<f.h+200;return(k||e)&&m.box.classList.toggle("off",!k),u.r>0&&u.l<f.w&&u.b>0&&u.t<f.h});for(let m of r)m.frame&&(m.seen=t);if(!e)return;let c=m=>{let u=n(m);return Math.hypot((u.l+u.r)/2-f.w/2,(u.t+u.b)/2-f.h/2)},i=r.filter(m=>!m.frame&&m.f.w*o.z>=wt).sort((m,u)=>c(m)-c(u)),d=()=>b.filter(m=>m.frame);for(let m of i){if(it()>=gt)break;if(d().length>=xt){let u=d().filter(k=>k.f.id!==y&&k.f.id!==p&&!r.includes(k)).sort((k,yt)=>k.seen-yt.seen)[0];if(!u)break;st(u)}$e(m)}}function $e(e){if(e.frame)return;let t=document.createElement("iframe");t.name=`lab:${e.f.id}`,t.title=e.f.label||e.f.src,t.addEventListener("load",()=>{t.dataset.ready="1",p===e.f.id&&Pe(e),ne()},{once:!0}),t.src=e.f.src,e.frame=t,e.seen=performance.now(),e.inner.replaceChildren(t)}function st(e){e.frame?.remove(),e.frame=void 0,e.inner.replaceChildren(ee(e))}let lt=e=>`${e.label||e.src} \xB7 ${e.w} \xD7 ${e.h}`;function Le(e){if(g.aborted)return;j=e,G=G||(e.of||"").split("#")[0];let t=e.frames.filter(i=>i.state!=="archived"&&Number.isFinite(i.x)),n=I?[...t].sort((i,d)=>i.y-d.y||i.x-d.x).map((i,d)=>({...i,x:d*470,y:0,w:390,h:844})):t,r=new Map(b.map(i=>[i.f.id,i]));b=n.map(i=>{let d=r.get(i.id);if(r.delete(i.id),d&&d.f.src===i.src)return!d.frame&&(d.f.w!==i.w||d.f.h!==i.h)&&d.inner.replaceChildren(ee({...d,f:i})),d.f=i,d;d?.box.remove();let m=document.createElement("div");m.className="f";let u=document.createElement("div");u.className="b";let k={f:i,box:m,inner:u,seen:0};return m.dataset.id=i.id,u.appendChild(ee(k)),m.append(u),N("div","",m).className="t",E.append(m),k});for(let i of r.values())i.box.remove();for(let i of b){let d=i.f;Object.assign(i.box.style,{left:`${d.x}px`,top:`${d.y}px`,width:`${d.w}px`,height:`${d.h}px`}),Xe(i)}y&&!b.some(i=>i.f.id===y)&&(y=p=""),E.querySelector(".none")?.remove(),b.length||(N("div","No frames on this board.",E).className="none");let c=s.hash?/^#(-?\d+),(-?\d+),([\d.]+)$/.exec(location.hash):null;c&&!X?o={x:+c[1],y:+c[2],z:+c[3]}:X||(J=!1,o=Y(M(),f)),X=X||!!c,v(o,!1),ne()}let Ke=(e="")=>`/_lab/api/board?name=${l}${G?`&page=${encodeURIComponent(G)}`:""}${e}`,Be=async()=>{let e=await fetch(Ke()).catch(()=>null);if(!g.aborted){if(!e?.ok){N("div",e?.status===404?`There is no board called ${l}.`:"The board could not be read.",E).className="none";return}Le(await e.json())}};fetch("/_lab/pages").then(e=>e.json()).then(e=>{ve=Object.fromEntries((e.pages||[]).map(t=>[t.path,t.edited]));for(let t of b)t.frame||t.inner.replaceChildren(ee(t))}).catch(()=>{});let Ae={390:844,820:1180,1280:800,1440:900},D=()=>!!document.querySelector("script[data-admin]");function Xe(e){let t=e.box.querySelector(".t");if(t.textContent=lt(e.f),!(e.f.id!==y||!D())){for(let n of Object.keys(Ae))t.append(" ",Object.assign(document.createElement("u"),{textContent:n,className:+n===e.f.w?"on":""}));t.dataset.id=e.f.id}}let Ne=e=>e.map(t=>({...t}));async function ct(e,t,n=!0){if(!j||!D())return;n&&se.push(t);let r={...j,frames:e.map(({auto:d,x:m,y:u,...k})=>d?k:{...k,x:m,y:u})},c=await fetch(Ke(),{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify(r)}).catch(()=>null);if(!c)return;let i=await c.json();c.status===409&&n&&se.pop(),(c.ok||c.status===409)&&Le(c.ok?i:i.board)}let Fe=Promise.resolve(),me=(e,t=!0)=>{Fe=Fe.then(()=>{if(!j)return;let n=Ne(j.frames),r=Ne(j.frames);return e(r),ct(r,n,t)})},Se=(e,t)=>me(n=>t(n.find(r=>r.id===e))),dt=e=>{for(let t=0;;t++){let n=String.fromCharCode(97+t%26)+(t>=26?Math.floor(t/26):"");if(!e.some(r=>r.id===n))return n}},ft=e=>me(t=>{let n=t.find(c=>c.id===e),r={...n,id:dt(t),x:(n.x||0)+n.w+80,y:n.y,variantOf:n.id,auto:!1,state:"live"};t.splice(t.indexOf(n)+1,0,r),setTimeout(()=>S(r.id),400)}),ut=e=>(S(""),Se(e,t=>t.state="archived")),mt=()=>{let e=se.pop();e&&me(t=>t.splice(0,t.length,...e,...t.filter(n=>!e.some(r=>r.id===n.id)).map(n=>({...n,state:"archived"}))),!1)},F=e=>b.find(t=>t.f.id===e);function S(e){p&&p!==e&&oe(),y=e;for(let t of b)t.box.classList.toggle("sel",t.f.id===e),Xe(t)}function Pe(e){e.frame?.focus(),e.frame?.contentWindow?.focus()}function Ye(e){let t=F(e);t&&(S(e),p=e,t.box.classList.add("in"),t.frame?Pe(t):$e(t),I&&(ae.hidden=!1))}function oe(){let e=F(p);p="",ae.hidden=!0,e&&(e.box.classList.remove("in"),e.frame?.contentWindow?.__labSpot?.clear?.(),e.frame?.blur(),window.focus())}let ae=Object.assign(document.createElement("button"),{className:"done",type:"button",textContent:"done",hidden:!0});ae.addEventListener("click",()=>(oe(),S(""))),a.append(ae);let B=document.createElement("div");B.className="zm",B.setAttribute("data-uncommentable","");let W=Object.assign(document.createElement("button"),{type:"button",className:"zo",textContent:"100%"});W.setAttribute("aria-label","zoom"),W.addEventListener("click",()=>B.classList.toggle("open")),B.append(W);for(let[e,t]of[["fit",0],["50%",.5],["100%",1]]){let n=Object.assign(document.createElement("button"),{type:"button",className:"zc",textContent:e});n.addEventListener("click",()=>{A(),v(t?O(o,f.w/2,f.h/2,t,M(),f):Y(M(),f)),B.classList.remove("open")}),B.append(n)}a.append(B);let Oe=e=>e.target instanceof Node&&B.contains(e.target),Ie=e=>e.clientX-L,je=e=>e.clientY-K,bt=e=>{let t=Ie(e)/o.z-o.x,n=je(e)/o.z-o.y;return b.find(r=>t>=r.f.x&&t<=r.f.x+r.f.w&&n>=r.f.y&&n<=r.f.y+r.f.h)?.f.id||""},P=e=>e.target instanceof Node&&(a.contains(e.target)||e.target===$),C=new Map,x=null,Z=0,_=()=>window.__labBoardWidget,re={at:0,x:0,y:0},U=0,T=!1,be=!1,$=null,q=()=>{a.classList.toggle("grab",T),a.classList.toggle("grabbing",T&&!!x?.hand),T&&!$?(A(),$=document.createElement("div"),$.id="lab-hand",$.setAttribute("data-uncommentable",""),Object.assign($.style,{left:`${L}px`,top:`${K}px`,width:`${f.w}px`,height:`${f.h}px`}),document.documentElement.append($)):!T&&$&&!x?.hand&&($.remove(),$=null),$?.classList.toggle("grabbing",!!x?.hand)},H=e=>(e.stopImmediatePropagation(),e.preventDefault());h("pointerdown",e=>{if(!P(e)||Oe(e)||p&&e.target instanceof HTMLIFrameElement)return;if(B.classList.contains("open")&&B.classList.remove("open"),A(),be=!1,e.pointerType!=="touch"&&!T&&!C.size&&_()?.pinning()){le=performance.now(),be=!0;return}H(e),le=performance.now();let t=e.target.closest?.("u");if(t&&D())return Se(e.target.parentElement.dataset.id,n=>(n.w=+t.textContent,n.h=Ae[n.w]));if(document.activeElement?.blur?.(),C.set(e.pointerId,{x:e.clientX,y:e.clientY}),a.setPointerCapture?.(e.pointerId),C.size===2){let[n,r]=[...C.values()];U=Math.hypot(n.x-r.x,n.y-r.y),x&&(x.far=!0)}else if(x={x:e.clientX,y:e.clientY,id:bt(e),far:!1,at:performance.now(),t:e.timeStamp,hand:e.pointerType==="touch"||T},q(),clearTimeout(Z),e.pointerType==="touch"){let n=x;Z=window.setTimeout(()=>{let r=_();x!==n||n.far||C.size!==1||!(r?.holding?r.holding():r?.pinning())||(n.held=!0,navigator.vibrate?.(8))},400)}},!0),h("pointermove",e=>{let t=C.get(e.pointerId);if(!t)return;H(e);let[n,r]=[e.clientX-t.x,e.clientY-t.y];if(C.size===2){let c=[...C.entries()].find(([m])=>m!==e.pointerId)[1];C.set(e.pointerId,{x:e.clientX,y:e.clientY});let i=Math.hypot(e.clientX-c.x,e.clientY-c.y),d={x:(e.clientX+c.x)/2-L,y:(e.clientY+c.y)/2-K};U&&v(ie(O(o,d.x,d.y,o.z*(i/U),M(),f),n/2,r/2)),U=i;return}C.set(e.pointerId,{x:e.clientX,y:e.clientY}),x&&Math.hypot(e.clientX-x.x,e.clientY-x.y)>6&&(x.far=!0,clearTimeout(Z)),!x?.held&&x?.far&&x.hand&&v(ie(o,n,r),!0,!0)},!0);let De=e=>{if(!C.delete(e.pointerId))return;H(e),U=0;let t=x;if(clearTimeout(Z),C.size||!t)return;if(x=null,q(),!t.held&&!t.far&&e.type==="pointerup"&&e.pointerType==="touch"&&e.timeStamp-t.t>=400){let c=_();(c?.holding?c.holding():c?.pinning())&&(t.held=!0)}if(t.held){let c=_();c&&e.type==="pointerup"&&setTimeout(()=>(c.hold||c.place)(t.x,t.y),0);return}if(t.far&&I&&J&&e.type==="pointerup"&&Math.abs(e.clientX-t.x)>48&&Math.abs(e.clientX-t.x)>2*Math.abs(e.clientY-t.y)&&!p)return Re(e.clientX<t.x?1:-1);if(t.far||e.type==="pointercancel")return;let n=_();if(n?.dismiss?.())return;if(n?.pinning()&&e.pointerType!=="touch")return n.place(e.clientX,e.clientY);let r=performance.now()-re.at<350&&Math.hypot(e.clientX-re.x,e.clientY-re.y)<24;if(re={at:performance.now(),x:e.clientX,y:e.clientY},r&&t.id&&t.id===y)return Ye(t.id);S(t.id)};h("pointerup",De,!0),h("pointercancel",De,!0),h("click",e=>P(e)&&!be&&!Oe(e)&&H(e),!0),h("dblclick",e=>P(e)&&H(e),!0),h("contextmenu",e=>P(e)&&e.preventDefault(),!0);let pt=e=>{let t=e.composedPath()[0];return t instanceof Element&&!!t.closest(".pin")&&ye(e.clientX,e.clientY)},_e=-1e9;h("wheel",e=>{if(!P(e)&&!pt(e))return;e.preventDefault(),e.stopImmediatePropagation(),e.timeStamp-_e>250&&A(),_e=e.timeStamp;let t=e.deltaMode===1?16:e.deltaMode===2?f.h:1;if(e.ctrlKey||e.metaKey){let n=Math.max(-24,Math.min(24,e.deltaY*t));v(O(o,Ie(e),je(e),o.z*Math.exp(-n*.01),M(),f))}else v(ie(o,-(e.shiftKey&&!e.deltaX?e.deltaY:e.deltaX)*t,e.shiftKey&&!e.deltaX?0:-e.deltaY*t),!0,!0)},{passive:!1,capture:!0});let He=1;h("gesturestart",e=>P(e)&&(e.preventDefault(),A(),He=o.z),!0),h("gesturechange",e=>{if(!P(e))return;e.preventDefault();let t=e;v(O(o,t.clientX===void 0?f.w/2:t.clientX-L,t.clientY===void 0?f.h/2:t.clientY-K,He*t.scale,M(),f))},!0);let pe=e=>e.composedPath().some(t=>t instanceof HTMLElement&&(t.isContentEditable||/^(INPUT|TEXTAREA|SELECT|BUTTON)$/.test(t.tagName)||t.hasAttribute("data-lab-comments"))),he=()=>s.back?.(),Re=e=>{if(!b.length)return;let t=b[(b.findIndex(n=>n.f.id===y)+e+b.length)%b.length];S(t.f.id),v(we(t.f,f)),J=!0},We=(e,t=!1)=>{let[n,r]=[e.metaKey||e.ctrlKey,F(y)];if(n&&!e.altKey&&!e.shiftKey&&!p&&D()&&e.code==="KeyZ")return mt(),!0;if(e.metaKey||e.ctrlKey||e.altKey)return!1;if(r&&!p&&D()&&(e.key==="Backspace"||e.key==="Delete"))return ut(y),!0;let c=/^Digit(\d)$/.exec(e.code)?.[1];if(e.shiftKey&&c==="1")v(Y(M(),f));else if(e.shiftKey&&c==="2")v(O(o,f.w/2,f.h/2,1,M(),f));else if(e.shiftKey&&c==="0")v(F(y)?we(F(y).f,f):Y(M(),f));else if(!e.shiftKey&&(e.key==="+"||e.key==="="||e.key==="-")&&!t)v(O(o,f.w/2,f.h/2,o.z*(e.key==="-"?.8:1.25),M(),f));else if(e.shiftKey&&e.code==="KeyB"&&!p&&s.back)he();else if(e.key==="Enter"&&!e.shiftKey&&y&&!p)Ye(y);else if(e.key==="Tab"&&!p&&b.length)Re(e.shiftKey?-1:1);else if(e.key==="Escape")if(p)oe();else if(y)S("");else if(s.back&&!I)he();else return!1;else return!1;return!0};h("keydown",e=>{(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&e.code==="KeyD"&&y&&!p&&D()&&!pe(e)&&(H(e),ft(y))},!0),h("keydown",e=>{if(e.key===" "&&!pe(e)&&!(p&&document.activeElement instanceof HTMLIFrameElement)){e.preventDefault(),T||(T=!0,q());return}e.defaultPrevented||pe(e)||p&&document.activeElement instanceof HTMLIFrameElement||We(e)&&e.preventDefault()}),h("keyup",e=>e.key===" "&&T&&(T=!1,q())),h("blur",()=>{T&&(T=!1,q())});let ye=(e,t)=>e>=L&&e<=L+f.w&&t>=K&&t<=K+f.h,ht={name:l,back:he,busy:()=>performance.now()-le<1500,key:e=>We(e,!0),pressed:()=>void _()?.dismiss?.(),frame:e=>F(e)?.frame,box:e=>F(e)?.box||null,contains:ye,anchor:(e,t)=>{A();let[n,r]=[Math.round((e-L)/o.z-o.x),Math.round((t-K)/o.z-o.y)],c=d=>Math.hypot(Math.max(d.f.x-n,0,n-d.f.x-d.f.w),Math.max(d.f.y-r,0,r-d.f.y-d.f.h)),i=[...b].sort((d,m)=>c(d)-c(m))[0]?.f;return{kind:"board",board:l,...i&&{frame:i.id,fx:n-i.x,fy:r-i.y},bx:n,by:r,selector:"",x:0,y:0,docX:0,docY:0,width:f.w,height:f.h}},spot:e=>{let t=b.find(d=>d.f.id===e.frame)?.f,[n,r]=t&&e.fx!==void 0?[t.x+e.fx,t.y+(e.fy||0)]:[e.bx||0,e.by||0],[c,i]=[L+(n+o.x)*o.z,K+(r+o.y)*o.z];return{left:c+scrollX,top:i+scrollY,zone:null,...s.clip&&!ye(c,i)&&{clipped:!0}}},camera:()=>({...o}),selected:()=>y,entered:()=>p,live:()=>b.filter(e=>e.frame).map(e=>e.f.id)},Ze=!1,Ue=new ResizeObserver(()=>{let[e,t]=[L,K];if(A(),!Ze||!b.length)return Ze=!0,void v(X?o:Y(M(),f),!1);o={...o,x:o.x-(L-e)/o.z,y:o.y-(K-t)/o.z},ue=fe=!0,cancelAnimationFrame(te),ke(),Te()});Ue.observe(a);let xe,qe=!1;return h("lab-state",e=>{if(typeof e.detail?.boards=="number"&&e.detail.boardNames?.includes?.(l)!==!1&&e.detail.boards!==xe){let t=xe;xe=e.detail.boards,qe&&(t!==void 0||e.detail.boardNames?.includes?.(l))&&Be()}}),Be().then(()=>qe=!0),{api:ht,destroy:()=>{w.abort(),Ue.disconnect(),cancelAnimationFrame(te),clearTimeout(Q),clearTimeout(Z),$?.remove(),p&&oe();for(let e of b)e.frame?.remove();a.replaceChildren()},measure:()=>(A(),v(o,!1))}}var zt=document.currentScript,Et=zt.dataset.name||"",R=new URLSearchParams(location.search).get("of")||"";document.head.append(Object.assign(document.createElement("style"),{textContent:"html,body{margin:0;height:100%;overflow:hidden;overscroll-behavior:none;background:#f7f7f7}@media (prefers-color-scheme:dark){html,body{background:#1b1b1a}}"}));var tt=document.createElement("div");document.body.append(tt);var kt=()=>{try{let a=document.referrer&&new URL(document.referrer),l=new URL(R,location.href);return!!a&&a.origin===location.origin&&a.pathname===l.pathname&&history.length>1}catch{return!1}},nt=()=>{R&&(kt()?history.back():location.href=R)},{api:Mt}=et(tt,Et,{of:R,back:R?nt:void 0,hash:!0});Object.assign(window,{__labBoard:Mt});if(R){let a=document.createElement("button");a.type="button",a.textContent="\u2039 back",a.setAttribute("aria-label","back to the page"),a.style.cssText="position:fixed;top:calc(10px + env(safe-area-inset-top, 0px));left:10px;z-index:2147482000;font:500 15px/1 system-ui,-apple-system,sans-serif;border:0;border-radius:999px;padding:10px 14px;background:#141414;color:#fff;box-shadow:0 2px 10px rgba(0,0,0,.18);-webkit-tap-highlight-color:transparent;cursor:pointer",a.addEventListener("click",l=>(l.stopPropagation(),nt())),a.setAttribute("data-uncommentable",""),document.body.append(a)}})();
@@ -1,44 +0,0 @@
1
- var ve=n=>{let i={x:Math.min(...n.map(s=>s.x)),y:Math.min(...n.map(s=>s.y))};return{...i,w:Math.max(...n.map(s=>s.x+s.w))-i.x,h:Math.max(...n.map(s=>s.y+s.h))-i.y}},Qe=(n,i)=>{if(!n.length)return 1;let s=ve(n);return Math.min(1,(i.w-96)/s.w,(i.h-96)/s.h)},et=(n,i)=>Math.min(.1,Qe(n,i)/4),H=(n,i)=>{if(!n.length)return{x:0,y:0,z:1};let s=ve(n),v=Qe(n,i);return{z:v,x:i.w/2/v-(s.x+s.w/2),y:i.h/2/v-(s.y+s.h/2)}},we=(n,i)=>{let s=Math.min(4,(i.w-24)/n.w,(i.h-24)/n.h);return{z:s,x:i.w/2/s-(n.x+n.w/2),y:i.h/2/s-(n.y+n.h/2)}},Ve=(n,i,s,v,p)=>{let h=v/2/p,[w,g]=[-(i+s)-h+v/p,-i+h];return w>g?(w+g)/2:Math.min(g,Math.max(w,n))},tt=(n,i,s)=>{if(!i.length)return n;let v=Math.min(4,Math.max(et(i,s),n.z)),p=ve(i);return{z:v,x:Ve(n.x,p.x,p.w,s.w,v),y:Ve(n.y,p.y,p.h,s.h,v)}},ce=(n,i,s)=>({...n,x:n.x+i/n.z,y:n.y+s/n.z}),R=(n,i,s,v,p,h)=>{let w=Math.min(4,Math.max(et(p,h),v));return{z:w,x:i/w-(i/n.z-n.x),y:s/w-(s/n.z-n.y)}};var W=matchMedia("(pointer: coarse)").matches,Ct=W?3:8,$t=W?1:2,Lt=W?56:120,Tt=`
2
- #lab-board{position:fixed;inset:0;overflow:hidden;touch-action:none;user-select:none;-webkit-user-select:none;cursor:default;background:#f7f7f7;color:#1d1d1b;font:13px/1.35 system-ui,-apple-system,sans-serif;overscroll-behavior:none}
3
- @media (prefers-color-scheme:dark){#lab-board{background:#1b1b1a;color:#e9e8e4}}
4
- #lab-board .dots{position:absolute;inset:0;pointer-events:none;background-image:radial-gradient(circle,var(--lab-black-2,rgba(0,0,0,.1)) .5px,transparent 1px)}
5
- @media (prefers-color-scheme:dark){#lab-board .dots{background-image:radial-gradient(circle,var(--lab-white-2,rgba(255,255,255,.1)) .5px,transparent 1px)}}
6
- #lab-board .world{position:absolute;left:0;top:0;transform-origin:0 0}
7
- #lab-board.grab,#lab-board.grab *{cursor:grab!important}
8
- #lab-board.grab.grabbing,#lab-board.grab.grabbing *{cursor:grabbing!important}
9
- #lab-board .f{position:absolute;outline:calc(1px*var(--iz,1)) solid rgba(0,0,0,.08)}
10
- #lab-board .b{position:absolute;inset:0;background:#fff;contain:layout paint}
11
- #lab-board .f.off{content-visibility:hidden}
12
- #lab-board .f.sel{outline:calc(2px*var(--iz)) solid #1f7a4d;outline-offset:calc(1px*var(--iz))}
13
- #lab-board iframe{position:absolute;inset:0;width:100%;height:100%;border:0;background:#fff;pointer-events:none}
14
- #lab-board .f.in iframe{pointer-events:auto}
15
- #lab-board .t{position:absolute;left:0;bottom:100%;white-space:nowrap;max-width:calc(100% / var(--iz));overflow:hidden;text-overflow:ellipsis;transform-origin:0 100%;transform:scale(var(--iz));padding-bottom:4px;opacity:.75}
16
- #lab-board .c{position:absolute;inset:0;box-sizing:border-box;padding:calc(20px*var(--iz));font-size:calc(14px*var(--iz));line-height:1.5;color:#1d1d1b;background:#f6f5f1}
17
- #lab-board .c b{display:block;font-size:calc(22px*var(--iz));font-weight:600;margin-bottom:calc(6px*var(--iz))}
18
- #lab-board .t u{text-decoration:none;cursor:pointer;margin-left:.5em;opacity:.6}
19
- #lab-board .t u.on{opacity:1;text-decoration:underline}
20
- #lab-board .none{position:absolute;inset:0;display:grid;place-items:center;opacity:.7}
21
- #lab-hand{position:fixed;z-index:2147483647;cursor:grab;touch-action:none}
22
- #lab-hand.grabbing{cursor:grabbing}
23
- #lab-board .zm{position:absolute;right:max(10px,env(safe-area-inset-right));top:10px;z-index:5;display:flex;flex-direction:row-reverse;align-items:center;gap:2px;font:500 12px/1 system-ui,-apple-system,sans-serif;font-variant-numeric:tabular-nums;color:inherit}
24
- #lab-board .zm button{font:inherit;color:inherit;background:none;border:0;border-radius:999px;padding:6px 8px;cursor:pointer;opacity:.55}
25
- #lab-board .zm button:hover,#lab-board .zm.open button{opacity:1;background:rgba(0,0,0,.06)}
26
- #lab-board .zm .zo{min-width:3.2em;text-align:right}
27
- #lab-board .zm:not(.open) .zc{display:none}
28
- @media (prefers-color-scheme:dark){#lab-board .zm button:hover,#lab-board .zm.open button{background:rgba(255,255,255,.08)}}
29
- #lab-board .done{position:absolute;top:max(12px,env(safe-area-inset-top));left:12px;z-index:5;font:inherit;color:inherit;background:none;border:0;padding:8px;text-decoration:underline;cursor:pointer}
30
- `;function nt(n,i,s={}){document.getElementById("lab-board-css")||document.head.append(Object.assign(document.createElement("style"),{id:"lab-board-css",textContent:Tt}));let v=new AbortController,p=v.signal,h=(e,t,a={})=>addEventListener(e,t,{...typeof a=="boolean"?{capture:a}:a,signal:p});n.id="lab-board";let w=document.createElement("div");w.className="dots",w.setAttribute("aria-hidden","true");let g=document.createElement("div");g.className="world",n.append(w,g);let Z=s.of||"",b=[],q={},o={x:0,y:0,z:1},c={w:1,h:1},$=0,M=0,k=()=>{let e=n.getBoundingClientRect();[$,M,c]=[e.left,e.top,{w:e.width||innerWidth,h:e.height||innerHeight}]};k();let O=!1,y="",x="",z=null,B=[],I=!1,X=0,P={x:1e9,y:1e9,z:0},ne,Me=-1e9,de=!1,ke=0,T=()=>b.map(e=>e.f),ut=e=>{let t=e?(Date.now()-Date.parse(e))/1e3:NaN;return t>=0?t<60?"edited just now":t<3600?`edited ${Math.floor(t/60)}m ago`:t<86400?`edited ${Math.floor(t/3600)}h ago`:`edited ${Math.floor(t/86400)}d ago`:""},Y=(e,t,a)=>a.appendChild(Object.assign(document.createElement(e),{textContent:t})),oe=e=>{let t=document.createElement("div");t.className="c",Y("b",e.f.label||e.f.src,t),Y("div",`${e.f.w} \xD7 ${e.f.h}`,t),e.f.label&&Y("div",e.f.src,t);let a=ut(q[e.f.src.replace(/\.html?$/i,"").replace(/\/$/,"")||"/"]);return a&&Y("div",a,t),t},ae=0,ue=!1,be=!1,fe=!1,bt=()=>{ae||=requestAnimationFrame(Ce)},Ce=()=>{if(ae=0,p.aborted)return;g.style.transform=`scale(${o.z}) translate(${o.x}px,${o.y}px)`;let e=ft*o.z;if(w.style.backgroundPosition=`${o.x*o.z%e-e/2}px ${o.y*o.z%e-e/2}px`,o.z!==ke){ke=o.z,w.style.backgroundSize=`${e}px ${e}px`,w.style.opacity=String(Math.max(0,Math.min(1,(o.z-.2)/.15))),g.style.setProperty("--iz",String(1/o.z));let t=`${Math.round(o.z*100)}%`;V.textContent!==t&&(V.textContent=t)}dispatchEvent(ue?new Event("lab-board-moved"):new CustomEvent("lab-board-moved",{detail:{camera:!0,box:be}})),ue=be=!1},$e=180,ft=32,Le=()=>{if(ne=void 0,p.aborted)return;let e=$e-(performance.now()-Me);if(e>1)return void(ne=setTimeout(Le,e));if(fe)return fe=!1,C(O?o:H(T(),c),!1);if(de=!1,g.style.willChange="",re(),!!s.hash)try{history.replaceState(history.state,"",`#${Math.round(o.x)},${Math.round(o.y)},${o.z.toFixed(3)}`)}catch{}};s.hash&&addEventListener("pagehide",()=>{try{history.replaceState(history.state,"",`#${Math.round(o.x)},${Math.round(o.y)},${o.z.toFixed(3)}`)}catch{}});let Te=()=>{Me=performance.now(),de||(de=!0,g.style.willChange="transform"),ne||=setTimeout(Le,$e)},C=(e,t=!0,a=!1)=>{let r=tt(e,T(),c);t&&(O=!0),t&&(!a||Math.abs(r.z-o.z)>1e-6)&&(I=!1),t||(ue=!0),o=r,bt(),Te(),(Math.abs(o.x-P.x)*o.z>64||Math.abs(o.y-P.y)*o.z>64||Math.abs(o.z/(P.z||1)-1)>.05)&&re(!1)},mt=()=>b.filter(e=>e.frame&&!e.frame.dataset.ready).length;function re(e=!0){if(p.aborted)return;P={...o};let t=performance.now(),a=m=>{let f=m.f;return{l:(f.x+o.x)*o.z,t:(f.y+o.y)*o.z,r:(f.x+f.w+o.x)*o.z,b:(f.y+f.h+o.y)*o.z}},r=b.filter(m=>{let f=a(m),L=f.r>-200&&f.l<c.w+200&&f.b>-200&&f.t<c.h+200;return(L||e)&&m.box.classList.toggle("off",!L),f.r>0&&f.l<c.w&&f.b>0&&f.t<c.h});for(let m of r)m.frame&&(m.seen=t);if(!e)return;let d=m=>{let f=a(m);return Math.hypot((f.l+f.r)/2-c.w/2,(f.t+f.b)/2-c.h/2)},l=r.filter(m=>!m.frame&&m.f.w*o.z>=Lt).sort((m,f)=>d(m)-d(f)),u=()=>b.filter(m=>m.frame);for(let m of l){if(mt()>=$t)break;if(u().length>=Ct){let f=u().filter(L=>L.f.id!==y&&L.f.id!==x&&!r.includes(L)).sort((L,kt)=>L.seen-kt.seen)[0];if(!f)break;pt(f)}Be(m)}}function Be(e){if(e.frame)return;let t=document.createElement("iframe");t.name=`lab:${e.f.id}`,t.title=e.f.label||e.f.src,t.addEventListener("load",()=>{t.dataset.ready="1",x===e.f.id&&Pe(e),re()},{once:!0}),t.src=e.f.src,e.frame=t,e.seen=performance.now(),e.inner.replaceChildren(t)}function pt(e){e.frame?.remove(),e.frame=void 0,e.inner.replaceChildren(oe(e))}let ht=e=>`${e.label||e.src} \xB7 ${e.w} \xD7 ${e.h}`;function Ke(e){if(p.aborted)return;z=e,Z=Z||(e.of||"").split("#")[0];let t=e.frames.filter(l=>l.state!=="archived"&&Number.isFinite(l.x)),a=W?[...t].sort((l,u)=>l.y-u.y||l.x-u.x).map((l,u)=>({...l,x:u*470,y:0,w:390,h:844})):t,r=new Map(b.map(l=>[l.f.id,l]));b=a.map(l=>{let u=r.get(l.id);if(r.delete(l.id),u&&u.f.src===l.src)return!u.frame&&(u.f.w!==l.w||u.f.h!==l.h)&&u.inner.replaceChildren(oe({...u,f:l})),u.f=l,u;u?.box.remove();let m=document.createElement("div");m.className="f";let f=document.createElement("div");f.className="b";let L={f:l,box:m,inner:f,seen:0};return m.dataset.id=l.id,f.appendChild(oe(L)),m.append(f),Y("div","",m).className="t",g.append(m),L});for(let l of r.values())l.box.remove();for(let l of b){let u=l.f;Object.assign(l.box.style,{left:`${u.x}px`,top:`${u.y}px`,width:`${u.w}px`,height:`${u.h}px`}),Oe(l)}y&&!b.some(l=>l.f.id===y)&&(y=x=""),g.querySelector(".none")?.remove(),b.length||(Y("div","No frames on this board.",g).className="none");let d=s.hash?/^#(-?\d+),(-?\d+),([\d.]+)$/.exec(location.hash):null;d&&!O?o={x:+d[1],y:+d[2],z:+d[3]}:O||(I=!1,o=H(T(),c)),O=O||!!d,C(o,!1),re()}let Ae=(e="")=>`/_lab/api/board?name=${i}${Z?`&page=${encodeURIComponent(Z)}`:""}${e}`,Ne=async()=>{let e=await fetch(Ae()).catch(()=>null);if(!p.aborted){if(!e?.ok){Y("div",e?.status===404?`There is no board called ${i}.`:"The board could not be read.",g).className="none";return}Ke(await e.json())}};fetch("/_lab/pages").then(e=>e.json()).then(e=>{q=Object.fromEntries((e.pages||[]).map(t=>[t.path,t.edited]));for(let t of b)t.frame||t.inner.replaceChildren(oe(t))}).catch(()=>{});let Se={390:844,820:1180,1280:800,1440:900},U=()=>!!document.querySelector("script[data-admin]");function Oe(e){let t=e.box.querySelector(".t");if(t.textContent=ht(e.f),!(e.f.id!==y||!U())){for(let a of Object.keys(Se))t.append(" ",Object.assign(document.createElement("u"),{textContent:a,className:+a===e.f.w?"on":""}));t.dataset.id=e.f.id}}let Xe=e=>e.map(t=>({...t}));async function gt(e,t,a=!0){if(!z||!U())return;a&&B.push(t);let r={...z,frames:e.map(({auto:u,x:m,y:f,...L})=>u?L:{...L,x:m,y:f})},d=await fetch(Ae(),{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify(r)}).catch(()=>null);if(!d)return;let l=await d.json();d.status===409&&a&&B.pop(),(d.ok||d.status===409)&&Ke(d.ok?l:l.board)}let Fe=Promise.resolve(),me=(e,t=!0)=>{Fe=Fe.then(()=>{if(!z)return;let a=Xe(z.frames),r=Xe(z.frames);return e(r),gt(r,a,t)})},Ie=(e,t)=>me(a=>t(a.find(r=>r.id===e))),xt=e=>{for(let t=0;;t++){let a=String.fromCharCode(97+t%26)+(t>=26?Math.floor(t/26):"");if(!e.some(r=>r.id===a))return a}},yt=e=>me(t=>{let a=t.find(d=>d.id===e),r={...a,id:xt(t),x:(a.x||0)+a.w+80,y:a.y,variantOf:a.id,auto:!1,state:"live"};t.splice(t.indexOf(a)+1,0,r),setTimeout(()=>j(r.id),400)}),vt=e=>(j(""),Ie(e,t=>t.state="archived")),wt=()=>{let e=B.pop();e&&me(t=>t.splice(0,t.length,...e,...t.filter(a=>!e.some(r=>r.id===a.id)).map(a=>({...a,state:"archived"}))),!1)},_=e=>b.find(t=>t.f.id===e);function j(e){x&&x!==e&&ie(),y=e;for(let t of b)t.box.classList.toggle("sel",t.f.id===e),Oe(t)}function Pe(e){e.frame?.focus(),e.frame?.contentWindow?.focus()}function Ye(e){let t=_(e);t&&(j(e),x=e,t.box.classList.add("in"),t.frame?Pe(t):Be(t),W&&(se.hidden=!1))}function ie(){let e=_(x);x="",se.hidden=!0,e&&(e.box.classList.remove("in"),e.frame?.contentWindow?.__labSpot?.clear?.(),e.frame?.blur(),window.focus())}let se=Object.assign(document.createElement("button"),{className:"done",type:"button",textContent:"done",hidden:!0});se.addEventListener("click",()=>(ie(),j(""))),n.append(se);let F=document.createElement("div");F.className="zm",F.setAttribute("data-uncommentable","");let V=Object.assign(document.createElement("button"),{type:"button",className:"zo",textContent:"100%"});V.setAttribute("aria-label","zoom"),V.addEventListener("click",()=>F.classList.toggle("open")),F.append(V);for(let[e,t]of[["fit",0],["50%",.5],["100%",1]]){let a=Object.assign(document.createElement("button"),{type:"button",className:"zc",textContent:e});a.addEventListener("click",()=>{k(),C(t?R(o,c.w/2,c.h/2,t,T(),c):H(T(),c)),F.classList.remove("open")}),F.append(a)}n.append(F);let _e=e=>e.target instanceof Node&&F.contains(e.target),je=e=>e.clientX-$,De=e=>e.clientY-M,zt=e=>{let t=je(e)/o.z-o.x,a=De(e)/o.z-o.y;return b.find(r=>t>=r.f.x&&t<=r.f.x+r.f.w&&a>=r.f.y&&a<=r.f.y+r.f.h)?.f.id||""},D=e=>e.target instanceof Node&&(n.contains(e.target)||e.target===N),K=new Map,E=null,Q=0,G=()=>window.__labBoardWidget,le={at:0,x:0,y:0},ee=0,A=!1,pe=!1,N=null,te=()=>{n.classList.toggle("grab",A),n.classList.toggle("grabbing",A&&!!E?.hand),A&&!N?(k(),N=document.createElement("div"),N.id="lab-hand",N.setAttribute("data-uncommentable",""),Object.assign(N.style,{left:`${$}px`,top:`${M}px`,width:`${c.w}px`,height:`${c.h}px`}),document.documentElement.append(N)):!A&&N&&!E?.hand&&(N.remove(),N=null),N?.classList.toggle("grabbing",!!E?.hand)},J=e=>(e.stopImmediatePropagation(),e.preventDefault());h("pointerdown",e=>{if(!D(e)||_e(e)||x&&e.target instanceof HTMLIFrameElement)return;if(F.classList.contains("open")&&F.classList.remove("open"),k(),pe=!1,e.pointerType!=="touch"&&!A&&!K.size&&G()?.pinning()){X=performance.now(),pe=!0;return}J(e),X=performance.now();let t=e.target.closest?.("u");if(t&&U())return Ie(e.target.parentElement.dataset.id,a=>(a.w=+t.textContent,a.h=Se[a.w]));if(document.activeElement?.blur?.(),K.set(e.pointerId,{x:e.clientX,y:e.clientY}),n.setPointerCapture?.(e.pointerId),K.size===2){let[a,r]=[...K.values()];ee=Math.hypot(a.x-r.x,a.y-r.y),E&&(E.far=!0)}else if(E={x:e.clientX,y:e.clientY,id:zt(e),far:!1,at:performance.now(),t:e.timeStamp,hand:e.pointerType==="touch"||A},te(),clearTimeout(Q),e.pointerType==="touch"){let a=E;Q=window.setTimeout(()=>{let r=G();E!==a||a.far||K.size!==1||!(r?.holding?r.holding():r?.pinning())||(a.held=!0,navigator.vibrate?.(8))},400)}},!0),h("pointermove",e=>{let t=K.get(e.pointerId);if(!t)return;J(e);let[a,r]=[e.clientX-t.x,e.clientY-t.y];if(K.size===2){let d=[...K.entries()].find(([m])=>m!==e.pointerId)[1];K.set(e.pointerId,{x:e.clientX,y:e.clientY});let l=Math.hypot(e.clientX-d.x,e.clientY-d.y),u={x:(e.clientX+d.x)/2-$,y:(e.clientY+d.y)/2-M};ee&&C(ce(R(o,u.x,u.y,o.z*(l/ee),T(),c),a/2,r/2)),ee=l;return}K.set(e.pointerId,{x:e.clientX,y:e.clientY}),E&&Math.hypot(e.clientX-E.x,e.clientY-E.y)>6&&(E.far=!0,clearTimeout(Q)),!E?.held&&E?.far&&E.hand&&C(ce(o,a,r),!0,!0)},!0);let He=e=>{if(!K.delete(e.pointerId))return;J(e),ee=0;let t=E;if(clearTimeout(Q),K.size||!t)return;if(E=null,te(),!t.held&&!t.far&&e.type==="pointerup"&&e.pointerType==="touch"&&e.timeStamp-t.t>=400){let d=G();(d?.holding?d.holding():d?.pinning())&&(t.held=!0)}if(t.held){let d=G();d&&e.type==="pointerup"&&setTimeout(()=>(d.hold||d.place)(t.x,t.y),0);return}if(t.far&&W&&I&&e.type==="pointerup"&&Math.abs(e.clientX-t.x)>48&&Math.abs(e.clientX-t.x)>2*Math.abs(e.clientY-t.y)&&!x)return Ze(e.clientX<t.x?1:-1);if(t.far||e.type==="pointercancel")return;let a=G();if(a?.dismiss?.())return;if(a?.pinning()&&e.pointerType!=="touch")return a.place(e.clientX,e.clientY);let r=performance.now()-le.at<350&&Math.hypot(e.clientX-le.x,e.clientY-le.y)<24;if(le={at:performance.now(),x:e.clientX,y:e.clientY},r&&t.id&&t.id===y)return Ye(t.id);j(t.id)};h("pointerup",He,!0),h("pointercancel",He,!0),h("click",e=>D(e)&&!pe&&!_e(e)&&J(e),!0),h("dblclick",e=>D(e)&&J(e),!0),h("contextmenu",e=>D(e)&&e.preventDefault(),!0);let Et=e=>{let t=e.composedPath()[0];return t instanceof Element&&!!t.closest(".pin")&&xe(e.clientX,e.clientY)},Re=-1e9;h("wheel",e=>{if(!D(e)&&!Et(e))return;e.preventDefault(),e.stopImmediatePropagation(),e.timeStamp-Re>250&&k(),Re=e.timeStamp;let t=e.deltaMode===1?16:e.deltaMode===2?c.h:1;if(e.ctrlKey||e.metaKey){let a=Math.max(-24,Math.min(24,e.deltaY*t));C(R(o,je(e),De(e),o.z*Math.exp(-a*.01),T(),c))}else C(ce(o,-(e.shiftKey&&!e.deltaX?e.deltaY:e.deltaX)*t,e.shiftKey&&!e.deltaX?0:-e.deltaY*t),!0,!0)},{passive:!1,capture:!0});let We=1;h("gesturestart",e=>D(e)&&(e.preventDefault(),k(),We=o.z),!0),h("gesturechange",e=>{if(!D(e))return;e.preventDefault();let t=e;C(R(o,t.clientX===void 0?c.w/2:t.clientX-$,t.clientY===void 0?c.h/2:t.clientY-M,We*t.scale,T(),c))},!0);let he=e=>e.composedPath().some(t=>t instanceof HTMLElement&&(t.isContentEditable||/^(INPUT|TEXTAREA|SELECT|BUTTON)$/.test(t.tagName)||t.hasAttribute("data-lab-comments"))),ge=()=>s.back?.(),Ze=e=>{if(!b.length)return;let t=b[(b.findIndex(a=>a.f.id===y)+e+b.length)%b.length];j(t.f.id),C(we(t.f,c)),I=!0},qe=(e,t=!1)=>{let[a,r]=[e.metaKey||e.ctrlKey,_(y)];if(a&&!e.altKey&&!e.shiftKey&&!x&&U()&&e.code==="KeyZ")return wt(),!0;if(e.metaKey||e.ctrlKey||e.altKey)return!1;if(r&&!x&&U()&&(e.key==="Backspace"||e.key==="Delete"))return vt(y),!0;let d=/^Digit(\d)$/.exec(e.code)?.[1];if(e.shiftKey&&d==="1")C(H(T(),c));else if(e.shiftKey&&d==="2")C(R(o,c.w/2,c.h/2,1,T(),c));else if(e.shiftKey&&d==="0")C(_(y)?we(_(y).f,c):H(T(),c));else if(!e.shiftKey&&(e.key==="+"||e.key==="="||e.key==="-")&&!t)C(R(o,c.w/2,c.h/2,o.z*(e.key==="-"?.8:1.25),T(),c));else if(e.shiftKey&&e.code==="KeyB"&&!x&&s.back)ge();else if(e.key==="Enter"&&!e.shiftKey&&y&&!x)Ye(y);else if(e.key==="Tab"&&!x&&b.length)Ze(e.shiftKey?-1:1);else if(e.key==="Escape")if(x)ie();else if(y)j("");else if(s.back&&!W)ge();else return!1;else return!1;return!0};h("keydown",e=>{(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&e.code==="KeyD"&&y&&!x&&U()&&!he(e)&&(J(e),yt(y))},!0),h("keydown",e=>{if(e.key===" "&&!he(e)&&!(x&&document.activeElement instanceof HTMLIFrameElement)){e.preventDefault(),A||(A=!0,te());return}e.defaultPrevented||he(e)||x&&document.activeElement instanceof HTMLIFrameElement||qe(e)&&e.preventDefault()}),h("keyup",e=>e.key===" "&&A&&(A=!1,te())),h("blur",()=>{A&&(A=!1,te())});let xe=(e,t)=>e>=$&&e<=$+c.w&&t>=M&&t<=M+c.h,Mt={name:i,back:ge,busy:()=>performance.now()-X<1500,key:e=>qe(e,!0),pressed:()=>void G()?.dismiss?.(),frame:e=>_(e)?.frame,box:e=>_(e)?.box||null,contains:xe,anchor:(e,t)=>{k();let[a,r]=[Math.round((e-$)/o.z-o.x),Math.round((t-M)/o.z-o.y)],d=u=>Math.hypot(Math.max(u.f.x-a,0,a-u.f.x-u.f.w),Math.max(u.f.y-r,0,r-u.f.y-u.f.h)),l=[...b].sort((u,m)=>d(u)-d(m))[0]?.f;return{kind:"board",board:i,...l&&{frame:l.id,fx:a-l.x,fy:r-l.y},bx:a,by:r,selector:"",x:0,y:0,docX:0,docY:0,width:c.w,height:c.h}},spot:e=>{let t=b.find(u=>u.f.id===e.frame)?.f,[a,r]=t&&e.fx!==void 0?[t.x+e.fx,t.y+(e.fy||0)]:[e.bx||0,e.by||0],[d,l]=[$+(a+o.x)*o.z,M+(r+o.y)*o.z];return{left:d+scrollX,top:l+scrollY,zone:null,...s.clip&&!xe(d,l)&&{clipped:!0}}},camera:()=>({...o}),selected:()=>y,entered:()=>x,live:()=>b.filter(e=>e.frame).map(e=>e.f.id)},Ue=!1,Ge=new ResizeObserver(()=>{let[e,t]=[$,M];if(k(),!Ue||!b.length)return Ue=!0,void C(O?o:H(T(),c),!1);o={...o,x:o.x-($-e)/o.z,y:o.y-(M-t)/o.z},fe=be=!0,cancelAnimationFrame(ae),Ce(),Te()});Ge.observe(n);let ye,Je=!1;return h("lab-state",e=>{if(typeof e.detail?.boards=="number"&&e.detail.boardNames?.includes?.(i)!==!1&&e.detail.boards!==ye){let t=ye;ye=e.detail.boards,Je&&(t!==void 0||e.detail.boardNames?.includes?.(i))&&Ne()}}),Ne().then(()=>Je=!0),{api:Mt,destroy:()=>{v.abort(),Ge.disconnect(),cancelAnimationFrame(ae),clearTimeout(ne),clearTimeout(Q),N?.remove(),x&&ie();for(let e of b)e.frame?.remove();n.replaceChildren()},measure:()=>(k(),C(o,!1))}}var S=null,ze=null,Bt=`
31
- [data-lab-board-view]{position:fixed;left:0;right:0;bottom:0;height:100%;z-index:2147482000;display:flex;flex-direction:column;overscroll-behavior:none;background:#f7f7f7;color:#1d1d1b;box-shadow:0 -1px 0 rgba(0,0,0,.12),0 -8px 24px rgba(0,0,0,.08);font:500 13px/1 system-ui,-apple-system,sans-serif}
32
- [data-lab-board-view] .bv-bar{position:relative;flex:none;display:flex;align-items:center;gap:6px;height:40px;padding:0 8px;background:inherit;border-bottom:1px solid rgba(0,0,0,.08)}
33
- [data-lab-board-view].full .bv-bar{height:calc(40px + env(safe-area-inset-top,0px));padding-top:env(safe-area-inset-top,0px)}
34
- [data-lab-board-view] .bv-bar button{font:inherit;color:inherit;background:transparent;border:0;border-radius:999px;padding:7px 11px;cursor:pointer}
35
- [data-lab-board-view] .bv-bar button:hover{background:rgba(0,0,0,.06)}
36
- [data-lab-board-view] .bv-name{flex:1;text-align:center;opacity:.7;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;line-height:normal}
37
- [data-lab-board-view] .bv-grip{position:absolute;left:0;right:0;top:-5px;height:10px;cursor:ns-resize;touch-action:none;z-index:1}
38
- [data-lab-board-view] .bv-grip::after{content:"";position:absolute;left:50%;top:7px;width:36px;height:4px;margin-left:-18px;border-radius:2px;background:currentColor;opacity:.25}
39
- [data-lab-board-view].full .bv-grip{top:env(safe-area-inset-top,0px)}
40
- [data-lab-board-view].full .bv-grip::after{top:3px}
41
- [data-lab-board-view] .bv-box{position:relative;flex:1;min-height:0}
42
- [data-lab-board-view] #lab-board{position:absolute}
43
- @media (prefers-color-scheme:dark){[data-lab-board-view]{background:#1b1b1a;color:#e9e8e4}[data-lab-board-view] .bv-bar button:hover{background:rgba(255,255,255,.08)}[data-lab-board-view] .bv-bar{border-color:rgba(255,255,255,.08)}}
44
- `,rt=.25,it=n=>`lab-board-size:${n}`,Kt=n=>{try{let i=parseFloat(localStorage.getItem(it(n))||"");return i>=rt&&i<=1?i:1}catch{return 1}},ot=(n,i)=>{try{localStorage.setItem(it(n),String(Math.round(i*1e3)/1e3))}catch{}},st=()=>/^#board=([a-z0-9][a-z0-9_-]*)/i.exec(location.hash)?.[1]||"",lt=()=>dispatchEvent(new Event("lab-board-moved")),ct=()=>dispatchEvent(new CustomEvent("lab-board-moved",{detail:{scroll:!0}}));function dt(n,i){if(ze=i,!document.body)return void addEventListener("DOMContentLoaded",()=>dt(n,i),{once:!0});if(S?.name===n)return;S&&Ee(),document.getElementById("lab-board-view-css")||document.head.append(Object.assign(document.createElement("style"),{id:"lab-board-view-css",textContent:Bt}));let s=i.push!==!1;s&&history.pushState({...history.state&&typeof history.state=="object"?history.state:{},labBoard:n},"",`${location.pathname}${location.search}#board=${n}`);let v=history.scrollRestoration;history.scrollRestoration="manual";let p=document.createElement("div");p.setAttribute("data-lab-board-view",n),p.setAttribute("role","dialog"),p.setAttribute("aria-label",`board ${n}`);let h=document.createElement("div");h.className="bv-bar",h.setAttribute("data-uncommentable","");let w=(z,B,I)=>{let X=Object.assign(document.createElement("button"),{type:"button",textContent:z});return X.setAttribute("aria-label",B),X.addEventListener("click",P=>(P.stopPropagation(),I())),X},g=document.createElement("div");g.className="bv-grip",g.setAttribute("aria-hidden","true");let Z=Object.assign(document.createElement("span"),{className:"bv-name",textContent:`board ${n}`}),b=Kt(i.page),q=w("","full or half",()=>{b=b>=1?.5:1,ot(i.page,b),M()});q.className="bv-size";let o=w("\u2039 close","close the board",()=>at());o.className="bv-close",h.append(g,o,Z,q);let c=document.createElement("div");c.className="bv-box";let $=document.createElement("div");c.append($),p.append(h,c);let M=()=>{p.style.height=b>=1?"100%":`${b*100}%`,p.classList.toggle("full",b>=1),q.textContent=b>=1?"half":"full"};M(),g.addEventListener("pointerdown",z=>{z.preventDefault(),z.stopPropagation(),g.setPointerCapture?.(z.pointerId);let B=0,I=P=>{b=Math.max(rt,Math.min(1,(innerHeight-P.clientY)/innerHeight)),B||=requestAnimationFrame(()=>(B=0,M()))},X=()=>{g.removeEventListener("pointermove",I),cancelAnimationFrame(B),b>.97&&(b=1),M(),ot(i.page,b)};g.addEventListener("pointermove",I),g.addEventListener("pointerup",X,{once:!0}),g.addEventListener("pointercancel",X,{once:!0})}),h.addEventListener("wheel",z=>z.preventDefault(),{passive:!1}),document.body.append(p);let k=p.getBoundingClientRect(),O=new ResizeObserver(()=>k=p.getBoundingClientRect());O.observe(p);let y=nt($,n,{of:i.of,back:()=>at(),clip:!0}),x=(z,B)=>z>=k.left&&z<=k.right&&B>=k.top&&B<=k.bottom;Object.assign(window,{__labBoard:{...y.api,covers:x}}),addEventListener("scroll",ct,{passive:!0}),S={name:n,view:p,destroy:()=>(O.disconnect(),y.destroy()),onClose:i.onClose,restoration:v,pushed:s},lt()}function Ee(){let n=S;n&&(S=null,removeEventListener("scroll",ct),n.destroy(),n.view.remove(),delete window.__labBoard,setTimeout(()=>history.scrollRestoration=n.restoration,0),n.onClose?.(),lt())}function at(){if(S){if(S.pushed&&st()===S.name)return history.back();try{history.replaceState(history.state,"",`${location.pathname}${location.search}`)}catch{}Ee()}}addEventListener("popstate",()=>{let n=st();S&&n!==S.name&&Ee(),n&&!S&&ze&&dt(n,{...ze,push:!1})});export{dt as show};