wizards 0.2.44 → 0.2.46

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 (89) hide show
  1. package/apps/runtime/dist/app.js +31 -1
  2. package/apps/runtime/dist/cli/main.js +8 -1
  3. package/apps/runtime/dist/cli/report.js +81 -0
  4. package/apps/runtime/dist/debug.js +196 -0
  5. package/apps/runtime/dist/harness/model.js +2 -0
  6. package/apps/runtime/dist/index.js +3 -0
  7. package/apps/runtime/dist/log.js +106 -0
  8. package/apps/runtime/dist/routes/debug.js +42 -0
  9. package/apps/runtime/dist/routes/internal.js +18 -5
  10. package/apps/runtime/dist/routes/runs.js +1 -1
  11. package/apps/runtime/dist/routes/studio.js +5 -2
  12. package/apps/runtime/dist/tenants/control.js +7 -0
  13. package/apps/runtime/dist/update.js +9 -5
  14. package/apps/web/dist/assets/AboutDialog-DkY1j7k6.js +1 -0
  15. package/apps/web/dist/assets/ChangelogDialog-820LI5Jt.js +1 -0
  16. package/apps/web/dist/assets/ChatView-DBl0iRMg.js +10 -0
  17. package/apps/web/dist/assets/EditorPage-BwJ-hqPg.js +3 -0
  18. package/apps/web/dist/assets/{FlowPreview-DgZiepFR.js → FlowPreview-ChXfiMn_.js} +1 -1
  19. package/apps/web/dist/assets/{Harness-ffZUxkbb.js → Harness-CfUfchNw.js} +2 -2
  20. package/apps/web/dist/assets/HomePage-BG5OZJkv.js +1 -0
  21. package/apps/web/dist/assets/Marketplace-BWhUJ4UX.js +2 -0
  22. package/apps/web/dist/assets/NewWizardPage-C3NqEGmg.js +1 -0
  23. package/apps/web/dist/assets/ProjectPage-Btf0TeP_.js +2 -0
  24. package/apps/web/dist/assets/PublicRunner-BxYinn04.js +1 -0
  25. package/apps/web/dist/assets/ReadOnly-C9P9aiU6.js +1 -0
  26. package/apps/web/dist/assets/RunDrawer-DfnEMPTq.js +4 -0
  27. package/apps/web/dist/assets/RunnerView-CLrGb-oq.js +2 -0
  28. package/apps/web/dist/assets/SettingsPage-FWH84btd.js +1 -0
  29. package/apps/web/dist/assets/SetupPage-BI0kUNVW.js +1 -0
  30. package/apps/web/dist/assets/SharePage-D5AvnhlY.js +1 -0
  31. package/apps/web/dist/assets/ThemeSwitch-C1qYFoYP.js +1 -0
  32. package/apps/web/dist/assets/arrow-right-Dpp_mpHe.js +1 -0
  33. package/apps/web/dist/assets/changelog-B6QMrVxX.js +1 -0
  34. package/apps/web/dist/assets/{circle-alert-D_6s0Xgw.js → circle-alert-CPo3Naay.js} +1 -1
  35. package/apps/web/dist/assets/definition-CQGiBQ4X.js +56 -0
  36. package/apps/web/dist/assets/{external-link-DitV3n6l.js → external-link-CpU8aJY2.js} +1 -1
  37. package/apps/web/dist/assets/index-CIO9W4pe.js +78 -0
  38. package/apps/web/dist/assets/index-DKHClEy3.css +1 -0
  39. package/apps/web/dist/assets/{lock-DSPinlFN.js → lock-C_WlXIQ0.js} +1 -1
  40. package/apps/web/dist/assets/logo-C80CWCDM.js +1 -0
  41. package/apps/web/dist/assets/{refresh-cw-CWRkEENy.js → refresh-cw-Cli5WGnW.js} +1 -1
  42. package/apps/web/dist/assets/session-miDEdw2c.js +1 -0
  43. package/apps/web/dist/assets/settings-menu-ROT8Lbbj.js +1 -0
  44. package/apps/web/dist/assets/sparkles-CP5H-O1E.js +1 -0
  45. package/apps/web/dist/assets/{trash-t3O7FdUR.js → trash-DU-hZpV0.js} +1 -1
  46. package/apps/web/dist/assets/ui-D92EkdEB.js +9 -0
  47. package/apps/web/dist/assets/upload-DMq5N6Fw.js +1 -0
  48. package/apps/web/dist/assets/useMutation-DKcIz55V.js +1 -0
  49. package/apps/web/dist/assets/volume-2-0SfkvOho.js +1 -0
  50. package/apps/web/dist/index.html +14 -13
  51. package/apps/web/dist/mcp/flow.html +43 -43
  52. package/modules/calls/dist/client.css +1 -1
  53. package/modules/sms/dist/client.css +1 -1
  54. package/modules/whatsapp/dist/client.css +1 -1
  55. package/package.json +1 -1
  56. package/apps/web/dist/assets/ChangelogDialog-C1_ZvuwE.js +0 -1
  57. package/apps/web/dist/assets/ChatView-DLG771z6.js +0 -10
  58. package/apps/web/dist/assets/CreditsDialog-Ce7Czhxq.js +0 -1
  59. package/apps/web/dist/assets/EditorPage-CXx32-a7.js +0 -3
  60. package/apps/web/dist/assets/HomePage-B3RVPuUu.js +0 -1
  61. package/apps/web/dist/assets/ImportWizard-CHlCjPEo.js +0 -1
  62. package/apps/web/dist/assets/NewWizardPage-BQW7PoZq.js +0 -2
  63. package/apps/web/dist/assets/ProjectPage-D-_A4iZz.js +0 -2
  64. package/apps/web/dist/assets/PublicRunner-sbya6PXg.js +0 -1
  65. package/apps/web/dist/assets/RunDrawer-BgLxai9C.js +0 -4
  66. package/apps/web/dist/assets/RunnerView-BVm9fL62.js +0 -2
  67. package/apps/web/dist/assets/SettingsPage-Ce6k9xDs.js +0 -1
  68. package/apps/web/dist/assets/SetupPage-CLymFxat.js +0 -1
  69. package/apps/web/dist/assets/SharePage-1Ni5ejt6.js +0 -1
  70. package/apps/web/dist/assets/ThemeSwitch-DN42WOTx.js +0 -1
  71. package/apps/web/dist/assets/arrow-right-BgKM1Npq.js +0 -1
  72. package/apps/web/dist/assets/changelog-CH4sN8Dm.js +0 -1
  73. package/apps/web/dist/assets/copy-BAtcCufT.js +0 -1
  74. package/apps/web/dist/assets/definition-CfFlylCM.js +0 -56
  75. package/apps/web/dist/assets/globe-CoQ1BSyl.js +0 -1
  76. package/apps/web/dist/assets/image-B1a1ax-P.js +0 -1
  77. package/apps/web/dist/assets/index-B8VsYgck.js +0 -78
  78. package/apps/web/dist/assets/index-mB3Du8ho.css +0 -1
  79. package/apps/web/dist/assets/meta-Bpe6vzmM.js +0 -1
  80. package/apps/web/dist/assets/mouse-pointer-click-SHJL7g1i.js +0 -1
  81. package/apps/web/dist/assets/pen-line-DgSzJ60H.js +0 -1
  82. package/apps/web/dist/assets/session-C24kIPr-.js +0 -1
  83. package/apps/web/dist/assets/settings-menu-e8OMChHm.js +0 -1
  84. package/apps/web/dist/assets/star-ClV5w6K4.js +0 -1
  85. package/apps/web/dist/assets/type-BbMmv2qL.js +0 -1
  86. package/apps/web/dist/assets/ui-C4b__6Oo.js +0 -9
  87. package/apps/web/dist/assets/video-D04-GeyG.js +0 -1
  88. package/apps/web/dist/assets/volume-2-FUU7z0rq.js +0 -1
  89. package/apps/web/dist/assets/wand-sparkles-BsD2e8V6.js +0 -1
@@ -0,0 +1 @@
1
+ import{a as e,i as t,n,t as r}from"./jsx-runtime-D3jfb0Ew.js";import{O as i,r as a}from"./logo-C80CWCDM.js";import{b as o,c as s,f as c,m as l,n as u,p as d,x as f}from"./Marketplace-BWhUJ4UX.js";import{t as p}from"./useMutation-DKcIz55V.js";import{A as m,B as ee,C as h,D as g,G as _,I as v,J as y,M as b,P as x,Q as te,R as ne,V as S,_ as C,a as re,c as w,d as ie,f as T,g as ae,i as oe,n as E,nt as D,o as O,r as k,s as A,t as j}from"./ui-D92EkdEB.js";import{n as se,r as M,t as ce}from"./sparkles-CP5H-O1E.js";import{t as N}from"./external-link-CpU8aJY2.js";import{n as le}from"./volume-2-0SfkvOho.js";import{O as ue}from"./definition-CQGiBQ4X.js";import{d as de,f as fe,s as P,t as pe,u as me}from"./session-miDEdw2c.js";import{a as F,i as he,r as I,t as ge}from"./ThemeSwitch-C1qYFoYP.js";var L={name:`arrow-up-right`,size:24,node:[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]};L.node;var _e=y(L),R={name:`book-open`,size:24,node:[[`path`,{d:`M12 5v16`,key:`1f6ucr`}],[`path`,{d:`M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z`,key:`1fyvmf`}]]};R.node;var z=y(R),B={name:`cloud`,size:24,node:[[`path`,{d:`M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z`,key:`p7xjir`}]]};B.node;var V=y(B),H={name:`fingerprint-pattern`,size:24,node:[[`path`,{d:`M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4`,key:`1nerag`}],[`path`,{d:`M14 13.12c0 2.38 0 6.38-1 8.88`,key:`o46ks0`}],[`path`,{d:`M17.29 21.02c.12-.6.43-2.3.5-3.02`,key:`ptglia`}],[`path`,{d:`M2 12a10 10 0 0 1 18-6`,key:`ydlgp0`}],[`path`,{d:`M2 16h.01`,key:`1gqxmh`}],[`path`,{d:`M21.8 16c.2-2 .131-5.354 0-6`,key:`drycrb`}],[`path`,{d:`M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2`,key:`1tidbn`}],[`path`,{d:`M8.65 22c.21-.66.45-1.32.57-2`,key:`13wd9y`}],[`path`,{d:`M9 6.8a6 6 0 0 1 9 5.2v2`,key:`1fr1j5`}]],aliases:[`fingerprint`]};H.node;var ve=y(H),ye={name:`hard-drive`,size:24,node:[[`path`,{d:`M10 16h.01`,key:`1bzywj`}],[`path`,{d:`M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`18tbho`}],[`path`,{d:`M21.946 12.013H2.054`,key:`zqlbp7`}],[`path`,{d:`M6 16h.01`,key:`1pmjb7`}]]};ye.node;var be=y(ye),xe={name:`inbox`,size:24,node:[[`polyline`,{points:`22 12 16 12 14 15 10 15 8 12 2 12`,key:`o97t9d`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`oot6mr`}]]};xe.node;var Se=y(xe),Ce={name:`laptop`,size:24,node:[[`path`,{d:`M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z`,key:`1pdavp`}],[`path`,{d:`M20.054 15.987H3.946`,key:`14rxg9`}]]};Ce.node;var U=y(Ce),we={name:`layout-grid`,size:24,node:[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]};we.node;var Te=y(we),Ee={name:`list`,size:24,node:[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]};Ee.node;var De=y(Ee),Oe={name:`log-out`,size:24,node:[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]};Oe.node;var ke=y(Oe),Ae={name:`message-circle-more`,size:24,node:[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}]]};Ae.node;var je=y(Ae),W={name:`message-circle`,size:24,node:[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}]]};W.node;var Me=y(W),Ne={name:`message-square-text`,size:24,node:[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M7 11h10`,key:`1twpyw`}],[`path`,{d:`M7 15h6`,key:`d9of3u`}],[`path`,{d:`M7 7h8`,key:`af5zfr`}]]};Ne.node;var Pe=y(Ne),Fe={name:`phone-call`,size:24,node:[[`path`,{d:`M13 2a9 9 0 0 1 9 9`,key:`1itnx2`}],[`path`,{d:`M13 6a5 5 0 0 1 5 5`,key:`11nki7`}],[`path`,{d:`M13.832 16.568a1 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 2A18 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 6.392 6.384`,key:`9njp5v`}]]};Fe.node;var Ie=y(Fe),Le={name:`radio`,size:24,node:[[`path`,{d:`M16.247 7.761a6 6 0 0 1 0 8.478`,key:`1fwjs5`}],[`path`,{d:`M19.075 4.933a10 10 0 0 1 0 14.134`,key:`ehdyv1`}],[`path`,{d:`M4.925 19.067a10 10 0 0 1 0-14.134`,key:`1q22gi`}],[`path`,{d:`M7.753 16.239a6 6 0 0 1 0-8.478`,key:`r2q7qm`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]};Le.node;var Re=y(Le),ze={name:`rows-3`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M21 9H3`,key:`1338ky`}],[`path`,{d:`M21 15H3`,key:`9uk58r`}]],aliases:[`panels-top-bottom`]};ze.node;var Be=y(ze),G=e(n(),1),Ve=e=>[`project-files`,e];function He(e){return a({queryKey:Ve(e),queryFn:()=>h.get(`/api/studio/projects/${e}/files`),refetchInterval:e=>e.state.data?.files.some(e=>e.status===`pending`)?2e3:!1})}function Ue(e,t){return m(`/api/studio/projects/${e}/files/${t}/content`)}function We(e,t=!1){let n=i(),[r,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)(null),c=()=>n.invalidateQueries({queryKey:Ve(e)}),l=async e=>{s(null);try{await e()}catch(e){s(e.message)}finally{await c()}};return{busy:r,error:o,readOnly:t,upload:async(t,n)=>{a(!0),await l(async()=>{for(let r of n)await h.upload(`/api/studio/projects/${e}/files?kind=${t}`,r),await c()}),a(!1)},describe:(t,n)=>l(()=>h.patch(`/api/studio/projects/${e}/files/${t}`,{description:n})),remove:t=>l(()=>h.del(`/api/studio/projects/${e}/files/${t}`)),reindex:t=>l(()=>h.post(`/api/studio/projects/${e}/files/${t}/reindex`)),order:(t,n)=>l(()=>h.put(`/api/studio/projects/${e}/files/order`,{kind:t,ids:n}))}}function Ge(e,t){let n=`wz.layout.${e}`,[r,i]=(0,G.useState)(()=>{try{let e=localStorage.getItem(n);return e===`list`||e===`cards`?e:t}catch{return t}});return[r,()=>i(e=>{let t=e===`list`?`cards`:`list`;try{localStorage.setItem(n,t)}catch{}return t})]}function Ke(e,t,n=700){let[r,i]=(0,G.useState)(`idle`),[a,o]=(0,G.useState)(null),s=JSON.stringify(e),c=(0,G.useRef)(s),l=(0,G.useRef)({value:e,json:s,save:t});l.current={value:e,json:s,save:t};let u=(0,G.useRef)(Promise.resolve()),d=(0,G.useCallback)(()=>{let e=l.current;e.json!==c.current&&(c.current=e.json,i(`saving`),u.current=u.current.then(async()=>{try{await e.save(e.value),o(null),i(`saved`)}catch(e){c.current=``,o(e.message),i(`error`)}}))},[]);return(0,G.useEffect)(()=>{if(s===c.current)return;let e=setTimeout(d,n);return()=>clearTimeout(e)},[s,n,d]),(0,G.useEffect)(()=>d,[d]),{state:r,error:a}}function qe(e){return e<1e6?`${Math.max(1,Math.round(e/1e3))} KB`:`${(e/1e6).toFixed(1)} MB`}var K=e(r(),1);function Je({id:e,children:t}){return(0,K.jsx)(`div`,{id:e,className:`scroll-mt-6 max-md:scroll-mt-20`,children:t})}function q({title:e,hint:t,save:n,action:r,locked:i,plain:a,children:o}){return(0,K.jsxs)(`section`,{className:`flex flex-col gap-2.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-4 px-1`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`h2`,{className:`font-display font-semibold text-lg leading-tight`,children:e}),n?.state===`saving`?(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[0.75rem] text-ink-3`,children:[(0,K.jsx)(T,{className:`size-3`}),` `,x(`project.saving`)]}):n?.state===`saved`?(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[0.75rem] text-moss`,children:[(0,K.jsx)(_,{className:`size-3.5`}),` `,x(`settings.saved`)]}):null]}),t?(0,K.jsx)(`p`,{className:`mt-1 text-[0.875rem] text-ink-3 leading-snug`,children:t}):null]}),r?(0,K.jsx)(`div`,{className:`shrink-0`,children:r}):null]}),a?o:(0,K.jsxs)(E,{className:`p-3.5 sm:p-5`,children:[i?(0,K.jsx)(`fieldset`,{disabled:!0,className:`min-w-0`,children:o}):o,n?.state===`error`&&n.error?(0,K.jsx)(`p`,{className:`mt-4 text-[0.875rem] text-rose`,children:n.error}):null]})]})}function Ye({children:e,layout:t,onToggle:n}){return(0,K.jsxs)(`div`,{className:`mb-3 flex items-start gap-2`,children:[(0,K.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,K.jsx)(`div`,{className:`w-56 max-w-full transition-[width] duration-200 focus-within:w-full has-[input:not(:placeholder-shown)]:w-full`,children:e})}),(0,K.jsx)(O,{label:x(t===`list`?`project.viewCards`:`project.viewList`),onClick:n,children:t===`list`?(0,K.jsx)(Te,{className:`size-4`}):(0,K.jsx)(De,{className:`size-4`})})]})}function Xe({value:e,onChange:t,onEnter:n,placeholder:r,busy:i}){return(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(c,{className:`-translate-y-1/2 pointer-events-none absolute top-1/2 left-3 size-4 text-ink-4`}),(0,K.jsx)(`input`,{type:`search`,value:e,placeholder:r,onChange:e=>t(e.target.value),onKeyDown:e=>e.key===`Enter`&&n?.(),className:`h-9 w-full rounded-lg border border-input bg-card pr-3 pl-9 text-[0.875rem] text-ink outline-none transition placeholder:text-ink-4 focus:border-focus focus:ring-4 focus:ring-focus-glow`}),i?(0,K.jsx)(T,{className:`-translate-y-1/2 absolute top-1/2 right-3 size-4 text-ink-3`}):null]})}function Ze({onFiles:e,accept:t,multiple:n=!0,className:r,children:i}){return(0,K.jsxs)(`label`,{onDragOver:e=>{e.preventDefault(),e.currentTarget.dataset.over=`1`},onDragLeave:e=>{delete e.currentTarget.dataset.over},onDrop:t=>{t.preventDefault(),delete t.currentTarget.dataset.over;let r=Array.from(t.dataTransfer.files);r.length&&e(n?r:r.slice(0,1))},className:C(`flex cursor-pointer items-center justify-center gap-2 rounded-lg border border-input border-dashed text-[0.875rem] text-ink-3 transition focus-within:border-focus focus-within:ring-4 focus-within:ring-focus-glow hover:border-ink-4 hover:text-ink data-[over]:border-focus data-[over]:bg-paper-2 data-[over]:text-ink`,r),children:[i,(0,K.jsx)(`input`,{className:`sr-only`,type:`file`,accept:t,multiple:n,onChange:t=>{let n=Array.from(t.target.files??[]);t.target.value=``,n.length&&e(n)}})]})}function J(e){try{return new URL(e).host}catch{return e}}var Y=e=>`${window.location.origin}${g}/w/${e.shareToken}`;function X(e,t,n){if(!e.published)return{kind:`draft`};if(t.mode===`managed`)return{kind:`live`,url:Y(e),runs:e.publishedVersion??0,notes:0,cloud:!1};if(!t.account||n===null)return{kind:`here`};if(n===void 0)return{kind:`unknown`};let{copy:r,error:i}=n,a=r?.publishedVersion??null,o=r&&a!==null?r.shareUrl:null;return i?.again?{kind:`sending`,url:o,runs:a,again:i.again}:i?{kind:`missing`,url:o,runs:a,why:i.message}:!r||r.version<(e.publishedVersion??0)?{kind:`missing`,url:o,runs:a,why:x(`cloud.notSent`)}:!r.runnable||!o||a===null?{kind:`missing`,url:o,runs:a,why:`${x(`cloud.notRunnable`,{v:r.version})} ${a===null?x(`cloud.nothingRuns`):x(`cloud.keepsRunning`,{v:a})}`}:{kind:`live`,url:o,runs:a,notes:r.problems.filter(e=>!e.blocking).length,cloud:!0}}function Qe(e){return e.kind===`live`||e.kind===`sending`||e.kind===`missing`?e.url:null}function $e({where:e,me:t,version:n}){let r=J(t.account?.cloudUrl??``),i=`size-3.5`;switch(e.kind){case`draft`:return null;case`unknown`:return(0,K.jsx)(k,{tone:`live`,children:x(`home.live`)});case`here`:return(0,K.jsx)(k,{icon:(0,K.jsx)(U,{className:i}),title:x(`where.hereHint`),children:n?x(`where.hereVersion`,{v:n}):x(`where.here`)});case`live`:{let t=n?x(`editor.published`,{v:e.runs}):x(`home.live`),a=e.notes===1?x(`where.note`):e.notes>1?x(`where.notes`,{n:e.notes}):null;return(0,K.jsx)(k,{tone:`live`,icon:e.cloud?(0,K.jsx)(V,{className:i}):void 0,title:e.cloud?x(`where.liveHint`,{host:r}):void 0,children:a?`${t} · ${a}`:t})}case`sending`:return(0,K.jsx)(k,{tone:`warn`,icon:(0,K.jsx)(S,{className:i}),title:x(`cloud.again`,{when:new Intl.DateTimeFormat(b,{timeStyle:`short`}).format(new Date(e.again))}),children:x(`where.sending`)});case`missing`:return(0,K.jsx)(k,{tone:`warn`,icon:(0,K.jsx)(f,{className:i}),title:e.why,children:e.runs===null?x(`where.missing`):x(`editor.published`,{v:e.runs})})}}var et=`mt-1.5 text-[0.8125rem] text-ink-3`;function Z(e){let t=i(),[n,r]=(0,G.useState)(!1),a=p({mutationFn:e=>h.post(`/api/studio/account/link`,e),onSuccess:({url:e})=>{I(e),r(!0)}});return(0,G.useEffect)(()=>{if(!n)return;let e=setInterval(()=>void t.invalidateQueries({queryKey:[`me`]}),2e3),i=setTimeout(()=>r(!1),3e5);return()=>{clearInterval(e),clearTimeout(i)}},[n,t]),(0,G.useEffect)(()=>{e&&r(!1)},[e]),{link:a,waiting:n}}function Q({link:e,waiting:t}){return e.isError?(0,K.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:x(`local.accountFailed`)}):t?(0,K.jsxs)(`p`,{className:`flex items-center gap-2 text-[0.8125rem] text-ink-3`,children:[(0,K.jsx)(T,{className:`size-3.5`}),` `,x(`local.accountWaiting`)]}):null}function tt(){let e=Z(!1),{link:t}=e,[n,r]=(0,G.useState)(``);return(0,K.jsxs)(`div`,{className:`flex flex-col divide-y divide-border-soft`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-4 py-5 first:pt-0 last:pb-0`,children:[(0,K.jsx)(`div`,{className:`flex size-11 shrink-0 items-center justify-center rounded-full bg-paper-2 text-ink-2`,children:(0,K.jsx)(be,{className:`size-5`})}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`div`,{className:`font-medium text-[0.9375rem]`,children:x(`account.local`)}),(0,K.jsx)(`p`,{className:`mt-1 text-[0.875rem] text-ink-3 leading-relaxed`,children:x(`account.localText`)})]})]}),F.account?(0,K.jsxs)(`div`,{className:`flex flex-col gap-4 py-5 last:pb-0`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`font-medium text-[0.9375rem]`,children:x(`account.with`)}),(0,K.jsxs)(`ul`,{className:`mt-2 flex flex-col gap-2 text-[0.875rem] text-ink-2 leading-snug`,children:[(0,K.jsxs)(`li`,{className:`flex items-start gap-2.5`,children:[(0,K.jsx)(o,{className:`mt-0.5 size-4 shrink-0 text-amber`}),x(`account.withCredits`)]}),(0,K.jsxs)(`li`,{className:`flex items-start gap-2.5`,children:[(0,K.jsx)(V,{className:`mt-0.5 size-4 shrink-0 text-cobalt`}),x(`account.withCloud`)]})]})]}),(0,K.jsx)(`div`,{children:(0,K.jsx)(j,{busy:t.isPending&&!t.variables?.signup,onClick:()=>t.mutate({}),children:x(`account.signIn`)})})]}):null,F.account?(0,K.jsxs)(`form`,{className:`flex flex-col gap-3 py-5 last:pb-0`,onSubmit:e=>{e.preventDefault(),t.mutate({signup:!0,code:n.trim()||void 0})},children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`font-medium text-[0.9375rem]`,children:x(`account.new`)}),(0,K.jsx)(`p`,{className:`mt-1 text-[0.875rem] text-ink-3 leading-relaxed`,children:x(`account.newHint`)})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(A,{value:n,maxLength:64,autoComplete:`off`,spellCheck:!1,placeholder:x(`account.code`),"aria-label":x(`account.code`),onChange:e=>r(e.target.value),className:`w-56 font-mono text-[0.875rem]`}),(0,K.jsx)(j,{type:`submit`,variant:`secondary`,className:`h-11`,busy:t.isPending&&!!t.variables?.signup,children:x(`account.create`)})]}),(0,K.jsx)(Q,{...e})]}):null]})}var nt={start:`account.kind.start`,monthly:`account.kind.monthly`,gift:`account.kind.gift`};function rt({account:e}){let t=i(),n=Z(e.signedIn),r=p({mutationFn:()=>h.del(`/api/studio/account`),onSuccess:()=>t.invalidateQueries({queryKey:[`me`]})}),a=new Intl.DateTimeFormat(b,{dateStyle:`medium`});return(0,K.jsxs)(`div`,{className:`flex flex-col divide-y divide-border-soft`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-3 py-5 first:pt-0`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`truncate font-medium text-[0.9375rem]`,children:e.name||e.email}),e.signedIn?(0,K.jsx)(k,{tone:`live`,children:x(`account.linked`)}):null]}),(0,K.jsx)(`div`,{className:`truncate text-[0.875rem] text-ink-3`,children:e.email})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsxs)(j,{variant:`secondary`,onClick:()=>I(e.url),children:[x(`setup.openAccount`),` `,(0,K.jsx)(N,{className:`size-4`})]}),(0,K.jsxs)(j,{variant:`ghost`,busy:r.isPending,onClick:()=>r.mutate(),children:[(0,K.jsx)(ke,{className:`size-4`}),` `,x(`nav.logout`)]})]})]}),e.signedIn?null:(0,K.jsxs)(`div`,{className:`flex flex-col gap-3 py-5`,children:[(0,K.jsx)(`p`,{className:`text-[0.875rem] text-ink-2`,children:x(`local.accountExpired`)}),(0,K.jsx)(`div`,{children:(0,K.jsx)(j,{busy:n.link.isPending,onClick:()=>n.link.mutate({}),children:x(`account.signInAgain`)})}),(0,K.jsx)(Q,{...n})]}),e.credits===null?null:(0,K.jsxs)(`div`,{className:`py-5`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-3`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`div`,{className:`text-[0.8125rem] text-ink-3`,children:x(`account.credits`)}),(0,K.jsx)(`div`,{className:`font-display font-semibold text-[1.375rem] tabular-nums leading-tight`,children:x(`nav.credits`,{n:Math.floor(e.credits).toLocaleString()})})]}),(0,K.jsxs)(j,{variant:`secondary`,onClick:()=>I(`${e.url}/billing`),children:[x(`account.topUp`),` `,(0,K.jsx)(N,{className:`size-4`})]})]}),e.expiring.length?(0,K.jsx)(`ul`,{className:`mt-3 flex flex-col gap-1 text-[0.8125rem] text-ink-3 tabular-nums`,children:e.expiring.map(e=>(0,K.jsxs)(`li`,{children:[x(`account.expires`,{n:Math.floor(e.credits).toLocaleString(),date:a.format(new Date(e.expiresAt))}),nt[e.kind]?(0,K.jsxs)(`span`,{className:`text-ink-4`,children:[` · `,x(nt[e.kind])]}):null]},`${e.kind}:${e.expiresAt}`))}):null]}),(0,K.jsxs)(`div`,{className:`flex items-start gap-2.5 py-5 text-[0.875rem] text-ink-2 leading-snug last:pb-0`,children:[(0,K.jsx)(V,{className:`mt-0.5 size-4 shrink-0 text-cobalt`}),(0,K.jsx)(`p`,{children:x(`account.cloud`,{host:J(e.cloudUrl)})})]})]})}function it({me:e,fromAccount:t}){let n=i(),[r,a]=(0,G.useState)(e.profile),o=e=>a(t=>({...t,...e})),s=Ke(r,async e=>{await h.put(`/api/studio/profile`,e),await n.invalidateQueries({queryKey:[`me`]})});return(0,K.jsx)(q,{title:x(`account.profile`),hint:x(`account.hint`),save:s,children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-6 sm:flex-row sm:gap-8`,children:[(0,K.jsxs)(`div`,{className:`flex shrink-0 flex-col items-center gap-2 sm:w-32`,children:[(0,K.jsx)(`div`,{className:`flex size-20 items-center justify-center overflow-hidden rounded-full bg-ember-tint font-semibold text-[1.75rem] text-ember-strong ring-1 ring-border-soft`,children:e.user.image?(0,K.jsx)(`img`,{src:e.user.image,alt:``,className:`size-full object-cover`}):pe(r.name)||`?`}),(0,K.jsx)(`p`,{className:`text-center text-[0.75rem] text-ink-3 leading-snug`,children:x(`account.initials`)})]}),(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-5`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(w,{children:x(`account.name`)}),(0,K.jsx)(A,{value:r.name,maxLength:80,disabled:t,onChange:e=>o({name:e.target.value})}),(0,K.jsx)(`p`,{className:et,children:x(t?`account.fromAccount`:`account.nameHint`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(w,{children:x(`account.about`)}),(0,K.jsx)(ae,{minRows:3,maxLength:2e3,value:r.about,onChange:e=>o({about:e.target.value})}),(0,K.jsx)(`p`,{className:et,children:x(`account.aboutHint`)})]}),(0,K.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(w,{children:x(`account.email`)}),(0,K.jsx)(A,{type:`email`,value:r.email,maxLength:200,disabled:t,onChange:e=>o({email:e.target.value})})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(w,{children:x(`account.phone`)}),(0,K.jsx)(A,{type:`tel`,value:r.phone,maxLength:40,onChange:e=>o({phone:e.target.value})})]})]})]})]})})}function at({me:e}){let t=e.mode===`managed`,n=t||!!e.account;return(0,K.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[(0,K.jsx)(q,{title:x(`account.connection`),hint:x(`account.connectionHint`),children:t?(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`truncate font-medium text-[0.9375rem]`,children:e.user.name}),(0,K.jsx)(k,{tone:`live`,children:x(`account.linked`)})]}),(0,K.jsx)(`div`,{className:`truncate text-[0.875rem] text-ink-3`,children:e.user.email})]}),e.manageUrl?(0,K.jsxs)(j,{variant:`secondary`,onClick:()=>I(`${e.manageUrl}/account`),children:[x(`setup.openAccount`),` `,(0,K.jsx)(N,{className:`size-4`})]}):null]}):e.account?(0,K.jsx)(rt,{account:e.account}):(0,K.jsx)(tt,{})}),(0,K.jsx)(it,{me:e,fromAccount:n},n?`account`:`own`),(0,K.jsx)(q,{title:x(`account.look`),hint:x(`account.lookHint`),children:(0,K.jsxs)(`div`,{className:`flex flex-col divide-y divide-border-soft`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-4 pb-4`,children:[(0,K.jsx)(`span`,{className:`font-medium text-[0.875rem]`,children:x(`nav.language`)}),(0,K.jsx)(he,{tone:`surface`})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-4 pt-4`,children:[(0,K.jsx)(`span`,{className:`font-medium text-[0.875rem]`,children:x(`nav.theme`)}),(0,K.jsx)(ge,{})]})]})})]})}var ot={steps:Be,chat:Me,talk:ee,whatsapp:je,sms:Pe,call:Ie,video:le},st=e=>ot[e]??d,ct=[`steps`,`chat`];function lt(){return a({queryKey:[`runners`],queryFn:()=>h.get(`/api/studio/runners`),staleTime:6e4})}function ut(e,t){let n=new Set(t.map(e=>e.id)),r=(e.runners?.enabled??ct).filter(e=>n.has(e)),i=e.runners?.default??`steps`;return[...r].sort((e,t)=>e===i?-1:+(t===i))}function dt({w:e,runners:t}){let n=ut(e,t),r=e.runners?.default??`steps`;return(0,K.jsx)(`span`,{className:`inline-flex items-center gap-1.5`,children:n.map(e=>{let n=st(e),i=t.find(t=>t.id===e)?.label[b]??e;return(0,K.jsx)(n,{"aria-label":i,className:C(`size-3.5`,e===r?`text-ink-2`:`text-ink-4`),children:(0,K.jsx)(`title`,{children:i})},e)})})}var ft=t({HomePage:()=>Ot,NewSpaceDialog:()=>$,ProjectSwitcher:()=>mt}),pt=[{icon:s,name:()=>x(`nav.wizards`),what:`space.holds.wizards`},{icon:ve,name:()=>x(`space.info`),what:`space.holds.info`},{icon:z,name:()=>`${x(`space.knowledge`)} & ${x(`space.data`)}`,what:`space.holds.knowledge`},{icon:l,name:()=>x(`connectors.title`),what:`space.holds.connectors`},{icon:Se,name:()=>x(`space.results`),what:`space.holds.results`}];function $({open:e,onClose:t}){let{select:n}=P(),r=i(),[a,o]=(0,G.useState)(``),s=p({mutationFn:()=>h.post(`/api/studio/projects`,{name:a}),onSuccess:async({id:e})=>{await r.invalidateQueries({queryKey:[`projects`]}),n(e),o(``),t()}});return(0,K.jsxs)(oe,{open:e,onClose:t,title:x(`home.newProject`),children:[(0,K.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-2`,children:x(`space.holds.intro`)}),(0,K.jsx)(`dl`,{className:`mt-4 flex flex-col gap-2.5 text-[0.8125rem]`,children:pt.map(e=>(0,K.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,K.jsx)(e.icon,{className:`mt-0.5 size-4 shrink-0 text-ink-3`}),(0,K.jsx)(`dt`,{className:`w-28 shrink-0 font-medium text-ink`,children:e.name()}),(0,K.jsx)(`dd`,{className:`min-w-0 text-ink-3`,children:x(e.what)})]},e.what))}),(0,K.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-ink-4`,children:x(`space.holds.shared`)}),(0,K.jsxs)(`form`,{className:`mt-5`,onSubmit:e=>{e.preventDefault(),a.trim()&&s.mutate()},children:[(0,K.jsx)(A,{autoFocus:!0,placeholder:x(`home.projectName`),value:a,onChange:e=>o(e.target.value)}),(0,K.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,K.jsx)(j,{variant:`ghost`,onClick:t,children:x(`common.cancel`)}),(0,K.jsx)(j,{type:`submit`,busy:s.isPending,disabled:!a.trim(),children:x(`home.newProject`)})]})]})]})}function mt(){let{project:e,projects:t,select:n}=P(),r=fe().data?.limits.projects??1,i=de(),[a,o]=(0,G.useState)(!1);return!e||r!==null&&r<=1?null:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(ie,{className:`w-56`,value:e.id,onChange:e=>e===`__new`?o(!0):n(e),options:[...t.map(e=>({value:e.id,label:e.name})),...i?[r===null||t.length<r?{value:`__new`,label:`+ ${x(`home.newProject`)}`}:{value:`__new`,label:x(`home.projectLimit`,{n:r}),disabled:!0}]:[]]}),(0,K.jsx)($,{open:a,onClose:()=>o(!1)})]})}function ht({url:e}){let[t,n]=(0,G.useState)(!1);return(0,K.jsxs)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)},className:`inline-flex h-8 items-center gap-1.5 rounded-full px-3 text-[0.8125rem] text-ink-3 hover:bg-accent hover:text-ink`,children:[t?(0,K.jsx)(_,{className:`size-3.5`}):(0,K.jsx)(M,{className:`size-3.5`}),x(t?`share.copied`:`share.link`)]})}function gt(){let e=D(),t=Z(!1),[n,r]=(0,G.useState)(!1),i=(0,G.useRef)(null);return(0,G.useEffect)(()=>{if(!n)return;let e=e=>{i.current?.contains(e.target)||r(!1)},t=e=>{e.key===`Escape`&&r(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[n]),(0,K.jsxs)(`div`,{className:`relative`,ref:i,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`button`,{type:`button`,"aria-expanded":n,onClick:()=>r(e=>!e),className:`inline-flex h-8 items-center gap-1.5 rounded-full px-3 text-[0.8125rem] text-ink-3 hover:bg-accent hover:text-ink`,children:[(0,K.jsx)(M,{className:`size-3.5`}),` `,x(`share.link`)]}),n?(0,K.jsxs)(`div`,{className:`absolute right-0 bottom-10 z-20 flex w-72 animate-rise flex-col gap-3 rounded-xl bg-card p-3.5 shadow-overlay ring-1 ring-border-soft`,children:[(0,K.jsx)(`p`,{className:`text-[0.8125rem] text-ink-2 leading-relaxed`,children:x(`teaser.link`)}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(j,{size:`sm`,busy:t.link.isPending,onClick:()=>t.link.mutate({}),children:x(`account.signIn`)}),(0,K.jsx)(j,{size:`sm`,variant:`secondary`,onClick:()=>e(`/settings/account`),children:x(`account.create`)})]}),(0,K.jsx)(Q,{...t})]}):null]})}function _t({w:e,me:t,runners:n}){let r=D(),i=X(e,t,e.cloud),a=Qe(i),o=a??(e.published?Y(e):null);return(0,K.jsxs)(`div`,{className:`relative pt-6`,children:[(0,K.jsx)(`div`,{className:`pointer-events-none absolute top-0 left-4 z-10`,children:(0,K.jsx)(ue,{kind:e.avatar,size:52})}),(0,K.jsxs)(E,{className:`relative flex h-full cursor-pointer flex-col px-5 pt-10 pb-3 transition hover:shadow-elevated`,onClick:()=>r(`/edit/${e.id}`),children:[(0,K.jsx)(`div`,{className:`absolute top-3 right-3`,children:e.published?(0,K.jsx)($e,{where:i,me:t}):(0,K.jsx)(k,{children:x(`home.draft`)})}),(0,K.jsx)(`h3`,{className:`font-display font-semibold text-[1.0625rem] leading-snug`,children:e.title}),(0,K.jsx)(`p`,{className:`mt-1 line-clamp-2 text-[0.875rem] text-ink-3`,children:e.description}),(0,K.jsxs)(`div`,{className:`mt-auto flex min-h-8 items-center justify-between pt-3`,children:[(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-2.5 text-[0.75rem] text-ink-4`,children:[x(`home.steps`,{n:e.stepCount}),(0,K.jsx)(dt,{w:e,runners:n})]}),(0,K.jsxs)(`div`,{className:`flex items-center`,children:[a?(0,K.jsx)(ht,{url:a}):i.kind===`here`&&F.account?(0,K.jsx)(gt,{}):null,o?(0,K.jsx)(O,{label:x(a?`share.open`:`share.openHere`),className:`ml-1 size-8`,onClick:e=>{e.stopPropagation(),I(o)},children:(0,K.jsx)(_e,{className:`size-4`})}):null]})]})]})]})}var vt=[`draft`,`here`,`live`,`missing`],yt={draft:se,here:U,live:Re,missing:f},bt=e=>x(e===`draft`?`home.draft`:e===`here`?`where.here`:e===`live`?`home.live`:`where.missing`);function xt(e,t){let{kind:n}=X(e,t,e.cloud);return n===`draft`||n===`here`?n:n===`live`||n===`unknown`?`live`:`missing`}function St({wizards:e,me:t,value:n,onChange:r}){let i=new Map;for(let n of e){let e=xt(n,t);i.set(e,(i.get(e)??0)+1)}if(i.size<2)return null;let a=e=>C(`inline-flex h-8 items-center gap-1.5 rounded-full px-3 font-medium text-[0.8125rem] transition`,e?`bg-paper-2 text-ink`:`text-ink-3 hover:text-ink`);return(0,K.jsxs)(`div`,{className:`mt-5 flex flex-wrap items-center gap-1`,children:[(0,K.jsxs)(`button`,{type:`button`,className:a(n===null),onClick:()=>r(null),children:[x(`home.all`),(0,K.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:e.length})]}),vt.filter(e=>i.has(e)).map(e=>{let t=yt[e];return(0,K.jsxs)(`button`,{type:`button`,"aria-pressed":n===e,className:a(n===e),onClick:()=>r(n===e?null:e),children:[(0,K.jsx)(t,{className:`size-3.5`}),bt(e),(0,K.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:i.get(e)})]},e)})]})}var Ct=12,wt=3;function Tt({value:e,onChange:t}){return(0,K.jsxs)(`label`,{className:`relative flex h-10 w-full max-w-md items-center gap-2.5 rounded-full bg-card px-4 shadow-soft ring-1 ring-border-soft transition focus-within:ring-2 focus-within:ring-focus sm:h-11`,children:[(0,K.jsx)(c,{className:`size-4 shrink-0 text-ink-3`}),(0,K.jsx)(`input`,{type:`search`,value:e,onChange:e=>t(e.target.value),placeholder:x(`home.search`),"aria-label":x(`home.search`),className:`min-w-0 flex-1 bg-transparent text-[0.9375rem] outline-none placeholder:text-ink-4 [&::-webkit-search-cancel-button]:hidden`}),e?(0,K.jsx)(`button`,{type:`button`,"aria-label":x(`market.reset`),onClick:()=>t(``),className:`-mr-1.5 flex size-7 shrink-0 items-center justify-center rounded-full text-ink-3 hover:bg-paper-2 hover:text-ink`,children:(0,K.jsx)(v,{className:`size-4`})}):null]})}var Et=`curl -fsSL https://engenty.ai/install.sh | bash`;function Dt(){let[e,t]=(0,G.useState)(!1),n=[x(`home.local.install`),x(`home.local.signIn`),x(`home.local.publish`)];return(0,K.jsxs)(`div`,{className:`mx-auto flex max-w-xl animate-rise flex-col items-center pt-4 text-center`,children:[(0,K.jsx)(ue,{kind:`round`,size:120}),(0,K.jsx)(`h1`,{className:`mt-2 font-display font-semibold text-[1.75rem] leading-tight tracking-tight`,children:x(`home.local.title`)}),(0,K.jsx)(`p`,{className:`mt-3 text-[0.9375rem] text-ink-2 leading-relaxed`,children:x(`home.local.text`)}),(0,K.jsx)(`ol`,{className:`mt-8 flex w-full flex-col gap-4 text-left`,children:n.map((n,r)=>(0,K.jsxs)(`li`,{className:`flex gap-3`,children:[(0,K.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-full bg-paper-2 font-medium text-[0.8125rem] text-ink-2`,children:r+1}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1 pt-0.5`,children:[(0,K.jsx)(`p`,{className:`text-[0.9375rem] leading-snug`,children:n}),r===0?(0,K.jsxs)(`div`,{className:`mt-2 flex items-center gap-2 rounded-lg bg-paper-2 py-1.5 pr-1.5 pl-3`,children:[(0,K.jsx)(`code`,{className:`min-w-0 flex-1 select-all overflow-x-auto whitespace-nowrap font-mono text-[0.8125rem] text-ink-2`,children:Et}),(0,K.jsxs)(j,{variant:`secondary`,size:`sm`,onClick:()=>{navigator.clipboard.writeText(Et),t(!0),setTimeout(()=>t(!1),1500)},children:[e?(0,K.jsx)(_,{className:`size-3.5`}):(0,K.jsx)(M,{className:`size-3.5`}),x(e?`share.copied`:`share.copy`)]})]}):null]})]},n))})]})}function Ot(){let e=D(),t=i(),{project:n,projects:r,loading:o}=P(),s=fe().data,c=me(),l=de(),d=a({queryKey:[`wizards`,n?.id,!!s?.account],queryFn:()=>h.get(`/api/studio/projects/${n.id}/wizards`),enabled:!!n}),f=lt().data??[],[m,ee]=(0,G.useState)(null),[g,_]=(0,G.useState)(``),v=(d.data?.length??0)>Ct,y=v?g.trim().toLowerCase():``,S=(d.data??[]).filter(e=>(!m||!s||xt(e,s)===m)&&(!y||`${e.title} ${e.description}`.toLowerCase().includes(y))),C=!!y&&S.length<wt,w=p({mutationFn:e=>h.post(`/api/studio/wizards`,{projectId:n.id,starterId:e,lang:b}),onSuccess:async({id:n})=>{await t.invalidateQueries({queryKey:[`projects`]}),await t.invalidateQueries({queryKey:[`wizards`]}),e(`/edit/${n}`)}}),ie=r.reduce((e,t)=>e+t.wizardCount,0),T=l&&!n?.readOnly;return!o&&T&&r.length&&ie===0?(0,K.jsx)(te,{to:`/new`,replace:!0}):!o&&!c&&r.length===0?(0,K.jsx)(Dt,{}):(0,K.jsxs)(`div`,{className:`animate-rise`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-4`,children:[v?(0,K.jsx)(Tt,{value:g,onChange:_}):(0,K.jsx)(`h1`,{className:`font-display font-semibold text-[1.75rem] tracking-tight`,children:x(`home.title`)}),T?(0,K.jsxs)(j,{onClick:()=>e(`/new`),children:[(0,K.jsx)(ne,{className:`size-4`}),` `,x(`home.new`)]}):null]}),n?.origin===`local`?(0,K.jsxs)(`p`,{className:`mt-2 text-[0.875rem] text-ink-3`,children:[x(`home.fromLocal`),` `,n.syncedAt?x(`home.syncedAt`,{when:new Intl.DateTimeFormat(b,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(n.syncedAt))}):null]}):null,d.data&&d.data.length===0?(0,K.jsxs)(re,{children:[(0,K.jsx)(`p`,{children:x(`home.empty`)}),T?(0,K.jsxs)(j,{className:`mt-5`,onClick:()=>e(`/new`),children:[(0,K.jsx)(ne,{className:`size-4`}),` `,x(`home.new`)]}):null]}):null,d.data?.length&&s?(0,K.jsx)(St,{wizards:d.data,me:s,value:m,onChange:ee}):null,y&&S.length===0?(0,K.jsx)(`p`,{className:`mt-6 text-[0.875rem] text-ink-3`,children:x(`home.noMatch`)}):null,(0,K.jsx)(`div`,{className:`mt-6 grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:s?S.map(e=>(0,K.jsx)(_t,{w:e,me:s,runners:f},e.id)):null}),C?(0,K.jsxs)(K.Fragment,{children:[T?(0,K.jsx)(u,{query:g,busy:w.isPending,onUse:e=>n&&!w.isPending&&w.mutate(e.id)}):(0,K.jsx)(u,{query:g}),T?(0,K.jsx)(`div`,{className:`mt-8 flex justify-center`,children:(0,K.jsxs)(j,{variant:`secondary`,onClick:()=>e(`/new?wish=${encodeURIComponent(g.trim())}`),children:[(0,K.jsx)(ce,{className:`size-4`}),` `,x(`home.newFromSearch`,{q:g.trim()})]})}):null]}):null]})}export{z as A,Me as C,Se as D,U as E,ve as O,He as S,Te as T,qe as _,Q as a,We as b,J as c,X as d,Je as f,q as g,Xe as h,at as i,V as k,Y as l,Ye as m,$ as n,Z as o,Ze as p,mt as r,$e as s,ft as t,Qe as u,Ue as v,ke as w,Ge as x,Ke as y};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FlowPreview-ChXfiMn_.js","assets/jsx-runtime-D3jfb0Ew.js","assets/ui-D92EkdEB.js","assets/preload-helper-CNEI7N0N.js","assets/esm-rJY59Ixx.js","assets/react-dom-DenslgJm.js"])))=>i.map(i=>d[i]);
2
+ import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{O as r,a as i,c as a,i as o,r as s,s as c,v as l}from"./logo-C80CWCDM.js";import{t as u}from"./useMutation-DKcIz55V.js";import{t as d}from"./preload-helper-CNEI7N0N.js";import{B as f,C as p,G as m,I as h,J as g,M as _,P as v,V as y,W as b,_ as x,f as S,i as ee,n as C,nt as te,r as w,t as T}from"./ui-D92EkdEB.js";import{a as E,i as D,n as O,r as k,t as A}from"./volume-2-0SfkvOho.js";import{O as j,P as ne}from"./definition-CQGiBQ4X.js";import{l as re,u as ie}from"./engenty-Cm8yZLON.js";var ae=class extends i{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type=`infinite`,super.setOptions(e)}getOptimisticResult(e){return e._type=`infinite`,super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:o,isError:s,isRefetchError:l}=r,u=n.fetchMeta?.fetchMore?.direction,d=s&&u===`forward`,f=i&&u===`forward`,p=s&&u===`backward`,m=i&&u===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:c(t,n.data),hasPreviousPage:a(t,n.data),isFetchNextPageError:d,isFetchingNextPage:f,isFetchPreviousPageError:p,isFetchingPreviousPage:m,isRefetchError:l&&!d&&!p,isRefetching:o&&!f&&!m}}};function oe(e,t){return o(e,ae,t)}var se={name:`app-window`,size:24,node:[[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}],[`path`,{d:`M10 4v4`,key:`pp8u80`}],[`path`,{d:`M2 8h20`,key:`d11cs7`}],[`path`,{d:`M6 4v4`,key:`1svtjw`}]]};se.node;var M=g(se),ce={name:`audio-lines`,size:24,node:[[`path`,{d:`M2 10v3`,key:`1fnikh`}],[`path`,{d:`M6 6v11`,key:`11sgs0`}],[`path`,{d:`M10 3v18`,key:`yhl04a`}],[`path`,{d:`M14 8v7`,key:`3a1oy3`}],[`path`,{d:`M18 5v13`,key:`123xd1`}],[`path`,{d:`M22 10v3`,key:`154ddg`}]]};ce.node;var le=g(ce),ue={name:`bot`,size:24,node:[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]};ue.node;var N=g(ue),de={name:`chart-column`,size:24,node:[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]],aliases:[`bar-chart-3`]};de.node;var fe=g(de),pe={name:`circle-dollar-sign`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8`,key:`1h4pet`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}]]};pe.node;var me=g(pe),he={name:`circle-euro`,size:24,node:[[`path`,{d:`M15 9.4a4 4 0 1 0 0 5.2`,key:`1makmb`}],[`path`,{d:`M7 12h5`,key:`gblrwe`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]};he.node;var ge=g(he),_e={name:`clapperboard`,size:24,node:[[`path`,{d:`m12.296 3.464 3.02 3.956`,key:`qash78`}],[`path`,{d:`M20.2 6 3 11l-.9-2.4c-.3-1.1.3-2.2 1.3-2.5l13.5-4c1.1-.3 2.2.3 2.5 1.3z`,key:`1h7j8b`}],[`path`,{d:`M3 11h18v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`4lm6w1`}],[`path`,{d:`m6.18 5.276 3.1 3.899`,key:`zjj9t3`}]]};_e.node;var P=g(_e),ve={name:`cloud-off`,size:24,node:[[`path`,{d:`M10.94 5.274A7 7 0 0 1 15.71 10h1.79a4.5 4.5 0 0 1 4.222 6.057`,key:`1uxyv8`}],[`path`,{d:`M18.796 18.81A4.5 4.5 0 0 1 17.5 19H9A7 7 0 0 1 5.79 5.78`,key:`99tcn7`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};ve.node;var F=g(ve),ye={name:`coins`,size:24,node:[[`path`,{d:`M13.744 17.736a6 6 0 1 1-7.48-7.48`,key:`bq4yh3`}],[`path`,{d:`M15 6h1v4`,key:`11y1tn`}],[`path`,{d:`m6.134 14.768.866-.5 2 3.464`,key:`17snzx`}],[`circle`,{cx:`16`,cy:`8`,r:`6`,key:`14bfc9`}]]};ye.node;var be=g(ye),xe={name:`eye`,size:24,node:[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]};xe.node;var I=g(xe),Se={name:`flag`,size:24,node:[[`path`,{d:`M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528`,key:`1jaruq`}]]};Se.node;var Ce=g(Se),we={name:`globe`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]};we.node;var Te=g(we),Ee={name:`image`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]};Ee.node;var L=g(Ee),De={name:`layout-dashboard`,size:24,node:[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`,key:`10lvy0`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`,key:`16une8`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`,key:`1hutg5`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`ldoo1y`}]]};De.node;var Oe=g(De),ke={name:`layout-template`,size:24,node:[[`rect`,{width:`18`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`f1a2em`}],[`rect`,{width:`9`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`jqznyg`}],[`rect`,{width:`5`,height:`7`,x:`16`,y:`14`,rx:`1`,key:`q5h2i8`}]]};ke.node;var Ae=g(ke),je={name:`list-checks`,size:24,node:[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]};je.node;var R=g(je),Me={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`}]]};Me.node;var Ne=g(Me),Pe={name:`puzzle`,size:24,node:[[`path`,{d:`M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z`,key:`w46dr5`}]]};Pe.node;var Fe=g(Pe),Ie={name:`scan-text`,size:24,node:[[`path`,{d:`M3 7V5a2 2 0 0 1 2-2h2`,key:`aa7l1z`}],[`path`,{d:`M17 3h2a2 2 0 0 1 2 2v2`,key:`4qcy5o`}],[`path`,{d:`M21 17v2a2 2 0 0 1-2 2h-2`,key:`6vwrx8`}],[`path`,{d:`M7 21H5a2 2 0 0 1-2-2v-2`,key:`ioqczr`}],[`path`,{d:`M7 8h8`,key:`1jbsf9`}],[`path`,{d:`M7 12h10`,key:`b7w52i`}],[`path`,{d:`M7 16h6`,key:`1vyc9m`}]]};Ie.node;var Le=g(Ie),Re={name:`search`,size:24,node:[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]};Re.node;var z=g(Re),ze={name:`star`,size:24,node:[[`path`,{d:`M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z`,key:`r04s7s`}]]};ze.node;var B=g(ze),Be={name:`table-2`,size:24,node:[[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]]};Be.node;var Ve=g(Be),He={name:`terminal`,size:24,node:[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]};He.node;var Ue=g(He),We={name:`type`,size:24,node:[[`path`,{d:`M12 4v16`,key:`1654pz`}],[`path`,{d:`M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2`,key:`e0r10z`}],[`path`,{d:`M9 20h6`,key:`s66wpe`}]]};We.node;var Ge=g(We),Ke={name:`wand-sparkles`,size:24,node:[[`path`,{d:`m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72`,key:`ul74o6`}],[`path`,{d:`m14 7 3 3`,key:`1r5n42`}],[`path`,{d:`M5 6v4`,key:`ilb8ba`}],[`path`,{d:`M19 14v4`,key:`blhpug`}],[`path`,{d:`M10 2v2`,key:`7u0qdc`}],[`path`,{d:`M7 8H3`,key:`zfb6yr`}],[`path`,{d:`M21 16h-4`,key:`1cnmox`}],[`path`,{d:`M11 3H9`,key:`1obp7u`}]],aliases:[`wand-2`]};Ke.node;var V=g(Ke),H={text:{de:`Text`,en:`Text`},document:{de:`Dokument (PDF, Word)`,en:`Document (PDF, Word)`},table:{de:`Tabelle`,en:`Table`},image:{de:`Bild`,en:`Image`},video:{de:`Video`,en:`Video`},audio:{de:`Audio`,en:`Audio`},dashboard:{de:`Dashboard`,en:`Dashboard`}},qe={any:{de:`Jede Branche`,en:`Any industry`},trades:{de:`Handwerk`,en:`Trades`},gastronomy:{de:`Gastronomie`,en:`Food service`},hospitality:{de:`Hotel & Tourismus`,en:`Hotels & tourism`},realEstate:{de:`Immobilien`,en:`Real estate`},retail:{de:`Handel`,en:`Retail`},health:{de:`Gesundheit`,en:`Health`},professional:{de:`Kanzlei & Beratung`,en:`Professional services`},agency:{de:`Agentur & Marketing`,en:`Agency & marketing`},events:{de:`Veranstaltungen`,en:`Events`},publicSector:{de:`Vereine & Öffentliches`,en:`Associations & public sector`}},Je={marketing:{de:`Marketing & Social Media`,en:`Marketing & social media`},sales:{de:`Angebote & Verkauf`,en:`Offers & sales`},accounting:{de:`Buchhaltung & Belege`,en:`Accounting & receipts`},service:{de:`Kundenservice`,en:`Customer service`},research:{de:`Recherche & Analyse`,en:`Research & analysis`},hr:{de:`Personal & Bewerbungen`,en:`HR & applications`},operations:{de:`Planung & Abläufe`,en:`Planning & operations`},website:{de:`Helfer für die Website`,en:`Website helpers`},visuals:{de:`Bilder & Video`,en:`Images & video`},inquiries:{de:`Anfragen & Termine`,en:`Inquiries & bookings`},advice:{de:`Beratung & Preise`,en:`Advice & pricing`}},U={text:{de:`Text schreiben`,en:`Writes text`},web:{de:`Websuche`,en:`Web search`},browser:{de:`Browser bedienen`,en:`Drives a browser`},documents:{de:`Dokumente & Fotos lesen`,en:`Reads documents & photos`},image:{de:`Bilder erzeugen`,en:`Makes images`},video:{de:`Videos erzeugen`,en:`Makes video`},speech:{de:`Sprachausgabe`,en:`Speech output`},listening:{de:`Sprachnotizen verstehen`,en:`Understands voice notes`},code:{de:`Code ausführen`,en:`Runs code`},connectors:{de:`Verbundene Konten & Systeme`,en:`Connected accounts & systems`},film:{de:`Filme mit Claude Code (auf deinem Abo)`,en:`Films with Claude Code (on your subscription)`}},Ye={low:{de:`günstig`,en:`low cost`},medium:{de:`mittel`,en:`medium cost`},high:{de:`teuer`,en:`high cost`}},Xe={free:{de:`Kostenlos`,en:`Free`},pro:{de:`Pro`,en:`Pro`}},W=e=>Object.keys(e);W(H),W(qe),W(Je),W(U),W(Xe);var G=e(t(),1);function Ze(e){switch(e.type){case`page`:return R;case`agent`:return N;case`generate`:return e.asset===`image`?L:e.asset===`video`?O:e.asset===`dashboard`?Oe:E;case`widget`:return M;case`surface`:return Ae;case`film`:return P;case`review`:return I;case`result`:return Ce}return V}var Qe={page:`bg-cobalt-tint text-cobalt`,agent:`bg-ember-tint text-ember-strong`,generate:`bg-amber-tint text-ink-2`,widget:`bg-ember-veil text-ember-strong`,surface:`bg-ember-veil text-ember-strong`,film:`bg-amber-tint text-ink-2`,review:`bg-moss-tint text-moss`,result:`bg-paper-2 text-ink-2`};function $e(e){return v(`type.${e.type}`)}var et=[`web_search`,`web_fetch`,`browser`,`sandbox`,`image`,`http`,`pages`];function tt(e){return et.includes(e)?v(`tool.${e}`):e}function nt(e){switch(e.type){case`page`:return e.fields.map(e=>e.label).join(` · `);case`agent`:{let t=e.tools.map(tt),n=e.mcp?.length?[`MCP: ${e.mcp.join(`, `)}`]:[];return[...t,...n].join(` · `)||e.instructions.slice(0,90)}case`generate`:{let t=[e.asset];return e.options?.aspectRatio&&t.push(e.options.aspectRatio),e.options?.duration&&t.push(`${e.options.duration}s`),e.options?.resolution&&t.push(e.options.resolution),e.options?.template&&t.push(e.options.template),t.join(` · `)}case`widget`:return[e.entry,Object.keys(e.data).join(`, `)].filter(Boolean).join(` · `);case`surface`:return e.candidates?e.candidates.map(e=>e.id).join(` · `):Object.keys(e.data).join(`, `);case`film`:return[e.format,e.seconds?`${e.seconds}s`:null,e.skills.join(`, `)].filter(Boolean).join(` · `);case`review`:return[e.edit?v(`editor.reviewEditable`):null,e.regenerate?v(`editor.reviewRedo`):null].filter(Boolean).join(` · `);case`result`:return e.deliverables.map(e=>`${e.label??e.from} (${e.formats.join(`, `)})`).join(` · `)}return``}var K=e(n(),1),rt=(0,G.lazy)(()=>d(()=>import(`./FlowPreview-ChXfiMn_.js`),__vite__mapDeps([0,1,2,3,4,5]))),it={useCase:``,industry:``,format:``,capability:``,plan:``},q=(e,t)=>e[t]?.[_]??t;function at(e){if(e<1)return 1;let t=10**Math.floor(Math.log10(e));return Math.round(e/t)*t}function ot(e){return e.credits?v(`market.credits`,{n:at(e.credits.credits)}):Ye[e.costTier][_]}var st={text:Ge,document:E,table:Ve,image:L,video:O,audio:le,dashboard:fe};function J({format:e,className:t}){let n=st[e],r=q(H,e);return(0,K.jsx)(`span`,{title:r,className:`inline-flex`,children:(0,K.jsx)(n,{className:t,"aria-label":r,role:`img`})})}var ct=[`low`,`medium`,`high`];function Y({entry:e}){let t=ct.indexOf(e.costTier)+1,n=_===`de`?ge:me;return(0,K.jsxs)(`span`,{title:ot(e),className:`inline-flex items-center gap-1`,children:[(0,K.jsx)(`span`,{"aria-hidden":`true`,className:`inline-flex shrink-0`,children:ct.slice(0,t).map((e,t)=>(0,K.jsx)(`span`,{className:x(`rounded-full bg-(--coin-bg,var(--color-card))`,t>0&&`-ml-1.5`),children:(0,K.jsx)(n,{className:`size-4`})},e))}),Ye[e.costTier][_]]})}function lt(){return(0,K.jsx)(w,{tone:`ember`,title:v(`market.proHint`),children:v(`market.pro`)})}function ut({plugin:e}){return(0,K.jsx)(w,{icon:(0,K.jsx)(Fe,{className:`size-3.5`}),title:v(`market.fromPlugin`,{name:e.name}),children:e.name})}function dt({entry:e,onOpen:t}){return(0,K.jsxs)(C,{role:`button`,tabIndex:0,onClick:t,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t())},className:x(`relative flex min-h-[124px] cursor-pointer flex-col gap-5 p-4 text-left transition sm:min-h-[136px] sm:p-5 hover:shadow-elevated focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus`,(!e.usable||e.missing.length>0||!!e.needs?.length)&&`opacity-60`),children:[(0,K.jsx)(`span`,{className:`-top-4 pointer-events-none absolute right-4`,children:(0,K.jsx)(j,{kind:e.avatar,size:68})}),(0,K.jsxs)(`div`,{className:`min-w-0 pr-20`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 font-display font-semibold text-[0.9375rem]`,children:[e.title,e.plan===`pro`?(0,K.jsx)(lt,{}):null,e.starred?(0,K.jsx)(B,{className:`size-3.5 shrink-0 fill-amber text-amber`,"aria-label":v(`market.starred`)}):null]}),(0,K.jsx)(`div`,{className:`mt-0.5 text-[0.8125rem] text-ink-3 leading-snug`,children:e.pitch})]}),(0,K.jsxs)(`div`,{className:`mt-auto flex flex-wrap items-center gap-x-3 gap-y-1.5 text-[0.75rem] text-ink-3`,children:[e.plugin?(0,K.jsx)(ut,{plugin:e.plugin}):null,e.needs?.length?(0,K.jsx)(w,{tone:`warn`,children:v(`market.needsPro`,{list:e.needs.join(`, `)})}):e.usable&&e.missing.length?(0,K.jsx)(w,{tone:`warn`,children:v(`market.missing`,{list:Z(e.missing)})}):e.usable?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,K.jsx)(y,{className:`size-3.5`}),` `,v(`market.minutes`,{n:e.effort.minutes})]}),(0,K.jsx)(Y,{entry:e}),e.optional?.length?(0,K.jsx)(w,{title:v(`market.optionalHint`,{list:Z(e.optional)}),children:v(`market.without`,{list:Z(e.optional)})}):null,(0,K.jsx)(`span`,{className:`ml-auto inline-flex items-center gap-1.5`,children:e.formats.map(e=>(0,K.jsx)(J,{format:e,className:`size-4`},e))})]}):(0,K.jsx)(w,{tone:`warn`,children:v(`market.needsUpdate`)})]})]})}function X({title:e,children:t}){return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`mb-1.5 font-medium text-[0.75rem] text-ink-3 uppercase tracking-[0.06em]`,children:e}),t]})}var Z=e=>e.map(e=>q(U,e)).join(`, `),ft={text:k,web:Te,browser:D,documents:Le,image:L,video:O,speech:A,listening:f,code:Ue,connectors:Ne,film:P};function pt(e){switch(e.type){case`page`:return R;case`agent`:return N;case`generate`:return e.asset===`image`?L:e.asset===`video`?O:e.asset===`voice`?A:e.asset===`dashboard`?fe:E;case`widget`:return e.video?P:M;case`surface`:return M;case`film`:return P;case`review`:return I;case`result`:return Ce}return V}function mt(e){let t=new Set;for(let[n,r]of e.entries())for(let i of r.branches??[]){let r=i.to===`end`?e.length:e.findIndex(e=>e.id===i.to);for(let i=n+1;i<r;i++)t.add(e[i].id)}return t}function ht(e){let t=mt(e);return e.map(e=>({id:e.id,title:e.title,icon:pt(e),tone:Qe[e.type]??`bg-paper-2 text-ink-2`,optional:t.has(e.id),branches:e.branches}))}function Q({title:e,children:t}){return(0,K.jsx)(`span`,{title:e,className:`inline-flex items-center gap-2 border-border border-l px-4 first:border-l-0 first:pl-0`,children:t})}function $({icon:e,children:t,more:n}){return(0,K.jsxs)(`div`,{className:`flex gap-2.5`,children:[(0,K.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:e}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-[0.875rem] text-ink leading-snug`,children:t}),n?(0,K.jsx)(`div`,{className:`text-[0.75rem] text-ink-3 leading-snug`,children:n}):null]})]})}function gt({className:e,children:t}){let n=(0,G.useRef)(null),[r,i]=(0,G.useState)({above:!1,below:!1});(0,G.useEffect)(()=>{let e=n.current;if(!e)return;let t=()=>{let t=e.scrollTop>1,n=e.scrollTop+e.clientHeight<e.scrollHeight-1;i(e=>e.above===t&&e.below===n?e:{above:t,below:n})};t(),e.addEventListener(`scroll`,t,{passive:!0});let r=new ResizeObserver(t);return r.observe(e),e.firstElementChild&&r.observe(e.firstElementChild),()=>{e.removeEventListener(`scroll`,t),r.disconnect()}},[]);let a=`linear-gradient(to bottom, ${r.above?`transparent`:`black`} 0, black 28px, black calc(100% - 44px), ${r.below?`transparent`:`black`} 100%)`;return(0,K.jsx)(`div`,{ref:n,className:e,style:{maskImage:a,WebkitMaskImage:a},children:(0,K.jsx)(`div`,{children:t})})}function _t({id:e,fallback:t,onClose:n,onUse:i,busy:a}){let o=r(),c=te(),l=s({queryKey:[`marketplace-entry`,e,_],queryFn:()=>p.get(`/api/studio/marketplace/${encodeURIComponent(e)}?lang=${_}`),enabled:!!e,retry:!1}),d=l.data??t,f=u({mutationFn:t=>{let n=`/api/studio/marketplace/${encodeURIComponent(e)}/star`;return t?p.put(n):p.del(n)},onSuccess:()=>Promise.all([o.invalidateQueries({queryKey:[`marketplace`]}),o.invalidateQueries({queryKey:[`marketplace-entry`,e]})])}),m=ne()===`dark`,g=re[ie[d?.avatar||`round`]],b=m?`var(--card)`:`color-mix(in oklch, ${g??`var(--ink-4)`} 14%, var(--paper-2))`;return(0,K.jsx)(ee,{open:!!e,onClose:n,wide:!0,bare:!0,children:d?(0,K.jsxs)(`div`,{className:`relative flex max-h-[calc(100dvh-48px)] flex-col rounded-2xl bg-card shadow-overlay max-sm:h-dvh max-sm:max-h-none max-sm:rounded-none`,children:[(0,K.jsx)(`button`,{type:`button`,"aria-label":v(`common.close`),onClick:n,className:`sm:-top-3.5 sm:-right-3.5 absolute top-3 right-3 z-20 flex size-9 items-center justify-center rounded-full bg-card text-ink-2 shadow-elevated ring-1 ring-border-soft transition hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus`,children:(0,K.jsx)(h,{className:`size-4`})}),(0,K.jsxs)(`header`,{className:`relative shrink-0 border-border-soft border-b px-5 pt-5 pb-4 text-ink sm:rounded-t-2xl sm:px-7`,style:{background:b,"--coin-bg":b},children:[(0,K.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 overflow-hidden sm:rounded-t-2xl`,children:(0,K.jsx)(`span`,{className:x(`-top-28 -right-10 absolute size-80 rounded-full bg-white blur-3xl`,m?`opacity-[0.14]`:`opacity-80`)})}),(0,K.jsx)(`div`,{className:`-bottom-5 absolute right-9 z-10 max-sm:hidden`,children:(0,K.jsx)(j,{kind:d.avatar,size:104})}),(0,K.jsxs)(`div`,{className:`relative sm:pr-36`,children:[(0,K.jsx)(`h2`,{className:`font-display font-semibold text-[1.375rem] leading-tight tracking-tight max-sm:pr-10`,children:d.title}),(0,K.jsx)(`p`,{className:`mt-1 text-[0.875rem] text-ink-2 leading-snug`,children:l.data?.description||d.pitch})]}),d.usable?(0,K.jsxs)(`div`,{className:`-mx-5 sm:-mx-7 relative mt-3.5 flex flex-wrap items-center gap-y-2 border-border-soft border-t px-5 pt-3 font-medium text-[0.875rem] sm:px-7 sm:pr-40`,children:[(0,K.jsxs)(Q,{title:v(`market.duration`),children:[(0,K.jsx)(y,{className:`size-4 text-ink-3`}),v(`market.minutes`,{n:d.effort.minutes})]}),(0,K.jsx)(Q,{title:v(`market.cost`),children:(0,K.jsx)(Y,{entry:d})}),(0,K.jsx)(Q,{title:v(`market.result`),children:d.formats.map(e=>(0,K.jsx)(J,{format:e,className:`size-4`},e))})]}):null]}),d.usable?(0,K.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-x-7 gap-y-6 px-5 pt-6 max-sm:overflow-y-auto max-sm:pb-4 sm:grid-cols-[230px_minmax(0,1fr)] sm:grid-rows-[minmax(0,1fr)] sm:px-7`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-5 sm:min-h-0 sm:overflow-y-auto`,children:[(0,K.jsx)(X,{title:v(`market.duration`),children:(0,K.jsx)($,{icon:(0,K.jsx)(y,{className:`size-4 text-moss`}),more:v(`market.durationHint`,{n:d.effort.fields}),children:v(`market.minutes`,{n:d.effort.minutes})})}),(0,K.jsx)(X,{title:v(`market.cost`),children:(0,K.jsx)($,{icon:(0,K.jsx)(be,{className:`size-4 text-amber`}),more:d.credits?v(`market.creditsHint`):void 0,children:(0,K.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2`,children:[(0,K.jsx)(Y,{entry:d}),d.credits?(0,K.jsx)(`span`,{className:`text-ink-2`,children:v(`market.creditsRange`,{n:at(d.credits.credits)})}):null]})})}),(0,K.jsx)(X,{title:v(`market.result`),children:(0,K.jsx)(`div`,{className:`flex flex-col gap-2`,children:(l.data?.results??[]).map(e=>(0,K.jsx)($,{icon:(0,K.jsx)(J,{format:e.kind,className:`size-4 text-ember-strong`}),more:e.formats.map(e=>e.toUpperCase()).join(` · `),children:e.title},e.title))})}),(0,K.jsx)(X,{title:v(`market.needs`),children:(0,K.jsx)(`ul`,{className:`flex flex-col gap-2`,children:d.capabilities.map(e=>{let t=ft[e],n=d.missing.includes(e),r=d.optional?.includes(e);return(0,K.jsxs)(`li`,{className:x(`flex items-center gap-2.5 text-[0.875rem]`,n?`text-ink-3`:`text-ink-2`),children:[(0,K.jsx)(t,{className:x(`size-4 shrink-0`,n?`text-rose`:r?`text-amber`:`text-cobalt`)}),q(U,e),n?(0,K.jsx)(`span`,{className:`text-[0.75rem] text-rose`,children:v(`market.unavailable`)}):r?(0,K.jsx)(`span`,{className:`text-[0.75rem] text-amber`,children:v(`market.optional`)}):null]},e)})})})]}),(0,K.jsxs)(`div`,{className:`flex flex-col sm:min-h-0`,children:[(0,K.jsx)(`div`,{className:`mb-1.5 shrink-0 font-medium text-[0.75rem] text-ink-3 uppercase tracking-[0.06em]`,children:v(`market.steps`)}),(0,K.jsx)(gt,{className:`-mr-2 overscroll-contain pt-1 pr-2 pl-1 sm:min-h-0 sm:flex-1 sm:overflow-y-auto`,children:l.isLoading?(0,K.jsx)(S,{className:`size-5 text-ink-3`}):(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(S,{className:`size-5 text-ink-3`}),children:(0,K.jsx)(rt,{steps:ht(l.data?.outline??[])})})})]})]}):(0,K.jsx)(`div`,{className:`flex-1 px-5 pt-6 sm:px-7`,children:(0,K.jsx)(`p`,{className:`rounded-lg bg-amber-tint p-3 text-[0.875rem] text-ink-2`,children:v(`market.needsUpdateHint`)})}),(0,K.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 px-5 pt-4 pb-5 max-sm:border-border-soft max-sm:border-t sm:px-7 sm:pb-6`,children:[d.plugin?(0,K.jsx)(`span`,{className:`mr-auto flex items-center`,children:(0,K.jsx)(ut,{plugin:d.plugin})}):(0,K.jsxs)(T,{variant:`ghost`,className:`mr-auto`,title:v(`market.starHint`),"aria-pressed":d.starred,busy:f.isPending,onClick:()=>f.mutate(!d.starred),children:[(0,K.jsx)(B,{className:x(`size-4`,d.starred&&`fill-amber text-amber`)}),(0,K.jsx)(`span`,{className:`max-sm:sr-only`,children:v(d.starred?`market.starred`:`market.star`)})]}),(0,K.jsx)(T,{variant:`secondary`,onClick:n,children:v(`common.close`)}),d.usable&&d.missing.length?(0,K.jsx)(T,{variant:`secondary`,onClick:()=>c(`/settings/models`),children:v(`editor.models.settings`)}):null,i?(0,K.jsx)(T,{disabled:!d.usable||d.missing.length>0||!!d.needs?.length,title:d.needs?.length?v(`market.needsProHint`,{list:d.needs.join(`, `)}):d.missing.length?v(`market.missingHint`,{list:Z(d.missing)}):d.optional?.length?v(`market.optionalHint`,{list:Z(d.optional)}):void 0,busy:a,onClick:()=>i(d),children:v(`market.use`)}):null]})]}):(0,K.jsx)(`div`,{className:`flex min-h-48 flex-col items-center justify-center gap-3 rounded-2xl bg-card p-8 text-[0.875rem] text-ink-2 shadow-overlay`,children:l.isLoading?(0,K.jsx)(S,{className:`size-6 text-ink-3`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{children:v(`market.notFound`)}),(0,K.jsx)(T,{variant:`secondary`,onClick:n,children:v(`common.close`)})]})})})}function vt({name:e,value:t,options:n,onChange:r}){let[i,a]=(0,G.useState)(!1),o=(0,G.useRef)(null);(0,G.useEffect)(()=>{if(!i)return;let e=e=>{o.current?.contains(e.target)||a(!1)},t=e=>{e.key===`Escape`&&a(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[i]);let s=n.find(e=>e.value===t);return(0,K.jsxs)(`div`,{ref:o,className:`relative`,children:[(0,K.jsxs)(`div`,{className:x(`flex h-8 items-center rounded-full text-[0.8125rem] transition`,s?`bg-ember-tint text-ink`:`text-ink-2 hover:bg-paper-2 hover:text-ink`,i&&!s&&`bg-paper-2 text-ink`),children:[(0,K.jsx)(`button`,{type:`button`,"aria-haspopup":`listbox`,"aria-expanded":i,onClick:()=>a(!i),className:x(`flex h-full items-center gap-1.5 rounded-full pl-3 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus`,s?`pr-1`:`pr-2.5`),children:s?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`text-ink-3`,children:e}),(0,K.jsx)(`span`,{className:`font-medium`,children:s.label})]}):(0,K.jsxs)(K.Fragment,{children:[e,(0,K.jsx)(b,{className:x(`size-3.5 transition`,i&&`rotate-180`)})]})}),s?(0,K.jsx)(`button`,{type:`button`,"aria-label":`${e}: ${v(`market.reset`)}`,onClick:()=>r(``),className:`mr-1 flex size-6 items-center justify-center rounded-full text-ink-3 hover:bg-card hover:text-ink`,children:(0,K.jsx)(h,{className:`size-3.5`})}):null]}),i?(0,K.jsx)(`div`,{role:`listbox`,"aria-label":e,className:`absolute top-full left-0 z-30 mt-1.5 max-h-80 min-w-60 overflow-y-auto rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,children:n.map(e=>(0,K.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":e.value===t,disabled:!e.count||e.unavailable,onClick:()=>{r(e.value===t?``:e.value),a(!1)},className:x(`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-left text-[0.875rem] transition coarse:py-2.5`,e.count&&!e.unavailable?`text-ink-2 hover:bg-paper-2 hover:text-ink`:`text-ink-4`,e.value===t&&`font-medium text-ink`),children:[e.icon,(0,K.jsx)(`span`,{className:`flex-1 whitespace-nowrap`,children:e.label}),e.value===t?(0,K.jsx)(m,{className:`size-4 text-ember`}):e.unavailable?(0,K.jsx)(`span`,{className:`whitespace-nowrap text-[0.75rem] text-ink-4`,children:v(`market.unavailable`)}):(0,K.jsx)(`span`,{className:`text-[0.75rem] text-ink-4 tabular-nums`,children:e.count})]},e.value))}):null]})}function yt(e,t){let[n,r]=(0,G.useState)(e);return(0,G.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n}var bt=60;function xt({query:e,onUse:t,busy:n,limit:r=6}){let[i,a]=(0,G.useState)(null),o=yt(e.trim(),250),c=s({queryKey:[`marketplace`,_,o,`hits`,r],queryFn:()=>p.get(`/api/studio/marketplace?${new URLSearchParams({lang:_,limit:String(r),offset:`0`,q:o})}`),enabled:!!o,placeholderData:l}),u=o?c.data?.entries??[]:[];return u.length?(0,K.jsxs)(`section`,{className:`mt-10`,children:[(0,K.jsxs)(`h2`,{className:`mb-5 flex items-center gap-2 font-medium text-[0.8125rem] text-ink-3 uppercase tracking-[0.08em]`,children:[v(`market.hits`),c.isFetching?(0,K.jsx)(S,{className:`size-3.5`}):null]}),(0,K.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:u.map(e=>(0,K.jsx)(dt,{entry:e,onOpen:()=>a(e.id)},e.id))}),(0,K.jsx)(_t,{id:i,fallback:u.find(e=>e.id===i)??null,onClose:()=>a(null),onUse:t,busy:n})]}):null}function St({onUse:e,busy:t,open:n}){let[r,i]=(0,G.useState)(``),[a,o]=(0,G.useState)(it),[s,c]=(0,G.useState)(!1),[u,d]=(0,G.useState)(n??null),f=yt(r.trim(),250),m=oe({queryKey:[`marketplace`,_,f,a,s],queryFn:({pageParam:e})=>{let t=new URLSearchParams({lang:_,limit:String(bt),offset:String(e)});f&&t.set(`q`,f);for(let[e,n]of Object.entries(a))n&&t.set(e,n);return s&&t.set(`starred`,`1`),p.get(`/api/studio/marketplace?${t}`)},initialPageParam:0,getNextPageParam:(e,t)=>{let n=t.reduce((e,t)=>e+t.entries.length,0);return n<e.total?n:void 0},placeholderData:l}),g=m.data?.pages[0],y=m.data?.pages.flatMap(e=>e.entries)??[],b=g?.all??0,ee=r.trim()!==f||m.isFetching&&!m.isFetchingNextPage,C=(e,t,n)=>Object.keys(t).filter(t=>g?.facets[e]?.[t]!==void 0).map(r=>({value:r,label:q(t,r),icon:n?.(r),count:(g?.facets[e])[r]??0,unavailable:e===`capability`&&te.has(r)})),te=new Set(g?.unavailable??[]),w=C(`useCase`,Je),E=[{key:`industry`,name:v(`market.industry`),options:C(`industry`,qe)},{key:`format`,name:v(`market.format`),options:C(`format`,H,e=>(0,K.jsx)(J,{format:e,className:`size-4 text-ink-3`}))},{key:`plan`,name:v(`market.plan`),options:C(`plan`,Xe)},{key:`capability`,name:v(`market.capability`),options:C(`capability`,U,e=>{let t=ft[e];return(0,K.jsx)(t,{className:`size-4 text-ink-3`})})}],D=!!r.trim()||s||Object.values(a).some(Boolean),O=()=>{o(it),i(``),c(!1)};if(m.isLoading)return(0,K.jsx)(`div`,{className:`flex justify-center py-10`,children:(0,K.jsx)(S,{className:`size-6 text-ink-3`})});let k=g?.offline?(0,K.jsxs)(`p`,{className:`mt-4 flex items-center justify-center gap-2 text-[0.8125rem] text-ink-3`,children:[(0,K.jsx)(F,{className:`size-4 shrink-0`}),v(`market.offline`)]}):null;if(!b&&!D)return k;let A=r?(0,K.jsx)(`button`,{type:`button`,"aria-label":v(`market.reset`),onClick:()=>i(``),className:`-mr-1.5 flex size-7 shrink-0 items-center justify-center rounded-full text-ink-3 hover:bg-paper-2 hover:text-ink`,children:(0,K.jsx)(h,{className:`size-4`})}):null,j=e=>x(`inline-flex h-7 shrink-0 items-center gap-1 whitespace-nowrap rounded-full px-2.5 text-[0.78125rem] transition`,e?`bg-card font-medium text-ink shadow-soft ring-1 ring-border-soft`:`text-ink-3 hover:bg-card/60 hover:text-ink`);return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`relative mx-auto flex h-10 max-w-md items-center gap-2.5 rounded-full bg-card px-4 shadow-soft ring-1 ring-border-soft transition focus-within:ring-2 focus-within:ring-focus sm:h-11`,children:[ee?(0,K.jsx)(S,{className:`size-4 shrink-0 text-ink-3`}):(0,K.jsx)(z,{className:`size-4 shrink-0 text-ink-3`}),(0,K.jsx)(`input`,{type:`search`,value:r,onChange:e=>i(e.target.value),placeholder:v(`market.search`),"aria-label":v(`market.search`),className:`min-w-0 flex-1 bg-transparent text-[0.9375rem] outline-none placeholder:text-ink-4 [&::-webkit-search-cancel-button]:hidden`}),A]}),k,(0,K.jsxs)(`div`,{className:`max-sm:-mx-3 mt-4 flex gap-1 max-sm:overflow-x-auto max-sm:px-3 max-sm:[scrollbar-width:none] sm:flex-wrap sm:justify-center max-sm:[&::-webkit-scrollbar]:hidden`,children:[[{value:``,label:v(`market.all`)},...w].map(e=>(0,K.jsx)(`button`,{type:`button`,"aria-pressed":!s&&a.useCase===e.value,onClick:()=>{c(!1),o({...a,useCase:e.value})},className:j(!s&&a.useCase===e.value),children:e.label},e.value)),(0,K.jsxs)(`button`,{type:`button`,"aria-pressed":s,onClick:()=>c(!s),className:j(s),children:[(0,K.jsx)(B,{className:x(`size-3.5`,s&&`fill-amber text-amber`)}),v(`market.starred`)]})]}),(0,K.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-1 gap-y-2 sm:mt-6`,children:[s?null:E.map(e=>(0,K.jsx)(vt,{name:e.name,value:a[e.key],options:e.options,onChange:t=>o({...a,[e.key]:t})},e.key)),(0,K.jsxs)(`span`,{className:`ml-auto flex items-center gap-3 whitespace-nowrap pl-2 text-[0.8125rem] text-ink-3`,children:[D?(0,K.jsxs)(`button`,{type:`button`,onClick:O,className:`inline-flex items-center gap-1 text-ember-strong underline-offset-2 hover:underline`,children:[(0,K.jsx)(h,{className:`size-3.5 max-sm:size-4`}),(0,K.jsx)(`span`,{className:`max-sm:sr-only`,children:v(`market.resetShort`)})]}):null,D?(0,K.jsx)(`span`,{className:`tabular-nums sm:hidden`,children:v(`market.countOfShort`,{n:g?.total??0,all:b})}):null,(0,K.jsx)(`span`,{className:x(`tabular-nums`,D&&`max-sm:hidden`),children:D?v(`market.countOf`,{n:g?.total??0,all:b}):v(`market.count`,{n:b})})]})]}),y.length?(0,K.jsx)(`div`,{className:`mt-4 grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:y.map(e=>(0,K.jsx)(dt,{entry:e,onOpen:()=>d(e.id)},e.id))}):(0,K.jsxs)(`div`,{className:`py-10 text-center text-[0.875rem] text-ink-3`,children:[(0,K.jsx)(`p`,{children:v(s?`market.noneStarred`:`market.none`)}),(0,K.jsx)(T,{variant:`ghost`,className:`mt-2`,onClick:O,children:v(`market.reset`)})]}),m.hasNextPage?(0,K.jsx)(`div`,{className:`mt-6 flex justify-center`,children:(0,K.jsx)(T,{variant:`secondary`,busy:m.isFetchingNextPage,onClick:()=>void m.fetchNextPage(),children:v(`market.more`)})}):null,(0,K.jsx)(_t,{id:u,fallback:y.find(e=>e.id===u)??null,onClose:()=>d(null),onUse:e,busy:t})]})}export{N as C,P as S,L as _,nt as a,be as b,V as c,B as d,z as f,Ae as g,R as h,Ze as i,Ge as l,Ne as m,xt as n,tt as o,Fe as p,Qe as r,$e as s,St as t,Ve as u,Te as v,M as w,F as x,I as y};
@@ -0,0 +1 @@
1
+ import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{O as r}from"./logo-C80CWCDM.js";import{t as i}from"./Marketplace-BWhUJ4UX.js";import{t as a}from"./useMutation-DKcIz55V.js";import{C as o,M as s,P as c,Q as l,S as u,g as d,i as f,it as p,nt as m,t as h}from"./ui-D92EkdEB.js";import{t as g}from"./arrow-right-Dpp_mpHe.js";import{O as _}from"./definition-CQGiBQ4X.js";import{t as v}from"./upload-DMq5N6Fw.js";import{d as y,s as b}from"./session-miDEdw2c.js";var x=e(t(),1),S=e(n(),1);function C({variant:e=`secondary`,label:t=c(`home.import`)}){let n=m(),i=r(),{project:s}=b(),l=y(),d=(0,x.useRef)(null),p=a({mutationFn:e=>o.upload(`/api/studio/projects/${s.id}/wizards/import`,e),onSuccess:async({id:e})=>{await i.invalidateQueries({queryKey:[`projects`]}),await i.invalidateQueries({queryKey:[`wizards`]}),n(`/edit/${e}`)}}),g=p.error instanceof u?p.error.body?.issues??[]:[];return!l||s?.readOnly?null:(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(h,{variant:e,busy:p.isPending,disabled:!s,onClick:()=>d.current?.click(),children:[(0,S.jsx)(v,{className:`size-4`}),` `,t]}),(0,S.jsx)(`input`,{ref:d,hidden:!0,type:`file`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&p.mutate(t)}}),(0,S.jsxs)(f,{open:p.isError,onClose:p.reset,title:c(`import.failed`),children:[(0,S.jsx)(`p`,{className:`text-[0.875rem] text-ink-2`,children:p.error?.message}),g.length?(0,S.jsx)(`ul`,{className:`mt-3 flex list-disc flex-col gap-1 pl-5 text-[0.8125rem] text-ink-2`,children:g.slice(0,8).map(e=>(0,S.jsx)(`li`,{children:e.message},e.message))}):null,(0,S.jsx)(`div`,{className:`mt-5 flex justify-end`,children:(0,S.jsx)(h,{variant:`secondary`,onClick:p.reset,children:c(`common.close`)})})]})]})}var w={de:[`Stellenanzeige aus ein paar Stichworten, als PDF und LinkedIn-Post`,`Produktbeschreibung für den Onlineshop mit drei Bildvarianten`,`Wettbewerbsanalyse zu einer Firma mit Quellen`,`Lead aus einem Formular in unser CRM eintragen`],en:[`A job ad from a few keywords, as PDF and LinkedIn post`,`A shop product description with three image variants`,`A competitor analysis for a company, with sources`,`Put a lead from a form into our CRM`]};function T(){let e=m(),t=r(),{project:n}=b(),u=y(),[f]=p(),[v,T]=(0,x.useState)(f.get(`wish`)??``),E=a({mutationFn:e=>o.post(`/api/studio/wizards`,{projectId:n.id,starterId:e,lang:s}),onSuccess:async({id:n},r)=>{await t.invalidateQueries({queryKey:[`projects`]}),await t.invalidateQueries({queryKey:[`wizards`]}),e(r?`/edit/${n}`:`/edit/${n}?prompt=${encodeURIComponent(v.trim())}`)}}),D=()=>{v.trim()&&n&&E.mutate(void 0)};return!u||n?.readOnly?(0,S.jsx)(l,{to:`/`,replace:!0}):(0,S.jsxs)(`div`,{className:`animate-rise pt-4`,children:[(0,S.jsxs)(`div`,{className:`mx-auto max-w-2xl`,children:[(0,S.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,S.jsx)(_,{kind:`sprout`,size:150,fluffy:!0}),(0,S.jsx)(`h1`,{className:`mt-2 font-display font-semibold text-[2rem] leading-tight tracking-tight sm:text-[2.375rem]`,children:c(`new.title`)})]}),(0,S.jsxs)(`div`,{className:`mt-8 rounded-2xl bg-card p-2 shadow-elevated ring-1 ring-border-soft focus-within:ring-focus`,children:[(0,S.jsx)(d,{autoFocus:!0,minRows:4,value:v,onChange:e=>T(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&D()},placeholder:c(`new.placeholder`),className:`border-0 bg-transparent text-[1rem] shadow-none focus:ring-0`}),(0,S.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-2 pb-1`,children:[(0,S.jsx)(`span`,{className:`hidden text-[0.75rem] text-ink-4 sm:block`,children:c(`new.hint`)}),(0,S.jsxs)(h,{size:`md`,onClick:D,busy:E.isPending&&!E.variables,disabled:!v.trim(),children:[c(`new.build`),` `,(0,S.jsx)(g,{className:`size-4`})]})]})]}),(0,S.jsx)(`div`,{className:`mt-4 flex flex-wrap justify-center gap-2`,children:w[s].map(e=>(0,S.jsx)(`button`,{type:`button`,onClick:()=>T(e),className:`rounded-full bg-paper-2 px-3.5 py-1.5 text-[0.8125rem] text-ink-2 transition hover:bg-paper-3 hover:text-ink`,children:e},e))})]}),(0,S.jsxs)(`section`,{className:`mx-auto max-w-5xl`,children:[(0,S.jsx)(`h2`,{className:`mt-16 mb-5 text-center font-medium text-[0.8125rem] text-ink-3 uppercase tracking-[0.08em]`,children:c(`new.orStarter`)}),(0,S.jsx)(i,{open:f.get(`starter`),busy:E.isPending&&!!E.variables,onUse:e=>n&&!E.isPending&&E.mutate(e.id)}),E.error?(0,S.jsx)(`p`,{className:`mt-3 text-center text-[0.875rem] text-rose`,children:E.error.message}):null]}),(0,S.jsx)(`div`,{className:`mt-8 flex justify-center`,children:(0,S.jsx)(C,{variant:`ghost`,label:c(`new.import`)})})]})}export{T as NewWizardPage};
@@ -0,0 +1,2 @@
1
+ import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{O as r,r as i}from"./logo-C80CWCDM.js";import{c as a,d as o,f as s,l as c,p as l,y as u}from"./Marketplace-BWhUJ4UX.js";import{t as d}from"./useMutation-DKcIz55V.js";import{C as f,G as p,J as m,K as h,M as g,P as _,Q as v,R as y,_ as b,a as ee,c as x,d as te,f as S,g as C,i as w,it as ne,m as T,n as E,nt as re,o as D,p as O,r as k,rt as ie,s as A,t as j,tt as ae,z as M}from"./ui-D92EkdEB.js";import{_ as oe,b as N,t as se,v as ce,y as P}from"./RunnerView-CLrGb-oq.js";import{S as F,T as le,_ as I,b as L,f as R,g as z,h as B,m as V,p as H,r as U,v as W,x as ue,y as G}from"./HomePage-BG5OZJkv.js";import{_ as de,a as fe,b as K,c as pe,d as me,f as q,g as he,h as ge,i as _e,l as ve,m as ye,n as J,o as be,p as xe,s as Se,u as Ce,v as we,x as Te,y as Ee}from"./RunDrawer-DfnEMPTq.js";import{t as De}from"./external-link-CpU8aJY2.js";import{n as Oe,t as Y}from"./trash-DU-hZpV0.js";import{t as ke}from"./refresh-cw-Cli5WGnW.js";import{t as Ae}from"./upload-DMq5N6Fw.js";import{c as je,l as Me,s as Ne}from"./session-miDEdw2c.js";import{N as Pe,P as Fe,a as Ie,c as Le,i as Re,m as ze,o as Be,r as Ve,s as He,t as Ue}from"./index-CIO9W4pe.js";import{a as X,c as We,f as Ge,i as Ke,n as qe,o as Je,r as Ye,s as Xe,t as Ze,u as Qe}from"./settings-menu-ROT8Lbbj.js";import{n as $e,t as et}from"./ReadOnly-C9P9aiU6.js";var tt={name:`layers`,size:24,node:[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]],aliases:[`layers-3`]};tt.node;var nt=m(tt),rt={name:`music`,size:24,node:[[`path`,{d:`M9 18V5l12-2v13`,key:`1jmyc2`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`circle`,{cx:`18`,cy:`16`,r:`3`,key:`1hluhg`}]]};rt.node;var it=m(rt),at={name:`text-align-start`,size:24,node:[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M17 19H3`,key:`z6ezky`}]],aliases:[`text`,`align-left`]};at.node;var ot=m(at),Z=e(t(),1),Q=e(n(),1),st={backgroundImage:`repeating-conic-gradient(#c9c9c9 0% 25%, #dedede 0% 50%)`,backgroundSize:`16px 16px`};function ct({file:e,actions:t}){let[n,r]=(0,Z.useState)(e.description),i=(0,Z.useRef)(e.description),a=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{e.description!==i.current&&(r(t=>t===i.current?e.description:t),i.current=e.description)},[e.description]),(0,Z.useLayoutEffect)(()=>{let e=a.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`)},[n]);let o=e.status===`pending`&&!n;return t.readOnly?n?(0,Q.jsx)(`p`,{className:`text-[0.8125rem] text-ink-2 leading-snug`,children:n}):null:(0,Q.jsx)(`textarea`,{ref:a,rows:1,value:n,maxLength:600,placeholder:_(o?`project.describing`:`project.description`),onChange:e=>r(e.target.value),onBlur:()=>{n.trim()!==e.description&&(i.current=n.trim(),t.describe(e.id,n.trim()))},className:`-mx-1 block w-[calc(100%+0.5rem)] resize-none overflow-hidden rounded-md bg-transparent px-1 py-0.5 text-[0.8125rem] text-ink-2 leading-snug outline-none transition placeholder:text-ink-4 hover:bg-paper-2 focus:bg-card focus:text-ink focus:ring-1 focus:ring-border`})}function lt(e,t){confirm(_(`project.removeConfirm`,{name:e.name}))&&t.remove(e.id)}function ut({projectId:e,file:t,small:n}){let r=W(e,t.id);return t.mime.startsWith(`image/`)?(0,Q.jsx)(`img`,{src:r,alt:``,loading:`lazy`,className:b(`size-full`,t.kind===`logo`?`object-contain p-3`:`object-cover`)}):t.mime.startsWith(`video/`)?(0,Q.jsx)(`video`,{src:`${r}#t=0.1`,preload:`metadata`,controls:!n,className:`size-full object-cover`}):(0,Q.jsx)(`div`,{className:`flex size-full items-center justify-center text-ink-3`,children:t.mime.startsWith(`audio/`)?(0,Q.jsx)(it,{className:n?`size-5`:`size-7`}):(0,Q.jsx)(N,{className:n?`size-5`:`size-7`})})}function dt({projectId:e,kind:t,files:n,actions:r,accept:i,addLabel:a,onPreview:s}){return(0,Q.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(184px,1fr))] gap-3`,children:[n.map((i,a)=>(0,Q.jsxs)(`div`,{className:`group relative flex flex-col gap-1.5 rounded-lg bg-paper p-2 pb-2.5 ring-1 ring-border-soft`,children:[t===`logo`&&a===0?(0,Q.jsx)(`span`,{className:`absolute -top-3 left-3 z-10 rounded-full ring-2 ring-card`,children:(0,Q.jsx)(k,{tone:`ember`,children:_(`project.logoMain`)})}):null,(0,Q.jsxs)(`div`,{className:`relative h-28 overflow-hidden rounded-md bg-paper-2`,style:t===`logo`?st:void 0,children:[s&&i.mime.startsWith(`image/`)?(0,Q.jsx)(`button`,{type:`button`,"aria-label":`${_(`project.preview`)}: ${i.name}`,onClick:()=>s(i),className:`block size-full cursor-zoom-in`,children:(0,Q.jsx)(ut,{projectId:e,file:i})}):(0,Q.jsx)(ut,{projectId:e,file:i}),(0,Q.jsxs)(`div`,{className:`absolute top-1 right-1 flex gap-1 opacity-0 transition focus-within:opacity-100 group-hover:opacity-100 coarse:opacity-100`,children:[s?(0,Q.jsx)(D,{label:_(`project.preview`),onClick:()=>s(i),className:`size-8 bg-card shadow-soft`,children:(0,Q.jsx)(u,{className:`size-4`})}):null,t===`logo`&&a>0&&!r.readOnly?(0,Q.jsx)(D,{label:_(`project.logoMakeMain`),onClick:()=>r.order(`logo`,[i.id,...n.filter(e=>e.id!==i.id).map(e=>e.id)]),className:`size-8 bg-card shadow-soft`,children:(0,Q.jsx)(o,{className:`size-4`})}):null,r.readOnly?null:(0,Q.jsx)(D,{label:_(`project.remove`),onClick:()=>lt(i,r),className:`size-8 bg-card shadow-soft hover:text-rose`,children:(0,Q.jsx)(Y,{className:`size-4`})})]})]}),t===`asset`?(0,Q.jsx)(`div`,{className:`truncate px-0.5 text-[0.75rem] text-ink-3`,title:i.name,children:i.name}):null,(0,Q.jsx)(ct,{file:i,actions:r})]},i.id)),a&&!r.readOnly?(0,Q.jsxs)(H,{accept:i,multiple:!1,onFiles:e=>r.upload(t,e),className:`min-h-28 flex-col p-3`,children:[r.busy?(0,Q.jsx)(S,{className:`size-5`}):(0,Q.jsx)(y,{className:`size-5`}),a]}):null]})}function ft({projectId:e,data:t,readOnly:n}){let r=L(e,n);return(0,Q.jsxs)(z,{title:_(`project.logos`),hint:_(`project.logosHint`),children:[(0,Q.jsx)(dt,{projectId:e,kind:`logo`,files:t.files.filter(e=>e.kind===`logo`),actions:r,accept:`image/*`,addLabel:_(`project.logoAdd`)}),r.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:r.error}):null]})}var pt=e=>[(e.name.includes(`.`)?e.name.split(`.`).pop():e.mime.split(`/`).pop())?.toUpperCase().slice(0,5),I(e.size)].filter(Boolean).join(` · `);function mt({projectId:e,file:t,actions:n,onClose:r}){let i=W(e,t.id);return(0,Q.jsxs)(w,{open:!0,onClose:r,wide:`page`,title:t.name,children:[(0,Q.jsxs)(`div`,{className:`-mt-2 mb-4 flex items-center justify-between gap-3`,children:[(0,Q.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3`,children:pt(t)}),(0,Q.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,"aria-label":_(`project.openOriginal`),title:_(`project.openOriginal`),className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,Q.jsx)(De,{className:`size-4`})})]}),t.mime.startsWith(`image/`)?(0,Q.jsx)(`div`,{className:`overflow-hidden rounded-lg`,style:st,children:(0,Q.jsx)(`img`,{src:i,alt:``,className:`mx-auto max-h-[68dvh] object-contain`})}):t.mime.startsWith(`video/`)?(0,Q.jsx)(`video`,{src:i,controls:!0,className:`max-h-[68dvh] w-full rounded-lg bg-black`}):(0,Q.jsx)(`audio`,{src:i,controls:!0,className:`w-full`}),(0,Q.jsx)(`div`,{className:`mt-4`,children:(0,Q.jsx)(ct,{file:t,actions:n})})]})}function ht({projectId:e,file:t,actions:n,onPreview:r}){return(0,Q.jsxs)(`li`,{className:`flex items-start gap-3 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,Q.jsx)(`button`,{type:`button`,"aria-label":`${_(`project.preview`)}: ${t.name}`,onClick:r,className:`size-14 shrink-0 cursor-zoom-in overflow-hidden rounded-md bg-paper-2`,children:(0,Q.jsx)(ut,{projectId:e,file:t,small:!0})}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1 py-0.5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:r,title:t.name,className:`min-w-0 truncate font-medium text-[0.875rem] hover:underline`,children:t.name}),(0,Q.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:pt(t)})]}),(0,Q.jsx)(ct,{file:t,actions:n})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start`,children:[(0,Q.jsx)(D,{label:_(`project.preview`),onClick:r,children:(0,Q.jsx)(u,{className:`size-4`})}),n.readOnly?null:(0,Q.jsx)(D,{label:_(`project.remove`),onClick:()=>lt(t,n),className:`hover:text-rose`,children:(0,Q.jsx)(Y,{className:`size-4`})})]})]})}function gt({projectId:e,data:t,readOnly:n}){let r=L(e,n),[i,a]=ue(`assets`,`cards`),[o,s]=(0,Z.useState)(``),[c,l]=(0,Z.useState)(null),u=t.files.filter(e=>e.kind===`asset`),d=u.find(e=>e.id===c),f=o.trim().toLowerCase(),p=f?u.filter(e=>`${e.name} ${e.description}`.toLowerCase().includes(f)):u;return(0,Q.jsxs)(z,{title:_(`project.assets`),hint:_(`project.assetsHint`),children:[u.length?(0,Q.jsx)(V,{layout:i,onToggle:a,children:(0,Q.jsx)(B,{value:o,onChange:s,placeholder:_(`project.assetSearch`)})}):null,p.length?(0,Q.jsx)(`div`,{className:`mb-3`,children:i===`cards`?(0,Q.jsx)(dt,{projectId:e,kind:`asset`,files:p,actions:r,onPreview:e=>l(e.id)}):(0,Q.jsx)(`ul`,{className:`flex flex-col gap-2`,children:p.map(t=>(0,Q.jsx)(ht,{projectId:e,file:t,actions:r,onPreview:()=>l(t.id)},t.id))})}):null,n?u.length?null:(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:_(`project.staysLocal`)}):(0,Q.jsxs)(H,{accept:`image/*,video/*,audio/*`,onFiles:e=>r.upload(`asset`,e),className:`h-16 w-full`,children:[r.busy?(0,Q.jsx)(S,{className:`size-4`}):(0,Q.jsx)(Ae,{className:`size-4`}),_(`project.drop`),` `,(0,Q.jsx)(`span`,{className:`underline`,children:_(`project.assetAdd`)})]}),r.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:r.error}):null,d?(0,Q.jsx)(mt,{projectId:e,file:d,actions:r,onClose:()=>l(null)}):null]})}function _t(e,t,n){return i({queryKey:[`project-file-text`,t.id,t.chars,n],queryFn:()=>f.get(`/api/studio/projects/${e}/files/${t.id}/text?limit=${n}`),enabled:t.status===`ready`,staleTime:6e4})}function vt(e){return((e.name.includes(`.`)?e.name.split(`.`).pop():``)||e.mime.split(`/`).pop()||``).toUpperCase().slice(0,5)}var yt=e=>[vt(e),e.pages?_(`project.pages`,{n:e.pages}):null,I(e.size)].filter(Boolean).join(` · `),bt=2e5;function xt({projectId:e,fileId:t,readOnly:n,onGone:i}){let a=r(),o=F(e),s=ye(e),c=L(e,n),l=o.data?.files.find(e=>e.id===t),u=l?l.mime===`application/pdf`||l.mime.startsWith(`image/`):!1,[d,f]=(0,Z.useState)(null);if(!l)return o.isLoading?(0,Q.jsx)(S,{className:`mx-auto text-ink-3`}):null;let p=d??(u?`original`:`text`),m=s.data?.items.find(e=>e.key===`f:${l.id}`),h=W(e,l.id),g=(e,t)=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":p===e,onClick:()=>f(e),className:b(`rounded-full px-3 py-1 text-[0.8125rem] transition`,p===e?`bg-paper-2 font-medium text-ink`:`text-ink-3 hover:text-ink`),children:t});return(0,Q.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,Q.jsx)(`h2`,{className:`min-w-0 flex-1 truncate font-display font-semibold text-lg`,children:l.name}),(0,Q.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 max-sm:hidden`,children:yt(l)}),(0,Q.jsx)(`a`,{href:h,target:`_blank`,rel:`noreferrer`,"aria-label":_(`project.openOriginal`),title:_(`project.openOriginal`),className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,Q.jsx)(De,{className:`size-4`})}),n?null:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(D,{label:_(`project.reindex`),onClick:async()=>{await c.reindex(l.id),await a.invalidateQueries({queryKey:[`knowledge`,e]})},children:(0,Q.jsx)(ke,{className:`size-4`})}),(0,Q.jsx)(D,{label:_(`know.deleteFile`),className:`hover:text-rose`,onClick:async()=>{confirm(_(`data.confirmDelete`,{title:l.name}))&&(await c.remove(l.id),await a.invalidateQueries({queryKey:[`knowledge`,e]}),i())},children:(0,Q.jsx)(Y,{className:`size-4`})})]})]}),(0,Q.jsx)(q,{projectId:e,itemKey:`f:${l.id}`,has:m?.categories??[],originLabel:m?.originLabel??null,kept:!1,review:null,file:null,readOnly:n,onReviewed:()=>void 0}),(0,Q.jsx)(`div`,{className:`px-1`,children:(0,Q.jsx)(ct,{file:l,actions:c})}),l.status===`failed`?(0,Q.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:l.error}):null,(0,Q.jsxs)(E,{className:`flex flex-col`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 border-border-soft border-b px-2 py-1.5`,children:[u?g(`original`,_(`project.original`)):null,g(`text`,_(`project.readText`))]}),p===`original`?l.mime===`application/pdf`?(0,Q.jsx)(`iframe`,{src:h,title:l.name,className:`h-[70dvh] w-full rounded-b-xl bg-paper-2`}):(0,Q.jsx)(`img`,{src:h,alt:``,className:`mx-auto max-h-[70dvh] object-contain p-4`}):(0,Q.jsx)(St,{projectId:e,file:l})]})]})}function St({projectId:e,file:t}){let n=_t(e,t,bt);return n.isLoading||t.status===`pending`?(0,Q.jsx)(`div`,{className:`flex h-40 items-center justify-center text-ink-3`,children:(0,Q.jsx)(S,{})}):n.data?.text?(0,Q.jsxs)(`div`,{className:`overflow-x-auto p-4 sm:p-5`,children:[(0,Q.jsx)(ze,{text:n.data.text,className:`text-[0.875rem]`}),n.data.chars>n.data.text.length?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-ink-3`,children:_(`project.textCut`,{shown:n.data.text.length.toLocaleString(),total:n.data.chars.toLocaleString()})}):null]}):(0,Q.jsx)(`p`,{className:`py-8 text-center text-[0.875rem] text-ink-3`,children:_(`project.noText`)})}var Ct=[`text`,`longtext`,`number`,`date`,`url`,`email`,`phone`,`boolean`],wt=/^(\d{4}-\d{2}-\d{2}|\d{1,2}\.\s?\d{1,2}\.\s?\d{4})$/,Tt=/^[+-]?\d{1,3}([.,\s']?\d{3})*([.,]\d+)?$/,Et=/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/,Dt=/^(https?:\/\/|www\.)\S+$/i,Ot=/^\+?[\d\s()/.-]{7,20}$/,kt=/^(ja|nein|yes|no|true|false)$/i;function At(e){let t=e.trim();return t?t.includes(`
2
+ `)||t.length>140?`longtext`:kt.test(t)?`boolean`:Et.test(t)?`email`:Dt.test(t)?`url`:wt.test(t)?`date`:Tt.test(t)&&!/^(\+|0\d)/.test(t)?`number`:Ot.test(t)&&t.replace(/\D/g,``).length>=7?`phone`:`text`:`text`}function jt(e,t=[]){let n=e.toLowerCase().replace(/ä/g,`ae`).replace(/ö/g,`oe`).replace(/ü/g,`ue`).replace(/ß/g,`ss`).normalize(`NFD`).replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``).slice(0,40)||`fakt`,r=n;for(let e=2;t.includes(r);e++)r=`${n}_${e}`;return r}var Mt=[{key:`adresse`,de:`Adresse`,en:`Address`},{key:`plz`,de:`PLZ`,en:`Postcode`},{key:`ort`,de:`Ort`,en:`City`},{key:`uid`,de:`UID`,en:`VAT id`},{key:`telefon`,de:`Telefon`,en:`Phone`},{key:`e_mail`,de:`E-Mail`,en:`Email`},{key:`website`,de:`Website`,en:`Website`},{key:`iban`,de:`IBAN`,en:`IBAN`}],Nt={facts:100,colors:12,files:{logo:8,asset:100,document:2e3},bytes:{logo:5e6,asset:15e6,video:8e7,document:3e7}},Pt=/^#[0-9a-fA-F]{6}$/;function Ft({onAdd:e,onClose:t}){let[n,r]=(0,Z.useState)(`#e0531b`),[i,a]=(0,Z.useState)(``),o=Pt.test(n);return(0,Q.jsx)(w,{open:!0,onClose:t,title:_(`project.colorAddTitle`),children:(0,Q.jsxs)(`form`,{onSubmit:r=>{r.preventDefault(),o&&(e({name:i.trim(),value:n.toLowerCase()}),t())},className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(x,{children:_(`project.colorValue`)}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(O,{value:o?n:`#888888`,onChange:e=>r(e.target.value)}),(0,Q.jsx)(A,{value:n,placeholder:`#e0531b`,spellCheck:!1,onChange:e=>r(e.target.value.trim()),className:`font-mono text-[0.875rem]`})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(x,{children:_(`project.colorUseLabel`)}),(0,Q.jsx)(A,{autoFocus:!0,value:i,maxLength:120,placeholder:_(`project.colorName`),onChange:e=>a(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:_(`project.colorUse`)})]}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(j,{variant:`ghost`,onClick:t,children:_(`common.cancel`)}),(0,Q.jsx)(j,{type:`submit`,disabled:!o,children:_(`project.add`)})]})]})})}function It({colors:e,save:t,readOnly:n}){let r=(0,Z.useRef)(0),[i,a]=(0,Z.useState)(()=>e.map(e=>({...e,id:`c${r.current++}`}))),[o,s]=(0,Z.useState)(!1),c=G(i.filter(e=>Pt.test(e.value)).map(({name:e,value:t})=>({name:e.trim(),value:t})),t),l=(e,t)=>a(n=>n.map(n=>n.id===e?{...n,...t}:n));return(0,Q.jsxs)(z,{title:_(`project.colors`),hint:_(`project.colorsHint`),save:c,locked:n,children:[(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:i.map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(O,{value:Pt.test(e.value)?e.value:`#888888`,onChange:t=>l(e.id,{value:t.target.value})}),(0,Q.jsx)(A,{value:e.name,placeholder:_(`project.colorName`),maxLength:120,onChange:t=>l(e.id,{name:t.target.value}),className:`min-w-0 flex-1`}),(0,Q.jsx)(A,{value:e.value,placeholder:`#e0531b`,spellCheck:!1,onChange:t=>l(e.id,{value:t.target.value.trim()}),className:`w-28 font-mono text-[0.8125rem]`}),(0,Q.jsxs)(`div`,{className:`flex w-24 shrink-0 items-center justify-end max-sm:w-auto`,children:[t===0?(0,Q.jsx)(`span`,{className:`mr-1 max-sm:hidden`,children:(0,Q.jsx)(k,{tone:`ember`,children:_(`project.colorAccent`)})}):n?null:(0,Q.jsx)(D,{label:_(`project.colorFirst`),onClick:()=>a(t=>[e,...t.filter(t=>t.id!==e.id)]),children:(0,Q.jsx)(h,{className:`size-4`})}),n?null:(0,Q.jsx)(D,{label:_(`project.remove`),onClick:()=>a(t=>t.filter(t=>t.id!==e.id)),className:`hover:text-rose`,children:(0,Q.jsx)(Y,{className:`size-4`})})]})]},e.id))}),i.length&&!n?(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:_(`project.colorUse`)}):null,i.length<Nt.colors&&!n?(0,Q.jsxs)(j,{variant:`secondary`,size:`sm`,className:i.length?`mt-3`:void 0,onClick:()=>s(!0),children:[(0,Q.jsx)(y,{className:`size-4`}),` `,_(`project.colorAdd`)]}):null,o?(0,Q.jsx)(Ft,{onClose:()=>s(!1),onAdd:e=>a(t=>[...t,{...e,id:`c${r.current++}`}])}):null]})}var Lt=e=>/^(ja|yes|true)$/i.test(e.trim()),Rt={text:c,longtext:ot,number:K,date:Te,url:Oe,email:P,phone:oe,boolean:Ee};function zt({type:e,detected:t,onChange:n}){let[r,i]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1),c=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{if(!r)return;let e=e=>{c.current?.contains(e.target)||i(!1)},t=e=>e.key===`Escape`&&i(!1);return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[r]);let l=Rt[e??t],u=`${_(`project.factType`)}: ${_(`project.type.${e??t}`)}`,d=`flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-[0.875rem] text-ink-2 hover:bg-accent hover:text-ink`,f=e=>{n(e),i(!1)};return(0,Q.jsxs)(`div`,{className:`relative`,ref:c,children:[(0,Q.jsx)(`button`,{type:`button`,"aria-label":u,title:u,"aria-haspopup":`menu`,"aria-expanded":r,onClick:e=>{s(window.innerHeight-e.currentTarget.getBoundingClientRect().bottom<400),i(e=>!e)},className:b(`inline-flex size-11 items-center justify-center rounded-lg transition hover:bg-accent hover:text-ink`,r?`bg-accent text-ink`:e?`text-ink-2`:`text-ink-4`),children:(0,Q.jsx)(l,{className:`size-4`})}),r?(0,Q.jsxs)(`div`,{role:`menu`,className:b(`absolute right-0 z-50 w-56 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,o?`bottom-12`:`top-12`),children:[(0,Q.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":!e,className:d,onClick:()=>f(void 0),children:[(0,Q.jsx)(a,{className:`size-4 shrink-0`}),(0,Q.jsx)(`span`,{className:`flex-1`,children:_(`project.factAuto`)}),(0,Q.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:_(`project.type.${t}`)}),(0,Q.jsx)(p,{className:b(`size-4 shrink-0`,e&&`invisible`)})]}),(0,Q.jsx)(`div`,{className:`mx-2 my-1 h-px bg-border-soft`}),Ct.map(t=>{let n=Rt[t];return(0,Q.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e===t,className:d,onClick:()=>f(t),children:[(0,Q.jsx)(n,{className:`size-4 shrink-0`}),(0,Q.jsx)(`span`,{className:`flex-1`,children:_(`project.type.${t}`)}),(0,Q.jsx)(p,{className:b(`size-4 shrink-0`,e!==t&&`invisible`)})]},t)})]}):null]})}function Bt({facts:e,save:t,readOnly:n}){let r=(0,Z.useRef)(0),i=(0,Z.useRef)(null),[a,o]=(0,Z.useState)(()=>e.map(e=>({...e,id:`f${r.current++}`}))),s=G(a.filter(e=>e.key&&e.label.trim()).map(({key:e,label:t,value:n,type:r})=>({key:e,label:t.trim(),value:n,...r?{type:r}:{}})),t),c=(e,t)=>o(n=>n.map(n=>n.id===e?{...n,...t}:n)),l=(e,t,n=!1)=>{let a=`f${r.current++}`;i.current=`${a}:${t}`;let s={id:a,key:``,label:``,value:``,...e};o(e=>n?[s,...e]:[...e,s])},u=e=>t=>{t&&i.current===e&&(i.current=null,t.focus())},d=Mt.filter(e=>!a.some(t=>t.key===e.key));return(0,Q.jsxs)(z,{title:_(`project.facts`),hint:_(`project.factsHint`),save:s,locked:n,action:a.length<Nt.facts&&!n?(0,Q.jsxs)(j,{variant:`secondary`,size:`sm`,onClick:()=>l({},`label`,!0),children:[(0,Q.jsx)(y,{className:`size-4`}),` `,_(`project.factAdd`)]}):null,children:[(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:a.map(e=>{let t=At(e.value),r=e.type??t;return(0,Q.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto_auto] items-start gap-x-1 gap-y-2 sm:grid-cols-[minmax(0,2fr)_minmax(0,3fr)_auto_auto]`,children:[(0,Q.jsx)(A,{ref:u(`${e.id}:label`),value:e.label,placeholder:_(`project.factLabel`),title:e.key?`{{facts.${e.key}}}`:void 0,onChange:t=>c(e.id,{label:t.target.value}),onBlur:()=>{!e.key&&e.label.trim()&&c(e.id,{key:jt(e.label,a.map(e=>e.key))})},className:`max-sm:col-span-3 max-sm:font-medium sm:mr-1`}),e.type===`boolean`?(0,Q.jsxs)(`div`,{className:`flex h-11 items-center gap-3`,children:[(0,Q.jsx)(T,{checked:Lt(e.value),label:e.label,onChange:t=>c(e.id,{value:_(t?`project.yes`:`project.no`)})}),(0,Q.jsx)(`span`,{className:`text-[0.875rem] text-ink-2`,children:Lt(e.value)?_(`project.yes`):_(`project.no`)})]}):(0,Q.jsx)(C,{ref:u(`${e.id}:value`),rows:1,minRows:r===`longtext`?2:1,maxRows:10,value:e.value,placeholder:_(`project.factValue`),onChange:t=>c(e.id,{value:t.target.value}),className:`min-h-11`}),(0,Q.jsx)(zt,{type:e.type,detected:t,onChange:t=>c(e.id,{type:t})}),n?null:(0,Q.jsx)(D,{label:_(`project.remove`),onClick:()=>o(t=>t.filter(t=>t.id!==e.id)),className:`size-11 rounded-lg hover:text-rose`,children:(0,Q.jsx)(Y,{className:`size-4`})})]},e.id)})}),a.length<Nt.facts&&!n?(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${a.length?`mt-4`:``}`,children:[(0,Q.jsxs)(j,{variant:`secondary`,size:`sm`,onClick:()=>l({},`label`),children:[(0,Q.jsx)(y,{className:`size-4`}),` `,_(`project.factAdd`)]}),d.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>l({key:e.key,label:g===`en`?e.en:e.de},`value`),className:`inline-flex h-8 items-center gap-1 rounded-full bg-paper-2 px-3 text-[0.8125rem] text-ink-2 transition hover:bg-paper-3 hover:text-ink`,children:[(0,Q.jsx)(y,{className:`size-3.5`}),` `,g===`en`?e.en:e.de]},e.key))]}):null]})}function Vt({project:e,save:t}){let[n,r]=(0,Z.useState)(e.brand.name??``),[i,a]=(0,Z.useState)(e.brand.about??``),o=G({name:n.trim(),about:i.trim()},e=>t({brand:e}));return(0,Q.jsx)(z,{title:_(`project.base`),hint:_(`project.baseHint`),save:o,locked:e.readOnly,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(x,{children:_(`project.title`)}),(0,Q.jsx)(A,{value:n,maxLength:120,onChange:e=>r(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:_(`project.titleHint`)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(x,{children:_(`project.about`)}),(0,Q.jsx)(C,{minRows:4,value:i,onChange:e=>a(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:_(`project.aboutHint`)})]})]})})}function Ht({project:e,group:t,docked:n=!1,children:i}){let a=r(),o=F(e.id),[s,c]=(0,Z.useState)(0),l=async t=>{await f.patch(`/api/studio/projects/${e.id}`,t),await a.invalidateQueries({queryKey:[`projects`]})},u=d({mutationFn:()=>f.del(`/api/studio/projects/${e.id}`),onSuccess:()=>a.invalidateQueries({queryKey:[`projects`]})}),p=Me(),m=je(),h=o.data??{files:[],embeddings:!0},g=`${e.id}:${s}`,v=e.readOnly;return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-9 pb-32`,children:[v?(0,Q.jsx)(et,{children:$e(e)}):(0,Q.jsx)(Le,{projectId:e.id,part:t,docked:n,onChanged:()=>c(e=>e+1)},e.id),t===`info`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(R,{id:`base`,children:(0,Q.jsx)(Vt,{project:e,save:l},`base:${g}`)}),(0,Q.jsx)(R,{id:`logos`,children:(0,Q.jsx)(ft,{projectId:e.id,data:h,readOnly:v})}),(0,Q.jsx)(R,{id:`colors`,children:(0,Q.jsx)(It,{colors:e.brand.colors??[],save:e=>l({brand:{colors:e}}),readOnly:v},`colors:${g}`)}),(0,Q.jsx)(R,{id:`assets`,children:(0,Q.jsx)(gt,{projectId:e.id,data:h,readOnly:v})}),(0,Q.jsx)(R,{id:`facts`,children:(0,Q.jsx)(Bt,{facts:e.facts,save:e=>l({facts:e}),readOnly:v},`facts:${g}`)})]}):null,i,t===`info`&&p&&!v&&m?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(j,{variant:`danger`,busy:u.isPending,onClick:()=>confirm(`${_(`settings.delete`)}?`)&&u.mutate(),children:_(`settings.delete`)}),u.error?(0,Q.jsx)(`p`,{className:`mt-2 text-[0.875rem] text-rose`,children:u.error.message}):null]}):null]})}var Ut={q:``,mode:``,days:0};function Wt(e,t,n){let r=new URLSearchParams;t&&r.set(`wizard`,t),n.q.trim()&&r.set(`q`,n.q.trim()),n.mode&&r.set(`mode`,n.mode),n.days&&r.set(`days`,String(n.days));let a=r.toString();return i({queryKey:[`results`,e,a],queryFn:()=>f.get(`/api/studio/projects/${e}/results${a&&`?${a}`}`),enabled:!!e,placeholderData:e=>e,refetchInterval:15e3})}function Gt({filter:e,onFilter:t}){let[n,r]=(0,Z.useState)(e.q);return(0,Z.useEffect)(()=>{if(n===e.q)return;let r=setTimeout(()=>t({...e,q:n}),250);return()=>clearTimeout(r)},[n,e,t]),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsxs)(`div`,{className:`relative min-w-0 flex-1 basis-56`,children:[(0,Q.jsx)(s,{className:`-translate-y-1/2 pointer-events-none absolute top-1/2 left-3 size-4 text-ink-3`}),(0,Q.jsx)(A,{type:`search`,value:n,onChange:e=>r(e.target.value),placeholder:_(`space.resultsSearch`),"aria-label":_(`space.resultsSearch`),className:`w-full pl-9`})]}),(0,Q.jsx)(te,{value:e.mode,onChange:n=>t({...e,mode:n}),options:[{value:``,label:_(`space.resultsModeAll`)},{value:`live`,label:`Live`},{value:`test`,label:`Test`}],className:`w-32`}),(0,Q.jsx)(te,{value:String(e.days),onChange:n=>t({...e,days:Number(n)}),options:[{value:`0`,label:_(`space.resultsAnyTime`)},{value:`1`,label:_(`space.resultsDay`)},{value:`7`,label:_(`space.resultsDays`,{n:7})},{value:`30`,label:_(`space.resultsDays`,{n:30})}],className:`w-44`})]})}function Kt({data:e,wizardId:t,filter:n,onFilter:r}){let[i,a]=(0,Z.useState)(null),o=t=>e.wizards.find(e=>e.id===t)?.title??``,s=new Intl.DateTimeFormat(g,{dateStyle:`medium`,timeStyle:`short`});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(z,{title:t?o(t):_(`space.resultsAll`),hint:_(`space.resultsHint`),plain:!0,children:[(0,Q.jsx)(Gt,{filter:n,onFilter:r}),e.runs.length?(0,Q.jsx)(E,{className:`flex flex-col p-1.5`,children:e.runs.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>a(e),className:`flex items-center gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`truncate text-[0.875rem]`,children:t?s.format(new Date(e.doneAt)):o(e.wizardId)}),(0,Q.jsxs)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:[t?null:`${s.format(new Date(e.doneAt))} · `,_(`space.resultCredits`,{n:e.credits})]})]}),e.assets?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[0.75rem] text-ink-3 tabular-nums`,title:_(`space.resultFiles`,{n:e.assets}),children:[(0,Q.jsx)(M,{className:`size-3.5`}),e.assets]}):null,e.mode===`test`?(0,Q.jsx)(k,{children:`Test`}):(0,Q.jsxs)(k,{tone:`live`,children:[`Live v`,e.version]})]},e.id))}):(0,Q.jsx)(E,{children:(0,Q.jsx)(ee,{children:n.q.trim()||n.mode||n.days?_(`space.resultsNone`):_(`space.resultsEmpty`)})})]}),i?(0,Q.jsx)(J,{header:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-[0.875rem]`,children:o(i.wizardId)}),i.mode===`test`?(0,Q.jsx)(k,{children:`Test`}):(0,Q.jsxs)(k,{tone:`live`,children:[`Live v`,i.version]})]}),onClose:()=>a(null),children:(0,Q.jsx)(se,{runId:i.id,compact:!0},i.id)}):null]})}function qt({project:e,save:t}){let[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(e.name),o=d({mutationFn:()=>t({name:i.trim()}),onSuccess:()=>r(!1)});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(D,{label:_(`project.rename`),onClick:()=>{a(e.name),r(!0)},children:(0,Q.jsx)(ce,{className:`size-4`})}),(0,Q.jsx)(w,{open:n,onClose:()=>r(!1),title:_(`project.rename`),children:(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),i.trim()&&o.mutate()},children:[(0,Q.jsx)(A,{"data-autofocus":!0,value:i,maxLength:80,onChange:e=>a(e.target.value)}),o.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:o.error.message}):null,(0,Q.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,Q.jsx)(j,{variant:`ghost`,onClick:()=>r(!1),children:_(`common.cancel`)}),(0,Q.jsx)(j,{type:`submit`,busy:o.isPending,disabled:!i.trim(),children:_(`settings.save`)})]})]})})]})}function Jt({project:e}){let t=r();return(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(U,{}),e.readOnly?null:(0,Q.jsx)(qt,{project:e,save:async n=>{await f.patch(`/api/studio/projects/${e.id}`,n),await t.invalidateQueries({queryKey:[`projects`]})}})]})}function Yt(e){let t=e.join(` `),[n,r]=(0,Z.useState)(e[0]);return(0,Z.useEffect)(()=>{let e=t.split(` `),n=0,i=()=>{n=0;let t=Pe(),i=t.scrollTop>0&&t.clientHeight+t.scrollTop>=t.scrollHeight-4,a=(t===document.documentElement?0:t.getBoundingClientRect().top)+Math.max(120,t.clientHeight/3),o=e[0];for(let t of e){let e=document.getElementById(t)?.getBoundingClientRect().top;e!==void 0&&e<=a&&(o=t)}r(i?e.at(-1):o)},a=()=>{n||=requestAnimationFrame(i)};return i(),window.addEventListener(`scroll`,a,{passive:!0,capture:!0}),window.addEventListener(`resize`,a),()=>{cancelAnimationFrame(n),window.removeEventListener(`scroll`,a,{capture:!0}),window.removeEventListener(`resize`,a)}},[t]),n}function Xt(e,t){let n=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;document.getElementById(e)?.scrollIntoView({block:`start`,behavior:t&&!n?`smooth`:`auto`})}function $({groups:e,current:t,onPick:n}){return e.map(e=>{let r=e.sections.map(e=>(0,Q.jsx)(X,{icon:e.icon??l,label:e.label,selected:e.id===t,onPick:()=>n(e.id)},e.id));return e.label?(0,Q.jsx)(Ke,{label:e.label,children:r},e.plugin):(0,Q.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:r},`own`)})}function Zt(){let{group:e}=ie(),[t,n]=ne(),r=re(),i=ae(),{hash:o}=i,{project:s,loading:c}=Ne(),l=Me(),u=Ve(),d=Qe(),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(null),[g,y]=(0,Z.useState)(null),x=Ie(e)?e:void 0,te=i.state?.parts===!0,S=He().map(e=>({...e,to:`/space/${e.id}`})),C=S.find(e=>e.id===x),w=t.get(`show`),T=x?w?2:1:0,E=d?Math.min(T,1):x&&g!==x&&!te?1:0,D=Ge(E),O=Ge(T),k=(0,Z.useMemo)(()=>({slot:f,narrow:d,setDetail:h}),[f,d]),A=s?s.brand.name?.trim()||s.name:_(`nav.project`),j=x&&x!==`results`?Be(x,u):[],M=x?Be(x,u).filter(e=>e.plugin):[],oe=Yt([...j,...x===`results`?M:[]].flatMap(e=>e.sections.map(e=>e.id))),N=x===`results`&&w&&w!==`all`?w:null,[se,ce]=(0,Z.useState)(Ut),P=Wt(x===`results`?s?.id:void 0,N,se),F=P.data?.wizards.find(e=>e.id===N)?.title,I=x===`data`&&w&&w!==`all`||x===`knowledge`&&w&&/^[ptfcvs]:/.test(w)?w:null,L=I?.startsWith(`s:`)?u.spaceSections.find(e=>e.id===I.slice(2)):void 0,B=x===`knowledge`&&I&&/^[ptf]:/.test(I)?I:null,V=pe(x===`data`?s?.id:void 0),H=ye(x===`knowledge`?s?.id:void 0),U=we(I?.startsWith(`v:`)?I.slice(2):``),W=H.data?.categories.find(e=>e.id===(I?.startsWith(`c:`)?I.slice(2):U.data?.category.id)),ue=x===`knowledge`?L?L.label():I?.startsWith(`v:`)?U.data&&`${U.data.category.name}: ${U.data.value}`:I?.startsWith(`c:`)?W?.name:H.data?.items.find(e=>e.key===I)?.title:V.data?Se(V.data).flatMap(e=>e.items).find(e=>e.key===I)?.title:void 0;Fe([{label:_(`nav.project`),to:`/space`},...C?[{label:C.label,to:`/space/${C.id}`}]:[],...C&&(m??F??ue)?[{label:m??F??ue}]:[]]);let G=x===`results`||x===`data`||I?o.slice(1):w||o.slice(1),K=(0,Z.useRef)(``);if((0,Z.useEffect)(()=>{let e=`${x}#${G}`;G&&K.current!==e&&document.getElementById(G)&&(K.current=e,requestAnimationFrame(()=>Xt(G,!1)))},[x,G,s?.id,u.spaceSections]),!x){let t=o.slice(1),n=t?Re(t,u):null;if(n===`knowledge`&&u.spaceSections.some(e=>e.id===t))return(0,Q.jsx)(v,{to:`/space/knowledge?show=s:${t}`,replace:!0});if(n)return(0,Q.jsx)(v,{to:d?`/space/${n}?show=${t}`:{pathname:`/space/${n}`,hash:t},replace:!0});if(t&&u.status!==`ready`)return null;if(e!==void 0||!d)return(0,Q.jsx)(v,{to:`/space/info`,replace:!0,state:{parts:!0}})}if(x===`knowledge`&&!w&&u.spaceSections.some(e=>e.id===o.slice(1)))return(0,Q.jsx)(v,{to:`/space/knowledge?show=s:${o.slice(1)}`,replace:!0});let q=e=>{if(d){r({search:`?show=${e}`});return}K.current=`${x}#${e}`,Xt(e,!0),r({search:``,hash:e},{replace:!0})},J=e=>d?n({show:e}):n(e===`all`?{}:{show:e},{replace:!0}),Te=e=>e.flatMap(e=>e.sections).map(e=>u.spaceSections.find(t=>t.id===e.id)).filter(e=>e!==void 0).map(e=>(0,Q.jsx)(R,{id:e.id,children:(0,Q.jsx)(z,{title:e.label(),hint:e.hint?.(),plain:!0,children:(0,Q.jsx)(Ue,{of:e,children:(0,Q.jsx)(e.component,{})})})},e.serial)),Ee=d?void 0:oe;return(0,Q.jsx)(Je.Provider,{value:k,children:(0,Q.jsx)(`div`,{className:`animate-rise`,children:(0,Q.jsxs)(`div`,{className:`grid gap-6 md:grid-cols-[13.5rem_minmax(0,1fr)] md:gap-8 lg:grid-cols-[15rem_minmax(0,1fr)] lg:gap-10`,children:[(0,Q.jsxs)(`aside`,{className:b(`min-w-0 md:sticky md:top-6 md:self-start`,d&&T===2&&`hidden`,d&&O===`back`&&We(`back`)),children:[(0,Q.jsx)(qe,{title:A,open:E===1?C??null:null,onBack:()=>d?r(`/space`):y(x??null)}),(0,Q.jsx)(`div`,{className:b(We(D)),children:E===0?(0,Q.jsx)(Ye,{entries:S,current:d?void 0:C,onPick:()=>y(null)}):(0,Q.jsx)(`div`,{ref:p})},E)]}),x?(0,Q.jsxs)(`div`,{className:b(`min-w-0`,d&&T<2&&`hidden`,d&&O===`deeper`&&We(`deeper`)),children:[d?(0,Q.jsx)(`div`,{className:`mb-3`,children:(0,Q.jsx)(Ze,{label:C?.label??A,onBack:()=>r(`/space/${x}`)})}):null,l&&s?(0,Q.jsx)(`div`,{className:`mb-6`,children:(0,Q.jsx)(Jt,{project:s})}):null,x===`results`?(0,Q.jsxs)(Xe,{children:[(0,Q.jsxs)(`ul`,{className:`flex flex-col gap-0.5`,children:[(0,Q.jsx)(X,{icon:nt,label:_(`space.resultsAll`),selected:!d&&!N,onPick:()=>J(`all`)}),P.data?.wizards.filter(e=>e.results||e.id===N).map(e=>(0,Q.jsx)(X,{icon:a,label:e.title,badge:e.results?(0,Q.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:e.results}):null,selected:!d&&e.id===N,onPick:()=>J(e.id)},e.id))]}),(0,Q.jsx)($,{groups:M,current:Ee,onPick:q})]}):x===`data`?(0,Q.jsxs)(Xe,{children:[(0,Q.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,Q.jsx)(X,{icon:le,label:_(`data.all`),selected:!d&&!I,onPick:()=>J(`all`)})}),V.data?Se(V.data).map(e=>(0,Q.jsx)(Ke,{label:e.label,children:e.items.map(e=>(0,Q.jsx)(X,{icon:fe[e.kind],label:e.title,selected:!d&&e.key===I,onPick:()=>J(e.key)},e.key))},e.key)):null,(0,Q.jsx)($,{groups:M,current:Ee,onPick:q})]}):x===`knowledge`?(0,Q.jsxs)(Xe,{children:[(0,Q.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,Q.jsx)(X,{icon:le,label:_(`know.all`),selected:!(d||I),onPick:()=>J(`all`)})}),H.data?.categories.length?(0,Q.jsx)(Ke,{label:_(`know.categories`),children:H.data.categories.map(e=>(0,Q.jsx)(X,{icon:ge[e.type],label:e.name,badge:(0,Q.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:e.proposed?`·`:e.count}),selected:!d&&(I===`c:${e.id}`||U.data?.category.id===e.id),onPick:()=>J(`c:${e.id}`)},e.id))}):null,(0,Q.jsx)($,{groups:M,current:d?void 0:L?.id,onPick:e=>J(`s:${e}`)})]}):(0,Q.jsx)(Xe,{children:(0,Q.jsx)($,{groups:j,current:Ee,onPick:q})}),s&&(x===`info`||x===`knowledge`)?(0,Q.jsxs)(Ht,{project:s,group:x,docked:x===`knowledge`&&!!I&&!L,children:[x===`knowledge`?B?B.startsWith(`p:`)?(0,Q.jsx)(ve,{pageId:B.slice(2),onGone:()=>J(`all`),onOpen:J},B):B.startsWith(`t:`)?(0,Q.jsx)(_e,{tableId:B.slice(2),onGone:()=>J(`all`)},B):(0,Q.jsx)(xt,{projectId:s.id,fileId:B.slice(2),readOnly:s.readOnly,onGone:()=>J(`all`)},B):H.data?L?(0,Q.jsx)(z,{title:L.label(),hint:L.hint?.(),plain:!0,children:(0,Q.jsx)(Ue,{of:L,children:(0,Q.jsx)(L.component,{})})},I):I?.startsWith(`c:`)?W?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(he,{projectId:s.id,category:W,readOnly:s.readOnly,onOpen:J,onGone:()=>J(`all`)}),W.type===`choice`?null:(0,Q.jsx)(Ce,{projectId:s.id,category:W,categories:H.data.categories,onOpen:J})]},I):null:I?.startsWith(`v:`)?U.data?(0,Q.jsx)(de,{value:U.data,readOnly:s.readOnly,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[U.data.items.length?(0,Q.jsx)(`div`,{className:`flex flex-col rounded-xl bg-card p-1.5 shadow-soft ring-1 ring-border-soft`,children:U.data.items.map(e=>(0,Q.jsx)(me,{item:e,categories:H.data.categories.filter(e=>e.id!==U.data?.category.id),onOpen:J},e.key))}):null,U.data.rows.map(e=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>J(`t:${e.tableId}`),className:`px-1 text-left text-[0.8125rem] text-ink-3 hover:text-ink`,children:_(`know.tocRows`,{n:e.count,table:e.title})},e.tableId))]})},I):null:(0,Q.jsx)(R,{id:`documents`,children:(0,Q.jsx)(xe,{projectId:s.id,data:H.data,readOnly:s.readOnly,onOpen:J})}):null:null,x===`info`?Te(M):null]},s.id):null,s&&x===`data`?(0,Q.jsx)(`div`,{className:`flex flex-col gap-9 pb-20`,children:I?.startsWith(`t:`)?(0,Q.jsx)(_e,{tableId:I.slice(2),onGone:()=>J(`all`)},I):I?.startsWith(`p:`)?(0,Q.jsx)(ve,{pageId:I.slice(2),onGone:()=>J(`all`)},I):(0,Q.jsxs)(Q.Fragment,{children:[V.data?(0,Q.jsx)(be,{projectId:s.id,data:V.data,readOnly:s.readOnly,onOpen:J}):null,Te(M)]})}):null,s&&x===`results`?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[P.data?(0,Q.jsx)(Kt,{data:P.data,wizardId:N,filter:se,onFilter:ce}):null,P.isError?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:P.error.message}):null,Te(M)]}):null,s||c?null:(0,Q.jsx)(ee,{children:_(`settings.noProject`)})]}):null]})})})}export{Zt as ProjectPage};
@@ -0,0 +1 @@
1
+ import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{r}from"./logo-C80CWCDM.js";import{A as i,C as a,D as o,I as s,J as c,P as l,Q as u,_ as d,f,nt as p,o as m,rt as h,t as g,w as _}from"./ui-D92EkdEB.js";import{t as ee}from"./RunnerView-CLrGb-oq.js";import{t as v}from"./arrow-right-Dpp_mpHe.js";import{a as y,i as b,n as x,o as S,r as C,s as w,t as T}from"./ChatView-DBl0iRMg.js";import{E,N as te,O as D,k as O}from"./definition-CQGiBQ4X.js";import{A as ne,E as k,k as A}from"./index-CIO9W4pe.js";var j={name:`bookmark`,size:24,node:[[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}]]};j.node;var M=c(j),N={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`}]]};N.node;var P=c(N),F={name:`square-plus`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}],[`path`,{d:`M12 8v8`,key:`napkw2`}]],aliases:[`plus-square`]};F.node;var I=c(F),L=e(t(),1);function R(){if(window.self===window.top)return null;let e=new URLSearchParams(window.location.search).get(`embed`);return e===`inline`||e===`modal`||e===`popout`?e:null}var z=R(),B=(e,t={})=>window.parent.postMessage({type:`engenty-wizard:${e}`,...t},`*`),re=()=>B(`close`);function ie(e){(0,L.useEffect)(()=>{if(z===`inline`&&!e){let e=document.documentElement;document.getElementById(`root`)?.style.setProperty(`min-height`,`0`),e.style.overflow=`hidden`;let t=new ResizeObserver(()=>B(`height`,{height:Math.ceil(e.getBoundingClientRect().height)}));return t.observe(e),()=>t.disconnect()}if(z===`modal`||z===`popout`){let e=e=>{e.key===`Escape`&&!document.querySelector(`dialog[open]`)&&B(`close`)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}},[e])}var V=e(n(),1);function H(e){(0,L.useEffect)(()=>{if(!e)return;let t=document.documentElement;return t.style.setProperty(`--raw-primary`,e),()=>{t.style.removeProperty(`--raw-primary`)}},[e])}function U(e,t){(0,L.useEffect)(()=>{if(!e||!t)return;let n=i(`/api/public/wizards/${e}`),r=[{rel:`manifest`,href:`${n}/manifest.webmanifest`},{rel:`apple-touch-icon`,href:`${n}/icons/apple-touch-icon.png`},{rel:`icon`,href:`${n}/icons/favicon.png`,type:`image/png`}].flatMap(({rel:e,href:t,type:n})=>{let r=document.querySelector(`link[rel="${e}"]`);if(!r)return[];let i={href:r.getAttribute(`href`),type:r.getAttribute(`type`)};return r.setAttribute(`href`,t),n&&r.setAttribute(`type`,n),[{link:r,before:i}]}),a=document.createElement(`meta`);return a.name=`apple-mobile-web-app-title`,a.content=t,document.head.appendChild(a),()=>{for(let{link:e,before:t}of r)for(let[n,r]of Object.entries(t))r===null?e.removeAttribute(n):e.setAttribute(n,r);a.remove()}},[e,t])}var W=/iPhone|iPad|iPod/.test(navigator.userAgent)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1,G=W||/Android/.test(navigator.userAgent);function K(){let[e,t]=(0,L.useState)(()=>window.wizardInstall??null),[n,r]=(0,L.useState)(!1);if((0,L.useEffect)(()=>{let e=()=>t(window.wizardInstall??null);return window.addEventListener(`wizard-install`,e),()=>window.removeEventListener(`wizard-install`,e)},[]),window.matchMedia(`(display-mode: standalone)`).matches||navigator.standalone===!0||G&&!e&&!W)return null;let i=/Mac/.test(navigator.platform),a=l(G?`install.ios`:i?`install.bookmark.mac`:`install.bookmark.pc`);return(0,V.jsxs)(`div`,{className:`mt-6 flex flex-col items-center gap-2 text-[0.8125rem] text-ink-3`,children:[(0,V.jsxs)(`button`,{type:`button`,onClick:()=>{G&&e?(e.prompt(),window.wizardInstall=null,t(null)):r(e=>!e)},className:`inline-flex items-center gap-1.5 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:[G?(0,V.jsx)(I,{className:`size-4`}):(0,V.jsx)(M,{className:`size-4`}),l(G?`install.add`:`install.bookmark`)]}),n?(0,V.jsx)(`p`,{className:`max-w-xs leading-relaxed`,children:a}):null]})}function q({brand:e,toggle:t=!0}){return(0,V.jsx)(`header`,{className:`safe-top`,children:(0,V.jsxs)(`div`,{className:`relative flex h-14 items-center justify-center px-5`,children:[e.logoUrl?(0,V.jsx)(`img`,{src:i(e.logoUrl),alt:e.name,className:`h-7 max-w-[160px] object-contain`}):e.name?(0,V.jsx)(`span`,{className:`max-w-[60%] truncate font-display font-semibold text-[0.9375rem] text-ink-2 tracking-tight`,children:e.name}):null,t?(0,V.jsx)(`div`,{className:`absolute right-3`,children:(0,V.jsx)(O,{})}):null]})})}function J({siteKey:e,onToken:t}){let n=(0,L.useRef)(null);return(0,L.useEffect)(()=>{let r=()=>{n.current&&window.turnstile&&!n.current.childElementCount&&window.turnstile.render(n.current,{sitekey:e,callback:t,appearance:`interaction-only`})};if(window.turnstile){r();return}let i=document.createElement(`script`);i.src=`https://challenges.cloudflare.com/turnstile/v0/api.js`,i.async=!0,i.onload=r,document.head.appendChild(i)},[e,t]),(0,V.jsx)(`div`,{ref:n,className:`mt-4 flex justify-center`})}function ae({token:e}){return!/iPhone|iPad|iPod|Android/.test(navigator.userAgent)||k||z?null:(0,V.jsxs)(`a`,{href:A(`${window.location.origin}${o}/w/${e}`),className:`mt-3 inline-flex items-center gap-1.5 text-[0.8125rem] text-ink-3 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:[(0,V.jsx)(P,{className:`size-4`}),` `,l(`install.app`)]})}var Y=e=>`wz.run.${e}`,X=k&&new URLSearchParams(window.location.search).get(`start`)===`1`,Z=z===`inline`?`min-h-80`:`min-h-dvh`;function Q(e,t){let n=p(),[r,i]=(0,L.useState)(!1),[o,s]=(0,L.useState)(null),[c,l]=(0,L.useState)(null),u=(()=>{try{return localStorage.getItem(Y(e.token))}catch{return null}})();return{busy:r,error:o,captcha:c,setCaptcha:l,start:async()=>{i(!0),s(null);try{let{runId:r}=await a.post(`/api/public/wizards/${e.token}/runs`,{turnstileToken:c??void 0,embedded:z!==null});try{localStorage.setItem(Y(e.token),r)}catch{}n(`${t}/${r}`,{replace:X})}catch(e){s(e.message),i(!1)}},resume:u?()=>n(`${t}/${u}`):null}}function oe({wizard:e}){let{busy:t,error:n,captcha:r,setCaptcha:i,start:a,resume:o}=Q(e,`/w/${e.token}`),s=X&&e.available&&!e.turnstileSiteKey,c=(0,L.useRef)(!1);return(0,L.useEffect)(()=>{s&&!c.current&&(c.current=!0,a())},[s]),s&&!n?(0,V.jsx)(`div`,{className:`flex min-h-[60dvh] items-center justify-center text-ink-4`,children:(0,V.jsx)(f,{})}):(0,V.jsxs)(`div`,{className:`mx-auto flex max-w-lg animate-rise flex-col items-center px-6 pt-6 pb-12 text-center sm:pt-16 sm:pb-16`,children:[(0,V.jsx)(D,{kind:e.avatar,size:190,fluffy:!0}),(0,V.jsx)(`h1`,{className:`mt-2 text-balance font-display font-semibold text-[1.875rem] leading-[1.1] tracking-tight sm:text-[2.125rem]`,children:e.title}),e.description?(0,V.jsx)(`p`,{className:`mt-3 text-[1rem] text-ink-2 leading-relaxed`,children:e.description}):null,e.available?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(g,{size:`lg`,className:`mt-10 min-w-48`,busy:t,disabled:!!e.turnstileSiteKey&&!r,onClick:a,children:[l(`run.start`),` `,(0,V.jsx)(v,{className:`size-4`})]}),e.turnstileSiteKey?(0,V.jsx)(J,{siteKey:e.turnstileSiteKey,onToken:i}):null,o?(0,V.jsx)(`button`,{type:`button`,onClick:o,className:`mt-4 text-[0.875rem] text-ink-3 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:l(`run.resume`)}):null,(0,V.jsx)($,{wizard:e,current:`steps`}),z||k?null:(0,V.jsx)(K,{}),(0,V.jsx)(ae,{token:e.token})]}):(0,V.jsx)(`p`,{className:`mt-10 rounded-xl bg-paper-2 px-5 py-4 text-[0.9375rem] text-ink-2`,children:e.unavailableReason??l(`run.unavailable`)}),n?(0,V.jsx)(`p`,{className:`mt-4 text-[0.875rem] text-rose`,children:n}):null]})}function $({wizard:e,current:t}){let n=e.runners.filter(e=>e.id!==t&&e.kind===`page`&&e.url);return n.length?(0,V.jsx)(`p`,{className:`mt-4 flex flex-wrap justify-center gap-x-4 text-[0.875rem] text-ink-3`,children:n.map(e=>(0,V.jsx)(`a`,{href:e.url??void 0,className:`underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:l(`run.orAs`,{label:e.label})},e.id))}):null}function se({wizard:e}){let t=w();return(0,V.jsx)(`header`,{className:`safe-top shrink-0 border-border-soft border-b`,children:(0,V.jsxs)(`div`,{className:`mx-auto flex h-16 w-full max-w-[760px] items-center gap-3 pr-2 pl-4 sm:pr-4 sm:pl-6`,children:[(0,V.jsx)(`span`,{className:d(t?.speaking&&`animate-breathe`),children:(0,V.jsx)(D,{kind:e.avatar,size:38})}),(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,V.jsx)(`div`,{className:`truncate font-display font-semibold text-[1rem] leading-tight tracking-tight`,children:e.title}),e.brand.name?(0,V.jsx)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:e.brand.name}):null]}),e.brand.logoUrl&&z!==`popout`?(0,V.jsx)(`img`,{src:i(e.brand.logoUrl),alt:e.brand.name,className:`h-6 max-w-[120px] object-contain max-sm:hidden`}):null,z?null:(0,V.jsx)(O,{}),z===`popout`?(0,V.jsx)(m,{label:l(`common.close`),onClick:re,children:(0,V.jsx)(s,{className:`size-5`})}):null]})})}function ce({door:e,wizard:t,header:n,footer:r}){let{busy:i,error:a,captcha:o,setCaptcha:s,start:c,resume:u}=Q(t,`/w/${t.token}/${e}`),d=[{key:`hello`,who:`bot`,node:t.description||t.title}];return e!==`chat`&&d.push({key:e,who:`bot`,node:l(e===`video`?`video.hint`:`talk.joinHint`)}),t.available||d.push({key:`unavailable`,who:`bot`,node:t.unavailableReason??l(`run.unavailable`)}),a&&d.push({key:`error`,who:`bot`,node:a,tone:`error`}),t.available&&d.push(S(`start`,(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(b,{primary:!0,busy:i,disabled:!!t.turnstileSiteKey&&!o,onClick:()=>void c(),children:[l(`run.start`),` `,(0,V.jsx)(v,{className:`size-4`})]}),u?(0,V.jsx)(b,{onClick:u,children:l(`run.resume`)}):null,t.turnstileSiteKey?(0,V.jsx)(J,{siteKey:t.turnstileSiteKey,onToken:s}):null]}))),(0,V.jsxs)(x,{header:n,footer:r,children:[(0,V.jsx)(y,{avatar:t.avatar,lines:d}),(0,V.jsx)(C,{})]})}function le({className:e}){return(0,V.jsx)(`footer`,{className:d(`text-center text-ink-4`,e),children:(0,V.jsx)(`a`,{href:`${o}/`,target:z?`_blank`:void 0,rel:`noreferrer`,className:`inline-block hover:text-ink-2`,children:l(`run.madeWith`).replace(`engenty wizards`,E.name)})})}function ue({chat:e=!1,steps:t=!1,talk:n=!1,video:i=!1}){let{token:s,runId:c}=h(),m=p(),v=r({queryKey:[`public`,s],queryFn:()=>a.get(`/api/public/wizards/${s}`),retry:(e,t)=>_(t)&&e<3}),y=v.data?.runners??[],b=!v.data||y.some(e=>e.id===`talk`),x=!v.data||y.some(e=>e.id===`video`),S=!v.data||y.some(e=>e.id===`chat`)||n&&b||i&&x,C=y[0]?.id,w=e||z===`popout`||!t&&!c&&S&&(C===`chat`||C===`talk`||C===`video`),O=i&&x||!t&&!e&&!n&&C===`video`,A=!O&&(n&&b||!t&&!e&&C===`talk`),j=O?`video`:A?`talk`:`chat`;if(H(v.data?.brand.accent),te(v.data?.avatar),U(s,v.data?.title),ie(w),(0,L.useEffect)(()=>{v.data&&(document.title=v.data.title)},[v.data]),(0,L.useEffect)(()=>{s&&c&&ne(`run`,{token:s,runId:c})},[s,c]),v.isLoading)return(0,V.jsx)(`div`,{className:d(`flex items-center justify-center text-ink-4`,Z),children:(0,V.jsx)(f,{})});if(e&&v.data&&!S||n&&v.data&&!b||i&&v.data&&!x)return(0,V.jsx)(u,{to:`/w/${s}`,replace:!0});if(!v.data){let e=_(v.error);return(0,V.jsxs)(`div`,{className:d(`flex flex-col items-center justify-center gap-4 px-6 text-center`,Z),children:[(0,V.jsx)(D,{kind:`pebble`,size:80}),(0,V.jsx)(`p`,{className:`max-w-xs text-ink-3`,children:l(e?`common.offline`:`run.notFound`)}),e?(0,V.jsx)(g,{variant:`secondary`,onClick:()=>void v.refetch(),children:l(`common.retry`)}):null]})}if(w){let e=(0,V.jsx)(se,{wizard:v.data}),t=k?(0,V.jsx)(`div`,{className:`safe-bottom`}):(0,V.jsx)(le,{className:`pb-[max(0.375rem,env(safe-area-inset-bottom))] text-[0.6875rem]`});return(0,V.jsx)(`div`,{className:`flex h-dvh flex-col`,children:c?(0,V.jsx)(T,{runId:c,talk:A,call:O?`video`:A?`audio`:!1,onRestart:()=>m(`/w/${s}/${j}`),header:O||A?void 0:e,footer:t}):(0,V.jsx)(ce,{wizard:v.data,header:e,footer:t,door:j})})}return(0,V.jsxs)(`div`,{className:d(`flex flex-col`,Z),children:[z===`inline`||k?null:(0,V.jsx)(q,{brand:v.data.brand,toggle:!z}),(0,V.jsx)(`div`,{className:`flex-1`,children:c?(0,V.jsx)(ee,{runId:c,onRestart:()=>m(`/w/${s}`)}):(0,V.jsx)(oe,{wizard:v.data})}),k?(0,V.jsx)(`div`,{className:`safe-bottom`}):(0,V.jsx)(`footer`,{className:`safe-bottom pt-6 text-center text-[0.75rem] text-ink-4`,children:(0,V.jsx)(`a`,{href:`${o}/`,target:z?`_blank`:void 0,rel:`noreferrer`,className:`inline-block py-3.5 hover:text-ink-2`,children:l(`run.madeWith`).replace(`engenty wizards`,E.name)})})]})}export{q as BrandHeader,ue as PublicRunner,H as useBrandAccent};
@@ -0,0 +1 @@
1
+ import{a as e,t}from"./jsx-runtime-D3jfb0Ew.js";import{P as n}from"./ui-D92EkdEB.js";import{t as r}from"./lock-C_WlXIQ0.js";var i=e(t(),1);function a(e){return n(e.origin===`local`?`readonly.project`:`readonly.server`)}function o({children:e}){return(0,i.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl bg-paper-2 px-4 py-3 text-[0.875rem] text-ink-2 leading-relaxed`,children:[(0,i.jsx)(r,{className:`mt-0.5 size-4 shrink-0 text-ink-3`}),(0,i.jsx)(`p`,{className:`min-w-0`,children:e})]})}export{a as n,o as t};
@@ -0,0 +1,4 @@
1
+ import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{O as r,r as i}from"./logo-C80CWCDM.js";import{l as a,u as o}from"./Marketplace-BWhUJ4UX.js";import{t as s}from"./useMutation-DKcIz55V.js";import{C as c,G as l,H as u,I as d,J as f,M as p,P as m,R as h,S as g,W as _,_ as v,a as y,c as b,d as x,f as S,g as C,i as w,m as T,n as E,o as D,r as O,s as k,t as A,u as j,z as M}from"./ui-D92EkdEB.js";import{b as N,g as P,h as ee,p as te,v as F,y as ne}from"./HomePage-BG5OZJkv.js";import{a as I}from"./volume-2-0SfkvOho.js";import{t as L}from"./trash-DU-hZpV0.js";import"./definition-CQGiBQ4X.js";import{t as re}from"./refresh-cw-Cli5WGnW.js";import{t as ie}from"./upload-DMq5N6Fw.js";import{B as ae,m as oe}from"./index-CIO9W4pe.js";var se={name:`calendar`,size:24,node:[[`path`,{d:`M8 2v3`,key:`1ioesn`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}],[`path`,{d:`M3 9h18`,key:`1pudct`}]]};se.node;var ce=f(se),le={name:`files`,size:24,node:[[`path`,{d:`M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8`,key:`14sh0y`}],[`path`,{d:`M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z`,key:`1970lx`}],[`path`,{d:`M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1`,key:`l4dndm`}]]};le.node;var ue=f(le),de={name:`hash`,size:24,node:[[`line`,{x1:`4`,x2:`20`,y1:`9`,y2:`9`,key:`4lhtct`}],[`line`,{x1:`4`,x2:`20`,y1:`15`,y2:`15`,key:`vyu0kd`}],[`line`,{x1:`10`,x2:`8`,y1:`3`,y2:`21`,key:`1ggp8o`}],[`line`,{x1:`16`,x2:`14`,y1:`3`,y2:`21`,key:`weycgp`}]]};de.node;var fe=f(de),R={name:`list-ordered`,size:24,node:[[`path`,{d:`M11 5h10`,key:`1cz7ny`}],[`path`,{d:`M11 12h10`,key:`1438ji`}],[`path`,{d:`M11 19h10`,key:`11t30w`}],[`path`,{d:`M4 4h1v5`,key:`10yrso`}],[`path`,{d:`M4 9h2`,key:`r1h2o0`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`,key:`xtkcd5`}]]};R.node;var pe=f(R),z={name:`messages-square`,size:24,node:[[`path`,{d:`M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z`,key:`1n2ejm`}],[`path`,{d:`M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1`,key:`1qfcsi`}]]};z.node;var B=f(z),V={name:`minimize-2`,size:24,node:[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]};V.node;var me=f(V),he={name:`tags`,size:24,node:[[`path`,{d:`M13.172 2a2 2 0 0 1 1.414.586l6.71 6.71a2.4 2.4 0 0 1 0 3.408l-4.592 4.592a2.4 2.4 0 0 1-3.408 0l-6.71-6.71A2 2 0 0 1 6 9.172V3a1 1 0 0 1 1-1z`,key:`16rjxf`}],[`path`,{d:`M2 7v6.172a2 2 0 0 0 .586 1.414l6.71 6.71a2.4 2.4 0 0 0 3.191.193`,key:`178nd4`}],[`circle`,{cx:`10.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`12ikhr`}]]};he.node;var ge=f(he),_e={name:`toggle-left`,size:24,node:[[`circle`,{cx:`9`,cy:`12`,r:`3`,key:`u3jwor`}],[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`7`,key:`g7kal2`}]]};_e.node;var H=f(_e),U=e(t(),1),W=e(n(),1),G={choice:ge,date:ce,number:fe,text:a,boolean:H},K=e=>[`knowledge`,e];function ve(e){return e===1?m(`know.item`):m(`know.items`,{n:e})}function q(e,t){if(e.type===`boolean`||typeof t==`boolean`)return m(t?`know.yes`:`know.no`);if(e.type===`date`&&typeof t==`string`){let[e,n]=t.split(` `),r=new Date(`${e}T00:00:00`),i=Number.isNaN(r.getTime())?t:r.toLocaleDateString(p,{day:`2-digit`,month:`2-digit`,year:`numeric`});return n?`${i} ${n}`:i}return e.type===`number`&&typeof t==`number`?`${t.toLocaleString(p)}${e.unit?` ${e.unit}`:``}`:String(t)}function ye(e,t){return e.flatMap(e=>{let n=t.find(t=>t.categoryId===e.id);return n?e.type===`boolean`?n.values[0]===!0?[e.name]:[]:[n.values.map(t=>q(e,t)).join(`, `)]:[]}).join(` · `)}function be({trigger:e,open:t,onOpen:n,children:r}){let i=(0,U.useRef)(null);return(0,U.useEffect)(()=>{if(!t)return;let e=e=>{i.current?.contains(e.target)||n(!1)},r=e=>e.key===`Escape`&&n(!1);return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,r),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,r)}},[t,n]),(0,W.jsxs)(`div`,{ref:i,className:`relative inline-flex`,children:[e,t?(0,W.jsx)(`div`,{className:`absolute top-full left-0 z-30 mt-1.5 w-72 max-w-[calc(100vw-32px)] rounded-xl bg-card p-3 shadow-overlay ring-1 ring-border-soft`,children:r}):null]})}function xe({category:e,current:t,onSave:n}){let[r,i]=(0,U.useState)(t[0]===void 0?``:String(t[0]));if(e.type===`choice`){let a=t.map(String);return(0,W.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[e.values.length?(0,W.jsx)(j,{multi:!0,value:a,options:e.values.map(e=>e.value),onChange:t=>n(e.multiple?t:t.filter(e=>!a.includes(e)).slice(0,1))}):null,(0,W.jsxs)(`form`,{className:`flex gap-2`,onSubmit:t=>{t.preventDefault(),r.trim()&&n(e.multiple?[...a,r.trim()]:[r.trim()])},children:[(0,W.jsx)(k,{"data-autofocus":!0,value:a.includes(r)?``:r,placeholder:m(`know.addValue`),onChange:e=>i(e.target.value),className:`h-9`}),(0,W.jsx)(D,{label:m(`know.addValue`),type:`submit`,children:(0,W.jsx)(h,{className:`size-4`})})]})]})}return e.type===`boolean`?(0,W.jsx)(j,{value:t[0]===!0?m(`know.yes`):t[0]===!1?m(`know.no`):``,options:[m(`know.yes`),m(`know.no`)],onChange:e=>n([e===m(`know.yes`)])}):(0,W.jsxs)(`form`,{className:`flex gap-2`,onSubmit:t=>{t.preventDefault(),n(r.trim()?[e.type===`number`?Number(r.replace(`,`,`.`)):r.trim()]:[])},children:[(0,W.jsx)(k,{"data-autofocus":!0,type:e.type===`date`?`date`:e.type===`number`?`number`:`text`,step:`any`,value:e.type===`date`?r.slice(0,10):r,onChange:e=>i(e.target.value),className:`h-9`}),(0,W.jsx)(A,{type:`submit`,size:`sm`,children:`OK`})]})}function Se({projectId:e,itemKey:t,has:n,categories:i,readOnly:a}){let o=r(),[l,u]=(0,U.useState)(null),[f,p]=(0,U.useState)(n);(0,U.useEffect)(()=>p(n),[n]);let g=s({mutationFn:({categoryId:n,next:r})=>c.put(`/api/studio/projects/${e}/items/${t}/categories/${n}`,{values:r}),onSuccess:()=>o.invalidateQueries({queryKey:K(e)})}),_=i.filter(e=>!(e.proposed||e.tableId)),v=(e,t)=>{p(n=>[...n.filter(t=>t.categoryId!==e.id),...t.length?[{categoryId:e.id,values:t,by:`person`}]:[]]),g.mutate({categoryId:e.id,next:t}),u(null)},y=_.filter(e=>f.some(t=>t.categoryId===e.id)),b=_.filter(e=>!f.some(t=>t.categoryId===e.id));return _.length?(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[y.map(e=>{let t=f.find(t=>t.categoryId===e.id),n=G[e.type],r=(0,W.jsxs)(`button`,{type:`button`,disabled:a,title:`${e.name} · ${m(`know.by.${t.by}`)}`,onClick:()=>u(l===e.id?null:e.id),className:`inline-flex h-7 items-center gap-1.5 rounded-full bg-paper-2 px-2.5 text-[0.75rem] text-ink-2 transition hover:bg-paper-3 hover:text-ink disabled:pointer-events-none`,children:[(0,W.jsx)(n,{className:`size-3.5 text-ink-3`}),(0,W.jsx)(`span`,{className:`text-ink-3`,children:e.name}),(0,W.jsx)(`span`,{className:`font-medium`,children:t.values.map(t=>q(e,t)).join(`, `)})]},e.id);return a?(0,W.jsx)(`span`,{children:r},e.id):(0,W.jsxs)(be,{trigger:r,open:l===e.id,onOpen:t=>u(t?e.id:null),children:[(0,W.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,W.jsx)(`span`,{className:`font-medium text-[0.8125rem]`,children:e.name}),(0,W.jsx)(D,{label:m(`know.remove`),onClick:()=>v(e,[]),className:`size-7`,children:(0,W.jsx)(d,{className:`size-3.5`})})]}),(0,W.jsx)(xe,{category:e,current:t.values,onSave:t=>v(e,t)})]},e.id)}),a||!b.length?null:(0,W.jsx)(be,{open:l===`+`,onOpen:e=>u(e?`+`:null),trigger:(0,W.jsxs)(`button`,{type:`button`,onClick:()=>u(l===`+`?null:`+`),className:`inline-flex h-7 items-center gap-1 rounded-full px-2 text-[0.75rem] text-ink-3 ring-1 ring-border-soft transition hover:text-ink hover:ring-border`,children:[(0,W.jsx)(h,{className:`size-3.5`}),` `,m(`know.category`)]}),children:(0,W.jsx)(Ce,{categories:b,onSave:v})})]}):null}function Ce({categories:e,onSave:t}){let[n,r]=(0,U.useState)(e[0]?.id??``),i=e.find(e=>e.id===n);return(0,W.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[(0,W.jsx)(x,{value:n,onChange:r,options:e.map(e=>({value:e.id,label:e.name}))}),i?(0,W.jsx)(xe,{category:i,current:[],onSave:e=>t(i,e)},i.id):null]})}function we({projectId:e,open:t,onClose:n,onMade:i}){let a=r(),[o,l]=(0,U.useState)(``),[u,d]=(0,U.useState)(`choice`),[f,p]=(0,U.useState)(``),[h,g]=(0,U.useState)(!1),[_,v]=(0,U.useState)(!1),[y,S]=(0,U.useState)(``),[E,D]=(0,U.useState)(``),O=s({mutationFn:()=>c.post(`/api/studio/projects/${e}/categories`,{name:o.trim(),type:u,unit:u===`number`&&f.trim()||null,multiple:u===`choice`&&h,ordered:u===`choice`&&_,hint:E.trim()||null,values:u===`choice`?y.split(`
2
+ `).map(e=>e.trim()).filter(Boolean):void 0}),onSuccess:async({id:t})=>{await a.invalidateQueries({queryKey:K(e)}),l(``),S(``),D(``),i(t)}});return(0,W.jsx)(w,{open:t,onClose:n,title:m(`know.newCategory`),children:(0,W.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),o.trim()&&O.mutate()},children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(b,{children:m(`know.name`)}),(0,W.jsx)(k,{"data-autofocus":!0,value:o,maxLength:80,onChange:e=>l(e.target.value)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(b,{children:m(`know.type`)}),(0,W.jsx)(x,{value:u,onChange:e=>d(e),options:[`choice`,`date`,`number`,`text`,`boolean`].map(e=>({value:e,label:m(`know.type.${e}`)}))})]}),u===`number`?(0,W.jsxs)(`div`,{children:[(0,W.jsx)(b,{hint:m(`know.unitHint`),children:m(`know.unit`)}),(0,W.jsx)(k,{value:f,maxLength:20,onChange:e=>p(e.target.value)})]}):null,u===`choice`?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(b,{hint:m(`know.valuesHint`),children:m(`know.values`)}),(0,W.jsx)(C,{minRows:3,value:y,onChange:e=>S(e.target.value)})]}),(0,W.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-[0.875rem]`,children:[m(`know.multiple`),(0,W.jsx)(T,{checked:h,onChange:g})]}),(0,W.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-[0.875rem]`,children:[m(`know.ordered`),(0,W.jsx)(T,{checked:_,onChange:v})]})]}):null,(0,W.jsxs)(`div`,{children:[(0,W.jsx)(b,{hint:m(`know.hintFieldHint`),children:m(`know.hintField`)}),(0,W.jsx)(k,{value:E,maxLength:120,onChange:e=>D(e.target.value)})]}),O.error?(0,W.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:O.error.message}):null,(0,W.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,W.jsx)(A,{variant:`ghost`,onClick:n,children:m(`common.cancel`)}),(0,W.jsx)(A,{type:`submit`,busy:O.isPending,disabled:!o.trim(),children:m(`know.create`)})]})]})})}function Te({projectId:e,category:t,readOnly:n,onOpen:i,onGone:a}){let o=r(),l=()=>o.invalidateQueries({queryKey:K(e)}),[u,d]=(0,U.useState)(``),f=s({mutationFn:e=>e(),onSuccess:l}),p=G[t.type],g=new Map(t.values.map(e=>[e.id,e]));return(0,W.jsxs)(P,{title:t.name,hint:[m(`know.type.${t.type}`),t.unit,t.hint].filter(Boolean).join(` · `),plain:!0,action:n?null:(0,W.jsx)(D,{label:m(`know.deleteCategory`),className:`hover:text-rose`,onClick:()=>confirm(m(`know.confirmCategory`,{name:t.name}))&&f.mutate(async()=>{await c.del(`/api/studio/categories/${t.id}`),a()}),children:(0,W.jsx)(L,{className:`size-4`})}),children:[t.proposed&&!n?(0,W.jsxs)(E,{className:`flex flex-wrap items-center gap-3 p-4`,children:[(0,W.jsx)(O,{tone:`ember`,children:m(`know.proposed`)}),(0,W.jsx)(`span`,{className:`flex-1 text-[0.875rem] text-ink-2`,children:m(`know.proposedHint`)}),(0,W.jsx)(A,{size:`sm`,onClick:()=>f.mutate(()=>c.patch(`/api/studio/categories/${t.id}`,{proposed:!1})),children:m(`know.accept`)})]}):null,t.alike.map(([e,t])=>{let r=g.get(e),i=g.get(t);if(!(r&&i))return null;let[a,o]=r.count<i.count?[r,i]:[i,r];return(0,W.jsxs)(E,{className:`flex flex-wrap items-center gap-3 p-4`,children:[(0,W.jsx)(`span`,{className:`flex-1 text-[0.875rem] text-ink-2`,children:m(`know.alike`,{a:a.value,b:o.value})}),n?null:(0,W.jsx)(A,{size:`sm`,variant:`secondary`,busy:f.isPending,onClick:()=>f.mutate(()=>c.post(`/api/studio/values/${a.id}/merge`,{into:o.id})),children:m(`know.merge`)})]},`${e}:${t}`)}),(0,W.jsxs)(E,{className:`flex flex-col p-1.5`,children:[t.type===`choice`?t.values.length?t.values.map(e=>(0,W.jsxs)(`button`,{type:`button`,onClick:()=>i(`v:${e.id}`),className:`flex items-center gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent`,children:[(0,W.jsx)(p,{className:`size-4 shrink-0 text-ink-3`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.875rem]`,children:e.value}),e.summary?(0,W.jsx)(O,{children:m(`know.summary`)}):null,(0,W.jsx)(`span`,{className:`shrink-0 text-[0.75rem] text-ink-3 tabular-nums`,children:ve(e.count)})]},e.id)):(0,W.jsx)(y,{children:m(`know.empty`)}):(0,W.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2.5 text-[0.875rem]`,children:[(0,W.jsx)(p,{className:`size-4 shrink-0 text-ink-3`}),(0,W.jsx)(`span`,{className:`flex-1 text-ink-2`,children:t.range?m(`know.range`,{min:q(t,t.range.min),max:q(t,t.range.max)}):m(`know.unset`)}),(0,W.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:ve(t.count)})]}),t.type===`choice`&&!n?(0,W.jsxs)(`form`,{className:`flex gap-2 border-border-soft border-t p-2`,onSubmit:e=>{e.preventDefault();let n=u.trim();n&&(d(``),f.mutate(()=>c.post(`/api/studio/categories/${t.id}/values`,{value:n})))},children:[(0,W.jsx)(k,{value:u,placeholder:m(`know.addValue`),onChange:e=>d(e.target.value),className:`h-9`}),(0,W.jsx)(D,{label:m(`know.addValue`),type:`submit`,children:(0,W.jsx)(h,{className:`size-4`})})]}):null]}),f.error?(0,W.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:f.error.message}):null]})}function Ee(e){return i({queryKey:[`knowledge-value`,e],queryFn:()=>c.get(`/api/studio/values/${e}`),enabled:!!e})}function De({value:e,readOnly:t,children:n}){let i=r(),a=s({mutationFn:()=>c.post(`/api/studio/values/${e.id}/summary`),onSuccess:()=>i.invalidateQueries({queryKey:[`knowledge-value`,e.id]})});return(0,W.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[(0,W.jsx)(P,{title:m(`know.summary`),hint:m(`know.summaryHint`),plain:!0,action:t?null:(0,W.jsxs)(A,{variant:`secondary`,size:`sm`,busy:a.isPending,onClick:()=>a.mutate(),children:[e.summary?(0,W.jsx)(re,{className:`size-4`}):null,e.summary?m(`know.summaryAgain`):m(`know.summaryWrite`)]}),children:(0,W.jsxs)(E,{className:`p-4 sm:p-5`,children:[a.isPending?(0,W.jsx)(`div`,{className:`flex h-24 items-center justify-center text-ink-3`,children:(0,W.jsx)(S,{})}):e.summary?(0,W.jsx)(oe,{text:e.summary,className:`text-[0.875rem]`}):(0,W.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:m(`know.summaryEmpty`)}),a.error?(0,W.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:a.error.message}):null]})}),(0,W.jsx)(P,{title:m(`know.toc`),plain:!0,children:n})]})}function Oe(e){return i({queryKey:[`knowledge`,e],queryFn:()=>c.get(`/api/studio/projects/${e}/knowledge`),enabled:!!e,refetchInterval:e=>e.state.data?.items.some(e=>e.status===`pending`)?2e3:!1})}function ke(e){return e.kind===`table`?e.format===`faq`?B:o:e.kind===`file`?M:e.children?ue:I}function J({item:e,categories:t,onOpen:n}){let r=ke(e),i=[ye(t,e.categories),e.children?e.children===1?m(`know.oneSub`):m(`know.sub`,{n:e.children}):``,e.rows===null?``:e.rows===1?m(`know.row`):m(`know.rows`,{n:e.rows}),e.originLabel??``].filter(Boolean).join(` · `);return(0,W.jsxs)(`button`,{type:`button`,onClick:()=>n(e.key),disabled:e.status===`pending`,className:`flex items-start gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent disabled:pointer-events-none`,children:[(0,W.jsx)(r,{className:`mt-0.5 size-4 shrink-0 text-ink-3`}),(0,W.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`span`,{className:`block truncate text-[0.875rem]`,children:e.title}),i?(0,W.jsx)(`span`,{className:`block truncate text-[0.75rem] text-ink-3`,children:i}):null]}),e.status===`pending`?(0,W.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1.5 text-[0.75rem] text-ink-3`,children:[(0,W.jsx)(S,{className:`size-3`}),` `,m(`know.reading`)]}):e.review?(0,W.jsx)(O,{tone:`warn`,title:e.review,children:m(`know.review`)}):null]})}function Y({projectId:e,itemKey:t,has:n,originLabel:r,kept:i,review:a,file:o,readOnly:s,onReviewed:c}){let l=Oe(e),u=[r?m(i?`know.kept`:`know.from`,{label:r}):``].filter(Boolean);return(0,W.jsxs)(`div`,{className:`flex flex-col gap-2 px-1`,children:[l.data?(0,W.jsx)(Se,{projectId:e,itemKey:t,has:n,categories:l.data.categories,readOnly:s}):null,u.length||o||a?(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-[0.8125rem] text-ink-3`,children:[u.map(e=>(0,W.jsx)(`span`,{children:e},e)),o?(0,W.jsxs)(`a`,{href:F(e,o.id),target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 underline-offset-2 hover:text-ink hover:underline`,children:[(0,W.jsx)(M,{className:`size-3.5`}),` `,m(`know.original`),`: `,o.name]}):null,a?(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,W.jsx)(O,{tone:`warn`,children:m(`know.review`)}),(0,W.jsx)(`span`,{children:a}),s?null:(0,W.jsx)(`button`,{type:`button`,onClick:c,className:`underline hover:text-ink`,children:m(`know.reviewed`)})]}):null]}):null]})}function Ae(e){let t=e.filter(Number.isFinite).sort((e,t)=>e-t);if(new Set(t).size<=4)return[];let n=t[0],r=t.at(-1),i=e=>e.slice(0,-1).map((t,n)=>({lo:t,hi:e[n+1]})).filter(e=>t.some(t=>t>=e.lo&&t<e.hi));if(n>0&&r/n>=30){let e=Math.floor(Math.log10(n)),t=Math.floor(Math.log10(r))+1;for(let a of[[1,2,5],[1,3],[1]]){let o=[];for(let n=e;n<=t;n++)for(let e of a)o.push(e*10**n);let s=i(o.filter((e,t)=>e<=n||o[t-1]<=r));if(s.length<=7)return s}}let a=(r-n)/5,o=10**Math.floor(Math.log10(a)),s=([1,2,2.5,5,10].map(e=>e*o).find(e=>e>=a)??a)||1,c=[];for(let e=Math.floor(n/s)*s;e<=r;e+=s)c.push(e);return c.push(c.at(-1)+s),i(c)}function je({projectId:e,category:t,categories:n,onOpen:r}){let a=i({queryKey:[`knowledge`,e,`category`,t.id],queryFn:()=>c.get(`/api/studio/categories/${t.id}/items`)});if(!a.data)return a.isLoading?(0,W.jsx)(S,{className:`mx-auto size-4 text-ink-3`}):null;let o=e=>e.categories.find(e=>e.categoryId===t.id)?.values[0],s=[...a.data.items].sort((e,t)=>{let n=o(e),r=o(t);return typeof n==`number`&&typeof r==`number`?n-r:String(r??``).localeCompare(String(n??``),p)}),l=t.type===`number`?Ae(s.map(o).filter(e=>typeof e==`number`)):[],u=new Intl.NumberFormat(p,{notation:`compact`,maximumFractionDigits:1}),d=t.unit?` ${t.unit}`:``,f=new Map;for(let e of s){let n=o(e),r=typeof n==`number`?l.find(e=>n>=e.lo&&n<e.hi):void 0,i=n===void 0?``:t.type===`date`?new Date(`${String(n).slice(0,7)}-01T00:00:00`).toLocaleDateString(p,{month:`long`,year:`numeric`}):r?m(`know.range`,{min:`${u.format(r.lo)}${d}`,max:`${u.format(r.hi)}${d}`}):q(t,n);f.set(i,[...f.get(i)??[],e])}return(0,W.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[[...f].map(([e,t])=>(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e?(0,W.jsx)(`p`,{className:`px-1 font-medium text-[0.6875rem] text-ink-4 uppercase tracking-[0.12em]`,children:e}):null,(0,W.jsx)(E,{className:`flex flex-col p-1.5`,children:t.map(e=>(0,W.jsx)(J,{item:e,categories:n,onOpen:r},e.key))})]},e)),a.data.rows.map(e=>(0,W.jsx)(`button`,{type:`button`,onClick:()=>r(`t:${e.tableId}`),className:`px-1 text-left text-[0.8125rem] text-ink-3 hover:text-ink`,children:m(`know.tocRows`,{n:e.count,table:e.title})},e.tableId))]})}function Me(e,t,n){return Array.isArray(n)?t.some(e=>n.map(String).includes(String(e))):typeof n==`object`&&n?t.some(t=>{if(e.type===`number`&&typeof t==`number`)return(n.gte===void 0||t>=n.gte)&&(n.lte===void 0||t<=n.lte);if(e.type===`date`){let e=String(t).slice(0,10);return(!n.after||e>=n.after)&&(!n.before||e<=n.before)}return!n.contains||String(t).toLowerCase().includes(n.contains.toLowerCase())}):t.some(e=>e===n)}function Ne(e,t){if(Array.isArray(t))return t.map(String).join(`, `);if(typeof t==`boolean`)return m(t?`know.yes`:`know.no`);if(typeof t==`object`&&t){let n=t.gte??t.after,r=t.lte??t.before;return t.contains?`${m(`know.contains`)} ${t.contains}`:[n===void 0?``:`${m(`know.minimum`)} ${q(e,n)}`,r===void 0?``:`${m(`know.maximum`)} ${q(e,r)}`].filter(Boolean).join(` `)}return String(t)}function Pe({category:e,value:t,onChange:n}){let[r,i]=(0,U.useState)(!1),a=(0,U.useRef)(null);(0,U.useEffect)(()=>{if(!r)return;let e=e=>!a.current?.contains(e.target)&&i(!1);return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[r]);let o=G[e.type],s=typeof t==`object`&&t&&!Array.isArray(t)?t:{},c=(t,r)=>{let i={...s,[t]:r===``?void 0:e.type===`number`?Number(r):r},a=Object.fromEntries(Object.entries(i).filter(([,e])=>e!==void 0));n(Object.keys(a).length?a:void 0)};return(0,W.jsxs)(`div`,{ref:a,className:`relative`,children:[(0,W.jsxs)(`button`,{type:`button`,onClick:()=>i(!r),className:v(`inline-flex h-8 items-center gap-1.5 rounded-full px-3 text-[0.8125rem] transition`,t===void 0?`text-ink-2 ring-1 ring-border-soft hover:ring-border`:`bg-ember-tint text-ink ring-1 ring-ember/30`),children:[(0,W.jsx)(o,{className:`size-3.5 text-ink-3`}),e.name,t===void 0?null:(0,W.jsxs)(`span`,{className:`font-medium`,children:[`: `,Ne(e,t)]}),(0,W.jsx)(_,{className:`size-3.5 text-ink-3`})]}),r?(0,W.jsxs)(`div`,{className:`absolute top-full left-0 z-30 mt-1.5 w-72 max-w-[calc(100vw-32px)] rounded-xl bg-card p-3 shadow-overlay ring-1 ring-border-soft`,children:[e.type===`choice`?(0,W.jsx)(j,{multi:!0,value:Array.isArray(t)?t.map(String):[],options:e.values.map(e=>e.value),onChange:e=>n(e.length?e:void 0)}):e.type===`boolean`?(0,W.jsx)(j,{value:t===!0?m(`know.yes`):t===!1?m(`know.no`):``,options:[m(`know.yes`),m(`know.no`)],onChange:e=>n(e===m(`know.yes`))}):e.type===`text`?(0,W.jsx)(k,{"data-autofocus":!0,value:s.contains??``,placeholder:m(`know.contains`),onChange:e=>n(e.target.value?{contains:e.target.value}:void 0),className:`h-9`}):(0,W.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:(e.type===`number`?[`gte`,`lte`]:[`after`,`before`]).map((t,n)=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(b,{children:m(n===0?`know.minimum`:`know.maximum`)}),(0,W.jsx)(k,{type:e.type===`number`?`number`:`date`,step:`any`,value:String(s[t]??``),placeholder:e.range?String(n===0?e.range.min:e.range.max):``,onChange:e=>c(t,e.target.value),className:`h-9`})]},t))}),t===void 0?null:(0,W.jsx)(`button`,{type:`button`,onClick:()=>{n(void 0),i(!1)},className:`mt-3 text-[0.8125rem] text-ink-3 underline hover:text-ink`,children:m(`know.clear`)})]}):null]})}function Fe({found:e,onOpen:t}){return e.hits.length?(0,W.jsxs)(`div`,{className:`flex flex-col`,children:[(0,W.jsx)(`p`,{className:`px-3 pt-1 pb-2 text-[0.75rem] text-ink-3`,children:e.checked?m(`know.searchStats`,{candidates:e.candidates,hits:e.hits.length}):m(`know.searchUnchecked`,{hits:e.hits.length})}),e.hits.map(e=>{let n=e.open;return(0,W.jsxs)(`button`,{type:`button`,disabled:!n,onClick:()=>n&&t(n),className:`flex items-start gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent disabled:pointer-events-none`,children:[(0,W.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`span`,{className:`block truncate text-[0.875rem]`,children:[e.title,e.heading&&e.heading!==e.title?(0,W.jsxs)(`span`,{className:`text-ink-3`,children:[` › `,e.heading]}):null]}),(0,W.jsx)(`span`,{className:`line-clamp-2 text-[0.8125rem] text-ink-3`,children:e.text})]}),e.relevance===null?null:(0,W.jsx)(`span`,{className:`shrink-0 font-medium text-[0.75rem] text-moss tabular-nums`,children:e.relevance.toLocaleString(p,{minimumFractionDigits:2})})]},`${e.key}:${e.heading}`)})]}):(0,W.jsx)(`p`,{className:`px-3 py-4 text-[0.875rem] text-ink-3`,children:m(`know.searchNone`)})}function Ie({kind:e,projectId:t,onClose:n,onMade:i}){let a=r(),[o,l]=(0,U.useState)(``),[u,d]=(0,U.useState)(!1),f=s({mutationFn:()=>c.post(`/api/studio/projects/${t}/${e===`table`?`tables`:`pages`}`,{title:o.trim(),...e===`table`&&u?{format:`faq`}:{}}),onSuccess:async({id:n})=>{await a.invalidateQueries({queryKey:[`knowledge`,t]}),i(`${e===`table`?`t`:`p`}:${n}`),l(``),d(!1)}});return(0,W.jsx)(w,{open:e!==null,onClose:n,title:m(e===`table`?`know.newTable`:`know.newPage`),children:(0,W.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),o.trim()&&f.mutate()},children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(b,{children:m(`data.title`)}),(0,W.jsx)(k,{"data-autofocus":!0,value:o,maxLength:120,onChange:e=>l(e.target.value)})]}),e===`table`?(0,W.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-[0.875rem]`,children:[m(`know.asFaq`),(0,W.jsx)(T,{checked:u,onChange:d})]}):null,f.error?(0,W.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:f.error.message}):null,(0,W.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,W.jsx)(A,{variant:`ghost`,onClick:n,children:m(`common.cancel`)}),(0,W.jsx)(A,{type:`submit`,busy:f.isPending,disabled:!o.trim(),children:m(`know.create`)})]})]})})}function Le({projectId:e,data:t,readOnly:n,onOpen:i}){let a=r(),o=N(e,n),[l,u]=(0,U.useState)({}),[d,f]=(0,U.useState)(``),[p,g]=(0,U.useState)(null),[_,v]=(0,U.useState)(!1),[b,x]=(0,U.useState)(null),C=t.categories.filter(e=>!e.proposed&&e.count>0),w=t.categories.filter(e=>e.proposed),T=t.items.filter(e=>Object.entries(l).every(([n,r])=>{let i=t.categories.find(e=>e.name===n),a=e.categories.find(e=>e.categoryId===i?.id);return i&&a?Me(i,a.values,r):!1})),D=async()=>{if(!d.trim()){g(null);return}v(!0);try{g(await c.post(`/api/studio/projects/${e}/search`,{query:d,...Object.keys(l).length?{where:l}:{}}))}catch{g({hits:[],candidates:0,checked:!1,filtered:null})}finally{v(!1)}},k=s({mutationFn:({id:e,keep:t})=>t?c.patch(`/api/studio/categories/${e}`,{proposed:!1}):c.del(`/api/studio/categories/${e}`),onSuccess:()=>a.invalidateQueries({queryKey:[`knowledge`,e]})});return(0,W.jsxs)(P,{title:m(`know.title`),hint:m(`know.hint`),plain:!0,action:n?null:(0,W.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,W.jsxs)(A,{variant:`secondary`,size:`sm`,onClick:()=>x(`page`),children:[(0,W.jsx)(h,{className:`size-4`}),` `,m(`know.page`)]}),(0,W.jsxs)(A,{variant:`secondary`,size:`sm`,onClick:()=>x(`table`),children:[(0,W.jsx)(h,{className:`size-4`}),` `,m(`know.table`)]}),(0,W.jsxs)(A,{variant:`secondary`,size:`sm`,onClick:()=>x(`category`),children:[(0,W.jsx)(h,{className:`size-4`}),` `,m(`know.category`)]})]}),children:[w.length&&!n?(0,W.jsx)(E,{className:`flex flex-col gap-2 p-4`,children:w.map(e=>{let t=G[e.type];return(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5`,children:[(0,W.jsx)(O,{tone:`ember`,children:m(`know.proposed`)}),(0,W.jsx)(t,{className:`size-4 text-ink-3`}),(0,W.jsx)(`span`,{className:`font-medium text-[0.875rem]`,children:e.name}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.8125rem] text-ink-3`,children:[m(`know.type.${e.type}`),e.hint].filter(Boolean).join(` · `)}),(0,W.jsx)(A,{size:`sm`,variant:`ghost`,onClick:()=>k.mutate({id:e.id,keep:!1}),children:m(`know.dismiss`)}),(0,W.jsx)(A,{size:`sm`,onClick:()=>k.mutate({id:e.id,keep:!0}),children:m(`know.accept`)})]},e.id)})}):null,t.items.length?(0,W.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,W.jsx)(ee,{value:d,placeholder:m(`know.search`),busy:_,onEnter:()=>void D(),onChange:e=>{f(e),e.trim()||g(null)}}),C.length?(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[C.map(e=>(0,W.jsx)(Pe,{category:e,value:l[e.name],onChange:t=>{g(null),u(n=>{let r={...n};return t===void 0?delete r[e.name]:r[e.name]=t,r})}},e.id)),Object.keys(l).length?(0,W.jsx)(`button`,{type:`button`,onClick:()=>u({}),className:`px-2 text-[0.8125rem] text-ink-3 underline hover:text-ink`,children:m(`know.clear`)}):null]}):null]}):null,(0,W.jsx)(E,{className:`flex flex-col p-1.5`,children:p?(0,W.jsx)(Fe,{found:p,onOpen:i}):T.length?T.map(e=>(0,W.jsx)(J,{item:e,categories:t.categories,onOpen:i},e.key)):(0,W.jsx)(y,{children:m(`know.empty`)})}),n?null:(0,W.jsxs)(te,{accept:`.pdf,.docx,.doc,.xlsx,.csv,.tsv,.txt,.md,.json,.html,.eml,image/*`,onFiles:async t=>{await o.upload(`document`,t),await a.invalidateQueries({queryKey:[`knowledge`,e]})},className:`h-14 w-full`,children:[o.busy?(0,W.jsx)(S,{className:`size-4`}):(0,W.jsx)(ie,{className:`size-4`}),m(`know.drop`),` `,(0,W.jsx)(`span`,{className:`underline`,children:m(`know.pick`)})]}),o.error?(0,W.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:o.error}):null,t.items.length&&!(t.checked&&t.embeddings)?(0,W.jsx)(`p`,{className:`px-1 text-[0.8125rem] text-ink-3`,children:[t.embeddings?``:m(`know.keywordsOnly`),t.checked?``:m(`know.unchecked`)].filter(Boolean).join(` `)}):null,(0,W.jsx)(Ie,{kind:b===`page`||b===`table`?b:null,projectId:e,onClose:()=>x(null),onMade:e=>{x(null),i(e)}}),(0,W.jsx)(we,{projectId:e,open:b===`category`,onClose:()=>x(null),onMade:e=>{x(null),i(`c:${e}`)}})]})}function Re({page:e,onGone:t,onOpen:n}){let i=r(),[a,o]=(0,U.useState)(e.title),[d,f]=(0,U.useState)(e.markdown),[p,g]=(0,U.useState)(e.markdown?`read`:`write`),_=e.knowledge,y=async()=>{await i.invalidateQueries({queryKey:[`space-data`,e.projectId]}),await i.invalidateQueries({queryKey:[`knowledge`,e.projectId]})},b=ne({title:a.trim()||e.title,markdown:d},async t=>{await c.patch(`/api/studio/pages/${e.id}`,t),i.setQueryData([`space-page`,e.id],e=>e&&{...e,...t}),t.title!==e.title&&await y()}),x=s({mutationFn:()=>c.del(`/api/studio/pages/${e.id}`),onSuccess:async()=>{await y(),t()}}),C=s({mutationFn:()=>c.post(`/api/studio/projects/${e.projectId}/pages`,{title:m(`know.addSub`),parentId:e.id}),onSuccess:async({id:e})=>{await y(),n?.(`p:${e}`)}}),w=s({mutationFn:()=>c.patch(`/api/studio/pages/${e.id}`,{review:null}),onSuccess:()=>i.invalidateQueries({queryKey:[`space-page`,e.id]})}),T=async t=>{let r=t.target.closest(`a`)?.getAttribute(`href`);if(!(r?.startsWith(`pages/`)&&n))return;t.preventDefault();let i=await c.get(`/api/studio/projects/${e.projectId}/resolve?path=${encodeURIComponent(r)}`).catch(()=>null);i?.kind===`page`&&n(`p:${i.id}`)},O=e.readOnly,k=_?.file&&(_.file.mime===`application/pdf`||_.file.mime.startsWith(`image/`))?_.file:null,j=(e,t)=>(0,W.jsx)(`button`,{type:`button`,"aria-pressed":p===e,onClick:()=>g(e),className:v(`rounded-full px-3 py-1 text-[0.8125rem] transition`,p===e?`bg-paper-2 font-medium text-ink`:`text-ink-3 hover:text-ink`),children:t});return(0,W.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[_?.parents.length&&n?(0,W.jsx)(`nav`,{className:`-mb-1.5 flex flex-wrap items-center gap-1 px-1 text-[0.8125rem] text-ink-3`,children:_.parents.map(e=>(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:()=>n(`p:${e.id}`),className:`hover:text-ink`,children:e.title}),(0,W.jsx)(u,{className:`size-3.5`})]},e.id))}):null,(0,W.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,W.jsx)(`input`,{value:a,disabled:O,maxLength:200,onChange:e=>o(e.target.value),"aria-label":m(`data.title`),className:`-ml-1 min-w-0 flex-1 rounded-md bg-transparent px-1 font-display font-semibold text-lg outline-none hover:bg-accent focus:bg-paper focus:ring-1 focus:ring-ring disabled:hover:bg-transparent`}),b.state===`saving`?(0,W.jsx)(S,{className:`size-3.5 text-ink-3`}):b.state===`saved`?(0,W.jsx)(l,{className:`size-4 text-moss`,"aria-label":m(`settings.saved`)}):null,O?null:(0,W.jsx)(D,{label:m(`data.deletePage`),onClick:()=>confirm(m(`data.confirmDelete`,{title:e.title}))&&x.mutate(),className:`hover:text-rose`,children:(0,W.jsx)(L,{className:`size-4`})})]}),_?(0,W.jsx)(Y,{projectId:e.projectId,itemKey:`p:${e.id}`,has:_.categories,originLabel:_.originLabel,kept:_.kept,review:_.review,file:k?null:_.file,readOnly:O,onReviewed:()=>w.mutate()}):null,(0,W.jsxs)(E,{className:`flex flex-col`,children:[O&&!k?null:(0,W.jsxs)(`div`,{className:`flex items-center gap-1 border-border-soft border-b px-2 py-1.5`,children:[O?null:j(`write`,m(`data.write`)),j(`read`,m(`data.preview`)),k?j(`original`,m(`know.original`)):null,(0,W.jsx)(`span`,{className:`ml-auto truncate px-2 text-[0.75rem] text-ink-4 max-sm:hidden`,children:p===`original`&&k?k.name:m(`data.markdownHint`)})]}),p===`original`&&k?k.mime===`application/pdf`?(0,W.jsx)(`iframe`,{src:F(e.projectId,k.id),title:k.name,className:`h-[70dvh] w-full rounded-b-xl bg-paper-2`}):(0,W.jsx)(`img`,{src:F(e.projectId,k.id),alt:``,className:`mx-auto max-h-[70dvh] object-contain p-4`}):p===`write`&&!O?(0,W.jsx)(`textarea`,{value:d,onChange:e=>f(e.target.value),"aria-label":e.title,placeholder:m(`data.pageEmpty`),className:`field-sizing-content min-h-[50vh] w-full resize-none bg-transparent p-4 font-mono text-[0.8125rem] leading-relaxed outline-none placeholder:text-ink-4 sm:p-5`}):(0,W.jsx)(`div`,{className:`min-h-40 p-4 sm:p-5`,onClick:T,children:d.trim()?(0,W.jsx)(oe,{text:d}):(0,W.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:m(`data.pageEmpty`)})})]}),b.state===`error`&&b.error?(0,W.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:b.error}):null,_&&n&&(_.children.length||!O)?(0,W.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between px-1`,children:[(0,W.jsx)(`p`,{className:`font-medium text-[0.6875rem] text-ink-4 uppercase tracking-[0.12em]`,children:_.children.length?m(`know.subPages`):null}),O?null:(0,W.jsxs)(A,{variant:`ghost`,size:`sm`,busy:C.isPending,onClick:()=>C.mutate(),children:[(0,W.jsx)(h,{className:`size-4`}),` `,m(`know.addSub`)]})]}),_.children.length?(0,W.jsx)(E,{className:`flex flex-col p-1.5`,children:_.children.map(e=>(0,W.jsxs)(`button`,{type:`button`,onClick:()=>n(`p:${e.id}`),className:`flex items-center gap-3 rounded-lg px-3 py-2 text-left transition hover:bg-accent`,children:[(0,W.jsx)(I,{className:`size-4 shrink-0 text-ink-3`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.875rem]`,children:e.title})]},e.id))}):null]}):null]})}function ze({pageId:e,onGone:t,onOpen:n}){let r=i({queryKey:[`space-page`,e],queryFn:()=>c.get(`/api/studio/pages/${e}`),refetchOnWindowFocus:!1});return r.data?(0,W.jsx)(Re,{page:r.data,onGone:t,onOpen:n},r.data.id):r.isError?(0,W.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:r.error.message}):null}function Be(e){return i({queryKey:[`space-data`,e],queryFn:()=>c.get(`/api/studio/projects/${e}/data`),enabled:!!e})}function Ve(e){let t=t=>[...e.tables.filter(e=>e.wizardId===t).map(e=>({key:`t:${e.id}`,kind:`table`,title:e.title,rows:e.rows})),...e.pages.filter(e=>e.wizardId===t).map(e=>({key:`p:${e.id}`,kind:`page`,title:e.title}))];return[{key:`own`,label:m(`data.own`),items:t(null)},...e.wizards.map(e=>({key:e.id,label:e.title,items:t(e.id)}))].filter(e=>e.items.length)}var He={table:o,page:I};function Ue({kind:e,projectId:t,data:n,onClose:i,onMade:a}){let o=r(),[l,u]=(0,U.useState)(``),[d,f]=(0,U.useState)(``),p=s({mutationFn:()=>c.post(`/api/studio/projects/${t}/${e===`table`?`tables`:`pages`}`,{title:l.trim(),wizardId:d||null}),onSuccess:async({id:n})=>{await o.invalidateQueries({queryKey:[`space-data`,t]}),a(`${e===`table`?`t`:`p`}:${n}`),u(``),f(``)}});return(0,W.jsx)(w,{open:e!==null,onClose:i,title:m(e===`table`?`data.newTable`:`data.newPage`),children:(0,W.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),l.trim()&&p.mutate()},children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(b,{children:m(`data.title`)}),(0,W.jsx)(k,{"data-autofocus":!0,value:l,maxLength:120,onChange:e=>u(e.target.value)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(b,{children:m(`data.owner`)}),(0,W.jsx)(x,{value:d,onChange:f,options:[{value:``,label:m(`data.own`)},...n.wizards.map(e=>({value:e.id,label:e.title}))]})]}),p.error?(0,W.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:p.error.message}):null,(0,W.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,W.jsx)(A,{variant:`ghost`,onClick:i,children:m(`common.cancel`)}),(0,W.jsx)(A,{type:`submit`,busy:p.isPending,disabled:!l.trim(),children:m(`data.create`)})]})]})})}function We({projectId:e,data:t,readOnly:n,onOpen:r}){let[i,a]=(0,U.useState)(null),o=Ve(t),s=new Map([...t.tables.map(e=>[`t:${e.id}`,e.updatedAt]),...t.pages.map(e=>[`p:${e.id}`,e.updatedAt])]),c=new Intl.DateTimeFormat(p,{dateStyle:`medium`});return(0,W.jsxs)(P,{title:m(`space.data`),hint:m(`data.hint`),plain:!0,action:n?null:(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsxs)(A,{variant:`secondary`,size:`sm`,onClick:()=>a(`table`),children:[(0,W.jsx)(h,{className:`size-4`}),` `,m(`data.table`)]}),(0,W.jsxs)(A,{variant:`secondary`,size:`sm`,onClick:()=>a(`page`),children:[(0,W.jsx)(h,{className:`size-4`}),` `,m(`data.page`)]})]}),children:[o.length?(0,W.jsx)(`div`,{className:`flex flex-col gap-5`,children:o.map(e=>(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,W.jsx)(`p`,{className:`px-1 font-medium text-[0.6875rem] text-ink-4 uppercase tracking-[0.12em]`,children:e.label}),(0,W.jsx)(E,{className:`flex flex-col p-1.5`,children:e.items.map(e=>{let t=He[e.kind];return(0,W.jsxs)(`button`,{type:`button`,onClick:()=>r(e.key),className:`flex items-center gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent`,children:[(0,W.jsx)(t,{className:`size-4 shrink-0 text-ink-3`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.875rem]`,children:e.title}),(0,W.jsxs)(`span`,{className:`shrink-0 text-[0.75rem] text-ink-3 tabular-nums`,children:[e.kind===`table`?`${m(`data.rows`,{n:e.rows??0})} · `:``,c.format(new Date(s.get(e.key)??Date.now()))]})]},e.key)})})]},e.key))}):(0,W.jsx)(E,{children:(0,W.jsx)(y,{children:m(`data.empty`)})}),(0,W.jsx)(Ue,{kind:i,projectId:e,data:t,onClose:()=>a(null),onMade:e=>{a(null),r(e)}})]})}function Ge(e,t){let n=e.normalize(`NFKD`).replace(/[̀-ͯ]/g,``).toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``).replace(/^[^a-z]+/,``).slice(0,48)||`column`,r=n,i=2;for(;t.includes(r);)r=`${n}_${i++}`;return r}var Ke={milliseconds:1,seconds:1e3,minutes:6e4,hours:36e5,days:864e5},qe=[`text`,`number`,`date`,`duration`,`select`,`boolean`];function Je(e,t){if(t==null)return``;if(e.type===`duration`&&typeof t==`number`)return String(t/Ke[e.format.inputUnit]);if(e.type===`date`&&e.format.kind===`datetime`&&typeof t==`string`){let e=new Date(t);return new Date(e.getTime()-e.getTimezoneOffset()*6e4).toISOString().slice(0,16)}return String(t)}function Ye(e,t){return t.trim()===``?null:e.type===`date`&&e.format.kind===`datetime`?new Date(t).toISOString():t}var X=`w-full min-w-0 rounded-md bg-transparent px-2 py-1.5 text-[0.875rem] outline-none transition placeholder:text-ink-4 hover:bg-accent focus:bg-paper focus:ring-1 focus:ring-ring disabled:hover:bg-transparent`;function Xe({column:e,value:t,readOnly:n,invalid:r,onSave:i}){let a=Je(e,t),[o,s]=(0,U.useState)(a);(0,U.useEffect)(()=>s(a),[a]);let c=(t=o)=>{t!==a&&i(Ye(e,t))};if(e.type===`boolean`)return(0,W.jsx)(`div`,{className:`px-2 py-1.5`,children:(0,W.jsx)(`input`,{type:`checkbox`,checked:t===!0,disabled:n,onChange:e=>i(e.target.checked),"aria-label":e.name,className:`size-4 accent-[var(--ember)]`})});if(e.type===`select`&&e.format.multiple){let r=Array.isArray(t)?t:[],a=t=>e.format.options.find(e=>e.id===t)?.label??t;return(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 px-2 py-1`,children:[r.map(e=>(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-paper-2 py-0.5 pr-1 pl-2 text-[0.75rem]`,children:[a(e),n?null:(0,W.jsx)(`button`,{type:`button`,"aria-label":m(`data.removeOption`),onClick:()=>i(r.filter(t=>t!==e)),className:`rounded-full text-ink-3 hover:text-ink`,children:(0,W.jsx)(d,{className:`size-3`})})]},e)),n?null:(0,W.jsxs)(`select`,{value:``,onChange:e=>e.target.value&&i([...r,e.target.value]),"aria-label":e.name,className:`h-7 rounded-md bg-transparent px-1 text-[0.75rem] text-ink-3 outline-none hover:bg-accent`,children:[(0,W.jsx)(`option`,{value:``,children:`+`}),e.format.options.filter(e=>!r.includes(e.id)).map(e=>(0,W.jsx)(`option`,{value:e.id,children:e.label},e.id))]})]})}if(e.type===`select`)return(0,W.jsxs)(`select`,{value:typeof t==`string`?t:``,disabled:n,onChange:e=>i(e.target.value||null),"aria-label":e.name,className:X,children:[(0,W.jsx)(`option`,{value:``}),e.format.options.map(e=>(0,W.jsx)(`option`,{value:e.id,children:e.label},e.id))]});if(e.type===`text`&&e.format?.style&&e.format.style!==`single`)return(0,W.jsx)(`textarea`,{value:o,rows:1,disabled:n,onChange:e=>s(e.target.value),onBlur:()=>c(),"aria-label":e.name,className:v(X,`field-sizing-content max-h-40 resize-none`)});let l=e.type===`date`?{date:`date`,datetime:`datetime-local`,time:`time`}[e.format.kind]:`text`;return(0,W.jsx)(`input`,{type:l,inputMode:e.type===`number`||e.type===`duration`?`decimal`:void 0,value:o,disabled:n,onChange:t=>{s(t.target.value),e.type===`date`&&c(t.target.value)},onBlur:()=>e.type!==`date`&&c(),onKeyDown:e=>{e.key===`Enter`&&e.target.blur(),e.key===`Escape`&&s(a)},"aria-label":e.name,className:v(X,(e.type===`number`||e.type===`duration`)&&`text-right tabular-nums`,r&&`ring-1 ring-rose`)})}function Ze(e){return e.type===`number`&&e.format.style===`currency`?e.format.currency??null:e.type===`number`&&e.format.style===`percent`?`%`:e.type===`duration`?m(`data.unit.${e.format.inputUnit}`):null}function Qe(e){return{name:e?.name??``,type:e?.type??`text`,required:e?.required??!1,textStyle:e?.type===`text`&&(e.format?.style??`single`)!==`single`?`multiline`:`single`,numberStyle:e?.type===`number`?e.format.style:`decimal`,currency:e?.type===`number`?e.format.currency??`EUR`:`EUR`,dateKind:e?.type===`date`?e.format.kind:`date`,unit:e?.type===`duration`&&[`minutes`,`hours`,`days`].includes(e.format.inputUnit)?e.format.inputUnit:`minutes`,options:e?.type===`select`?e.format.options.map(e=>e.label).join(`
3
+ `):``,multiple:e?.type===`select`&&!!e.format.multiple}}function $e(e,t,n){let r={id:t,name:e.name.trim(),...e.required?{required:!0}:{}};switch(e.type){case`number`:return{...r,type:`number`,format:e.numberStyle===`currency`?{style:`currency`,currency:e.currency.trim().toUpperCase()}:{style:e.numberStyle}};case`date`:return{...r,type:`date`,format:{kind:e.dateKind}};case`duration`:return{...r,type:`duration`,format:{inputUnit:e.unit,display:`hms`}};case`select`:{let t=n?.type===`select`?n.format.options:[],i=[],a=e.options.split(`
4
+ `).map(e=>e.trim()).filter(Boolean).map(e=>{let n=t.find(t=>t.label===e)?.id??Ge(e,i);return i.push(n),{id:n,label:e}});return{...r,type:`select`,format:{allowCustom:!1,options:a,...e.multiple?{multiple:!0}:{}}}}case`boolean`:return{...r,type:`boolean`};default:return{...r,type:`text`,...e.textStyle===`multiline`?{format:{style:`multiline`}}:{}}}}function et({open:e,column:t,columns:n,onClose:r,onSave:i}){let[a,o]=(0,U.useState)(()=>Qe(t)),[s,c]=(0,U.useState)(null),[l,u]=(0,U.useState)(!1);(0,U.useEffect)(()=>{e&&(o(Qe(t)),c(null))},[e,t]);let d=e=>o(t=>({...t,...e})),f=async e=>{u(!0),c(null);try{await i(e),r()}catch(e){c(e.message)}finally{u(!1)}},p=()=>{let e=t?.id??Ge(a.name,n.map(e=>e.id)),r=$e(a,e,t);return f(t?n.map(e=>e.id===t.id?r:e):[...n,r])};return(0,W.jsx)(w,{open:e,onClose:r,title:t?t.name:m(`data.newColumn`),children:(0,W.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),a.name.trim()&&p()},children:[(0,W.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(b,{children:m(`data.columnName`)}),(0,W.jsx)(k,{"data-autofocus":!0,value:a.name,maxLength:128,onChange:e=>d({name:e.target.value})})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(b,{children:m(`data.columnType`)}),(0,W.jsx)(x,{value:a.type,onChange:e=>d({type:e}),options:qe.map(e=>({value:e,label:m(`data.type.${e}`)}))})]})]}),a.type===`text`?(0,W.jsx)(x,{value:a.textStyle,onChange:e=>d({textStyle:e}),options:[{value:`single`,label:m(`data.text.single`)},{value:`multiline`,label:m(`data.text.multiline`)}]}):null,a.type===`number`?(0,W.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,W.jsx)(x,{value:a.numberStyle,onChange:e=>d({numberStyle:e}),options:[`integer`,`decimal`,`percent`,`currency`].map(e=>({value:e,label:m(`data.number.${e}`)}))}),a.numberStyle===`currency`?(0,W.jsx)(k,{value:a.currency,maxLength:3,"aria-label":m(`data.currency`),placeholder:`EUR`,onChange:e=>d({currency:e.target.value})}):null]}):null,a.type===`date`?(0,W.jsx)(x,{value:a.dateKind,onChange:e=>d({dateKind:e}),options:[`date`,`datetime`,`time`].map(e=>({value:e,label:m(`data.date.${e}`)}))}):null,a.type===`duration`?(0,W.jsxs)(`div`,{children:[(0,W.jsx)(b,{children:m(`data.unit`)}),(0,W.jsx)(x,{value:a.unit,onChange:e=>d({unit:e}),options:[`minutes`,`hours`,`days`].map(e=>({value:e,label:m(`data.unit.${e}`)}))})]}):null,a.type===`select`?(0,W.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(b,{children:m(`data.options`)}),(0,W.jsx)(C,{minRows:3,value:a.options,onChange:e=>d({options:e.target.value})})]}),(0,W.jsxs)(`label`,{className:`flex items-center gap-3 text-[0.875rem]`,children:[(0,W.jsx)(T,{checked:a.multiple,onChange:e=>d({multiple:e})}),m(`data.multiple`)]})]}):null,(0,W.jsxs)(`label`,{className:`flex items-center gap-3 text-[0.875rem]`,children:[(0,W.jsx)(T,{checked:a.required,onChange:e=>d({required:e})}),m(`data.required`)]}),s?(0,W.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:s}):null,(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t&&n.length>1?(0,W.jsx)(A,{variant:`ghost`,className:`text-rose`,disabled:l,onClick:()=>confirm(m(`data.confirmDelete`,{title:t.name}))&&void f(n.filter(e=>e.id!==t.id)),children:m(`data.deleteColumn`)}):null,(0,W.jsx)(`span`,{className:`flex-1`}),(0,W.jsx)(A,{variant:`ghost`,onClick:r,children:m(`common.cancel`)}),(0,W.jsx)(A,{type:`submit`,busy:l,disabled:!a.name.trim(),children:m(`settings.save`)})]})]})})}function tt({tableId:e,onGone:t}){let n=r(),a=[`space-table`,e],o=i({queryKey:a,queryFn:()=>c.get(`/api/studio/tables/${e}`)}),[l,u]=(0,U.useState)(null),[d,f]=(0,U.useState)(null),[p,_]=(0,U.useState)(null),[v,y]=(0,U.useState)(``);(0,U.useEffect)(()=>y(o.data?.title??``),[o.data?.title]);let b=async()=>{await n.invalidateQueries({queryKey:[`space-data`,o.data?.projectId]}),await n.invalidateQueries({queryKey:[`knowledge`,o.data?.projectId]})},x=e=>n.setQueryData(a,t=>t&&{...t,rows:e(t.rows)}),S=e=>{f(e.message),o.refetch()},C=async t=>{await c.patch(`/api/studio/tables/${e}`,t),await o.refetch(),await b()},w=s({mutationFn:({row:t,column:n,value:r})=>c.patch(`/api/studio/tables/${e}/rows/${t}`,{cells:{[n]:r}}),onSuccess:(e,{row:t,column:n})=>{f(null),_(e=>e===`${t}:${n}`?null:e),x(t=>t.map(t=>t.id===e.id?{...t,cells:e.cells}:t))},onError:(e,{row:t,column:n})=>{if(e instanceof g&&e.body?.column===n){let e=o.data?.columns.find(e=>e.id===n)?.name??n;_(`${t}:${n}`),f(m(`data.badCell`,{column:e}));return}S(e)}}),T=s({mutationFn:()=>c.post(`/api/studio/tables/${e}/rows`,{}),onSuccess:async e=>{x(t=>[...t,{...e,updatedAt:new Date().toISOString()}]),await b()},onError:S}),O=s({mutationFn:t=>c.post(`/api/studio/tables/${e}/rows/delete`,{ids:[t]}),onSuccess:async(e,t)=>{x(e=>e.filter(e=>e.id!==t)),await b()},onError:S}),k=s({mutationFn:()=>c.del(`/api/studio/tables/${e}`),onSuccess:async()=>{await b(),t()}});if(!o.data)return o.isError?(0,W.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:o.error.message}):null;let{columns:j,rows:M,readOnly:N}=o.data,P=!!o.data.list;return(0,W.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,W.jsx)(`input`,{value:v,disabled:N,maxLength:120,onChange:e=>y(e.target.value),onBlur:()=>v.trim()&&v!==o.data?.title&&void C({title:v}).catch(S),onKeyDown:e=>e.key===`Enter`&&e.target.blur(),"aria-label":m(`data.title`),className:`-ml-1 min-w-0 flex-1 rounded-md bg-transparent px-1 font-display font-semibold text-lg outline-none hover:bg-accent focus:bg-paper focus:ring-1 focus:ring-ring disabled:hover:bg-transparent`}),N?null:(0,W.jsx)(D,{label:m(`data.deleteTable`),onClick:()=>confirm(m(`data.confirmDelete`,{title:o.data.title}))&&k.mutate(),className:`hover:text-rose`,children:(0,W.jsx)(L,{className:`size-4`})})]}),P?(0,W.jsx)(`p`,{className:`-mt-1.5 px-1 text-[0.8125rem] text-ink-3`,children:m(`data.fromList`)}):null,o.data.knowledge?(0,W.jsx)(Y,{projectId:o.data.projectId,itemKey:`t:${o.data.id}`,has:o.data.knowledge.categories,originLabel:o.data.knowledge.originLabel,kept:o.data.knowledge.kept,review:o.data.knowledge.review,file:o.data.knowledge.file,readOnly:N,onReviewed:()=>void c.patch(`/api/studio/tables/${e}`,{review:null}).then(()=>o.refetch()).catch(S)}):null,(0,W.jsxs)(E,{className:`overflow-hidden`,children:[(0,W.jsx)(`div`,{className:`overflow-x-auto`,children:(0,W.jsxs)(`table`,{className:`w-full border-collapse text-left`,children:[(0,W.jsx)(`thead`,{children:(0,W.jsxs)(`tr`,{className:`border-border-soft border-b`,children:[j.map(e=>(0,W.jsx)(`th`,{className:`min-w-36 border-border-soft border-l p-1 font-medium first:border-l-0`,children:(0,W.jsxs)(`button`,{type:`button`,disabled:N||P,onClick:()=>u(e),className:`flex w-full items-center gap-1 rounded-md px-2 py-1.5 text-left text-[0.8125rem] text-ink-2 transition hover:bg-accent hover:text-ink disabled:hover:bg-transparent`,children:[(0,W.jsx)(`span`,{className:`truncate`,children:e.name}),e.required?(0,W.jsx)(`span`,{className:`text-ember`,children:`*`}):null,Ze(e)?(0,W.jsx)(`span`,{className:`font-normal text-ink-4`,children:Ze(e)}):null]})},e.id)),(0,W.jsx)(`th`,{className:`w-10 p-1`,children:N||P?null:(0,W.jsx)(D,{label:m(`data.newColumn`),onClick:()=>u(`new`),className:`size-8`,children:(0,W.jsx)(h,{className:`size-4`})})})]})}),(0,W.jsx)(`tbody`,{children:M.map(e=>(0,W.jsxs)(`tr`,{className:`group border-border-soft border-b last:border-b-0`,children:[j.map(t=>(0,W.jsx)(`td`,{className:`border-border-soft border-l p-1 align-top first:border-l-0`,children:(0,W.jsx)(Xe,{column:t,value:e.cells[t.id],readOnly:N,invalid:p===`${e.id}:${t.id}`,onSave:n=>w.mutate({row:e.id,column:t.id,value:n})})},t.id)),(0,W.jsx)(`td`,{className:`w-10 p-1 align-top`,children:N?null:(0,W.jsx)(D,{label:m(`data.deleteRow`),onClick:()=>O.mutate(e.id),className:`size-8 opacity-0 hover:text-rose focus:opacity-100 group-hover:opacity-100 coarse:opacity-100`,children:(0,W.jsx)(L,{className:`size-3.5`})})})]},e.id))})]})}),M.length?null:(0,W.jsx)(`p`,{className:`px-4 py-6 text-center text-[0.875rem] text-ink-3`,children:m(`data.noRows`)}),N?null:(0,W.jsx)(`div`,{className:`border-border-soft border-t p-1.5`,children:(0,W.jsxs)(A,{variant:`ghost`,size:`sm`,busy:T.isPending,onClick:()=>T.mutate(),children:[(0,W.jsx)(h,{className:`size-4`}),` `,m(`data.addRow`)]})})]}),d?(0,W.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:d}):null,(0,W.jsx)(et,{open:l!==null,column:l===`new`?null:l,columns:j,onClose:()=>u(null),onSave:e=>C({columns:e})})]})}var nt=`wizards.runDrawer.width`,rt=`wizards.runDrawer.wide`,it=`wizards.runDrawer.look`,at=680,Z=400,ot=()=>Math.max(Z,window.innerWidth-120);function Q(e){try{return localStorage.getItem(e)}catch{return null}}function $(e,t){try{localStorage.setItem(e,t)}catch{}}function st(){let[e,t]=(0,U.useState)(()=>{let e=Number(Q(nt));return e?Math.min(Math.max(e,Z),ot()):at}),[n,r]=(0,U.useState)(()=>Q(rt)===`1`),i=(0,U.useCallback)(e=>{let n=Math.round(Math.min(Math.max(e,Z),ot()));t(n),$(nt,String(n))},[]);return{width:e,wide:n,toggleWide:()=>{r(!n),$(rt,n?`0`:`1`)},onPointerDown:t=>{t.preventDefault();let n=t.clientX,r=e,a=e=>i(r+n-e.clientX),o=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),document.body.style.removeProperty(`cursor`),document.body.style.removeProperty(`user-select`)};document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`,window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o)},onKeyDown:t=>{let n=t.shiftKey?64:16;t.key===`ArrowLeft`?(t.preventDefault(),i(e+n)):t.key===`ArrowRight`&&(t.preventDefault(),i(e-n))},reset:()=>i(at)}}function ct(){let[e,t]=(0,U.useState)(()=>Q(it)===`chat`?`chat`:`steps`);return[e,e=>{t(e),$(it,e)}]}function lt({look:e,onChange:t}){let n=[{id:`steps`,label:m(`chat.steps`),Icon:pe},{id:`chat`,label:m(`chat.chat`),Icon:B}];return(0,W.jsx)(`fieldset`,{"aria-label":m(`chat.view`),className:`m-0 flex min-w-0 rounded-full border-0 bg-paper-2 p-0.5`,children:n.map(({id:n,label:r,Icon:i})=>(0,W.jsxs)(`button`,{type:`button`,"aria-pressed":e===n,title:r,onClick:()=>t(n),className:v(`inline-flex h-7 items-center gap-1.5 rounded-full px-2.5 font-medium text-[0.75rem] transition coarse:h-9`,e===n?`bg-card text-ink shadow-soft`:`text-ink-3 hover:text-ink`),children:[(0,W.jsx)(i,{className:`size-3.5`}),(0,W.jsx)(`span`,{className:`max-sm:hidden`,children:r})]},n))})}function ut({header:e,actions:t,onClose:n,children:r}){let i=st();return(0,W.jsx)(`div`,{className:`fixed inset-0 z-50 flex justify-end bg-[oklch(20%_0.01_60/0.22)] backdrop-blur-[1px]`,onClick:n,children:(0,W.jsxs)(`div`,{className:v(`relative flex h-full w-full animate-rise flex-col bg-background shadow-overlay`,!i.wide&&`sm:w-[var(--drawer)]`),style:{"--drawer":`${i.width}px`},onClick:e=>e.stopPropagation(),children:[i.wide?null:(0,W.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":m(`editor.resize`),"aria-valuenow":i.width,tabIndex:0,title:m(`editor.resize`),onPointerDown:i.onPointerDown,onKeyDown:i.onKeyDown,onDoubleClick:i.reset,className:`group -left-2.5 absolute inset-y-0 z-10 hidden w-5 cursor-col-resize outline-none sm:block`,children:(0,W.jsx)(`span`,{className:`-translate-y-1/2 absolute top-1/2 left-[7px] h-12 w-1.5 rounded-full bg-ink-4/40 transition group-hover:bg-ember/70 group-focus-visible:bg-ember group-active:h-16 group-active:bg-ember`})}),(0,W.jsxs)(`div`,{className:`flex h-14 shrink-0 items-center gap-3 px-4`,children:[(0,W.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:e}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[t,(0,W.jsx)(D,{label:m(i.wide?`runDrawer.shrink`:`runDrawer.expand`),onClick:i.toggleWide,className:`max-sm:hidden`,children:i.wide?(0,W.jsx)(me,{className:`size-4`}):(0,W.jsx)(ae,{className:`size-4`})}),(0,W.jsx)(D,{label:m(`editor.close`),onClick:n,children:(0,W.jsx)(d,{className:`size-5`})})]})]}),(0,W.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:r})]})})}export{De as _,He as a,fe as b,Be as c,J as d,Y as f,Te as g,G as h,tt as i,ze as l,Oe as m,ut as n,We as o,Le as p,ct as r,Ve as s,lt as t,je as u,Ee as v,ce as x,H as y};