@engenty/wizards-runtime 0.17.0 → 0.17.2

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 (149) hide show
  1. package/apps/runtime/dist/app.js +2 -0
  2. package/apps/runtime/dist/broker/account.js +20 -1
  3. package/apps/runtime/dist/broker/call.js +116 -20
  4. package/apps/runtime/dist/broker/host.js +8 -2
  5. package/apps/runtime/dist/broker/index.js +3 -2
  6. package/apps/runtime/dist/broker/log.js +149 -14
  7. package/apps/runtime/dist/broker/over.js +38 -0
  8. package/apps/runtime/dist/broker/rights.js +192 -0
  9. package/apps/runtime/dist/broker/rwx.js +295 -51
  10. package/apps/runtime/dist/broker/send.js +25 -12
  11. package/apps/runtime/dist/bundles/discover.js +133 -0
  12. package/apps/runtime/dist/bundles/fetch.js +119 -0
  13. package/apps/runtime/dist/bundles/index.js +621 -0
  14. package/apps/runtime/dist/bundles/read.js +607 -0
  15. package/apps/runtime/dist/connectors/external.js +540 -61
  16. package/apps/runtime/dist/connectors/person-sign-ins.js +1 -0
  17. package/apps/runtime/dist/connectors/reload.js +73 -0
  18. package/apps/runtime/dist/connectors/space-connections.js +73 -6
  19. package/apps/runtime/dist/db/migrations/tenant/0058_mcp_state_across_roles.sql +26 -0
  20. package/apps/runtime/dist/db/migrations/tenant/0059_space_connection_paused.sql +2 -0
  21. package/apps/runtime/dist/db/migrations/tenant/0060_space_bundle.sql +21 -0
  22. package/apps/runtime/dist/db/migrations/tenant/0061_space_connection_limits.sql +2 -0
  23. package/apps/runtime/dist/db/migrations/tenant/meta/0058_snapshot.json +6696 -0
  24. package/apps/runtime/dist/db/migrations/tenant/meta/0059_snapshot.json +6710 -0
  25. package/apps/runtime/dist/db/migrations/tenant/meta/0060_snapshot.json +6857 -0
  26. package/apps/runtime/dist/db/migrations/tenant/meta/0061_snapshot.json +6871 -0
  27. package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +28 -0
  28. package/apps/runtime/dist/db/schema.js +81 -3
  29. package/apps/runtime/dist/docs/dev/broker.md +312 -32
  30. package/apps/runtime/dist/docs/dev/skills.md +8 -1
  31. package/apps/runtime/dist/docs/user-guide/capabilities.md +127 -5
  32. package/apps/runtime/dist/docs/user-guide/connectors.md +103 -5
  33. package/apps/runtime/dist/docs/user-guide/protocol.md +15 -4
  34. package/apps/runtime/dist/docs/user-guide/skills.md +11 -1
  35. package/apps/runtime/dist/docs/user-guide/test-and-share.md +1 -1
  36. package/apps/runtime/dist/elements/caller.js +2 -2
  37. package/apps/runtime/dist/engenty/connections-external/build-connector.js +23 -8
  38. package/apps/runtime/dist/engenty/connections-external/import-service.js +18 -9
  39. package/apps/runtime/dist/engenty/connections-external/importer/classify.js +12 -0
  40. package/apps/runtime/dist/engenty/connections-external/invoke/http-invoker.js +1 -0
  41. package/apps/runtime/dist/engenty/connections-external/net/guarded-fetch.js +6 -3
  42. package/apps/runtime/dist/engenty/connections-sdk/oauth2.js +2 -2
  43. package/apps/runtime/dist/engenty/shims/web-ingest.js +64 -0
  44. package/apps/runtime/dist/engine/resources.js +15 -6
  45. package/apps/runtime/dist/engine/runner.js +2 -1
  46. package/apps/runtime/dist/env.js +2 -0
  47. package/apps/runtime/dist/index.js +11 -2
  48. package/apps/runtime/dist/mcp/handler.js +2 -2
  49. package/apps/runtime/dist/mcp/seen.js +71 -51
  50. package/apps/runtime/dist/mcp/tools.js +5 -1
  51. package/apps/runtime/dist/prompts/mcp.md +1 -1
  52. package/apps/runtime/dist/prompts/tools.md +16 -0
  53. package/apps/runtime/dist/routes/broker.js +1 -1
  54. package/apps/runtime/dist/routes/bundles.js +91 -0
  55. package/apps/runtime/dist/routes/connections.js +14 -3
  56. package/apps/runtime/dist/routes/discover.js +1 -0
  57. package/apps/runtime/dist/routes/rules.js +53 -9
  58. package/apps/runtime/dist/routes/studio.js +23 -18
  59. package/apps/runtime/dist/services/cloud.js +2 -0
  60. package/apps/runtime/dist/services/discover.js +9 -3
  61. package/apps/runtime/dist/services/draft-events.js +79 -6
  62. package/apps/runtime/dist/services/files.js +2 -2
  63. package/apps/runtime/dist/services/skills.js +61 -5
  64. package/apps/runtime/dist/services/space-index.js +113 -11
  65. package/apps/runtime/dist/services/synced-spaces.js +5 -1
  66. package/apps/runtime/dist/services/wizards.js +48 -2
  67. package/apps/runtime/dist/sharing/jobs.js +6 -2
  68. package/apps/runtime/dist/sync/records.js +6 -1
  69. package/apps/runtime/dist/texts.js +36 -1
  70. package/apps/runtime/dist/tools/connections.js +8 -0
  71. package/apps/runtime/dist/tools/connector.js +13 -1
  72. package/apps/runtime/dist/tools/index.js +8 -3
  73. package/apps/runtime/dist/tools/skills.js +11 -1
  74. package/apps/web/dist/assets/{AboutDialog-B2Xmxyj4.js → AboutDialog-NzB-GEj_.js} +1 -1
  75. package/apps/web/dist/assets/{BlockEditor-D0HoUSih.js → BlockEditor-HyDf8fOb.js} +1 -1
  76. package/apps/web/dist/assets/Bundle-B0Bhs0By.js +1 -0
  77. package/apps/web/dist/assets/CapabilitiesPage-CQSaMsWK.js +2 -0
  78. package/apps/web/dist/assets/{ChangelogDialog-BIrJbAKi.js → ChangelogDialog-Ngxuqubx.js} +1 -1
  79. package/apps/web/dist/assets/{CodeEditor-DUVcXI5P.js → CodeEditor-C2LBf4pS.js} +1 -1
  80. package/apps/web/dist/assets/EditorPage-Dysvvadu.js +3 -0
  81. package/apps/web/dist/assets/{FlowPreview-BIag8_Be.js → FlowPreview-CGfSaeYu.js} +1 -1
  82. package/apps/web/dist/assets/LangSwitch-B7UQlGh5.js +1 -0
  83. package/apps/web/dist/assets/Marketplace-BkIxd1PW.js +2 -0
  84. package/apps/web/dist/assets/{NewWizardChannels-DI3SQ4iS.js → NewWizardChannels-BWLaVFld.js} +1 -1
  85. package/apps/web/dist/assets/NewWizardPage-BpRd8tDF.js +7 -0
  86. package/apps/web/dist/assets/OnboardingPage-ScEcQcR0.js +1 -0
  87. package/apps/web/dist/assets/PreviewPane-CaC1FYxZ.js +7 -0
  88. package/apps/web/dist/assets/ProtocolSection-CILRCYLD.js +1 -0
  89. package/apps/web/dist/assets/PublicRunner-DHX431Pr.js +1 -0
  90. package/apps/web/dist/assets/{ReadOnly-CWf5x74a.js → ReadOnly-DqS1UDQs.js} +1 -1
  91. package/apps/web/dist/assets/SettingsPage-Dp2-rHXu.js +2 -0
  92. package/apps/web/dist/assets/SetupPage-mzMLQcD5.js +1 -0
  93. package/apps/web/dist/assets/SharePage-CBDgqEH7.js +1 -0
  94. package/apps/web/dist/assets/SkillEditor-Cf6FqkkU.js +1 -0
  95. package/apps/web/dist/assets/{Skills-CN4QE7Kx.js → Skills-DqV5Oqqu.js} +5 -5
  96. package/apps/web/dist/assets/SpacePage-C3SXe2hs.js +2 -0
  97. package/apps/web/dist/assets/{UpdateCheck-QhBI3rlQ.js → UpdateCheck-B51jMIhp.js} +2 -2
  98. package/apps/web/dist/assets/brand-CG35IRgr.js +2 -0
  99. package/apps/web/dist/assets/changelog-DN6sziTl.js +1 -0
  100. package/apps/web/dist/assets/{code-editor-DkPo1C-L.js → code-editor-Bsyy7cuT.js} +2 -2
  101. package/apps/web/dist/assets/{host-D6H6Z9Jp.js → host-DaDyLfqT.js} +16 -16
  102. package/apps/web/dist/assets/i18n-CyrHWeGk.js +55 -0
  103. package/apps/web/dist/assets/index-Db9JthZr.css +1 -0
  104. package/apps/web/dist/assets/index-LjwVRoki.js +10 -0
  105. package/apps/web/dist/assets/minus-BpYkOkYw.js +1 -0
  106. package/apps/web/dist/assets/plug-De3mHDFV.js +1 -0
  107. package/apps/web/dist/assets/{read-aloud-CnFwDSGD.js → read-aloud-DCTouK7J.js} +1 -1
  108. package/apps/web/dist/assets/{runners-0sTPbWzr.js → runners-DtiBHvG7.js} +1 -1
  109. package/apps/web/dist/assets/session-DKGZUy6h.js +1 -0
  110. package/apps/web/dist/assets/{theme-CkNTe-_Z.js → theme-Bcj8TXQr.js} +2 -2
  111. package/apps/web/dist/assets/{ui-DAk_vjrL.js → ui-C6vSmisV.js} +1 -1
  112. package/apps/web/dist/assets/{useMutation-isHfB33W.js → useMutation-B8hJ5Z6N.js} +1 -1
  113. package/apps/web/dist/assets/{viewers-ijNZHJFG.js → viewers-b9FdC42r.js} +2 -2
  114. package/apps/web/dist/assets/{volume-2-BqlBtCIJ.js → volume-2-B1roRk6x.js} +1 -1
  115. package/apps/web/dist/index.html +15 -13
  116. package/apps/web/dist/mcp/flow.html +2 -2
  117. package/node_modules/@engenty/wizards-shared/dist/bundles.d.ts +219 -0
  118. package/node_modules/@engenty/wizards-shared/dist/bundles.js +19 -0
  119. package/node_modules/@engenty/wizards-shared/dist/connectors.d.ts +105 -4
  120. package/node_modules/@engenty/wizards-shared/dist/connectors.js +6 -0
  121. package/node_modules/@engenty/wizards-shared/dist/discover.d.ts +28 -1
  122. package/node_modules/@engenty/wizards-shared/dist/run.d.ts +8 -0
  123. package/node_modules/@engenty/wizards-shared/dist/run.js +16 -0
  124. package/node_modules/@engenty/wizards-shared/dist/rwx.d.ts +84 -1
  125. package/node_modules/@engenty/wizards-shared/dist/rwx.js +69 -1
  126. package/node_modules/@engenty/wizards-shared/dist/skills.d.ts +20 -3
  127. package/node_modules/@engenty/wizards-shared/dist/skills.js +5 -2
  128. package/package.json +1 -1
  129. package/plugin/.claude-plugin/plugin.json +1 -1
  130. package/plugin/plugin.json +1 -1
  131. package/apps/web/dist/assets/CapabilitiesPage-C1th2cZE.js +0 -2
  132. package/apps/web/dist/assets/EditorPage-56sIqEfF.js +0 -3
  133. package/apps/web/dist/assets/LangSwitch-CJ00IgaO.js +0 -1
  134. package/apps/web/dist/assets/Marketplace-D7-ot9Dz.js +0 -2
  135. package/apps/web/dist/assets/NewWizardPage-CytheHxX.js +0 -7
  136. package/apps/web/dist/assets/OnboardingPage-_91Pa8Ad.js +0 -1
  137. package/apps/web/dist/assets/PreviewPane-BDsYm-_K.js +0 -7
  138. package/apps/web/dist/assets/ProtocolSection-D_zaxHEL.js +0 -1
  139. package/apps/web/dist/assets/PublicRunner-CEgXSk3r.js +0 -1
  140. package/apps/web/dist/assets/SettingsPage-Dr8SDk-L.js +0 -2
  141. package/apps/web/dist/assets/SetupPage-B68n0l4I.js +0 -1
  142. package/apps/web/dist/assets/SharePage-DfznN7ar.js +0 -1
  143. package/apps/web/dist/assets/SkillEditor-BIcIczRc.js +0 -1
  144. package/apps/web/dist/assets/SpacePage-DiVTwhnJ.js +0 -2
  145. package/apps/web/dist/assets/changelog-a_CuplMX.js +0 -1
  146. package/apps/web/dist/assets/i18n-BaPKbQ1s.js +0 -55
  147. package/apps/web/dist/assets/index-CCUG6Vnh.css +0 -1
  148. package/apps/web/dist/assets/index-De0Wb42y.js +0 -10
  149. package/apps/web/dist/assets/session-BMiUrqHg.js +0 -2
@@ -0,0 +1 @@
1
+ import{d as e}from"./marked.esm-DQ7XA7AC.js";var t={name:`minus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]};t.node;var n=e(t);export{n as t};
@@ -0,0 +1 @@
1
+ import{d as e}from"./marked.esm-DQ7XA7AC.js";var t={name:`plug`,size:24,node:[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]};t.node;var n=e(t);export{n as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{Q as r,gr as i,pt as a}from"./ui-DAk_vjrL.js";import{d as o}from"./marked.esm-DQ7XA7AC.js";import{n as s,s as c,st as l}from"./i18n-BaPKbQ1s.js";var u={name:`folder-up`,size:24,node:[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}],[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`m9 13 3-3 3 3`,key:`1pxg3c`}]]};u.node;var d=o(u),f={name:`mic-off`,size:24,node:[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M15 9.34V5a3 3 0 0 0-5.68-1.33`,key:`1gzdoj`}],[`path`,{d:`M16.95 16.95A7 7 0 0 1 5 12v-2`,key:`cqa7eg`}],[`path`,{d:`M18.89 13.23A7 7 0 0 0 19 12v-2`,key:`16hl24`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v3a3 3 0 0 0 5.12 2.12`,key:`r2i35w`}]]};f.node;var p=o(f),m={name:`phone-off`,size:24,node:[[`path`,{d:`M10.1 13.9a14 14 0 0 0 3.732 2.668 1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2 18 18 0 0 1-12.728-5.272`,key:`1wngk7`}],[`path`,{d:`M22 2 2 22`,key:`y4kqgn`}],[`path`,{d:`M4.76 13.582A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 .244.473`,key:`10hv5p`}]]};m.node;var h=o(m),g={name:`undo-2`,size:24,node:[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]};g.node;var _=o(g),v=e(n(),1);async function y(){let{account:e}=await(await fetch(a(`/api/auth/sign-out`),{method:`POST`,credentials:`include`,headers:{"content-type":`application/json`},body:`{}`})).json().catch(()=>({}));if(!e){window.location.reload();return}let t=document.createElement(`form`);t.method=`POST`,t.action=e,document.body.append(t),t.submit()}function b({name:e,until:t}){let n=new Intl.DateTimeFormat(s,{timeStyle:`short`}).format(new Date(t));return(0,v.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-x-3 gap-y-1 bg-amber-tint px-4 py-2 text-center text-[0.8125rem] text-ink`,children:[(0,v.jsx)(`span`,{children:c(`impersonation.banner`,{name:e,time:n})}),(0,v.jsx)(`button`,{type:`button`,className:`font-medium underline underline-offset-2 hover:text-ink-2`,onClick:()=>void y(),children:c(`impersonation.back`)})]})}function x(){let e=i({queryKey:[`impersonation`],queryFn:()=>r.get(`/api/public/impersonation`),staleTime:6e4,retry:!1});return e.data?(0,v.jsx)(b,{name:e.data.name,until:e.data.until}):null}var S=e(t(),1),C=`wz.readAloud`,w=typeof window<`u`&&`speechSynthesis`in window&&`SpeechSynthesisUtterance`in window;function T(){try{return localStorage.getItem(C)===`1`}catch{return!1}}function E(e){try{localStorage.setItem(C,e?`1`:`0`)}catch{}}function D(e){let t=window.speechSynthesis.getVoices(),n=e.slice(0,2);return t.find(t=>t.lang===e&&t.default)??t.find(t=>t.lang===e)??t.find(e=>e.lang.startsWith(n)&&e.default)??t.find(e=>e.lang.startsWith(n))??null}function O(e,t=s,n=!1){if(!w||!e.trim())return;let r=window.speechSynthesis;n&&r.cancel();let i=l(t),a=new SpeechSynthesisUtterance(e.trim().slice(0,2e3));a.lang=i;let o=D(i);o&&(a.voice=o),r.speak(a)}function k(e,t=s){if(!w||!e.trim())return Promise.resolve();let n=window.speechSynthesis;n.cancel();let r=l(t),i=new SpeechSynthesisUtterance(e.trim().slice(0,4e3));i.lang=r;let a=D(r);return a&&(i.voice=a),new Promise(e=>{i.onend=()=>e(),i.onerror=()=>e(),n.speak(i)})}function A(e){return e.replace(/```[\s\S]*?```/g,``).replace(/!\[[^\]]*\]\([^)]*\)/g,``).replace(/\[([^\]]+)\]\([^)]*\)/g,`$1`).replace(/https?:\/\/\S+/g,``).replace(/^#+\s*/gm,``).replace(/^\s*[-*]\s+/gm,``).replace(/[*_`>|]/g,``).replace(/\n{2,}/g,`. `).replace(/\s+/g,` `).trim()}function j(){w&&window.speechSynthesis.cancel()}function M(){let[e,t]=(0,S.useState)(()=>w&&T()),n=(0,S.useCallback)(e=>{t(e),E(e),e||j()},[]);return(0,S.useEffect)(()=>{w&&window.speechSynthesis.getVoices()},[]),(0,S.useEffect)(()=>()=>j(),[]),[e,n]}function N(e,t,n,r){let i=(0,S.useRef)(null);(0,S.useEffect)(()=>{if(!e){i.current=null;return}let a=n.map(e=>e.key);if(!i.current){i.current=new Set(a);let e=[...n].reverse().find(e=>e.who===`bot`&&e.spoken!==!1);if(e){let n=r(e.key);n&&O(n,t,!0)}return}let o=n.filter(e=>!i.current?.has(e.key));for(let e of a)i.current.add(e);o.some(e=>e.who===`me`)&&j();for(let e of o)if(e.who===`bot`&&e.spoken!==!1){let n=r(e.key);n&&O(n,t)}},[e,t,n,r])}export{M as a,x as c,p as d,d as f,A as i,_ as l,j as n,N as o,k as r,b as s,w as t,h as u};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{Q as r,gr as i,pt as a}from"./ui-C6vSmisV.js";import{d as o}from"./marked.esm-DQ7XA7AC.js";import{n as s,s as c,st as l}from"./i18n-CyrHWeGk.js";var u={name:`folder-up`,size:24,node:[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}],[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`m9 13 3-3 3 3`,key:`1pxg3c`}]]};u.node;var d=o(u),f={name:`mic-off`,size:24,node:[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M15 9.34V5a3 3 0 0 0-5.68-1.33`,key:`1gzdoj`}],[`path`,{d:`M16.95 16.95A7 7 0 0 1 5 12v-2`,key:`cqa7eg`}],[`path`,{d:`M18.89 13.23A7 7 0 0 0 19 12v-2`,key:`16hl24`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v3a3 3 0 0 0 5.12 2.12`,key:`r2i35w`}]]};f.node;var p=o(f),m={name:`phone-off`,size:24,node:[[`path`,{d:`M10.1 13.9a14 14 0 0 0 3.732 2.668 1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2 18 18 0 0 1-12.728-5.272`,key:`1wngk7`}],[`path`,{d:`M22 2 2 22`,key:`y4kqgn`}],[`path`,{d:`M4.76 13.582A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 .244.473`,key:`10hv5p`}]]};m.node;var h=o(m),g={name:`undo-2`,size:24,node:[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]};g.node;var _=o(g),v=e(n(),1);async function y(){let{account:e}=await(await fetch(a(`/api/auth/sign-out`),{method:`POST`,credentials:`include`,headers:{"content-type":`application/json`},body:`{}`})).json().catch(()=>({}));if(!e){window.location.reload();return}let t=document.createElement(`form`);t.method=`POST`,t.action=e,document.body.append(t),t.submit()}function b({name:e,until:t}){let n=new Intl.DateTimeFormat(s,{timeStyle:`short`}).format(new Date(t));return(0,v.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-x-3 gap-y-1 bg-amber-tint px-4 py-2 text-center text-[0.8125rem] text-ink`,children:[(0,v.jsx)(`span`,{children:c(`impersonation.banner`,{name:e,time:n})}),(0,v.jsx)(`button`,{type:`button`,className:`font-medium underline underline-offset-2 hover:text-ink-2`,onClick:()=>void y(),children:c(`impersonation.back`)})]})}function x(){let e=i({queryKey:[`impersonation`],queryFn:()=>r.get(`/api/public/impersonation`),staleTime:6e4,retry:!1});return e.data?(0,v.jsx)(b,{name:e.data.name,until:e.data.until}):null}var S=e(t(),1),C=`wz.readAloud`,w=typeof window<`u`&&`speechSynthesis`in window&&`SpeechSynthesisUtterance`in window;function T(){try{return localStorage.getItem(C)===`1`}catch{return!1}}function E(e){try{localStorage.setItem(C,e?`1`:`0`)}catch{}}function D(e){let t=window.speechSynthesis.getVoices(),n=e.slice(0,2);return t.find(t=>t.lang===e&&t.default)??t.find(t=>t.lang===e)??t.find(e=>e.lang.startsWith(n)&&e.default)??t.find(e=>e.lang.startsWith(n))??null}function O(e,t=s,n=!1){if(!w||!e.trim())return;let r=window.speechSynthesis;n&&r.cancel();let i=l(t),a=new SpeechSynthesisUtterance(e.trim().slice(0,2e3));a.lang=i;let o=D(i);o&&(a.voice=o),r.speak(a)}function k(e,t=s){if(!w||!e.trim())return Promise.resolve();let n=window.speechSynthesis;n.cancel();let r=l(t),i=new SpeechSynthesisUtterance(e.trim().slice(0,4e3));i.lang=r;let a=D(r);return a&&(i.voice=a),new Promise(e=>{i.onend=()=>e(),i.onerror=()=>e(),n.speak(i)})}function A(e){return e.replace(/```[\s\S]*?```/g,``).replace(/!\[[^\]]*\]\([^)]*\)/g,``).replace(/\[([^\]]+)\]\([^)]*\)/g,`$1`).replace(/https?:\/\/\S+/g,``).replace(/^#+\s*/gm,``).replace(/^\s*[-*]\s+/gm,``).replace(/[*_`>|]/g,``).replace(/\n{2,}/g,`. `).replace(/\s+/g,` `).trim()}function j(){w&&window.speechSynthesis.cancel()}function M(){let[e,t]=(0,S.useState)(()=>w&&T()),n=(0,S.useCallback)(e=>{t(e),E(e),e||j()},[]);return(0,S.useEffect)(()=>{w&&window.speechSynthesis.getVoices()},[]),(0,S.useEffect)(()=>()=>j(),[]),[e,n]}function N(e,t,n,r){let i=(0,S.useRef)(null);(0,S.useEffect)(()=>{if(!e){i.current=null;return}let a=n.map(e=>e.key);if(!i.current){i.current=new Set(a);let e=[...n].reverse().find(e=>e.who===`bot`&&e.spoken!==!1);if(e){let n=r(e.key);n&&O(n,t,!0)}return}let o=n.filter(e=>!i.current?.has(e.key));for(let e of a)i.current.add(e);o.some(e=>e.who===`me`)&&j();for(let e of o)if(e.who===`bot`&&e.spoken!==!1){let n=r(e.key);n&&O(n,t)}},[e,t,n,r])}export{M as a,x as c,p as d,d as f,A as i,_ as l,j as n,N as o,k as r,b as s,w as t,h as u};
@@ -1 +1 @@
1
- import{E as e}from"./i18n-BaPKbQ1s.js";var t=[`text`,`data`,`image`,`video`,`voice`,`document`,`dashboard`,`widget`,`motion-graphics`,`surface`];[...e],[...t];var n={default:`steps`,enabled:[`steps`,`chat`]};export{n as t};
1
+ import{E as e}from"./i18n-CyrHWeGk.js";var t=[`text`,`data`,`image`,`video`,`voice`,`document`,`dashboard`,`widget`,`motion-graphics`,`surface`];[...e],[...t];var n={default:`steps`,enabled:[`steps`,`chat`]};export{n as t};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t}from"./jsx-runtime-BNakU3Ej.js";import{Kt as n,Q as r,Vr as i,X as a,ct as o,gr as s,ot as c,pt as l}from"./ui-C6vSmisV.js";import{P as u,i as d,o as f}from"./i18n-CyrHWeGk.js";var p={account:{kind:`release`,default:!0,label:`Account in a local install`,hint:`Linking, Settings → Account, the offer to sign in.`},twoWaySync:{kind:`release`,default:!0,label:`Two-way sync with the cloud`,hint:`A local install with an account keeps its spaces in step with the organization in the cloud, both ways: wizards, knowledge, data and files.`},liveChanges:{kind:`release`,default:!0,label:`Live changes in the studio`,hint:`An open studio shows what changed elsewhere (another member, a run, the AI, the sync) without a reload.`},unsetConnectors:{kind:`release`,default:!1,label:`Connectors without an OAuth client`,hint:`Built-in connectors are shown although their client is not set up.`},site:{kind:`release`,default:!1,label:`Link to the website in the setup`,hint:`The local install's setup links the product's site.`},teamPlans:{kind:`release`,default:!1,label:`Organization plans`,hint:`The organization page in the cloud studio, and plans that carry this switch on the account pages.`},organizationSettings:{kind:`release`,default:!1,label:`Organization settings in the studio`,hint:`Settings › Organisation in the cloud studio: the organization's name, its members and invitations, changed there instead of on the account pages.`},brandSections:{kind:`release`,default:!1,label:`Sections in Brand`,hint:`Sections of logos and of colours, gradients and patterns among them.`},brandRules:{kind:`release`,default:!1,label:`Rules in Brand`,hint:`Rules for how the logos, the colours and the type may be used.`},typography:{kind:`release`,default:!1,label:`Typography in Brand`,hint:`The brand's fonts, their licences and a type scale.`},channelVoice:{kind:`release`,default:!1,label:`Live voice`,hint:`Wizards run as a spoken conversation in the browser: offered when building and sharing.`},channelVideo:{kind:`release`,default:!1,label:`Video call`,hint:`Wizards run as a video call in the browser: offered when building and sharing.`},pages:{kind:`release`,default:!1,label:`Public page`,hint:`A space's page at the organization's address on wizards.page: its part in the space, the share dialog's switch.`},wordpress:{kind:`release`,default:!1,label:`WordPress plugin`,hint:`The plugin for WordPress sites, and a wizard as a package for one: offered in the share dialog and under Settings → Integrate.`},skills:{kind:`release`,default:!0,label:`Skills`,hint:`Skills, a place of their own in the app bar: from skills.sh, uploaded or written; always on in every AI step, or read by a wizard when it needs one.`},plugins:{kind:`release`,default:!1,label:`Plugins in the settings`,hint:`Settings › Plugins, also before any plugin is installed. Installing a plugin turns it on.`},goose:{kind:`release`,default:!1,label:`Goose`,hint:`The studio's assistant: its chat at the foot of the page and in the sidebar.`},workMode:{kind:`release`,default:!1,label:`Work mode`,hint:"The switch between Studio and Work in the app bar, and Work's chats. Client comes with the public page (`pages`)."},workWip:{kind:`release`,default:!1,label:`Work – WiP`,hint:`Work's places that aren't built yet, in the app bar under the chats: engenties, files, data, results and the bell.`},modelTiers:{kind:`release`,default:!1,label:`Model tiers`,hint:`The organization's model tier: steps may name a maker, calls say what they are for, and the studio shows what each class runs on in the tier.`},customDomains:{kind:`release`,default:!1,label:`Own domains`,hint:`Settings › Allgemein: the organization's wizards under a domain of its own, once a TXT record confirms it.`},broker:{kind:`release`,default:!0,label:`Broker`,hint:`RWX rules per space: who may read, write and execute what; enforced at every reader.`},capabilities:{kind:`release`,default:!0,label:`Capabilities`,hint:`One place in the app bar for Skills and Verbindungen: the space's connections with sign-in, audience and rules, each person's own sign-ins, the broker's Protokoll, Entdecken.`},clientSpaces:{kind:`release`,default:!1,label:`Client spaces`,hint:`A space's clients, each in a client space under it: their own data, results and chats, the firm's setup read from the space (docs/plans/client-spaces.md).`},knowledgeTree:{kind:`release`,default:!1,label:`Knowledge as a knowledge base`,hint:`Knowledge's start page with one Add menu, folders in its menu and categories as a tab, the block editor for pages (docs/plans/knowledge-base.md).`},knowledgeMedia:{kind:`release`,default:!1,label:`Pictures in Wissen by what they show`,hint:`Pictures and PDF pages are embedded as pictures where the embedding model takes them (EmbeddingGemma 2), so a search finds a photo by what it shows (docs/plans/media-and-files.md).`},gatewaySearch:{kind:`release`,default:!1,label:`Web search through the gateway`,hint:`web_search through the gateway's /v1/web/search for every model and client, in place of the model's own search. On once the gateway has its provider's key.`},dateien:{kind:`release`,default:!1,label:`Dateien`,hint:`File trees another party owns, mounted in a space and indexed where they live: a folder on this computer first (docs/plans/media-and-files.md).`},durableRuns:{kind:`release`,default:!1,label:`Runs that wait for days`,hint:`Wait steps: a run leaves every process and a clock wakes it. A deadline on automatic steps.`},ownKeys:{kind:`plan`,default:!0,label:`Own API keys`,hint:`The organization puts its providers' keys into the cloud studio instead of running on credits.`},personSignIn:{kind:`plan`,default:!0,label:`Each person signs in to a connection`,hint:`A space's connection may have each person sign in with their own account. Without it a connection signs in as the space.`}};function m(e,t){let n=e?.[t];return typeof n==`boolean`?n:Object.hasOwn(p,t)?p[t].default:!1}function h(e=p){let t={};for(let[n,r]of Object.entries(e))t[n]=r.default;return t}var g=e(t(),1);function _(e){return Object.fromEntries(u.filter(t=>e[t]?.startsWith(`apple:`)).map(e=>[e,``]))}function v(e){return e.split(/\s+/).map(e=>e.match(/[\p{L}\p{N}]/u)?.[0]??``).join(``).slice(0,2).toUpperCase()}function y(){let e=T().data?.limits.spaces;return e===null||(e??1)>1}function b(){return T().data?.limits.build??!0}function x(){let e=T().data,t=M().space?.studio??!1;return!e||e.limits.create||m(e.features,`capabilities`)&&e.limits.build&&t}function S(){let e=T().data;return!e||e.mode===`local`||e.tenant.role!==`member`}function C(){let e=i();return t=>{d(t),e.setQueryData([`me`],e=>e&&{...e,lang:t}),r.put(`/api/studio/lang`,{lang:t}).catch(()=>void 0)}}function w(e){let t=i();(0,g.useEffect)(()=>{if(!e)return;if(e.lang){d(e.lang);return}let n=f();n&&(t.setQueryData([`me`],e=>e&&{...e,lang:n}),r.put(`/api/studio/lang`,{lang:n}).catch(()=>void 0))},[e,t])}function T(){return s({queryKey:[`me`],queryFn:async()=>{try{return await r.get(`/api/studio/me`)}catch(e){if(e instanceof n&&e.status===401)return null;throw e}},staleTime:3e4})}function E(e=!0){return s({queryKey:a.spaces(),queryFn:()=>r.get(`/api/studio/spaces`),enabled:e})}var D=`wz.space`;function O(){try{return localStorage.getItem(D)}catch{return null}}var k=O(),A=new Set;function j(e){k=e;try{localStorage.setItem(D,e)}catch{}for(let e of A)e()}function M(){let e=E(),t=(0,g.useSyncExternalStore)(e=>(A.add(e),()=>A.delete(e)),()=>k),n=e.data??[];return{space:n.find(e=>e.id===t)??n[0]??null,spaces:n,select:j,loading:e.isLoading}}function N(e,t){return s({queryKey:[`cloud`,e],queryFn:()=>r.get(`/api/studio/wizards/${e}/cloud`),enabled:t})}function P(e){return e instanceof n&&e.body?.code===`read_only`?e.message:null}async function F(){let{account:e}=await(await fetch(l(`/api/auth/sign-out`),{method:`POST`,credentials:`include`,headers:{"content-type":`application/json`},body:`{}`})).json().catch(()=>({}));if(!e){window.location.href=`${c}/`;return}let t=document.createElement(`form`);t.method=`POST`,t.action=e;let n=document.createElement(`input`);n.type=`hidden`,n.name=`return`,n.value=`${window.location.origin}${c}/`,t.append(n),document.body.append(t),t.submit()}function I(e=L(),t){let n=new URLSearchParams({return:e});o!==c&&n.set(`organization`,o.slice(c.length+1)),t?.trim()&&n.set(`wish`,t.trim()),window.location.href=l(`/api/auth/login?${n}`)}function L(){let e=new URLSearchParams(window.location.search);e.delete(`signin`);let t=e.toString();return`${window.location.pathname}${t?`?${t}`:``}`}var R=`wizards.wish`,z=1;function B(e){try{localStorage.setItem(R,JSON.stringify({text:e,at:Date.now()}))}catch{}}function V(){try{let e=JSON.parse(localStorage.getItem(R)??`null`);if(typeof e?.text==`string`&&typeof e.at==`number`&&Date.now()-e.at<z*864e5)return e.text}catch{}return null}function H(){try{localStorage.removeItem(R)}catch{}}export{E as _,P as a,m as b,w as c,S as d,y as f,C as g,T as h,V as i,N as l,x as m,v as n,I as o,b as p,B as r,F as s,H as t,M as u,_ as v,h as y};
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/400-CyB00QFz.css","assets/500-DqciRChS.css","assets/600-B9Zp6bBy.css","assets/700-5l7ov3HZ.css","assets/400-n8m3eWIv.css","assets/500-BrSlhPjT.css","assets/600-CfY_-NCo.css","assets/700-CGFQ5xCB.css","assets/400-C1aMvkWZ.css","assets/500-XHIL5p_x.css","assets/600-BpnjcFCp.css","assets/700-BwKwxaTT.css","assets/400-CvPzio2w.css","assets/500-vjb4iIph.css","assets/600-BMp88EpG.css","assets/700-CReDayoA.css","assets/400-C-EAXind.css","assets/500-BacxruX7.css","assets/600-Bv31zJWL.css","assets/700-D1QH7Wga.css","assets/400-an-Q8PSH.css","assets/500-Dk7ZdhaB.css","assets/600-Bu09rnu5.css","assets/700-CEuaYRw2.css","assets/400-BpGVy8f9.css","assets/500-DjLsfQf4.css","assets/600-BvFs-CRM.css","assets/700-BXdZ1Wt4.css","assets/400-Bx8aXxdn.css","assets/500-ueODFTvD.css","assets/600-CX1ZBIY5.css","assets/700-B057BQ0n.css","assets/400-W7eSYfM-.css","assets/500--5BQEKwF.css","assets/600-B1b7x6MC.css","assets/700-pQg9ODXE.css","assets/400-NJi9pVr7.css","assets/400-fDO2E_2J.css","assets/500-Bp7rE3sO.css","assets/600-D7AGNg1U.css","assets/700-CBDkNWxO.css","assets/400-DiVWFxeN.css","assets/400-CWy8yahC.css"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{At as r,Ct as i,En as a,Fn as o,Ft as s,Ht as c,It as l,Kt as u,Mn as d,Nt as f,Ot as p,Pt as m,Q as h,Sn as g,St as _,Ut as v,Vt as y,Wt as b,_n as x,bn as S,bt as C,f as w,gt as T,hn as E,ht as D,in as O,jt as k,kn as A,mn as j,pt as M,sn as N,tr as P,un as F,wt as I,xn as ee,xt as te}from"./ui-DAk_vjrL.js";import{t as L}from"./react-dom-hf6EcyAr.js";import{t as R}from"./preload-helper-DpV6A1kQ.js";import{d as z,u as ne}from"./marked.esm-DQ7XA7AC.js";import{t as re}from"./volume-2-BqlBtCIJ.js";import{a as ie,d as ae,l as oe,o as se,t as ce,u as le}from"./read-aloud-CnFwDSGD.js";import{A as ue,D as de,E as fe,S as pe}from"./session-BMiUrqHg.js";import{t as me}from"./phone-B4uKDBFq.js";import{t as he}from"./engenty-CNjaZCVM.js";import{Ct as ge,D as _e,Dt as ve,Et as B,F as ye,K as be,St as xe,bt as V,h as Se,it as H,n as Ce,s as U,t as we,u as Te,wt as W,xt as Ee,yt as De}from"./i18n-BaPKbQ1s.js";import{t as Oe}from"./index-De0Wb42y.js";var ke={name:`hand`,size:24,node:[[`path`,{d:`M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2`,key:`1fvzgz`}],[`path`,{d:`M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2`,key:`1kc0my`}],[`path`,{d:`M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8`,key:`10h0bg`}],[`path`,{d:`M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15`,key:`1s1gnw`}]]};ke.node;var Ae=z(ke),je={name:`smartphone`,size:24,node:[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]};je.node;var Me=z(je),Ne={name:`video-off`,size:24,node:[[`path`,{d:`M10.66 6H14a2 2 0 0 1 2 2v2.5l5.248-3.062A.5.5 0 0 1 22 7.87v8.196`,key:`w8jjjt`}],[`path`,{d:`M16 16a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h2`,key:`1xawa7`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};Ne.node;var Pe=z(Ne),Fe={name:`volume-x`,size:24,node:[[`path`,{d:`M11 4.702a.7.7 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.7.7 0 0 0 11 19.298z`,key:`1p7khw`}],[`path`,{d:`m16.5 14.5 5-5`,key:`cul3yw`}],[`path`,{d:`m16.5 9.5 5 5`,key:`1akey5`}]]};Fe.node;var Ie=z(Fe),Le=3e3,Re=new Set;function ze(e,t,n){let r=`${e.family}\n${e.url}`;if(Re.has(r))return;Re.add(r);let i=!1,a=setTimeout(()=>i||n(),Le),o=()=>{i=!0,clearTimeout(a)},s=()=>{o(),n()};if(e.stylesheet){let n=document.createElement(`link`);n.rel=`stylesheet`,n.href=t,n.onerror=s,n.onload=()=>{document.fonts.load(`1em "${e.family.replace(/"/g,``)}"`).then(e=>e.length?o():s(),s)},document.head.append(n);return}new FontFace(e.family,`url("${t.replace(/["\\\n]/g,encodeURIComponent)}")`,{display:`swap`,weight:`100 900`}).load().then(e=>{document.fonts.add(e),o()},s)}var Be=e(L(),1),G=e(t(),1),K=e(n(),1),Ve=typeof window<`u`&&window.matchMedia(`(pointer: coarse)`).matches;function He({since:e}){let[t,n]=(0,G.useState)(Date.now());if((0,G.useEffect)(()=>{if(!e)return;let t=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(t)},[e]),!e)return null;let r=Math.max(0,Math.floor((t-e)/1e3)),i=String(Math.floor(r/60)).padStart(2,`0`),a=String(r%60).padStart(2,`0`);return(0,K.jsxs)(`span`,{className:`font-mono text-[0.8125rem] text-white/60 tabular-nums`,children:[i,`:`,a]})}function Ue({label:e,on:t,danger:n,busy:r,onClick:i,children:a}){return(0,K.jsx)(`button`,{type:`button`,"aria-label":e,title:e,"aria-pressed":t,disabled:r,onClick:i,className:E(`flex size-12 items-center justify-center rounded-full transition disabled:opacity-50`,n?`bg-rose text-white hover:brightness-110`:t===!1?`bg-white text-neutral-900 hover:bg-white/90`:`bg-white/15 text-white hover:bg-white/25`),children:r?(0,K.jsx)(F,{className:`size-5`}):a})}function We({voice:e}){let t=(0,G.useRef)(null),{captions:n}=e;return(0,G.useEffect)(()=>{n.length&&t.current?.scrollIntoView({block:`end`})},[n]),n.length?(0,K.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 sm:px-5`,children:(0,K.jsxs)(`ol`,{className:`mx-auto flex max-w-[720px] flex-col gap-2 py-2`,children:[n.map(e=>(0,K.jsx)(`li`,{className:E(`text-[0.9375rem] leading-snug`,e.who===`bot`?`text-white/95`:`text-right text-white/50`),children:e.text},e.id)),(0,K.jsx)(`div`,{ref:t})]})}):null}function Ge({voice:e,view:t,video:n,className:r}){let i=e.state===`live`,a=e.state===`connecting`,[s,c]=(0,G.useState)(null),[l,u]=(0,G.useState)(!1);(0,G.useEffect)(()=>{c(i?Date.now():null)},[i]);let d=async()=>{u(!1),await e.start(),n&&await e.startCamera()},f=()=>{e.stop(),u(!0)},p=n||e.camera,m=[...e.captions].reverse().find(e=>e.who===`bot`),h=[...e.captions].reverse().find(e=>e.who===`me`),g=e.speaking?U(`talk.speaking`):e.listening?U(`talk.listening`):i?U(`talk.live`):a?U(`talk.connecting`):l?U(`video.ended`):``;return(0,K.jsxs)(`section`,{className:E(`relative flex min-h-0 flex-col bg-neutral-950 text-white`,`safe-top`,r),children:[(0,K.jsxs)(`div`,{className:`flex h-14 shrink-0 items-center gap-3 px-4 sm:px-5`,children:[(0,K.jsx)(`div`,{className:`min-w-0 flex-1 truncate font-display font-semibold text-[1rem] tracking-tight`,children:t?.wizard.title??``}),g?(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[0.8125rem] text-white/70`,children:[i?(0,K.jsx)(`span`,{className:E(`size-2 rounded-full`,e.speaking?`animate-pulse-dot bg-emerald-400`:`bg-rose`)}):null,g]}):null,(0,K.jsx)(He,{since:s})]}),(0,K.jsxs)(`div`,{className:E(`grid min-h-0 gap-2 px-3 pb-2 sm:px-4`,p?`flex-1 grid-cols-1 sm:grid-cols-2`:`shrink-0 grid-cols-1`,!p&&i&&e.captions.length?`h-[38%]`:p?``:`flex-1`),children:[(0,K.jsxs)(`div`,{className:E(`relative min-h-0 overflow-hidden rounded-2xl bg-neutral-900`,!p&&`hidden`),children:[(0,K.jsx)(`video`,{ref:e.video,muted:!0,playsInline:!0,autoPlay:!0,className:E(`absolute inset-0 h-full w-full object-cover`,e.facing===`user`&&`-scale-x-100`,e.camera?`block`:`hidden`)}),e.camera?null:(0,K.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-2 text-white/50`,children:[(0,K.jsx)(Pe,{className:`size-8`}),(0,K.jsx)(`span`,{className:`text-[0.8125rem]`,children:U(`video.cameraOff`)})]}),(0,K.jsxs)(`span`,{className:`absolute bottom-2 left-3 rounded-md bg-black/50 px-2 py-0.5 text-[0.75rem]`,children:[U(`video.you`),e.muted?(0,K.jsx)(ae,{className:`ml-1.5 inline size-3`}):null]})]}),(0,K.jsxs)(`div`,{className:E(`relative flex min-h-0 items-center justify-center overflow-hidden rounded-2xl transition-shadow`,p?`bg-neutral-900`:`bg-transparent`,p&&e.speaking&&`ring-2 ring-emerald-400/70`),children:[(0,K.jsx)(`div`,{className:E(`rounded-full transition-shadow duration-500`,!p&&e.listening&&`shadow-[0_0_80px_20px_rgba(244,63,94,0.25)]`,!p&&e.speaking&&`shadow-[0_0_80px_20px_rgba(52,211,153,0.3)]`,e.speaking&&`animate-breathe`),children:(0,K.jsx)(pe,{kind:t?.wizard.avatar??`round`,costume:t?.wizard.costume,size:p?140:200,fluffy:!0,interactive:!1})}),p?(0,K.jsx)(`span`,{className:`absolute bottom-2 left-3 max-w-[85%] truncate rounded-md bg-black/50 px-2 py-0.5 text-[0.75rem]`,children:t?.wizard.title??``}):null]})]}),i&&!p?(0,K.jsx)(We,{voice:e}):i&&(m||h)?(0,K.jsx)(`div`,{className:`shrink-0 px-4 pb-2 sm:px-5`,children:(0,K.jsxs)(`div`,{className:`mx-auto max-w-[720px] space-y-1 text-center`,children:[h?(0,K.jsx)(`p`,{className:`line-clamp-1 text-[0.8125rem] text-white/50`,children:h.text}):null,m?(0,K.jsx)(`p`,{className:`line-clamp-3 text-[0.9375rem] text-white/95 leading-snug`,children:m.text}):null]})}):null,e.error?(0,K.jsx)(`p`,{className:`shrink-0 px-5 pb-2 text-center text-[0.8125rem] text-rose`,children:e.error}):null,(0,K.jsx)(`div`,{className:`flex shrink-0 items-center justify-center gap-3 px-4 pt-1 pb-4`,children:i?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ue,{label:U(e.muted?`video.unmute`:`video.mute`),on:!e.muted,onClick:e.toggleMute,children:e.muted?(0,K.jsx)(ae,{className:`size-5`}):(0,K.jsx)(o,{className:`size-5`})}),(0,K.jsx)(Ue,{label:U(e.camera?`talk.cameraOff`:`talk.camera`),on:e.camera,onClick:()=>e.camera?e.stopCamera():void e.startCamera(),children:e.camera?(0,K.jsx)(x,{className:`size-5`}):(0,K.jsx)(Pe,{className:`size-5`})}),e.camera&&Ve?(0,K.jsx)(Ue,{label:U(`video.flip`),onClick:()=>void e.flipCamera(),children:(0,K.jsx)(S,{className:`size-5`})}):null,(0,K.jsx)(Ue,{label:U(`video.leave`),danger:!0,onClick:f,children:(0,K.jsx)(le,{className:`size-5`})})]}):(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[(0,K.jsxs)(`button`,{type:`button`,disabled:a||!t?.talk,onClick:()=>void d(),className:`flex h-12 items-center gap-2 rounded-full bg-emerald-500 px-6 font-medium text-[0.9375rem] text-white transition hover:brightness-110 disabled:opacity-50`,children:[a?(0,K.jsx)(F,{className:`size-4`}):n?(0,K.jsx)(x,{className:`size-5`}):(0,K.jsx)(o,{className:`size-5`}),U(l?`video.rejoin`:n?`video.join`:`talk.start`)]}),!l&&!e.error?(0,K.jsx)(`p`,{className:`max-w-sm text-center text-[0.75rem] text-white/50`,children:U(n?`video.hint`:`talk.joinHint`)}):null]})})]})}var Ke=e=>_e[e.kind]!==`device`,qe=1024,Je=4e3;function Ye(e,t){return e?e.length>t?`${e.slice(0,t)} …`:e:``}function Xe(e,t,n=!1){let r=[`status: ${e.status}`,`camera: ${n?`on`:`off`}`];if(e.ask)return r.push(e.ask.kind===`confirm`?`question: the step wants to "${e.ask.action.summary}" in ${e.ask.service}; answer_ask allows or skips it`:`question: a sign-in at ${e.ask.site.host}; the person types it on the screen, wait`),r.join(`
2
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{At as r,Ct as i,En as a,Fn as o,Ft as s,Ht as c,It as l,Kt as u,Mn as d,Nt as f,Ot as p,Pt as m,Q as h,Sn as g,St as _,Ut as v,Vt as y,Wt as b,_n as x,bn as S,bt as C,f as w,gt as T,hn as E,ht as D,in as O,jt as k,kn as A,mn as j,pt as M,sn as N,tr as P,un as F,wt as I,xn as ee,xt as te}from"./ui-C6vSmisV.js";import{t as L}from"./react-dom-hf6EcyAr.js";import{t as R}from"./preload-helper-DpV6A1kQ.js";import{d as z,u as ne}from"./marked.esm-DQ7XA7AC.js";import{t as re}from"./volume-2-B1roRk6x.js";import{a as ie,d as ae,l as oe,o as se,t as ce,u as le}from"./read-aloud-DCTouK7J.js";import{n as ue,o as de,s as fe,u as pe}from"./brand-CG35IRgr.js";import{t as me}from"./phone-B4uKDBFq.js";import{t as he}from"./engenty-CNjaZCVM.js";import{Ct as ge,D as _e,Dt as ve,Et as B,F as ye,K as be,St as xe,bt as V,h as Se,it as H,n as Ce,s as U,t as we,u as Te,wt as W,xt as Ee,yt as De}from"./i18n-CyrHWeGk.js";import{t as Oe}from"./index-LjwVRoki.js";var ke={name:`hand`,size:24,node:[[`path`,{d:`M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2`,key:`1fvzgz`}],[`path`,{d:`M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2`,key:`1kc0my`}],[`path`,{d:`M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8`,key:`10h0bg`}],[`path`,{d:`M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15`,key:`1s1gnw`}]]};ke.node;var Ae=z(ke),je={name:`smartphone`,size:24,node:[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]};je.node;var Me=z(je),Ne={name:`video-off`,size:24,node:[[`path`,{d:`M10.66 6H14a2 2 0 0 1 2 2v2.5l5.248-3.062A.5.5 0 0 1 22 7.87v8.196`,key:`w8jjjt`}],[`path`,{d:`M16 16a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h2`,key:`1xawa7`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};Ne.node;var Pe=z(Ne),Fe={name:`volume-x`,size:24,node:[[`path`,{d:`M11 4.702a.7.7 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.7.7 0 0 0 11 19.298z`,key:`1p7khw`}],[`path`,{d:`m16.5 14.5 5-5`,key:`cul3yw`}],[`path`,{d:`m16.5 9.5 5 5`,key:`1akey5`}]]};Fe.node;var Ie=z(Fe),Le=3e3,Re=new Set;function ze(e,t,n){let r=`${e.family}\n${e.url}`;if(Re.has(r))return;Re.add(r);let i=!1,a=setTimeout(()=>i||n(),Le),o=()=>{i=!0,clearTimeout(a)},s=()=>{o(),n()};if(e.stylesheet){let n=document.createElement(`link`);n.rel=`stylesheet`,n.href=t,n.onerror=s,n.onload=()=>{document.fonts.load(`1em "${e.family.replace(/"/g,``)}"`).then(e=>e.length?o():s(),s)},document.head.append(n);return}new FontFace(e.family,`url("${t.replace(/["\\\n]/g,encodeURIComponent)}")`,{display:`swap`,weight:`100 900`}).load().then(e=>{document.fonts.add(e),o()},s)}var Be=e(L(),1),G=e(t(),1),K=e(n(),1),Ve=typeof window<`u`&&window.matchMedia(`(pointer: coarse)`).matches;function He({since:e}){let[t,n]=(0,G.useState)(Date.now());if((0,G.useEffect)(()=>{if(!e)return;let t=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(t)},[e]),!e)return null;let r=Math.max(0,Math.floor((t-e)/1e3)),i=String(Math.floor(r/60)).padStart(2,`0`),a=String(r%60).padStart(2,`0`);return(0,K.jsxs)(`span`,{className:`font-mono text-[0.8125rem] text-white/60 tabular-nums`,children:[i,`:`,a]})}function Ue({label:e,on:t,danger:n,busy:r,onClick:i,children:a}){return(0,K.jsx)(`button`,{type:`button`,"aria-label":e,title:e,"aria-pressed":t,disabled:r,onClick:i,className:E(`flex size-12 items-center justify-center rounded-full transition disabled:opacity-50`,n?`bg-rose text-white hover:brightness-110`:t===!1?`bg-white text-neutral-900 hover:bg-white/90`:`bg-white/15 text-white hover:bg-white/25`),children:r?(0,K.jsx)(F,{className:`size-5`}):a})}function We({voice:e}){let t=(0,G.useRef)(null),{captions:n}=e;return(0,G.useEffect)(()=>{n.length&&t.current?.scrollIntoView({block:`end`})},[n]),n.length?(0,K.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 sm:px-5`,children:(0,K.jsxs)(`ol`,{className:`mx-auto flex max-w-[720px] flex-col gap-2 py-2`,children:[n.map(e=>(0,K.jsx)(`li`,{className:E(`text-[0.9375rem] leading-snug`,e.who===`bot`?`text-white/95`:`text-right text-white/50`),children:e.text},e.id)),(0,K.jsx)(`div`,{ref:t})]})}):null}function Ge({voice:e,view:t,video:n,className:r}){let i=e.state===`live`,a=e.state===`connecting`,[s,c]=(0,G.useState)(null),[l,u]=(0,G.useState)(!1);(0,G.useEffect)(()=>{c(i?Date.now():null)},[i]);let d=async()=>{u(!1),await e.start(),n&&await e.startCamera()},f=()=>{e.stop(),u(!0)},p=n||e.camera,m=[...e.captions].reverse().find(e=>e.who===`bot`),h=[...e.captions].reverse().find(e=>e.who===`me`),g=e.speaking?U(`talk.speaking`):e.listening?U(`talk.listening`):i?U(`talk.live`):a?U(`talk.connecting`):l?U(`video.ended`):``;return(0,K.jsxs)(`section`,{className:E(`relative flex min-h-0 flex-col bg-neutral-950 text-white`,`safe-top`,r),children:[(0,K.jsxs)(`div`,{className:`flex h-14 shrink-0 items-center gap-3 px-4 sm:px-5`,children:[(0,K.jsx)(`div`,{className:`min-w-0 flex-1 truncate font-display font-semibold text-[1rem] tracking-tight`,children:t?.wizard.title??``}),g?(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[0.8125rem] text-white/70`,children:[i?(0,K.jsx)(`span`,{className:E(`size-2 rounded-full`,e.speaking?`animate-pulse-dot bg-emerald-400`:`bg-rose`)}):null,g]}):null,(0,K.jsx)(He,{since:s})]}),(0,K.jsxs)(`div`,{className:E(`grid min-h-0 gap-2 px-3 pb-2 sm:px-4`,p?`flex-1 grid-cols-1 sm:grid-cols-2`:`shrink-0 grid-cols-1`,!p&&i&&e.captions.length?`h-[38%]`:p?``:`flex-1`),children:[(0,K.jsxs)(`div`,{className:E(`relative min-h-0 overflow-hidden rounded-2xl bg-neutral-900`,!p&&`hidden`),children:[(0,K.jsx)(`video`,{ref:e.video,muted:!0,playsInline:!0,autoPlay:!0,className:E(`absolute inset-0 h-full w-full object-cover`,e.facing===`user`&&`-scale-x-100`,e.camera?`block`:`hidden`)}),e.camera?null:(0,K.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-2 text-white/50`,children:[(0,K.jsx)(Pe,{className:`size-8`}),(0,K.jsx)(`span`,{className:`text-[0.8125rem]`,children:U(`video.cameraOff`)})]}),(0,K.jsxs)(`span`,{className:`absolute bottom-2 left-3 rounded-md bg-black/50 px-2 py-0.5 text-[0.75rem]`,children:[U(`video.you`),e.muted?(0,K.jsx)(ae,{className:`ml-1.5 inline size-3`}):null]})]}),(0,K.jsxs)(`div`,{className:E(`relative flex min-h-0 items-center justify-center overflow-hidden rounded-2xl transition-shadow`,p?`bg-neutral-900`:`bg-transparent`,p&&e.speaking&&`ring-2 ring-emerald-400/70`),children:[(0,K.jsx)(`div`,{className:E(`rounded-full transition-shadow duration-500`,!p&&e.listening&&`shadow-[0_0_80px_20px_rgba(244,63,94,0.25)]`,!p&&e.speaking&&`shadow-[0_0_80px_20px_rgba(52,211,153,0.3)]`,e.speaking&&`animate-breathe`),children:(0,K.jsx)(ue,{kind:t?.wizard.avatar??`round`,costume:t?.wizard.costume,size:p?140:200,fluffy:!0,interactive:!1})}),p?(0,K.jsx)(`span`,{className:`absolute bottom-2 left-3 max-w-[85%] truncate rounded-md bg-black/50 px-2 py-0.5 text-[0.75rem]`,children:t?.wizard.title??``}):null]})]}),i&&!p?(0,K.jsx)(We,{voice:e}):i&&(m||h)?(0,K.jsx)(`div`,{className:`shrink-0 px-4 pb-2 sm:px-5`,children:(0,K.jsxs)(`div`,{className:`mx-auto max-w-[720px] space-y-1 text-center`,children:[h?(0,K.jsx)(`p`,{className:`line-clamp-1 text-[0.8125rem] text-white/50`,children:h.text}):null,m?(0,K.jsx)(`p`,{className:`line-clamp-3 text-[0.9375rem] text-white/95 leading-snug`,children:m.text}):null]})}):null,e.error?(0,K.jsx)(`p`,{className:`shrink-0 px-5 pb-2 text-center text-[0.8125rem] text-rose`,children:e.error}):null,(0,K.jsx)(`div`,{className:`flex shrink-0 items-center justify-center gap-3 px-4 pt-1 pb-4`,children:i?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ue,{label:U(e.muted?`video.unmute`:`video.mute`),on:!e.muted,onClick:e.toggleMute,children:e.muted?(0,K.jsx)(ae,{className:`size-5`}):(0,K.jsx)(o,{className:`size-5`})}),(0,K.jsx)(Ue,{label:U(e.camera?`talk.cameraOff`:`talk.camera`),on:e.camera,onClick:()=>e.camera?e.stopCamera():void e.startCamera(),children:e.camera?(0,K.jsx)(x,{className:`size-5`}):(0,K.jsx)(Pe,{className:`size-5`})}),e.camera&&Ve?(0,K.jsx)(Ue,{label:U(`video.flip`),onClick:()=>void e.flipCamera(),children:(0,K.jsx)(S,{className:`size-5`})}):null,(0,K.jsx)(Ue,{label:U(`video.leave`),danger:!0,onClick:f,children:(0,K.jsx)(le,{className:`size-5`})})]}):(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[(0,K.jsxs)(`button`,{type:`button`,disabled:a||!t?.talk,onClick:()=>void d(),className:`flex h-12 items-center gap-2 rounded-full bg-emerald-500 px-6 font-medium text-[0.9375rem] text-white transition hover:brightness-110 disabled:opacity-50`,children:[a?(0,K.jsx)(F,{className:`size-4`}):n?(0,K.jsx)(x,{className:`size-5`}):(0,K.jsx)(o,{className:`size-5`}),U(l?`video.rejoin`:n?`video.join`:`talk.start`)]}),!l&&!e.error?(0,K.jsx)(`p`,{className:`max-w-sm text-center text-[0.75rem] text-white/50`,children:U(n?`video.hint`:`talk.joinHint`)}):null]})})]})}var Ke=e=>_e[e.kind]!==`device`,qe=1024,Je=4e3;function Ye(e,t){return e?e.length>t?`${e.slice(0,t)} …`:e:``}function Xe(e,t,n=!1){let r=[`status: ${e.status}`,`camera: ${n?`on`:`off`}`];if(e.ask)return r.push(e.ask.kind===`confirm`?`question: the step wants to "${e.ask.action.summary}" in ${e.ask.service}; answer_ask allows or skips it`:`question: a sign-in at ${e.ask.site.host}; the person types it on the screen, wait`),r.join(`
3
3
  `);if(e.status===`running`){let t=[...e.events].reverse().find(e=>e.type===`tool`||e.type===`info`||e.type===`step_started`);return r.push(`working on: ${e.step?.title??``}`),t&&r.push(`doing: ${we(t)}`),r.join(`
4
4
  `)}if(e.status===`sleeping`)return r.push(`waiting until: ${e.wakeAt??`soon`}; it goes on by itself, nothing to do`),r.join(`
5
5
  `);if(e.status===`done`){r.push(`done. made:`);for(let{step:t,output:n}of e.shown)r.push(`- ${t.title}: ${Ye(n?.text,400)||`(a file, on the screen)`}`);return r.join(`
@@ -9,4 +9,4 @@ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./j
9
9
  `)}return r.push(`step: ${e.step?.title??``}`),r.join(`
10
10
  `)}function Ze(e,t,n,r){let[i,a]=(0,G.useState)(`off`),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(!1),[f,p]=(0,G.useState)(!1),[m,g]=(0,G.useState)(`environment`),[_,v]=(0,G.useState)(!1),[y,b]=(0,G.useState)([]),x=(0,G.useRef)(null),S=(0,G.useRef)(null),C=(0,G.useRef)(0),w=(0,G.useRef)(!1);w.current=f;let T=(0,G.useRef)(null),E=(0,G.useRef)(null),D=(0,G.useRef)(null),O=(0,G.useRef)(null),k=(0,G.useRef)(t);k.current=t;let A=(0,G.useRef)(r);A.current=r;let j=(0,G.useRef)(n);j.current=n;let M=(0,G.useRef)(``),N=(0,G.useCallback)(e=>{let t=E.current;t&&t.readyState===`open`&&t.send(JSON.stringify(e))},[]),P=(0,G.useCallback)(()=>{let e=x.current;if(!w.current||!e||e.videoWidth===0)return null;let t=Math.min(1,qe/e.videoWidth),n=document.createElement(`canvas`);return n.width=Math.round(e.videoWidth*t),n.height=Math.round(e.videoHeight*t),n.getContext(`2d`)?.drawImage(e,0,0,n.width,n.height),n.toDataURL(`image/jpeg`,.75)},[]),F=(0,G.useCallback)(()=>{for(let e of S.current?.getTracks()??[])e.stop();S.current=null,x.current&&(x.current.srcObject=null),p(!1)},[]),I=(0,G.useCallback)(async e=>{if(S.current)return;let t=e??`environment`;try{let e=await navigator.mediaDevices.getUserMedia({video:{facingMode:{ideal:t},width:{ideal:1280}},audio:!1});S.current=e;let n=e.getVideoTracks()[0]?.getSettings().facingMode;g(n===`user`||n===`environment`?n:t),x.current&&(x.current.srcObject=e,await x.current.play().catch(()=>void 0)),p(!0)}catch(e){s(e.name===`NotAllowedError`?U(`talk.cameraDenied`):e.message)}},[]),ee=(0,G.useCallback)(async()=>{let e=m===`user`?`environment`:`user`;F(),await I(e)},[m,F,I]),te=(0,G.useCallback)(()=>{v(e=>{for(let t of O.current?.getAudioTracks()??[])t.enabled=e;return!e})},[]),L=(0,G.useCallback)(()=>{F(),E.current?.close(),E.current=null,T.current?.close(),T.current=null;for(let e of O.current?.getTracks()??[])e.stop();O.current=null,D.current&&=(D.current.srcObject=null,D.current.remove(),null),M.current=``,l(!1),d(!1),v(!1),a(`off`)},[F]);(0,G.useEffect)(()=>()=>L(),[L]);let R=(0,G.useCallback)(async(t,n)=>{let r=k.current,i=A.current,a=j.current;switch(t){case`get_state`:return r?Xe(r,i,w.current):`no run`;case`look`:{let e=P();return e?(N({type:`conversation.item.create`,item:{type:`message`,role:`user`,content:[{type:`input_text`,text:`[camera] what the person shows right now`},{type:`input_image`,image_url:e}]}}),`a picture arrived as the next message`):`the camera is off; ask the person to switch it on`}case`take_photo`:{if(!i)return`no page is open`;let t=i.fields.find(e=>e.id===String(n.field??``));if(t?.kind!==`image`)return`no such photo field on this page`;let r=P();if(!r)return`the camera is off; ask the person to switch it on`;try{let n=await(await fetch(r)).blob(),a=new File([n],`photo-${Date.now()}.jpg`,{type:`image/jpeg`}),o=await h.upload(`/api/runs/${e}/uploads`,a),s=i.values[t.id],c=t.multiple?[...Array.isArray(s)?s:s?[s]:[],o.id]:o.id,l=i.setField(t.id,c);return l?`refused: ${l}`:`the photo is in the field`}catch(e){return`failed: ${e.message}`}}case`set_field`:{if(!i)return`no page is open`;let e=i.setField(String(n.field??``),n.value);return e?`refused: ${e}`:`kept`}case`submit_page`:{if(!i)return`no page is open`;let e=i.fields.filter(e=>e.required&&Ke(e)&&e.kind!==`toggle`&&(i.values[e.id]===void 0||i.values[e.id]===null||i.values[e.id]===``));return e.length?`still open: ${e.map(e=>e.id).join(`, `)}`:(i.submit(),`sent; wait for the next state`)}case`accept_review`:return r?.step?.type===`review`?await a.accept(r.step.id)?`accepted`:a.error??`refused`:`no review is open`;case`regenerate`:return r?.step?.type===`review`?await a.regenerate(r.step.id,String(n.target??``),String(n.note??``))?`the wizard makes it again; wait`:a.error??`refused`:`no review is open`;case`answer_ask`:if(!r?.ask)return`no question is open`;try{return await h.post(`/api/runs/${e}/ask/${r.ask.id}`,{type:n.allow?`done`:`skip`}),n.allow?`allowed`:`skipped`}catch(e){return`refused: ${e.message}`}case`go_back`:return await a.back()?`went back; wait for the state`:a.error??`refused`;default:return`unknown tool ${t}`}},[e,P,N]),z=(0,G.useCallback)(async()=>{if(!T.current){s(null),b([]),a(`connecting`);try{let t=await h.post(`/api/runs/${e}/talk`),n=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}});O.current=n;let r=new RTCPeerConnection;T.current=r;let i=document.createElement(`audio`);i.autoplay=!0,i.setAttribute(`playsinline`,``),document.body.append(i),D.current=i,r.ontrack=e=>{i.srcObject=e.streams[0]};for(let e of n.getTracks())r.addTrack(e,n);let o=r.createDataChannel(`oai-events`);E.current=o,o.onmessage=e=>{let t;try{t=JSON.parse(e.data)}catch{return}switch(t.type){case`output_audio_buffer.started`:l(!0);break;case`output_audio_buffer.stopped`:case`output_audio_buffer.cleared`:l(!1);break;case`input_audio_buffer.speech_started`:{d(!0);let e=Date.now()-C.current>Je?P():null;e&&(C.current=Date.now(),N({type:`conversation.item.create`,item:{type:`message`,role:`user`,content:[{type:`input_text`,text:`[camera] what the person shows while speaking`},{type:`input_image`,image_url:e}]}}));break}case`input_audio_buffer.speech_stopped`:d(!1);break;case`response.output_audio_transcript.done`:case`conversation.item.input_audio_transcription.completed`:{let e=String(t.transcript??``).trim();if(e){let n=t.type===`response.output_audio_transcript.done`?`bot`:`me`;b(t=>[...t.slice(-199),{id:`${Date.now()}:${n}`,who:n,text:e}])}break}case`response.function_call_arguments.done`:{let e=String(t.name??``),n=String(t.call_id??``),r={};try{r=JSON.parse(String(t.arguments??`{}`))}catch{}R(e,r).then(e=>{N({type:`conversation.item.create`,item:{type:`function_call_output`,call_id:n,output:e}}),N({type:`response.create`})});break}case`error`:s(String(t.error?.message??`error`))}},o.onopen=()=>{a(`live`);let e=k.current;e&&(M.current=Xe(e,A.current,w.current),N({type:`conversation.item.create`,item:{type:`message`,role:`user`,content:[{type:`input_text`,text:`[state]\n${M.current}\n\nGreet the person in one sentence and ask the first open field.`}]}}),N({type:`response.create`}))},o.onclose=()=>{T.current===r&&L()};let c=await r.createOffer();await r.setLocalDescription(c);let u=await fetch(t.endpoint,{method:`POST`,headers:{authorization:`Bearer ${t.clientSecret}`,"content-type":`application/sdp`},body:c.sdp});if(!u.ok)throw Error(`${U(`talk.failed`)} (${u.status})`);await r.setRemoteDescription({type:`answer`,sdp:await u.text()})}catch(e){L(),s(e.name===`NotAllowedError`?U(`chat.micDenied`):e.message),a(`error`)}}},[e,R,P,N,L]);return(0,G.useEffect)(()=>{if(i!==`live`||!t)return;let e=Xe(t,r,f);if(e===M.current)return;let n=M.current;M.current=e,N({type:`conversation.item.create`,item:{type:`message`,role:`user`,content:[{type:`input_text`,text:`[state]\n${e}`}]}}),(t.status===`running`&&n.startsWith(`status: running`)&&!n.includes(`working on: `)||t.status!==`running`||n.split(`
11
11
  `)[1]!==e.split(`
12
- `)[1])&&N({type:`response.create`})},[i,t,r,f,N]),{state:i,error:o,speaking:c,listening:u,start:z,stop:L,camera:f,facing:m,startCamera:I,stopCamera:F,flipCamera:ee,muted:_,toggleMute:te,captions:y,video:x}}var Qe=[`classifier`,`low`],$e=12e3;function et(e){T(`think`)&&h.post(`/api/runs/${e}/device`,{think:{classes:Qe,maxChars:$e}}).catch(()=>void 0)}async function tt(e,t){if(t.kind!==`think`)return;let n;try{let e=await D(`think`,{system:t.system,prompt:t.prompt,schema:t.schema});n={text:String(e?.text??``)}}catch(e){n={error:e.message.slice(0,500)}}await h.post(`/api/runs/${e}/device/${t.id}`,n).catch(()=>void 0)}var nt=45e3;function rt(e){let[t,n]=(0,G.useState)(null),[r,i]=(0,G.useState)(null),[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(!1),[l,d]=(0,G.useState)({});(0,G.useEffect)(()=>{if(n(null),o(!1),!e)return;let t=!1,r=0,i,a=null,s=Date.now(),c=()=>{t=!0,a?.close(),o(!0)},l=async()=>{try{let r=await h.get(`/api/runs/${e}`);t||n(r)}catch(e){e instanceof u&&e.status===404&&c()}},d=()=>{if(clearTimeout(i),a?.close(),t)return;let o=new EventSource(M(`/api/runs/${e}/stream`),{withCredentials:!0});a=o,s=Date.now(),et(e),o.addEventListener(`device`,t=>{s=Date.now(),tt(e,JSON.parse(t.data))}),o.addEventListener(`view`,e=>{r=0,s=Date.now(),n(JSON.parse(e.data))}),o.addEventListener(`ping`,()=>{s=Date.now()}),o.onerror=()=>{o.close(),!(t||a!==o)&&(a=null,l(),r=Math.min(r+1,6),i=setTimeout(d,500*2**r))}},f=()=>{t||document.visibilityState!==`visible`||(!a||a.readyState===EventSource.CLOSED||Date.now()-s>nt?(r=0,d()):l())},p=setInterval(()=>{!t&&a&&Date.now()-s>nt&&(r=0,d())},15e3);return d(),document.addEventListener(`visibilitychange`,f),window.addEventListener(`pageshow`,f),window.addEventListener(`online`,f),()=>{t=!0,clearTimeout(i),clearInterval(p),document.removeEventListener(`visibilitychange`,f),window.removeEventListener(`pageshow`,f),window.removeEventListener(`online`,f),a?.close()}},[e]);let f=(0,G.useCallback)(async(t,n)=>{if(!e)return!1;c(!0),i(null),d({});try{return await h.post(`/api/runs/${e}/${t}`,n),!0}catch(e){return e instanceof u&&e.status===422&&Array.isArray(e.body?.fields)&&d(Object.fromEntries(e.body.fields.map(e=>[e.field,e.message]))),i(e.message),!1}finally{c(!1)}},[e]);return Se(t?.translation?.labels),{view:t,notFound:a,error:r,busy:s,fieldErrors:l,submitPage:(e,t)=>f(`pages/${e}`,{values:t}),accept:(e,t)=>f(`reviews/${e}`,{type:`accept`,edits:t}),regenerate:(e,t,n,r)=>f(`reviews/${e}`,{type:`regenerate`,target:t,note:n,items:r?.length?r:void 0}),back:()=>f(`back`),retry:()=>f(`retry`),translateResult:e=>f(`translate-result`,{stepId:e}),setLang:e=>f(`lang`,{lang:e})}}var q=(e,t,n)=>({key:e,who:`bot`,node:t,...n}),it=(e,t,n)=>({key:e,who:`me`,node:t,...n}),at=(0,G.createContext)(null),J=(0,G.createContext)(null);function ot(){return(0,G.useContext)(J)?.voice??null}function st({children:e}){let t=(0,G.useContext)(at);return t?(0,Be.createPortal)(e,t):null}function ct({header:e,footer:t,children:n}){let[r,i]=(0,G.useState)(null),a=(0,G.useRef)(null),o=(0,G.useRef)(null),s=(0,G.useRef)(!0);return(0,G.useLayoutEffect)(()=>{let e=a.current,t=o.current;if(!e||!t)return;let n=e.scrollTop,r=()=>{e.scrollHeight-e.scrollTop-e.clientHeight<120?s.current=!0:e.scrollTop<n&&(s.current=!1),n=e.scrollTop},i=null,c=new ResizeObserver(()=>{let r=t.querySelector(`[data-anchor]`);r&&r!==i?(i=r,e.scrollTop+=r.getBoundingClientRect().top-e.getBoundingClientRect().top-12,s.current=!1,n=e.scrollTop):s.current&&(e.scrollTop=e.scrollHeight)});return e.scrollTop=e.scrollHeight,e.addEventListener(`scroll`,r,{passive:!0}),c.observe(t),c.observe(e),()=>{c.disconnect(),e.removeEventListener(`scroll`,r)}},[]),(0,K.jsx)(at.Provider,{value:r,children:(0,K.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[e,(0,K.jsx)(`div`,{ref:a,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,K.jsx)(`div`,{ref:o,className:`mx-auto flex w-full max-w-[760px] flex-col gap-3 px-3 pt-5 pb-4 sm:px-6`,children:n})}),(0,K.jsxs)(`div`,{className:`shrink-0 border-border-soft border-t bg-background`,onPointerDownCapture:()=>{s.current=!0},onKeyDownCapture:()=>{s.current=!0},children:[(0,K.jsx)(`div`,{ref:i,className:`mx-auto w-full max-w-[760px] px-3 pt-3 sm:px-6`}),t]})]})})}function Y({avatar:e,costume:t,lines:n}){let r=(0,G.useContext)(J),i=(0,G.useMemo)(()=>n.map(e=>({key:e.key,who:e.who,spoken:!e.bare&&!e.wide})),[n]),a=(0,G.useCallback)(e=>{let t=document.querySelector(`[data-say="${CSS.escape(e)}"]`);return t?.querySelector(`[data-say-text]`)?.getAttribute(`data-say-text`)??t?.innerText??null},[]);se(!!r?.readAloud,r?.lang??Ce,i,a);let o=[];for(let e of n){let t=o.at(-1);t&&t.who===`bot`&&e.who===`bot`?t.lines.push(e):o.push({who:e.who,lines:[e]})}return o.map((n,r)=>n.who===`bot`?(0,K.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,K.jsx)(`div`,{className:`sticky top-1 shrink-0 pt-0.5`,children:(0,K.jsx)(pe,{kind:e,costume:t,size:30,interactive:r>=o.length-2})}),(0,K.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col items-start gap-1.5`,children:n.lines.map(e=>(0,K.jsx)(`div`,{"data-anchor":e.anchor?``:void 0,"data-say":e.key,className:E(`animate-rise`,e.bare?`w-full pt-1`:`rounded-2xl rounded-tl-md text-[0.9375rem] text-ink leading-relaxed`,!e.bare&&(e.wide?E(`w-full bg-card p-4 shadow-soft ring-1 ring-border-soft`,e.wide===`most`&&`md:w-4/5`):`max-w-[min(36rem,100%)] bg-card px-4 py-2.5 shadow-soft ring-1 ring-border-soft`),e.tone===`error`&&`bg-rose-tint text-rose shadow-none ring-0`),children:e.node},e.key))})]},n.lines[0].key):n.lines.map(e=>(0,K.jsxs)(`div`,{className:`flex animate-rise flex-col items-end gap-1 pl-10`,children:[(0,K.jsx)(`div`,{className:`max-w-[min(32rem,100%)] whitespace-pre-wrap break-words rounded-2xl rounded-br-md bg-primary px-4 py-2.5 text-[0.9375rem] text-primary-foreground leading-relaxed`,children:e.node}),e.onEdit?(0,K.jsxs)(`button`,{type:`button`,onClick:e.onEdit,className:`inline-flex items-center gap-1 px-1 text-[0.75rem] text-ink-4 transition hover:text-ink-2 coarse:min-h-9`,children:[(0,K.jsx)(A,{className:`size-3`}),` `,U(`chat.change`)]}):null]},e.key)))}function lt(){return(0,K.jsx)(`span`,{className:`inline-flex items-center gap-1 py-1.5`,role:`status`,"aria-label":U(`run.working`),children:[0,1,2].map(e=>(0,K.jsx)(`span`,{className:`size-1.5 animate-typing rounded-full bg-ink-3`,style:{animationDelay:`${e*160}ms`}},e))})}function ut({children:e}){return(0,K.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:e})}var X=(e,t)=>q(e,(0,K.jsx)(ut,{children:t}),{bare:!0});function Z({onClick:e,children:t,primary:n,on:r,disabled:i,busy:a}){return(0,K.jsxs)(`button`,{type:`button`,"aria-pressed":r,disabled:i||a,onClick:e,className:E(`inline-flex h-10 items-center gap-1.5 rounded-full px-4 font-medium text-[0.875rem] transition active:scale-[0.98] disabled:pointer-events-none disabled:opacity-50 coarse:h-11`,n?`bg-primary text-primary-foreground hover:brightness-[1.06]`:r?`bg-ember-tint text-ink ring-1 ring-ember`:`bg-card text-ink-2 ring-1 ring-input hover:text-ink hover:ring-ink-4`),children:[a?(0,K.jsx)(F,{className:`size-4`}):null,t]})}function dt({initial:e=``,placeholder:t,multiline:n,inputProps:r,busy:i,disabled:a,inputRef:s,onSend:c}){let[l,u]=(0,G.useState)(e),d=(0,G.useRef)(null),f=s??d,p=(0,G.useContext)(J),m=w(l,u,{endpoint:p?`/api/runs/${p.runId}/transcribe`:void 0}),h=!!p&&m.supported&&!a;(0,G.useEffect)(()=>{if(!h)return;let e=e=>{(e.metaKey||e.ctrlKey)&&e.shiftKey&&e.key.toLowerCase()===`m`&&(e.preventDefault(),m.toggle())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[h,m.toggle]),(0,G.useEffect)(()=>{!y&&!a&&f.current?.focus()},[a,f]);let g=()=>{i||a||(m.listening&&m.toggle(),c(l)!==!1&&u(``))},_=m.listening?U(`chat.listening`):m.processing?U(`chat.transcribing`):t,v=p?.voice??null,b=!!p?.call,S=p&&!b&&(ce||h||v)?(0,K.jsxs)(`div`,{className:`mb-1 flex shrink-0 items-center`,children:[v?(0,K.jsx)(O,{label:U(v.state===`live`?`talk.stop`:v.state===`connecting`?`talk.connecting`:`talk.start`),"aria-pressed":v.state===`live`,disabled:v.state===`connecting`,onClick:()=>v.state===`live`?v.stop():void v.start(),className:E(`size-9`,v.state===`live`&&`bg-rose-tint text-rose hover:bg-rose-tint hover:text-rose`,v.state===`off`&&p.talk&&`bg-primary text-primary-foreground hover:bg-primary`),children:v.state===`connecting`?(0,K.jsx)(F,{className:`size-4`}):v.state===`live`?(0,K.jsx)(le,{className:`size-4`}):(0,K.jsx)(me,{className:`size-4`})}):null,v?.state===`live`?(0,K.jsx)(O,{label:U(v.camera?`talk.cameraOff`:`talk.camera`),"aria-pressed":v.camera,onClick:()=>v.camera?v.stopCamera():void v.startCamera(),className:E(`size-9`,v.camera&&`text-ink`),children:v.camera?(0,K.jsx)(x,{className:`size-4`}):(0,K.jsx)(Pe,{className:`size-4`})}):null,ce?(0,K.jsx)(O,{label:U(p.readAloud?`chat.readAloudOff`:`chat.readAloud`),"aria-pressed":p.readAloud,onClick:()=>p.setReadAloud(!p.readAloud),className:E(`size-9`,p.readAloud&&`text-ink`),children:p.readAloud?(0,K.jsx)(re,{className:`size-4`}):(0,K.jsx)(Ie,{className:`size-4`})}):null,h?(0,K.jsx)(O,{label:U(m.listening?`chat.dictateStop`:`chat.dictate`),"aria-pressed":m.listening,disabled:m.processing,onClick:m.toggle,className:E(`size-9`,m.listening&&`bg-rose-tint text-rose hover:bg-rose-tint hover:text-rose`),children:m.processing?(0,K.jsx)(F,{className:`size-4`}):m.listening?(0,K.jsx)(ee,{className:`size-3.5 animate-pulse-dot fill-current`}):(0,K.jsx)(o,{className:`size-4`})}):null]}):null;return(0,K.jsxs)(`form`,{className:`pb-3`,onSubmit:e=>{e.preventDefault(),g()},children:[v&&!b?(0,K.jsx)(`video`,{ref:v.video,muted:!0,playsInline:!0,autoPlay:!0,className:E(`mb-2 ml-auto w-32 rounded-xl bg-black object-cover shadow-soft ring-1 ring-border-soft`,v.camera?`block`:`hidden`)}):null,(0,K.jsxs)(`div`,{className:E(`flex items-end gap-1 rounded-[1.375rem] border border-input bg-card pr-1.5 pl-1 transition focus-within:border-focus focus-within:ring-4 focus-within:ring-focus-glow`,a&&`opacity-60`),children:[S,n?(0,K.jsx)(j,{ref:f,minRows:1,maxRows:6,value:l,disabled:a,placeholder:_,autoCapitalize:`sentences`,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!y&&!e.nativeEvent.isComposing&&(e.preventDefault(),g())},className:`min-h-11 border-0 bg-transparent py-2.5 shadow-none focus:ring-0`}):(0,K.jsx)(`input`,{ref:f,...r,value:l,disabled:a,placeholder:_,enterKeyHint:`send`,onChange:e=>u(e.target.value),className:`h-11 min-w-0 flex-1 bg-transparent px-3 text-[0.9375rem] text-ink outline-none placeholder:text-ink-4`}),(0,K.jsx)(`button`,{type:`submit`,"aria-label":U(`chat.send`),title:U(`chat.send`),disabled:i||a,className:`mb-1 flex size-9 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground transition hover:brightness-[1.06] disabled:opacity-40`,children:i?(0,K.jsx)(F,{className:`size-4`}):(0,K.jsx)(P,{className:`size-4`})})]}),m.error?(0,K.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-rose`,children:m.error===`denied`?U(`chat.micDenied`):m.error}):b?null:v?.error?(0,K.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-rose`,children:v.error}):v?.state===`live`?(0,K.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-ink-3`,children:v.speaking?U(`talk.speaking`):v.listening?U(`talk.listening`):U(`talk.live`)}):p?.talk&&v?.state===`off`?(0,K.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-ink-3`,children:U(`talk.hint`)}):null]})}function Q({placeholder:e=U(`chat.above`)}){return(0,K.jsx)(st,{children:(0,K.jsx)(dt,{disabled:!0,placeholder:e,onSend:()=>!1})})}function ft(e){let t=_e[e.kind];return t===`typed`&&!e.scan?`typed`:t===`tapped`?`tapped`:`control`}var pt=e=>e==null||e===``||Array.isArray(e)&&e.length===0;function mt(e,t){let n=e.kind===`toggle`||e.kind===`connection`||e.kind===`list`;if(pt(t))return e.required&&!n?U(`chat.required`):null;let r=String(t).trim();if(e.kind===`email`&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(r))return U(`chat.badEmail`);if(e.kind===`url`)try{new URL(r)}catch{return U(`chat.badUrl`)}return e.kind===`number`&&De(r)===null?U(`chat.badNumber`):Array.isArray(t)&&e.multiple&&e.min&&t.length<e.min?U(`run.filesMin`,{n:t.length,min:e.min}):null}function ht(e,t){let n=e.kind===`textarea`?t.replace(/\s+$/,``):t.trim();if(n)return e.kind===`url`&&!/^[a-z][a-z0-9+.-]*:/i.test(n)?`https://${n}`:n}function gt({field:e}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`font-medium`,children:e.label}),e.help?(0,K.jsx)(`span`,{className:`mt-0.5 block text-[0.8125rem] text-ink-3`,children:e.help}):null]})}function _t({step:e,only:t}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`font-medium`,children:e.title}),e.description?(0,K.jsx)(`span`,{className:`mt-0.5 block text-ink-2`,children:e.description}):null,t?.help?(0,K.jsx)(`span`,{className:`mt-1 block text-[0.8125rem] text-ink-3`,children:t.help}):null]})}function vt({field:e,value:t,runId:n}){if(e.kind===`connection`)return(0,K.jsx)(K.Fragment,{children:typeof t==`string`&&t?t:U(`chat.connected`)});if(e.kind===`list`)return(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,K.jsx)(ne,{className:`size-4`}),` `,U(`chat.checked`)]});if(e.kind===`toggle`)return(0,K.jsx)(K.Fragment,{children:U(t===!0?`run.yes`:`run.no`)});if(pt(t))return(0,K.jsx)(`span`,{className:`italic opacity-80`,children:U(`chat.skipped`)});switch(e.kind){case`multiselect`:return(0,K.jsx)(K.Fragment,{children:t.map(Te).join(`, `)});case`select`:return(0,K.jsx)(K.Fragment,{children:Te(String(t))});case`date`:{let e=new Date(`${String(t)}T00:00`);return(0,K.jsx)(K.Fragment,{children:Number.isNaN(e.getTime())?String(t):new Intl.DateTimeFormat(Ce,{dateStyle:`long`}).format(e)})}case`color`:return(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`size-4 rounded-full ring-1 ring-white/50`,style:{background:String(t)}}),String(t)]});case`image`:case`signature`:return(0,K.jsx)(`span`,{className:`-mx-1.5 flex flex-wrap gap-1.5`,children:(Array.isArray(t)?t:[String(t)]).map(t=>(0,K.jsx)(`img`,{src:M(`/api/runs/${n}/assets/${t}`),alt:``,className:E(`h-16 rounded-lg bg-white`,e.kind===`image`?`w-16 object-cover`:`object-contain px-1`)},t))});case`file`:{let e=Array.isArray(t)?t.length:1;return(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,K.jsx)(d,{className:`size-4`}),` `,U(e===1?`chat.file`:`chat.files`,{n:e})]})}case`audio`:{let e=t.seconds;return(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,K.jsx)(o,{className:`size-4`}),` `,U(`chat.voice`),e?` · ${Math.round(e)} s`:``]})}case`location`:{let e=t;return(0,K.jsx)(K.Fragment,{children:e.label||`${e.lat?.toFixed(5)}, ${e.lng?.toFixed(5)}`})}case`items`:return(0,K.jsx)(K.Fragment,{children:U(`chat.rows`,{n:Array.isArray(t)?t.length:0})});default:return(0,K.jsx)(K.Fragment,{children:String(t)})}}function yt(e,t,n,r,i,a){let o=[q(t,(0,K.jsx)(_t,{step:e,only:a}))];for(let e of i)a||o.push(q(`${t}:${e.id}`,(0,K.jsx)(gt,{field:e}))),o.push(it(`${t}:${e.id}:a`,(0,K.jsx)(vt,{field:e,value:n[e.id],runId:r})));return o}var bt=(e,t)=>e.fields.filter(e=>!e.when&&!be(e)||t[e.id]!==void 0&&t[e.id]!==null);function xt(e,t){let n=[];e.wizard.description&&n.push(q(`hello`,e.wizard.description)),e.wizard.intro&&n.push(q(`intro`,e.wizard.intro));for(let[t,r]of e.answered.entries()){let i=`${t}:${r.id}`;if(r.type===`page`){let t=r.fields.length===1?r.fields[0]:void 0;n.push(...yt(r,i,e.values,e.id,bt(r,e.values),t))}else r.type===`review`&&(n.push(q(i,(0,K.jsx)(`span`,{className:`font-medium`,children:r.title}))),n.push(it(`${i}:a`,U(`run.accept`))))}let r=n.at(-1);return t&&r?.who===`me`&&(n[n.length-1]={...r,onEdit:t}),n}function St(e,t){return e.fields.filter(e=>!be(e)||t.decidedFields?.includes(e.id)).map(e=>t.options?.[e.id]?.length?{...e,options:t.options[e.id]}:e)}function Ct({view:e,run:t,step:n,before:i}){let a=(0,G.useMemo)(()=>St(n,e),[n,e]),o=e.known??{},[s,c]=(0,G.useState)(()=>_(n,e)),[l,u]=(0,G.useState)(()=>n.fields.some(t=>e.values[t.id]!==void 0)?H(St(n,e),e.known??{},_(n,e)).slice(0,-1).map(e=>e.id):[]),[d,f]=(0,G.useState)({}),[p,m]=(0,G.useState)(!1),[h,g]=(0,G.useState)(!1),v=H(a,o,s),y=v.filter(e=>l.includes(e.id)),b=v.find(e=>!l.includes(e.id)),x=a.length===1?a[0]:void 0,S=y.at(-1),C=S?()=>u(e=>e.filter(e=>e!==S.id)):void 0;(0,G.useEffect)(()=>{let e=Object.keys(t.fieldErrors),n=H(a,o,s),r=n.findIndex(t=>e.includes(t.id));r>=0&&(u(n.slice(0,r).map(e=>e.id)),f(t.fieldErrors))},[t.fieldErrors]);let w=e=>{t.submitPage(n.id,e).then(g)},T=(0,G.useContext)(J),E=(0,G.useRef)(s);E.current=s;let D=T?.bindPage,O=(0,G.useRef)(w);O.current=w,(0,G.useEffect)(()=>{if(!D)return;let e=H(a,o,s);return D({step:n,fields:e,values:s,setField:(t,n)=>{let r=e.find(e=>e.id===t);return r?mt(r,n)||(c(e=>({...e,[t]:n})),u(e=>e.includes(t)?e:[...e,t]),f({}),null):`no such field on this page`},submit:()=>O.current(E.current)}),()=>D(null)},[D,n,a,o,s]);let k=e=>{if(!b)return!1;let t=mt(b,e);if(t)return f({[b.id]:t}),!1;let n={...s,[b.id]:e},r=[...l,b.id];return c(n),u(r),f({}),H(a,o,n).some(e=>!r.includes(e.id))||w(n),!0},A=[...i.map(e=>l.length?{...e,onEdit:void 0}:e),...yt(n,`now:${n.id}`,s,e.id,y,x).map((e,t,n)=>t===n.length-1&&e.who===`me`&&b?{...e,onEdit:C}:e)];b?(ft(b)===`control`?A.push(q(`now:${n.id}:${b.id}:control`,(0,K.jsx)(r,{field:b,value:s[b.id],values:s,runId:e.id,view:e,closed:e.closed?.[b.id],onChange:e=>c(t=>({...t,[b.id]:e})),onBusy:m}),{wide:!0})):x||A.push(q(`now:${n.id}:${b.id}`,(0,K.jsx)(gt,{field:b}))),d[b.id]&&A.push(q(`now:${n.id}:${b.id}:error`,d[b.id],{tone:`error`}))):t.busy||h?A.push(q(`sending`,(0,K.jsx)(lt,{}))):t.error&&A.push(q(`send-error`,t.error,{tone:`error`}));let j=(0,K.jsx)(Q,{});if(h||!b&&l.length>0&&t.busy)j=(0,K.jsx)(Q,{placeholder:U(`run.working`)});else if(!b)A.push(X(`now:${n.id}:go`,(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Z,{primary:!0,busy:t.busy,onClick:()=>w(s),children:n.cta||U(`run.next`)}),C?(0,K.jsx)(Z,{onClick:C,disabled:t.busy,children:U(`run.back`)}):null]})));else{let r=ft(b),i=!b.required&&b.kind!==`connection`&&b.kind!==`list`?(0,K.jsx)(Z,{onClick:()=>k(void 0),children:U(`chat.skip`)}):null;if(r===`typed`){i&&A.push(X(`now:${n.id}:${b.id}:replies`,i));let e=s[b.id];j=(0,K.jsx)(st,{children:(0,K.jsx)(dt,{initial:pt(e)?``:String(e),multiline:b.kind===`textarea`,placeholder:b.placeholder||(x?b.label:U(`chat.placeholder`)),inputProps:wt(b),busy:t.busy,onSend:e=>k(ht(b,e))},b.id)})}else if(r===`tapped`)A.push(q(`now:${n.id}:${b.id}:replies`,(0,K.jsx)(Tt,{field:b,view:e,value:s[b.id],onAnswer:k}),{bare:!0}));else{let e=v.filter(e=>!l.includes(e.id)).length===1;A.push(X(`now:${n.id}:${b.id}:replies`,(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Z,{primary:!0,disabled:p,onClick:()=>k(s[b.id]),children:e&&n.cta?n.cta:U(`chat.send`)}),i]})))}}return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Y,{avatar:e.wizard.avatar,costume:e.wizard.costume,lines:A}),j]})}function wt(e){switch(e.kind){case`number`:return{inputMode:`decimal`,autoComplete:`off`};case`email`:return{type:`email`,inputMode:`email`,autoComplete:`email`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1};case`url`:return{inputMode:`url`,autoComplete:`url`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1};case`date`:return{type:`date`};default:return k(e)}}function Tt({field:e,view:t,value:n,onAnswer:r}){let i=new Set(t.closed?.[e.id]?.values.map(String)),[a,o]=(0,G.useState)(Array.isArray(n)?n:[]);if(e.kind===`toggle`)return(0,K.jsxs)(ut,{children:[(0,K.jsx)(Z,{on:n===!1,disabled:i.has(`false`),onClick:()=>r(!1),children:U(`run.no`)}),(0,K.jsx)(Z,{on:n===!0,disabled:i.has(`true`),onClick:()=>r(!0),children:U(`run.yes`)})]});let s=e.options??[];return e.kind===`multiselect`?(0,K.jsxs)(ut,{children:[s.map(e=>(0,K.jsx)(Z,{on:a.includes(e),onClick:()=>o(t=>t.includes(e)?t.filter(t=>t!==e):s.filter(n=>n===e||t.includes(n))),children:Te(e)},e)),(0,K.jsx)(Z,{primary:!0,disabled:e.required&&!a.length,onClick:()=>r(a),children:a.length||e.required?U(`chat.send`):U(`chat.skip`)})]}):(0,K.jsxs)(ut,{children:[s.map(e=>(0,K.jsx)(Z,{on:n===e,disabled:i.has(e),onClick:()=>r(e),children:Te(e)},e)),e.required?null:(0,K.jsx)(Z,{onClick:()=>r(void 0),children:U(`chat.skip`)})]})}function Et({view:e}){let t=(0,G.useMemo)(()=>[...e.events].reverse().find(t=>t.type===`step_started`&&t.stepId===e.step?.id),[e.events,e.step?.id]),n=t?new Date(t.at).getTime():Date.now(),[r,i]=(0,G.useState)(Date.now());(0,G.useEffect)(()=>{let e=setInterval(()=>i(Date.now()),1e3);return()=>clearInterval(e)},[]);let a=e.events.filter(e=>(e.type===`tool`||e.type===`info`)&&new Date(e.at).getTime()>=n-500),o=a.at(-1),s=[...a].reverse().find(Ot),c=[...new Set(a.map(e=>e.asset).filter(e=>!!e))];return(0,K.jsxs)(`div`,{className:E(`flex max-w-full flex-col gap-1`,s?`w-full`:`w-96`),"data-say-text":t?.message??e.step?.title??U(`run.working`),children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(lt,{}),(0,K.jsx)(`span`,{className:`font-medium`,children:t?.message??e.step?.title??U(`run.working`)}),(0,K.jsx)(`span`,{className:`text-[0.75rem] text-ink-4 tabular-nums`,children:U(`run.elapsed`,{s:Math.max(0,Math.round((r-n)/1e3))})})]}),o&&o!==s?(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[0.8125rem] text-ink-3`,children:[(0,K.jsx)(g,{className:`size-3.5 shrink-0 animate-breathe text-ember`}),(0,K.jsx)(`span`,{className:`truncate`,children:we(o)})]}):null,s&&e.status===`running`?(0,K.jsx)(At,{runId:e.id,event:s}):null,c.length?(0,K.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-1.5`,children:c.slice(-6).map(t=>(0,K.jsx)(`img`,{src:M(`/api/runs/${e.id}/assets/${t}`),alt:``,className:`size-14 rounded-lg bg-paper-2 object-cover ring-1 ring-border-soft`},t))}):null]})}var Dt=new Set([`opens`,`clicks`,`clicksOn`,`types`,`typesText`,`selects`,`scrolls`,`presses`,`goesBack`,`waitsForPage`,`fastLoop`,`looksAtPage`,`personDrives`,`agentDrives`]);function Ot(e){return!!e.note&&Dt.has(e.note.code)}var kt=1e4;function At({runId:e,event:t}){let[n,r]=(0,G.useState)(null),[i,a]=(0,G.useState)(`agent`),[o,s]=(0,G.useState)(!1),c=t.note?.code;if((0,G.useEffect)(()=>{c===`personDrives`?a(`person`):c===`agentDrives`&&a(`agent`)},[c]),(0,G.useEffect)(()=>{let t=()=>h.get(`/api/runs/${e}/browser/seat`).then(e=>a(e.seat)).catch(()=>void 0);if(t(),i!==`person`)return;let n=setInterval(t,kt);return()=>clearInterval(n)},[e,i]),n!==null&&n>=t.id)return null;let l=i===`person`,u=async()=>{s(!0);try{let t=await h.post(`/api/runs/${e}/browser/seat`,{to:l?`agent`:`person`});a(t.seat)}catch{}finally{s(!1)}};return(0,K.jsx)(b,{runId:e,driving:l,caption:we(t),hint:U(`browser.driving`),onBroken:()=>r(t.id),className:`mt-1.5`,action:(0,K.jsxs)(`button`,{type:`button`,disabled:o,onClick:()=>void u(),className:E(`flex h-8 items-center gap-1.5 rounded-full px-3 font-medium text-[0.8125rem] shadow-soft transition-colors disabled:opacity-60`,l?`bg-primary text-primary-foreground hover:bg-primary/90`:`bg-card/90 text-ink ring-1 ring-border-soft backdrop-blur hover:bg-card`),children:[l?(0,K.jsx)(oe,{className:`size-3.5`}):(0,K.jsx)(Ae,{className:`size-3.5`}),U(l?`browser.handBack`:`browser.takeOver`)]})},n??0)}function jt({children:e,end:t}){return(0,K.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,K.jsx)(`h3`,{className:`font-display font-semibold text-[1rem]`,children:e}),t]})}function Mt({view:e,run:t,step:n,before:r,asked:i,onNote:a}){let o=e.shown.filter(e=>e.output),[c,l]=(0,G.useState)(o.length===1?o[0].step.id:null),u=(0,G.useRef)(null),d=[...r,...i.map((e,t)=>it(`review:${n.id}:asked:${t}`,e)),q(`review:${n.id}`,(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`font-medium`,children:n.title}),n.description?(0,K.jsx)(`span`,{className:`mt-0.5 block text-ink-2`,children:n.description}):null]}),{anchor:!0}),...o.map(({step:t,output:r})=>q(`review:${n.id}:${t.id}`,(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(jt,{children:t.title}),(0,K.jsx)(p,{base:`/api/runs/${e.id}`,step:t,output:r,onSurfaceAction:n.regenerate?()=>{l(t.id),u.current?.focus()}:void 0})]}),{wide:!0})),...e.lists.map(t=>q(`review:${n.id}:list:${t.def.id}`,(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(jt,{children:t.def.title}),t.def.check?(0,K.jsx)(f,{runId:e.id,list:t}):(0,K.jsx)(s,{runId:e.id,list:t,editable:!0})]}),{wide:!0}))];t.error&&d.push(q(`review-error`,t.error,{tone:`error`}));let m=n.regenerate&&o.length>0;return d.push(X(`review:${n.id}:replies`,(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(Z,{primary:!0,busy:t.busy,onClick:()=>void t.accept(n.id),children:[(0,K.jsx)(ne,{className:`size-4`}),` `,U(`run.accept`)]}),m&&o.length>1?o.map(({step:e})=>(0,K.jsx)(Z,{on:c===e.id,onClick:()=>l(e.id),children:e.title},e.id)):null]}))),(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Y,{avatar:e.wizard.avatar,costume:e.wizard.costume,lines:d}),m?(0,K.jsx)(st,{children:(0,K.jsx)(dt,{multiline:!0,inputRef:u,busy:t.busy,placeholder:o.length>1&&!c?U(`run.feedbackPick`):U(`run.feedbackPlaceholder`),disabled:!c,onSend:e=>{let r=e.trim();return!r||!c?!1:(a(r),t.regenerate(n.id,c,r),!0)}})}):(0,K.jsx)(Q,{})]})}function Nt({view:e,run:t,step:n,before:r,onRestart:i}){let o=e.shown.filter(e=>e.output),c=`/api/runs/${e.id}`,u=[...r,q(`result:${n.id}`,(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`font-display font-semibold text-[1.0625rem]`,children:n.title}),n.message?(0,K.jsx)(`span`,{className:`mt-0.5 block text-ink-2`,children:n.message}):null]}),{anchor:!0}),...o.map(({step:e,output:t,formats:n,label:r})=>q(`result:${e.id}`,(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(jt,{end:(0,K.jsx)(I,{base:c,stepId:e.id,formats:n,title:r??e.title}),children:r??e.title}),(0,K.jsx)(p,{base:c,step:e,output:t}),t?.assets?.some(e=>e.ai)?(0,K.jsx)(`p`,{className:`mt-3 text-[0.75rem] text-ink-3 leading-relaxed`,children:U(`ai.publish`)}):null]}),{wide:!0})),...e.lists.map(t=>q(`result:list:${t.def.id}`,(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(jt,{end:(0,K.jsx)(m,{runId:e.id,list:t}),children:t.label??t.def.title}),(0,K.jsx)(s,{runId:e.id,list:t,editable:!0})]}),{wide:!0}))];return u.push(X(`result:replies`,(0,K.jsxs)(K.Fragment,{children:[o.length?(0,K.jsx)(Oe,{view:e,title:`${n.title} · ${e.wizard.title}`}):null,i?(0,K.jsxs)(Z,{onClick:i,children:[(0,K.jsx)(a,{className:`size-4`}),` `,U(`run.again`)]}):null,e.canBack?(0,K.jsx)(Z,{onClick:()=>void t.back(),disabled:t.busy,children:U(`run.back`)}):null,e.keeps?(0,K.jsx)(`span`,{className:`ml-1`,children:(0,K.jsx)(l,{runId:e.id})}):null]}))),(0,K.jsx)(Y,{avatar:e.wizard.avatar,costume:e.wizard.costume,lines:u})}function Pt({runId:e,onRestart:t,onNotFound:n,onView:r,header:o,footer:s,talk:l=!1,call:u=!1}){let d=rt(e),{view:f}=d,[p,m]=(0,G.useState)(null),h=Ze(e,f,d,p);(0,G.useEffect)(()=>{r?.(f)},[f,r]),(0,G.useEffect)(()=>{d.notFound&&n?.()},[d.notFound,n]);let[g,_]=ie(),y=(0,G.useMemo)(()=>({runId:e,lang:f?.lang??Ce,readAloud:g,setReadAloud:_,voice:f?.talk?h:null,talk:l,call:!!u,bindPage:m}),[e,f?.lang,f?.talk,g,_,h,l,u]);c(f?.status===`running`&&!f.ask),i(f);let[b,x]=(0,G.useState)({}),[S,C]=(0,G.useState)(null);(0,G.useEffect)(()=>{f&&f.status!==`running`&&C(null)},[f]);let w;if(d.notFound)w=n?null:(0,K.jsx)(`div`,{className:`py-24 text-center text-ink-3`,children:U(`run.notFound`)});else if(!f)w=(0,K.jsx)(`div`,{className:`flex justify-center py-24 text-ink-4`,children:(0,K.jsx)(F,{})});else{let e=f.step,n=f.status===`waiting_input`,r=xt(f,f.canBack&&n&&!d.busy?()=>void d.back():void 0);if(f.status===`running`&&f.ask)w=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Y,{avatar:f.wizard.avatar,costume:f.wizard.costume,lines:[...r,q(`ask:${f.ask.id}`,(0,K.jsx)(v,{runId:f.id,ask:f.ask}),{wide:!0})]}),(0,K.jsx)(Q,{})]});else if(f.status===`running`)w=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Y,{avatar:f.wizard.avatar,costume:f.wizard.costume,lines:[...r,...S?[it(`note`,S)]:[],q(`working:${e?.id}`,(0,K.jsx)(Et,{view:f}),{wide:f.events.some(t=>t.stepId===e?.id&&Ot(t))?`most`:void 0})]}),(0,K.jsx)(Q,{placeholder:U(`run.working`)})]});else if(f.status===`sleeping`)w=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Y,{avatar:f.wizard.avatar,costume:f.wizard.costume,lines:[...r,q(`sleeping`,te(f.wakeAt))]}),(0,K.jsx)(Q,{placeholder:U(`run.leavePage`)})]});else if(f.status===`failed`)w=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Y,{avatar:f.wizard.avatar,costume:f.wizard.costume,lines:[...r,q(`failed`,(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`font-medium`,children:U(`run.failed`)}),f.error?(0,K.jsx)(`span`,{className:`mt-0.5 block`,children:(0,K.jsx)(N,{text:f.error})}):null]}),{tone:`error`}),X(`failed:replies`,(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(Z,{primary:!0,busy:d.busy,onClick:()=>void d.retry(),children:[(0,K.jsx)(a,{className:`size-4`}),` `,U(`run.retry`)]}),f.canBack?(0,K.jsx)(Z,{onClick:()=>void d.back(),disabled:d.busy,children:U(`run.back`)}):null]}))]}),(0,K.jsx)(Q,{})]});else if(f.status===`cancelled`)w=(0,K.jsx)(Y,{avatar:f.wizard.avatar,costume:f.wizard.costume,lines:[...r,q(`cancelled`,U(`run.cancelled`)),...t?[X(`cancelled:replies`,(0,K.jsxs)(Z,{primary:!0,onClick:t,children:[(0,K.jsx)(a,{className:`size-4`}),` `,U(`run.again`)]}))]:[]]});else if(e?.type===`page`)w=(0,K.jsx)(Ct,{view:f,run:d,step:e,before:r},e.id);else if(e?.type===`review`){let t=f.shown.map(e=>e.output?.at??``).join(`|`);w=(0,K.jsx)(Mt,{view:f,run:d,step:e,before:r,asked:b[e.id]??[],onNote:t=>{C(t),x(n=>({...n,[e.id]:[...n[e.id]??[],t]}))}},`${e.id}:${t}`)}else w=e?.type===`result`?(0,K.jsx)(Nt,{view:f,run:d,step:e,before:r,onRestart:t}):(0,K.jsx)(Y,{avatar:f.wizard.avatar,costume:f.wizard.costume,lines:r})}return u?(0,K.jsx)(J.Provider,{value:y,children:(0,K.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col lg:flex-row`,children:[(0,K.jsx)(Ge,{voice:h,view:f,video:u===`video`,className:`h-[46dvh] shrink-0 lg:h-auto lg:min-h-0 lg:flex-1`}),(0,K.jsx)(`aside`,{className:`flex min-h-0 flex-1 flex-col border-border-soft border-t lg:w-[420px] lg:flex-none lg:border-t-0 lg:border-l`,children:(0,K.jsx)(ct,{footer:s,children:w})})]})}):(0,K.jsx)(J.Provider,{value:y,children:(0,K.jsx)(ct,{header:o,footer:s,children:w})})}function Ft({runId:e,onNotFound:t,...n}){let r=rt(e);return(0,G.useEffect)(()=>{r.notFound&&t?.()},[r.notFound,t]),r.notFound&&t?null:(0,K.jsx)(C,{run:r,...n})}function $(e){let t=Math.sin(e*127.1+311.7)*43758.5453;return t-Math.floor(t)}function It(e){let t=Array.from({length:7},(t,n)=>({a:(n+.2+$(e+n)*.5)/7.2*(Math.PI/2),len:200*(.84+.16*$(e+n+20))})),n=t.map(e=>`M0 0L${(Math.cos(e.a)*e.len).toFixed(1)} ${(Math.sin(e.a)*e.len).toFixed(1)}`);for(let e=1;e<=9;e++){let r=200*(e/9.6)**1.08;t.slice(1).forEach((e,i)=>{let a=t[i],o=Math.min(r,a.len),s=Math.min(r,e.len),c=(a.a+e.a)/2,l=r*.86;i===0&&n.push(`M${(Math.cos(a.a)*o).toFixed(1)} ${(Math.sin(a.a)*o).toFixed(1)}`),n.push(`Q${(Math.cos(c)*l).toFixed(1)} ${(Math.sin(c)*l).toFixed(1)} ${(Math.cos(e.a)*s).toFixed(1)} ${(Math.sin(e.a)*s).toFixed(1)}`)})}return n.join(``)}var Lt={left:It(1),right:It(9)};function Rt({side:e,className:t}){return(0,K.jsx)(`svg`,{className:t??`wizard-web wizard-web-${e}`,viewBox:`0 0 200 200`,"aria-hidden":`true`,children:(0,K.jsx)(`path`,{d:Lt[e],fill:`none`,stroke:`currentColor`,strokeLinecap:`round`})})}function zt(){return(0,K.jsxs)(`div`,{className:`wizard-spider`,children:[(0,K.jsx)(`div`,{className:`wizard-spider-thread`}),(0,K.jsxs)(`svg`,{viewBox:`-30 -10 60 60`,"aria-hidden":`true`,children:[(0,K.jsx)(`g`,{stroke:`currentColor`,strokeWidth:`2.6`,strokeLinecap:`round`,fill:`none`,children:[0,1,2,3].map(e=>(0,K.jsxs)(`g`,{children:[(0,K.jsx)(`path`,{d:`M0 ${8+e*5} Q-16 ${-2+e*6} -24 ${14+e*6}`}),(0,K.jsx)(`path`,{d:`M0 ${8+e*5} Q16 ${-2+e*6} 24 ${14+e*6}`})]},e))}),(0,K.jsx)(`ellipse`,{cx:`0`,cy:`22`,rx:`11`,ry:`14`,fill:`currentColor`}),(0,K.jsx)(`circle`,{cx:`0`,cy:`6`,r:`7`,fill:`currentColor`}),(0,K.jsx)(`circle`,{cx:`-2.6`,cy:`7`,r:`1.6`,className:`wizard-spider-eye`}),(0,K.jsx)(`circle`,{cx:`2.6`,cy:`7`,r:`1.6`,className:`wizard-spider-eye`})]})]})}function Bt({side:e}){let t=Array.from({length:9},(e,t)=>{let n=(t+.5)/9*(Math.PI/2),r=70+$(t+40)*110,i=Math.cos(n)*r,a=Math.sin(n)*r,o=Math.cos(n)*r*.55,s=Math.sin(n)*r*.55,c=14+$(t+50)*16;return`M0 0L${i.toFixed(1)} ${a.toFixed(1)}M${o.toFixed(1)} ${s.toFixed(1)}l${(Math.cos(n+.6)*c).toFixed(1)} ${(Math.sin(n+.6)*c).toFixed(1)}M${o.toFixed(1)} ${s.toFixed(1)}l${(Math.cos(n-.6)*c).toFixed(1)} ${(Math.sin(n-.6)*c).toFixed(1)}`}).join(``);return(0,K.jsx)(`svg`,{className:`wizard-frost wizard-web-${e}`,viewBox:`0 0 200 200`,"aria-hidden":`true`,children:(0,K.jsx)(`path`,{d:t,fill:`none`,stroke:`currentColor`,strokeLinecap:`round`})})}function Vt({kind:e}){let t=e===`stars`?28:22;return(0,K.jsx)(`div`,{className:`wizard-particles wizard-particles-${e}`,children:Array.from({length:t},(t,n)=>(0,K.jsx)(`span`,{style:{left:`${($(n+1)*100).toFixed(2)}%`,top:e===`stars`?`${($(n+2)*100).toFixed(2)}%`:void 0,animationDuration:`${(e===`stars`?2.5:9)+$(n+3)*8}s`,animationDelay:`${(-$(n+4)*16).toFixed(2)}s`,scale:(.6+$(n+5)*.9).toFixed(2),"--hue":`${Math.round($(n+6)*360)}`}},n))})}var Ht=[{kind:`round`,top:16,size:64,seconds:17,delay:1},{kind:`drop`,top:42,size:48,seconds:21,delay:7},{kind:`tower`,top:26,size:56,seconds:19,delay:12.5}],Ut=[{kind:`flame`,side:`right`,seconds:14,delay:2},{kind:`sprout`,side:`left`,seconds:16,delay:9}];function Wt({costume:e,motion:t}){return t===`peek`?(0,K.jsx)(K.Fragment,{children:Ut.map(t=>(0,K.jsx)(`div`,{className:`wizard-peek wizard-peek-${t.side}`,style:{animationDuration:`${t.seconds}s`,animationDelay:`${t.delay}s`},children:(0,K.jsx)(he,{kind:t.kind,costume:e,size:96})},t.kind))}):(0,K.jsx)(K.Fragment,{children:Ht.map(t=>(0,K.jsx)(`div`,{className:`wizard-bat`,style:{top:`${t.top}%`,animationDuration:`${t.seconds}s`,animationDelay:`${t.delay}s`},children:(0,K.jsx)(`div`,{className:`wizard-bat-bob`,children:(0,K.jsx)(he,{kind:t.kind,costume:e,size:t.size})})},t.kind))})}var Gt=[`witch`,`devil`,`bat`,`pumpkin`];function Kt({effects:e,contained:t}){let n=(e??[]).filter(e=>[`corners`,`particles`,`figures`,`fog`].includes(e.id));if(!n.length)return null;let r=(e,t)=>typeof e[t]==`string`?String(e[t]):``;return(0,K.jsxs)(K.Fragment,{children:[n.some(e=>e.id===`fog`)?(0,K.jsx)(`div`,{"aria-hidden":`true`,className:t?`wizard-fog wizard-fx-contained`:`wizard-fog`}):null,(0,K.jsx)(`div`,{"aria-hidden":`true`,className:t?`wizard-fx wizard-fx-contained`:`wizard-fx`,children:n.map((e,t)=>{let n=`${e.id}-${t}`;if(e.id===`corners`){let t=r(e,`kind`)||`webs`;return t===`frost`?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Bt,{side:`left`}),(0,K.jsx)(Bt,{side:`right`})]},n):t===`webs`?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Rt,{side:`left`}),(0,K.jsx)(Rt,{side:`right`}),(0,K.jsx)(zt,{})]},n):null}if(e.id===`particles`){let t=r(e,`kind`)||`embers`;return[`embers`,`snow`,`confetti`,`stars`].includes(t)?(0,K.jsx)(Vt,{kind:t},n):null}if(e.id===`figures`){let t=r(e,`costume`);return(0,K.jsx)(Wt,{costume:Gt.includes(t)?t:void 0,motion:r(e,`motion`)||`fly`},n)}return null})})]})}var qt=[`brand`,`host`,`default`],Jt=[...qt,`engenty`,`wizard`,`wizards`],Yt=[`Inter`,`Figtree`,`DM Sans`,`Nunito`,`Fredoka`,`Bricolage Grotesque`,`Fraunces`,`Playfair Display`,`Lora`,`Young Serif`,`Caveat`,`Creepster`,`Nosifer`],Xt=B().regex(/^#[0-9a-fA-F]{6}$/,`a colour as #rrggbb`),Zt=W({accent:Xt.optional(),background:Xt.optional(),text:Xt.optional()}).extend({scheme:V([`light`,`dark`])}),Qt=W({radius:V([`sharp`,`soft`,`round`]).optional(),cards:V([`solid`,`outline`,`glass`]).optional(),headings:V([`normal`,`uppercase`]).optional()}),$t=W({id:B().min(1).max(40)}).catchall(ve([B().max(40),ge(),xe()])),en=B().min(1).max(60).regex(/^[A-Za-z0-9 -]+$/,`a font by its family name, or brand`);W({id:B().regex(ye,`a theme id: lowercase letters, digits and dashes`),name:B().min(1).max(80),version:B().regex(/^\d+\.\d+\.\d+$/).default(`1.0.0`),base:V(qt).default(`brand`),colors:Ee(Zt).min(1).max(2).refine(e=>new Set(e.map(e=>e.scheme)).size===e.length,{message:`Each scheme once: light, dark.`}).optional(),fonts:W({heading:en.optional(),text:en.optional()}).optional(),shape:Qt.optional(),effects:Ee($t).max(8).optional()});function tn(e,t){if(!t.has(e))return e;for(let n=2;;n++){let r=`${e.slice(0,44)}-${n}`;if(!t.has(r))return r}}function nn(e){let t=e.normalize(`NFKD`).replace(/[̀-ͯ]/g,``).toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,48);return t&&!Jt.includes(t)?t:`look`}function rn(e,t){let n=e?.colors?.find(e=>e.scheme===t);if(!n)return;let{scheme:r,...i}=n;return i}var an=`ui-sans-serif, system-ui, sans-serif`,on=`ui-serif, Georgia, serif`,sn=/serif|fraunces|playfair|lora|garamond|antiqua|baskerville|caslon|bodoni|didot|times|georgia|merriweather|tiempos/i,cn=e=>sn.test(e)&&!/sans/i.test(e),ln=e=>cn(e)?`Lora`:`Inter`;function un(e,t=[]){let n=t.some(t=>t.family===e)?`"${ln(e)}", `:``;return`"${e.replace(/"/g,``)}", ${n}${cn(e)?on:an}`}function dn(e,t){let n=e.modes?.[t];return{accent:n?.accent??e.accent,background:n?.background??e.background,text:n?.text??null}}var fn={Inter:()=>[R(()=>Promise.resolve({}),__vite__mapDeps([0])),R(()=>Promise.resolve({}),__vite__mapDeps([1])),R(()=>Promise.resolve({}),__vite__mapDeps([2])),R(()=>Promise.resolve({}),__vite__mapDeps([3]))],Figtree:()=>[R(()=>Promise.resolve({}),__vite__mapDeps([4])),R(()=>Promise.resolve({}),__vite__mapDeps([5])),R(()=>Promise.resolve({}),__vite__mapDeps([6])),R(()=>Promise.resolve({}),__vite__mapDeps([7]))],"DM Sans":()=>[R(()=>Promise.resolve({}),__vite__mapDeps([8])),R(()=>Promise.resolve({}),__vite__mapDeps([9])),R(()=>Promise.resolve({}),__vite__mapDeps([10])),R(()=>Promise.resolve({}),__vite__mapDeps([11]))],Nunito:()=>[R(()=>Promise.resolve({}),__vite__mapDeps([12])),R(()=>Promise.resolve({}),__vite__mapDeps([13])),R(()=>Promise.resolve({}),__vite__mapDeps([14])),R(()=>Promise.resolve({}),__vite__mapDeps([15]))],Fredoka:()=>[R(()=>Promise.resolve({}),__vite__mapDeps([16])),R(()=>Promise.resolve({}),__vite__mapDeps([17])),R(()=>Promise.resolve({}),__vite__mapDeps([18])),R(()=>Promise.resolve({}),__vite__mapDeps([19]))],"Bricolage Grotesque":()=>[R(()=>Promise.resolve({}),__vite__mapDeps([20])),R(()=>Promise.resolve({}),__vite__mapDeps([21])),R(()=>Promise.resolve({}),__vite__mapDeps([22])),R(()=>Promise.resolve({}),__vite__mapDeps([23]))],Fraunces:()=>[R(()=>Promise.resolve({}),__vite__mapDeps([24])),R(()=>Promise.resolve({}),__vite__mapDeps([25])),R(()=>Promise.resolve({}),__vite__mapDeps([26])),R(()=>Promise.resolve({}),__vite__mapDeps([27]))],"Playfair Display":()=>[R(()=>Promise.resolve({}),__vite__mapDeps([28])),R(()=>Promise.resolve({}),__vite__mapDeps([29])),R(()=>Promise.resolve({}),__vite__mapDeps([30])),R(()=>Promise.resolve({}),__vite__mapDeps([31]))],Lora:()=>[R(()=>Promise.resolve({}),__vite__mapDeps([32])),R(()=>Promise.resolve({}),__vite__mapDeps([33])),R(()=>Promise.resolve({}),__vite__mapDeps([34])),R(()=>Promise.resolve({}),__vite__mapDeps([35]))],"Young Serif":()=>[R(()=>Promise.resolve({}),__vite__mapDeps([36]))],Caveat:()=>[R(()=>Promise.resolve({}),__vite__mapDeps([37])),R(()=>Promise.resolve({}),__vite__mapDeps([38])),R(()=>Promise.resolve({}),__vite__mapDeps([39])),R(()=>Promise.resolve({}),__vite__mapDeps([40]))],Creepster:()=>[R(()=>Promise.resolve({}),__vite__mapDeps([41]))],Nosifer:()=>[R(()=>Promise.resolve({}),__vite__mapDeps([42]))]},pn=new Set;function mn(e){e&&!pn.has(e)&&e in fn&&(pn.add(e),Promise.all(fn[e]()).catch(()=>pn.delete(e)))}function hn(e){ze(e,e.url.startsWith(`/`)?M(e.url):e.url,()=>mn(ln(e.family)))}function gn(e,t){let n=e.faces??[],r=!!e.modes,i=dn({accent:e.accent??null,background:e.background??null,modes:e.modes??null},r?t:e.dark?`dark`:`light`),a=r?t===`dark`:!!e.dark,o=[[`--raw-primary`,i.accent],[`--raw-second`,e.second],[`--raw-background`,i.background],[`--brand-stage`,i.background?a?i.background:`oklch(from ${i.background} 0.3 clamp(0.02, calc(c * 3), 0.1) h)`:null],[`--ink`,i.text],[`--f-display`,e.display?un(e.display,n):null],[`--f-ui`,e.body?un(e.body,n):null],[`font-synthesis-weight`,e.display||e.body?`none`:null]],s=[...Object.entries(e.shape??{}).filter(([,e])=>e).map(([e,t])=>`shape-${e}-${t}`),...(e.effects??[]).flatMap(e=>e.id===`glow`?[`fx-glow`]:e.id===`pattern`?[`fx-pattern-${e.kind??`dots`}`]:[])];return{props:o.filter(e=>!!e[1]),marks:s,dark:a,themed:r}}function _n(e){return!!(e&&!e.pinned&&e.modes?.light&&e.modes.dark)}function vn(e){for(let t of e.faces??[])hn(t);mn(e.display),mn(e.body)}function yn(e){fe(e?.pinned?e.dark?`dark`:`light`:null),de(e?.prefer??null);let t=ue(),n=JSON.stringify(e??{});(0,G.useEffect)(()=>{let e=JSON.parse(n),r=document.documentElement;vn(e);let{props:i,marks:a,themed:o}=gn(e,t);for(let[e,t]of i)r.style.setProperty(e,t);r.classList.add(...a);let s=r.classList.contains(`dark`);return!o&&e.dark&&!e.pinned&&r.classList.add(`dark`),()=>{for(let[e]of i)r.style.removeProperty(e);r.classList.remove(...a),!o&&e.dark&&!e.pinned&&!s&&r.classList.remove(`dark`)}},[n,t])}function bn(e,t){let n=JSON.stringify(e??{});if((0,G.useEffect)(()=>{vn(JSON.parse(n))},[n]),!e)return null;let r=e.pinned||!e.prefer?e.dark?`dark`:`light`:e.prefer,{props:i,marks:a,dark:o}=gn(e,t&&_n(e)?t:r);return{className:[`wizard-themed`,...a,o?`dark`:``].filter(Boolean).join(` `),style:Object.fromEntries(i)}}export{Y as _,mn as a,Me as b,rn as c,Kt as d,Ft as f,Z as g,Q as h,hn as i,nn as l,ct as m,yn as n,Yt as o,Pt as p,bn as r,tn as s,_n as t,Rt as u,X as v,ot as y};
12
+ `)[1])&&N({type:`response.create`})},[i,t,r,f,N]),{state:i,error:o,speaking:c,listening:u,start:z,stop:L,camera:f,facing:m,startCamera:I,stopCamera:F,flipCamera:ee,muted:_,toggleMute:te,captions:y,video:x}}var Qe=[`classifier`,`low`],$e=12e3;function et(e){T(`think`)&&h.post(`/api/runs/${e}/device`,{think:{classes:Qe,maxChars:$e}}).catch(()=>void 0)}async function tt(e,t){if(t.kind!==`think`)return;let n;try{let e=await D(`think`,{system:t.system,prompt:t.prompt,schema:t.schema});n={text:String(e?.text??``)}}catch(e){n={error:e.message.slice(0,500)}}await h.post(`/api/runs/${e}/device/${t.id}`,n).catch(()=>void 0)}var nt=45e3;function rt(e){let[t,n]=(0,G.useState)(null),[r,i]=(0,G.useState)(null),[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(!1),[l,d]=(0,G.useState)({});(0,G.useEffect)(()=>{if(n(null),o(!1),!e)return;let t=!1,r=0,i,a=null,s=Date.now(),c=()=>{t=!0,a?.close(),o(!0)},l=async()=>{try{let r=await h.get(`/api/runs/${e}`);t||n(r)}catch(e){e instanceof u&&e.status===404&&c()}},d=()=>{if(clearTimeout(i),a?.close(),t)return;let o=new EventSource(M(`/api/runs/${e}/stream`),{withCredentials:!0});a=o,s=Date.now(),et(e),o.addEventListener(`device`,t=>{s=Date.now(),tt(e,JSON.parse(t.data))}),o.addEventListener(`view`,e=>{r=0,s=Date.now(),n(JSON.parse(e.data))}),o.addEventListener(`ping`,()=>{s=Date.now()}),o.onerror=()=>{o.close(),!(t||a!==o)&&(a=null,l(),r=Math.min(r+1,6),i=setTimeout(d,500*2**r))}},f=()=>{t||document.visibilityState!==`visible`||(!a||a.readyState===EventSource.CLOSED||Date.now()-s>nt?(r=0,d()):l())},p=setInterval(()=>{!t&&a&&Date.now()-s>nt&&(r=0,d())},15e3);return d(),document.addEventListener(`visibilitychange`,f),window.addEventListener(`pageshow`,f),window.addEventListener(`online`,f),()=>{t=!0,clearTimeout(i),clearInterval(p),document.removeEventListener(`visibilitychange`,f),window.removeEventListener(`pageshow`,f),window.removeEventListener(`online`,f),a?.close()}},[e]);let f=(0,G.useCallback)(async(t,n)=>{if(!e)return!1;c(!0),i(null),d({});try{return await h.post(`/api/runs/${e}/${t}`,n),!0}catch(e){return e instanceof u&&e.status===422&&Array.isArray(e.body?.fields)&&d(Object.fromEntries(e.body.fields.map(e=>[e.field,e.message]))),i(e.message),!1}finally{c(!1)}},[e]);return Se(t?.translation?.labels),{view:t,notFound:a,error:r,busy:s,fieldErrors:l,submitPage:(e,t)=>f(`pages/${e}`,{values:t}),accept:(e,t)=>f(`reviews/${e}`,{type:`accept`,edits:t}),regenerate:(e,t,n,r)=>f(`reviews/${e}`,{type:`regenerate`,target:t,note:n,items:r?.length?r:void 0}),back:()=>f(`back`),retry:()=>f(`retry`),translateResult:e=>f(`translate-result`,{stepId:e}),setLang:e=>f(`lang`,{lang:e})}}var q=(e,t,n)=>({key:e,who:`bot`,node:t,...n}),it=(e,t,n)=>({key:e,who:`me`,node:t,...n}),at=(0,G.createContext)(null),J=(0,G.createContext)(null);function ot(){return(0,G.useContext)(J)?.voice??null}function st({children:e}){let t=(0,G.useContext)(at);return t?(0,Be.createPortal)(e,t):null}function ct({header:e,footer:t,children:n}){let[r,i]=(0,G.useState)(null),a=(0,G.useRef)(null),o=(0,G.useRef)(null),s=(0,G.useRef)(!0);return(0,G.useLayoutEffect)(()=>{let e=a.current,t=o.current;if(!e||!t)return;let n=e.scrollTop,r=()=>{e.scrollHeight-e.scrollTop-e.clientHeight<120?s.current=!0:e.scrollTop<n&&(s.current=!1),n=e.scrollTop},i=null,c=new ResizeObserver(()=>{let r=t.querySelector(`[data-anchor]`);r&&r!==i?(i=r,e.scrollTop+=r.getBoundingClientRect().top-e.getBoundingClientRect().top-12,s.current=!1,n=e.scrollTop):s.current&&(e.scrollTop=e.scrollHeight)});return e.scrollTop=e.scrollHeight,e.addEventListener(`scroll`,r,{passive:!0}),c.observe(t),c.observe(e),()=>{c.disconnect(),e.removeEventListener(`scroll`,r)}},[]),(0,K.jsx)(at.Provider,{value:r,children:(0,K.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[e,(0,K.jsx)(`div`,{ref:a,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,K.jsx)(`div`,{ref:o,className:`mx-auto flex w-full max-w-[760px] flex-col gap-3 px-3 pt-5 pb-4 sm:px-6`,children:n})}),(0,K.jsxs)(`div`,{className:`shrink-0 border-border-soft border-t bg-background`,onPointerDownCapture:()=>{s.current=!0},onKeyDownCapture:()=>{s.current=!0},children:[(0,K.jsx)(`div`,{ref:i,className:`mx-auto w-full max-w-[760px] px-3 pt-3 sm:px-6`}),t]})]})})}function Y({avatar:e,costume:t,lines:n}){let r=(0,G.useContext)(J),i=(0,G.useMemo)(()=>n.map(e=>({key:e.key,who:e.who,spoken:!e.bare&&!e.wide})),[n]),a=(0,G.useCallback)(e=>{let t=document.querySelector(`[data-say="${CSS.escape(e)}"]`);return t?.querySelector(`[data-say-text]`)?.getAttribute(`data-say-text`)??t?.innerText??null},[]);se(!!r?.readAloud,r?.lang??Ce,i,a);let o=[];for(let e of n){let t=o.at(-1);t&&t.who===`bot`&&e.who===`bot`?t.lines.push(e):o.push({who:e.who,lines:[e]})}return o.map((n,r)=>n.who===`bot`?(0,K.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,K.jsx)(`div`,{className:`sticky top-1 shrink-0 pt-0.5`,children:(0,K.jsx)(ue,{kind:e,costume:t,size:30,interactive:r>=o.length-2})}),(0,K.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col items-start gap-1.5`,children:n.lines.map(e=>(0,K.jsx)(`div`,{"data-anchor":e.anchor?``:void 0,"data-say":e.key,className:E(`animate-rise`,e.bare?`w-full pt-1`:`rounded-2xl rounded-tl-md text-[0.9375rem] text-ink leading-relaxed`,!e.bare&&(e.wide?E(`w-full bg-card p-4 shadow-soft ring-1 ring-border-soft`,e.wide===`most`&&`md:w-4/5`):`max-w-[min(36rem,100%)] bg-card px-4 py-2.5 shadow-soft ring-1 ring-border-soft`),e.tone===`error`&&`bg-rose-tint text-rose shadow-none ring-0`),children:e.node},e.key))})]},n.lines[0].key):n.lines.map(e=>(0,K.jsxs)(`div`,{className:`flex animate-rise flex-col items-end gap-1 pl-10`,children:[(0,K.jsx)(`div`,{className:`max-w-[min(32rem,100%)] whitespace-pre-wrap break-words rounded-2xl rounded-br-md bg-primary px-4 py-2.5 text-[0.9375rem] text-primary-foreground leading-relaxed`,children:e.node}),e.onEdit?(0,K.jsxs)(`button`,{type:`button`,onClick:e.onEdit,className:`inline-flex items-center gap-1 px-1 text-[0.75rem] text-ink-4 transition hover:text-ink-2 coarse:min-h-9`,children:[(0,K.jsx)(A,{className:`size-3`}),` `,U(`chat.change`)]}):null]},e.key)))}function lt(){return(0,K.jsx)(`span`,{className:`inline-flex items-center gap-1 py-1.5`,role:`status`,"aria-label":U(`run.working`),children:[0,1,2].map(e=>(0,K.jsx)(`span`,{className:`size-1.5 animate-typing rounded-full bg-ink-3`,style:{animationDelay:`${e*160}ms`}},e))})}function ut({children:e}){return(0,K.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:e})}var X=(e,t)=>q(e,(0,K.jsx)(ut,{children:t}),{bare:!0});function Z({onClick:e,children:t,primary:n,on:r,disabled:i,busy:a}){return(0,K.jsxs)(`button`,{type:`button`,"aria-pressed":r,disabled:i||a,onClick:e,className:E(`inline-flex h-10 items-center gap-1.5 rounded-full px-4 font-medium text-[0.875rem] transition active:scale-[0.98] disabled:pointer-events-none disabled:opacity-50 coarse:h-11`,n?`bg-primary text-primary-foreground hover:brightness-[1.06]`:r?`bg-ember-tint text-ink ring-1 ring-ember`:`bg-card text-ink-2 ring-1 ring-input hover:text-ink hover:ring-ink-4`),children:[a?(0,K.jsx)(F,{className:`size-4`}):null,t]})}function dt({initial:e=``,placeholder:t,multiline:n,inputProps:r,busy:i,disabled:a,inputRef:s,onSend:c}){let[l,u]=(0,G.useState)(e),d=(0,G.useRef)(null),f=s??d,p=(0,G.useContext)(J),m=w(l,u,{endpoint:p?`/api/runs/${p.runId}/transcribe`:void 0}),h=!!p&&m.supported&&!a;(0,G.useEffect)(()=>{if(!h)return;let e=e=>{(e.metaKey||e.ctrlKey)&&e.shiftKey&&e.key.toLowerCase()===`m`&&(e.preventDefault(),m.toggle())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[h,m.toggle]),(0,G.useEffect)(()=>{!y&&!a&&f.current?.focus()},[a,f]);let g=()=>{i||a||(m.listening&&m.toggle(),c(l)!==!1&&u(``))},_=m.listening?U(`chat.listening`):m.processing?U(`chat.transcribing`):t,v=p?.voice??null,b=!!p?.call,S=p&&!b&&(ce||h||v)?(0,K.jsxs)(`div`,{className:`mb-1 flex shrink-0 items-center`,children:[v?(0,K.jsx)(O,{label:U(v.state===`live`?`talk.stop`:v.state===`connecting`?`talk.connecting`:`talk.start`),"aria-pressed":v.state===`live`,disabled:v.state===`connecting`,onClick:()=>v.state===`live`?v.stop():void v.start(),className:E(`size-9`,v.state===`live`&&`bg-rose-tint text-rose hover:bg-rose-tint hover:text-rose`,v.state===`off`&&p.talk&&`bg-primary text-primary-foreground hover:bg-primary`),children:v.state===`connecting`?(0,K.jsx)(F,{className:`size-4`}):v.state===`live`?(0,K.jsx)(le,{className:`size-4`}):(0,K.jsx)(me,{className:`size-4`})}):null,v?.state===`live`?(0,K.jsx)(O,{label:U(v.camera?`talk.cameraOff`:`talk.camera`),"aria-pressed":v.camera,onClick:()=>v.camera?v.stopCamera():void v.startCamera(),className:E(`size-9`,v.camera&&`text-ink`),children:v.camera?(0,K.jsx)(x,{className:`size-4`}):(0,K.jsx)(Pe,{className:`size-4`})}):null,ce?(0,K.jsx)(O,{label:U(p.readAloud?`chat.readAloudOff`:`chat.readAloud`),"aria-pressed":p.readAloud,onClick:()=>p.setReadAloud(!p.readAloud),className:E(`size-9`,p.readAloud&&`text-ink`),children:p.readAloud?(0,K.jsx)(re,{className:`size-4`}):(0,K.jsx)(Ie,{className:`size-4`})}):null,h?(0,K.jsx)(O,{label:U(m.listening?`chat.dictateStop`:`chat.dictate`),"aria-pressed":m.listening,disabled:m.processing,onClick:m.toggle,className:E(`size-9`,m.listening&&`bg-rose-tint text-rose hover:bg-rose-tint hover:text-rose`),children:m.processing?(0,K.jsx)(F,{className:`size-4`}):m.listening?(0,K.jsx)(ee,{className:`size-3.5 animate-pulse-dot fill-current`}):(0,K.jsx)(o,{className:`size-4`})}):null]}):null;return(0,K.jsxs)(`form`,{className:`pb-3`,onSubmit:e=>{e.preventDefault(),g()},children:[v&&!b?(0,K.jsx)(`video`,{ref:v.video,muted:!0,playsInline:!0,autoPlay:!0,className:E(`mb-2 ml-auto w-32 rounded-xl bg-black object-cover shadow-soft ring-1 ring-border-soft`,v.camera?`block`:`hidden`)}):null,(0,K.jsxs)(`div`,{className:E(`flex items-end gap-1 rounded-[1.375rem] border border-input bg-card pr-1.5 pl-1 transition focus-within:border-focus focus-within:ring-4 focus-within:ring-focus-glow`,a&&`opacity-60`),children:[S,n?(0,K.jsx)(j,{ref:f,minRows:1,maxRows:6,value:l,disabled:a,placeholder:_,autoCapitalize:`sentences`,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!y&&!e.nativeEvent.isComposing&&(e.preventDefault(),g())},className:`min-h-11 border-0 bg-transparent py-2.5 shadow-none focus:ring-0`}):(0,K.jsx)(`input`,{ref:f,...r,value:l,disabled:a,placeholder:_,enterKeyHint:`send`,onChange:e=>u(e.target.value),className:`h-11 min-w-0 flex-1 bg-transparent px-3 text-[0.9375rem] text-ink outline-none placeholder:text-ink-4`}),(0,K.jsx)(`button`,{type:`submit`,"aria-label":U(`chat.send`),title:U(`chat.send`),disabled:i||a,className:`mb-1 flex size-9 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground transition hover:brightness-[1.06] disabled:opacity-40`,children:i?(0,K.jsx)(F,{className:`size-4`}):(0,K.jsx)(P,{className:`size-4`})})]}),m.error?(0,K.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-rose`,children:m.error===`denied`?U(`chat.micDenied`):m.error}):b?null:v?.error?(0,K.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-rose`,children:v.error}):v?.state===`live`?(0,K.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-ink-3`,children:v.speaking?U(`talk.speaking`):v.listening?U(`talk.listening`):U(`talk.live`)}):p?.talk&&v?.state===`off`?(0,K.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-ink-3`,children:U(`talk.hint`)}):null]})}function Q({placeholder:e=U(`chat.above`)}){return(0,K.jsx)(st,{children:(0,K.jsx)(dt,{disabled:!0,placeholder:e,onSend:()=>!1})})}function ft(e){let t=_e[e.kind];return t===`typed`&&!e.scan?`typed`:t===`tapped`?`tapped`:`control`}var pt=e=>e==null||e===``||Array.isArray(e)&&e.length===0;function mt(e,t){let n=e.kind===`toggle`||e.kind===`connection`||e.kind===`list`;if(pt(t))return e.required&&!n?U(`chat.required`):null;let r=String(t).trim();if(e.kind===`email`&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(r))return U(`chat.badEmail`);if(e.kind===`url`)try{new URL(r)}catch{return U(`chat.badUrl`)}return e.kind===`number`&&De(r)===null?U(`chat.badNumber`):Array.isArray(t)&&e.multiple&&e.min&&t.length<e.min?U(`run.filesMin`,{n:t.length,min:e.min}):null}function ht(e,t){let n=e.kind===`textarea`?t.replace(/\s+$/,``):t.trim();if(n)return e.kind===`url`&&!/^[a-z][a-z0-9+.-]*:/i.test(n)?`https://${n}`:n}function gt({field:e}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`font-medium`,children:e.label}),e.help?(0,K.jsx)(`span`,{className:`mt-0.5 block text-[0.8125rem] text-ink-3`,children:e.help}):null]})}function _t({step:e,only:t}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`font-medium`,children:e.title}),e.description?(0,K.jsx)(`span`,{className:`mt-0.5 block text-ink-2`,children:e.description}):null,t?.help?(0,K.jsx)(`span`,{className:`mt-1 block text-[0.8125rem] text-ink-3`,children:t.help}):null]})}function vt({field:e,value:t,runId:n}){if(e.kind===`connection`)return(0,K.jsx)(K.Fragment,{children:typeof t==`string`&&t?t:U(`chat.connected`)});if(e.kind===`list`)return(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,K.jsx)(ne,{className:`size-4`}),` `,U(`chat.checked`)]});if(e.kind===`toggle`)return(0,K.jsx)(K.Fragment,{children:U(t===!0?`run.yes`:`run.no`)});if(pt(t))return(0,K.jsx)(`span`,{className:`italic opacity-80`,children:U(`chat.skipped`)});switch(e.kind){case`multiselect`:return(0,K.jsx)(K.Fragment,{children:t.map(Te).join(`, `)});case`select`:return(0,K.jsx)(K.Fragment,{children:Te(String(t))});case`date`:{let e=new Date(`${String(t)}T00:00`);return(0,K.jsx)(K.Fragment,{children:Number.isNaN(e.getTime())?String(t):new Intl.DateTimeFormat(Ce,{dateStyle:`long`}).format(e)})}case`color`:return(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`size-4 rounded-full ring-1 ring-white/50`,style:{background:String(t)}}),String(t)]});case`image`:case`signature`:return(0,K.jsx)(`span`,{className:`-mx-1.5 flex flex-wrap gap-1.5`,children:(Array.isArray(t)?t:[String(t)]).map(t=>(0,K.jsx)(`img`,{src:M(`/api/runs/${n}/assets/${t}`),alt:``,className:E(`h-16 rounded-lg bg-white`,e.kind===`image`?`w-16 object-cover`:`object-contain px-1`)},t))});case`file`:{let e=Array.isArray(t)?t.length:1;return(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,K.jsx)(d,{className:`size-4`}),` `,U(e===1?`chat.file`:`chat.files`,{n:e})]})}case`audio`:{let e=t.seconds;return(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,K.jsx)(o,{className:`size-4`}),` `,U(`chat.voice`),e?` · ${Math.round(e)} s`:``]})}case`location`:{let e=t;return(0,K.jsx)(K.Fragment,{children:e.label||`${e.lat?.toFixed(5)}, ${e.lng?.toFixed(5)}`})}case`items`:return(0,K.jsx)(K.Fragment,{children:U(`chat.rows`,{n:Array.isArray(t)?t.length:0})});default:return(0,K.jsx)(K.Fragment,{children:String(t)})}}function yt(e,t,n,r,i,a){let o=[q(t,(0,K.jsx)(_t,{step:e,only:a}))];for(let e of i)a||o.push(q(`${t}:${e.id}`,(0,K.jsx)(gt,{field:e}))),o.push(it(`${t}:${e.id}:a`,(0,K.jsx)(vt,{field:e,value:n[e.id],runId:r})));return o}var bt=(e,t)=>e.fields.filter(e=>!e.when&&!be(e)||t[e.id]!==void 0&&t[e.id]!==null);function xt(e,t){let n=[];e.wizard.description&&n.push(q(`hello`,e.wizard.description)),e.wizard.intro&&n.push(q(`intro`,e.wizard.intro));for(let[t,r]of e.answered.entries()){let i=`${t}:${r.id}`;if(r.type===`page`){let t=r.fields.length===1?r.fields[0]:void 0;n.push(...yt(r,i,e.values,e.id,bt(r,e.values),t))}else r.type===`review`&&(n.push(q(i,(0,K.jsx)(`span`,{className:`font-medium`,children:r.title}))),n.push(it(`${i}:a`,U(`run.accept`))))}let r=n.at(-1);return t&&r?.who===`me`&&(n[n.length-1]={...r,onEdit:t}),n}function St(e,t){return e.fields.filter(e=>!be(e)||t.decidedFields?.includes(e.id)).map(e=>t.options?.[e.id]?.length?{...e,options:t.options[e.id]}:e)}function Ct({view:e,run:t,step:n,before:i}){let a=(0,G.useMemo)(()=>St(n,e),[n,e]),o=e.known??{},[s,c]=(0,G.useState)(()=>_(n,e)),[l,u]=(0,G.useState)(()=>n.fields.some(t=>e.values[t.id]!==void 0)?H(St(n,e),e.known??{},_(n,e)).slice(0,-1).map(e=>e.id):[]),[d,f]=(0,G.useState)({}),[p,m]=(0,G.useState)(!1),[h,g]=(0,G.useState)(!1),v=H(a,o,s),y=v.filter(e=>l.includes(e.id)),b=v.find(e=>!l.includes(e.id)),x=a.length===1?a[0]:void 0,S=y.at(-1),C=S?()=>u(e=>e.filter(e=>e!==S.id)):void 0;(0,G.useEffect)(()=>{let e=Object.keys(t.fieldErrors),n=H(a,o,s),r=n.findIndex(t=>e.includes(t.id));r>=0&&(u(n.slice(0,r).map(e=>e.id)),f(t.fieldErrors))},[t.fieldErrors]);let w=e=>{t.submitPage(n.id,e).then(g)},T=(0,G.useContext)(J),E=(0,G.useRef)(s);E.current=s;let D=T?.bindPage,O=(0,G.useRef)(w);O.current=w,(0,G.useEffect)(()=>{if(!D)return;let e=H(a,o,s);return D({step:n,fields:e,values:s,setField:(t,n)=>{let r=e.find(e=>e.id===t);return r?mt(r,n)||(c(e=>({...e,[t]:n})),u(e=>e.includes(t)?e:[...e,t]),f({}),null):`no such field on this page`},submit:()=>O.current(E.current)}),()=>D(null)},[D,n,a,o,s]);let k=e=>{if(!b)return!1;let t=mt(b,e);if(t)return f({[b.id]:t}),!1;let n={...s,[b.id]:e},r=[...l,b.id];return c(n),u(r),f({}),H(a,o,n).some(e=>!r.includes(e.id))||w(n),!0},A=[...i.map(e=>l.length?{...e,onEdit:void 0}:e),...yt(n,`now:${n.id}`,s,e.id,y,x).map((e,t,n)=>t===n.length-1&&e.who===`me`&&b?{...e,onEdit:C}:e)];b?(ft(b)===`control`?A.push(q(`now:${n.id}:${b.id}:control`,(0,K.jsx)(r,{field:b,value:s[b.id],values:s,runId:e.id,view:e,closed:e.closed?.[b.id],onChange:e=>c(t=>({...t,[b.id]:e})),onBusy:m}),{wide:!0})):x||A.push(q(`now:${n.id}:${b.id}`,(0,K.jsx)(gt,{field:b}))),d[b.id]&&A.push(q(`now:${n.id}:${b.id}:error`,d[b.id],{tone:`error`}))):t.busy||h?A.push(q(`sending`,(0,K.jsx)(lt,{}))):t.error&&A.push(q(`send-error`,t.error,{tone:`error`}));let j=(0,K.jsx)(Q,{});if(h||!b&&l.length>0&&t.busy)j=(0,K.jsx)(Q,{placeholder:U(`run.working`)});else if(!b)A.push(X(`now:${n.id}:go`,(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Z,{primary:!0,busy:t.busy,onClick:()=>w(s),children:n.cta||U(`run.next`)}),C?(0,K.jsx)(Z,{onClick:C,disabled:t.busy,children:U(`run.back`)}):null]})));else{let r=ft(b),i=!b.required&&b.kind!==`connection`&&b.kind!==`list`?(0,K.jsx)(Z,{onClick:()=>k(void 0),children:U(`chat.skip`)}):null;if(r===`typed`){i&&A.push(X(`now:${n.id}:${b.id}:replies`,i));let e=s[b.id];j=(0,K.jsx)(st,{children:(0,K.jsx)(dt,{initial:pt(e)?``:String(e),multiline:b.kind===`textarea`,placeholder:b.placeholder||(x?b.label:U(`chat.placeholder`)),inputProps:wt(b),busy:t.busy,onSend:e=>k(ht(b,e))},b.id)})}else if(r===`tapped`)A.push(q(`now:${n.id}:${b.id}:replies`,(0,K.jsx)(Tt,{field:b,view:e,value:s[b.id],onAnswer:k}),{bare:!0}));else{let e=v.filter(e=>!l.includes(e.id)).length===1;A.push(X(`now:${n.id}:${b.id}:replies`,(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Z,{primary:!0,disabled:p,onClick:()=>k(s[b.id]),children:e&&n.cta?n.cta:U(`chat.send`)}),i]})))}}return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Y,{avatar:e.wizard.avatar,costume:e.wizard.costume,lines:A}),j]})}function wt(e){switch(e.kind){case`number`:return{inputMode:`decimal`,autoComplete:`off`};case`email`:return{type:`email`,inputMode:`email`,autoComplete:`email`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1};case`url`:return{inputMode:`url`,autoComplete:`url`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1};case`date`:return{type:`date`};default:return k(e)}}function Tt({field:e,view:t,value:n,onAnswer:r}){let i=new Set(t.closed?.[e.id]?.values.map(String)),[a,o]=(0,G.useState)(Array.isArray(n)?n:[]);if(e.kind===`toggle`)return(0,K.jsxs)(ut,{children:[(0,K.jsx)(Z,{on:n===!1,disabled:i.has(`false`),onClick:()=>r(!1),children:U(`run.no`)}),(0,K.jsx)(Z,{on:n===!0,disabled:i.has(`true`),onClick:()=>r(!0),children:U(`run.yes`)})]});let s=e.options??[];return e.kind===`multiselect`?(0,K.jsxs)(ut,{children:[s.map(e=>(0,K.jsx)(Z,{on:a.includes(e),onClick:()=>o(t=>t.includes(e)?t.filter(t=>t!==e):s.filter(n=>n===e||t.includes(n))),children:Te(e)},e)),(0,K.jsx)(Z,{primary:!0,disabled:e.required&&!a.length,onClick:()=>r(a),children:a.length||e.required?U(`chat.send`):U(`chat.skip`)})]}):(0,K.jsxs)(ut,{children:[s.map(e=>(0,K.jsx)(Z,{on:n===e,disabled:i.has(e),onClick:()=>r(e),children:Te(e)},e)),e.required?null:(0,K.jsx)(Z,{onClick:()=>r(void 0),children:U(`chat.skip`)})]})}function Et({view:e}){let t=(0,G.useMemo)(()=>[...e.events].reverse().find(t=>t.type===`step_started`&&t.stepId===e.step?.id),[e.events,e.step?.id]),n=t?new Date(t.at).getTime():Date.now(),[r,i]=(0,G.useState)(Date.now());(0,G.useEffect)(()=>{let e=setInterval(()=>i(Date.now()),1e3);return()=>clearInterval(e)},[]);let a=e.events.filter(e=>(e.type===`tool`||e.type===`info`)&&new Date(e.at).getTime()>=n-500),o=a.at(-1),s=[...a].reverse().find(Ot),c=[...new Set(a.map(e=>e.asset).filter(e=>!!e))];return(0,K.jsxs)(`div`,{className:E(`flex max-w-full flex-col gap-1`,s?`w-full`:`w-96`),"data-say-text":t?.message??e.step?.title??U(`run.working`),children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(lt,{}),(0,K.jsx)(`span`,{className:`font-medium`,children:t?.message??e.step?.title??U(`run.working`)}),(0,K.jsx)(`span`,{className:`text-[0.75rem] text-ink-4 tabular-nums`,children:U(`run.elapsed`,{s:Math.max(0,Math.round((r-n)/1e3))})})]}),o&&o!==s?(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[0.8125rem] text-ink-3`,children:[(0,K.jsx)(g,{className:`size-3.5 shrink-0 animate-breathe text-ember`}),(0,K.jsx)(`span`,{className:`truncate`,children:we(o)})]}):null,s&&e.status===`running`?(0,K.jsx)(At,{runId:e.id,event:s}):null,c.length?(0,K.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-1.5`,children:c.slice(-6).map(t=>(0,K.jsx)(`img`,{src:M(`/api/runs/${e.id}/assets/${t}`),alt:``,className:`size-14 rounded-lg bg-paper-2 object-cover ring-1 ring-border-soft`},t))}):null]})}var Dt=new Set([`opens`,`clicks`,`clicksOn`,`types`,`typesText`,`selects`,`scrolls`,`presses`,`goesBack`,`waitsForPage`,`fastLoop`,`looksAtPage`,`personDrives`,`agentDrives`]);function Ot(e){return!!e.note&&Dt.has(e.note.code)}var kt=1e4;function At({runId:e,event:t}){let[n,r]=(0,G.useState)(null),[i,a]=(0,G.useState)(`agent`),[o,s]=(0,G.useState)(!1),c=t.note?.code;if((0,G.useEffect)(()=>{c===`personDrives`?a(`person`):c===`agentDrives`&&a(`agent`)},[c]),(0,G.useEffect)(()=>{let t=()=>h.get(`/api/runs/${e}/browser/seat`).then(e=>a(e.seat)).catch(()=>void 0);if(t(),i!==`person`)return;let n=setInterval(t,kt);return()=>clearInterval(n)},[e,i]),n!==null&&n>=t.id)return null;let l=i===`person`,u=async()=>{s(!0);try{let t=await h.post(`/api/runs/${e}/browser/seat`,{to:l?`agent`:`person`});a(t.seat)}catch{}finally{s(!1)}};return(0,K.jsx)(b,{runId:e,driving:l,caption:we(t),hint:U(`browser.driving`),onBroken:()=>r(t.id),className:`mt-1.5`,action:(0,K.jsxs)(`button`,{type:`button`,disabled:o,onClick:()=>void u(),className:E(`flex h-8 items-center gap-1.5 rounded-full px-3 font-medium text-[0.8125rem] shadow-soft transition-colors disabled:opacity-60`,l?`bg-primary text-primary-foreground hover:bg-primary/90`:`bg-card/90 text-ink ring-1 ring-border-soft backdrop-blur hover:bg-card`),children:[l?(0,K.jsx)(oe,{className:`size-3.5`}):(0,K.jsx)(Ae,{className:`size-3.5`}),U(l?`browser.handBack`:`browser.takeOver`)]})},n??0)}function jt({children:e,end:t}){return(0,K.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,K.jsx)(`h3`,{className:`font-display font-semibold text-[1rem]`,children:e}),t]})}function Mt({view:e,run:t,step:n,before:r,asked:i,onNote:a}){let o=e.shown.filter(e=>e.output),[c,l]=(0,G.useState)(o.length===1?o[0].step.id:null),u=(0,G.useRef)(null),d=[...r,...i.map((e,t)=>it(`review:${n.id}:asked:${t}`,e)),q(`review:${n.id}`,(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`font-medium`,children:n.title}),n.description?(0,K.jsx)(`span`,{className:`mt-0.5 block text-ink-2`,children:n.description}):null]}),{anchor:!0}),...o.map(({step:t,output:r})=>q(`review:${n.id}:${t.id}`,(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(jt,{children:t.title}),(0,K.jsx)(p,{base:`/api/runs/${e.id}`,step:t,output:r,onSurfaceAction:n.regenerate?()=>{l(t.id),u.current?.focus()}:void 0})]}),{wide:!0})),...e.lists.map(t=>q(`review:${n.id}:list:${t.def.id}`,(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(jt,{children:t.def.title}),t.def.check?(0,K.jsx)(f,{runId:e.id,list:t}):(0,K.jsx)(s,{runId:e.id,list:t,editable:!0})]}),{wide:!0}))];t.error&&d.push(q(`review-error`,t.error,{tone:`error`}));let m=n.regenerate&&o.length>0;return d.push(X(`review:${n.id}:replies`,(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(Z,{primary:!0,busy:t.busy,onClick:()=>void t.accept(n.id),children:[(0,K.jsx)(ne,{className:`size-4`}),` `,U(`run.accept`)]}),m&&o.length>1?o.map(({step:e})=>(0,K.jsx)(Z,{on:c===e.id,onClick:()=>l(e.id),children:e.title},e.id)):null]}))),(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Y,{avatar:e.wizard.avatar,costume:e.wizard.costume,lines:d}),m?(0,K.jsx)(st,{children:(0,K.jsx)(dt,{multiline:!0,inputRef:u,busy:t.busy,placeholder:o.length>1&&!c?U(`run.feedbackPick`):U(`run.feedbackPlaceholder`),disabled:!c,onSend:e=>{let r=e.trim();return!r||!c?!1:(a(r),t.regenerate(n.id,c,r),!0)}})}):(0,K.jsx)(Q,{})]})}function Nt({view:e,run:t,step:n,before:r,onRestart:i}){let o=e.shown.filter(e=>e.output),c=`/api/runs/${e.id}`,u=[...r,q(`result:${n.id}`,(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`font-display font-semibold text-[1.0625rem]`,children:n.title}),n.message?(0,K.jsx)(`span`,{className:`mt-0.5 block text-ink-2`,children:n.message}):null]}),{anchor:!0}),...o.map(({step:e,output:t,formats:n,label:r})=>q(`result:${e.id}`,(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(jt,{end:(0,K.jsx)(I,{base:c,stepId:e.id,formats:n,title:r??e.title}),children:r??e.title}),(0,K.jsx)(p,{base:c,step:e,output:t}),t?.assets?.some(e=>e.ai)?(0,K.jsx)(`p`,{className:`mt-3 text-[0.75rem] text-ink-3 leading-relaxed`,children:U(`ai.publish`)}):null]}),{wide:!0})),...e.lists.map(t=>q(`result:list:${t.def.id}`,(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(jt,{end:(0,K.jsx)(m,{runId:e.id,list:t}),children:t.label??t.def.title}),(0,K.jsx)(s,{runId:e.id,list:t,editable:!0})]}),{wide:!0}))];return u.push(X(`result:replies`,(0,K.jsxs)(K.Fragment,{children:[o.length?(0,K.jsx)(Oe,{view:e,title:`${n.title} · ${e.wizard.title}`}):null,i?(0,K.jsxs)(Z,{onClick:i,children:[(0,K.jsx)(a,{className:`size-4`}),` `,U(`run.again`)]}):null,e.canBack?(0,K.jsx)(Z,{onClick:()=>void t.back(),disabled:t.busy,children:U(`run.back`)}):null,e.keeps?(0,K.jsx)(`span`,{className:`ml-1`,children:(0,K.jsx)(l,{runId:e.id})}):null]}))),(0,K.jsx)(Y,{avatar:e.wizard.avatar,costume:e.wizard.costume,lines:u})}function Pt({runId:e,onRestart:t,onNotFound:n,onView:r,header:o,footer:s,talk:l=!1,call:u=!1}){let d=rt(e),{view:f}=d,[p,m]=(0,G.useState)(null),h=Ze(e,f,d,p);(0,G.useEffect)(()=>{r?.(f)},[f,r]),(0,G.useEffect)(()=>{d.notFound&&n?.()},[d.notFound,n]);let[g,_]=ie(),y=(0,G.useMemo)(()=>({runId:e,lang:f?.lang??Ce,readAloud:g,setReadAloud:_,voice:f?.talk?h:null,talk:l,call:!!u,bindPage:m}),[e,f?.lang,f?.talk,g,_,h,l,u]);c(f?.status===`running`&&!f.ask),i(f);let[b,x]=(0,G.useState)({}),[S,C]=(0,G.useState)(null);(0,G.useEffect)(()=>{f&&f.status!==`running`&&C(null)},[f]);let w;if(d.notFound)w=n?null:(0,K.jsx)(`div`,{className:`py-24 text-center text-ink-3`,children:U(`run.notFound`)});else if(!f)w=(0,K.jsx)(`div`,{className:`flex justify-center py-24 text-ink-4`,children:(0,K.jsx)(F,{})});else{let e=f.step,n=f.status===`waiting_input`,r=xt(f,f.canBack&&n&&!d.busy?()=>void d.back():void 0);if(f.status===`running`&&f.ask)w=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Y,{avatar:f.wizard.avatar,costume:f.wizard.costume,lines:[...r,q(`ask:${f.ask.id}`,(0,K.jsx)(v,{runId:f.id,ask:f.ask}),{wide:!0})]}),(0,K.jsx)(Q,{})]});else if(f.status===`running`)w=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Y,{avatar:f.wizard.avatar,costume:f.wizard.costume,lines:[...r,...S?[it(`note`,S)]:[],q(`working:${e?.id}`,(0,K.jsx)(Et,{view:f}),{wide:f.events.some(t=>t.stepId===e?.id&&Ot(t))?`most`:void 0})]}),(0,K.jsx)(Q,{placeholder:U(`run.working`)})]});else if(f.status===`sleeping`)w=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Y,{avatar:f.wizard.avatar,costume:f.wizard.costume,lines:[...r,q(`sleeping`,te(f.wakeAt))]}),(0,K.jsx)(Q,{placeholder:U(`run.leavePage`)})]});else if(f.status===`failed`)w=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Y,{avatar:f.wizard.avatar,costume:f.wizard.costume,lines:[...r,q(`failed`,(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`font-medium`,children:U(`run.failed`)}),f.error?(0,K.jsx)(`span`,{className:`mt-0.5 block`,children:(0,K.jsx)(N,{text:f.error})}):null]}),{tone:`error`}),X(`failed:replies`,(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(Z,{primary:!0,busy:d.busy,onClick:()=>void d.retry(),children:[(0,K.jsx)(a,{className:`size-4`}),` `,U(`run.retry`)]}),f.canBack?(0,K.jsx)(Z,{onClick:()=>void d.back(),disabled:d.busy,children:U(`run.back`)}):null]}))]}),(0,K.jsx)(Q,{})]});else if(f.status===`cancelled`)w=(0,K.jsx)(Y,{avatar:f.wizard.avatar,costume:f.wizard.costume,lines:[...r,q(`cancelled`,U(`run.cancelled`)),...t?[X(`cancelled:replies`,(0,K.jsxs)(Z,{primary:!0,onClick:t,children:[(0,K.jsx)(a,{className:`size-4`}),` `,U(`run.again`)]}))]:[]]});else if(e?.type===`page`)w=(0,K.jsx)(Ct,{view:f,run:d,step:e,before:r},e.id);else if(e?.type===`review`){let t=f.shown.map(e=>e.output?.at??``).join(`|`);w=(0,K.jsx)(Mt,{view:f,run:d,step:e,before:r,asked:b[e.id]??[],onNote:t=>{C(t),x(n=>({...n,[e.id]:[...n[e.id]??[],t]}))}},`${e.id}:${t}`)}else w=e?.type===`result`?(0,K.jsx)(Nt,{view:f,run:d,step:e,before:r,onRestart:t}):(0,K.jsx)(Y,{avatar:f.wizard.avatar,costume:f.wizard.costume,lines:r})}return u?(0,K.jsx)(J.Provider,{value:y,children:(0,K.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col lg:flex-row`,children:[(0,K.jsx)(Ge,{voice:h,view:f,video:u===`video`,className:`h-[46dvh] shrink-0 lg:h-auto lg:min-h-0 lg:flex-1`}),(0,K.jsx)(`aside`,{className:`flex min-h-0 flex-1 flex-col border-border-soft border-t lg:w-[420px] lg:flex-none lg:border-t-0 lg:border-l`,children:(0,K.jsx)(ct,{footer:s,children:w})})]})}):(0,K.jsx)(J.Provider,{value:y,children:(0,K.jsx)(ct,{header:o,footer:s,children:w})})}function Ft({runId:e,onNotFound:t,...n}){let r=rt(e);return(0,G.useEffect)(()=>{r.notFound&&t?.()},[r.notFound,t]),r.notFound&&t?null:(0,K.jsx)(C,{run:r,...n})}function $(e){let t=Math.sin(e*127.1+311.7)*43758.5453;return t-Math.floor(t)}function It(e){let t=Array.from({length:7},(t,n)=>({a:(n+.2+$(e+n)*.5)/7.2*(Math.PI/2),len:200*(.84+.16*$(e+n+20))})),n=t.map(e=>`M0 0L${(Math.cos(e.a)*e.len).toFixed(1)} ${(Math.sin(e.a)*e.len).toFixed(1)}`);for(let e=1;e<=9;e++){let r=200*(e/9.6)**1.08;t.slice(1).forEach((e,i)=>{let a=t[i],o=Math.min(r,a.len),s=Math.min(r,e.len),c=(a.a+e.a)/2,l=r*.86;i===0&&n.push(`M${(Math.cos(a.a)*o).toFixed(1)} ${(Math.sin(a.a)*o).toFixed(1)}`),n.push(`Q${(Math.cos(c)*l).toFixed(1)} ${(Math.sin(c)*l).toFixed(1)} ${(Math.cos(e.a)*s).toFixed(1)} ${(Math.sin(e.a)*s).toFixed(1)}`)})}return n.join(``)}var Lt={left:It(1),right:It(9)};function Rt({side:e,className:t}){return(0,K.jsx)(`svg`,{className:t??`wizard-web wizard-web-${e}`,viewBox:`0 0 200 200`,"aria-hidden":`true`,children:(0,K.jsx)(`path`,{d:Lt[e],fill:`none`,stroke:`currentColor`,strokeLinecap:`round`})})}function zt(){return(0,K.jsxs)(`div`,{className:`wizard-spider`,children:[(0,K.jsx)(`div`,{className:`wizard-spider-thread`}),(0,K.jsxs)(`svg`,{viewBox:`-30 -10 60 60`,"aria-hidden":`true`,children:[(0,K.jsx)(`g`,{stroke:`currentColor`,strokeWidth:`2.6`,strokeLinecap:`round`,fill:`none`,children:[0,1,2,3].map(e=>(0,K.jsxs)(`g`,{children:[(0,K.jsx)(`path`,{d:`M0 ${8+e*5} Q-16 ${-2+e*6} -24 ${14+e*6}`}),(0,K.jsx)(`path`,{d:`M0 ${8+e*5} Q16 ${-2+e*6} 24 ${14+e*6}`})]},e))}),(0,K.jsx)(`ellipse`,{cx:`0`,cy:`22`,rx:`11`,ry:`14`,fill:`currentColor`}),(0,K.jsx)(`circle`,{cx:`0`,cy:`6`,r:`7`,fill:`currentColor`}),(0,K.jsx)(`circle`,{cx:`-2.6`,cy:`7`,r:`1.6`,className:`wizard-spider-eye`}),(0,K.jsx)(`circle`,{cx:`2.6`,cy:`7`,r:`1.6`,className:`wizard-spider-eye`})]})]})}function Bt({side:e}){let t=Array.from({length:9},(e,t)=>{let n=(t+.5)/9*(Math.PI/2),r=70+$(t+40)*110,i=Math.cos(n)*r,a=Math.sin(n)*r,o=Math.cos(n)*r*.55,s=Math.sin(n)*r*.55,c=14+$(t+50)*16;return`M0 0L${i.toFixed(1)} ${a.toFixed(1)}M${o.toFixed(1)} ${s.toFixed(1)}l${(Math.cos(n+.6)*c).toFixed(1)} ${(Math.sin(n+.6)*c).toFixed(1)}M${o.toFixed(1)} ${s.toFixed(1)}l${(Math.cos(n-.6)*c).toFixed(1)} ${(Math.sin(n-.6)*c).toFixed(1)}`}).join(``);return(0,K.jsx)(`svg`,{className:`wizard-frost wizard-web-${e}`,viewBox:`0 0 200 200`,"aria-hidden":`true`,children:(0,K.jsx)(`path`,{d:t,fill:`none`,stroke:`currentColor`,strokeLinecap:`round`})})}function Vt({kind:e}){let t=e===`stars`?28:22;return(0,K.jsx)(`div`,{className:`wizard-particles wizard-particles-${e}`,children:Array.from({length:t},(t,n)=>(0,K.jsx)(`span`,{style:{left:`${($(n+1)*100).toFixed(2)}%`,top:e===`stars`?`${($(n+2)*100).toFixed(2)}%`:void 0,animationDuration:`${(e===`stars`?2.5:9)+$(n+3)*8}s`,animationDelay:`${(-$(n+4)*16).toFixed(2)}s`,scale:(.6+$(n+5)*.9).toFixed(2),"--hue":`${Math.round($(n+6)*360)}`}},n))})}var Ht=[{kind:`round`,top:16,size:64,seconds:17,delay:1},{kind:`drop`,top:42,size:48,seconds:21,delay:7},{kind:`tower`,top:26,size:56,seconds:19,delay:12.5}],Ut=[{kind:`flame`,side:`right`,seconds:14,delay:2},{kind:`sprout`,side:`left`,seconds:16,delay:9}];function Wt({costume:e,motion:t}){return t===`peek`?(0,K.jsx)(K.Fragment,{children:Ut.map(t=>(0,K.jsx)(`div`,{className:`wizard-peek wizard-peek-${t.side}`,style:{animationDuration:`${t.seconds}s`,animationDelay:`${t.delay}s`},children:(0,K.jsx)(he,{kind:t.kind,costume:e,size:96})},t.kind))}):(0,K.jsx)(K.Fragment,{children:Ht.map(t=>(0,K.jsx)(`div`,{className:`wizard-bat`,style:{top:`${t.top}%`,animationDuration:`${t.seconds}s`,animationDelay:`${t.delay}s`},children:(0,K.jsx)(`div`,{className:`wizard-bat-bob`,children:(0,K.jsx)(he,{kind:t.kind,costume:e,size:t.size})})},t.kind))})}var Gt=[`witch`,`devil`,`bat`,`pumpkin`];function Kt({effects:e,contained:t}){let n=(e??[]).filter(e=>[`corners`,`particles`,`figures`,`fog`].includes(e.id));if(!n.length)return null;let r=(e,t)=>typeof e[t]==`string`?String(e[t]):``;return(0,K.jsxs)(K.Fragment,{children:[n.some(e=>e.id===`fog`)?(0,K.jsx)(`div`,{"aria-hidden":`true`,className:t?`wizard-fog wizard-fx-contained`:`wizard-fog`}):null,(0,K.jsx)(`div`,{"aria-hidden":`true`,className:t?`wizard-fx wizard-fx-contained`:`wizard-fx`,children:n.map((e,t)=>{let n=`${e.id}-${t}`;if(e.id===`corners`){let t=r(e,`kind`)||`webs`;return t===`frost`?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Bt,{side:`left`}),(0,K.jsx)(Bt,{side:`right`})]},n):t===`webs`?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Rt,{side:`left`}),(0,K.jsx)(Rt,{side:`right`}),(0,K.jsx)(zt,{})]},n):null}if(e.id===`particles`){let t=r(e,`kind`)||`embers`;return[`embers`,`snow`,`confetti`,`stars`].includes(t)?(0,K.jsx)(Vt,{kind:t},n):null}if(e.id===`figures`){let t=r(e,`costume`);return(0,K.jsx)(Wt,{costume:Gt.includes(t)?t:void 0,motion:r(e,`motion`)||`fly`},n)}return null})})]})}var qt=[`brand`,`host`,`default`],Jt=[...qt,`engenty`,`wizard`,`wizards`],Yt=[`Inter`,`Figtree`,`DM Sans`,`Nunito`,`Fredoka`,`Bricolage Grotesque`,`Fraunces`,`Playfair Display`,`Lora`,`Young Serif`,`Caveat`,`Creepster`,`Nosifer`],Xt=B().regex(/^#[0-9a-fA-F]{6}$/,`a colour as #rrggbb`),Zt=W({accent:Xt.optional(),background:Xt.optional(),text:Xt.optional()}).extend({scheme:V([`light`,`dark`])}),Qt=W({radius:V([`sharp`,`soft`,`round`]).optional(),cards:V([`solid`,`outline`,`glass`]).optional(),headings:V([`normal`,`uppercase`]).optional()}),$t=W({id:B().min(1).max(40)}).catchall(ve([B().max(40),ge(),xe()])),en=B().min(1).max(60).regex(/^[A-Za-z0-9 -]+$/,`a font by its family name, or brand`);W({id:B().regex(ye,`a theme id: lowercase letters, digits and dashes`),name:B().min(1).max(80),version:B().regex(/^\d+\.\d+\.\d+$/).default(`1.0.0`),base:V(qt).default(`brand`),colors:Ee(Zt).min(1).max(2).refine(e=>new Set(e.map(e=>e.scheme)).size===e.length,{message:`Each scheme once: light, dark.`}).optional(),fonts:W({heading:en.optional(),text:en.optional()}).optional(),shape:Qt.optional(),effects:Ee($t).max(8).optional()});function tn(e,t){if(!t.has(e))return e;for(let n=2;;n++){let r=`${e.slice(0,44)}-${n}`;if(!t.has(r))return r}}function nn(e){let t=e.normalize(`NFKD`).replace(/[̀-ͯ]/g,``).toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,48);return t&&!Jt.includes(t)?t:`look`}function rn(e,t){let n=e?.colors?.find(e=>e.scheme===t);if(!n)return;let{scheme:r,...i}=n;return i}var an=`ui-sans-serif, system-ui, sans-serif`,on=`ui-serif, Georgia, serif`,sn=/serif|fraunces|playfair|lora|garamond|antiqua|baskerville|caslon|bodoni|didot|times|georgia|merriweather|tiempos/i,cn=e=>sn.test(e)&&!/sans/i.test(e),ln=e=>cn(e)?`Lora`:`Inter`;function un(e,t=[]){let n=t.some(t=>t.family===e)?`"${ln(e)}", `:``;return`"${e.replace(/"/g,``)}", ${n}${cn(e)?on:an}`}function dn(e,t){let n=e.modes?.[t];return{accent:n?.accent??e.accent,background:n?.background??e.background,text:n?.text??null}}var fn={Inter:()=>[R(()=>Promise.resolve({}),__vite__mapDeps([0])),R(()=>Promise.resolve({}),__vite__mapDeps([1])),R(()=>Promise.resolve({}),__vite__mapDeps([2])),R(()=>Promise.resolve({}),__vite__mapDeps([3]))],Figtree:()=>[R(()=>Promise.resolve({}),__vite__mapDeps([4])),R(()=>Promise.resolve({}),__vite__mapDeps([5])),R(()=>Promise.resolve({}),__vite__mapDeps([6])),R(()=>Promise.resolve({}),__vite__mapDeps([7]))],"DM Sans":()=>[R(()=>Promise.resolve({}),__vite__mapDeps([8])),R(()=>Promise.resolve({}),__vite__mapDeps([9])),R(()=>Promise.resolve({}),__vite__mapDeps([10])),R(()=>Promise.resolve({}),__vite__mapDeps([11]))],Nunito:()=>[R(()=>Promise.resolve({}),__vite__mapDeps([12])),R(()=>Promise.resolve({}),__vite__mapDeps([13])),R(()=>Promise.resolve({}),__vite__mapDeps([14])),R(()=>Promise.resolve({}),__vite__mapDeps([15]))],Fredoka:()=>[R(()=>Promise.resolve({}),__vite__mapDeps([16])),R(()=>Promise.resolve({}),__vite__mapDeps([17])),R(()=>Promise.resolve({}),__vite__mapDeps([18])),R(()=>Promise.resolve({}),__vite__mapDeps([19]))],"Bricolage Grotesque":()=>[R(()=>Promise.resolve({}),__vite__mapDeps([20])),R(()=>Promise.resolve({}),__vite__mapDeps([21])),R(()=>Promise.resolve({}),__vite__mapDeps([22])),R(()=>Promise.resolve({}),__vite__mapDeps([23]))],Fraunces:()=>[R(()=>Promise.resolve({}),__vite__mapDeps([24])),R(()=>Promise.resolve({}),__vite__mapDeps([25])),R(()=>Promise.resolve({}),__vite__mapDeps([26])),R(()=>Promise.resolve({}),__vite__mapDeps([27]))],"Playfair Display":()=>[R(()=>Promise.resolve({}),__vite__mapDeps([28])),R(()=>Promise.resolve({}),__vite__mapDeps([29])),R(()=>Promise.resolve({}),__vite__mapDeps([30])),R(()=>Promise.resolve({}),__vite__mapDeps([31]))],Lora:()=>[R(()=>Promise.resolve({}),__vite__mapDeps([32])),R(()=>Promise.resolve({}),__vite__mapDeps([33])),R(()=>Promise.resolve({}),__vite__mapDeps([34])),R(()=>Promise.resolve({}),__vite__mapDeps([35]))],"Young Serif":()=>[R(()=>Promise.resolve({}),__vite__mapDeps([36]))],Caveat:()=>[R(()=>Promise.resolve({}),__vite__mapDeps([37])),R(()=>Promise.resolve({}),__vite__mapDeps([38])),R(()=>Promise.resolve({}),__vite__mapDeps([39])),R(()=>Promise.resolve({}),__vite__mapDeps([40]))],Creepster:()=>[R(()=>Promise.resolve({}),__vite__mapDeps([41]))],Nosifer:()=>[R(()=>Promise.resolve({}),__vite__mapDeps([42]))]},pn=new Set;function mn(e){e&&!pn.has(e)&&e in fn&&(pn.add(e),Promise.all(fn[e]()).catch(()=>pn.delete(e)))}function hn(e){ze(e,e.url.startsWith(`/`)?M(e.url):e.url,()=>mn(ln(e.family)))}function gn(e,t){let n=e.faces??[],r=!!e.modes,i=dn({accent:e.accent??null,background:e.background??null,modes:e.modes??null},r?t:e.dark?`dark`:`light`),a=r?t===`dark`:!!e.dark,o=[[`--raw-primary`,i.accent],[`--raw-second`,e.second],[`--raw-background`,i.background],[`--brand-stage`,i.background?a?i.background:`oklch(from ${i.background} 0.3 clamp(0.02, calc(c * 3), 0.1) h)`:null],[`--ink`,i.text],[`--f-display`,e.display?un(e.display,n):null],[`--f-ui`,e.body?un(e.body,n):null],[`font-synthesis-weight`,e.display||e.body?`none`:null]],s=[...Object.entries(e.shape??{}).filter(([,e])=>e).map(([e,t])=>`shape-${e}-${t}`),...(e.effects??[]).flatMap(e=>e.id===`glow`?[`fx-glow`]:e.id===`pattern`?[`fx-pattern-${e.kind??`dots`}`]:[])];return{props:o.filter(e=>!!e[1]),marks:s,dark:a,themed:r}}function _n(e){return!!(e&&!e.pinned&&e.modes?.light&&e.modes.dark)}function vn(e){for(let t of e.faces??[])hn(t);mn(e.display),mn(e.body)}function yn(e){de(e?.pinned?e.dark?`dark`:`light`:null),fe(e?.prefer??null);let t=pe(),n=JSON.stringify(e??{});(0,G.useEffect)(()=>{let e=JSON.parse(n),r=document.documentElement;vn(e);let{props:i,marks:a,themed:o}=gn(e,t);for(let[e,t]of i)r.style.setProperty(e,t);r.classList.add(...a);let s=r.classList.contains(`dark`);return!o&&e.dark&&!e.pinned&&r.classList.add(`dark`),()=>{for(let[e]of i)r.style.removeProperty(e);r.classList.remove(...a),!o&&e.dark&&!e.pinned&&!s&&r.classList.remove(`dark`)}},[n,t])}function bn(e,t){let n=JSON.stringify(e??{});if((0,G.useEffect)(()=>{vn(JSON.parse(n))},[n]),!e)return null;let r=e.pinned||!e.prefer?e.dark?`dark`:`light`:e.prefer,{props:i,marks:a,dark:o}=gn(e,t&&_n(e)?t:r);return{className:[`wizard-themed`,...a,o?`dark`:``].filter(Boolean).join(` `),style:Object.fromEntries(i)}}export{Y as _,mn as a,Me as b,rn as c,Kt as d,Ft as f,Z as g,Q as h,hn as i,nn as l,ct as m,yn as n,Yt as o,Pt as p,bn as r,tn as s,_n as t,Rt as u,X as v,ot as y};