wizards 0.3.5 → 0.3.7
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.
- package/apps/runtime/dist/agents/studio-assistant.js +285 -31
- package/apps/runtime/dist/agents/website.js +256 -34
- package/apps/runtime/dist/db/schema.js +1 -1
- package/apps/runtime/dist/docs/user/test-and-share.md +21 -11
- package/apps/runtime/dist/documents/parse.js +14 -0
- package/apps/runtime/dist/engine/steps.js +42 -6
- package/apps/runtime/dist/engine/template.js +50 -3
- package/apps/runtime/dist/film/project.js +54 -4
- package/apps/runtime/dist/routes/studio.js +52 -3
- package/apps/runtime/dist/services/brand.js +6 -3
- package/apps/runtime/dist/services/project-files.js +59 -3
- package/apps/runtime/dist/services/projects.js +150 -2
- package/apps/runtime/dist/services/wizards.js +25 -0
- package/apps/web/dist/assets/AboutDialog-C0dN86zd.js +1 -0
- package/apps/web/dist/assets/{ChangelogDialog-VEBTlC3f.js → ChangelogDialog-Cv81t7tj.js} +1 -1
- package/apps/web/dist/assets/ChatView-uogJ3nht.js +10 -0
- package/apps/web/dist/assets/EditorPage-n8YuTh6j.js +3 -0
- package/apps/web/dist/assets/{FlowPreview-86xWWfdk.js → FlowPreview-D4dp1MWS.js} +1 -1
- package/apps/web/dist/assets/{Harness-CF6H2TYJ.js → Harness-v7r0e6vK.js} +2 -2
- package/apps/web/dist/assets/NewWizardChannels-Be-7VhBi.js +1 -0
- package/apps/web/dist/assets/NewWizardPage-C8hPvrK8.js +7 -0
- package/apps/web/dist/assets/ProjectPage-B686ArYy.js +1 -0
- package/apps/web/dist/assets/PublicRunner-DeCpVfZP.js +1 -0
- package/apps/web/dist/assets/{ReadOnly-mhKW496R.js → ReadOnly-B-UCgnqW.js} +1 -1
- package/apps/web/dist/assets/RunDrawer-C6pzi8AJ.js +4 -0
- package/apps/web/dist/assets/{RunnerView-CTRFgyu5.js → RunnerView-Deenymq0.js} +1 -1
- package/apps/web/dist/assets/SettingsPage-CK6L0yEe.js +1 -0
- package/apps/web/dist/assets/SetupPage-9CH3qXdH.js +1 -0
- package/apps/web/dist/assets/SharePage-B778xUFo.js +1 -0
- package/apps/web/dist/assets/changelog-DCJo2mbx.js +1 -0
- package/apps/web/dist/assets/{circle-alert-CYs622_r.js → circle-alert-DLvC9ePT.js} +1 -1
- package/apps/web/dist/assets/{esm-B52LIMhP.js → esm-BJskogLD.js} +1 -1
- package/apps/web/dist/assets/index-D6hUM8NU.css +1 -0
- package/apps/web/dist/assets/index-Df6UxElH.js +12 -0
- package/apps/web/dist/assets/{lock-BvSWZOin.js → lock-DR7NakPn.js} +1 -1
- package/apps/web/dist/assets/{phone-CI2Flerg.js → phone-BORh3jfv.js} +1 -1
- package/apps/web/dist/assets/{settings-menu-BOOPxcJH.js → settings-menu-DV5D91TD.js} +1 -1
- package/apps/web/dist/assets/{ui-CMdSOoUZ.js → ui-BOCXzzHi.js} +1 -1
- package/apps/web/dist/assets/{upload-Cz9HgBT9.js → upload-B3yv8gsk.js} +1 -1
- package/apps/web/dist/index.html +3 -8
- package/apps/web/dist/mcp/flow.html +2 -2
- package/node_modules/@engenty-wizards/plugin-sdk/dist/index.d.ts +3 -3
- package/node_modules/@engenty-wizards/shared/dist/changes.d.ts +22 -0
- package/node_modules/@engenty-wizards/shared/dist/changes.js +61 -0
- package/node_modules/@engenty-wizards/shared/dist/definition.d.ts +8 -8
- package/node_modules/@engenty-wizards/shared/dist/marketplace.d.ts +1 -1
- package/node_modules/@engenty-wizards/shared/dist/projects.d.ts +138 -3
- package/node_modules/@engenty-wizards/shared/dist/projects.js +153 -4
- package/node_modules/@engenty-wizards/shared/dist/wizard-package.d.ts +1 -1
- package/package.json +1 -1
- package/apps/web/dist/assets/AboutDialog-D1N4-3FE.js +0 -1
- package/apps/web/dist/assets/ChatView-DSRUEpb6.js +0 -10
- package/apps/web/dist/assets/EditorPage-UkaHDklX.js +0 -3
- package/apps/web/dist/assets/Marketplace-C-Vz3yEk.js +0 -2
- package/apps/web/dist/assets/NewWizardChannels-Cc7gDitg.js +0 -1
- package/apps/web/dist/assets/NewWizardPage-sY5q-l99.js +0 -7
- package/apps/web/dist/assets/ProjectPage-iSdpJAZS.js +0 -2
- package/apps/web/dist/assets/PublicRunner-BgRXMUxS.js +0 -1
- package/apps/web/dist/assets/RunDrawer-B0gJzdxH.js +0 -4
- package/apps/web/dist/assets/SettingsPage-CBF8i6j6.js +0 -1
- package/apps/web/dist/assets/SetupPage-Fpz9aSLN.js +0 -1
- package/apps/web/dist/assets/SharePage-Dv3Csh4A.js +0 -1
- package/apps/web/dist/assets/brand-BamUjXVr.js +0 -2
- package/apps/web/dist/assets/changelog-ViHoNW7e.js +0 -1
- package/apps/web/dist/assets/index-Bdx1Qity.js +0 -11
- package/apps/web/dist/assets/index-CDdJDojq.css +0 -1
- package/apps/web/dist/assets/session-BEHF6g4Y.js +0 -1
- package/apps/web/dist/assets/useMutation-DKyQXgyj.js +0 -1
- package/apps/web/dist/assets/volume-2-CyQuz1nn.js +0 -1
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FlowPreview-86xWWfdk.js","assets/rolldown-runtime-hePW80VL.js","assets/jsx-runtime-BNakU3Ej.js","assets/ui-CMdSOoUZ.js","assets/preload-helper-CNEI7N0N.js","assets/esm-B52LIMhP.js","assets/index-Bdx1Qity.js","assets/logo-C4V2_3Ar.js","assets/engenty-eXZ-EAwd.js","assets/useMutation-DKyQXgyj.js","assets/brand-BamUjXVr.js","assets/volume-2-CyQuz1nn.js","assets/session-BEHF6g4Y.js","assets/index-CDdJDojq.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{n as e,r as t}from"./rolldown-runtime-hePW80VL.js";import{n,t as r}from"./jsx-runtime-BNakU3Ej.js";import{O as i,a,c as o,i as s,r as c,s as l,v as u}from"./logo-C4V2_3Ar.js";import{t as d}from"./useMutation-DKyQXgyj.js";import{t as f}from"./preload-helper-CNEI7N0N.js";import{Dt as p,Gt as m,Kt as h,Mt as g,Tt as _,Ut as v,Xt as y,an as ee,bt as b,dn as x,dt as S,ft as te,in as ne,jt as C,kt as w,l as T,lt as E,on as D,tn as O,ut as k,yn as A}from"./ui-CMdSOoUZ.js";import{l as j,r as re}from"./brand-BamUjXVr.js";import{t as ie}from"./volume-2-CyQuz1nn.js";import{l as ae,u as oe}from"./engenty-eXZ-EAwd.js";import{d as se,s as ce}from"./session-BEHF6g4Y.js";var le=class extends a{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type=`infinite`,super.setOptions(e)}getOptimisticResult(e){return e._type=`infinite`,super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:s,isRefetchError:c}=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:l(t,n.data),hasPreviousPage:o(t,n.data),isFetchNextPageError:d,isFetchingNextPage:f,isFetchPreviousPageError:p,isFetchingPreviousPage:m,isRefetchError:c&&!d&&!p,isRefetching:a&&!f&&!m}}};function ue(e,t){return s(e,le,t)}var de={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`}]]};de.node;var M=x(de),fe={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`}]]};fe.node;var N=x(fe),pe={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`]};pe.node;var me=x(pe),he={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`}]]};he.node;var ge=x(he),_e={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`}]]};_e.node;var ve=x(_e),ye={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`}]]};ye.node;var P=x(ye),be={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`}]]};be.node;var xe=x(be),Se={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`}]]};Se.node;var Ce=x(Se),we={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`}]]};we.node;var F=x(we),Te={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`}]]};Te.node;var Ee=x(Te),De={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`}]]};De.node;var Oe=x(De),ke={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`}]]};ke.node;var I=x(ke),Ae={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`}]]};Ae.node;var je=x(Ae),Me={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`}]]};Me.node;var Ne=x(Me),Pe={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`}]]};Pe.node;var L=x(Pe),Fe={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`}]]};Fe.node;var Ie=x(Fe),Le={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`}]]};Le.node;var Re=x(Le),ze={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`}]]};ze.node;var Be=x(ze),Ve={name:`search`,size:24,node:[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]};Ve.node;var He=x(Ve),Ue={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`}]]};Ue.node;var R=x(Ue),We={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`}]]};We.node;var Ge=x(We),Ke={name:`terminal`,size:24,node:[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]};Ke.node;var qe=x(Ke),Je={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`}]]};Je.node;var Ye=x(Je),Xe={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`]};Xe.node;var z=x(Xe),B={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`}},Ze={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`}},V={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)`}},$e={low:{de:`günstig`,en:`low cost`},medium:{de:`mittel`,en:`medium cost`},high:{de:`teuer`,en:`high cost`}},et={free:{de:`Kostenlos`,en:`Free`},pro:{de:`Pro`,en:`Pro`}},H=e=>Object.keys(e);H(B),H(Ze),H(Qe),H(V),H(et);var U=t(n(),1);function tt(e){switch(e.type){case`page`:return L;case`agent`:return N;case`generate`:return e.asset===`image`?I:e.asset===`video`?g:e.asset===`dashboard`?je:y;case`widget`:return M;case`surface`:return Ne;case`film`:return P;case`review`:return F;case`result`:return Ee}return z}var nt={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 rt(e){return w(`type.${e.type}`)}var it=[`web_search`,`web_fetch`,`browser`,`sandbox`,`image`,`http`,`pages`];function at(e){return it.includes(e)?w(`tool.${e}`):e}function ot(e){switch(e.type){case`page`:return e.fields.map(e=>e.label).join(` · `);case`agent`:{let t=e.tools.map(at),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?w(`editor.reviewEditable`):null,e.regenerate?w(`editor.reviewRedo`):null].filter(Boolean).join(` · `);case`result`:return e.deliverables.map(e=>`${e.label??e.from} (${e.formats.join(`, `)})`).join(` · `)}return``}var st=e({EntryDialog:()=>Q,MarketplaceBrowser:()=>Et,MarketplaceCards:()=>Tt,MarketplaceHits:()=>wt,ProChip:()=>mt,useSettled:()=>$}),W=t(r(),1),ct=(0,U.lazy)(()=>f(()=>import(`./FlowPreview-86xWWfdk.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13]))),lt={useCase:``,industry:``,format:``,capability:``,plan:``},G=(e,t)=>e[t]?.[p]??t;function ut(e){if(e<1)return 1;let t=10**Math.floor(Math.log10(e));return Math.round(e/t)*t}function dt(e){return e.credits?w(`market.credits`,{n:ut(e.credits.credits)}):$e[e.costTier][p]}var ft={text:Ye,document:y,table:Ge,image:I,video:g,audio:D,dashboard:me};function K({format:e,className:t}){let n=ft[e],r=G(B,e);return(0,W.jsx)(`span`,{title:r,className:`inline-flex`,children:(0,W.jsx)(n,{className:t,"aria-label":r,role:`img`})})}var pt=[`low`,`medium`,`high`];function q({entry:e}){let t=pt.indexOf(e.costTier)+1,n=p===`de`?ve:ge;return(0,W.jsxs)(`span`,{title:dt(e),className:`inline-flex items-center gap-1`,children:[(0,W.jsx)(`span`,{"aria-hidden":`true`,className:`inline-flex shrink-0`,children:pt.slice(0,t).map((e,t)=>(0,W.jsx)(`span`,{className:_(`rounded-full bg-(--coin-bg,var(--color-card))`,t>0&&`-ml-1.5`),children:(0,W.jsx)(n,{className:`size-4`})},e))}),$e[e.costTier][p]]})}function mt(){return(0,W.jsx)(S,{tone:`ember`,title:w(`market.proHint`),children:w(`market.pro`)})}function ht({plugin:e}){return(0,W.jsx)(S,{icon:(0,W.jsx)(Re,{className:`size-3.5`}),title:w(`market.fromPlugin`,{name:e.name}),children:e.name})}function gt({entry:e,onOpen:t}){return(0,W.jsxs)(k,{role:`button`,tabIndex:0,onClick:t,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t())},className:_(`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,W.jsx)(`span`,{className:`-top-4 pointer-events-none absolute right-4`,children:(0,W.jsx)(re,{kind:e.avatar,size:68})}),(0,W.jsxs)(`div`,{className:`min-w-0 pr-20`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5 font-display font-semibold text-[0.9375rem]`,children:[e.title,e.plan===`pro`?(0,W.jsx)(mt,{}):null,e.starred?(0,W.jsx)(R,{className:`size-3.5 shrink-0 fill-amber text-amber`,"aria-label":w(`market.starred`)}):null]}),(0,W.jsx)(`div`,{className:`mt-0.5 text-[0.8125rem] text-ink-3 leading-snug`,children:e.pitch})]}),(0,W.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,W.jsx)(ht,{plugin:e.plugin}):null,e.needs?.length?(0,W.jsx)(S,{tone:`warn`,children:w(`market.needsPro`,{list:e.needs.join(`, `)})}):e.usable&&e.missing.length?(0,W.jsx)(S,{tone:`warn`,children:w(`market.missing`,{list:Y(e.missing)})}):e.usable?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,W.jsx)(O,{className:`size-3.5`}),` `,w(`market.minutes`,{n:e.effort.minutes})]}),(0,W.jsx)(q,{entry:e}),e.optional?.length?(0,W.jsx)(S,{title:w(`market.optionalHint`,{list:Y(e.optional)}),children:w(`market.without`,{list:Y(e.optional)})}):null,(0,W.jsx)(`span`,{className:`ml-auto inline-flex items-center gap-1.5`,children:e.formats.map(e=>(0,W.jsx)(K,{format:e,className:`size-4`},e))})]}):(0,W.jsx)(S,{tone:`warn`,children:w(`market.needsUpdate`)})]})]})}function J({title:e,children:t}){return(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`mb-1.5 font-medium text-[0.75rem] text-ink-3 uppercase tracking-[0.06em]`,children:e}),t]})}var Y=e=>e.map(e=>G(V,e)).join(`, `),_t={text:v,web:Oe,browser:m,documents:Be,image:I,video:g,speech:ie,listening:h,code:qe,connectors:Ie,film:P};function vt(e){switch(e.type){case`page`:return L;case`agent`:return N;case`generate`:return e.asset===`image`?I:e.asset===`video`?g:e.asset===`voice`?ie:e.asset===`dashboard`?me:y;case`widget`:return e.video?P:M;case`surface`:return M;case`film`:return P;case`review`:return F;case`result`:return Ee}return z}function yt(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 bt(e){let t=yt(e);return e.map(e=>({id:e.id,title:e.title,icon:vt(e),tone:nt[e.type]??`bg-paper-2 text-ink-2`,optional:t.has(e.id),branches:e.branches}))}function X({title:e,children:t}){return(0,W.jsx)(`span`,{title:e,className:`inline-flex items-center gap-2 border-border border-l px-4 first:border-l-0 first:pl-0`,children:t})}function Z({icon:e,children:t,more:n}){return(0,W.jsxs)(`div`,{className:`flex gap-2.5`,children:[(0,W.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:e}),(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`div`,{className:`text-[0.875rem] text-ink leading-snug`,children:t}),n?(0,W.jsx)(`div`,{className:`text-[0.75rem] text-ink-3 leading-snug`,children:n}):null]})]})}function xt({className:e,children:t}){let n=(0,U.useRef)(null),[r,i]=(0,U.useState)({above:!1,below:!1});(0,U.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,W.jsx)(`div`,{ref:n,className:e,style:{maskImage:a,WebkitMaskImage:a},children:(0,W.jsx)(`div`,{children:t})})}function Q({id:e,fallback:t,onClose:n,onUse:r,busy:a}){let o=i(),s=A(),l=c({queryKey:[`marketplace-entry`,e,p],queryFn:()=>T.get(`/api/studio/marketplace/${encodeURIComponent(e)}?lang=${p}`),enabled:!!e,retry:!1}),u=l.data??t,f=d({mutationFn:t=>{let n=`/api/studio/marketplace/${encodeURIComponent(e)}/star`;return t?T.put(n):T.del(n)},onSuccess:()=>Promise.all([o.invalidateQueries({queryKey:[`marketplace`]}),o.invalidateQueries({queryKey:[`marketplace-entry`,e]})])}),m=j()===`dark`,h=ae[oe[u?.avatar||`round`]],g=m?`var(--card)`:`color-mix(in oklch, ${h??`var(--ink-4)`} 14%, var(--paper-2))`;return(0,W.jsx)(te,{open:!!e,onClose:n,wide:!0,bare:!0,children:u?(0,W.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,W.jsx)(`button`,{type:`button`,"aria-label":w(`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,W.jsx)(C,{className:`size-4`})}),(0,W.jsxs)(`header`,{className:`relative shrink-0 border-border-soft border-b px-5 pt-5 pb-4 text-ink sm:rounded-t-2xl sm:px-7`,style:{background:g,"--coin-bg":g},children:[(0,W.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 overflow-hidden sm:rounded-t-2xl`,children:(0,W.jsx)(`span`,{className:_(`-top-28 -right-10 absolute size-80 rounded-full bg-white blur-3xl`,m?`opacity-[0.14]`:`opacity-80`)})}),(0,W.jsx)(`div`,{className:`-bottom-5 absolute right-9 z-10 max-sm:hidden`,children:(0,W.jsx)(re,{kind:u.avatar,size:104})}),(0,W.jsxs)(`div`,{className:`relative sm:pr-36`,children:[(0,W.jsx)(`h2`,{className:`font-display font-semibold text-[1.375rem] leading-tight tracking-tight max-sm:pr-10`,children:u.title}),(0,W.jsx)(`p`,{className:`mt-1 text-[0.875rem] text-ink-2 leading-snug`,children:l.data?.description||u.pitch})]}),u.usable?(0,W.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,W.jsxs)(X,{title:w(`market.duration`),children:[(0,W.jsx)(O,{className:`size-4 text-ink-3`}),w(`market.minutes`,{n:u.effort.minutes})]}),(0,W.jsx)(X,{title:w(`market.cost`),children:(0,W.jsx)(q,{entry:u})}),(0,W.jsx)(X,{title:w(`market.result`),children:u.formats.map(e=>(0,W.jsx)(K,{format:e,className:`size-4`},e))})]}):null]}),u.usable?(0,W.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,W.jsxs)(`div`,{className:`flex flex-col gap-5 sm:min-h-0 sm:overflow-y-auto`,children:[(0,W.jsx)(J,{title:w(`market.duration`),children:(0,W.jsx)(Z,{icon:(0,W.jsx)(O,{className:`size-4 text-moss`}),more:w(`market.durationHint`,{n:u.effort.fields}),children:w(`market.minutes`,{n:u.effort.minutes})})}),(0,W.jsx)(J,{title:w(`market.cost`),children:(0,W.jsx)(Z,{icon:(0,W.jsx)(Ce,{className:`size-4 text-amber`}),more:u.credits?w(`market.creditsHint`):void 0,children:(0,W.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2`,children:[(0,W.jsx)(q,{entry:u}),u.credits?(0,W.jsx)(`span`,{className:`text-ink-2`,children:w(`market.creditsRange`,{n:ut(u.credits.credits)})}):null]})})}),(0,W.jsx)(J,{title:w(`market.result`),children:(0,W.jsx)(`div`,{className:`flex flex-col gap-2`,children:(l.data?.results??[]).map(e=>(0,W.jsx)(Z,{icon:(0,W.jsx)(K,{format:e.kind,className:`size-4 text-ember-strong`}),more:e.formats.map(e=>e.toUpperCase()).join(` · `),children:e.title},e.title))})}),(0,W.jsx)(J,{title:w(`market.needs`),children:(0,W.jsx)(`ul`,{className:`flex flex-col gap-2`,children:u.capabilities.map(e=>{let t=_t[e],n=u.missing.includes(e),r=u.optional?.includes(e);return(0,W.jsxs)(`li`,{className:_(`flex items-center gap-2.5 text-[0.875rem]`,n?`text-ink-3`:`text-ink-2`),children:[(0,W.jsx)(t,{className:_(`size-4 shrink-0`,n?`text-rose`:r?`text-amber`:`text-cobalt`)}),G(V,e),n?(0,W.jsx)(`span`,{className:`text-[0.75rem] text-rose`,children:w(`market.unavailable`)}):r?(0,W.jsx)(`span`,{className:`text-[0.75rem] text-amber`,children:w(`market.optional`)}):null]},e)})})})]}),(0,W.jsxs)(`div`,{className:`flex flex-col sm:min-h-0`,children:[(0,W.jsx)(`div`,{className:`mb-1.5 shrink-0 font-medium text-[0.75rem] text-ink-3 uppercase tracking-[0.06em]`,children:w(`market.steps`)}),(0,W.jsx)(xt,{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,W.jsx)(b,{className:`size-5 text-ink-3`}):(0,W.jsx)(U.Suspense,{fallback:(0,W.jsx)(b,{className:`size-5 text-ink-3`}),children:(0,W.jsx)(ct,{steps:bt(l.data?.outline??[])})})})]})]}):(0,W.jsx)(`div`,{className:`flex-1 px-5 pt-6 sm:px-7`,children:(0,W.jsx)(`p`,{className:`rounded-lg bg-amber-tint p-3 text-[0.875rem] text-ink-2`,children:w(`market.needsUpdateHint`)})}),(0,W.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:[u.plugin?(0,W.jsx)(`span`,{className:`mr-auto flex items-center`,children:(0,W.jsx)(ht,{plugin:u.plugin})}):(0,W.jsxs)(E,{variant:`ghost`,className:`mr-auto`,title:w(`market.starHint`),"aria-pressed":u.starred,busy:f.isPending,onClick:()=>f.mutate(!u.starred),children:[(0,W.jsx)(R,{className:_(`size-4`,u.starred&&`fill-amber text-amber`)}),(0,W.jsx)(`span`,{className:`max-sm:sr-only`,children:w(u.starred?`market.starred`:`market.star`)})]}),(0,W.jsx)(E,{variant:`secondary`,onClick:n,children:w(`common.close`)}),u.usable&&u.missing.length?(0,W.jsx)(E,{variant:`secondary`,onClick:()=>s(`/settings/models`),children:w(`editor.models.settings`)}):null,r?(0,W.jsx)(E,{disabled:!u.usable||u.missing.length>0||!!u.needs?.length,title:u.needs?.length?w(`market.needsProHint`,{list:u.needs.join(`, `)}):u.missing.length?w(`market.missingHint`,{list:Y(u.missing)}):u.optional?.length?w(`market.optionalHint`,{list:Y(u.optional)}):void 0,busy:a,onClick:()=>r(u),children:w(`market.use`)}):null]})]}):(0,W.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,W.jsx)(b,{className:`size-6 text-ink-3`}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{children:w(`market.notFound`)}),(0,W.jsx)(E,{variant:`secondary`,onClick:n,children:w(`common.close`)})]})})})}function St({name:e,value:t,options:n,onChange:r}){let[i,a]=(0,U.useState)(!1),o=(0,U.useRef)(null);(0,U.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,W.jsxs)(`div`,{ref:o,className:`relative`,children:[(0,W.jsxs)(`div`,{className:_(`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,W.jsx)(`button`,{type:`button`,"aria-haspopup":`listbox`,"aria-expanded":i,onClick:()=>a(!i),className:_(`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,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{className:`text-ink-3`,children:e}),(0,W.jsx)(`span`,{className:`font-medium`,children:s.label})]}):(0,W.jsxs)(W.Fragment,{children:[e,(0,W.jsx)(ne,{className:_(`size-3.5 transition`,i&&`rotate-180`)})]})}),s?(0,W.jsx)(`button`,{type:`button`,"aria-label":`${e}: ${w(`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,W.jsx)(C,{className:`size-3.5`})}):null]}),i?(0,W.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,W.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:_(`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,W.jsx)(`span`,{className:`flex-1 whitespace-nowrap`,children:e.label}),e.value===t?(0,W.jsx)(ee,{className:`size-4 text-ember`}):e.unavailable?(0,W.jsx)(`span`,{className:`whitespace-nowrap text-[0.75rem] text-ink-4`,children:w(`market.unavailable`)}):(0,W.jsx)(`span`,{className:`text-[0.75rem] text-ink-4 tabular-nums`,children:e.count})]},e.value))}):null]})}function $(e,t){let[n,r]=(0,U.useState)(e);return(0,U.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n}var Ct=60;function wt({query:e,onUse:t,busy:n,limit:r=6}){let[i,a]=(0,U.useState)(null),o=$(e.trim(),250),s=c({queryKey:[`marketplace`,p,o,`hits`,r],queryFn:()=>T.get(`/api/studio/marketplace?${new URLSearchParams({lang:p,limit:String(r),offset:`0`,q:o})}`),enabled:!!o,placeholderData:u}),l=o?s.data?.entries??[]:[];return l.length?(0,W.jsxs)(`section`,{className:`mt-10`,children:[(0,W.jsxs)(`h2`,{className:`mb-5 flex items-center gap-2 font-medium text-[0.8125rem] text-ink-3 uppercase tracking-[0.08em]`,children:[w(`market.hits`),s.isFetching?(0,W.jsx)(b,{className:`size-3.5`}):null]}),(0,W.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:l.map(e=>(0,W.jsx)(gt,{entry:e,onOpen:()=>a(e.id)},e.id))}),(0,W.jsx)(Q,{id:i,fallback:l.find(e=>e.id===i)??null,onClose:()=>a(null),onUse:t,busy:n})]}):null}function Tt({entries:e}){let t=i(),n=A(),{project:r}=ce(),a=se()&&!!r&&!r?.readOnly,[o,s]=(0,U.useState)(null),c=d({mutationFn:e=>T.post(`/api/studio/wizards`,{projectId:r.id,starterId:e,lang:p}),onSuccess:async({id:e})=>{await t.invalidateQueries({queryKey:[`projects`]}),await t.invalidateQueries({queryKey:[`wizards`]}),s(null),n(`/edit/${e}`)}});return(0,W.jsxs)(`div`,{className:`@container mt-3`,children:[(0,W.jsx)(`div`,{className:`grid gap-4 @xl:grid-cols-2`,children:e.map(e=>(0,W.jsx)(gt,{entry:e,onOpen:()=>s(e.id)},e.id))}),c.error?(0,W.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-rose`,children:c.error.message}):null,(0,W.jsx)(Q,{id:o,fallback:e.find(e=>e.id===o)??null,onClose:()=>s(null),onUse:a?e=>!c.isPending&&c.mutate(e.id):void 0,busy:c.isPending})]})}function Et({onUse:e,busy:t,open:n,search:r}){let[i,a]=(0,U.useState)(``);(0,U.useEffect)(()=>{r&&a(r.text)},[r]);let[o,s]=(0,U.useState)(lt),[c,l]=(0,U.useState)(!1),[d,f]=(0,U.useState)(n??null),m=$(i.trim(),250),h=ue({queryKey:[`marketplace`,p,m,o,c],queryFn:({pageParam:e})=>{let t=new URLSearchParams({lang:p,limit:String(Ct),offset:String(e)});m&&t.set(`q`,m);for(let[e,n]of Object.entries(o))n&&t.set(e,n);return c&&t.set(`starred`,`1`),T.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:u}),g=h.data?.pages[0],v=h.data?.pages.flatMap(e=>e.entries)??[],y=g?.all??0,ee=i.trim()!==m||h.isFetching&&!h.isFetchingNextPage,x=(e,t,n)=>Object.keys(t).filter(t=>g?.facets[e]?.[t]!==void 0).map(r=>({value:r,label:G(t,r),icon:n?.(r),count:(g?.facets[e])[r]??0,unavailable:e===`capability`&&S.has(r)})),S=new Set(g?.unavailable??[]),te=x(`useCase`,Qe),ne=[{key:`industry`,name:w(`market.industry`),options:x(`industry`,Ze)},{key:`format`,name:w(`market.format`),options:x(`format`,B,e=>(0,W.jsx)(K,{format:e,className:`size-4 text-ink-3`}))},{key:`plan`,name:w(`market.plan`),options:x(`plan`,et)},{key:`capability`,name:w(`market.capability`),options:x(`capability`,V,e=>{let t=_t[e];return(0,W.jsx)(t,{className:`size-4 text-ink-3`})})}],D=!!i.trim()||c||Object.values(o).some(Boolean),O=()=>{s(lt),a(``),l(!1)};if(h.isLoading)return(0,W.jsx)(`div`,{className:`flex justify-center py-10`,children:(0,W.jsx)(b,{className:`size-6 text-ink-3`})});let k=g?.offline?(0,W.jsxs)(`p`,{className:`mt-4 flex items-center justify-center gap-2 text-[0.8125rem] text-ink-3`,children:[(0,W.jsx)(xe,{className:`size-4 shrink-0`}),w(`market.offline`)]}):null;if(!y&&!D)return k;let A=i?(0,W.jsx)(`button`,{type:`button`,"aria-label":w(`market.reset`),onClick:()=>a(``),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,W.jsx)(C,{className:`size-4`})}):null,j=e=>_(`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,W.jsxs)(`div`,{children:[(0,W.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,W.jsx)(b,{className:`size-4 shrink-0 text-ink-3`}):(0,W.jsx)(He,{className:`size-4 shrink-0 text-ink-3`}),(0,W.jsx)(`input`,{type:`search`,value:i,onChange:e=>a(e.target.value),placeholder:w(`market.search`),"aria-label":w(`market.search`),className:`min-w-0 flex-1 bg-transparent text-[0.9375rem] outline-none placeholder:text-ink-4 [&::-webkit-search-cancel-button]:hidden`}),A]}),k,(0,W.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:w(`market.all`)},...te].map(e=>(0,W.jsx)(`button`,{type:`button`,"aria-pressed":!c&&o.useCase===e.value,onClick:()=>{l(!1),s({...o,useCase:e.value})},className:j(!c&&o.useCase===e.value),children:e.label},e.value)),(0,W.jsxs)(`button`,{type:`button`,"aria-pressed":c,onClick:()=>l(!c),className:j(c),children:[(0,W.jsx)(R,{className:_(`size-3.5`,c&&`fill-amber text-amber`)}),w(`market.starred`)]})]}),(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-1 gap-y-2 sm:mt-6`,children:[c?null:ne.map(e=>(0,W.jsx)(St,{name:e.name,value:o[e.key],options:e.options,onChange:t=>s({...o,[e.key]:t})},e.key)),(0,W.jsxs)(`span`,{className:`ml-auto flex items-center gap-3 whitespace-nowrap pl-2 text-[0.8125rem] text-ink-3`,children:[D?(0,W.jsxs)(`button`,{type:`button`,onClick:O,className:`inline-flex items-center gap-1 text-ember-strong underline-offset-2 hover:underline`,children:[(0,W.jsx)(C,{className:`size-3.5 max-sm:size-4`}),(0,W.jsx)(`span`,{className:`max-sm:sr-only`,children:w(`market.resetShort`)})]}):null,D?(0,W.jsx)(`span`,{className:`tabular-nums sm:hidden`,children:w(`market.countOfShort`,{n:g?.total??0,all:y})}):null,(0,W.jsx)(`span`,{className:_(`tabular-nums`,D&&`max-sm:hidden`),children:D?w(`market.countOf`,{n:g?.total??0,all:y}):w(`market.count`,{n:y})})]})]}),v.length?(0,W.jsx)(`div`,{className:`mt-4 grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:v.map(e=>(0,W.jsx)(gt,{entry:e,onOpen:()=>f(e.id)},e.id))}):(0,W.jsxs)(`div`,{className:`py-10 text-center text-[0.875rem] text-ink-3`,children:[(0,W.jsx)(`p`,{children:w(c?`market.noneStarred`:`market.none`)}),(0,W.jsx)(E,{variant:`ghost`,className:`mt-2`,onClick:O,children:w(`market.reset`)})]}),h.hasNextPage?(0,W.jsx)(`div`,{className:`mt-6 flex justify-center`,children:(0,W.jsx)(E,{variant:`secondary`,busy:h.isFetchingNextPage,onClick:()=>void h.fetchNextPage(),children:w(`market.more`)})}):null,(0,W.jsx)(Q,{id:d,fallback:v.find(e=>e.id===d)??null,onClose:()=>f(null),onUse:e,busy:t})]})}export{Oe as C,P as D,xe as E,N as O,I as S,Ce as T,He as _,mt as a,L as b,tt as c,rt as d,V as f,R as g,Ge as h,st as i,M as k,ot as l,Ye as m,Et as n,$ as o,z as p,wt as r,nt as s,Q as t,at as u,Re as v,F as w,Ne as x,Ie as y};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{C as r,b as i}from"./Marketplace-C-Vz3yEk.js";import{Mt as a,R as o,Tt as s,an as c,dn as l,kt as u,on as d}from"./ui-CMdSOoUZ.js";import{t as f}from"./phone-CI2Flerg.js";import{ot as p,st as m}from"./index-Bdx1Qity.js";var h={name:`message-square`,size:24,node:[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]};h.node;var g=l(h),_=[`text`,`data`,`image`,`video`,`voice`,`document`,`dashboard`,`widget`,`film`,`surface`];[...o],[..._];var v={default:`steps`,enabled:[`steps`,`chat`]},y=e(t(),1),b=e(n(),1),x=[{id:`steps`,group:`web`,runner:`steps`,label:`new.ch.steps`,icon:i},{id:`chat`,group:`web`,runner:`chat`,label:`new.ch.chat`,icon:m},{id:`talk`,group:`web`,runner:`talk`,label:`new.ch.talk`,icon:d},{id:`video`,group:`web`,runner:`video`,label:`new.ch.video`,icon:a},{id:`call`,group:`phone`,runner:`call`,label:`new.ch.call`,icon:f},{id:`wacall`,group:`phone`,runner:`call`,label:`new.ch.whatsapp`,icon:null},{id:`sms`,group:`message`,runner:`sms`,label:`new.ch.sms`,icon:g},{id:`whatsapp`,group:`message`,runner:`whatsapp`,label:`new.ch.whatsapp`,icon:null}],S=[{id:`web`,label:`new.web`,icon:r},{id:`phone`,label:`new.phone`,icon:f},{id:`message`,label:`new.messages`,icon:p}],C=x.filter(e=>v.enabled.includes(e.id)).map(e=>e.id),w=e=>x.filter(t=>e.includes(t.id));function T(e){return e.length===C.length&&C.every(t=>e.includes(t))}function E(e){let t=w(e),n=[...new Set(t.map(e=>e.runner))];return{default:t.find(e=>e.group===`web`)?.runner??n[0]??v.default,enabled:n}}var D=e=>e.map(e=>u(e.label));function O(e){return x.find(t=>t.runner===e)}function k(e){return x.filter(t=>t.id!==`wacall`&&e.includes(t.runner)).map(e=>e.id)}function A(e){let t=w(e),n=S.flatMap(e=>{let n=D(t.filter(t=>t.group===e.id));return n.length?[e.id===`web`?n.join(`, `):`${u(e.label)}: ${n.join(`, `)}`]:[]});return`${u(`new.runsAs`)}: ${n.join(` · `)}`}function j(e){return e.length<=2?e.join(`, `):`${e.slice(0,2).join(`, `)} +${e.length-2}`}function M({channel:e,className:t}){let n=e.icon;return n?(0,b.jsx)(n,{className:t??`size-4`}):(0,b.jsx)(`span`,{"aria-hidden":`true`,className:`font-semibold text-[0.625rem] tracking-wide`,children:`WA`})}function N(e){let t=new Set(e?.map(e=>e.id)??[`steps`,`chat`,`talk`,`video`]);return x.filter(e=>t.has(e.runner))}function P({value:e,onChange:t,runners:n,without:r,disabled:i}){let a=N(n).filter(e=>!r?.includes(e.id)),o=t=>e.includes(t.id),l=n=>{i||o(n)&&e.length===1||t(o(n)?e.filter(e=>e!==n.id):[...e,n.id])},d=t=>{let n=S.find(e=>e.id===t),r=a.filter(e=>e.group===t);if(!(n&&r.length))return null;let d=n.icon;return(0,b.jsxs)(`fieldset`,{className:`m-0 flex min-w-0 flex-col border-0 p-0`,children:[(0,b.jsxs)(`legend`,{className:`flex items-center gap-1.5 px-2 pt-2 pb-1 text-[0.75rem] text-ink-3`,children:[(0,b.jsx)(d,{className:`size-3.5`}),` `,u(n.label)]}),r.map(t=>(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(`label`,{className:s(`flex h-10 w-full cursor-pointer items-center gap-2.5 rounded-lg px-2 text-[0.875rem] transition hover:bg-accent has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-focus coarse:h-11`,o(t)&&`bg-paper-2`),children:[(0,b.jsx)(`span`,{className:`flex w-5 justify-center text-ink-3`,children:(0,b.jsx)(M,{channel:t})}),(0,b.jsx)(`span`,{className:`flex-1`,children:u(t.label)}),(0,b.jsx)(`input`,{type:`checkbox`,className:`sr-only`,"aria-label":u(t.label),checked:o(t),disabled:i,"aria-disabled":o(t)&&e.length===1,onChange:()=>l(t)}),(0,b.jsx)(`span`,{"aria-hidden":`true`,className:s(`flex size-[1.125rem] items-center justify-center rounded-md ring-1`,o(t)?`bg-ink text-paper ring-ink`:`ring-border`),children:o(t)?(0,b.jsx)(c,{className:`size-3`,strokeWidth:3}):null})]}),t.id===`call`&&o(t)?(0,b.jsx)(`p`,{className:`px-2 pb-1.5 pl-9 text-[0.75rem] text-ink-3`,children:u(`new.callHandoff`)}):null]},t.id))]})};return(0,b.jsxs)(`div`,{className:`grid gap-x-4 sm:grid-cols-2`,children:[d(`web`),(0,b.jsxs)(`div`,{className:`flex flex-col`,children:[d(`phone`),d(`message`)]})]})}function F({value:e,onChange:t,runners:n,className:r}){let[i,a]=(0,y.useState)(!1),[o,c]=(0,y.useState)(0),l=(0,y.useRef)(null);(0,y.useEffect)(()=>{if(!i)return;let e=e=>{l.current?.contains(e.target)||a(!1)},t=e=>{e.key===`Escape`&&a(!1)};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[i]);let d=N(n),f=S.filter(e=>d.some(t=>t.group===e.id)),p=t=>e.includes(t.id);return(0,b.jsxs)(`div`,{ref:l,className:s(`relative flex flex-wrap items-center gap-1.5`,r),children:[(0,b.jsx)(`span`,{className:`mr-0.5 px-1 text-[0.8125rem] text-ink-3`,children:u(`new.runsAs`)}),f.map(e=>{let t=D(d.filter(t=>t.group===e.id&&p(t))),n=e.icon;return(0,b.jsxs)(`button`,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i,"aria-label":`${u(e.label)}: ${t.length?t.join(`, `):u(`new.off`)}`,onClick:e=>{let t=e.currentTarget;c(t.offsetLeft+t.offsetWidth/2),a(e=>!e)},className:s(`inline-flex h-9 items-center justify-center gap-1.5 rounded-full font-medium text-[0.8125rem] transition coarse:h-11`,t.length?`bg-ink px-3 text-paper`:`w-9 text-ink-3 ring-1 ring-border hover:text-ink coarse:w-11`),children:[(0,b.jsx)(n,{className:`size-4 shrink-0`}),t.length?(0,b.jsx)(`span`,{className:`truncate`,children:j(t)}):null]},e.id)}),i?(0,b.jsxs)(`div`,{role:`dialog`,"aria-label":u(`new.where`),style:{transformOrigin:`${o}px top`},className:`absolute top-full left-0 z-20 mt-2 w-[min(32rem,calc(100vw-2rem))] animate-unfold rounded-2xl bg-card p-3 text-left shadow-overlay ring-1 ring-border`,children:[(0,b.jsx)(`p`,{className:`px-2 pt-1 font-semibold text-[0.9375rem]`,children:u(`new.where`)}),(0,b.jsx)(P,{value:e,onChange:t,runners:n})]}):null]})}export{C as a,k as c,F as i,T as l,M as n,A as o,P as r,O as s,S as t,E as u};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{O as r,r as i,v as a}from"./logo-C4V2_3Ar.js";import{a as o,n as s,o as c,t as l}from"./Marketplace-C-Vz3yEk.js";import{t as u}from"./useMutation-DKyQXgyj.js";import{Bt as d,Dt as f,Tt as p,Wt as m,a as h,c as g,cn as _,dt as v,ft as y,hn as b,i as x,jt as S,kt as C,l as w,lt as T,o as ee,r as te,s as ne,st as E,v as D,wt as O,xn as re,yn as k}from"./ui-CMdSOoUZ.js";import{a as ie,i as ae,l as A,o as j,u as M}from"./NewWizardChannels-Cc7gDitg.js";import{r as oe}from"./brand-BamUjXVr.js";import{t as N}from"./upload-Cz9HgBT9.js";import{d as P,s as F}from"./session-BEHF6g4Y.js";var I=[[`id`,8],[`toolId`,10],[`moduleId`,7],[`pluginId`,6],[`title`,6],[`description`,4],[`tags`,3],[`path`,3],[`inputSchema`,2],[`outputSchema`,2],[`request`,1],[`response`,1]];function L(e){return e.normalize(`NFKD`).replace(/[̀-ͯ]/g,``).replace(/([a-z])([A-Z])/g,`$1 $2`).toLowerCase()}function R(e){return L(e).split(/[^a-z0-9]+/).map(e=>e.trim()).filter(e=>e.length>1)}function z(e){return e==null?``:Array.isArray(e)?e.map(z).filter(Boolean).join(` `):typeof e==`object`?Object.values(e).map(z).filter(Boolean).join(` `):String(e)}function B(e,t){let n=t.map(([t,n])=>({text:z(e[t]),weight:n})).filter(e=>e.text.length>0);return{fields:n,tokens:n.flatMap(e=>R(e.text))}}function V(e){let t=[e];if(e.length<5)return t;if(e.endsWith(`ing`)){let n=e.slice(0,-3);n.length>=3&&t.push(n,`${n}e`)}else if(e.endsWith(`ies`)&&e.length>=6)t.push(`${e.slice(0,-3)}y`);else if(e.endsWith(`es`))t.push(e.slice(0,-2),e.slice(0,-1));else if(e.endsWith(`ed`)){let n=e.slice(0,-2);t.push(n,`${n}e`)}else e.endsWith(`s`)&&!e.endsWith(`ss`)&&t.push(e.slice(0,-1));return[...new Set(t)]}function H(e,t){if(e===t)return 1;let n=0;for(let r of V(e))for(let i of V(t)){if(r===i){n=Math.max(n,r===e&&i===t?1:.75);continue}r.length>=2&&i.startsWith(r)&&(n=Math.max(n,.55*(r.length/i.length))),i.length>=4&&r.startsWith(i)&&(n=Math.max(n,.4*(i.length/r.length)))}return n}function U(e,t){return e.reduce((e,n)=>e+H(t,n),0)}function W(e,t,n=I){if(!t?.trim())return 0;let r=R(t);if(r.length===0)return 0;let i=B(e,n);return i.tokens.length===0?0:r.reduce((e,t)=>U(i.tokens,t)===0?e:e+i.fields.reduce((e,n)=>{let r=R(n.text),i=U(r,t);if(i===0)return e;let a=i*2.2/(i+1.2+r.length/16);return e+n.weight*a},0),0)}var G=new Set(R(`aber als also am an auch auf aus bei bin bitte brauche brauchen braucht das dass dem den der
|
|
2
|
-
des die dies diese dieser doch du ein eine einem einen einer eines er es etwas fuer für gerne
|
|
3
|
-
habe haben hat ich ihr im in ist kann können koennen mache machen mag mein meine meinem meinen
|
|
4
|
-
meiner mich mir mit möchte moechte nach nicht noch nur oder sich sie sind soll suche suchen
|
|
5
|
-
sucht um und uns unser unsere vom von vor was wie will wir wird wo wollen zu zum zur
|
|
6
|
-
a about an and are as at be can do for from have how i in is it like looking me my need of on
|
|
7
|
-
or our that the this to want we what which who with would you your`)),K=e=>e.replace(/ß/g,`ss`);function q(e){let t=R(K(e)),n=t.filter(e=>!G.has(e));return n.length?n:t}var J=e=>e.trim().split(/\s+/).filter(Boolean).length>=3,Y=e(t(),1),X=e(n(),1);function se({variant:e=`secondary`,label:t=C(`home.import`)}){let n=k(),i=r(),{project:a}=F(),o=P(),s=(0,Y.useRef)(null),c=u({mutationFn:e=>w.upload(`/api/studio/projects/${a.id}/wizards/import`,e),onSuccess:async({id:e})=>{await i.invalidateQueries({queryKey:[`projects`]}),await i.invalidateQueries({queryKey:[`wizards`]}),n(`/edit/${e}`)}}),l=c.error instanceof E?c.error.body?.issues??[]:[];return!o||a?.readOnly?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(T,{variant:e,busy:c.isPending,disabled:!a,onClick:()=>s.current?.click(),children:[(0,X.jsx)(N,{className:`size-4`}),` `,t]}),(0,X.jsx)(`input`,{ref:s,hidden:!0,type:`file`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&c.mutate(t)}}),(0,X.jsxs)(y,{open:c.isError,onClose:c.reset,title:C(`import.failed`),children:[(0,X.jsx)(`p`,{className:`text-[0.875rem] text-ink-2`,children:c.error?.message}),l.length?(0,X.jsx)(`ul`,{className:`mt-3 flex list-disc flex-col gap-1 pl-5 text-[0.8125rem] text-ink-2`,children:l.slice(0,8).map(e=>(0,X.jsx)(`li`,{children:e.message},e.message))}):null,(0,X.jsx)(`div`,{className:`mt-5 flex justify-end`,children:(0,X.jsx)(T,{variant:`secondary`,onClick:c.reset,children:C(`common.close`)})})]})]})}var Z=10,Q=3;async function ce(e,t){let n=await fetch(D(`/api/studio/wizards/${e}/files/${encodeURIComponent(t.name)}`),{method:`PUT`,credentials:`include`,headers:{"content-type":t.type||`application/octet-stream`},body:t});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??n.statusText)}}function $({over:e,onClick:t}){return(0,X.jsx)(`button`,{type:`button`,"aria-label":C(`editor.detach`),onClick:t,className:p(`inline-flex shrink-0 items-center justify-center rounded-full`,e?`-top-1.5 -right-1.5 absolute size-5 bg-ink text-paper shadow-soft coarse:size-7`:`size-5 text-ink-3 hover:bg-paper-3 hover:text-ink coarse:size-7`),children:(0,X.jsx)(S,{className:`size-3`})})}function le(e,t){let n=q(t);if(!n.length)return[];let r=e.map(e=>({w:e,score:W({title:e.title,summary:e.description},n.join(` `),[[`title`,10],[`summary`,6]])})).filter(e=>e.score>0).sort((e,t)=>t.score-e.score),i=J(t)?(r[0]?.score??0)*.4:0;return r.filter(e=>e.score>=i).slice(0,Q).map(e=>e.w)}function ue({wish:e,projectId:t,busy:n,onTake:r,onMore:s}){let u=k(),[d,p]=(0,Y.useState)(null),m=c(e.trim(),300),h=i({queryKey:[`wizards`,t,`similar`],queryFn:()=>w.get(`/api/studio/projects/${t}/wizards`)}),g=i({queryKey:[`marketplace`,f,m,`similar`],queryFn:()=>w.get(`/api/studio/marketplace?${new URLSearchParams({lang:f,limit:String(Z),offset:`0`,q:m})}`),enabled:m.length>=3,placeholderData:a});if(m.length<3)return null;let _=le(h.data??[],m),y=(g.data?.entries??[]).slice(0,Z-_.length),b=(g.data?.total??0)-y.length;if(!(_.length||y.length))return null;let x=`flex items-center gap-3 rounded-xl bg-card py-2 pr-2 pl-3.5 ring-1 ring-border-soft`;return(0,X.jsxs)(`section`,{className:`mt-5`,children:[(0,X.jsx)(`h2`,{className:`mb-2 px-1 text-[0.8125rem] text-ink-3`,children:C(`new.similar`)}),(0,X.jsxs)(`ul`,{className:`flex flex-col gap-1.5`,children:[_.map(e=>(0,X.jsxs)(`li`,{className:x,children:[(0,X.jsx)(v,{children:C(`new.yours`)}),(0,X.jsxs)(`button`,{type:`button`,onClick:()=>u(`/edit/${e.id}`),className:`min-w-0 flex-1 text-left`,children:[(0,X.jsx)(`span`,{className:`block truncate font-medium text-[0.9375rem]`,children:e.title}),(0,X.jsx)(`span`,{className:`block truncate text-[0.8125rem] text-ink-3`,children:e.description})]}),(0,X.jsx)(T,{variant:`secondary`,size:`sm`,onClick:()=>u(`/edit/${e.id}`),children:C(`new.open`)})]},e.id)),y.map(e=>(0,X.jsxs)(`li`,{className:x,children:[(0,X.jsx)(v,{children:C(`new.template`)}),(0,X.jsxs)(`button`,{type:`button`,onClick:()=>p(e.id),className:`min-w-0 flex-1 text-left`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`truncate font-medium text-[0.9375rem]`,children:e.title}),e.plan===`pro`?(0,X.jsx)(o,{}):null]}),(0,X.jsx)(`span`,{className:`block truncate text-[0.8125rem] text-ink-3`,children:e.pitch})]}),(0,X.jsx)(T,{variant:`secondary`,size:`sm`,disabled:n,onClick:()=>r(e),children:C(`new.take`)})]},e.id))]}),b>0?(0,X.jsx)(`button`,{type:`button`,onClick:()=>s(m),className:`mt-2 px-1 text-[0.875rem] text-ink-2 hover:text-ink coarse:min-h-11`,children:C(`new.more`,{n:b})}):null,(0,X.jsx)(l,{id:d,fallback:y.find(e=>e.id===d)??null,onClose:()=>p(null),onUse:r,busy:n})]})}function de(){let e=k(),t=r(),{project:n}=F(),a=P(),[o]=re(),[c,l]=(0,Y.useState)(o.get(`wish`)??``),[v,y]=(0,Y.useState)(ie),[S,E]=(0,Y.useState)([]),[D,N]=(0,Y.useState)(!1),[I,L]=(0,Y.useState)(null),R=(0,Y.useRef)(null),z=(0,Y.useRef)(null),B=(0,Y.useRef)(null),[V]=g(),H=ne(c,l,{deviceId:V.deviceId}),U=i({queryKey:[`runners`],queryFn:()=>w.get(`/api/studio/runners`)}),W=e=>{let t=e.map(ee);E(e=>[...e.filter(e=>!t.some(t=>t.name===e.name)),...t])},[G,K]=(0,Y.useState)(new Map);(0,Y.useEffect)(()=>{let e=new Map(S.filter(e=>e.type.startsWith(`image/`)).map(e=>[e,URL.createObjectURL(e)]));return K(e),()=>{for(let t of e.values())URL.revokeObjectURL(t)}},[S]);let q=u({mutationFn:e=>w.post(`/api/studio/wizards`,{projectId:n.id,starterId:e,lang:f}),onSuccess:async({id:n})=>{await t.invalidateQueries({queryKey:[`projects`]}),await t.invalidateQueries({queryKey:[`wizards`]}),e(`/edit/${n}`)}}),J=u({mutationFn:async()=>{let e=B.current??(await w.post(`/api/studio/wizards`,{projectId:n.id,lang:f})).id;B.current=e,A(v)||await w.patch(`/api/studio/wizards/${e}`,{runners:M(v)});for(let t of S)await ce(e,t);return e},onSuccess:async n=>{await t.invalidateQueries({queryKey:[`projects`]}),await t.invalidateQueries({queryKey:[`wizards`]});let r=c.trim();A(v)||(r+=`\n\n${j(v)}`),S.length&&(r+=`\n\n${C(`editor.attached`)}: ${S.map(e=>e.name).join(`, `)}`),e(`/edit/${n}?prompt=${encodeURIComponent(r)}`)}}),Z=()=>{c.trim()&&n&&!J.isPending&&(H.listening&&H.stop(),J.mutate())};if(!a||n?.readOnly)return(0,X.jsx)(b,{to:`/`,replace:!0});let Q=J.error??q.error;return(0,X.jsxs)(`div`,{className:`animate-rise pt-4`,children:[(0,X.jsxs)(`div`,{className:`mx-auto max-w-2xl`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,X.jsx)(oe,{kind:`sprout`,size:150,fluffy:!0}),(0,X.jsx)(`h1`,{className:`mt-2 font-display font-semibold text-[2rem] leading-tight tracking-tight sm:text-[2.375rem]`,children:C(`new.title`)}),(0,X.jsx)(`p`,{className:`mt-2 text-[0.9375rem] text-ink-3`,children:C(`new.hint`)})]}),(0,X.jsx)(ae,{value:v,onChange:y,runners:U.data,className:`mt-8 px-1`}),(0,X.jsxs)(`div`,{className:p(`relative mt-3 rounded-2xl bg-card p-2 shadow-elevated ring-1 ring-border-soft focus-within:ring-focus`,D&&`ring-2 ring-focus`),onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),N(!0))},onDragLeave:()=>N(!1),onDrop:e=>{e.preventDefault(),N(!1),W(Array.from(e.dataTransfer.files).map(h))},children:[S.length?(0,X.jsx)(`div`,{className:`flex flex-wrap items-center gap-2 px-2 pt-2 pb-1`,children:S.map((e,t)=>{let n=G.get(e),r=()=>E(e=>e.filter((e,n)=>n!==t));return n?(0,X.jsx)(x,{url:n,label:e.name,children:(0,X.jsx)($,{over:!!n,onClick:r})},`${e.name}-${t}`):(0,X.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-1.5 rounded-full bg-paper-2 py-1 pr-1 pl-2.5 text-[0.8125rem] text-ink-2`,children:[(0,X.jsx)(m,{className:`size-3.5 shrink-0 text-ink-4`}),(0,X.jsx)(`span`,{className:`truncate`,children:e.name}),(0,X.jsx)($,{over:!!n,onClick:r})]},`${e.name}-${t}`)})}):null,(0,X.jsx)(O,{autoFocus:!0,minRows:4,value:c,onChange:e=>l(e.target.value),onPaste:e=>{let t=Array.from(e.clipboardData.files);t.length&&(e.preventDefault(),W(t.map(h)))},onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&Z()},placeholder:H.listening?C(`editor.listening`):C(`new.placeholder`),className:`border-0 bg-transparent text-[1rem] shadow-none focus:ring-0`}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2 px-1 pb-1`,children:[(0,X.jsx)(`button`,{type:`button`,"aria-label":C(`editor.attach`),title:C(`editor.attach`),onClick:()=>z.current?.click(),className:`inline-flex size-10 shrink-0 items-center justify-center rounded-full border border-border text-ink transition hover:bg-paper-2 coarse:size-11`,children:(0,X.jsx)(d,{className:`size-4`})}),(0,X.jsx)(`input`,{ref:z,type:`file`,multiple:!0,hidden:!0,onChange:e=>{let t=Array.from(e.target.files??[]);e.target.value=``,W(t)}}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.75rem] text-ink-4`,children:D?C(`new.dropHint`):null}),H.supported?(0,X.jsx)(te,{speech:H}):null,(0,X.jsxs)(T,{size:`md`,onClick:Z,busy:J.isPending,disabled:!c.trim()||q.isPending,children:[C(`new.build`),` `,(0,X.jsx)(_,{className:`size-4`})]})]})]}),H.error?(0,X.jsx)(`p`,{className:`mt-2 px-3 text-[0.75rem] text-rose`,children:H.error===`denied`?C(`editor.micDenied`):H.error}):null,Q?(0,X.jsx)(`p`,{className:`mt-3 text-center text-[0.875rem] text-rose`,children:Q.message}):null,n?(0,X.jsx)(ue,{wish:c,projectId:n.id,busy:q.isPending||J.isPending,onTake:e=>!q.isPending&&q.mutate(e.id),onMore:e=>{L({text:e}),R.current?.scrollIntoView({behavior:`smooth`,block:`start`})}}):null]}),(0,X.jsxs)(`section`,{ref:R,className:`mx-auto max-w-5xl scroll-mt-6`,children:[(0,X.jsx)(`h2`,{className:`mt-16 mb-5 text-center font-medium text-[0.8125rem] text-ink-3 uppercase tracking-[0.08em]`,children:C(`new.orStarter`)}),(0,X.jsx)(s,{open:o.get(`starter`),search:I,busy:q.isPending,onUse:e=>n&&!q.isPending&&q.mutate(e.id)})]}),(0,X.jsx)(`div`,{className:`mt-8 flex justify-center`,children:(0,X.jsx)(se,{variant:`ghost`,label:C(`new.import`)})})]})}export{de as NewWizardPage};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{O as r,r as i}from"./logo-C4V2_3Ar.js";import{_ as a,g as o,m as s,p as c,v as l,w as u}from"./Marketplace-C-Vz3yEk.js";import{t as d}from"./useMutation-DKyQXgyj.js";import{Bt as f,Dt as p,Jt as m,Nt as h,Rt as g,St as _,T as v,Tt as y,Vt as ee,Wt as te,Yt as b,Zt as x,an as S,bn as ne,bt as C,dn as re,dt as w,ft as T,gt as E,hn as D,ht as O,kt as k,l as A,lt as j,mt as M,pt as ie,sn as ae,ut as N,vn as oe,wt as P,xn as se,xt as F,yn as ce,yt as I}from"./ui-CMdSOoUZ.js";import{_ as le,a as ue,b as L,c as de,d as fe,f as R,g as pe,h as me,i as he,l as ge,m as _e,n as z,o as ve,p as ye,s as be,u as xe,v as Se,x as B,y as V}from"./RunDrawer-B0gJzdxH.js";import{t as H}from"./phone-CI2Flerg.js";import{n as U,r as Ce,t as W}from"./ReadOnly-mhKW496R.js";import{t as G}from"./upload-Cz9HgBT9.js";import{c as K,l as we,s as Te}from"./session-BEHF6g4Y.js";import{A as q,D as J,E as Y,F as Ee,H as De,I as X,M as Oe,N as ke,O as Ae,P as je,_ as Me,ct as Ne,d as Pe,f as Fe,g as Ie,j as Le,k as Re,l as ze,lt as Be,p as Ve,s as He,u as Ue,v as We}from"./index-Bdx1Qity.js";import{a as Z,c as Ge,f as Ke,i as qe,n as Je,o as Ye,r as Xe,s as Ze,t as Qe,u as $e}from"./settings-menu-BOOPxcJH.js";import{t as et}from"./RunnerView-CTRFgyu5.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=re(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=re(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:k(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(k(`project.removeConfirm`,{name:e.name}))&&t.remove(e.id)}function ct({projectId:e,file:t,small:n}){let r=Oe(e,t.id);return t.mime.startsWith(`image/`)?(0,$.jsx)(`img`,{src:r,alt:``,loading:`lazy`,className:y(`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)(b,{className:n?`size-5`:`size-7`})})}function lt({projectId:e,kind:t,files:n,actions:r,accept:i,addLabel:a,onPreview:s}){return(0,$.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(184px,1fr))] gap-3`,children:[n.map((i,a)=>(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`&&a===0?(0,$.jsx)(`span`,{className:`absolute -top-3 left-3 z-10 rounded-full ring-2 ring-card`,children:(0,$.jsx)(w,{tone:`ember`,children:k(`project.logoMain`)})}):null,(0,$.jsxs)(`div`,{className:`relative h-28 overflow-hidden rounded-md bg-paper-2`,style:t===`logo`?at:void 0,children:[s&&i.mime.startsWith(`image/`)?(0,$.jsx)(`button`,{type:`button`,"aria-label":`${k(`project.preview`)}: ${i.name}`,onClick:()=>s(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:[s?(0,$.jsx)(M,{label:k(`project.preview`),onClick:()=>s(i),className:`size-8 bg-card shadow-soft`,children:(0,$.jsx)(u,{className:`size-4`})}):null,t===`logo`&&a>0&&!r.readOnly?(0,$.jsx)(M,{label:k(`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)(M,{label:k(`project.remove`),onClick:()=>st(i,r),className:`size-8 bg-card shadow-soft hover:text-rose`,children:(0,$.jsx)(h,{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)),a&&!r.readOnly?(0,$.jsxs)(J,{accept:i,multiple:!1,onFiles:e=>r.upload(t,e),className:`min-h-28 flex-col p-3`,children:[r.busy?(0,$.jsx)(C,{className:`size-5`}):(0,$.jsx)(f,{className:`size-5`}),a]}):null]})}function ut({projectId:e,data:t,readOnly:n}){let r=je(e,n);return(0,$.jsxs)(q,{title:k(`project.logos`),hint:k(`project.logosHint`),children:[(0,$.jsx)(lt,{projectId:e,kind:`logo`,files:t.files.filter(e=>e.kind===`logo`),actions:r,accept:`image/*`,addLabel:k(`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),Le(e.size)].filter(Boolean).join(` · `);function ft({projectId:e,file:t,actions:n,onClose:r}){let i=Oe(e,t.id);return(0,$.jsxs)(T,{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":k(`project.openOriginal`),title:k(`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)(x,{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":`${k(`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)(M,{label:k(`project.preview`),onClick:r,children:(0,$.jsx)(u,{className:`size-4`})}),n.readOnly?null:(0,$.jsx)(M,{label:k(`project.remove`),onClick:()=>st(t,n),className:`hover:text-rose`,children:(0,$.jsx)(h,{className:`size-4`})})]})]})}function mt({projectId:e,data:t,readOnly:n}){let r=je(e,n),[i,a]=Ee(`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)(q,{title:k(`project.assets`),hint:k(`project.assetsHint`),children:[u.length?(0,$.jsx)(Ae,{layout:i,onToggle:a,children:(0,$.jsx)(Re,{value:o,onChange:s,placeholder:k(`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:k(`project.staysLocal`)}):(0,$.jsxs)(J,{accept:`image/*,video/*,audio/*`,onFiles:e=>r.upload(`asset`,e),className:`h-16 w-full`,children:[r.busy?(0,$.jsx)(C,{className:`size-4`}):(0,$.jsx)(G,{className:`size-4`}),k(`project.drop`),` `,(0,$.jsx)(`span`,{className:`underline`,children:k(`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:()=>A.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?k(`project.pages`,{n:e.pages}):null,Le(e.size)].filter(Boolean).join(` · `),vt=2e5;function yt({projectId:e,fileId:t,readOnly:n,onGone:i}){let a=r(),o=X(e),s=_e(e),c=je(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)(C,{className:`mx-auto text-ink-3`}):null;let p=d??(u?`original`:`text`),m=s.data?.items.find(e=>e.key===`f:${l.id}`),_=Oe(e,l.id),v=(e,t)=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":p===e,onClick:()=>f(e),className:y(`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:_,target:`_blank`,rel:`noreferrer`,"aria-label":k(`project.openOriginal`),title:k(`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)(x,{className:`size-4`})}),n?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(M,{label:k(`project.reindex`),onClick:async()=>{await c.reindex(l.id),await a.invalidateQueries({queryKey:[`knowledge`,e]})},children:(0,$.jsx)(g,{className:`size-4`})}),(0,$.jsx)(M,{label:k(`know.deleteFile`),className:`hover:text-rose`,onClick:async()=>{confirm(k(`data.confirmDelete`,{title:l.name}))&&(await c.remove(l.id),await a.invalidateQueries({queryKey:[`knowledge`,e]}),i())},children:(0,$.jsx)(h,{className:`size-4`})})]})]}),(0,$.jsx)(R,{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)(N,{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?v(`original`,k(`project.original`)):null,v(`text`,k(`project.readText`))]}),p===`original`?l.mime===`application/pdf`?(0,$.jsx)(`iframe`,{src:_,title:l.name,className:`h-[70dvh] w-full rounded-b-xl bg-paper-2`}):(0,$.jsx)(`img`,{src:_,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)(C,{})}):n.data?.text?(0,$.jsxs)(`div`,{className:`overflow-x-auto p-4 sm:p-5`,children:[(0,$.jsx)(v,{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:k(`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:k(`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)(T,{open:!0,onClose:t,title:k(`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)(E,{children:k(`project.colorValue`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(F,{value:o?n:`#888888`,onChange:e=>r(e.target.value)}),(0,$.jsx)(O,{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)(E,{children:k(`project.colorUseLabel`)}),(0,$.jsx)(O,{autoFocus:!0,value:i,maxLength:120,placeholder:k(`project.colorName`),onChange:e=>a(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:k(`project.colorUse`)})]}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(j,{variant:`ghost`,onClick:t,children:k(`common.cancel`)}),(0,$.jsx)(j,{type:`submit`,disabled:!o,children:k(`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=ke(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)(q,{title:k(`project.colors`),hint:k(`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)(F,{value:Mt.test(e.value)?e.value:`#888888`,onChange:t=>l(e.id,{value:t.target.value})}),(0,$.jsx)(O,{value:e.name,placeholder:k(`project.colorName`),maxLength:120,onChange:t=>l(e.id,{name:t.target.value}),className:`min-w-0 flex-1`}),(0,$.jsx)(O,{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)(w,{tone:`ember`,children:k(`project.colorAccent`)})}):n?null:(0,$.jsx)(M,{label:k(`project.colorFirst`),onClick:()=>a(t=>[e,...t.filter(t=>t.id!==e.id)]),children:(0,$.jsx)(ae,{className:`size-4`})}),n?null:(0,$.jsx)(M,{label:k(`project.remove`),onClick:()=>a(t=>t.filter(t=>t.id!==e.id)),className:`hover:text-rose`,children:(0,$.jsx)(h,{className:`size-4`})})]})]},e.id))}),i.length&&!n?(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:k(`project.colorUse`)}):null,i.length<jt.colors&&!n?(0,$.jsxs)(j,{variant:`secondary`,size:`sm`,className:i.length?`mt-3`:void 0,onClick:()=>s(!0),children:[(0,$.jsx)(f,{className:`size-4`}),` `,k(`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:s,longtext:Ce,number:L,date:B,url:m,email:Ne,phone:H,boolean:V};function Lt({type:e,detected:t,onChange:n}){let[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(!1),s=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(!r)return;let e=e=>{s.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=`${k(`project.factType`)}: ${k(`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:s,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:y(`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:y(`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)(c,{className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1`,children:k(`project.factAuto`)}),(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:k(`project.type.${t}`)}),(0,$.jsx)(S,{className:y(`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:k(`project.type.${t}`)}),(0,$.jsx)(S,{className:y(`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=ke(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)(q,{title:k(`project.facts`),hint:k(`project.factsHint`),save:s,locked:n,action:a.length<jt.facts&&!n?(0,$.jsxs)(j,{variant:`secondary`,size:`sm`,onClick:()=>l({},`label`,!0),children:[(0,$.jsx)(f,{className:`size-4`}),` `,k(`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)(O,{ref:u(`${e.id}:label`),value:e.label,placeholder:k(`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)(_,{checked:Ft(e.value),label:e.label,onChange:t=>c(e.id,{value:k(t?`project.yes`:`project.no`)})}),(0,$.jsx)(`span`,{className:`text-[0.875rem] text-ink-2`,children:Ft(e.value)?k(`project.yes`):k(`project.no`)})]}):(0,$.jsx)(P,{ref:u(`${e.id}:value`),rows:1,minRows:r===`longtext`?2:1,maxRows:10,value:e.value,placeholder:k(`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)(M,{label:k(`project.remove`),onClick:()=>o(t=>t.filter(t=>t.id!==e.id)),className:`size-11 rounded-lg hover:text-rose`,children:(0,$.jsx)(h,{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)(j,{variant:`secondary`,size:`sm`,onClick:()=>l({},`label`),children:[(0,$.jsx)(f,{className:`size-4`}),` `,k(`project.factAdd`)]}),d.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>l({key:e.key,label:p===`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)(f,{className:`size-3.5`}),` `,p===`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=ke({name:n.trim(),about:i.trim()},e=>t({brand:e}));return(0,$.jsx)(q,{title:k(`project.base`),hint:k(`project.baseHint`),save:o,locked:e.readOnly,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(E,{children:k(`project.title`)}),(0,$.jsx)(O,{value:n,maxLength:120,onChange:e=>r(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:k(`project.titleHint`)})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(E,{children:k(`project.about`)}),(0,$.jsx)(P,{minRows:4,value:i,onChange:e=>a(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:k(`project.aboutHint`)})]})]})})}function Bt({project:e,group:t,children:n}){let i=r(),a=X(e.id),[o,s]=(0,Q.useState)(0),c=async t=>{await A.patch(`/api/studio/projects/${e.id}`,t),await i.invalidateQueries({queryKey:[`projects`]})},l=d({mutationFn:()=>A.del(`/api/studio/projects/${e.id}`),onSuccess:()=>i.invalidateQueries({queryKey:[`projects`]})}),u=we(),f=K(),p=a.data??{files:[],embeddings:!0},m=`${e.id}:${o}`,h=e.readOnly,g=t===`knowledge`;return De(h?{}:{title:k(g?`project.assistantTitleKnowledge`:`project.assistantTitle`),hello:k(g?`project.assistantHelloKnowledge`:`project.assistantHello`),placeholder:k(g?`project.assistantComposerKnowledge`:`project.assistantComposer`),suggestions:g?[{label:k(`assistant.suggest.knowledgeHow`)},{label:k(`assistant.suggest.knowledgeSite`),fill:!0},{label:k(`assistant.suggest.knowledgeCategories`)}]:[{label:k(`assistant.suggest.readSite`),fill:!0},{label:k(`assistant.suggest.missing`)},{label:k(`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)(W,{children:U(e)}):null,t===`info`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Y,{id:`base`,children:(0,$.jsx)(zt,{project:e,save:c},`base:${m}`)}),(0,$.jsx)(Y,{id:`logos`,children:(0,$.jsx)(ut,{projectId:e.id,data:p,readOnly:h})}),(0,$.jsx)(Y,{id:`colors`,children:(0,$.jsx)(Pt,{colors:e.brand.colors??[],save:e=>c({brand:{colors:e}}),readOnly:h},`colors:${m}`)}),(0,$.jsx)(Y,{id:`assets`,children:(0,$.jsx)(mt,{projectId:e.id,data:p,readOnly:h})}),(0,$.jsx)(Y,{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)(j,{variant:`danger`,busy:l.isPending,onClick:()=>confirm(`${k(`settings.delete`)}?`)&&l.mutate(),children:k(`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:()=>A.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)(a,{className:`-translate-y-1/2 pointer-events-none absolute top-1/2 left-3 size-4 text-ink-3`}),(0,$.jsx)(O,{type:`search`,value:n,onChange:e=>r(e.target.value),placeholder:k(`space.resultsSearch`),"aria-label":k(`space.resultsSearch`),className:`w-full pl-9`})]}),(0,$.jsx)(I,{value:e.mode,onChange:n=>t({...e,mode:n}),options:[{value:``,label:k(`space.resultsModeAll`)},{value:`live`,label:`Live`},{value:`test`,label:`Test`}],className:`w-32`}),(0,$.jsx)(I,{value:String(e.days),onChange:n=>t({...e,days:Number(n)}),options:[{value:`0`,label:k(`space.resultsAnyTime`)},{value:`1`,label:k(`space.resultsDay`)},{value:`7`,label:k(`space.resultsDays`,{n:7})},{value:`30`,label:k(`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(p,{dateStyle:`medium`,timeStyle:`short`});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(q,{title:t?o(t):k(`space.resultsAll`),hint:k(`space.resultsHint`),plain:!0,children:[(0,$.jsx)(Ut,{filter:n,onFilter:r}),e.runs.length?(0,$.jsx)(N,{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))} · `,k(`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:k(`space.resultFiles`,{n:e.assets}),children:[(0,$.jsx)(te,{className:`size-3.5`}),e.assets]}):null,e.mode===`test`?(0,$.jsx)(w,{children:`Test`}):(0,$.jsxs)(w,{tone:`live`,children:[`Live v`,e.version]})]},e.id))}):(0,$.jsx)(N,{children:(0,$.jsx)(ie,{children:n.q.trim()||n.mode||n.days?k(`space.resultsNone`):k(`space.resultsEmpty`)})})]}),i?(0,$.jsx)(z,{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)(w,{children:`Test`}):(0,$.jsxs)(w,{tone:`live`,children:[`Live v`,i.version]})]}),onClose:()=>a(null),children:(0,$.jsx)(et,{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)(M,{label:k(`project.rename`),onClick:()=>{a(e.name),r(!0)},children:(0,$.jsx)(ee,{className:`size-4`})}),(0,$.jsx)(T,{open:n,onClose:()=>r(!1),title:k(`project.rename`),children:(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),i.trim()&&o.mutate()},children:[(0,$.jsx)(O,{"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)(j,{variant:`ghost`,onClick:()=>r(!1),children:k(`common.cancel`)}),(0,$.jsx)(j,{type:`submit`,busy:o.isPending,disabled:!i.trim(),children:k(`settings.save`)})]})]})})]})}function Kt({project:e}){let t=r();return(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(We,{}),e.readOnly?null:(0,$.jsx)(Gt,{project:e,save:async n=>{await A.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=Ie(),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??l,label:e.label,selected:e.id===t,onPick:()=>n(e.id)},e.id));return e.label?(0,$.jsx)(qe,{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}=ne(),[t,n]=se(),r=ce(),i=oe(),{hash:a}=i,{project:o,loading:s}=Te(),l=we(),u=ze(),d=$e(),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(null),v=Pe(e)?e:void 0,ee=i.state?.parts===!0,te=Ve().map(e=>({...e,to:`/space/${e.id}`})),b=te.find(e=>e.id===v),x=t.get(`show`),S=v?x?2:1:0,C=d?Math.min(S,1):v&&g!==v&&!ee?1:0,re=Ke(C),w=Ke(S),T=(0,Q.useMemo)(()=>({slot:f,narrow:d,setDetail:h}),[f,d]),E=o?o.brand.name?.trim()||o.name:k(`nav.project`),O=v&&v!==`results`?Fe(v,u):[],A=v?Fe(v,u).filter(e=>e.plugin):[],j=qt([...O,...v===`results`?A:[]].flatMap(e=>e.sections.map(e=>e.id))),M=v===`results`&&x&&x!==`all`?x:null,[ae,N]=(0,Q.useState)(Vt),P=Ht(v===`results`?o?.id:void 0,M,ae),F=P.data?.wizards.find(e=>e.id===M)?.title,I=v===`data`&&x&&x!==`all`||v===`knowledge`&&x&&/^[ptfcvs]:/.test(x)?x:null,L=I?.startsWith(`s:`)?u.spaceSections.find(e=>e.id===I.slice(2)):void 0,R=v===`knowledge`&&I&&/^[ptf]:/.test(I)?I:null,z=de(v===`data`?o?.id:void 0),B=_e(v===`knowledge`?o?.id:void 0),V=Se(I?.startsWith(`v:`)?I.slice(2):``),H=B.data?.categories.find(e=>e.id===(I?.startsWith(`c:`)?I.slice(2):V.data?.category.id)),U=v===`knowledge`?L?L.label():I?.startsWith(`v:`)?V.data&&`${V.data.category.name}: ${V.data.value}`:I?.startsWith(`c:`)?H?.name:B.data?.items.find(e=>e.key===I)?.title:z.data?be(z.data).flatMap(e=>e.items).find(e=>e.key===I)?.title:void 0;Me([{label:k(`nav.project`),to:`/space`},...b?[{label:b.label,to:`/space/${b.id}`}]:[],...b&&(m??F??U)?[{label:m??F??U}]:[]]);let Ce={p:`page`,t:`table`,f:`file`,c:`kategorie`,v:`kategorie value`,s:`plugin section`};De({...v===`data`||v===`results`?{compact:!0}:{},...v===`data`?{suggestions:[{label:k(`assistant.suggest.dataWhat`)},{label:k(`assistant.suggest.dataWho`)},{label:k(`assistant.suggest.dataEdit`)}]}:v===`results`?{suggestions:[{label:k(`assistant.suggest.resultsFailed`)},{label:k(`assistant.suggest.resultsCost`)},{label:k(`assistant.suggest.resultsShare`)}]}:{},...I&&U?{open:{kind:Ce[I[0]]??`item`,id:I.slice(2),label:U}}:M&&F?{open:{kind:`wizard`,id:M,label:F}}:{}});let W=v===`results`||v===`data`||I?a.slice(1):x||a.slice(1),G=(0,Q.useRef)(``);if((0,Q.useEffect)(()=>{let e=`${v}#${W}`;W&&G.current!==e&&document.getElementById(W)&&(G.current=e,requestAnimationFrame(()=>Jt(W,!1)))},[v,W,o?.id,u.spaceSections]),!v){let t=a.slice(1),n=t?Ue(t,u):null;if(n===`knowledge`&&u.spaceSections.some(e=>e.id===t))return(0,$.jsx)(D,{to:`/space/knowledge?show=s:${t}`,replace:!0});if(n)return(0,$.jsx)(D,{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)(D,{to:`/space/info`,replace:!0,state:{parts:!0}})}if(v===`knowledge`&&!x&&u.spaceSections.some(e=>e.id===a.slice(1)))return(0,$.jsx)(D,{to:`/space/knowledge?show=s:${a.slice(1)}`,replace:!0});let K=e=>{if(d){r({search:`?show=${e}`});return}G.current=`${v}#${e}`,Jt(e,!0),r({search:``,hash:e},{replace:!0})},J=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)(Y,{id:e.id,children:(0,$.jsx)(q,{title:e.label(),hint:e.hint?.(),plain:!0,children:(0,$.jsx)(He,{of:e,children:(0,$.jsx)(e.component,{})})})},e.serial)),X=d?void 0:j;return(0,$.jsx)(Ye.Provider,{value:T,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:y(`min-w-0 md:sticky md:top-6 md:self-start`,d&&S===2&&`hidden`,d&&w===`back`&&Ge(`back`)),children:[(0,$.jsx)(Je,{title:E,open:C===1?b??null:null,onBack:()=>d?r(`/space`):_(v??null)}),(0,$.jsx)(`div`,{className:y(Ge(re)),children:C===0?(0,$.jsx)(Xe,{entries:te,current:d?void 0:b,onPick:()=>_(null)}):(0,$.jsx)(`div`,{ref:p})},C)]}),v?(0,$.jsxs)(`div`,{className:y(`min-w-0`,d&&S<2&&`hidden`,d&&w===`deeper`&&Ge(`deeper`)),children:[d?(0,$.jsx)(`div`,{className:`mb-3`,children:(0,$.jsx)(Qe,{label:b?.label??E,onBack:()=>r(`/space/${v}`)})}):null,l&&o?(0,$.jsx)(`div`,{className:`mb-6`,children:(0,$.jsx)(Kt,{project:o})}):null,v===`results`?(0,$.jsxs)(Ze,{children:[(0,$.jsxs)(`ul`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsx)(Z,{icon:nt,label:k(`space.resultsAll`),selected:!d&&!M,onPick:()=>J(`all`)}),P.data?.wizards.filter(e=>e.results||e.id===M).map(e=>(0,$.jsx)(Z,{icon:c,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===M,onPick:()=>J(e.id)},e.id))]}),(0,$.jsx)(Yt,{groups:A,current:X,onPick:K})]}):v===`data`?(0,$.jsxs)(Ze,{children:[(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,$.jsx)(Z,{icon:Be,label:k(`data.all`),selected:!d&&!I,onPick:()=>J(`all`)})}),z.data?be(z.data).map(e=>(0,$.jsx)(qe,{label:e.label,children:e.items.map(e=>(0,$.jsx)(Z,{icon:ue[e.kind],label:e.title,selected:!d&&e.key===I,onPick:()=>J(e.key)},e.key))},e.key)):null,(0,$.jsx)(Yt,{groups:A,current:X,onPick:K})]}):v===`knowledge`?(0,$.jsxs)(Ze,{children:[(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,$.jsx)(Z,{icon:Be,label:k(`know.all`),selected:!(d||I),onPick:()=>J(`all`)})}),B.data?.categories.length?(0,$.jsx)(qe,{label:k(`know.categories`),children:B.data.categories.map(e=>(0,$.jsx)(Z,{icon:me[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&&(I===`c:${e.id}`||V.data?.category.id===e.id),onPick:()=>J(`c:${e.id}`)},e.id))}):null,(0,$.jsx)(Yt,{groups:A,current:d?void 0:L?.id,onPick:e=>J(`s:${e}`)})]}):(0,$.jsx)(Ze,{children:(0,$.jsx)(Yt,{groups:O,current:X,onPick:K})}),o&&(v===`info`||v===`knowledge`)?(0,$.jsxs)(Bt,{project:o,group:v,children:[v===`knowledge`?R?R.startsWith(`p:`)?(0,$.jsx)(ge,{pageId:R.slice(2),onGone:()=>J(`all`),onOpen:J},R):R.startsWith(`t:`)?(0,$.jsx)(he,{tableId:R.slice(2),onGone:()=>J(`all`)},R):(0,$.jsx)(yt,{projectId:o.id,fileId:R.slice(2),readOnly:o.readOnly,onGone:()=>J(`all`)},R):B.data?L?(0,$.jsx)(q,{title:L.label(),hint:L.hint?.(),plain:!0,children:(0,$.jsx)(He,{of:L,children:(0,$.jsx)(L.component,{})})},I):I?.startsWith(`c:`)?H?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(pe,{projectId:o.id,category:H,readOnly:o.readOnly,onOpen:J,onGone:()=>J(`all`)}),H.type===`choice`?null:(0,$.jsx)(xe,{projectId:o.id,category:H,categories:B.data.categories,onOpen:J})]},I):null:I?.startsWith(`v:`)?V.data?(0,$.jsx)(le,{value:V.data,readOnly:o.readOnly,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[V.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:V.data.items.map(e=>(0,$.jsx)(fe,{item:e,categories:B.data.categories.filter(e=>e.id!==V.data?.category.id),onOpen:J},e.key))}):null,V.data.rows.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>J(`t:${e.tableId}`),className:`px-1 text-left text-[0.8125rem] text-ink-3 hover:text-ink`,children:k(`know.tocRows`,{n:e.count,table:e.title})},e.tableId))]})},I):null:(0,$.jsx)(Y,{id:`documents`,children:(0,$.jsx)(ye,{projectId:o.id,data:B.data,readOnly:o.readOnly,onOpen:J})}):null:null,v===`info`?Ee(A):null]},o.id):null,o&&v===`data`?(0,$.jsx)(`div`,{className:`flex flex-col gap-9 pb-20`,children:I?.startsWith(`t:`)?(0,$.jsx)(he,{tableId:I.slice(2),onGone:()=>J(`all`)},I):I?.startsWith(`p:`)?(0,$.jsx)(ge,{pageId:I.slice(2),onGone:()=>J(`all`)},I):(0,$.jsxs)($.Fragment,{children:[z.data?(0,$.jsx)(ve,{projectId:o.id,data:z.data,readOnly:o.readOnly,onOpen:J}):null,Ee(A)]})}):null,o&&v===`results`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[P.data?(0,$.jsx)(Wt,{data:P.data,wizardId:M,filter:ae,onFilter:N}):null,P.isError?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:P.error.message}):null,Ee(A)]}):null,o||s?null:(0,$.jsx)(ie,{children:k(`settings.noProject`)})]}):null]})})})}export{Xt as ProjectPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{r}from"./logo-C4V2_3Ar.js";import{Tt as i,bn as a,bt as o,cn as s,ct as c,dn as l,hn as u,jt as d,kt as f,l as p,lt as m,mt as h,p as g,v as _,yn as v}from"./ui-CMdSOoUZ.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-DSRUEpb6.js";import{c as ee,i as E,r as D,t as O}from"./brand-BamUjXVr.js";import{a as k,n as A,o as j}from"./index-Bdx1Qity.js";import{t as M}from"./RunnerView-CTRFgyu5.js";var N={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`}]]};N.node;var te=l(N),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=l(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=l(I),R=e(t(),1);function ne(){if(window.self===window.top)return null;let e=new URLSearchParams(window.location.search).get(`embed`);return e===`inline`||e===`modal`||e===`popout`?e:null}var z=ne(),re=z?new URLSearchParams(window.location.search).get(`page`):null,B=(e,t={})=>window.parent.postMessage({type:`engenty-wizard:${e}`,...t},`*`),ie=()=>B(`close`);function ae(e){(0,R.useEffect)(()=>{if(z===`inline`&&!e){let e=document.documentElement;document.getElementById(`root`)?.style.setProperty(`min-height`,`0`),e.style.overflow=`hidden`;let t=new ResizeObserver(()=>B(`height`,{height:Math.ceil(e.getBoundingClientRect().height)}));return t.observe(e),()=>t.disconnect()}if(z===`modal`||z===`popout`){let e=e=>{e.key===`Escape`&&!document.querySelector(`dialog[open]`)&&B(`close`)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}},[e])}var V=e(n(),1);function H(e){(0,R.useEffect)(()=>{if(!e)return;let t=document.documentElement;return t.style.setProperty(`--raw-primary`,e),()=>{t.style.removeProperty(`--raw-primary`)}},[e])}function U(e,t){(0,R.useEffect)(()=>{if(!e||!t)return;let n=_(`/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 W=/iPhone|iPad|iPod/.test(navigator.userAgent)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1,G=W||/Android/.test(navigator.userAgent);function K(){let[e,t]=(0,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||G&&!e&&!W)return null;let i=/Mac/.test(navigator.platform),a=f(G?`install.ios`:i?`install.bookmark.mac`:`install.bookmark.pc`);return(0,V.jsxs)(`div`,{className:`mt-6 flex flex-col items-center gap-2 text-[0.8125rem] text-ink-3`,children:[(0,V.jsxs)(`button`,{type:`button`,onClick:()=>{G&&e?(e.prompt(),window.wizardInstall=null,t(null)):r(e=>!e)},className:`inline-flex items-center gap-1.5 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:[G?(0,V.jsx)(L,{className:`size-4`}):(0,V.jsx)(te,{className:`size-4`}),f(G?`install.add`:`install.bookmark`)]}),n?(0,V.jsx)(`p`,{className:`max-w-xs leading-relaxed`,children:a}):null]})}function q({brand:e,toggle:t=!0}){return(0,V.jsx)(`header`,{className:`safe-top`,children:(0,V.jsxs)(`div`,{className:`relative flex h-14 items-center justify-center px-5`,children:[e.logoUrl?(0,V.jsx)(`img`,{src:_(e.logoUrl),alt:e.name,className:`h-7 max-w-[160px] object-contain`}):e.name?(0,V.jsx)(`span`,{className:`max-w-[60%] truncate font-display font-semibold text-[0.9375rem] text-ink-2 tracking-tight`,children:e.name}):null,t?(0,V.jsx)(`div`,{className:`absolute right-3`,children:(0,V.jsx)(E,{})}):null]})})}function J({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,V.jsx)(`div`,{ref:n,className:`mt-4 flex justify-center`})}function oe({token:e}){return!/iPhone|iPad|iPod|Android/.test(navigator.userAgent)||A||z?null:(0,V.jsxs)(`a`,{href:k(`${window.location.origin}${g}/w/${e}`),className:`mt-3 inline-flex items-center gap-1.5 text-[0.8125rem] text-ink-3 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:[(0,V.jsx)(F,{className:`size-4`}),` `,f(`install.app`)]})}var Y=e=>`wz.run.${e}`,X=A&&new URLSearchParams(window.location.search).get(`start`)===`1`,Z=z===`inline`?`min-h-80`:`min-h-dvh`;function Q(e,t){let n=v(),[r,i]=(0,R.useState)(!1),[a,o]=(0,R.useState)(null),[s,c]=(0,R.useState)(null),l=(()=>{try{return localStorage.getItem(Y(e.token))}catch{return null}})();return{busy:r,error:a,captcha:s,setCaptcha:c,start:async()=>{i(!0),o(null);try{let{runId:r}=await p.post(`/api/public/wizards/${e.token}/runs`,{turnstileToken:s??void 0,embedded:z!==null,origin:re??void 0});try{localStorage.setItem(Y(e.token),r)}catch{}n(`${t}/${r}`,{replace:X})}catch(e){o(e.message),i(!1)}},resume:l?()=>n(`${t}/${l}`):null}}function se({wizard:e}){let{busy:t,error:n,captcha:r,setCaptcha:i,start:a,resume:c}=Q(e,`/w/${e.token}`),l=X&&e.available&&!e.turnstileSiteKey,u=(0,R.useRef)(!1);return(0,R.useEffect)(()=>{l&&!u.current&&(u.current=!0,a())},[l]),l&&!n?(0,V.jsx)(`div`,{className:`flex min-h-[60dvh] items-center justify-center text-ink-4`,children:(0,V.jsx)(o,{})}):(0,V.jsxs)(`div`,{className:`mx-auto flex max-w-lg animate-rise flex-col items-center px-6 pt-6 pb-12 text-center sm:pt-16 sm:pb-16`,children:[(0,V.jsx)(D,{kind:e.avatar,size:190,fluffy:!0}),(0,V.jsx)(`h1`,{className:`mt-2 text-balance font-display font-semibold text-[1.875rem] leading-[1.1] tracking-tight sm:text-[2.125rem]`,children:e.title}),e.description?(0,V.jsx)(`p`,{className:`mt-3 text-[1rem] text-ink-2 leading-relaxed`,children:e.description}):null,e.available?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(m,{size:`lg`,className:`mt-10 min-w-48`,busy:t,disabled:!!e.turnstileSiteKey&&!r,onClick:a,children:[f(`run.start`),` `,(0,V.jsx)(s,{className:`size-4`})]}),e.turnstileSiteKey?(0,V.jsx)(J,{siteKey:e.turnstileSiteKey,onToken:i}):null,c?(0,V.jsx)(`button`,{type:`button`,onClick:c,className:`mt-4 text-[0.875rem] text-ink-3 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:f(`run.resume`)}):null,(0,V.jsx)(ce,{wizard:e,current:`steps`}),z||A?null:(0,V.jsx)(K,{}),(0,V.jsx)(oe,{token:e.token})]}):(0,V.jsx)(`p`,{className:`mt-10 rounded-xl bg-paper-2 px-5 py-4 text-[0.9375rem] text-ink-2`,children:e.unavailableReason??f(`run.unavailable`)}),n?(0,V.jsx)(`p`,{className:`mt-4 text-[0.875rem] text-rose`,children:n}):null]})}function ce({wizard:e,current:t}){let n=e.runners.filter(e=>e.id!==t&&e.kind===`page`&&e.url);return n.length?(0,V.jsx)(`p`,{className:`mt-4 flex flex-wrap justify-center gap-x-4 text-[0.875rem] text-ink-3`,children:n.map(e=>(0,V.jsx)(`a`,{href:e.url??void 0,className:`underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:f(`run.orAs`,{label:e.label})},e.id))}):null}function le({wizard:e}){let t=w();return(0,V.jsx)(`header`,{className:`safe-top shrink-0 border-border-soft border-b`,children:(0,V.jsxs)(`div`,{className:`mx-auto flex h-16 w-full max-w-[760px] items-center gap-3 pr-2 pl-4 sm:pr-4 sm:pl-6`,children:[(0,V.jsx)(`span`,{className:i(t?.speaking&&`animate-breathe`),children:(0,V.jsx)(D,{kind:e.avatar,size:38})}),(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,V.jsx)(`div`,{className:`truncate font-display font-semibold text-[1rem] leading-tight tracking-tight`,children:e.title}),e.brand.name?(0,V.jsx)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:e.brand.name}):null]}),e.brand.logoUrl&&z!==`popout`?(0,V.jsx)(`img`,{src:_(e.brand.logoUrl),alt:e.brand.name,className:`h-6 max-w-[120px] object-contain max-sm:hidden`}):null,z?null:(0,V.jsx)(E,{}),z===`popout`?(0,V.jsx)(h,{label:f(`common.close`),onClick:ie,children:(0,V.jsx)(d,{className:`size-5`})}):null]})})}function $({door:e,wizard:t,header:n,footer:r}){let{busy:i,error:a,captcha:o,setCaptcha:c,start:l,resume:u}=Q(t,`/w/${t.token}/${e}`),d=[{key:`hello`,who:`bot`,node:t.description||t.title}];return e!==`chat`&&d.push({key:e,who:`bot`,node:f(e===`video`?`video.hint`:`talk.joinHint`)}),t.available||d.push({key:`unavailable`,who:`bot`,node:t.unavailableReason??f(`run.unavailable`)}),a&&d.push({key:`error`,who:`bot`,node:a,tone:`error`}),t.available&&d.push(S(`start`,(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(b,{primary:!0,busy:i,disabled:!!t.turnstileSiteKey&&!o,onClick:()=>void l(),children:[f(`run.start`),` `,(0,V.jsx)(s,{className:`size-4`})]}),u?(0,V.jsx)(b,{onClick:u,children:f(`run.resume`)}):null,t.turnstileSiteKey?(0,V.jsx)(J,{siteKey:t.turnstileSiteKey,onToken:c}):null]}))),(0,V.jsxs)(x,{header:n,footer:r,children:[(0,V.jsx)(y,{avatar:t.avatar,lines:d}),(0,V.jsx)(C,{})]})}function ue({className:e}){return(0,V.jsx)(`footer`,{className:i(`text-center text-ink-4`,e),children:(0,V.jsx)(`a`,{href:`${g}/`,target:z?`_blank`:void 0,rel:`noreferrer`,className:`inline-block hover:text-ink-2`,children:f(`run.madeWith`).replace(`engenty wizards`,O.name)})})}function de({chat:e=!1,steps:t=!1,talk:n=!1,video:s=!1}){let{token:l,runId:d}=a(),h=v(),_=r({queryKey:[`public`,l],queryFn:()=>p.get(`/api/public/wizards/${l}`),retry:(e,t)=>c(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||s&&x,C=y[0]?.id,w=e||z===`popout`||!t&&!d&&S&&(C===`chat`||C===`talk`||C===`video`),E=s&&x||!t&&!e&&!n&&C===`video`,k=!E&&(n&&b||!t&&!e&&C===`talk`),N=E?`video`:k?`talk`:`chat`;if(H(_.data?.brand.accent),ee(_.data?.avatar),U(l,_.data?.title),ae(w),(0,R.useEffect)(()=>{_.data&&(document.title=_.data.title)},[_.data]),(0,R.useEffect)(()=>{l&&d&&j(`run`,{token:l,runId:d})},[l,d]),_.isLoading)return(0,V.jsx)(`div`,{className:i(`flex items-center justify-center text-ink-4`,Z),children:(0,V.jsx)(o,{})});if(e&&_.data&&!S||n&&_.data&&!b||s&&_.data&&!x)return(0,V.jsx)(u,{to:`/w/${l}`,replace:!0});if(!_.data){let e=c(_.error);return(0,V.jsxs)(`div`,{className:i(`flex flex-col items-center justify-center gap-4 px-6 text-center`,Z),children:[(0,V.jsx)(D,{kind:`pebble`,size:80}),(0,V.jsx)(`p`,{className:`max-w-xs text-ink-3`,children:f(e?`common.offline`:`run.notFound`)}),e?(0,V.jsx)(m,{variant:`secondary`,onClick:()=>void _.refetch(),children:f(`common.retry`)}):null]})}if(w){let e=(0,V.jsx)(le,{wizard:_.data}),t=A?(0,V.jsx)(`div`,{className:`safe-bottom`}):(0,V.jsx)(ue,{className:`pb-[max(0.375rem,env(safe-area-inset-bottom))] text-[0.6875rem]`});return(0,V.jsx)(`div`,{className:`flex h-dvh flex-col`,children:d?(0,V.jsx)(T,{runId:d,talk:k,call:E?`video`:k?`audio`:!1,onRestart:()=>h(`/w/${l}/${N}`),header:E||k?void 0:e,footer:t}):(0,V.jsx)($,{wizard:_.data,header:e,footer:t,door:N})})}return(0,V.jsxs)(`div`,{className:i(`flex flex-col`,Z),children:[z===`inline`||A?null:(0,V.jsx)(q,{brand:_.data.brand,toggle:!z}),(0,V.jsx)(`div`,{className:`flex-1`,children:d?(0,V.jsx)(M,{runId:d,onRestart:()=>h(`/w/${l}`)}):(0,V.jsx)(se,{wizard:_.data})}),A?(0,V.jsx)(`div`,{className:`safe-bottom`}):(0,V.jsx)(`footer`,{className:`safe-bottom pt-6 text-center text-[0.75rem] text-ink-4`,children:(0,V.jsx)(`a`,{href:`${g}/`,target:z?`_blank`:void 0,rel:`noreferrer`,className:`inline-block py-3.5 hover:text-ink-2`,children:f(`run.madeWith`).replace(`engenty wizards`,O.name)})})]})}export{q as BrandHeader,de as PublicRunner,H as useBrandAccent};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{O as r,r as i}from"./logo-C4V2_3Ar.js";import{h as a,m as o}from"./Marketplace-C-Vz3yEk.js";import{t as s}from"./useMutation-DKyQXgyj.js";import{Bt as c,Dt as l,Nt as u,Rt as d,St as f,T as p,Tt as m,Wt as h,Xt as g,an as _,bt as v,dn as y,dt as b,ft as x,gt as S,ht as C,in as w,jt as T,kt as E,l as D,lt as O,mt as k,nn as A,pt as j,qt as M,st as N,ut as P,vt as F,wt as ee,yt as I}from"./ui-CMdSOoUZ.js";import{t as te}from"./upload-Cz9HgBT9.js";import{A as L,D as ne,M as R,N as re,P as ie,it as ae,k as oe}from"./index-Bdx1Qity.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=y(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=y(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=y(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=y(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=y(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=y(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=y(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?E(`know.item`):E(`know.items`,{n:e})}function q(e,t){if(e.type===`boolean`||typeof t==`boolean`)return E(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)(F,{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)(C,{"data-autofocus":!0,value:a.includes(r)?``:r,placeholder:E(`know.addValue`),onChange:e=>i(e.target.value),className:`h-9`}),(0,W.jsx)(k,{label:E(`know.addValue`),type:`submit`,children:(0,W.jsx)(c,{className:`size-4`})})]})]})}return e.type===`boolean`?(0,W.jsx)(F,{value:t[0]===!0?E(`know.yes`):t[0]===!1?E(`know.no`):``,options:[E(`know.yes`),E(`know.no`)],onChange:e=>n([e===E(`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)(C,{"data-autofocus":!0,type:e.type===`date`?`date`:e.type===`number`?`number`:`text`,step:`any`,value:e.type===`date`?r.slice(0,10):r,onChange:e=>i(e.target.value),className:`h-9`}),(0,W.jsx)(O,{type:`submit`,size:`sm`,children:`OK`})]})}function xe({projectId:e,itemKey:t,has:n,categories:i,readOnly:a}){let o=r(),[l,u]=(0,U.useState)(null),[d,f]=(0,U.useState)(n);(0,U.useEffect)(()=>f(n),[n]);let p=s({mutationFn:({categoryId:n,next:r})=>D.put(`/api/studio/projects/${e}/items/${t}/categories/${n}`,{values:r}),onSuccess:()=>o.invalidateQueries({queryKey:K(e)})}),m=i.filter(e=>!(e.proposed||e.tableId)),h=(e,t)=>{f(n=>[...n.filter(t=>t.categoryId!==e.id),...t.length?[{categoryId:e.id,values:t,by:`person`}]:[]]),p.mutate({categoryId:e.id,next:t}),u(null)},g=m.filter(e=>d.some(t=>t.categoryId===e.id)),_=m.filter(e=>!d.some(t=>t.categoryId===e.id));return m.length?(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[g.map(e=>{let t=d.find(t=>t.categoryId===e.id),n=G[e.type],r=(0,W.jsxs)(`button`,{type:`button`,disabled:a,title:`${e.name} · ${E(`know.by.${t.by}`)}`,onClick:()=>u(l===e.id?null:e.id),className:`inline-flex h-7 items-center gap-1.5 rounded-full bg-paper-2 px-2.5 text-[0.75rem] text-ink-2 transition hover:bg-paper-3 hover:text-ink disabled:pointer-events-none`,children:[(0,W.jsx)(n,{className:`size-3.5 text-ink-3`}),(0,W.jsx)(`span`,{className:`text-ink-3`,children:e.name}),(0,W.jsx)(`span`,{className:`font-medium`,children:t.values.map(t=>q(e,t)).join(`, `)})]},e.id);return a?(0,W.jsx)(`span`,{children:r},e.id):(0,W.jsxs)(ye,{trigger:r,open:l===e.id,onOpen:t=>u(t?e.id:null),children:[(0,W.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,W.jsx)(`span`,{className:`font-medium text-[0.8125rem]`,children:e.name}),(0,W.jsx)(k,{label:E(`know.remove`),onClick:()=>h(e,[]),className:`size-7`,children:(0,W.jsx)(T,{className:`size-3.5`})})]}),(0,W.jsx)(be,{category:e,current:t.values,onSave:t=>h(e,t)})]},e.id)}),a||!_.length?null:(0,W.jsx)(ye,{open:l===`+`,onOpen:e=>u(e?`+`:null),trigger:(0,W.jsxs)(`button`,{type:`button`,onClick:()=>u(l===`+`?null:`+`),className:`inline-flex h-7 items-center gap-1 rounded-full px-2 text-[0.75rem] text-ink-3 ring-1 ring-border-soft transition hover:text-ink hover:ring-border`,children:[(0,W.jsx)(c,{className:`size-3.5`}),` `,E(`know.category`)]}),children:(0,W.jsx)(Se,{categories:_,onSave:h})})]}):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)(I,{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,p]=(0,U.useState)(``),[m,h]=(0,U.useState)(!1),[g,_]=(0,U.useState)(!1),[v,y]=(0,U.useState)(``),[b,w]=(0,U.useState)(``),T=s({mutationFn:()=>D.post(`/api/studio/projects/${e}/categories`,{name:o.trim(),type:l,unit:l===`number`&&d.trim()||null,multiple:l===`choice`&&m,ordered:l===`choice`&&g,hint:b.trim()||null,values:l===`choice`?v.split(`
|
|
2
|
-
`).map(e=>e.trim()).filter(Boolean):void 0}),onSuccess:async({id:t})=>{await a.invalidateQueries({queryKey:K(e)}),c(``),y(``),w(``),i(t)}});return(0,W.jsx)(x,{open:t,onClose:n,title:E(`know.newCategory`),children:(0,W.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),o.trim()&&T.mutate()},children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(S,{children:E(`know.name`)}),(0,W.jsx)(C,{"data-autofocus":!0,value:o,maxLength:80,onChange:e=>c(e.target.value)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(S,{children:E(`know.type`)}),(0,W.jsx)(I,{value:l,onChange:e=>u(e),options:[`choice`,`date`,`number`,`text`,`boolean`].map(e=>({value:e,label:E(`know.type.${e}`)}))})]}),l===`number`?(0,W.jsxs)(`div`,{children:[(0,W.jsx)(S,{hint:E(`know.unitHint`),children:E(`know.unit`)}),(0,W.jsx)(C,{value:d,maxLength:20,onChange:e=>p(e.target.value)})]}):null,l===`choice`?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(S,{hint:E(`know.valuesHint`),children:E(`know.values`)}),(0,W.jsx)(ee,{minRows:3,value:v,onChange:e=>y(e.target.value)})]}),(0,W.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-[0.875rem]`,children:[E(`know.multiple`),(0,W.jsx)(f,{checked:m,onChange:h})]}),(0,W.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-[0.875rem]`,children:[E(`know.ordered`),(0,W.jsx)(f,{checked:g,onChange:_})]})]}):null,(0,W.jsxs)(`div`,{children:[(0,W.jsx)(S,{hint:E(`know.hintFieldHint`),children:E(`know.hintField`)}),(0,W.jsx)(C,{value:b,maxLength:120,onChange:e=>w(e.target.value)})]}),T.error?(0,W.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:T.error.message}):null,(0,W.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,W.jsx)(O,{variant:`ghost`,onClick:n,children:E(`common.cancel`)}),(0,W.jsx)(O,{type:`submit`,busy:T.isPending,disabled:!o.trim(),children:E(`know.create`)})]})]})})}function we({projectId:e,category:t,readOnly:n,onOpen:i,onGone:a}){let o=r(),l=()=>o.invalidateQueries({queryKey:K(e)}),[d,f]=(0,U.useState)(``),p=s({mutationFn:e=>e(),onSuccess:l}),m=G[t.type],h=new Map(t.values.map(e=>[e.id,e]));return(0,W.jsxs)(L,{title:t.name,hint:[E(`know.type.${t.type}`),t.unit,t.hint].filter(Boolean).join(` · `),plain:!0,action:n?null:(0,W.jsx)(k,{label:E(`know.deleteCategory`),className:`hover:text-rose`,onClick:()=>confirm(E(`know.confirmCategory`,{name:t.name}))&&p.mutate(async()=>{await D.del(`/api/studio/categories/${t.id}`),a()}),children:(0,W.jsx)(u,{className:`size-4`})}),children:[t.proposed&&!n?(0,W.jsxs)(P,{className:`flex flex-wrap items-center gap-3 p-4`,children:[(0,W.jsx)(b,{tone:`ember`,children:E(`know.proposed`)}),(0,W.jsx)(`span`,{className:`flex-1 text-[0.875rem] text-ink-2`,children:E(`know.proposedHint`)}),(0,W.jsx)(O,{size:`sm`,onClick:()=>p.mutate(()=>D.patch(`/api/studio/categories/${t.id}`,{proposed:!1})),children:E(`know.accept`)})]}):null,t.alike.map(([e,t])=>{let r=h.get(e),i=h.get(t);if(!(r&&i))return null;let[a,o]=r.count<i.count?[r,i]:[i,r];return(0,W.jsxs)(P,{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:E(`know.alike`,{a:a.value,b:o.value})}),n?null:(0,W.jsx)(O,{size:`sm`,variant:`secondary`,busy:p.isPending,onClick:()=>p.mutate(()=>D.post(`/api/studio/values/${a.id}/merge`,{into:o.id})),children:E(`know.merge`)})]},`${e}:${t}`)}),(0,W.jsxs)(P,{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)(m,{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)(b,{children:E(`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)(j,{children:E(`know.empty`)}):(0,W.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2.5 text-[0.875rem]`,children:[(0,W.jsx)(m,{className:`size-4 shrink-0 text-ink-3`}),(0,W.jsx)(`span`,{className:`flex-1 text-ink-2`,children:t.range?E(`know.range`,{min:q(t,t.range.min),max:q(t,t.range.max)}):E(`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=d.trim();n&&(f(``),p.mutate(()=>D.post(`/api/studio/categories/${t.id}/values`,{value:n})))},children:[(0,W.jsx)(C,{value:d,placeholder:E(`know.addValue`),onChange:e=>f(e.target.value),className:`h-9`}),(0,W.jsx)(k,{label:E(`know.addValue`),type:`submit`,children:(0,W.jsx)(c,{className:`size-4`})})]}):null]}),p.error?(0,W.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:p.error.message}):null]})}function Te(e){return i({queryKey:[`knowledge-value`,e],queryFn:()=>D.get(`/api/studio/values/${e}`),enabled:!!e})}function Ee({value:e,readOnly:t,children:n}){let i=r(),a=s({mutationFn:()=>D.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:E(`know.summary`),hint:E(`know.summaryHint`),plain:!0,action:t?null:(0,W.jsxs)(O,{variant:`secondary`,size:`sm`,busy:a.isPending,onClick:()=>a.mutate(),children:[e.summary?(0,W.jsx)(d,{className:`size-4`}):null,e.summary?E(`know.summaryAgain`):E(`know.summaryWrite`)]}),children:(0,W.jsxs)(P,{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)(v,{})}):e.summary?(0,W.jsx)(p,{text:e.summary,className:`text-[0.875rem]`}):(0,W.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:E(`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:E(`know.toc`),plain:!0,children:n})]})}function De(e){return i({queryKey:[`knowledge`,e],queryFn:()=>D.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`?h:e.children?le:g}function J({item:e,categories:t,onOpen:n}){let r=Oe(e),i=[ve(t,e.categories),e.children?e.children===1?E(`know.oneSub`):E(`know.sub`,{n:e.children}):``,e.rows===null?``:e.rows===1?E(`know.row`):E(`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)(v,{className:`size-3`}),` `,E(`know.reading`)]}):e.review?(0,W.jsx)(b,{tone:`warn`,title:e.review,children:E(`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?E(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)(h,{className:`size-3.5`}),` `,E(`know.original`),`: `,o.name]}):null,a?(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,W.jsx)(b,{tone:`warn`,children:E(`know.review`)}),(0,W.jsx)(`span`,{children:a}),s?null:(0,W.jsx)(`button`,{type:`button`,onClick:c,className:`underline hover:text-ink`,children:E(`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:()=>D.get(`/api/studio/categories/${t.id}/items`)});if(!a.data)return a.isLoading?(0,W.jsx)(v,{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?E(`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)(P,{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:E(`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 E(t?`know.yes`:`know.no`);if(typeof t==`object`&&t){let n=t.gte??t.after,r=t.lte??t.before;return t.contains?`${E(`know.contains`)} ${t.contains}`:[n===void 0?``:`${E(`know.minimum`)} ${q(e,n)}`,r===void 0?``:`${E(`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:{},c=(t,r)=>{let i={...s,[t]:r===``?void 0:e.type===`number`?Number(r):r},a=Object.fromEntries(Object.entries(i).filter(([,e])=>e!==void 0));n(Object.keys(a).length?a:void 0)};return(0,W.jsxs)(`div`,{ref:a,className:`relative`,children:[(0,W.jsxs)(`button`,{type:`button`,onClick:()=>i(!r),className:m(`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)(w,{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)(F,{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)(F,{value:t===!0?E(`know.yes`):t===!1?E(`know.no`):``,options:[E(`know.yes`),E(`know.no`)],onChange:e=>n(e===E(`know.yes`))}):e.type===`text`?(0,W.jsx)(C,{"data-autofocus":!0,value:s.contains??``,placeholder:E(`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)(S,{children:E(n===0?`know.minimum`:`know.maximum`)}),(0,W.jsx)(C,{type:e.type===`number`?`number`:`date`,step:`any`,value:String(s[t]??``),placeholder:e.range?String(n===0?e.range.min:e.range.max):``,onChange:e=>c(t,e.target.value),className:`h-9`})]},t))}),t===void 0?null:(0,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:E(`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?E(`know.searchStats`,{candidates:e.candidates,hits:e.hits.length}):E(`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:E(`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:()=>D.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)(x,{open:e!==null,onClose:n,title:E(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)(S,{children:E(`data.title`)}),(0,W.jsx)(C,{"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:[E(`know.asFaq`),(0,W.jsx)(f,{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)(O,{variant:`ghost`,onClick:n,children:E(`common.cancel`)}),(0,W.jsx)(O,{type:`submit`,busy:d.isPending,disabled:!o.trim(),children:E(`know.create`)})]})]})})}function Ie({projectId:e,data:t,readOnly:n,onOpen:i}){let a=r(),o=ie(e,n),[l,u]=(0,U.useState)({}),[d,f]=(0,U.useState)(``),[p,m]=(0,U.useState)(null),[h,g]=(0,U.useState)(!1),[_,y]=(0,U.useState)(null),x=t.categories.filter(e=>!e.proposed&&e.count>0),S=t.categories.filter(e=>e.proposed),C=t.items.filter(e=>Object.entries(l).every(([n,r])=>{let i=t.categories.find(e=>e.name===n),a=e.categories.find(e=>e.categoryId===i?.id);return i&&a?je(i,a.values,r):!1})),w=async()=>{if(!d.trim()){m(null);return}g(!0);try{m(await D.post(`/api/studio/projects/${e}/search`,{query:d,...Object.keys(l).length?{where:l}:{}}))}catch{m({hits:[],candidates:0,checked:!1,filtered:null})}finally{g(!1)}},T=s({mutationFn:({id:e,keep:t})=>t?D.patch(`/api/studio/categories/${e}`,{proposed:!1}):D.del(`/api/studio/categories/${e}`),onSuccess:()=>a.invalidateQueries({queryKey:[`knowledge`,e]})});return(0,W.jsxs)(L,{title:E(`know.title`),hint:E(`know.hint`),plain:!0,action:n?null:(0,W.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,W.jsxs)(O,{variant:`secondary`,size:`sm`,onClick:()=>y(`page`),children:[(0,W.jsx)(c,{className:`size-4`}),` `,E(`know.page`)]}),(0,W.jsxs)(O,{variant:`secondary`,size:`sm`,onClick:()=>y(`table`),children:[(0,W.jsx)(c,{className:`size-4`}),` `,E(`know.table`)]}),(0,W.jsxs)(O,{variant:`secondary`,size:`sm`,onClick:()=>y(`category`),children:[(0,W.jsx)(c,{className:`size-4`}),` `,E(`know.category`)]})]}),children:[S.length&&!n?(0,W.jsx)(P,{className:`flex flex-col gap-2 p-4`,children:S.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)(b,{tone:`ember`,children:E(`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:[E(`know.type.${e.type}`),e.hint].filter(Boolean).join(` · `)}),(0,W.jsx)(O,{size:`sm`,variant:`ghost`,onClick:()=>T.mutate({id:e.id,keep:!1}),children:E(`know.dismiss`)}),(0,W.jsx)(O,{size:`sm`,onClick:()=>T.mutate({id:e.id,keep:!0}),children:E(`know.accept`)})]},e.id)})}):null,t.items.length?(0,W.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,W.jsx)(oe,{value:d,placeholder:E(`know.search`),busy:h,onEnter:()=>void w(),onChange:e=>{f(e),e.trim()||m(null)}}),x.length?(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[x.map(e=>(0,W.jsx)(Ne,{category:e,value:l[e.name],onChange:t=>{m(null),u(n=>{let r={...n};return t===void 0?delete r[e.name]:r[e.name]=t,r})}},e.id)),Object.keys(l).length?(0,W.jsx)(`button`,{type:`button`,onClick:()=>u({}),className:`px-2 text-[0.8125rem] text-ink-3 underline hover:text-ink`,children:E(`know.clear`)}):null]}):null]}):null,(0,W.jsx)(P,{className:`flex flex-col p-1.5`,children:p?(0,W.jsx)(Pe,{found:p,onOpen:i}):C.length?C.map(e=>(0,W.jsx)(J,{item:e,categories:t.categories,onOpen:i},e.key)):(0,W.jsx)(j,{children:E(`know.empty`)})}),n?null:(0,W.jsxs)(ne,{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)(v,{className:`size-4`}):(0,W.jsx)(te,{className:`size-4`}),E(`know.drop`),` `,(0,W.jsx)(`span`,{className:`underline`,children:E(`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?``:E(`know.keywordsOnly`),t.checked?``:E(`know.unchecked`)].filter(Boolean).join(` `)}):null,(0,W.jsx)(Fe,{kind:_===`page`||_===`table`?_:null,projectId:e,onClose:()=>y(null),onMade:e=>{y(null),i(e)}}),(0,W.jsx)(Ce,{projectId:e,open:_===`category`,onClose:()=>y(null),onMade:e=>{y(null),i(`c:${e}`)}})]})}function Le({page:e,onGone:t,onOpen:n}){let i=r(),[a,o]=(0,U.useState)(e.title),[l,d]=(0,U.useState)(e.markdown),[f,h]=(0,U.useState)(e.markdown?`read`:`write`),y=e.knowledge,b=async()=>{await i.invalidateQueries({queryKey:[`space-data`,e.projectId]}),await i.invalidateQueries({queryKey:[`knowledge`,e.projectId]})},x=re({title:a.trim()||e.title,markdown:l},async t=>{await D.patch(`/api/studio/pages/${e.id}`,t),i.setQueryData([`space-page`,e.id],e=>e&&{...e,...t}),t.title!==e.title&&await b()}),S=s({mutationFn:()=>D.del(`/api/studio/pages/${e.id}`),onSuccess:async()=>{await b(),t()}}),C=s({mutationFn:()=>D.post(`/api/studio/projects/${e.projectId}/pages`,{title:E(`know.addSub`),parentId:e.id}),onSuccess:async({id:e})=>{await b(),n?.(`p:${e}`)}}),w=s({mutationFn:()=>D.patch(`/api/studio/pages/${e.id}`,{review:null}),onSuccess:()=>i.invalidateQueries({queryKey:[`space-page`,e.id]})}),T=async t=>{let r=t.target.closest(`a`)?.getAttribute(`href`);if(!(r?.startsWith(`pages/`)&&n))return;t.preventDefault();let i=await D.get(`/api/studio/projects/${e.projectId}/resolve?path=${encodeURIComponent(r)}`).catch(()=>null);i?.kind===`page`&&n(`p:${i.id}`)},j=e.readOnly,M=y?.file&&(y.file.mime===`application/pdf`||y.file.mime.startsWith(`image/`))?y.file:null,N=(e,t)=>(0,W.jsx)(`button`,{type:`button`,"aria-pressed":f===e,onClick:()=>h(e),className:m(`rounded-full px-3 py-1 text-[0.8125rem] transition`,f===e?`bg-paper-2 font-medium text-ink`:`text-ink-3 hover:text-ink`),children:t});return(0,W.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[y?.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:y.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)(A,{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:j,maxLength:200,onChange:e=>o(e.target.value),"aria-label":E(`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`}),x.state===`saving`?(0,W.jsx)(v,{className:`size-3.5 text-ink-3`}):x.state===`saved`?(0,W.jsx)(_,{className:`size-4 text-moss`,"aria-label":E(`settings.saved`)}):null,j?null:(0,W.jsx)(k,{label:E(`data.deletePage`),onClick:()=>confirm(E(`data.confirmDelete`,{title:e.title}))&&S.mutate(),className:`hover:text-rose`,children:(0,W.jsx)(u,{className:`size-4`})})]}),y?(0,W.jsx)(Y,{projectId:e.projectId,itemKey:`p:${e.id}`,has:y.categories,originLabel:y.originLabel,kept:y.kept,review:y.review,file:M?null:y.file,readOnly:j,onReviewed:()=>w.mutate()}):null,(0,W.jsxs)(P,{className:`flex flex-col`,children:[j&&!M?null:(0,W.jsxs)(`div`,{className:`flex items-center gap-1 border-border-soft border-b px-2 py-1.5`,children:[j?null:N(`write`,E(`data.write`)),N(`read`,E(`data.preview`)),M?N(`original`,E(`know.original`)):null,(0,W.jsx)(`span`,{className:`ml-auto truncate px-2 text-[0.75rem] text-ink-4 max-sm:hidden`,children:f===`original`&&M?M.name:E(`data.markdownHint`)})]}),f===`original`&&M?M.mime===`application/pdf`?(0,W.jsx)(`iframe`,{src:R(e.projectId,M.id),title:M.name,className:`h-[70dvh] w-full rounded-b-xl bg-paper-2`}):(0,W.jsx)(`img`,{src:R(e.projectId,M.id),alt:``,className:`mx-auto max-h-[70dvh] object-contain p-4`}):f===`write`&&!j?(0,W.jsx)(`textarea`,{value:l,onChange:e=>d(e.target.value),"aria-label":e.title,placeholder:E(`data.pageEmpty`),className:`field-sizing-content min-h-[50vh] w-full resize-none bg-transparent p-4 font-mono text-[0.8125rem] leading-relaxed outline-none placeholder:text-ink-4 sm:p-5`}):(0,W.jsx)(`div`,{className:`min-h-40 p-4 sm:p-5`,onClick:T,children:l.trim()?(0,W.jsx)(p,{text:l}):(0,W.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:E(`data.pageEmpty`)})})]}),x.state===`error`&&x.error?(0,W.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:x.error}):null,y&&n&&(y.children.length||!j)?(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:y.children.length?E(`know.subPages`):null}),j?null:(0,W.jsxs)(O,{variant:`ghost`,size:`sm`,busy:C.isPending,onClick:()=>C.mutate(),children:[(0,W.jsx)(c,{className:`size-4`}),` `,E(`know.addSub`)]})]}),y.children.length?(0,W.jsx)(P,{className:`flex flex-col p-1.5`,children:y.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)(g,{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:()=>D.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:()=>D.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:E(`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:g};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:()=>D.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)(x,{open:e!==null,onClose:i,title:E(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)(S,{children:E(`data.title`)}),(0,W.jsx)(C,{"data-autofocus":!0,value:c,maxLength:120,onChange:e=>l(e.target.value)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(S,{children:E(`data.owner`)}),(0,W.jsx)(I,{value:u,onChange:d,options:[{value:``,label:E(`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)(O,{variant:`ghost`,onClick:i,children:E(`common.cancel`)}),(0,W.jsx)(O,{type:`submit`,busy:f.isPending,disabled:!c.trim(),children:E(`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])]),u=new Intl.DateTimeFormat(l,{dateStyle:`medium`});return(0,W.jsxs)(L,{title:E(`space.data`),hint:E(`data.hint`),plain:!0,action:n?null:(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsxs)(O,{variant:`secondary`,size:`sm`,onClick:()=>a(`table`),children:[(0,W.jsx)(c,{className:`size-4`}),` `,E(`data.table`)]}),(0,W.jsxs)(O,{variant:`secondary`,size:`sm`,onClick:()=>a(`page`),children:[(0,W.jsx)(c,{className:`size-4`}),` `,E(`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)(P,{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`?`${E(`data.rows`,{n:e.rows??0})} · `:``,u.format(new Date(s.get(e.key)??Date.now()))]})]},e.key)})})]},e.key))}):(0,W.jsx)(P,{children:(0,W.jsx)(j,{children:E(`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":E(`data.removeOption`),onClick:()=>i(r.filter(t=>t!==e)),className:`rounded-full text-ink-3 hover:text-ink`,children:(0,W.jsx)(T,{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:m(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:m(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`?E(`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})),p=async e=>{u(!0),c(null);try{await i(e),r()}catch(e){c(e.message)}finally{u(!1)}},m=()=>{let e=t?.id??We(a.name,n.map(e=>e.id)),r=Qe(a,e,t);return p(t?n.map(e=>e.id===t.id?r:e):[...n,r])};return(0,W.jsx)(x,{open:e,onClose:r,title:t?t.name:E(`data.newColumn`),children:(0,W.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),a.name.trim()&&m()},children:[(0,W.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(S,{children:E(`data.columnName`)}),(0,W.jsx)(C,{"data-autofocus":!0,value:a.name,maxLength:128,onChange:e=>d({name:e.target.value})})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(S,{children:E(`data.columnType`)}),(0,W.jsx)(I,{value:a.type,onChange:e=>d({type:e}),options:Ke.map(e=>({value:e,label:E(`data.type.${e}`)}))})]})]}),a.type===`text`?(0,W.jsx)(I,{value:a.textStyle,onChange:e=>d({textStyle:e}),options:[{value:`single`,label:E(`data.text.single`)},{value:`multiline`,label:E(`data.text.multiline`)}]}):null,a.type===`number`?(0,W.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,W.jsx)(I,{value:a.numberStyle,onChange:e=>d({numberStyle:e}),options:[`integer`,`decimal`,`percent`,`currency`].map(e=>({value:e,label:E(`data.number.${e}`)}))}),a.numberStyle===`currency`?(0,W.jsx)(C,{value:a.currency,maxLength:3,"aria-label":E(`data.currency`),placeholder:`EUR`,onChange:e=>d({currency:e.target.value})}):null]}):null,a.type===`date`?(0,W.jsx)(I,{value:a.dateKind,onChange:e=>d({dateKind:e}),options:[`date`,`datetime`,`time`].map(e=>({value:e,label:E(`data.date.${e}`)}))}):null,a.type===`duration`?(0,W.jsxs)(`div`,{children:[(0,W.jsx)(S,{children:E(`data.unit`)}),(0,W.jsx)(I,{value:a.unit,onChange:e=>d({unit:e}),options:[`minutes`,`hours`,`days`].map(e=>({value:e,label:E(`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)(S,{children:E(`data.options`)}),(0,W.jsx)(ee,{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)(f,{checked:a.multiple,onChange:e=>d({multiple:e})}),E(`data.multiple`)]})]}):null,(0,W.jsxs)(`label`,{className:`flex items-center gap-3 text-[0.875rem]`,children:[(0,W.jsx)(f,{checked:a.required,onChange:e=>d({required:e})}),E(`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)(O,{variant:`ghost`,className:`text-rose`,disabled:l,onClick:()=>confirm(E(`data.confirmDelete`,{title:t.name}))&&void p(n.filter(e=>e.id!==t.id)),children:E(`data.deleteColumn`)}):null,(0,W.jsx)(`span`,{className:`flex-1`}),(0,W.jsx)(O,{variant:`ghost`,onClick:r,children:E(`common.cancel`)}),(0,W.jsx)(O,{type:`submit`,busy:l,disabled:!a.name.trim(),children:E(`settings.save`)})]})]})})}function et({tableId:e,onGone:t}){let n=r(),a=[`space-table`,e],o=i({queryKey:a,queryFn:()=>D.get(`/api/studio/tables/${e}`)}),[l,d]=(0,U.useState)(null),[f,p]=(0,U.useState)(null),[m,h]=(0,U.useState)(null),[g,_]=(0,U.useState)(``);(0,U.useEffect)(()=>_(o.data?.title??``),[o.data?.title]);let v=async()=>{await n.invalidateQueries({queryKey:[`space-data`,o.data?.projectId]}),await n.invalidateQueries({queryKey:[`knowledge`,o.data?.projectId]})},y=e=>n.setQueryData(a,t=>t&&{...t,rows:e(t.rows)}),b=e=>{p(e.message),o.refetch()},x=async t=>{await D.patch(`/api/studio/tables/${e}`,t),await o.refetch(),await v()},S=s({mutationFn:({row:t,column:n,value:r})=>D.patch(`/api/studio/tables/${e}/rows/${t}`,{cells:{[n]:r}}),onSuccess:(e,{row:t,column:n})=>{p(null),h(e=>e===`${t}:${n}`?null:e),y(t=>t.map(t=>t.id===e.id?{...t,cells:e.cells}:t))},onError:(e,{row:t,column:n})=>{if(e instanceof N&&e.body?.column===n){let e=o.data?.columns.find(e=>e.id===n)?.name??n;h(`${t}:${n}`),p(E(`data.badCell`,{column:e}));return}b(e)}}),C=s({mutationFn:()=>D.post(`/api/studio/tables/${e}/rows`,{}),onSuccess:async e=>{y(t=>[...t,{...e,updatedAt:new Date().toISOString()}]),await v()},onError:b}),w=s({mutationFn:t=>D.post(`/api/studio/tables/${e}/rows/delete`,{ids:[t]}),onSuccess:async(e,t)=>{y(e=>e.filter(e=>e.id!==t)),await v()},onError:b}),T=s({mutationFn:()=>D.del(`/api/studio/tables/${e}`),onSuccess:async()=>{await v(),t()}});if(!o.data)return o.isError?(0,W.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:o.error.message}):null;let{columns:A,rows:j,readOnly:M}=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:M,maxLength:120,onChange:e=>_(e.target.value),onBlur:()=>g.trim()&&g!==o.data?.title&&void x({title:g}).catch(b),onKeyDown:e=>e.key===`Enter`&&e.target.blur(),"aria-label":E(`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`}),M?null:(0,W.jsx)(k,{label:E(`data.deleteTable`),onClick:()=>confirm(E(`data.confirmDelete`,{title:o.data.title}))&&T.mutate(),className:`hover:text-rose`,children:(0,W.jsx)(u,{className:`size-4`})})]}),F?(0,W.jsx)(`p`,{className:`-mt-1.5 px-1 text-[0.8125rem] text-ink-3`,children:E(`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:M,onReviewed:()=>void D.patch(`/api/studio/tables/${e}`,{review:null}).then(()=>o.refetch()).catch(b)}):null,(0,W.jsxs)(P,{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:[A.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:M||F,onClick:()=>d(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:M||F?null:(0,W.jsx)(k,{label:E(`data.newColumn`),onClick:()=>d(`new`),className:`size-8`,children:(0,W.jsx)(c,{className:`size-4`})})})]})}),(0,W.jsx)(`tbody`,{children:j.map(e=>(0,W.jsxs)(`tr`,{className:`group border-border-soft border-b last:border-b-0`,children:[A.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:M,invalid:m===`${e.id}:${t.id}`,onSave:n=>S.mutate({row:e.id,column:t.id,value:n})})},t.id)),(0,W.jsx)(`td`,{className:`w-10 p-1 align-top`,children:M?null:(0,W.jsx)(k,{label:E(`data.deleteRow`),onClick:()=>w.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)(u,{className:`size-3.5`})})})]},e.id))})]})}),j.length?null:(0,W.jsx)(`p`,{className:`px-4 py-6 text-center text-[0.875rem] text-ink-3`,children:E(`data.noRows`)}),M?null:(0,W.jsx)(`div`,{className:`border-border-soft border-t p-1.5`,children:(0,W.jsxs)(O,{variant:`ghost`,size:`sm`,busy:C.isPending,onClick:()=>C.mutate(),children:[(0,W.jsx)(c,{className:`size-4`}),` `,E(`data.addRow`)]})})]}),f?(0,W.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:f}):null,(0,W.jsx)($e,{open:l!==null,column:l===`new`?null:l,columns:A,onClose:()=>d(null),onSave:e=>x({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:E(`chat.steps`),Icon:fe},{id:`chat`,label:E(`chat.chat`),Icon:pe}];return(0,W.jsx)(`fieldset`,{"aria-label":E(`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:m(`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:m(`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":E(`editor.resize`),"aria-valuenow":i.width,tabIndex:0,title:E(`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)(k,{label:E(i.wide?`runDrawer.shrink`:`runDrawer.expand`),onClick:i.toggleWide,className:`max-sm:hidden`,children:i.wide?(0,W.jsx)(ae,{className:`size-4`}):(0,W.jsx)(M,{className:`size-4`})}),(0,W.jsx)(k,{label:E(`editor.close`),onClick:n,children:(0,W.jsx)(T,{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};
|