wizards 0.2.61 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/apps/runtime/dist/app.js +122 -83
  2. package/apps/runtime/dist/engine/runner.js +1 -1
  3. package/apps/runtime/dist/env.js +23 -6
  4. package/apps/runtime/dist/index.js +3 -3
  5. package/apps/runtime/dist/link-preview.js +3 -3
  6. package/apps/runtime/dist/mcp/flow-app.js +5 -2
  7. package/apps/runtime/dist/plugins/public.js +1 -1
  8. package/apps/runtime/dist/routes/api.js +1 -1
  9. package/apps/runtime/dist/routes/runs.js +5 -2
  10. package/apps/runtime/dist/services/api.js +2 -2
  11. package/apps/runtime/dist/services/runners.js +1 -1
  12. package/apps/runtime/dist/services/shares.js +2 -2
  13. package/apps/runtime/dist/services/wizards.js +1 -1
  14. package/apps/web/dist/assets/{AboutDialog-OEVFZuMQ.js → AboutDialog-rEV1tY7v.js} +1 -1
  15. package/apps/web/dist/assets/{ChangelogDialog-6xNrjOIm.js → ChangelogDialog-no0Qp8Xx.js} +1 -1
  16. package/apps/web/dist/assets/ChatView--IperikB.js +10 -0
  17. package/apps/web/dist/assets/EditorPage-ogKP-1WD.js +3 -0
  18. package/apps/web/dist/assets/{FlowPreview-COK6Z3jV.js → FlowPreview-BFfYNi_w.js} +1 -1
  19. package/apps/web/dist/assets/{Harness-DrnkZ8kf.js → Harness-WF0mxIv3.js} +2 -2
  20. package/apps/web/dist/assets/{Marketplace-CmeAQDOY.js → Marketplace-CuE6WgnO.js} +2 -2
  21. package/apps/web/dist/assets/{NewWizardPage-BBaIaspG.js → NewWizardPage-DVG3ABgm.js} +1 -1
  22. package/apps/web/dist/assets/ProjectPage-CkPTmzYS.js +2 -0
  23. package/apps/web/dist/assets/PublicRunner-DRH7BXnH.js +1 -0
  24. package/apps/web/dist/assets/{ReadOnly-B--cynCf.js → ReadOnly-Bxbgr2n2.js} +1 -1
  25. package/apps/web/dist/assets/RunDrawer-D46YTsXi.js +4 -0
  26. package/apps/web/dist/assets/{RunnerView-Dzz0vC_M.js → RunnerView-EpmDp2lS.js} +1 -1
  27. package/apps/web/dist/assets/SettingsPage-CIimi5gU.js +1 -0
  28. package/apps/web/dist/assets/SetupPage-K4aU8yPc.js +1 -0
  29. package/apps/web/dist/assets/SharePage-A97exWhO.js +1 -0
  30. package/apps/web/dist/assets/{brand-ClxXyg-d.js → brand-cgisQRwA.js} +1 -1
  31. package/apps/web/dist/assets/changelog-DO6Z2SDc.js +1 -0
  32. package/apps/web/dist/assets/{circle-alert-CyjKeZm5.js → circle-alert-R2GwpaDI.js} +1 -1
  33. package/apps/web/dist/assets/{esm-C0TPPvNu.js → esm-C_f_4oeZ.js} +1 -1
  34. package/apps/web/dist/assets/index-DIF70pQf.js +11 -0
  35. package/apps/web/dist/assets/{lock-D5tH2Lqc.js → lock-BqMtfg3I.js} +1 -1
  36. package/apps/web/dist/assets/{session-DEXxyxEc.js → session-Dej-L4l9.js} +1 -1
  37. package/apps/web/dist/assets/{settings-menu-vtL00p0G.js → settings-menu-mxakooyx.js} +1 -1
  38. package/apps/web/dist/assets/{ui-SKtUMhUq.js → ui-aWLrX8hF.js} +2 -2
  39. package/apps/web/dist/assets/{upload-hT54Sh8P.js → upload-CNYeHI5s.js} +1 -1
  40. package/apps/web/dist/assets/{volume-2-BX_wS3Lh.js → volume-2-B7cfghgd.js} +1 -1
  41. package/apps/web/dist/index.html +6 -6
  42. package/package.json +1 -1
  43. package/apps/web/dist/assets/ChatView-3ESCXBad.js +0 -10
  44. package/apps/web/dist/assets/EditorPage-DEWSbQzj.js +0 -3
  45. package/apps/web/dist/assets/ProjectPage-7WwZ4ier.js +0 -2
  46. package/apps/web/dist/assets/PublicRunner-DL3Zdyyp.js +0 -1
  47. package/apps/web/dist/assets/RunDrawer-DhKe5qPM.js +0 -4
  48. package/apps/web/dist/assets/SettingsPage-CaTwyuf_.js +0 -1
  49. package/apps/web/dist/assets/SetupPage-BqW4ZghT.js +0 -1
  50. package/apps/web/dist/assets/SharePage-CYtDkLLD.js +0 -1
  51. package/apps/web/dist/assets/changelog-CUTIPZpA.js +0 -1
  52. package/apps/web/dist/assets/index-CsKV2ZNO.js +0 -11
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FlowPreview-COK6Z3jV.js","assets/rolldown-runtime-hePW80VL.js","assets/jsx-runtime-BNakU3Ej.js","assets/ui-SKtUMhUq.js","assets/preload-helper-CNEI7N0N.js","assets/esm-C0TPPvNu.js","assets/index-CsKV2ZNO.js","assets/logo-C4V2_3Ar.js","assets/engenty-eXZ-EAwd.js","assets/useMutation-DKyQXgyj.js","assets/brand-ClxXyg-d.js","assets/volume-2-BX_wS3Lh.js","assets/session-DEXxyxEc.js","assets/index-BBpolc_L.css"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{O as r,a as i,c as a,i as o,r as s,s as c,v as l}from"./logo-C4V2_3Ar.js";import{t as u}from"./useMutation-DKyQXgyj.js";import{t as d}from"./preload-helper-CNEI7N0N.js";import{$t as f,Ct as p,Et as m,It as h,Jt as g,Qt as _,Rt as ee,Tt as v,Ut as y,Zt as te,a as b,at as x,fn as ne,in as S,it as C,mt as w,ot as T,rt as E,xt as D,yt as O,zt as re}from"./ui-SKtUMhUq.js";import{l as k,r as ie}from"./brand-ClxXyg-d.js";import{t as ae}from"./volume-2-BX_wS3Lh.js";import{l as oe,u as se}from"./engenty-eXZ-EAwd.js";var ce=class extends i{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type=`infinite`,super.setOptions(e)}getOptimisticResult(e){return e._type=`infinite`,super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:o,isError:s,isRefetchError:l}=r,u=n.fetchMeta?.fetchMore?.direction,d=s&&u===`forward`,f=i&&u===`forward`,p=s&&u===`backward`,m=i&&u===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:c(t,n.data),hasPreviousPage:a(t,n.data),isFetchNextPageError:d,isFetchingNextPage:f,isFetchPreviousPageError:p,isFetchingPreviousPage:m,isRefetchError:l&&!d&&!p,isRefetching:o&&!f&&!m}}};function le(e,t){return o(e,ce,t)}var ue={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`}]]};ue.node;var A=S(ue),de={name:`bot`,size:24,node:[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]};de.node;var j=S(de),fe={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`]};fe.node;var pe=S(fe),me={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`}]]};me.node;var he=S(me),ge={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`}]]};ge.node;var _e=S(ge),ve={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`}]]};ve.node;var M=S(ve),N={name:`cloud-off`,size:24,node:[[`path`,{d:`M10.94 5.274A7 7 0 0 1 15.71 10h1.79a4.5 4.5 0 0 1 4.222 6.057`,key:`1uxyv8`}],[`path`,{d:`M18.796 18.81A4.5 4.5 0 0 1 17.5 19H9A7 7 0 0 1 5.79 5.78`,key:`99tcn7`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};N.node;var P=S(N),F={name:`coins`,size:24,node:[[`path`,{d:`M13.744 17.736a6 6 0 1 1-7.48-7.48`,key:`bq4yh3`}],[`path`,{d:`M15 6h1v4`,key:`11y1tn`}],[`path`,{d:`m6.134 14.768.866-.5 2 3.464`,key:`17snzx`}],[`circle`,{cx:`16`,cy:`8`,r:`6`,key:`14bfc9`}]]};F.node;var ye=S(F),be={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`}]]};be.node;var I=S(be),xe={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`}]]};xe.node;var Se=S(xe),Ce={name:`globe`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]};Ce.node;var we=S(Ce),Te={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`}]]};Te.node;var L=S(Te),Ee={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`}]]};Ee.node;var De=S(Ee),Oe={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`}]]};Oe.node;var ke=S(Oe),Ae={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`}]]};Ae.node;var R=S(Ae),je={name:`plug`,size:24,node:[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]};je.node;var Me=S(je),z={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`}]]};z.node;var Ne=S(z),Pe={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`}]]};Pe.node;var Fe=S(Pe),Ie={name:`search`,size:24,node:[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]};Ie.node;var Le=S(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 B=S(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=S(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=S(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=S(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 V=S(Ge),H={text:{de:`Text`,en:`Text`},document:{de:`Dokument (PDF, Word)`,en:`Document (PDF, Word)`},table:{de:`Tabelle`,en:`Table`},image:{de:`Bild`,en:`Image`},video:{de:`Video`,en:`Video`},audio:{de:`Audio`,en:`Audio`},dashboard:{de:`Dashboard`,en:`Dashboard`}},Ke={any:{de:`Jede Branche`,en:`Any industry`},trades:{de:`Handwerk`,en:`Trades`},gastronomy:{de:`Gastronomie`,en:`Food service`},hospitality:{de:`Hotel & Tourismus`,en:`Hotels & tourism`},realEstate:{de:`Immobilien`,en:`Real estate`},retail:{de:`Handel`,en:`Retail`},health:{de:`Gesundheit`,en:`Health`},professional:{de:`Kanzlei & Beratung`,en:`Professional services`},agency:{de:`Agentur & Marketing`,en:`Agency & marketing`},events:{de:`Veranstaltungen`,en:`Events`},publicSector:{de:`Vereine & Öffentliches`,en:`Associations & public sector`}},qe={marketing:{de:`Marketing & Social Media`,en:`Marketing & social media`},sales:{de:`Angebote & Verkauf`,en:`Offers & sales`},accounting:{de:`Buchhaltung & Belege`,en:`Accounting & receipts`},service:{de:`Kundenservice`,en:`Customer service`},research:{de:`Recherche & Analyse`,en:`Research & analysis`},hr:{de:`Personal & Bewerbungen`,en:`HR & applications`},operations:{de:`Planung & Abläufe`,en:`Planning & operations`},website:{de:`Helfer für die Website`,en:`Website helpers`},visuals:{de:`Bilder & Video`,en:`Images & video`},inquiries:{de:`Anfragen & Termine`,en:`Inquiries & bookings`},advice:{de:`Beratung & Preise`,en:`Advice & pricing`}},U={text:{de:`Text schreiben`,en:`Writes text`},web:{de:`Websuche`,en:`Web search`},browser:{de:`Browser bedienen`,en:`Drives a browser`},documents:{de:`Dokumente & Fotos lesen`,en:`Reads documents & photos`},image:{de:`Bilder erzeugen`,en:`Makes images`},video:{de:`Videos erzeugen`,en:`Makes video`},speech:{de:`Sprachausgabe`,en:`Speech output`},listening:{de:`Sprachnotizen verstehen`,en:`Understands voice notes`},code:{de:`Code ausführen`,en:`Runs code`},connectors:{de:`Verbundene Konten & Systeme`,en:`Connected accounts & systems`},film:{de:`Filme mit Claude Code (auf deinem Abo)`,en:`Films with Claude Code (on your subscription)`}},Je={low:{de:`günstig`,en:`low cost`},medium:{de:`mittel`,en:`medium cost`},high:{de:`teuer`,en:`high cost`}},Ye={free:{de:`Kostenlos`,en:`Free`},pro:{de:`Pro`,en:`Pro`}},W=e=>Object.keys(e);W(H),W(Ke),W(qe),W(U),W(Ye);var G=e(t(),1);function Xe(e){switch(e.type){case`page`:return R;case`agent`:return j;case`generate`:return e.asset===`image`?L:e.asset===`video`?m:e.asset===`dashboard`?De:y;case`widget`:return A;case`surface`:return ke;case`film`:return M;case`review`:return I;case`result`:return Se}return V}var Ze={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 Qe(e){return p(`type.${e.type}`)}var $e=[`web_search`,`web_fetch`,`browser`,`sandbox`,`image`,`http`,`pages`];function et(e){return $e.includes(e)?p(`tool.${e}`):e}function tt(e){switch(e.type){case`page`:return e.fields.map(e=>e.label).join(` · `);case`agent`:{let t=e.tools.map(et),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?p(`editor.reviewEditable`):null,e.regenerate?p(`editor.reviewRedo`):null].filter(Boolean).join(` · `);case`result`:return e.deliverables.map(e=>`${e.label??e.from} (${e.formats.join(`, `)})`).join(` · `)}return``}var K=e(n(),1),nt=(0,G.lazy)(()=>d(()=>import(`./FlowPreview-COK6Z3jV.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13]))),rt={useCase:``,industry:``,format:``,capability:``,plan:``},q=(e,t)=>e[t]?.[D]??t;function it(e){if(e<1)return 1;let t=10**Math.floor(Math.log10(e));return Math.round(e/t)*t}function at(e){return e.credits?p(`market.credits`,{n:it(e.credits.credits)}):Je[e.costTier][D]}var ot={text:We,document:y,table:Be,image:L,video:m,audio:f,dashboard:pe};function J({format:e,className:t}){let n=ot[e],r=q(H,e);return(0,K.jsx)(`span`,{title:r,className:`inline-flex`,children:(0,K.jsx)(n,{className:t,"aria-label":r,role:`img`})})}var st=[`low`,`medium`,`high`];function Y({entry:e}){let t=st.indexOf(e.costTier)+1,n=D===`de`?_e:he;return(0,K.jsxs)(`span`,{title:at(e),className:`inline-flex items-center gap-1`,children:[(0,K.jsx)(`span`,{"aria-hidden":`true`,className:`inline-flex shrink-0`,children:st.slice(0,t).map((e,t)=>(0,K.jsx)(`span`,{className:O(`rounded-full bg-(--coin-bg,var(--color-card))`,t>0&&`-ml-1.5`),children:(0,K.jsx)(n,{className:`size-4`})},e))}),Je[e.costTier][D]]})}function ct(){return(0,K.jsx)(x,{tone:`ember`,title:p(`market.proHint`),children:p(`market.pro`)})}function lt({plugin:e}){return(0,K.jsx)(x,{icon:(0,K.jsx)(Ne,{className:`size-3.5`}),title:p(`market.fromPlugin`,{name:e.name}),children:e.name})}function ut({entry:e,onOpen:t}){return(0,K.jsxs)(C,{role:`button`,tabIndex:0,onClick:t,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t())},className:O(`relative flex min-h-[124px] cursor-pointer flex-col gap-5 p-4 text-left transition sm:min-h-[136px] sm:p-5 hover:shadow-elevated focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus`,(!e.usable||e.missing.length>0||!!e.needs?.length)&&`opacity-60`),children:[(0,K.jsx)(`span`,{className:`-top-4 pointer-events-none absolute right-4`,children:(0,K.jsx)(ie,{kind:e.avatar,size:68})}),(0,K.jsxs)(`div`,{className:`min-w-0 pr-20`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 font-display font-semibold text-[0.9375rem]`,children:[e.title,e.plan===`pro`?(0,K.jsx)(ct,{}):null,e.starred?(0,K.jsx)(B,{className:`size-3.5 shrink-0 fill-amber text-amber`,"aria-label":p(`market.starred`)}):null]}),(0,K.jsx)(`div`,{className:`mt-0.5 text-[0.8125rem] text-ink-3 leading-snug`,children:e.pitch})]}),(0,K.jsxs)(`div`,{className:`mt-auto flex flex-wrap items-center gap-x-3 gap-y-1.5 text-[0.75rem] text-ink-3`,children:[e.plugin?(0,K.jsx)(lt,{plugin:e.plugin}):null,e.needs?.length?(0,K.jsx)(x,{tone:`warn`,children:p(`market.needsPro`,{list:e.needs.join(`, `)})}):e.usable&&e.missing.length?(0,K.jsx)(x,{tone:`warn`,children:p(`market.missing`,{list:Z(e.missing)})}):e.usable?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,K.jsx)(g,{className:`size-3.5`}),` `,p(`market.minutes`,{n:e.effort.minutes})]}),(0,K.jsx)(Y,{entry:e}),e.optional?.length?(0,K.jsx)(x,{title:p(`market.optionalHint`,{list:Z(e.optional)}),children:p(`market.without`,{list:Z(e.optional)})}):null,(0,K.jsx)(`span`,{className:`ml-auto inline-flex items-center gap-1.5`,children:e.formats.map(e=>(0,K.jsx)(J,{format:e,className:`size-4`},e))})]}):(0,K.jsx)(x,{tone:`warn`,children:p(`market.needsUpdate`)})]})]})}function X({title:e,children:t}){return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`mb-1.5 font-medium text-[0.75rem] text-ink-3 uppercase tracking-[0.06em]`,children:e}),t]})}var Z=e=>e.map(e=>q(U,e)).join(`, `),dt={text:h,web:we,browser:ee,documents:Fe,image:L,video:m,speech:ae,listening:re,code:He,connectors:Me,film:M};function ft(e){switch(e.type){case`page`:return R;case`agent`:return j;case`generate`:return e.asset===`image`?L:e.asset===`video`?m:e.asset===`voice`?ae:e.asset===`dashboard`?pe:y;case`widget`:return e.video?M:A;case`surface`:return A;case`film`:return M;case`review`:return I;case`result`:return Se}return V}function pt(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 mt(e){let t=pt(e);return e.map(e=>({id:e.id,title:e.title,icon:ft(e),tone:Ze[e.type]??`bg-paper-2 text-ink-2`,optional:t.has(e.id),branches:e.branches}))}function Q({title:e,children:t}){return(0,K.jsx)(`span`,{title:e,className:`inline-flex items-center gap-2 border-border border-l px-4 first:border-l-0 first:pl-0`,children:t})}function $({icon:e,children:t,more:n}){return(0,K.jsxs)(`div`,{className:`flex gap-2.5`,children:[(0,K.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:e}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-[0.875rem] text-ink leading-snug`,children:t}),n?(0,K.jsx)(`div`,{className:`text-[0.75rem] text-ink-3 leading-snug`,children:n}):null]})]})}function ht({className:e,children:t}){let n=(0,G.useRef)(null),[r,i]=(0,G.useState)({above:!1,below:!1});(0,G.useEffect)(()=>{let e=n.current;if(!e)return;let t=()=>{let t=e.scrollTop>1,n=e.scrollTop+e.clientHeight<e.scrollHeight-1;i(e=>e.above===t&&e.below===n?e:{above:t,below:n})};t(),e.addEventListener(`scroll`,t,{passive:!0});let r=new ResizeObserver(t);return r.observe(e),e.firstElementChild&&r.observe(e.firstElementChild),()=>{e.removeEventListener(`scroll`,t),r.disconnect()}},[]);let a=`linear-gradient(to bottom, ${r.above?`transparent`:`black`} 0, black 28px, black calc(100% - 44px), ${r.below?`transparent`:`black`} 100%)`;return(0,K.jsx)(`div`,{ref:n,className:e,style:{maskImage:a,WebkitMaskImage:a},children:(0,K.jsx)(`div`,{children:t})})}function gt({id:e,fallback:t,onClose:n,onUse:i,busy:a}){let o=r(),c=ne(),l=s({queryKey:[`marketplace-entry`,e,D],queryFn:()=>b.get(`/api/studio/marketplace/${encodeURIComponent(e)}?lang=${D}`),enabled:!!e,retry:!1}),d=l.data??t,f=u({mutationFn:t=>{let n=`/api/studio/marketplace/${encodeURIComponent(e)}/star`;return t?b.put(n):b.del(n)},onSuccess:()=>Promise.all([o.invalidateQueries({queryKey:[`marketplace`]}),o.invalidateQueries({queryKey:[`marketplace-entry`,e]})])}),m=k()===`dark`,h=oe[se[d?.avatar||`round`]],_=m?`var(--card)`:`color-mix(in oklch, ${h??`var(--ink-4)`} 14%, var(--paper-2))`;return(0,K.jsx)(T,{open:!!e,onClose:n,wide:!0,bare:!0,children:d?(0,K.jsxs)(`div`,{className:`relative flex max-h-[calc(100dvh-48px)] flex-col rounded-2xl bg-card shadow-overlay max-sm:h-dvh max-sm:max-h-none max-sm:rounded-none`,children:[(0,K.jsx)(`button`,{type:`button`,"aria-label":p(`common.close`),onClick:n,className:`sm:-top-3.5 sm:-right-3.5 absolute top-3 right-3 z-20 flex size-9 items-center justify-center rounded-full bg-card text-ink-2 shadow-elevated ring-1 ring-border-soft transition hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus`,children:(0,K.jsx)(v,{className:`size-4`})}),(0,K.jsxs)(`header`,{className:`relative shrink-0 border-border-soft border-b px-5 pt-5 pb-4 text-ink sm:rounded-t-2xl sm:px-7`,style:{background:_,"--coin-bg":_},children:[(0,K.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 overflow-hidden sm:rounded-t-2xl`,children:(0,K.jsx)(`span`,{className:O(`-top-28 -right-10 absolute size-80 rounded-full bg-white blur-3xl`,m?`opacity-[0.14]`:`opacity-80`)})}),(0,K.jsx)(`div`,{className:`-bottom-5 absolute right-9 z-10 max-sm:hidden`,children:(0,K.jsx)(ie,{kind:d.avatar,size:104})}),(0,K.jsxs)(`div`,{className:`relative sm:pr-36`,children:[(0,K.jsx)(`h2`,{className:`font-display font-semibold text-[1.375rem] leading-tight tracking-tight max-sm:pr-10`,children:d.title}),(0,K.jsx)(`p`,{className:`mt-1 text-[0.875rem] text-ink-2 leading-snug`,children:l.data?.description||d.pitch})]}),d.usable?(0,K.jsxs)(`div`,{className:`-mx-5 sm:-mx-7 relative mt-3.5 flex flex-wrap items-center gap-y-2 border-border-soft border-t px-5 pt-3 font-medium text-[0.875rem] sm:px-7 sm:pr-40`,children:[(0,K.jsxs)(Q,{title:p(`market.duration`),children:[(0,K.jsx)(g,{className:`size-4 text-ink-3`}),p(`market.minutes`,{n:d.effort.minutes})]}),(0,K.jsx)(Q,{title:p(`market.cost`),children:(0,K.jsx)(Y,{entry:d})}),(0,K.jsx)(Q,{title:p(`market.result`),children:d.formats.map(e=>(0,K.jsx)(J,{format:e,className:`size-4`},e))})]}):null]}),d.usable?(0,K.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-x-7 gap-y-6 px-5 pt-6 max-sm:overflow-y-auto max-sm:pb-4 sm:grid-cols-[230px_minmax(0,1fr)] sm:grid-rows-[minmax(0,1fr)] sm:px-7`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-5 sm:min-h-0 sm:overflow-y-auto`,children:[(0,K.jsx)(X,{title:p(`market.duration`),children:(0,K.jsx)($,{icon:(0,K.jsx)(g,{className:`size-4 text-moss`}),more:p(`market.durationHint`,{n:d.effort.fields}),children:p(`market.minutes`,{n:d.effort.minutes})})}),(0,K.jsx)(X,{title:p(`market.cost`),children:(0,K.jsx)($,{icon:(0,K.jsx)(ye,{className:`size-4 text-amber`}),more:d.credits?p(`market.creditsHint`):void 0,children:(0,K.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2`,children:[(0,K.jsx)(Y,{entry:d}),d.credits?(0,K.jsx)(`span`,{className:`text-ink-2`,children:p(`market.creditsRange`,{n:it(d.credits.credits)})}):null]})})}),(0,K.jsx)(X,{title:p(`market.result`),children:(0,K.jsx)(`div`,{className:`flex flex-col gap-2`,children:(l.data?.results??[]).map(e=>(0,K.jsx)($,{icon:(0,K.jsx)(J,{format:e.kind,className:`size-4 text-ember-strong`}),more:e.formats.map(e=>e.toUpperCase()).join(` · `),children:e.title},e.title))})}),(0,K.jsx)(X,{title:p(`market.needs`),children:(0,K.jsx)(`ul`,{className:`flex flex-col gap-2`,children:d.capabilities.map(e=>{let t=dt[e],n=d.missing.includes(e),r=d.optional?.includes(e);return(0,K.jsxs)(`li`,{className:O(`flex items-center gap-2.5 text-[0.875rem]`,n?`text-ink-3`:`text-ink-2`),children:[(0,K.jsx)(t,{className:O(`size-4 shrink-0`,n?`text-rose`:r?`text-amber`:`text-cobalt`)}),q(U,e),n?(0,K.jsx)(`span`,{className:`text-[0.75rem] text-rose`,children:p(`market.unavailable`)}):r?(0,K.jsx)(`span`,{className:`text-[0.75rem] text-amber`,children:p(`market.optional`)}):null]},e)})})})]}),(0,K.jsxs)(`div`,{className:`flex flex-col sm:min-h-0`,children:[(0,K.jsx)(`div`,{className:`mb-1.5 shrink-0 font-medium text-[0.75rem] text-ink-3 uppercase tracking-[0.06em]`,children:p(`market.steps`)}),(0,K.jsx)(ht,{className:`-mr-2 overscroll-contain pt-1 pr-2 pl-1 sm:min-h-0 sm:flex-1 sm:overflow-y-auto`,children:l.isLoading?(0,K.jsx)(w,{className:`size-5 text-ink-3`}):(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(w,{className:`size-5 text-ink-3`}),children:(0,K.jsx)(nt,{steps:mt(l.data?.outline??[])})})})]})]}):(0,K.jsx)(`div`,{className:`flex-1 px-5 pt-6 sm:px-7`,children:(0,K.jsx)(`p`,{className:`rounded-lg bg-amber-tint p-3 text-[0.875rem] text-ink-2`,children:p(`market.needsUpdateHint`)})}),(0,K.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 px-5 pt-4 pb-5 max-sm:border-border-soft max-sm:border-t sm:px-7 sm:pb-6`,children:[d.plugin?(0,K.jsx)(`span`,{className:`mr-auto flex items-center`,children:(0,K.jsx)(lt,{plugin:d.plugin})}):(0,K.jsxs)(E,{variant:`ghost`,className:`mr-auto`,title:p(`market.starHint`),"aria-pressed":d.starred,busy:f.isPending,onClick:()=>f.mutate(!d.starred),children:[(0,K.jsx)(B,{className:O(`size-4`,d.starred&&`fill-amber text-amber`)}),(0,K.jsx)(`span`,{className:`max-sm:sr-only`,children:p(d.starred?`market.starred`:`market.star`)})]}),(0,K.jsx)(E,{variant:`secondary`,onClick:n,children:p(`common.close`)}),d.usable&&d.missing.length?(0,K.jsx)(E,{variant:`secondary`,onClick:()=>c(`/settings/models`),children:p(`editor.models.settings`)}):null,i?(0,K.jsx)(E,{disabled:!d.usable||d.missing.length>0||!!d.needs?.length,title:d.needs?.length?p(`market.needsProHint`,{list:d.needs.join(`, `)}):d.missing.length?p(`market.missingHint`,{list:Z(d.missing)}):d.optional?.length?p(`market.optionalHint`,{list:Z(d.optional)}):void 0,busy:a,onClick:()=>i(d),children:p(`market.use`)}):null]})]}):(0,K.jsx)(`div`,{className:`flex min-h-48 flex-col items-center justify-center gap-3 rounded-2xl bg-card p-8 text-[0.875rem] text-ink-2 shadow-overlay`,children:l.isLoading?(0,K.jsx)(w,{className:`size-6 text-ink-3`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{children:p(`market.notFound`)}),(0,K.jsx)(E,{variant:`secondary`,onClick:n,children:p(`common.close`)})]})})})}function _t({name:e,value:t,options:n,onChange:r}){let[i,a]=(0,G.useState)(!1),o=(0,G.useRef)(null);(0,G.useEffect)(()=>{if(!i)return;let e=e=>{o.current?.contains(e.target)||a(!1)},t=e=>{e.key===`Escape`&&a(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[i]);let s=n.find(e=>e.value===t);return(0,K.jsxs)(`div`,{ref:o,className:`relative`,children:[(0,K.jsxs)(`div`,{className:O(`flex h-8 items-center rounded-full text-[0.8125rem] transition`,s?`bg-ember-tint text-ink`:`text-ink-2 hover:bg-paper-2 hover:text-ink`,i&&!s&&`bg-paper-2 text-ink`),children:[(0,K.jsx)(`button`,{type:`button`,"aria-haspopup":`listbox`,"aria-expanded":i,onClick:()=>a(!i),className:O(`flex h-full items-center gap-1.5 rounded-full pl-3 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus`,s?`pr-1`:`pr-2.5`),children:s?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`text-ink-3`,children:e}),(0,K.jsx)(`span`,{className:`font-medium`,children:s.label})]}):(0,K.jsxs)(K.Fragment,{children:[e,(0,K.jsx)(te,{className:O(`size-3.5 transition`,i&&`rotate-180`)})]})}),s?(0,K.jsx)(`button`,{type:`button`,"aria-label":`${e}: ${p(`market.reset`)}`,onClick:()=>r(``),className:`mr-1 flex size-6 items-center justify-center rounded-full text-ink-3 hover:bg-card hover:text-ink`,children:(0,K.jsx)(v,{className:`size-3.5`})}):null]}),i?(0,K.jsx)(`div`,{role:`listbox`,"aria-label":e,className:`absolute top-full left-0 z-30 mt-1.5 max-h-80 min-w-60 overflow-y-auto rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,children:n.map(e=>(0,K.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":e.value===t,disabled:!e.count||e.unavailable,onClick:()=>{r(e.value===t?``:e.value),a(!1)},className:O(`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-left text-[0.875rem] transition coarse:py-2.5`,e.count&&!e.unavailable?`text-ink-2 hover:bg-paper-2 hover:text-ink`:`text-ink-4`,e.value===t&&`font-medium text-ink`),children:[e.icon,(0,K.jsx)(`span`,{className:`flex-1 whitespace-nowrap`,children:e.label}),e.value===t?(0,K.jsx)(_,{className:`size-4 text-ember`}):e.unavailable?(0,K.jsx)(`span`,{className:`whitespace-nowrap text-[0.75rem] text-ink-4`,children:p(`market.unavailable`)}):(0,K.jsx)(`span`,{className:`text-[0.75rem] text-ink-4 tabular-nums`,children:e.count})]},e.value))}):null]})}function vt(e,t){let[n,r]=(0,G.useState)(e);return(0,G.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n}var yt=60;function bt({query:e,onUse:t,busy:n,limit:r=6}){let[i,a]=(0,G.useState)(null),o=vt(e.trim(),250),c=s({queryKey:[`marketplace`,D,o,`hits`,r],queryFn:()=>b.get(`/api/studio/marketplace?${new URLSearchParams({lang:D,limit:String(r),offset:`0`,q:o})}`),enabled:!!o,placeholderData:l}),u=o?c.data?.entries??[]:[];return u.length?(0,K.jsxs)(`section`,{className:`mt-10`,children:[(0,K.jsxs)(`h2`,{className:`mb-5 flex items-center gap-2 font-medium text-[0.8125rem] text-ink-3 uppercase tracking-[0.08em]`,children:[p(`market.hits`),c.isFetching?(0,K.jsx)(w,{className:`size-3.5`}):null]}),(0,K.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:u.map(e=>(0,K.jsx)(ut,{entry:e,onOpen:()=>a(e.id)},e.id))}),(0,K.jsx)(gt,{id:i,fallback:u.find(e=>e.id===i)??null,onClose:()=>a(null),onUse:t,busy:n})]}):null}function xt({onUse:e,busy:t,open:n}){let[r,i]=(0,G.useState)(``),[a,o]=(0,G.useState)(rt),[s,c]=(0,G.useState)(!1),[u,d]=(0,G.useState)(n??null),f=vt(r.trim(),250),m=le({queryKey:[`marketplace`,D,f,a,s],queryFn:({pageParam:e})=>{let t=new URLSearchParams({lang:D,limit:String(yt),offset:String(e)});f&&t.set(`q`,f);for(let[e,n]of Object.entries(a))n&&t.set(e,n);return s&&t.set(`starred`,`1`),b.get(`/api/studio/marketplace?${t}`)},initialPageParam:0,getNextPageParam:(e,t)=>{let n=t.reduce((e,t)=>e+t.entries.length,0);return n<e.total?n:void 0},placeholderData:l}),h=m.data?.pages[0],g=m.data?.pages.flatMap(e=>e.entries)??[],_=h?.all??0,ee=r.trim()!==f||m.isFetching&&!m.isFetchingNextPage,y=(e,t,n)=>Object.keys(t).filter(t=>h?.facets[e]?.[t]!==void 0).map(r=>({value:r,label:q(t,r),icon:n?.(r),count:(h?.facets[e])[r]??0,unavailable:e===`capability`&&te.has(r)})),te=new Set(h?.unavailable??[]),x=y(`useCase`,qe),ne=[{key:`industry`,name:p(`market.industry`),options:y(`industry`,Ke)},{key:`format`,name:p(`market.format`),options:y(`format`,H,e=>(0,K.jsx)(J,{format:e,className:`size-4 text-ink-3`}))},{key:`plan`,name:p(`market.plan`),options:y(`plan`,Ye)},{key:`capability`,name:p(`market.capability`),options:y(`capability`,U,e=>{let t=dt[e];return(0,K.jsx)(t,{className:`size-4 text-ink-3`})})}],S=!!r.trim()||s||Object.values(a).some(Boolean),C=()=>{o(rt),i(``),c(!1)};if(m.isLoading)return(0,K.jsx)(`div`,{className:`flex justify-center py-10`,children:(0,K.jsx)(w,{className:`size-6 text-ink-3`})});let T=h?.offline?(0,K.jsxs)(`p`,{className:`mt-4 flex items-center justify-center gap-2 text-[0.8125rem] text-ink-3`,children:[(0,K.jsx)(P,{className:`size-4 shrink-0`}),p(`market.offline`)]}):null;if(!_&&!S)return T;let re=r?(0,K.jsx)(`button`,{type:`button`,"aria-label":p(`market.reset`),onClick:()=>i(``),className:`-mr-1.5 flex size-7 shrink-0 items-center justify-center rounded-full text-ink-3 hover:bg-paper-2 hover:text-ink`,children:(0,K.jsx)(v,{className:`size-4`})}):null,k=e=>O(`inline-flex h-7 shrink-0 items-center gap-1 whitespace-nowrap rounded-full px-2.5 text-[0.78125rem] transition`,e?`bg-card font-medium text-ink shadow-soft ring-1 ring-border-soft`:`text-ink-3 hover:bg-card/60 hover:text-ink`);return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`relative mx-auto flex h-10 max-w-md items-center gap-2.5 rounded-full bg-card px-4 shadow-soft ring-1 ring-border-soft transition focus-within:ring-2 focus-within:ring-focus sm:h-11`,children:[ee?(0,K.jsx)(w,{className:`size-4 shrink-0 text-ink-3`}):(0,K.jsx)(Le,{className:`size-4 shrink-0 text-ink-3`}),(0,K.jsx)(`input`,{type:`search`,value:r,onChange:e=>i(e.target.value),placeholder:p(`market.search`),"aria-label":p(`market.search`),className:`min-w-0 flex-1 bg-transparent text-[0.9375rem] outline-none placeholder:text-ink-4 [&::-webkit-search-cancel-button]:hidden`}),re]}),T,(0,K.jsxs)(`div`,{className:`max-sm:-mx-3 mt-4 flex gap-1 max-sm:overflow-x-auto max-sm:px-3 max-sm:[scrollbar-width:none] sm:flex-wrap sm:justify-center max-sm:[&::-webkit-scrollbar]:hidden`,children:[[{value:``,label:p(`market.all`)},...x].map(e=>(0,K.jsx)(`button`,{type:`button`,"aria-pressed":!s&&a.useCase===e.value,onClick:()=>{c(!1),o({...a,useCase:e.value})},className:k(!s&&a.useCase===e.value),children:e.label},e.value)),(0,K.jsxs)(`button`,{type:`button`,"aria-pressed":s,onClick:()=>c(!s),className:k(s),children:[(0,K.jsx)(B,{className:O(`size-3.5`,s&&`fill-amber text-amber`)}),p(`market.starred`)]})]}),(0,K.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-1 gap-y-2 sm:mt-6`,children:[s?null:ne.map(e=>(0,K.jsx)(_t,{name:e.name,value:a[e.key],options:e.options,onChange:t=>o({...a,[e.key]:t})},e.key)),(0,K.jsxs)(`span`,{className:`ml-auto flex items-center gap-3 whitespace-nowrap pl-2 text-[0.8125rem] text-ink-3`,children:[S?(0,K.jsxs)(`button`,{type:`button`,onClick:C,className:`inline-flex items-center gap-1 text-ember-strong underline-offset-2 hover:underline`,children:[(0,K.jsx)(v,{className:`size-3.5 max-sm:size-4`}),(0,K.jsx)(`span`,{className:`max-sm:sr-only`,children:p(`market.resetShort`)})]}):null,S?(0,K.jsx)(`span`,{className:`tabular-nums sm:hidden`,children:p(`market.countOfShort`,{n:h?.total??0,all:_})}):null,(0,K.jsx)(`span`,{className:O(`tabular-nums`,S&&`max-sm:hidden`),children:S?p(`market.countOf`,{n:h?.total??0,all:_}):p(`market.count`,{n:_})})]})]}),g.length?(0,K.jsx)(`div`,{className:`mt-4 grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:g.map(e=>(0,K.jsx)(ut,{entry:e,onOpen:()=>d(e.id)},e.id))}):(0,K.jsxs)(`div`,{className:`py-10 text-center text-[0.875rem] text-ink-3`,children:[(0,K.jsx)(`p`,{children:p(s?`market.noneStarred`:`market.none`)}),(0,K.jsx)(E,{variant:`ghost`,className:`mt-2`,onClick:C,children:p(`market.reset`)})]}),m.hasNextPage?(0,K.jsx)(`div`,{className:`mt-6 flex justify-center`,children:(0,K.jsx)(E,{variant:`secondary`,busy:m.isFetchingNextPage,onClick:()=>void m.fetchNextPage(),children:p(`market.more`)})}):null,(0,K.jsx)(gt,{id:u,fallback:g.find(e=>e.id===u)??null,onClose:()=>d(null),onUse:e,busy:t})]})}export{M as C,P as S,A as T,ke as _,tt as a,I as b,U as c,Be as d,B as f,R as g,Me as h,Xe as i,V as l,Ne as m,bt as n,et as o,Le as p,Ze as r,Qe as s,xt as t,We as u,L as v,j as w,ye as x,we as y};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FlowPreview-BFfYNi_w.js","assets/rolldown-runtime-hePW80VL.js","assets/jsx-runtime-BNakU3Ej.js","assets/ui-aWLrX8hF.js","assets/preload-helper-CNEI7N0N.js","assets/esm-C_f_4oeZ.js","assets/index-DIF70pQf.js","assets/logo-C4V2_3Ar.js","assets/engenty-eXZ-EAwd.js","assets/useMutation-DKyQXgyj.js","assets/brand-cgisQRwA.js","assets/volume-2-B7cfghgd.js","assets/session-Dej-L4l9.js","assets/index-BBpolc_L.css"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{O as r,a as i,c as a,i as o,r as s,s as c,v as l}from"./logo-C4V2_3Ar.js";import{t as u}from"./useMutation-DKyQXgyj.js";import{t as d}from"./preload-helper-CNEI7N0N.js";import{$t as f,Bt as p,Ct as m,Dt as h,Gt as g,Ot as _,Rt as v,Tt as y,Vt as ee,Xt as b,a as x,at as S,ct as te,en as ne,gt as C,mn as re,on as w,ot as T,st as E,tn as D,xt as O}from"./ui-aWLrX8hF.js";import{l as k,r as ie}from"./brand-cgisQRwA.js";import{t as ae}from"./volume-2-B7cfghgd.js";import{l as oe,u as se}from"./engenty-eXZ-EAwd.js";var ce=class extends i{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type=`infinite`,super.setOptions(e)}getOptimisticResult(e){return e._type=`infinite`,super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:o,isError:s,isRefetchError:l}=r,u=n.fetchMeta?.fetchMore?.direction,d=s&&u===`forward`,f=i&&u===`forward`,p=s&&u===`backward`,m=i&&u===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:c(t,n.data),hasPreviousPage:a(t,n.data),isFetchNextPageError:d,isFetchingNextPage:f,isFetchPreviousPageError:p,isFetchingPreviousPage:m,isRefetchError:l&&!d&&!p,isRefetching:o&&!f&&!m}}};function le(e,t){return o(e,ce,t)}var ue={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`}]]};ue.node;var A=w(ue),de={name:`bot`,size:24,node:[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]};de.node;var j=w(de),fe={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`]};fe.node;var pe=w(fe),me={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`}]]};me.node;var he=w(me),ge={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`}]]};ge.node;var _e=w(ge),M={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`}]]};M.node;var N=w(M),P={name:`cloud-off`,size:24,node:[[`path`,{d:`M10.94 5.274A7 7 0 0 1 15.71 10h1.79a4.5 4.5 0 0 1 4.222 6.057`,key:`1uxyv8`}],[`path`,{d:`M18.796 18.81A4.5 4.5 0 0 1 17.5 19H9A7 7 0 0 1 5.79 5.78`,key:`99tcn7`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};P.node;var F=w(P),ve={name:`coins`,size:24,node:[[`path`,{d:`M13.744 17.736a6 6 0 1 1-7.48-7.48`,key:`bq4yh3`}],[`path`,{d:`M15 6h1v4`,key:`11y1tn`}],[`path`,{d:`m6.134 14.768.866-.5 2 3.464`,key:`17snzx`}],[`circle`,{cx:`16`,cy:`8`,r:`6`,key:`14bfc9`}]]};ve.node;var ye=w(ve),be={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`}]]};be.node;var I=w(be),xe={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`}]]};xe.node;var Se=w(xe),Ce={name:`globe`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]};Ce.node;var we=w(Ce),Te={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`}]]};Te.node;var L=w(Te),Ee={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`}]]};Ee.node;var De=w(Ee),Oe={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`}]]};Oe.node;var ke=w(Oe),Ae={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`}]]};Ae.node;var R=w(Ae),je={name:`plug`,size:24,node:[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]};je.node;var Me=w(je),z={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`}]]};z.node;var Ne=w(z),Pe={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`}]]};Pe.node;var Fe=w(Pe),Ie={name:`search`,size:24,node:[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]};Ie.node;var Le=w(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 B=w(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=w(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=w(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=w(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 V=w(Ge),H={text:{de:`Text`,en:`Text`},document:{de:`Dokument (PDF, Word)`,en:`Document (PDF, Word)`},table:{de:`Tabelle`,en:`Table`},image:{de:`Bild`,en:`Image`},video:{de:`Video`,en:`Video`},audio:{de:`Audio`,en:`Audio`},dashboard:{de:`Dashboard`,en:`Dashboard`}},Ke={any:{de:`Jede Branche`,en:`Any industry`},trades:{de:`Handwerk`,en:`Trades`},gastronomy:{de:`Gastronomie`,en:`Food service`},hospitality:{de:`Hotel & Tourismus`,en:`Hotels & tourism`},realEstate:{de:`Immobilien`,en:`Real estate`},retail:{de:`Handel`,en:`Retail`},health:{de:`Gesundheit`,en:`Health`},professional:{de:`Kanzlei & Beratung`,en:`Professional services`},agency:{de:`Agentur & Marketing`,en:`Agency & marketing`},events:{de:`Veranstaltungen`,en:`Events`},publicSector:{de:`Vereine & Öffentliches`,en:`Associations & public sector`}},qe={marketing:{de:`Marketing & Social Media`,en:`Marketing & social media`},sales:{de:`Angebote & Verkauf`,en:`Offers & sales`},accounting:{de:`Buchhaltung & Belege`,en:`Accounting & receipts`},service:{de:`Kundenservice`,en:`Customer service`},research:{de:`Recherche & Analyse`,en:`Research & analysis`},hr:{de:`Personal & Bewerbungen`,en:`HR & applications`},operations:{de:`Planung & Abläufe`,en:`Planning & operations`},website:{de:`Helfer für die Website`,en:`Website helpers`},visuals:{de:`Bilder & Video`,en:`Images & video`},inquiries:{de:`Anfragen & Termine`,en:`Inquiries & bookings`},advice:{de:`Beratung & Preise`,en:`Advice & pricing`}},U={text:{de:`Text schreiben`,en:`Writes text`},web:{de:`Websuche`,en:`Web search`},browser:{de:`Browser bedienen`,en:`Drives a browser`},documents:{de:`Dokumente & Fotos lesen`,en:`Reads documents & photos`},image:{de:`Bilder erzeugen`,en:`Makes images`},video:{de:`Videos erzeugen`,en:`Makes video`},speech:{de:`Sprachausgabe`,en:`Speech output`},listening:{de:`Sprachnotizen verstehen`,en:`Understands voice notes`},code:{de:`Code ausführen`,en:`Runs code`},connectors:{de:`Verbundene Konten & Systeme`,en:`Connected accounts & systems`},film:{de:`Filme mit Claude Code (auf deinem Abo)`,en:`Films with Claude Code (on your subscription)`}},Je={low:{de:`günstig`,en:`low cost`},medium:{de:`mittel`,en:`medium cost`},high:{de:`teuer`,en:`high cost`}},Ye={free:{de:`Kostenlos`,en:`Free`},pro:{de:`Pro`,en:`Pro`}},W=e=>Object.keys(e);W(H),W(Ke),W(qe),W(U),W(Ye);var G=e(t(),1);function Xe(e){switch(e.type){case`page`:return R;case`agent`:return j;case`generate`:return e.asset===`image`?L:e.asset===`video`?_:e.asset===`dashboard`?De:g;case`widget`:return A;case`surface`:return ke;case`film`:return N;case`review`:return I;case`result`:return Se}return V}var Ze={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 Qe(e){return y(`type.${e.type}`)}var $e=[`web_search`,`web_fetch`,`browser`,`sandbox`,`image`,`http`,`pages`];function et(e){return $e.includes(e)?y(`tool.${e}`):e}function tt(e){switch(e.type){case`page`:return e.fields.map(e=>e.label).join(` · `);case`agent`:{let t=e.tools.map(et),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?y(`editor.reviewEditable`):null,e.regenerate?y(`editor.reviewRedo`):null].filter(Boolean).join(` · `);case`result`:return e.deliverables.map(e=>`${e.label??e.from} (${e.formats.join(`, `)})`).join(` · `)}return``}var K=e(n(),1),nt=(0,G.lazy)(()=>d(()=>import(`./FlowPreview-BFfYNi_w.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13]))),rt={useCase:``,industry:``,format:``,capability:``,plan:``},q=(e,t)=>e[t]?.[m]??t;function it(e){if(e<1)return 1;let t=10**Math.floor(Math.log10(e));return Math.round(e/t)*t}function at(e){return e.credits?y(`market.credits`,{n:it(e.credits.credits)}):Je[e.costTier][m]}var ot={text:We,document:g,table:Be,image:L,video:_,audio:D,dashboard:pe};function J({format:e,className:t}){let n=ot[e],r=q(H,e);return(0,K.jsx)(`span`,{title:r,className:`inline-flex`,children:(0,K.jsx)(n,{className:t,"aria-label":r,role:`img`})})}var st=[`low`,`medium`,`high`];function Y({entry:e}){let t=st.indexOf(e.costTier)+1,n=m===`de`?_e:he;return(0,K.jsxs)(`span`,{title:at(e),className:`inline-flex items-center gap-1`,children:[(0,K.jsx)(`span`,{"aria-hidden":`true`,className:`inline-flex shrink-0`,children:st.slice(0,t).map((e,t)=>(0,K.jsx)(`span`,{className:O(`rounded-full bg-(--coin-bg,var(--color-card))`,t>0&&`-ml-1.5`),children:(0,K.jsx)(n,{className:`size-4`})},e))}),Je[e.costTier][m]]})}function ct(){return(0,K.jsx)(E,{tone:`ember`,title:y(`market.proHint`),children:y(`market.pro`)})}function lt({plugin:e}){return(0,K.jsx)(E,{icon:(0,K.jsx)(Ne,{className:`size-3.5`}),title:y(`market.fromPlugin`,{name:e.name}),children:e.name})}function ut({entry:e,onOpen:t}){return(0,K.jsxs)(T,{role:`button`,tabIndex:0,onClick:t,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t())},className:O(`relative flex min-h-[124px] cursor-pointer flex-col gap-5 p-4 text-left transition sm:min-h-[136px] sm:p-5 hover:shadow-elevated focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus`,(!e.usable||e.missing.length>0||!!e.needs?.length)&&`opacity-60`),children:[(0,K.jsx)(`span`,{className:`-top-4 pointer-events-none absolute right-4`,children:(0,K.jsx)(ie,{kind:e.avatar,size:68})}),(0,K.jsxs)(`div`,{className:`min-w-0 pr-20`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 font-display font-semibold text-[0.9375rem]`,children:[e.title,e.plan===`pro`?(0,K.jsx)(ct,{}):null,e.starred?(0,K.jsx)(B,{className:`size-3.5 shrink-0 fill-amber text-amber`,"aria-label":y(`market.starred`)}):null]}),(0,K.jsx)(`div`,{className:`mt-0.5 text-[0.8125rem] text-ink-3 leading-snug`,children:e.pitch})]}),(0,K.jsxs)(`div`,{className:`mt-auto flex flex-wrap items-center gap-x-3 gap-y-1.5 text-[0.75rem] text-ink-3`,children:[e.plugin?(0,K.jsx)(lt,{plugin:e.plugin}):null,e.needs?.length?(0,K.jsx)(E,{tone:`warn`,children:y(`market.needsPro`,{list:e.needs.join(`, `)})}):e.usable&&e.missing.length?(0,K.jsx)(E,{tone:`warn`,children:y(`market.missing`,{list:Z(e.missing)})}):e.usable?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,K.jsx)(b,{className:`size-3.5`}),` `,y(`market.minutes`,{n:e.effort.minutes})]}),(0,K.jsx)(Y,{entry:e}),e.optional?.length?(0,K.jsx)(E,{title:y(`market.optionalHint`,{list:Z(e.optional)}),children:y(`market.without`,{list:Z(e.optional)})}):null,(0,K.jsx)(`span`,{className:`ml-auto inline-flex items-center gap-1.5`,children:e.formats.map(e=>(0,K.jsx)(J,{format:e,className:`size-4`},e))})]}):(0,K.jsx)(E,{tone:`warn`,children:y(`market.needsUpdate`)})]})]})}function X({title:e,children:t}){return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`mb-1.5 font-medium text-[0.75rem] text-ink-3 uppercase tracking-[0.06em]`,children:e}),t]})}var Z=e=>e.map(e=>q(U,e)).join(`, `),dt={text:v,web:we,browser:p,documents:Fe,image:L,video:_,speech:ae,listening:ee,code:He,connectors:Me,film:N};function ft(e){switch(e.type){case`page`:return R;case`agent`:return j;case`generate`:return e.asset===`image`?L:e.asset===`video`?_:e.asset===`voice`?ae:e.asset===`dashboard`?pe:g;case`widget`:return e.video?N:A;case`surface`:return A;case`film`:return N;case`review`:return I;case`result`:return Se}return V}function pt(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 mt(e){let t=pt(e);return e.map(e=>({id:e.id,title:e.title,icon:ft(e),tone:Ze[e.type]??`bg-paper-2 text-ink-2`,optional:t.has(e.id),branches:e.branches}))}function Q({title:e,children:t}){return(0,K.jsx)(`span`,{title:e,className:`inline-flex items-center gap-2 border-border border-l px-4 first:border-l-0 first:pl-0`,children:t})}function $({icon:e,children:t,more:n}){return(0,K.jsxs)(`div`,{className:`flex gap-2.5`,children:[(0,K.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:e}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-[0.875rem] text-ink leading-snug`,children:t}),n?(0,K.jsx)(`div`,{className:`text-[0.75rem] text-ink-3 leading-snug`,children:n}):null]})]})}function ht({className:e,children:t}){let n=(0,G.useRef)(null),[r,i]=(0,G.useState)({above:!1,below:!1});(0,G.useEffect)(()=>{let e=n.current;if(!e)return;let t=()=>{let t=e.scrollTop>1,n=e.scrollTop+e.clientHeight<e.scrollHeight-1;i(e=>e.above===t&&e.below===n?e:{above:t,below:n})};t(),e.addEventListener(`scroll`,t,{passive:!0});let r=new ResizeObserver(t);return r.observe(e),e.firstElementChild&&r.observe(e.firstElementChild),()=>{e.removeEventListener(`scroll`,t),r.disconnect()}},[]);let a=`linear-gradient(to bottom, ${r.above?`transparent`:`black`} 0, black 28px, black calc(100% - 44px), ${r.below?`transparent`:`black`} 100%)`;return(0,K.jsx)(`div`,{ref:n,className:e,style:{maskImage:a,WebkitMaskImage:a},children:(0,K.jsx)(`div`,{children:t})})}function gt({id:e,fallback:t,onClose:n,onUse:i,busy:a}){let o=r(),c=re(),l=s({queryKey:[`marketplace-entry`,e,m],queryFn:()=>x.get(`/api/studio/marketplace/${encodeURIComponent(e)}?lang=${m}`),enabled:!!e,retry:!1}),d=l.data??t,f=u({mutationFn:t=>{let n=`/api/studio/marketplace/${encodeURIComponent(e)}/star`;return t?x.put(n):x.del(n)},onSuccess:()=>Promise.all([o.invalidateQueries({queryKey:[`marketplace`]}),o.invalidateQueries({queryKey:[`marketplace-entry`,e]})])}),p=k()===`dark`,g=oe[se[d?.avatar||`round`]],_=p?`var(--card)`:`color-mix(in oklch, ${g??`var(--ink-4)`} 14%, var(--paper-2))`;return(0,K.jsx)(te,{open:!!e,onClose:n,wide:!0,bare:!0,children:d?(0,K.jsxs)(`div`,{className:`relative flex max-h-[calc(100dvh-48px)] flex-col rounded-2xl bg-card shadow-overlay max-sm:h-dvh max-sm:max-h-none max-sm:rounded-none`,children:[(0,K.jsx)(`button`,{type:`button`,"aria-label":y(`common.close`),onClick:n,className:`sm:-top-3.5 sm:-right-3.5 absolute top-3 right-3 z-20 flex size-9 items-center justify-center rounded-full bg-card text-ink-2 shadow-elevated ring-1 ring-border-soft transition hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus`,children:(0,K.jsx)(h,{className:`size-4`})}),(0,K.jsxs)(`header`,{className:`relative shrink-0 border-border-soft border-b px-5 pt-5 pb-4 text-ink sm:rounded-t-2xl sm:px-7`,style:{background:_,"--coin-bg":_},children:[(0,K.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 overflow-hidden sm:rounded-t-2xl`,children:(0,K.jsx)(`span`,{className:O(`-top-28 -right-10 absolute size-80 rounded-full bg-white blur-3xl`,p?`opacity-[0.14]`:`opacity-80`)})}),(0,K.jsx)(`div`,{className:`-bottom-5 absolute right-9 z-10 max-sm:hidden`,children:(0,K.jsx)(ie,{kind:d.avatar,size:104})}),(0,K.jsxs)(`div`,{className:`relative sm:pr-36`,children:[(0,K.jsx)(`h2`,{className:`font-display font-semibold text-[1.375rem] leading-tight tracking-tight max-sm:pr-10`,children:d.title}),(0,K.jsx)(`p`,{className:`mt-1 text-[0.875rem] text-ink-2 leading-snug`,children:l.data?.description||d.pitch})]}),d.usable?(0,K.jsxs)(`div`,{className:`-mx-5 sm:-mx-7 relative mt-3.5 flex flex-wrap items-center gap-y-2 border-border-soft border-t px-5 pt-3 font-medium text-[0.875rem] sm:px-7 sm:pr-40`,children:[(0,K.jsxs)(Q,{title:y(`market.duration`),children:[(0,K.jsx)(b,{className:`size-4 text-ink-3`}),y(`market.minutes`,{n:d.effort.minutes})]}),(0,K.jsx)(Q,{title:y(`market.cost`),children:(0,K.jsx)(Y,{entry:d})}),(0,K.jsx)(Q,{title:y(`market.result`),children:d.formats.map(e=>(0,K.jsx)(J,{format:e,className:`size-4`},e))})]}):null]}),d.usable?(0,K.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-x-7 gap-y-6 px-5 pt-6 max-sm:overflow-y-auto max-sm:pb-4 sm:grid-cols-[230px_minmax(0,1fr)] sm:grid-rows-[minmax(0,1fr)] sm:px-7`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-5 sm:min-h-0 sm:overflow-y-auto`,children:[(0,K.jsx)(X,{title:y(`market.duration`),children:(0,K.jsx)($,{icon:(0,K.jsx)(b,{className:`size-4 text-moss`}),more:y(`market.durationHint`,{n:d.effort.fields}),children:y(`market.minutes`,{n:d.effort.minutes})})}),(0,K.jsx)(X,{title:y(`market.cost`),children:(0,K.jsx)($,{icon:(0,K.jsx)(ye,{className:`size-4 text-amber`}),more:d.credits?y(`market.creditsHint`):void 0,children:(0,K.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2`,children:[(0,K.jsx)(Y,{entry:d}),d.credits?(0,K.jsx)(`span`,{className:`text-ink-2`,children:y(`market.creditsRange`,{n:it(d.credits.credits)})}):null]})})}),(0,K.jsx)(X,{title:y(`market.result`),children:(0,K.jsx)(`div`,{className:`flex flex-col gap-2`,children:(l.data?.results??[]).map(e=>(0,K.jsx)($,{icon:(0,K.jsx)(J,{format:e.kind,className:`size-4 text-ember-strong`}),more:e.formats.map(e=>e.toUpperCase()).join(` · `),children:e.title},e.title))})}),(0,K.jsx)(X,{title:y(`market.needs`),children:(0,K.jsx)(`ul`,{className:`flex flex-col gap-2`,children:d.capabilities.map(e=>{let t=dt[e],n=d.missing.includes(e),r=d.optional?.includes(e);return(0,K.jsxs)(`li`,{className:O(`flex items-center gap-2.5 text-[0.875rem]`,n?`text-ink-3`:`text-ink-2`),children:[(0,K.jsx)(t,{className:O(`size-4 shrink-0`,n?`text-rose`:r?`text-amber`:`text-cobalt`)}),q(U,e),n?(0,K.jsx)(`span`,{className:`text-[0.75rem] text-rose`,children:y(`market.unavailable`)}):r?(0,K.jsx)(`span`,{className:`text-[0.75rem] text-amber`,children:y(`market.optional`)}):null]},e)})})})]}),(0,K.jsxs)(`div`,{className:`flex flex-col sm:min-h-0`,children:[(0,K.jsx)(`div`,{className:`mb-1.5 shrink-0 font-medium text-[0.75rem] text-ink-3 uppercase tracking-[0.06em]`,children:y(`market.steps`)}),(0,K.jsx)(ht,{className:`-mr-2 overscroll-contain pt-1 pr-2 pl-1 sm:min-h-0 sm:flex-1 sm:overflow-y-auto`,children:l.isLoading?(0,K.jsx)(C,{className:`size-5 text-ink-3`}):(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(C,{className:`size-5 text-ink-3`}),children:(0,K.jsx)(nt,{steps:mt(l.data?.outline??[])})})})]})]}):(0,K.jsx)(`div`,{className:`flex-1 px-5 pt-6 sm:px-7`,children:(0,K.jsx)(`p`,{className:`rounded-lg bg-amber-tint p-3 text-[0.875rem] text-ink-2`,children:y(`market.needsUpdateHint`)})}),(0,K.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 px-5 pt-4 pb-5 max-sm:border-border-soft max-sm:border-t sm:px-7 sm:pb-6`,children:[d.plugin?(0,K.jsx)(`span`,{className:`mr-auto flex items-center`,children:(0,K.jsx)(lt,{plugin:d.plugin})}):(0,K.jsxs)(S,{variant:`ghost`,className:`mr-auto`,title:y(`market.starHint`),"aria-pressed":d.starred,busy:f.isPending,onClick:()=>f.mutate(!d.starred),children:[(0,K.jsx)(B,{className:O(`size-4`,d.starred&&`fill-amber text-amber`)}),(0,K.jsx)(`span`,{className:`max-sm:sr-only`,children:y(d.starred?`market.starred`:`market.star`)})]}),(0,K.jsx)(S,{variant:`secondary`,onClick:n,children:y(`common.close`)}),d.usable&&d.missing.length?(0,K.jsx)(S,{variant:`secondary`,onClick:()=>c(`/settings/models`),children:y(`editor.models.settings`)}):null,i?(0,K.jsx)(S,{disabled:!d.usable||d.missing.length>0||!!d.needs?.length,title:d.needs?.length?y(`market.needsProHint`,{list:d.needs.join(`, `)}):d.missing.length?y(`market.missingHint`,{list:Z(d.missing)}):d.optional?.length?y(`market.optionalHint`,{list:Z(d.optional)}):void 0,busy:a,onClick:()=>i(d),children:y(`market.use`)}):null]})]}):(0,K.jsx)(`div`,{className:`flex min-h-48 flex-col items-center justify-center gap-3 rounded-2xl bg-card p-8 text-[0.875rem] text-ink-2 shadow-overlay`,children:l.isLoading?(0,K.jsx)(C,{className:`size-6 text-ink-3`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{children:y(`market.notFound`)}),(0,K.jsx)(S,{variant:`secondary`,onClick:n,children:y(`common.close`)})]})})})}function _t({name:e,value:t,options:n,onChange:r}){let[i,a]=(0,G.useState)(!1),o=(0,G.useRef)(null);(0,G.useEffect)(()=>{if(!i)return;let e=e=>{o.current?.contains(e.target)||a(!1)},t=e=>{e.key===`Escape`&&a(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[i]);let s=n.find(e=>e.value===t);return(0,K.jsxs)(`div`,{ref:o,className:`relative`,children:[(0,K.jsxs)(`div`,{className:O(`flex h-8 items-center rounded-full text-[0.8125rem] transition`,s?`bg-ember-tint text-ink`:`text-ink-2 hover:bg-paper-2 hover:text-ink`,i&&!s&&`bg-paper-2 text-ink`),children:[(0,K.jsx)(`button`,{type:`button`,"aria-haspopup":`listbox`,"aria-expanded":i,onClick:()=>a(!i),className:O(`flex h-full items-center gap-1.5 rounded-full pl-3 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus`,s?`pr-1`:`pr-2.5`),children:s?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`text-ink-3`,children:e}),(0,K.jsx)(`span`,{className:`font-medium`,children:s.label})]}):(0,K.jsxs)(K.Fragment,{children:[e,(0,K.jsx)(f,{className:O(`size-3.5 transition`,i&&`rotate-180`)})]})}),s?(0,K.jsx)(`button`,{type:`button`,"aria-label":`${e}: ${y(`market.reset`)}`,onClick:()=>r(``),className:`mr-1 flex size-6 items-center justify-center rounded-full text-ink-3 hover:bg-card hover:text-ink`,children:(0,K.jsx)(h,{className:`size-3.5`})}):null]}),i?(0,K.jsx)(`div`,{role:`listbox`,"aria-label":e,className:`absolute top-full left-0 z-30 mt-1.5 max-h-80 min-w-60 overflow-y-auto rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,children:n.map(e=>(0,K.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":e.value===t,disabled:!e.count||e.unavailable,onClick:()=>{r(e.value===t?``:e.value),a(!1)},className:O(`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-left text-[0.875rem] transition coarse:py-2.5`,e.count&&!e.unavailable?`text-ink-2 hover:bg-paper-2 hover:text-ink`:`text-ink-4`,e.value===t&&`font-medium text-ink`),children:[e.icon,(0,K.jsx)(`span`,{className:`flex-1 whitespace-nowrap`,children:e.label}),e.value===t?(0,K.jsx)(ne,{className:`size-4 text-ember`}):e.unavailable?(0,K.jsx)(`span`,{className:`whitespace-nowrap text-[0.75rem] text-ink-4`,children:y(`market.unavailable`)}):(0,K.jsx)(`span`,{className:`text-[0.75rem] text-ink-4 tabular-nums`,children:e.count})]},e.value))}):null]})}function vt(e,t){let[n,r]=(0,G.useState)(e);return(0,G.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n}var yt=60;function bt({query:e,onUse:t,busy:n,limit:r=6}){let[i,a]=(0,G.useState)(null),o=vt(e.trim(),250),c=s({queryKey:[`marketplace`,m,o,`hits`,r],queryFn:()=>x.get(`/api/studio/marketplace?${new URLSearchParams({lang:m,limit:String(r),offset:`0`,q:o})}`),enabled:!!o,placeholderData:l}),u=o?c.data?.entries??[]:[];return u.length?(0,K.jsxs)(`section`,{className:`mt-10`,children:[(0,K.jsxs)(`h2`,{className:`mb-5 flex items-center gap-2 font-medium text-[0.8125rem] text-ink-3 uppercase tracking-[0.08em]`,children:[y(`market.hits`),c.isFetching?(0,K.jsx)(C,{className:`size-3.5`}):null]}),(0,K.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:u.map(e=>(0,K.jsx)(ut,{entry:e,onOpen:()=>a(e.id)},e.id))}),(0,K.jsx)(gt,{id:i,fallback:u.find(e=>e.id===i)??null,onClose:()=>a(null),onUse:t,busy:n})]}):null}function xt({onUse:e,busy:t,open:n}){let[r,i]=(0,G.useState)(``),[a,o]=(0,G.useState)(rt),[s,c]=(0,G.useState)(!1),[u,d]=(0,G.useState)(n??null),f=vt(r.trim(),250),p=le({queryKey:[`marketplace`,m,f,a,s],queryFn:({pageParam:e})=>{let t=new URLSearchParams({lang:m,limit:String(yt),offset:String(e)});f&&t.set(`q`,f);for(let[e,n]of Object.entries(a))n&&t.set(e,n);return s&&t.set(`starred`,`1`),x.get(`/api/studio/marketplace?${t}`)},initialPageParam:0,getNextPageParam:(e,t)=>{let n=t.reduce((e,t)=>e+t.entries.length,0);return n<e.total?n:void 0},placeholderData:l}),g=p.data?.pages[0],_=p.data?.pages.flatMap(e=>e.entries)??[],v=g?.all??0,ee=r.trim()!==f||p.isFetching&&!p.isFetchingNextPage,b=(e,t,n)=>Object.keys(t).filter(t=>g?.facets[e]?.[t]!==void 0).map(r=>({value:r,label:q(t,r),icon:n?.(r),count:(g?.facets[e])[r]??0,unavailable:e===`capability`&&te.has(r)})),te=new Set(g?.unavailable??[]),ne=b(`useCase`,qe),re=[{key:`industry`,name:y(`market.industry`),options:b(`industry`,Ke)},{key:`format`,name:y(`market.format`),options:b(`format`,H,e=>(0,K.jsx)(J,{format:e,className:`size-4 text-ink-3`}))},{key:`plan`,name:y(`market.plan`),options:b(`plan`,Ye)},{key:`capability`,name:y(`market.capability`),options:b(`capability`,U,e=>{let t=dt[e];return(0,K.jsx)(t,{className:`size-4 text-ink-3`})})}],w=!!r.trim()||s||Object.values(a).some(Boolean),T=()=>{o(rt),i(``),c(!1)};if(p.isLoading)return(0,K.jsx)(`div`,{className:`flex justify-center py-10`,children:(0,K.jsx)(C,{className:`size-6 text-ink-3`})});let E=g?.offline?(0,K.jsxs)(`p`,{className:`mt-4 flex items-center justify-center gap-2 text-[0.8125rem] text-ink-3`,children:[(0,K.jsx)(F,{className:`size-4 shrink-0`}),y(`market.offline`)]}):null;if(!v&&!w)return E;let D=r?(0,K.jsx)(`button`,{type:`button`,"aria-label":y(`market.reset`),onClick:()=>i(``),className:`-mr-1.5 flex size-7 shrink-0 items-center justify-center rounded-full text-ink-3 hover:bg-paper-2 hover:text-ink`,children:(0,K.jsx)(h,{className:`size-4`})}):null,k=e=>O(`inline-flex h-7 shrink-0 items-center gap-1 whitespace-nowrap rounded-full px-2.5 text-[0.78125rem] transition`,e?`bg-card font-medium text-ink shadow-soft ring-1 ring-border-soft`:`text-ink-3 hover:bg-card/60 hover:text-ink`);return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`relative mx-auto flex h-10 max-w-md items-center gap-2.5 rounded-full bg-card px-4 shadow-soft ring-1 ring-border-soft transition focus-within:ring-2 focus-within:ring-focus sm:h-11`,children:[ee?(0,K.jsx)(C,{className:`size-4 shrink-0 text-ink-3`}):(0,K.jsx)(Le,{className:`size-4 shrink-0 text-ink-3`}),(0,K.jsx)(`input`,{type:`search`,value:r,onChange:e=>i(e.target.value),placeholder:y(`market.search`),"aria-label":y(`market.search`),className:`min-w-0 flex-1 bg-transparent text-[0.9375rem] outline-none placeholder:text-ink-4 [&::-webkit-search-cancel-button]:hidden`}),D]}),E,(0,K.jsxs)(`div`,{className:`max-sm:-mx-3 mt-4 flex gap-1 max-sm:overflow-x-auto max-sm:px-3 max-sm:[scrollbar-width:none] sm:flex-wrap sm:justify-center max-sm:[&::-webkit-scrollbar]:hidden`,children:[[{value:``,label:y(`market.all`)},...ne].map(e=>(0,K.jsx)(`button`,{type:`button`,"aria-pressed":!s&&a.useCase===e.value,onClick:()=>{c(!1),o({...a,useCase:e.value})},className:k(!s&&a.useCase===e.value),children:e.label},e.value)),(0,K.jsxs)(`button`,{type:`button`,"aria-pressed":s,onClick:()=>c(!s),className:k(s),children:[(0,K.jsx)(B,{className:O(`size-3.5`,s&&`fill-amber text-amber`)}),y(`market.starred`)]})]}),(0,K.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-1 gap-y-2 sm:mt-6`,children:[s?null:re.map(e=>(0,K.jsx)(_t,{name:e.name,value:a[e.key],options:e.options,onChange:t=>o({...a,[e.key]:t})},e.key)),(0,K.jsxs)(`span`,{className:`ml-auto flex items-center gap-3 whitespace-nowrap pl-2 text-[0.8125rem] text-ink-3`,children:[w?(0,K.jsxs)(`button`,{type:`button`,onClick:T,className:`inline-flex items-center gap-1 text-ember-strong underline-offset-2 hover:underline`,children:[(0,K.jsx)(h,{className:`size-3.5 max-sm:size-4`}),(0,K.jsx)(`span`,{className:`max-sm:sr-only`,children:y(`market.resetShort`)})]}):null,w?(0,K.jsx)(`span`,{className:`tabular-nums sm:hidden`,children:y(`market.countOfShort`,{n:g?.total??0,all:v})}):null,(0,K.jsx)(`span`,{className:O(`tabular-nums`,w&&`max-sm:hidden`),children:w?y(`market.countOf`,{n:g?.total??0,all:v}):y(`market.count`,{n:v})})]})]}),_.length?(0,K.jsx)(`div`,{className:`mt-4 grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:_.map(e=>(0,K.jsx)(ut,{entry:e,onOpen:()=>d(e.id)},e.id))}):(0,K.jsxs)(`div`,{className:`py-10 text-center text-[0.875rem] text-ink-3`,children:[(0,K.jsx)(`p`,{children:y(s?`market.noneStarred`:`market.none`)}),(0,K.jsx)(S,{variant:`ghost`,className:`mt-2`,onClick:T,children:y(`market.reset`)})]}),p.hasNextPage?(0,K.jsx)(`div`,{className:`mt-6 flex justify-center`,children:(0,K.jsx)(S,{variant:`secondary`,busy:p.isFetchingNextPage,onClick:()=>void p.fetchNextPage(),children:y(`market.more`)})}):null,(0,K.jsx)(gt,{id:u,fallback:_.find(e=>e.id===u)??null,onClose:()=>d(null),onUse:e,busy:t})]})}export{N as C,F as S,A as T,ke as _,tt as a,I as b,U as c,Be as d,B as f,R as g,Me as h,Xe as i,V as l,Ne as m,bt as n,et as o,Le as p,Ze as r,Qe as s,xt as t,We as u,L as v,j as w,ye as x,we as y};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{O as r}from"./logo-C4V2_3Ar.js";import{t as i}from"./Marketplace-CmeAQDOY.js";import{t as a}from"./useMutation-DKyQXgyj.js";import{Ct as o,a as s,cn as c,fn as l,mn as u,ot as d,rt as f,tn as p,tt as m,vt as h,xt as g}from"./ui-SKtUMhUq.js";import{r as _}from"./brand-ClxXyg-d.js";import{t as v}from"./upload-hT54Sh8P.js";import{d as y,s as b}from"./session-DEXxyxEc.js";var x=e(t(),1),S=e(n(),1);function C({variant:e=`secondary`,label:t=o(`home.import`)}){let n=l(),i=r(),{project:c}=b(),u=y(),p=(0,x.useRef)(null),h=a({mutationFn:e=>s.upload(`/api/studio/projects/${c.id}/wizards/import`,e),onSuccess:async({id:e})=>{await i.invalidateQueries({queryKey:[`projects`]}),await i.invalidateQueries({queryKey:[`wizards`]}),n(`/edit/${e}`)}}),g=h.error instanceof m?h.error.body?.issues??[]:[];return!u||c?.readOnly?null:(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(f,{variant:e,busy:h.isPending,disabled:!c,onClick:()=>p.current?.click(),children:[(0,S.jsx)(v,{className:`size-4`}),` `,t]}),(0,S.jsx)(`input`,{ref:p,hidden:!0,type:`file`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&h.mutate(t)}}),(0,S.jsxs)(d,{open:h.isError,onClose:h.reset,title:o(`import.failed`),children:[(0,S.jsx)(`p`,{className:`text-[0.875rem] text-ink-2`,children:h.error?.message}),g.length?(0,S.jsx)(`ul`,{className:`mt-3 flex list-disc flex-col gap-1 pl-5 text-[0.8125rem] text-ink-2`,children:g.slice(0,8).map(e=>(0,S.jsx)(`li`,{children:e.message},e.message))}):null,(0,S.jsx)(`div`,{className:`mt-5 flex justify-end`,children:(0,S.jsx)(f,{variant:`secondary`,onClick:h.reset,children:o(`common.close`)})})]})]})}var w={de:[`Stellenanzeige aus ein paar Stichworten, als PDF und LinkedIn-Post`,`Produktbeschreibung für den Onlineshop mit drei Bildvarianten`,`Wettbewerbsanalyse zu einer Firma mit Quellen`,`Lead aus einem Formular in unser CRM eintragen`],en:[`A job ad from a few keywords, as PDF and LinkedIn post`,`A shop product description with three image variants`,`A competitor analysis for a company, with sources`,`Put a lead from a form into our CRM`]};function T(){let e=l(),t=r(),{project:n}=b(),d=y(),[m]=u(),[v,T]=(0,x.useState)(m.get(`wish`)??``),E=a({mutationFn:e=>s.post(`/api/studio/wizards`,{projectId:n.id,starterId:e,lang:g}),onSuccess:async({id:n},r)=>{await t.invalidateQueries({queryKey:[`projects`]}),await t.invalidateQueries({queryKey:[`wizards`]}),e(r?`/edit/${n}`:`/edit/${n}?prompt=${encodeURIComponent(v.trim())}`)}}),D=()=>{v.trim()&&n&&E.mutate(void 0)};return!d||n?.readOnly?(0,S.jsx)(c,{to:`/`,replace:!0}):(0,S.jsxs)(`div`,{className:`animate-rise pt-4`,children:[(0,S.jsxs)(`div`,{className:`mx-auto max-w-2xl`,children:[(0,S.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,S.jsx)(_,{kind:`sprout`,size:150,fluffy:!0}),(0,S.jsx)(`h1`,{className:`mt-2 font-display font-semibold text-[2rem] leading-tight tracking-tight sm:text-[2.375rem]`,children:o(`new.title`)})]}),(0,S.jsxs)(`div`,{className:`mt-8 rounded-2xl bg-card p-2 shadow-elevated ring-1 ring-border-soft focus-within:ring-focus`,children:[(0,S.jsx)(h,{autoFocus:!0,minRows:4,value:v,onChange:e=>T(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&D()},placeholder:o(`new.placeholder`),className:`border-0 bg-transparent text-[1rem] shadow-none focus:ring-0`}),(0,S.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-2 pb-1`,children:[(0,S.jsx)(`span`,{className:`hidden text-[0.75rem] text-ink-4 sm:block`,children:o(`new.hint`)}),(0,S.jsxs)(f,{size:`md`,onClick:D,busy:E.isPending&&!E.variables,disabled:!v.trim(),children:[o(`new.build`),` `,(0,S.jsx)(p,{className:`size-4`})]})]})]}),(0,S.jsx)(`div`,{className:`mt-4 flex flex-wrap justify-center gap-2`,children:w[g].map(e=>(0,S.jsx)(`button`,{type:`button`,onClick:()=>T(e),className:`rounded-full bg-paper-2 px-3.5 py-1.5 text-[0.8125rem] text-ink-2 transition hover:bg-paper-3 hover:text-ink`,children:e},e))})]}),(0,S.jsxs)(`section`,{className:`mx-auto max-w-5xl`,children:[(0,S.jsx)(`h2`,{className:`mt-16 mb-5 text-center font-medium text-[0.8125rem] text-ink-3 uppercase tracking-[0.08em]`,children:o(`new.orStarter`)}),(0,S.jsx)(i,{open:m.get(`starter`),busy:E.isPending&&!!E.variables,onUse:e=>n&&!E.isPending&&E.mutate(e.id)}),E.error?(0,S.jsx)(`p`,{className:`mt-3 text-center text-[0.875rem] text-rose`,children:E.error.message}):null]}),(0,S.jsx)(`div`,{className:`mt-8 flex justify-center`,children:(0,S.jsx)(C,{variant:`ghost`,label:o(`new.import`)})})]})}export{T as NewWizardPage};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{O as r}from"./logo-C4V2_3Ar.js";import{t as i}from"./Marketplace-CuE6WgnO.js";import{t as a}from"./useMutation-DKyQXgyj.js";import{Ct as o,Tt as s,a as c,at as l,bt as u,ct as d,gn as f,mn as p,rn as m,rt as h,un as g}from"./ui-aWLrX8hF.js";import{r as _}from"./brand-cgisQRwA.js";import{t as v}from"./upload-CNYeHI5s.js";import{d as y,s as b}from"./session-Dej-L4l9.js";var x=e(t(),1),S=e(n(),1);function C({variant:e=`secondary`,label:t=s(`home.import`)}){let n=p(),i=r(),{project:o}=b(),u=y(),f=(0,x.useRef)(null),m=a({mutationFn:e=>c.upload(`/api/studio/projects/${o.id}/wizards/import`,e),onSuccess:async({id:e})=>{await i.invalidateQueries({queryKey:[`projects`]}),await i.invalidateQueries({queryKey:[`wizards`]}),n(`/edit/${e}`)}}),g=m.error instanceof h?m.error.body?.issues??[]:[];return!u||o?.readOnly?null:(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(l,{variant:e,busy:m.isPending,disabled:!o,onClick:()=>f.current?.click(),children:[(0,S.jsx)(v,{className:`size-4`}),` `,t]}),(0,S.jsx)(`input`,{ref:f,hidden:!0,type:`file`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&m.mutate(t)}}),(0,S.jsxs)(d,{open:m.isError,onClose:m.reset,title:s(`import.failed`),children:[(0,S.jsx)(`p`,{className:`text-[0.875rem] text-ink-2`,children:m.error?.message}),g.length?(0,S.jsx)(`ul`,{className:`mt-3 flex list-disc flex-col gap-1 pl-5 text-[0.8125rem] text-ink-2`,children:g.slice(0,8).map(e=>(0,S.jsx)(`li`,{children:e.message},e.message))}):null,(0,S.jsx)(`div`,{className:`mt-5 flex justify-end`,children:(0,S.jsx)(l,{variant:`secondary`,onClick:m.reset,children:s(`common.close`)})})]})]})}var w={de:[`Stellenanzeige aus ein paar Stichworten, als PDF und LinkedIn-Post`,`Produktbeschreibung für den Onlineshop mit drei Bildvarianten`,`Wettbewerbsanalyse zu einer Firma mit Quellen`,`Lead aus einem Formular in unser CRM eintragen`],en:[`A job ad from a few keywords, as PDF and LinkedIn post`,`A shop product description with three image variants`,`A competitor analysis for a company, with sources`,`Put a lead from a form into our CRM`]};function T(){let e=p(),t=r(),{project:n}=b(),d=y(),[h]=f(),[v,T]=(0,x.useState)(h.get(`wish`)??``),E=a({mutationFn:e=>c.post(`/api/studio/wizards`,{projectId:n.id,starterId:e,lang:o}),onSuccess:async({id:n},r)=>{await t.invalidateQueries({queryKey:[`projects`]}),await t.invalidateQueries({queryKey:[`wizards`]}),e(r?`/edit/${n}`:`/edit/${n}?prompt=${encodeURIComponent(v.trim())}`)}}),D=()=>{v.trim()&&n&&E.mutate(void 0)};return!d||n?.readOnly?(0,S.jsx)(g,{to:`/`,replace:!0}):(0,S.jsxs)(`div`,{className:`animate-rise pt-4`,children:[(0,S.jsxs)(`div`,{className:`mx-auto max-w-2xl`,children:[(0,S.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,S.jsx)(_,{kind:`sprout`,size:150,fluffy:!0}),(0,S.jsx)(`h1`,{className:`mt-2 font-display font-semibold text-[2rem] leading-tight tracking-tight sm:text-[2.375rem]`,children:s(`new.title`)})]}),(0,S.jsxs)(`div`,{className:`mt-8 rounded-2xl bg-card p-2 shadow-elevated ring-1 ring-border-soft focus-within:ring-focus`,children:[(0,S.jsx)(u,{autoFocus:!0,minRows:4,value:v,onChange:e=>T(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&D()},placeholder:s(`new.placeholder`),className:`border-0 bg-transparent text-[1rem] shadow-none focus:ring-0`}),(0,S.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-2 pb-1`,children:[(0,S.jsx)(`span`,{className:`hidden text-[0.75rem] text-ink-4 sm:block`,children:s(`new.hint`)}),(0,S.jsxs)(l,{size:`md`,onClick:D,busy:E.isPending&&!E.variables,disabled:!v.trim(),children:[s(`new.build`),` `,(0,S.jsx)(m,{className:`size-4`})]})]})]}),(0,S.jsx)(`div`,{className:`mt-4 flex flex-wrap justify-center gap-2`,children:w[o].map(e=>(0,S.jsx)(`button`,{type:`button`,onClick:()=>T(e),className:`rounded-full bg-paper-2 px-3.5 py-1.5 text-[0.8125rem] text-ink-2 transition hover:bg-paper-3 hover:text-ink`,children:e},e))})]}),(0,S.jsxs)(`section`,{className:`mx-auto max-w-5xl`,children:[(0,S.jsx)(`h2`,{className:`mt-16 mb-5 text-center font-medium text-[0.8125rem] text-ink-3 uppercase tracking-[0.08em]`,children:s(`new.orStarter`)}),(0,S.jsx)(i,{open:h.get(`starter`),busy:E.isPending&&!!E.variables,onUse:e=>n&&!E.isPending&&E.mutate(e.id)}),E.error?(0,S.jsx)(`p`,{className:`mt-3 text-center text-[0.875rem] text-rose`,children:E.error.message}):null]}),(0,S.jsx)(`div`,{className:`mt-8 flex justify-center`,children:(0,S.jsx)(C,{variant:`ghost`,label:s(`new.import`)})})]})}export{T as NewWizardPage};
@@ -0,0 +1,2 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{O as r,r as i}from"./logo-C4V2_3Ar.js";import{b as a,f as o,l as s,m as c,p as l,u}from"./Marketplace-CuE6WgnO.js";import{t as d}from"./useMutation-DKyQXgyj.js";import{Ct as f,Ft as p,It as m,Kt as h,Pt as g,Tt as _,Ut as v,Wt as y,_t as ee,a as b,at as x,bt as S,ct as C,dt as w,en as te,ft as T,gn as ne,gt as E,hn as re,ht as D,kt as O,lt as ie,mn as ae,nn as k,on as oe,ot as A,pn as se,st as j,un as M,ut as N,vt as P,x as F,xt as I,zt as L}from"./ui-aWLrX8hF.js";import{_ as ce,a as le,b as R,c as ue,d as de,f as z,g as fe,h as pe,i as me,l as he,m as ge,n as B,o as _e,p as ve,s as ye,u as be,v as xe,x as V,y as H}from"./RunDrawer-D46YTsXi.js";import{r as U,t as W}from"./RunnerView-EpmDp2lS.js";import{n as Se,r as G,t as K}from"./ReadOnly-Bxbgr2n2.js";import{t as Ce}from"./upload-CNYeHI5s.js";import{c as q,l as we,s as Te}from"./session-Dej-L4l9.js";import{A as Ee,F as J,I as De,L as Oe,M as Y,N as ke,O as X,P as Ae,R as je,W as Me,_ as Ne,ct as Pe,d as Fe,f as Ie,g as Le,j as Re,k as ze,l as Be,lt as Ve,p as He,s as Ue,u as We,v as Ge}from"./index-DIF70pQf.js";import{a as Z,c as Ke,f as qe,i as Je,n as Ye,o as Xe,r as Ze,s as Qe,t as $e,u as et}from"./settings-menu-mxakooyx.js";var tt={name:`layers`,size:24,node:[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]],aliases:[`layers-3`]};tt.node;var nt=oe(tt),rt={name:`music`,size:24,node:[[`path`,{d:`M9 18V5l12-2v13`,key:`1jmyc2`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`circle`,{cx:`18`,cy:`16`,r:`3`,key:`1hluhg`}]]};rt.node;var it=oe(rt),Q=e(t(),1),$=e(n(),1),at={backgroundImage:`repeating-conic-gradient(#c9c9c9 0% 25%, #dedede 0% 50%)`,backgroundSize:`16px 16px`};function ot({file:e,actions:t}){let[n,r]=(0,Q.useState)(e.description),i=(0,Q.useRef)(e.description),a=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{e.description!==i.current&&(r(t=>t===i.current?e.description:t),i.current=e.description)},[e.description]),(0,Q.useLayoutEffect)(()=>{let e=a.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`)},[n]);let o=e.status===`pending`&&!n;return t.readOnly?n?(0,$.jsx)(`p`,{className:`text-[0.8125rem] text-ink-2 leading-snug`,children:n}):null:(0,$.jsx)(`textarea`,{ref:a,rows:1,value:n,maxLength:600,placeholder:_(o?`project.describing`:`project.description`),onChange:e=>r(e.target.value),onBlur:()=>{n.trim()!==e.description&&(i.current=n.trim(),t.describe(e.id,n.trim()))},className:`-mx-1 block w-[calc(100%+0.5rem)] resize-none overflow-hidden rounded-md bg-transparent px-1 py-0.5 text-[0.8125rem] text-ink-2 leading-snug outline-none transition placeholder:text-ink-4 hover:bg-paper-2 focus:bg-card focus:text-ink focus:ring-1 focus:ring-border`})}function st(e,t){confirm(_(`project.removeConfirm`,{name:e.name}))&&t.remove(e.id)}function ct({projectId:e,file:t,small:n}){let r=Ae(e,t.id);return t.mime.startsWith(`image/`)?(0,$.jsx)(`img`,{src:r,alt:``,loading:`lazy`,className:I(`size-full`,t.kind===`logo`?`object-contain p-3`:`object-cover`)}):t.mime.startsWith(`video/`)?(0,$.jsx)(`video`,{src:`${r}#t=0.1`,preload:`metadata`,controls:!n,className:`size-full object-cover`}):(0,$.jsx)(`div`,{className:`flex size-full items-center justify-center text-ink-3`,children:t.mime.startsWith(`audio/`)?(0,$.jsx)(it,{className:n?`size-5`:`size-7`}):(0,$.jsx)(y,{className:n?`size-5`:`size-7`})})}function lt({projectId:e,kind:t,files:n,actions:r,accept:i,addLabel:s,onPreview:c}){return(0,$.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(184px,1fr))] gap-3`,children:[n.map((i,s)=>(0,$.jsxs)(`div`,{className:`group relative flex flex-col gap-1.5 rounded-lg bg-paper p-2 pb-2.5 ring-1 ring-border-soft`,children:[t===`logo`&&s===0?(0,$.jsx)(`span`,{className:`absolute -top-3 left-3 z-10 rounded-full ring-2 ring-card`,children:(0,$.jsx)(j,{tone:`ember`,children:_(`project.logoMain`)})}):null,(0,$.jsxs)(`div`,{className:`relative h-28 overflow-hidden rounded-md bg-paper-2`,style:t===`logo`?at:void 0,children:[c&&i.mime.startsWith(`image/`)?(0,$.jsx)(`button`,{type:`button`,"aria-label":`${_(`project.preview`)}: ${i.name}`,onClick:()=>c(i),className:`block size-full cursor-zoom-in`,children:(0,$.jsx)(ct,{projectId:e,file:i})}):(0,$.jsx)(ct,{projectId:e,file:i}),(0,$.jsxs)(`div`,{className:`absolute top-1 right-1 flex gap-1 opacity-0 transition focus-within:opacity-100 group-hover:opacity-100 coarse:opacity-100`,children:[c?(0,$.jsx)(N,{label:_(`project.preview`),onClick:()=>c(i),className:`size-8 bg-card shadow-soft`,children:(0,$.jsx)(a,{className:`size-4`})}):null,t===`logo`&&s>0&&!r.readOnly?(0,$.jsx)(N,{label:_(`project.logoMakeMain`),onClick:()=>r.order(`logo`,[i.id,...n.filter(e=>e.id!==i.id).map(e=>e.id)]),className:`size-8 bg-card shadow-soft`,children:(0,$.jsx)(o,{className:`size-4`})}):null,r.readOnly?null:(0,$.jsx)(N,{label:_(`project.remove`),onClick:()=>st(i,r),className:`size-8 bg-card shadow-soft hover:text-rose`,children:(0,$.jsx)(O,{className:`size-4`})})]})]}),t===`asset`?(0,$.jsx)(`div`,{className:`truncate px-0.5 text-[0.75rem] text-ink-3`,title:i.name,children:i.name}):null,(0,$.jsx)(ot,{file:i,actions:r})]},i.id)),s&&!r.readOnly?(0,$.jsxs)(ze,{accept:i,multiple:!1,onFiles:e=>r.upload(t,e),className:`min-h-28 flex-col p-3`,children:[r.busy?(0,$.jsx)(E,{className:`size-5`}):(0,$.jsx)(p,{className:`size-5`}),s]}):null]})}function ut({projectId:e,data:t,readOnly:n}){let r=De(e,n);return(0,$.jsxs)(Y,{title:_(`project.logos`),hint:_(`project.logosHint`),children:[(0,$.jsx)(lt,{projectId:e,kind:`logo`,files:t.files.filter(e=>e.kind===`logo`),actions:r,accept:`image/*`,addLabel:_(`project.logoAdd`)}),r.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:r.error}):null]})}var dt=e=>[(e.name.includes(`.`)?e.name.split(`.`).pop():e.mime.split(`/`).pop())?.toUpperCase().slice(0,5),ke(e.size)].filter(Boolean).join(` · `);function ft({projectId:e,file:t,actions:n,onClose:r}){let i=Ae(e,t.id);return(0,$.jsxs)(C,{open:!0,onClose:r,wide:`page`,title:t.name,children:[(0,$.jsxs)(`div`,{className:`-mt-2 mb-4 flex items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3`,children:dt(t)}),(0,$.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,"aria-label":_(`project.openOriginal`),title:_(`project.openOriginal`),className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,$.jsx)(h,{className:`size-4`})})]}),t.mime.startsWith(`image/`)?(0,$.jsx)(`div`,{className:`overflow-hidden rounded-lg`,style:at,children:(0,$.jsx)(`img`,{src:i,alt:``,className:`mx-auto max-h-[68dvh] object-contain`})}):t.mime.startsWith(`video/`)?(0,$.jsx)(`video`,{src:i,controls:!0,className:`max-h-[68dvh] w-full rounded-lg bg-black`}):(0,$.jsx)(`audio`,{src:i,controls:!0,className:`w-full`}),(0,$.jsx)(`div`,{className:`mt-4`,children:(0,$.jsx)(ot,{file:t,actions:n})})]})}function pt({projectId:e,file:t,actions:n,onPreview:r}){return(0,$.jsxs)(`li`,{className:`flex items-start gap-3 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":`${_(`project.preview`)}: ${t.name}`,onClick:r,className:`size-14 shrink-0 cursor-zoom-in overflow-hidden rounded-md bg-paper-2`,children:(0,$.jsx)(ct,{projectId:e,file:t,small:!0})}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1 py-0.5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:r,title:t.name,className:`min-w-0 truncate font-medium text-[0.875rem] hover:underline`,children:t.name}),(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:dt(t)})]}),(0,$.jsx)(ot,{file:t,actions:n})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start`,children:[(0,$.jsx)(N,{label:_(`project.preview`),onClick:r,children:(0,$.jsx)(a,{className:`size-4`})}),n.readOnly?null:(0,$.jsx)(N,{label:_(`project.remove`),onClick:()=>st(t,n),className:`hover:text-rose`,children:(0,$.jsx)(O,{className:`size-4`})})]})]})}function mt({projectId:e,data:t,readOnly:n}){let r=De(e,n),[i,a]=Oe(`assets`,`cards`),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(null),u=t.files.filter(e=>e.kind===`asset`),d=u.find(e=>e.id===c),f=o.trim().toLowerCase(),p=f?u.filter(e=>`${e.name} ${e.description}`.toLowerCase().includes(f)):u;return(0,$.jsxs)(Y,{title:_(`project.assets`),hint:_(`project.assetsHint`),children:[u.length?(0,$.jsx)(Ee,{layout:i,onToggle:a,children:(0,$.jsx)(Re,{value:o,onChange:s,placeholder:_(`project.assetSearch`)})}):null,p.length?(0,$.jsx)(`div`,{className:`mb-3`,children:i===`cards`?(0,$.jsx)(lt,{projectId:e,kind:`asset`,files:p,actions:r,onPreview:e=>l(e.id)}):(0,$.jsx)(`ul`,{className:`flex flex-col gap-2`,children:p.map(t=>(0,$.jsx)(pt,{projectId:e,file:t,actions:r,onPreview:()=>l(t.id)},t.id))})}):null,n?u.length?null:(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:_(`project.staysLocal`)}):(0,$.jsxs)(ze,{accept:`image/*,video/*,audio/*`,onFiles:e=>r.upload(`asset`,e),className:`h-16 w-full`,children:[r.busy?(0,$.jsx)(E,{className:`size-4`}):(0,$.jsx)(Ce,{className:`size-4`}),_(`project.drop`),` `,(0,$.jsx)(`span`,{className:`underline`,children:_(`project.assetAdd`)})]}),r.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:r.error}):null,d?(0,$.jsx)(ft,{projectId:e,file:d,actions:r,onClose:()=>l(null)}):null]})}function ht(e,t,n){return i({queryKey:[`project-file-text`,t.id,t.chars,n],queryFn:()=>b.get(`/api/studio/projects/${e}/files/${t.id}/text?limit=${n}`),enabled:t.status===`ready`,staleTime:6e4})}function gt(e){return((e.name.includes(`.`)?e.name.split(`.`).pop():``)||e.mime.split(`/`).pop()||``).toUpperCase().slice(0,5)}var _t=e=>[gt(e),e.pages?_(`project.pages`,{n:e.pages}):null,ke(e.size)].filter(Boolean).join(` · `),vt=2e5;function yt({projectId:e,fileId:t,readOnly:n,onGone:i}){let a=r(),o=je(e),s=ge(e),c=De(e,n),l=o.data?.files.find(e=>e.id===t),u=l?l.mime===`application/pdf`||l.mime.startsWith(`image/`):!1,[d,f]=(0,Q.useState)(null);if(!l)return o.isLoading?(0,$.jsx)(E,{className:`mx-auto text-ink-3`}):null;let p=d??(u?`original`:`text`),m=s.data?.items.find(e=>e.key===`f:${l.id}`),v=Ae(e,l.id),y=(e,t)=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":p===e,onClick:()=>f(e),className:I(`rounded-full px-3 py-1 text-[0.8125rem] transition`,p===e?`bg-paper-2 font-medium text-ink`:`text-ink-3 hover:text-ink`),children:t});return(0,$.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,$.jsx)(`h2`,{className:`min-w-0 flex-1 truncate font-display font-semibold text-lg`,children:l.name}),(0,$.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 max-sm:hidden`,children:_t(l)}),(0,$.jsx)(`a`,{href:v,target:`_blank`,rel:`noreferrer`,"aria-label":_(`project.openOriginal`),title:_(`project.openOriginal`),className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,$.jsx)(h,{className:`size-4`})}),n?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(N,{label:_(`project.reindex`),onClick:async()=>{await c.reindex(l.id),await a.invalidateQueries({queryKey:[`knowledge`,e]})},children:(0,$.jsx)(g,{className:`size-4`})}),(0,$.jsx)(N,{label:_(`know.deleteFile`),className:`hover:text-rose`,onClick:async()=>{confirm(_(`data.confirmDelete`,{title:l.name}))&&(await c.remove(l.id),await a.invalidateQueries({queryKey:[`knowledge`,e]}),i())},children:(0,$.jsx)(O,{className:`size-4`})})]})]}),(0,$.jsx)(z,{projectId:e,itemKey:`f:${l.id}`,has:m?.categories??[],originLabel:m?.originLabel??null,kept:!1,review:null,file:null,readOnly:n,onReviewed:()=>void 0}),(0,$.jsx)(`div`,{className:`px-1`,children:(0,$.jsx)(ot,{file:l,actions:c})}),l.status===`failed`?(0,$.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:l.error}):null,(0,$.jsxs)(A,{className:`flex flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 border-border-soft border-b px-2 py-1.5`,children:[u?y(`original`,_(`project.original`)):null,y(`text`,_(`project.readText`))]}),p===`original`?l.mime===`application/pdf`?(0,$.jsx)(`iframe`,{src:v,title:l.name,className:`h-[70dvh] w-full rounded-b-xl bg-paper-2`}):(0,$.jsx)(`img`,{src:v,alt:``,className:`mx-auto max-h-[70dvh] object-contain p-4`}):(0,$.jsx)(bt,{projectId:e,file:l})]})]})}function bt({projectId:e,file:t}){let n=ht(e,t,vt);return n.isLoading||t.status===`pending`?(0,$.jsx)(`div`,{className:`flex h-40 items-center justify-center text-ink-3`,children:(0,$.jsx)(E,{})}):n.data?.text?(0,$.jsxs)(`div`,{className:`overflow-x-auto p-4 sm:p-5`,children:[(0,$.jsx)(F,{text:n.data.text,className:`text-[0.875rem]`}),n.data.chars>n.data.text.length?(0,$.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-ink-3`,children:_(`project.textCut`,{shown:n.data.text.length.toLocaleString(),total:n.data.chars.toLocaleString()})}):null]}):(0,$.jsx)(`p`,{className:`py-8 text-center text-[0.875rem] text-ink-3`,children:_(`project.noText`)})}var xt=[`text`,`longtext`,`number`,`date`,`url`,`email`,`phone`,`boolean`],St=/^(\d{4}-\d{2}-\d{2}|\d{1,2}\.\s?\d{1,2}\.\s?\d{4})$/,Ct=/^[+-]?\d{1,3}([.,\s']?\d{3})*([.,]\d+)?$/,wt=/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/,Tt=/^(https?:\/\/|www\.)\S+$/i,Et=/^\+?[\d\s()/.-]{7,20}$/,Dt=/^(ja|nein|yes|no|true|false)$/i;function Ot(e){let t=e.trim();return t?t.includes(`
2
+ `)||t.length>140?`longtext`:Dt.test(t)?`boolean`:wt.test(t)?`email`:Tt.test(t)?`url`:St.test(t)?`date`:Ct.test(t)&&!/^(\+|0\d)/.test(t)?`number`:Et.test(t)&&t.replace(/\D/g,``).length>=7?`phone`:`text`:`text`}function kt(e,t=[]){let n=e.toLowerCase().replace(/ä/g,`ae`).replace(/ö/g,`oe`).replace(/ü/g,`ue`).replace(/ß/g,`ss`).normalize(`NFD`).replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``).slice(0,40)||`fakt`,r=n;for(let e=2;t.includes(r);e++)r=`${n}_${e}`;return r}var At=[{key:`adresse`,de:`Adresse`,en:`Address`},{key:`plz`,de:`PLZ`,en:`Postcode`},{key:`ort`,de:`Ort`,en:`City`},{key:`uid`,de:`UID`,en:`VAT id`},{key:`telefon`,de:`Telefon`,en:`Phone`},{key:`e_mail`,de:`E-Mail`,en:`Email`},{key:`website`,de:`Website`,en:`Website`},{key:`iban`,de:`IBAN`,en:`IBAN`}],jt={facts:100,colors:12,files:{logo:8,asset:100,document:2e3},bytes:{logo:5e6,asset:15e6,video:8e7,document:3e7}},Mt=/^#[0-9a-fA-F]{6}$/;function Nt({onAdd:e,onClose:t}){let[n,r]=(0,Q.useState)(`#e0531b`),[i,a]=(0,Q.useState)(``),o=Mt.test(n);return(0,$.jsx)(C,{open:!0,onClose:t,title:_(`project.colorAddTitle`),children:(0,$.jsxs)(`form`,{onSubmit:r=>{r.preventDefault(),o&&(e({name:i.trim(),value:n.toLowerCase()}),t())},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(T,{children:_(`project.colorValue`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(ee,{value:o?n:`#888888`,onChange:e=>r(e.target.value)}),(0,$.jsx)(w,{value:n,placeholder:`#e0531b`,spellCheck:!1,onChange:e=>r(e.target.value.trim()),className:`font-mono text-[0.875rem]`})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(T,{children:_(`project.colorUseLabel`)}),(0,$.jsx)(w,{autoFocus:!0,value:i,maxLength:120,placeholder:_(`project.colorName`),onChange:e=>a(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:_(`project.colorUse`)})]}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(x,{variant:`ghost`,onClick:t,children:_(`common.cancel`)}),(0,$.jsx)(x,{type:`submit`,disabled:!o,children:_(`project.add`)})]})]})})}function Pt({colors:e,save:t,readOnly:n}){let r=(0,Q.useRef)(0),[i,a]=(0,Q.useState)(()=>e.map(e=>({...e,id:`c${r.current++}`}))),[o,s]=(0,Q.useState)(!1),c=J(i.filter(e=>Mt.test(e.value)).map(({name:e,value:t})=>({name:e.trim(),value:t})),t),l=(e,t)=>a(n=>n.map(n=>n.id===e?{...n,...t}:n));return(0,$.jsxs)(Y,{title:_(`project.colors`),hint:_(`project.colorsHint`),save:c,locked:n,children:[(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:i.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(ee,{value:Mt.test(e.value)?e.value:`#888888`,onChange:t=>l(e.id,{value:t.target.value})}),(0,$.jsx)(w,{value:e.name,placeholder:_(`project.colorName`),maxLength:120,onChange:t=>l(e.id,{name:t.target.value}),className:`min-w-0 flex-1`}),(0,$.jsx)(w,{value:e.value,placeholder:`#e0531b`,spellCheck:!1,onChange:t=>l(e.id,{value:t.target.value.trim()}),className:`w-28 font-mono text-[0.8125rem]`}),(0,$.jsxs)(`div`,{className:`flex w-24 shrink-0 items-center justify-end max-sm:w-auto`,children:[t===0?(0,$.jsx)(`span`,{className:`mr-1 max-sm:hidden`,children:(0,$.jsx)(j,{tone:`ember`,children:_(`project.colorAccent`)})}):n?null:(0,$.jsx)(N,{label:_(`project.colorFirst`),onClick:()=>a(t=>[e,...t.filter(t=>t.id!==e.id)]),children:(0,$.jsx)(k,{className:`size-4`})}),n?null:(0,$.jsx)(N,{label:_(`project.remove`),onClick:()=>a(t=>t.filter(t=>t.id!==e.id)),className:`hover:text-rose`,children:(0,$.jsx)(O,{className:`size-4`})})]})]},e.id))}),i.length&&!n?(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:_(`project.colorUse`)}):null,i.length<jt.colors&&!n?(0,$.jsxs)(x,{variant:`secondary`,size:`sm`,className:i.length?`mt-3`:void 0,onClick:()=>s(!0),children:[(0,$.jsx)(p,{className:`size-4`}),` `,_(`project.colorAdd`)]}):null,o?(0,$.jsx)(Nt,{onClose:()=>s(!1),onAdd:e=>a(t=>[...t,{...e,id:`c${r.current++}`}])}):null]})}var Ft=e=>/^(ja|yes|true)$/i.test(e.trim()),It={text:u,longtext:G,number:R,date:V,url:v,email:Pe,phone:U,boolean:H};function Lt({type:e,detected:t,onChange:n}){let[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(!1),c=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(!r)return;let e=e=>{c.current?.contains(e.target)||i(!1)},t=e=>e.key===`Escape`&&i(!1);return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[r]);let l=It[e??t],u=`${_(`project.factType`)}: ${_(`project.type.${e??t}`)}`,d=`flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-[0.875rem] text-ink-2 hover:bg-accent hover:text-ink`,f=e=>{n(e),i(!1)};return(0,$.jsxs)(`div`,{className:`relative`,ref:c,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":u,title:u,"aria-haspopup":`menu`,"aria-expanded":r,onClick:e=>{o(window.innerHeight-e.currentTarget.getBoundingClientRect().bottom<400),i(e=>!e)},className:I(`inline-flex size-11 items-center justify-center rounded-lg transition hover:bg-accent hover:text-ink`,r?`bg-accent text-ink`:e?`text-ink-2`:`text-ink-4`),children:(0,$.jsx)(l,{className:`size-4`})}),r?(0,$.jsxs)(`div`,{role:`menu`,className:I(`absolute right-0 z-50 w-56 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,a?`bottom-12`:`top-12`),children:[(0,$.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":!e,className:d,onClick:()=>f(void 0),children:[(0,$.jsx)(s,{className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1`,children:_(`project.factAuto`)}),(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:_(`project.type.${t}`)}),(0,$.jsx)(te,{className:I(`size-4 shrink-0`,e&&`invisible`)})]}),(0,$.jsx)(`div`,{className:`mx-2 my-1 h-px bg-border-soft`}),xt.map(t=>{let n=It[t];return(0,$.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e===t,className:d,onClick:()=>f(t),children:[(0,$.jsx)(n,{className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1`,children:_(`project.type.${t}`)}),(0,$.jsx)(te,{className:I(`size-4 shrink-0`,e!==t&&`invisible`)})]},t)})]}):null]})}function Rt({facts:e,save:t,readOnly:n}){let r=(0,Q.useRef)(0),i=(0,Q.useRef)(null),[a,o]=(0,Q.useState)(()=>e.map(e=>({...e,id:`f${r.current++}`}))),s=J(a.filter(e=>e.key&&e.label.trim()).map(({key:e,label:t,value:n,type:r})=>({key:e,label:t.trim(),value:n,...r?{type:r}:{}})),t),c=(e,t)=>o(n=>n.map(n=>n.id===e?{...n,...t}:n)),l=(e,t,n=!1)=>{let a=`f${r.current++}`;i.current=`${a}:${t}`;let s={id:a,key:``,label:``,value:``,...e};o(e=>n?[s,...e]:[...e,s])},u=e=>t=>{t&&i.current===e&&(i.current=null,t.focus())},d=At.filter(e=>!a.some(t=>t.key===e.key));return(0,$.jsxs)(Y,{title:_(`project.facts`),hint:_(`project.factsHint`),save:s,locked:n,action:a.length<jt.facts&&!n?(0,$.jsxs)(x,{variant:`secondary`,size:`sm`,onClick:()=>l({},`label`,!0),children:[(0,$.jsx)(p,{className:`size-4`}),` `,_(`project.factAdd`)]}):null,children:[(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:a.map(e=>{let t=Ot(e.value),r=e.type??t;return(0,$.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto_auto] items-start gap-x-1 gap-y-2 sm:grid-cols-[minmax(0,2fr)_minmax(0,3fr)_auto_auto]`,children:[(0,$.jsx)(w,{ref:u(`${e.id}:label`),value:e.label,placeholder:_(`project.factLabel`),title:e.key?`{{facts.${e.key}}}`:void 0,onChange:t=>c(e.id,{label:t.target.value}),onBlur:()=>{!e.key&&e.label.trim()&&c(e.id,{key:kt(e.label,a.map(e=>e.key))})},className:`max-sm:col-span-3 max-sm:font-medium sm:mr-1`}),e.type===`boolean`?(0,$.jsxs)(`div`,{className:`flex h-11 items-center gap-3`,children:[(0,$.jsx)(P,{checked:Ft(e.value),label:e.label,onChange:t=>c(e.id,{value:_(t?`project.yes`:`project.no`)})}),(0,$.jsx)(`span`,{className:`text-[0.875rem] text-ink-2`,children:Ft(e.value)?_(`project.yes`):_(`project.no`)})]}):(0,$.jsx)(S,{ref:u(`${e.id}:value`),rows:1,minRows:r===`longtext`?2:1,maxRows:10,value:e.value,placeholder:_(`project.factValue`),onChange:t=>c(e.id,{value:t.target.value}),className:`min-h-11`}),(0,$.jsx)(Lt,{type:e.type,detected:t,onChange:t=>c(e.id,{type:t})}),n?null:(0,$.jsx)(N,{label:_(`project.remove`),onClick:()=>o(t=>t.filter(t=>t.id!==e.id)),className:`size-11 rounded-lg hover:text-rose`,children:(0,$.jsx)(O,{className:`size-4`})})]},e.id)})}),a.length<jt.facts&&!n?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${a.length?`mt-4`:``}`,children:[(0,$.jsxs)(x,{variant:`secondary`,size:`sm`,onClick:()=>l({},`label`),children:[(0,$.jsx)(p,{className:`size-4`}),` `,_(`project.factAdd`)]}),d.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>l({key:e.key,label:f===`en`?e.en:e.de},`value`),className:`inline-flex h-8 items-center gap-1 rounded-full bg-paper-2 px-3 text-[0.8125rem] text-ink-2 transition hover:bg-paper-3 hover:text-ink`,children:[(0,$.jsx)(p,{className:`size-3.5`}),` `,f===`en`?e.en:e.de]},e.key))]}):null]})}function zt({project:e,save:t}){let[n,r]=(0,Q.useState)(e.brand.name??``),[i,a]=(0,Q.useState)(e.brand.about??``),o=J({name:n.trim(),about:i.trim()},e=>t({brand:e}));return(0,$.jsx)(Y,{title:_(`project.base`),hint:_(`project.baseHint`),save:o,locked:e.readOnly,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(T,{children:_(`project.title`)}),(0,$.jsx)(w,{value:n,maxLength:120,onChange:e=>r(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:_(`project.titleHint`)})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(T,{children:_(`project.about`)}),(0,$.jsx)(S,{minRows:4,value:i,onChange:e=>a(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:_(`project.aboutHint`)})]})]})})}function Bt({project:e,group:t,children:n}){let i=r(),a=je(e.id),[o,s]=(0,Q.useState)(0),c=async t=>{await b.patch(`/api/studio/projects/${e.id}`,t),await i.invalidateQueries({queryKey:[`projects`]})},l=d({mutationFn:()=>b.del(`/api/studio/projects/${e.id}`),onSuccess:()=>i.invalidateQueries({queryKey:[`projects`]})}),u=we(),f=q(),p=a.data??{files:[],embeddings:!0},m=`${e.id}:${o}`,h=e.readOnly,g=t===`knowledge`;return Me(h?{}:{title:_(g?`project.assistantTitleKnowledge`:`project.assistantTitle`),hello:_(g?`project.assistantHelloKnowledge`:`project.assistantHello`),placeholder:_(g?`project.assistantComposerKnowledge`:`project.assistantComposer`),suggestions:g?[{label:_(`assistant.suggest.knowledgeHow`)},{label:_(`assistant.suggest.knowledgeSite`),fill:!0},{label:_(`assistant.suggest.knowledgeCategories`)}]:[{label:_(`assistant.suggest.readSite`),fill:!0},{label:_(`assistant.suggest.missing`)},{label:_(`assistant.suggest.facts`)}],summary:g?void 0:[e.brand.name?`title "${e.brand.name}"`:`no title`,`${e.facts.length} facts`,`${e.brand.colors?.length??0} colours`,`${p.files.filter(e=>e.kind===`logo`).length} logos`].join(` · `),onChanged:()=>s(e=>e+1)}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[h?(0,$.jsx)(K,{children:Se(e)}):null,t===`info`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(X,{id:`base`,children:(0,$.jsx)(zt,{project:e,save:c},`base:${m}`)}),(0,$.jsx)(X,{id:`logos`,children:(0,$.jsx)(ut,{projectId:e.id,data:p,readOnly:h})}),(0,$.jsx)(X,{id:`colors`,children:(0,$.jsx)(Pt,{colors:e.brand.colors??[],save:e=>c({brand:{colors:e}}),readOnly:h},`colors:${m}`)}),(0,$.jsx)(X,{id:`assets`,children:(0,$.jsx)(mt,{projectId:e.id,data:p,readOnly:h})}),(0,$.jsx)(X,{id:`facts`,children:(0,$.jsx)(Rt,{facts:e.facts,save:e=>c({facts:e}),readOnly:h},`facts:${m}`)})]}):null,n,t===`info`&&u&&!h&&f?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(x,{variant:`danger`,busy:l.isPending,onClick:()=>confirm(`${_(`settings.delete`)}?`)&&l.mutate(),children:_(`settings.delete`)}),l.error?(0,$.jsx)(`p`,{className:`mt-2 text-[0.875rem] text-rose`,children:l.error.message}):null]}):null]})}var Vt={q:``,mode:``,days:0};function Ht(e,t,n){let r=new URLSearchParams;t&&r.set(`wizard`,t),n.q.trim()&&r.set(`q`,n.q.trim()),n.mode&&r.set(`mode`,n.mode),n.days&&r.set(`days`,String(n.days));let a=r.toString();return i({queryKey:[`results`,e,a],queryFn:()=>b.get(`/api/studio/projects/${e}/results${a&&`?${a}`}`),enabled:!!e,placeholderData:e=>e,refetchInterval:15e3})}function Ut({filter:e,onFilter:t}){let[n,r]=(0,Q.useState)(e.q);return(0,Q.useEffect)(()=>{if(n===e.q)return;let r=setTimeout(()=>t({...e,q:n}),250);return()=>clearTimeout(r)},[n,e,t]),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsxs)(`div`,{className:`relative min-w-0 flex-1 basis-56`,children:[(0,$.jsx)(l,{className:`-translate-y-1/2 pointer-events-none absolute top-1/2 left-3 size-4 text-ink-3`}),(0,$.jsx)(w,{type:`search`,value:n,onChange:e=>r(e.target.value),placeholder:_(`space.resultsSearch`),"aria-label":_(`space.resultsSearch`),className:`w-full pl-9`})]}),(0,$.jsx)(D,{value:e.mode,onChange:n=>t({...e,mode:n}),options:[{value:``,label:_(`space.resultsModeAll`)},{value:`live`,label:`Live`},{value:`test`,label:`Test`}],className:`w-32`}),(0,$.jsx)(D,{value:String(e.days),onChange:n=>t({...e,days:Number(n)}),options:[{value:`0`,label:_(`space.resultsAnyTime`)},{value:`1`,label:_(`space.resultsDay`)},{value:`7`,label:_(`space.resultsDays`,{n:7})},{value:`30`,label:_(`space.resultsDays`,{n:30})}],className:`w-44`})]})}function Wt({data:e,wizardId:t,filter:n,onFilter:r}){let[i,a]=(0,Q.useState)(null),o=t=>e.wizards.find(e=>e.id===t)?.title??``,s=new Intl.DateTimeFormat(f,{dateStyle:`medium`,timeStyle:`short`});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Y,{title:t?o(t):_(`space.resultsAll`),hint:_(`space.resultsHint`),plain:!0,children:[(0,$.jsx)(Ut,{filter:n,onFilter:r}),e.runs.length?(0,$.jsx)(A,{className:`flex flex-col p-1.5`,children:e.runs.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>a(e),className:`flex items-center gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`truncate text-[0.875rem]`,children:t?s.format(new Date(e.doneAt)):o(e.wizardId)}),(0,$.jsxs)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:[t?null:`${s.format(new Date(e.doneAt))} · `,_(`space.resultCredits`,{n:e.credits})]})]}),e.assets?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[0.75rem] text-ink-3 tabular-nums`,title:_(`space.resultFiles`,{n:e.assets}),children:[(0,$.jsx)(L,{className:`size-3.5`}),e.assets]}):null,e.mode===`test`?(0,$.jsx)(j,{children:`Test`}):(0,$.jsxs)(j,{tone:`live`,children:[`Live v`,e.version]})]},e.id))}):(0,$.jsx)(A,{children:(0,$.jsx)(ie,{children:n.q.trim()||n.mode||n.days?_(`space.resultsNone`):_(`space.resultsEmpty`)})})]}),i?(0,$.jsx)(B,{header:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-[0.875rem]`,children:o(i.wizardId)}),i.mode===`test`?(0,$.jsx)(j,{children:`Test`}):(0,$.jsxs)(j,{tone:`live`,children:[`Live v`,i.version]})]}),onClose:()=>a(null),children:(0,$.jsx)(W,{runId:i.id,compact:!0},i.id)}):null]})}function Gt({project:e,save:t}){let[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(e.name),o=d({mutationFn:()=>t({name:i.trim()}),onSuccess:()=>r(!1)});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(N,{label:_(`project.rename`),onClick:()=>{a(e.name),r(!0)},children:(0,$.jsx)(m,{className:`size-4`})}),(0,$.jsx)(C,{open:n,onClose:()=>r(!1),title:_(`project.rename`),children:(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),i.trim()&&o.mutate()},children:[(0,$.jsx)(w,{"data-autofocus":!0,value:i,maxLength:80,onChange:e=>a(e.target.value)}),o.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:o.error.message}):null,(0,$.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,$.jsx)(x,{variant:`ghost`,onClick:()=>r(!1),children:_(`common.cancel`)}),(0,$.jsx)(x,{type:`submit`,busy:o.isPending,disabled:!i.trim(),children:_(`settings.save`)})]})]})})]})}function Kt({project:e}){let t=r();return(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(Ge,{}),e.readOnly?null:(0,$.jsx)(Gt,{project:e,save:async n=>{await b.patch(`/api/studio/projects/${e.id}`,n),await t.invalidateQueries({queryKey:[`projects`]})}})]})}function qt(e){let t=e.join(` `),[n,r]=(0,Q.useState)(e[0]);return(0,Q.useEffect)(()=>{let e=t.split(` `),n=0,i=()=>{n=0;let t=Le(),i=t.scrollTop>0&&t.clientHeight+t.scrollTop>=t.scrollHeight-4,a=(t===document.documentElement?0:t.getBoundingClientRect().top)+Math.max(120,t.clientHeight/3),o=e[0];for(let t of e){let e=document.getElementById(t)?.getBoundingClientRect().top;e!==void 0&&e<=a&&(o=t)}r(i?e.at(-1):o)},a=()=>{n||=requestAnimationFrame(i)};return i(),window.addEventListener(`scroll`,a,{passive:!0,capture:!0}),window.addEventListener(`resize`,a),()=>{cancelAnimationFrame(n),window.removeEventListener(`scroll`,a,{capture:!0}),window.removeEventListener(`resize`,a)}},[t]),n}function Jt(e,t){let n=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;document.getElementById(e)?.scrollIntoView({block:`start`,behavior:t&&!n?`smooth`:`auto`})}function Yt({groups:e,current:t,onPick:n}){return e.map(e=>{let r=e.sections.map(e=>(0,$.jsx)(Z,{icon:e.icon??c,label:e.label,selected:e.id===t,onPick:()=>n(e.id)},e.id));return e.label?(0,$.jsx)(Je,{label:e.label,children:r},e.plugin):(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:r},`own`)})}function Xt(){let{group:e}=re(),[t,n]=ne(),r=ae(),i=se(),{hash:a}=i,{project:o,loading:c}=Te(),l=we(),u=Be(),d=et(),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(null),[g,v]=(0,Q.useState)(null),y=Fe(e)?e:void 0,ee=i.state?.parts===!0,b=He().map(e=>({...e,to:`/space/${e.id}`})),x=b.find(e=>e.id===y),S=t.get(`show`),C=y?S?2:1:0,w=d?Math.min(C,1):y&&g!==y&&!ee?1:0,te=qe(w),T=qe(C),E=(0,Q.useMemo)(()=>({slot:f,narrow:d,setDetail:h}),[f,d]),D=o?o.brand.name?.trim()||o.name:_(`nav.project`),O=y&&y!==`results`?Ie(y,u):[],k=y?Ie(y,u).filter(e=>e.plugin):[],oe=qt([...O,...y===`results`?k:[]].flatMap(e=>e.sections.map(e=>e.id))),A=y===`results`&&S&&S!==`all`?S:null,[j,N]=(0,Q.useState)(Vt),P=Ht(y===`results`?o?.id:void 0,A,j),F=P.data?.wizards.find(e=>e.id===A)?.title,L=y===`data`&&S&&S!==`all`||y===`knowledge`&&S&&/^[ptfcvs]:/.test(S)?S:null,R=L?.startsWith(`s:`)?u.spaceSections.find(e=>e.id===L.slice(2)):void 0,z=y===`knowledge`&&L&&/^[ptf]:/.test(L)?L:null,B=ue(y===`data`?o?.id:void 0),V=ge(y===`knowledge`?o?.id:void 0),H=xe(L?.startsWith(`v:`)?L.slice(2):``),U=V.data?.categories.find(e=>e.id===(L?.startsWith(`c:`)?L.slice(2):H.data?.category.id)),W=y===`knowledge`?R?R.label():L?.startsWith(`v:`)?H.data&&`${H.data.category.name}: ${H.data.value}`:L?.startsWith(`c:`)?U?.name:V.data?.items.find(e=>e.key===L)?.title:B.data?ye(B.data).flatMap(e=>e.items).find(e=>e.key===L)?.title:void 0;Ne([{label:_(`nav.project`),to:`/space`},...x?[{label:x.label,to:`/space/${x.id}`}]:[],...x&&(m??F??W)?[{label:m??F??W}]:[]]);let Se={p:`page`,t:`table`,f:`file`,c:`kategorie`,v:`kategorie value`,s:`plugin section`};Me({...y===`data`||y===`results`?{compact:!0}:{},...y===`data`?{suggestions:[{label:_(`assistant.suggest.dataWhat`)},{label:_(`assistant.suggest.dataWho`)},{label:_(`assistant.suggest.dataEdit`)}]}:y===`results`?{suggestions:[{label:_(`assistant.suggest.resultsFailed`)},{label:_(`assistant.suggest.resultsCost`)},{label:_(`assistant.suggest.resultsShare`)}]}:{},...L&&W?{open:{kind:Se[L[0]]??`item`,id:L.slice(2),label:W}}:A&&F?{open:{kind:`wizard`,id:A,label:F}}:{}});let G=y===`results`||y===`data`||L?a.slice(1):S||a.slice(1),K=(0,Q.useRef)(``);if((0,Q.useEffect)(()=>{let e=`${y}#${G}`;G&&K.current!==e&&document.getElementById(G)&&(K.current=e,requestAnimationFrame(()=>Jt(G,!1)))},[y,G,o?.id,u.spaceSections]),!y){let t=a.slice(1),n=t?We(t,u):null;if(n===`knowledge`&&u.spaceSections.some(e=>e.id===t))return(0,$.jsx)(M,{to:`/space/knowledge?show=s:${t}`,replace:!0});if(n)return(0,$.jsx)(M,{to:d?`/space/${n}?show=${t}`:{pathname:`/space/${n}`,hash:t},replace:!0});if(t&&u.status!==`ready`)return null;if(e!==void 0||!d)return(0,$.jsx)(M,{to:`/space/info`,replace:!0,state:{parts:!0}})}if(y===`knowledge`&&!S&&u.spaceSections.some(e=>e.id===a.slice(1)))return(0,$.jsx)(M,{to:`/space/knowledge?show=s:${a.slice(1)}`,replace:!0});let Ce=e=>{if(d){r({search:`?show=${e}`});return}K.current=`${y}#${e}`,Jt(e,!0),r({search:``,hash:e},{replace:!0})},q=e=>d?n({show:e}):n(e===`all`?{}:{show:e},{replace:!0}),Ee=e=>e.flatMap(e=>e.sections).map(e=>u.spaceSections.find(t=>t.id===e.id)).filter(e=>e!==void 0).map(e=>(0,$.jsx)(X,{id:e.id,children:(0,$.jsx)(Y,{title:e.label(),hint:e.hint?.(),plain:!0,children:(0,$.jsx)(Ue,{of:e,children:(0,$.jsx)(e.component,{})})})},e.serial)),J=d?void 0:oe;return(0,$.jsx)(Xe.Provider,{value:E,children:(0,$.jsx)(`div`,{className:`animate-rise`,children:(0,$.jsxs)(`div`,{className:`grid gap-6 md:grid-cols-[13.5rem_minmax(0,1fr)] md:gap-8 lg:grid-cols-[15rem_minmax(0,1fr)] lg:gap-10`,children:[(0,$.jsxs)(`aside`,{className:I(`min-w-0 md:sticky md:top-6 md:self-start`,d&&C===2&&`hidden`,d&&T===`back`&&Ke(`back`)),children:[(0,$.jsx)(Ye,{title:D,open:w===1?x??null:null,onBack:()=>d?r(`/space`):v(y??null)}),(0,$.jsx)(`div`,{className:I(Ke(te)),children:w===0?(0,$.jsx)(Ze,{entries:b,current:d?void 0:x,onPick:()=>v(null)}):(0,$.jsx)(`div`,{ref:p})},w)]}),y?(0,$.jsxs)(`div`,{className:I(`min-w-0`,d&&C<2&&`hidden`,d&&T===`deeper`&&Ke(`deeper`)),children:[d?(0,$.jsx)(`div`,{className:`mb-3`,children:(0,$.jsx)($e,{label:x?.label??D,onBack:()=>r(`/space/${y}`)})}):null,l&&o?(0,$.jsx)(`div`,{className:`mb-6`,children:(0,$.jsx)(Kt,{project:o})}):null,y===`results`?(0,$.jsxs)(Qe,{children:[(0,$.jsxs)(`ul`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsx)(Z,{icon:nt,label:_(`space.resultsAll`),selected:!d&&!A,onPick:()=>q(`all`)}),P.data?.wizards.filter(e=>e.results||e.id===A).map(e=>(0,$.jsx)(Z,{icon:s,label:e.title,badge:e.results?(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:e.results}):null,selected:!d&&e.id===A,onPick:()=>q(e.id)},e.id))]}),(0,$.jsx)(Yt,{groups:k,current:J,onPick:Ce})]}):y===`data`?(0,$.jsxs)(Qe,{children:[(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,$.jsx)(Z,{icon:Ve,label:_(`data.all`),selected:!d&&!L,onPick:()=>q(`all`)})}),B.data?ye(B.data).map(e=>(0,$.jsx)(Je,{label:e.label,children:e.items.map(e=>(0,$.jsx)(Z,{icon:le[e.kind],label:e.title,selected:!d&&e.key===L,onPick:()=>q(e.key)},e.key))},e.key)):null,(0,$.jsx)(Yt,{groups:k,current:J,onPick:Ce})]}):y===`knowledge`?(0,$.jsxs)(Qe,{children:[(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,$.jsx)(Z,{icon:Ve,label:_(`know.all`),selected:!(d||L),onPick:()=>q(`all`)})}),V.data?.categories.length?(0,$.jsx)(Je,{label:_(`know.categories`),children:V.data.categories.map(e=>(0,$.jsx)(Z,{icon:pe[e.type],label:e.name,badge:(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:e.proposed?`·`:e.count}),selected:!d&&(L===`c:${e.id}`||H.data?.category.id===e.id),onPick:()=>q(`c:${e.id}`)},e.id))}):null,(0,$.jsx)(Yt,{groups:k,current:d?void 0:R?.id,onPick:e=>q(`s:${e}`)})]}):(0,$.jsx)(Qe,{children:(0,$.jsx)(Yt,{groups:O,current:J,onPick:Ce})}),o&&(y===`info`||y===`knowledge`)?(0,$.jsxs)(Bt,{project:o,group:y,children:[y===`knowledge`?z?z.startsWith(`p:`)?(0,$.jsx)(he,{pageId:z.slice(2),onGone:()=>q(`all`),onOpen:q},z):z.startsWith(`t:`)?(0,$.jsx)(me,{tableId:z.slice(2),onGone:()=>q(`all`)},z):(0,$.jsx)(yt,{projectId:o.id,fileId:z.slice(2),readOnly:o.readOnly,onGone:()=>q(`all`)},z):V.data?R?(0,$.jsx)(Y,{title:R.label(),hint:R.hint?.(),plain:!0,children:(0,$.jsx)(Ue,{of:R,children:(0,$.jsx)(R.component,{})})},L):L?.startsWith(`c:`)?U?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(fe,{projectId:o.id,category:U,readOnly:o.readOnly,onOpen:q,onGone:()=>q(`all`)}),U.type===`choice`?null:(0,$.jsx)(be,{projectId:o.id,category:U,categories:V.data.categories,onOpen:q})]},L):null:L?.startsWith(`v:`)?H.data?(0,$.jsx)(ce,{value:H.data,readOnly:o.readOnly,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[H.data.items.length?(0,$.jsx)(`div`,{className:`flex flex-col rounded-xl bg-card p-1.5 shadow-soft ring-1 ring-border-soft`,children:H.data.items.map(e=>(0,$.jsx)(de,{item:e,categories:V.data.categories.filter(e=>e.id!==H.data?.category.id),onOpen:q},e.key))}):null,H.data.rows.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>q(`t:${e.tableId}`),className:`px-1 text-left text-[0.8125rem] text-ink-3 hover:text-ink`,children:_(`know.tocRows`,{n:e.count,table:e.title})},e.tableId))]})},L):null:(0,$.jsx)(X,{id:`documents`,children:(0,$.jsx)(ve,{projectId:o.id,data:V.data,readOnly:o.readOnly,onOpen:q})}):null:null,y===`info`?Ee(k):null]},o.id):null,o&&y===`data`?(0,$.jsx)(`div`,{className:`flex flex-col gap-9 pb-20`,children:L?.startsWith(`t:`)?(0,$.jsx)(me,{tableId:L.slice(2),onGone:()=>q(`all`)},L):L?.startsWith(`p:`)?(0,$.jsx)(he,{pageId:L.slice(2),onGone:()=>q(`all`)},L):(0,$.jsxs)($.Fragment,{children:[B.data?(0,$.jsx)(_e,{projectId:o.id,data:B.data,readOnly:o.readOnly,onOpen:q}):null,Ee(k)]})}):null,o&&y===`results`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[P.data?(0,$.jsx)(Wt,{data:P.data,wizardId:A,filter:j,onFilter:N}):null,P.isError?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:P.error.message}):null,Ee(k)]}):null,o||c?null:(0,$.jsx)(ie,{children:_(`settings.noProject`)})]}):null]})})})}export{Xt as ProjectPage};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{r}from"./logo-C4V2_3Ar.js";import{Dt as i,Tt as a,a as o,at as s,gt as c,hn as l,it as u,l as d,m as f,mn as p,on as m,rn as h,un as g,ut as _,xt as v}from"./ui-aWLrX8hF.js";import{a as y,i as b,n as x,o as S,r as C,s as w,t as T}from"./ChatView--IperikB.js";import{c as ee,i as E,r as D,t as O}from"./brand-cgisQRwA.js";import{t as k}from"./RunnerView-EpmDp2lS.js";import{a as A,n as j,o as te}from"./index-DIF70pQf.js";var M={name:`bookmark`,size:24,node:[[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}]]};M.node;var N=m(M),P={name:`smartphone`,size:24,node:[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]};P.node;var F=m(P),I={name:`square-plus`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}],[`path`,{d:`M12 8v8`,key:`napkw2`}]],aliases:[`plus-square`]};I.node;var L=m(I),R=e(t(),1);function z(){if(window.self===window.top)return null;let e=new URLSearchParams(window.location.search).get(`embed`);return e===`inline`||e===`modal`||e===`popout`?e:null}var B=z(),V=B?new URLSearchParams(window.location.search).get(`page`):null,H=(e,t={})=>window.parent.postMessage({type:`engenty-wizard:${e}`,...t},`*`),U=()=>H(`close`);function ne(e){(0,R.useEffect)(()=>{if(B===`inline`&&!e){let e=document.documentElement;document.getElementById(`root`)?.style.setProperty(`min-height`,`0`),e.style.overflow=`hidden`;let t=new ResizeObserver(()=>H(`height`,{height:Math.ceil(e.getBoundingClientRect().height)}));return t.observe(e),()=>t.disconnect()}if(B===`modal`||B===`popout`){let e=e=>{e.key===`Escape`&&!document.querySelector(`dialog[open]`)&&H(`close`)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}},[e])}var W=e(n(),1);function G(e){(0,R.useEffect)(()=>{if(!e)return;let t=document.documentElement;return t.style.setProperty(`--raw-primary`,e),()=>{t.style.removeProperty(`--raw-primary`)}},[e])}function re(e,t){(0,R.useEffect)(()=>{if(!e||!t)return;let n=f(`/api/public/wizards/${e}`),r=[{rel:`manifest`,href:`${n}/manifest.webmanifest`},{rel:`apple-touch-icon`,href:`${n}/icons/apple-touch-icon.png`},{rel:`icon`,href:`${n}/icons/favicon.png`,type:`image/png`}].flatMap(({rel:e,href:t,type:n})=>{let r=document.querySelector(`link[rel="${e}"]`);if(!r)return[];let i={href:r.getAttribute(`href`),type:r.getAttribute(`type`)};return r.setAttribute(`href`,t),n&&r.setAttribute(`type`,n),[{link:r,before:i}]}),i=document.createElement(`meta`);return i.name=`apple-mobile-web-app-title`,i.content=t,document.head.appendChild(i),()=>{for(let{link:e,before:t}of r)for(let[n,r]of Object.entries(t))r===null?e.removeAttribute(n):e.setAttribute(n,r);i.remove()}},[e,t])}var K=/iPhone|iPad|iPod/.test(navigator.userAgent)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1,q=K||/Android/.test(navigator.userAgent);function ie(){let[e,t]=(0,R.useState)(()=>window.wizardInstall??null),[n,r]=(0,R.useState)(!1);if((0,R.useEffect)(()=>{let e=()=>t(window.wizardInstall??null);return window.addEventListener(`wizard-install`,e),()=>window.removeEventListener(`wizard-install`,e)},[]),window.matchMedia(`(display-mode: standalone)`).matches||navigator.standalone===!0||q&&!e&&!K)return null;let i=/Mac/.test(navigator.platform),o=a(q?`install.ios`:i?`install.bookmark.mac`:`install.bookmark.pc`);return(0,W.jsxs)(`div`,{className:`mt-6 flex flex-col items-center gap-2 text-[0.8125rem] text-ink-3`,children:[(0,W.jsxs)(`button`,{type:`button`,onClick:()=>{q&&e?(e.prompt(),window.wizardInstall=null,t(null)):r(e=>!e)},className:`inline-flex items-center gap-1.5 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:[q?(0,W.jsx)(L,{className:`size-4`}):(0,W.jsx)(N,{className:`size-4`}),a(q?`install.add`:`install.bookmark`)]}),n?(0,W.jsx)(`p`,{className:`max-w-xs leading-relaxed`,children:o}):null]})}function J({brand:e,toggle:t=!0}){return(0,W.jsx)(`header`,{className:`safe-top`,children:(0,W.jsxs)(`div`,{className:`relative flex h-14 items-center justify-center px-5`,children:[e.logoUrl?(0,W.jsx)(`img`,{src:f(e.logoUrl),alt:e.name,className:`h-7 max-w-[160px] object-contain`}):e.name?(0,W.jsx)(`span`,{className:`max-w-[60%] truncate font-display font-semibold text-[0.9375rem] text-ink-2 tracking-tight`,children:e.name}):null,t?(0,W.jsx)(`div`,{className:`absolute right-3`,children:(0,W.jsx)(E,{})}):null]})})}function Y({siteKey:e,onToken:t}){let n=(0,R.useRef)(null);return(0,R.useEffect)(()=>{let r=()=>{n.current&&window.turnstile&&!n.current.childElementCount&&window.turnstile.render(n.current,{sitekey:e,callback:t,appearance:`interaction-only`})};if(window.turnstile){r();return}let i=document.createElement(`script`);i.src=`https://challenges.cloudflare.com/turnstile/v0/api.js`,i.async=!0,i.onload=r,document.head.appendChild(i)},[e,t]),(0,W.jsx)(`div`,{ref:n,className:`mt-4 flex justify-center`})}function ae({token:e}){return!/iPhone|iPad|iPod|Android/.test(navigator.userAgent)||j||B?null:(0,W.jsxs)(`a`,{href:A(`${window.location.origin}${d}/w/${e}`),className:`mt-3 inline-flex items-center gap-1.5 text-[0.8125rem] text-ink-3 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:[(0,W.jsx)(F,{className:`size-4`}),` `,a(`install.app`)]})}var X=e=>`wz.run.${e}`,Z=j&&new URLSearchParams(window.location.search).get(`start`)===`1`,Q=B===`inline`?`min-h-80`:`min-h-dvh`;function $(e,t){let n=p(),[r,i]=(0,R.useState)(!1),[a,s]=(0,R.useState)(null),[c,l]=(0,R.useState)(null),u=(()=>{try{return localStorage.getItem(X(e.token))}catch{return null}})();return{busy:r,error:a,captcha:c,setCaptcha:l,start:async()=>{i(!0),s(null);try{let{runId:r}=await o.post(`/api/public/wizards/${e.token}/runs`,{turnstileToken:c??void 0,embedded:B!==null,origin:V??void 0});try{localStorage.setItem(X(e.token),r)}catch{}n(`${t}/${r}`,{replace:Z})}catch(e){s(e.message),i(!1)}},resume:u?()=>n(`${t}/${u}`):null}}function oe({wizard:e}){let{busy:t,error:n,captcha:r,setCaptcha:i,start:o,resume:l}=$(e,`/w/${e.token}`),u=Z&&e.available&&!e.turnstileSiteKey,d=(0,R.useRef)(!1);return(0,R.useEffect)(()=>{u&&!d.current&&(d.current=!0,o())},[u]),u&&!n?(0,W.jsx)(`div`,{className:`flex min-h-[60dvh] items-center justify-center text-ink-4`,children:(0,W.jsx)(c,{})}):(0,W.jsxs)(`div`,{className:`mx-auto flex max-w-lg animate-rise flex-col items-center px-6 pt-6 pb-12 text-center sm:pt-16 sm:pb-16`,children:[(0,W.jsx)(D,{kind:e.avatar,size:190,fluffy:!0}),(0,W.jsx)(`h1`,{className:`mt-2 text-balance font-display font-semibold text-[1.875rem] leading-[1.1] tracking-tight sm:text-[2.125rem]`,children:e.title}),e.description?(0,W.jsx)(`p`,{className:`mt-3 text-[1rem] text-ink-2 leading-relaxed`,children:e.description}):null,e.available?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(s,{size:`lg`,className:`mt-10 min-w-48`,busy:t,disabled:!!e.turnstileSiteKey&&!r,onClick:o,children:[a(`run.start`),` `,(0,W.jsx)(h,{className:`size-4`})]}),e.turnstileSiteKey?(0,W.jsx)(Y,{siteKey:e.turnstileSiteKey,onToken:i}):null,l?(0,W.jsx)(`button`,{type:`button`,onClick:l,className:`mt-4 text-[0.875rem] text-ink-3 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:a(`run.resume`)}):null,(0,W.jsx)(se,{wizard:e,current:`steps`}),B||j?null:(0,W.jsx)(ie,{}),(0,W.jsx)(ae,{token:e.token})]}):(0,W.jsx)(`p`,{className:`mt-10 rounded-xl bg-paper-2 px-5 py-4 text-[0.9375rem] text-ink-2`,children:e.unavailableReason??a(`run.unavailable`)}),n?(0,W.jsx)(`p`,{className:`mt-4 text-[0.875rem] text-rose`,children:n}):null]})}function se({wizard:e,current:t}){let n=e.runners.filter(e=>e.id!==t&&e.kind===`page`&&e.url);return n.length?(0,W.jsx)(`p`,{className:`mt-4 flex flex-wrap justify-center gap-x-4 text-[0.875rem] text-ink-3`,children:n.map(e=>(0,W.jsx)(`a`,{href:e.url??void 0,className:`underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:a(`run.orAs`,{label:e.label})},e.id))}):null}function ce({wizard:e}){let t=w();return(0,W.jsx)(`header`,{className:`safe-top shrink-0 border-border-soft border-b`,children:(0,W.jsxs)(`div`,{className:`mx-auto flex h-16 w-full max-w-[760px] items-center gap-3 pr-2 pl-4 sm:pr-4 sm:pl-6`,children:[(0,W.jsx)(`span`,{className:v(t?.speaking&&`animate-breathe`),children:(0,W.jsx)(D,{kind:e.avatar,size:38})}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`div`,{className:`truncate font-display font-semibold text-[1rem] leading-tight tracking-tight`,children:e.title}),e.brand.name?(0,W.jsx)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:e.brand.name}):null]}),e.brand.logoUrl&&B!==`popout`?(0,W.jsx)(`img`,{src:f(e.brand.logoUrl),alt:e.brand.name,className:`h-6 max-w-[120px] object-contain max-sm:hidden`}):null,B?null:(0,W.jsx)(E,{}),B===`popout`?(0,W.jsx)(_,{label:a(`common.close`),onClick:U,children:(0,W.jsx)(i,{className:`size-5`})}):null]})})}function le({door:e,wizard:t,header:n,footer:r}){let{busy:i,error:o,captcha:s,setCaptcha:c,start:l,resume:u}=$(t,`/w/${t.token}/${e}`),d=[{key:`hello`,who:`bot`,node:t.description||t.title}];return e!==`chat`&&d.push({key:e,who:`bot`,node:a(e===`video`?`video.hint`:`talk.joinHint`)}),t.available||d.push({key:`unavailable`,who:`bot`,node:t.unavailableReason??a(`run.unavailable`)}),o&&d.push({key:`error`,who:`bot`,node:o,tone:`error`}),t.available&&d.push(S(`start`,(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(b,{primary:!0,busy:i,disabled:!!t.turnstileSiteKey&&!s,onClick:()=>void l(),children:[a(`run.start`),` `,(0,W.jsx)(h,{className:`size-4`})]}),u?(0,W.jsx)(b,{onClick:u,children:a(`run.resume`)}):null,t.turnstileSiteKey?(0,W.jsx)(Y,{siteKey:t.turnstileSiteKey,onToken:c}):null]}))),(0,W.jsxs)(x,{header:n,footer:r,children:[(0,W.jsx)(y,{avatar:t.avatar,lines:d}),(0,W.jsx)(C,{})]})}function ue({className:e}){return(0,W.jsx)(`footer`,{className:v(`text-center text-ink-4`,e),children:(0,W.jsx)(`a`,{href:`${d}/`,target:B?`_blank`:void 0,rel:`noreferrer`,className:`inline-block hover:text-ink-2`,children:a(`run.madeWith`).replace(`engenty wizards`,O.name)})})}function de({chat:e=!1,steps:t=!1,talk:n=!1,video:i=!1}){let{token:f,runId:m}=l(),h=p(),_=r({queryKey:[`public`,f],queryFn:()=>o.get(`/api/public/wizards/${f}`),retry:(e,t)=>u(t)&&e<3}),y=_.data?.runners??[],b=!_.data||y.some(e=>e.id===`talk`),x=!_.data||y.some(e=>e.id===`video`),S=!_.data||y.some(e=>e.id===`chat`)||n&&b||i&&x,C=y[0]?.id,w=e||B===`popout`||!t&&!m&&S&&(C===`chat`||C===`talk`||C===`video`),E=i&&x||!t&&!e&&!n&&C===`video`,A=!E&&(n&&b||!t&&!e&&C===`talk`),M=E?`video`:A?`talk`:`chat`;if(G(_.data?.brand.accent),ee(_.data?.avatar),re(f,_.data?.title),ne(w),(0,R.useEffect)(()=>{_.data&&(document.title=_.data.title)},[_.data]),(0,R.useEffect)(()=>{f&&m&&te(`run`,{token:f,runId:m})},[f,m]),_.isLoading)return(0,W.jsx)(`div`,{className:v(`flex items-center justify-center text-ink-4`,Q),children:(0,W.jsx)(c,{})});if(e&&_.data&&!S||n&&_.data&&!b||i&&_.data&&!x)return(0,W.jsx)(g,{to:`/w/${f}`,replace:!0});if(!_.data){let e=u(_.error);return(0,W.jsxs)(`div`,{className:v(`flex flex-col items-center justify-center gap-4 px-6 text-center`,Q),children:[(0,W.jsx)(D,{kind:`pebble`,size:80}),(0,W.jsx)(`p`,{className:`max-w-xs text-ink-3`,children:a(e?`common.offline`:`run.notFound`)}),e?(0,W.jsx)(s,{variant:`secondary`,onClick:()=>void _.refetch(),children:a(`common.retry`)}):null]})}if(w){let e=(0,W.jsx)(ce,{wizard:_.data}),t=j?(0,W.jsx)(`div`,{className:`safe-bottom`}):(0,W.jsx)(ue,{className:`pb-[max(0.375rem,env(safe-area-inset-bottom))] text-[0.6875rem]`});return(0,W.jsx)(`div`,{className:`flex h-dvh flex-col`,children:m?(0,W.jsx)(T,{runId:m,talk:A,call:E?`video`:A?`audio`:!1,onRestart:()=>h(`/w/${f}/${M}`),header:E||A?void 0:e,footer:t}):(0,W.jsx)(le,{wizard:_.data,header:e,footer:t,door:M})})}return(0,W.jsxs)(`div`,{className:v(`flex flex-col`,Q),children:[B===`inline`||j?null:(0,W.jsx)(J,{brand:_.data.brand,toggle:!B}),(0,W.jsx)(`div`,{className:`flex-1`,children:m?(0,W.jsx)(k,{runId:m,onRestart:()=>h(`/w/${f}`)}):(0,W.jsx)(oe,{wizard:_.data})}),j?(0,W.jsx)(`div`,{className:`safe-bottom`}):(0,W.jsx)(`footer`,{className:`safe-bottom pt-6 text-center text-[0.75rem] text-ink-4`,children:(0,W.jsx)(`a`,{href:`${d}/`,target:B?`_blank`:void 0,rel:`noreferrer`,className:`inline-block py-3.5 hover:text-ink-2`,children:a(`run.madeWith`).replace(`engenty wizards`,O.name)})})]})}export{J as BrandHeader,de as PublicRunner,G as useBrandAccent};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./jsx-runtime-BNakU3Ej.js";import{Ct as n,in as r}from"./ui-SKtUMhUq.js";import{t as i}from"./lock-D5tH2Lqc.js";var a={name:`text-align-start`,size:24,node:[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M17 19H3`,key:`z6ezky`}]],aliases:[`text`,`align-left`]};a.node;var o=r(a),s=e(t(),1);function c(e){return n(e.origin===`local`?`readonly.project`:`readonly.server`)}function l({children:e}){return(0,s.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl bg-paper-2 px-4 py-3 text-[0.875rem] text-ink-2 leading-relaxed`,children:[(0,s.jsx)(i,{className:`mt-0.5 size-4 shrink-0 text-ink-3`}),(0,s.jsx)(`p`,{className:`min-w-0`,children:e})]})}export{c as n,o as r,l as t};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./jsx-runtime-BNakU3Ej.js";import{Tt as n,on as r}from"./ui-aWLrX8hF.js";import{t as i}from"./lock-BqMtfg3I.js";var a={name:`text-align-start`,size:24,node:[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M17 19H3`,key:`z6ezky`}]],aliases:[`text`,`align-left`]};a.node;var o=r(a),s=e(t(),1);function c(e){return n(e.origin===`local`?`readonly.project`:`readonly.server`)}function l({children:e}){return(0,s.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl bg-paper-2 px-4 py-3 text-[0.875rem] text-ink-2 leading-relaxed`,children:[(0,s.jsx)(i,{className:`mt-0.5 size-4 shrink-0 text-ink-3`}),(0,s.jsx)(`p`,{className:`min-w-0`,children:e})]})}export{c as n,o as r,l as t};
@@ -0,0 +1,4 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{O as r,r as i}from"./logo-C4V2_3Ar.js";import{d as a,u as o}from"./Marketplace-CuE6WgnO.js";import{t as s}from"./useMutation-DKyQXgyj.js";import{$t as c,Ct as l,Dt as u,Ft as d,Gt as f,Ht as p,Pt as m,Tt as h,Zt as g,a as _,at as v,bt as y,ct as b,dt as x,en as S,ft as C,gt as w,ht as T,kt as E,lt as D,mt as O,on as k,ot as A,rt as j,st as M,ut as N,vt as P,x as F,xt as I,zt as ee}from"./ui-aWLrX8hF.js";import{t as te}from"./upload-CNYeHI5s.js";import{F as ne,I as re,M as L,P as R,at as ie,j as ae,k as oe}from"./index-DIF70pQf.js";var se={name:`calendar`,size:24,node:[[`path`,{d:`M8 2v3`,key:`1ioesn`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}],[`path`,{d:`M3 9h18`,key:`1pudct`}]]};se.node;var z=k(se),ce={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`}]]};ce.node;var le=k(ce),ue={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`}]]};ue.node;var de=k(ue),B={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`}]]};B.node;var fe=k(B),V={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`}]]};V.node;var pe=k(V),H={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`}]]};H.node;var me=k(H),he={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`}]]};he.node;var ge=k(he),U=e(t(),1),W=e(n(),1),G={choice:me,date:z,number:de,text:o,boolean:ge},K=e=>[`knowledge`,e];function _e(e){return e===1?h(`know.item`):h(`know.items`,{n:e})}function q(e,t){if(e.type===`boolean`||typeof t==`boolean`)return h(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(l,{day:`2-digit`,month:`2-digit`,year:`numeric`});return n?`${i} ${n}`:i}return e.type===`number`&&typeof t==`number`?`${t.toLocaleString(l)}${e.unit?` ${e.unit}`:``}`:String(t)}function ve(e,t){return e.flatMap(e=>{let n=t.find(t=>t.categoryId===e.id);return n?e.type===`boolean`?n.values[0]===!0?[e.name]:[]:[n.values.map(t=>q(e,t)).join(`, `)]:[]}).join(` · `)}function ye({trigger:e,open:t,onOpen:n,children:r}){let i=(0,U.useRef)(null);return(0,U.useEffect)(()=>{if(!t)return;let e=e=>{i.current?.contains(e.target)||n(!1)},r=e=>e.key===`Escape`&&n(!1);return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,r),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,r)}},[t,n]),(0,W.jsxs)(`div`,{ref:i,className:`relative inline-flex`,children:[e,t?(0,W.jsx)(`div`,{className:`absolute top-full left-0 z-30 mt-1.5 w-72 max-w-[calc(100vw-32px)] rounded-xl bg-card p-3 shadow-overlay ring-1 ring-border-soft`,children:r}):null]})}function be({category:e,current:t,onSave:n}){let[r,i]=(0,U.useState)(t[0]===void 0?``:String(t[0]));if(e.type===`choice`){let a=t.map(String);return(0,W.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[e.values.length?(0,W.jsx)(O,{multi:!0,value:a,options:e.values.map(e=>e.value),onChange:t=>n(e.multiple?t:t.filter(e=>!a.includes(e)).slice(0,1))}):null,(0,W.jsxs)(`form`,{className:`flex gap-2`,onSubmit:t=>{t.preventDefault(),r.trim()&&n(e.multiple?[...a,r.trim()]:[r.trim()])},children:[(0,W.jsx)(x,{"data-autofocus":!0,value:a.includes(r)?``:r,placeholder:h(`know.addValue`),onChange:e=>i(e.target.value),className:`h-9`}),(0,W.jsx)(N,{label:h(`know.addValue`),type:`submit`,children:(0,W.jsx)(d,{className:`size-4`})})]})]})}return e.type===`boolean`?(0,W.jsx)(O,{value:t[0]===!0?h(`know.yes`):t[0]===!1?h(`know.no`):``,options:[h(`know.yes`),h(`know.no`)],onChange:e=>n([e===h(`know.yes`)])}):(0,W.jsxs)(`form`,{className:`flex gap-2`,onSubmit:t=>{t.preventDefault(),n(r.trim()?[e.type===`number`?Number(r.replace(`,`,`.`)):r.trim()]:[])},children:[(0,W.jsx)(x,{"data-autofocus":!0,type:e.type===`date`?`date`:e.type===`number`?`number`:`text`,step:`any`,value:e.type===`date`?r.slice(0,10):r,onChange:e=>i(e.target.value),className:`h-9`}),(0,W.jsx)(v,{type:`submit`,size:`sm`,children:`OK`})]})}function xe({projectId:e,itemKey:t,has:n,categories:i,readOnly:a}){let o=r(),[c,l]=(0,U.useState)(null),[f,p]=(0,U.useState)(n);(0,U.useEffect)(()=>p(n),[n]);let m=s({mutationFn:({categoryId:n,next:r})=>_.put(`/api/studio/projects/${e}/items/${t}/categories/${n}`,{values:r}),onSuccess:()=>o.invalidateQueries({queryKey:K(e)})}),g=i.filter(e=>!(e.proposed||e.tableId)),v=(e,t)=>{p(n=>[...n.filter(t=>t.categoryId!==e.id),...t.length?[{categoryId:e.id,values:t,by:`person`}]:[]]),m.mutate({categoryId:e.id,next:t}),l(null)},y=g.filter(e=>f.some(t=>t.categoryId===e.id)),b=g.filter(e=>!f.some(t=>t.categoryId===e.id));return g.length?(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[y.map(e=>{let t=f.find(t=>t.categoryId===e.id),n=G[e.type],r=(0,W.jsxs)(`button`,{type:`button`,disabled:a,title:`${e.name} · ${h(`know.by.${t.by}`)}`,onClick:()=>l(c===e.id?null:e.id),className:`inline-flex h-7 items-center gap-1.5 rounded-full bg-paper-2 px-2.5 text-[0.75rem] text-ink-2 transition hover:bg-paper-3 hover:text-ink disabled:pointer-events-none`,children:[(0,W.jsx)(n,{className:`size-3.5 text-ink-3`}),(0,W.jsx)(`span`,{className:`text-ink-3`,children:e.name}),(0,W.jsx)(`span`,{className:`font-medium`,children:t.values.map(t=>q(e,t)).join(`, `)})]},e.id);return a?(0,W.jsx)(`span`,{children:r},e.id):(0,W.jsxs)(ye,{trigger:r,open:c===e.id,onOpen:t=>l(t?e.id:null),children:[(0,W.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,W.jsx)(`span`,{className:`font-medium text-[0.8125rem]`,children:e.name}),(0,W.jsx)(N,{label:h(`know.remove`),onClick:()=>v(e,[]),className:`size-7`,children:(0,W.jsx)(u,{className:`size-3.5`})})]}),(0,W.jsx)(be,{category:e,current:t.values,onSave:t=>v(e,t)})]},e.id)}),a||!b.length?null:(0,W.jsx)(ye,{open:c===`+`,onOpen:e=>l(e?`+`:null),trigger:(0,W.jsxs)(`button`,{type:`button`,onClick:()=>l(c===`+`?null:`+`),className:`inline-flex h-7 items-center gap-1 rounded-full px-2 text-[0.75rem] text-ink-3 ring-1 ring-border-soft transition hover:text-ink hover:ring-border`,children:[(0,W.jsx)(d,{className:`size-3.5`}),` `,h(`know.category`)]}),children:(0,W.jsx)(Se,{categories:b,onSave:v})})]}):null}function Se({categories:e,onSave:t}){let[n,r]=(0,U.useState)(e[0]?.id??``),i=e.find(e=>e.id===n);return(0,W.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[(0,W.jsx)(T,{value:n,onChange:r,options:e.map(e=>({value:e.id,label:e.name}))}),i?(0,W.jsx)(be,{category:i,current:[],onSave:e=>t(i,e)},i.id):null]})}function Ce({projectId:e,open:t,onClose:n,onMade:i}){let a=r(),[o,c]=(0,U.useState)(``),[l,u]=(0,U.useState)(`choice`),[d,f]=(0,U.useState)(``),[p,m]=(0,U.useState)(!1),[g,S]=(0,U.useState)(!1),[w,E]=(0,U.useState)(``),[D,O]=(0,U.useState)(``),k=s({mutationFn:()=>_.post(`/api/studio/projects/${e}/categories`,{name:o.trim(),type:l,unit:l===`number`&&d.trim()||null,multiple:l===`choice`&&p,ordered:l===`choice`&&g,hint:D.trim()||null,values:l===`choice`?w.split(`
2
+ `).map(e=>e.trim()).filter(Boolean):void 0}),onSuccess:async({id:t})=>{await a.invalidateQueries({queryKey:K(e)}),c(``),E(``),O(``),i(t)}});return(0,W.jsx)(b,{open:t,onClose:n,title:h(`know.newCategory`),children:(0,W.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),o.trim()&&k.mutate()},children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(C,{children:h(`know.name`)}),(0,W.jsx)(x,{"data-autofocus":!0,value:o,maxLength:80,onChange:e=>c(e.target.value)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(C,{children:h(`know.type`)}),(0,W.jsx)(T,{value:l,onChange:e=>u(e),options:[`choice`,`date`,`number`,`text`,`boolean`].map(e=>({value:e,label:h(`know.type.${e}`)}))})]}),l===`number`?(0,W.jsxs)(`div`,{children:[(0,W.jsx)(C,{hint:h(`know.unitHint`),children:h(`know.unit`)}),(0,W.jsx)(x,{value:d,maxLength:20,onChange:e=>f(e.target.value)})]}):null,l===`choice`?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(C,{hint:h(`know.valuesHint`),children:h(`know.values`)}),(0,W.jsx)(y,{minRows:3,value:w,onChange:e=>E(e.target.value)})]}),(0,W.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-[0.875rem]`,children:[h(`know.multiple`),(0,W.jsx)(P,{checked:p,onChange:m})]}),(0,W.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-[0.875rem]`,children:[h(`know.ordered`),(0,W.jsx)(P,{checked:g,onChange:S})]})]}):null,(0,W.jsxs)(`div`,{children:[(0,W.jsx)(C,{hint:h(`know.hintFieldHint`),children:h(`know.hintField`)}),(0,W.jsx)(x,{value:D,maxLength:120,onChange:e=>O(e.target.value)})]}),k.error?(0,W.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:k.error.message}):null,(0,W.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,W.jsx)(v,{variant:`ghost`,onClick:n,children:h(`common.cancel`)}),(0,W.jsx)(v,{type:`submit`,busy:k.isPending,disabled:!o.trim(),children:h(`know.create`)})]})]})})}function we({projectId:e,category:t,readOnly:n,onOpen:i,onGone:a}){let o=r(),c=()=>o.invalidateQueries({queryKey:K(e)}),[l,u]=(0,U.useState)(``),f=s({mutationFn:e=>e(),onSuccess:c}),p=G[t.type],m=new Map(t.values.map(e=>[e.id,e]));return(0,W.jsxs)(L,{title:t.name,hint:[h(`know.type.${t.type}`),t.unit,t.hint].filter(Boolean).join(` · `),plain:!0,action:n?null:(0,W.jsx)(N,{label:h(`know.deleteCategory`),className:`hover:text-rose`,onClick:()=>confirm(h(`know.confirmCategory`,{name:t.name}))&&f.mutate(async()=>{await _.del(`/api/studio/categories/${t.id}`),a()}),children:(0,W.jsx)(E,{className:`size-4`})}),children:[t.proposed&&!n?(0,W.jsxs)(A,{className:`flex flex-wrap items-center gap-3 p-4`,children:[(0,W.jsx)(M,{tone:`ember`,children:h(`know.proposed`)}),(0,W.jsx)(`span`,{className:`flex-1 text-[0.875rem] text-ink-2`,children:h(`know.proposedHint`)}),(0,W.jsx)(v,{size:`sm`,onClick:()=>f.mutate(()=>_.patch(`/api/studio/categories/${t.id}`,{proposed:!1})),children:h(`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,W.jsxs)(A,{className:`flex flex-wrap items-center gap-3 p-4`,children:[(0,W.jsx)(`span`,{className:`flex-1 text-[0.875rem] text-ink-2`,children:h(`know.alike`,{a:a.value,b:o.value})}),n?null:(0,W.jsx)(v,{size:`sm`,variant:`secondary`,busy:f.isPending,onClick:()=>f.mutate(()=>_.post(`/api/studio/values/${a.id}/merge`,{into:o.id})),children:h(`know.merge`)})]},`${e}:${t}`)}),(0,W.jsxs)(A,{className:`flex flex-col p-1.5`,children:[t.type===`choice`?t.values.length?t.values.map(e=>(0,W.jsxs)(`button`,{type:`button`,onClick:()=>i(`v:${e.id}`),className:`flex items-center gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent`,children:[(0,W.jsx)(p,{className:`size-4 shrink-0 text-ink-3`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.875rem]`,children:e.value}),e.summary?(0,W.jsx)(M,{children:h(`know.summary`)}):null,(0,W.jsx)(`span`,{className:`shrink-0 text-[0.75rem] text-ink-3 tabular-nums`,children:_e(e.count)})]},e.id)):(0,W.jsx)(D,{children:h(`know.empty`)}):(0,W.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2.5 text-[0.875rem]`,children:[(0,W.jsx)(p,{className:`size-4 shrink-0 text-ink-3`}),(0,W.jsx)(`span`,{className:`flex-1 text-ink-2`,children:t.range?h(`know.range`,{min:q(t,t.range.min),max:q(t,t.range.max)}):h(`know.unset`)}),(0,W.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:_e(t.count)})]}),t.type===`choice`&&!n?(0,W.jsxs)(`form`,{className:`flex gap-2 border-border-soft border-t p-2`,onSubmit:e=>{e.preventDefault();let n=l.trim();n&&(u(``),f.mutate(()=>_.post(`/api/studio/categories/${t.id}/values`,{value:n})))},children:[(0,W.jsx)(x,{value:l,placeholder:h(`know.addValue`),onChange:e=>u(e.target.value),className:`h-9`}),(0,W.jsx)(N,{label:h(`know.addValue`),type:`submit`,children:(0,W.jsx)(d,{className:`size-4`})})]}):null]}),f.error?(0,W.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:f.error.message}):null]})}function Te(e){return i({queryKey:[`knowledge-value`,e],queryFn:()=>_.get(`/api/studio/values/${e}`),enabled:!!e})}function Ee({value:e,readOnly:t,children:n}){let i=r(),a=s({mutationFn:()=>_.post(`/api/studio/values/${e.id}/summary`),onSuccess:()=>i.invalidateQueries({queryKey:[`knowledge-value`,e.id]})});return(0,W.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[(0,W.jsx)(L,{title:h(`know.summary`),hint:h(`know.summaryHint`),plain:!0,action:t?null:(0,W.jsxs)(v,{variant:`secondary`,size:`sm`,busy:a.isPending,onClick:()=>a.mutate(),children:[e.summary?(0,W.jsx)(m,{className:`size-4`}):null,e.summary?h(`know.summaryAgain`):h(`know.summaryWrite`)]}),children:(0,W.jsxs)(A,{className:`p-4 sm:p-5`,children:[a.isPending?(0,W.jsx)(`div`,{className:`flex h-24 items-center justify-center text-ink-3`,children:(0,W.jsx)(w,{})}):e.summary?(0,W.jsx)(F,{text:e.summary,className:`text-[0.875rem]`}):(0,W.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:h(`know.summaryEmpty`)}),a.error?(0,W.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:a.error.message}):null]})}),(0,W.jsx)(L,{title:h(`know.toc`),plain:!0,children:n})]})}function De(e){return i({queryKey:[`knowledge`,e],queryFn:()=>_.get(`/api/studio/projects/${e}/knowledge`),enabled:!!e,refetchInterval:e=>e.state.data?.items.some(e=>e.status===`pending`)?2e3:!1})}function Oe(e){return e.kind===`table`?e.format===`faq`?pe:a:e.kind===`file`?ee:e.children?le:f}function J({item:e,categories:t,onOpen:n}){let r=Oe(e),i=[ve(t,e.categories),e.children?e.children===1?h(`know.oneSub`):h(`know.sub`,{n:e.children}):``,e.rows===null?``:e.rows===1?h(`know.row`):h(`know.rows`,{n:e.rows}),e.originLabel??``].filter(Boolean).join(` · `);return(0,W.jsxs)(`button`,{type:`button`,onClick:()=>n(e.key),disabled:e.status===`pending`,className:`flex items-start gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent disabled:pointer-events-none`,children:[(0,W.jsx)(r,{className:`mt-0.5 size-4 shrink-0 text-ink-3`}),(0,W.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`span`,{className:`block truncate text-[0.875rem]`,children:e.title}),i?(0,W.jsx)(`span`,{className:`block truncate text-[0.75rem] text-ink-3`,children:i}):null]}),e.status===`pending`?(0,W.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1.5 text-[0.75rem] text-ink-3`,children:[(0,W.jsx)(w,{className:`size-3`}),` `,h(`know.reading`)]}):e.review?(0,W.jsx)(M,{tone:`warn`,title:e.review,children:h(`know.review`)}):null]})}function Y({projectId:e,itemKey:t,has:n,originLabel:r,kept:i,review:a,file:o,readOnly:s,onReviewed:c}){let l=De(e),u=[r?h(i?`know.kept`:`know.from`,{label:r}):``].filter(Boolean);return(0,W.jsxs)(`div`,{className:`flex flex-col gap-2 px-1`,children:[l.data?(0,W.jsx)(xe,{projectId:e,itemKey:t,has:n,categories:l.data.categories,readOnly:s}):null,u.length||o||a?(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-[0.8125rem] text-ink-3`,children:[u.map(e=>(0,W.jsx)(`span`,{children:e},e)),o?(0,W.jsxs)(`a`,{href:R(e,o.id),target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 underline-offset-2 hover:text-ink hover:underline`,children:[(0,W.jsx)(ee,{className:`size-3.5`}),` `,h(`know.original`),`: `,o.name]}):null,a?(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,W.jsx)(M,{tone:`warn`,children:h(`know.review`)}),(0,W.jsx)(`span`,{children:a}),s?null:(0,W.jsx)(`button`,{type:`button`,onClick:c,className:`underline hover:text-ink`,children:h(`know.reviewed`)})]}):null]}):null]})}function ke(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 Ae({projectId:e,category:t,categories:n,onOpen:r}){let a=i({queryKey:[`knowledge`,e,`category`,t.id],queryFn:()=>_.get(`/api/studio/categories/${t.id}/items`)});if(!a.data)return a.isLoading?(0,W.jsx)(w,{className:`mx-auto size-4 text-ink-3`}):null;let o=e=>e.categories.find(e=>e.categoryId===t.id)?.values[0],s=[...a.data.items].sort((e,t)=>{let n=o(e),r=o(t);return typeof n==`number`&&typeof r==`number`?n-r:String(r??``).localeCompare(String(n??``),l)}),c=t.type===`number`?ke(s.map(o).filter(e=>typeof e==`number`)):[],u=new Intl.NumberFormat(l,{notation:`compact`,maximumFractionDigits:1}),d=t.unit?` ${t.unit}`:``,f=new Map;for(let e of s){let n=o(e),r=typeof n==`number`?c.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(l,{month:`long`,year:`numeric`}):r?h(`know.range`,{min:`${u.format(r.lo)}${d}`,max:`${u.format(r.hi)}${d}`}):q(t,n);f.set(i,[...f.get(i)??[],e])}return(0,W.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[[...f].map(([e,t])=>(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e?(0,W.jsx)(`p`,{className:`px-1 font-medium text-[0.6875rem] text-ink-4 uppercase tracking-[0.12em]`,children:e}):null,(0,W.jsx)(A,{className:`flex flex-col p-1.5`,children:t.map(e=>(0,W.jsx)(J,{item:e,categories:n,onOpen:r},e.key))})]},e)),a.data.rows.map(e=>(0,W.jsx)(`button`,{type:`button`,onClick:()=>r(`t:${e.tableId}`),className:`px-1 text-left text-[0.8125rem] text-ink-3 hover:text-ink`,children:h(`know.tocRows`,{n:e.count,table:e.title})},e.tableId))]})}function je(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 Me(e,t){if(Array.isArray(t))return t.map(String).join(`, `);if(typeof t==`boolean`)return h(t?`know.yes`:`know.no`);if(typeof t==`object`&&t){let n=t.gte??t.after,r=t.lte??t.before;return t.contains?`${h(`know.contains`)} ${t.contains}`:[n===void 0?``:`${h(`know.minimum`)} ${q(e,n)}`,r===void 0?``:`${h(`know.maximum`)} ${q(e,r)}`].filter(Boolean).join(` `)}return String(t)}function Ne({category:e,value:t,onChange:n}){let[r,i]=(0,U.useState)(!1),a=(0,U.useRef)(null);(0,U.useEffect)(()=>{if(!r)return;let e=e=>!a.current?.contains(e.target)&&i(!1);return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[r]);let o=G[e.type],s=typeof t==`object`&&t&&!Array.isArray(t)?t:{},l=(t,r)=>{let i={...s,[t]:r===``?void 0:e.type===`number`?Number(r):r},a=Object.fromEntries(Object.entries(i).filter(([,e])=>e!==void 0));n(Object.keys(a).length?a:void 0)};return(0,W.jsxs)(`div`,{ref:a,className:`relative`,children:[(0,W.jsxs)(`button`,{type:`button`,onClick:()=>i(!r),className:I(`inline-flex h-8 items-center gap-1.5 rounded-full px-3 text-[0.8125rem] transition`,t===void 0?`text-ink-2 ring-1 ring-border-soft hover:ring-border`:`bg-ember-tint text-ink ring-1 ring-ember/30`),children:[(0,W.jsx)(o,{className:`size-3.5 text-ink-3`}),e.name,t===void 0?null:(0,W.jsxs)(`span`,{className:`font-medium`,children:[`: `,Me(e,t)]}),(0,W.jsx)(c,{className:`size-3.5 text-ink-3`})]}),r?(0,W.jsxs)(`div`,{className:`absolute top-full left-0 z-30 mt-1.5 w-72 max-w-[calc(100vw-32px)] rounded-xl bg-card p-3 shadow-overlay ring-1 ring-border-soft`,children:[e.type===`choice`?(0,W.jsx)(O,{multi:!0,value:Array.isArray(t)?t.map(String):[],options:e.values.map(e=>e.value),onChange:e=>n(e.length?e:void 0)}):e.type===`boolean`?(0,W.jsx)(O,{value:t===!0?h(`know.yes`):t===!1?h(`know.no`):``,options:[h(`know.yes`),h(`know.no`)],onChange:e=>n(e===h(`know.yes`))}):e.type===`text`?(0,W.jsx)(x,{"data-autofocus":!0,value:s.contains??``,placeholder:h(`know.contains`),onChange:e=>n(e.target.value?{contains:e.target.value}:void 0),className:`h-9`}):(0,W.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:(e.type===`number`?[`gte`,`lte`]:[`after`,`before`]).map((t,n)=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(C,{children:h(n===0?`know.minimum`:`know.maximum`)}),(0,W.jsx)(x,{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=>l(t,e.target.value),className:`h-9`})]},t))}),t===void 0?null:(0,W.jsx)(`button`,{type:`button`,onClick:()=>{n(void 0),i(!1)},className:`mt-3 text-[0.8125rem] text-ink-3 underline hover:text-ink`,children:h(`know.clear`)})]}):null]})}function Pe({found:e,onOpen:t}){return e.hits.length?(0,W.jsxs)(`div`,{className:`flex flex-col`,children:[(0,W.jsx)(`p`,{className:`px-3 pt-1 pb-2 text-[0.75rem] text-ink-3`,children:e.checked?h(`know.searchStats`,{candidates:e.candidates,hits:e.hits.length}):h(`know.searchUnchecked`,{hits:e.hits.length})}),e.hits.map(e=>{let n=e.open;return(0,W.jsxs)(`button`,{type:`button`,disabled:!n,onClick:()=>n&&t(n),className:`flex items-start gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent disabled:pointer-events-none`,children:[(0,W.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`span`,{className:`block truncate text-[0.875rem]`,children:[e.title,e.heading&&e.heading!==e.title?(0,W.jsxs)(`span`,{className:`text-ink-3`,children:[` › `,e.heading]}):null]}),(0,W.jsx)(`span`,{className:`line-clamp-2 text-[0.8125rem] text-ink-3`,children:e.text})]}),e.relevance===null?null:(0,W.jsx)(`span`,{className:`shrink-0 font-medium text-[0.75rem] text-moss tabular-nums`,children:e.relevance.toLocaleString(l,{minimumFractionDigits:2})})]},`${e.key}:${e.heading}`)})]}):(0,W.jsx)(`p`,{className:`px-3 py-4 text-[0.875rem] text-ink-3`,children:h(`know.searchNone`)})}function Fe({kind:e,projectId:t,onClose:n,onMade:i}){let a=r(),[o,c]=(0,U.useState)(``),[l,u]=(0,U.useState)(!1),d=s({mutationFn:()=>_.post(`/api/studio/projects/${t}/${e===`table`?`tables`:`pages`}`,{title:o.trim(),...e===`table`&&l?{format:`faq`}:{}}),onSuccess:async({id:n})=>{await a.invalidateQueries({queryKey:[`knowledge`,t]}),i(`${e===`table`?`t`:`p`}:${n}`),c(``),u(!1)}});return(0,W.jsx)(b,{open:e!==null,onClose:n,title:h(e===`table`?`know.newTable`:`know.newPage`),children:(0,W.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),o.trim()&&d.mutate()},children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(C,{children:h(`data.title`)}),(0,W.jsx)(x,{"data-autofocus":!0,value:o,maxLength:120,onChange:e=>c(e.target.value)})]}),e===`table`?(0,W.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-[0.875rem]`,children:[h(`know.asFaq`),(0,W.jsx)(P,{checked:l,onChange:u})]}):null,d.error?(0,W.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:d.error.message}):null,(0,W.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,W.jsx)(v,{variant:`ghost`,onClick:n,children:h(`common.cancel`)}),(0,W.jsx)(v,{type:`submit`,busy:d.isPending,disabled:!o.trim(),children:h(`know.create`)})]})]})})}function Ie({projectId:e,data:t,readOnly:n,onOpen:i}){let a=r(),o=re(e,n),[c,l]=(0,U.useState)({}),[u,f]=(0,U.useState)(``),[p,m]=(0,U.useState)(null),[g,y]=(0,U.useState)(!1),[b,x]=(0,U.useState)(null),S=t.categories.filter(e=>!e.proposed&&e.count>0),C=t.categories.filter(e=>e.proposed),T=t.items.filter(e=>Object.entries(c).every(([n,r])=>{let i=t.categories.find(e=>e.name===n),a=e.categories.find(e=>e.categoryId===i?.id);return i&&a?je(i,a.values,r):!1})),E=async()=>{if(!u.trim()){m(null);return}y(!0);try{m(await _.post(`/api/studio/projects/${e}/search`,{query:u,...Object.keys(c).length?{where:c}:{}}))}catch{m({hits:[],candidates:0,checked:!1,filtered:null})}finally{y(!1)}},O=s({mutationFn:({id:e,keep:t})=>t?_.patch(`/api/studio/categories/${e}`,{proposed:!1}):_.del(`/api/studio/categories/${e}`),onSuccess:()=>a.invalidateQueries({queryKey:[`knowledge`,e]})});return(0,W.jsxs)(L,{title:h(`know.title`),hint:h(`know.hint`),plain:!0,action:n?null:(0,W.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,W.jsxs)(v,{variant:`secondary`,size:`sm`,onClick:()=>x(`page`),children:[(0,W.jsx)(d,{className:`size-4`}),` `,h(`know.page`)]}),(0,W.jsxs)(v,{variant:`secondary`,size:`sm`,onClick:()=>x(`table`),children:[(0,W.jsx)(d,{className:`size-4`}),` `,h(`know.table`)]}),(0,W.jsxs)(v,{variant:`secondary`,size:`sm`,onClick:()=>x(`category`),children:[(0,W.jsx)(d,{className:`size-4`}),` `,h(`know.category`)]})]}),children:[C.length&&!n?(0,W.jsx)(A,{className:`flex flex-col gap-2 p-4`,children:C.map(e=>{let t=G[e.type];return(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5`,children:[(0,W.jsx)(M,{tone:`ember`,children:h(`know.proposed`)}),(0,W.jsx)(t,{className:`size-4 text-ink-3`}),(0,W.jsx)(`span`,{className:`font-medium text-[0.875rem]`,children:e.name}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.8125rem] text-ink-3`,children:[h(`know.type.${e.type}`),e.hint].filter(Boolean).join(` · `)}),(0,W.jsx)(v,{size:`sm`,variant:`ghost`,onClick:()=>O.mutate({id:e.id,keep:!1}),children:h(`know.dismiss`)}),(0,W.jsx)(v,{size:`sm`,onClick:()=>O.mutate({id:e.id,keep:!0}),children:h(`know.accept`)})]},e.id)})}):null,t.items.length?(0,W.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,W.jsx)(ae,{value:u,placeholder:h(`know.search`),busy:g,onEnter:()=>void E(),onChange:e=>{f(e),e.trim()||m(null)}}),S.length?(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[S.map(e=>(0,W.jsx)(Ne,{category:e,value:c[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(c).length?(0,W.jsx)(`button`,{type:`button`,onClick:()=>l({}),className:`px-2 text-[0.8125rem] text-ink-3 underline hover:text-ink`,children:h(`know.clear`)}):null]}):null]}):null,(0,W.jsx)(A,{className:`flex flex-col p-1.5`,children:p?(0,W.jsx)(Pe,{found:p,onOpen:i}):T.length?T.map(e=>(0,W.jsx)(J,{item:e,categories:t.categories,onOpen:i},e.key)):(0,W.jsx)(D,{children:h(`know.empty`)})}),n?null:(0,W.jsxs)(oe,{accept:`.pdf,.docx,.doc,.xlsx,.csv,.tsv,.txt,.md,.json,.html,.eml,image/*`,onFiles:async t=>{await o.upload(`document`,t),await a.invalidateQueries({queryKey:[`knowledge`,e]})},className:`h-14 w-full`,children:[o.busy?(0,W.jsx)(w,{className:`size-4`}):(0,W.jsx)(te,{className:`size-4`}),h(`know.drop`),` `,(0,W.jsx)(`span`,{className:`underline`,children:h(`know.pick`)})]}),o.error?(0,W.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:o.error}):null,t.items.length&&!(t.checked&&t.embeddings)?(0,W.jsx)(`p`,{className:`px-1 text-[0.8125rem] text-ink-3`,children:[t.embeddings?``:h(`know.keywordsOnly`),t.checked?``:h(`know.unchecked`)].filter(Boolean).join(` `)}):null,(0,W.jsx)(Fe,{kind:b===`page`||b===`table`?b:null,projectId:e,onClose:()=>x(null),onMade:e=>{x(null),i(e)}}),(0,W.jsx)(Ce,{projectId:e,open:b===`category`,onClose:()=>x(null),onMade:e=>{x(null),i(`c:${e}`)}})]})}function Le({page:e,onGone:t,onOpen:n}){let i=r(),[a,o]=(0,U.useState)(e.title),[c,l]=(0,U.useState)(e.markdown),[u,p]=(0,U.useState)(e.markdown?`read`:`write`),m=e.knowledge,y=async()=>{await i.invalidateQueries({queryKey:[`space-data`,e.projectId]}),await i.invalidateQueries({queryKey:[`knowledge`,e.projectId]})},b=ne({title:a.trim()||e.title,markdown:c},async t=>{await _.patch(`/api/studio/pages/${e.id}`,t),i.setQueryData([`space-page`,e.id],e=>e&&{...e,...t}),t.title!==e.title&&await y()}),x=s({mutationFn:()=>_.del(`/api/studio/pages/${e.id}`),onSuccess:async()=>{await y(),t()}}),C=s({mutationFn:()=>_.post(`/api/studio/projects/${e.projectId}/pages`,{title:h(`know.addSub`),parentId:e.id}),onSuccess:async({id:e})=>{await y(),n?.(`p:${e}`)}}),T=s({mutationFn:()=>_.patch(`/api/studio/pages/${e.id}`,{review:null}),onSuccess:()=>i.invalidateQueries({queryKey:[`space-page`,e.id]})}),D=async t=>{let r=t.target.closest(`a`)?.getAttribute(`href`);if(!(r?.startsWith(`pages/`)&&n))return;t.preventDefault();let i=await _.get(`/api/studio/projects/${e.projectId}/resolve?path=${encodeURIComponent(r)}`).catch(()=>null);i?.kind===`page`&&n(`p:${i.id}`)},O=e.readOnly,k=m?.file&&(m.file.mime===`application/pdf`||m.file.mime.startsWith(`image/`))?m.file:null,j=(e,t)=>(0,W.jsx)(`button`,{type:`button`,"aria-pressed":u===e,onClick:()=>p(e),className:I(`rounded-full px-3 py-1 text-[0.8125rem] transition`,u===e?`bg-paper-2 font-medium text-ink`:`text-ink-3 hover:text-ink`),children:t});return(0,W.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[m?.parents.length&&n?(0,W.jsx)(`nav`,{className:`-mb-1.5 flex flex-wrap items-center gap-1 px-1 text-[0.8125rem] text-ink-3`,children:m.parents.map(e=>(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:()=>n(`p:${e.id}`),className:`hover:text-ink`,children:e.title}),(0,W.jsx)(g,{className:`size-3.5`})]},e.id))}):null,(0,W.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,W.jsx)(`input`,{value:a,disabled:O,maxLength:200,onChange:e=>o(e.target.value),"aria-label":h(`data.title`),className:`-ml-1 min-w-0 flex-1 rounded-md bg-transparent px-1 font-display font-semibold text-lg outline-none hover:bg-accent focus:bg-paper focus:ring-1 focus:ring-ring disabled:hover:bg-transparent`}),b.state===`saving`?(0,W.jsx)(w,{className:`size-3.5 text-ink-3`}):b.state===`saved`?(0,W.jsx)(S,{className:`size-4 text-moss`,"aria-label":h(`settings.saved`)}):null,O?null:(0,W.jsx)(N,{label:h(`data.deletePage`),onClick:()=>confirm(h(`data.confirmDelete`,{title:e.title}))&&x.mutate(),className:`hover:text-rose`,children:(0,W.jsx)(E,{className:`size-4`})})]}),m?(0,W.jsx)(Y,{projectId:e.projectId,itemKey:`p:${e.id}`,has:m.categories,originLabel:m.originLabel,kept:m.kept,review:m.review,file:k?null:m.file,readOnly:O,onReviewed:()=>T.mutate()}):null,(0,W.jsxs)(A,{className:`flex flex-col`,children:[O&&!k?null:(0,W.jsxs)(`div`,{className:`flex items-center gap-1 border-border-soft border-b px-2 py-1.5`,children:[O?null:j(`write`,h(`data.write`)),j(`read`,h(`data.preview`)),k?j(`original`,h(`know.original`)):null,(0,W.jsx)(`span`,{className:`ml-auto truncate px-2 text-[0.75rem] text-ink-4 max-sm:hidden`,children:u===`original`&&k?k.name:h(`data.markdownHint`)})]}),u===`original`&&k?k.mime===`application/pdf`?(0,W.jsx)(`iframe`,{src:R(e.projectId,k.id),title:k.name,className:`h-[70dvh] w-full rounded-b-xl bg-paper-2`}):(0,W.jsx)(`img`,{src:R(e.projectId,k.id),alt:``,className:`mx-auto max-h-[70dvh] object-contain p-4`}):u===`write`&&!O?(0,W.jsx)(`textarea`,{value:c,onChange:e=>l(e.target.value),"aria-label":e.title,placeholder:h(`data.pageEmpty`),className:`field-sizing-content min-h-[50vh] w-full resize-none bg-transparent p-4 font-mono text-[0.8125rem] leading-relaxed outline-none placeholder:text-ink-4 sm:p-5`}):(0,W.jsx)(`div`,{className:`min-h-40 p-4 sm:p-5`,onClick:D,children:c.trim()?(0,W.jsx)(F,{text:c}):(0,W.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:h(`data.pageEmpty`)})})]}),b.state===`error`&&b.error?(0,W.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:b.error}):null,m&&n&&(m.children.length||!O)?(0,W.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between px-1`,children:[(0,W.jsx)(`p`,{className:`font-medium text-[0.6875rem] text-ink-4 uppercase tracking-[0.12em]`,children:m.children.length?h(`know.subPages`):null}),O?null:(0,W.jsxs)(v,{variant:`ghost`,size:`sm`,busy:C.isPending,onClick:()=>C.mutate(),children:[(0,W.jsx)(d,{className:`size-4`}),` `,h(`know.addSub`)]})]}),m.children.length?(0,W.jsx)(A,{className:`flex flex-col p-1.5`,children:m.children.map(e=>(0,W.jsxs)(`button`,{type:`button`,onClick:()=>n(`p:${e.id}`),className:`flex items-center gap-3 rounded-lg px-3 py-2 text-left transition hover:bg-accent`,children:[(0,W.jsx)(f,{className:`size-4 shrink-0 text-ink-3`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.875rem]`,children:e.title})]},e.id))}):null]}):null]})}function Re({pageId:e,onGone:t,onOpen:n}){let r=i({queryKey:[`space-page`,e],queryFn:()=>_.get(`/api/studio/pages/${e}`),refetchOnWindowFocus:!1});return r.data?(0,W.jsx)(Le,{page:r.data,onGone:t,onOpen:n},r.data.id):r.isError?(0,W.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:r.error.message}):null}function ze(e){return i({queryKey:[`space-data`,e],queryFn:()=>_.get(`/api/studio/projects/${e}/data`),enabled:!!e})}function Be(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:h(`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 Ve={table:a,page:f};function He({kind:e,projectId:t,data:n,onClose:i,onMade:a}){let o=r(),[c,l]=(0,U.useState)(``),[u,d]=(0,U.useState)(``),f=s({mutationFn:()=>_.post(`/api/studio/projects/${t}/${e===`table`?`tables`:`pages`}`,{title:c.trim(),wizardId:u||null}),onSuccess:async({id:n})=>{await o.invalidateQueries({queryKey:[`space-data`,t]}),a(`${e===`table`?`t`:`p`}:${n}`),l(``),d(``)}});return(0,W.jsx)(b,{open:e!==null,onClose:i,title:h(e===`table`?`data.newTable`:`data.newPage`),children:(0,W.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),c.trim()&&f.mutate()},children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(C,{children:h(`data.title`)}),(0,W.jsx)(x,{"data-autofocus":!0,value:c,maxLength:120,onChange:e=>l(e.target.value)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(C,{children:h(`data.owner`)}),(0,W.jsx)(T,{value:u,onChange:d,options:[{value:``,label:h(`data.own`)},...n.wizards.map(e=>({value:e.id,label:e.title}))]})]}),f.error?(0,W.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:f.error.message}):null,(0,W.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,W.jsx)(v,{variant:`ghost`,onClick:i,children:h(`common.cancel`)}),(0,W.jsx)(v,{type:`submit`,busy:f.isPending,disabled:!c.trim(),children:h(`data.create`)})]})]})})}function Ue({projectId:e,data:t,readOnly:n,onOpen:r}){let[i,a]=(0,U.useState)(null),o=Be(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(l,{dateStyle:`medium`});return(0,W.jsxs)(L,{title:h(`space.data`),hint:h(`data.hint`),plain:!0,action:n?null:(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsxs)(v,{variant:`secondary`,size:`sm`,onClick:()=>a(`table`),children:[(0,W.jsx)(d,{className:`size-4`}),` `,h(`data.table`)]}),(0,W.jsxs)(v,{variant:`secondary`,size:`sm`,onClick:()=>a(`page`),children:[(0,W.jsx)(d,{className:`size-4`}),` `,h(`data.page`)]})]}),children:[o.length?(0,W.jsx)(`div`,{className:`flex flex-col gap-5`,children:o.map(e=>(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,W.jsx)(`p`,{className:`px-1 font-medium text-[0.6875rem] text-ink-4 uppercase tracking-[0.12em]`,children:e.label}),(0,W.jsx)(A,{className:`flex flex-col p-1.5`,children:e.items.map(e=>{let t=Ve[e.kind];return(0,W.jsxs)(`button`,{type:`button`,onClick:()=>r(e.key),className:`flex items-center gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent`,children:[(0,W.jsx)(t,{className:`size-4 shrink-0 text-ink-3`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.875rem]`,children:e.title}),(0,W.jsxs)(`span`,{className:`shrink-0 text-[0.75rem] text-ink-3 tabular-nums`,children:[e.kind===`table`?`${h(`data.rows`,{n:e.rows??0})} · `:``,c.format(new Date(s.get(e.key)??Date.now()))]})]},e.key)})})]},e.key))}):(0,W.jsx)(A,{children:(0,W.jsx)(D,{children:h(`data.empty`)})}),(0,W.jsx)(He,{kind:i,projectId:e,data:t,onClose:()=>a(null),onMade:e=>{a(null),r(e)}})]})}function We(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 Ge={milliseconds:1,seconds:1e3,minutes:6e4,hours:36e5,days:864e5},Ke=[`text`,`number`,`date`,`duration`,`select`,`boolean`];function qe(e,t){if(t==null)return``;if(e.type===`duration`&&typeof t==`number`)return String(t/Ge[e.format.inputUnit]);if(e.type===`date`&&e.format.kind===`datetime`&&typeof t==`string`){let e=new Date(t);return new Date(e.getTime()-e.getTimezoneOffset()*6e4).toISOString().slice(0,16)}return String(t)}function Je(e,t){return t.trim()===``?null:e.type===`date`&&e.format.kind===`datetime`?new Date(t).toISOString():t}var X=`w-full min-w-0 rounded-md bg-transparent px-2 py-1.5 text-[0.875rem] outline-none transition placeholder:text-ink-4 hover:bg-accent focus:bg-paper focus:ring-1 focus:ring-ring disabled:hover:bg-transparent`;function Ye({column:e,value:t,readOnly:n,invalid:r,onSave:i}){let a=qe(e,t),[o,s]=(0,U.useState)(a);(0,U.useEffect)(()=>s(a),[a]);let c=(t=o)=>{t!==a&&i(Je(e,t))};if(e.type===`boolean`)return(0,W.jsx)(`div`,{className:`px-2 py-1.5`,children:(0,W.jsx)(`input`,{type:`checkbox`,checked:t===!0,disabled:n,onChange:e=>i(e.target.checked),"aria-label":e.name,className:`size-4 accent-[var(--ember)]`})});if(e.type===`select`&&e.format.multiple){let r=Array.isArray(t)?t:[],a=t=>e.format.options.find(e=>e.id===t)?.label??t;return(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 px-2 py-1`,children:[r.map(e=>(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-paper-2 py-0.5 pr-1 pl-2 text-[0.75rem]`,children:[a(e),n?null:(0,W.jsx)(`button`,{type:`button`,"aria-label":h(`data.removeOption`),onClick:()=>i(r.filter(t=>t!==e)),className:`rounded-full text-ink-3 hover:text-ink`,children:(0,W.jsx)(u,{className:`size-3`})})]},e)),n?null:(0,W.jsxs)(`select`,{value:``,onChange:e=>e.target.value&&i([...r,e.target.value]),"aria-label":e.name,className:`h-7 rounded-md bg-transparent px-1 text-[0.75rem] text-ink-3 outline-none hover:bg-accent`,children:[(0,W.jsx)(`option`,{value:``,children:`+`}),e.format.options.filter(e=>!r.includes(e.id)).map(e=>(0,W.jsx)(`option`,{value:e.id,children:e.label},e.id))]})]})}if(e.type===`select`)return(0,W.jsxs)(`select`,{value:typeof t==`string`?t:``,disabled:n,onChange:e=>i(e.target.value||null),"aria-label":e.name,className:X,children:[(0,W.jsx)(`option`,{value:``}),e.format.options.map(e=>(0,W.jsx)(`option`,{value:e.id,children:e.label},e.id))]});if(e.type===`text`&&e.format?.style&&e.format.style!==`single`)return(0,W.jsx)(`textarea`,{value:o,rows:1,disabled:n,onChange:e=>s(e.target.value),onBlur:()=>c(),"aria-label":e.name,className:I(X,`field-sizing-content max-h-40 resize-none`)});let l=e.type===`date`?{date:`date`,datetime:`datetime-local`,time:`time`}[e.format.kind]:`text`;return(0,W.jsx)(`input`,{type:l,inputMode:e.type===`number`||e.type===`duration`?`decimal`:void 0,value:o,disabled:n,onChange:t=>{s(t.target.value),e.type===`date`&&c(t.target.value)},onBlur:()=>e.type!==`date`&&c(),onKeyDown:e=>{e.key===`Enter`&&e.target.blur(),e.key===`Escape`&&s(a)},"aria-label":e.name,className:I(X,(e.type===`number`||e.type===`duration`)&&`text-right tabular-nums`,r&&`ring-1 ring-rose`)})}function Xe(e){return e.type===`number`&&e.format.style===`currency`?e.format.currency??null:e.type===`number`&&e.format.style===`percent`?`%`:e.type===`duration`?h(`data.unit.${e.format.inputUnit}`):null}function Ze(e){return{name:e?.name??``,type:e?.type??`text`,required:e?.required??!1,textStyle:e?.type===`text`&&(e.format?.style??`single`)!==`single`?`multiline`:`single`,numberStyle:e?.type===`number`?e.format.style:`decimal`,currency:e?.type===`number`?e.format.currency??`EUR`:`EUR`,dateKind:e?.type===`date`?e.format.kind:`date`,unit:e?.type===`duration`&&[`minutes`,`hours`,`days`].includes(e.format.inputUnit)?e.format.inputUnit:`minutes`,options:e?.type===`select`?e.format.options.map(e=>e.label).join(`
3
+ `):``,multiple:e?.type===`select`&&!!e.format.multiple}}function Qe(e,t,n){let r={id:t,name:e.name.trim(),...e.required?{required:!0}:{}};switch(e.type){case`number`:return{...r,type:`number`,format:e.numberStyle===`currency`?{style:`currency`,currency:e.currency.trim().toUpperCase()}:{style:e.numberStyle}};case`date`:return{...r,type:`date`,format:{kind:e.dateKind}};case`duration`:return{...r,type:`duration`,format:{inputUnit:e.unit,display:`hms`}};case`select`:{let t=n?.type===`select`?n.format.options:[],i=[],a=e.options.split(`
4
+ `).map(e=>e.trim()).filter(Boolean).map(e=>{let n=t.find(t=>t.label===e)?.id??We(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 $e({open:e,column:t,columns:n,onClose:r,onSave:i}){let[a,o]=(0,U.useState)(()=>Ze(t)),[s,c]=(0,U.useState)(null),[l,u]=(0,U.useState)(!1);(0,U.useEffect)(()=>{e&&(o(Ze(t)),c(null))},[e,t]);let d=e=>o(t=>({...t,...e})),f=async e=>{u(!0),c(null);try{await i(e),r()}catch(e){c(e.message)}finally{u(!1)}},p=()=>{let e=t?.id??We(a.name,n.map(e=>e.id)),r=Qe(a,e,t);return f(t?n.map(e=>e.id===t.id?r:e):[...n,r])};return(0,W.jsx)(b,{open:e,onClose:r,title:t?t.name:h(`data.newColumn`),children:(0,W.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),a.name.trim()&&p()},children:[(0,W.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(C,{children:h(`data.columnName`)}),(0,W.jsx)(x,{"data-autofocus":!0,value:a.name,maxLength:128,onChange:e=>d({name:e.target.value})})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(C,{children:h(`data.columnType`)}),(0,W.jsx)(T,{value:a.type,onChange:e=>d({type:e}),options:Ke.map(e=>({value:e,label:h(`data.type.${e}`)}))})]})]}),a.type===`text`?(0,W.jsx)(T,{value:a.textStyle,onChange:e=>d({textStyle:e}),options:[{value:`single`,label:h(`data.text.single`)},{value:`multiline`,label:h(`data.text.multiline`)}]}):null,a.type===`number`?(0,W.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,W.jsx)(T,{value:a.numberStyle,onChange:e=>d({numberStyle:e}),options:[`integer`,`decimal`,`percent`,`currency`].map(e=>({value:e,label:h(`data.number.${e}`)}))}),a.numberStyle===`currency`?(0,W.jsx)(x,{value:a.currency,maxLength:3,"aria-label":h(`data.currency`),placeholder:`EUR`,onChange:e=>d({currency:e.target.value})}):null]}):null,a.type===`date`?(0,W.jsx)(T,{value:a.dateKind,onChange:e=>d({dateKind:e}),options:[`date`,`datetime`,`time`].map(e=>({value:e,label:h(`data.date.${e}`)}))}):null,a.type===`duration`?(0,W.jsxs)(`div`,{children:[(0,W.jsx)(C,{children:h(`data.unit`)}),(0,W.jsx)(T,{value:a.unit,onChange:e=>d({unit:e}),options:[`minutes`,`hours`,`days`].map(e=>({value:e,label:h(`data.unit.${e}`)}))})]}):null,a.type===`select`?(0,W.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(C,{children:h(`data.options`)}),(0,W.jsx)(y,{minRows:3,value:a.options,onChange:e=>d({options:e.target.value})})]}),(0,W.jsxs)(`label`,{className:`flex items-center gap-3 text-[0.875rem]`,children:[(0,W.jsx)(P,{checked:a.multiple,onChange:e=>d({multiple:e})}),h(`data.multiple`)]})]}):null,(0,W.jsxs)(`label`,{className:`flex items-center gap-3 text-[0.875rem]`,children:[(0,W.jsx)(P,{checked:a.required,onChange:e=>d({required:e})}),h(`data.required`)]}),s?(0,W.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:s}):null,(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t&&n.length>1?(0,W.jsx)(v,{variant:`ghost`,className:`text-rose`,disabled:l,onClick:()=>confirm(h(`data.confirmDelete`,{title:t.name}))&&void f(n.filter(e=>e.id!==t.id)),children:h(`data.deleteColumn`)}):null,(0,W.jsx)(`span`,{className:`flex-1`}),(0,W.jsx)(v,{variant:`ghost`,onClick:r,children:h(`common.cancel`)}),(0,W.jsx)(v,{type:`submit`,busy:l,disabled:!a.name.trim(),children:h(`settings.save`)})]})]})})}function et({tableId:e,onGone:t}){let n=r(),a=[`space-table`,e],o=i({queryKey:a,queryFn:()=>_.get(`/api/studio/tables/${e}`)}),[c,l]=(0,U.useState)(null),[u,f]=(0,U.useState)(null),[p,m]=(0,U.useState)(null),[g,y]=(0,U.useState)(``);(0,U.useEffect)(()=>y(o.data?.title??``),[o.data?.title]);let b=async()=>{await n.invalidateQueries({queryKey:[`space-data`,o.data?.projectId]}),await n.invalidateQueries({queryKey:[`knowledge`,o.data?.projectId]})},x=e=>n.setQueryData(a,t=>t&&{...t,rows:e(t.rows)}),S=e=>{f(e.message),o.refetch()},C=async t=>{await _.patch(`/api/studio/tables/${e}`,t),await o.refetch(),await b()},w=s({mutationFn:({row:t,column:n,value:r})=>_.patch(`/api/studio/tables/${e}/rows/${t}`,{cells:{[n]:r}}),onSuccess:(e,{row:t,column:n})=>{f(null),m(e=>e===`${t}:${n}`?null:e),x(t=>t.map(t=>t.id===e.id?{...t,cells:e.cells}:t))},onError:(e,{row:t,column:n})=>{if(e instanceof j&&e.body?.column===n){let e=o.data?.columns.find(e=>e.id===n)?.name??n;m(`${t}:${n}`),f(h(`data.badCell`,{column:e}));return}S(e)}}),T=s({mutationFn:()=>_.post(`/api/studio/tables/${e}/rows`,{}),onSuccess:async e=>{x(t=>[...t,{...e,updatedAt:new Date().toISOString()}]),await b()},onError:S}),D=s({mutationFn:t=>_.post(`/api/studio/tables/${e}/rows/delete`,{ids:[t]}),onSuccess:async(e,t)=>{x(e=>e.filter(e=>e.id!==t)),await b()},onError:S}),O=s({mutationFn:()=>_.del(`/api/studio/tables/${e}`),onSuccess:async()=>{await b(),t()}});if(!o.data)return o.isError?(0,W.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:o.error.message}):null;let{columns:k,rows:M,readOnly:P}=o.data,F=!!o.data.list;return(0,W.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,W.jsx)(`input`,{value:g,disabled:P,maxLength:120,onChange:e=>y(e.target.value),onBlur:()=>g.trim()&&g!==o.data?.title&&void C({title:g}).catch(S),onKeyDown:e=>e.key===`Enter`&&e.target.blur(),"aria-label":h(`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`}),P?null:(0,W.jsx)(N,{label:h(`data.deleteTable`),onClick:()=>confirm(h(`data.confirmDelete`,{title:o.data.title}))&&O.mutate(),className:`hover:text-rose`,children:(0,W.jsx)(E,{className:`size-4`})})]}),F?(0,W.jsx)(`p`,{className:`-mt-1.5 px-1 text-[0.8125rem] text-ink-3`,children:h(`data.fromList`)}):null,o.data.knowledge?(0,W.jsx)(Y,{projectId:o.data.projectId,itemKey:`t:${o.data.id}`,has:o.data.knowledge.categories,originLabel:o.data.knowledge.originLabel,kept:o.data.knowledge.kept,review:o.data.knowledge.review,file:o.data.knowledge.file,readOnly:P,onReviewed:()=>void _.patch(`/api/studio/tables/${e}`,{review:null}).then(()=>o.refetch()).catch(S)}):null,(0,W.jsxs)(A,{className:`overflow-hidden`,children:[(0,W.jsx)(`div`,{className:`overflow-x-auto`,children:(0,W.jsxs)(`table`,{className:`w-full border-collapse text-left`,children:[(0,W.jsx)(`thead`,{children:(0,W.jsxs)(`tr`,{className:`border-border-soft border-b`,children:[k.map(e=>(0,W.jsx)(`th`,{className:`min-w-36 border-border-soft border-l p-1 font-medium first:border-l-0`,children:(0,W.jsxs)(`button`,{type:`button`,disabled:P||F,onClick:()=>l(e),className:`flex w-full items-center gap-1 rounded-md px-2 py-1.5 text-left text-[0.8125rem] text-ink-2 transition hover:bg-accent hover:text-ink disabled:hover:bg-transparent`,children:[(0,W.jsx)(`span`,{className:`truncate`,children:e.name}),e.required?(0,W.jsx)(`span`,{className:`text-ember`,children:`*`}):null,Xe(e)?(0,W.jsx)(`span`,{className:`font-normal text-ink-4`,children:Xe(e)}):null]})},e.id)),(0,W.jsx)(`th`,{className:`w-10 p-1`,children:P||F?null:(0,W.jsx)(N,{label:h(`data.newColumn`),onClick:()=>l(`new`),className:`size-8`,children:(0,W.jsx)(d,{className:`size-4`})})})]})}),(0,W.jsx)(`tbody`,{children:M.map(e=>(0,W.jsxs)(`tr`,{className:`group border-border-soft border-b last:border-b-0`,children:[k.map(t=>(0,W.jsx)(`td`,{className:`border-border-soft border-l p-1 align-top first:border-l-0`,children:(0,W.jsx)(Ye,{column:t,value:e.cells[t.id],readOnly:P,invalid:p===`${e.id}:${t.id}`,onSave:n=>w.mutate({row:e.id,column:t.id,value:n})})},t.id)),(0,W.jsx)(`td`,{className:`w-10 p-1 align-top`,children:P?null:(0,W.jsx)(N,{label:h(`data.deleteRow`),onClick:()=>D.mutate(e.id),className:`size-8 opacity-0 hover:text-rose focus:opacity-100 group-hover:opacity-100 coarse:opacity-100`,children:(0,W.jsx)(E,{className:`size-3.5`})})})]},e.id))})]})}),M.length?null:(0,W.jsx)(`p`,{className:`px-4 py-6 text-center text-[0.875rem] text-ink-3`,children:h(`data.noRows`)}),P?null:(0,W.jsx)(`div`,{className:`border-border-soft border-t p-1.5`,children:(0,W.jsxs)(v,{variant:`ghost`,size:`sm`,busy:T.isPending,onClick:()=>T.mutate(),children:[(0,W.jsx)(d,{className:`size-4`}),` `,h(`data.addRow`)]})})]}),u?(0,W.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:u}):null,(0,W.jsx)($e,{open:c!==null,column:c===`new`?null:c,columns:k,onClose:()=>l(null),onSave:e=>C({columns:e})})]})}var tt=`wizards.runDrawer.width`,nt=`wizards.runDrawer.wide`,rt=`wizards.runDrawer.look`,it=680,Z=400,at=()=>Math.max(Z,window.innerWidth-120);function Q(e){try{return localStorage.getItem(e)}catch{return null}}function $(e,t){try{localStorage.setItem(e,t)}catch{}}function ot(){let[e,t]=(0,U.useState)(()=>{let e=Number(Q(tt));return e?Math.min(Math.max(e,Z),at()):it}),[n,r]=(0,U.useState)(()=>Q(nt)===`1`),i=(0,U.useCallback)(e=>{let n=Math.round(Math.min(Math.max(e,Z),at()));t(n),$(tt,String(n))},[]);return{width:e,wide:n,toggleWide:()=>{r(!n),$(nt,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(it)}}function st(){let[e,t]=(0,U.useState)(()=>Q(rt)===`chat`?`chat`:`steps`);return[e,e=>{t(e),$(rt,e)}]}function ct({look:e,onChange:t}){let n=[{id:`steps`,label:h(`chat.steps`),Icon:fe},{id:`chat`,label:h(`chat.chat`),Icon:pe}];return(0,W.jsx)(`fieldset`,{"aria-label":h(`chat.view`),className:`m-0 flex min-w-0 rounded-full border-0 bg-paper-2 p-0.5`,children:n.map(({id:n,label:r,Icon:i})=>(0,W.jsxs)(`button`,{type:`button`,"aria-pressed":e===n,title:r,onClick:()=>t(n),className:I(`inline-flex h-7 items-center gap-1.5 rounded-full px-2.5 font-medium text-[0.75rem] transition coarse:h-9`,e===n?`bg-card text-ink shadow-soft`:`text-ink-3 hover:text-ink`),children:[(0,W.jsx)(i,{className:`size-3.5`}),(0,W.jsx)(`span`,{className:`max-sm:hidden`,children:r})]},n))})}function lt({header:e,actions:t,onClose:n,children:r}){let i=ot();return(0,W.jsx)(`div`,{className:`fixed inset-0 z-50 flex justify-end bg-[oklch(20%_0.01_60/0.22)] backdrop-blur-[1px]`,onClick:n,children:(0,W.jsxs)(`div`,{className:I(`relative flex h-full w-full animate-rise flex-col bg-background shadow-overlay`,!i.wide&&`sm:w-[var(--drawer)]`),style:{"--drawer":`${i.width}px`},onClick:e=>e.stopPropagation(),children:[i.wide?null:(0,W.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":h(`editor.resize`),"aria-valuenow":i.width,tabIndex:0,title:h(`editor.resize`),onPointerDown:i.onPointerDown,onKeyDown:i.onKeyDown,onDoubleClick:i.reset,className:`group -left-2.5 absolute inset-y-0 z-10 hidden w-5 cursor-col-resize outline-none sm:block`,children:(0,W.jsx)(`span`,{className:`-translate-y-1/2 absolute top-1/2 left-[7px] h-12 w-1.5 rounded-full bg-ink-4/40 transition group-hover:bg-ember/70 group-focus-visible:bg-ember group-active:h-16 group-active:bg-ember`})}),(0,W.jsxs)(`div`,{className:`flex h-14 shrink-0 items-center gap-3 px-4`,children:[(0,W.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:e}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[t,(0,W.jsx)(N,{label:h(i.wide?`runDrawer.shrink`:`runDrawer.expand`),onClick:i.toggleWide,className:`max-sm:hidden`,children:i.wide?(0,W.jsx)(ie,{className:`size-4`}):(0,W.jsx)(p,{className:`size-4`})}),(0,W.jsx)(N,{label:h(`editor.close`),onClick:n,children:(0,W.jsx)(u,{className:`size-5`})})]})]}),(0,W.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:r})]})})}export{Ee as _,Ve as a,de as b,ze as c,J as d,Y as f,we as g,G as h,et as i,Re as l,De as m,lt as n,Ue as o,Ie as p,st as r,Be as s,ct as t,Ae as u,Te as v,z as x,ge as y};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{a as r,f as i,in as a,p as o,tt as s}from"./ui-SKtUMhUq.js";import{i as c,r as l}from"./index-CsKV2ZNO.js";var u={name:`phone`,size:24,node:[[`path`,{d:`M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384`,key:`9njp5v`}]]};u.node;var d=a(u),f=e(t(),1),p=e(n(),1),m=[`classifier`,`standard`],h=12e3;function g(e){c(`think`)&&r.post(`/api/runs/${e}/device`,{think:{classes:m,maxChars:h}}).catch(()=>void 0)}async function _(e,t){if(t.kind!==`think`)return;let n;try{let e=await l(`think`,{system:t.system,prompt:t.prompt,schema:t.schema});n={text:String(e?.text??``)}}catch(e){n={error:e.message.slice(0,500)}}await r.post(`/api/runs/${e}/device/${t.id}`,n).catch(()=>void 0)}var v=45e3;function y(e){let[t,n]=(0,f.useState)(null),[a,o]=(0,f.useState)(null),[c,l]=(0,f.useState)(!1),[u,d]=(0,f.useState)(!1),[p,m]=(0,f.useState)({});(0,f.useEffect)(()=>{if(n(null),l(!1),!e)return;let t=!1,a=0,o,c=null,u=Date.now(),d=()=>{t=!0,c?.close(),l(!0)},f=async()=>{try{let i=await r.get(`/api/runs/${e}`);t||n(i)}catch(e){e instanceof s&&e.status===404&&d()}},p=()=>{if(clearTimeout(o),c?.close(),t)return;let r=new EventSource(i(`/api/runs/${e}/stream`),{withCredentials:!0});c=r,u=Date.now(),g(e),r.addEventListener(`device`,t=>{u=Date.now(),_(e,JSON.parse(t.data))}),r.addEventListener(`view`,e=>{a=0,u=Date.now(),n(JSON.parse(e.data))}),r.addEventListener(`ping`,()=>{u=Date.now()}),r.onerror=()=>{r.close(),!(t||c!==r)&&(c=null,f(),a=Math.min(a+1,6),o=setTimeout(p,500*2**a))}},m=()=>{t||document.visibilityState!==`visible`||(!c||c.readyState===EventSource.CLOSED||Date.now()-u>v?(a=0,p()):f())},h=setInterval(()=>{!t&&c&&Date.now()-u>v&&(a=0,p())},15e3);return p(),document.addEventListener(`visibilitychange`,m),window.addEventListener(`pageshow`,m),window.addEventListener(`online`,m),()=>{t=!0,clearTimeout(o),clearInterval(h),document.removeEventListener(`visibilitychange`,m),window.removeEventListener(`pageshow`,m),window.removeEventListener(`online`,m),c?.close()}},[e]);let h=(0,f.useCallback)(async(t,n)=>{if(!e)return!1;d(!0),o(null),m({});try{return await r.post(`/api/runs/${e}/${t}`,n),!0}catch(e){return e instanceof s&&e.status===422&&Array.isArray(e.body?.fields)&&m(Object.fromEntries(e.body.fields.map(e=>[e.field,e.message]))),o(e.message),!1}finally{d(!1)}},[e]);return{view:t,notFound:c,error:a,busy:u,fieldErrors:p,submitPage:(e,t)=>h(`pages/${e}`,{values:t}),accept:(e,t)=>h(`reviews/${e}`,{type:`accept`,edits:t}),regenerate:(e,t,n,r)=>h(`reviews/${e}`,{type:`regenerate`,target:t,note:n,items:r?.length?r:void 0}),back:()=>h(`back`),retry:()=>h(`retry`)}}function b({runId:e,...t}){let n=y(e);return(0,p.jsx)(o,{run:n,...t})}export{y as n,d as r,b as t};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{a as r,h as i,m as a,on as o,rt as s}from"./ui-aWLrX8hF.js";import{i as c,r as l}from"./index-DIF70pQf.js";var u={name:`phone`,size:24,node:[[`path`,{d:`M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384`,key:`9njp5v`}]]};u.node;var d=o(u),f=e(t(),1),p=e(n(),1),m=[`classifier`,`standard`],h=12e3;function g(e){c(`think`)&&r.post(`/api/runs/${e}/device`,{think:{classes:m,maxChars:h}}).catch(()=>void 0)}async function _(e,t){if(t.kind!==`think`)return;let n;try{let e=await l(`think`,{system:t.system,prompt:t.prompt,schema:t.schema});n={text:String(e?.text??``)}}catch(e){n={error:e.message.slice(0,500)}}await r.post(`/api/runs/${e}/device/${t.id}`,n).catch(()=>void 0)}var v=45e3;function y(e){let[t,n]=(0,f.useState)(null),[i,o]=(0,f.useState)(null),[c,l]=(0,f.useState)(!1),[u,d]=(0,f.useState)(!1),[p,m]=(0,f.useState)({});(0,f.useEffect)(()=>{if(n(null),l(!1),!e)return;let t=!1,i=0,o,c=null,u=Date.now(),d=()=>{t=!0,c?.close(),l(!0)},f=async()=>{try{let i=await r.get(`/api/runs/${e}`);t||n(i)}catch(e){e instanceof s&&e.status===404&&d()}},p=()=>{if(clearTimeout(o),c?.close(),t)return;let r=new EventSource(a(`/api/runs/${e}/stream`),{withCredentials:!0});c=r,u=Date.now(),g(e),r.addEventListener(`device`,t=>{u=Date.now(),_(e,JSON.parse(t.data))}),r.addEventListener(`view`,e=>{i=0,u=Date.now(),n(JSON.parse(e.data))}),r.addEventListener(`ping`,()=>{u=Date.now()}),r.onerror=()=>{r.close(),!(t||c!==r)&&(c=null,f(),i=Math.min(i+1,6),o=setTimeout(p,500*2**i))}},m=()=>{t||document.visibilityState!==`visible`||(!c||c.readyState===EventSource.CLOSED||Date.now()-u>v?(i=0,p()):f())},h=setInterval(()=>{!t&&c&&Date.now()-u>v&&(i=0,p())},15e3);return p(),document.addEventListener(`visibilitychange`,m),window.addEventListener(`pageshow`,m),window.addEventListener(`online`,m),()=>{t=!0,clearTimeout(o),clearInterval(h),document.removeEventListener(`visibilitychange`,m),window.removeEventListener(`pageshow`,m),window.removeEventListener(`online`,m),c?.close()}},[e]);let h=(0,f.useCallback)(async(t,n)=>{if(!e)return!1;d(!0),o(null),m({});try{return await r.post(`/api/runs/${e}/${t}`,n),!0}catch(e){return e instanceof s&&e.status===422&&Array.isArray(e.body?.fields)&&m(Object.fromEntries(e.body.fields.map(e=>[e.field,e.message]))),o(e.message),!1}finally{d(!1)}},[e]);return{view:t,notFound:c,error:i,busy:u,fieldErrors:p,submitPage:(e,t)=>h(`pages/${e}`,{values:t}),accept:(e,t)=>h(`reviews/${e}`,{type:`accept`,edits:t}),regenerate:(e,t,n,r)=>h(`reviews/${e}`,{type:`regenerate`,target:t,note:n,items:r?.length?r:void 0}),back:()=>h(`back`),retry:()=>h(`retry`)}}function b({runId:e,...t}){let n=y(e);return(0,p.jsx)(i,{run:n,...t})}export{y as n,d as r,b as t};