@engenty/wizards-runtime 0.11.0 → 0.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/README.md +25 -6
  2. package/apps/runtime/dist/app.js +5 -0
  3. package/apps/runtime/dist/authoring/guide.js +19 -19
  4. package/apps/runtime/dist/docs/dev/index.md +1 -0
  5. package/apps/runtime/dist/docs/dev/licensing.md +60 -0
  6. package/apps/runtime/dist/docs/dev/meta.json +2 -1
  7. package/apps/runtime/dist/docs/dev/plugins/runners.md +2 -2
  8. package/apps/runtime/dist/docs/dev/wizard-format/index.md +4 -4
  9. package/apps/runtime/dist/docs/dev/wizard-format/meta.json +1 -1
  10. package/apps/runtime/dist/docs/dev/wizard-format/motion-graphics-steps.md +47 -0
  11. package/apps/runtime/dist/docs/dev/wizard-format/review-and-result.md +2 -2
  12. package/apps/runtime/dist/docs/dev/wizard-format/views-and-widgets.md +2 -2
  13. package/apps/runtime/dist/docs/dev/wizard-format/wizard-file.md +4 -4
  14. package/apps/runtime/dist/docs/user-guide/space.md +5 -1
  15. package/apps/runtime/dist/docs/user-guide/steps.md +12 -12
  16. package/apps/runtime/dist/engine/requirements.js +7 -7
  17. package/apps/runtime/dist/engine/runner.js +8 -1
  18. package/apps/runtime/dist/engine/steps.js +3 -3
  19. package/apps/runtime/dist/files/storage.js +3 -3
  20. package/apps/runtime/dist/index.js +3 -0
  21. package/apps/runtime/dist/limits.js +16 -0
  22. package/apps/runtime/dist/manage.js +19 -0
  23. package/apps/runtime/dist/models.js +8 -8
  24. package/apps/runtime/dist/{film → motion-graphics}/project.js +54 -54
  25. package/apps/runtime/dist/{film → motion-graphics}/sounds.js +3 -3
  26. package/apps/runtime/dist/{film → motion-graphics}/step.js +37 -37
  27. package/apps/runtime/dist/{film → motion-graphics}/tools.js +1 -1
  28. package/apps/runtime/dist/render/downloads.js +2 -2
  29. package/apps/runtime/dist/render/guard.js +1 -1
  30. package/apps/runtime/dist/routes/delivery.js +1 -1
  31. package/apps/runtime/dist/routes/internal.js +1 -1
  32. package/apps/runtime/dist/routes/marketplace.js +4 -3
  33. package/apps/runtime/dist/routes/reports.js +80 -0
  34. package/apps/runtime/dist/routes/runs.js +25 -1
  35. package/apps/runtime/dist/services/brand.js +1 -1
  36. package/apps/runtime/dist/services/manage-reports.js +190 -0
  37. package/apps/runtime/dist/services/marketplace.js +33 -1
  38. package/apps/runtime/dist/services/pages.js +1 -1
  39. package/apps/runtime/dist/services/shipped-fonts.js +2 -1
  40. package/apps/runtime/dist/services/wizards.js +7 -0
  41. package/apps/runtime/dist/widgets/render.js +9 -9
  42. package/apps/runtime/dist/widgets/runtime.js +3 -3
  43. package/apps/runtime/dist/widgets/step.js +20 -20
  44. package/apps/web/dist/assets/AboutDialog-Bx6j5lZO.js +1 -0
  45. package/apps/web/dist/assets/ChangelogDialog-C620Sw_A.js +1 -0
  46. package/apps/web/dist/assets/CodeEditor-DifBNaqQ.js +2 -0
  47. package/apps/web/dist/assets/EditorPage-DWf9QG-U.js +3 -0
  48. package/apps/web/dist/assets/{FlowPreview-BV1NJ0rF.js → FlowPreview-ucwQ_dTr.js} +1 -1
  49. package/apps/web/dist/assets/{Harness-DYviBlHB.js → Harness-Br0Z_anI.js} +2 -2
  50. package/apps/web/dist/assets/Marketplace-CFDpVMWM.js +2 -0
  51. package/apps/web/dist/assets/NewWizardChannels-Cau6XSbl.js +1 -0
  52. package/apps/web/dist/assets/NewWizardPage-CrFqInHR.js +7 -0
  53. package/apps/web/dist/assets/OnboardingPage-BZk42_R7.js +1 -0
  54. package/apps/web/dist/assets/PreviewPane-D9n6tylf.js +10 -0
  55. package/apps/web/dist/assets/ProjectPage-CteRfxpz.js +1 -0
  56. package/apps/web/dist/assets/PublicRunner-CNanj6-w.js +1 -0
  57. package/apps/web/dist/assets/ReadOnly-DGBDtXFP.js +1 -0
  58. package/apps/web/dist/assets/SettingsPage-ClFQewEL.js +2 -0
  59. package/apps/web/dist/assets/SetupPage-k9gyFvow.js +1 -0
  60. package/apps/web/dist/assets/SharePage-BhWeqF3w.js +1 -0
  61. package/apps/web/dist/assets/changelog-BrhGlZT6.js +1 -0
  62. package/apps/web/dist/assets/{coins-DQ91VJAB.js → coins-CwURUZyt.js} +1 -1
  63. package/apps/web/dist/assets/dist-BwhPmMDu.js +1 -0
  64. package/apps/web/dist/assets/dist-DVpDdhG9.js +1 -0
  65. package/apps/web/dist/assets/dist-DzdNG7Sf.js +10 -0
  66. package/apps/web/dist/assets/i18n-DEmaSTJV.js +55 -0
  67. package/apps/web/dist/assets/index-ClNm5JaU.js +34 -0
  68. package/apps/web/dist/assets/index-DImS12WR.css +1 -0
  69. package/apps/web/dist/assets/json-D2GVvTXK.js +1 -0
  70. package/apps/web/dist/assets/markdown-DwdMW7q0.js +29 -0
  71. package/apps/web/dist/assets/{oss-credits-C2JUsf2d.js → oss-credits-C6bPkfSE.js} +1 -1
  72. package/apps/web/dist/assets/{phone-jIuRIwyg.js → phone-DTxGRwhK.js} +1 -1
  73. package/apps/web/dist/assets/runners-BMOIT6Ze.js +1 -0
  74. package/apps/web/dist/assets/session-xJpGiTU_.js +2 -0
  75. package/apps/web/dist/assets/{settings-menu-CoLUNJGQ.js → settings-menu-DcPFhgGA.js} +1 -1
  76. package/apps/web/dist/assets/theme-DTi1Zdw8.js +11 -0
  77. package/apps/web/dist/assets/ui-gsqxnFnT.js +83 -0
  78. package/apps/web/dist/assets/{upload-BcOvBWHS.js → upload-BkwjFS-0.js} +1 -1
  79. package/apps/web/dist/assets/{useMutation-CD7HmAxR.js → useMutation-BS-U9g_a.js} +1 -1
  80. package/apps/web/dist/assets/{volume-2-D2To9w5D.js → volume-2-CYOgux-z.js} +1 -1
  81. package/apps/web/dist/assets/{wrench-B98ubRvB.js → wrench-DIfUvYPN.js} +1 -1
  82. package/apps/web/dist/index.html +9 -8
  83. package/apps/web/dist/mcp/flow.html +32 -32
  84. package/node_modules/@engenty/wizards/dist/plugin/index.d.ts +1 -1
  85. package/node_modules/@engenty/wizards-shared/dist/definition.d.ts +11 -11
  86. package/node_modules/@engenty/wizards-shared/dist/definition.js +24 -23
  87. package/node_modules/@engenty/wizards-shared/dist/engenty/data-tables/columns-value.js +1 -0
  88. package/node_modules/@engenty/wizards-shared/dist/fit.d.ts +7 -2
  89. package/node_modules/@engenty/wizards-shared/dist/fit.js +23 -6
  90. package/node_modules/@engenty/wizards-shared/dist/marketplace-entry.d.ts +1 -1
  91. package/node_modules/@engenty/wizards-shared/dist/marketplace-entry.js +1 -1
  92. package/node_modules/@engenty/wizards-shared/dist/marketplace.d.ts +9 -7
  93. package/node_modules/@engenty/wizards-shared/dist/marketplace.js +7 -23
  94. package/node_modules/@engenty/wizards-shared/dist/run.d.ts +15 -14
  95. package/node_modules/@engenty/wizards-shared/dist/run.js +30 -28
  96. package/node_modules/@engenty/wizards-shared/dist/runners.d.ts +1 -1
  97. package/node_modules/@engenty/wizards-shared/dist/runners.js +5 -5
  98. package/node_modules/@engenty/wizards-shared/dist/store.d.ts +1 -1
  99. package/node_modules/@engenty/wizards-shared/dist/store.js +1 -2
  100. package/node_modules/@engenty/wizards-shared/dist/theme-look.d.ts +39 -0
  101. package/node_modules/@engenty/wizards-shared/dist/theme-look.js +112 -0
  102. package/node_modules/@engenty/wizards-shared/dist/theme.d.ts +0 -38
  103. package/node_modules/@engenty/wizards-shared/dist/theme.js +1 -108
  104. package/node_modules/@engenty/wizards-shared/dist/wizard-package.js +1 -0
  105. package/package.json +1 -1
  106. package/plugin/.claude-plugin/plugin.json +1 -1
  107. package/plugin/plugin.json +1 -1
  108. package/apps/runtime/dist/docs/dev/wizard-format/film-steps.md +0 -47
  109. package/apps/web/dist/assets/AboutDialog-9VcgySrQ.js +0 -1
  110. package/apps/web/dist/assets/ChangelogDialog-BXvT2VMU.js +0 -1
  111. package/apps/web/dist/assets/EditorPage-Cvzd0nah.js +0 -4
  112. package/apps/web/dist/assets/Marketplace-DTSg7_U7.js +0 -2
  113. package/apps/web/dist/assets/NewWizardChannels-DiujJzOR.js +0 -1
  114. package/apps/web/dist/assets/NewWizardPage-CngUh9g-.js +0 -7
  115. package/apps/web/dist/assets/OnboardingPage-DFKJnWtw.js +0 -1
  116. package/apps/web/dist/assets/PreviewPane-C0E9OLzB.js +0 -9
  117. package/apps/web/dist/assets/ProjectPage-CYDX-JYc.js +0 -1
  118. package/apps/web/dist/assets/PublicRunner-CkRO_Pw-.js +0 -1
  119. package/apps/web/dist/assets/ReadOnly-E-h9y_QO.js +0 -1
  120. package/apps/web/dist/assets/SettingsPage-BMgP3aRV.js +0 -2
  121. package/apps/web/dist/assets/SetupPage-DBO_rzj7.js +0 -1
  122. package/apps/web/dist/assets/SharePage-BvvmYB5N.js +0 -1
  123. package/apps/web/dist/assets/changelog-zllICQ4q.js +0 -1
  124. package/apps/web/dist/assets/index-Bjn557f1.js +0 -20
  125. package/apps/web/dist/assets/index-DN0VMwsS.css +0 -1
  126. package/apps/web/dist/assets/runners-DloOxEbh.js +0 -1
  127. package/apps/web/dist/assets/session-BpsCkDv6.js +0 -2
  128. package/apps/web/dist/assets/theme-2XjIQXH3.js +0 -11
  129. package/apps/web/dist/assets/ui-BIWmkPh6.js +0 -137
  130. /package/apps/runtime/dist/{film → motion-graphics}/skills.js +0 -0
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FlowPreview-BV1NJ0rF.js","assets/rolldown-runtime-hePW80VL.js","assets/jsx-runtime-BNakU3Ej.js","assets/ui-BIWmkPh6.js","assets/preload-helper-DpV6A1kQ.js","assets/esm-BdxDT9Km.js","assets/react-dom-hf6EcyAr.js"])))=>i.map(i=>d[i]);
2
- import{n as e,r as t}from"./rolldown-runtime-hePW80VL.js";import{n,t as r}from"./jsx-runtime-BNakU3Ej.js";import{Bt as i,Cr as a,Er as o,G as s,Hr as c,Mr as l,Rr as u,Rt as d,Tr as f,Vr as p,Vt as m,W as h,Wr as g,Yr as _,Yt as v,ci as y,cr as b,di as x,en as S,gr as ee,ji as C,lr as w,nn as T,oi as E,pn as te,ri as D,si as ne,sn as O,ui as k,xi as re,zt as A}from"./ui-BIWmkPh6.js";import{t as j}from"./useMutation-CD7HmAxR.js";import{t as ie}from"./preload-helper-DpV6A1kQ.js";import{i as M,n as ae,r as oe,t as se}from"./volume-2-D2To9w5D.js";import{n as ce,t as le}from"./coins-DQ91VJAB.js";import{d as ue,h as de,k as fe,x as pe}from"./session-BpsCkDv6.js";import{c as me,s as he}from"./engenty-CNjaZCVM.js";var ge=class extends y{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:a,isError:o,isRefetchError:s}=r,c=n.fetchMeta?.fetchMore?.direction,l=o&&c===`forward`,u=i&&c===`forward`,d=o&&c===`backward`,f=i&&c===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:k(t,n.data),hasPreviousPage:x(t,n.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:d,isFetchingPreviousPage:f,isRefetchError:s&&!l&&!d,isRefetching:a&&!u&&!f}}};function _e(e,t){return ne(e,ge,t)}var ve={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`}]]};ve.node;var N=_(ve),ye={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`]};ye.node;var be=_(ye),xe={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`}]]};xe.node;var Se=_(xe),Ce={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`}]]};Ce.node;var we=_(Ce),Te={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`}]]};Te.node;var P=_(Te),Ee={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`}]]};Ee.node;var F=_(Ee),De={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`}]]};De.node;var I=_(De),Oe={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`}]]};Oe.node;var L=_(Oe),ke={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`}]]};ke.node;var Ae=_(ke),je={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`}]]};je.node;var Me=_(je),Ne={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`}]]};Ne.node;var R=_(Ne),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=_(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=_(Ie),Re={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`}]]};Re.node;var z=_(Re),ze={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`}]]};ze.node;var Be=_(ze),Ve={name:`terminal`,size:24,node:[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]};Ve.node;var He=_(Ve),Ue={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`}]]};Ue.node;var We=_(Ue),Ge={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`]};Ge.node;var B=_(Ge),Ke=[`text`,`document`,`table`,`image`,`video`,`audio`,`dashboard`],qe=[`any`,`trades`,`gastronomy`,`hospitality`,`realEstate`,`retail`,`health`,`professional`,`agency`,`events`,`publicSector`],Je=[`marketing`,`sales`,`accounting`,`service`,`research`,`hr`,`operations`,`website`,`visuals`,`inquiries`,`advice`],Ye=[`text`,`web`,`browser`,`documents`,`image`,`video`,`speech`,`listening`,`code`,`connectors`,`film`],Xe=[`free`,`pro`],Ze={"format.text":`Text`,"format.document":`Document (PDF, Word)`,"format.table":`Table`,"format.image":`Image`,"format.video":`Video`,"format.audio":`Audio`,"format.dashboard":`Dashboard`,"industry.any":`Any industry`,"industry.trades":`Trades`,"industry.gastronomy":`Food service`,"industry.hospitality":`Hotels & tourism`,"industry.realEstate":`Real estate`,"industry.retail":`Retail`,"industry.health":`Health`,"industry.professional":`Professional services`,"industry.agency":`Agency & marketing`,"industry.events":`Events`,"industry.publicSector":`Associations & public sector`,"useCase.marketing":`Marketing & social media`,"useCase.sales":`Offers & sales`,"useCase.accounting":`Accounting & receipts`,"useCase.service":`Customer service`,"useCase.research":`Research & analysis`,"useCase.hr":`HR & applications`,"useCase.operations":`Planning & operations`,"useCase.website":`Website helpers`,"useCase.visuals":`Images & video`,"useCase.inquiries":`Inquiries & bookings`,"useCase.advice":`Advice & pricing`,"capability.text":`Writes text`,"capability.web":`Web search`,"capability.browser":`Drives a browser`,"capability.documents":`Reads documents & photos`,"capability.image":`Makes images`,"capability.video":`Makes video`,"capability.speech":`Speech output`,"capability.listening":`Understands voice notes`,"capability.code":`Runs code`,"capability.connectors":`Connected accounts & systems`,"capability.film":`Films with Claude Code (on your subscription)`,"cost.low":`low cost`,"cost.medium":`medium cost`,"cost.high":`high cost`,"plan.free":`Free`,"plan.pro":`Pro`,"outline.otherwise":`otherwise`,"outline.and":`{first} and {second}`,"outline.with":`with {name}`,"outline.without":`without {name}`,"outline.contains":`{name} contains {value}`},Qe={en:Ze,de:{"format.text":`Text`,"format.document":`Dokument (PDF, Word)`,"format.table":`Tabelle`,"format.image":`Bild`,"format.video":`Video`,"format.audio":`Audio`,"format.dashboard":`Dashboard`,"industry.any":`Jede Branche`,"industry.trades":`Handwerk`,"industry.gastronomy":`Gastronomie`,"industry.hospitality":`Hotel & Tourismus`,"industry.realEstate":`Immobilien`,"industry.retail":`Handel`,"industry.health":`Gesundheit`,"industry.professional":`Kanzlei & Beratung`,"industry.agency":`Agentur & Marketing`,"industry.events":`Veranstaltungen`,"industry.publicSector":`Vereine & Öffentliches`,"useCase.marketing":`Marketing & Social Media`,"useCase.sales":`Angebote & Verkauf`,"useCase.accounting":`Buchhaltung & Belege`,"useCase.service":`Kundenservice`,"useCase.research":`Recherche & Analyse`,"useCase.hr":`Personal & Bewerbungen`,"useCase.operations":`Planung & Abläufe`,"useCase.website":`Helfer für die Website`,"useCase.visuals":`Bilder & Video`,"useCase.inquiries":`Anfragen & Termine`,"useCase.advice":`Beratung & Preise`,"capability.text":`Text schreiben`,"capability.web":`Websuche`,"capability.browser":`Browser bedienen`,"capability.documents":`Dokumente & Fotos lesen`,"capability.image":`Bilder erzeugen`,"capability.video":`Videos erzeugen`,"capability.speech":`Sprachausgabe`,"capability.listening":`Sprachnotizen verstehen`,"capability.code":`Code ausführen`,"capability.connectors":`Verbundene Konten & Systeme`,"capability.film":`Filme mit Claude Code (auf deinem Abo)`,"cost.low":`günstig`,"cost.medium":`mittel`,"cost.high":`teuer`,"plan.free":`Kostenlos`,"plan.pro":`Pro`,"outline.otherwise":`sonst`,"outline.and":`{first} und {second}`,"outline.with":`mit {name}`,"outline.without":`ohne {name}`,"outline.contains":`{name} enthält {value}`}};function $e(e,t,n,r){let i=`${e}.${t}`;return i in Ze?te(Qe,i,n,r):t}var V=t(n(),1);function et(e){switch(e.type){case`page`:return R;case`agent`:return M;case`generate`:return e.asset===`image`?L:e.asset===`video`?w:e.asset===`dashboard`?Ae:l;case`widget`:return N;case`surface`:return Me;case`film`:return P;case`review`:return F;case`result`:return I}return B}var tt={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 nt(e){return O(`type.${e.type}`)}var rt=[`web_search`,`web_fetch`,`browser`,`sandbox`,`image`,`http`,`pages`,`code`];function it(e){return rt.includes(e)?O(`tool.${e}`):e}function at(e){switch(e.type){case`page`:return e.fields.map(e=>e.label).join(` · `);case`agent`:{let t=e.tools.map(it),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?O(`editor.reviewEditable`):null,e.regenerate?O(`editor.reviewRedo`):null].filter(Boolean).join(` · `);case`result`:return e.deliverables.map(e=>`${e.label??e.from} (${e.formats.join(`, `)})`).join(` · `)}return``}var ot=e({EntryDialog:()=>Q,MarketplaceBrowser:()=>wt,MarketplaceCards:()=>Ct,MarketplaceHits:()=>St,ProChip:()=>K,useSettled:()=>$}),H=t(r(),1),st=(0,V.lazy)(()=>ie(()=>import(`./FlowPreview-BV1NJ0rF.js`),__vite__mapDeps([0,1,2,3,4,5,6]))),ct={useCase:``,industry:``,format:``,capability:``,plan:``},U=(e,t)=>$e(e,t,T),lt={en:Se,de:we};function ut(e){if(e<1)return 1;let t=10**Math.floor(Math.log10(e));return Math.round(e/t)*t}function dt(e){return e.credits?O(`market.credits`,{n:ut(e.credits.credits)}):U(`cost`,e.costTier)}var ft={text:We,document:l,table:Be,image:L,video:w,audio:g,dashboard:be};function W({format:e,className:t}){let n=ft[e],r=U(`format`,e);return(0,H.jsx)(`span`,{title:r,className:`inline-flex`,children:(0,H.jsx)(n,{className:t,"aria-label":r,role:`img`})})}var pt=[`low`,`medium`,`high`];function G({entry:e}){let t=pt.indexOf(e.costTier)+1,n=lt[T];return(0,H.jsxs)(`span`,{title:dt(e),className:`inline-flex items-center gap-1`,children:[(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`inline-flex shrink-0`,children:pt.slice(0,t).map((e,t)=>(0,H.jsx)(`span`,{className:S(`rounded-full bg-(--coin-bg,var(--color-card))`,t>0&&`-ml-1.5`),children:(0,H.jsx)(n,{className:`size-4`})},e))}),U(`cost`,e.costTier)]})}function K(){return(0,H.jsx)(i,{tone:`ember`,title:O(`market.proHint`),children:O(`market.pro`)})}function mt({plugin:e}){return(0,H.jsx)(i,{icon:(0,H.jsx)(Fe,{className:`size-3.5`}),title:O(`market.fromPlugin`,{name:e.name}),children:e.name})}function q({entry:e,onOpen:t}){return(0,H.jsxs)(A,{role:`button`,tabIndex:0,onClick:t,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t())},className:S(`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,H.jsx)(`span`,{className:`-top-4 pointer-events-none absolute right-4`,children:(0,H.jsx)(pe,{kind:e.avatar,costume:e.costume,size:68})}),(0,H.jsxs)(`div`,{className:`min-w-0 pr-20`,children:[(0,H.jsxs)(`div`,{className:`font-display font-semibold text-[0.9375rem]`,children:[e.title,e.plan===`pro`?(0,H.jsx)(`span`,{className:`ml-1.5 inline-flex align-middle`,children:(0,H.jsx)(K,{})}):null,e.starred?(0,H.jsx)(z,{className:`ml-1.5 inline size-3.5 fill-amber align-[-2px] text-amber`,"aria-label":O(`market.starred`)}):null]}),(0,H.jsx)(`div`,{className:`mt-0.5 text-[0.8125rem] text-ink-3 leading-snug`,children:e.pitch})]}),(0,H.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,H.jsx)(mt,{plugin:e.plugin}):null,e.needs?.length?(0,H.jsx)(i,{tone:`warn`,children:O(`market.needsPro`,{list:e.needs.join(`, `)})}):e.usable&&e.missing.length?(0,H.jsx)(i,{tone:`warn`,children:O(`market.missing`,{list:Y(e.missing)})}):e.usable?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,H.jsx)(u,{className:`size-3.5`}),` `,O(`market.minutes`,{n:e.effort.minutes})]}),(0,H.jsx)(G,{entry:e}),e.optional?.length?(0,H.jsx)(i,{title:O(`market.optionalHint`,{list:Y(e.optional)}),children:O(`market.without`,{list:Y(e.optional)})}):null,(0,H.jsx)(`span`,{className:`ml-auto inline-flex items-center gap-1.5`,children:e.formats.map(e=>(0,H.jsx)(W,{format:e,className:`size-4`},e))})]}):(0,H.jsx)(i,{tone:`warn`,children:O(`market.needsUpdate`)})]})]})}function J({title:e,children:t}){return(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`mb-1.5 font-medium text-[0.75rem] text-ink-3 uppercase tracking-[0.06em]`,children:e}),t]})}var Y=e=>e.map(e=>U(`capability`,e)).join(`, `),ht={text:a,web:oe,browser:f,documents:Le,image:L,video:w,speech:se,listening:o,code:He,connectors:ae,film:P};function gt(e){switch(e.type){case`page`:return R;case`agent`:return M;case`generate`:return e.asset===`image`?L:e.asset===`video`?w:e.asset===`voice`?se:e.asset===`dashboard`?be:l;case`widget`:return e.video?P:N;case`surface`:return N;case`film`:return P;case`review`:return F;case`result`:return I}return B}function _t(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 vt(e){let t=_t(e);return e.map(e=>({id:e.id,title:e.title,icon:gt(e),tone:tt[e.type]??`bg-paper-2 text-ink-2`,optional:t.has(e.id),branches:e.branches}))}function X({title:e,children:t}){return(0,H.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 Z({icon:e,children:t,more:n}){return(0,H.jsxs)(`div`,{className:`flex gap-2.5`,children:[(0,H.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:e}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`div`,{className:`text-[0.875rem] text-ink leading-snug`,children:t}),n?(0,H.jsx)(`div`,{className:`text-[0.75rem] text-ink-3 leading-snug`,children:n}):null]})]})}function yt({className:e,children:t}){let n=(0,V.useRef)(null),[r,i]=(0,V.useState)({above:!1,below:!1});(0,V.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,H.jsx)(`div`,{ref:n,className:e,style:{maskImage:a,WebkitMaskImage:a},children:(0,H.jsx)(`div`,{children:t})})}function Q({id:e,fallback:t,onClose:n,onUse:r,busy:i}){let a=C(),o=D(),c=E({queryKey:[`marketplace-entry`,e,T],queryFn:()=>s.get(`/api/studio/marketplace/${encodeURIComponent(e)}?lang=${T}`),enabled:!!e,retry:!1}),l=c.data??t,f=j({mutationFn:t=>{let n=`/api/studio/marketplace/${encodeURIComponent(e)}/star`;return t?s.put(n):s.del(n)},onSuccess:()=>Promise.all([a.invalidateQueries({queryKey:[`marketplace`]}),a.invalidateQueries({queryKey:[`marketplace-entry`,e]})])}),p=fe()===`dark`,h=he[me[l?.avatar||`round`]],g=p?`var(--card)`:`color-mix(in oklch, ${h??`var(--ink-4)`} 14%, var(--paper-2))`;return(0,H.jsx)(m,{open:!!e,onClose:n,wide:!0,bare:!0,children:l?(0,H.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,H.jsx)(`button`,{type:`button`,"aria-label":O(`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,H.jsx)(b,{className:`size-4`})}),(0,H.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:g,"--coin-bg":g},children:[(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 overflow-hidden sm:rounded-t-2xl`,children:(0,H.jsx)(`span`,{className:S(`-top-28 -right-10 absolute size-80 rounded-full bg-white blur-3xl`,p?`opacity-[0.14]`:`opacity-80`)})}),(0,H.jsx)(`div`,{className:`-bottom-5 absolute right-9 z-10 max-sm:hidden`,children:(0,H.jsx)(pe,{kind:l.avatar,costume:l.costume,size:104})}),(0,H.jsxs)(`div`,{className:`relative sm:pr-36`,children:[(0,H.jsx)(`h2`,{className:`font-display font-semibold text-[1.375rem] leading-tight tracking-tight max-sm:pr-10`,children:l.title}),(0,H.jsx)(`p`,{className:`mt-1 text-[0.875rem] text-ink-2 leading-snug`,children:c.data?.description||l.pitch})]}),l.usable?(0,H.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,H.jsxs)(X,{title:O(`market.duration`),children:[(0,H.jsx)(u,{className:`size-4 text-ink-3`}),O(`market.minutes`,{n:l.effort.minutes})]}),(0,H.jsx)(X,{title:O(`market.cost`),children:(0,H.jsx)(G,{entry:l})}),(0,H.jsx)(X,{title:O(`market.result`),children:l.formats.map(e=>(0,H.jsx)(W,{format:e,className:`size-4`},e))})]}):null]}),l.usable?(0,H.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,H.jsxs)(`div`,{className:`flex flex-col gap-5 sm:min-h-0 sm:overflow-y-auto`,children:[(0,H.jsx)(J,{title:O(`market.duration`),children:(0,H.jsx)(Z,{icon:(0,H.jsx)(u,{className:`size-4 text-moss`}),more:O(`market.durationHint`,{n:l.effort.fields}),children:O(`market.minutes`,{n:l.effort.minutes})})}),(0,H.jsx)(J,{title:O(`market.cost`),children:(0,H.jsx)(Z,{icon:(0,H.jsx)(le,{className:`size-4 text-amber`}),more:l.credits?O(`market.creditsHint`):void 0,children:(0,H.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2`,children:[(0,H.jsx)(G,{entry:l}),l.credits?(0,H.jsx)(`span`,{className:`text-ink-2`,children:O(`market.creditsRange`,{n:ut(l.credits.credits)})}):null]})})}),(0,H.jsx)(J,{title:O(`market.result`),children:(0,H.jsx)(`div`,{className:`flex flex-col gap-2`,children:(c.data?.results??[]).map(e=>(0,H.jsx)(Z,{icon:(0,H.jsx)(W,{format:e.kind,className:`size-4 text-ember-strong`}),more:e.formats.map(e=>e.toUpperCase()).join(` · `),children:e.title},e.title))})}),(0,H.jsx)(J,{title:O(`market.needs`),children:(0,H.jsx)(`ul`,{className:`flex flex-col gap-2`,children:l.capabilities.map(e=>{let t=ht[e],n=l.missing.includes(e),r=l.optional?.includes(e);return(0,H.jsxs)(`li`,{className:S(`flex items-center gap-2.5 text-[0.875rem]`,n?`text-ink-3`:`text-ink-2`),children:[(0,H.jsx)(t,{className:S(`size-4 shrink-0`,n?`text-rose`:r?`text-amber`:`text-cobalt`)}),U(`capability`,e),n?(0,H.jsx)(`span`,{className:`text-[0.75rem] text-rose`,children:O(`market.unavailable`)}):r?(0,H.jsx)(`span`,{className:`text-[0.75rem] text-amber`,children:O(`market.optional`)}):null]},e)})})})]}),(0,H.jsxs)(`div`,{className:`flex flex-col sm:min-h-0`,children:[(0,H.jsx)(`div`,{className:`mb-1.5 shrink-0 font-medium text-[0.75rem] text-ink-3 uppercase tracking-[0.06em]`,children:O(`market.steps`)}),(0,H.jsx)(yt,{className:`-mr-2 overscroll-contain pt-1 pr-2 pl-1 sm:min-h-0 sm:flex-1 sm:overflow-y-auto`,children:c.isLoading?(0,H.jsx)(v,{className:`size-5 text-ink-3`}):(0,H.jsx)(V.Suspense,{fallback:(0,H.jsx)(v,{className:`size-5 text-ink-3`}),children:(0,H.jsx)(st,{steps:vt(c.data?.outline??[])})})})]})]}):(0,H.jsx)(`div`,{className:`flex-1 px-5 pt-6 sm:px-7`,children:(0,H.jsx)(`p`,{className:`rounded-lg bg-amber-tint p-3 text-[0.875rem] text-ink-2`,children:O(`market.needsUpdateHint`)})}),(0,H.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:[l.plugin?(0,H.jsx)(`span`,{className:`mr-auto flex items-center`,children:(0,H.jsx)(mt,{plugin:l.plugin})}):(0,H.jsxs)(d,{variant:`ghost`,className:`mr-auto`,title:O(`market.starHint`),"aria-pressed":l.starred,busy:f.isPending,onClick:()=>f.mutate(!l.starred),children:[(0,H.jsx)(z,{className:S(`size-4`,l.starred&&`fill-amber text-amber`)}),(0,H.jsx)(`span`,{className:`max-sm:sr-only`,children:O(l.starred?`market.starred`:`market.star`)})]}),(0,H.jsx)(d,{variant:`secondary`,onClick:n,children:O(`common.close`)}),l.usable&&l.missing.length?(0,H.jsx)(d,{variant:`secondary`,onClick:()=>o(`/settings/models`),children:O(`editor.models.settings`)}):null,r?(0,H.jsx)(d,{disabled:!l.usable||l.missing.length>0||!!l.needs?.length,title:l.needs?.length?O(`market.needsProHint`,{list:l.needs.join(`, `)}):l.missing.length?O(`market.missingHint`,{list:Y(l.missing)}):l.optional?.length?O(`market.optionalHint`,{list:Y(l.optional)}):void 0,busy:i,onClick:()=>r(l),children:O(`market.use`)}):null]})]}):(0,H.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:c.isLoading?(0,H.jsx)(v,{className:`size-6 text-ink-3`}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`p`,{children:O(`market.notFound`)}),(0,H.jsx)(d,{variant:`secondary`,onClick:n,children:O(`common.close`)})]})})})}function bt({name:e,value:t,options:n,onChange:r}){let[i,a]=(0,V.useState)(!1),o=(0,V.useRef)(null);(0,V.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,H.jsxs)(`div`,{ref:o,className:`relative`,children:[(0,H.jsxs)(`div`,{className:S(`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,H.jsx)(`button`,{type:`button`,"aria-haspopup":`listbox`,"aria-expanded":i,onClick:()=>a(!i),className:S(`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,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`text-ink-3`,children:e}),(0,H.jsx)(`span`,{className:`font-medium`,children:s.label})]}):(0,H.jsxs)(H.Fragment,{children:[e,(0,H.jsx)(p,{className:S(`size-3.5 transition`,i&&`rotate-180`)})]})}),s?(0,H.jsx)(`button`,{type:`button`,"aria-label":`${e}: ${O(`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,H.jsx)(b,{className:`size-3.5`})}):null]}),i?(0,H.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,H.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:S(`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,H.jsx)(`span`,{className:`flex-1 whitespace-nowrap`,children:e.label}),e.value===t?(0,H.jsx)(c,{className:`size-4 text-ember`}):e.unavailable?(0,H.jsx)(`span`,{className:`whitespace-nowrap text-[0.75rem] text-ink-4`,children:O(`market.unavailable`)}):(0,H.jsx)(`span`,{className:`text-[0.75rem] text-ink-4 tabular-nums`,children:e.count})]},e.value))}):null]})}function $(e,t){let[n,r]=(0,V.useState)(e);return(0,V.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n}var xt=60;function St({query:e,onUse:t,busy:n,limit:r=6}){let[i,a]=(0,V.useState)(null),o=$(e.trim(),250),c=E({queryKey:[`marketplace`,T,o,`hits`,r],queryFn:()=>s.get(`/api/studio/marketplace?${new URLSearchParams({lang:T,limit:String(r),offset:`0`,q:o})}`),enabled:!!o,placeholderData:re}),l=o?c.data?.entries??[]:[];return l.length?(0,H.jsxs)(`section`,{className:`mt-10`,children:[(0,H.jsxs)(`h2`,{className:`mb-5 flex items-center gap-2 font-medium text-[0.8125rem] text-ink-3 uppercase tracking-[0.08em]`,children:[O(`market.hits`),c.isFetching?(0,H.jsx)(v,{className:`size-3.5`}):null]}),(0,H.jsx)(`div`,{className:`flex flex-col gap-4 sm:grid sm:grid-cols-2 lg:grid-cols-3`,children:l.map(e=>(0,H.jsx)(q,{entry:e,onOpen:()=>a(e.id)},e.id))}),(0,H.jsx)(Q,{id:i,fallback:l.find(e=>e.id===i)??null,onClose:()=>a(null),onUse:t,busy:n})]}):null}function Ct({entries:e}){let t=C(),n=D(),{project:r}=ue(),i=de()&&!!r&&!r?.readOnly,[a,o]=(0,V.useState)(null),c=j({mutationFn:e=>s.post(`/api/studio/wizards`,{projectId:r.id,starterId:e,lang:T}),onSuccess:async({id:e})=>{await t.invalidateQueries({queryKey:h.spaces()}),await t.invalidateQueries({queryKey:[`wizards`]}),o(null),n(`/edit/${e}`)}});return(0,H.jsxs)(`div`,{className:`@container mt-3`,children:[(0,H.jsx)(`div`,{className:`flex flex-col gap-4 @xl:grid @xl:grid-cols-2`,children:e.map(e=>(0,H.jsx)(q,{entry:e,onOpen:()=>o(e.id)},e.id))}),c.error?(0,H.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-rose`,children:c.error.message}):null,(0,H.jsx)(Q,{id:a,fallback:e.find(e=>e.id===a)??null,onClose:()=>o(null),onUse:i?e=>!c.isPending&&c.mutate(e.id):void 0,busy:c.isPending})]})}function wt({onUse:e,busy:t,open:n,search:r,onGuestOpen:i}){let[a,o]=(0,V.useState)(``);(0,V.useEffect)(()=>{r&&o(r.text)},[r]);let[c,l]=(0,V.useState)(ct),[u,f]=(0,V.useState)(!1),[p,m]=(0,V.useState)(n??null),h=$(a.trim(),250),g=(0,V.useRef)(null);(0,V.useEffect)(()=>{let e=g.current;h&&e&&window.matchMedia(`(max-width: 639px)`).matches&&e.scrollIntoView({behavior:`smooth`,block:`start`})},[h]);let _=_e({queryKey:[`marketplace`,T,h,c,u],queryFn:({pageParam:e})=>{let t=new URLSearchParams({lang:T,limit:String(xt),offset:String(e)});h&&t.set(`q`,h);for(let[e,n]of Object.entries(c))n&&t.set(e,n);return u&&t.set(`starred`,`1`),s.get(`/api/${i?`guest`:`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:re}),y=_.data?.pages[0],x=_.data?.pages.flatMap(e=>e.entries)??[],C=y?.all??0,w=a.trim()!==h||_.isFetching&&!_.isFetchingNextPage,E=(e,t,n,r)=>n.filter(t=>y?.facets[e]?.[t]!==void 0).map(n=>({value:n,label:U(t,n),icon:r?.(n),count:(y?.facets[e])[n]??0,unavailable:e===`capability`&&te.has(n)})),te=new Set(y?.unavailable??[]),D=E(`useCase`,`useCase`,Je),ne=[{key:`industry`,name:O(`market.industry`),options:E(`industry`,`industry`,qe)},{key:`format`,name:O(`market.format`),options:E(`format`,`format`,Ke,e=>(0,H.jsx)(W,{format:e,className:`size-4 text-ink-3`}))},{key:`plan`,name:O(`market.plan`),options:E(`plan`,`plan`,Xe)},{key:`capability`,name:O(`market.capability`),options:E(`capability`,`capability`,Ye,e=>{let t=ht[e];return(0,H.jsx)(t,{className:`size-4 text-ink-3`})})}],k=!!a.trim()||u||Object.values(c).some(Boolean),A=()=>{l(ct),o(``),f(!1)};if(_.isLoading)return(0,H.jsx)(`div`,{className:`flex justify-center py-10`,children:(0,H.jsx)(v,{className:`size-6 text-ink-3`})});let j=y?.offline?(0,H.jsxs)(`p`,{className:`mt-4 flex items-center justify-center gap-2 text-[0.8125rem] text-ink-3`,children:[(0,H.jsx)(ce,{className:`size-4 shrink-0`}),O(`market.offline`)]}):null;if(!C&&!k)return j;let ie=a?(0,H.jsx)(`button`,{type:`button`,"aria-label":O(`market.reset`),onClick:()=>o(``),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,H.jsx)(b,{className:`size-4`})}):null,M=e=>S(`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,H.jsxs)(`div`,{children:[(0,H.jsxs)(`label`,{ref:g,className:`relative mx-auto flex h-10 max-w-md scroll-mt-4 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:[w?(0,H.jsx)(v,{className:`size-4 shrink-0 text-ink-3`}):(0,H.jsx)(ee,{className:`size-4 shrink-0 text-ink-3`}),(0,H.jsx)(`input`,{type:`search`,value:a,onChange:e=>o(e.target.value),placeholder:O(`market.search`),"aria-label":O(`market.search`),className:`min-w-0 flex-1 bg-transparent text-[0.9375rem] outline-none placeholder:text-ink-4 [&::-webkit-search-cancel-button]:hidden`}),ie]}),j,(0,H.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:O(`market.all`)},...D].map(e=>(0,H.jsx)(`button`,{type:`button`,"aria-pressed":!u&&c.useCase===e.value,onClick:()=>{f(!1),l({...c,useCase:e.value})},className:M(!u&&c.useCase===e.value),children:e.label},e.value)),i?null:(0,H.jsxs)(`button`,{type:`button`,"aria-pressed":u,onClick:()=>f(!u),className:M(u),children:[(0,H.jsx)(z,{className:S(`size-3.5`,u&&`fill-amber text-amber`)}),O(`market.starred`)]})]}),(0,H.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-1 gap-y-2 sm:mt-6`,children:[u?null:ne.map(e=>(0,H.jsx)(bt,{name:e.name,value:c[e.key],options:e.options,onChange:t=>l({...c,[e.key]:t})},e.key)),(0,H.jsxs)(`span`,{className:`ml-auto flex items-center gap-3 whitespace-nowrap pl-2 text-[0.8125rem] text-ink-3`,children:[k?(0,H.jsxs)(`button`,{type:`button`,onClick:A,className:`inline-flex items-center gap-1 text-ember-strong underline-offset-2 hover:underline`,children:[(0,H.jsx)(b,{className:`size-3.5 max-sm:size-4`}),(0,H.jsx)(`span`,{className:`max-sm:sr-only`,children:O(`market.resetShort`)})]}):null,k?(0,H.jsx)(`span`,{className:`tabular-nums sm:hidden`,children:O(`market.countOfShort`,{n:y?.total??0,all:C})}):null,(0,H.jsx)(`span`,{className:S(`tabular-nums`,k&&`max-sm:hidden`),children:k?O(`market.countOf`,{n:y?.total??0,all:C}):O(`market.count`,{n:C})})]})]}),x.length?(0,H.jsx)(`div`,{className:`mt-4 flex flex-col gap-4 sm:grid sm:grid-cols-2 lg:grid-cols-3`,children:x.map(e=>(0,H.jsx)(q,{entry:e,onOpen:()=>i?i(e):m(e.id)},e.id))}):(0,H.jsxs)(`div`,{className:`py-10 text-center text-[0.875rem] text-ink-3`,children:[(0,H.jsx)(`p`,{children:O(u?`market.noneStarred`:`market.none`)}),(0,H.jsx)(d,{variant:`ghost`,className:`mt-2`,onClick:A,children:O(`market.reset`)})]}),_.hasNextPage?(0,H.jsx)(`div`,{className:`mt-6 flex justify-center`,children:(0,H.jsx)(d,{variant:`secondary`,busy:_.isFetchingNextPage,onClick:()=>void _.fetchNextPage(),children:O(`market.more`)})}):null,(0,H.jsx)(Q,{id:p,fallback:x.find(e=>e.id===p)??null,onClose:()=>m(null),onUse:e,busy:t})]})}export{P as C,F as S,Fe as _,K as a,L as b,et as c,nt as d,$e as f,z as g,Be as h,ot as i,at as l,We as m,wt as n,$ as o,B as p,St as r,tt as s,Q as t,it as u,R as v,N as w,I as x,Me as y};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{Hr as r,Wr as i,br as a,en as o,lr as s,sn as c}from"./ui-BIWmkPh6.js";import{v as l}from"./Marketplace-DTSg7_U7.js";import{r as u}from"./volume-2-D2To9w5D.js";import{t as d}from"./phone-jIuRIwyg.js";import{At as f,Ot as p,kt as m}from"./index-Bjn557f1.js";import{t as h}from"./runners-DloOxEbh.js";var g=e(t(),1),_=e(n(),1),v=[{id:`steps`,group:`web`,runner:`steps`,label:`new.ch.steps`,icon:l},{id:`chat`,group:`web`,runner:`chat`,label:`new.ch.chat`,icon:f},{id:`talk`,group:`web`,runner:`talk`,label:`new.ch.talk`,icon:i},{id:`video`,group:`web`,runner:`video`,label:`new.ch.video`,icon:s},{id:`call`,group:`phone`,runner:`call`,label:`new.ch.call`,icon:d},{id:`wacall`,group:`phone`,runner:`call`,label:`new.ch.whatsapp`,icon:null},{id:`sms`,group:`message`,runner:`sms`,label:`new.ch.sms`,icon:p},{id:`whatsapp`,group:`message`,runner:`whatsapp`,label:`new.ch.whatsapp`,icon:null}],y=[{id:`web`,label:`new.web`,icon:u},{id:`phone`,label:`new.phone`,icon:d},{id:`message`,label:`new.messages`,icon:m}],b=v.filter(e=>h.enabled.includes(e.id)).map(e=>e.id),x=e=>v.filter(t=>e.includes(t.id));function S(e){return e.length===b.length&&b.every(t=>e.includes(t))}function C(e){let t=x(e),n=[...new Set(t.map(e=>e.runner))];return{default:t.find(e=>e.group===`web`)?.runner??n[0]??h.default,enabled:n}}var w=e=>e.map(e=>c(e.label));function T(e){return v.find(t=>t.runner===e)}function E(e){return v.filter(t=>t.id!==`wacall`&&e.includes(t.runner)).map(e=>e.id)}function D(e){let t=x(e),n=y.flatMap(e=>{let n=w(t.filter(t=>t.group===e.id));return n.length?[e.id===`web`?n.join(`, `):`${c(e.label)}: ${n.join(`, `)}`]:[]});return`${c(`new.runsAs`)}: ${n.join(` · `)}`}function O(e){return e.length<=2?e.join(`, `):`${e.slice(0,2).join(`, `)} +${e.length-2}`}function k({channel:e,className:t}){let n=e.icon;return n?(0,_.jsx)(n,{className:t??`size-4`}):(0,_.jsx)(`span`,{"aria-hidden":`true`,className:`font-semibold text-[0.625rem] tracking-wide`,children:`WA`})}function A(e){let t=new Set(e?.map(e=>e.id)??[`steps`,`chat`]);return v.filter(e=>t.has(e.runner))}function j({value:e,onChange:t,runners:n,without:i,disabled:a}){let s=A(n).filter(e=>!i?.includes(e.id)),l=t=>e.includes(t.id),u=n=>{a||l(n)&&e.length===1||t(l(n)?e.filter(e=>e!==n.id):[...e,n.id])},d=t=>{let n=y.find(e=>e.id===t),i=s.filter(e=>e.group===t);if(!(n&&i.length))return null;let d=n.icon;return(0,_.jsxs)(`fieldset`,{className:`m-0 flex min-w-0 flex-col gap-0.5 border-0 p-0`,children:[(0,_.jsxs)(`legend`,{className:`flex items-center gap-1.5 px-2 pt-2 pb-1 text-[0.75rem] text-ink-3`,children:[(0,_.jsx)(d,{className:`size-3.5`}),` `,c(n.label)]}),i.map(t=>(0,_.jsxs)(`div`,{children:[(0,_.jsxs)(`label`,{className:o(`flex h-10 w-full cursor-pointer items-center gap-2.5 rounded-lg px-2 text-[0.875rem] transition hover:bg-accent has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-focus coarse:h-11`,l(t)&&`bg-paper-2`),children:[(0,_.jsx)(`span`,{className:`flex w-5 justify-center text-ink-3`,children:(0,_.jsx)(k,{channel:t})}),(0,_.jsx)(`span`,{className:`flex-1`,children:c(t.label)}),(0,_.jsx)(`input`,{type:`checkbox`,className:`sr-only`,"aria-label":c(t.label),checked:l(t),disabled:a,"aria-disabled":l(t)&&e.length===1,onChange:()=>u(t)}),(0,_.jsx)(`span`,{"aria-hidden":`true`,className:o(`flex size-[1.125rem] items-center justify-center rounded-md ring-1`,l(t)?`bg-ink text-paper ring-ink`:`ring-border`),children:l(t)?(0,_.jsx)(r,{className:`size-3`,strokeWidth:3}):null})]}),t.id===`call`&&l(t)?(0,_.jsx)(`p`,{className:`px-2 pb-1.5 pl-9 text-[0.75rem] text-ink-3`,children:c(`new.callHandoff`)}):null]},t.id))]})};return(0,_.jsxs)(`div`,{className:`grid gap-x-4 sm:grid-cols-2`,children:[d(`web`),(0,_.jsxs)(`div`,{className:`flex flex-col`,children:[d(`phone`),d(`message`)]})]})}function M({value:e,onChange:t,runners:n,className:r}){let[i,s]=(0,g.useState)(!1),[l,u]=(0,g.useState)(0),d=(0,g.useRef)(null);(0,g.useEffect)(()=>{if(!i)return;let e=e=>{d.current?.contains(e.target)||s(!1)},t=e=>{e.key===`Escape`&&s(!1)};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[i]);let f=A(n),p=y.filter(e=>f.some(t=>t.group===e.id)),m=t=>e.includes(t.id);return(0,_.jsxs)(`div`,{ref:d,className:o(`relative flex flex-wrap items-center gap-1.5`,r),children:[(0,_.jsx)(`span`,{className:`mr-0.5 px-1 text-[0.8125rem] text-ink-3`,children:c(`new.runsAs`)}),p.map(e=>{let t=w(f.filter(t=>t.group===e.id&&m(t))),n=e.icon;return(0,_.jsxs)(`button`,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i,"aria-label":`${c(e.label)}: ${t.length?t.join(`, `):c(`new.off`)}`,onClick:e=>{let t=e.currentTarget;u(t.offsetLeft+t.offsetWidth/2),s(e=>!e)},className:o(`inline-flex h-9 items-center justify-center gap-1.5 rounded-full font-medium text-[0.8125rem] transition coarse:h-11`,t.length?`bg-ink px-3 text-paper`:`w-9 text-ink-3 ring-1 ring-border hover:text-ink coarse:w-11`),children:[(0,_.jsx)(n,{className:`size-4 shrink-0`}),t.length?(0,_.jsx)(`span`,{className:`truncate`,children:O(t)}):null]},e.id)}),(0,_.jsx)(`button`,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i,"aria-label":c(`new.where`),onClick:e=>{let t=e.currentTarget;u(t.offsetLeft+t.offsetWidth/2),s(e=>!e)},className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 ring-1 ring-border transition hover:text-ink coarse:size-11`,children:(0,_.jsx)(a,{className:`size-4`})}),i?(0,_.jsxs)(`div`,{role:`dialog`,"aria-label":c(`new.where`),style:{transformOrigin:`${l}px top`},className:`absolute top-full left-0 z-20 mt-2 w-[min(32rem,calc(100vw-2rem))] animate-unfold rounded-2xl bg-card p-3 text-left shadow-overlay ring-1 ring-border`,children:[(0,_.jsx)(`p`,{className:`px-2 pt-1 font-semibold text-[0.9375rem]`,children:c(`new.where`)}),(0,_.jsx)(j,{value:e,onChange:t,runners:n})]}):null]})}export{D as a,S as c,M as i,C as l,k as n,T as o,j as r,E as s,y as t};
@@ -1,7 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$r as r,$t as i,Bt as a,G as o,Kr as s,Rt as c,Vt as l,W as u,ai as d,br as f,c as p,cr as m,en as h,et as g,i as _,ji as v,jt as y,l as ee,nn as b,o as te,oi as x,ri as S,s as C,sn as w,u as ne,wr as re,xi as T}from"./ui-BIWmkPh6.js";import{a as E,n as ie,o as D,t as O}from"./Marketplace-DTSg7_U7.js";import{t as k}from"./useMutation-CD7HmAxR.js";import{d as A,h as j,i as M,t as ae,x as oe}from"./session-BpsCkDv6.js";import{t as N}from"./upload-BcOvBWHS.js";import{a as se,c as P,i as ce,l as le}from"./NewWizardChannels-DiujJzOR.js";var F=[[`id`,8],[`toolId`,10],[`moduleId`,7],[`pluginId`,6],[`title`,6],[`description`,4],[`tags`,3],[`path`,3],[`inputSchema`,2],[`outputSchema`,2],[`request`,1],[`response`,1]];function I(e){return e.normalize(`NFKD`).replace(/[̀-ͯ]/g,``).replace(/([a-z])([A-Z])/g,`$1 $2`).toLowerCase()}function L(e){return I(e).split(/[^a-z0-9]+/).map(e=>e.trim()).filter(e=>e.length>1)}function R(e){return e==null?``:Array.isArray(e)?e.map(R).filter(Boolean).join(` `):typeof e==`object`?Object.values(e).map(R).filter(Boolean).join(` `):String(e)}function z(e,t){let n=t.map(([t,n])=>({text:R(e[t]),weight:n})).filter(e=>e.text.length>0);return{fields:n,tokens:n.flatMap(e=>L(e.text))}}function B(e){let t=[e];if(e.length<5)return t;if(e.endsWith(`ing`)){let n=e.slice(0,-3);n.length>=3&&t.push(n,`${n}e`)}else if(e.endsWith(`ies`)&&e.length>=6)t.push(`${e.slice(0,-3)}y`);else if(e.endsWith(`es`))t.push(e.slice(0,-2),e.slice(0,-1));else if(e.endsWith(`ed`)){let n=e.slice(0,-2);t.push(n,`${n}e`)}else e.endsWith(`s`)&&!e.endsWith(`ss`)&&t.push(e.slice(0,-1));return[...new Set(t)]}function V(e,t){if(e===t)return 1;let n=0;for(let r of B(e))for(let i of B(t)){if(r===i){n=Math.max(n,r===e&&i===t?1:.75);continue}r.length>=2&&i.startsWith(r)&&(n=Math.max(n,.55*(r.length/i.length))),i.length>=4&&r.startsWith(i)&&(n=Math.max(n,.4*(i.length/r.length)))}return n}function H(e,t){return e.reduce((e,n)=>e+V(t,n),0)}function U(e,t,n=F){if(!t?.trim())return 0;let r=L(t);if(r.length===0)return 0;let i=z(e,n);return i.tokens.length===0?0:r.reduce((e,t)=>H(i.tokens,t)===0?e:e+i.fields.reduce((e,n)=>{let r=L(n.text),i=H(r,t);if(i===0)return e;let a=i*2.2/(i+1.2+r.length/16);return e+n.weight*a},0),0)}var W=new Set(L(`aber als also am an auch auf aus bei bin bitte brauche brauchen braucht das dass dem den der
2
- des die dies diese dieser doch du ein eine einem einen einer eines er es etwas fuer für gerne
3
- habe haben hat ich ihr im in ist kann können koennen mache machen mag mein meine meinem meinen
4
- meiner mich mir mit möchte moechte nach nicht noch nur oder sich sie sind soll suche suchen
5
- sucht um und uns unser unsere vom von vor was wie will wir wird wo wollen zu zum zur
6
- a about an and are as at be can do for from have how i in is it like looking me my need of on
7
- or our that the this to want we what which who with would you your`)),G=e=>e.replace(/ß/g,`ss`);function K(e){let t=L(G(e)),n=t.filter(e=>!W.has(e));return n.length?n:t}var q=e=>e.trim().split(/\s+/).filter(Boolean).length>=3,J=e(t(),1),Y=e(n(),1);function ue({variant:e=`secondary`,label:t=w(`home.import`)}){let n=S(),r=v(),{project:i}=A(),a=j(),s=(0,J.useRef)(null),d=k({mutationFn:e=>o.upload(`/api/studio/projects/${i.id}/wizards/import`,e),onSuccess:async({id:e})=>{await r.invalidateQueries({queryKey:u.spaces()}),await r.invalidateQueries({queryKey:[`wizards`]}),n(`/edit/${e}`)}}),f=d.error instanceof y?d.error.body?.issues??[]:[];return!a||i?.readOnly?null:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(c,{variant:e,busy:d.isPending,disabled:!i,onClick:()=>s.current?.click(),children:[(0,Y.jsx)(N,{className:`size-4`}),` `,t]}),(0,Y.jsx)(`input`,{ref:s,hidden:!0,type:`file`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&d.mutate(t)}}),(0,Y.jsxs)(l,{open:d.isError,onClose:d.reset,title:w(`import.failed`),children:[(0,Y.jsx)(`p`,{className:`text-[0.875rem] text-ink-2`,children:d.error?.message}),f.length?(0,Y.jsx)(`ul`,{className:`mt-3 flex list-disc flex-col gap-1 pl-5 text-[0.8125rem] text-ink-2`,children:f.slice(0,8).map(e=>(0,Y.jsx)(`li`,{children:e.message},e.message))}):null,(0,Y.jsx)(`div`,{className:`mt-5 flex justify-end`,children:(0,Y.jsx)(c,{variant:`secondary`,onClick:d.reset,children:w(`common.close`)})})]})]})}var X=10,Z=3;async function de(e,t){let n=await fetch(g(`/api/studio/wizards/${e}/files/${encodeURIComponent(t.name)}`),{method:`PUT`,credentials:`include`,headers:{"content-type":t.type||`application/octet-stream`,"accept-language":b},body:t});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??n.statusText)}}function Q({over:e,onClick:t}){return(0,Y.jsx)(`button`,{type:`button`,"aria-label":w(`editor.detach`),onClick:t,className:h(`inline-flex shrink-0 items-center justify-center rounded-full`,e?`-top-1.5 -right-1.5 absolute size-5 bg-ink text-paper shadow-soft coarse:size-7`:`size-5 text-ink-3 hover:bg-paper-3 hover:text-ink coarse:size-7`),children:(0,Y.jsx)(m,{className:`size-3`})})}function $(e,t){let n=K(t);if(!n.length)return[];let r=e.map(e=>({w:e,score:U({title:e.title,summary:e.description},n.join(` `),[[`title`,10],[`summary`,6]])})).filter(e=>e.score>0).sort((e,t)=>t.score-e.score),i=q(t)?(r[0]?.score??0)*.4:0;return r.filter(e=>e.score>=i).slice(0,Z).map(e=>e.w)}function fe({wish:e,projectId:t,busy:n,onTake:r,onMore:i}){let s=S(),[l,u]=(0,J.useState)(null),d=D(e.trim(),300),f=x({queryKey:[`wizards`,t,`similar`],queryFn:()=>o.get(`/api/studio/projects/${t}/wizards`)}),p=x({queryKey:[`marketplace`,b,d,`similar`],queryFn:()=>o.get(`/api/studio/marketplace?${new URLSearchParams({lang:b,limit:String(X),offset:`0`,q:d})}`),enabled:d.length>=3,placeholderData:T});if(d.length<3)return null;let m=$(f.data??[],d),h=(p.data?.entries??[]).slice(0,X-m.length),g=(p.data?.total??0)-h.length;if(!(m.length||h.length))return null;let _=`flex items-center gap-3 rounded-xl bg-card py-2 pr-2 pl-3.5 ring-1 ring-border-soft`;return(0,Y.jsxs)(`section`,{className:`mt-5`,children:[(0,Y.jsx)(`h2`,{className:`mb-2 px-1 text-[0.8125rem] text-ink-3`,children:w(`new.similar`)}),(0,Y.jsxs)(`ul`,{className:`flex flex-col gap-1.5`,children:[m.map(e=>(0,Y.jsxs)(`li`,{className:_,children:[(0,Y.jsx)(a,{children:w(`new.yours`)}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>s(`/edit/${e.id}`),className:`min-w-0 flex-1 text-left`,children:[(0,Y.jsx)(`span`,{className:`block truncate font-medium text-[0.9375rem]`,children:e.title}),(0,Y.jsx)(`span`,{className:`block truncate text-[0.8125rem] text-ink-3`,children:e.description})]}),(0,Y.jsx)(c,{variant:`secondary`,size:`sm`,onClick:()=>s(`/edit/${e.id}`),children:w(`new.open`)})]},e.id)),h.map(e=>(0,Y.jsxs)(`li`,{className:_,children:[(0,Y.jsx)(a,{children:w(`new.template`)}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>u(e.id),className:`min-w-0 flex-1 text-left`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`truncate font-medium text-[0.9375rem]`,children:e.title}),e.plan===`pro`?(0,Y.jsx)(E,{}):null]}),(0,Y.jsx)(`span`,{className:`block truncate text-[0.8125rem] text-ink-3`,children:e.pitch})]}),(0,Y.jsx)(c,{variant:`secondary`,size:`sm`,disabled:n,onClick:()=>r(e),children:w(`new.take`)})]},e.id))]}),g>0?(0,Y.jsx)(`button`,{type:`button`,onClick:()=>i(d),className:`mt-2 px-1 text-[0.875rem] text-ink-2 hover:text-ink coarse:min-h-11`,children:w(`new.more`,{n:g})}):null,(0,Y.jsx)(O,{id:l,fallback:h.find(e=>e.id===l)??null,onClose:()=>u(null),onUse:r,busy:n})]})}function pe(){let e=S(),t=v(),{project:n}=A(),a=j(),[l]=d(),[m,g]=(0,J.useState)(()=>l.get(`wish`)??M()??``),y=(0,J.useRef)(M()!==null),[T,E]=(0,J.useState)([`steps`]),[D,O]=(0,J.useState)([]),[N,F]=(0,J.useState)(!1),[I,L]=(0,J.useState)(null),R=(0,J.useRef)(null),z=(0,J.useRef)(null),B=(0,J.useRef)(null),[V]=ne(),H=ee(m,g,{deviceId:V.deviceId}),U=x({queryKey:[`runners`],queryFn:()=>o.get(`/api/studio/runners`)}),W=e=>{let t=e.map(p);O(e=>[...e.filter(e=>!t.some(t=>t.name===e.name)),...t])},[G,K]=(0,J.useState)(new Map);(0,J.useEffect)(()=>{let e=new Map(D.filter(e=>e.type.startsWith(`image/`)).map(e=>[e,URL.createObjectURL(e)]));return K(e),()=>{for(let t of e.values())URL.revokeObjectURL(t)}},[D]);let q=k({mutationFn:e=>o.post(`/api/studio/wizards`,{projectId:n.id,starterId:e,lang:b}),onSuccess:async({id:n})=>{await t.invalidateQueries({queryKey:u.spaces()}),await t.invalidateQueries({queryKey:[`wizards`]}),e(`/edit/${n}`)}}),X=k({mutationFn:async()=>{let e=B.current??(await o.post(`/api/studio/wizards`,{projectId:n.id,lang:b})).id;B.current=e,P(T)||await o.patch(`/api/studio/wizards/${e}`,{runners:le(T)});for(let t of D)await de(e,t);return e},onSuccess:async n=>{ae(),await t.invalidateQueries({queryKey:u.spaces()}),await t.invalidateQueries({queryKey:[`wizards`]});let r=m.trim();P(T)||(r+=`\n\n${se(T)}`),D.length&&(r+=`\n\n${w(`editor.attached`)}: ${D.map(e=>e.name).join(`, `)}`),e(`/edit/${n}?prompt=${encodeURIComponent(r)}`)}}),Z=()=>{m.trim()&&n&&!X.isPending&&(H.listening&&H.stop(),X.mutate())};if((0,J.useEffect)(()=>{y.current&&n&&a&&!n.readOnly&&m.trim()&&(y.current=!1,X.mutate())},[n,a,m,X]),!a||n?.readOnly)return(0,Y.jsx)(r,{to:`/`,replace:!0});let $=X.error??q.error;return(0,Y.jsxs)(`div`,{className:`animate-rise md:pt-4`,children:[(0,Y.jsxs)(`div`,{className:`mx-auto max-w-2xl`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,Y.jsx)(`div`,{className:`size-[84px] md:size-auto`,children:(0,Y.jsx)(`div`,{className:`origin-top-left scale-[0.56] md:scale-100`,children:(0,Y.jsx)(oe,{kind:`sprout`,size:150,fluffy:!0})})}),(0,Y.jsx)(`h1`,{className:`mt-1 font-display font-semibold text-[1.5rem] leading-tight tracking-tight md:mt-2 md:text-[2.375rem]`,children:w(`new.title`)})]}),(0,Y.jsx)(ce,{value:T,onChange:E,runners:U.data,className:`mt-4 px-1 md:mt-8`}),(0,Y.jsxs)(`div`,{className:h(`relative mt-3 rounded-2xl bg-card p-2 shadow-elevated ring-1 ring-border-soft focus-within:ring-focus`,N&&`ring-2 ring-focus`),onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),F(!0))},onDragLeave:()=>F(!1),onDrop:e=>{e.preventDefault(),F(!1),W(Array.from(e.dataTransfer.files).map(C))},children:[D.length?(0,Y.jsx)(`div`,{className:`flex flex-wrap items-center gap-2 px-2 pt-2 pb-1`,children:D.map((e,t)=>{let n=G.get(e),r=()=>O(e=>e.filter((e,n)=>n!==t));return n?(0,Y.jsx)(te,{url:n,label:e.name,children:(0,Y.jsx)(Q,{over:!!n,onClick:r})},`${e.name}-${t}`):(0,Y.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-1.5 rounded-full bg-paper-2 py-1 pr-1 pl-2.5 text-[0.8125rem] text-ink-2`,children:[(0,Y.jsx)(re,{className:`size-3.5 shrink-0 text-ink-4`}),(0,Y.jsx)(`span`,{className:`truncate`,children:e.name}),(0,Y.jsx)(Q,{over:!!n,onClick:r})]},`${e.name}-${t}`)})}):null,(0,Y.jsx)(i,{autoFocus:!0,minRows:4,value:m,onChange:e=>g(e.target.value),onPaste:e=>{let t=Array.from(e.clipboardData.files);t.length&&(e.preventDefault(),W(t.map(C)))},onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&Z()},placeholder:H.listening?w(`editor.listening`):w(`new.placeholder`),className:`border-0 bg-transparent text-[1rem] shadow-none focus:ring-0`}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-1 pb-1`,children:[(0,Y.jsx)(`button`,{type:`button`,"aria-label":w(`editor.attach`),title:w(`editor.attach`),onClick:()=>z.current?.click(),className:`inline-flex size-10 shrink-0 items-center justify-center rounded-full border border-border text-ink transition hover:bg-paper-2 coarse:size-11`,children:(0,Y.jsx)(f,{className:`size-4`})}),(0,Y.jsx)(`input`,{ref:z,type:`file`,multiple:!0,hidden:!0,onChange:e=>{let t=Array.from(e.target.files??[]);e.target.value=``,W(t)}}),H.supported?(0,Y.jsx)(_,{speech:H,labelled:!0}):null,(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.75rem] text-ink-4`,children:N?w(`new.dropHint`):null}),(0,Y.jsxs)(c,{size:`md`,onClick:Z,busy:X.isPending,disabled:!m.trim()||q.isPending,children:[w(`new.build`),` `,(0,Y.jsx)(s,{className:`size-4`})]})]})]}),(0,Y.jsx)(`p`,{className:`mt-3 text-center text-[0.875rem] text-ink-3`,children:w(`new.hint`)}),H.error?(0,Y.jsx)(`p`,{className:`mt-2 px-3 text-[0.75rem] text-rose`,children:H.error===`denied`?w(`editor.micDenied`):H.error}):null,$?(0,Y.jsx)(`p`,{className:`mt-3 text-center text-[0.875rem] text-rose`,children:$.message}):null,n?(0,Y.jsx)(fe,{wish:m,projectId:n.id,busy:q.isPending||X.isPending,onTake:e=>!q.isPending&&q.mutate(e.id),onMore:e=>{L({text:e}),R.current?.scrollIntoView({behavior:`smooth`,block:`start`})}}):null]}),(0,Y.jsxs)(`section`,{ref:R,className:`mx-auto max-w-5xl scroll-mt-6`,children:[(0,Y.jsx)(`h2`,{className:`mt-16 mb-5 text-center font-medium text-[0.8125rem] text-ink-3 uppercase tracking-[0.08em]`,children:w(`new.orStarter`)}),(0,Y.jsx)(ie,{open:l.get(`starter`),search:I,busy:q.isPending,onUse:e=>n&&!q.isPending&&q.mutate(e.id)})]}),(0,Y.jsx)(`div`,{className:`mt-8 flex justify-center`,children:(0,Y.jsx)(ue,{variant:`ghost`,label:w(`new.import`)})})]})}export{pe as NewWizardPage};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{G as r,Hr as i,Kr as a,Mr as ee,W as o,ai as te,en as s,ji as ne,nn as c,ri as re,sn as l}from"./ui-BIWmkPh6.js";import{t as u}from"./useMutation-CD7HmAxR.js";import{d as ie,g as ae,i as oe,w as se,x as ce}from"./session-BpsCkDv6.js";import{t as le}from"./upload-BcOvBWHS.js";import{t as d}from"./logo-CGNoptDg.js";import{et as ue}from"./index-Bjn557f1.js";var f=e(t(),1),p=e(n(),1),m=`oklch(50% 0.2 262)`,h=`oklch(32% 0.15 262)`,de={"--on":`white`,"--dot":`oklch(90% 0.1 80)`,"--ink-2":`oklch(96% 0.02 262)`,"--ink-3":`oklch(90% 0.035 262)`,"--moss":`oklch(90% 0.14 150)`,"--rose":`oklch(89% 0.09 45)`},g={kind:1,details:1,organization:1,site:2,know:3,space:4},fe=e=>e!==null&&Object.hasOwn(g,e),_=`w-full rounded-[18px] border border-white/30 bg-white/15 px-6 py-5 text-[1.375rem] text-white outline-none placeholder:text-white/55 focus:border-white/60`;function pe(){return(0,p.jsxs)(`span`,{className:`inline-flex items-center gap-2.5`,children:[(0,p.jsx)(d,{size:28}),(0,p.jsxs)(`span`,{className:`font-display font-semibold text-[1.0625rem] tracking-tight`,children:[`engenty`,(0,p.jsx)(`span`,{className:`mr-[0.09em] ml-[0.06em] text-(color:--dot)`,children:`.`}),(0,p.jsx)(`span`,{className:`font-normal text-white/70`,children:`wizards`})]})]})}function v({children:e,busy:t,onClick:n,type:r=`button`}){return(0,p.jsxs)(`button`,{type:r,disabled:t,onClick:n,className:`inline-flex h-13 cursor-pointer items-center gap-2.5 rounded-full bg-white px-7 font-semibold text-[1rem] transition hover:bg-white/90 disabled:cursor-default disabled:opacity-70`,style:{color:h},children:[e,(0,p.jsx)(a,{className:`size-[18px]`})]})}function y({children:e,onClick:t}){return(0,p.jsx)(`button`,{type:`button`,onClick:t,className:`cursor-pointer font-semibold text-[0.9375rem] text-white/85 transition hover:text-white`,children:e})}function b({step:e}){return(0,p.jsx)(`span`,{className:`ml-auto inline-flex gap-1.5`,role:`img`,"aria-label":l(`onboard.step`,{n:e}),children:[1,2,3,4].map(t=>(0,p.jsx)(`span`,{className:s(`size-2 rounded-full`,t===e?`bg-white`:`bg-white/40`)},t))})}var x=[{kind:`personal`,label:`onboard.kindPersonal`,sub:`onboard.kindPersonalSub`},{kind:`club`,label:`onboard.kindClub`,sub:`onboard.kindClubSub`},{kind:`small`,label:`onboard.kindSmall`,sub:`onboard.kindSmallSub`},{kind:`corp`,label:`onboard.kindCorp`,sub:`onboard.kindCorpSub`}],S=new Set([`gmail.com`,`googlemail.com`,`gmx.at`,`gmx.de`,`gmx.net`,`web.de`,`outlook.com`,`hotmail.com`,`live.com`,`icloud.com`,`me.com`,`yahoo.com`,`yahoo.de`,`aon.at`,`a1.net`,`chello.at`,`t-online.de`,`proton.me`,`protonmail.com`]);function me(e){let t=(e.split(`@`)[1]??``).trim().toLowerCase();return t?S.has(t)?{kind:`personal`,domain:t}:/(verein|club|klub|^sv-|^fc-|^ff-|feuerwehr|musik|chor)/.test(t)?{kind:`club`,domain:t}:{kind:`small`,domain:t}:{kind:null,domain:t}}var C={club:[`0-50`,`50-250`,`250-1000`,`1000+`],small:[`1`,`2-9`,`10-49`],corp:[`50-249`,`250-999`,`1000+`]},w=e=>Number(e).toLocaleString(c),T=e=>{if(e===`1`)return l(`onboard.justMe`);if(e.endsWith(`+`))return`${w(e.slice(0,-1))}+`;let[t,n]=e.split(`-`);return t===`0`?`≤ ${w(n)}`:`${w(t)}–${w(n)}`},he=[`sport`,`culture`,`social`,`education`,`environment`,`rescue`,`other`],ge=[`chair`,`board`,`treasurer`,`secretary`,`member`],_e=[`management`,`it`,`marketing`,`sales`,`operations`,`other`],E=`w-full rounded-[14px] border border-white/30 bg-white/15 px-4 py-3 text-[1.0625rem] text-white outline-none placeholder:text-white/55 focus:border-white/60`;function ve({picked:e,label:t,sub:n,onClick:r}){return(0,p.jsxs)(`button`,{type:`button`,"aria-pressed":e,onClick:r,className:s(`flex cursor-pointer flex-col gap-1 rounded-[18px] border px-5 py-4 text-left transition`,e?`border-white bg-white/25`:`border-white/30 bg-white/10 hover:bg-white/15`),children:[(0,p.jsx)(`span`,{className:`font-display font-semibold text-[1.125rem]`,children:t}),(0,p.jsx)(`span`,{className:`text-[0.875rem] text-white/80`,children:n})]})}function D({label:e,options:t,value:n,text:r,onChange:i}){return(0,p.jsxs)(`fieldset`,{className:`flex flex-col gap-2`,children:[(0,p.jsx)(`legend`,{className:`mb-2 text-[0.9375rem] text-white/85`,children:e}),(0,p.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t.map(e=>(0,p.jsx)(`button`,{type:`button`,"aria-pressed":n===e,onClick:()=>i(e),className:s(`cursor-pointer rounded-full border px-4 py-2 text-[0.9375rem] transition`,n===e?`border-white bg-white`:`border-white/30 hover:bg-white/15`),style:n===e?{color:h}:void 0,children:r(e)},e))})]})}function O(e,t,n){let r=`${k}${e}:${t}`,[i,a]=(0,f.useState)(()=>{try{let e=sessionStorage.getItem(r);return e===null?n:JSON.parse(e)}catch{return n}});return(0,f.useEffect)(()=>{try{sessionStorage.setItem(r,JSON.stringify(i))}catch{}},[r,i]),[i,a]}var k=`wizards.onboarding:`;function ye(){try{for(let e of Object.keys(sessionStorage))e.startsWith(k)&&sessionStorage.removeItem(e)}catch{}}function A(){se(m);let e=ae(),t=ne(),n=re(),{project:a}=ie(),d=e.data?.user.id??``,[w,k]=O(d,`organization`,``),[A,j]=O(d,`site`,``),[M,N]=O(d,`line`,null),[P,be]=(0,f.useState)(null),[F,I]=(0,f.useState)([]),L=(0,f.useRef)(null),[R]=(0,f.useState)(oe),[z]=(0,f.useState)(()=>me(e.data?.user.email??``)),[B,xe]=O(d,`profile`,{kind:z.kind,size:null,sector:``,role:null,need:``,legalName:``,phone:``}),[Se,Ce]=te(),V=Se.get(`page`),H=fe(V)&&(V!==`details`||B.kind)?V:`kind`,U=g[H],W=e=>Ce(t=>{let n=new URLSearchParams(t);return n.set(`page`,e),n}),G=e=>xe(t=>({...t,...e})),K=u({mutationFn:e=>r.put(`/api/studio/organization/profile`,{kind:B.kind,size:B.size,sector:B.sector.trim()||null,role:B.role,need:B.need.trim()||null,legalName:B.legalName.trim()||null,phone:B.phone.trim()||null,website:e?.trim()||null})}),q=B.kind===`personal`,J=()=>{!A&&z.domain&&B.kind!==`personal`&&!S.has(z.domain)&&j(z.domain),W(`site`)},Y=u({mutationFn:e=>r.put(`/api/studio/organization`,{name:e}),onSuccess:()=>t.invalidateQueries({queryKey:[`organization`]})}),X=u({mutationFn:e=>r.post(`/api/studio/projects/${a?.id}/website`,{url:e,lang:c}),onSuccess:async e=>{be(e),await t.invalidateQueries({queryKey:o.spaces()})}}),Z=u({mutationFn:e=>r.patch(`/api/studio/projects/${a?.id}`,{brand:{about:e}}),onSuccess:()=>t.invalidateQueries({queryKey:o.spaces()})}),Q=u({mutationFn:()=>r.post(`/api/studio/onboarding/done`),onSuccess:async()=>{ye(),await t.invalidateQueries({queryKey:[`me`]}),n(`/new`,{replace:!0})}}),we=e.data?.user.name??``,$=we.includes(`@`)?``:we.split(` `)[0],Te=async e=>{if(e&&a){for(let t of Array.from(e)){I(e=>[...e,{name:t.name,state:`uploading`}]);try{await r.upload(`/api/studio/projects/${a.id}/files?kind=document`,t),I(e=>e.map(e=>e.name===t.name?{...e,state:`done`}:e))}catch{I(e=>e.map(e=>e.name===t.name?{...e,state:`failed`}:e))}}await t.invalidateQueries({queryKey:o.spaces()})}},Ee=P?[P.about?l(`onboard.readAbout`):``,P.colors?l(`onboard.readColors`,{n:P.colors}):``,P.fonts?l(`onboard.readFonts`,{n:P.fonts}):``,P.logo?l(`onboard.readLogo`):``,P.facts?l(`onboard.readFacts`,{n:P.facts}):``,P.assets?l(`onboard.readAssets`,{n:P.assets}):``].join(``):``;return(0,p.jsxs)(`div`,{className:`flex min-h-dvh flex-col px-6 text-white sm:px-10`,style:{...de,background:m},children:[(0,p.jsxs)(`header`,{className:`flex items-center justify-between pt-6 sm:pt-8`,children:[(0,p.jsx)(pe,{}),(0,p.jsx)(ue,{tone:`ground`,ink:h})]}),(0,p.jsxs)(`main`,{className:`mx-auto grid w-full max-w-6xl flex-1 items-center gap-10 py-10 lg:grid-cols-[5fr_7fr] lg:gap-12`,children:[(0,p.jsxs)(`div`,{className:`flex flex-col items-center gap-8 max-lg:order-first`,children:[(0,p.jsx)(ce,{kind:`drop`,size:240,fluffy:!0,coat:`fur`}),R?(0,p.jsxs)(`figure`,{className:`w-full max-w-sm rounded-[18px] bg-white/15 px-5 py-4`,children:[(0,p.jsx)(`figcaption`,{className:`font-medium text-[0.75rem] text-white/85 uppercase tracking-[0.14em]`,children:l(`onboard.wish`)}),(0,p.jsx)(`blockquote`,{className:`mt-1.5 line-clamp-6 whitespace-pre-line break-words text-[1rem] leading-relaxed`,children:R}),(0,p.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-white/75`,children:l(`onboard.wishNext`)})]}):null]}),(0,p.jsxs)(`div`,{className:`flex min-w-0 max-w-2xl animate-rise flex-col gap-5`,children:[H===`kind`?(0,p.jsxs)(`form`,{className:`contents`,onSubmit:e=>{e.preventDefault(),B.kind&&W(`details`)},children:[(0,p.jsx)(`p`,{className:`font-medium text-[0.75rem] text-white/85 uppercase tracking-[0.14em]`,children:$?l(`onboard.kicker1`,{name:$}):l(`onboard.kicker1Anon`)}),(0,p.jsx)(`h1`,{className:`font-display font-bold text-[2.5rem] leading-[1.05] tracking-[-0.02em] sm:text-[3.25rem]`,children:l(`onboard.kind`)}),(0,p.jsx)(`p`,{className:`text-[1.0625rem] text-white/90 leading-relaxed`,children:l(`onboard.kindSub`)}),z.kind?(0,p.jsx)(`p`,{className:`text-[0.9375rem] text-white/80`,children:l(`onboard.guess`,{domain:z.domain,kind:l(x.find(e=>e.kind===z.kind)?.label??`onboard.kindSmall`)})}):null,(0,p.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:x.map(e=>(0,p.jsx)(ve,{picked:B.kind===e.kind,label:l(e.label),sub:l(e.sub),onClick:()=>G({kind:e.kind,size:e.kind===B.kind?B.size:null})},e.kind))}),(0,p.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,p.jsx)(v,{type:`submit`,children:l(`onboard.continue`)}),(0,p.jsx)(b,{step:1})]})]}):null,H===`details`&&B.kind?(0,p.jsxs)(`form`,{className:`contents`,onSubmit:e=>{e.preventDefault(),K.mutate(void 0),B.kind===`corp`&&B.legalName.trim()&&!w&&k(B.legalName.trim()),B.kind===`personal`?J():W(`organization`)},children:[(0,p.jsx)(`p`,{className:`font-medium text-[0.75rem] text-white/85 uppercase tracking-[0.14em]`,children:$?l(`onboard.kicker1`,{name:$}):l(`onboard.kicker1Anon`)}),(0,p.jsx)(`h1`,{className:`font-display font-bold text-[2.25rem] leading-[1.05] tracking-[-0.02em] sm:text-[2.75rem]`,children:l(B.kind===`personal`?`onboard.personalTitle`:B.kind===`club`?`onboard.clubTitle`:`onboard.businessTitle`)}),B.kind===`personal`?(0,p.jsx)(`textarea`,{value:B.need,onChange:e=>G({need:e.target.value}),placeholder:l(`onboard.personalPlaceholder`),rows:3,maxLength:2e3,"aria-label":l(`onboard.personalTitle`),className:s(_,`resize-none text-[1.125rem] leading-relaxed`)}):null,B.kind===`club`?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(D,{label:l(`onboard.clubKind`),options:he,value:B.sector,text:e=>l(`onboard.club.${e}`),onChange:e=>G({sector:e})}),(0,p.jsx)(D,{label:l(`onboard.members`),options:C.club,value:B.size,text:T,onChange:e=>G({size:e})}),(0,p.jsx)(D,{label:l(`onboard.yourRole`),options:ge,value:B.role,text:e=>l(`onboard.role.${e}`),onChange:e=>G({role:e})})]}):null,B.kind===`small`?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(D,{label:l(`onboard.people`),options:C.small,value:B.size,text:T,onChange:e=>G({size:e})}),(0,p.jsxs)(`label`,{className:`flex flex-col gap-2 text-[0.9375rem] text-white/85`,children:[l(`onboard.sector`),(0,p.jsx)(`input`,{value:B.sector,onChange:e=>G({sector:e.target.value}),placeholder:l(`onboard.sectorPlaceholder`),maxLength:120,className:E})]}),(0,p.jsxs)(`label`,{className:`flex flex-col gap-2 text-[0.9375rem] text-white/85`,children:[(0,p.jsxs)(`span`,{children:[l(`onboard.need`),` `,(0,p.jsx)(`span`,{className:`text-white/60`,children:l(`onboard.optional`)})]}),(0,p.jsx)(`textarea`,{value:B.need,onChange:e=>G({need:e.target.value}),placeholder:l(`onboard.needPlaceholder`),rows:2,maxLength:2e3,className:s(E,`resize-none`)})]})]}):null,B.kind===`corp`?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(D,{label:l(`onboard.people`),options:C.corp,value:B.size,text:T,onChange:e=>G({size:e})}),(0,p.jsx)(D,{label:l(`onboard.yourRole`),options:_e,value:B.role,text:e=>l(`onboard.role.${e}`),onChange:e=>G({role:e})}),(0,p.jsxs)(`label`,{className:`flex flex-col gap-2 text-[0.9375rem] text-white/85`,children:[l(`onboard.legalName`),(0,p.jsx)(`input`,{value:B.legalName,onChange:e=>G({legalName:e.target.value}),placeholder:l(`onboard.legalNamePlaceholder`),maxLength:200,autoComplete:`organization`,className:E})]}),(0,p.jsxs)(`label`,{className:`flex flex-col gap-2 text-[0.9375rem] text-white/85`,children:[(0,p.jsxs)(`span`,{children:[l(`onboard.phone`),` `,(0,p.jsx)(`span`,{className:`text-white/60`,children:l(`onboard.phoneWhy`)})]}),(0,p.jsx)(`input`,{type:`tel`,value:B.phone,onChange:e=>G({phone:e.target.value.replace(/[^+0-9 ()/.-]/g,``)}),placeholder:`+43 …`,maxLength:40,autoComplete:`tel`,className:E})]})]}):null,(0,p.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,p.jsx)(v,{type:`submit`,busy:K.isPending,children:l(`onboard.continue`)}),(0,p.jsx)(y,{onClick:()=>window.history.state?.idx>0?n(-1):W(`kind`),children:l(`onboard.back`)}),(0,p.jsx)(b,{step:1})]})]}):null,H===`organization`?(0,p.jsxs)(`form`,{className:`contents`,onSubmit:e=>{e.preventDefault();let t=w.trim();t?Y.mutate(t,{onSuccess:J}):J()},children:[(0,p.jsx)(`p`,{className:`font-medium text-[0.75rem] text-white/85 uppercase tracking-[0.14em]`,children:$?l(`onboard.kicker1`,{name:$}):l(`onboard.kicker1Anon`)}),(0,p.jsx)(`h1`,{className:`font-display font-bold text-[2.5rem] leading-[1.05] tracking-[-0.02em] sm:text-[3.25rem]`,children:l(`onboard.organization`)}),(0,p.jsx)(`p`,{className:`text-[1.0625rem] text-white/90 leading-relaxed`,children:l(`onboard.organizationSub`)}),(0,p.jsx)(`input`,{value:w,onChange:e=>k(e.target.value),placeholder:l(`onboard.organizationPlaceholder`),maxLength:80,"aria-label":l(`onboard.organization`),className:_}),(0,p.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,p.jsx)(v,{type:`submit`,busy:Y.isPending,children:l(`onboard.continue`)}),(0,p.jsx)(b,{step:1})]})]}):null,U===2?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`p`,{className:`font-medium text-[0.75rem] text-white/85 uppercase tracking-[0.14em]`,children:l(q?`onboard.kicker2Personal`:`onboard.kicker2`)}),(0,p.jsx)(`h1`,{className:`font-display font-bold text-[2.5rem] leading-[1.05] tracking-[-0.02em] sm:text-[3.25rem]`,children:l(`onboard.site`)}),(0,p.jsx)(`p`,{className:`text-[1.0625rem] text-white/90 leading-relaxed`,children:l(q?`onboard.siteSubPersonal`:`onboard.siteSub`)}),M===null?(0,p.jsxs)(`form`,{className:`contents`,onSubmit:e=>{e.preventDefault();let t=A.trim();if(t&&!X.isPending){if(B.kind&&K.mutate(t),!t.includes(`.`)){W(`know`);return}X.mutate(t)}},children:[(0,p.jsx)(`input`,{value:A,onChange:e=>j(e.target.value),placeholder:l(q?`onboard.sitePlaceholderPersonal`:`onboard.sitePlaceholder`),autoCapitalize:`none`,"aria-label":l(`onboard.site`),className:_}),q?null:(0,p.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-white/75`,children:l(`onboard.siteNameHint`)}),P?(0,p.jsxs)(`p`,{className:`flex items-center gap-2 text-[0.9375rem] text-(color:--moss)`,children:[(0,p.jsx)(i,{className:`size-4`}),l(`onboard.readDone`,{name:P.name,details:Ee})]}):X.isError?(0,p.jsx)(`p`,{className:`text-[0.9375rem] text-(color:--rose)`,children:l(`onboard.readFailed`)}):null,(0,p.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[P?(0,p.jsx)(v,{onClick:()=>W(`know`),children:l(`onboard.continue`)}):(0,p.jsx)(v,{type:`submit`,busy:X.isPending,children:X.isPending?l(`onboard.reading`):l(`onboard.read`)}),(0,p.jsx)(y,{onClick:()=>N(``),children:l(`onboard.line`)}),(0,p.jsx)(y,{onClick:()=>W(`know`),children:l(`onboard.skip`)}),(0,p.jsx)(b,{step:2})]})]}):(0,p.jsxs)(`form`,{className:`contents`,onSubmit:e=>{e.preventDefault();let t=M.trim();t?Z.mutate(t,{onSuccess:()=>W(`know`)}):W(`know`)},children:[(0,p.jsx)(`textarea`,{value:M,onChange:e=>N(e.target.value),placeholder:l(q?`onboard.linePlaceholderPersonal`:`onboard.linePlaceholder`),rows:3,maxLength:8e3,"aria-label":l(`onboard.line`),className:s(_,`resize-none text-[1.125rem] leading-relaxed`)}),(0,p.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,p.jsx)(v,{type:`submit`,busy:Z.isPending,children:l(`onboard.continue`)}),(0,p.jsx)(y,{onClick:()=>N(null),children:l(`onboard.site`)}),(0,p.jsx)(y,{onClick:()=>W(`know`),children:l(`onboard.skip`)}),(0,p.jsx)(b,{step:2})]})]})]}):null,U===3?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`p`,{className:`font-medium text-[0.75rem] text-white/85 uppercase tracking-[0.14em]`,children:l(`onboard.kicker3`)}),(0,p.jsx)(`h1`,{className:`font-display font-bold text-[2.5rem] leading-[1.05] tracking-[-0.02em] sm:text-[3.25rem]`,children:l(`onboard.know`)}),(0,p.jsx)(`p`,{className:`text-[1.0625rem] text-white/90 leading-relaxed`,children:l(`onboard.knowSub`)}),(0,p.jsxs)(`button`,{type:`button`,onClick:()=>L.current?.click(),onDragOver:e=>e.preventDefault(),onDrop:e=>{e.preventDefault(),Te(e.dataTransfer.files)},className:`flex cursor-pointer flex-col items-center gap-2 rounded-[18px] border-2 border-white/45 border-dashed bg-white/10 px-6 py-7 text-center transition hover:bg-white/15`,children:[(0,p.jsx)(le,{className:`size-7`}),(0,p.jsx)(`span`,{className:`font-semibold text-[1.0625rem]`,children:l(`onboard.drop`)}),(0,p.jsx)(`span`,{className:`text-[0.875rem] text-white/80`,children:`PDF · Word · Excel · Markdown`}),(0,p.jsx)(`input`,{ref:L,type:`file`,multiple:!0,className:`sr-only`,onChange:e=>{Te(e.target.files),e.target.value=``}})]}),F.length?(0,p.jsx)(`ul`,{className:`flex flex-col gap-2`,children:F.map(e=>(0,p.jsxs)(`li`,{className:`flex items-center gap-2.5 rounded-xl bg-white/15 px-3.5 py-2.5 text-[0.875rem]`,children:[(0,p.jsx)(ee,{className:`size-4 shrink-0`}),(0,p.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,p.jsx)(`span`,{className:s(`text-white/80`,e.state===`failed`?`text-(color:--rose)`:``),children:e.state===`uploading`?l(`onboard.uploading`):e.state===`done`?l(`onboard.uploaded`):l(`onboard.uploadFailed`)})]},e.name))}):null,(0,p.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,p.jsx)(v,{busy:F.some(e=>e.state===`uploading`),onClick:()=>W(`space`),children:l(`onboard.continue`)}),F.length?null:(0,p.jsx)(y,{onClick:()=>W(`space`),children:l(`onboard.skip`)}),(0,p.jsx)(b,{step:3})]})]}):null,U===4?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`p`,{className:`font-medium text-[0.75rem] text-white/85 uppercase tracking-[0.14em]`,children:l(`onboard.kicker4`)}),(0,p.jsx)(`h1`,{className:`font-display font-bold text-[2.5rem] leading-[1.05] tracking-[-0.02em] sm:text-[3.25rem]`,children:l(`onboard.space`)}),(0,p.jsx)(`p`,{className:`text-[1.0625rem] text-white/90 leading-relaxed`,children:l(`onboard.spaceSub`,{space:a?.name??``})}),(0,p.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[[`partInfo`,`partInfoText`,!!(P||M)],[`partKnow`,`partKnowText`,F.some(e=>e.state===`done`)],[`partData`,`partDataText`,!1],[`partResults`,`partResultsText`,!1]].map(([e,t,n])=>(0,p.jsxs)(`div`,{className:`flex flex-col gap-1.5 rounded-2xl border border-white/20 bg-white/10 px-4.5 py-4`,children:[(0,p.jsxs)(`span`,{className:`flex items-center gap-2 font-semibold text-[1rem]`,children:[n?(0,p.jsx)(i,{className:`size-4 text-(color:--moss)`}):null,l(`onboard.${e}`)]}),(0,p.jsx)(`span`,{className:`text-[0.84375rem] text-white/85 leading-snug`,children:l(`onboard.${t}`)})]},e))}),(0,p.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,p.jsx)(v,{busy:Q.isPending,onClick:()=>Q.mutate(),children:l(`onboard.build`)}),(0,p.jsx)(b,{step:4})]})]}):null]},H)]}),(0,p.jsxs)(`footer`,{className:`mx-auto flex w-full max-w-6xl items-center justify-between pb-6 text-[0.75rem] text-white/55 sm:pb-8`,children:[(0,p.jsx)(`span`,{children:`engenty.wizards`}),(0,p.jsx)(`span`,{"aria-hidden":`true`,className:`size-[3px] bg-(color:--dot)`})]})]})}export{A as OnboardingPage};
@@ -1,9 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$t as r,B as i,Bn as a,Bt as o,Dr as s,G as c,Gt as l,Hr as u,Ht as d,Jt as f,Ln as p,Mr as m,Or as h,Rt as g,Ut as _,V as v,Vn as y,Vr as b,Vt as x,W as S,Wt as C,Xn as w,Yn as T,Yr as E,Yt as D,Zt as O,_r as k,br as A,cr as j,dr as M,dt as N,en as P,fn as F,hr as ee,ji as I,jt as te,m as L,nn as R,oi as z,pt as B,qr as V,qt as H,ri as ne,sn as U,st as re,ur as ie,v as W,vr as ae,wr as oe,xi as se,xr as ce,y as G,z as le,zr as ue,zt as K}from"./ui-BIWmkPh6.js";import{S as de,h as q,m as fe}from"./Marketplace-DTSg7_U7.js";import{t as J}from"./useMutation-CD7HmAxR.js";import{i as pe}from"./volume-2-D2To9w5D.js";import{b as me,d as he,f as ge,p as _e,r as ve,t as ye}from"./theme-2XjIQXH3.js";import{M as be,g as Y,j as xe,x as Se}from"./session-BpsCkDv6.js";import{t as Ce}from"./upload-BcOvBWHS.js";import{A as we,C as Te,Ct as Ee,D as De,E as Oe,Et as ke,Lt as Ae,O as je,S as Me,T as Ne,a as Pe,i as Fe,k as Ie,n as Le,o as Re,ot as ze,pt as Be,r as Ve,w as He,yt as Ue}from"./index-Bjn557f1.js";import{t as We}from"./runners-DloOxEbh.js";var Ge={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`}]]};Ge.node;var Ke=E(Ge),qe={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`}]]};qe.node;var Je=E(qe),Ye={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`}]]};Ye.node;var Xe=E(Ye),Ze={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`}]]};Ze.node;var Qe=E(Ze),$e={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`}]]};$e.node;var et=E($e),tt={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`}]]};tt.node;var nt=E(tt),rt={name:`panel-right-close`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m8 9 3 3-3 3`,key:`12hl5m`}]]};rt.node;var it=E(rt),at={name:`panel-right-open`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m10 15-3-3 3-3`,key:`1pgupc`}]]};at.node;var ot=E(at),st={name:`play`,size:24,node:[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]};st.node;var X=E(st),ct={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`}]]};ct.node;var lt=E(ct),ut={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`}]]};ut.node;var dt=E(ut),ft={name:`user`,size:24,node:[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]};ft.node;var pt=E(ft),Z=e(n(),1),Q=e(t(),1);function mt(e){return z({queryKey:[`share-targets`,e,R],queryFn:()=>c.get(`/api/studio/wizards/${e}/share-targets?lang=${R}`),enabled:!!e,staleTime:6e4})}var ht=(0,Q.createContext)(null);function gt(e){return e.share?e.share.length?`own`:`off`:`default`}var _t=e=>e.byDefault&&e.usable;function vt(e,t){let n=gt(e),r=e.share??[],i=new Map,a=e=>{let t=i.get(e)??0;return i.set(e,t+1),`${e}#${t}`},o=e=>({key:a(e.id),target:e.id,info:e,index:null,option:null,on:!1,name:e.name});if(n==="default")return{mode:n,rows:t.filter(_t).map(e=>({...o(e),on:!0})),unset:t.filter(e=>e.byDefault&&!e.usable)};let s=r.map((e,n)=>{let r=t.find(t=>t.id===e.target);return{key:a(e.target),target:e.target,info:r,index:n,option:e,on:!0,name:e.label||r?.name||e.target}}),c=new Set(r.map(e=>e.target));return s.push(...t.filter(e=>_t(e)&&!c.has(e.id)).map(o)),{mode:n,rows:s,unset:t.filter(e=>e.byDefault&&!e.usable&&!c.has(e.id))}}function yt(e,t){let n=t.filter(e=>e.on&&e.info?.usable);return{visitors:n.filter(t=>!(e==="default"&&t.info?.agent)),onlyYou:e==="default"?n.filter(e=>e.info?.agent):[],broken:t.filter(e=>e.on&&!e.info?.usable)}}function bt(e){return e.filter(e=>_t(e)&&!e.agent).map(e=>({target:e.id}))}function xt(e,t){let n=gt(e);return n===`own`?e.share??[]:n==="default"?bt(t):[]}function St(e,t,n,r){let i=xt(e,t);return r?[...i,{target:n.target}]:n.index===null?i.filter(e=>e.target!==n.target):i.filter((e,t)=>t!==n.index)}function Ct(e,t,n,r){let i=xt(e,t),a=n.index??i.findIndex(e=>e.target===n.target);return a===-1?[...i,r]:i.map((e,t)=>t===a?r:e)}function wt(e,t,n){return[...xt(e,t),{target:n}]}function Tt(e,t){let n=new Set(e.map(e=>e.target));return t.filter(e=>e.usable&&!e.byDefault&&!n.has(e.id))}function Et(e,t){let n=e.steps.slice(0,e.steps.indexOf(t));return[...n.flatMap(e=>e.type===`page`?e.fields.filter(e=>e.kind!==`image`&&e.kind!==`file`&&e.kind!==`signature`).map(e=>({ref:e.id,label:e.label})):[]),...n.flatMap(e=>e.type===`agent`&&e.output.format!==`json`?[{ref:`steps.${e.id}`,label:e.title}]:[]),{ref:`brand.name`,label:U(`shareEditor.brandName`)}]}function Dt(e){return new Intl.ListFormat(R===`en`?`en-GB`:R,{style:`long`,type:`conjunction`}).format(e)}var Ot=(e,t)=>`${e}/${t}`;function kt(e,t,n){if(e.endsWith(`.localhost`)){let r=n&&URL.canParse(n)?new URL(n).port:``;return`http://${e}${r?`:${r}`:``}/${t}`}return`https://${e}/${t}`}var At=e=>e.lang===`en`?`en`:e.form===`sie`?`de-sie`:`de-du`;function jt(e){return e===`en`?{lang:`en`}:{lang:`de`,form:e===`de-sie`?`sie`:`du`}}function Mt(e,t,n){let r=0;for(;r<e.length&&r<t.length&&e[r]===t[r];)r++;let i=e.length,a=t.length;for(;i>r&&a>r&&e[i-1]===t[a-1];)i--,a--;let o=[];for(let e=0;e<r;e++)o.push([e,e]);let s=i-r,c=a-r;if(s>0&&c>0){let i=s+c,a=i,l=new Int32Array(2*i+2),u=[],d=!1;for(let o=0;o<=i&&o<=n;o++){u.push(l.slice());for(let n=-o;n<=o;n+=2){let i=n===-o||n!==o&&l[a+n-1]<l[a+n+1]?l[a+n+1]:l[a+n-1]+1,u=i-n;for(;i<s&&u<c&&e[r+i]===t[r+u];)i++,u++;if(l[a+n]=i,i>=s&&u>=c){d=!0;break}}if(d)break}if(!d)return null;let f=[],p=s,m=c;for(let e=u.length-1;e>=0&&(p>0||m>0);e--){let t=u[e],n=p-m,i=n===-e||n!==e&&t[a+n-1]<t[a+n+1]?n+1:n-1,o=e===0?0:t[a+i],s=o-i;for(;p>o&&m>s;)p--,m--,f.push([r+p,r+m]);e>0&&(p=o,m=s)}o.push(...f.reverse())}for(let t=0;t<e.length-i;t++)o.push([i+t,a+t]);return o}var Nt=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),Pt=4e3;function Ft(e,t,n){if(t===n||n===e)return{text:t,clean:!0,conflicts:0};if(t===e)return{text:n,clean:!0,conflicts:0};let r=e.split(`
2
- `),i=t.split(`
3
- `),a=n.split(`
4
- `),o=Mt(r,i,Pt),s=Mt(r,a,Pt);if(!o||!s)return{text:t,clean:!1,conflicts:1};let c=new Map(o.map(([e,t])=>[e,t])),l=new Map(s.map(([e,t])=>[e,t])),u=[],d=0,f=0,p=0,m=0,h=(e,t,n)=>{let o=r.slice(f,e),s=i.slice(p,t),c=a.slice(m,n);Nt(s,o)?u.push(...c):(Nt(c,o)||Nt(s,c)||d++,u.push(...s))};for(let e=0;e<r.length;e++){let t=c.get(e),n=l.get(e);t===void 0||n===void 0||t<p||n<m||(h(e,t,n),u.push(r[e]),f=e+1,p=t+1,m=n+1)}return h(r.length,i.length,a.length),{text:u.join(`
5
- `),clean:d===0,conflicts:d}}var It=class extends Error{theirs;constructor(e){super(`changed elsewhere`),this.theirs=e}},Lt=(e,t)=>Date.parse(e)>Date.parse(t);function Rt(e){let t=(0,Q.useRef)(e);t.current=e;let n=(0,Q.useRef)(e.initial),r=(0,Q.useRef)(null),i=(0,Q.useRef)(null),[a,o]=(0,Q.useState)(null),s=(0,Q.useCallback)(e=>{n.current=e,t.current.surface.apply(e.value)},[]);(0,Q.useEffect)(()=>we(e.kind,e.id,e=>{let a=e.view===void 0?null:t.current.fromView(e.view);a&&Lt(a.at,n.current.at)&&(i.current?i.current=a:t.current.surface.hasUnsavedEdits()?r.current=a:s(a))}),[e.kind,e.id,s]),(0,Q.useEffect)(()=>{if(a!==`merged`)return;let e=setTimeout(()=>o(null),6e3);return()=>clearTimeout(e)},[a]);let c=(0,Q.useCallback)(async(e,a=1)=>{let s=t.current;if(i.current)return;let l=e,u=n.current.at,d=r.current;if(r.current=null,d){let t=s.merge(n.current.value,e,d.value);if(!t.clean){i.current=d,o(`conflict`);return}l=t.value,u=d.at,s.same(l,e)||s.surface.apply(l),o(`merged`)}try{let e=await s.send(l,u);n.current={value:l,at:e}}catch(e){if(e instanceof It&&a>0)return r.current=e.theirs,c(l,a-1);throw e}},[]);return{save:e=>c(e),notice:a,keepMine:(0,Q.useCallback)(()=>{let e=i.current;i.current=null,o(null),e&&(n.current={value:n.current.value,at:e.at}),t.current.surface.saveNow()},[]),takeTheirs:(0,Q.useCallback)(()=>{let e=i.current;i.current=null,o(null),e&&s(e)},[s])}}var zt={choice:lt,date:Ke,number:Xe,text:fe,boolean:dt},Bt=e=>S.knowledge(e);function Vt(e){return e===1?U(`know.item`):U(`know.items`,{n:e})}function $(e,t){if(e.type===`boolean`||typeof t==`boolean`)return U(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(R,{day:`2-digit`,month:`2-digit`,year:`numeric`});return n?`${i} ${n}`:i}return e.type===`number`&&typeof t==`number`?`${t.toLocaleString(R)}${e.unit?` ${e.unit}`:``}`:String(t)}function Ht(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=>$(e,t)).join(`, `)]:[]}).join(` · `)}function Ut({trigger:e,open:t,onOpen:n,children:r}){let i=(0,Q.useRef)(null);return(0,Q.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,Z.jsxs)(`div`,{ref:i,className:`relative inline-flex`,children:[e,t?(0,Z.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 Wt({category:e,current:t,onSave:n}){let[r,i]=(0,Q.useState)(t[0]===void 0?``:String(t[0]));if(e.type===`choice`){let a=t.map(String);return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[e.values.length?(0,Z.jsx)(H,{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,Z.jsxs)(`form`,{className:`flex gap-2`,onSubmit:t=>{t.preventDefault(),r.trim()&&n(e.multiple?[...a,r.trim()]:[r.trim()])},children:[(0,Z.jsx)(C,{"data-autofocus":!0,value:a.includes(r)?``:r,placeholder:U(`know.addValue`),onChange:e=>i(e.target.value),className:`h-9`}),(0,Z.jsx)(_,{label:U(`know.addValue`),type:`submit`,children:(0,Z.jsx)(A,{className:`size-4`})})]})]})}return e.type===`boolean`?(0,Z.jsx)(H,{value:t[0]===!0?U(`know.yes`):t[0]===!1?U(`know.no`):``,options:[U(`know.yes`),U(`know.no`)],onChange:e=>n([e===U(`know.yes`)])}):(0,Z.jsxs)(`form`,{className:`flex gap-2`,onSubmit:t=>{t.preventDefault(),n(r.trim()?[e.type===`number`?Number(r.replace(`,`,`.`)):r.trim()]:[])},children:[(0,Z.jsx)(C,{"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,Z.jsx)(g,{type:`submit`,size:`sm`,children:`OK`})]})}function Gt({projectId:e,itemKey:t,has:n,categories:r,readOnly:i}){let a=I(),[o,s]=(0,Q.useState)(null),[l,u]=(0,Q.useState)(n);(0,Q.useEffect)(()=>u(n),[n]);let d=J({mutationFn:({categoryId:n,next:r})=>c.put(`/api/studio/projects/${e}/items/${t}/categories/${n}`,{values:r}),onSuccess:()=>a.invalidateQueries({queryKey:Bt(e)})}),f=r.filter(e=>!(e.proposed||e.tableId)),p=(e,t)=>{u(n=>[...n.filter(t=>t.categoryId!==e.id),...t.length?[{categoryId:e.id,values:t,by:`person`}]:[]]),d.mutate({categoryId:e.id,next:t}),s(null)},m=f.filter(e=>l.some(t=>t.categoryId===e.id)),h=f.filter(e=>!l.some(t=>t.categoryId===e.id));return f.length?(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[m.map(e=>{let t=l.find(t=>t.categoryId===e.id),n=zt[e.type],r=(0,Z.jsxs)(`button`,{type:`button`,disabled:i,title:`${e.name} · ${U(`know.by.${t.by}`)}`,onClick:()=>s(o===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,Z.jsx)(n,{className:`size-3.5 text-ink-3`}),(0,Z.jsx)(`span`,{className:`text-ink-3`,children:e.name}),(0,Z.jsx)(`span`,{className:`font-medium`,children:t.values.map(t=>$(e,t)).join(`, `)})]},e.id);return i?(0,Z.jsx)(`span`,{children:r},e.id):(0,Z.jsxs)(Ut,{trigger:r,open:o===e.id,onOpen:t=>s(t?e.id:null),children:[(0,Z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-[0.8125rem]`,children:e.name}),(0,Z.jsx)(_,{label:U(`know.remove`),onClick:()=>p(e,[]),className:`size-7`,children:(0,Z.jsx)(j,{className:`size-3.5`})})]}),(0,Z.jsx)(Wt,{category:e,current:t.values,onSave:t=>p(e,t)})]},e.id)}),i||!h.length?null:(0,Z.jsx)(Ut,{open:o===`+`,onOpen:e=>s(e?`+`:null),trigger:(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>s(o===`+`?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,Z.jsx)(A,{className:`size-3.5`}),` `,U(`know.category`)]}),children:(0,Z.jsx)(Kt,{categories:h,onSave:p})})]}):null}function Kt({categories:e,onSave:t}){let[n,r]=(0,Q.useState)(e[0]?.id??``),i=e.find(e=>e.id===n);return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[(0,Z.jsx)(f,{value:n,onChange:r,options:e.map(e=>({value:e.id,label:e.name}))}),i?(0,Z.jsx)(Wt,{category:i,current:[],onSave:e=>t(i,e)},i.id):null]})}function qt({projectId:e,open:t,onClose:n,onMade:i}){let a=I(),[o,s]=(0,Q.useState)(``),[u,d]=(0,Q.useState)(`choice`),[p,m]=(0,Q.useState)(``),[h,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(!1),[b,S]=(0,Q.useState)(``),[w,T]=(0,Q.useState)(``),E=J({mutationFn:()=>c.post(`/api/studio/projects/${e}/categories`,{name:o.trim(),type:u,unit:u===`number`&&p.trim()||null,multiple:u===`choice`&&h,ordered:u===`choice`&&v,hint:w.trim()||null,values:u===`choice`?b.split(`
6
- `).map(e=>e.trim()).filter(Boolean):void 0}),onSuccess:async({id:t})=>{await a.invalidateQueries({queryKey:Bt(e)}),s(``),S(``),T(``),i(t)}});return(0,Z.jsx)(x,{open:t,onClose:n,title:U(`know.newCategory`),children:(0,Z.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),o.trim()&&E.mutate()},children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(l,{children:U(`know.name`)}),(0,Z.jsx)(C,{"data-autofocus":!0,value:o,maxLength:80,onChange:e=>s(e.target.value)})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(l,{children:U(`know.type`)}),(0,Z.jsx)(f,{value:u,onChange:e=>d(e),options:[`choice`,`date`,`number`,`text`,`boolean`].map(e=>({value:e,label:U(`know.type.${e}`)}))})]}),u===`number`?(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(l,{hint:U(`know.unitHint`),children:U(`know.unit`)}),(0,Z.jsx)(C,{value:p,maxLength:20,onChange:e=>m(e.target.value)})]}):null,u===`choice`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(l,{hint:U(`know.valuesHint`),children:U(`know.values`)}),(0,Z.jsx)(r,{minRows:3,value:b,onChange:e=>S(e.target.value)})]}),(0,Z.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-[0.875rem]`,children:[U(`know.multiple`),(0,Z.jsx)(O,{checked:h,onChange:_})]}),(0,Z.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-[0.875rem]`,children:[U(`know.ordered`),(0,Z.jsx)(O,{checked:v,onChange:y})]})]}):null,(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(l,{hint:U(`know.hintFieldHint`),children:U(`know.hintField`)}),(0,Z.jsx)(C,{value:w,maxLength:120,onChange:e=>T(e.target.value)})]}),E.error?(0,Z.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:E.error.message}):null,(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Z.jsx)(g,{variant:`ghost`,onClick:n,children:U(`common.cancel`)}),(0,Z.jsx)(g,{type:`submit`,busy:E.isPending,disabled:!o.trim(),children:U(`know.create`)})]})]})})}function Jt({projectId:e,category:t,readOnly:n,onOpen:r,onGone:i}){let a=I(),s=()=>a.invalidateQueries({queryKey:Bt(e)}),[l,u]=(0,Q.useState)(``),f=J({mutationFn:e=>e(),onSuccess:s}),p=zt[t.type],m=new Map(t.values.map(e=>[e.id,e]));return(0,Z.jsxs)(G,{title:t.name,hint:[U(`know.type.${t.type}`),t.unit,t.hint].filter(Boolean).join(` · `),plain:!0,action:n?null:(0,Z.jsx)(_,{label:U(`know.deleteCategory`),className:`hover:text-rose`,onClick:()=>confirm(U(`know.confirmCategory`,{name:t.name}))&&f.mutate(async()=>{await c.del(`/api/studio/categories/${t.id}`),i()}),children:(0,Z.jsx)(M,{className:`size-4`})}),children:[t.proposed&&!n?(0,Z.jsxs)(K,{className:`flex flex-wrap items-center gap-3 p-4`,children:[(0,Z.jsx)(o,{tone:`ember`,children:U(`know.proposed`)}),(0,Z.jsx)(`span`,{className:`flex-1 text-[0.875rem] text-ink-2`,children:U(`know.proposedHint`)}),(0,Z.jsx)(g,{size:`sm`,onClick:()=>f.mutate(()=>c.patch(`/api/studio/categories/${t.id}`,{proposed:!1})),children:U(`know.accept`)})]}):null,t.alike.map(([e,t])=>{let r=m.get(e),i=m.get(t);if(!(r&&i))return null;let[a,o]=r.count<i.count?[r,i]:[i,r];return(0,Z.jsxs)(K,{className:`flex flex-wrap items-center gap-3 p-4`,children:[(0,Z.jsx)(`span`,{className:`flex-1 text-[0.875rem] text-ink-2`,children:U(`know.alike`,{a:a.value,b:o.value})}),n?null:(0,Z.jsx)(g,{size:`sm`,variant:`secondary`,busy:f.isPending,onClick:()=>f.mutate(()=>c.post(`/api/studio/values/${a.id}/merge`,{into:o.id})),children:U(`know.merge`)})]},`${e}:${t}`)}),(0,Z.jsxs)(K,{className:`flex flex-col p-1.5`,children:[t.type===`choice`?t.values.length?t.values.map(e=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>r(`v:${e.id}`),className:`flex items-center gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent`,children:[(0,Z.jsx)(p,{className:`size-4 shrink-0 text-ink-3`}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.875rem]`,children:e.value}),e.summary?(0,Z.jsx)(o,{children:U(`know.summary`)}):null,(0,Z.jsx)(`span`,{className:`shrink-0 text-[0.75rem] text-ink-3 tabular-nums`,children:Vt(e.count)})]},e.id)):(0,Z.jsx)(d,{children:U(`know.empty`)}):(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2.5 text-[0.875rem]`,children:[(0,Z.jsx)(p,{className:`size-4 shrink-0 text-ink-3`}),(0,Z.jsx)(`span`,{className:`flex-1 text-ink-2`,children:t.range?U(`know.range`,{min:$(t,t.range.min),max:$(t,t.range.max)}):U(`know.unset`)}),(0,Z.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:Vt(t.count)})]}),t.type===`choice`&&!n?(0,Z.jsxs)(`form`,{className:`flex gap-2 border-border-soft border-t p-2`,onSubmit:e=>{e.preventDefault();let n=l.trim();n&&(u(``),f.mutate(()=>c.post(`/api/studio/categories/${t.id}/values`,{value:n})))},children:[(0,Z.jsx)(C,{value:l,placeholder:U(`know.addValue`),onChange:e=>u(e.target.value),className:`h-9`}),(0,Z.jsx)(_,{label:U(`know.addValue`),type:`submit`,children:(0,Z.jsx)(A,{className:`size-4`})})]}):null]}),f.error?(0,Z.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:f.error.message}):null]})}function Yt(e){return z({queryKey:[`knowledge-value`,e],queryFn:()=>c.get(`/api/studio/values/${e}`),enabled:!!e})}function Xt({value:e,readOnly:t,children:n}){let r=I(),i=J({mutationFn:()=>c.post(`/api/studio/values/${e.id}/summary`),onSuccess:()=>r.invalidateQueries({queryKey:[`knowledge-value`,e.id]})});return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[(0,Z.jsx)(G,{title:U(`know.summary`),hint:U(`know.summaryHint`),plain:!0,action:t?null:(0,Z.jsxs)(g,{variant:`secondary`,size:`sm`,busy:i.isPending,onClick:()=>i.mutate(),children:[e.summary?(0,Z.jsx)(ae,{className:`size-4`}):null,e.summary?U(`know.summaryAgain`):U(`know.summaryWrite`)]}),children:(0,Z.jsxs)(K,{className:`p-4 sm:p-5`,children:[i.isPending?(0,Z.jsx)(`div`,{className:`flex h-24 items-center justify-center text-ink-3`,children:(0,Z.jsx)(D,{})}):e.summary?(0,Z.jsx)(B,{text:e.summary,className:`text-[0.875rem]`}):(0,Z.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:U(`know.summaryEmpty`)}),i.error?(0,Z.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:i.error.message}):null]})}),(0,Z.jsx)(G,{title:U(`know.toc`),plain:!0,children:n})]})}function Zt(e){return z({queryKey:S.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 Qt(e){return e.kind===`table`?e.format===`faq`?et:q:e.kind===`file`?oe:e.children?Je:m}function $t({item:e,categories:t,onOpen:n}){let r=Qt(e),i=[Ht(t,e.categories),e.children?e.children===1?U(`know.oneSub`):U(`know.sub`,{n:e.children}):``,e.rows===null?``:e.rows===1?U(`know.row`):U(`know.rows`,{n:e.rows}),e.originLabel??``].filter(Boolean).join(` · `);return(0,Z.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,Z.jsx)(r,{className:`mt-0.5 size-4 shrink-0 text-ink-3`}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`block truncate text-[0.875rem]`,children:e.title}),i?(0,Z.jsx)(`span`,{className:`block truncate text-[0.75rem] text-ink-3`,children:i}):null]}),e.status===`pending`?(0,Z.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1.5 text-[0.75rem] text-ink-3`,children:[(0,Z.jsx)(D,{className:`size-3`}),` `,U(`know.reading`)]}):e.review?(0,Z.jsx)(o,{tone:`warn`,title:e.review,children:U(`know.review`)}):null]})}function en({projectId:e,itemKey:t,has:n,originLabel:r,kept:i,review:a,file:s,readOnly:c,onReviewed:l}){let u=Zt(e),d=[r?U(i?`know.kept`:`know.from`,{label:r}):``].filter(Boolean);return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 px-1`,children:[u.data?(0,Z.jsx)(Gt,{projectId:e,itemKey:t,has:n,categories:u.data.categories,readOnly:c}):null,d.length||s||a?(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-[0.8125rem] text-ink-3`,children:[d.map(e=>(0,Z.jsx)(`span`,{children:e},e)),s?(0,Z.jsxs)(`a`,{href:le(e,s.id),target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 underline-offset-2 hover:text-ink hover:underline`,children:[(0,Z.jsx)(oe,{className:`size-3.5`}),` `,U(`know.original`),`: `,s.name]}):null,a?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,Z.jsx)(o,{tone:`warn`,children:U(`know.review`)}),(0,Z.jsx)(`span`,{children:a}),c?null:(0,Z.jsx)(`button`,{type:`button`,onClick:l,className:`underline hover:text-ink`,children:U(`know.reviewed`)})]}):null]}):null]})}function tn(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 nn({projectId:e,category:t,categories:n,onOpen:r}){let i=z({queryKey:[`knowledge`,e,`category`,t.id],queryFn:()=>c.get(`/api/studio/categories/${t.id}/items`)});if(!i.data)return i.isLoading?(0,Z.jsx)(D,{className:`mx-auto size-4 text-ink-3`}):null;let a=e=>e.categories.find(e=>e.categoryId===t.id)?.values[0],o=[...i.data.items].sort((e,t)=>{let n=a(e),r=a(t);return typeof n==`number`&&typeof r==`number`?n-r:String(r??``).localeCompare(String(n??``),R)}),s=t.type===`number`?tn(o.map(a).filter(e=>typeof e==`number`)):[],l=new Intl.NumberFormat(R,{notation:`compact`,maximumFractionDigits:1}),u=t.unit?` ${t.unit}`:``,d=new Map;for(let e of o){let n=a(e),r=typeof n==`number`?s.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(R,{month:`long`,year:`numeric`}):r?U(`know.range`,{min:`${l.format(r.lo)}${u}`,max:`${l.format(r.hi)}${u}`}):$(t,n);d.set(i,[...d.get(i)??[],e])}return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[[...d].map(([e,t])=>(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e?(0,Z.jsx)(`p`,{className:`px-1 font-medium text-[0.6875rem] text-ink-4 uppercase tracking-[0.12em]`,children:e}):null,(0,Z.jsx)(K,{className:`flex flex-col p-1.5`,children:t.map(e=>(0,Z.jsx)($t,{item:e,categories:n,onOpen:r},e.key))})]},e)),i.data.rows.map(e=>(0,Z.jsx)(`button`,{type:`button`,onClick:()=>r(`t:${e.tableId}`),className:`px-1 text-left text-[0.8125rem] text-ink-3 hover:text-ink`,children:U(`know.tocRows`,{n:e.count,table:e.title})},e.tableId))]})}function rn(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 an(e,t){if(Array.isArray(t))return t.map(String).join(`, `);if(typeof t==`boolean`)return U(t?`know.yes`:`know.no`);if(typeof t==`object`&&t){let n=t.gte??t.after,r=t.lte??t.before;return t.contains?`${U(`know.contains`)} ${t.contains}`:[n===void 0?``:`${U(`know.minimum`)} ${$(e,n)}`,r===void 0?``:`${U(`know.maximum`)} ${$(e,r)}`].filter(Boolean).join(` `)}return String(t)}function on({category:e,value:t,onChange:n}){let[r,i]=(0,Q.useState)(!1),a=(0,Q.useRef)(null);(0,Q.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=zt[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,Z.jsxs)(`div`,{ref:a,className:`relative`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>i(!r),className:P(`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,Z.jsx)(o,{className:`size-3.5 text-ink-3`}),e.name,t===void 0?null:(0,Z.jsxs)(`span`,{className:`font-medium`,children:[`: `,an(e,t)]}),(0,Z.jsx)(b,{className:`size-3.5 text-ink-3`})]}),r?(0,Z.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,Z.jsx)(H,{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,Z.jsx)(H,{value:t===!0?U(`know.yes`):t===!1?U(`know.no`):``,options:[U(`know.yes`),U(`know.no`)],onChange:e=>n(e===U(`know.yes`))}):e.type===`text`?(0,Z.jsx)(C,{"data-autofocus":!0,value:s.contains??``,placeholder:U(`know.contains`),onChange:e=>n(e.target.value?{contains:e.target.value}:void 0),className:`h-9`}):(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:(e.type===`number`?[`gte`,`lte`]:[`after`,`before`]).map((t,n)=>(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(l,{children:U(n===0?`know.minimum`:`know.maximum`)}),(0,Z.jsx)(C,{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,Z.jsx)(`button`,{type:`button`,onClick:()=>{n(void 0),i(!1)},className:`mt-3 text-[0.8125rem] text-ink-3 underline hover:text-ink`,children:U(`know.clear`)})]}):null]})}function sn({found:e,onOpen:t}){return e.hits.length?(0,Z.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Z.jsx)(`p`,{className:`px-3 pt-1 pb-2 text-[0.75rem] text-ink-3`,children:e.checked?U(`know.searchStats`,{candidates:e.candidates,hits:e.hits.length}):U(`know.searchUnchecked`,{hits:e.hits.length})}),e.hits.map(e=>{let n=e.open;return(0,Z.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,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`span`,{className:`block truncate text-[0.875rem]`,children:[e.title,e.heading&&e.heading!==e.title?(0,Z.jsxs)(`span`,{className:`text-ink-3`,children:[` › `,e.heading]}):null]}),(0,Z.jsx)(`span`,{className:`line-clamp-2 text-[0.8125rem] text-ink-3`,children:e.text})]}),e.relevance===null?null:(0,Z.jsx)(`span`,{className:`shrink-0 font-medium text-[0.75rem] text-moss tabular-nums`,children:e.relevance.toLocaleString(R,{minimumFractionDigits:2})})]},`${e.key}:${e.heading}`)})]}):(0,Z.jsx)(`p`,{className:`px-3 py-4 text-[0.875rem] text-ink-3`,children:U(`know.searchNone`)})}function cn({kind:e,projectId:t,onClose:n,onMade:r}){let i=I(),[a,o]=(0,Q.useState)(``),[s,u]=(0,Q.useState)(!1),d=J({mutationFn:()=>c.post(`/api/studio/projects/${t}/${e===`table`?`tables`:`pages`}`,{title:a.trim(),...e===`table`&&s?{format:`faq`}:{}}),onSuccess:async({id:n})=>{await i.invalidateQueries({queryKey:S.knowledge(t)}),r(`${e===`table`?`t`:`p`}:${n}`),o(``),u(!1)}});return(0,Z.jsx)(x,{open:e!==null,onClose:n,title:U(e===`table`?`know.newTable`:`know.newPage`),children:(0,Z.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),a.trim()&&d.mutate()},children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(l,{children:U(`data.title`)}),(0,Z.jsx)(C,{"data-autofocus":!0,value:a,maxLength:120,onChange:e=>o(e.target.value)})]}),e===`table`?(0,Z.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-[0.875rem]`,children:[U(`know.asFaq`),(0,Z.jsx)(O,{checked:s,onChange:u})]}):null,d.error?(0,Z.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:d.error.message}):null,(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Z.jsx)(g,{variant:`ghost`,onClick:n,children:U(`common.cancel`)}),(0,Z.jsx)(g,{type:`submit`,busy:d.isPending,disabled:!a.trim(),children:U(`know.create`)})]})]})})}function ln({projectId:e,data:t,readOnly:n,onOpen:r}){let i=I(),a=v(e,n),[s,l]=(0,Q.useState)({}),[u,f]=(0,Q.useState)(``),[p,m]=(0,Q.useState)(null),[h,_]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(null),x=t.categories.filter(e=>!e.proposed&&e.count>0),C=t.categories.filter(e=>e.proposed),w=t.items.filter(e=>Object.entries(s).every(([n,r])=>{let i=t.categories.find(e=>e.name===n),a=e.categories.find(e=>e.categoryId===i?.id);return i&&a?rn(i,a.values,r):!1})),T=async()=>{if(!u.trim()){m(null);return}_(!0);try{m(await c.post(`/api/studio/projects/${e}/search`,{query:u,...Object.keys(s).length?{where:s}:{}}))}catch{m({hits:[],candidates:0,checked:!1,filtered:null})}finally{_(!1)}},E=J({mutationFn:({id:e,keep:t})=>t?c.patch(`/api/studio/categories/${e}`,{proposed:!1}):c.del(`/api/studio/categories/${e}`),onSuccess:()=>i.invalidateQueries({queryKey:S.knowledge(e)})});return(0,Z.jsxs)(G,{title:U(`know.title`),hint:U(`know.hint`),plain:!0,action:n?null:(0,Z.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,Z.jsxs)(g,{variant:`secondary`,size:`sm`,onClick:()=>b(`page`),children:[(0,Z.jsx)(A,{className:`size-4`}),` `,U(`know.page`)]}),(0,Z.jsxs)(g,{variant:`secondary`,size:`sm`,onClick:()=>b(`table`),children:[(0,Z.jsx)(A,{className:`size-4`}),` `,U(`know.table`)]}),(0,Z.jsxs)(g,{variant:`secondary`,size:`sm`,onClick:()=>b(`category`),children:[(0,Z.jsx)(A,{className:`size-4`}),` `,U(`know.category`)]})]}),children:[C.length&&!n?(0,Z.jsx)(K,{className:`flex flex-col gap-2 p-4`,children:C.map(e=>{let t=zt[e.type];return(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5`,children:[(0,Z.jsx)(o,{tone:`ember`,children:U(`know.proposed`)}),(0,Z.jsx)(t,{className:`size-4 text-ink-3`}),(0,Z.jsx)(`span`,{className:`font-medium text-[0.875rem]`,children:e.name}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.8125rem] text-ink-3`,children:[U(`know.type.${e.type}`),e.hint].filter(Boolean).join(` · `)}),(0,Z.jsx)(g,{size:`sm`,variant:`ghost`,onClick:()=>E.mutate({id:e.id,keep:!1}),children:U(`know.dismiss`)}),(0,Z.jsx)(g,{size:`sm`,onClick:()=>E.mutate({id:e.id,keep:!0}),children:U(`know.accept`)})]},e.id)})}):null,t.items.length?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(W,{value:u,placeholder:U(`know.search`),busy:h,onEnter:()=>void T(),onChange:e=>{f(e),e.trim()||m(null)}}),x.length?(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[x.map(e=>(0,Z.jsx)(on,{category:e,value:s[e.name],onChange:t=>{m(null),l(n=>{let r={...n};return t===void 0?delete r[e.name]:r[e.name]=t,r})}},e.id)),Object.keys(s).length?(0,Z.jsx)(`button`,{type:`button`,onClick:()=>l({}),className:`px-2 text-[0.8125rem] text-ink-3 underline hover:text-ink`,children:U(`know.clear`)}):null]}):null]}):null,(0,Z.jsx)(K,{className:`flex flex-col p-1.5`,children:p?(0,Z.jsx)(sn,{found:p,onOpen:r}):w.length?w.map(e=>(0,Z.jsx)($t,{item:e,categories:t.categories,onOpen:r},e.key)):(0,Z.jsx)(d,{children:U(`know.empty`)})}),n?null:(0,Z.jsxs)(L,{accept:`.pdf,.docx,.doc,.xlsx,.csv,.tsv,.txt,.md,.json,.html,.eml,image/*`,onFiles:async t=>{await a.upload(`document`,t),await i.invalidateQueries({queryKey:S.knowledge(e)})},className:`h-14 w-full`,children:[a.busy?(0,Z.jsx)(D,{className:`size-4`}):(0,Z.jsx)(Ce,{className:`size-4`}),U(`know.drop`),` `,(0,Z.jsx)(`span`,{className:`underline`,children:U(`know.pick`)})]}),a.error?(0,Z.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:a.error}):null,t.items.length&&!(t.checked&&t.embeddings)?(0,Z.jsx)(`p`,{className:`px-1 text-[0.8125rem] text-ink-3`,children:[t.embeddings?``:U(`know.keywordsOnly`),t.checked?``:U(`know.unchecked`)].filter(Boolean).join(` `)}):null,(0,Z.jsx)(cn,{kind:y===`page`||y===`table`?y:null,projectId:e,onClose:()=>b(null),onMade:e=>{b(null),r(e)}}),(0,Z.jsx)(qt,{projectId:e,open:y===`category`,onClose:()=>b(null),onMade:e=>{b(null),r(`c:${e}`)}})]})}function un({page:e,onGone:t,onOpen:n}){let r=I(),[a,s]=(0,Q.useState)(e.title),[l,d]=(0,Q.useState)(e.markdown),[f,p]=(0,Q.useState)(e.markdown?`read`:`write`),h=e.knowledge,v=Y().data?.user.id,[y,b]=(0,Q.useState)(!1),[x,C]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{if(!y)return;let e=setTimeout(()=>b(!1),1e4);return()=>clearTimeout(e)},[y,l,a]),Ie(`page`,e.id,{state:y?`editing`:`viewing`,place:x?.id,placeLabel:x?.label});let w=Ne(`page`,e.id,v,y?x?.id:null),T=Oe(`page`,e.id,v),E=e=>{let t=fn(e.currentTarget.value,e.currentTarget.selectionStart);C(e=>e?.id===t?.id?e:t)},O=async()=>{await r.invalidateQueries({queryKey:S.spaceData(e.projectId)}),await r.invalidateQueries({queryKey:S.knowledge(e.projectId)})},k=i({title:a.trim()||e.title,markdown:l},e=>j.save(e)),j=Rt({kind:`page`,id:e.id,initial:{value:{title:e.title,markdown:e.markdown},at:e.updatedAt},fromView:e=>{let t=e;return{value:{title:t.title,markdown:t.markdown},at:t.updatedAt}},merge:(e,t,n)=>{let r=Ft(e.markdown,t.markdown,n.markdown),i=t.title===n.title||n.title===e.title?t.title:t.title===e.title?n.title:null;return{value:{title:i??t.title,markdown:r.text},clean:r.clean&&i!==null}},same:(e,t)=>e.title===t.title&&e.markdown===t.markdown,surface:{apply:t=>{s(t.title),d(t.markdown),k.markSaved(t),r.setQueryData(S.page(e.id),e=>e&&{...e,...t})},hasUnsavedEdits:()=>k.pending(),saveNow:()=>k.saveNow()},send:async(t,n)=>{try{let{updatedAt:i}=await c.patch(`/api/studio/pages/${e.id}`,{...t,baseUpdatedAt:n});return r.setQueryData(S.page(e.id),e=>e&&{...e,...t,updatedAt:i}),t.title!==e.title&&await O(),i}catch(e){let t=e instanceof te&&e.status===409?e.body?.page:null;throw t?new It({value:{title:t.title,markdown:t.markdown},at:t.updatedAt}):e}}}),N=J({mutationFn:()=>c.del(`/api/studio/pages/${e.id}`),onSuccess:async()=>{await O(),t()}}),F=J({mutationFn:()=>c.post(`/api/studio/projects/${e.projectId}/pages`,{title:U(`know.addSub`),parentId:e.id}),onSuccess:async({id:e})=>{await O(),n?.(`p:${e}`)}}),ee=J({mutationFn:()=>c.patch(`/api/studio/pages/${e.id}`,{review:null}),onSuccess:()=>r.invalidateQueries({queryKey:S.page(e.id)})}),L=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}`)},R=e.readOnly,z=h?.file&&(h.file.mime===`application/pdf`||h.file.mime.startsWith(`image/`))?h.file:null,V=(e,t)=>(0,Z.jsx)(`button`,{type:`button`,"aria-pressed":f===e,onClick:()=>p(e),className:P(`rounded-full px-3 py-1 text-[0.8125rem] transition`,f===e?`bg-paper-2 font-medium text-ink`:`text-ink-3 hover:text-ink`),children:t});return(0,Z.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[h?.parents.length&&n?(0,Z.jsx)(`nav`,{className:`-mb-1.5 flex flex-wrap items-center gap-1 px-1 text-[0.8125rem] text-ink-3`,children:h.parents.map(e=>(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>n(`p:${e.id}`),className:`hover:text-ink`,children:e.title}),(0,Z.jsx)(ue,{className:`size-3.5`})]},e.id))}):null,(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,Z.jsx)(`input`,{value:a,disabled:R,maxLength:200,onChange:e=>{s(e.target.value),b(!0)},"aria-label":U(`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`}),j.notice===`merged`?(0,Z.jsx)(o,{icon:(0,Z.jsx)(Ae,{className:`size-3`}),children:T[0]?U(`editor.mergedWith`,{name:T[0].name}):U(`editor.merged`)}):null,(0,Z.jsx)(Me,{kind:`page`,item:e.id,me:v}),j.notice===`conflict`?null:k.state===`saving`?(0,Z.jsx)(D,{className:`size-3.5 text-ink-3`}):k.state===`saved`?(0,Z.jsx)(u,{className:`size-4 text-moss`,"aria-label":U(`settings.saved`)}):null,R?null:(0,Z.jsx)(_,{label:U(`data.deletePage`),onClick:()=>confirm(U(`data.confirmDelete`,{title:e.title}))&&N.mutate(),className:`hover:text-rose`,children:(0,Z.jsx)(M,{className:`size-4`})})]}),w&&j.notice!==`conflict`?(0,Z.jsx)(`p`,{className:`-mt-1 px-1 text-[0.8125rem] text-ink-3`,children:U(`presence.alsoHere`,{name:w.name})}):null,j.notice===`conflict`?(0,Z.jsxs)(`div`,{role:`status`,className:`flex flex-wrap items-center gap-2 rounded-lg bg-paper-2 px-3 py-2 text-[0.8125rem]`,children:[(0,Z.jsx)(Ae,{className:`size-4 shrink-0 text-ink-3`}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1`,children:U(`data.changedElsewhere`)}),(0,Z.jsx)(g,{size:`sm`,variant:`ghost`,onClick:j.takeTheirs,children:U(`data.takeTheirs`)}),(0,Z.jsx)(g,{size:`sm`,onClick:j.keepMine,children:U(`data.keepMine`)})]}):null,h?(0,Z.jsx)(en,{projectId:e.projectId,itemKey:`p:${e.id}`,has:h.categories,originLabel:h.originLabel,kept:h.kept,review:h.review,file:z?null:h.file,readOnly:R,onReviewed:()=>ee.mutate()}):null,(0,Z.jsxs)(K,{className:`flex flex-col`,children:[R&&!z?null:(0,Z.jsxs)(`div`,{className:`flex items-center gap-1 border-border-soft border-b px-2 py-1.5`,children:[R?null:V(`write`,U(`data.write`)),V(`read`,U(`data.preview`)),z?V(`original`,U(`know.original`)):null,(0,Z.jsx)(`span`,{className:`ml-auto truncate px-2 text-[0.75rem] text-ink-4 max-sm:hidden`,children:f===`original`&&z?z.name:U(`data.markdownHint`)})]}),f===`original`&&z?z.mime===`application/pdf`?(0,Z.jsx)(`iframe`,{src:le(e.projectId,z.id),title:z.name,className:`h-[70dvh] w-full rounded-b-xl bg-paper-2`}):(0,Z.jsx)(`img`,{src:le(e.projectId,z.id),alt:``,className:`mx-auto max-h-[70dvh] object-contain p-4`}):f===`write`&&!R?(0,Z.jsx)(`textarea`,{value:l,onChange:e=>{d(e.target.value),b(!0),E(e)},onSelect:E,"aria-label":e.title,placeholder:U(`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,Z.jsx)(`div`,{className:`min-h-40 p-4 sm:p-5`,onClick:L,children:l.trim()?(0,Z.jsx)(B,{text:l}):(0,Z.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:U(`data.pageEmpty`)})})]}),k.state===`error`&&k.error?(0,Z.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:k.error}):null,h&&n&&(h.children.length||!R)?(0,Z.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between px-1`,children:[(0,Z.jsx)(`p`,{className:`font-medium text-[0.6875rem] text-ink-4 uppercase tracking-[0.12em]`,children:h.children.length?U(`know.subPages`):null}),R?null:(0,Z.jsxs)(g,{variant:`ghost`,size:`sm`,busy:F.isPending,onClick:()=>F.mutate(),children:[(0,Z.jsx)(A,{className:`size-4`}),` `,U(`know.addSub`)]})]}),h.children.length?(0,Z.jsx)(K,{className:`flex flex-col p-1.5`,children:h.children.map(e=>(0,Z.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,Z.jsx)(m,{className:`size-4 shrink-0 text-ink-3`}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.875rem]`,children:e.title})]},e.id))}):null]}):null]})}function dn({pageId:e,onGone:t,onOpen:n}){let r=z({queryKey:S.page(e),queryFn:()=>c.get(`/api/studio/pages/${e}`),refetchOnWindowFocus:!1});return r.data?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(ze,{kind:`page`,item:e}),(0,Z.jsx)(un,{page:r.data,onGone:t,onOpen:n},r.data.id)]}):r.isError?(0,Z.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:r.error.message}):null}function fn(e,t){let n=e.slice(0,t).split(`
7
- `);for(let e=n.length-1;e>=0;e--){let t=/^#{1,6}\s+(.+?)\s*#*$/.exec(n[e]??``);if(t?.[1])return{id:`h:${t[1].toLowerCase()}`,label:t[1]}}return null}function pn(e){return z({queryKey:S.spaceData(e),queryFn:()=>c.get(`/api/studio/projects/${e}/data`),enabled:!!e})}function mn(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:U(`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 hn={table:q,page:m};function gn({kind:e,projectId:t,data:n,onClose:r,onMade:i}){let a=I(),[o,s]=(0,Q.useState)(``),[u,d]=(0,Q.useState)(``),p=J({mutationFn:()=>c.post(`/api/studio/projects/${t}/${e===`table`?`tables`:`pages`}`,{title:o.trim(),wizardId:u||null}),onSuccess:async({id:n})=>{await a.invalidateQueries({queryKey:S.spaceData(t)}),i(`${e===`table`?`t`:`p`}:${n}`),s(``),d(``)}});return(0,Z.jsx)(x,{open:e!==null,onClose:r,title:U(e===`table`?`data.newTable`:`data.newPage`),children:(0,Z.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),o.trim()&&p.mutate()},children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(l,{children:U(`data.title`)}),(0,Z.jsx)(C,{"data-autofocus":!0,value:o,maxLength:120,onChange:e=>s(e.target.value)})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(l,{children:U(`data.owner`)}),(0,Z.jsx)(f,{value:u,onChange:d,options:[{value:``,label:U(`data.own`)},...n.wizards.map(e=>({value:e.id,label:e.title}))]})]}),p.error?(0,Z.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:p.error.message}):null,(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Z.jsx)(g,{variant:`ghost`,onClick:r,children:U(`common.cancel`)}),(0,Z.jsx)(g,{type:`submit`,busy:p.isPending,disabled:!o.trim(),children:U(`data.create`)})]})]})})}function _n({projectId:e,data:t,readOnly:n,onOpen:r}){let[i,a]=(0,Q.useState)(null);Be(n?null:{icon:A,label:U(`data.newTable`),run:()=>a(`table`)});let o=mn(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(R,{dateStyle:`medium`});return(0,Z.jsxs)(G,{title:U(`space.data`),hint:U(`data.hint`),plain:!0,action:n?null:(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsxs)(g,{variant:`secondary`,size:`sm`,onClick:()=>a(`table`),children:[(0,Z.jsx)(A,{className:`size-4`}),` `,U(`data.table`)]}),(0,Z.jsxs)(g,{variant:`secondary`,size:`sm`,onClick:()=>a(`page`),children:[(0,Z.jsx)(A,{className:`size-4`}),` `,U(`data.page`)]})]}),children:[o.length?(0,Z.jsx)(`div`,{className:`flex flex-col gap-5`,children:o.map(e=>(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`p`,{className:`px-1 font-medium text-[0.6875rem] text-ink-4 uppercase tracking-[0.12em]`,children:e.label}),(0,Z.jsx)(K,{className:`flex flex-col p-1.5`,children:e.items.map(e=>{let t=hn[e.kind];return(0,Z.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,Z.jsx)(t,{className:`size-4 shrink-0 text-ink-3`}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.875rem]`,children:e.title}),(0,Z.jsxs)(`span`,{className:`shrink-0 text-[0.75rem] text-ink-3 tabular-nums`,children:[e.kind===`table`?`${U(`data.rows`,{n:e.rows??0})} · `:``,c.format(new Date(s.get(e.key)??Date.now()))]})]},e.key)})})]},e.key))}):(0,Z.jsx)(K,{children:(0,Z.jsx)(d,{children:U(`data.empty`)})}),(0,Z.jsx)(gn,{kind:i,projectId:e,data:t,onClose:()=>a(null),onMade:e=>{a(null),r(e)}})]})}function vn(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 yn={milliseconds:1,seconds:1e3,minutes:6e4,hours:36e5,days:864e5},bn=[`text`,`number`,`date`,`duration`,`select`,`boolean`];function xn(e,t){if(t==null)return``;if(e.type===`duration`&&typeof t==`number`)return String(t/yn[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)}var Sn=`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 Cn({column:e,value:t,readOnly:n,invalid:r,onSave:i}){let a=xn(e,t),[o,s]=(0,Q.useState)(a),c=(0,Q.useRef)(a);(0,Q.useEffect)(()=>{s(e=>e===c.current?a:e),c.current=a},[a]);let l=(t=o)=>{t!==a&&i(w(e,t))};if(e.type===`boolean`)return(0,Z.jsx)(`div`,{className:`px-2 py-1.5`,children:(0,Z.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,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 px-2 py-1`,children:[r.map(e=>(0,Z.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,Z.jsx)(`button`,{type:`button`,"aria-label":U(`data.removeOption`),onClick:()=>i(r.filter(t=>t!==e)),className:`rounded-full text-ink-3 hover:text-ink`,children:(0,Z.jsx)(j,{className:`size-3`})})]},e)),n?null:(0,Z.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,Z.jsx)(`option`,{value:``,children:`+`}),e.format.options.filter(e=>!r.includes(e.id)).map(e=>(0,Z.jsx)(`option`,{value:e.id,children:e.label},e.id))]})]})}if(e.type===`select`)return(0,Z.jsxs)(`select`,{value:typeof t==`string`?t:``,disabled:n,onChange:e=>i(e.target.value||null),"aria-label":e.name,className:Sn,children:[(0,Z.jsx)(`option`,{value:``}),e.format.options.map(e=>(0,Z.jsx)(`option`,{value:e.id,children:e.label},e.id))]});if(e.type===`text`&&e.format?.style&&e.format.style!==`single`)return(0,Z.jsx)(`textarea`,{value:o,rows:1,disabled:n,onChange:e=>s(e.target.value),onBlur:()=>l(),"aria-label":e.name,className:P(Sn,`field-sizing-content max-h-40 resize-none`)});let u=e.type===`date`?{date:`date`,datetime:`datetime-local`,time:`time`}[e.format.kind]:`text`;return(0,Z.jsx)(`input`,{type:u,inputMode:e.type===`number`||e.type===`duration`?`decimal`:void 0,value:o,disabled:n,onChange:t=>{s(t.target.value),e.type===`date`&&l(t.target.value)},onBlur:()=>e.type!==`date`&&l(),onKeyDown:e=>{e.key===`Enter`&&e.target.blur(),e.key===`Escape`&&s(a)},"aria-label":e.name,className:P(Sn,(e.type===`number`||e.type===`duration`)&&`text-right tabular-nums`,r&&`ring-1 ring-rose`)})}function wn(e){return e.type===`number`&&e.format.style===`currency`?e.format.currency??null:e.type===`number`&&e.format.style===`percent`?`%`:e.type===`duration`?U(`data.unit.${e.format.inputUnit}`):null}function Tn(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(`
8
- `):``,multiple:e?.type===`select`&&!!e.format.multiple}}function En(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(`
9
- `).map(e=>e.trim()).filter(Boolean).map(e=>{let n=t.find(t=>t.label===e)?.id??vn(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 Dn({open:e,column:t,columns:n,onClose:i,onSave:a}){let[o,s]=(0,Q.useState)(()=>Tn(t)),[c,u]=(0,Q.useState)(null),[d,p]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{e&&(s(Tn(t)),u(null))},[e,t]);let m=e=>s(t=>({...t,...e})),h=async e=>{p(!0),u(null);try{await a(e),i()}catch(e){u(e.message)}finally{p(!1)}},_=()=>{let e=t?.id??vn(o.name,n.map(e=>e.id)),r=En(o,e,t);return h(t?n.map(e=>e.id===t.id?r:e):[...n,r])};return(0,Z.jsx)(x,{open:e,onClose:i,title:t?t.name:U(`data.newColumn`),children:(0,Z.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),o.name.trim()&&_()},children:[(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(l,{children:U(`data.columnName`)}),(0,Z.jsx)(C,{"data-autofocus":!0,value:o.name,maxLength:128,onChange:e=>m({name:e.target.value})})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(l,{children:U(`data.columnType`)}),(0,Z.jsx)(f,{value:o.type,onChange:e=>m({type:e}),options:bn.map(e=>({value:e,label:U(`data.type.${e}`)}))})]})]}),o.type===`text`?(0,Z.jsx)(f,{value:o.textStyle,onChange:e=>m({textStyle:e}),options:[{value:`single`,label:U(`data.text.single`)},{value:`multiline`,label:U(`data.text.multiline`)}]}):null,o.type===`number`?(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsx)(f,{value:o.numberStyle,onChange:e=>m({numberStyle:e}),options:[`integer`,`decimal`,`percent`,`currency`].map(e=>({value:e,label:U(`data.number.${e}`)}))}),o.numberStyle===`currency`?(0,Z.jsx)(C,{value:o.currency,maxLength:3,"aria-label":U(`data.currency`),placeholder:`EUR`,onChange:e=>m({currency:e.target.value})}):null]}):null,o.type===`date`?(0,Z.jsx)(f,{value:o.dateKind,onChange:e=>m({dateKind:e}),options:[`date`,`datetime`,`time`].map(e=>({value:e,label:U(`data.date.${e}`)}))}):null,o.type===`duration`?(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(l,{children:U(`data.unit`)}),(0,Z.jsx)(f,{value:o.unit,onChange:e=>m({unit:e}),options:[`minutes`,`hours`,`days`].map(e=>({value:e,label:U(`data.unit.${e}`)}))})]}):null,o.type===`select`?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(l,{children:U(`data.options`)}),(0,Z.jsx)(r,{minRows:3,value:o.options,onChange:e=>m({options:e.target.value})})]}),(0,Z.jsxs)(`label`,{className:`flex items-center gap-3 text-[0.875rem]`,children:[(0,Z.jsx)(O,{checked:o.multiple,onChange:e=>m({multiple:e})}),U(`data.multiple`)]})]}):null,(0,Z.jsxs)(`label`,{className:`flex items-center gap-3 text-[0.875rem]`,children:[(0,Z.jsx)(O,{checked:o.required,onChange:e=>m({required:e})}),U(`data.required`)]}),c?(0,Z.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:c}):null,(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t&&n.length>1?(0,Z.jsx)(g,{variant:`ghost`,className:`text-rose`,disabled:d,onClick:()=>confirm(U(`data.confirmDelete`,{title:t.name}))&&void h(n.filter(e=>e.id!==t.id)),children:U(`data.deleteColumn`)}):null,(0,Z.jsx)(`span`,{className:`flex-1`}),(0,Z.jsx)(g,{variant:`ghost`,onClick:i,children:U(`common.cancel`)}),(0,Z.jsx)(g,{type:`submit`,busy:d,disabled:!o.name.trim(),children:U(`settings.save`)})]})]})})}function On({id:e,by:t,children:n}){let r=De(e);return(0,Z.jsx)(`tr`,{"data-row":e,title:t?He(t):void 0,className:P(`group border-border-soft border-b last:border-b-0`,r),style:t?{boxShadow:`inset 3px 0 0 ${Te(t.who)}`}:void 0,children:n})}function kn({tableId:e,onGone:t}){let n=I(),r=S.table(e),i=z({queryKey:r,queryFn:()=>c.get(`/api/studio/tables/${e}`)}),[a,o]=(0,Q.useState)(null),[s,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(``);(0,Q.useEffect)(()=>p(i.data?.title??``),[i.data?.title]);let m=Y().data?.user.id,[h,v]=(0,Q.useState)(null);Ie(`table`,e,{state:h?`editing`:`viewing`,place:h?`row:${h}`:null,placeLabel:h?U(`data.rowN`,{n:(i.data?.rows.findIndex(e=>e.id===h)??0)+1}):null});let y=je(`table`,e,m),b=new Map(y.filter(e=>e.state===`editing`&&e.place?.startsWith(`row:`)).map(e=>[e.place?.slice(4)??``,e])),x=async()=>{await n.invalidateQueries({queryKey:S.spaceData(i.data?.projectId)}),await n.invalidateQueries({queryKey:S.knowledge(i.data?.projectId)})},C=e=>n.setQueryData(r,t=>t&&{...t,rows:e(t.rows)}),w=e=>{l(e.message),i.refetch()},T=async t=>{await c.patch(`/api/studio/tables/${e}`,t),await i.refetch(),await x()},E=J({mutationFn:({row:t,column:n,value:r})=>c.patch(`/api/studio/tables/${e}/rows/${t}`,{cells:{[n]:r}}),onSuccess:(e,{row:t,column:n})=>{l(null),d(e=>e===`${t}:${n}`?null:e),C(t=>t.map(t=>t.id===e.id?{...t,cells:e.cells,updatedAt:e.updatedAt??t.updatedAt}:t))},onError:(e,{row:t,column:n})=>{if(e instanceof te&&e.body?.column===n){let e=i.data?.columns.find(e=>e.id===n)?.name??n;d(`${t}:${n}`),l(U(`data.badCell`,{column:e}));return}w(e)}}),D=J({mutationFn:()=>c.post(`/api/studio/tables/${e}/rows`,{}),onSuccess:async e=>{C(t=>[...t,{...e,updatedAt:new Date().toISOString()}]),await x()},onError:w}),O=J({mutationFn:t=>c.post(`/api/studio/tables/${e}/rows/delete`,{ids:[t]}),onSuccess:async(e,t)=>{C(e=>e.filter(e=>e.id!==t)),await x()},onError:w}),k=J({mutationFn:()=>c.del(`/api/studio/tables/${e}`),onSuccess:async()=>{await x(),t()}});if(!i.data)return i.isError?(0,Z.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:i.error.message}):null;let{columns:j,rows:N,readOnly:P}=i.data,F=!!i.data.list;return(0,Z.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(ze,{kind:`table`,item:e}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,Z.jsx)(`input`,{value:f,disabled:P,maxLength:120,onChange:e=>p(e.target.value),onBlur:()=>f.trim()&&f!==i.data?.title&&void T({title:f}).catch(w),onKeyDown:e=>e.key===`Enter`&&e.target.blur(),"aria-label":U(`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`}),(0,Z.jsx)(Me,{kind:`table`,item:e,me:m}),P?null:(0,Z.jsx)(_,{label:U(`data.deleteTable`),onClick:()=>confirm(U(`data.confirmDelete`,{title:i.data.title}))&&k.mutate(),className:`hover:text-rose`,children:(0,Z.jsx)(M,{className:`size-4`})})]}),F?(0,Z.jsx)(`p`,{className:`-mt-1.5 px-1 text-[0.8125rem] text-ink-3`,children:U(`data.fromList`)}):null,i.data.knowledge?(0,Z.jsx)(en,{projectId:i.data.projectId,itemKey:`t:${i.data.id}`,has:i.data.knowledge.categories,originLabel:i.data.knowledge.originLabel,kept:i.data.knowledge.kept,review:i.data.knowledge.review,file:i.data.knowledge.file,readOnly:P,onReviewed:()=>void c.patch(`/api/studio/tables/${e}`,{review:null}).then(()=>i.refetch()).catch(w)}):null,(0,Z.jsxs)(K,{className:`overflow-hidden`,children:[(0,Z.jsx)(`div`,{className:`overflow-x-auto`,children:(0,Z.jsxs)(`table`,{className:`w-full border-collapse text-left`,onFocus:e=>v(e.target.closest(`tr[data-row]`)?.getAttribute(`data-row`)??null),onBlur:()=>v(null),children:[(0,Z.jsx)(`thead`,{children:(0,Z.jsxs)(`tr`,{className:`border-border-soft border-b`,children:[j.map(e=>(0,Z.jsx)(`th`,{className:`min-w-36 border-border-soft border-l p-1 font-medium first:border-l-0`,children:(0,Z.jsxs)(`button`,{type:`button`,disabled:P||F,onClick:()=>o(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,Z.jsx)(`span`,{className:`truncate`,children:e.name}),e.required?(0,Z.jsx)(`span`,{className:`text-ember`,children:`*`}):null,wn(e)?(0,Z.jsx)(`span`,{className:`font-normal text-ink-4`,children:wn(e)}):null]})},e.id)),(0,Z.jsx)(`th`,{className:`w-10 p-1`,children:P||F?null:(0,Z.jsx)(_,{label:U(`data.newColumn`),onClick:()=>o(`new`),className:`size-8`,children:(0,Z.jsx)(A,{className:`size-4`})})})]})}),(0,Z.jsx)(`tbody`,{children:N.map(e=>(0,Z.jsxs)(On,{id:e.id,by:b.get(e.id),children:[j.map(t=>(0,Z.jsx)(`td`,{className:`border-border-soft border-l p-1 align-top first:border-l-0`,children:(0,Z.jsx)(Cn,{column:t,value:e.cells[t.id],readOnly:P,invalid:u===`${e.id}:${t.id}`,onSave:n=>E.mutate({row:e.id,column:t.id,value:n})})},t.id)),(0,Z.jsx)(`td`,{className:`w-10 p-1 align-top`,children:P?null:(0,Z.jsx)(_,{label:U(`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,Z.jsx)(M,{className:`size-3.5`})})})]},e.id))})]})}),N.length?null:(0,Z.jsx)(`p`,{className:`px-4 py-6 text-center text-[0.875rem] text-ink-3`,children:U(`data.noRows`)}),P?null:(0,Z.jsx)(`div`,{className:`border-border-soft border-t p-1.5`,children:(0,Z.jsxs)(g,{variant:`ghost`,size:`sm`,busy:D.isPending,onClick:()=>D.mutate(),children:[(0,Z.jsx)(A,{className:`size-4`}),` `,U(`data.addRow`)]})})]}),s?(0,Z.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:s}):null,(0,Z.jsx)(Dn,{open:a!==null,column:a===`new`?null:a,columns:j,onClose:()=>o(null),onSave:e=>T({columns:e})})]})}var An=`wizards.runDrawer.width`,jn=`wizards.runDrawer.wide`,Mn=680,Nn=400,Pn=()=>Math.max(Nn,window.innerWidth-120);function Fn(e){try{return localStorage.getItem(e)}catch{return null}}function In(e,t){try{localStorage.setItem(e,t)}catch{}}function Ln(){let[e,t]=(0,Q.useState)(()=>{let e=Number(Fn(An));return e?Math.min(Math.max(e,Nn),Pn()):Mn}),[n,r]=(0,Q.useState)(()=>Fn(jn)===`1`),i=(0,Q.useCallback)(e=>{let n=Math.round(Math.min(Math.max(e,Nn),Pn()));t(n),In(An,String(n))},[]);return{width:e,wide:n,toggleWide:()=>{r(!n),In(jn,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(Mn)}}function Rn({look:e,onChange:t,ways:n=[`steps`,`chat`]}){let r=[{id:`steps`,label:U(`chat.steps`),Icon:Qe},{id:`chat`,label:U(`chat.chat`),Icon:et}].filter(e=>n.includes(e.id));return(0,Z.jsx)(`fieldset`,{"aria-label":U(`chat.view`),className:`m-0 flex min-w-0 rounded-full border-0 bg-paper-2 p-0.5`,children:r.map(({id:n,label:r,Icon:i})=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":e===n,title:r,onClick:()=>t(n),className:P(`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,Z.jsx)(i,{className:`size-3.5`}),(0,Z.jsx)(`span`,{className:P(e!==n&&`sr-only`),children:r})]},n))})}function zn({header:e,actions:t,onClose:n,children:r}){let i=Ln();return(0,Z.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,Z.jsxs)(`div`,{className:P(`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,Z.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":U(`editor.resize`),"aria-valuenow":i.width,tabIndex:0,title:U(`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,Z.jsx)(`span`,{className:`-translate-x-1/2 -translate-y-1/2 absolute top-1/2 left-1/2 h-8 w-1 rounded-full bg-ink-4/20 transition group-hover:bg-ember/60 group-focus-visible:bg-ember group-active:h-12 group-active:bg-ember`})}),(0,Z.jsxs)(`div`,{className:`kb-hide flex h-14 shrink-0 items-center gap-3 px-4`,children:[(0,Z.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:e}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[t,(0,Z.jsx)(_,{label:U(i.wide?`runDrawer.shrink`:`runDrawer.expand`),onClick:i.toggleWide,className:`max-sm:hidden`,children:i.wide?(0,Z.jsx)(nt,{className:`size-4`}):(0,Z.jsx)(s,{className:`size-4`})}),(0,Z.jsx)(_,{label:U(`editor.close`),onClick:n,children:(0,Z.jsx)(j,{className:`size-5`})})]})]}),(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:r})]})})}function Bn(e,t){return t.deliverables.map(t=>{let n=y(t.from),r=n?e.lists?.find(e=>e.id===n)?.title:e.steps.find(e=>e.id===t.from)?.title;return{from:t.from,label:t.label??r??t.from,formats:t.formats}})}function Vn({wizardId:e,def:t,step:n,revision:r,audience:i,onAudience:a,lead:o,under:s,end:l,onTest:u,testBusy:d,testDisabled:f}){let p=z({queryKey:[`share-preview`,e,n.id,r,i,R],queryFn:()=>c.get(`/api/studio/wizards/${e}/share-preview?step=${encodeURIComponent(n.id)}&as=${i}&lang=${R}`),placeholderData:se}),[m,h]=(0,Q.useState)(!0),[_,v]=(0,Q.useState)(null),y=p.data,b=y?.targets.find(e=>e.key===_),x=Bn(t,n),S=y?.run?new Intl.DateTimeFormat(R,{dateStyle:`short`,timeStyle:`short`}).format(new Date(y.run.at)):null;return(0,Z.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,Z.jsxs)(`div`,{className:`flex h-12 shrink-0 items-center gap-2 border-ember border-b-2 px-3`,children:[o,(0,Z.jsx)(`span`,{className:`flex-1`}),(0,Z.jsx)(`fieldset`,{"aria-label":U(`resultPreview.seenBy`),className:`m-0 flex rounded-full border-0 bg-paper-2 p-0.5`,children:[`visitor`,`owner`].map(e=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":i===e,onClick:()=>a(e),className:P(`inline-flex h-7 items-center gap-1.5 whitespace-nowrap rounded-full px-2.5 font-medium text-[0.8125rem] transition coarse:h-9`,i===e?`bg-card text-ink shadow-soft`:`text-ink-3 hover:text-ink`),children:[e===`visitor`?(0,Z.jsx)(Ue,{className:`size-3.5`}):(0,Z.jsx)(pt,{className:`size-3.5`}),(0,Z.jsx)(`span`,{className:`max-sm:sr-only`,children:U(e===`visitor`?`resultPreview.visitor`:`resultPreview.you`)})]},e))}),(0,Z.jsxs)(g,{size:`sm`,variant:`secondary`,busy:d,disabled:f,onClick:u,children:[(0,Z.jsx)(X,{className:`size-3.5`}),U(`editor.test`)]}),l]}),s,(0,Z.jsx)(`div`,{className:`@container min-h-0 flex-1 overflow-y-auto`,children:(0,Z.jsxs)(`div`,{className:`mx-auto max-w-2xl px-4 py-5 sm:px-6`,children:[(0,Z.jsxs)(`p`,{className:`mb-5 flex items-center gap-2 text-[0.75rem] text-ink-3`,children:[p.isFetching?(0,Z.jsx)(D,{className:`size-3.5 shrink-0`}):(0,Z.jsx)(Ee,{className:`size-3.5 shrink-0`}),S?U(`resultPreview.from`,{time:S}):U(`resultPreview.none`)]}),(0,Z.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-x-4 gap-y-4`,children:[(0,Z.jsx)(Se,{kind:t.avatar,costume:t.costume,size:56,interactive:!1}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 basis-[12rem]`,children:[(0,Z.jsx)(`h2`,{className:`text-balance font-display font-semibold text-[1.5rem] leading-tight tracking-tight`,children:n.title}),n.message?(0,Z.jsx)(`p`,{className:`mt-1 text-[0.9375rem] text-ink-3`,children:n.message}):null]}),(0,Z.jsxs)(g,{variant:`secondary`,"aria-expanded":m,onClick:()=>h(!m),className:P(m&&`ring-2 ring-ember`),children:[(0,Z.jsx)(ee,{className:`size-4`}),` `,U(`shareRun.button`)]})]}),m?(0,Z.jsx)(K,{className:`mb-6 p-4 shadow-elevated sm:p-5`,children:b?(0,Z.jsx)(Un,{target:b,deliverables:x,hasRun:!!y?.run,onBack:()=>v(null)},`${b.key}:${JSON.stringify(b.fields.map(e=>e.value))}`):(0,Z.jsx)(Hn,{data:y,onPick:v})}):null,(0,Z.jsx)(`div`,{className:`flex flex-col gap-6`,children:x.map(e=>{let t=y?.outputs[e.from];return(0,Z.jsxs)(K,{className:`p-4 sm:p-5`,children:[(0,Z.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-3`,children:[(0,Z.jsx)(`h3`,{className:`font-display font-semibold text-[1.0625rem]`,children:e.label}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.formats.map(e=>(0,Z.jsx)(`span`,{className:`inline-flex h-7 items-center rounded-full bg-paper-2 px-3 font-medium text-[0.75rem] text-ink-2`,children:N[e]},e))})]}),t?(0,Z.jsx)(`div`,{className:`max-h-72 overflow-hidden [mask-image:linear-gradient(to_bottom,black_70%,transparent)]`,children:(0,Z.jsx)(B,{text:t})}):(0,Z.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:U(`resultPreview.notMade`)})]},e.from)})})]})})]})}function Hn({data:e,onPick:t}){let n=ne(),r=e?.left.filter(e=>e.why===`agent`)??[],i=e?.left.filter(e=>e.why===`setup`)??[];return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Z.jsx)(`h3`,{className:`font-medium text-[1.0625rem]`,children:U(`shareRun.title`)}),(0,Z.jsxs)(`div`,{className:`grid gap-2.5 @lg:grid-cols-2`,children:[(0,Z.jsx)(Le,{icon:h,name:U(`share.link`),description:U(`shareRun.linkHint`)}),(e?.targets??[]).map(e=>(0,Z.jsx)(Le,{icon:Re[e.icon],name:e.name,description:e.description,onClick:()=>t(e.key)},e.key))]}),r.length?(0,Z.jsxs)(`p`,{className:`flex items-start gap-2 rounded-lg bg-paper-2 px-3 py-2.5 text-[0.8125rem] text-ink-2 leading-relaxed`,children:[(0,Z.jsx)(de,{className:`mt-0.5 size-4 shrink-0 text-ink-3`}),U(`resultPreview.agentLeft`,{names:Dt(r.map(e=>e.name))})]}):null,i.length?(0,Z.jsxs)(`p`,{className:`flex flex-wrap items-start gap-x-2 gap-y-1 rounded-lg bg-amber-tint px-3 py-2.5 text-[0.8125rem] text-ink-2 leading-relaxed`,children:[(0,Z.jsx)(ie,{className:`mt-0.5 size-4 shrink-0 text-amber`}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1`,children:U(`resultPreview.setupLeft`,{names:Dt(i.map(e=>e.name))})}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>n(`/settings/connectors`),className:`font-medium text-ember-strong hover:underline`,children:U(`shareEditor.setUp`)})]}):null]})}function Un({target:e,deliverables:t,hasRun:n,onBack:r}){let[i,a]=(0,Q.useState)(()=>Object.fromEntries(e.fields.map(e=>[e.id,e.value??``]))),[o,s]=(0,Q.useState)(()=>Object.fromEntries(t.map(e=>[e.from,e.formats[0]]))),c=[...e.connection?[U(`shareRun.stepAccount`)]:[],U(`shareRun.stepForm`),U(`shareRun.stepSend`)];return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Z.jsx)(_,{label:U(`run.back`),onClick:r,className:`-ml-2`,children:(0,Z.jsx)(V,{className:`size-4`})}),(0,Z.jsx)(`h3`,{className:`min-w-0 flex-1 truncate font-medium text-[1.0625rem]`,children:e.name})]}),(0,Z.jsx)(`div`,{className:`-mb-6`,children:(0,Z.jsx)(Pe,{steps:c,now:+!!e.connection})}),e.connection?.account?(0,Z.jsx)(`p`,{className:`rounded-lg bg-paper-2 px-3 py-2 text-[0.8125rem] text-ink-2`,children:U(`shareRun.as`,{account:e.connection.account.label})}):null,e.agent?(0,Z.jsxs)(`p`,{className:`flex items-start gap-2.5 rounded-lg bg-ember-tint px-3 py-2.5 text-[0.8125rem] text-ink-2 leading-relaxed`,children:[(0,Z.jsx)(pe,{className:`mt-0.5 size-4 shrink-0 text-ember-strong`}),` `,U(`shareRun.agentHint`)]}):null,e.fields.map(e=>(0,Z.jsx)(Ve,{field:e,value:i[e.id]??``,choices:[],onChange:t=>a(n=>({...n,[e.id]:t}))},e.id)),n&&e.empty.length?(0,Z.jsxs)(`p`,{className:`flex items-start gap-2 rounded-lg bg-amber-tint px-3 py-2.5 text-[0.8125rem] text-ink-2`,children:[(0,Z.jsx)(ie,{className:`mt-0.5 size-4 shrink-0 text-amber`}),U(`resultPreview.empty`,{names:e.empty.map(e=>`{{${e}}}`).join(`, `)})]}):null,e.takes===`files`&&t.length?(0,Z.jsx)(Fe,{deliverables:t,picked:o,onPick:(e,t)=>s(n=>({...n,[e]:t}))}):null,(0,Z.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:U(`resultPreview.nothingSent`)})]})}function Wn({label:e,value:t,onChange:n,options:r,named:i}){return(0,Z.jsx)(`fieldset`,{"aria-label":e,className:`m-0 flex shrink-0 rounded-full border-0 bg-paper-2 p-0.5`,children:r.map(e=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":t===e.id,title:e.label,onClick:()=>n(e.id),className:P(`inline-flex h-7 items-center gap-1.5 whitespace-nowrap rounded-full px-2.5 font-medium text-[0.75rem] transition coarse:h-9`,t===e.id?`bg-card text-ink shadow-soft`:`text-ink-3 hover:text-ink`),children:[e.icon,(0,Z.jsx)(`span`,{className:P(!!e.icon&&!(i&&t===e.id)&&`sr-only`,i&&`@min-[26rem]:not-sr-only`),children:e.label})]},e.id))})}function Gn({label:e,value:t,onChange:n,options:r}){return(0,Z.jsxs)(`label`,{className:`relative flex shrink-0 items-center`,children:[(0,Z.jsx)(`span`,{className:`sr-only`,children:e}),(0,Z.jsx)(`select`,{value:t,onChange:e=>n(e.target.value),title:e,className:P(`h-8 appearance-none truncate rounded-full border-0 bg-paper-2 py-0 pr-7 pl-3 font-medium text-[0.75rem] text-ink outline-none focus-visible:ring-2 focus-visible:ring-ember coarse:h-10 max-w-40`),children:r.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,Z.jsx)(`svg`,{"aria-hidden":`true`,className:`pointer-events-none absolute right-2.5 size-3 text-ink-3`,viewBox:`0 0 16 16`,fill:`none`,children:(0,Z.jsx)(`path`,{d:`M4 6l4 4 4-4`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`})})]})}function Kn(e){return e.name??U(e.id==="default"?`inspector.lookThemeDefault`:`inspector.lookThemeBrand`)}function qn({wizard:e,runId:t,runView:n,onView:r,stepId:i,audience:o,onAudience:s,test:l,column:u,onColumn:d,onClose:f,building:m,log:h,strip:v,lead:y,onShowRun:b,onEdit:x}){let C=e.draft,w=z({queryKey:[`wizard-looks`,e.id,e.revision],queryFn:()=>c.get(`/api/studio/wizards/${e.id}/looks`),placeholderData:se}).data?.looks,[E,D]=(0,Q.useState)(null),O=w?.find(e=>e.id===E)??w?.[0]??null,A=O?.theme??n?.brand.theme??null,[M,N]=(0,Q.useState)(null),ee=A?.prefer??(A?.dark?`dark`:`light`),I=M??ee,te=ve(A,M),L=e.runners??We,B=[`steps`,`chat`].filter(e=>L.enabled.includes(e)||L.default===e),V=L.default===`chat`&&B.includes(`chat`)?`chat`:`steps`,[H,ne]=(0,Q.useState)(null),ie=H??V,W=T(C),ae=z({queryKey:S.translations(e.id),queryFn:()=>c.get(`/api/studio/wizards/${e.id}/translations`),enabled:e.published&&e.translate}),oe=[W,...e.translate?(ae.data?.translations??[]).map(e=>e.lang):[]].filter((e,t,n)=>n.indexOf(e)===t),[G,le]=(0,Q.useState)(W),ue=(0,Q.useRef)({run:null,lang:W});(0,Q.useEffect)(()=>{if(!t)return;let e=ue.current;ue.current={run:t,lang:G},!(e.run===t?e.lang===G:G===W)&&c.post(`/api/runs/${t}/lang`,{lang:G===W?null:G}).catch(()=>void 0)},[t,G,W]),(0,Q.useEffect)(()=>(G!==W&&p(G)&&F(G),()=>F(R)),[G,W]);let[K,de]=(0,Q.useState)(`desk`),q=i?C.steps.find(e=>e.id===i)??null:null,fe=z({queryKey:[`draft-step-view`,e.id,q?.id,e.revision,G],queryFn:()=>c.get(`/api/studio/wizards/${e.id}/steps/${encodeURIComponent(q?.id??``)}/view${G===W?``:`?lang=${encodeURIComponent(G)}`}`),enabled:!!(q&&q.type!==`result`),placeholderData:(e,t)=>t?.queryKey[2]===q?.id?e:void 0}),J=async()=>!1,pe=q&&fe.data?{view:fe.data,notFound:!1,error:null,busy:!1,fieldErrors:{},submitPage:J,accept:J,regenerate:J,back:J,retry:J}:null,Y=q?.type===`result`?q:null,Ce=u===null?null:(0,Z.jsx)(_,{label:U(u?`editor.columnHide`:`editor.columnShow`),onClick:()=>d(!u),children:u?(0,Z.jsx)(it,{className:`size-4`}):(0,Z.jsx)(ot,{className:`size-4`})});return(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[Y?(0,Z.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,Z.jsx)(Vn,{wizardId:e.id,def:C,step:Y,revision:e.revision,audience:o,onAudience:s,lead:y,under:v,end:Ce,onTest:l.start,testBusy:l.busy,testDisabled:l.disabled})}):null,(0,Z.jsxs)(`div`,{className:P(`flex min-h-0 flex-1 flex-col`,Y&&`hidden`),children:[(0,Z.jsxs)(`div`,{className:`kb-hide flex h-12 shrink-0 items-center gap-1.5 overflow-x-auto border-border-soft border-b px-3 [scrollbar-width:none]`,children:[y,B.length>1&&!q?(0,Z.jsx)(`span`,{className:`shrink-0`,children:(0,Z.jsx)(Rn,{look:ie,onChange:ne,ways:[...B]})}):null,b?(0,Z.jsxs)(`button`,{type:`button`,onClick:b,className:`inline-flex h-8 shrink-0 items-center gap-1.5 rounded-full bg-paper-2 px-3 font-medium text-[0.75rem] text-ink-2 transition hover:text-ink`,children:[(0,Z.jsx)(X,{className:`size-3.5`}),U(`run.testChip`)]}):null,(0,Z.jsx)(`span`,{className:`flex-1`}),x?(0,Z.jsxs)(g,{variant:`secondary`,size:`sm`,onClick:x,children:[(0,Z.jsx)(ce,{className:`size-3.5`}),U(`editor.edit`)]}):null,w&&w.length>1&&O?(0,Z.jsx)(Gn,{label:U(`editor.previewTheme`),value:O.id,onChange:D,options:w.map(e=>({value:e.id,label:Kn(e)}))}):null,ye(A)?(0,Z.jsx)(Wn,{label:U(`editor.previewMode`),value:I,onChange:N,options:[{id:`light`,label:U(`theme.light`),icon:(0,Z.jsx)(xe,{className:`size-3.5`})},{id:`dark`,label:U(`theme.dark`),icon:(0,Z.jsx)(be,{className:`size-3.5`})}]}):null,oe.length>1?(0,Z.jsx)(Gn,{label:U(`editor.previewLang`),value:G,onChange:le,options:oe.map(e=>({value:e,label:a(e)}))}):null,(0,Z.jsx)(`span`,{className:`max-sm:hidden`,children:(0,Z.jsx)(Wn,{label:U(`editor.device`),value:K,onChange:de,options:[{id:`desk`,label:U(`editor.deviceDesk`),icon:(0,Z.jsx)(ke,{className:`size-3.5`})},{id:`phone`,label:U(`editor.devicePhone`),icon:(0,Z.jsx)(me,{className:`size-3.5`})}]})}),t?(0,Z.jsx)(_,{label:U(`editor.restart`),disabled:l.disabled||l.busy,onClick:l.start,children:(0,Z.jsx)(k,{className:`size-4`})}):(0,Z.jsxs)(g,{size:`sm`,variant:`secondary`,busy:l.busy,disabled:l.disabled,onClick:l.start,children:[(0,Z.jsx)(X,{className:`size-3.5`}),U(`editor.test`)]}),Ce,t?(0,Z.jsx)(_,{label:U(`editor.close`),onClick:f,children:(0,Z.jsx)(j,{className:`size-4`})}):null]}),v,(0,Z.jsx)(`div`,{className:P(`relative flex min-h-0 flex-1 justify-center`,K===`phone`&&`bg-paper-2 py-4`),children:(0,Z.jsxs)(`div`,{className:P(`relative min-h-0 w-full`,te?.className,K===`phone`&&`max-w-[390px] overflow-hidden rounded-[2rem] shadow-elevated ring-8 ring-paper-3`),style:te?.style,children:[(0,Z.jsx)(he,{effects:A?.effects,contained:!0}),(0,Z.jsx)(`div`,{className:`absolute inset-0 overflow-y-auto bg-background`,children:m?(0,Z.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-[0.875rem] text-ink-3`,children:m}):q||t?(0,Z.jsxs)(Z.Fragment,{children:[q&&pe?(0,Z.jsx)(re,{run:pe,compact:!0,studio:!0},q.id):null,t?(0,Z.jsx)(`div`,{className:P(q&&`hidden`),children:ie===`chat`?(0,Z.jsx)(_e,{runId:t,onRestart:l.start,onView:r},t):(0,Z.jsx)(ge,{runId:t,compact:!0,studio:!0,onRestart:l.start,onView:r},t)}):null]}):(0,Z.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-4 px-6 text-center`,children:[(0,Z.jsx)(Se,{kind:C.avatar,costume:C.costume,size:160,fluffy:!0}),(0,Z.jsx)(`h2`,{className:`text-balance font-display font-semibold text-[1.5rem] tracking-tight`,children:C.title}),C.description?(0,Z.jsx)(`p`,{className:`max-w-md text-balance text-[0.9375rem] text-ink-2`,children:C.description}):null,(0,Z.jsxs)(g,{busy:l.busy,disabled:l.disabled,onClick:l.start,children:[(0,Z.jsx)(X,{className:`size-4`}),U(`editor.test`)]}),(0,Z.jsx)(`p`,{className:`max-w-sm text-balance text-[0.8125rem] text-ink-3`,children:U(`editor.previewEmpty`)})]})})]})}),t&&!q?h:null]})]})}export{vt as A,ht as C,Dt as D,Tt as E,Xe as F,Ke as I,mt as M,dt as N,Et as O,X as P,At as S,yt as T,Xt as _,hn as a,Ot as b,pn as c,$t as d,en as f,Jt as g,zt as h,kn as i,St as j,Ct as k,dn as l,Zt as m,qn as n,_n as o,ln as p,zn as r,mn as s,Wn as t,nn as u,Yt as v,wt as w,kt as x,jt as y};