@popmelt.com/core 0.33.1 → 0.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -1
- package/claude-plugin/.claude-plugin/plugin.json +1 -1
- package/codex-plugin/.codex-plugin/plugin.json +1 -1
- package/dist/ExploreAttachment-BG7ZOQSA.mjs +1 -0
- package/dist/PagePreviewLayer-CBDGPMJQ.mjs +1 -0
- package/dist/ParticipantRuntime-FSZX2PUQ.mjs +1 -0
- package/dist/PhoneHostGate-OM7FLOJ2.mjs +1 -0
- package/dist/PopmeltTasteConnectedPane-KJSBPJQR.mjs +1 -0
- package/dist/{PreviewRuntime-LFPK56NW.mjs → PreviewRuntime-EYKB7MG5.mjs} +1 -1
- package/dist/SuppliedContext-7THB2WZY.mjs +1 -0
- package/dist/ThreadErrorCard-J2VTA5JW.mjs +1 -0
- package/dist/ThreadPanel-PNVMIIYJ.mjs +1 -0
- package/dist/bridge-entry.mjs +1 -1
- package/dist/bridgeSSEStream-K3UIMBTC.mjs +1 -0
- package/dist/{bridgeWebSocketStream-H3DCP4T3.mjs → bridgeWebSocketStream-2SUZUBE3.mjs} +1 -1
- package/dist/browser-runtime-FFT5NH66.mjs +1 -0
- package/dist/browser.mjs +1 -1
- package/dist/{canvas-chat-note-NHYL3T6J.mjs → canvas-chat-note-MGAEUYJO.mjs} +1 -1
- package/dist/{checkFixture-MWBOYIM2.mjs → checkFixture-AMLLLJNS.mjs} +1 -1
- package/dist/chunk-2ETPREWQ.mjs +1 -0
- package/dist/chunk-3GXLNBXU.mjs +1 -0
- package/dist/chunk-3WSTAV5B.mjs +1 -0
- package/dist/chunk-53SKVMWR.mjs +1 -0
- package/dist/chunk-57FM7XQV.mjs +1 -0
- package/dist/chunk-5D2ADU7H.mjs +1 -0
- package/dist/chunk-67OWRNU3.mjs +30 -0
- package/dist/chunk-67QNAAUC.mjs +1 -0
- package/dist/chunk-BACXPVHP.mjs +1 -0
- package/dist/chunk-BFVLMSG5.mjs +1 -0
- package/dist/chunk-BJ25TGJN.mjs +1 -0
- package/dist/chunk-DOCRI237.mjs +1 -0
- package/dist/{chunk-HVD5ZG6W.mjs → chunk-E5WNW4WE.mjs} +1 -1
- package/dist/chunk-FMI4VQDZ.mjs +1 -0
- package/dist/chunk-G2ZHJXHZ.mjs +1 -0
- package/dist/chunk-G6RYESYI.mjs +1 -0
- package/dist/{chunk-75PQGTKX.mjs → chunk-G7JR5Z3P.mjs} +1 -1
- package/dist/chunk-GRPDZGPP.mjs +1 -0
- package/dist/{chunk-GASEZICN.mjs → chunk-GSEMSZDB.mjs} +1 -1
- package/dist/chunk-H2RLTCUJ.mjs +1 -0
- package/dist/{chunk-EAV2VV2V.mjs → chunk-HAE5LUJX.mjs} +1 -1
- package/dist/{chunk-IKCHOC3U.mjs → chunk-HV7HRQ2S.mjs} +0 -1
- package/dist/{chunk-2ZJ4FBTG.mjs → chunk-JRP5XFYN.mjs} +1 -1
- package/dist/chunk-LD3532UC.mjs +1 -0
- package/dist/chunk-MJ2PFKF3.mjs +1 -0
- package/dist/chunk-MP6ZV2DN.mjs +1 -0
- package/dist/chunk-N66ZZG3L.mjs +1 -0
- package/dist/chunk-NSCO633B.mjs +1 -0
- package/dist/chunk-P4KM3K5M.mjs +1 -0
- package/dist/chunk-PH2MLB3T.mjs +1 -0
- package/dist/chunk-Q6C7ZA3H.mjs +1 -0
- package/dist/chunk-Q6N77LIS.mjs +1 -0
- package/dist/chunk-Q74FBX2I.mjs +1 -0
- package/dist/chunk-QQB5G3VB.mjs +1 -0
- package/dist/chunk-R3FPXDQS.mjs +1 -0
- package/dist/chunk-RK6UROPO.mjs +1 -0
- package/dist/chunk-RR4SHK7O.mjs +1 -0
- package/dist/chunk-RSUMSUAW.mjs +1 -0
- package/dist/{chunk-GL4I4MI6.mjs → chunk-RUJC32MA.mjs} +1 -1
- package/dist/{chunk-2IASPT6L.mjs → chunk-RUTWU5W2.mjs} +1 -1
- package/dist/chunk-TRHC7WBO.mjs +1 -0
- package/dist/chunk-XSMCZUDR.mjs +1 -0
- package/dist/{chunk-DNOKP3JS.mjs → chunk-XT6PHPPG.mjs} +1 -1
- package/dist/chunk-Y6WD56SO.mjs +1 -0
- package/dist/chunk-YC5CUNRU.mjs +1 -0
- package/dist/chunk-YFDD7HGT.mjs +1 -0
- package/dist/{chunk-JMMP5JSP.mjs → chunk-YTUQYKLM.mjs} +1 -1
- package/dist/chunk-YXPRWW6B.mjs +1 -0
- package/dist/chunk-ZVDKW7TO.mjs +1 -0
- package/dist/cli.mjs +1 -1
- package/dist/codex-note-context-NUKGR2WT.mjs +1 -0
- package/dist/codex-project-KE7ZZ6YX.mjs +1 -0
- package/dist/{codex-session-registry-SPRWY2WW.mjs → codex-session-registry-ONODFWFD.mjs} +1 -2
- package/dist/focus-inspection-BPPRCMNN.mjs +1 -0
- package/dist/index.d.mts +25 -0
- package/dist/index.mjs +1 -1
- package/dist/memory-store.mjs +1 -1
- package/dist/peer-client-UQDASAO7.mjs +1 -0
- package/dist/plugin-astro.mjs +1 -1
- package/dist/plugin-next.mjs +1 -1
- package/dist/plugin-nuxt.mjs +1 -1
- package/dist/plugin-vite.mjs +1 -1
- package/dist/server.mjs +1 -1
- package/dist/steerStyles-VKQD57KC.mjs +1 -0
- package/package.json +1 -1
- package/dist/ExploreAttachment-VKCCEIM7.mjs +0 -1
- package/dist/ParticipantRuntime-YS5SIZUQ.mjs +0 -1
- package/dist/PopmeltTasteConnectedPane-FKIJM3C7.mjs +0 -1
- package/dist/SuppliedContext-RWN6UR3K.mjs +0 -1
- package/dist/ThreadErrorCard-7J62GD5W.mjs +0 -1
- package/dist/ThreadPanel-KVNM67WO.mjs +0 -1
- package/dist/bridgeSSEStream-NEYI73TC.mjs +0 -1
- package/dist/browser-runtime-AP35S5MK.mjs +0 -1
- package/dist/chunk-27ADDVGC.mjs +0 -1
- package/dist/chunk-2VCHBI7Y.mjs +0 -1
- package/dist/chunk-6V2VCKPG.mjs +0 -1
- package/dist/chunk-6VXFTT5U.mjs +0 -1
- package/dist/chunk-BVTLSUQT.mjs +0 -1
- package/dist/chunk-CPOYMGYY.mjs +0 -1
- package/dist/chunk-H7XMDLGU.mjs +0 -30
- package/dist/chunk-N2QUNHV6.mjs +0 -1
- package/dist/chunk-N6JTX4PD.mjs +0 -2
- package/dist/chunk-ODIGT4YJ.mjs +0 -1
- package/dist/chunk-PSSHCTJ2.mjs +0 -1
- package/dist/chunk-QOJCTLQW.mjs +0 -1
- package/dist/chunk-RESPUCV7.mjs +0 -1
- package/dist/chunk-SHAIHRV2.mjs +0 -1
- package/dist/chunk-VPPVURBR.mjs +0 -2
- package/dist/chunk-W5NIRROD.mjs +0 -1
- package/dist/chunk-XKD2ABCO.mjs +0 -1
- package/dist/chunk-YLKEDOII.mjs +0 -31
- package/dist/chunk-ZHJZPC7U.mjs +0 -1
- package/dist/codex-note-context-4JYQ437H.mjs +0 -2
- package/dist/codex-project-FA4EK6VR.mjs +0 -2
- package/dist/focus-inspection-VBS5656D.mjs +0 -1
- package/dist/peer-client-KJCPXT76.mjs +0 -2
package/README.md
CHANGED
|
@@ -96,6 +96,28 @@ Paste images into a comment to attach visual references. An image-count chip kee
|
|
|
96
96
|
|
|
97
97
|
Double-click visible text to edit it directly. Popmelt records the text change so it can be handed off alongside comments and Steer changes.
|
|
98
98
|
|
|
99
|
+
#### Compare Explore options
|
|
100
|
+
|
|
101
|
+
When a thread is attached to one page element, Claude or Codex can also start a round from an ordinary request for visual alternatives, or revise the options in an existing card. Asking for feedback can stay conversational; the checkmark still applies only the chosen option in code.
|
|
102
|
+
|
|
103
|
+
Each new `/explore` round opens on its first suggestion. Step back once in the card or expanded canvas to compare it with **Original**, the target at the time of the request. History keeps a separate Original for each round. New rounds keep their editable recipes and pack the compiled previews together in `.popmelt`. Applying an option, editing its source, and archiving the thread preserve the reviewed previews. When you iterate on an attached option, **Based on** opens its frozen parent with the text and style edits you submitted. **Back to iteration** returns to the child. Later edits to the parent stay in its current draft. Older rounds can also replay when their saved bundle is available or their recipe rebuilds to the same hash. When runnable replay is unavailable, History shows the captured image if one was saved.
|
|
104
|
+
|
|
105
|
+
The card appears while Explore is building. Each option becomes available as soon as it passes its browser check. You can preview it, attach feedback, or queue it to be applied while later options are still building.
|
|
106
|
+
|
|
107
|
+
Click an element in a preview to attach it to your comment. Feedback on an attached element starts a revision of that option and keeps its Steer edits. Ask for all options explicitly to revise the whole round. On desktop, hold Option (Alt on Windows or Linux) to operate the fixture itself, such as clicking a button or dragging a scene.
|
|
108
|
+
|
|
109
|
+
#### On a phone
|
|
110
|
+
|
|
111
|
+
On a phone, open Chat and tap an element to comment. Swipe to scroll. The thread title has **Minimize** (leave the annotation on the page) and **Archive** (move the thread to History). Explore keeps its controls visible and opens above the conversation. Steer requires a fine pointer.
|
|
112
|
+
|
|
113
|
+
**Pair your own phone as a developer.** Use the same running dev project you use on desktop, with its Popmelt dev integration. Open the dev site over **HTTPS** on the phone first; the certificate must be trusted there. A phone cannot reach the computer's `localhost`. Use a reachable dev hostname or a private HTTPS tunnel to the app port. The bridge itself stays on loopback. From the same project directory, run:
|
|
114
|
+
|
|
115
|
+
```sh
|
|
116
|
+
popmelt phone https://my-mac.local:3000
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Open the private link on the phone within five minutes. The phone uses that project’s Imprint and thread history. On a multiplayer bridge it joins the same canvas as the developer. Subsequent visits from that browser reuse the pairing. The link is single-use; the browser session lasts up to seven days or until the bridge stops. Run `popmelt phone revoke` to disconnect all paired phones immediately. Only pair a dev origin whose scripts you trust. Pairing does not enable multiplayer, publish the dev server, or grant access to other visitors. Provider sign-in and bridge administration remain on the computer.
|
|
120
|
+
|
|
99
121
|
#### Screens inside a canvas
|
|
100
122
|
|
|
101
123
|
Chat can target elements and edit visible DOM text inside **same-origin iframes**, including screens laid out in a translated/scaled canvas. Install Popmelt once in the outer page. Notes, text previews, and screenshot markers follow the selected screen through pan, zoom, and internal scrolling. Sent context includes the screen's URL, title, and frame label; identical element IDs in different screens remain distinct. Preview text edits affect only the selected screen instance, not the source code until handed off.
|
|
@@ -133,6 +155,7 @@ Imprint opens the project's shared understanding. Use its filters to review grou
|
|
|
133
155
|
- Press Backspace or Delete with a thread open, or with one of its historical annotations selected, to archive that thread
|
|
134
156
|
- Right-click a draft comment or staged Steer change in its annotation rail to remove only that draft item
|
|
135
157
|
- Right-click a replied rail to dismiss it from the canvas without deleting its history or reverting applied edits. Press **Command/Control+Z** outside a text editor to restore it before reloading. Rails with fresh drafts or active runs are protected.
|
|
158
|
+
- In the thread composer, Enter sends and Shift+Enter adds a line. During an active run, the host can press Enter or tap Send to redirect it with a new message. Command+Enter on macOS or Ctrl+Enter on Windows and Linux queues the message for later. If the original run finishes first, the message becomes a follow-up.
|
|
136
159
|
- When a reply is queued, use its pencil or trash button to edit or delete that individual message before it starts. Save an edit with the checkmark or Command/Control+Enter; Escape cancels the edit
|
|
137
160
|
- Codex permission requests appear chronologically in the thread as a compact action card, while the canvas and toolbar show **Approval needed**. Expand the card to inspect the exact command or file changes, then choose **Allow once** or **Deny**. Answered requests become an inline tool icon and label, retained in the thread history. Chat text is not a permission grant; Popmelt does not create remembered approvals. Your existing Codex permission rules still apply, so previously allowed commands may run without a new card. After 10 seconds without a response, a run waiting solely on approval yields to other queued jobs. Approving it while parked moves it to the front of the waiting queue, without interrupting active work. The exact action resumes only after reacquiring a slot; unanswered requests expire on resumption (or at 10 seconds if the run cannot safely yield). Same-thread follow-ups cannot overtake a parked run, and disconnected runs cannot be approved.
|
|
138
161
|
|
|
@@ -215,7 +238,7 @@ Then check the setup without launching an agent request or restarting a bridge:
|
|
|
215
238
|
npx @popmelt.com/core claude doctor
|
|
216
239
|
```
|
|
217
240
|
|
|
218
|
-
`infrastructureReady` covers registration, locally reported sign-in, and the identity/version of an already-running project bridge. `sessionVerified` requires recent prompt-hook, MCP-tool, and completion-hook observations from one session of that installed plugin version. `ok` requires both. Observations expire after 24 hours and do not prove the session is still live or that Claude read the skill. Missing observations are **unverified**, not a reason to reinstall repeatedly. Bridge probes cover the standard 1111–
|
|
241
|
+
`infrastructureReady` covers registration, locally reported sign-in, and the identity/version of an already-running project bridge. `sessionVerified` requires recent prompt-hook, MCP-tool, and completion-hook observations from one session of that installed plugin version. `ok` requires both. Observations expire after 24 hours and do not prove the session is still live or that Claude read the skill. Missing observations are **unverified**, not a reason to reinstall repeatedly. Bridge probes cover the standard 1111–1142 range; verify a custom port separately.
|
|
219
242
|
|
|
220
243
|
In a multi-store workspace, diagnostics honor the same saved human-selected primary and read-only mounts as ambient sessions. If that choice is missing, invalid, or no longer matches the available stores, orientation remains required; diagnostics never pick a replacement or rewrite the saved choice.
|
|
221
244
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{d as e,e as t}from"./chunk-Y6WD56SO.mjs";import{g as n,f as r,b as a}from"./chunk-3WSTAV5B.mjs";import{a as o,b as i,c as s}from"./chunk-TRHC7WBO.mjs";import{b as l}from"./chunk-F5XSNRGT.mjs";import{c as p,f as d,d as c,e as u,a as h,b as m}from"./chunk-MJ2PFKF3.mjs";import{a as g}from"./chunk-BJ25TGJN.mjs";import{c as f,a as v,b}from"./chunk-DOCRI237.mjs";import"./chunk-RK6UROPO.mjs";import{a as x}from"./chunk-G2ZHJXHZ.mjs";import{a as y,d as w}from"./chunk-G6RYESYI.mjs";import{g as k}from"./chunk-XT6PHPPG.mjs";import{q as S,p as C,n as I,b as E,c as P,o as T,m as O,l as N}from"./chunk-N66ZZG3L.mjs";import"./chunk-Q6N77LIS.mjs";import{c as R}from"./chunk-ZVDKW7TO.mjs";import{a as j}from"./chunk-Q6C7ZA3H.mjs";import{l as M}from"./chunk-HAE5LUJX.mjs";import"./chunk-RR4SHK7O.mjs";import"./chunk-53SKVMWR.mjs";import"./chunk-57FM7XQV.mjs";import"./chunk-V2I7PSJW.mjs";import"./chunk-5K7SACPW.mjs";import{b as A}from"./chunk-67QNAAUC.mjs";import"./chunk-5D2ADU7H.mjs";import{v as z}from"./chunk-WHJEKDNP.mjs";import{useContext as B,useState as J,useRef as L,useLayoutEffect as D,useMemo as V,useEffect as W,useCallback as q}from"react";import{Check as H,Eye as K,Minimize2 as X,Maximize2 as U,ArrowLeft as Y,MessageCircle as F,ChevronLeft as G,ChevronRight as $}from"lucide-react";import{createPortal as Z}from"react-dom";import{jsxs as Q,Fragment as _,jsx as ee}from"react/jsx-runtime";import{createContext as te,domToCanvas as ne,destroyContext as re}from"modern-screenshot";function ae(e,t,n,r=!1){let[a,o]=J({}),i=n?.backdrop,s=n?.style.color;return D(()=>{if(location.pathname!==e.pathname||r&&i)return void o({background:i,ink:s});let n="component"===t?E(e):void 0,a=n?.component??n?.element??z(e.selector,e.element);if(!a)return void o({background:i,ink:s});let l=a.ownerDocument.defaultView,p=()=>{let e=b(a)??i,t=l.getComputedStyle(a).color;o(n=>n.background===e&&n.ink===t?n:{background:e,ink:t})};p();let d=new MutationObserver(p),c=[a,...v(a)],u=e=>{["color","background-color"].includes(e.propertyName)&&e.target===e.currentTarget&&p()};for(let e of c)d.observe(e,{attributes:!0}),e.addEventListener("transitionend",u);let h=l.matchMedia("(prefers-color-scheme: dark)");return h.addEventListener("change",p),l.addEventListener("resize",p),()=>{d.disconnect();for(let e of c)e.removeEventListener("transitionend",u);h.removeEventListener("change",p),l.removeEventListener("resize",p)}},[e,t,i,s,r]),a}var oe=`\n.sp-card button { border: 0; cursor: pointer; font: inherit; }\n.sp-card {\n --sp-control-bg: light-dark(var(--popmelt-thread-soft, #f2f2f2), #363636);\n position: relative;\n align-self: stretch;\n min-width: 0;\n width: 100%;\n margin-top: 6px;\n border-radius: 12px;\n overflow: hidden;\n color: var(--popmelt-thread-primary, #222);\n font:\n 13px/1.38 'Popmelt Geist',\n system-ui,\n sans-serif;\n}\n.sp-card, .sp-workspace {\n color-scheme: light dark;\n background-color: var(--sp-page-background, var(--popmelt-thread-raised, light-dark(#fff, #181818)));\n background-image: radial-gradient(circle, var(--sp-page-dot, light-dark(#f2f2f2, #222222)) 1px, transparent 1.25px);\n background-size: 11px 11px;\n}\n:is(.sp-workspace[data-popmelt-theme='dark'], [data-popmelt-theme='dark'] .sp-card) {\n color-scheme: dark;\n}\n:is(.sp-workspace[data-popmelt-theme='light'], [data-popmelt-theme='light'] .sp-card) {\n color-scheme: light;\n}\n.sp-stage {\n position: relative;\n min-height: 185px;\n display: grid;\n /* The zoom viewport measures this track. Keep captured images and previous\n zoom measurements from increasing its intrinsic minimum width. */\n grid-template-columns: minmax(0, 1fr);\n place-items: center;\n padding: 0;\n}\n.sp-actions,\n.sp-zoom-actions {\n position: absolute;\n z-index: 2;\n top: 6px;\n display: flex;\n gap: 3px;\n opacity: 0;\n pointer-events: none;\n transition: opacity 120ms ease-out;\n}\n.sp-actions {\n right: 6px;\n}\n.sp-zoom-actions {\n left: 6px;\n}\n.sp-card:is(:hover, :has(:focus-visible)) :is(.sp-actions, .sp-zoom-actions),\n.sp-actions[data-preview-active='true'] {\n opacity: 1;\n pointer-events: auto;\n}\n.sp-zoom-actions [role='group'] {\n display: flex;\n gap: 2px;\n}\n.sp-card :is(.sp-actions, .sp-zoom-actions) button {\n color: var(--popmelt-thread-primary, #383838);\n background: var(--sp-control-bg);\n border-radius: 8px;\n width: 28px;\n height: 26px;\n display: grid;\n place-items: center;\n}\n.sp-card .sp-zoom-actions button {\n width: 26px;\n}\n.sp-card .sp-zoom-actions button:disabled {\n color: #aaa;\n cursor: default;\n}\n.sp-card .sp-actions button[aria-pressed='true'] {\n background: var(--sp-accent, #ed1014);\n color: white;\n}\n.sp-card button:focus-visible {\n outline: 2px solid var(--sp-accent, #ed1014);\n outline-offset: 2px;\n}\n.sp-card svg {\n width: 14px;\n height: 14px;\n}\n/* Thread text is selectable by default, including individual spans. */\n.sp-card footer, .sp-card footer * {\n -webkit-user-select: none !important;\n user-select: none !important;\n}\n.sp-card footer {\n font: 14px/1.5 ${y};\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 3px;\n position: absolute;\n inset: auto 0 0;\n z-index: 2;\n padding: 6px;\n pointer-events: none;\n}\n.sp-card .tag-option,\n.sp-card .pager button {\n padding: 3px;\n background: none;\n color: inherit;\n}\n.sp-card .tag-option {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n min-width: 0;\n text-align: left;\n}\n.sp-card .tag-option > span {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.sp-card .tag-option > svg {\n flex: none;\n opacity: 0;\n transition: opacity 120ms ease-out;\n}\n.sp-card .tag-option:is(:hover, :focus-visible) > svg {\n opacity: 1;\n}\n@media (hover: none), (max-width: 480px) {\n .sp-card .tag-option > svg {\n opacity: 1;\n }\n}\n@media (prefers-reduced-motion: reduce) {\n .sp-card .tag-option > svg {\n transition: none;\n }\n}\n.sp-card .pager {\n display: flex;\n align-items: center;\n gap: 3px;\n color: var(--popmelt-thread-primary, #383838);\n white-space: nowrap;\n}\n.sp-card .pager-number {\n font-variant-numeric: tabular-nums;\n}\n.sp-card .pager button {\n width: 22px;\n height: 22px;\n display: grid;\n place-items: center;\n}\n.sp-card footer :is(.tag-option, .pager) {\n pointer-events: auto;\n touch-action: manipulation;\n}\n.sp-card footer .tag-option {\n padding: 0;\n}\n.sp-card .tag-option > span,\n.sp-card .pager {\n box-sizing: border-box;\n min-height: 26px;\n padding: 2px 8px;\n border-radius: 8px;\n background: var(--sp-control-bg);\n}\n.sp-card .tag-option > span {\n align-content: center;\n}\n.sp-card footer .pager {\n padding-inline: 2px;\n touch-action: pan-y pinch-zoom;\n}\n@media (prefers-reduced-motion: reduce) {\n .sp-actions,\n .sp-zoom-actions {\n transition: none;\n }\n}\n@media (hover: none), (max-width: 480px) {\n .sp-actions,\n .sp-zoom-actions {\n pointer-events: auto;\n opacity: 1;\n transition: none;\n }\n}\n\n.sp-expanded-placeholder, .sp-steer-frame { height: 260px; }\n.sp-steer-frame {\n position: relative;\n border: 0;\n display: block;\n width: 100%;\n border-radius: inherit;\n}\n\n/* An expanded card covers the annotation canvas. Its editor takes the free side of the thread. */\n/* Group the toolbar and its popovers above the editor, alongside the thread. */\n:is(body, [data-popmelt-root]):has(> .sp-workspace:not([hidden])) [data-popmelt-toolbar-layer] {\n position: relative;\n z-index: 10004;\n}\n/* Preserve the toolbar's geometry while the active preview covers its controls. */\n[data-popmelt-toolbar-layer][inert] { opacity: 0; }\n.sp-workspace {\n position: fixed;\n inset: 8px;\n overflow: clip;\n box-shadow: 0 0 0 100vmax light-dark(rgb(255 255 255 / 50%), rgb(0 0 0 / 50%));\n}\n.sp-workspace .sp-card {\n position: absolute;\n inset: 0 var(--sp-work-right, 0px) 0 var(--sp-work-left, 0px);\n width: auto;\n display: flex;\n flex-direction: column;\n margin: 0;\n border-radius: 0;\n background: transparent;\n}\n.sp-workspace .sp-stage {\n flex: 1;\n min-height: 0;\n}\n.sp-workspace .sp-steer-frame {\n position: absolute;\n inset: 0;\n height: 100%;\n}\n.sp-workspace :is(.sp-actions, .sp-zoom-actions) {\n top: 12px;\n opacity: 1;\n pointer-events: auto;\n}\n.sp-workspace .sp-actions { right: 12px; }\n.sp-workspace .sp-zoom-actions { left: 12px; }\n.sp-workspace .sp-card footer { padding: 12px; }\n.sp-card .sp-expanded-badge {\n display: inline-flex;\n align-items: center;\n gap: 5px;\n border-radius: 8px;\n min-height: 26px;\n padding: 2px 8px;\n background: var(--sp-control-bg);\n color: inherit;\n}\n[data-popmelt-explore-canvas="right"] .sp-expanded-badge > svg { rotate: 180deg; }\n@media (max-width: 480px) {\n /* Keep the same mounted composer and card; the portal uses the space above them. */\n [data-devtools="thread-panel"][data-popmelt-explore-canvas] {\n top: auto !important;\n height: auto !important;\n padding: 0 !important;\n border: 0 !important;\n background: transparent !important;\n backdrop-filter: none !important;\n }\n [data-popmelt-explore-canvas] [data-popmelt-thread-shell] {\n overflow: visible !important;\n background: transparent !important;\n }\n [data-popmelt-explore-canvas] :is([data-popmelt-thread-header], [data-devtools="thread-panel-messages"], [data-queued-replies-area], [data-scroll-to-bottom]) {\n display: none !important;\n }\n .sp-workspace {\n inset: max(var(--popmelt-thread-visible-top, 8px), env(safe-area-inset-top))\n max(8px, env(safe-area-inset-right))\n calc(max(var(--popmelt-thread-visible-bottom, 8px), env(safe-area-inset-bottom)) + var(--sp-thread-height, 0px) + 6px)\n max(8px, env(safe-area-inset-left));\n }\n .sp-workspace .sp-card { inset: 0; }\n [data-popmelt-explore-canvas] .sp-expanded-badge > svg { rotate: 90deg; }\n}\n`;function ie({anchor:e,surfaceStyle:n,children:r}){let{visible:a}=B(h),o=L(null),[i,s]=J(null);return D(()=>{s(e.current?.closest("[data-popmelt-root]")??document.body)},[e]),D(()=>{if(a&&i)return t(i.ownerDocument)},[i,a]),D(()=>{let t=o.current,n=e.current?.closest('[data-devtools="thread-panel"]');if(!t||!n||!a)return;n.dataset.popmeltExploreCanvas="left";let r=i?.querySelector("[data-popmelt-toolbar-layer]"),s=r?.querySelector("#devtools-toolbar"),l=()=>{let e=n.getBoundingClientRect();if(r&&s){let t=s.getBoundingClientRect(),n=e.left<t.right+1&&e.right>t.left-1&&e.top<t.bottom+1&&e.bottom>t.top-1;r.inert=j(window.innerWidth)||n}let a=t.getBoundingClientRect(),o=e.left-a.left>=a.right-e.right;n.dataset.popmeltExploreCanvas=o?"left":"right",t.style.setProperty("--sp-thread-height",`${e.height}px`),t.style.setProperty("--sp-work-left",o?"0px":`${Math.max(0,e.right-a.left)}px`),t.style.setProperty("--sp-work-right",o?`${Math.max(0,a.right-e.left)}px`:"0px"),t.style.borderRadius=getComputedStyle(n).borderRadius,t.dataset.popmeltTheme=n.dataset.popmeltTheme;for(let e of Array.from(n.style))e.startsWith("--popmelt-thread-")&&t.style.setProperty(e,n.style.getPropertyValue(e))};l();let p=new ResizeObserver(l);p.observe(n),s&&p.observe(s);let d=new MutationObserver(l);return d.observe(n,{attributes:!0,attributeFilter:["style","data-popmelt-theme"]}),s&&d.observe(s,{attributeFilter:["style"]}),window.addEventListener("resize",l),()=>{r&&(r.inert=!1),delete n.dataset.popmeltExploreCanvas,p.disconnect(),d.disconnect(),window.removeEventListener("resize",l)}},[e,i,a]),i?Z(ee("div",{hidden:!a,ref:o,className:"sp-workspace","data-popmelt-font":"sans",style:{...n,zIndex:10003},children:r}),i):null}function se({tag:e,framing:t}){let n=L(null);return ee("div",{"data-devtools":"preview-feedback-picker",style:{position:"absolute",inset:0,cursor:e?"crosshair":"default",userSelect:"none"},onPointerDown:e=>{n.current=e.isPrimary&&0===e.button?{id:e.pointerId,x:e.clientX,y:e.clientY,dragged:!1}:null},onPointerMove:e=>{let r=n.current;if(r?.id!==e.pointerId)return;let a=e.clientX-r.x,o=e.clientY-r.y;if(!r.dragged&&Math.hypot(a,o)<=8||(r.dragged=!0,r.x=e.clientX,r.y=e.clientY,"touch"!==e.pointerType||t.getScale()<=1))return;let{width:i,height:s}=e.currentTarget.getBoundingClientRect();if(!i||!s)return;let l=t.getView(i,s);t.setView(l.scale,l.x+a/i,l.y+o/s,i,s)},onPointerLeave:()=>{n.current=null},onPointerCancel:()=>{n.current=null},onPointerUp:t=>{let r=n.current;if(n.current=null,r?.id!==t.pointerId||r.dragged||Math.hypot(t.clientX-r.x,t.clientY-r.y)>8||!e)return;let a=t.currentTarget.parentElement?.querySelector(".sp-fit");if(!a)return;let o=k(t.clientX,t.clientY,{within:a})?.closest("[data-scratch-part]");o&&e(o.getAttribute("data-scratch-part"),N(o))}})}function le({capture:e,framing:t}){let n=L(null),[r,a]=J(1);return D(()=>{let r=n.current,o=()=>{let n=Math.max(.01,Math.min(1,(r.clientWidth-36)/e.width,(r.clientHeight-36)/e.height));a(n),t.setFitScale(n)};o();let i=new ResizeObserver(o);return i.observe(r),()=>i.disconnect()},[e,t]),ee("div",{className:"sp-steer-frame",ref:n,children:ee(s,{interactive:!0,framing:t,overlay:ee(se,{framing:t}),children:ee("div",{style:{display:"grid",placeItems:"center",width:"100%",height:"100%"},children:ee("img",{alt:"Original at exploration time",src:e.still,draggable:!1,style:{width:e.width*r,height:e.height*r,maxWidth:"none"}})})})})}function pe({original:e,bundles:t,target:n,theme:r,accent:a,framing:o,onEscape:i}){let[s,l]=J(!1),{capture:p,runnable:d}=e,c=d&&t?.[d.fixture.bundle];return d&&!s&&"string"!=typeof c?c?ee(u,{bundle:c,target:n,readOnly:!0,capture:p,theme:r,accent:a,framing:o,initial:[],onError:()=>l(!0),onEscape:i}):ee("div",{className:"sp-steer-frame",role:"status",children:"Loading original…"}):p?.still?ee(le,{capture:p,framing:o}):ee("div",{className:"sp-steer-frame",role:"status",children:"Original unavailable for this round."})}function de({frameUrl:e,theme:t,...n}){let[r,a]=J(null);return D(()=>{r&&t&&(r.documentElement.style.colorScheme=t)},[r,t]),D(()=>{if(!r||!n.captureRef)return;let e=()=>{let e=r.querySelector(".sp-fit");return e?async function(e,t){let n=e.ownerDocument;await n.fonts.ready;let r=e.getBoundingClientRect(),a=e.offsetWidth,o=e.offsetHeight;if(!a||!o||!r.width)throw Error("The option is not ready to capture.");let i=r.width/a,s=Array.from(e.children,e=>e.getBoundingClientRect()).filter(e=>e.width&&e.height);s.length||s.push(r);let l,p=Math.max(0,(Math.min(r.right,...s.map(e=>e.left))-r.left)/i-12),d=Math.max(0,(Math.min(r.bottom,...s.map(e=>e.top))-r.top)/i-12),c=Math.min(a,(Math.max(r.left,...s.map(e=>e.right))-r.left)/i+12),u=Math.min(o,(Math.max(r.top,...s.map(e=>e.bottom))-r.top)/i+12),h=await te(e,{width:a,height:o,scale:Math.min(2,1600/Math.max(a,o)),backgroundColor:t,timeout:2500,style:{transform:"none",position:"static",margin:"0"},onCloneEachNode:e=>{if(1!==e.nodeType)return;let t=e;(t.hasAttribute("data-tagged")||t.hasAttribute("data-badge-hover")||t.hasAttribute("data-scratch-part"))&&(t.style.outline="none"),t.removeAttribute("data-tagged"),t.removeAttribute("data-badge-hover")}});h.sandbox=n.createElement("iframe");try{l=await ne(h)}finally{re(h)}let m=n.createElement("canvas"),g=l.width/a;return m.width=Math.max(1,Math.ceil((c-p)*g)),m.height=Math.max(1,Math.ceil((u-d)*g)),m.getContext("2d").drawImage(l,-p*g,-d*g),new Promise((e,t)=>m.toBlob(n=>n?e(n):t(Error("Could not capture the reviewed option.")),"image/png"))}(e,n.captureBackground??"transparent"):Promise.reject(Error("The option is still loading."))},t=n.captureRef;return t.current=e,()=>{t.current===e&&(t.current=null)}},[r,n.captureRef,n.captureBackground]),Q(_,{children:[ee("iframe",{className:"sp-steer-frame",style:{colorScheme:t},"aria-label":"Edit or comment on this option",src:e,srcDoc:e?void 0:g,onLoad:e=>{let t=e.currentTarget.contentDocument;t&&w(t),a(t)}}),r&&ee(ce,{doc:r,...n},n.editorKey)]})}function ce({doc:e,...t}){let{toggle:n}=B(h),r=L(t),a=L(t);a.current=t;let o=L(void 0);D(()=>{let t=e.defaultView;if(!t)return;let{node:i,initial:s,target:l,accentColor:p,framing:d}=r.current,c=!0,u=s;o.current=t.startScratchSteer?.(i,l,p,d,e=>{if(!c)return;let t=O(s,e);JSON.stringify(t)!==JSON.stringify(u)&&(u=t,a.current.onChange(t))},e=>{c&&a.current.onTag(e)},e=>{c&&a.current.onPreview(e)},n);let h=e=>{"Escape"!==e.key||!a.current.onEscapeWorkspace||e.target?.closest?.('input, textarea, [contenteditable="true"]')||(e.preventDefault(),e.stopImmediatePropagation(),a.current.onEscapeWorkspace())};return t.addEventListener("keydown",h,!0),()=>{c=!1,o.current=void 0,a.current.onPreview(null),t.removeEventListener("keydown",h,!0)}},[e,n]);let i=R(),[s,l]=J();D(()=>{let t=e.defaultView?.frameElement;if(t instanceof HTMLIFrameElement)return m(t,l,()=>{e.documentElement.setAttribute("data-preview-control-hovered","")})},[e]);let{selectedPart:p,hoveredPart:d,focusRequest:c}=t;return D(()=>{o.current?.({feedbackOnly:i,selectedPart:p,hoveredPart:d,focusRequest:c,controlBounds:s})},[e,n,p,d,c,s,i]),null}function ue(e){!e||e.getRootNode().activeElement?.closest("[data-popmelt-thread-composer]")||e.querySelector("[data-expand-option]")?.focus({preventScroll:!0})}function he({batch:t,frameUrl:n,bundles:r,canApply:a=!0,frozenVersion:s,framing:p,theme:d,accentColor:u,selection:h,preview:m,setTag:g,onTogglePreview:v,onBrowse:b,edits:x,revisions:y,index:w,hoveredTarget:k,focusRequest:S,onPreviewStyle:C,onFixtureCanvas:I,onSteer:E,onApply:P,busy:T,expanded:O,onExpand:N}){let R=L(null),[j,A]=J(""),[z,B]=J(!1),V=L(null),W=L(null),F=q(e=>{W.current=e,ue(e)},[]),G=L(O);D(()=>{G.current&&!O&&ue(V.current),G.current=O},[O]),D(()=>{if(S?.batchId!==t.id||S.option!==w)return;let e=O?W.current:V.current,n=e?.closest('[data-devtools="thread-panel-messages"]');if(!e||!n)return;let r=e.getBoundingClientRect(),a=n.getBoundingClientRect();r.top>=a.top&&r.bottom<=a.bottom||n.scrollBy({top:r.top-a.top-Math.max(0,(n.clientHeight-r.height)/2),behavior:window.matchMedia("(prefers-reduced-motion: reduce)").matches?"instant":"smooth"})},[t.id,w,S,O]);let $=JSON.stringify([t.id,w,s??y?.[w]??0]),[Z]=J(()=>p??o(null)),te=t.options.length,ne=-1===w?t.original:void 0,re=t.options[Math.max(0,w)],{background:se,ink:le}=ae(t.target,ne?.capture?.scope??("fixture"in re?re.previewScope:void 0),t.original?.capture,!!ne),ce=se?f(se):void 0,he=ce?.theme??d,ge={"--sp-page-background":se,"--sp-accent":u,"--sp-page-dot":ce?.dot,backgroundImage:ne?"none":void 0},fe={batchId:t.id,option:w,path:[]},ve=m?.showVariant&&m.target.batchId===t.id&&m.target.option===w;let be="fixture"in re?r?.[re.fixture.bundle]:void 0,xe=ee(me,{title:ne?"Original":re.title,index:ne?-1:w,hasOriginal:!!t.original,optionCount:te,accentColor:u,canTag:a,onTag:()=>g(fe),browseBy:function(e){let n=t.original?-1:0,r=te-n,a=n+(w-n+e+r)%r;A(""),b({...fe,option:a})}}),ye=Q("div",{className:"sp-stage",style:{cursor:M(u)},children:[ee("div",{className:"sp-zoom-actions",children:ee(i,{framing:Z})}),Q("div",{className:"sp-actions","data-preview-active":!!m,children:[!ne&&ve&&a&&ee(l,{type:"button","aria-label":"Apply this option in code",disabled:T||z,onClick:async()=>{A(""),B(!0);try{if(!R.current)throw Error("The option is still loading. Try again in a moment.");let e=await R.current();await P(fe,e)}catch(e){A(e instanceof Error?e.message:"Could not apply this option.")}finally{B(!1)}},children:ee(H,{})}),!s&&(!ne||!!m)&&ee(l,{type:"button","aria-pressed":!!m,hint:!O&&m?"Turn off page preview":"Preview on page","aria-label":"Preview on page",disabled:"fixture"in re&&(!be||"string"==typeof be),onClick:()=>v(fe),children:ee(K,{})}),ee(l,{type:"button","data-expand-option":"","aria-label":O?"Collapse preview":"Expand preview","aria-expanded":O,onClick:()=>N(!O),children:ee(O?X:U,{})})]}),ne?ee(pe,{original:ne,target:t.target,bundles:r,framing:Z,theme:he,accent:u,onEscape:O?()=>N(!1):void 0}):"fixture"in re?ee(c,{captureRef:R,captureBackground:se??void 0,frameKey:$,frozenParent:!!s,readOnly:!!s,capture:s?t.original?.capture:void 0,bundle:be,previewScope:re.previewScope,target:t.target,pageInk:se?le:void 0,framing:Z,theme:he,accent:u,initial:x.filter(e=>e.batchId===t.id&&e.option===w),onCanvas:e=>I?.(re.fixture.bundle,e),onEscape:O?()=>N(!1):void 0,selected:h?.batchId===t.id&&h.option===w?h.fixturePart:void 0,onTag:(e,t)=>g({...fe,fixturePart:e,fixturePartLabel:t}),onChange:e=>E(w,e),onPreview:e=>C(w,e)}):ee(de,{captureRef:R,captureBackground:se??void 0,editorKey:$,readOnly:!!s,framing:Z,onEscapeWorkspace:O?()=>N(!1):void 0,frameUrl:n,target:t.target,node:re.root,theme:he,accentColor:u,initial:x.filter(e=>e.batchId===t.id&&e.option===w),onPreview:e=>C(w,e),hoveredPart:k?.batchId===t.id&&k.option===w?k.part:void 0,focusRequest:S?.batchId===t.id&&S.option===w?S:void 0,selectedPart:h?.batchId===t.id&&h.option===w?h.path.join(".")+(h.field?"/label":""):void 0,onChange:e=>E(w,e),onTag:e=>{let[t,n]=e.split("/");g({...fe,path:t?t.split(".").map(Number):[],field:"label"===n?"label":void 0})}}),j&&ee("span",{role:"alert",children:j}),xe]});return Q(_,{children:[Q("section",{ref:V,"data-explore-batch":t.id,"aria-label":"Explore options",className:"sp-card",style:ge,"data-popmelt-tooltip-group":"",children:[ee("style",{children:oe}),O?Q("div",{className:"sp-stage sp-expanded-placeholder",children:[Q(l,{type:"button",className:"sp-expanded-badge",hint:"Collapse preview","aria-label":"Preview expanded. Collapse preview","aria-expanded":!0,onClick:()=>N(!1),children:[ee(Y,{"aria-hidden":"true"}),"Preview expanded"]}),xe]}):ye]}),!ne&&"fixture"in re&&re.rationale&&ee(e,{text:re.rationale}),O&&ee(ie,{anchor:V,surfaceStyle:ge,children:ee("section",{ref:F,"aria-label":"Expanded explore options",className:"sp-card","data-popmelt-tooltip-group":"","data-popmelt-tooltip-boundary":!0,children:ye})})]})}function me({title:e,index:t,optionCount:n,hasOriginal:r,accentColor:a,onTag:o,canTag:i,browseBy:s}){let p=L(null),d=L(null);return Q("footer",{children:[t<0?ee("span",{className:"tag-option",children:ee("span",{children:e})}):Q(l,{above:!0,className:"tag-option",disabled:!i,hint:"Add to chat",anchorRef:p,"aria-label":`Add ${e} to chat`,onClick:o,children:[ee("span",{children:e}),ee(F,{ref:p,"aria-hidden":"true",color:a})]}),(r||n>1)&&Q("div",{className:"pager",onTouchStart:e=>{let t=e.touches[0];d.current=1===e.touches.length?{id:t.identifier,x:t.clientX,y:t.clientY}:null},onTouchCancel:()=>{d.current=null},onTouchEnd:e=>{let t=d.current;d.current=null;let n=e.changedTouches[0];if(!t||!n||n.identifier!==t.id||e.touches.length)return;let r=n.clientX-t.x,a=n.clientY-t.y;Math.abs(r)<24||Math.abs(r)<1.3*Math.abs(a)||(e.preventDefault(),s(r>0?1:-1))},children:[ee("button",{type:"button","aria-label":"Previous option",onClick:()=>s(-1),children:ee(G,{})}),Q("span",{"aria-live":"polite",children:[ee("span",{className:"pager-number",children:t+1})," of"," ",ee("span",{className:"pager-number",children:n})]}),ee("button",{type:"button","aria-label":"Next option",onClick:()=>s(1),children:ee($,{})})]})]})}function ge(e,t,n){return`popmelt-explore-draft:${e}:${t}:${n}`}function fe(e,t){let n={};return t.options.forEach((r,a)=>{try{let r=window.localStorage.getItem(ge(e,t.id,a));if(!r)return;let o=JSON.parse(r),{revision:i,edits:s}=Array.isArray(o)?{revision:0,edits:o}:o;if(!Number.isSafeInteger(i)||i<0||!Array.isArray(s))return;let l=s.map(T);if(l.some(e=>e.batchId!==t.id||e.option!==a))return;C({messages:[{batch:t}]},I(l)),n[a]={revision:i,edits:l}}catch{}}),n}function ve(e,t,n,r,a){try{let o=ge(e,t,n);void 0!==a?window.localStorage.setItem(o,JSON.stringify({revision:a,edits:r})):r.length?window.localStorage.setItem(o,JSON.stringify(r)):window.localStorage.removeItem(o)}catch{}}function be(e,t,n,r){try{let a=ge(e,t,n),o=window.localStorage.getItem(a);if(!o)return;let i=JSON.parse(o),s=Array.isArray(i)?{revision:0,edits:i}:i;s.revision===r.revision&&JSON.stringify(s.edits.map(T))===JSON.stringify(r.edits)&&window.localStorage.removeItem(a)}catch{}}var xe={edits:[]};function ye(e,t,n,r,a){let[o]=J(()=>fe(e,t)),[i,s]=J(()=>({...n,...o})),l=L(i),p=L({...n}),d=L({...o}),c=L(new Set),u=L(new Map),[h,m]=J({}),[g,f]=J(""),v=a&&void 0!==n;function b(e,t,n){let r=l.current[e]??xe;l.current={...l.current,[e]:t},JSON.stringify(r.edits)!==JSON.stringify(t.edits)&&(s(l.current),n&&m(t=>({...t,[e]:(t[e]??0)+1})))}async function x(n){if(v&&!c.current.has(n)){c.current.add(n);try{for(;d.current[n];){let a=d.current[n],o=await A(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({batchId:t.id,option:n,...a})});if(!o.ok&&409!==o.status)throw Error();let{draft:i}=await o.json();if(!i||!Number.isSafeInteger(i.revision)||!Array.isArray(i.edits))throw Error();i.revision>=(p.current[n]?.revision??0)&&(p.current[n]=i);let s=d.current[n];409===o.status||s===a?(delete d.current[n],be(e,t.id,n,s),b(n,p.current[n],!0),f(409===o.status?"This option changed on another device. Its latest saved edits are shown.":"")):(s.revision=i.revision,ve(e,t.id,n,s.edits,s.revision))}}catch{f("Couldn’t sync option edits to this project.")}finally{c.current.delete(n)}}}let y=()=>Object.keys(d.current).forEach(e=>{x(Number(e))}),w=L(y);return D(()=>{w.current=y}),D(()=>{if(n)for(let[e,t]of Object.entries(n)){let n=Number(e);t.revision<(p.current[n]?.revision??0)||(p.current[n]=t,d.current[n]||b(n,t,!0))}},[n]),W(()=>{if(!v)return;let e=()=>w.current();e(),window.addEventListener("online",e);let t=u.current;return()=>{window.removeEventListener("online",e);for(let e of t.values())clearTimeout(e);t.clear(),e()}},[v]),{edits:V(()=>Object.values(i).flatMap(e=>e.edits),[i]),save:function(n,r){let a=d.current[n]?.revision??p.current[n]?.revision??0,o={revision:a,edits:r.map(T)};JSON.stringify(l.current[n]?.edits??[])!==JSON.stringify(o.edits)&&(d.current[n]=o,ve(e,t.id,n,o.edits,a),b(n,o,!1),v&&(clearTimeout(u.current.get(n)),u.current.set(n,setTimeout(()=>{u.current.delete(n),x(n)},220))))},revisions:h,failure:g,retry:y,unsynced:!!Object.keys(d.current).length}}function we({batch:e,draftScope:t,threadId:i,sharedDrafts:s,bridgeUrl:l,theme:c,accentColor:u,active:h,hidden:m,revealOnPage:g,activate:f,expanded:v,onExpand:b,canReply:y,submit:w,selection:k,onAttach:T,focusRequest:O,workspaceRef:N,followSource:R}){let j=p(l,S(e)),M=B(x),A=M?.preview?.batchId===e.id&&M.preview.threadId===i?M.preview:null,z=M?!!A?.enabled:h,[W,q]=J(()=>A?.index??0),H=L(null);D(()=>{H.current!==O&&(H.current=O,O&&O.batchId===e.id&&e.options[O.option]&&q(O.option))},[O,e.id,e.options]);let K=V(()=>O?{...O,part:""}:null,[O]),X=ye(t,e,s,l+"/thread/"+encodeURIComponent(i)+"/explore-draft",y),[U,Y]=J(),F=O!==U&&O?.option===W?O.snapshot:void 0,G=F?.edits??X.edits,[$]=J(()=>o(null)),Z=V(()=>v&&!m&&!F&&W>=0?{batchId:e.id,option:W}:null,[v,m,F,e.id,W]),[te,ne]=J(A?.targets??null),[re,ae]=J(()=>A&&"fixture"in A.option?{[A.option.fixture.bundle]:A.hasCanvas}:{}),[oe,ie]=J(""),[se,le]=J(null),pe=V(()=>C({messages:[{batch:e}]},I(G)).messages[0].batch,[e,G]);D(()=>{if(!Z)return;let e={source:Z,framing:$,reference:()=>r(pe,{...Z,path:[]},G)};return N.current=e,()=>{N.current===e&&(N.current=null)}},[N,Z,$,pe,G]),D(()=>{let t=N.current;if(!t||t.source!==R)return;let n=e.options.findIndex((n,r)=>{let a=e.parents?.[r];return a?.batchId===t.source.batchId&&a.option===t.source.option&&(!("fixture"in n)||"object"==typeof j[n.fixture.bundle])});n<0||($.restore(t.framing.snapshot()),q(n),b(!0))},[e,j,R,$,b,N]);let de=pe.options[Math.max(0,W)],ce=e=>"fixture"in de?P(e,de.previewScope,!!re[de.fixture.bundle]):e.element,ue=W>=0&&te&&ce(te),me="fixture"in de&&"component"===de.previewScope?"Core could not locate a single root for this component on the page. You can still review the option here.":"Open the annotated page with its target visible to preview this option.",ge="fixture"in de?j[de.fixture.bundle]??(A&&"fixture"in A.option&&A.option.fixture.bundle===de.fixture.bundle?A.bundle:void 0):void 0,fe=V(()=>{let t=I(G)[e.id]?.[W]??{},n={...t};if(se?.option===W)for(let[e,r]of Object.entries(se.parts))n[e]={...t[e],...r};return n},[G,e.id,W,se]),ve="fixture"in de&&!!re[de.fixture.bundle],be=V(()=>te?{threadId:i,batchId:e.id,index:W,enabled:!0,target:e.target,option:de,targets:te,hasCanvas:ve,bundle:"string"==typeof ge?void 0:ge,parts:fe,theme:c,accentColor:u,revealOnPage:g}:null,[i,e.id,e.target,W,de,te,ve,ge,fe,c,u,g]),xe=!!A,we=M?.setPreview;D(()=>{F||!xe||!be||!we||we(t=>t?.batchId===e.id&&t.threadId===i?{...be,enabled:t.enabled,suspended:t.suspended}:t)},[F,xe,be,we,e.id,i]);let ke=()=>{we?.(t=>t?.batchId===e.id&&t.threadId===i?{...t,enabled:!1}:t),f(!1)},Se=z?{target:{batchId:e.id,option:W,path:[]},showVariant:W>=0}:null,Ce=e.parents?.[W];return Q(_,{children:[ee(he,{batch:pe,framing:$,bundles:j,index:W,edits:G,theme:c,accentColor:u,selection:k,preview:Se,expanded:v&&!m,onExpand:b,revisions:X.revisions,focusRequest:K,hoveredTarget:null,busy:!1,canApply:y&&!F,frozenVersion:F?O?.returnTo:void 0,onTogglePreview:()=>{if(ie(""),Se&&!v)return void ke();let t=E(e.target),n=location.pathname===e.target.pathname&&ce(t);n&&n.parentElement&&!n.matches("body,html")&&!n.closest("[data-devtools]")?(ne(t),we?.({threadId:i,batchId:e.id,index:W,enabled:!0,target:e.target,option:de,targets:t,hasCanvas:ve,bundle:"string"==typeof ge?void 0:ge,parts:fe,theme:c,accentColor:u,revealOnPage:g}),b(!1),f(!0)):ie(me)},onBrowse:e=>{Y(O),q(e.option),le(null)},onFixtureCanvas:(e,t)=>ae(n=>n[e]===t?n:{...n,[e]:t}),onPreviewStyle:(e,t)=>le(n=>t?{option:e,parts:t}:n?.option===e?null:n),onSteer:(t,n)=>{if(F)return;let r=n.map(n=>({...n,batchId:e.id,option:t}));X.save(t,r)},setTag:e=>{y&&!F&&T(r(pe,e,G))},onApply:async(e,t)=>{let{text:r,meta:a}=n(pe,e.option,G);if(!await w(r,t?{...a,exploreOption:{...a.exploreOption,selection:{...a.exploreOption.selection,reviewedImage:{replyImageIndex:0,capturedAt:Date.now(),description:"The attached image shows this reviewed option with its saved edits. Use it as the visual target to apply; the original annotation screenshot is earlier context."}}}}:a,t?[t]:void 0))throw Error("This thread cannot send the apply request.");ke(),b(!1)}}),F&&O?.returnTo?Q("span",{children:["Parent version ·"," ",ee(a,{reference:O.returnTo,children:"Back to iteration"})]}):Ce?Q("span",{children:["Based on"," ",ee(a,{reference:{...Ce,snapshot:Ce,returnTo:{batchId:e.id,option:W,title:de.title}},showVersion:!0})]}):null,X.failure&&Q("span",{role:"alert",children:[X.failure," ",X.unsynced&&ee("button",{type:"button",onClick:X.retry,children:"Retry"})]}),(oe||z&&W>=0&&!m&&te&&!ue)&&ee("span",{role:"alert",children:oe||me}),!M&&!F&&z&&!m&&be&&ee(d,{preview:be})]})}export{we as ExploreAttachment};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";export{f as PagePreviewLayer}from"./chunk-MJ2PFKF3.mjs";import"./chunk-BJ25TGJN.mjs";import"./chunk-N66ZZG3L.mjs";import"./chunk-Q6N77LIS.mjs";import"./chunk-ZVDKW7TO.mjs";import"./chunk-Q6C7ZA3H.mjs";import"./chunk-HAE5LUJX.mjs";import"./chunk-RR4SHK7O.mjs";import"./chunk-53SKVMWR.mjs";import"./chunk-57FM7XQV.mjs";import"./chunk-V2I7PSJW.mjs";import"./chunk-5K7SACPW.mjs";import"./chunk-67QNAAUC.mjs";import"./chunk-5D2ADU7H.mjs";import"./chunk-WHJEKDNP.mjs";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{e,a as t,d as n,b as i,c as r}from"./chunk-P4KM3K5M.mjs";import"./chunk-RUTWU5W2.mjs";import"./chunk-GSEMSZDB.mjs";import{m as a,b as o,n as s,l as d,a as l,i as c,k as m,j as p}from"./chunk-FMI4VQDZ.mjs";import"./chunk-PQT5FYN5.mjs";import"./chunk-MP6ZV2DN.mjs";import{i as u,a as h,h as f}from"./chunk-BACXPVHP.mjs";import{ba as y,Aa as g}from"./chunk-LD3532UC.mjs";import"./chunk-NSCO633B.mjs";import"./chunk-J4WDYITA.mjs";import"./chunk-PH2MLB3T.mjs";import"./chunk-R3FPXDQS.mjs";import"./chunk-RK6UROPO.mjs";import"./chunk-G2ZHJXHZ.mjs";import{d as v,a as b}from"./chunk-G6RYESYI.mjs";import"./chunk-4LHTPRFY.mjs";import"./chunk-G7JR5Z3P.mjs";import{a as j}from"./chunk-JRP5XFYN.mjs";import"./chunk-XT6PHPPG.mjs";import"./chunk-ZVDKW7TO.mjs";import"./chunk-Q6C7ZA3H.mjs";import"./chunk-HAE5LUJX.mjs";import"./chunk-RR4SHK7O.mjs";import"./chunk-53SKVMWR.mjs";import{c as w,a as k}from"./chunk-57FM7XQV.mjs";import"./chunk-V2I7PSJW.mjs";import"./chunk-5K7SACPW.mjs";import"./chunk-67QNAAUC.mjs";import"./chunk-5D2ADU7H.mjs";import"./chunk-XTOCFTVW.mjs";import"./chunk-LVEMYZOA.mjs";import"./chunk-WHJEKDNP.mjs";import{useState as S,useSyncExternalStore as I,useEffect as x,useRef as C,useId as P,useLayoutEffect as O}from"react";import{Link2 as T,Ban as A,Clock as R,X as J,Hand as N,SendHorizontal as E}from"lucide-react";import{jsxs as F,jsx as z,Fragment as W}from"react/jsx-runtime";function H(e){let i,a={phase:"starting"},o=0,s=!1,d=!1,l=0,c=new Set,m=`popmelt-participant:${e.projectId}`,p=new t(e.url,e.projectId),u=e=>{if(!d){a=e;for(let e of c)e()}},h=async(t={})=>{let n=await fetch("/__popmelt/host",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin",body:JSON.stringify(t),redirect:"error"});if(403===n.status)return null;if(!n.ok)throw new Error(`Host entry unavailable (${n.status}).`);let i=`popmelt-before-participants:${e.projectId}`;return null===localStorage.getItem(i)&&localStorage.setItem(i,JSON.stringify(Object.fromEntries(Object.values(y(e.projectId)).map(e=>[e,localStorage.getItem(e)])))),await n.json()},f=async(t,n=l)=>{if(d||n!==l)return;let a=await(t=>r({bridgeUrl:e.url,projectId:e.projectId,credential:t,runtimeStorage:sessionStorage,observedSource:{sourceId:e.projectId,revision:e.revision}}))(t);if(d||n!==l)a.dispose();else{try{localStorage.setItem(m,JSON.stringify(t))}catch(e){throw a.dispose(),e}i?.dispose(),i=a,u({phase:"connected",connection:a}),h({credential:t}).catch(()=>{})}},g=()=>{l++,i?.dispose(),i=void 0,function(e,t){e.removeItem(`popmelt-participant:${t}`);let n,i=`popmelt-admission:${t}`;try{n=JSON.parse(e.getItem(i)??"null")}catch{return void e.removeItem(i)}n&&"object"==typeof n&&e.setItem(i,JSON.stringify({name:n.name,colorIdentity:n.colorIdentity??n.receipt}))}(localStorage,e.projectId),u({phase:"entry",invitation:null})};return{client:p,getSnapshot:()=>a,subscribe:e=>(c.add(e),()=>{c.delete(e)}),retain(){if(d)throw new Error("Participant lifecycle is disposed");o++,s||(s=!0,(async()=>{let e=n(location.href),t=new URL(e.cleanUrl),i=new URLSearchParams(t.hash.slice(1)),r=i.get("popmelt-host");i.delete("popmelt-host"),r&&(t.hash=i.toString()),t.href!==location.href&&history.replaceState(history.state,"",t);let a=null;if(r){if(a=await h({token:r}),!a)throw new Error("Host entry expired. Use the current private host link.")}else if(!e.token){try{a=JSON.parse(localStorage.getItem(m)??"null")}catch{}a??(a=await h())}if(!d){if(!a)return void u({phase:"entry",invitation:e.token??null});try{await f(a)}catch(e){if(d)return;if("access_removed"===e.code)return void g();if(401!==e.status)throw e;let t=await h();t?await f(t):g()}}})().catch(e=>u({phase:"error",message:e.message})));let e=!1;return()=>{e||(e=!0,o--,queueMicrotask(()=>{o||d||(d=!0,l++,i?.dispose(),i=void 0,c.clear())}))}},removed:g,async join(t,n){if("entry"!==a.phase||!a.invitation||d)throw new Error("No active invitation");if(!n)throw new Error("Peer identity is not ready");let i=l,r=await p.joinOrRequestAdmission(a.invitation,t,n);if(!d&&i===l){if("admission"in r)return localStorage.setItem(`popmelt-admission:${e.projectId}`,JSON.stringify({name:r.admission.name,receipt:n,colorIdentity:n})),void u({phase:"entry",invitation:null});await f(r.joined.credential,i)}},admit:e=>f(e)}}function U(){let e=crypto.getRandomValues(new Uint8Array(32));return{id:crypto.randomUUID(),token:Array.from(e,e=>e.toString(16).padStart(2,"0")).join("")}}var q=360,M=120,D=180;function L({client:e,storage:t,storageKey:n,onAdmitted:r,theme:a="light",themePreference:o=a,onThemePreferenceChange:y,onJoin:w}){let I=C(null),T=C(!1);if(!T.current){T.current=!0;try{I.current=JSON.parse(t.getItem(n)??"null")}catch{}}let[H,L]=S(I.current?.name??""),[$,K]=S(w?void 0:I.current?.receipt),[X,B]=S(null),[V,Z]=S(),[Y,Q]=S(),G=C(null),[_,ee]=S(!!w),[te,ne]=S(!1),[ie,re]=S(0),[ae,oe]=S(),[se,de]=S("idle"),[le,ce]=S(),[me,pe]=S(),ue=C(!1),[he,fe]=S(""),ye=C(null),ge=C(null),ve=C(null),be=C(null),je=C(!1),we=C(0),ke=C(!1),Se=P(),Ie=C(!1),xe=C(0),Ce=C(r);Ce.current=r;let Pe=C(!1),Oe=C(null),Te=C(()=>{});Oe.current||(Oe.current=new Promise(e=>{Te.current=e}));let Ae=k[a],Re=_&&!V;x(()=>{let e,t,n=!1,i=()=>{n||(n=!0,Pe.current=!0,Te.current())};"function"==typeof requestAnimationFrame&&(e=requestAnimationFrame(()=>{t=requestAnimationFrame(i)}));let r=window.setTimeout(i,64);return()=>{void 0!==e&&cancelAnimationFrame(e),void 0!==t&&cancelAnimationFrame(t),window.clearTimeout(r),i()}},[]),x(()=>v(document),[]),O(()=>{let e=!0,t=()=>{if(!e||!ve.current)return;let t=getComputedStyle(ve.current),n=document.createElement("span");Object.assign(n.style,{position:"fixed",visibility:"hidden",pointerEvents:"none",whiteSpace:"nowrap",fontFamily:t.fontFamily,fontSize:t.fontSize,fontWeight:t.fontWeight,lineHeight:t.lineHeight}),document.body.append(n);let i=Number.parseFloat(t.paddingLeft)+Number.parseFloat(t.paddingRight);n.textContent="Ask for access";let r=i+12+3+n.getBoundingClientRect().width;n.textContent="Request pending";let a=i+12+3+n.getBoundingClientRect().width;n.textContent="Request declined";let o=i+12+3+n.getBoundingClientRect().width;if(n.remove(),r>15&&a>15&&o>15&&ce({ask:Math.ceil(r),pending:Math.ceil(a),declined:Math.ceil(o)}),be.current){let e=getComputedStyle(be.current),t=document.createElement("span");Object.assign(t.style,{position:"fixed",visibility:"hidden",pointerEvents:"none",whiteSpace:"nowrap",fontFamily:e.fontFamily,fontSize:e.fontSize,fontWeight:e.fontWeight,lineHeight:e.lineHeight}),t.textContent="Sending...",document.body.append(t);let n=Number.parseFloat(e.paddingLeft)+Number.parseFloat(e.paddingRight);pe({idle:Math.ceil(n+14),sending:Math.ceil(n+t.getBoundingClientRect().width)}),t.remove()}};return t(),document.fonts?.ready.then(t),()=>{e=!1}},[a,_]),x(()=>{if(!ie)return;let e=setTimeout(()=>re(0),q);return()=>clearTimeout(e)},[ie]),x(()=>{if(!ae)return;let e=setTimeout(()=>oe(void 0),q);return()=>clearTimeout(e)},[ae]),x(()=>{if("in"!==se)return;let e=setTimeout(()=>de("idle"),D);return()=>clearTimeout(e)},[se]),x(()=>{I.current&&delete I.current.color;try{let e=JSON.parse(t.getItem(n)??"null");e&&"object"==typeof e&&"color"in e&&(delete e.color,t.setItem(n,JSON.stringify(e)))}catch{}},[t,n]);let Je=!(!$||X&&"pending"!==X.status&&"granted"!==X.status),Ne=(e,i)=>{I.current={...I.current,name:e,receipt:i},t.setItem(n,JSON.stringify(I.current))};x(()=>{if("cancelled"===X?.status){I.current={...I.current,name:H,receipt:void 0};try{t.setItem(n,JSON.stringify(I.current))}catch{}K(void 0),B(null)}},[X,H,t,n]);let Ee=()=>{if(G.current)return G.current;return G.current=(async()=>{let i,r=JSON.parse(t.getItem(n)??"null"),a=r?.colorIdentity??r?.receipt??U();I.current={name:H,receipt:r?.receipt,colorIdentity:a},t.setItem(n,JSON.stringify(I.current));try{i=await e.reserveAdmissionColor(a)}catch(r){let o=r.status;if(400!==o&&401!==o)throw r;a=U(),I.current={...I.current,colorIdentity:a},t.setItem(n,JSON.stringify(I.current)),i=await e.reserveAdmissionColor(a)}return Z(i.color),Q(g(i)),a})().finally(()=>{G.current=null}),G.current},Fe=C(Ee);Fe.current=Ee;let ze=!!w;x(()=>{if(!_||V)return;let e,t=!1,n=0,r=async()=>{try{await Fe.current()}catch{if(t)return;e=setTimeout(()=>{r()},i(++n))}};return r(),()=>{t=!0,clearTimeout(e)}},[_,V,t,n]),x(()=>{if(!_)return;ge.current?.focus();let e=e=>{e.composedPath().includes(ye.current)||ee(!1)};return document.addEventListener("pointerdown",e),()=>document.removeEventListener("pointerdown",e)},[_]),x(()=>{if(!$)return;let r,a,o=!0,s=!1,d=!1,l=()=>{xe.current+=1,I.current={...I.current,name:H,receipt:void 0};try{t.setItem(n,JSON.stringify(I.current))}catch{}K(void 0),B(null),ee(!1),fe("")},c=()=>{d=!0;let r=U(),s=0,l=async()=>{if(o)try{let i=await Fe.current();I.current={...I.current,name:H,receipt:r,colorIdentity:i},t.setItem(n,JSON.stringify(I.current));let a=await e.requestAdmission(r,H,i);if(!o)return;xe.current+=1,K(r),B(a),fe("")}catch{if(!o)return;a=setTimeout(()=>{l()},i(++s))}};l()},m=async()=>{if(s||d||ke.current||Ie.current)return;s=!0;let t=xe.current;try{let n=await e.admissionStatus($);if(!o||t!==xe.current)return;if("declined"===n.status){if(Pe.current||await Oe.current,!o||t!==xe.current)return;d=!0;let e=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches,n=()=>{o&&(de("rejected"),re(e=>e+1),r=setTimeout(()=>{if(o){if(e)return l(),void de("idle");de("rejected-out"),r=setTimeout(()=>{o&&(l(),de("in"))},M)}},q))};return void(e?n():(de("pending-out"),r=setTimeout(n,M)))}if("expired"===n.status)return void c();if(B(n),d="cancelled"===n.status,fe(""),n.credential){ke.current=!0;try{await Ce.current(n.credential),d=!0}finally{ke.current=!1}}}catch(e){if(!o||t!==xe.current)return;401===e.status&&c()}finally{s=!1}};m();let p=setInterval(m,1500);return()=>{o=!1,clearInterval(p),clearTimeout(r),clearTimeout(a)}},[e,$,H,t,n]);return F("div",{ref:ye,"data-devtools":"participant-admission","data-popmelt-font":"sans","data-popmelt-theme":a,style:{display:"contents"},onKeyDown:e=>{"Escape"===e.key&&(ee(!1),e.stopPropagation())},children:[z("style",{children:`\n ${d}\n [data-popmelt-admission-ask] {\n transition: box-shadow 120ms ease, width 180ms ease;\n }\n [data-popmelt-admission-ask][data-popmelt-admission-rejection="odd"] {\n animation: popmelt-admission-rejection-odd 360ms ease-out;\n }\n [data-popmelt-admission-ask][data-popmelt-admission-rejection="even"] {\n animation: popmelt-admission-rejection-even 360ms ease-out;\n }\n [data-popmelt-admission-submit-rejection="odd"] {\n animation: popmelt-admission-rejection-odd 360ms ease-out;\n }\n [data-popmelt-admission-submit-rejection="even"] {\n animation: popmelt-admission-rejection-even 360ms ease-out;\n }\n @keyframes popmelt-admission-rejection-odd {\n 0%, 100% { transform: translateX(0); }\n 38% { transform: translateX(-3px); }\n }\n @keyframes popmelt-admission-rejection-even {\n 0%, 100% { transform: translateX(0); }\n 38% { transform: translateX(-3px); }\n }\n [data-popmelt-admission-sending-dot] {\n animation-duration: 1.2s;\n animation-iteration-count: infinite;\n animation-timing-function: step-end;\n }\n [data-popmelt-admission-sending-dot="1"] {\n animation-name: popmelt-admission-sending-dot-1;\n }\n [data-popmelt-admission-sending-dot="2"] {\n animation-name: popmelt-admission-sending-dot-2;\n }\n [data-popmelt-admission-sending-dot="3"] {\n animation-name: popmelt-admission-sending-dot-3;\n }\n @keyframes popmelt-admission-sending-dot-1 {\n 0%, 24.99% { opacity: 0; }\n 25%, 100% { opacity: 1; }\n }\n @keyframes popmelt-admission-sending-dot-2 {\n 0%, 49.99% { opacity: 0; }\n 50%, 100% { opacity: 1; }\n }\n @keyframes popmelt-admission-sending-dot-3 {\n 0%, 74.99% { opacity: 0; }\n 75%, 100% { opacity: 1; }\n }\n @keyframes popmelt-admission-send-icon-out {\n 0%, 30% {\n opacity: 1;\n transform: translate(0, -50%);\n }\n 100% {\n opacity: 0;\n transform: translate(10px, -50%);\n }\n }\n @keyframes popmelt-admission-sending-label-in {\n 0% {\n opacity: 0;\n transform: translate(-12px, -50%);\n }\n 100% {\n opacity: 1;\n transform: translate(0, -50%);\n }\n }\n [data-devtools="participant-admission"][data-popmelt-theme="${a}"] [data-popmelt-admission-ask]:is([aria-expanded="false"], [data-popmelt-admission-pending]):is(:hover, :focus-visible) {\n box-shadow: inset 0 0 0 100px ${Ae.softHairline};\n }\n [data-popmelt-admission-pending-label],\n [data-popmelt-admission-cancel-label],\n [data-popmelt-admission-declined-label] {\n grid-area: 1 / 1;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 3px;\n }\n [data-popmelt-admission-cancel-label] { visibility: hidden; }\n [data-popmelt-admission-ask]:is(:hover, :focus-visible, [aria-busy="true"]) [data-popmelt-admission-pending-label] { visibility: hidden; }\n [data-popmelt-admission-ask]:is(:hover, :focus-visible, [aria-busy="true"]) [data-popmelt-admission-cancel-label] { visibility: visible; }\n [data-devtools="participant-admission"][data-popmelt-theme="${a}"] input::placeholder {\n color: ${Ae.secondary};\n opacity: 1;\n }\n @media (prefers-reduced-motion: reduce) {\n [data-popmelt-admission-ask] { transition: none; animation: none; }\n [data-popmelt-admission-submit-rejection] { animation: none; }\n [data-popmelt-admission-sending-dot] { animation: none; opacity: 1; }\n [data-popmelt-admission-send-icon],\n [data-popmelt-admission-sending-label] { animation: none !important; }\n }\n `}),z(s,{entry:{theme:a,themePreference:o,onThemePreferenceChange:y,deemphasizeControls:_,onCollapse:()=>ee(!1),panel:_||he?F(W,{children:[_&&!Je&&F("form",{"aria-label":ze?"Join session":"Ask for access","data-popmelt-font":"sans",style:{...p(a),flexWrap:"wrap"},onSubmit:i=>{i.preventDefault();let r=je.current?"enter":"send";je.current=!1,(async i=>{if(!H.trim()||te||Je||ue.current)return;if(ue.current=!0,ne(!0),fe(""),oe(void 0),w){try{let e=await Ee();Ne(H.trim()),await w(H.trim(),e)}catch(e){fe(e instanceof Error?e.message:"Could not join. Please try again.")}finally{ue.current=!1,ne(!1)}return}try{I.current=JSON.parse(t.getItem(n)??"null")}catch{}let r=!X&&I.current?.receipt?I.current.receipt:U();try{let t=await Ee();Ne(H,r),I.current={...I.current,name:H,receipt:r};let n=await e.requestAdmission(r,H.trim(),t);K(r),L(n.name),B(n),ee(!1)}catch{I.current={...I.current,name:H,receipt:r},oe({target:i,pulse:++we.current})}finally{ue.current=!1,ne(!1)}})(r)},children:[F("div",{style:{display:"flex",alignItems:"center",gap:6,flex:1,minWidth:0},children:[z(l,{"data-popmelt-entry-avatar":!0,shape:Y,color:V??(Re?Ae.muted:"transparent"),size:h.identitySize}),F("span",{"data-popmelt-admission-name-field":!0,style:{display:"inline-grid",flex:"0 1 auto",minWidth:0},children:[z("span",{"aria-hidden":"true","data-popmelt-admission-name-measure":!0,style:{gridArea:"1 / 1",visibility:"hidden",whiteSpace:"pre",overflow:"hidden",paddingRight:1},children:H||"what’s your name?"}),z("input",{ref:ge,"aria-label":"Your name",placeholder:"what’s your name?",autoComplete:"nickname",maxLength:48,value:H,disabled:te,onKeyDown:e=>{"Enter"===e.key&&(je.current=!0)},onKeyUp:e=>{"Enter"===e.key&&(je.current=!1)},onBlur:()=>{je.current=!1},onChange:e=>{L(e.target.value);try{Ne(e.target.value,I.current?.receipt)}catch{}},style:{gridArea:"1 / 1",minWidth:"100%",width:0,padding:0,border:0,borderRadius:0,background:"transparent",color:te?Ae.mutedStrong:Ae.primary,WebkitTextFillColor:te?Ae.mutedStrong:Ae.primary,caretColor:te?"transparent":Ae.primary,opacity:1,transition:"color 120ms ease",font:"inherit",fontFamily:b,outline:"none",boxShadow:"none",appearance:"none"}})]}),z("kbd",{"aria-hidden":"true","data-popmelt-admission-enter-hint":!0,"data-popmelt-admission-submit-rejection":"enter"===ae?.target?ae.pulse%2?"odd":"even":void 0,style:{...c(a),...f,flexShrink:0,color:H.trim()?Ae.primary:Ae.muted,opacity:te?0:1,pointerEvents:te?"none":void 0,transition:"opacity 120ms ease"},children:"enter"})]}),F("button",{ref:be,type:"submit",disabled:te||Re||!V||!H.trim(),"aria-label":te?"Sending…":ze?"Join session":"Send request","aria-keyshortcuts":"Enter","aria-busy":te||void 0,"data-popmelt-admission-submit-rejection":"send"===ae?.target?ae.pulse%2?"odd":"even":void 0,style:{...m(a),width:me?me[te?"sending":"idle"]:void 0,position:"relative",boxSizing:"border-box",overflow:"hidden",fontSize:12,color:te||!H.trim()?Ae.muted:Ae.primary,transition:"color 120ms ease, width 180ms ease"},children:[z("span",{"aria-hidden":"true","data-popmelt-admission-submit-sizer":!0,style:{width:14,height:14,flexShrink:0}}),F("span",{"aria-hidden":"true","data-popmelt-admission-submit-content":!0,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[z(E,{size:14,"data-popmelt-admission-send-icon":!0,style:{position:"absolute",top:"50%",right:8,opacity:te?0:1,transform:te?"translate(10px, -50%)":"translate(0, -50%)",animation:te?"popmelt-admission-send-icon-out 260ms ease both":void 0}}),F("span",{"data-popmelt-admission-sending-label":!0,style:{position:"absolute",top:"50%",right:8,opacity:te?1:0,transform:te?"translate(0, -50%)":"translate(-12px, -50%)",animation:te?"popmelt-admission-sending-label-in 260ms ease 40ms both":void 0},children:["Sending",F("span",{"data-popmelt-admission-sending-dots":!0,"aria-hidden":"true",style:{display:"inline-block"},children:[z("span",{"data-popmelt-admission-sending-dot":"1",children:"."}),z("span",{"data-popmelt-admission-sending-dot":"2",children:"."}),z("span",{"data-popmelt-admission-sending-dot":"3",children:"."})]})]})]})]}),he&&z("span",{role:"alert",style:{flexBasis:"100%",fontSize:12},children:he})]}),!_&&he&&z("div",{role:"status",style:{...p(a),fontSize:12},children:he})]}):null,action:F(W,{children:[z("span",{"aria-hidden":"true","data-popmelt-admission-host":!0,style:{width:22,height:22,marginLeft:5,flexShrink:0,boxSizing:"border-box",border:`1px solid ${Ae.surface}`,borderRadius:"50%",background:j.activeColor,opacity:_||Je?.2:1,transition:Pe.current?"opacity 120ms ease":"none"}}),z("button",{ref:ve,type:"button","data-popmelt-font":"sans","data-popmelt-admission-ask":!0,"data-popmelt-admission-pending":Je?"":void 0,"data-popmelt-admission-declined":"rejected"===se||"rejected-out"===se?"":void 0,"data-popmelt-admission-rejection":ie?ie%2?"odd":"even":void 0,"data-popmelt-admission-transition":"idle"===se?void 0:se,"data-popmelt-entry-control":!0,"aria-expanded":Je?void 0:_,"aria-label":"rejected"===se||"rejected-out"===se?"Request declined":Je?"Cancel request":void 0,"aria-describedby":Je?Se:void 0,"aria-busy":!(!Je||!te)||void 0,disabled:Je&&(te||"idle"!==se),onClick:()=>"idle"===se&&(Je?void(async()=>{if($&&!te&&!Ie.current){Ie.current=!0,xe.current+=1,ne(!0),fe("");try{let t=await e.cancelAdmission($);B(t),ee(!1)}catch{re(e=>e+1)}finally{Ie.current=!1,ne(!1)}}})():(ee(!_),void(_||fe("")))),"aria-description":Je?void 0:ze?"Enter your name to join the session.":"Ask the host to join in Suggest mode.",style:{...u(a),width:le?le["rejected"===se||"rejected-out"===se?"declined":Je?"pending":"ask"]:void 0,paddingLeft:3,overflow:"hidden",transition:"box-shadow 120ms ease, width 180ms ease",background:Je&&X?.color?`color-mix(in srgb, ${X.color} 10%, ${Ae.control})`:Ae.control},children:F("span",{"data-popmelt-entry-content":!0,style:{display:Je?"inline-grid":"inline-flex",alignItems:"center",gap:"inherit",opacity:"pending-out"===se||"rejected-out"===se?0:1,transition:Pe.current?"opacity 120ms ease":"none"},children:["rejected"===se||"rejected-out"===se?F("span",{id:Se,"data-popmelt-admission-declined-label":!0,"aria-hidden":"true",children:[z(A,{size:12}),"Request declined"]}):Je?F(W,{children:[F("span",{id:Se,"data-popmelt-admission-pending-label":!0,"aria-hidden":"true",children:[z(R,{size:12,style:{color:X?.color}}),"Request pending"]}),F("span",{"data-popmelt-admission-cancel-label":!0,"aria-hidden":"true",children:[z(J,{size:12}),"Cancel request"]})]}):z(N,{size:12,"aria-hidden":"true","data-popmelt-admission-wave":!0}),!Je&&"Ask for access"]})})]})}})]})}function $({config:t,children:n}){let[i]=S(()=>H(t));a();let r=I(i.subscribe,i.getSnapshot,i.getSnapshot);x(()=>i.retain(),[i]);let[d,l,c]=w(),m="connected"===r.phase?r.connection:null,p="error"===r.phase?r.message:"",u="entry"===r.phase?r.invitation:null,h=F("span",{"data-popmelt-entry-content":!0,style:{...o(k[d],!1),cursor:"default"},children:[z(T,{size:14,strokeWidth:1.5,"aria-hidden":"true"}),z("span",{children:"Disconnected"})]});return m?z(e,{connection:m,codePreviewUrl:location.href,onAccessRemoved:i.removed,children:n}):"starting"===r.phase?null:z("div",{"data-devtools":"participant-entry",style:{display:"contents"},children:p?z(s,{entry:{theme:d,themePreference:c,onThemePreferenceChange:l,ariaLabel:"Popmelt disconnected",action:null,logoOnly:!0,connection:h}}):z(L,{client:i.client,storage:localStorage,storageKey:`popmelt-admission:${t.projectId}`,theme:d,themePreference:c,onThemePreferenceChange:l,onAdmitted:i.admit,onJoin:u?i.join:void 0},u??"request-access")})}export{$ as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{c as r,e as t}from"./chunk-P4KM3K5M.mjs";import"./chunk-RUTWU5W2.mjs";import"./chunk-GSEMSZDB.mjs";import"./chunk-LD3532UC.mjs";import"./chunk-NSCO633B.mjs";import"./chunk-J4WDYITA.mjs";import"./chunk-R3FPXDQS.mjs";import"./chunk-RK6UROPO.mjs";import"./chunk-G2ZHJXHZ.mjs";import"./chunk-G6RYESYI.mjs";import"./chunk-4LHTPRFY.mjs";import"./chunk-G7JR5Z3P.mjs";import"./chunk-JRP5XFYN.mjs";import"./chunk-XT6PHPPG.mjs";import"./chunk-HAE5LUJX.mjs";import"./chunk-RR4SHK7O.mjs";import"./chunk-53SKVMWR.mjs";import"./chunk-57FM7XQV.mjs";import"./chunk-V2I7PSJW.mjs";import"./chunk-5K7SACPW.mjs";import{b as o}from"./chunk-67QNAAUC.mjs";import{d as n,f as e,c as i,a as c}from"./chunk-5D2ADU7H.mjs";import"./chunk-LVEMYZOA.mjs";import"./chunk-WHJEKDNP.mjs";import{useState as m,useEffect as s,cloneElement as p}from"react";import{jsxs as h,jsx as u}from"react/jsx-runtime";function a({children:a,projectId:j,participantConfig:l}){let[d,k]=m(null),[f,I]=m("");if(s(()=>{let t,i,m=!1;return k(null),I(""),n(j).then(async n=>{if(m)return;let s=location.origin+c;i=e(s,n);let p=await o(s+"/status",{signal:AbortSignal.timeout(6e3)}),h=p.ok?await p.json():null;if(h?.projectId!==n.projectId)throw new Error("Phone access expired. Create a fresh pairing link in the project terminal.");if(!m){if(h.phoneParticipantId)t=await r({projectId:n.projectId,bridgeUrl:s,credential:{participantId:h.phoneParticipantId,token:""},runtimeStorage:sessionStorage,observedSource:{sourceId:n.projectId,revision:l?.revision??"unversioned"}});else if(l)throw new Error("This phone is not connected to the multiplayer host.");m?t?.dispose():k({bridgeUrl:s,projectId:n.projectId,connection:t})}}).catch(r=>{i?.(),m||I(r instanceof Error?r.message:"Phone pairing failed.")}),()=>{m=!0,t?.dispose(),i?.()}},[j,l]),f)return h("p",{role:"alert","data-devtools":"phone-pairing-error",children:[f," ",u("button",{type:"button",onClick:i,children:"Forget this pairing"})]});if(!d)return null;let P=p(a,{bridgeUrl:d.bridgeUrl,projectId:d.projectId});return d.connection?u(t,{connection:d.connection,onAccessRemoved:i,children:P}):P}export{a as PhoneHostGate};
|