@engenty/wizards-runtime 0.9.2 → 0.9.3
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/docs/dev/integration/openui.md +6 -2
- package/apps/runtime/dist/docs/user/build-a-wizard.md +25 -19
- package/apps/runtime/dist/docs/user/test-and-share.md +9 -7
- package/apps/runtime/dist/engine/runner.js +7 -4
- package/apps/runtime/dist/routes/runs.js +26 -0
- package/apps/runtime/dist/routes/studio.js +9 -2
- package/apps/runtime/dist/services/brand.js +20 -0
- package/apps/runtime/dist/services/runners.js +12 -2
- package/apps/runtime/dist/services/runs.js +73 -1
- package/apps/runtime/dist/services/shipped-fonts.js +33 -0
- package/apps/web/dist/assets/AboutDialog-DsGqq2Es.js +1 -0
- package/apps/web/dist/assets/{ChangelogDialog-ClkjHGE_.js → ChangelogDialog-Hn7oDuyx.js} +1 -1
- package/apps/web/dist/assets/EditorPage-DsJqhoXy.js +4 -0
- package/apps/web/dist/assets/{FlowPreview-DZRkWedM.js → FlowPreview-DZ1XL_o1.js} +1 -1
- package/apps/web/dist/assets/{Harness-FiDeF3LX.js → Harness-BBpl_EUW.js} +2 -2
- package/apps/web/dist/assets/Marketplace-BF0Rx0VR.js +2 -0
- package/apps/web/dist/assets/NewWizardChannels-WaAOvmzw.js +1 -0
- package/apps/web/dist/assets/NewWizardPage-kpm-UyQC.js +7 -0
- package/apps/web/dist/assets/OnboardingPage-Birm-hM5.js +1 -0
- package/apps/web/dist/assets/ProjectPage-CqtpxOq5.js +1 -0
- package/apps/web/dist/assets/PublicRunner-CXTHGYHv.js +1 -0
- package/apps/web/dist/assets/{ReadOnly-I-Lm7a8y.js → ReadOnly-CcW91P4l.js} +1 -1
- package/apps/web/dist/assets/RunDrawer-ByvmBv6e.js +4 -0
- package/apps/web/dist/assets/{RunnerView-DeDApA-9.js → RunnerView-DcduYZly.js} +1 -1
- package/apps/web/dist/assets/SettingsPage-Q2CUb7kK.js +2 -0
- package/apps/web/dist/assets/SetupPage-C7mzUoiR.js +1 -0
- package/apps/web/dist/assets/SharePage-CC7V2TYJ.js +1 -0
- package/apps/web/dist/assets/changelog-7DN_qWR2.js +1 -0
- package/apps/web/dist/assets/coins-RUupcqZx.js +1 -0
- package/apps/web/dist/assets/esm-BdxDT9Km.js +7 -0
- package/apps/web/dist/assets/index-myC3mJie.css +1 -0
- package/apps/web/dist/assets/index-qnpoZzuw.js +14 -0
- package/apps/web/dist/assets/logo-CGNoptDg.js +1 -0
- package/apps/web/dist/assets/media-Cej-H610.js +1 -0
- package/apps/web/dist/assets/oss-credits-D7izqI_0.js +1 -0
- package/apps/web/dist/assets/{phone-BprN_SDS.js → phone-ChnpShTU.js} +1 -1
- package/apps/web/dist/assets/react-dom-hf6EcyAr.js +1 -0
- package/apps/web/dist/assets/session-DekDyd9S.js +2 -0
- package/apps/web/dist/assets/settings-menu-CLw_oucZ.js +1 -0
- package/apps/web/dist/assets/theme-DjpqxoRe.js +11 -0
- package/apps/web/dist/assets/ui-DRYauuxF.js +137 -0
- package/apps/web/dist/assets/{upload-Cvztyjuj.js → upload-0sFU9K8-.js} +1 -1
- package/apps/web/dist/assets/useMutation-1jFwXbI6.js +1 -0
- package/apps/web/dist/assets/volume-2-C51sO2X0.js +1 -0
- package/apps/web/dist/assets/{wrench-CWT9IGKq.js → wrench-DdT-nErU.js} +1 -1
- package/apps/web/dist/index.html +11 -3
- package/apps/web/dist/mcp/flow.html +54 -54
- package/node_modules/@engenty/wizards-shared/dist/feature-flags.d.ts +12 -0
- package/node_modules/@engenty/wizards-shared/dist/feature-flags.js +12 -0
- package/node_modules/@engenty/wizards-shared/dist/theme.d.ts +7 -0
- package/node_modules/@engenty/wizards-shared/dist/theme.js +11 -0
- package/package.json +16 -3
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/plugin.json +1 -1
- package/apps/web/dist/assets/AboutDialog-BUdEn9X_.js +0 -1
- package/apps/web/dist/assets/EditorPage-j5HjqTMV.js +0 -4
- package/apps/web/dist/assets/NewWizardChannels-DeJP5h5I.js +0 -1
- package/apps/web/dist/assets/NewWizardPage-CIS3qNUz.js +0 -7
- package/apps/web/dist/assets/OnboardingPage-CoTYSubc.js +0 -1
- package/apps/web/dist/assets/ProjectPage-XVhe87S4.js +0 -1
- package/apps/web/dist/assets/PublicRunner-Bc-3e7UU.js +0 -1
- package/apps/web/dist/assets/RunDrawer-DXqyxTsm.js +0 -4
- package/apps/web/dist/assets/SettingsPage-ChpDzJVn.js +0 -2
- package/apps/web/dist/assets/SetupPage-E5JoQMBM.js +0 -1
- package/apps/web/dist/assets/SharePage-DW1b2g9t.js +0 -1
- package/apps/web/dist/assets/changelog-DuSV2HiU.js +0 -1
- package/apps/web/dist/assets/esm-yMT-rSPa.js +0 -7
- package/apps/web/dist/assets/index-D9oqYYa8.css +0 -1
- package/apps/web/dist/assets/index-DfHH4icT.js +0 -14
- package/apps/web/dist/assets/oss-credits-6A3pxilr.js +0 -1
- package/apps/web/dist/assets/settings-menu-CVl54phq.js +0 -1
- package/apps/web/dist/assets/theme-DZZXa238.js +0 -11
- package/apps/web/dist/assets/ui-kIzOrA_W.js +0 -137
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FlowPreview-DZ1XL_o1.js","assets/rolldown-runtime-hePW80VL.js","assets/jsx-runtime-BNakU3Ej.js","assets/ui-DRYauuxF.js","assets/preload-helper-CNEI7N0N.js","assets/esm-BdxDT9Km.js","assets/react-dom-hf6EcyAr.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{n as e,r as t}from"./rolldown-runtime-hePW80VL.js";import{n,t as r}from"./jsx-runtime-BNakU3Ej.js";import{Er as i,Fr as a,Ft as o,Gt as s,Ir as c,It as l,Lt as u,Mr as d,Pt as f,Qt as p,Rr as m,Ti as h,Ur as g,V as _,Xt as v,Zr as y,_r as b,ai as x,br as S,ei as C,hi as ee,ii as te,ln as w,ni as ne,nr as T,rn as E,rr as D,ti as re,ur as ie,yr as O}from"./ui-DRYauuxF.js";import{t as k}from"./useMutation-1jFwXbI6.js";import{t as A}from"./preload-helper-CNEI7N0N.js";import{i as j,n as M,r as ae,t as oe}from"./volume-2-C51sO2X0.js";import{n as se,t as ce}from"./coins-RUupcqZx.js";import{d as le,h as ue,k as de,x as fe}from"./session-DekDyd9S.js";import{c as pe,s as me}from"./engenty-CNjaZCVM.js";var he=class extends ne{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type=`infinite`,super.setOptions(e)}getOptimisticResult(e){return e._type=`infinite`,super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,c=n.fetchMeta?.fetchMore?.direction,l=o&&c===`forward`,u=i&&c===`forward`,d=o&&c===`backward`,f=i&&c===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:te(t,n.data),hasPreviousPage:x(t,n.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:d,isFetchingPreviousPage:f,isRefetchError:s&&!l&&!d,isRefetching:a&&!u&&!f}}};function ge(e,t){return re(e,he,t)}var _e={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`}]]};_e.node;var N=g(_e),ve={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`]};ve.node;var ye=g(ve),be={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`}]]};be.node;var xe=g(be),Se={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`}]]};Se.node;var Ce=g(Se),we={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`}]]};we.node;var P=g(we),Te={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`}]]};Te.node;var F=g(Te),Ee={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`}]]};Ee.node;var I=g(Ee),De={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`}]]};De.node;var L=g(De),Oe={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`}]]};Oe.node;var ke=g(Oe),Ae={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`}]]};Ae.node;var je=g(Ae),Me={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`}]]};Me.node;var R=g(Me),Ne={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`}]]};Ne.node;var Pe=g(Ne),Fe={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`}]]};Fe.node;var Ie=g(Fe),Le={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`}]]};Le.node;var z=g(Le),Re={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`}]]};Re.node;var ze=g(Re),Be={name:`terminal`,size:24,node:[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]};Be.node;var Ve=g(Be),He={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`}]]};He.node;var Ue=g(He),We={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`]};We.node;var B=g(We),Ge=[`text`,`document`,`table`,`image`,`video`,`audio`,`dashboard`],Ke=[`any`,`trades`,`gastronomy`,`hospitality`,`realEstate`,`retail`,`health`,`professional`,`agency`,`events`,`publicSector`],qe=[`marketing`,`sales`,`accounting`,`service`,`research`,`hr`,`operations`,`website`,`visuals`,`inquiries`,`advice`],Je=[`text`,`web`,`browser`,`documents`,`image`,`video`,`speech`,`listening`,`code`,`connectors`,`film`],Ye=[`free`,`pro`],Xe={"format.text":`Text`,"format.document":`Document (PDF, Word)`,"format.table":`Table`,"format.image":`Image`,"format.video":`Video`,"format.audio":`Audio`,"format.dashboard":`Dashboard`,"industry.any":`Any industry`,"industry.trades":`Trades`,"industry.gastronomy":`Food service`,"industry.hospitality":`Hotels & tourism`,"industry.realEstate":`Real estate`,"industry.retail":`Retail`,"industry.health":`Health`,"industry.professional":`Professional services`,"industry.agency":`Agency & marketing`,"industry.events":`Events`,"industry.publicSector":`Associations & public sector`,"useCase.marketing":`Marketing & social media`,"useCase.sales":`Offers & sales`,"useCase.accounting":`Accounting & receipts`,"useCase.service":`Customer service`,"useCase.research":`Research & analysis`,"useCase.hr":`HR & applications`,"useCase.operations":`Planning & operations`,"useCase.website":`Website helpers`,"useCase.visuals":`Images & video`,"useCase.inquiries":`Inquiries & bookings`,"useCase.advice":`Advice & pricing`,"capability.text":`Writes text`,"capability.web":`Web search`,"capability.browser":`Drives a browser`,"capability.documents":`Reads documents & photos`,"capability.image":`Makes images`,"capability.video":`Makes video`,"capability.speech":`Speech output`,"capability.listening":`Understands voice notes`,"capability.code":`Runs code`,"capability.connectors":`Connected accounts & systems`,"capability.film":`Films with Claude Code (on your subscription)`,"cost.low":`low cost`,"cost.medium":`medium cost`,"cost.high":`high cost`,"plan.free":`Free`,"plan.pro":`Pro`,"outline.otherwise":`otherwise`,"outline.and":`{first} and {second}`,"outline.with":`with {name}`,"outline.without":`without {name}`,"outline.contains":`{name} contains {value}`},Ze={en:Xe,de:{"format.text":`Text`,"format.document":`Dokument (PDF, Word)`,"format.table":`Tabelle`,"format.image":`Bild`,"format.video":`Video`,"format.audio":`Audio`,"format.dashboard":`Dashboard`,"industry.any":`Jede Branche`,"industry.trades":`Handwerk`,"industry.gastronomy":`Gastronomie`,"industry.hospitality":`Hotel & Tourismus`,"industry.realEstate":`Immobilien`,"industry.retail":`Handel`,"industry.health":`Gesundheit`,"industry.professional":`Kanzlei & Beratung`,"industry.agency":`Agentur & Marketing`,"industry.events":`Veranstaltungen`,"industry.publicSector":`Vereine & Öffentliches`,"useCase.marketing":`Marketing & Social Media`,"useCase.sales":`Angebote & Verkauf`,"useCase.accounting":`Buchhaltung & Belege`,"useCase.service":`Kundenservice`,"useCase.research":`Recherche & Analyse`,"useCase.hr":`Personal & Bewerbungen`,"useCase.operations":`Planung & Abläufe`,"useCase.website":`Helfer für die Website`,"useCase.visuals":`Bilder & Video`,"useCase.inquiries":`Anfragen & Termine`,"useCase.advice":`Beratung & Preise`,"capability.text":`Text schreiben`,"capability.web":`Websuche`,"capability.browser":`Browser bedienen`,"capability.documents":`Dokumente & Fotos lesen`,"capability.image":`Bilder erzeugen`,"capability.video":`Videos erzeugen`,"capability.speech":`Sprachausgabe`,"capability.listening":`Sprachnotizen verstehen`,"capability.code":`Code ausführen`,"capability.connectors":`Verbundene Konten & Systeme`,"capability.film":`Filme mit Claude Code (auf deinem Abo)`,"cost.low":`günstig`,"cost.medium":`mittel`,"cost.high":`teuer`,"plan.free":`Kostenlos`,"plan.pro":`Pro`,"outline.otherwise":`sonst`,"outline.and":`{first} und {second}`,"outline.with":`mit {name}`,"outline.without":`ohne {name}`,"outline.contains":`{name} enthält {value}`}};function Qe(e,t,n,r){let i=`${e}.${t}`;return i in Xe?w(Ze,i,n,r):t}var V=t(n(),1);function $e(e){switch(e.type){case`page`:return R;case`agent`:return j;case`generate`:return e.asset===`image`?L:e.asset===`video`?D:e.asset===`dashboard`?ke:i;case`widget`:return N;case`surface`:return je;case`film`:return P;case`review`:return F;case`result`:return I}return B}var et={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 tt(e){return E(`type.${e.type}`)}var nt=[`web_search`,`web_fetch`,`browser`,`sandbox`,`image`,`http`,`pages`,`code`];function rt(e){return nt.includes(e)?E(`tool.${e}`):e}function it(e){switch(e.type){case`page`:return e.fields.map(e=>e.label).join(` · `);case`agent`:{let t=e.tools.map(rt),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?E(`editor.reviewEditable`):null,e.regenerate?E(`editor.reviewRedo`):null].filter(Boolean).join(` · `);case`result`:return e.deliverables.map(e=>`${e.label??e.from} (${e.formats.join(`, `)})`).join(` · `)}return``}var at=e({EntryDialog:()=>Q,MarketplaceBrowser:()=>Ct,MarketplaceCards:()=>St,MarketplaceHits:()=>xt,ProChip:()=>K,useSettled:()=>$}),H=t(r(),1),ot=(0,V.lazy)(()=>A(()=>import(`./FlowPreview-DZ1XL_o1.js`),__vite__mapDeps([0,1,2,3,4,5,6]))),st={useCase:``,industry:``,format:``,capability:``,plan:``},U=(e,t)=>Qe(e,t,p),ct={en:xe,de:Ce};function lt(e){if(e<1)return 1;let t=10**Math.floor(Math.log10(e));return Math.round(e/t)*t}function ut(e){return e.credits?E(`market.credits`,{n:lt(e.credits.credits)}):U(`cost`,e.costTier)}var dt={text:Ue,document:i,table:ze,image:L,video:D,audio:m,dashboard:ye};function W({format:e,className:t}){let n=dt[e],r=U(`format`,e);return(0,H.jsx)(`span`,{title:r,className:`inline-flex`,children:(0,H.jsx)(n,{className:t,"aria-label":r,role:`img`})})}var ft=[`low`,`medium`,`high`];function G({entry:e}){let t=ft.indexOf(e.costTier)+1,n=ct[p];return(0,H.jsxs)(`span`,{title:ut(e),className:`inline-flex items-center gap-1`,children:[(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`inline-flex shrink-0`,children:ft.slice(0,t).map((e,t)=>(0,H.jsx)(`span`,{className:v(`rounded-full bg-(--coin-bg,var(--color-card))`,t>0&&`-ml-1.5`),children:(0,H.jsx)(n,{className:`size-4`})},e))}),U(`cost`,e.costTier)]})}function K(){return(0,H.jsx)(l,{tone:`ember`,title:E(`market.proHint`),children:E(`market.pro`)})}function pt({plugin:e}){return(0,H.jsx)(l,{icon:(0,H.jsx)(Pe,{className:`size-3.5`}),title:E(`market.fromPlugin`,{name:e.name}),children:e.name})}function q({entry:e,onOpen:t}){return(0,H.jsxs)(o,{role:`button`,tabIndex:0,onClick:t,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t())},className:v(`relative flex min-h-[124px] cursor-pointer flex-col gap-5 p-4 text-left transition sm:min-h-[136px] sm:p-5 hover:shadow-elevated focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus`,(!e.usable||e.missing.length>0||!!e.needs?.length)&&`opacity-60`),children:[(0,H.jsx)(`span`,{className:`-top-4 pointer-events-none absolute right-4`,children:(0,H.jsx)(fe,{kind:e.avatar,costume:e.costume,size:68})}),(0,H.jsxs)(`div`,{className:`min-w-0 pr-20`,children:[(0,H.jsxs)(`div`,{className:`font-display font-semibold text-[0.9375rem]`,children:[e.title,e.plan===`pro`?(0,H.jsx)(`span`,{className:`ml-1.5 inline-flex align-middle`,children:(0,H.jsx)(K,{})}):null,e.starred?(0,H.jsx)(z,{className:`ml-1.5 inline size-3.5 fill-amber align-[-2px] text-amber`,"aria-label":E(`market.starred`)}):null]}),(0,H.jsx)(`div`,{className:`mt-0.5 text-[0.8125rem] text-ink-3 leading-snug`,children:e.pitch})]}),(0,H.jsxs)(`div`,{className:`mt-auto flex flex-wrap items-center gap-x-3 gap-y-1.5 text-[0.75rem] text-ink-3`,children:[e.plugin?(0,H.jsx)(pt,{plugin:e.plugin}):null,e.needs?.length?(0,H.jsx)(l,{tone:`warn`,children:E(`market.needsPro`,{list:e.needs.join(`, `)})}):e.usable&&e.missing.length?(0,H.jsx)(l,{tone:`warn`,children:E(`market.missing`,{list:Y(e.missing)})}):e.usable?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,H.jsx)(d,{className:`size-3.5`}),` `,E(`market.minutes`,{n:e.effort.minutes})]}),(0,H.jsx)(G,{entry:e}),e.optional?.length?(0,H.jsx)(l,{title:E(`market.optionalHint`,{list:Y(e.optional)}),children:E(`market.without`,{list:Y(e.optional)})}):null,(0,H.jsx)(`span`,{className:`ml-auto inline-flex items-center gap-1.5`,children:e.formats.map(e=>(0,H.jsx)(W,{format:e,className:`size-4`},e))})]}):(0,H.jsx)(l,{tone:`warn`,children:E(`market.needsUpdate`)})]})]})}function J({title:e,children:t}){return(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`mb-1.5 font-medium text-[0.75rem] text-ink-3 uppercase tracking-[0.06em]`,children:e}),t]})}var Y=e=>e.map(e=>U(`capability`,e)).join(`, `),mt={text:b,web:ae,browser:O,documents:Ie,image:L,video:D,speech:oe,listening:S,code:Ve,connectors:M,film:P};function ht(e){switch(e.type){case`page`:return R;case`agent`:return j;case`generate`:return e.asset===`image`?L:e.asset===`video`?D:e.asset===`voice`?oe:e.asset===`dashboard`?ye:i;case`widget`:return e.video?P:N;case`surface`:return N;case`film`:return P;case`review`:return F;case`result`:return I}return B}function gt(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 _t(e){let t=gt(e);return e.map(e=>({id:e.id,title:e.title,icon:ht(e),tone:et[e.type]??`bg-paper-2 text-ink-2`,optional:t.has(e.id),branches:e.branches}))}function X({title:e,children:t}){return(0,H.jsx)(`span`,{title:e,className:`inline-flex items-center gap-2 border-border border-l px-4 first:border-l-0 first:pl-0`,children:t})}function Z({icon:e,children:t,more:n}){return(0,H.jsxs)(`div`,{className:`flex gap-2.5`,children:[(0,H.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:e}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`div`,{className:`text-[0.875rem] text-ink leading-snug`,children:t}),n?(0,H.jsx)(`div`,{className:`text-[0.75rem] text-ink-3 leading-snug`,children:n}):null]})]})}function vt({className:e,children:t}){let n=(0,V.useRef)(null),[r,i]=(0,V.useState)({above:!1,below:!1});(0,V.useEffect)(()=>{let e=n.current;if(!e)return;let t=()=>{let t=e.scrollTop>1,n=e.scrollTop+e.clientHeight<e.scrollHeight-1;i(e=>e.above===t&&e.below===n?e:{above:t,below:n})};t(),e.addEventListener(`scroll`,t,{passive:!0});let r=new ResizeObserver(t);return r.observe(e),e.firstElementChild&&r.observe(e.firstElementChild),()=>{e.removeEventListener(`scroll`,t),r.disconnect()}},[]);let a=`linear-gradient(to bottom, ${r.above?`transparent`:`black`} 0, black 28px, black calc(100% - 44px), ${r.below?`transparent`:`black`} 100%)`;return(0,H.jsx)(`div`,{ref:n,className:e,style:{maskImage:a,WebkitMaskImage:a},children:(0,H.jsx)(`div`,{children:t})})}function Q({id:e,fallback:t,onClose:n,onUse:r,busy:i}){let a=h(),o=y(),c=C({queryKey:[`marketplace-entry`,e,p],queryFn:()=>_.get(`/api/studio/marketplace/${encodeURIComponent(e)}?lang=${p}`),enabled:!!e,retry:!1}),l=c.data??t,m=k({mutationFn:t=>{let n=`/api/studio/marketplace/${encodeURIComponent(e)}/star`;return t?_.put(n):_.del(n)},onSuccess:()=>Promise.all([a.invalidateQueries({queryKey:[`marketplace`]}),a.invalidateQueries({queryKey:[`marketplace-entry`,e]})])}),g=de()===`dark`,b=me[pe[l?.avatar||`round`]],x=g?`var(--card)`:`color-mix(in oklch, ${b??`var(--ink-4)`} 14%, var(--paper-2))`;return(0,H.jsx)(u,{open:!!e,onClose:n,wide:!0,bare:!0,children:l?(0,H.jsxs)(`div`,{className:`relative flex max-h-[calc(100dvh-48px)] flex-col rounded-2xl bg-card shadow-overlay max-sm:h-dvh max-sm:max-h-none max-sm:rounded-none`,children:[(0,H.jsx)(`button`,{type:`button`,"aria-label":E(`common.close`),onClick:n,className:`sm:-top-3.5 sm:-right-3.5 absolute top-3 right-3 z-20 flex size-9 items-center justify-center rounded-full bg-card text-ink-2 shadow-elevated ring-1 ring-border-soft transition hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus`,children:(0,H.jsx)(T,{className:`size-4`})}),(0,H.jsxs)(`header`,{className:`relative shrink-0 border-border-soft border-b px-5 pt-5 pb-4 text-ink sm:rounded-t-2xl sm:px-7`,style:{background:x,"--coin-bg":x},children:[(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 overflow-hidden sm:rounded-t-2xl`,children:(0,H.jsx)(`span`,{className:v(`-top-28 -right-10 absolute size-80 rounded-full bg-white blur-3xl`,g?`opacity-[0.14]`:`opacity-80`)})}),(0,H.jsx)(`div`,{className:`-bottom-5 absolute right-9 z-10 max-sm:hidden`,children:(0,H.jsx)(fe,{kind:l.avatar,costume:l.costume,size:104})}),(0,H.jsxs)(`div`,{className:`relative sm:pr-36`,children:[(0,H.jsx)(`h2`,{className:`font-display font-semibold text-[1.375rem] leading-tight tracking-tight max-sm:pr-10`,children:l.title}),(0,H.jsx)(`p`,{className:`mt-1 text-[0.875rem] text-ink-2 leading-snug`,children:c.data?.description||l.pitch})]}),l.usable?(0,H.jsxs)(`div`,{className:`-mx-5 sm:-mx-7 relative mt-3.5 flex flex-wrap items-center gap-y-2 border-border-soft border-t px-5 pt-3 font-medium text-[0.875rem] sm:px-7 sm:pr-40`,children:[(0,H.jsxs)(X,{title:E(`market.duration`),children:[(0,H.jsx)(d,{className:`size-4 text-ink-3`}),E(`market.minutes`,{n:l.effort.minutes})]}),(0,H.jsx)(X,{title:E(`market.cost`),children:(0,H.jsx)(G,{entry:l})}),(0,H.jsx)(X,{title:E(`market.result`),children:l.formats.map(e=>(0,H.jsx)(W,{format:e,className:`size-4`},e))})]}):null]}),l.usable?(0,H.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-x-7 gap-y-6 px-5 pt-6 max-sm:overflow-y-auto max-sm:pb-4 sm:grid-cols-[230px_minmax(0,1fr)] sm:grid-rows-[minmax(0,1fr)] sm:px-7`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col gap-5 sm:min-h-0 sm:overflow-y-auto`,children:[(0,H.jsx)(J,{title:E(`market.duration`),children:(0,H.jsx)(Z,{icon:(0,H.jsx)(d,{className:`size-4 text-moss`}),more:E(`market.durationHint`,{n:l.effort.fields}),children:E(`market.minutes`,{n:l.effort.minutes})})}),(0,H.jsx)(J,{title:E(`market.cost`),children:(0,H.jsx)(Z,{icon:(0,H.jsx)(ce,{className:`size-4 text-amber`}),more:l.credits?E(`market.creditsHint`):void 0,children:(0,H.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2`,children:[(0,H.jsx)(G,{entry:l}),l.credits?(0,H.jsx)(`span`,{className:`text-ink-2`,children:E(`market.creditsRange`,{n:lt(l.credits.credits)})}):null]})})}),(0,H.jsx)(J,{title:E(`market.result`),children:(0,H.jsx)(`div`,{className:`flex flex-col gap-2`,children:(c.data?.results??[]).map(e=>(0,H.jsx)(Z,{icon:(0,H.jsx)(W,{format:e.kind,className:`size-4 text-ember-strong`}),more:e.formats.map(e=>e.toUpperCase()).join(` · `),children:e.title},e.title))})}),(0,H.jsx)(J,{title:E(`market.needs`),children:(0,H.jsx)(`ul`,{className:`flex flex-col gap-2`,children:l.capabilities.map(e=>{let t=mt[e],n=l.missing.includes(e),r=l.optional?.includes(e);return(0,H.jsxs)(`li`,{className:v(`flex items-center gap-2.5 text-[0.875rem]`,n?`text-ink-3`:`text-ink-2`),children:[(0,H.jsx)(t,{className:v(`size-4 shrink-0`,n?`text-rose`:r?`text-amber`:`text-cobalt`)}),U(`capability`,e),n?(0,H.jsx)(`span`,{className:`text-[0.75rem] text-rose`,children:E(`market.unavailable`)}):r?(0,H.jsx)(`span`,{className:`text-[0.75rem] text-amber`,children:E(`market.optional`)}):null]},e)})})})]}),(0,H.jsxs)(`div`,{className:`flex flex-col sm:min-h-0`,children:[(0,H.jsx)(`div`,{className:`mb-1.5 shrink-0 font-medium text-[0.75rem] text-ink-3 uppercase tracking-[0.06em]`,children:E(`market.steps`)}),(0,H.jsx)(vt,{className:`-mr-2 overscroll-contain pt-1 pr-2 pl-1 sm:min-h-0 sm:flex-1 sm:overflow-y-auto`,children:c.isLoading?(0,H.jsx)(s,{className:`size-5 text-ink-3`}):(0,H.jsx)(V.Suspense,{fallback:(0,H.jsx)(s,{className:`size-5 text-ink-3`}),children:(0,H.jsx)(ot,{steps:_t(c.data?.outline??[])})})})]})]}):(0,H.jsx)(`div`,{className:`flex-1 px-5 pt-6 sm:px-7`,children:(0,H.jsx)(`p`,{className:`rounded-lg bg-amber-tint p-3 text-[0.875rem] text-ink-2`,children:E(`market.needsUpdateHint`)})}),(0,H.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 px-5 pt-4 pb-5 max-sm:border-border-soft max-sm:border-t sm:px-7 sm:pb-6`,children:[l.plugin?(0,H.jsx)(`span`,{className:`mr-auto flex items-center`,children:(0,H.jsx)(pt,{plugin:l.plugin})}):(0,H.jsxs)(f,{variant:`ghost`,className:`mr-auto`,title:E(`market.starHint`),"aria-pressed":l.starred,busy:m.isPending,onClick:()=>m.mutate(!l.starred),children:[(0,H.jsx)(z,{className:v(`size-4`,l.starred&&`fill-amber text-amber`)}),(0,H.jsx)(`span`,{className:`max-sm:sr-only`,children:E(l.starred?`market.starred`:`market.star`)})]}),(0,H.jsx)(f,{variant:`secondary`,onClick:n,children:E(`common.close`)}),l.usable&&l.missing.length?(0,H.jsx)(f,{variant:`secondary`,onClick:()=>o(`/settings/models`),children:E(`editor.models.settings`)}):null,r?(0,H.jsx)(f,{disabled:!l.usable||l.missing.length>0||!!l.needs?.length,title:l.needs?.length?E(`market.needsProHint`,{list:l.needs.join(`, `)}):l.missing.length?E(`market.missingHint`,{list:Y(l.missing)}):l.optional?.length?E(`market.optionalHint`,{list:Y(l.optional)}):void 0,busy:i,onClick:()=>r(l),children:E(`market.use`)}):null]})]}):(0,H.jsx)(`div`,{className:`flex min-h-48 flex-col items-center justify-center gap-3 rounded-2xl bg-card p-8 text-[0.875rem] text-ink-2 shadow-overlay`,children:c.isLoading?(0,H.jsx)(s,{className:`size-6 text-ink-3`}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`p`,{children:E(`market.notFound`)}),(0,H.jsx)(f,{variant:`secondary`,onClick:n,children:E(`common.close`)})]})})})}function yt({name:e,value:t,options:n,onChange:r}){let[i,o]=(0,V.useState)(!1),s=(0,V.useRef)(null);(0,V.useEffect)(()=>{if(!i)return;let e=e=>{s.current?.contains(e.target)||o(!1)},t=e=>{e.key===`Escape`&&o(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[i]);let l=n.find(e=>e.value===t);return(0,H.jsxs)(`div`,{ref:s,className:`relative`,children:[(0,H.jsxs)(`div`,{className:v(`flex h-8 items-center rounded-full text-[0.8125rem] transition`,l?`bg-ember-tint text-ink`:`text-ink-2 hover:bg-paper-2 hover:text-ink`,i&&!l&&`bg-paper-2 text-ink`),children:[(0,H.jsx)(`button`,{type:`button`,"aria-haspopup":`listbox`,"aria-expanded":i,onClick:()=>o(!i),className:v(`flex h-full items-center gap-1.5 rounded-full pl-3 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus`,l?`pr-1`:`pr-2.5`),children:l?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`text-ink-3`,children:e}),(0,H.jsx)(`span`,{className:`font-medium`,children:l.label})]}):(0,H.jsxs)(H.Fragment,{children:[e,(0,H.jsx)(a,{className:v(`size-3.5 transition`,i&&`rotate-180`)})]})}),l?(0,H.jsx)(`button`,{type:`button`,"aria-label":`${e}: ${E(`market.reset`)}`,onClick:()=>r(``),className:`mr-1 flex size-6 items-center justify-center rounded-full text-ink-3 hover:bg-card hover:text-ink`,children:(0,H.jsx)(T,{className:`size-3.5`})}):null]}),i?(0,H.jsx)(`div`,{role:`listbox`,"aria-label":e,className:`absolute top-full left-0 z-30 mt-1.5 max-h-80 min-w-60 overflow-y-auto rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,children:n.map(e=>(0,H.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":e.value===t,disabled:!e.count||e.unavailable,onClick:()=>{r(e.value===t?``:e.value),o(!1)},className:v(`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-left text-[0.875rem] transition coarse:py-2.5`,e.count&&!e.unavailable?`text-ink-2 hover:bg-paper-2 hover:text-ink`:`text-ink-4`,e.value===t&&`font-medium text-ink`),children:[e.icon,(0,H.jsx)(`span`,{className:`flex-1 whitespace-nowrap`,children:e.label}),e.value===t?(0,H.jsx)(c,{className:`size-4 text-ember`}):e.unavailable?(0,H.jsx)(`span`,{className:`whitespace-nowrap text-[0.75rem] text-ink-4`,children:E(`market.unavailable`)}):(0,H.jsx)(`span`,{className:`text-[0.75rem] text-ink-4 tabular-nums`,children:e.count})]},e.value))}):null]})}function $(e,t){let[n,r]=(0,V.useState)(e);return(0,V.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n}var bt=60;function xt({query:e,onUse:t,busy:n,limit:r=6}){let[i,a]=(0,V.useState)(null),o=$(e.trim(),250),c=C({queryKey:[`marketplace`,p,o,`hits`,r],queryFn:()=>_.get(`/api/studio/marketplace?${new URLSearchParams({lang:p,limit:String(r),offset:`0`,q:o})}`),enabled:!!o,placeholderData:ee}),l=o?c.data?.entries??[]:[];return l.length?(0,H.jsxs)(`section`,{className:`mt-10`,children:[(0,H.jsxs)(`h2`,{className:`mb-5 flex items-center gap-2 font-medium text-[0.8125rem] text-ink-3 uppercase tracking-[0.08em]`,children:[E(`market.hits`),c.isFetching?(0,H.jsx)(s,{className:`size-3.5`}):null]}),(0,H.jsx)(`div`,{className:`flex flex-col gap-4 sm:grid sm:grid-cols-2 lg:grid-cols-3`,children:l.map(e=>(0,H.jsx)(q,{entry:e,onOpen:()=>a(e.id)},e.id))}),(0,H.jsx)(Q,{id:i,fallback:l.find(e=>e.id===i)??null,onClose:()=>a(null),onUse:t,busy:n})]}):null}function St({entries:e}){let t=h(),n=y(),{project:r}=le(),i=ue()&&!!r&&!r?.readOnly,[a,o]=(0,V.useState)(null),s=k({mutationFn:e=>_.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`]}),o(null),n(`/edit/${e}`)}});return(0,H.jsxs)(`div`,{className:`@container mt-3`,children:[(0,H.jsx)(`div`,{className:`flex flex-col gap-4 @xl:grid @xl:grid-cols-2`,children:e.map(e=>(0,H.jsx)(q,{entry:e,onOpen:()=>o(e.id)},e.id))}),s.error?(0,H.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-rose`,children:s.error.message}):null,(0,H.jsx)(Q,{id:a,fallback:e.find(e=>e.id===a)??null,onClose:()=>o(null),onUse:i?e=>!s.isPending&&s.mutate(e.id):void 0,busy:s.isPending})]})}function Ct({onUse:e,busy:t,open:n,search:r,onGuestOpen:i}){let[a,o]=(0,V.useState)(``);(0,V.useEffect)(()=>{r&&o(r.text)},[r]);let[c,l]=(0,V.useState)(st),[u,d]=(0,V.useState)(!1),[m,h]=(0,V.useState)(n??null),g=$(a.trim(),250),y=(0,V.useRef)(null);(0,V.useEffect)(()=>{let e=y.current;g&&e&&window.matchMedia(`(max-width: 639px)`).matches&&e.scrollIntoView({behavior:`smooth`,block:`start`})},[g]);let b=ge({queryKey:[`marketplace`,p,g,c,u],queryFn:({pageParam:e})=>{let t=new URLSearchParams({lang:p,limit:String(bt),offset:String(e)});g&&t.set(`q`,g);for(let[e,n]of Object.entries(c))n&&t.set(e,n);return u&&t.set(`starred`,`1`),_.get(`/api/${i?`guest`:`studio`}/marketplace?${t}`)},initialPageParam:0,getNextPageParam:(e,t)=>{let n=t.reduce((e,t)=>e+t.entries.length,0);return n<e.total?n:void 0},placeholderData:ee}),x=b.data?.pages[0],S=b.data?.pages.flatMap(e=>e.entries)??[],C=x?.all??0,te=a.trim()!==g||b.isFetching&&!b.isFetchingNextPage,w=(e,t,n,r)=>n.filter(t=>x?.facets[e]?.[t]!==void 0).map(n=>({value:n,label:U(t,n),icon:r?.(n),count:(x?.facets[e])[n]??0,unavailable:e===`capability`&&ne.has(n)})),ne=new Set(x?.unavailable??[]),D=w(`useCase`,`useCase`,qe),re=[{key:`industry`,name:E(`market.industry`),options:w(`industry`,`industry`,Ke)},{key:`format`,name:E(`market.format`),options:w(`format`,`format`,Ge,e=>(0,H.jsx)(W,{format:e,className:`size-4 text-ink-3`}))},{key:`plan`,name:E(`market.plan`),options:w(`plan`,`plan`,Ye)},{key:`capability`,name:E(`market.capability`),options:w(`capability`,`capability`,Je,e=>{let t=mt[e];return(0,H.jsx)(t,{className:`size-4 text-ink-3`})})}],O=!!a.trim()||u||Object.values(c).some(Boolean),k=()=>{l(st),o(``),d(!1)};if(b.isLoading)return(0,H.jsx)(`div`,{className:`flex justify-center py-10`,children:(0,H.jsx)(s,{className:`size-6 text-ink-3`})});let A=x?.offline?(0,H.jsxs)(`p`,{className:`mt-4 flex items-center justify-center gap-2 text-[0.8125rem] text-ink-3`,children:[(0,H.jsx)(se,{className:`size-4 shrink-0`}),E(`market.offline`)]}):null;if(!C&&!O)return A;let j=a?(0,H.jsx)(`button`,{type:`button`,"aria-label":E(`market.reset`),onClick:()=>o(``),className:`-mr-1.5 flex size-7 shrink-0 items-center justify-center rounded-full text-ink-3 hover:bg-paper-2 hover:text-ink`,children:(0,H.jsx)(T,{className:`size-4`})}):null,M=e=>v(`inline-flex h-7 shrink-0 items-center gap-1 whitespace-nowrap rounded-full px-2.5 text-[0.78125rem] transition`,e?`bg-card font-medium text-ink shadow-soft ring-1 ring-border-soft`:`text-ink-3 hover:bg-card/60 hover:text-ink`);return(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`label`,{ref:y,className:`relative mx-auto flex h-10 max-w-md scroll-mt-4 items-center gap-2.5 rounded-full bg-card px-4 shadow-soft ring-1 ring-border-soft transition focus-within:ring-2 focus-within:ring-focus sm:h-11`,children:[te?(0,H.jsx)(s,{className:`size-4 shrink-0 text-ink-3`}):(0,H.jsx)(ie,{className:`size-4 shrink-0 text-ink-3`}),(0,H.jsx)(`input`,{type:`search`,value:a,onChange:e=>o(e.target.value),placeholder:E(`market.search`),"aria-label":E(`market.search`),className:`min-w-0 flex-1 bg-transparent text-[0.9375rem] outline-none placeholder:text-ink-4 [&::-webkit-search-cancel-button]:hidden`}),j]}),A,(0,H.jsxs)(`div`,{className:`max-sm:-mx-3 mt-4 flex gap-1 max-sm:overflow-x-auto max-sm:px-3 max-sm:[scrollbar-width:none] sm:flex-wrap sm:justify-center max-sm:[&::-webkit-scrollbar]:hidden`,children:[[{value:``,label:E(`market.all`)},...D].map(e=>(0,H.jsx)(`button`,{type:`button`,"aria-pressed":!u&&c.useCase===e.value,onClick:()=>{d(!1),l({...c,useCase:e.value})},className:M(!u&&c.useCase===e.value),children:e.label},e.value)),i?null:(0,H.jsxs)(`button`,{type:`button`,"aria-pressed":u,onClick:()=>d(!u),className:M(u),children:[(0,H.jsx)(z,{className:v(`size-3.5`,u&&`fill-amber text-amber`)}),E(`market.starred`)]})]}),(0,H.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-1 gap-y-2 sm:mt-6`,children:[u?null:re.map(e=>(0,H.jsx)(yt,{name:e.name,value:c[e.key],options:e.options,onChange:t=>l({...c,[e.key]:t})},e.key)),(0,H.jsxs)(`span`,{className:`ml-auto flex items-center gap-3 whitespace-nowrap pl-2 text-[0.8125rem] text-ink-3`,children:[O?(0,H.jsxs)(`button`,{type:`button`,onClick:k,className:`inline-flex items-center gap-1 text-ember-strong underline-offset-2 hover:underline`,children:[(0,H.jsx)(T,{className:`size-3.5 max-sm:size-4`}),(0,H.jsx)(`span`,{className:`max-sm:sr-only`,children:E(`market.resetShort`)})]}):null,O?(0,H.jsx)(`span`,{className:`tabular-nums sm:hidden`,children:E(`market.countOfShort`,{n:x?.total??0,all:C})}):null,(0,H.jsx)(`span`,{className:v(`tabular-nums`,O&&`max-sm:hidden`),children:O?E(`market.countOf`,{n:x?.total??0,all:C}):E(`market.count`,{n:C})})]})]}),S.length?(0,H.jsx)(`div`,{className:`mt-4 flex flex-col gap-4 sm:grid sm:grid-cols-2 lg:grid-cols-3`,children:S.map(e=>(0,H.jsx)(q,{entry:e,onOpen:()=>i?i(e):h(e.id)},e.id))}):(0,H.jsxs)(`div`,{className:`py-10 text-center text-[0.875rem] text-ink-3`,children:[(0,H.jsx)(`p`,{children:E(u?`market.noneStarred`:`market.none`)}),(0,H.jsx)(f,{variant:`ghost`,className:`mt-2`,onClick:k,children:E(`market.reset`)})]}),b.hasNextPage?(0,H.jsx)(`div`,{className:`mt-6 flex justify-center`,children:(0,H.jsx)(f,{variant:`secondary`,busy:b.isFetchingNextPage,onClick:()=>void b.fetchNextPage(),children:E(`market.more`)})}):null,(0,H.jsx)(Q,{id:m,fallback:S.find(e=>e.id===m)??null,onClose:()=>h(null),onUse:e,busy:t})]})}export{P as C,F as S,Pe as _,K as a,L as b,$e as c,tt as d,Qe as f,z as g,ze as h,at as i,it as l,Ue as m,Ct as n,$ as o,B as p,xt as r,et as s,Q as t,rt as u,R as v,N as w,I as x,je as y};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{Ir as r,Rr as i,Xt as a,hn as o,mr as s,rn as c,rr as l}from"./ui-DRYauuxF.js";import{v as u}from"./Marketplace-BF0Rx0VR.js";import{r as d}from"./volume-2-C51sO2X0.js";import{t as f}from"./phone-ChnpShTU.js";import{_t as p,gt as m,ht as h}from"./index-qnpoZzuw.js";var g=[`text`,`data`,`image`,`video`,`voice`,`document`,`dashboard`,`widget`,`film`,`surface`];[...o],[...g];var _={default:`steps`,enabled:[`steps`,`chat`]},v=e(t(),1),y=e(n(),1),b=[{id:`steps`,group:`web`,runner:`steps`,label:`new.ch.steps`,icon:u},{id:`chat`,group:`web`,runner:`chat`,label:`new.ch.chat`,icon:p},{id:`talk`,group:`web`,runner:`talk`,label:`new.ch.talk`,icon:i},{id:`video`,group:`web`,runner:`video`,label:`new.ch.video`,icon:l},{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:h},{id:`whatsapp`,group:`message`,runner:`whatsapp`,label:`new.ch.whatsapp`,icon:null}],x=[{id:`web`,label:`new.web`,icon:d},{id:`phone`,label:`new.phone`,icon:f},{id:`message`,label:`new.messages`,icon:m}],S=b.filter(e=>_.enabled.includes(e.id)).map(e=>e.id),C=e=>b.filter(t=>e.includes(t.id));function w(e){return e.length===S.length&&S.every(t=>e.includes(t))}function T(e){let t=C(e),n=[...new Set(t.map(e=>e.runner))];return{default:t.find(e=>e.group===`web`)?.runner??n[0]??_.default,enabled:n}}var E=e=>e.map(e=>c(e.label));function D(e){return b.find(t=>t.runner===e)}function O(e){return b.filter(t=>t.id!==`wacall`&&e.includes(t.runner)).map(e=>e.id)}function k(e){let t=C(e),n=x.flatMap(e=>{let n=E(t.filter(t=>t.group===e.id));return n.length?[e.id===`web`?n.join(`, `):`${c(e.label)}: ${n.join(`, `)}`]:[]});return`${c(`new.runsAs`)}: ${n.join(` · `)}`}function A(e){return e.length<=2?e.join(`, `):`${e.slice(0,2).join(`, `)} +${e.length-2}`}function j({channel:e,className:t}){let n=e.icon;return n?(0,y.jsx)(n,{className:t??`size-4`}):(0,y.jsx)(`span`,{"aria-hidden":`true`,className:`font-semibold text-[0.625rem] tracking-wide`,children:`WA`})}function M(e){let t=new Set(e?.map(e=>e.id)??[`steps`,`chat`]);return b.filter(e=>t.has(e.runner))}function N({value:e,onChange:t,runners:n,without:i,disabled:o}){let s=M(n).filter(e=>!i?.includes(e.id)),l=t=>e.includes(t.id),u=n=>{o||l(n)&&e.length===1||t(l(n)?e.filter(e=>e!==n.id):[...e,n.id])},d=t=>{let n=x.find(e=>e.id===t),i=s.filter(e=>e.group===t);if(!(n&&i.length))return null;let d=n.icon;return(0,y.jsxs)(`fieldset`,{className:`m-0 flex min-w-0 flex-col gap-0.5 border-0 p-0`,children:[(0,y.jsxs)(`legend`,{className:`flex items-center gap-1.5 px-2 pt-2 pb-1 text-[0.75rem] text-ink-3`,children:[(0,y.jsx)(d,{className:`size-3.5`}),` `,c(n.label)]}),i.map(t=>(0,y.jsxs)(`div`,{children:[(0,y.jsxs)(`label`,{className:a(`flex h-10 w-full cursor-pointer items-center gap-2.5 rounded-lg px-2 text-[0.875rem] transition hover:bg-accent has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-focus coarse:h-11`,l(t)&&`bg-paper-2`),children:[(0,y.jsx)(`span`,{className:`flex w-5 justify-center text-ink-3`,children:(0,y.jsx)(j,{channel:t})}),(0,y.jsx)(`span`,{className:`flex-1`,children:c(t.label)}),(0,y.jsx)(`input`,{type:`checkbox`,className:`sr-only`,"aria-label":c(t.label),checked:l(t),disabled:o,"aria-disabled":l(t)&&e.length===1,onChange:()=>u(t)}),(0,y.jsx)(`span`,{"aria-hidden":`true`,className:a(`flex size-[1.125rem] items-center justify-center rounded-md ring-1`,l(t)?`bg-ink text-paper ring-ink`:`ring-border`),children:l(t)?(0,y.jsx)(r,{className:`size-3`,strokeWidth:3}):null})]}),t.id===`call`&&l(t)?(0,y.jsx)(`p`,{className:`px-2 pb-1.5 pl-9 text-[0.75rem] text-ink-3`,children:c(`new.callHandoff`)}):null]},t.id))]})};return(0,y.jsxs)(`div`,{className:`grid gap-x-4 sm:grid-cols-2`,children:[d(`web`),(0,y.jsxs)(`div`,{className:`flex flex-col`,children:[d(`phone`),d(`message`)]})]})}function P({value:e,onChange:t,runners:n,className:r}){let[i,o]=(0,v.useState)(!1),[l,u]=(0,v.useState)(0),d=(0,v.useRef)(null);(0,v.useEffect)(()=>{if(!i)return;let e=e=>{d.current?.contains(e.target)||o(!1)},t=e=>{e.key===`Escape`&&o(!1)};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[i]);let f=M(n),p=x.filter(e=>f.some(t=>t.group===e.id)),m=t=>e.includes(t.id);return(0,y.jsxs)(`div`,{ref:d,className:a(`relative flex flex-wrap items-center gap-1.5`,r),children:[(0,y.jsx)(`span`,{className:`mr-0.5 px-1 text-[0.8125rem] text-ink-3`,children:c(`new.runsAs`)}),p.map(e=>{let t=E(f.filter(t=>t.group===e.id&&m(t))),n=e.icon;return(0,y.jsxs)(`button`,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i,"aria-label":`${c(e.label)}: ${t.length?t.join(`, `):c(`new.off`)}`,onClick:e=>{let t=e.currentTarget;u(t.offsetLeft+t.offsetWidth/2),o(e=>!e)},className:a(`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,y.jsx)(n,{className:`size-4 shrink-0`}),t.length?(0,y.jsx)(`span`,{className:`truncate`,children:A(t)}):null]},e.id)}),(0,y.jsx)(`button`,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i,"aria-label":c(`new.where`),onClick:e=>{let t=e.currentTarget;u(t.offsetLeft+t.offsetWidth/2),o(e=>!e)},className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 ring-1 ring-border transition hover:text-ink coarse:size-11`,children:(0,y.jsx)(s,{className:`size-4`})}),i?(0,y.jsxs)(`div`,{role:`dialog`,"aria-label":c(`new.where`),style:{transformOrigin:`${l}px top`},className:`absolute top-full left-0 z-20 mt-2 w-[min(32rem,calc(100vw-2rem))] animate-unfold rounded-2xl bg-card p-3 text-left shadow-overlay ring-1 ring-border`,children:[(0,y.jsx)(`p`,{className:`px-2 pt-1 font-semibold text-[0.9375rem]`,children:c(`new.where`)}),(0,y.jsx)(N,{value:e,onChange:t,runners:n})]}):null]})}export{k as a,w as c,P as i,T as l,j as n,D as o,N as r,O as s,x as t,_ as u};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$r as r,Br as i,Dt as a,It as o,Lt as s,Pt as c,Qt as l,Ti as u,V as d,X as f,Xt as p,Yt as m,Zr as h,c as g,ei as _,hi as v,i as y,l as b,mr as x,nr as S,o as ee,qr as te,rn as C,s as w,u as ne,vr as re}from"./ui-DRYauuxF.js";import{a as T,n as ie,o as E,t as D}from"./Marketplace-BF0Rx0VR.js";import{t as O}from"./useMutation-1jFwXbI6.js";import{d as k,h as A,i as j,t as ae,x as oe}from"./session-DekDyd9S.js";import{t as M}from"./upload-0sFU9K8-.js";import{a as se,c as N,i as P,l as ce}from"./NewWizardChannels-WaAOvmzw.js";var F=[[`id`,8],[`toolId`,10],[`moduleId`,7],[`pluginId`,6],[`title`,6],[`description`,4],[`tags`,3],[`path`,3],[`inputSchema`,2],[`outputSchema`,2],[`request`,1],[`response`,1]];function I(e){return e.normalize(`NFKD`).replace(/[̀-ͯ]/g,``).replace(/([a-z])([A-Z])/g,`$1 $2`).toLowerCase()}function L(e){return I(e).split(/[^a-z0-9]+/).map(e=>e.trim()).filter(e=>e.length>1)}function R(e){return e==null?``:Array.isArray(e)?e.map(R).filter(Boolean).join(` `):typeof e==`object`?Object.values(e).map(R).filter(Boolean).join(` `):String(e)}function z(e,t){let n=t.map(([t,n])=>({text:R(e[t]),weight:n})).filter(e=>e.text.length>0);return{fields:n,tokens:n.flatMap(e=>L(e.text))}}function B(e){let t=[e];if(e.length<5)return t;if(e.endsWith(`ing`)){let n=e.slice(0,-3);n.length>=3&&t.push(n,`${n}e`)}else if(e.endsWith(`ies`)&&e.length>=6)t.push(`${e.slice(0,-3)}y`);else if(e.endsWith(`es`))t.push(e.slice(0,-2),e.slice(0,-1));else if(e.endsWith(`ed`)){let n=e.slice(0,-2);t.push(n,`${n}e`)}else e.endsWith(`s`)&&!e.endsWith(`ss`)&&t.push(e.slice(0,-1));return[...new Set(t)]}function V(e,t){if(e===t)return 1;let n=0;for(let r of B(e))for(let i of B(t)){if(r===i){n=Math.max(n,r===e&&i===t?1:.75);continue}r.length>=2&&i.startsWith(r)&&(n=Math.max(n,.55*(r.length/i.length))),i.length>=4&&r.startsWith(i)&&(n=Math.max(n,.4*(i.length/r.length)))}return n}function H(e,t){return e.reduce((e,n)=>e+V(t,n),0)}function U(e,t,n=F){if(!t?.trim())return 0;let r=L(t);if(r.length===0)return 0;let i=z(e,n);return i.tokens.length===0?0:r.reduce((e,t)=>H(i.tokens,t)===0?e:e+i.fields.reduce((e,n)=>{let r=L(n.text),i=H(r,t);if(i===0)return e;let a=i*2.2/(i+1.2+r.length/16);return e+n.weight*a},0),0)}var W=new Set(L(`aber als also am an auch auf aus bei bin bitte brauche brauchen braucht das dass dem den der
|
|
2
|
+
des die dies diese dieser doch du ein eine einem einen einer eines er es etwas fuer für gerne
|
|
3
|
+
habe haben hat ich ihr im in ist kann können koennen mache machen mag mein meine meinem meinen
|
|
4
|
+
meiner mich mir mit möchte moechte nach nicht noch nur oder sich sie sind soll suche suchen
|
|
5
|
+
sucht um und uns unser unsere vom von vor was wie will wir wird wo wollen zu zum zur
|
|
6
|
+
a about an and are as at be can do for from have how i in is it like looking me my need of on
|
|
7
|
+
or our that the this to want we what which who with would you your`)),G=e=>e.replace(/ß/g,`ss`);function K(e){let t=L(G(e)),n=t.filter(e=>!W.has(e));return n.length?n:t}var q=e=>e.trim().split(/\s+/).filter(Boolean).length>=3,J=e(t(),1),Y=e(n(),1);function le({variant:e=`secondary`,label:t=C(`home.import`)}){let n=h(),r=u(),{project:i}=k(),o=A(),l=(0,J.useRef)(null),f=O({mutationFn:e=>d.upload(`/api/studio/projects/${i.id}/wizards/import`,e),onSuccess:async({id:e})=>{await r.invalidateQueries({queryKey:[`projects`]}),await r.invalidateQueries({queryKey:[`wizards`]}),n(`/edit/${e}`)}}),p=f.error instanceof a?f.error.body?.issues??[]:[];return!o||i?.readOnly?null:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(c,{variant:e,busy:f.isPending,disabled:!i,onClick:()=>l.current?.click(),children:[(0,Y.jsx)(M,{className:`size-4`}),` `,t]}),(0,Y.jsx)(`input`,{ref:l,hidden:!0,type:`file`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&f.mutate(t)}}),(0,Y.jsxs)(s,{open:f.isError,onClose:f.reset,title:C(`import.failed`),children:[(0,Y.jsx)(`p`,{className:`text-[0.875rem] text-ink-2`,children:f.error?.message}),p.length?(0,Y.jsx)(`ul`,{className:`mt-3 flex list-disc flex-col gap-1 pl-5 text-[0.8125rem] text-ink-2`,children:p.slice(0,8).map(e=>(0,Y.jsx)(`li`,{children:e.message},e.message))}):null,(0,Y.jsx)(`div`,{className:`mt-5 flex justify-end`,children:(0,Y.jsx)(c,{variant:`secondary`,onClick:f.reset,children:C(`common.close`)})})]})]})}var X=10,Z=3;async function ue(e,t){let n=await fetch(f(`/api/studio/wizards/${e}/files/${encodeURIComponent(t.name)}`),{method:`PUT`,credentials:`include`,headers:{"content-type":t.type||`application/octet-stream`,"accept-language":l},body:t});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??n.statusText)}}function Q({over:e,onClick:t}){return(0,Y.jsx)(`button`,{type:`button`,"aria-label":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,Y.jsx)(S,{className:`size-3`})})}function $(e,t){let n=K(t);if(!n.length)return[];let r=e.map(e=>({w:e,score:U({title:e.title,summary:e.description},n.join(` `),[[`title`,10],[`summary`,6]])})).filter(e=>e.score>0).sort((e,t)=>t.score-e.score),i=q(t)?(r[0]?.score??0)*.4:0;return r.filter(e=>e.score>=i).slice(0,Z).map(e=>e.w)}function de({wish:e,projectId:t,busy:n,onTake:r,onMore:i}){let a=h(),[s,u]=(0,J.useState)(null),f=E(e.trim(),300),p=_({queryKey:[`wizards`,t,`similar`],queryFn:()=>d.get(`/api/studio/projects/${t}/wizards`)}),m=_({queryKey:[`marketplace`,l,f,`similar`],queryFn:()=>d.get(`/api/studio/marketplace?${new URLSearchParams({lang:l,limit:String(X),offset:`0`,q:f})}`),enabled:f.length>=3,placeholderData:v});if(f.length<3)return null;let g=$(p.data??[],f),y=(m.data?.entries??[]).slice(0,X-g.length),b=(m.data?.total??0)-y.length;if(!(g.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,Y.jsxs)(`section`,{className:`mt-5`,children:[(0,Y.jsx)(`h2`,{className:`mb-2 px-1 text-[0.8125rem] text-ink-3`,children:C(`new.similar`)}),(0,Y.jsxs)(`ul`,{className:`flex flex-col gap-1.5`,children:[g.map(e=>(0,Y.jsxs)(`li`,{className:x,children:[(0,Y.jsx)(o,{children:C(`new.yours`)}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>a(`/edit/${e.id}`),className:`min-w-0 flex-1 text-left`,children:[(0,Y.jsx)(`span`,{className:`block truncate font-medium text-[0.9375rem]`,children:e.title}),(0,Y.jsx)(`span`,{className:`block truncate text-[0.8125rem] text-ink-3`,children:e.description})]}),(0,Y.jsx)(c,{variant:`secondary`,size:`sm`,onClick:()=>a(`/edit/${e.id}`),children:C(`new.open`)})]},e.id)),y.map(e=>(0,Y.jsxs)(`li`,{className:x,children:[(0,Y.jsx)(o,{children:C(`new.template`)}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>u(e.id),className:`min-w-0 flex-1 text-left`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`truncate font-medium text-[0.9375rem]`,children:e.title}),e.plan===`pro`?(0,Y.jsx)(T,{}):null]}),(0,Y.jsx)(`span`,{className:`block truncate text-[0.8125rem] text-ink-3`,children:e.pitch})]}),(0,Y.jsx)(c,{variant:`secondary`,size:`sm`,disabled:n,onClick:()=>r(e),children:C(`new.take`)})]},e.id))]}),b>0?(0,Y.jsx)(`button`,{type:`button`,onClick:()=>i(f),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,Y.jsx)(D,{id:s,fallback:y.find(e=>e.id===s)??null,onClose:()=>u(null),onUse:r,busy:n})]})}function fe(){let e=h(),t=u(),{project:n}=k(),a=A(),[o]=r(),[s,f]=(0,J.useState)(()=>o.get(`wish`)??j()??``),v=(0,J.useRef)(j()!==null),[S,T]=(0,J.useState)([`steps`]),[E,D]=(0,J.useState)([]),[M,F]=(0,J.useState)(!1),[I,L]=(0,J.useState)(null),R=(0,J.useRef)(null),z=(0,J.useRef)(null),B=(0,J.useRef)(null),[V]=ne(),H=b(s,f,{deviceId:V.deviceId}),U=_({queryKey:[`runners`],queryFn:()=>d.get(`/api/studio/runners`)}),W=e=>{let t=e.map(g);D(e=>[...e.filter(e=>!t.some(t=>t.name===e.name)),...t])},[G,K]=(0,J.useState)(new Map);(0,J.useEffect)(()=>{let e=new Map(E.filter(e=>e.type.startsWith(`image/`)).map(e=>[e,URL.createObjectURL(e)]));return K(e),()=>{for(let t of e.values())URL.revokeObjectURL(t)}},[E]);let q=O({mutationFn:e=>d.post(`/api/studio/wizards`,{projectId:n.id,starterId:e,lang:l}),onSuccess:async({id:n})=>{await t.invalidateQueries({queryKey:[`projects`]}),await t.invalidateQueries({queryKey:[`wizards`]}),e(`/edit/${n}`)}}),X=O({mutationFn:async()=>{let e=B.current??(await d.post(`/api/studio/wizards`,{projectId:n.id,lang:l})).id;B.current=e,N(S)||await d.patch(`/api/studio/wizards/${e}`,{runners:ce(S)});for(let t of E)await ue(e,t);return e},onSuccess:async n=>{ae(),await t.invalidateQueries({queryKey:[`projects`]}),await t.invalidateQueries({queryKey:[`wizards`]});let r=s.trim();N(S)||(r+=`\n\n${se(S)}`),E.length&&(r+=`\n\n${C(`editor.attached`)}: ${E.map(e=>e.name).join(`, `)}`),e(`/edit/${n}?prompt=${encodeURIComponent(r)}`)}}),Z=()=>{s.trim()&&n&&!X.isPending&&(H.listening&&H.stop(),X.mutate())};if((0,J.useEffect)(()=>{v.current&&n&&a&&!n.readOnly&&s.trim()&&(v.current=!1,X.mutate())},[n,a,s,X]),!a||n?.readOnly)return(0,Y.jsx)(te,{to:`/`,replace:!0});let $=X.error??q.error;return(0,Y.jsxs)(`div`,{className:`animate-rise md:pt-4`,children:[(0,Y.jsxs)(`div`,{className:`mx-auto max-w-2xl`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,Y.jsx)(`div`,{className:`size-[84px] md:size-auto`,children:(0,Y.jsx)(`div`,{className:`origin-top-left scale-[0.56] md:scale-100`,children:(0,Y.jsx)(oe,{kind:`sprout`,size:150,fluffy:!0})})}),(0,Y.jsx)(`h1`,{className:`mt-1 font-display font-semibold text-[1.5rem] leading-tight tracking-tight md:mt-2 md:text-[2.375rem]`,children:C(`new.title`)})]}),(0,Y.jsx)(P,{value:S,onChange:T,runners:U.data,className:`mt-4 px-1 md:mt-8`}),(0,Y.jsxs)(`div`,{className:p(`relative mt-3 rounded-2xl bg-card p-2 shadow-elevated ring-1 ring-border-soft focus-within:ring-focus`,M&&`ring-2 ring-focus`),onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),F(!0))},onDragLeave:()=>F(!1),onDrop:e=>{e.preventDefault(),F(!1),W(Array.from(e.dataTransfer.files).map(w))},children:[E.length?(0,Y.jsx)(`div`,{className:`flex flex-wrap items-center gap-2 px-2 pt-2 pb-1`,children:E.map((e,t)=>{let n=G.get(e),r=()=>D(e=>e.filter((e,n)=>n!==t));return n?(0,Y.jsx)(ee,{url:n,label:e.name,children:(0,Y.jsx)(Q,{over:!!n,onClick:r})},`${e.name}-${t}`):(0,Y.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-1.5 rounded-full bg-paper-2 py-1 pr-1 pl-2.5 text-[0.8125rem] text-ink-2`,children:[(0,Y.jsx)(re,{className:`size-3.5 shrink-0 text-ink-4`}),(0,Y.jsx)(`span`,{className:`truncate`,children:e.name}),(0,Y.jsx)(Q,{over:!!n,onClick:r})]},`${e.name}-${t}`)})}):null,(0,Y.jsx)(m,{autoFocus:!0,minRows:4,value:s,onChange:e=>f(e.target.value),onPaste:e=>{let t=Array.from(e.clipboardData.files);t.length&&(e.preventDefault(),W(t.map(w)))},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,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-1 pb-1`,children:[(0,Y.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,Y.jsx)(x,{className:`size-4`})}),(0,Y.jsx)(`input`,{ref:z,type:`file`,multiple:!0,hidden:!0,onChange:e=>{let t=Array.from(e.target.files??[]);e.target.value=``,W(t)}}),H.supported?(0,Y.jsx)(y,{speech:H,labelled:!0}):null,(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.75rem] text-ink-4`,children:M?C(`new.dropHint`):null}),(0,Y.jsxs)(c,{size:`md`,onClick:Z,busy:X.isPending,disabled:!s.trim()||q.isPending,children:[C(`new.build`),` `,(0,Y.jsx)(i,{className:`size-4`})]})]})]}),(0,Y.jsx)(`p`,{className:`mt-3 text-center text-[0.875rem] text-ink-3`,children:C(`new.hint`)}),H.error?(0,Y.jsx)(`p`,{className:`mt-2 px-3 text-[0.75rem] text-rose`,children:H.error===`denied`?C(`editor.micDenied`):H.error}):null,$?(0,Y.jsx)(`p`,{className:`mt-3 text-center text-[0.875rem] text-rose`,children:$.message}):null,n?(0,Y.jsx)(de,{wish:s,projectId:n.id,busy:q.isPending||X.isPending,onTake:e=>!q.isPending&&q.mutate(e.id),onMore:e=>{L({text:e}),R.current?.scrollIntoView({behavior:`smooth`,block:`start`})}}):null]}),(0,Y.jsxs)(`section`,{ref:R,className:`mx-auto max-w-5xl scroll-mt-6`,children:[(0,Y.jsx)(`h2`,{className:`mt-16 mb-5 text-center font-medium text-[0.8125rem] text-ink-3 uppercase tracking-[0.08em]`,children:C(`new.orStarter`)}),(0,Y.jsx)(ie,{open:o.get(`starter`),search:I,busy:q.isPending,onUse:e=>n&&!q.isPending&&q.mutate(e.id)})]}),(0,Y.jsx)(`div`,{className:`mt-8 flex justify-center`,children:(0,Y.jsx)(le,{variant:`ghost`,label:C(`new.import`)})})]})}export{fe as NewWizardPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$r as r,Br as i,Er as a,Ir as o,Qt as s,Ti as ee,V as c,Xt as l,Zr as te,rn as u}from"./ui-DRYauuxF.js";import{t as d}from"./useMutation-1jFwXbI6.js";import{d as ne,g as re,i as ie,w as ae,x as oe}from"./session-DekDyd9S.js";import{t as se}from"./upload-0sFU9K8-.js";import{t as f}from"./logo-CGNoptDg.js";import{W as ce}from"./index-qnpoZzuw.js";var p=e(t(),1),m=e(n(),1),h=`oklch(50% 0.2 262)`,g=`oklch(32% 0.15 262)`,le={"--on":`white`,"--dot":`oklch(90% 0.1 80)`,"--ink-2":`oklch(96% 0.02 262)`,"--ink-3":`oklch(90% 0.035 262)`,"--moss":`oklch(90% 0.14 150)`,"--rose":`oklch(89% 0.09 45)`},_={kind:1,details:1,team:1,site:2,know:3,space:4},ue=e=>e!==null&&Object.hasOwn(_,e),v=`w-full rounded-[18px] border border-white/30 bg-white/15 px-6 py-5 text-[1.375rem] text-white outline-none placeholder:text-white/55 focus:border-white/60`;function de(){return(0,m.jsxs)(`span`,{className:`inline-flex items-center gap-2.5`,children:[(0,m.jsx)(f,{size:28}),(0,m.jsxs)(`span`,{className:`font-display font-semibold text-[1.0625rem] tracking-tight`,children:[`engenty`,(0,m.jsx)(`span`,{className:`mr-[0.09em] ml-[0.06em] text-(color:--dot)`,children:`.`}),(0,m.jsx)(`span`,{className:`font-normal text-white/70`,children:`wizards`})]})]})}function y({children:e,busy:t,onClick:n,type:r=`button`}){return(0,m.jsxs)(`button`,{type:r,disabled:t,onClick:n,className:`inline-flex h-13 cursor-pointer items-center gap-2.5 rounded-full bg-white px-7 font-semibold text-[1rem] transition hover:bg-white/90 disabled:cursor-default disabled:opacity-70`,style:{color:g},children:[e,(0,m.jsx)(i,{className:`size-[18px]`})]})}function b({children:e,onClick:t}){return(0,m.jsx)(`button`,{type:`button`,onClick:t,className:`cursor-pointer font-semibold text-[0.9375rem] text-white/85 transition hover:text-white`,children:e})}function x({step:e}){return(0,m.jsx)(`span`,{className:`ml-auto inline-flex gap-1.5`,role:`img`,"aria-label":u(`onboard.step`,{n:e}),children:[1,2,3,4].map(t=>(0,m.jsx)(`span`,{className:l(`size-2 rounded-full`,t===e?`bg-white`:`bg-white/40`)},t))})}var S=[{kind:`personal`,label:`onboard.kindPersonal`,sub:`onboard.kindPersonalSub`},{kind:`club`,label:`onboard.kindClub`,sub:`onboard.kindClubSub`},{kind:`small`,label:`onboard.kindSmall`,sub:`onboard.kindSmallSub`},{kind:`corp`,label:`onboard.kindCorp`,sub:`onboard.kindCorpSub`}],C=new Set([`gmail.com`,`googlemail.com`,`gmx.at`,`gmx.de`,`gmx.net`,`web.de`,`outlook.com`,`hotmail.com`,`live.com`,`icloud.com`,`me.com`,`yahoo.com`,`yahoo.de`,`aon.at`,`a1.net`,`chello.at`,`t-online.de`,`proton.me`,`protonmail.com`]);function fe(e){let t=(e.split(`@`)[1]??``).trim().toLowerCase();return t?C.has(t)?{kind:`personal`,domain:t}:/(verein|club|klub|^sv-|^fc-|^ff-|feuerwehr|musik|chor)/.test(t)?{kind:`club`,domain:t}:{kind:`small`,domain:t}:{kind:null,domain:t}}var w={club:[`0-50`,`50-250`,`250-1000`,`1000+`],small:[`1`,`2-9`,`10-49`],corp:[`50-249`,`250-999`,`1000+`]},T=e=>Number(e).toLocaleString(s),E=e=>{if(e===`1`)return u(`onboard.justMe`);if(e.endsWith(`+`))return`${T(e.slice(0,-1))}+`;let[t,n]=e.split(`-`);return t===`0`?`≤ ${T(n)}`:`${T(t)}–${T(n)}`},pe=[`sport`,`culture`,`social`,`education`,`environment`,`rescue`,`other`],me=[`chair`,`board`,`treasurer`,`secretary`,`member`],he=[`management`,`it`,`marketing`,`sales`,`operations`,`other`],D=`w-full rounded-[14px] border border-white/30 bg-white/15 px-4 py-3 text-[1.0625rem] text-white outline-none placeholder:text-white/55 focus:border-white/60`;function ge({picked:e,label:t,sub:n,onClick:r}){return(0,m.jsxs)(`button`,{type:`button`,"aria-pressed":e,onClick:r,className:l(`flex cursor-pointer flex-col gap-1 rounded-[18px] border px-5 py-4 text-left transition`,e?`border-white bg-white/25`:`border-white/30 bg-white/10 hover:bg-white/15`),children:[(0,m.jsx)(`span`,{className:`font-display font-semibold text-[1.125rem]`,children:t}),(0,m.jsx)(`span`,{className:`text-[0.875rem] text-white/80`,children:n})]})}function O({label:e,options:t,value:n,text:r,onChange:i}){return(0,m.jsxs)(`fieldset`,{className:`flex flex-col gap-2`,children:[(0,m.jsx)(`legend`,{className:`mb-2 text-[0.9375rem] text-white/85`,children:e}),(0,m.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t.map(e=>(0,m.jsx)(`button`,{type:`button`,"aria-pressed":n===e,onClick:()=>i(e),className:l(`cursor-pointer rounded-full border px-4 py-2 text-[0.9375rem] transition`,n===e?`border-white bg-white`:`border-white/30 hover:bg-white/15`),style:n===e?{color:g}:void 0,children:r(e)},e))})]})}function k(e,t,n){let r=`${A}${e}:${t}`,[i,a]=(0,p.useState)(()=>{try{let e=sessionStorage.getItem(r);return e===null?n:JSON.parse(e)}catch{return n}});return(0,p.useEffect)(()=>{try{sessionStorage.setItem(r,JSON.stringify(i))}catch{}},[r,i]),[i,a]}var A=`wizards.onboarding:`;function _e(){try{for(let e of Object.keys(sessionStorage))e.startsWith(A)&&sessionStorage.removeItem(e)}catch{}}function j(){ae(h);let e=re(),t=ee(),n=te(),{project:i}=ne(),s=e.data?.user.id??``,[f,T]=k(s,`team`,``),[A,j]=k(s,`site`,``),[M,N]=k(s,`line`,null),[P,ve]=(0,p.useState)(null),[F,I]=(0,p.useState)([]),L=(0,p.useRef)(null),[R]=(0,p.useState)(ie),[z]=(0,p.useState)(()=>fe(e.data?.user.email??``)),[B,ye]=k(s,`profile`,{kind:z.kind,size:null,sector:``,role:null,need:``,legalName:``,phone:``}),[be,xe]=r(),V=be.get(`page`),H=ue(V)&&(V!==`details`||B.kind)?V:`kind`,U=_[H],W=e=>xe(t=>{let n=new URLSearchParams(t);return n.set(`page`,e),n}),G=e=>ye(t=>({...t,...e})),K=d({mutationFn:e=>c.put(`/api/studio/team/profile`,{kind:B.kind,size:B.size,sector:B.sector.trim()||null,role:B.role,need:B.need.trim()||null,legalName:B.legalName.trim()||null,phone:B.phone.trim()||null,website:e?.trim()||null})}),q=B.kind===`personal`,J=()=>{!A&&z.domain&&B.kind!==`personal`&&!C.has(z.domain)&&j(z.domain),W(`site`)},Y=d({mutationFn:e=>c.put(`/api/studio/team`,{name:e}),onSuccess:()=>t.invalidateQueries({queryKey:[`team`]})}),X=d({mutationFn:e=>c.post(`/api/studio/projects/${i?.id}/website`,{url:e}),onSuccess:async e=>{ve(e),await t.invalidateQueries({queryKey:[`projects`]})}}),Z=d({mutationFn:e=>c.patch(`/api/studio/projects/${i?.id}`,{brand:{about:e}}),onSuccess:()=>t.invalidateQueries({queryKey:[`projects`]})}),Se=d({mutationFn:()=>c.post(`/api/studio/onboarding/done`),onSuccess:async()=>{_e(),await t.invalidateQueries({queryKey:[`me`]}),n(`/new`,{replace:!0})}}),Ce=e.data?.user.name??``,Q=Ce.includes(`@`)?``:Ce.split(` `)[0],$=async e=>{if(e&&i){for(let t of Array.from(e)){I(e=>[...e,{name:t.name,state:`uploading`}]);try{await c.upload(`/api/studio/projects/${i.id}/files?kind=document`,t),I(e=>e.map(e=>e.name===t.name?{...e,state:`done`}:e))}catch{I(e=>e.map(e=>e.name===t.name?{...e,state:`failed`}:e))}}await t.invalidateQueries({queryKey:[`projects`]})}},we=P?[P.about?u(`onboard.readAbout`):``,P.colors?u(`onboard.readColors`,{n:P.colors}):``,P.logo?u(`onboard.readLogo`):``].join(``):``;return(0,m.jsxs)(`div`,{className:`flex min-h-dvh flex-col px-6 text-white sm:px-10`,style:{...le,background:h},children:[(0,m.jsxs)(`header`,{className:`flex items-center justify-between pt-6 sm:pt-8`,children:[(0,m.jsx)(de,{}),(0,m.jsx)(ce,{tone:`ground`,ink:g})]}),(0,m.jsxs)(`main`,{className:`mx-auto grid w-full max-w-6xl flex-1 items-center gap-10 py-10 lg:grid-cols-[5fr_7fr] lg:gap-12`,children:[(0,m.jsxs)(`div`,{className:`flex flex-col items-center gap-8 max-lg:order-first`,children:[(0,m.jsx)(oe,{kind:`drop`,size:240,fluffy:!0,coat:`fur`}),R?(0,m.jsxs)(`figure`,{className:`w-full max-w-sm rounded-[18px] bg-white/15 px-5 py-4`,children:[(0,m.jsx)(`figcaption`,{className:`font-medium text-[0.75rem] text-white/85 uppercase tracking-[0.14em]`,children:u(`onboard.wish`)}),(0,m.jsx)(`blockquote`,{className:`mt-1.5 line-clamp-6 whitespace-pre-line break-words text-[1rem] leading-relaxed`,children:R}),(0,m.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-white/75`,children:u(`onboard.wishNext`)})]}):null]}),(0,m.jsxs)(`div`,{className:`flex min-w-0 max-w-2xl animate-rise flex-col gap-5`,children:[H===`kind`?(0,m.jsxs)(`form`,{className:`contents`,onSubmit:e=>{e.preventDefault(),B.kind&&W(`details`)},children:[(0,m.jsx)(`p`,{className:`font-medium text-[0.75rem] text-white/85 uppercase tracking-[0.14em]`,children:Q?u(`onboard.kicker1`,{name:Q}):u(`onboard.kicker1Anon`)}),(0,m.jsx)(`h1`,{className:`font-display font-bold text-[2.5rem] leading-[1.05] tracking-[-0.02em] sm:text-[3.25rem]`,children:u(`onboard.kind`)}),(0,m.jsx)(`p`,{className:`text-[1.0625rem] text-white/90 leading-relaxed`,children:u(`onboard.kindSub`)}),z.kind?(0,m.jsx)(`p`,{className:`text-[0.9375rem] text-white/80`,children:u(`onboard.guess`,{domain:z.domain,kind:u(S.find(e=>e.kind===z.kind)?.label??`onboard.kindSmall`)})}):null,(0,m.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:S.map(e=>(0,m.jsx)(ge,{picked:B.kind===e.kind,label:u(e.label),sub:u(e.sub),onClick:()=>G({kind:e.kind,size:e.kind===B.kind?B.size:null})},e.kind))}),(0,m.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,m.jsx)(y,{type:`submit`,children:u(`onboard.continue`)}),(0,m.jsx)(x,{step:1})]})]}):null,H===`details`&&B.kind?(0,m.jsxs)(`form`,{className:`contents`,onSubmit:e=>{e.preventDefault(),K.mutate(void 0),B.kind===`corp`&&B.legalName.trim()&&!f&&T(B.legalName.trim()),B.kind===`personal`?J():W(`team`)},children:[(0,m.jsx)(`p`,{className:`font-medium text-[0.75rem] text-white/85 uppercase tracking-[0.14em]`,children:Q?u(`onboard.kicker1`,{name:Q}):u(`onboard.kicker1Anon`)}),(0,m.jsx)(`h1`,{className:`font-display font-bold text-[2.25rem] leading-[1.05] tracking-[-0.02em] sm:text-[2.75rem]`,children:u(B.kind===`personal`?`onboard.personalTitle`:B.kind===`club`?`onboard.clubTitle`:`onboard.businessTitle`)}),B.kind===`personal`?(0,m.jsx)(`textarea`,{value:B.need,onChange:e=>G({need:e.target.value}),placeholder:u(`onboard.personalPlaceholder`),rows:3,maxLength:2e3,"aria-label":u(`onboard.personalTitle`),className:l(v,`resize-none text-[1.125rem] leading-relaxed`)}):null,B.kind===`club`?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(O,{label:u(`onboard.clubKind`),options:pe,value:B.sector,text:e=>u(`onboard.club.${e}`),onChange:e=>G({sector:e})}),(0,m.jsx)(O,{label:u(`onboard.members`),options:w.club,value:B.size,text:E,onChange:e=>G({size:e})}),(0,m.jsx)(O,{label:u(`onboard.yourRole`),options:me,value:B.role,text:e=>u(`onboard.role.${e}`),onChange:e=>G({role:e})})]}):null,B.kind===`small`?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(O,{label:u(`onboard.people`),options:w.small,value:B.size,text:E,onChange:e=>G({size:e})}),(0,m.jsxs)(`label`,{className:`flex flex-col gap-2 text-[0.9375rem] text-white/85`,children:[u(`onboard.sector`),(0,m.jsx)(`input`,{value:B.sector,onChange:e=>G({sector:e.target.value}),placeholder:u(`onboard.sectorPlaceholder`),maxLength:120,className:D})]}),(0,m.jsxs)(`label`,{className:`flex flex-col gap-2 text-[0.9375rem] text-white/85`,children:[(0,m.jsxs)(`span`,{children:[u(`onboard.need`),` `,(0,m.jsx)(`span`,{className:`text-white/60`,children:u(`onboard.optional`)})]}),(0,m.jsx)(`textarea`,{value:B.need,onChange:e=>G({need:e.target.value}),placeholder:u(`onboard.needPlaceholder`),rows:2,maxLength:2e3,className:l(D,`resize-none`)})]})]}):null,B.kind===`corp`?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(O,{label:u(`onboard.people`),options:w.corp,value:B.size,text:E,onChange:e=>G({size:e})}),(0,m.jsx)(O,{label:u(`onboard.yourRole`),options:he,value:B.role,text:e=>u(`onboard.role.${e}`),onChange:e=>G({role:e})}),(0,m.jsxs)(`label`,{className:`flex flex-col gap-2 text-[0.9375rem] text-white/85`,children:[u(`onboard.legalName`),(0,m.jsx)(`input`,{value:B.legalName,onChange:e=>G({legalName:e.target.value}),placeholder:u(`onboard.legalNamePlaceholder`),maxLength:200,autoComplete:`organization`,className:D})]}),(0,m.jsxs)(`label`,{className:`flex flex-col gap-2 text-[0.9375rem] text-white/85`,children:[(0,m.jsxs)(`span`,{children:[u(`onboard.phone`),` `,(0,m.jsx)(`span`,{className:`text-white/60`,children:u(`onboard.phoneWhy`)})]}),(0,m.jsx)(`input`,{type:`tel`,value:B.phone,onChange:e=>G({phone:e.target.value.replace(/[^+0-9 ()/.-]/g,``)}),placeholder:`+43 …`,maxLength:40,autoComplete:`tel`,className:D})]})]}):null,(0,m.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,m.jsx)(y,{type:`submit`,busy:K.isPending,children:u(`onboard.continue`)}),(0,m.jsx)(b,{onClick:()=>window.history.state?.idx>0?n(-1):W(`kind`),children:u(`onboard.back`)}),(0,m.jsx)(x,{step:1})]})]}):null,H===`team`?(0,m.jsxs)(`form`,{className:`contents`,onSubmit:e=>{e.preventDefault();let t=f.trim();t?Y.mutate(t,{onSuccess:J}):J()},children:[(0,m.jsx)(`p`,{className:`font-medium text-[0.75rem] text-white/85 uppercase tracking-[0.14em]`,children:Q?u(`onboard.kicker1`,{name:Q}):u(`onboard.kicker1Anon`)}),(0,m.jsx)(`h1`,{className:`font-display font-bold text-[2.5rem] leading-[1.05] tracking-[-0.02em] sm:text-[3.25rem]`,children:u(`onboard.team`)}),(0,m.jsx)(`p`,{className:`text-[1.0625rem] text-white/90 leading-relaxed`,children:u(`onboard.teamSub`)}),(0,m.jsx)(`input`,{value:f,onChange:e=>T(e.target.value),placeholder:u(`onboard.teamPlaceholder`),maxLength:80,"aria-label":u(`onboard.team`),className:v}),(0,m.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,m.jsx)(y,{type:`submit`,busy:Y.isPending,children:u(`onboard.continue`)}),(0,m.jsx)(x,{step:1})]})]}):null,U===2?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`p`,{className:`font-medium text-[0.75rem] text-white/85 uppercase tracking-[0.14em]`,children:u(q?`onboard.kicker2Personal`:`onboard.kicker2`)}),(0,m.jsx)(`h1`,{className:`font-display font-bold text-[2.5rem] leading-[1.05] tracking-[-0.02em] sm:text-[3.25rem]`,children:u(`onboard.site`)}),(0,m.jsx)(`p`,{className:`text-[1.0625rem] text-white/90 leading-relaxed`,children:u(q?`onboard.siteSubPersonal`:`onboard.siteSub`)}),M===null?(0,m.jsxs)(`form`,{className:`contents`,onSubmit:e=>{e.preventDefault();let t=A.trim();if(t&&!X.isPending){if(B.kind&&K.mutate(t),!t.includes(`.`)){W(`know`);return}X.mutate(t)}},children:[(0,m.jsx)(`input`,{value:A,onChange:e=>j(e.target.value),placeholder:u(q?`onboard.sitePlaceholderPersonal`:`onboard.sitePlaceholder`),autoCapitalize:`none`,"aria-label":u(`onboard.site`),className:v}),q?null:(0,m.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-white/75`,children:u(`onboard.siteNameHint`)}),P?(0,m.jsxs)(`p`,{className:`flex items-center gap-2 text-[0.9375rem] text-(color:--moss)`,children:[(0,m.jsx)(o,{className:`size-4`}),u(`onboard.readDone`,{name:P.name,details:we})]}):X.isError?(0,m.jsx)(`p`,{className:`text-[0.9375rem] text-(color:--rose)`,children:u(`onboard.readFailed`)}):null,(0,m.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[P?(0,m.jsx)(y,{onClick:()=>W(`know`),children:u(`onboard.continue`)}):(0,m.jsx)(y,{type:`submit`,busy:X.isPending,children:X.isPending?u(`onboard.reading`):u(`onboard.read`)}),(0,m.jsx)(b,{onClick:()=>N(``),children:u(`onboard.line`)}),(0,m.jsx)(b,{onClick:()=>W(`know`),children:u(`onboard.skip`)}),(0,m.jsx)(x,{step:2})]})]}):(0,m.jsxs)(`form`,{className:`contents`,onSubmit:e=>{e.preventDefault();let t=M.trim();t?Z.mutate(t,{onSuccess:()=>W(`know`)}):W(`know`)},children:[(0,m.jsx)(`textarea`,{value:M,onChange:e=>N(e.target.value),placeholder:u(q?`onboard.linePlaceholderPersonal`:`onboard.linePlaceholder`),rows:3,maxLength:8e3,"aria-label":u(`onboard.line`),className:l(v,`resize-none text-[1.125rem] leading-relaxed`)}),(0,m.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,m.jsx)(y,{type:`submit`,busy:Z.isPending,children:u(`onboard.continue`)}),(0,m.jsx)(b,{onClick:()=>N(null),children:u(`onboard.site`)}),(0,m.jsx)(b,{onClick:()=>W(`know`),children:u(`onboard.skip`)}),(0,m.jsx)(x,{step:2})]})]})]}):null,U===3?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`p`,{className:`font-medium text-[0.75rem] text-white/85 uppercase tracking-[0.14em]`,children:u(`onboard.kicker3`)}),(0,m.jsx)(`h1`,{className:`font-display font-bold text-[2.5rem] leading-[1.05] tracking-[-0.02em] sm:text-[3.25rem]`,children:u(`onboard.know`)}),(0,m.jsx)(`p`,{className:`text-[1.0625rem] text-white/90 leading-relaxed`,children:u(`onboard.knowSub`)}),(0,m.jsxs)(`button`,{type:`button`,onClick:()=>L.current?.click(),onDragOver:e=>e.preventDefault(),onDrop:e=>{e.preventDefault(),$(e.dataTransfer.files)},className:`flex cursor-pointer flex-col items-center gap-2 rounded-[18px] border-2 border-white/45 border-dashed bg-white/10 px-6 py-7 text-center transition hover:bg-white/15`,children:[(0,m.jsx)(se,{className:`size-7`}),(0,m.jsx)(`span`,{className:`font-semibold text-[1.0625rem]`,children:u(`onboard.drop`)}),(0,m.jsx)(`span`,{className:`text-[0.875rem] text-white/80`,children:`PDF · Word · Excel · Markdown`}),(0,m.jsx)(`input`,{ref:L,type:`file`,multiple:!0,className:`sr-only`,onChange:e=>{$(e.target.files),e.target.value=``}})]}),F.length?(0,m.jsx)(`ul`,{className:`flex flex-col gap-2`,children:F.map(e=>(0,m.jsxs)(`li`,{className:`flex items-center gap-2.5 rounded-xl bg-white/15 px-3.5 py-2.5 text-[0.875rem]`,children:[(0,m.jsx)(a,{className:`size-4 shrink-0`}),(0,m.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,m.jsx)(`span`,{className:l(`text-white/80`,e.state===`failed`?`text-(color:--rose)`:``),children:e.state===`uploading`?u(`onboard.uploading`):e.state===`done`?u(`onboard.uploaded`):u(`onboard.uploadFailed`)})]},e.name))}):null,(0,m.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,m.jsx)(y,{busy:F.some(e=>e.state===`uploading`),onClick:()=>W(`space`),children:u(`onboard.continue`)}),F.length?null:(0,m.jsx)(b,{onClick:()=>W(`space`),children:u(`onboard.skip`)}),(0,m.jsx)(x,{step:3})]})]}):null,U===4?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`p`,{className:`font-medium text-[0.75rem] text-white/85 uppercase tracking-[0.14em]`,children:u(`onboard.kicker4`)}),(0,m.jsx)(`h1`,{className:`font-display font-bold text-[2.5rem] leading-[1.05] tracking-[-0.02em] sm:text-[3.25rem]`,children:u(`onboard.space`)}),(0,m.jsx)(`p`,{className:`text-[1.0625rem] text-white/90 leading-relaxed`,children:u(`onboard.spaceSub`,{space:i?.name??``})}),(0,m.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[[`partInfo`,`partInfoText`,!!(P||M)],[`partKnow`,`partKnowText`,F.some(e=>e.state===`done`)],[`partData`,`partDataText`,!1],[`partResults`,`partResultsText`,!1]].map(([e,t,n])=>(0,m.jsxs)(`div`,{className:`flex flex-col gap-1.5 rounded-2xl border border-white/20 bg-white/10 px-4.5 py-4`,children:[(0,m.jsxs)(`span`,{className:`flex items-center gap-2 font-semibold text-[1rem]`,children:[n?(0,m.jsx)(o,{className:`size-4 text-(color:--moss)`}):null,u(`onboard.${e}`)]}),(0,m.jsx)(`span`,{className:`text-[0.84375rem] text-white/85 leading-snug`,children:u(`onboard.${t}`)})]},e))}),(0,m.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,m.jsx)(y,{busy:Se.isPending,onClick:()=>Se.mutate(),children:u(`onboard.build`)}),(0,m.jsx)(x,{step:4})]})]}):null]},H)]}),(0,m.jsxs)(`footer`,{className:`mx-auto flex w-full max-w-6xl items-center justify-between pb-6 text-[0.75rem] text-white/55 sm:pb-8`,children:[(0,m.jsx)(`span`,{children:`engenty.wizards`}),(0,m.jsx)(`span`,{"aria-hidden":`true`,className:`size-[3px] bg-(color:--dot)`})]})]})}export{j as OnboardingPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$r as r,A as i,B as a,Bt as o,C as s,Cr as c,D as l,Dr as u,E as d,Er as f,F as p,Ft as m,Gt as h,I as g,Ir as _,It as v,Jt as y,Kt as b,L as x,Lt as S,M as C,O as w,P as T,Pt as E,Qr as D,Qt as O,R as ee,Rt as k,S as A,Sr as te,T as ne,Ti as j,Tr as M,Ur as N,Ut as P,V as F,Vt as I,Wt as re,Xr as ie,Xt as L,Yt as ae,Zr as oe,_ as se,ar as R,b as z,cr as B,d as V,ei as H,f as U,fr as W,g as ce,h as G,hr as le,j as ue,jr as de,k as fe,kr as K,lt as pe,m as me,mr as q,p as he,qn as ge,qr as _e,qt as ve,rn as J,ur as ye,v as be,vr as xe,w as Se,x as Y,y as X,z as Ce,zr as we,zt as Z}from"./ui-DRYauuxF.js";import{S as Te,_ as Ee,g as De,m as Oe,p as ke,v as Ae}from"./Marketplace-BF0Rx0VR.js";import{t as je}from"./useMutation-1jFwXbI6.js";import{_ as Me,a as Ne,b as Pe,c as Fe,d as Ie,f as Le,g as Re,h as ze,i as Be,l as Ve,m as He,n as Ue,o as We,p as Ge,r as Ke,s as qe,u as Je,v as Ye,y as Xe}from"./RunDrawer-ByvmBv6e.js";import{d as Ze,f as Qe,p as $e}from"./session-DekDyd9S.js";import{t as et}from"./phone-ChnpShTU.js";import{n as tt,r as nt,t as rt}from"./ReadOnly-CcW91P4l.js";import{t as it}from"./upload-0sFU9K8-.js";import{K as at,St as ot,b as st,c as ct,d as lt,et as ut,f as dt,ft,h as pt,it as mt,lt as ht,m as gt,p as _t,s as vt,u as yt,v as bt,vt as xt,y as St,yt as Ct}from"./index-qnpoZzuw.js";import{a as wt,c as Tt,f as Et,i as Dt,n as Ot,o as kt,r as At,s as jt,t as Mt,u as Nt}from"./settings-menu-CLw_oucZ.js";import{t as Pt}from"./RunnerView-DcduYZly.js";var Ft={name:`blend`,size:24,node:[[`circle`,{cx:`15`,cy:`9`,r:`7`,key:`1i12rt`}],[`circle`,{cx:`9`,cy:`15`,r:`7`,key:`19bs8k`}]]};Ft.node;var It=N(Ft),Lt={name:`box`,size:24,node:[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]};Lt.node;var Rt=N(Lt),zt={name:`case-upper`,size:24,node:[[`path`,{d:`M15 11h4.5a1 1 0 0 1 0 5h-4a.5.5 0 0 1-.5-.5v-9a.5.5 0 0 1 .5-.5h3a1 1 0 0 1 0 5`,key:`nxs35`}],[`path`,{d:`m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16`,key:`d5nyq2`}],[`path`,{d:`M3.304 13h6.392`,key:`1q3zxz`}]]};zt.node;var Bt=N(zt),Vt={name:`folder-plus`,size:24,node:[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]};Vt.node;var Ht=N(Vt),Ut={name:`grid-2x2`,size:24,node:[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]],aliases:[`grid-2-x-2`]};Ut.node;var Wt=N(Ut),Gt={name:`layout-grid`,size:24,node:[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]};Gt.node;var Kt=N(Gt),qt={name:`link`,size:24,node:[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`,key:`1cjeqo`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`,key:`19qd67`}]]};qt.node;var Jt=N(qt),Yt={name:`list`,size:24,node:[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]};Yt.node;var Xt=N(Yt),Zt={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`}]]};Zt.node;var Qt=N(Zt),Q=e(t(),1),$=e(n(),1),$t={backgroundImage:`repeating-conic-gradient(#c9c9c9 0% 25%, #dedede 0% 50%)`,backgroundSize:`16px 16px`};function en({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:J(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 tn(e,t){confirm(J(`project.removeConfirm`,{name:e.name}))&&t.remove(e.id)}function nn({projectId:e,file:t,small:n}){let r=g(e,t.id);if(t.mime.startsWith(`image/`))return(0,$.jsx)(`img`,{src:r,alt:``,loading:`lazy`,className:L(`size-full`,t.kind===`logo`?`object-contain p-3`:`object-cover`)});if(t.mime.startsWith(`video/`))return(0,$.jsx)(`video`,{src:`${r}#t=0.1`,preload:`metadata`,controls:!n,className:`size-full object-cover`});if(t.mime.startsWith(`font/`))return(0,$.jsx)(rn,{src:r,small:n});let i=n?`size-5`:`size-7`;return(0,$.jsxs)(`div`,{className:`flex size-full flex-col items-center justify-center gap-1.5 text-ink-3`,children:[t.mime.startsWith(`audio/`)?(0,$.jsx)(Qt,{className:i}):t.mime===`application/pdf`?(0,$.jsx)(f,{className:i}):t.mime===`application/json`?(0,$.jsx)(B,{className:i}):t.mime.startsWith(`model/`)?(0,$.jsx)(Rt,{className:i}):(0,$.jsx)(M,{className:i}),n?null:(0,$.jsx)(`span`,{className:`text-[0.6875rem] uppercase tracking-wide`,children:t.mime===`application/json`?`Lottie / JSON`:t.mime.split(`/`).pop()})]})}function rn({src:e,small:t}){let[n,r]=(0,Q.useState)(null);return(0,Q.useEffect)(()=>{let t=`asset-${e.split(`/`).slice(-2,-1)[0]}`;new FontFace(t,`url("${e}")`).load().then(e=>{document.fonts.add(e),r(t)}).catch(()=>r(null))},[e]),(0,$.jsx)(`div`,{className:L(`flex size-full items-center justify-center text-ink`,t?`text-[1.25rem]`:`text-[2.75rem]`),style:n?{fontFamily:`"${n}"`}:void 0,children:`Aa`})}var an=`application/x-wizards-logo`;function on({projectId:e,kind:t,files:n,actions:r,accept:i,addLabel:a,onUpload:o,onPreview:s,mainId:c,onMakeMain:l,moveTo:u,onRemove:d}){let f=e=>d?d(e):tn(e,r);return(0,$.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(184px,1fr))] gap-3`,children:[n.map(n=>(0,$.jsxs)(`div`,{draggable:u&&!r.readOnly?!0:void 0,onDragStart:e=>e.dataTransfer.setData(an,n.id),className:`group relative flex flex-col gap-1.5 rounded-lg bg-paper p-2 pb-2.5 ring-1 ring-border-soft`,children:[n.id===c?(0,$.jsx)(`span`,{className:`absolute -top-3 left-3 z-10 rounded-full ring-2 ring-card`,children:(0,$.jsx)(v,{tone:`ember`,children:J(`project.logoMain`)})}):null,(0,$.jsxs)(`div`,{className:`relative h-28 overflow-hidden rounded-md bg-paper-2`,style:t===`logo`?$t:void 0,children:[s&&n.mime.startsWith(`image/`)?(0,$.jsx)(`button`,{type:`button`,"aria-label":`${J(`project.preview`)}: ${n.name}`,onClick:()=>s(n),className:`block size-full cursor-zoom-in`,children:(0,$.jsx)(nn,{projectId:e,file:n})}):(0,$.jsx)(nn,{projectId:e,file:n}),(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)(Z,{label:J(`project.preview`),onClick:()=>s(n),className:`size-8 bg-card shadow-soft`,children:(0,$.jsx)(Te,{className:`size-4`})}):null,l&&n.id!==c&&!r.readOnly?(0,$.jsx)(Z,{label:J(`project.logoMakeMain`),onClick:()=>l(n),className:`size-8 bg-card shadow-soft`,children:(0,$.jsx)(De,{className:`size-4`})}):null,u&&!r.readOnly?(0,$.jsx)(ce,{options:u.options,value:u.current(n),onChange:e=>u.onMove(n,e),className:`bg-card shadow-soft`}):null,r.readOnly?null:(0,$.jsx)(Z,{label:J(`project.remove`),onClick:()=>f(n),className:`size-8 bg-card shadow-soft hover:text-rose`,children:(0,$.jsx)(R,{className:`size-4`})})]})]}),t===`asset`?(0,$.jsx)(`div`,{className:`truncate px-0.5 text-[0.75rem] text-ink-3`,title:n.name,children:n.name}):null,(0,$.jsx)(en,{file:n,actions:r})]},n.id)),a&&!r.readOnly?(0,$.jsxs)(me,{accept:i,multiple:!1,onFiles:e=>o?o(e):r.upload(t,e),className:`min-h-28 flex-col p-3`,children:[r.busy?(0,$.jsx)(h,{className:`size-5`}):(0,$.jsx)(q,{className:`size-5`}),a]}):null]})}function sn({kind:e,fetchUrl:t,onAdded:n,onClose:r}){let[i,a]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(null),[p,m]=(0,Q.useState)([]),h=async()=>{c(!0),u(null);try{let a=await t(i.trim());a.file?(n([a.file]),r()):a.candidates?.length?(f(a.candidates),m([a.candidates[0].url])):u(J(e===`logo`?`project.logoNoneFound`:`project.assetNoneFound`))}catch(e){u(e.message)}c(!1)},g=async()=>{c(!0),u(null);let e=[];try{for(let n of p){let r=await t(n);r.file&&e.push(r.file)}}catch(e){u(e.message)}c(!1),e.length&&n(e),e.length===p.length&&r()};return(0,$.jsx)(S,{open:!0,onClose:r,wide:d?!0:void 0,title:J(d?e===`logo`?`project.logoFound`:`project.assetFound`:e===`logo`?`project.logoFromUrl`:`project.assetFromUrl`),children:d?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:J(e===`logo`?`project.logoFoundHint`:`project.assetFoundHint`)}),(0,$.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(150px,1fr))] gap-3`,children:d.map(t=>{let n=p.includes(t.url);return(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":n,title:t.hint,onClick:()=>m(e=>n?e.filter(e=>e!==t.url):[...e,t.url]),className:L(`relative h-28 overflow-hidden rounded-lg ring-1 transition`,n?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),style:$t,children:[(0,$.jsx)(`img`,{src:t.url,alt:``,className:L(`size-full`,e===`logo`?`object-contain p-3`:`object-cover`)}),n?(0,$.jsx)(`span`,{className:`absolute top-1.5 right-1.5 grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,$.jsx)(_,{className:`size-3.5`})}):null]},t.url)})}),l?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:l}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(E,{variant:`ghost`,onClick:()=>f(null),children:J(`run.back`)}),(0,$.jsx)(E,{busy:s,disabled:!p.length,onClick:()=>void g(),children:p.length>1?J(`project.addMany`,{n:p.length}):J(`project.add`)})]})]}):(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),h()},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(I,{children:J(`project.logoUrl`)}),(0,$.jsx)(o,{autoFocus:!0,value:i,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>a(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:J(e===`logo`?`project.logoUrlHint`:`project.assetUrlHint`)})]}),l?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:l}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(E,{variant:`ghost`,onClick:r,children:J(`common.cancel`)}),(0,$.jsx)(E,{type:`submit`,busy:s,disabled:!i.trim(),children:J(`run.next`)})]})]})})}function cn(e,t,n){return H({queryKey:[`project-file-text`,t.id,t.chars,n],queryFn:()=>F.get(`/api/studio/projects/${e}/files/${t.id}/text?limit=${n}`),enabled:t.status===`ready`,staleTime:6e4})}function ln(e){return((e.name.includes(`.`)?e.name.split(`.`).pop():``)||e.mime.split(`/`).pop()||``).toUpperCase().slice(0,5)}var un=e=>[ln(e),e.pages?J(`project.pages`,{n:e.pages}):null,ge(e.size)].filter(Boolean).join(` · `),dn=2e5;function fn({projectId:e,fileId:t,readOnly:n,onGone:r}){let i=j(),o=a(e),s=Ge(e),c=ee(e,n),l=o.data?.files.find(e=>e.id===t),d=l?l.mime===`application/pdf`||l.mime.startsWith(`image/`):!1,[f,p]=(0,Q.useState)(null);if(!l)return o.isLoading?(0,$.jsx)(h,{className:`mx-auto text-ink-3`}):null;let _=f??(d?`original`:`text`),v=s.data?.items.find(e=>e.key===`f:${l.id}`),y=g(e,l.id),b=(e,t)=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":_===e,onClick:()=>p(e),className:L(`rounded-full px-3 py-1 text-[0.8125rem] transition`,_===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:un(l)}),(0,$.jsx)(`a`,{href:y,target:`_blank`,rel:`noreferrer`,"aria-label":J(`project.openOriginal`),title:J(`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)(u,{className:`size-4`})}),n?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{label:J(`project.reindex`),onClick:async()=>{await c.reindex(l.id),await i.invalidateQueries({queryKey:[`knowledge`,e]})},children:(0,$.jsx)(W,{className:`size-4`})}),(0,$.jsx)(Z,{label:J(`know.deleteFile`),className:`hover:text-rose`,onClick:async()=>{confirm(J(`data.confirmDelete`,{title:l.name}))&&(await c.remove(l.id),await i.invalidateQueries({queryKey:[`knowledge`,e]}),r())},children:(0,$.jsx)(R,{className:`size-4`})})]})]}),(0,$.jsx)(Ie,{projectId:e,itemKey:`f:${l.id}`,has:v?.categories??[],originLabel:v?.originLabel??null,kept:!1,review:null,file:null,readOnly:n,onReviewed:()=>void 0}),(0,$.jsx)(`div`,{className:`px-1`,children:(0,$.jsx)(en,{file:l,actions:c})}),l.status===`failed`?(0,$.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:l.error}):null,(0,$.jsxs)(m,{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:[d?b(`original`,J(`project.original`)):null,b(`text`,J(`project.readText`))]}),_===`original`?l.mime===`application/pdf`?(0,$.jsx)(`iframe`,{src:y,title:l.name,className:`h-[70dvh] w-full rounded-b-xl bg-paper-2`}):(0,$.jsx)(`img`,{src:y,alt:``,className:`mx-auto max-h-[70dvh] object-contain p-4`}):(0,$.jsx)(pn,{projectId:e,file:l})]})]})}function pn({projectId:e,file:t}){let n=cn(e,t,dn);return n.isLoading||t.status===`pending`?(0,$.jsx)(`div`,{className:`flex h-40 items-center justify-center text-ink-3`,children:(0,$.jsx)(h,{})}):n.data?.text?(0,$.jsxs)(`div`,{className:`overflow-x-auto p-4 sm:p-5`,children:[(0,$.jsx)(pe,{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:J(`project.textCut`,{shown:n.data.text.length.toLocaleString(O),total:n.data.chars.toLocaleString(O)})}):null]}):(0,$.jsx)(`p`,{className:`py-8 text-center text-[0.875rem] text-ink-3`,children:J(`project.noText`)})}var mn=`image/*,video/*,audio/*,application/pdf,.pdf,.woff2,.woff,.ttf,.otf,.json,.glb,.gltf`,hn=e=>[(e.name.includes(`.`)?e.name.split(`.`).pop():e.mime.split(`/`).pop())?.toUpperCase().slice(0,5),ge(e.size)].filter(Boolean).join(` · `);function gn({projectId:e,file:t,actions:n,onClose:r}){let i=g(e,t.id);return(0,$.jsxs)(S,{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:hn(t)}),(0,$.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,"aria-label":J(`project.openOriginal`),title:J(`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)(u,{className:`size-4`})})]}),t.mime.startsWith(`image/`)?(0,$.jsx)(`div`,{className:`overflow-hidden rounded-lg`,style:$t,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)(en,{file:t,actions:n})})]})}function _n({projectId:e,file:t,actions:n,moveTo:r,onPreview:i,onRemove:a}){return(0,$.jsxs)(`li`,{className:`group/row flex items-start gap-3 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":`${J(`project.preview`)}: ${t.name}`,onClick:i,className:`size-14 shrink-0 cursor-zoom-in overflow-hidden rounded-md bg-paper-2`,children:(0,$.jsx)(nn,{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:i,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:hn(t)})]}),(0,$.jsx)(en,{file:t,actions:n})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start opacity-0 transition focus-within:opacity-100 group-hover/row:opacity-100 coarse:opacity-100`,children:[(0,$.jsx)(Z,{label:J(`project.preview`),onClick:i,children:(0,$.jsx)(Te,{className:`size-4`})}),r&&!n.readOnly?(0,$.jsx)(ce,{options:r.options,value:r.current(t),onChange:e=>r.onMove(t,e),className:`size-9`}):null,n.readOnly?null:(0,$.jsx)(Z,{label:J(`project.remove`),onClick:a,className:`hover:text-rose`,children:(0,$.jsx)(R,{className:`size-4`})})]})]})}function vn({section:e,onSave:t,onRemove:n,onClose:r}){let[i,a]=(0,Q.useState)(e?.title??``);return(0,$.jsx)(S,{open:!0,onClose:r,title:J(e?`project.assetSectionRename`:`project.assetSectionAdd`),children:(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),i.trim()&&(t(i.trim()),r())},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(I,{children:J(`project.assetSectionName`)}),(0,$.jsx)(o,{autoFocus:!0,value:i,maxLength:80,placeholder:J(`project.assetSectionTitle`),onChange:e=>a(e.target.value)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n?(0,$.jsx)(E,{variant:`danger`,onClick:n,children:J(`project.sectionRemove`)}):null,(0,$.jsx)(`span`,{className:`flex-1`}),(0,$.jsx)(E,{variant:`ghost`,onClick:r,children:J(`common.cancel`)}),(0,$.jsx)(E,{type:`submit`,disabled:!i.trim(),children:J(e?`settings.save`:`project.add`)})]})]})})}function yn({projectId:e,data:t,readOnly:n,sections:r,save:i}){let a=ee(e,n),[o,s]=Ce(`assets`,`cards`),[c,l]=(0,Q.useState)(``),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(r),[m,g]=(0,Q.useState)(``),[_,v]=(0,Q.useState)(null),[b,S]=(0,Q.useState)(!1),C=(0,Q.useRef)(null),T=x({assetSections:f},i),E=t.files.filter(e=>e.kind===`asset`),D=new Map(E.map(e=>[e.id,e])),O=new Set(f.flatMap(e=>e.assets)),k=f.find(e=>e.id===m)??null,A=k?k.assets.map(e=>D.get(e)).filter(e=>!!e):E.filter(e=>!O.has(e.id)),te=E.find(e=>e.id===u),ne=c.trim().toLowerCase(),j=ne?A.filter(e=>`${e.name} ${e.description}`.toLowerCase().includes(ne)):A,M=(e,t)=>p(n=>n.map(n=>{let r=n.assets.filter(t=>t!==e);return{...n,assets:n.id===t?[...r,e]:r}})),N=async e=>{let t=k?.id??null;for(let n of await a.upload(`asset`,e))M(n.id,t)},P=e=>{confirm(J(`project.removeConfirm`,{name:e.name}))&&(a.remove(e.id),M(e.id,null))},F=f.length?{options:[{value:``,label:J(`project.assetsGeneral`)},...f.map(e=>({value:e.id,label:e.title||J(`project.sectionUntitled`)}))],current:e=>f.find(t=>t.assets.includes(e.id))?.id??``,onMove:(e,t)=>M(e.id,t||null)}:void 0,I=[{label:J(`project.assetUpload`),icon:(0,$.jsx)(it,{className:`size-4 shrink-0`}),onPick:()=>C.current?.click()},{label:J(`project.assetFromUrl`),icon:(0,$.jsx)(Jt,{className:`size-4 shrink-0`}),onPick:()=>S(!0)},...f.length<w.logoSections?[{label:J(`project.assetSectionAdd`),icon:(0,$.jsx)(Ht,{className:`size-4 shrink-0`}),onPick:()=>v(`new`)}]:[]],re=f.length||E.length?(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(`div`,{className:`-mx-1 flex min-w-0 flex-1 items-center gap-1 overflow-x-auto px-1 pb-0.5`,children:[f.length?(0,$.jsx)(y,{value:m,onChange:e=>{g(e),l(``)},label:J(`project.assets`),options:[{id:``,label:J(`project.assetsGeneral`)},...f.map(e=>({id:e.id,label:e.title||J(`project.sectionUntitled`)}))]}):null,k&&!n?(0,$.jsx)(Z,{label:J(`project.assetSectionRename`),onClick:()=>v(`current`),children:(0,$.jsx)(le,{className:`size-4`})}):null]}),A.length?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`w-56 max-w-[45%] shrink`,children:(0,$.jsx)(be,{value:c,onChange:l,placeholder:J(`project.assetSearch`)})}),(0,$.jsx)(Z,{label:J(o===`list`?`project.viewCards`:`project.viewList`),onClick:s,children:o===`list`?(0,$.jsx)(Kt,{className:`size-4`}):(0,$.jsx)(Xt,{className:`size-4`})})]}):null]}):null;return(0,$.jsxs)(X,{title:J(`project.assets`),hint:J(`project.assetsHint`),save:T,tabs:re,action:n?null:(0,$.jsx)(V,{entries:I}),children:[(0,$.jsx)(`input`,{ref:C,type:`file`,multiple:!0,accept:mn,className:`sr-only`,tabIndex:-1,"aria-hidden":!0,onChange:e=>{let t=Array.from(e.target.files??[]);e.target.value=``,t.length&&N(t)}}),j.length?o===`cards`?(0,$.jsx)(on,{projectId:e,kind:`asset`,files:j,actions:a,moveTo:F,onRemove:P,onPreview:e=>d(e.id)}):(0,$.jsx)(`ul`,{className:`flex flex-col gap-2`,children:j.map(t=>(0,$.jsx)(_n,{projectId:e,file:t,actions:a,moveTo:F,onPreview:()=>d(t.id),onRemove:()=>P(t)},t.id))}):A.length?null:n?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:J(`project.staysLocal`)}):(0,$.jsxs)(me,{accept:mn,onFiles:e=>void N(e),className:`h-16 w-full`,children:[a.busy?(0,$.jsx)(h,{className:`size-4`}):(0,$.jsx)(it,{className:`size-4`}),J(`project.drop`),` `,(0,$.jsx)(`span`,{className:`underline`,children:J(`project.assetAdd`)})]}),a.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:a.error}):null,te?(0,$.jsx)(gn,{projectId:e,file:te,actions:a,onClose:()=>d(null)}):null,_?(0,$.jsx)(vn,{section:_===`current`?k:null,onClose:()=>v(null),onSave:e=>{if(_===`current`&&k)p(t=>t.map(t=>t.id===k.id?{...t,title:e}:t));else{let t=Y();p(n=>[...n,{id:t,title:e,assets:[]}]),g(t)}},onRemove:_===`current`&&k?()=>{(!k.assets.length||confirm(J(`project.assetSectionRemoveConfirm`,{name:k.title})))&&(p(e=>e.filter(e=>e.id!==k.id)),g(``),v(null))}:void 0}):null,b?(0,$.jsx)(sn,{kind:`asset`,onClose:()=>S(!1),fetchUrl:e=>a.fromUrl(`asset`,e),onAdded:e=>{for(let t of e)M(t.id,k?.id??null)}}):null]})}var bn=/^#[0-9a-fA-F]{6}$/;async function xn(e,t){let[n,r]=[1920,1080],i=document.createElement(`canvas`);i.width=n,i.height=r;let a=i.getContext(`2d`);if(!a)return;let o=e.angle*Math.PI/180,s;if(e.type===`radial`)s=a.createRadialGradient(n/2,r/2,0,n/2,r/2,Math.hypot(n,r)/2);else if(e.type===`conic`)s=a.createConicGradient(o-Math.PI/2,n/2,r/2);else{let e=Math.abs(n*Math.sin(o))+Math.abs(r*Math.cos(o)),[t,i]=[Math.sin(o)*e/2,-Math.cos(o)*e/2];s=a.createLinearGradient(n/2-t,r/2-i,n/2+t,r/2+i)}for(let t of[...e.stops].sort((e,t)=>e.at-t.at))s.addColorStop(Math.min(1,Math.max(0,t.at/100)),t.color);a.fillStyle=s,a.fillRect(0,0,n,r);let c=await new Promise(e=>i.toBlob(e,`image/png`));if(c){let e=document.createElement(`a`);e.href=URL.createObjectURL(c),e.download=`${t||`gradient`}.png`,e.click(),setTimeout(()=>URL.revokeObjectURL(e.href),5e3)}}var Sn={linear:`project.gradientLinear`,radial:`project.gradientRadial`,conic:`project.gradientConic`};function Cn({projectId:e,gradient:t,isNew:n,brand:r,onSave:i,onClose:a}){let[s,c]=(0,Q.useState)(t),[u,d]=(0,Q.useState)(C(t)),[f,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(``),[_,v]=(0,Q.useState)(!1),[y,x]=(0,Q.useState)(null),[w,T]=(0,Q.useState)(!n),D=e=>{c(e),d(C(e)),m(!1)},O=(e,t)=>D({...s,stops:s.stops.map((n,r)=>r===e?{...n,...t}:n)}),ee=e=>{let t=[...s.stops].sort((e,t)=>e.at-t.at),n=50,r=-1;for(let e=0;e<t.length-1;e++)t[e+1].at-t[e].at>r&&(r=t[e+1].at-t[e].at,n=Math.round((t[e].at+t[e+1].at)/2));D({...s,stops:[...s.stops,{color:e??t[0]?.color??`#888888`,at:n}]})},k=async()=>{v(!0),x(null);try{let{gradient:t}=await F.post(`/api/studio/projects/${e}/gradients/describe`,{text:h.trim(),...w?{gradient:{name:s.name,type:s.type,angle:s.angle,stops:s.stops}}:{}});D({...s,...t,name:s.name.trim()?s.name:t.name}),g(``),T(!0)}catch(e){x(e.message)}v(!1)};return(0,$.jsx)(S,{open:!0,onClose:a,wide:!0,title:J(n?`project.gradientNew`:`project.gradientEdit`),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),h.trim()&&!_&&k()},children:[(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(o,{"data-autofocus":n||void 0,value:h,maxLength:1e3,"aria-label":J(`project.gradientDescribe`),placeholder:J(w?`project.gradientDescribeChange`:`project.gradientDescribeNew`),onChange:e=>g(e.target.value),className:`min-w-0 flex-1`}),(0,$.jsxs)(E,{type:`submit`,variant:`secondary`,busy:_,disabled:!h.trim(),children:[(0,$.jsx)(B,{className:`size-4`}),J(w?`project.gradientDescribeApply`:`project.gradientDescribeMake`)]})]}),(0,$.jsx)(`p`,{className:L(`mt-1.5 text-[0.8125rem]`,y?`text-rose`:`text-ink-3`),children:y??J(`project.gradientDescribeHint`)})]}),(0,$.jsx)(`div`,{className:`h-40 rounded-lg ring-1 ring-border-soft`,style:{background:C(s)}}),(0,$.jsxs)(`div`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(I,{children:J(`project.gradientName`)}),(0,$.jsx)(o,{value:s.name,maxLength:80,placeholder:J(`project.gradientNamePlaceholder`),onChange:e=>c({...s,name:e.target.value})})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(I,{children:J(`project.fillUseLabel`)}),(0,$.jsx)(o,{value:s.description??``,maxLength:400,placeholder:J(`project.gradientUse`),onChange:e=>c({...s,description:e.target.value})})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-end gap-x-6 gap-y-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(I,{children:J(`project.gradientType`)}),(0,$.jsx)(`div`,{className:`flex gap-1 rounded-full bg-paper-2 p-0.5 ring-1 ring-border-soft`,children:l.map(e=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":s.type===e,onClick:()=>D({...s,type:e}),className:L(`h-9 rounded-full px-4 font-medium text-[0.875rem] transition`,s.type===e?`bg-card text-ink shadow-sm`:`text-ink-3 hover:text-ink-2`),children:J(Sn[e])},e))})]}),s.type===`radial`?null:(0,$.jsxs)(`div`,{className:`min-w-56`,children:[(0,$.jsx)(I,{children:J(`project.gradientAngle`)}),(0,$.jsxs)(`div`,{className:`flex h-11 items-center gap-3`,children:[(0,$.jsx)(`input`,{type:`range`,min:0,max:360,value:s.angle,"aria-label":J(`project.gradientAngle`),onChange:e=>D({...s,angle:Number(e.target.value)}),className:`flex-1 accent-ink`}),(0,$.jsxs)(`span`,{className:`w-12 text-right text-[0.875rem] text-ink-2 tabular-nums`,children:[Math.round(s.angle),`°`]})]})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(I,{children:J(`project.gradientStops`)}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:s.stops.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(b,{value:bn.test(e.color)?e.color:`#888888`,onChange:e=>O(t,{color:e.target.value})}),(0,$.jsx)(o,{value:e.color,spellCheck:!1,onChange:e=>{let n=e.target.value.trim();bn.test(n)&&O(t,{color:n.toLowerCase()})},className:`w-28 font-mono text-[0.8125rem]`}),(0,$.jsx)(`input`,{type:`range`,min:0,max:100,value:e.at,"aria-label":J(`project.gradientAt`),onChange:e=>O(t,{at:Number(e.target.value)}),className:`flex-1 accent-ink`}),(0,$.jsxs)(`span`,{className:`w-10 text-right text-[0.875rem] text-ink-2 tabular-nums`,children:[Math.round(e.at),`%`]}),(0,$.jsx)(Z,{label:J(`project.remove`),disabled:s.stops.length<=2,onClick:()=>D({...s,stops:s.stops.filter((e,n)=>n!==t)}),className:`hover:text-rose`,children:(0,$.jsx)(R,{className:`size-4`})})]},t))}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[s.stops.length<12?(0,$.jsxs)(E,{variant:`secondary`,size:`sm`,onClick:()=>ee(),children:[(0,$.jsx)(q,{className:`size-4`}),` `,J(`project.gradientStopAdd`)]}):null,r.length&&s.stops.length<12?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`ml-2 text-[0.8125rem] text-ink-3`,children:J(`project.gradientFromBrand`)}),r.slice(0,10).map(e=>(0,$.jsx)(`button`,{type:`button`,title:e.name||e.value,"aria-label":e.name||e.value,onClick:()=>ee(e.value),className:`size-6 rounded-full ring-1 ring-border transition hover:scale-110`,style:{background:e.value}},e.value))]}):null]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(I,{children:`CSS`}),(0,$.jsx)(o,{value:u,spellCheck:!1,onChange:e=>{d(e.target.value);let t=p(e.target.value);m(!t),t&&c({...s,...t})},className:`font-mono text-[0.8125rem]`}),(0,$.jsx)(`p`,{className:L(`mt-1.5 text-[0.8125rem]`,f?`text-rose`:`text-ink-3`),children:J(f?`project.gradientCssError`:`project.gradientCssHint`)})]}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(E,{variant:`ghost`,onClick:a,children:J(`common.cancel`)}),(0,$.jsx)(E,{onClick:()=>{i(s),a()},children:J(`settings.save`)})]})]})})}var wn=`absolute top-1.5 right-1.5 flex gap-1 opacity-0 transition focus-within:opacity-100 group-hover/card:opacity-100 coarse:opacity-100`,Tn=`size-8 bg-card shadow-soft hover:bg-card`;function En({name:e,namePlaceholder:t,description:n,usePlaceholder:r,readOnly:i,onChange:a}){return i?(0,$.jsxs)(`div`,{className:`min-w-0 px-0.5`,children:[(0,$.jsx)(`p`,{className:`truncate text-[0.875rem]`,children:e||t}),n?(0,$.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3 leading-snug`,children:n}):null]}):(0,$.jsxs)(`div`,{className:`min-w-0 px-0.5`,children:[(0,$.jsx)(G,{value:e,label:J(`project.gradientName`),placeholder:t,maxLength:80,onChange:e=>a({name:e}),className:`font-medium text-[0.875rem]`}),(0,$.jsx)(G,{value:n??``,label:J(`project.fillUseLabel`),placeholder:r,maxLength:400,onChange:e=>a({description:e}),className:`text-[0.8125rem] text-ink-3`})]})}function Dn({gradient:e,readOnly:t,onEdit:n,onChange:r,onRemove:i}){let a=C(e),[o,s]=(0,Q.useState)(!1);return(0,$.jsxs)(`div`,{className:`group/card flex flex-col gap-2 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:t,"aria-label":J(`project.gradientEdit`),onClick:n,className:`block h-28 w-full rounded-md ring-1 ring-border-soft transition enabled:hover:brightness-105`,style:{background:a}}),(0,$.jsxs)(`div`,{className:wn,children:[(0,$.jsx)(Z,{label:J(o?`project.gradientCopied`:`project.gradientCopy`),onClick:()=>{navigator.clipboard.writeText(`background: ${a};`),s(!0),setTimeout(()=>s(!1),1500)},className:Tn,children:(0,$.jsx)(de,{className:`size-4`})}),(0,$.jsx)(Z,{label:J(`project.download`),onClick:()=>void xn(e,e.name),className:Tn,children:(0,$.jsx)(K,{className:`size-4`})}),t?null:(0,$.jsx)(Z,{label:J(`project.remove`),onClick:i,className:L(Tn,`hover:text-rose`),children:(0,$.jsx)(R,{className:`size-4`})})]})]}),(0,$.jsx)(En,{name:e.name,namePlaceholder:J(`project.gradientName`),description:e.description,usePlaceholder:J(`project.gradientUse`),readOnly:t,onChange:r})]})}function On(e,t){return{backgroundImage:`url("${e}")`,backgroundSize:t?`64px`:`cover`,backgroundRepeat:t?`repeat`:`no-repeat`,backgroundPosition:`center`}}function kn({projectId:e,pattern:t,fileName:n,readOnly:r,onEdit:i,onChange:a,onRemove:o}){let s=g(e,t.file);return(0,$.jsxs)(`div`,{className:`group/card flex flex-col gap-2 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:r,"aria-label":J(`project.patternEdit`),onClick:i,className:`block h-28 w-full rounded-md ring-1 ring-border-soft transition enabled:hover:brightness-105`,style:On(s,t.tile)}),(0,$.jsxs)(`div`,{className:wn,children:[(0,$.jsx)(`a`,{href:s,download:n,"aria-label":J(`project.download`),title:J(`project.download`),className:L(`inline-flex items-center justify-center rounded-full text-ink-3 transition hover:text-ink`,Tn),children:(0,$.jsx)(K,{className:`size-4`})}),r?null:(0,$.jsx)(Z,{label:J(`project.remove`),onClick:o,className:L(Tn,`hover:text-rose`),children:(0,$.jsx)(R,{className:`size-4`})})]})]}),(0,$.jsx)(En,{name:t.name,namePlaceholder:n,description:t.description,usePlaceholder:J(`project.patternUse`),readOnly:r,onChange:a})]})}function An({projectId:e,pattern:t,isNew:n,fileName:r,busy:i,error:a,upload:s,removeFile:l,onSave:u,onClose:d}){let[f,p]=(0,Q.useState)(t),[m,_]=(0,Q.useState)([]),v=async e=>{let t=e[0];if(!t)return;let n=await s(t);n&&(_(e=>[...e,n.id]),p(e=>({...e,file:n.id,name:e.name||n.name.replace(/\.[^.]+$/,``)})))},y=()=>{for(let e of m)l(e);d()};return(0,$.jsx)(S,{open:!0,onClose:y,wide:!0,title:J(n?`project.patternNew`:`project.patternEdit`),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[f.file?(0,$.jsx)(`div`,{className:`relative h-40 rounded-lg ring-1 ring-border-soft`,style:On(g(e,f.file),f.tile),children:(0,$.jsxs)(me,{accept:`image/*`,multiple:!1,onFiles:e=>void v(e),className:`absolute right-2 bottom-2 h-9 border-solid bg-card px-3.5 text-ink-2 shadow-soft`,children:[i?(0,$.jsx)(h,{className:`size-4`}):(0,$.jsx)(c,{className:`size-4`}),J(`project.patternReplace`)]})}):(0,$.jsxs)(me,{accept:`image/*`,multiple:!1,onFiles:e=>void v(e),className:`h-40 flex-col`,children:[i?(0,$.jsx)(h,{className:`size-5`}):(0,$.jsx)(c,{className:`size-5`}),J(`project.patternPick`)]}),(0,$.jsxs)(`div`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(I,{children:J(`project.patternName`)}),(0,$.jsx)(o,{value:f.name,maxLength:80,placeholder:f.file?r(f.file):J(`project.patternNamePlaceholder`),onChange:e=>p({...f,name:e.target.value})})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(I,{children:J(`project.fillUseLabel`)}),(0,$.jsx)(o,{value:f.description??``,maxLength:400,placeholder:J(`project.patternUse`),onChange:e=>p({...f,description:e.target.value})})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(I,{children:J(`project.patternShow`)}),(0,$.jsx)(`div`,{className:`flex w-fit gap-1 rounded-full bg-paper-2 p-0.5 ring-1 ring-border-soft`,children:[!1,!0].map(e=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":!!f.tile===e,onClick:()=>p({...f,tile:e||void 0}),className:L(`h-9 rounded-full px-4 font-medium text-[0.875rem] transition`,!!f.tile===e?`bg-card text-ink shadow-sm`:`text-ink-3 hover:text-ink-2`),children:J(e?`project.patternTile`:`project.patternFill`)},String(e)))})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[a?(0,$.jsx)(`p`,{className:`mr-auto text-[0.8125rem] text-rose`,children:a}):null,(0,$.jsx)(E,{variant:`ghost`,onClick:y,children:J(`common.cancel`)}),(0,$.jsx)(E,{disabled:!f.file||i,onClick:()=>{for(let e of m.filter(e=>e!==f.file))l(e);t.file&&t.file!==f.file&&l(t.file),u({...f,name:f.name.trim(),description:f.description?.trim()||void 0}),d()},children:J(n?`project.add`:`settings.save`)})]})]})})}var jn=/^#[0-9a-fA-F]{6}$/;function Mn({projectId:e,onAdd:t,onClose:n}){let[r,i]=(0,Q.useState)(``),[a,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)([]),m=async()=>{s(!0),l(null);try{let{colors:t}=await F.post(`/api/studio/projects/${e}/colors/scan`,{url:r.trim()});t.length?(d(t),p([])):l(J(`project.colorsNoneFound`))}catch(e){l(e.message)}s(!1)};return(0,$.jsx)(S,{open:!0,onClose:n,wide:u?!0:void 0,title:J(u?`project.colorsFound`:`project.colorsFromUrl`),children:u?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:J(`project.colorsFoundHint`)}),(0,$.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(120px,1fr))] gap-3`,children:u.map(e=>{let t=f.includes(e.value);return(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>p(n=>t?n.filter(t=>t!==e.value):[...n,e.value]),className:L(`relative flex flex-col overflow-hidden rounded-lg text-left ring-1 transition`,t?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),children:[(0,$.jsx)(`span`,{className:`h-16`,style:{background:e.value}}),(0,$.jsxs)(`span`,{className:`flex flex-col px-2.5 py-2`,children:[(0,$.jsx)(`span`,{className:`truncate text-[0.8125rem] text-ink-2`,children:e.name||`—`}),(0,$.jsx)(`span`,{className:`font-mono text-[0.75rem] text-ink-3`,children:e.value})]}),t?(0,$.jsx)(`span`,{className:`absolute top-1.5 right-1.5 grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,$.jsx)(_,{className:`size-3.5`})}):null]},e.value)})}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(E,{variant:`ghost`,onClick:()=>d(null),children:J(`run.back`)}),(0,$.jsx)(E,{disabled:!f.length,onClick:()=>{t(u.filter(e=>f.includes(e.value))),n()},children:f.length>1?J(`project.addMany`,{n:f.length}):J(`project.add`)})]})]}):(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),m()},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(I,{children:J(`project.logoUrl`)}),(0,$.jsx)(o,{autoFocus:!0,value:r,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>i(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:J(`project.colorsUrlHint`)})]}),c?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:c}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(E,{variant:`ghost`,onClick:n,children:J(`common.cancel`)}),(0,$.jsx)(E,{type:`submit`,busy:a,disabled:!r.trim(),children:J(`run.next`)})]})]})})}function Nn({projectId:e,data:t,colors:n,sections:r,gradients:i,patterns:a,rules:s,sectioned:c,ruled:l,save:u,readOnly:d}){let[f,p]=(0,Q.useState)(()=>n.map(e=>({...e,id:Y()}))),[m,h]=(0,Q.useState)(r),[g,_]=(0,Q.useState)(i),[y,S]=(0,Q.useState)(a),[C,T]=(0,Q.useState)(null),[E,D]=(0,Q.useState)(null),O=ee(e,d),k=A(s),[te,ne]=(0,Q.useState)(null),[j,M]=(0,Q.useState)(null),[N,P]=(0,Q.useState)(!1),F=x({colors:f.filter(e=>jn.test(e.value)).map(({name:e,value:t,section:n})=>({name:e.trim(),value:t,...n?{section:n}:{}})),colorSections:m,gradients:g,patterns:y,colorRules:k.rules},u),I=c?m:[],re=I.filter(e=>(e.kind??`colors`)===`colors`),ie=e=>re.some(t=>t.id===e.section),L=f.filter(e=>!ie(e)),ae=(L[0]??f[0])?.id,oe=(e,t)=>p(n=>n.map(n=>n.id===e?{...n,...t}:n)),B=e=>p(t=>[...t,...e.map(e=>({...e,id:Y()}))].slice(0,w.colors)),H=[{value:``,label:J(`project.sectionStandard`)},...re.map(e=>({value:e.id,label:e.title||J(`project.sectionUntitled`)}))],W=(e,t)=>{let n=Y();ne(n),h(r=>[...r,{id:n,title:t,...e===`colors`?{}:{kind:e}}])},G=e=>({id:Y(),name:``,section:e,type:`linear`,angle:90,stops:[{color:f[0]?.value&&jn.test(f[0].value)?f[0].value:`#4b73ff`,at:0},{color:f[1]?.value&&jn.test(f[1].value)?f[1].value:`#ff6d1b`,at:100}]}),le=e=>t.files.find(t=>t.id===e)?.name??`pattern`,ue=[...f.length<w.colors?[{label:J(`project.colorNew`),icon:(0,$.jsx)(q,{className:`size-4 shrink-0`}),onPick:()=>fe()},{label:J(`project.colorsFromUrl`),icon:(0,$.jsx)(Jt,{className:`size-4 shrink-0`}),onPick:()=>P(!0)}]:[],...c&&m.length<w.logoSections?[{label:J(`project.colorSectionAdd`),icon:(0,$.jsx)(Ht,{className:`size-4 shrink-0`}),onPick:()=>W(`colors`,``)},{label:J(`project.gradientSectionAdd`),icon:(0,$.jsx)(It,{className:`size-4 shrink-0`}),onPick:()=>W(`gradients`,J(`project.gradientSectionTitle`))},{label:J(`project.patternSectionAdd`),icon:(0,$.jsx)(Wt,{className:`size-4 shrink-0`}),onPick:()=>W(`patterns`,J(`project.patternSectionTitle`))}]:[],...!l||k.full?[]:[{label:J(`project.ruleNew`),icon:(0,$.jsx)(Ae,{className:`size-4 shrink-0`}),onPick:()=>k.add()}]],de=e=>(0,$.jsxs)(`div`,{className:`group/row flex items-center gap-2`,children:[(0,$.jsx)(b,{value:jn.test(e.value)?e.value:`#888888`,onChange:t=>oe(e.id,{value:t.target.value})}),(0,$.jsx)(o,{value:e.name,autoFocus:e.id===j,placeholder:J(`project.colorName`),maxLength:120,onChange:t=>oe(e.id,{name:t.target.value}),className:`min-w-0 flex-1`}),(0,$.jsx)(o,{value:e.value,placeholder:`#e0531b`,spellCheck:!1,onChange:t=>oe(e.id,{value:t.target.value.trim()}),className:`w-28 font-mono text-[0.8125rem]`}),(0,$.jsxs)(`div`,{className:`flex w-28 shrink-0 items-center justify-end max-sm:w-auto`,children:[e.id===ae?(0,$.jsx)(`span`,{className:`mr-1 max-sm:hidden`,children:(0,$.jsx)(v,{tone:`ember`,children:J(`project.colorAccent`)})}):d?null:(0,$.jsx)(Z,{label:J(`project.colorFirst`),onClick:()=>p(t=>[{...e,section:void 0},...t.filter(t=>t.id!==e.id)]),className:`opacity-0 transition focus:opacity-100 group-hover/row:opacity-100 coarse:opacity-100`,children:(0,$.jsx)(we,{className:`size-4`})}),d||!re.length?null:(0,$.jsx)(ce,{options:H,value:ie(e)?e.section??``:``,onChange:t=>oe(e.id,{section:t||void 0}),className:`opacity-0 focus-within:opacity-100 group-hover/row:opacity-100 coarse:opacity-100`}),d?null:(0,$.jsx)(Z,{label:J(`project.remove`),onClick:()=>p(t=>t.filter(t=>t.id!==e.id)),className:`opacity-0 transition focus:opacity-100 group-hover/row:opacity-100 coarse:opacity-100 hover:text-rose`,children:(0,$.jsx)(R,{className:`size-4`})})]})]},e.id),fe=e=>{let t=Y();M(t),p(n=>[...n,{id:t,name:``,value:`#888888`,...e?{section:e}:{}}])};return(0,$.jsxs)(X,{title:J(`project.colors`),hint:J(`project.colorsHint`),save:F,locked:d,action:d?null:(0,$.jsx)(V,{entries:ue}),children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[L.length?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:L.map(de)}),d?null:(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:J(`project.colorUse`)})]}):f.length?null:(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:J(`project.colorsEmpty`)}),I.map(t=>{let n=t.kind??`colors`,r=f.filter(e=>e.section===t.id),i=g.filter(e=>e.section===t.id),a=y.filter(e=>e.section===t.id),o=n===`gradients`?i.length:n===`patterns`?a.length:r.length;return(0,$.jsxs)(`div`,{className:`group/section flex flex-col gap-3`,children:[(0,$.jsx)(z,{title:t.title,titlePlaceholder:J(n===`gradients`?`project.gradientSectionTitlePlaceholder`:n===`patterns`?`project.patternSectionTitlePlaceholder`:`project.colorSectionTitle`),kind:n===`gradients`?{icon:(0,$.jsx)(It,{}),label:J(`project.kindGradients`)}:n===`patterns`?{icon:(0,$.jsx)(Wt,{}),label:J(`project.kindPatterns`)}:{icon:(0,$.jsx)(ft,{}),label:J(`project.kindColors`)},autoFocus:te===t.id,readOnly:d,onChange:e=>h(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>{if(!o||confirm(J(n===`colors`?`project.colorSectionRemoveConfirm`:`project.fillSectionRemoveConfirm`,{name:t.title||J(`project.sectionUntitled`)}))){h(e=>e.filter(e=>e.id!==t.id)),p(e=>e.map(e=>e.section===t.id?{...e,section:void 0}:e)),_(e=>e.filter(e=>e.section!==t.id));for(let e of a)O.remove(e.file);S(e=>e.filter(e=>e.section!==t.id))}}}),n===`gradients`?(0,$.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(200px,1fr))] gap-3`,children:[i.map(e=>(0,$.jsx)(Dn,{gradient:e,readOnly:d,onEdit:()=>T(e),onChange:t=>_(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>_(t=>t.filter(t=>t.id!==e.id))},e.id)),d||g.length>=w.gradients?null:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>T(G(t.id)),className:`flex min-h-28 flex-col items-center justify-center gap-2 rounded-lg border border-input border-dashed text-[0.875rem] text-ink-3 transition hover:border-ink-4 hover:text-ink`,children:[(0,$.jsx)(q,{className:`size-5`}),J(`project.gradientAdd`)]})]}):n===`patterns`?(0,$.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(200px,1fr))] gap-3`,children:[a.map(t=>(0,$.jsx)(kn,{projectId:e,pattern:t,fileName:le(t.file),readOnly:d,onEdit:()=>D(t),onChange:e=>S(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>{O.remove(t.file),S(e=>e.filter(e=>e.id!==t.id))}},t.id)),d||y.length>=w.files.pattern?null:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>D({id:Y(),name:``,section:t.id,file:``}),className:`flex min-h-28 flex-col items-center justify-center gap-2 rounded-lg border border-input border-dashed text-[0.875rem] text-ink-3 transition hover:border-ink-4 hover:text-ink`,children:[(0,$.jsx)(q,{className:`size-5`}),J(`project.patternAdd`)]})]}):(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.map(de),d||f.length>=w.colors?null:(0,$.jsx)(U,{label:J(`project.colorAdd`),onClick:()=>fe(t.id)})]})]},t.id)}),l?(0,$.jsx)(se,{rules:k,placeholder:J(`project.colorRulePlaceholder`),readOnly:d}):null]}),O.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:O.error}):null,C?(0,$.jsx)(Cn,{projectId:e,gradient:C,isNew:!g.some(e=>e.id===C.id),brand:f.filter(e=>jn.test(e.value)),onClose:()=>T(null),onSave:e=>_(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e])}):null,E?(0,$.jsx)(An,{projectId:e,pattern:E,isNew:!y.some(e=>e.id===E.id),fileName:le,busy:O.busy,error:O.error,upload:async e=>(await O.upload(`pattern`,[e]))[0]??null,removeFile:e=>void O.remove(e),onClose:()=>D(null),onSave:e=>S(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e])}):null,N?(0,$.jsx)(Mn,{projectId:e,onClose:()=>P(!1),onAdd:B}):null]})}var Pn=e=>/^(ja|yes|true)$/i.test(e.trim()),Fn={text:Oe,longtext:nt,number:Xe,date:Pe,url:te,email:xt,phone:et,boolean:Ye};function In({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 c=Fn[e??t],l=`${J(`project.factType`)}: ${J(`project.type.${e??t}`)}`,u=`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`,d=e=>{n(e),i(!1)};return(0,$.jsxs)(`div`,{className:`relative`,ref:s,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":l,title:l,"aria-haspopup":`menu`,"aria-expanded":r,onClick:e=>{o(window.innerHeight-e.currentTarget.getBoundingClientRect().bottom<400),i(e=>!e)},className:L(`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)(c,{className:`size-4`})}),r?(0,$.jsxs)(`div`,{role:`menu`,className:L(`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:u,onClick:()=>d(void 0),children:[(0,$.jsx)(ke,{className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1`,children:J(`project.factAuto`)}),(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:J(`project.type.${t}`)}),(0,$.jsx)(_,{className:L(`size-4 shrink-0`,e&&`invisible`)})]}),(0,$.jsx)(`div`,{className:`mx-2 my-1 h-px bg-border-soft`}),Se.map(t=>{let n=Fn[t];return(0,$.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e===t,className:u,onClick:()=>d(t),children:[(0,$.jsx)(n,{className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1`,children:J(`project.type.${t}`)}),(0,$.jsx)(_,{className:L(`size-4 shrink-0`,e!==t&&`invisible`)})]},t)})]}):null]})}function Ln({facts:e,save:t,readOnly:n}){let r=(0,Q.useRef)(0),a=(0,Q.useRef)(null),[c,l]=(0,Q.useState)(()=>e.map(e=>({...e,id:`f${r.current++}`}))),u=x(c.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),d=(e,t)=>l(n=>n.map(n=>n.id===e?{...n,...t}:n)),f=(e,t,n=!1)=>{let i=`f${r.current++}`;a.current=`${i}:${t}`;let o={id:i,key:``,label:``,value:``,...e};l(e=>n?[o,...e]:[...e,o])},p=e=>t=>{t&&a.current===e&&(a.current=null,t.focus())},m=s.filter(e=>!c.some(t=>t.key===e));return(0,$.jsxs)(X,{title:J(`project.facts`),hint:J(`project.factsHint`),save:u,locked:n,action:c.length<w.facts&&!n?(0,$.jsxs)(E,{variant:`secondary`,size:`sm`,onClick:()=>f({},`label`,!0),children:[(0,$.jsx)(q,{className:`size-4`}),` `,J(`project.factAdd`)]}):null,children:[(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:c.map(e=>{let t=fe(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:p(`${e.id}:label`),value:e.label,placeholder:J(`project.factLabel`),title:e.key?`{{facts.${e.key}}}`:void 0,onChange:t=>d(e.id,{label:t.target.value}),onBlur:()=>{!e.key&&e.label.trim()&&d(e.id,{key:i(e.label,c.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)(ve,{checked:Pn(e.value),label:e.label,onChange:t=>d(e.id,{value:J(t?`project.yes`:`project.no`)})}),(0,$.jsx)(`span`,{className:`text-[0.875rem] text-ink-2`,children:Pn(e.value)?J(`project.yes`):J(`project.no`)})]}):(0,$.jsx)(ae,{ref:p(`${e.id}:value`),rows:1,minRows:r===`longtext`?2:1,maxRows:10,value:e.value,placeholder:J(`project.factValue`),onChange:t=>d(e.id,{value:t.target.value}),className:`min-h-11`}),(0,$.jsx)(In,{type:e.type,detected:t,onChange:t=>d(e.id,{type:t})}),n?null:(0,$.jsx)(Z,{label:J(`project.remove`),onClick:()=>l(t=>t.filter(t=>t.id!==e.id)),className:`size-11 rounded-lg hover:text-rose`,children:(0,$.jsx)(R,{className:`size-4`})})]},e.id)})}),c.length<w.facts&&!n?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${c.length?`mt-4`:``}`,children:[(0,$.jsxs)(E,{variant:`secondary`,size:`sm`,onClick:()=>f({},`label`),children:[(0,$.jsx)(q,{className:`size-4`}),` `,J(`project.factAdd`)]}),m.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>f({key:e,label:J(`fact.${e}`)},`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)(q,{className:`size-3.5`}),` `,J(`fact.${e}`)]},e))]}):null]})}function Rn({onLogo:e,children:t,className:n}){let[r,i]=(0,Q.useState)(!1);return e?(0,$.jsx)(`div`,{onDragOver:e=>{e.dataTransfer.types.includes(`application/x-wizards-logo`)&&(e.preventDefault(),i(!0))},onDragLeave:()=>i(!1),onDrop:t=>{let n=t.dataTransfer.getData(an);i(!1),n&&(t.preventDefault(),e(n))},className:L(`-m-2 rounded-xl p-2 transition`,r&&`bg-paper-2 ring-1 ring-focus`,n),children:t}):(0,$.jsx)(`div`,{className:n,children:t})}function zn({projectId:e,data:t,readOnly:n,sections:r,rules:i,sectioned:a,ruled:o,save:s}){let c=ee(e,n),[l,u]=(0,Q.useState)(r),d=A(i),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(!1),g=(0,Q.useRef)(null),_=x({logoSections:l,logoRules:d.rules},s),v=t.files.filter(e=>e.kind===`logo`),y=new Map(v.map(e=>[e.id,e])),b=a?l:[],S=new Set(b.flatMap(e=>e.logos)),C=v.filter(e=>!S.has(e.id)),E=T(v,l)?.id,D=(e,t)=>u(n=>n.map(n=>{let r=n.logos.filter(t=>t!==e);return{...n,logos:n.id===t?[...r,e]:r}})),O=(e,t)=>u(n=>n.map(n=>n.id===e?{...n,...t}:n)),k=async(e,t)=>{let n=await c.upload(`logo`,e);for(let e of n)D(e.id,t)},te=b.length?{options:[{value:``,label:J(`project.sectionStandard`)},...b.map(e=>({value:e.id,label:e.title||J(`project.sectionUntitled`)}))],current:e=>b.find(t=>t.logos.includes(e.id))?.id??``,onMove:(e,t)=>D(e.id,t||null)}:void 0,ne=(t,n,r)=>(0,$.jsx)(on,{projectId:e,kind:`logo`,files:t,actions:c,accept:`image/*`,addLabel:r?J(`project.logoAdd`):void 0,onUpload:e=>void k(e,n),mainId:E,onMakeMain:e=>{D(e.id,null),c.order(`logo`,[e.id,...v.filter(t=>t.id!==e.id).map(e=>e.id)])},moveTo:te,onRemove:e=>{confirm(J(`project.removeConfirm`,{name:e.name}))&&(c.remove(e.id),D(e.id,null))}}),j=n?void 0:e=>t=>D(t,e),M=[{label:J(`project.logoUpload`),icon:(0,$.jsx)(it,{className:`size-4 shrink-0`}),onPick:()=>g.current?.click()},{label:J(`project.logoFromUrl`),icon:(0,$.jsx)(Jt,{className:`size-4 shrink-0`}),onPick:()=>h(!0)},...a&&l.length<w.logoSections?[{label:J(`project.logoSectionAdd`),icon:(0,$.jsx)(Ht,{className:`size-4 shrink-0`}),onPick:()=>{let e=Y();p(e),u(t=>[...t,{id:e,title:``,description:``,logos:[]}])}}]:[],...!o||d.full?[]:[{label:J(`project.ruleNew`),icon:(0,$.jsx)(Ae,{className:`size-4 shrink-0`}),onPick:()=>d.add()}]];return(0,$.jsxs)(X,{title:J(`project.logos`),hint:J(`project.logosHint`),save:_,action:n?null:(0,$.jsx)(V,{entries:M}),children:[(0,$.jsx)(`input`,{ref:g,type:`file`,accept:`image/*`,className:`sr-only`,tabIndex:-1,"aria-hidden":!0,onChange:e=>{let t=Array.from(e.target.files??[]);e.target.value=``,t.length&&k(t,null)}}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[(0,$.jsx)(Rn,{onLogo:j?.(null),children:ne(C,null,!0)}),b.map(e=>(0,$.jsx)(`div`,{className:`group/section`,children:(0,$.jsxs)(Rn,{onLogo:j?.(e.id),className:`flex flex-col gap-3`,children:[(0,$.jsx)(z,{title:e.title,description:e.description,titlePlaceholder:J(`project.logoSectionTitle`),descriptionPlaceholder:J(`project.logoSectionUse`),autoFocus:f===e.id,readOnly:n,onChange:t=>O(e.id,t),onRemove:()=>{(!e.logos.length||confirm(J(`project.logoSectionRemoveConfirm`,{name:e.title||J(`project.sectionUntitled`)})))&&u(t=>t.filter(t=>t.id!==e.id))}}),ne(e.logos.map(e=>y.get(e)).filter(e=>!!e),e.id,!0)]})},e.id)),o?(0,$.jsx)(se,{rules:d,placeholder:J(`project.logoRulePlaceholder`),readOnly:n}):null]}),c.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:c.error}):null,m?(0,$.jsx)(sn,{kind:`logo`,onClose:()=>h(!1),fetchUrl:e=>c.fromUrl(`logo`,e),onAdded:e=>{for(let t of e)D(t.id,null)}}):null]})}var Bn=e=>URL.canParse(e)?new URL(e).host:e;async function Vn(e,t){let n=ue({family:t,source:{url:e}});if(!n)return`down`;if(n.stylesheet)return await Hn(e,t);let r=await fetch(e,{mode:`cors`}).catch(()=>null);return r?r.ok?await new FontFace(`engenty-check-${Date.now()}`,await r.arrayBuffer()).load().then(()=>`ok`,()=>`noFont`):`down`:await fetch(e,{mode:`no-cors`}).then(()=>!0,()=>!1)?`cors`:`down`}function Hn(e,t){let n=new Set(document.fonts),r=document.createElement(`link`);return r.rel=`stylesheet`,r.href=e,new Promise(e=>{r.onerror=()=>e(`down`),r.onload=async()=>{let r=[...document.fonts].filter(e=>!n.has(e)&&e.family.replace(/^["']|["']$/g,``)===t),i=await Promise.allSettled(r.map(e=>e.load()));e(r.length===0?`missing`:i.some(e=>e.status===`fulfilled`)?`ok`:`cors`)},document.head.append(r)}).finally(()=>r.remove())}function Un(e,t){let n=e.source;if(!n)return J(`project.fontSourceNone`);if(`file`in n){let e=t.find(e=>e.id===n.file)?.name??``;return J(`project.fontSourceFile`,{name:e})}return J(`project.fontSourceUrl`,{host:Bn(n.url)})}function Wn({projectId:e,font:t,onSave:n,onClose:r}){let i=(a(e).data?.files??[]).filter(e=>e.mime.startsWith(`font/`)),s=ee(e),c=(0,Q.useRef)(null),[l,u]=(0,Q.useState)(t.source&&`url`in t.source?`url`:`file`),[d,f]=(0,Q.useState)(t.source&&`file`in t.source?t.source.file:``),[p,m]=(0,Q.useState)(t.source&&`url`in t.source?t.source.url:``),[h,g]=(0,Q.useState)(t.source&&`url`in t.source?{url:t.source.url,result:`ok`}:null),[_,v]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(t.license??``),[x,C]=(0,Q.useState)(!1),w=p.trim(),T=async()=>{v(!0),g({url:w,result:await Vn(w,t.family.trim())}),v(!1)},D=l===`file`?d?{file:d}:null:h?.url===w&&h.result===`ok`?{url:w}:null,O=h?.url===w?h.result:null;return(0,$.jsx)(S,{open:!0,onClose:r,title:J(`project.fontSourceTitle`,{family:t.family}),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:J(`project.fontSourceHint`)}),(0,$.jsx)(P,{value:l,options:[`file`,`url`],label:e=>J(`project.fontSourceKind.${e}`),onChange:e=>u(e)}),l===`file`?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(I,{children:J(`project.fontSourceFiles`)}),(0,$.jsx)(`div`,{className:`flex flex-col gap-1`,children:i.map(e=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":d===e.id,onClick:()=>f(e.id),className:L(`rounded-lg px-3 py-2 text-left text-[0.875rem] ring-1 transition`,d===e.id?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),children:e.name},e.id))}),(0,$.jsx)(`input`,{ref:c,type:`file`,accept:`.woff2,.woff,.ttf,.otf`,className:`hidden`,onChange:async e=>{let t=[...e.target.files??[]];e.target.value=``;let[n]=await s.upload(`asset`,t);n&&f(n.id)}}),(0,$.jsxs)(E,{variant:`ghost`,className:`mt-2`,busy:s.busy,onClick:()=>c.current?.click(),children:[(0,$.jsx)(it,{className:`size-4`}),J(`project.fontSourceUpload`)]}),s.error?(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.875rem] text-rose`,children:s.error}):null]}):(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),T()},children:[(0,$.jsx)(I,{children:J(`project.fontSourceUrlLabel`)}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(o,{value:p,inputMode:`url`,placeholder:J(`project.fontSourceUrlPlaceholder`),onChange:e=>m(e.target.value)}),(0,$.jsx)(E,{type:`submit`,variant:`ghost`,busy:_,disabled:!w.startsWith(`https://`),children:J(`project.fontSourceCheck`)})]}),O?(0,$.jsx)(`p`,{className:L(`mt-1.5 text-[0.875rem]`,O===`ok`?`text-ink-3`:`text-rose`),children:J(`project.fontCheck.${O}`,{host:Bn(w),family:t.family})}):null,O===`ok`?(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.875rem] text-ink-3`,children:J(`project.fontPrivacy`,{host:Bn(w)})}):null]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(I,{hint:J(`project.fontLicenseHint`),children:J(`project.fontLicense`)}),(0,$.jsx)(o,{value:y,maxLength:200,placeholder:J(`project.fontLicensePlaceholder`),onChange:e=>b(e.target.value)}),(0,$.jsxs)(`label`,{className:`mt-2 flex items-start gap-2 text-[0.875rem]`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 accent-ember`,checked:x,onChange:e=>C(e.target.checked)}),J(`project.fontLicenseConfirm`,{family:t.family})]})]}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[t.source?(0,$.jsx)(E,{variant:`ghost`,className:`mr-auto`,onClick:()=>{n({source:void 0,license:t.license}),r()},children:J(`project.fontSourceRemove`)}):null,(0,$.jsx)(E,{variant:`ghost`,onClick:r,children:J(`common.cancel`)}),(0,$.jsx)(E,{disabled:!(D&&x),onClick:()=>{D&&(n({source:D,license:y.trim()||void 0}),r())},children:J(`project.fontSourceSave`)})]})]})})}var Gn=new Set;function Kn(e){(0,Q.useEffect)(()=>{let t=e.trim().toLowerCase().replace(/\s+/g,`-`);if(!t||Gn.has(t))return;Gn.add(t);let n=document.createElement(`link`);n.rel=`stylesheet`,n.href=`https://fonts.bunny.net/css?family=${encodeURIComponent(t)}:${d.join(`,`)}&display=swap`,document.head.append(n)},[e])}var qn=e=>e?`"${e}", system-ui, sans-serif`:`system-ui, sans-serif`;function Jn({unit:e,label:t,...n}){return(0,$.jsxs)(`label`,{className:`inline-flex items-center gap-1 text-[0.75rem] text-ink-3`,title:t,children:[(0,$.jsx)(`input`,{type:`number`,"aria-label":t,className:`h-8 w-14 rounded-md border border-input bg-card px-1.5 text-right text-[0.8125rem] text-ink tabular-nums outline-none transition focus:border-focus focus:ring-2 focus:ring-focus-glow`,...n}),e]})}var Yn=`h-8 rounded-md border border-input bg-card px-1.5 text-[0.8125rem] text-ink outline-none transition focus:border-focus focus:ring-2 focus:ring-focus-glow`,Xn={web:`project.fontUseWeb`,documents:`project.fontUseDocuments`,print:`project.fontUsePrint`,images:`project.fontUseImages`,video:`project.fontUseVideo`};function Zn({projectId:e,font:t,first:n,readOnly:r,autoFocus:i,onChange:o,onRemove:s}){Kn(t.family);let c=a(e).data?.files??[],[l,u]=(0,Q.useState)(!1);return(0,$.jsxs)(`div`,{className:`group/font relative flex flex-col gap-2 rounded-lg bg-paper p-3 ring-1 ring-border-soft`,children:[(0,$.jsxs)(`div`,{className:`flex h-28 items-end justify-between overflow-hidden rounded-md bg-card px-4 pb-3 ring-1 ring-border-soft`,style:{fontFamily:qn(t.family)},children:[(0,$.jsx)(`span`,{className:`text-[3.5rem] text-ink leading-none`,children:`Aa`}),(0,$.jsx)(`span`,{className:`truncate pl-3 text-[0.875rem] text-ink-3`,children:`ABCDEFG abcdefg 0123456789`})]}),r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`font-medium text-[0.9375rem]`,children:t.family}),t.role?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:t.role}):null]}):(0,$.jsxs)(`div`,{children:[(0,$.jsx)(G,{value:t.family,label:J(`project.fontFamily`),placeholder:J(`project.fontFamily`),maxLength:80,autoFocus:i,onChange:e=>o({family:e}),className:`font-medium text-[0.9375rem]`}),(0,$.jsx)(G,{value:t.role,label:J(`project.fontRole`),placeholder:J(n?`project.fontRoleFirst`:`project.fontRole`),maxLength:200,onChange:e=>o({role:e}),className:`text-[0.875rem] text-ink-3`})]}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:d.map(e=>{let n=t.weights.includes(e);return(0,$.jsx)(`button`,{type:`button`,disabled:r,"aria-pressed":n,onClick:()=>o({weights:n?t.weights.filter(t=>t!==e):[...t.weights,e].sort((e,t)=>e-t)}),style:{fontFamily:qn(t.family),fontWeight:e},className:L(`h-7 rounded-full px-2.5 text-[0.8125rem] tabular-nums transition`,n?`bg-ink text-paper`:`bg-paper-2 text-ink-3 hover:text-ink`,r&&!n&&`hidden`),children:e},e)})}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[r?t.license?(0,$.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:t.license}):null:(0,$.jsx)(G,{value:t.license??``,label:J(`project.fontLicense`),placeholder:J(`project.fontLicensePlaceholder`),maxLength:200,onChange:e=>o({license:e}),className:`text-[0.8125rem] text-ink-3`}),r&&!t.uses?.length?null:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,$.jsx)(`span`,{className:`mr-1 text-[0.8125rem] text-ink-3`,children:J(`project.fontUses`)}),ne.map(e=>{let n=!!t.uses?.includes(e);return(0,$.jsxs)(`button`,{type:`button`,disabled:r,"aria-pressed":n,onClick:()=>{let r=n?(t.uses??[]).filter(t=>t!==e):ne.filter(n=>n===e||t.uses?.includes(n));o({uses:r.length?r:void 0})},className:L(`inline-flex h-7 items-center gap-1 rounded-full px-2.5 text-[0.8125rem] transition`,n?`bg-card text-ink ring-1 ring-border`:`bg-paper-2 text-ink-3 hover:text-ink`,r&&!n&&`hidden`),children:[n?(0,$.jsx)(_,{className:`size-3.5`}):null,J(Xn[e])]},e)})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-[0.8125rem] text-ink-3`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:Un(t,c)}),r||!t.family.trim()?null:(0,$.jsx)(`button`,{type:`button`,onClick:()=>u(!0),className:`text-ink underline decoration-border underline-offset-2 hover:decoration-ink`,children:J(t.source?`project.fontSourceChange`:`project.fontSourceSet`)})]}),l?(0,$.jsx)(Wn,{projectId:e,font:t,onSave:o,onClose:()=>u(!1)}):null,r?null:(0,$.jsx)(Z,{label:J(`project.remove`),onClick:s,className:`absolute top-4 right-4 size-8 bg-card opacity-0 shadow-soft transition focus:opacity-100 group-hover/font:opacity-100 coarse:opacity-100 hover:text-rose`,children:(0,$.jsx)(R,{className:`size-4`})})]})}function Qn({style:e,fonts:t,sample:n,readOnly:r,autoFocus:i,onChange:a,onRemove:o}){let s=t.find(t=>t.id===e.font)??t[0],c={fontFamily:qn(s?.family),fontWeight:e.weight,fontSize:`${Math.min(e.size,56)}px`,lineHeight:`${e.lineHeight}%`,letterSpacing:`${e.tracking/100}em`,textTransform:e.uppercase?`uppercase`:void 0};return(0,$.jsxs)(`li`,{className:`group/row flex flex-col gap-2 border-border-soft border-b py-4 first:pt-1 last:border-b-0`,children:[(0,$.jsx)(`div`,{className:`truncate text-ink`,style:c,children:n}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[r?(0,$.jsx)(`span`,{className:`font-medium text-[0.8125rem] text-ink-2 uppercase tracking-wide`,children:e.name}):(0,$.jsx)(`div`,{className:`w-40`,children:(0,$.jsx)(G,{value:e.name,label:J(`project.styleName`),placeholder:J(`project.styleName`),maxLength:60,autoFocus:i,onChange:e=>a({name:e}),className:`font-medium text-[0.8125rem] text-ink-2 uppercase tracking-wide`})}),(0,$.jsxs)(`fieldset`,{disabled:r,className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[t.length>1?(0,$.jsx)(`select`,{"aria-label":J(`project.styleFont`),value:s?.id??``,onChange:e=>a({font:e.target.value}),className:L(Yn,`max-w-40`),children:t.map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.family||J(`project.fontFamily`)},e.id))}):null,(0,$.jsx)(`select`,{"aria-label":J(`project.styleWeight`),value:e.weight,onChange:e=>a({weight:Number(e.target.value)}),className:Yn,children:[...new Set([...d,e.weight])].sort().map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))}),(0,$.jsx)(Jn,{unit:`px`,label:J(`project.styleSize`),min:6,max:400,value:e.size,onChange:e=>a({size:Number(e.target.value)||16})}),(0,$.jsx)(Jn,{unit:J(`project.styleLine`),label:J(`project.styleLineLabel`),min:50,max:300,value:e.lineHeight,onChange:e=>a({lineHeight:Number(e.target.value)||100})}),(0,$.jsx)(Jn,{unit:J(`project.styleTracking`),label:J(`project.styleTrackingLabel`),min:-20,max:50,step:.5,value:e.tracking,onChange:e=>a({tracking:Number(e.target.value)||0})}),(0,$.jsx)(`button`,{type:`button`,"aria-pressed":!!e.uppercase,title:J(`project.styleUpper`),"aria-label":J(`project.styleUpper`),onClick:()=>a({uppercase:!e.uppercase}),className:L(`grid size-8 place-items-center rounded-md transition`,e.uppercase?`bg-ink text-paper`:`text-ink-3 hover:bg-paper-2 hover:text-ink`),children:(0,$.jsx)(Bt,{className:`size-4`})})]}),r?null:(0,$.jsx)(Z,{label:J(`project.remove`),onClick:o,className:`ml-auto size-8 opacity-0 transition focus:opacity-100 group-hover/row:opacity-100 coarse:opacity-100 hover:text-rose`,children:(0,$.jsx)(R,{className:`size-4`})})]})]})}function $n({projectId:e,onAdd:t,onClose:n}){let[r,i]=(0,Q.useState)(``),[a,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)([]),m=async()=>{s(!0),l(null);try{let{fonts:t}=await F.post(`/api/studio/projects/${e}/fonts/scan`,{url:r.trim()});t.length?(d(t),p(t.slice(0,2).map(e=>e.family))):l(J(`project.fontsNoneFound`))}catch(e){l(e.message)}s(!1)};return(0,$.jsx)(S,{open:!0,onClose:n,wide:u?!0:void 0,title:J(u?`project.fontsFound`:`project.fontsFromUrl`),children:u?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:J(`project.fontsFoundHint`)}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:u.map(e=>(0,$.jsx)(er,{font:e,on:f.includes(e.family),onToggle:()=>p(t=>t.includes(e.family)?t.filter(t=>t!==e.family):[...t,e.family])},e.family))}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(E,{variant:`ghost`,onClick:()=>d(null),children:J(`run.back`)}),(0,$.jsx)(E,{disabled:!f.length,onClick:()=>{t(u.filter(e=>f.includes(e.family))),n()},children:f.length>1?J(`project.addMany`,{n:f.length}):J(`project.add`)})]})]}):(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),m()},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(I,{children:J(`project.logoUrl`)}),(0,$.jsx)(o,{autoFocus:!0,value:r,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>i(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:J(`project.fontsUrlHint`)})]}),c?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:c}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(E,{variant:`ghost`,onClick:n,children:J(`common.cancel`)}),(0,$.jsx)(E,{type:`submit`,busy:a,disabled:!r.trim(),children:J(`run.next`)})]})]})})}function er({font:e,on:t,onToggle:n}){return Kn(e.family),(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:n,className:L(`flex items-center gap-4 rounded-lg px-4 py-3 text-left ring-1 transition`,t?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),children:[(0,$.jsx)(`span`,{className:`text-[2rem] text-ink leading-none`,style:{fontFamily:qn(e.family)},children:`Aa`}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsx)(`span`,{className:`font-medium text-[0.9375rem]`,children:e.family}),(0,$.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 tabular-nums`,children:e.weights.length?e.weights.join(` · `):J(`project.fontWeightsUnknown`)})]}),t?(0,$.jsx)(`span`,{className:`grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,$.jsx)(_,{className:`size-3.5`})}):null]})}function tr({projectId:e,fonts:t,styles:n,rules:r,ruled:i,sample:a,save:o,readOnly:s}){let[c,l]=(0,Q.useState)(t),[u,d]=(0,Q.useState)(n),f=A(r),[p,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(!1),_=x({fonts:c,textStyles:u,typeRules:f.rules},o),v=(e,t=!1)=>{let n=e.map(e=>({id:Y(),family:e.family,role:``,weights:e.weights}));t&&n[0]&&m(n[0].id),l(e=>[...e,...n].slice(0,w.fonts))},y=()=>{let e=Y();m(e),d(t=>[...t,{id:e,name:``,size:16,weight:400,lineHeight:150,tracking:0}])},b=[...c.length<w.fonts?[{label:J(`project.fontNew`),icon:(0,$.jsx)(q,{className:`size-4 shrink-0`}),onPick:()=>v([{family:``,weights:[400,700]}],!0)},{label:J(`project.fontsFromUrl`),icon:(0,$.jsx)(Jt,{className:`size-4 shrink-0`}),onPick:()=>g(!0)}]:[],...u.length<w.textStyles?[{label:J(`project.styleNew`),icon:(0,$.jsx)(ht,{className:`size-4 shrink-0`}),onPick:y}]:[],...!i||f.full?[]:[{label:J(`project.ruleNew`),icon:(0,$.jsx)(Ae,{className:`size-4 shrink-0`}),onPick:()=>f.add()}]];return(0,$.jsxs)(X,{title:J(`project.typography`),hint:J(`project.typographyHint`),save:_,action:s?null:(0,$.jsx)(V,{entries:b}),children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[c.length?(0,$.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(260px,1fr))] gap-3`,children:c.map((t,n)=>(0,$.jsx)(Zn,{projectId:e,font:t,first:n===0,readOnly:s,autoFocus:p===t.id,onChange:e=>l(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>l(e=>e.filter(e=>e.id!==t.id))},t.id))}):(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:J(`project.fontsEmpty`)}),u.length?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`font-medium text-[0.9375rem]`,children:J(`project.styles`)}),s?null:(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3 leading-snug`,children:J(`project.stylesHint`)}),(0,$.jsx)(`ul`,{className:`mt-2 flex flex-col`,children:u.map(e=>(0,$.jsx)(Qn,{style:e,fonts:c,sample:a,readOnly:s,autoFocus:p===e.id,onChange:t=>d(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>d(t=>t.filter(t=>t.id!==e.id))},e.id))})]}):null,i?(0,$.jsx)(se,{rules:f,placeholder:J(`project.typeRulePlaceholder`),readOnly:s}):null]}),h?(0,$.jsx)($n,{projectId:e,onClose:()=>g(!1),onAdd:e=>v(e)}):null]})}function nr({project:e,save:t}){let[n,r]=(0,Q.useState)(e.brand.name??``),[i,a]=(0,Q.useState)(e.brand.about??``),s=x({name:n.trim(),about:i.trim()},e=>t({brand:e}));return(0,$.jsx)(X,{title:J(`project.base`),hint:J(`project.baseHint`),save:s,locked:e.readOnly,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(I,{children:J(`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:J(`project.titleHint`)})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(I,{children:J(`project.about`)}),(0,$.jsx)(ae,{minRows:4,value:i,onChange:e=>a(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:J(`project.aboutHint`)})]})]})})}function rr({project:e,group:t,children:n}){let r=j(),i=a(e.id),[o,s]=(0,Q.useState)(0),[c,l]=(0,Q.useState)(!1),u=async t=>{await F.patch(`/api/studio/projects/${e.id}`,t),await r.invalidateQueries({queryKey:[`projects`]})},d=je({mutationFn:()=>F.del(`/api/studio/projects/${e.id}`),onSuccess:()=>r.invalidateQueries({queryKey:[`projects`]})}),f=$e(),p=Qe(),m=i.data??{files:[],embeddings:!0},h=`${e.id}:${o}`,g=e.readOnly,_=t===`knowledge`,v=mt(`brandSections`),y=mt(`brandRules`),b=mt(`typography`);return at(g?{}:{title:J(_?`project.assistantTitleKnowledge`:`project.assistantTitle`),hello:J(_?`project.assistantHelloKnowledge`:`project.assistantHello`),placeholder:J(_?`project.assistantComposerKnowledge`:`project.assistantComposer`),suggestions:_?[{label:J(`assistant.suggest.knowledgeHow`)},{label:J(`assistant.suggest.knowledgeSite`),fill:!0},{label:J(`assistant.suggest.knowledgeCategories`)}]:[{label:J(`assistant.suggest.readSite`),fill:!0},{label:J(`assistant.suggest.missing`)},{label:J(`assistant.suggest.facts`)}],summary:_?void 0:[e.brand.name?`title "${e.brand.name}"`:`no title`,`${e.facts.length} facts`,`${e.brand.colors?.length??0} colours`,`${m.files.filter(e=>e.kind===`logo`).length} logos`].join(` · `),onChanged:()=>s(e=>e+1)}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[g?(0,$.jsx)(rt,{children:tt(e)}):null,t===`info`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(he,{id:`base`,children:(0,$.jsx)(nr,{project:e,save:u},`base:${h}`)}),(0,$.jsx)(he,{id:`facts`,children:(0,$.jsx)(Ln,{facts:e.facts,save:e=>u({facts:e}),readOnly:g},`facts:${h}`)}),(0,$.jsx)(he,{id:`logos`,children:(0,$.jsx)(zn,{projectId:e.id,data:m,readOnly:g,sections:e.brand.logoSections??[],rules:e.brand.logoRules??[],sectioned:v,ruled:y,save:e=>u({brand:e})},`logos:${h}`)}),(0,$.jsx)(he,{id:`colors`,children:(0,$.jsx)(Nn,{projectId:e.id,data:m,colors:e.brand.colors??[],sections:e.brand.colorSections??[],gradients:e.brand.gradients??[],patterns:e.brand.patterns??[],rules:e.brand.colorRules??[],sectioned:v,ruled:y,save:e=>u({brand:e}),readOnly:g},`colors:${h}`)}),b?(0,$.jsx)(he,{id:`typography`,children:(0,$.jsx)(tr,{projectId:e.id,fonts:e.brand.fonts??[],styles:e.brand.textStyles??[],rules:e.brand.typeRules??[],ruled:y,sample:e.brand.name||J(`project.typeSample`),save:e=>u({brand:e}),readOnly:g},`typography:${h}`)}):null,(0,$.jsx)(he,{id:`assets`,children:(0,$.jsx)(yn,{projectId:e.id,data:m,readOnly:g,sections:e.brand.assetSections??[],save:e=>u({brand:e})},`assets:${h}`)})]}):null,n,t===`info`&&f&&!g&&p?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(E,{variant:`danger`,onClick:()=>l(!0),children:J(`settings.delete`)}),(0,$.jsxs)(S,{open:c,onClose:()=>l(!1),title:J(`settings.deleteTitle`,{name:e.name}),children:[(0,$.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-2`,children:J(`settings.deleteBody`)}),d.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-rose`,children:d.error.message}):null,(0,$.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,$.jsx)(E,{variant:`ghost`,onClick:()=>l(!1),children:J(`common.cancel`)}),(0,$.jsx)(E,{variant:`danger`,busy:d.isPending,onClick:()=>d.mutate(),children:J(`common.delete`)})]})]})]}):null]})}var ir=`results-search`,ar={q:``,mode:``,days:0};function or(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 i=r.toString();return H({queryKey:[`results`,e,i],queryFn:()=>F.get(`/api/studio/projects/${e}/results${i&&`?${i}`}`),enabled:!!e,placeholderData:e=>e,refetchInterval:15e3})}function sr({data:e,wizardId:t,onWizard:n,filter:r,onFilter:i}){let[a,s]=(0,Q.useState)(r.q);return ut({icon:ye,label:J(`space.resultsSearch`),run:()=>{let e=document.getElementById(ir);e?.scrollIntoView({block:`center`,behavior:`smooth`}),e?.focus()}}),(0,Q.useEffect)(()=>{if(a===r.q)return;let e=setTimeout(()=>i({...r,q:a}),250);return()=>clearTimeout(e)},[a,r,i]),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(re,{value:t??``,onChange:e=>n(e||null),options:[{value:``,label:J(`space.resultsAllWizards`)},...e.wizards.filter(e=>e.results||e.id===t).map(e=>({value:e.id,label:`${e.title} (${e.results})`}))],className:`w-56 max-sm:w-full`}),(0,$.jsxs)(`div`,{className:`relative min-w-0 flex-1 basis-56`,children:[(0,$.jsx)(ye,{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:a,onChange:e=>s(e.target.value),id:ir,placeholder:J(`space.resultsSearch`),"aria-label":J(`space.resultsSearch`),className:`w-full pl-9`})]}),(0,$.jsx)(re,{value:r.mode,onChange:e=>i({...r,mode:e}),options:[{value:``,label:J(`space.resultsModeAll`)},{value:`live`,label:`Live`},{value:`test`,label:`Test`}],className:`w-32`}),(0,$.jsx)(re,{value:String(r.days),onChange:e=>i({...r,days:Number(e)}),options:[{value:`0`,label:J(`space.resultsAnyTime`)},{value:`1`,label:J(`space.resultsDay`)},{value:`7`,label:J(`space.resultsDays`,{n:7})},{value:`30`,label:J(`space.resultsDays`,{n:30})}],className:`w-44`})]})}function cr({data:e,wizardId:t,onWizard:n,filter:r,onFilter:i}){let[a,o]=(0,Q.useState)(null),s=t=>e.wizards.find(e=>e.id===t)?.title??``,c=new Intl.DateTimeFormat(O,{dateStyle:`medium`,timeStyle:`short`});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(X,{title:t?s(t):J(`space.resultsAll`),hint:J(`space.resultsHint`),plain:!0,children:[(0,$.jsx)(sr,{data:e,wizardId:t,onWizard:n,filter:r,onFilter:i}),e.runs.length?(0,$.jsx)(m,{className:`flex flex-col p-1.5`,children:e.runs.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>o(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?c.format(new Date(e.doneAt)):s(e.wizardId)}),(0,$.jsxs)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:[t?null:`${c.format(new Date(e.doneAt))} · `,J(`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:J(`space.resultFiles`,{n:e.assets}),children:[(0,$.jsx)(xe,{className:`size-3.5`}),e.assets]}):null,e.mode===`test`?(0,$.jsx)(v,{children:J(`run.testChip`)}):(0,$.jsxs)(v,{tone:`live`,children:[`Live v`,e.version]})]},e.id))}):(0,$.jsx)(m,{children:(0,$.jsx)(k,{children:r.q.trim()||r.mode||r.days?J(`space.resultsNone`):J(`space.resultsEmpty`)})})]}),a?(0,$.jsx)(Ue,{header:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-[0.875rem]`,children:s(a.wizardId)}),a.mode===`test`?(0,$.jsx)(v,{children:J(`run.testChip`)}):(0,$.jsxs)(v,{tone:`live`,children:[`Live v`,a.version]})]}),onClose:()=>o(null),children:(0,$.jsx)(Pt,{runId:a.id,compact:!0,studio:!0},a.id)}):null]})}function lr({project:e,save:t}){let[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(e.name),s=je({mutationFn:()=>t({name:i.trim()}),onSuccess:()=>r(!1)});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{label:J(`project.rename`),onClick:()=>{a(e.name),r(!0)},children:(0,$.jsx)(le,{className:`size-4`})}),(0,$.jsx)(S,{open:n,onClose:()=>r(!1),title:J(`project.rename`),children:(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),i.trim()&&s.mutate()},children:[(0,$.jsx)(o,{"data-autofocus":!0,value:i,maxLength:80,onChange:e=>a(e.target.value)}),s.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:s.error.message}):null,(0,$.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,$.jsx)(E,{variant:`ghost`,onClick:()=>r(!1),children:J(`common.cancel`)}),(0,$.jsx)(E,{type:`submit`,busy:s.isPending,disabled:!i.trim(),children:J(`settings.save`)})]})]})})]})}function ur({project:e}){let t=j();return(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(st,{}),e.readOnly?null:(0,$.jsx)(lr,{project:e,save:async n=>{await F.patch(`/api/studio/projects/${e.id}`,n),await t.invalidateQueries({queryKey:[`projects`]})}})]})}function dr(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=bt(),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 fr(e,t){let n=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;document.getElementById(e)?.scrollIntoView({block:`start`,behavior:t&&!n?`smooth`:`auto`})}function pr({groups:e,current:t,onPick:n}){return e.map(e=>{let r=e.sections.map(e=>(0,$.jsx)(wt,{icon:e.icon??Ee,label:e.label,selected:e.id===t,onPick:()=>n(e.id)},e.id));return e.label?(0,$.jsx)(Dt,{label:e.label,children:r},e.plugin):(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:r},`own`)})}function mr(){let{group:e}=D(),[t,n]=r(),i=oe(),a=ie(),{hash:o}=a,{project:s,loading:c}=Ze(),l=$e(),u=yt(),d=Nt(),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(null),v=dt(e)?e:void 0,y=v?void 0:u.spaceParts.find(t=>t.id===e),b=v??y?.id,x=a.state?.parts===!0,S=pt(gt(),u).map(e=>({...e,to:`/space/${e.id}`})),C={id:`results`,label:J(`space.results`),icon:ot,to:`/space/results`},w=v===`results`?C:S.find(e=>e.id===b),T=t.get(`show`),E=v===`results`?2:b?T?2:1:0,O=v===`results`?1:d?Math.min(E,1):b&&g!==b&&!x?1:0,ee=Et(O),A=Et(E),te=(0,Q.useMemo)(()=>({slot:f,narrow:d,setDetail:h}),[f,d]),ne=s?s.brand.name?.trim()||s.name:J(`nav.project`),j=mt(`typography`)?[]:[`typography`],M=y?u.spaceMenus[y.id]??[]:[],N=y?[{plugin:null,label:null,sections:M}]:v&&v!==`results`?_t(v,u,j):[],P=v?_t(v,u).filter(e=>e.plugin):[],F=dr([...N,...v===`results`?P:[]].flatMap(e=>e.sections.map(e=>e.id))),I=v===`results`&&T&&T!==`all`?T:null,[re,ae]=(0,Q.useState)(ar),se=or(v===`results`?s?.id:void 0,I,re),R=se.data?.wizards.find(e=>e.id===I)?.title,z=v===`data`&&T&&T!==`all`||v===`knowledge`&&T&&/^[ptfcvs]:/.test(T)?T:null,B=z?.startsWith(`s:`)?u.spaceSections.find(e=>e.id===z.slice(2)):void 0,V=v===`knowledge`&&z&&/^[ptf]:/.test(z)?z:null,H=qe(v===`data`?s?.id:void 0),U=Ge(v===`knowledge`?s?.id:void 0),W=Me(z?.startsWith(`v:`)?z.slice(2):``),ce=U.data?.categories.find(e=>e.id===(z?.startsWith(`c:`)?z.slice(2):W.data?.category.id)),G=v===`knowledge`?B?B.label():z?.startsWith(`v:`)?W.data&&`${W.data.category.name}: ${W.data.value}`:z?.startsWith(`c:`)?ce?.name:U.data?.items.find(e=>e.key===z)?.title:H.data?We(H.data).flatMap(e=>e.items).find(e=>e.key===z)?.title:void 0;St([...v===`results`?[]:[{label:J(`nav.project`),to:`/space`}],...w?[{label:w.label,to:`/space/${w.id}`}]:[],...w&&(m??R??G)?[{label:m??R??G}]:[]]);let le={p:`page`,t:`table`,f:`file`,c:`category`,v:`category value`,s:`plugin section`};at({...v===`data`||v===`results`?{compact:!0}:{},...v===`data`?{suggestions:[{label:J(`assistant.suggest.dataWhat`)},{label:J(`assistant.suggest.dataWho`)},{label:J(`assistant.suggest.dataEdit`)}]}:v===`results`?{suggestions:[{label:J(`assistant.suggest.resultsFailed`)},{label:J(`assistant.suggest.resultsCost`)},{label:J(`assistant.suggest.resultsShare`)}]}:{},...z&&G?{open:{kind:le[z[0]]??`item`,id:z.slice(2),label:G}}:I&&R?{open:{kind:`wizard`,id:I,label:R}}:{}});let ue=v===`results`||v===`data`||z?o.slice(1):T||o.slice(1),de=(0,Q.useRef)(``);if((0,Q.useEffect)(()=>{let e=`${b}#${ue}`;ue&&de.current!==e&&document.getElementById(ue)&&(de.current=e,requestAnimationFrame(()=>fr(ue,!1)))},[b,ue,s?.id,u.spaceSections,M.length]),!b){let t=o.slice(1),n=t?lt(t,u):null;if(n===`knowledge`&&u.spaceSections.some(e=>e.id===t))return(0,$.jsx)(_e,{to:`/space/knowledge?show=s:${t}`,replace:!0});if(n)return(0,$.jsx)(_e,{to:d?`/space/${n}?show=${t}`:{pathname:`/space/${n}`,hash:t},replace:!0});if((t||e)&&u.status!==`ready`)return null;if(e!==void 0||!d)return(0,$.jsx)(_e,{to:`/space/info`,replace:!0,state:{parts:!0}})}if(v===`knowledge`&&!T&&u.spaceSections.some(e=>e.id===o.slice(1)))return(0,$.jsx)(_e,{to:`/space/knowledge?show=s:${o.slice(1)}`,replace:!0});let fe=e=>{if(d){i({search:`?show=${e}`});return}de.current=`${b}#${e}`,fr(e,!0),i({search:``,hash:e},{replace:!0})},K=e=>d?n({show:e}):n(e===`all`?{}:{show:e},{replace:!0}),pe=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)(he,{id:e.id,children:(0,$.jsx)(X,{title:e.label(),hint:e.hint?.(),plain:!0,children:(0,$.jsx)(vt,{of:e,children:(0,$.jsx)(e.component,{})})})},e.serial)),me=d?void 0:F,q=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ot,{title:ne,open:O===1?w??null:null,onBack:v===`results`?void 0:()=>d?i(`/space`):_(b??null),root:{icon:Ct,label:J(`nav.project`),backLabel:J(`nav.wizards`),onBack:()=>i(`/`)}}),(0,$.jsx)(`div`,{className:L(Tt(ee)),children:O===0?(0,$.jsx)(At,{entries:S,current:d?void 0:w,onPick:()=>_(null)}):(0,$.jsx)(`div`,{ref:p})},O)]});return(0,$.jsx)(kt.Provider,{value:te,children:(0,$.jsx)(`div`,{className:`animate-rise`,children:(0,$.jsxs)(`div`,{className:L(`grid gap-6`,v!==`results`&&`md:grid-cols-[10.5rem_minmax(0,1fr)] md:gap-5 lg:grid-cols-[15rem_minmax(0,1fr)] lg:gap-10`),children:[v===`results`?null:(0,$.jsx)(`aside`,{className:L(`min-w-0 md:sticky md:top-6 md:self-start`,d&&E===2&&`hidden`,d&&A===`back`&&Tt(`back`)),children:q}),b?(0,$.jsxs)(`div`,{className:L(`min-w-0`,d&&E<2&&`hidden`,d&&A===`deeper`&&Tt(`deeper`)),children:[d&&v!==`results`?(0,$.jsx)(`div`,{className:`mb-3`,children:(0,$.jsx)(Mt,{label:w?.label??ne,onBack:()=>i(`/space/${b}`)})}):null,l&&s?(0,$.jsx)(`div`,{className:`mb-6`,children:(0,$.jsx)(ur,{project:s})}):null,v===`data`?(0,$.jsxs)(jt,{children:[(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,$.jsx)(wt,{icon:Kt,label:J(`data.all`),selected:!d&&!z,onPick:()=>K(`all`)})}),H.data?We(H.data).map(e=>(0,$.jsx)(Dt,{label:e.label,children:e.items.map(e=>(0,$.jsx)(wt,{icon:Be[e.kind],label:e.title,selected:!d&&e.key===z,onPick:()=>K(e.key)},e.key))},e.key)):null,(0,$.jsx)(pr,{groups:P,current:me,onPick:fe})]}):v===`knowledge`?(0,$.jsxs)(jt,{children:[(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,$.jsx)(wt,{icon:Kt,label:J(`know.all`),selected:!(d||z),onPick:()=>K(`all`)})}),U.data?.categories.length?(0,$.jsx)(Dt,{label:J(`know.categories`),children:U.data.categories.map(e=>(0,$.jsx)(wt,{icon:He[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&&(z===`c:${e.id}`||W.data?.category.id===e.id),onPick:()=>K(`c:${e.id}`)},e.id))}):null,(0,$.jsx)(pr,{groups:P,current:d?void 0:B?.id,onPick:e=>K(`s:${e}`)})]}):(0,$.jsx)(jt,{children:(0,$.jsx)(pr,{groups:N,current:me,onPick:fe})}),s&&(v===`info`||v===`knowledge`)?(0,$.jsxs)(rr,{project:s,group:v,children:[v===`knowledge`?V?V.startsWith(`p:`)?(0,$.jsx)(Fe,{pageId:V.slice(2),onGone:()=>K(`all`),onOpen:K},V):V.startsWith(`t:`)?(0,$.jsx)(Ke,{tableId:V.slice(2),onGone:()=>K(`all`)},V):(0,$.jsx)(fn,{projectId:s.id,fileId:V.slice(2),readOnly:s.readOnly,onGone:()=>K(`all`)},V):U.data?B?(0,$.jsx)(X,{title:B.label(),hint:B.hint?.(),plain:!0,children:(0,$.jsx)(vt,{of:B,children:(0,$.jsx)(B.component,{})})},z):z?.startsWith(`c:`)?ce?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(ze,{projectId:s.id,category:ce,readOnly:s.readOnly,onOpen:K,onGone:()=>K(`all`)}),ce.type===`choice`?null:(0,$.jsx)(Ve,{projectId:s.id,category:ce,categories:U.data.categories,onOpen:K})]},z):null:z?.startsWith(`v:`)?W.data?(0,$.jsx)(Re,{value:W.data,readOnly:s.readOnly,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[W.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:W.data.items.map(e=>(0,$.jsx)(Je,{item:e,categories:U.data.categories.filter(e=>e.id!==W.data?.category.id),onOpen:K},e.key))}):null,W.data.rows.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>K(`t:${e.tableId}`),className:`px-1 text-left text-[0.8125rem] text-ink-3 hover:text-ink`,children:J(`know.tocRows`,{n:e.count,table:e.title})},e.tableId))]})},z):null:(0,$.jsx)(he,{id:`documents`,children:(0,$.jsx)(Le,{projectId:s.id,data:U.data,readOnly:s.readOnly,onOpen:K})}):null:null,v===`info`?pe(P):null]},s.id):null,s&&y?(0,$.jsx)(vt,{of:y,children:(0,$.jsx)(ct,{part:y.id,children:(0,$.jsx)(y.component,{})},s.id)}):null,s&&v===`data`?(0,$.jsx)(`div`,{className:`flex flex-col gap-9 pb-20`,children:z?.startsWith(`t:`)?(0,$.jsx)(Ke,{tableId:z.slice(2),onGone:()=>K(`all`)},z):z?.startsWith(`p:`)?(0,$.jsx)(Fe,{pageId:z.slice(2),onGone:()=>K(`all`)},z):(0,$.jsxs)($.Fragment,{children:[H.data?(0,$.jsx)(Ne,{projectId:s.id,data:H.data,readOnly:s.readOnly,onOpen:K}):null,pe(P)]})}):null,s&&v===`results`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[se.data?(0,$.jsx)(cr,{data:se.data,wizardId:I,onWizard:e=>K(e??`all`),filter:re,onFilter:ae}):null,se.isError?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:se.error.message}):null,pe(P)]}):null,s||c?null:(0,$.jsx)(k,{children:J(`settings.noProject`)})]}):null]})})})}export{mr as ProjectPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{Br as r,G as i,Gt as a,Nn as o,Ot as s,Pt as c,Qr as l,Ur as u,V as d,X as f,Xt as p,Z as m,Zr as h,an as g,ei as _,nr as v,nt as ee,qr as te,rn as y,tn as b,tt as x,zt as S}from"./ui-DRYauuxF.js";import{_ as C,d as w,f as ne,g as T,h as E,m as D,n as re,p as O,v as k,y as A}from"./theme-DjpqxoRe.js";import{O as ie,S as j,b as M,x as N}from"./session-DekDyd9S.js";import{U as P}from"./index-qnpoZzuw.js";import{t as ae}from"./RunnerView-DcduYZly.js";var F={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`}]]};F.node;var oe=u(F),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 se=u(I),L=e(t(),1);function ce(){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 R=ce(),le=R?new URLSearchParams(window.location.search).get(`page`):null,z=new URLSearchParams(window.location.search).get(`theme`),B=z?`?theme=${encodeURIComponent(z)}`:``,V=(e,t={})=>window.parent.postMessage({type:`engenty-wizard:${e}`,...t},`*`),ue=()=>V(`close`);function de(e){(0,L.useEffect)(()=>{if(R===`inline`&&!e){let e=document.documentElement;document.getElementById(`root`)?.style.setProperty(`min-height`,`0`),e.style.overflow=`hidden`;let t=new ResizeObserver(()=>V(`height`,{height:Math.ceil(e.getBoundingClientRect().height)}));return t.observe(e),()=>t.disconnect()}if(R===`modal`||R===`popout`){let e=e=>{e.key===`Escape`&&!document.querySelector(`dialog[open]`)&&V(`close`)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}},[e])}var H=e(n(),1),U=`wizards.runner.translate`,W=new Set;function fe(){try{return localStorage.getItem(U)===`on`}catch{return!1}}function pe(e){try{localStorage.setItem(U,e?`on`:`off`)}catch{}for(let e of W)e()}function me(){return(0,L.useSyncExternalStore)(e=>(W.add(e),()=>W.delete(e)),fe)}function he(e){let t=me(),[n]=(0,L.useState)(()=>g()),r=e?.lang??`en`,i=e?.translatable&&n&&n!==r?n:null,a=i&&t?i:r,s=e?.token,c=_({queryKey:[`public-translation`,s,a],enabled:!!(s&&a!==r),queryFn:()=>d.post(`/api/public/wizards/${s}/translation${B}`,{lang:a}),staleTime:1/0,retry:!1}),l=_({queryKey:[`public-texts`,s,a],enabled:!(!s||o(a)),queryFn:()=>d.get(`/api/public/wizards/${s}/texts/${a}`),staleTime:1/0,retry:!1}),u=!o(a),f=a===r||c.data&&(!u||l.data),p=a!==r&&(c.isError||u&&l.isError),m=f&&!p?a:r,h=(0,L.useMemo)(()=>!o(m)&&l.data?.lang===m?{lang:l.data.lang,runner:l.data.runner,notes:l.data.notes}:null,[m,l.data]);if((0,L.useEffect)(()=>{e&&b(m,h)},[e,m,h]),(0,L.useEffect)(()=>()=>b(null),[]),!e)return null;let v=m!==r&&c.data?c.data:null;return{own:r,other:i,shown:m,wizard:v??e,translating:a!==r&&!f&&!p,failed:!!p,translated:!!v,machine:v?.translation?.machine??!1,pick:e=>pe(e!==r)}}function G({page:e,tone:t=`ground`}){if(!e?.other)return null;let n=e.translating?e.other:e.shown;return(0,H.jsx)(P,{langs:[e.own,e.other],value:n,onPick:e.pick,tone:t})}function K({page:e,small:t}){if(!e)return null;let n=t?`truncate text-[0.75rem]`:`text-[0.8125rem]`;return e.failed?(0,H.jsx)(`p`,{className:p(`text-ink-3`,n),children:y(`translation.failed`)}):e.translated?(0,H.jsxs)(`p`,{className:p(`text-ink-3`,n),children:[e.machine?(0,H.jsxs)(H.Fragment,{children:[y(`translation.machine`),` · `]}):null,(0,H.jsx)(`button`,{type:`button`,className:`underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,onClick:()=>e.pick(e.own),children:y(`translation.showOriginal`)})]}):null}function ge(e,t){let n=(0,L.useRef)(null),r=t&&!t.translating?t.translated?t.shown:null:void 0;(0,L.useEffect)(()=>{if(!e||r===void 0)return;let t=`${e}:${r}`;n.current!==t&&(n.current=t,d.post(`/api/runs/${e}/lang`,{lang:r}).catch(()=>void 0))},[e,r])}function _e(e,t){(0,L.useEffect)(()=>{if(!e||!t)return;let n=f(`/api/public/wizards/${e}`),r=[{rel:`manifest`,href:`${n}/manifest.webmanifest`},{rel:`apple-touch-icon`,href:`${n}/icons/apple-touch-icon.png`},{rel:`icon`,href:`${n}/icons/favicon.png`,type:`image/png`}].flatMap(({rel:e,href:t,type:n})=>{let r=document.querySelector(`link[rel="${e}"]`);if(!r)return[];let i={href:r.getAttribute(`href`),type:r.getAttribute(`type`)};return r.setAttribute(`href`,t),n&&r.setAttribute(`type`,n),[{link:r,before:i}]}),i=document.createElement(`meta`);return i.name=`apple-mobile-web-app-title`,i.content=t,document.head.appendChild(i),()=>{for(let{link:e,before:t}of r)for(let[n,r]of Object.entries(t))r===null?e.removeAttribute(n):e.setAttribute(n,r);i.remove()}},[e,t])}var q=/iPhone|iPad|iPod/.test(navigator.userAgent)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1,J=q||/Android/.test(navigator.userAgent);function ve(){let[e,t]=(0,L.useState)(()=>window.wizardInstall??null),[n,r]=(0,L.useState)(!1);if((0,L.useEffect)(()=>{let e=()=>t(window.wizardInstall??null);return window.addEventListener(`wizard-install`,e),()=>window.removeEventListener(`wizard-install`,e)},[]),window.matchMedia(`(display-mode: standalone)`).matches||navigator.standalone===!0||J&&!e&&!q)return null;let i=/Mac/.test(navigator.platform),a=y(J?`install.ios`:i?`install.bookmark.mac`:`install.bookmark.pc`);return(0,H.jsxs)(`div`,{className:`mt-6 flex flex-col items-center gap-2 text-[0.8125rem] text-ink-3`,children:[(0,H.jsxs)(`button`,{type:`button`,onClick:()=>{J&&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:[J?(0,H.jsx)(se,{className:`size-4`}):(0,H.jsx)(oe,{className:`size-4`}),y(J?`install.add`:`install.bookmark`)]}),n?(0,H.jsx)(`p`,{className:`max-w-xs leading-relaxed`,children:a}):null]})}function Y({brand:e,toggle:t=!0,start:n}){return(0,H.jsx)(`header`,{className:`safe-top`,children:(0,H.jsxs)(`div`,{className:`relative flex h-14 items-center justify-center px-5`,children:[n?(0,H.jsx)(`div`,{className:`absolute left-3`,children:n}):null,e.logoUrl?(0,H.jsx)(`img`,{src:f(e.logoUrl),alt:e.name,className:`h-7 max-w-[160px] object-contain`}):e.name?(0,H.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,H.jsx)(`div`,{className:`absolute right-3`,children:(0,H.jsx)(j,{})}):null]})})}function X({siteKey:e,onToken:t}){let n=(0,L.useRef)(null);return(0,L.useEffect)(()=>{let r=()=>{n.current&&window.turnstile&&!n.current.childElementCount&&window.turnstile.render(n.current,{sitekey:e,callback:t,appearance:`interaction-only`})};if(window.turnstile){r();return}let i=document.createElement(`script`);i.src=`https://challenges.cloudflare.com/turnstile/v0/api.js`,i.async=!0,i.onload=r,document.head.appendChild(i)},[e,t]),(0,H.jsx)(`div`,{ref:n,className:`mt-4 flex justify-center`})}function ye({token:e}){return!/iPhone|iPad|iPod|Android/.test(navigator.userAgent)||m||R?null:(0,H.jsxs)(`a`,{href:x(`${window.location.origin}${i}/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,H.jsx)(A,{className:`size-4`}),` `,y(`install.app`)]})}var Z=e=>`wz.run.${e}`,Q=m&&new URLSearchParams(window.location.search).get(`start`)===`1`,$=R===`inline`?`min-h-80`:`min-h-dvh`;function be(e,t,n){let r=h(),[i,a]=(0,L.useState)(!1),[o,s]=(0,L.useState)(null),[c,l]=(0,L.useState)(null),u=(()=>{try{return localStorage.getItem(Z(e.token))}catch{return null}})();return{busy:i,error:o,captcha:c,setCaptcha:l,start:async()=>{a(!0),s(null);try{let{runId:i}=await d.post(`/api/public/wizards/${e.token}/runs`,{turnstileToken:c??void 0,embedded:R!==null,origin:le??void 0,lang:n??void 0});try{localStorage.setItem(Z(e.token),i)}catch{}r(`${t}/${i}`,{replace:Q})}catch(e){s(e.message),a(!1)}},resume:u?()=>r(`${t}/${u}`):null}}function xe({wizard:e,page:t}){let{busy:n,error:i,captcha:o,setCaptcha:s,start:l,resume:u}=be(e,`/w/${e.token}`,t?.translated?t.shown:null),d=Q&&e.available&&!e.turnstileSiteKey,f=(0,L.useRef)(!1);return(0,L.useEffect)(()=>{d&&!f.current&&(f.current=!0,l())},[d]),d&&!i?(0,H.jsx)(`div`,{className:`flex min-h-[60dvh] items-center justify-center text-ink-4`,children:(0,H.jsx)(a,{})}):(0,H.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,H.jsx)(N,{kind:e.avatar,costume:e.costume,size:190,fluffy:!0}),(0,H.jsx)(`h1`,{className:`wizard-title 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,H.jsx)(`p`,{className:`mt-3 text-[1rem] text-ink-2 leading-relaxed`,children:e.description}):null,(0,H.jsx)(`div`,{className:`mt-3`,children:(0,H.jsx)(K,{page:t})}),e.available?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(c,{size:`lg`,className:`mt-10 min-w-48`,busy:n,disabled:!!e.turnstileSiteKey&&!o,onClick:l,children:[y(`run.start`),` `,(0,H.jsx)(r,{className:`size-4`})]}),e.turnstileSiteKey?(0,H.jsx)(X,{siteKey:e.turnstileSiteKey,onToken:s}):null,u?(0,H.jsx)(`button`,{type:`button`,onClick:u,className:`mt-4 text-[0.875rem] text-ink-3 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:y(`run.resume`)}):null,(0,H.jsx)(Se,{wizard:e,current:`steps`}),R||m?null:(0,H.jsx)(ve,{}),(0,H.jsx)(ye,{token:e.token})]}):(0,H.jsx)(`p`,{className:`mt-10 rounded-xl bg-paper-2 px-5 py-4 text-[0.9375rem] text-ink-2`,children:e.unavailableReason??y(`run.unavailable`)}),i?(0,H.jsx)(`p`,{className:`mt-4 text-[0.875rem] text-rose`,children:i}):null]})}function Se({wizard:e,current:t}){let n=e.runners.filter(e=>e.id!==t&&e.kind===`page`&&e.url);return n.length?(0,H.jsx)(`p`,{className:`mt-4 flex flex-wrap justify-center gap-x-4 text-[0.875rem] text-ink-3`,children:n.map(e=>(0,H.jsx)(`a`,{href:e.url??void 0,className:`underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:y(`run.orAs`,{label:e.label})},e.id))}):null}function Ce({wizard:e,page:t}){let n=k();return(0,H.jsx)(`header`,{className:`safe-top shrink-0 border-border-soft border-b`,children:(0,H.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,H.jsx)(`span`,{className:p(n?.speaking&&`animate-breathe`),children:(0,H.jsx)(N,{kind:e.avatar,costume:e.costume,size:38})}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`div`,{className:`truncate font-display font-semibold text-[1rem] leading-tight tracking-tight`,children:e.title}),e.brand.name?(0,H.jsx)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:e.brand.name}):null,(0,H.jsx)(K,{page:t,small:!0})]}),e.brand.logoUrl&&R!==`popout`?(0,H.jsx)(`img`,{src:f(e.brand.logoUrl),alt:e.brand.name,className:`h-6 max-w-[120px] object-contain max-sm:hidden`}):null,(0,H.jsx)(G,{page:t,tone:`surface`}),R?null:(0,H.jsx)(j,{}),R===`popout`?(0,H.jsx)(S,{label:y(`common.close`),onClick:ue,children:(0,H.jsx)(v,{className:`size-5`})}):null]})})}function we({door:e,wizard:t,page:n,header:i,footer:a}){let{busy:o,error:s,captcha:c,setCaptcha:l,start:u,resume:d}=be(t,`/w/${t.token}/${e}`,n?.translated?n.shown:null),f=[{key:`hello`,who:`bot`,node:t.description||t.title}];return e!==`chat`&&f.push({key:e,who:`bot`,node:y(e===`video`?`video.hint`:`talk.joinHint`)}),t.available||f.push({key:`unavailable`,who:`bot`,node:t.unavailableReason??y(`run.unavailable`)}),s&&f.push({key:`error`,who:`bot`,node:s,tone:`error`}),t.available&&f.push(C(`start`,(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(E,{primary:!0,busy:o,disabled:!!t.turnstileSiteKey&&!c,onClick:()=>void u(),children:[y(`run.start`),` `,(0,H.jsx)(r,{className:`size-4`})]}),d?(0,H.jsx)(E,{onClick:d,children:y(`run.resume`)}):null,t.turnstileSiteKey?(0,H.jsx)(X,{siteKey:t.turnstileSiteKey,onToken:l}):null]}))),(0,H.jsxs)(O,{header:i,footer:a,children:[(0,H.jsx)(T,{avatar:t.avatar,costume:t.costume,lines:f}),(0,H.jsx)(D,{})]})}function Te({className:e}){return(0,H.jsx)(`footer`,{className:p(`text-center text-ink-4`,e),children:(0,H.jsx)(`a`,{href:`${i}/`,target:R?`_blank`:void 0,rel:`noreferrer`,className:`inline-block hover:text-ink-2`,children:y(`run.madeWith`).replace(`engenty wizards`,M.name)})})}function Ee({chat:e=!1,steps:t=!1,talk:n=!1,video:r=!1}){let{token:o,runId:u}=l(),f=h(),g=_({queryKey:[`public`,o,B],queryFn:()=>d.get(`/api/public/wizards/${o}${B}`),retry:(e,t)=>s(t)&&e<3}),v=g.data?.runners??[],b=!g.data||v.some(e=>e.id===`talk`),x=!g.data||v.some(e=>e.id===`video`),S=!g.data||v.some(e=>e.id===`chat`)||n&&b||r&&x,C=v[0]?.id,T=e||R===`popout`||!t&&!u&&S&&(C===`chat`||C===`talk`||C===`video`),E=r&&x||!t&&!e&&!n&&C===`video`,D=!E&&(n&&b||!t&&!e&&C===`talk`),O=E?`video`:D?`talk`:`chat`,k=he(g.data);ge(u,k),re(g.data?.brand.theme),ie(g.data?.avatar),_e(o,g.data?.title),de(T);let A=k?.wizard.title??g.data?.title;if((0,L.useEffect)(()=>{A&&(document.title=A)},[A]),(0,L.useEffect)(()=>{o&&u&&ee(`run`,{token:o,runId:u})},[o,u]),g.isLoading)return(0,H.jsx)(`div`,{className:p(`flex items-center justify-center text-ink-4`,$),children:(0,H.jsx)(a,{})});if(e&&g.data&&!S||n&&g.data&&!b||r&&g.data&&!x)return(0,H.jsx)(te,{to:`/w/${o}`,replace:!0});if(!g.data){let e=s(g.error);return(0,H.jsxs)(`div`,{className:p(`flex flex-col items-center justify-center gap-4 px-6 text-center`,$),children:[(0,H.jsx)(N,{kind:`pebble`,size:80}),(0,H.jsx)(`p`,{className:`max-w-xs text-ink-3`,children:y(e?`common.offline`:`run.notFound`)}),e?(0,H.jsx)(c,{variant:`secondary`,onClick:()=>void g.refetch(),children:y(`common.retry`)}):null]})}let j=k?.wizard??g.data,P=k?.translating?(0,H.jsxs)(`div`,{className:p(`flex flex-col items-center justify-center gap-3 text-ink-3`,$),children:[(0,H.jsx)(a,{}),(0,H.jsx)(`p`,{className:`text-[0.875rem]`,children:y(`translation.working`)})]}):null;if(T){let e=(0,H.jsx)(Ce,{wizard:j,page:k}),t=m?(0,H.jsx)(`div`,{className:`safe-bottom`}):(0,H.jsx)(Te,{className:`pb-[max(0.375rem,env(safe-area-inset-bottom))] text-[0.6875rem]`});return(0,H.jsxs)(`div`,{className:`wizard-page flex h-dvh flex-col`,children:[(0,H.jsx)(w,{effects:g.data.brand.theme.effects}),P??(u?(0,H.jsx)(ne,{runId:u,talk:D,call:E?`video`:D?`audio`:!1,onRestart:()=>f(`/w/${o}/${O}`),header:E||D?void 0:e,footer:t}):(0,H.jsx)(we,{wizard:j,page:k,header:e,footer:t,door:O}))]})}return(0,H.jsxs)(`div`,{className:p(`wizard-page flex flex-col`,$),children:[(0,H.jsx)(w,{effects:g.data.brand.theme.effects}),R===`inline`||m?null:(0,H.jsx)(Y,{brand:g.data.brand,toggle:!R,start:(0,H.jsx)(G,{page:k})}),R===`inline`||m?(0,H.jsx)(`div`,{className:`flex justify-end px-3 pt-2`,children:(0,H.jsx)(G,{page:k,tone:`surface`})}):null,u&&(k?.translated||k?.failed)?(0,H.jsx)(`div`,{className:`flex justify-center px-5`,children:(0,H.jsx)(K,{page:k})}):null,(0,H.jsx)(`div`,{className:`flex-1`,children:P??(u?(0,H.jsx)(ae,{runId:u,onRestart:()=>f(`/w/${o}`)}):(0,H.jsx)(xe,{wizard:j,page:k}))}),m?(0,H.jsx)(`div`,{className:`safe-bottom`}):(0,H.jsx)(`footer`,{className:`safe-bottom pt-6 text-center text-[0.75rem] text-ink-4`,children:(0,H.jsx)(`a`,{href:`${i}/`,target:R?`_blank`:void 0,rel:`noreferrer`,className:`inline-block py-3.5 hover:text-ink-2`,children:y(`run.madeWith`).replace(`engenty wizards`,M.name)})})]})}export{Y as BrandHeader,Ee as PublicRunner};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./jsx-runtime-BNakU3Ej.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./jsx-runtime-BNakU3Ej.js";import{Ur as n,rn as r}from"./ui-DRYauuxF.js";import{bt as i}from"./index-qnpoZzuw.js";var a={name:`text-align-start`,size:24,node:[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M17 19H3`,key:`z6ezky`}]],aliases:[`text`,`align-left`]};a.node;var o=n(a),s=e(t(),1);function c(e){return r(e.origin===`local`?`readonly.project`:`readonly.server`)}function l({children:e}){return(0,s.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl bg-amber-tint px-4 py-3 font-medium text-[0.875rem] text-ink leading-relaxed`,children:[(0,s.jsx)(i,{className:`mt-0.5 size-4 shrink-0 text-amber`}),(0,s.jsx)(`p`,{className:`min-w-0`,children:e})]})}export{c as n,o as r,l as t};
|