@popmelt.com/core 0.36.0 → 0.37.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.
Files changed (222) hide show
  1. package/README.md +106 -23
  2. package/claude-plugin/.claude-plugin/plugin.json +1 -1
  3. package/claude-plugin/skills/popmelt-core/SKILL.md +6 -1
  4. package/codex-plugin/.codex-plugin/plugin.json +1 -1
  5. package/codex-plugin/skills/popmelt-core/SKILL.md +6 -1
  6. package/dist/ExploreAttachment-6AIMXC2K.mjs +1 -0
  7. package/dist/PagePreviewLayer-SIH7DDBF.mjs +1 -0
  8. package/dist/ParticipantRuntime-RTMEFDKF.mjs +1 -0
  9. package/dist/PhoneHostGate-RZRGWS2E.mjs +1 -0
  10. package/dist/PopmeltTasteConnectedPane-FAJXJEQQ.mjs +1 -0
  11. package/dist/PreviewRuntime-MW33PLMV.mjs +1 -0
  12. package/dist/{QueuedReplies-ESIFFRKS.mjs → QueuedReplies-4APDDNQX.mjs} +1 -1
  13. package/dist/SamplePlacementOverlay-2VLBRDPZ.mjs +1 -0
  14. package/dist/ShareProjectPane-OR2LS2A3.mjs +1 -0
  15. package/dist/SuppliedContext-SAQKEDWW.mjs +1 -0
  16. package/dist/ThreadErrorCard-OSHIWSHR.mjs +1 -0
  17. package/dist/ThreadPanel-CMC5Q6WM.mjs +1 -0
  18. package/dist/adapter-react-three-fiber.d.mts +20 -3
  19. package/dist/adapter-react-three-fiber.mjs +1 -1
  20. package/dist/adapter-three.d.mts +53 -2
  21. package/dist/adapter-three.mjs +45 -1
  22. package/dist/bridge-entry.mjs +1 -1
  23. package/dist/bridgeSSEStream-6OMAFDFW.mjs +1 -0
  24. package/dist/bridgeWebSocketStream-WIOGOPJW.mjs +1 -0
  25. package/dist/browser-runtime-5W2ZKUCZ.mjs +1 -0
  26. package/dist/browser.d.mts +4 -4
  27. package/dist/browser.mjs +1 -1
  28. package/dist/canvas-chat-note-O3USBECW.mjs +1 -0
  29. package/dist/checkFixture-DQPLFEUL.mjs +1 -0
  30. package/dist/{chunk-AH6LZOQC.mjs → chunk-3PSB5BST.mjs} +1 -1
  31. package/dist/chunk-3QYA5LGF.mjs +1 -0
  32. package/dist/chunk-3VOEPWRL.mjs +1 -0
  33. package/dist/chunk-4LVGVKSS.mjs +1 -0
  34. package/dist/chunk-5GEBVPTA.mjs +1 -0
  35. package/dist/chunk-5IZHN3A7.mjs +1 -0
  36. package/dist/chunk-6EO73WJN.mjs +1 -0
  37. package/dist/chunk-6XEEXK3U.mjs +1 -0
  38. package/dist/chunk-76WRZ2NH.mjs +1 -0
  39. package/dist/chunk-7EISKUU7.mjs +1 -0
  40. package/dist/chunk-7JWADHTH.mjs +1 -0
  41. package/dist/chunk-A4GARXVQ.mjs +1 -0
  42. package/dist/chunk-AAMUU2QA.mjs +1 -0
  43. package/dist/chunk-AGCS65LT.mjs +1 -0
  44. package/dist/{chunk-RR4SHK7O.mjs → chunk-AOTDTBQO.mjs} +1 -1
  45. package/dist/chunk-ATLUO4G7.mjs +1 -0
  46. package/dist/chunk-AYZUOBFI.mjs +1 -0
  47. package/dist/chunk-B22WBEQC.mjs +1 -0
  48. package/dist/chunk-B4DYUYX4.mjs +1 -0
  49. package/dist/{chunk-NDGM4DAP.mjs → chunk-BYASSHKJ.mjs} +1 -1
  50. package/dist/chunk-C2ZSNUXQ.mjs +1 -0
  51. package/dist/chunk-CCFTIBCJ.mjs +1 -0
  52. package/dist/chunk-CIKFUS7J.mjs +1 -0
  53. package/dist/chunk-CK3CDA3L.mjs +1 -0
  54. package/dist/chunk-CVVD2OMQ.mjs +1 -0
  55. package/dist/chunk-EBJ23A7F.mjs +1 -0
  56. package/dist/chunk-ECMLCGAM.mjs +1 -0
  57. package/dist/chunk-EFGQKWSZ.mjs +1 -0
  58. package/dist/chunk-EILBHZDX.mjs +1 -0
  59. package/dist/{chunk-DOCRI237.mjs → chunk-ELKVFX2O.mjs} +1 -1
  60. package/dist/{chunk-EXIUW3JX.mjs → chunk-EUFR7R5Q.mjs} +1 -1
  61. package/dist/chunk-EZVFCJEG.mjs +1 -0
  62. package/dist/chunk-F3VZQGPM.mjs +1 -0
  63. package/dist/chunk-FHCKFQBY.mjs +1 -0
  64. package/dist/chunk-FJWWBKCQ.mjs +1 -0
  65. package/dist/chunk-FON4QY7P.mjs +1 -0
  66. package/dist/chunk-GAUQZAW6.mjs +1 -0
  67. package/dist/chunk-GLF7Z5IR.mjs +1 -0
  68. package/dist/chunk-HAN6CUNB.mjs +1 -0
  69. package/dist/chunk-HAZXZ5TU.mjs +1 -0
  70. package/dist/chunk-HBFSPXIC.mjs +1 -0
  71. package/dist/chunk-HKHZBKAN.mjs +1 -0
  72. package/dist/chunk-HPU2UMVE.mjs +1 -0
  73. package/dist/{chunk-YHYFWNN6.mjs → chunk-IAXSC2ZN.mjs} +1 -1
  74. package/dist/chunk-IW7V7WNL.mjs +1 -0
  75. package/dist/chunk-JEGBAHYK.mjs +1 -0
  76. package/dist/chunk-JJK4LAN6.mjs +1 -0
  77. package/dist/chunk-JSNK6NX7.mjs +1 -0
  78. package/dist/chunk-KCDHP4N3.mjs +1 -0
  79. package/dist/chunk-KF73S7MG.mjs +1 -0
  80. package/dist/chunk-KXVXWEN4.mjs +1 -0
  81. package/dist/chunk-L6S66APQ.mjs +1 -0
  82. package/dist/chunk-LH7HKUCK.mjs +1 -0
  83. package/dist/chunk-LOUWY55X.mjs +1 -0
  84. package/dist/chunk-MPEVFQ43.mjs +1 -0
  85. package/dist/{chunk-57FM7XQV.mjs → chunk-NI77Y3WC.mjs} +1 -1
  86. package/dist/chunk-O2ZQFLNV.mjs +1 -0
  87. package/dist/chunk-OA63PYHZ.mjs +1 -0
  88. package/dist/chunk-OIKFQ2FV.mjs +1 -0
  89. package/dist/chunk-OREALBUO.mjs +1 -0
  90. package/dist/chunk-OVZ4CQGM.mjs +1 -0
  91. package/dist/chunk-PRPXMDZ7.mjs +1 -0
  92. package/dist/chunk-PWQB3FIW.mjs +1 -0
  93. package/dist/chunk-QE5XGXIA.mjs +30 -0
  94. package/dist/chunk-QV5G3XRE.mjs +1 -0
  95. package/dist/chunk-ROKRMYFR.mjs +1 -0
  96. package/dist/chunk-SBD7GQDN.mjs +1 -0
  97. package/dist/chunk-SKKHZBOJ.mjs +1 -0
  98. package/dist/chunk-SOGN7S54.mjs +1 -0
  99. package/dist/chunk-SOT33EQ4.mjs +1 -0
  100. package/dist/chunk-SUAHDXJZ.mjs +1 -0
  101. package/dist/chunk-TCGXG7UA.mjs +1 -0
  102. package/dist/chunk-TIAPJGX2.mjs +1 -0
  103. package/dist/chunk-TMSGNHXH.mjs +1 -0
  104. package/dist/chunk-UTP56NCY.mjs +1 -0
  105. package/dist/chunk-UX3DTCHL.mjs +1 -0
  106. package/dist/chunk-VVNZ5IEG.mjs +24 -0
  107. package/dist/chunk-W2QQVB2H.mjs +1 -0
  108. package/dist/chunk-WF3YGZPI.mjs +1 -0
  109. package/dist/chunk-WJHYEACV.mjs +1 -0
  110. package/dist/chunk-WP2SHSCG.mjs +1 -0
  111. package/dist/chunk-X6I6KQDG.mjs +1 -0
  112. package/dist/chunk-XJJDBMZI.mjs +1 -0
  113. package/dist/chunk-YMWXWXPV.mjs +1 -0
  114. package/dist/chunk-YYODLRV3.mjs +1 -0
  115. package/dist/cli.mjs +1 -1
  116. package/dist/codex-note-context-6QGJT2V3.mjs +1 -0
  117. package/dist/codex-project-3GJPU63O.mjs +1 -0
  118. package/dist/codex-session-registry-YNU6LEVH.mjs +1 -0
  119. package/dist/codex-store-mount-F6RBC77X.mjs +1 -0
  120. package/dist/{dev-server-DtX2_HCa.d.mts → dev-server-BRrhkH5t.d.mts} +11 -1
  121. package/dist/dev-server-KWVIMLLL.mjs +1 -0
  122. package/dist/focus-inspection-F25RXWZV.mjs +1 -0
  123. package/dist/guest-admission.d.mts +2 -0
  124. package/dist/guest-admission.mjs +1 -0
  125. package/dist/guest-live-canvas.d.mts +2 -0
  126. package/dist/guest-live-canvas.mjs +1 -0
  127. package/dist/index.d.mts +6 -6
  128. package/dist/index.mjs +1 -1
  129. package/dist/invitationLink-LUIIOAEZ.mjs +1 -0
  130. package/dist/inviteQr-HVHH45SN.mjs +1 -0
  131. package/dist/inviteQr-U77MLSEQ.mjs +1 -0
  132. package/dist/media.d.mts +3 -3
  133. package/dist/memory-store.d.mts +5 -1
  134. package/dist/page-interaction-TV3P6B3X.mjs +1 -0
  135. package/dist/page-planes-2ZepTpen.d.mts +817 -0
  136. package/dist/participantBootstrap-BuTrTQbo.d.mts +22 -0
  137. package/dist/{participantBootstrap-DFJlcKRI.d.mts → participantBootstrap-CSLsiQ-C.d.mts} +9 -3
  138. package/dist/peer-client-7X52EKMX.mjs +1 -0
  139. package/dist/plain-html-EF7MUNRZ.mjs +1 -0
  140. package/dist/plugin-astro.d.mts +5 -2
  141. package/dist/plugin-astro.mjs +1 -1
  142. package/dist/plugin-next.mjs +1 -1
  143. package/dist/plugin-nuxt.d.mts +4 -2
  144. package/dist/plugin-nuxt.mjs +1 -1
  145. package/dist/plugin-vite.d.mts +69 -9
  146. package/dist/plugin-vite.mjs +1 -1
  147. package/dist/qr-encoder.mjs +3 -0
  148. package/dist/server.d.mts +45 -20
  149. package/dist/server.mjs +1 -1
  150. package/dist/shared-page-GO76UP7I.mjs +1 -0
  151. package/dist/{subjects-DdavjSTL.d.mts → subjects-BQFCkehy.d.mts} +84 -1
  152. package/dist/taste-proposal-session-DBOUA54V.mjs +1 -0
  153. package/dist/toolbarFonts-GVPRHJGB.mjs +1 -0
  154. package/dist/{types-g9YCBx4Z.d.mts → types-CggBG-H6.d.mts} +1 -137
  155. package/dist/{video-adapter-DB6Hex1f.d.mts → video-adapter-C0kSwUir.d.mts} +2 -2
  156. package/dist/workspace-snapshot-6LN7U2NJ.mjs +1 -0
  157. package/package.json +45 -22
  158. package/samples/README.md +32 -0
  159. package/samples/build.d.mts +16 -0
  160. package/samples/build.mjs +138 -0
  161. package/dist/ExploreAttachment-H5WPEAZB.mjs +0 -1
  162. package/dist/PagePreviewLayer-WCYOBKAS.mjs +0 -1
  163. package/dist/ParticipantRuntime-HEC26AER.mjs +0 -1
  164. package/dist/PhoneHostGate-Q2AXVOSH.mjs +0 -1
  165. package/dist/PopmeltTasteConnectedPane-B7DHQKRQ.mjs +0 -1
  166. package/dist/PreviewRuntime-H2UOLP6T.mjs +0 -1
  167. package/dist/SuppliedContext-7ASO6GAW.mjs +0 -1
  168. package/dist/ThreadErrorCard-6R7W3RGZ.mjs +0 -1
  169. package/dist/ThreadPanel-3IS7GUYS.mjs +0 -1
  170. package/dist/bridgeSSEStream-K3UIMBTC.mjs +0 -1
  171. package/dist/bridgeWebSocketStream-2SUZUBE3.mjs +0 -1
  172. package/dist/browser-runtime-ILNTJLZ5.mjs +0 -1
  173. package/dist/canvas-chat-note-MGAEUYJO.mjs +0 -1
  174. package/dist/checkFixture-YE2ROOLL.mjs +0 -1
  175. package/dist/chunk-26P7UUHT.mjs +0 -1
  176. package/dist/chunk-2P2NUZW7.mjs +0 -1
  177. package/dist/chunk-3SEXH3AZ.mjs +0 -1
  178. package/dist/chunk-3XJEC6LS.mjs +0 -1
  179. package/dist/chunk-4LHTPRFY.mjs +0 -1
  180. package/dist/chunk-5D2ADU7H.mjs +0 -1
  181. package/dist/chunk-5K7SACPW.mjs +0 -1
  182. package/dist/chunk-67QNAAUC.mjs +0 -1
  183. package/dist/chunk-7CGKO4IU.mjs +0 -30
  184. package/dist/chunk-BACXPVHP.mjs +0 -1
  185. package/dist/chunk-DC47WNPG.mjs +0 -1
  186. package/dist/chunk-DJTGR3RO.mjs +0 -1
  187. package/dist/chunk-DLUNNAZC.mjs +0 -1
  188. package/dist/chunk-EX63NVDN.mjs +0 -1
  189. package/dist/chunk-FLTHWLRC.mjs +0 -1
  190. package/dist/chunk-G6RYESYI.mjs +0 -1
  191. package/dist/chunk-G7JR5Z3P.mjs +0 -1
  192. package/dist/chunk-GBVPRXA3.mjs +0 -1
  193. package/dist/chunk-HAE5LUJX.mjs +0 -1
  194. package/dist/chunk-HU2XWUJC.mjs +0 -1
  195. package/dist/chunk-HV7HRQ2S.mjs +0 -1
  196. package/dist/chunk-J4WDYITA.mjs +0 -1
  197. package/dist/chunk-L7QONR4K.mjs +0 -1
  198. package/dist/chunk-LVEMYZOA.mjs +0 -1
  199. package/dist/chunk-MSWXKP77.mjs +0 -1
  200. package/dist/chunk-NSCO633B.mjs +0 -1
  201. package/dist/chunk-NWE5PYKM.mjs +0 -1
  202. package/dist/chunk-O4HZP3RP.mjs +0 -1
  203. package/dist/chunk-OAHYSDJ4.mjs +0 -1
  204. package/dist/chunk-PNTM77NT.mjs +0 -1
  205. package/dist/chunk-RUTWU5W2.mjs +0 -1
  206. package/dist/chunk-TLREGQQB.mjs +0 -1
  207. package/dist/chunk-TUXBMJQZ.mjs +0 -1
  208. package/dist/chunk-V2I7PSJW.mjs +0 -1
  209. package/dist/chunk-WDAXARLI.mjs +0 -1
  210. package/dist/chunk-WHJEKDNP.mjs +0 -1
  211. package/dist/chunk-X2Q3H6X7.mjs +0 -1
  212. package/dist/chunk-XJQJQ5V5.mjs +0 -1
  213. package/dist/chunk-XT6PHPPG.mjs +0 -1
  214. package/dist/chunk-YD3PDEFX.mjs +0 -1
  215. package/dist/chunk-ZDXQ7WNW.mjs +0 -1
  216. package/dist/codex-note-context-YFURG7VL.mjs +0 -1
  217. package/dist/codex-project-3NSU5OWL.mjs +0 -1
  218. package/dist/codex-session-registry-ONODFWFD.mjs +0 -1
  219. package/dist/focus-inspection-SZJ5KP23.mjs +0 -1
  220. package/dist/peer-client-56EAHIGF.mjs +0 -1
  221. package/dist/taste-proposal-session-XU4N7RUV.mjs +0 -1
  222. package/dist/workspace-snapshot-RTTXNNUX.mjs +0 -1
package/README.md CHANGED
@@ -4,39 +4,122 @@
4
4
 
5
5
  # Popmelt
6
6
 
7
- Popmelt is a design layer for humans and AI. Point to an element in your local web app, describe a change, and work through it with your coding agent in a thread on the page.
7
+ Popmelt is a design layer for humans and AI. Click an element in your running app, show your coding agent what you want to change, and review the result on the page.
8
8
 
9
- ## Install and leave your first annotation
9
+ [Get started](#get-started) · [Features](#features) · [Keyboard and mouse shortcuts](#keyboard-and-mouse-shortcuts) · [Framework setup](https://popmelt.com/docs/core/getting-started)
10
10
 
11
- You'll need a local web project and Node.js 18 or newer (or the version your framework requires). Your coding agent can set up its CLI during installation.
11
+ ## Get started
12
12
 
13
- 1. Open your project in your coding agent and ask it to install Popmelt using the [setup guide for your framework](https://popmelt.com/docs/core/getting-started).
13
+ You'll need a local web project, a coding agent, and Node.js 18 or newer (or the version your framework requires).
14
14
 
15
- ```text
16
- Install @popmelt.com/core in this project. Set up the matching CLI for the agent I'm using in the environment that runs my dev server. If it's missing, install it using the vendor's setup instructions. If it needs sign-in, guide me through login and verify it afterward. Verify the Popmelt bridge and tell me which local URL to open.
17
- ```
15
+ 1. Ask your coding agent to set up `@popmelt.com/core` using the [guide for your framework](https://popmelt.com/docs/core/getting-started). Standard setups include Vite, Next.js, Astro, and Nuxt. For a plain HTML project, install the package and run `npx popmelt serve` in the site directory.
16
+ 2. Start your dev server. Open the local app URL in any browser on the computer running the dev server to use the same host session. For headless or forwarded sessions, use the private URL from `.popmelt/participant-host-link.json`. Guest access starts off.
17
+ 3. Double-tap **Command** on macOS or **Control** on Windows or Linux. Choose **Chat** (`C`), click a card, and type “Give this card more breathing room.”
18
+ 4. Click the **Send** arrow or press **Cmd/Ctrl + Enter**. Open the numbered badge to read your agent’s reply or ask for another adjustment.
18
19
 
19
- For agents handling setup, use the corresponding provider's installer if its CLI is missing from the dev server's PATH. Then check sign-in and guide the user through the provider's login flow if needed.
20
+ <details>
21
+ <summary>Copy a setup prompt for your agent</summary>
20
22
 
21
- | Desktop agent | CLI setup | Check sign-in | Sign in |
22
- | --- | --- | --- | --- |
23
- | Codex | [Codex CLI installation](https://github.com/openai/codex#installing-and-running-codex-cli) | `codex login status` | `codex login` |
24
- | Claude Code | [Claude Code installation](https://code.claude.com/docs/en/setup#installation) | `claude auth status` | `claude auth login` |
25
- | OpenCode 2 | [OpenCode CLI installation](https://opencode.ai/docs/) | `opencode models` | `opencode auth login` |
23
+ ```text
24
+ Install @popmelt.com/core in this project. For Git projects without existing ignore rules for .popmelt, add .popmelt/ to the project’s .gitignore. Set up a CLI that Popmelt supports in the environment that runs my dev server. Use my current agent’s CLI if supported. If it's missing, install it using the vendor's setup instructions. If it needs sign-in, guide me through login and verify it afterward. If the app uses React Three Fiber, check that each Canvas registers with PopmeltThreeAdapter from @popmelt.com/core/react-three-fiber or its hook, and verify a mesh can be annotated by name. Verify the Popmelt bridge and tell me which local URL to open.
25
+ ```
26
26
 
27
- 2. Start or restart your app with its usual development command and open its local URL.
28
- 3. Double-tap **Command** on macOS or **Control** on Windows or Linux to open the toolbar. Choose **Chat** (`C`), click a card, and type “Give this card more breathing room.”
29
- 4. Press **Cmd+Enter** or **Ctrl+Enter** to send the annotation. Review the change on the page and reply in the same thread.
27
+ | Desktop agent | CLI setup | Check sign-in | Sign in |
28
+ | --- | --- | --- | --- |
29
+ | Codex | [Codex CLI installation](https://github.com/openai/codex#installing-and-running-codex-cli) | `codex login status` | `codex login` |
30
+ | Claude Code | [Claude Code installation](https://code.claude.com/docs/en/setup#installation) | `claude auth status` | `claude auth login` |
31
+ | Grok Code (Cursor) | [Cursor CLI installation](https://cursor.com/docs/cli/installation) | `cursor-agent status` | `cursor-agent login` |
32
+ | OpenCode 2 | [OpenCode CLI installation](https://opencode.ai/docs/) | `opencode models` | `opencode auth login` |
30
33
 
31
- Threads and screenshots are saved in your project under `.popmelt/`. When you send an annotation, the relevant context goes to your selected AI provider.
34
+ For Grok Code (Cursor), choose a model in Popmelt’s model picker. The list comes from your installed Cursor CLI. Choose **Cursor default** to use the CLI’s configured model.
32
35
 
33
- ## Docs
36
+ </details>
34
37
 
35
- - [Annotate elements and work in threads](https://popmelt.com/docs/core/comments-and-threads)
36
- - [Preview style changes with Steer](https://popmelt.com/docs/core/steer)
37
- - [Review project memory with Imprint](https://popmelt.com/docs/core/imprint)
38
- - [Attach application context to annotations](https://popmelt.com/docs/core/application-context)
39
- - [Annotate Three.js scenes](https://popmelt.com/docs/core/media-and-3d)
38
+ ### Point at objects in React Three Fiber
39
+
40
+ The toolbar can identify individual meshes once the scene registers with Popmelt. When you add an R3F scene to an existing project, keep the app’s `PopmeltProvider` above the `Canvas` in the React tree and mount `PopmeltThreeAdapter` inside the canvas. Reuse an existing adapter component or `usePopmeltThreeAdapter` registration if the scene already has one. If the toolbar currently lives in a separate React root created by `mountPopmelt()`, move that integration into the app tree so the scene and toolbar share one provider.
41
+
42
+ ```tsx
43
+ import { Canvas } from '@react-three/fiber';
44
+ import { PopmeltProvider } from '@popmelt.com/core';
45
+ import { PopmeltThreeAdapter } from '@popmelt.com/core/react-three-fiber';
46
+
47
+ export function App() {
48
+ return (
49
+ <PopmeltProvider>
50
+ <Canvas style={{ height: '100dvh' }}>
51
+ <PopmeltThreeAdapter />
52
+ <mesh name="Beacon" userData={{ popmeltId: 'beacon' }}>
53
+ <boxGeometry />
54
+ <meshBasicMaterial color="gold" />
55
+ </mesh>
56
+ </Canvas>
57
+ </PopmeltProvider>
58
+ );
59
+ }
60
+ ```
61
+
62
+ Open the toolbar in Chat mode, hover the box, then click it. The annotation should identify **Beacon**. The mesh’s `name` supplies its label, and `userData.popmeltId` lets the annotation find it again if the scene hierarchy changes. For multiple canvases on the same page, give each adapter a distinct, stable `id`.
63
+
64
+ ## Features
65
+
66
+ | Feature | What you can do |
67
+ | --- | --- |
68
+ | [Annotations and threads](https://popmelt.com/docs/core/comments-and-threads) | Pin a question to an element, paste a reference image, or double-click text to draft a replacement. Follow up on the same badge or find the conversation in History. |
69
+ | [Steer](https://popmelt.com/docs/core/steer) | Try padding, gap, color, type, and other CSS values on the live element. Send the changes together when the preview looks right. |
70
+ | [Explore](https://popmelt.com/docs/core/explore) | Type `/explore` in a single-element annotation or thread to ask for alternatives. Compare them with the original on the page, refine one, and send it for implementation. |
71
+ | [Pair and Share](https://popmelt.com/docs/core/multiplayer) | Pair your own phone for host access, or turn on **Allow collaborators?** to invite a guest by QR code or link. Choose **Local** for the same network or **Remote** for a Cloudflare Tunnel. Projects start private. |
72
+ | [Multiplayer](https://popmelt.com/docs/core/multiplayer) | In a shared Git project, everyone gets their own version of the app, called a plane. Select anyone’s avatar to see their latest code and drafts update live. |
73
+ | [Sampling](#sampling) | Shift-click an element to copy it with its children. On your plane, click where to place the copy. From a teammate’s plane, the sample goes to the matching target on yours if there is one, or you choose where to place it. |
74
+ | [Media and 3D](https://popmelt.com/docs/core/media-and-3d) | Mark a region on an image or paused video. Connect a Three.js scene adapter to attach feedback to a moving object. |
75
+ | [Imprint](https://popmelt.com/docs/core/imprint) | Review what your agent has learned about the project, inspect its evidence, and confirm or correct its understanding. |
76
+ | [Custom context](https://popmelt.com/docs/core/application-context) | Attach app-specific state to an annotation so your agent knows what you were looking at when you left it. |
77
+
78
+ ## Keyboard and mouse shortcuts
79
+
80
+ **Mod** means **Command** on macOS and **Control** on Windows or Linux. Tool keys work with the toolbar open and focus outside a text field.
81
+
82
+ ### Toolbar and annotations
83
+
84
+ | Gesture | Action |
85
+ | --- | --- |
86
+ | Double-tap `Mod` | Open or collapse the toolbar. |
87
+ | `C` / `S` / `I` | Switch to Chat, Steer, or Imprint. |
88
+ | Click an element in Chat | Start an annotation. Double-click its text to edit the wording directly. |
89
+ | `Enter` / `Shift + Enter` | In a new annotation, finish the draft or add a line. In an existing thread, Enter sends a reply. |
90
+ | `Mod + Enter` | Send the annotation or staged changes to your agent. |
91
+ | `Mod + Z` / `Mod + Shift + Z` | Undo or redo a draft change. |
92
+ | Right-click a draft badge | Remove that draft item. |
93
+ | `Option` / `Alt` + drag | In Chat, mark a named region on an image or paused video. |
94
+
95
+ ### Steer
96
+
97
+ | Gesture | Action |
98
+ | --- | --- |
99
+ | `Space` | Search the dial for a property or value. |
100
+ | `Q` / `E` | Move between properties in the dial. |
101
+ | `←` / `→` or `A` / `D` | Preview the previous or next value. |
102
+ | `Enter` / `Esc` | Go deeper or stage the selected value with Enter. Go back one level with Esc. |
103
+
104
+ ### Multiplayer
105
+
106
+ | Gesture | Action |
107
+ | --- | --- |
108
+ | `Mod + ←` / `Mod + →` | Cycle through participants’ planes. |
109
+
110
+ ### Sampling
111
+
112
+ | Gesture | Action |
113
+ | --- | --- |
114
+ | Hold `Shift` over an element | Isolate the target and see whether it can be sampled. |
115
+ | `Shift` + click on your plane | Sample the element, then click where you want the copy. |
116
+ | `Shift` + click on a peer’s plane | Bring the element and its children to the matching target on your plane. If there’s no clear match, click where to place it. |
117
+ | `Mod + Shift` + click on a peer’s plane | Choose the destination yourself, even when a match exists. |
118
+ | `Esc` during placement | Cancel placement. |
119
+
120
+ In Three.js and React Three Fiber, registering the pointing adapter also enables sampling of meshes and groups. Drop on a visible surface or in empty space at the source depth. Copies replay from the corresponding source object on the receiving plane. For app-driven animation or interactions, `sampling.duplicate(source)` can return a fresh detached `{ object, dispose }`. Return `undefined` to use the default clone. For custom snapping, `sampling.position(source, hit, ray)` returns a world-space origin. An existing `sampleCanvas` codec takes precedence.
121
+
122
+ Threads and screenshots are stored locally under `.popmelt/`. The bridge creates `.popmelt/.gitignore` on first startup. When you send an annotation, the relevant context goes to your selected AI provider. [Data and privacy](https://popmelt.com/docs/core/data-and-privacy)
40
123
 
41
124
  ## License
42
125
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "popmelt-core",
3
- "version": "0.36.0",
3
+ "version": "0.37.1",
4
4
  "description": "Local Popmelt context, canvas tools, and ambient turn capture for Claude Code.",
5
5
  "author": {
6
6
  "name": "Popmelt",
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: popmelt-core
3
- description: Use Popmelt Core when the user asks to inspect project memory, expand relevant product context, review a surfaced decision candidate, ground a surfaced Imprint explanation, or discuss the current Popmelt thread.
3
+ description: Use Popmelt Core to inspect project memory, expand relevant product context, review a surfaced decision candidate, ground a surfaced Imprint explanation, discuss the current Popmelt thread, or set up object pointing when creating or editing a React Three Fiber scene in a Popmelt app.
4
4
  ---
5
5
 
6
6
  # Popmelt Core
@@ -12,6 +12,7 @@ Use the tools deliberately:
12
12
  - Pass the exact `tool session` ID supplied by the Ambient Popmelt Core context as `sessionId` on every tool call. This routes the call to the correct project even when the MCP process has a different working directory.
13
13
 
14
14
  - Use `popmelt_orient_stores` only after the human explicitly chooses the writable primary store and any mounted read stores from an ambient orientation packet. Save that choice as the workspace default unless the human explicitly requests a session-only override. Store proximity, nesting, size, or recency never implies that choice.
15
+ - In a Codex chat, use `popmelt codex mount-store <directory>` when the human asks to attach another workspace store. The mount is read-only and applies to that chat.
15
16
  - Use `popmelt_expand_context` when the automatically supplied packet is truncated or the user explicitly asks for broader history.
16
17
  - Pass the current ambient `threadId` and `jobId` when expanding context. Only a `registered` assessmentContext receipt makes fetched Imprint references available to that turn’s assessment.
17
18
  - Use `popmelt_inspect_thread` when the user asks to inspect the paired thread or its evidence.
@@ -23,6 +24,10 @@ Accepted product decisions are authoritative within scope. Imprint explanations
23
24
 
24
25
  If Popmelt reports `already_managed_by_bridge`, stop calling Popmelt Core tools for that run; the toolbar bridge owns the turn lifecycle.
25
26
 
27
+ ## React Three Fiber scenes
28
+
29
+ For a new or existing R3F scene, keep the app’s `PopmeltProvider` above the R3F `Canvas`. Inside each canvas, mount `<PopmeltThreeAdapter />` from `@popmelt.com/core/react-three-fiber` unless a scene child already registers it with the component or `usePopmeltThreeAdapter`. Give separate canvases distinct adapter `id` props. A meaningful mesh `name` supplies the label, and a stable `userData.popmeltId` preserves identity across hierarchy changes. In Popmelt Chat, click a named mesh and check that the annotation identifies it.
30
+
26
31
  ## Canvas chat notes
27
32
 
28
33
  New local Codex and Claude chats get Popmelt Edit access on first participation. Existing project restrictions still apply. When a local desktop chat posts to a canvas thread, Popmelt automatically addresses @Claude or @Codex replies to the most recent participating chat from that app in that thread. To receive the first note before posting, register this thread from the intended chat using `popmelt codex link-thread <canvas-thread-id>` or the Claude tool `popmelt_link_canvas_chat`. Both paths work without a host confirmation.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "popmelt-core",
3
- "version": "0.36.0",
3
+ "version": "0.37.1",
4
4
  "description": "Point out what you mean, talk through changes, and keep your AI on the same page.",
5
5
  "author": {
6
6
  "name": "Popmelt",
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: popmelt-core
3
- description: Use Popmelt Core when the user asks to inspect project memory, expand relevant product context, review a surfaced decision candidate, ground a surfaced Imprint explanation, or discuss the current Popmelt thread.
3
+ description: Use Popmelt Core to inspect project memory, expand relevant product context, review a surfaced decision candidate, ground a surfaced Imprint explanation, discuss the current Popmelt thread, or set up object pointing when creating or editing a React Three Fiber scene in a Popmelt app.
4
4
  ---
5
5
 
6
6
  # Popmelt Core
@@ -12,6 +12,7 @@ Use the tools deliberately:
12
12
  - Pass the exact `tool session` ID supplied by the Ambient Popmelt Core context as `sessionId` on every tool call. This routes the call to the correct project even when the MCP process has a different working directory.
13
13
 
14
14
  - Use `popmelt_orient_stores` only after the human explicitly chooses the writable primary store and any mounted read stores from an ambient orientation packet. Save that choice as the workspace default unless the human explicitly requests a session-only override. Store proximity, nesting, size, or recency never implies that choice.
15
+ - In a Codex chat, use `popmelt codex mount-store <directory>` when the human asks to attach another workspace store. The mount is read-only and applies to that chat.
15
16
  - Use `popmelt_expand_context` when the automatically supplied packet is truncated or the user explicitly asks for broader history.
16
17
  - Pass the current ambient `threadId` and `jobId` when expanding context. Only a `registered` assessmentContext receipt makes fetched Imprint references available to that turn’s assessment.
17
18
  - Use `popmelt_inspect_thread` when the user asks to inspect the paired thread or its evidence.
@@ -23,6 +24,10 @@ Accepted product decisions are authoritative within scope. Imprint explanations
23
24
 
24
25
  If Popmelt reports `already_managed_by_bridge`, stop calling Popmelt Core tools for that run; the toolbar bridge owns the turn lifecycle.
25
26
 
27
+ ## React Three Fiber scenes
28
+
29
+ For a new or existing R3F scene, keep the app’s `PopmeltProvider` above the R3F `Canvas`. Inside each canvas, mount `<PopmeltThreeAdapter />` from `@popmelt.com/core/react-three-fiber` unless a scene child already registers it with the component or `usePopmeltThreeAdapter`. Give separate canvases distinct adapter `id` props. A meaningful mesh `name` supplies the label, and a stable `userData.popmeltId` preserves identity across hierarchy changes. In Popmelt Chat, click a named mesh and check that the annotation identifies it.
30
+
26
31
  ## Canvas chat notes
27
32
 
28
33
  New local Codex and Claude chats get Popmelt Edit access on first participation. Existing project restrictions still apply. When a local desktop chat posts to a canvas thread, Popmelt automatically addresses @Claude or @Codex replies to the most recent participating chat from that app in that thread. To receive the first note before posting, register this thread from the intended chat using `popmelt codex link-thread <canvas-thread-id>` or the Claude tool `popmelt_link_canvas_chat`. Both paths work without a host confirmation.
@@ -0,0 +1 @@
1
+ "use client";import{d as e}from"./chunk-OZBMHEOD.mjs";import{g as t,f as n,b as r}from"./chunk-ZSL57PQ7.mjs";import{a as o,b as a,c as i}from"./chunk-EUFR7R5Q.mjs";import{c as s,f as l,d as p,e as d,a as c,b as u}from"./chunk-WF3YGZPI.mjs";import{a as h}from"./chunk-OIKFQ2FV.mjs";import{c as m,a as g,b as f}from"./chunk-ELKVFX2O.mjs";import{n as v,m as b,k as x,b as y,c as w,l as k,j as C,i as I}from"./chunk-PWQB3FIW.mjs";import"./chunk-Q6N77LIS.mjs";import{c as S}from"./chunk-ZVDKW7TO.mjs";import"./chunk-FHCKFQBY.mjs";import"./chunk-APP5IYTE.mjs";import{a as E}from"./chunk-G2ZHJXHZ.mjs";import"./chunk-TMSGNHXH.mjs";import"./chunk-53SKVMWR.mjs";import"./chunk-RK6UROPO.mjs";import{l as P}from"./chunk-5IZHN3A7.mjs";import"./chunk-AOTDTBQO.mjs";import{h as O}from"./chunk-W2QQVB2H.mjs";import"./chunk-WP2SHSCG.mjs";import{v as T}from"./chunk-LH7HKUCK.mjs";import{a as N}from"./chunk-Q6C7ZA3H.mjs";import{b as j}from"./chunk-CK3CDA3L.mjs";import"./chunk-NI77Y3WC.mjs";import{b as M}from"./chunk-FON4QY7P.mjs";import{D as A,N as R,aa as z,Z as B,s as L,_ as H,F as J,G as V}from"./chunk-OA63PYHZ.mjs";import{a as W,c as D}from"./chunk-ECMLCGAM.mjs";import"./chunk-AGCS65LT.mjs";import"./chunk-SUAHDXJZ.mjs";import{useContext as F,useState as K,useRef as Y,useLayoutEffect as q,useMemo as Q,useEffect as U,useCallback as X}from"react";import{createPortal as Z}from"react-dom";import{jsxs as G,Fragment as $,jsx as _}from"react/jsx-runtime";import{createContext as ee,domToCanvas as te,destroyContext as ne}from"modern-screenshot";function re(e,t,n,r=!1){let[o,a]=K({}),i=n?.backdrop,s=n?.style.color;return q(()=>{if(location.pathname!==e.pathname||r&&i)return void a({background:i,ink:s});let n="component"===t?y(e):void 0,o=n?.component??n?.element??T(e.selector,e.element);if(!o)return void a({background:i,ink:s});let l=o.ownerDocument.defaultView,p=()=>{let e=f(o)??i,t=l.getComputedStyle(o).color;a(n=>n.background===e&&n.ink===t?n:{background:e,ink:t})};p();let d=new MutationObserver(p),c=[o,...g(o)],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]),o}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 ${W};\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 ae({anchor:e,surfaceStyle:t,children:n}){let{visible:r}=F(c),o=Y(null),[a,i]=K(null);return q(()=>{i(e.current?.closest("[data-popmelt-root]")??document.body)},[e]),q(()=>{if(r&&a)return function(e){let t=e.createElement("style");return t.textContent=":root, body { overflow: hidden !important; overscroll-behavior: none !important; }",e.head.append(t),()=>t.remove()}(a.ownerDocument)},[a,r]),q(()=>{let t=o.current,n=e.current?.closest('[data-devtools="thread-panel"]');if(!t||!n||!r)return;n.dataset.popmeltExploreCanvas="left";let i=a?.querySelector("[data-popmelt-toolbar-layer]"),s=i?.querySelector("#devtools-toolbar"),l=()=>{let e=n.getBoundingClientRect();if(i&&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;i.inert=N(window.innerWidth)||n}let r=t.getBoundingClientRect(),o=e.left-r.left>=r.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-r.left)}px`),t.style.setProperty("--sp-work-right",o?`${Math.max(0,r.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),()=>{i&&(i.inert=!1),delete n.dataset.popmeltExploreCanvas,p.disconnect(),d.disconnect(),window.removeEventListener("resize",l)}},[e,a,r]),a?Z(_("div",{hidden:!r,ref:o,className:"sp-workspace","data-popmelt-font":"sans",style:{...t,zIndex:10003},children:n}),a):null}function ie({tag:e,framing:t}){let n=Y(null);return _("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 o=e.clientX-r.x,a=e.clientY-r.y;if(!r.dragged&&Math.hypot(o,a)<=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+o/i,l.y+a/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 o=t.currentTarget.parentElement?.querySelector(".sp-fit");if(!o)return;let a=O(t.clientX,t.clientY,{within:o})?.closest("[data-scratch-part]");a&&e(a.getAttribute("data-scratch-part"),I(a))}})}function se({capture:e,framing:t}){let n=Y(null),[r,o]=K(1);return q(()=>{let r=n.current,a=()=>{let n=Math.max(.01,Math.min(1,(r.clientWidth-36)/e.width,(r.clientHeight-36)/e.height));o(n),t.setFitScale(n)};a();let i=new ResizeObserver(a);return i.observe(r),()=>i.disconnect()},[e,t]),_("div",{className:"sp-steer-frame",ref:n,children:_(i,{interactive:!0,framing:t,overlay:_(ie,{framing:t}),children:_("div",{style:{display:"grid",placeItems:"center",width:"100%",height:"100%"},children:_("img",{alt:"Original at exploration time",src:e.still,draggable:!1,style:{width:e.width*r,height:e.height*r,maxWidth:"none"}})})})})}function le({original:e,bundles:t,target:n,theme:r,accent:o,framing:a,onEscape:i}){let[s,l]=K(!1),{capture:p,runnable:c}=e,u=c&&t?.[c.fixture.bundle];return c&&!s&&"string"!=typeof u?u?_(d,{bundle:u,target:n,readOnly:!0,capture:p,theme:r,accent:o,framing:a,initial:[],onError:()=>l(!0),onEscape:i}):_("div",{className:"sp-steer-frame",role:"status",children:"Loading original…"}):p?.still?_(se,{capture:p,framing:a}):_("div",{className:"sp-steer-frame",role:"status",children:"Original unavailable for this round."})}function pe({frameUrl:e,theme:t,...n}){let[r,o]=K(null);return q(()=>{r&&t&&(r.documentElement.style.colorScheme=t)},[r,t]),q(()=>{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(),o=e.offsetWidth,a=e.offsetHeight;if(!o||!a||!r.width)throw Error("The option is not ready to capture.");let i=r.width/o,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(o,(Math.max(r.left,...s.map(e=>e.right))-r.left)/i+12),u=Math.min(a,(Math.max(r.top,...s.map(e=>e.bottom))-r.top)/i+12),h=await ee(e,{width:o,height:a,scale:Math.min(2,1600/Math.max(o,a)),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 te(h)}finally{ne(h)}let m=n.createElement("canvas"),g=l.width/o;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]),G($,{children:[_("iframe",{className:"sp-steer-frame",style:{colorScheme:t},"aria-label":"Edit or comment on this option",src:e,srcDoc:e?void 0:h,onLoad:e=>{let t=e.currentTarget.contentDocument;t&&D(t),o(t)}}),r&&_(de,{doc:r,...n},n.editorKey)]})}function de({doc:e,...t}){let{toggle:n}=F(c),r=Y(t),o=Y(t);o.current=t;let a=Y(void 0);q(()=>{let t=e.defaultView;if(!t)return;let{node:i,initial:s,target:l,accentColor:p,framing:d}=r.current,c=!0,u=s;a.current=t.startScratchSteer?.(i,l,p,d,e=>{if(!c)return;let t=C(s,e);JSON.stringify(t)!==JSON.stringify(u)&&(u=t,o.current.onChange(t))},e=>{c&&o.current.onTag(e)},e=>{c&&o.current.onPreview(e)},n);let h=e=>{"Escape"!==e.key||!o.current.onEscapeWorkspace||e.target?.closest?.('input, textarea, [contenteditable="true"]')||(e.preventDefault(),e.stopImmediatePropagation(),o.current.onEscapeWorkspace())};return t.addEventListener("keydown",h,!0),()=>{c=!1,a.current=void 0,o.current.onPreview(null),t.removeEventListener("keydown",h,!0)}},[e,n]);let i=S(),[s,l]=K();q(()=>{let t=e.defaultView?.frameElement;if(t instanceof HTMLIFrameElement)return u(t,l,()=>{e.documentElement.setAttribute("data-preview-control-hovered","")})},[e]);let{selectedPart:p,hoveredPart:d,focusRequest:h}=t;return q(()=>{a.current?.({feedbackOnly:i,selectedPart:p,hoveredPart:d,focusRequest:h,controlBounds:s})},[e,n,p,d,h,s,i]),null}function ce(e){!e||e.getRootNode().activeElement?.closest("[data-popmelt-thread-composer]")||e.querySelector("[data-expand-option]")?.focus({preventScroll:!0})}function ue({batch:t,frameUrl:n,bundles:r,canApply:i=!0,frozenVersion:s,framing:l,theme:d,accentColor:c,selection:u,preview:h,setTag:g,onTogglePreview:f,onBrowse:v,edits:b,revisions:x,index:y,hoveredTarget:w,focusRequest:k,onPreviewStyle:C,onFixtureCanvas:I,onSteer:S,onApply:E,busy:O,expanded:T,onExpand:N}){let M=Y(null),[H,J]=K(""),[V,W]=K(!1),D=Y(null),F=Y(null),Q=X(e=>{F.current=e,ce(e)},[]),U=Y(T);q(()=>{U.current&&!T&&ce(D.current),U.current=T},[T]),q(()=>{if(k?.batchId!==t.id||k.option!==y)return;let e=T?F.current:D.current,n=e?.closest('[data-devtools="thread-panel-messages"]');if(!e||!n)return;let r=e.getBoundingClientRect(),o=n.getBoundingClientRect();r.top>=o.top&&r.bottom<=o.bottom||n.scrollBy({top:r.top-o.top-Math.max(0,(n.clientHeight-r.height)/2),behavior:window.matchMedia("(prefers-reduced-motion: reduce)").matches?"instant":"smooth"})},[t.id,y,k,T]);let Z=JSON.stringify([t.id,y,s??x?.[y]??0]),[ee]=K(()=>l??o(null)),te=t.options.length,ne=-1===y?t.original:void 0,ie=t.options[Math.max(0,y)],{background:se,ink:de}=re(t.target,ne?.capture?.scope??("fixture"in ie?ie.previewScope:void 0),t.original?.capture,!!ne),ue=se?m(se):void 0,me=ue?.theme??d,ge={"--sp-page-background":se,"--sp-accent":c,"--sp-page-dot":ue?.dot,backgroundImage:ne?"none":void 0},fe={batchId:t.id,option:y,path:[]},ve=h?.showVariant&&h.target.batchId===t.id&&h.target.option===y;let be="fixture"in ie?r?.[ie.fixture.bundle]:void 0,xe=_(he,{title:ne?"Original":ie.title,index:ne?-1:y,hasOriginal:!!t.original,optionCount:te,accentColor:c,canTag:i,onTag:()=>g(fe),browseBy:function(e){let n=t.original?-1:0,r=te-n,o=n+(y-n+e+r)%r;J(""),v({...fe,option:o})}}),ye=G("div",{className:"sp-stage",style:{cursor:P(c)},children:[_("div",{className:"sp-zoom-actions",children:_(a,{framing:ee})}),G("div",{className:"sp-actions","data-preview-active":!!h,children:[!ne&&ve&&i&&_(j,{type:"button","aria-label":"Apply this option in code",disabled:O||V,onClick:async()=>{J(""),W(!0);try{if(!M.current)throw Error("The option is still loading. Try again in a moment.");let e=await M.current();await E(fe,e)}catch(e){J(e instanceof Error?e.message:"Could not apply this option.")}finally{W(!1)}},children:_(A,{})}),!s&&(!ne||!!h)&&_(j,{type:"button","aria-pressed":!!h,hint:!T&&h?"Turn off page preview":"Preview on page","aria-label":"Preview on page",disabled:"fixture"in ie&&(!be||"string"==typeof be),onClick:()=>f(fe),children:_(R,{})}),_(j,{type:"button","data-expand-option":"","aria-label":T?"Collapse preview":"Expand preview","aria-expanded":T,onClick:()=>N(!T),children:_(T?z:B,{})})]}),ne?_(le,{original:ne,target:t.target,bundles:r,framing:ee,theme:me,accent:c,onEscape:T?()=>N(!1):void 0}):"fixture"in ie?_(p,{captureRef:M,captureBackground:se??void 0,frameKey:Z,frozenParent:!!s,readOnly:!!s,capture:s?t.original?.capture:void 0,bundle:be,previewScope:ie.previewScope,target:t.target,pageInk:se?de:void 0,framing:ee,theme:me,accent:c,initial:b.filter(e=>e.batchId===t.id&&e.option===y),onCanvas:e=>I?.(ie.fixture.bundle,e),onEscape:T?()=>N(!1):void 0,selected:u?.batchId===t.id&&u.option===y?u.fixturePart:void 0,onTag:(e,t)=>g({...fe,fixturePart:e,fixturePartLabel:t}),onChange:e=>S(y,e),onPreview:e=>C(y,e)}):_(pe,{captureRef:M,captureBackground:se??void 0,editorKey:Z,readOnly:!!s,framing:ee,onEscapeWorkspace:T?()=>N(!1):void 0,frameUrl:n,target:t.target,node:ie.root,theme:me,accentColor:c,initial:b.filter(e=>e.batchId===t.id&&e.option===y),onPreview:e=>C(y,e),hoveredPart:w?.batchId===t.id&&w.option===y?w.part:void 0,focusRequest:k?.batchId===t.id&&k.option===y?k:void 0,selectedPart:u?.batchId===t.id&&u.option===y?u.path.join(".")+(u.field?"/label":""):void 0,onChange:e=>S(y,e),onTag:e=>{let[t,n]=e.split("/");g({...fe,path:t?t.split(".").map(Number):[],field:"label"===n?"label":void 0})}}),H&&_("span",{role:"alert",children:H}),xe]});return G($,{children:[G("section",{ref:D,"data-explore-batch":t.id,"aria-label":"Explore options",className:"sp-card",style:ge,"data-popmelt-tooltip-group":"",children:[_("style",{children:oe}),T?G("div",{className:"sp-stage sp-expanded-placeholder",children:[G(j,{type:"button",className:"sp-expanded-badge",hint:"Collapse preview","aria-label":"Preview expanded. Collapse preview","aria-expanded":!0,onClick:()=>N(!1),children:[_(L,{"aria-hidden":"true"}),"Preview expanded"]}),xe]}):ye]}),!ne&&"fixture"in ie&&ie.rationale&&_(e,{text:ie.rationale}),T&&_(ae,{anchor:D,surfaceStyle:ge,children:_("section",{ref:Q,"aria-label":"Expanded explore options",className:"sp-card","data-popmelt-tooltip-group":"","data-popmelt-tooltip-boundary":!0,children:ye})})]})}function he({title:e,index:t,optionCount:n,hasOriginal:r,accentColor:o,onTag:a,canTag:i,browseBy:s}){let l=Y(null),p=Y(null);return G("footer",{children:[t<0?_("span",{className:"tag-option",children:_("span",{children:e})}):G(j,{above:!0,className:"tag-option",disabled:!i,hint:"Add to chat",anchorRef:l,"aria-label":`Add ${e} to chat`,onClick:a,children:[_("span",{children:e}),_(H,{ref:l,"aria-hidden":"true",color:o})]}),(r||n>1)&&G("div",{className:"pager",onTouchStart:e=>{let t=e.touches[0];p.current=1===e.touches.length?{id:t.identifier,x:t.clientX,y:t.clientY}:null},onTouchCancel:()=>{p.current=null},onTouchEnd:e=>{let t=p.current;p.current=null;let n=e.changedTouches[0];if(!t||!n||n.identifier!==t.id||e.touches.length)return;let r=n.clientX-t.x,o=n.clientY-t.y;Math.abs(r)<24||Math.abs(r)<1.3*Math.abs(o)||(e.preventDefault(),s(r>0?1:-1))},children:[_("button",{type:"button","aria-label":"Previous option",onClick:()=>s(-1),children:_(J,{})}),G("span",{"aria-live":"polite",children:[_("span",{className:"pager-number",children:t+1})," of"," ",_("span",{className:"pager-number",children:n})]}),_("button",{type:"button","aria-label":"Next option",onClick:()=>s(1),children:_(V,{})})]})]})}function me(e,t,n){return`popmelt-explore-draft:${e}:${t}:${n}`}function ge(e,t,n,r,o){try{let a=me(e,t,n);void 0!==o?window.localStorage.setItem(a,JSON.stringify({revision:o,edits:r})):r.length?window.localStorage.setItem(a,JSON.stringify(r)):window.localStorage.removeItem(a)}catch{}}function fe(e,t,n,r){try{let o=me(e,t,n),a=window.localStorage.getItem(o);if(!a)return;let i=JSON.parse(a),s=Array.isArray(i)?{revision:0,edits:i}:i;s.revision===r.revision&&JSON.stringify(s.edits.map(k))===JSON.stringify(r.edits)&&window.localStorage.removeItem(o)}catch{}}var ve={edits:[]};function be(e,t,n,r,o){let[a]=K(()=>function(e,t){let n={};return t.options.forEach((r,o)=>{try{let r=window.localStorage.getItem(me(e,t.id,o));if(!r)return;let a=JSON.parse(r),{revision:i,edits:s}=Array.isArray(a)?{revision:0,edits:a}:a;if(!Number.isSafeInteger(i)||i<0||!Array.isArray(s))return;let l=s.map(k);if(l.some(e=>e.batchId!==t.id||e.option!==o))return;b({messages:[{batch:t}]},x(l)),n[o]={revision:i,edits:l}}catch{}}),n}(e,t)),[i,s]=K(()=>({...n,...a})),l=Y(i),p=Y({...n}),d=Y({...a}),c=Y(new Set),u=Y(new Map),[h,m]=K({}),[g,f]=K(""),v=o&&void 0!==n;function y(e,t,n){let r=l.current[e]??ve;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 w(n){if(v&&!c.current.has(n)){c.current.add(n);try{for(;d.current[n];){let o=d.current[n],a=await M(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({batchId:t.id,option:n,...o})});if(!a.ok&&409!==a.status)throw Error();let{draft:i}=await a.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===a.status||s===o?(delete d.current[n],fe(e,t.id,n,s),y(n,p.current[n],!0),f(409===a.status?"This option changed on another device. Its latest saved edits are shown.":"")):(s.revision=i.revision,ge(e,t.id,n,s.edits,s.revision))}}catch{f("Couldn’t sync option edits to this project.")}finally{c.current.delete(n)}}}let C=()=>Object.keys(d.current).forEach(e=>{w(Number(e))}),I=Y(C);return q(()=>{I.current=C}),q(()=>{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]||y(n,t,!0))}},[n]),U(()=>{if(!v)return;let e=()=>I.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:Q(()=>Object.values(i).flatMap(e=>e.edits),[i]),save:function(n,r){let o=d.current[n]?.revision??p.current[n]?.revision??0,a={revision:o,edits:r.map(k)};JSON.stringify(l.current[n]?.edits??[])!==JSON.stringify(a.edits)&&(d.current[n]=a,ge(e,t.id,n,a.edits,o),y(n,a,!1),v&&(clearTimeout(u.current.get(n)),u.current.set(n,setTimeout(()=>{u.current.delete(n),w(n)},220))))},revisions:h,failure:g,retry:C,unsynced:!!Object.keys(d.current).length}}function xe({batch:e,draftScope:a,threadId:i,sharedDrafts:p,bridgeUrl:d,theme:c,accentColor:u,active:h,hidden:m,revealOnPage:g,activate:f,expanded:k,onExpand:C,canReply:I,submit:S,selection:P,onAttach:O,focusRequest:T,workspaceRef:N,followSource:j}){let M=s(d,v(e)),A=F(E),R=A?.preview?.batchId===e.id&&A.preview.threadId===i?A.preview:null,z=A?!!R?.enabled:h,[B,L]=K(()=>R?.index??0),H=Y(null);q(()=>{H.current!==T&&(H.current=T,T&&T.batchId===e.id&&e.options[T.option]&&L(T.option))},[T,e.id,e.options]);let J=Q(()=>T?{...T,part:""}:null,[T]),V=be(a,e,p,d+"/thread/"+encodeURIComponent(i)+"/explore-draft",I),[W,D]=K(),U=T!==W&&T?.option===B?T.snapshot:void 0,X=U?.edits??V.edits,[Z]=K(()=>o(null)),ee=Q(()=>k&&!m&&!U&&B>=0?{batchId:e.id,option:B}:null,[k,m,U,e.id,B]),[te,ne]=K(R?.targets??null),[re,oe]=K(()=>R&&"fixture"in R.option?{[R.option.fixture.bundle]:R.hasCanvas}:{}),[ae,ie]=K(""),[se,le]=K(null),pe=Q(()=>b({messages:[{batch:e}]},x(X)).messages[0].batch,[e,X]);q(()=>{if(!ee)return;let e={source:ee,framing:Z,reference:()=>n(pe,{...ee,path:[]},X)};return N.current=e,()=>{N.current===e&&(N.current=null)}},[N,ee,Z,pe,X]),q(()=>{let t=N.current;if(!t||t.source!==j)return;let n=e.options.findIndex((n,r)=>{let o=e.parents?.[r];return o?.batchId===t.source.batchId&&o.option===t.source.option&&(!("fixture"in n)||"object"==typeof M[n.fixture.bundle])});n<0||(Z.restore(t.framing.snapshot()),L(n),C(!0))},[e,M,j,Z,C,N]);let de=pe.options[Math.max(0,B)],ce=e=>"fixture"in de?w(e,de.previewScope,!!re[de.fixture.bundle]):e.element,he=B>=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?M[de.fixture.bundle]??(R&&"fixture"in R.option&&R.option.fixture.bundle===de.fixture.bundle?R.bundle:void 0):void 0,fe=Q(()=>{let t=x(X)[e.id]?.[B]??{},n={...t};if(se?.option===B)for(let[e,r]of Object.entries(se.parts))n[e]={...t[e],...r};return n},[X,e.id,B,se]),ve="fixture"in de&&!!re[de.fixture.bundle],xe=Q(()=>te?{threadId:i,batchId:e.id,index:B,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,B,de,te,ve,ge,fe,c,u,g]),ye=!!R,we=A?.setPreview;q(()=>{U||!ye||!xe||!we||we(t=>t?.batchId===e.id&&t.threadId===i?{...xe,enabled:t.enabled,suspended:t.suspended}:t)},[U,ye,xe,we,e.id,i]);let ke=()=>{we?.(t=>t?.batchId===e.id&&t.threadId===i?{...t,enabled:!1}:t),f(!1)},Ce=z?{target:{batchId:e.id,option:B,path:[]},showVariant:B>=0}:null,Ie=e.parents?.[B];return G($,{children:[_(ue,{batch:pe,framing:Z,bundles:M,index:B,edits:X,theme:c,accentColor:u,selection:P,preview:Ce,expanded:k&&!m,onExpand:C,revisions:V.revisions,focusRequest:J,hoveredTarget:null,busy:!1,canApply:I&&!U,frozenVersion:U?T?.returnTo:void 0,onTogglePreview:()=>{if(ie(""),Ce&&!k)return void ke();let t=y(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:B,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}),C(!1),f(!0)):ie(me)},onBrowse:e=>{D(T),L(e.option),le(null)},onFixtureCanvas:(e,t)=>oe(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(U)return;let r=n.map(n=>({...n,batchId:e.id,option:t}));V.save(t,r)},setTag:e=>{I&&!U&&O(n(pe,e,X))},onApply:async(e,n)=>{let{text:r,meta:o}=t(pe,e.option,X);if(!await S(r,n?{...o,exploreOption:{...o.exploreOption,selection:{...o.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."}}}}:o,n?[n]:void 0))throw Error("This thread cannot send the apply request.");ke(),C(!1)}}),U&&T?.returnTo?G("span",{children:["Parent version ·"," ",_(r,{reference:T.returnTo,children:"Back to iteration"})]}):Ie?G("span",{children:["Based on"," ",_(r,{reference:{...Ie,snapshot:Ie,returnTo:{batchId:e.id,option:B,title:de.title}},showVersion:!0})]}):null,V.failure&&G("span",{role:"alert",children:[V.failure," ",V.unsynced&&_("button",{type:"button",onClick:V.retry,children:"Retry"})]}),(ae||z&&B>=0&&!m&&te&&!he)&&_("span",{role:"alert",children:ae||me}),!A&&!U&&z&&!m&&xe&&_(l,{preview:xe})]})}export{xe as ExploreAttachment};
@@ -0,0 +1 @@
1
+ "use client";export{f as PagePreviewLayer}from"./chunk-WF3YGZPI.mjs";import"./chunk-OIKFQ2FV.mjs";import"./chunk-PWQB3FIW.mjs";import"./chunk-Q6N77LIS.mjs";import"./chunk-ZVDKW7TO.mjs";import"./chunk-FHCKFQBY.mjs";import"./chunk-APP5IYTE.mjs";import"./chunk-TMSGNHXH.mjs";import"./chunk-53SKVMWR.mjs";import"./chunk-5IZHN3A7.mjs";import"./chunk-AOTDTBQO.mjs";import"./chunk-WP2SHSCG.mjs";import"./chunk-LH7HKUCK.mjs";import"./chunk-Q6C7ZA3H.mjs";import"./chunk-NI77Y3WC.mjs";import"./chunk-FON4QY7P.mjs";import"./chunk-AGCS65LT.mjs";import"./chunk-SUAHDXJZ.mjs";
@@ -0,0 +1 @@
1
+ "use client";import{d as t,b as e,c as o,a as r}from"./chunk-3QYA5LGF.mjs";import"./chunk-GAUQZAW6.mjs";import"./chunk-4LVGVKSS.mjs";import{f as i}from"./chunk-VVNZ5IEG.mjs";import"./chunk-LOUWY55X.mjs";import"./chunk-PH2MLB3T.mjs";import"./chunk-ZVDKW7TO.mjs";import"./chunk-XTOCFTVW.mjs";import"./chunk-EFGQKWSZ.mjs";import"./chunk-SOGN7S54.mjs";import"./chunk-6XEEXK3U.mjs";import"./chunk-EZVFCJEG.mjs";import"./chunk-IAXSC2ZN.mjs";import"./chunk-HAN6CUNB.mjs";import{a as n}from"./chunk-SKKHZBOJ.mjs";import{i as a,Y as s}from"./chunk-HPU2UMVE.mjs";import"./chunk-B22WBEQC.mjs";import"./chunk-O2ZQFLNV.mjs";import"./chunk-G2ZHJXHZ.mjs";import"./chunk-TMSGNHXH.mjs";import"./chunk-53SKVMWR.mjs";import"./chunk-76WRZ2NH.mjs";import"./chunk-KXVXWEN4.mjs";import"./chunk-QV5G3XRE.mjs";import"./chunk-L6S66APQ.mjs";import"./chunk-FJWWBKCQ.mjs";import"./chunk-RK6UROPO.mjs";import"./chunk-5IZHN3A7.mjs";import"./chunk-AOTDTBQO.mjs";import"./chunk-HAZXZ5TU.mjs";import"./chunk-JEGBAHYK.mjs";import"./chunk-YYODLRV3.mjs";import"./chunk-W2QQVB2H.mjs";import"./chunk-WP2SHSCG.mjs";import{e as c,g as l,f as p}from"./chunk-AAMUU2QA.mjs";import"./chunk-LH7HKUCK.mjs";import{a as m}from"./chunk-7JWADHTH.mjs";import{b as h,f as u,c as d,d as f}from"./chunk-3VOEPWRL.mjs";import{o as j}from"./chunk-HBFSPXIC.mjs";import"./chunk-X6I6KQDG.mjs";import"./chunk-ATLUO4G7.mjs";import"./chunk-Q6C7ZA3H.mjs";import"./chunk-SOT33EQ4.mjs";import"./chunk-C2ZSNUXQ.mjs";import"./chunk-EBJ23A7F.mjs";import"./chunk-EILBHZDX.mjs";import"./chunk-XJJDBMZI.mjs";import"./chunk-OREALBUO.mjs";import"./chunk-B4DYUYX4.mjs";import"./chunk-CK3CDA3L.mjs";import{c as k,a as g}from"./chunk-NI77Y3WC.mjs";import"./chunk-FON4QY7P.mjs";import{U as w}from"./chunk-OA63PYHZ.mjs";import"./chunk-ECMLCGAM.mjs";import"./chunk-PRPXMDZ7.mjs";import"./chunk-A4GARXVQ.mjs";import"./chunk-AGCS65LT.mjs";import{b as y}from"./chunk-SUAHDXJZ.mjs";import{useState as S,useSyncExternalStore as v,useEffect as I}from"react";import{jsx as A,jsxs as O}from"react/jsx-runtime";function P(t,i){let n,a={phase:"starting"},m=0,j=!1,k=!1,g=0,w=new Set,S=`popmelt-participant:${t.projectId}`,v=new h(t.url,t.projectId),I=t=>{if(!k){a=t;for(let t of w)t()}},A=()=>history.state?.popmeltGuestEntry===t.projectId,O=e=>history.replaceState({...history.state,popmeltGuestEntry:t.projectId},"",e),P=t=>fetch("/__popmelt/host",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin",body:JSON.stringify(t),redirect:"error"}),H=async(e={},o=!1,r)=>{if(y(t.url))return null;let i=await P(e);if(403===i.status){let e=i.headers.get("X-Popmelt-Host-Origin"),n=i.headers.get("X-Popmelt-Session"),a=new URL(location.href);if(!o||!n||window.top!==window||!["localhost","127.0.0.1","[::1]"].includes(a.hostname)||a.pathname.startsWith("/__popmelt/")||a.searchParams.has("__popmelt_code_preview")||a.hash.includes("popmelt-")||A())return null;let s=localStorage.getItem(`popmelt-admission:${t.projectId}`);if(s)try{if(JSON.parse(s)?.receipt)return null}catch{return null}if(e&&function(t,e){try{let o=new URL(t),r=new URL(e),i=["localhost","127.0.0.1","[::1]"];return o.origin===t&&r.origin===e&&t!==e&&["http:","https:"].includes(o.protocol)&&o.protocol===r.protocol&&o.port===r.port&&i.includes(o.hostname)&&i.includes(r.hostname)}catch{return!1}}(location.origin,e)){let t=await fetch(e+"/__popmelt/host",{method:"HEAD",credentials:"omit",redirect:"error",referrerPolicy:"no-referrer",signal:AbortSignal.timeout(2e3)}).catch(()=>null);if(!k&&204===t?.status&&t.headers.get("X-Popmelt-Session")===n)throw a.host=new URL(e).host,location.replace(a.href),E;return null}let c=i.headers.get("X-Popmelt-Local-Port");if(!c||!/^[1-9]\d{0,4}$/.test(c)||Number(c)>65535)return null;let l=await fetch("http://127.0.0.1:"+c+"/",{method:"POST",headers:{"X-Popmelt-Session":n},credentials:"omit",cache:"no-store",redirect:"error",referrerPolicy:"no-referrer",signal:AbortSignal.timeout(6500)}).catch(()=>null);if(!l?.ok||k)return null;let p=await l.json().catch(()=>null);if("string"!=typeof p?.proof||(i=await P({localProof:p.proof,previousId:r}),403===i.status))return null}if(!i.ok)throw new Error(`Host entry unavailable (${i.status}).`);let n=`popmelt-before-participants:${t.projectId}`;return null===localStorage.getItem(n)&&localStorage.setItem(n,JSON.stringify(Object.fromEntries(Object.values(s(t.projectId)).map(t=>[t,localStorage.getItem(t)])))),await i.json()},E=Symbol("navigating"),b=async(a,s=g)=>{if(k||s!==g)return;let m=await r({bridgeUrl:t.url,projectId:t.projectId,credential:a,runtimeStorage:sessionStorage,observedSource:{sourceId:t.projectId,revision:t.revision},loadOwnSource:i,prepareApplication:t.planeApps?async r=>{if(k||s!==g)throw E;let i=c(location.pathname);if(r.author.id===a.participantId&&"host"===r.author.relationship&&!y(t.url)){if("/"!==i){let t=new URL(location.href);throw t.pathname=p(t.pathname),location.replace(t.href),E}return("/"===r.ownWorkspace?.basePath?r.ownWorkspace.revision:void 0)??r.draft.source?.revision??t.revision}let n=await e(a,a.participantId,void 0,location.pathname);if(k||s!==g)throw E;let m=o(n.application);if(t.appVersion??(t.appVersion=n.application.version),m!==l(location.pathname)||t.appVersion&&t.appVersion!==n.application.version)throw localStorage.setItem(S,JSON.stringify(a)),location.replace(m+location.search+location.hash),E;return n.application.basis??t.revision}:void 0}).catch(t=>{if(t!==E)throw t});if(m){if(k||s!==g)return void m.dispose();try{localStorage.setItem(S,JSON.stringify(a))}catch(t){throw m.dispose(),t}if(n?.dispose(),A()){let t={...history.state};delete t.popmeltGuestEntry,history.replaceState(t,"")}n=m,I({phase:"connected",connection:m}),H({credential:a}).catch(()=>{})}},U=()=>{O(location.href),g++,n?.dispose(),n=void 0,function(t,e){t.removeItem(`popmelt-participant:${e}`);let o,r=`popmelt-admission:${e}`;try{o=JSON.parse(t.getItem(r)??"null")}catch{return void t.removeItem(r)}o&&"object"==typeof o&&t.setItem(r,JSON.stringify({name:o.name,colorIdentity:o.colorIdentity??o.receipt}))}(localStorage,t.projectId),I({phase:"entry",invitation:null})};return{client:v,getSnapshot:()=>a,subscribe:t=>(w.add(t),()=>{w.delete(t)}),retain(){if(k)throw new Error("Participant lifecycle is disposed");m++,j||(j=!0,(async()=>{let t=u(location.href),e=new URL(t.cleanUrl),o=new URLSearchParams(e.hash.slice(1)),r=o.get("popmelt-host");o.delete("popmelt-host"),r&&(e.hash=o.toString()),t.token?O(e.href):e.href!==location.href&&history.replaceState(history.state,"",e);let i=null;if(r){if(i=await H({token:r}),!i&&!t.token&&(i=await H({},!0)),!i)throw new Error("Host entry expired. Use the current private host link.")}else if(!t.token&&!A()){try{i=JSON.parse(localStorage.getItem(S)??"null")}catch{}i??(i=await H({},!0))}if(k)return;if(!i)return void I({phase:"entry",invitation:t.token??null});let n=g;for(let e=1;!k&&n===g;e++)try{return void await b(i,n)}catch(o){if(k||n!==g)return;if(d(o)){I({phase:"error",message:o.message}),await new Promise(t=>setTimeout(t,f(e)));continue}if("access_removed"===o.code)return void U();if(401!==o.status)throw o;let a=await H({},!r&&!t.token,i.participantId);return void(a?await b(a):U())}})().catch(t=>{t!==E&&I({phase:"error",message:t.message})}));let t=!1;return()=>{t||(t=!0,m--,queueMicrotask(()=>{m||k||(k=!0,g++,n?.dispose(),n=void 0,w.clear())}))}},removed:U,async join(e,o){if("entry"!==a.phase||!a.invitation||k)throw new Error("No active invitation");if(!o)throw new Error("Peer identity is not ready");let r=g,i=await v.joinOrRequestAdmission(a.invitation,e,o);if(!k&&r===g){if("admission"in i)return localStorage.setItem(`popmelt-admission:${t.projectId}`,JSON.stringify({name:i.admission.name,receipt:o,colorIdentity:o})),void I({phase:"entry",invitation:null});await b(i.joined.credential,r)}},admit:t=>b(t)}}function H({config:r,loadOwnSource:s,children:p}){let[h]=S(()=>P(r,s)),u=a(),d=v(h.subscribe,h.getSnapshot,h.getSnapshot);I(()=>h.retain(),[h]);let[f,H,E]=k(),b="connected"===d.phase?d.connection:null;if(I(()=>{if(!b||!r.planeApps)return;let t,i=new AbortController,n=b.isHost&&!y(r.url)&&"/"===c(location.pathname),a=n?void 0:r.appVersion,s=async()=>{try{let t=await e(b.credential,b.credential.participantId,i.signal,location.pathname);if(n&&"/"!==t.application.basePath)throw new Error("Host checkout unavailable");let s=o(t.application);if(a??(a=t.application.version),!i.signal.aborted&&(s!==l(location.pathname)||t.application.version!==a)){if(b.isHost&&!y(r.url)){let t=await fetch(s+location.search,{method:"HEAD",headers:{Accept:"text/html"},mode:"same-origin",cache:"no-store",signal:i.signal});if(!t.ok||!t.headers.get("content-type")?.includes("text/html")||l(new URL(t.url).pathname)!==s)throw new Error("Host plane document unavailable")}return await b.state.flush(),void(i.signal.aborted||(s===l(location.pathname)?location.reload():location.replace(s+location.search+location.hash)))}}catch{}i.signal.aborted||(t=setTimeout(s,1500))};return s(),()=>{i.abort(),clearTimeout(t)}},[r.planeApps,r.appVersion,r.url,b,u]),b)return A(t,{connection:b,codePreviewUrl:location.href,planeApps:r.planeApps,onAccessRemoved:h.removed,children:p});let U="starting"===d.phase||"error"===d.phase,L="entry"===d.phase?d.invitation:null;return A(n,{children:A("div",{"data-devtools":"participant-entry",style:{display:"contents",pointerEvents:"auto"},children:U?A(i,{entry:{theme:f,themePreference:E,onThemePreferenceChange:H,ariaLabel:"starting"===d.phase?"Popmelt connecting":"Popmelt disconnected",action:null,logoOnly:!0,connected:!1,connection:O("span",{"data-popmelt-entry-content":!0,role:"status",style:{...j(g[f],!1),cursor:"default"},children:[A(w,{size:14,strokeWidth:1.5,"aria-hidden":"true"}),"starting"===d.phase?"Connecting…":"Disconnected"]})}}):A(m,{showHostLinkHelp:window.top===window&&["localhost","127.0.0.1","[::1]"].includes(location.hostname)&&!y(r.url)&&"/"===c(location.pathname),client:h.client,storage:localStorage,storageKey:`popmelt-admission:${r.projectId}`,theme:f,themePreference:E,onThemePreferenceChange:H,onAdmitted:h.admit,onJoin:L?h.join:void 0},L??"request-access")})})}export{H as default};
@@ -0,0 +1 @@
1
+ "use client";import{a as r,d as t}from"./chunk-3QYA5LGF.mjs";import"./chunk-GAUQZAW6.mjs";import"./chunk-4LVGVKSS.mjs";import"./chunk-EFGQKWSZ.mjs";import"./chunk-SOGN7S54.mjs";import"./chunk-6XEEXK3U.mjs";import"./chunk-HAN6CUNB.mjs";import"./chunk-HPU2UMVE.mjs";import"./chunk-B22WBEQC.mjs";import"./chunk-O2ZQFLNV.mjs";import"./chunk-G2ZHJXHZ.mjs";import"./chunk-TMSGNHXH.mjs";import"./chunk-53SKVMWR.mjs";import"./chunk-76WRZ2NH.mjs";import"./chunk-KXVXWEN4.mjs";import"./chunk-QV5G3XRE.mjs";import"./chunk-L6S66APQ.mjs";import"./chunk-FJWWBKCQ.mjs";import"./chunk-RK6UROPO.mjs";import"./chunk-5IZHN3A7.mjs";import"./chunk-AOTDTBQO.mjs";import"./chunk-HAZXZ5TU.mjs";import"./chunk-JEGBAHYK.mjs";import"./chunk-YYODLRV3.mjs";import"./chunk-W2QQVB2H.mjs";import"./chunk-WP2SHSCG.mjs";import"./chunk-AAMUU2QA.mjs";import"./chunk-LH7HKUCK.mjs";import"./chunk-3VOEPWRL.mjs";import"./chunk-EILBHZDX.mjs";import"./chunk-XJJDBMZI.mjs";import"./chunk-OREALBUO.mjs";import"./chunk-B4DYUYX4.mjs";import"./chunk-CK3CDA3L.mjs";import"./chunk-NI77Y3WC.mjs";import{b as o}from"./chunk-FON4QY7P.mjs";import"./chunk-OA63PYHZ.mjs";import"./chunk-ECMLCGAM.mjs";import"./chunk-PRPXMDZ7.mjs";import{d as n,f as i,c as m,a as e}from"./chunk-AGCS65LT.mjs";import"./chunk-SUAHDXJZ.mjs";import{useState as c,useEffect as s,cloneElement as p}from"react";import{jsxs as h,jsx as u}from"react/jsx-runtime";function j({children:j,projectId:a,participantConfig:k}){let[l,d]=c(null),[A,H]=c("");if(s(()=>{let t,m,c=!1;return d(null),H(""),n(a).then(async n=>{if(c)return;let s=location.origin+e;m=i(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(!c){if(h.phoneParticipantId)t=await r({projectId:n.projectId,bridgeUrl:s,credential:{participantId:h.phoneParticipantId,token:""},runtimeStorage:sessionStorage,observedSource:{sourceId:n.projectId,revision:k?.revision??"unversioned"}});else if(k)throw new Error("This phone is not connected to the multiplayer host.");c?t?.dispose():d({bridgeUrl:s,projectId:n.projectId,connection:t})}}).catch(r=>{m?.(),c||H(r instanceof Error?r.message:"Phone pairing failed.")}),()=>{c=!0,t?.dispose(),m?.()}},[a,k]),A)return h("p",{role:"alert","data-devtools":"phone-pairing-error",children:[A," ",u("button",{type:"button",onClick:m,children:"Forget this pairing"})]});if(!l)return null;let I=p(j,{bridgeUrl:l.bridgeUrl,projectId:l.projectId});return l.connection?u(t,{connection:l.connection,onAccessRemoved:m,children:I}):I}export{j as PhoneHostGate};