wizards 0.4.2 → 0.4.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/media/conversation.js +7 -1
- package/apps/web/dist/assets/{AboutDialog-CH1rQdia.js → AboutDialog-DWaBKvI6.js} +1 -1
- package/apps/web/dist/assets/{ChangelogDialog-78MQLHfA.js → ChangelogDialog-BcM1gXPM.js} +1 -1
- package/apps/web/dist/assets/{ChatView-DLJfy69U.js → ChatView-D0RRIl15.js} +2 -2
- package/apps/web/dist/assets/{EditorPage-BYrZokVk.js → EditorPage-DrJ6e_2q.js} +1 -1
- package/apps/web/dist/assets/{FlowPreview-xIWPdOCV.js → FlowPreview-S1s1yRaP.js} +1 -1
- package/apps/web/dist/assets/{Harness-CsDhNLSW.js → Harness-DILx5Edb.js} +1 -1
- package/apps/web/dist/assets/{NewWizardChannels-JB3V6DCL.js → NewWizardChannels-CEILDADp.js} +1 -1
- package/apps/web/dist/assets/{NewWizardPage-Bkh-hjSe.js → NewWizardPage-DxOtK2E-.js} +1 -1
- package/apps/web/dist/assets/{OnboardingPage-Diw1ILjC.js → OnboardingPage-xoGrKIJ-.js} +1 -1
- package/apps/web/dist/assets/{ProjectPage-FgoZDzPI.js → ProjectPage-6E5z4nZA.js} +1 -1
- package/apps/web/dist/assets/{PublicRunner-ClT6B7t5.js → PublicRunner-Cab2jUy6.js} +1 -1
- package/apps/web/dist/assets/{RunDrawer-DAwTEyjM.js → RunDrawer-B3FNYpgZ.js} +1 -1
- package/apps/web/dist/assets/{RunnerView-B_tJroFM.js → RunnerView-D6sGVnRy.js} +1 -1
- package/apps/web/dist/assets/{SettingsPage-BsMN-XQs.js → SettingsPage-DHtIqmOJ.js} +1 -1
- package/apps/web/dist/assets/{SetupPage-C7FuIpSt.js → SetupPage-Cn9iQbJx.js} +1 -1
- package/apps/web/dist/assets/{SharePage-CbFe83L9.js → SharePage-CMr72PeU.js} +1 -1
- package/apps/web/dist/assets/changelog-DfmWTlav.js +1 -0
- package/apps/web/dist/assets/{esm-BhIeKBJY.js → esm-BPfTI3lL.js} +1 -1
- package/apps/web/dist/assets/index-B-D8UvL9.js +14 -0
- package/apps/web/dist/assets/{settings-menu-C5Y8SOhG.js → settings-menu-BJm0CwOj.js} +1 -1
- package/apps/web/dist/index.html +1 -1
- package/package.json +1 -1
- package/apps/web/dist/assets/changelog-mYclku73.js +0 -1
- package/apps/web/dist/assets/index-fflYi8P1.js +0 -14
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$n as r,$t as i,A as a,An as o,Bn as s,Bt as c,C as l,D as u,E as d,En as f,Er as p,F as m,Gt as h,Ht as g,I as _,Jn as v,Kt as y,L as b,M as x,N as S,Nn as C,O as w,On as T,P as E,Qn as D,Qt as O,R as k,Rn as A,S as ee,T as j,Tn as te,Ut as ne,Vt as M,Wn as N,Wt as P,Xt as re,Yt as F,Zn as ie,Zt as ae,_ as oe,_n as I,an as L,b as R,d as z,en as B,er as se,f as V,fn as H,g as U,h as W,hn as G,j as K,jn as ce,k as le,kn as ue,ln as q,m as J,p as Y,pn as de,rn as fe,tn as X,tr as pe,tt as me,u as he,v as ge,vn as _e,w as ve,x as ye,xn as be,y as xe,z as Se,zt as Z}from"./ui-DTuixH4y.js";import{_ as Ce,a as we,b as Te,c as Ee,d as De,f as Oe,g as ke,h as Ae,i as je,l as Me,m as Ne,n as Pe,o as Fe,p as Ie,s as Le,u as Re,v as ze,x as Be,y as Ve}from"./RunDrawer-DAwTEyjM.js";import{t as He}from"./phone-BFD815nc.js";import{n as Ue,r as We,t as Ge}from"./ReadOnly-DQPHmvS0.js";import{t as Ke}from"./upload-BEf5-d6X.js";import{Bt as qe,Et as Je,Ft as Ye,Jt as Xe,Pt as Ze,Q as Qe,St as $e,Tt as et,U as tt,_t as nt,at as rt,b as it,bt as at,c as ot,d as st,f as ct,h as lt,it as ut,kt as dt,m as ft,p as pt,rt as mt,s as ht,u as gt,v as _t,y as vt}from"./index-fflYi8P1.js";import{a as yt,c as bt,f as xt,i as St,n as Ct,o as wt,r as Tt,s as Et,t as Dt,u as Ot}from"./settings-menu-C5Y8SOhG.js";import{t as kt}from"./RunnerView-B_tJroFM.js";var At={name:`blend`,size:24,node:[[`circle`,{cx:`15`,cy:`9`,r:`7`,key:`1i12rt`}],[`circle`,{cx:`9`,cy:`15`,r:`7`,key:`19bs8k`}]]};At.node;var jt=N(At),Mt={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`}]]};Mt.node;var Nt=N(Mt),Pt={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`}]]};Pt.node;var Ft=N(Pt),It={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`}]]};It.node;var Lt=N(It),Rt={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`]};Rt.node;var zt=N(Rt),Bt={name:`layers`,size:24,node:[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]],aliases:[`layers-3`]};Bt.node;var Vt=N(Bt),Ht={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`}]]};Ht.node;var Ut=N(Ht),Wt={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`}]]};Wt.node;var Gt=N(Wt),Kt={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`}]]};Kt.node;var qt=N(Kt),Jt={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`}]]};Jt.node;var Yt=N(Jt),Q=e(t(),1),$=e(n(),1),Xt={backgroundImage:`repeating-conic-gradient(#c9c9c9 0% 25%, #dedede 0% 50%)`,backgroundSize:`16px 16px`};function Zt({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:L(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 Qt(e,t){confirm(L(`project.removeConfirm`,{name:e.name}))&&t.remove(e.id)}function $t({projectId:e,file:t,small:n}){let r=E(e,t.id);if(t.mime.startsWith(`image/`))return(0,$.jsx)(`img`,{src:r,alt:``,loading:`lazy`,className:X(`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)(en,{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)(Yt,{className:i}):t.mime===`application/pdf`?(0,$.jsx)(ue,{className:i}):t.mime===`application/json`?(0,$.jsx)(H,{className:i}):t.mime.startsWith(`model/`)?(0,$.jsx)(Nt,{className:i}):(0,$.jsx)(T,{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 en({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:X(`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 tn=`application/x-wizards-logo`;function nn({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):Qt(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(tn,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)(M,{tone:`ember`,children:L(`project.logoMain`)})}):null,(0,$.jsxs)(`div`,{className:`relative h-28 overflow-hidden rounded-md bg-paper-2`,style:t===`logo`?Xt:void 0,children:[s&&n.mime.startsWith(`image/`)?(0,$.jsx)(`button`,{type:`button`,"aria-label":`${L(`project.preview`)}: ${n.name}`,onClick:()=>s(n),className:`block size-full cursor-zoom-in`,children:(0,$.jsx)($t,{projectId:e,file:n})}):(0,$.jsx)($t,{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)(P,{label:L(`project.preview`),onClick:()=>s(n),className:`size-8 bg-card shadow-soft`,children:(0,$.jsx)(qe,{className:`size-4`})}):null,l&&n.id!==c&&!r.readOnly?(0,$.jsx)(P,{label:L(`project.logoMakeMain`),onClick:()=>l(n),className:`size-8 bg-card shadow-soft`,children:(0,$.jsx)($e,{className:`size-4`})}):null,u&&!r.readOnly?(0,$.jsx)(W,{options:u.options,value:u.current(n),onChange:e=>u.onMove(n,e),className:`bg-card shadow-soft`}):null,r.readOnly?null:(0,$.jsx)(P,{label:L(`project.remove`),onClick:()=>f(n),className:`size-8 bg-card shadow-soft hover:text-rose`,children:(0,$.jsx)(q,{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)(Zt,{file:n,actions:r})]},n.id)),a&&!r.readOnly?(0,$.jsxs)(Y,{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)(re,{className:`size-5`}):(0,$.jsx)(I,{className:`size-5`}),a]}):null]})}function rn({kind:e,fetchUrl:t,onAdded:n,onClose:r}){let[i,a]=(0,Q.useState)(``),[o,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 a=await t(i.trim());a.file?(n([a.file]),r()):a.candidates?.length?(d(a.candidates),p([a.candidates[0].url])):l(L(e===`logo`?`project.logoNoneFound`:`project.assetNoneFound`))}catch(e){l(e.message)}s(!1)},_=async()=>{s(!0),l(null);let e=[];try{for(let n of f){let r=await t(n);r.file&&e.push(r.file)}}catch(e){l(e.message)}s(!1),e.length&&n(e),e.length===f.length&&r()};return(0,$.jsx)(g,{open:!0,onClose:r,wide:u?!0:void 0,title:L(u?e===`logo`?`project.logoFound`:`project.assetFound`:e===`logo`?`project.logoFromUrl`:`project.assetFromUrl`),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:L(e===`logo`?`project.logoFoundHint`:`project.assetFoundHint`)}),(0,$.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(150px,1fr))] gap-3`,children:u.map(t=>{let n=f.includes(t.url);return(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":n,title:t.hint,onClick:()=>p(e=>n?e.filter(e=>e!==t.url):[...e,t.url]),className:X(`relative h-28 overflow-hidden rounded-lg ring-1 transition`,n?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),style:Xt,children:[(0,$.jsx)(`img`,{src:t.url,alt:``,className:X(`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)(A,{className:`size-3.5`})}):null]},t.url)})}),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)(Z,{variant:`ghost`,onClick:()=>d(null),children:L(`run.back`)}),(0,$.jsx)(Z,{busy:o,disabled:!f.length,onClick:()=>void _(),children:f.length>1?L(`project.addMany`,{n:f.length}):L(`project.add`)})]})]}):(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),m()},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(y,{children:L(`project.logoUrl`)}),(0,$.jsx)(h,{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:L(e===`logo`?`project.logoUrlHint`:`project.assetUrlHint`)})]}),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)(Z,{variant:`ghost`,onClick:r,children:L(`common.cancel`)}),(0,$.jsx)(Z,{type:`submit`,busy:o,disabled:!i.trim(),children:L(`run.next`)})]})]})})}function an(e,t,n){return pe({queryKey:[`project-file-text`,t.id,t.chars,n],queryFn:()=>Se.get(`/api/studio/projects/${e}/files/${t.id}/text?limit=${n}`),enabled:t.status===`ready`,staleTime:6e4})}function on(e){return((e.name.includes(`.`)?e.name.split(`.`).pop():``)||e.mime.split(`/`).pop()||``).toUpperCase().slice(0,5)}var sn=e=>[on(e),e.pages?L(`project.pages`,{n:e.pages}):null,S(e.size)].filter(Boolean).join(` · `),cn=2e5;function ln({projectId:e,fileId:t,readOnly:n,onGone:r}){let i=p(),a=k(e),s=Ne(e),l=_(e,n),u=a.data?.files.find(e=>e.id===t),d=u?u.mime===`application/pdf`||u.mime.startsWith(`image/`):!1,[f,m]=(0,Q.useState)(null);if(!u)return a.isLoading?(0,$.jsx)(re,{className:`mx-auto text-ink-3`}):null;let h=f??(d?`original`:`text`),g=s.data?.items.find(e=>e.key===`f:${u.id}`),v=E(e,u.id),y=(e,t)=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":h===e,onClick:()=>m(e),className:X(`rounded-full px-3 py-1 text-[0.8125rem] transition`,h===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:u.name}),(0,$.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 max-sm:hidden`,children:sn(u)}),(0,$.jsx)(`a`,{href:v,target:`_blank`,rel:`noreferrer`,"aria-label":L(`project.openOriginal`),title:L(`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)(o,{className:`size-4`})}),n?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(P,{label:L(`project.reindex`),onClick:async()=>{await l.reindex(u.id),await i.invalidateQueries({queryKey:[`knowledge`,e]})},children:(0,$.jsx)(G,{className:`size-4`})}),(0,$.jsx)(P,{label:L(`know.deleteFile`),className:`hover:text-rose`,onClick:async()=>{confirm(L(`data.confirmDelete`,{title:u.name}))&&(await l.remove(u.id),await i.invalidateQueries({queryKey:[`knowledge`,e]}),r())},children:(0,$.jsx)(q,{className:`size-4`})})]})]}),(0,$.jsx)(Oe,{projectId:e,itemKey:`f:${u.id}`,has:g?.categories??[],originLabel:g?.originLabel??null,kept:!1,review:null,file:null,readOnly:n,onReviewed:()=>void 0}),(0,$.jsx)(`div`,{className:`px-1`,children:(0,$.jsx)(Zt,{file:u,actions:l})}),u.status===`failed`?(0,$.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:u.error}):null,(0,$.jsxs)(c,{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?y(`original`,L(`project.original`)):null,y(`text`,L(`project.readText`))]}),h===`original`?u.mime===`application/pdf`?(0,$.jsx)(`iframe`,{src:v,title:u.name,className:`h-[70dvh] w-full rounded-b-xl bg-paper-2`}):(0,$.jsx)(`img`,{src:v,alt:``,className:`mx-auto max-h-[70dvh] object-contain p-4`}):(0,$.jsx)(un,{projectId:e,file:u})]})]})}function un({projectId:e,file:t}){let n=an(e,t,cn);return n.isLoading||t.status===`pending`?(0,$.jsx)(`div`,{className:`flex h-40 items-center justify-center text-ink-3`,children:(0,$.jsx)(re,{})}):n.data?.text?(0,$.jsxs)(`div`,{className:`overflow-x-auto p-4 sm:p-5`,children:[(0,$.jsx)(me,{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:L(`project.textCut`,{shown:n.data.text.length.toLocaleString(),total:n.data.chars.toLocaleString()})}):null]}):(0,$.jsx)(`p`,{className:`py-8 text-center text-[0.875rem] text-ink-3`,children:L(`project.noText`)})}var dn=`image/*,video/*,audio/*,application/pdf,.pdf,.woff2,.woff,.ttf,.otf,.json,.glb,.gltf`,fn=e=>[(e.name.includes(`.`)?e.name.split(`.`).pop():e.mime.split(`/`).pop())?.toUpperCase().slice(0,5),S(e.size)].filter(Boolean).join(` · `);function pn({projectId:e,file:t,actions:n,onClose:r}){let i=E(e,t.id);return(0,$.jsxs)(g,{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:fn(t)}),(0,$.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,"aria-label":L(`project.openOriginal`),title:L(`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)(o,{className:`size-4`})})]}),t.mime.startsWith(`image/`)?(0,$.jsx)(`div`,{className:`overflow-hidden rounded-lg`,style:Xt,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)(Zt,{file:t,actions:n})})]})}function mn({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":`${L(`project.preview`)}: ${t.name}`,onClick:i,className:`size-14 shrink-0 cursor-zoom-in overflow-hidden rounded-md bg-paper-2`,children:(0,$.jsx)($t,{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:fn(t)})]}),(0,$.jsx)(Zt,{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)(P,{label:L(`project.preview`),onClick:i,children:(0,$.jsx)(qe,{className:`size-4`})}),r&&!n.readOnly?(0,$.jsx)(W,{options:r.options,value:r.current(t),onChange:e=>r.onMove(t,e),className:`size-9`}):null,n.readOnly?null:(0,$.jsx)(P,{label:L(`project.remove`),onClick:a,className:`hover:text-rose`,children:(0,$.jsx)(q,{className:`size-4`})})]})]})}function hn({section:e,onSave:t,onRemove:n,onClose:r}){let[i,a]=(0,Q.useState)(e?.title??``);return(0,$.jsx)(g,{open:!0,onClose:r,title:L(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)(y,{children:L(`project.assetSectionName`)}),(0,$.jsx)(h,{autoFocus:!0,value:i,maxLength:80,placeholder:L(`project.assetSectionTitle`),onChange:e=>a(e.target.value)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n?(0,$.jsx)(Z,{variant:`danger`,onClick:n,children:L(`project.sectionRemove`)}):null,(0,$.jsx)(`span`,{className:`flex-1`}),(0,$.jsx)(Z,{variant:`ghost`,onClick:r,children:L(`common.cancel`)}),(0,$.jsx)(Z,{type:`submit`,disabled:!i.trim(),children:L(e?`settings.save`:`project.add`)})]})]})})}function gn({projectId:e,data:t,readOnly:n,sections:r,save:a}){let o=_(e,n),[s,c]=b(`assets`,`cards`),[l,d]=(0,Q.useState)(``),[f,p]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(r),[v,y]=(0,Q.useState)(``),[x,S]=(0,Q.useState)(null),[C,w]=(0,Q.useState)(!1),T=(0,Q.useRef)(null),E=m({assetSections:h},a),D=t.files.filter(e=>e.kind===`asset`),O=new Map(D.map(e=>[e.id,e])),k=new Set(h.flatMap(e=>e.assets)),A=h.find(e=>e.id===v)??null,ee=A?A.assets.map(e=>O.get(e)).filter(e=>!!e):D.filter(e=>!k.has(e.id)),j=D.find(e=>e.id===f),te=l.trim().toLowerCase(),ne=te?ee.filter(e=>`${e.name} ${e.description}`.toLowerCase().includes(te)):ee,M=(e,t)=>g(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=A?.id??null;for(let n of await o.upload(`asset`,e))M(n.id,t)},F=e=>{confirm(L(`project.removeConfirm`,{name:e.name}))&&(o.remove(e.id),M(e.id,null))},ie=h.length?{options:[{value:``,label:L(`project.assetsGeneral`)},...h.map(e=>({value:e.id,label:e.title||L(`project.sectionUntitled`)}))],current:e=>h.find(t=>t.assets.includes(e.id))?.id??``,onMove:(e,t)=>M(e.id,t||null)}:void 0,ae=[{label:L(`project.assetUpload`),icon:(0,$.jsx)(Ke,{className:`size-4 shrink-0`}),onPick:()=>T.current?.click()},{label:L(`project.assetFromUrl`),icon:(0,$.jsx)(Gt,{className:`size-4 shrink-0`}),onPick:()=>w(!0)},...h.length<u.logoSections?[{label:L(`project.assetSectionAdd`),icon:(0,$.jsx)(Lt,{className:`size-4 shrink-0`}),onPick:()=>S(`new`)}]:[]],I=h.length||D.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:[h.length?(0,$.jsx)(i,{value:v,onChange:e=>{y(e),d(``)},label:L(`project.assets`),options:[{id:``,label:L(`project.assetsGeneral`)},...h.map(e=>({id:e.id,label:e.title||L(`project.sectionUntitled`)}))]}):null,A&&!n?(0,$.jsx)(P,{label:L(`project.assetSectionRename`),onClick:()=>S(`current`),children:(0,$.jsx)(_e,{className:`size-4`})}):null]}),ee.length?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`w-56 max-w-[45%] shrink`,children:(0,$.jsx)(oe,{value:l,onChange:d,placeholder:L(`project.assetSearch`)})}),(0,$.jsx)(P,{label:L(s===`list`?`project.viewCards`:`project.viewList`),onClick:c,children:s===`list`?(0,$.jsx)(Ut,{className:`size-4`}):(0,$.jsx)(qt,{className:`size-4`})})]}):null]}):null;return(0,$.jsxs)(ge,{title:L(`project.assets`),hint:L(`project.assetsHint`),save:E,tabs:I,action:n?null:(0,$.jsx)(he,{entries:ae}),children:[(0,$.jsx)(`input`,{ref:T,type:`file`,multiple:!0,accept:dn,className:`sr-only`,tabIndex:-1,"aria-hidden":!0,onChange:e=>{let t=Array.from(e.target.files??[]);e.target.value=``,t.length&&N(t)}}),ne.length?s===`cards`?(0,$.jsx)(nn,{projectId:e,kind:`asset`,files:ne,actions:o,moveTo:ie,onRemove:F,onPreview:e=>p(e.id)}):(0,$.jsx)(`ul`,{className:`flex flex-col gap-2`,children:ne.map(t=>(0,$.jsx)(mn,{projectId:e,file:t,actions:o,moveTo:ie,onPreview:()=>p(t.id),onRemove:()=>F(t)},t.id))}):ee.length?null:n?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:L(`project.staysLocal`)}):(0,$.jsxs)(Y,{accept:dn,onFiles:e=>void N(e),className:`h-16 w-full`,children:[o.busy?(0,$.jsx)(re,{className:`size-4`}):(0,$.jsx)(Ke,{className:`size-4`}),L(`project.drop`),` `,(0,$.jsx)(`span`,{className:`underline`,children:L(`project.assetAdd`)})]}),o.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:o.error}):null,j?(0,$.jsx)(pn,{projectId:e,file:j,actions:o,onClose:()=>p(null)}):null,x?(0,$.jsx)(hn,{section:x===`current`?A:null,onClose:()=>S(null),onSave:e=>{if(x===`current`&&A)g(t=>t.map(t=>t.id===A.id?{...t,title:e}:t));else{let t=R();g(n=>[...n,{id:t,title:e,assets:[]}]),y(t)}},onRemove:x===`current`&&A?()=>{(!A.assets.length||confirm(L(`project.assetSectionRemoveConfirm`,{name:A.title})))&&(g(e=>e.filter(e=>e.id!==A.id)),y(``),S(null))}:void 0}):null,C?(0,$.jsx)(rn,{kind:`asset`,onClose:()=>w(!1),fetchUrl:e=>o.fromUrl(`asset`,e),onAdded:e=>{for(let t of e)M(t.id,A?.id??null)}}):null]})}var _n=/^#[0-9a-fA-F]{6}$/;async function vn(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 yn={linear:`project.gradientLinear`,radial:`project.gradientRadial`,conic:`project.gradientConic`};function bn({projectId:e,gradient:t,isNew:n,brand:r,onSave:i,onClose:o}){let[s,c]=(0,Q.useState)(t),[l,u]=(0,Q.useState)(a(t)),[f,p]=(0,Q.useState)(!1),[m,_]=(0,Q.useState)(``),[v,b]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(null),[w,T]=(0,Q.useState)(!n),E=e=>{c(e),u(a(e)),p(!1)},D=(e,t)=>E({...s,stops:s.stops.map((n,r)=>r===e?{...n,...t}:n)}),O=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));E({...s,stops:[...s.stops,{color:e??t[0]?.color??`#888888`,at:n}]})},k=async()=>{b(!0),C(null);try{let{gradient:t}=await Se.post(`/api/studio/projects/${e}/gradients/describe`,{text:m.trim(),...w?{gradient:{name:s.name,type:s.type,angle:s.angle,stops:s.stops}}:{}});E({...s,...t,name:s.name.trim()?s.name:t.name}),_(``),T(!0)}catch(e){C(e.message)}b(!1)};return(0,$.jsx)(g,{open:!0,onClose:o,wide:!0,title:L(n?`project.gradientNew`:`project.gradientEdit`),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),m.trim()&&!v&&k()},children:[(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(h,{"data-autofocus":n||void 0,value:m,maxLength:1e3,"aria-label":L(`project.gradientDescribe`),placeholder:L(w?`project.gradientDescribeChange`:`project.gradientDescribeNew`),onChange:e=>_(e.target.value),className:`min-w-0 flex-1`}),(0,$.jsxs)(Z,{type:`submit`,variant:`secondary`,busy:v,disabled:!m.trim(),children:[(0,$.jsx)(H,{className:`size-4`}),L(w?`project.gradientDescribeApply`:`project.gradientDescribeMake`)]})]}),(0,$.jsx)(`p`,{className:X(`mt-1.5 text-[0.8125rem]`,S?`text-rose`:`text-ink-3`),children:S??L(`project.gradientDescribeHint`)})]}),(0,$.jsx)(`div`,{className:`h-40 rounded-lg ring-1 ring-border-soft`,style:{background:a(s)}}),(0,$.jsxs)(`div`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(y,{children:L(`project.gradientName`)}),(0,$.jsx)(h,{value:s.name,maxLength:80,placeholder:L(`project.gradientNamePlaceholder`),onChange:e=>c({...s,name:e.target.value})})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(y,{children:L(`project.fillUseLabel`)}),(0,$.jsx)(h,{value:s.description??``,maxLength:400,placeholder:L(`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)(y,{children:L(`project.gradientType`)}),(0,$.jsx)(`div`,{className:`flex gap-1 rounded-full bg-paper-2 p-0.5 ring-1 ring-border-soft`,children:d.map(e=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":s.type===e,onClick:()=>E({...s,type:e}),className:X(`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:L(yn[e])},e))})]}),s.type===`radial`?null:(0,$.jsxs)(`div`,{className:`min-w-56`,children:[(0,$.jsx)(y,{children:L(`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":L(`project.gradientAngle`),onChange:e=>E({...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)(y,{children:L(`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)(ae,{value:_n.test(e.color)?e.color:`#888888`,onChange:e=>D(t,{color:e.target.value})}),(0,$.jsx)(h,{value:e.color,spellCheck:!1,onChange:e=>{let n=e.target.value.trim();_n.test(n)&&D(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":L(`project.gradientAt`),onChange:e=>D(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)(P,{label:L(`project.remove`),disabled:s.stops.length<=2,onClick:()=>E({...s,stops:s.stops.filter((e,n)=>n!==t)}),className:`hover:text-rose`,children:(0,$.jsx)(q,{className:`size-4`})})]},t))}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[s.stops.length<12?(0,$.jsxs)(Z,{variant:`secondary`,size:`sm`,onClick:()=>O(),children:[(0,$.jsx)(I,{className:`size-4`}),` `,L(`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:L(`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:()=>O(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)(y,{children:`CSS`}),(0,$.jsx)(h,{value:l,spellCheck:!1,onChange:e=>{u(e.target.value);let t=x(e.target.value);p(!t),t&&c({...s,...t})},className:`font-mono text-[0.8125rem]`}),(0,$.jsx)(`p`,{className:X(`mt-1.5 text-[0.8125rem]`,f?`text-rose`:`text-ink-3`),children:L(f?`project.gradientCssError`:`project.gradientCssHint`)})]}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(Z,{variant:`ghost`,onClick:o,children:L(`common.cancel`)}),(0,$.jsx)(Z,{onClick:()=>{i(s),o()},children:L(`settings.save`)})]})]})})}var xn=`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`,Sn=`size-8 bg-card shadow-soft hover:bg-card`;function Cn({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)(J,{value:e,label:L(`project.gradientName`),placeholder:t,maxLength:80,onChange:e=>a({name:e}),className:`font-medium text-[0.875rem]`}),(0,$.jsx)(J,{value:n??``,label:L(`project.fillUseLabel`),placeholder:r,maxLength:400,onChange:e=>a({description:e}),className:`text-[0.8125rem] text-ink-3`})]})}function wn({gradient:e,readOnly:t,onEdit:n,onChange:r,onRemove:i}){let o=a(e),[s,c]=(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":L(`project.gradientEdit`),onClick:n,className:`block h-28 w-full rounded-md ring-1 ring-border-soft transition enabled:hover:brightness-105`,style:{background:o}}),(0,$.jsxs)(`div`,{className:xn,children:[(0,$.jsx)(P,{label:L(s?`project.gradientCopied`:`project.gradientCopy`),onClick:()=>{navigator.clipboard.writeText(`background: ${o};`),c(!0),setTimeout(()=>c(!1),1500)},className:Sn,children:(0,$.jsx)(C,{className:`size-4`})}),(0,$.jsx)(P,{label:L(`project.download`),onClick:()=>void vn(e,e.name),className:Sn,children:(0,$.jsx)(ce,{className:`size-4`})}),t?null:(0,$.jsx)(P,{label:L(`project.remove`),onClick:i,className:X(Sn,`hover:text-rose`),children:(0,$.jsx)(q,{className:`size-4`})})]})]}),(0,$.jsx)(Cn,{name:e.name,namePlaceholder:L(`project.gradientName`),description:e.description,usePlaceholder:L(`project.gradientUse`),readOnly:t,onChange:r})]})}function Tn(e,t){return{backgroundImage:`url("${e}")`,backgroundSize:t?`64px`:`cover`,backgroundRepeat:t?`repeat`:`no-repeat`,backgroundPosition:`center`}}function En({projectId:e,pattern:t,fileName:n,readOnly:r,onEdit:i,onChange:a,onRemove:o}){let s=E(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":L(`project.patternEdit`),onClick:i,className:`block h-28 w-full rounded-md ring-1 ring-border-soft transition enabled:hover:brightness-105`,style:Tn(s,t.tile)}),(0,$.jsxs)(`div`,{className:xn,children:[(0,$.jsx)(`a`,{href:s,download:n,"aria-label":L(`project.download`),title:L(`project.download`),className:X(`inline-flex items-center justify-center rounded-full text-ink-3 transition hover:text-ink`,Sn),children:(0,$.jsx)(ce,{className:`size-4`})}),r?null:(0,$.jsx)(P,{label:L(`project.remove`),onClick:o,className:X(Sn,`hover:text-rose`),children:(0,$.jsx)(q,{className:`size-4`})})]})]}),(0,$.jsx)(Cn,{name:t.name,namePlaceholder:n,description:t.description,usePlaceholder:L(`project.patternUse`),readOnly:r,onChange:a})]})}function Dn({projectId:e,pattern:t,isNew:n,fileName:r,busy:i,error:a,upload:o,removeFile:s,onSave:c,onClose:l}){let[u,d]=(0,Q.useState)(t),[p,m]=(0,Q.useState)([]),_=async e=>{let t=e[0];if(!t)return;let n=await o(t);n&&(m(e=>[...e,n.id]),d(e=>({...e,file:n.id,name:e.name||n.name.replace(/\.[^.]+$/,``)})))},v=()=>{for(let e of p)s(e);l()};return(0,$.jsx)(g,{open:!0,onClose:v,wide:!0,title:L(n?`project.patternNew`:`project.patternEdit`),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[u.file?(0,$.jsx)(`div`,{className:`relative h-40 rounded-lg ring-1 ring-border-soft`,style:Tn(E(e,u.file),u.tile),children:(0,$.jsxs)(Y,{accept:`image/*`,multiple:!1,onFiles:e=>void _(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)(re,{className:`size-4`}):(0,$.jsx)(f,{className:`size-4`}),L(`project.patternReplace`)]})}):(0,$.jsxs)(Y,{accept:`image/*`,multiple:!1,onFiles:e=>void _(e),className:`h-40 flex-col`,children:[i?(0,$.jsx)(re,{className:`size-5`}):(0,$.jsx)(f,{className:`size-5`}),L(`project.patternPick`)]}),(0,$.jsxs)(`div`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(y,{children:L(`project.patternName`)}),(0,$.jsx)(h,{value:u.name,maxLength:80,placeholder:u.file?r(u.file):L(`project.patternNamePlaceholder`),onChange:e=>d({...u,name:e.target.value})})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(y,{children:L(`project.fillUseLabel`)}),(0,$.jsx)(h,{value:u.description??``,maxLength:400,placeholder:L(`project.patternUse`),onChange:e=>d({...u,description:e.target.value})})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(y,{children:L(`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":!!u.tile===e,onClick:()=>d({...u,tile:e||void 0}),className:X(`h-9 rounded-full px-4 font-medium text-[0.875rem] transition`,!!u.tile===e?`bg-card text-ink shadow-sm`:`text-ink-3 hover:text-ink-2`),children:L(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)(Z,{variant:`ghost`,onClick:v,children:L(`common.cancel`)}),(0,$.jsx)(Z,{disabled:!u.file||i,onClick:()=>{for(let e of p.filter(e=>e!==u.file))s(e);t.file&&t.file!==u.file&&s(t.file),c({...u,name:u.name.trim(),description:u.description?.trim()||void 0}),l()},children:L(n?`project.add`:`settings.save`)})]})]})})}var On=/^#[0-9a-fA-F]{6}$/;function kn({projectId:e,onAdd:t,onClose:n}){let[r,i]=(0,Q.useState)(``),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)([]),p=async()=>{o(!0),c(null);try{let{colors:t}=await Se.post(`/api/studio/projects/${e}/colors/scan`,{url:r.trim()});t.length?(u(t),f([])):c(L(`project.colorsNoneFound`))}catch(e){c(e.message)}o(!1)};return(0,$.jsx)(g,{open:!0,onClose:n,wide:l?!0:void 0,title:L(l?`project.colorsFound`:`project.colorsFromUrl`),children:l?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:L(`project.colorsFoundHint`)}),(0,$.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(120px,1fr))] gap-3`,children:l.map(e=>{let t=d.includes(e.value);return(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>f(n=>t?n.filter(t=>t!==e.value):[...n,e.value]),className:X(`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)(A,{className:`size-3.5`})}):null]},e.value)})}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(Z,{variant:`ghost`,onClick:()=>u(null),children:L(`run.back`)}),(0,$.jsx)(Z,{disabled:!d.length,onClick:()=>{t(l.filter(e=>d.includes(e.value))),n()},children:d.length>1?L(`project.addMany`,{n:d.length}):L(`project.add`)})]})]}):(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),p()},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(y,{children:L(`project.logoUrl`)}),(0,$.jsx)(h,{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:L(`project.colorsUrlHint`)})]}),s?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:s}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(Z,{variant:`ghost`,onClick:n,children:L(`common.cancel`)}),(0,$.jsx)(Z,{type:`submit`,busy:a,disabled:!r.trim(),children:L(`run.next`)})]})]})})}function An({projectId:e,data:t,colors:n,sections:r,gradients:i,patterns:a,rules:o,sectioned:c,ruled:l,save:d,readOnly:f}){let[p,g]=(0,Q.useState)(()=>n.map(e=>({...e,id:R()}))),[v,y]=(0,Q.useState)(r),[b,x]=(0,Q.useState)(i),[S,C]=(0,Q.useState)(a),[w,T]=(0,Q.useState)(null),[E,D]=(0,Q.useState)(null),O=_(e,f),k=ye(o),[A,ee]=(0,Q.useState)(null),[j,te]=(0,Q.useState)(null),[ne,N]=(0,Q.useState)(!1),re=m({colors:p.filter(e=>On.test(e.value)).map(({name:e,value:t,section:n})=>({name:e.trim(),value:t,...n?{section:n}:{}})),colorSections:v,gradients:b,patterns:S,colorRules:k.rules},d),F=c?v:[],ie=F.filter(e=>(e.kind??`colors`)===`colors`),oe=e=>ie.some(t=>t.id===e.section),B=p.filter(e=>!oe(e)),se=(B[0]??p[0])?.id,V=(e,t)=>g(n=>n.map(n=>n.id===e?{...n,...t}:n)),H=e=>g(t=>[...t,...e.map(e=>({...e,id:R()}))].slice(0,u.colors)),G=[{value:``,label:L(`project.sectionStandard`)},...ie.map(e=>({value:e.id,label:e.title||L(`project.sectionUntitled`)}))],K=(e,t)=>{let n=R();ee(n),y(r=>[...r,{id:n,title:t,...e===`colors`?{}:{kind:e}}])},ce=e=>({id:R(),name:``,section:e,type:`linear`,angle:90,stops:[{color:p[0]?.value&&On.test(p[0].value)?p[0].value:`#4b73ff`,at:0},{color:p[1]?.value&&On.test(p[1].value)?p[1].value:`#ff6d1b`,at:100}]}),le=e=>t.files.find(t=>t.id===e)?.name??`pattern`,ue=[...p.length<u.colors?[{label:L(`project.colorNew`),icon:(0,$.jsx)(I,{className:`size-4 shrink-0`}),onPick:()=>Y()},{label:L(`project.colorsFromUrl`),icon:(0,$.jsx)(Gt,{className:`size-4 shrink-0`}),onPick:()=>N(!0)}]:[],...c&&v.length<u.logoSections?[{label:L(`project.colorSectionAdd`),icon:(0,$.jsx)(Lt,{className:`size-4 shrink-0`}),onPick:()=>K(`colors`,``)},{label:L(`project.gradientSectionAdd`),icon:(0,$.jsx)(jt,{className:`size-4 shrink-0`}),onPick:()=>K(`gradients`,L(`project.gradientSectionTitle`))},{label:L(`project.patternSectionAdd`),icon:(0,$.jsx)(zt,{className:`size-4 shrink-0`}),onPick:()=>K(`patterns`,L(`project.patternSectionTitle`))}]:[],...!l||k.full?[]:[{label:L(`project.ruleNew`),icon:(0,$.jsx)(Ye,{className:`size-4 shrink-0`}),onPick:()=>k.add()}]],J=e=>(0,$.jsxs)(`div`,{className:`group/row flex items-center gap-2`,children:[(0,$.jsx)(ae,{value:On.test(e.value)?e.value:`#888888`,onChange:t=>V(e.id,{value:t.target.value})}),(0,$.jsx)(h,{value:e.name,autoFocus:e.id===j,placeholder:L(`project.colorName`),maxLength:120,onChange:t=>V(e.id,{name:t.target.value}),className:`min-w-0 flex-1`}),(0,$.jsx)(h,{value:e.value,placeholder:`#e0531b`,spellCheck:!1,onChange:t=>V(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===se?(0,$.jsx)(`span`,{className:`mr-1 max-sm:hidden`,children:(0,$.jsx)(M,{tone:`ember`,children:L(`project.colorAccent`)})}):f?null:(0,$.jsx)(P,{label:L(`project.colorFirst`),onClick:()=>g(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)(s,{className:`size-4`})}),f||!ie.length?null:(0,$.jsx)(W,{options:G,value:oe(e)?e.section??``:``,onChange:t=>V(e.id,{section:t||void 0}),className:`opacity-0 focus-within:opacity-100 group-hover/row:opacity-100 coarse:opacity-100`}),f?null:(0,$.jsx)(P,{label:L(`project.remove`),onClick:()=>g(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)(q,{className:`size-4`})})]})]},e.id),Y=e=>{let t=R();te(t),g(n=>[...n,{id:t,name:``,value:`#888888`,...e?{section:e}:{}}])};return(0,$.jsxs)(ge,{title:L(`project.colors`),hint:L(`project.colorsHint`),save:re,locked:f,action:f?null:(0,$.jsx)(he,{entries:ue}),children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[B.length?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:B.map(J)}),f?null:(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:L(`project.colorUse`)})]}):p.length?null:(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:L(`project.colorsEmpty`)}),F.map(t=>{let n=t.kind??`colors`,r=p.filter(e=>e.section===t.id),i=b.filter(e=>e.section===t.id),a=S.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)(xe,{title:t.title,titlePlaceholder:L(n===`gradients`?`project.gradientSectionTitlePlaceholder`:n===`patterns`?`project.patternSectionTitlePlaceholder`:`project.colorSectionTitle`),kind:n===`gradients`?{icon:(0,$.jsx)(jt,{}),label:L(`project.kindGradients`)}:n===`patterns`?{icon:(0,$.jsx)(zt,{}),label:L(`project.kindPatterns`)}:{icon:(0,$.jsx)(dt,{}),label:L(`project.kindColors`)},autoFocus:A===t.id,readOnly:f,onChange:e=>y(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>{if(!o||confirm(L(n===`colors`?`project.colorSectionRemoveConfirm`:`project.fillSectionRemoveConfirm`,{name:t.title||L(`project.sectionUntitled`)}))){y(e=>e.filter(e=>e.id!==t.id)),g(e=>e.map(e=>e.section===t.id?{...e,section:void 0}:e)),x(e=>e.filter(e=>e.section!==t.id));for(let e of a)O.remove(e.file);C(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)(wn,{gradient:e,readOnly:f,onEdit:()=>T(e),onChange:t=>x(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>x(t=>t.filter(t=>t.id!==e.id))},e.id)),f||b.length>=u.gradients?null:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>T(ce(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)(I,{className:`size-5`}),L(`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)(En,{projectId:e,pattern:t,fileName:le(t.file),readOnly:f,onEdit:()=>D(t),onChange:e=>C(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>{O.remove(t.file),C(e=>e.filter(e=>e.id!==t.id))}},t.id)),f||S.length>=u.files.pattern?null:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>D({id:R(),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)(I,{className:`size-5`}),L(`project.patternAdd`)]})]}):(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.map(J),f||p.length>=u.colors?null:(0,$.jsx)(z,{label:L(`project.colorAdd`),onClick:()=>Y(t.id)})]})]},t.id)}),l?(0,$.jsx)(U,{rules:k,placeholder:L(`project.colorRulePlaceholder`),readOnly:f}):null]}),O.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:O.error}):null,w?(0,$.jsx)(bn,{projectId:e,gradient:w,isNew:!b.some(e=>e.id===w.id),brand:p.filter(e=>On.test(e.value)),onClose:()=>T(null),onSave:e=>x(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e])}):null,E?(0,$.jsx)(Dn,{projectId:e,pattern:E,isNew:!S.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=>C(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e])}):null,ne?(0,$.jsx)(kn,{projectId:e,onClose:()=>N(!1),onAdd:H}):null]})}var jn=e=>/^(ja|yes|true)$/i.test(e.trim()),Mn={text:at,longtext:We,number:Te,date:Be,url:te,email:Ze,phone:He,boolean:Ve};function Nn({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=Mn[e??t],u=`${L(`project.factType`)}: ${L(`project.type.${e??t}`)}`,d=`flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-[0.875rem] text-ink-2 hover:bg-accent hover:text-ink`,f=e=>{n(e),i(!1)};return(0,$.jsxs)(`div`,{className:`relative`,ref:s,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":u,title:u,"aria-haspopup":`menu`,"aria-expanded":r,onClick:e=>{o(window.innerHeight-e.currentTarget.getBoundingClientRect().bottom<400),i(e=>!e)},className:X(`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:X(`absolute right-0 z-50 w-56 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,a?`bottom-12`:`top-12`),children:[(0,$.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":!e,className:d,onClick:()=>f(void 0),children:[(0,$.jsx)(nt,{className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1`,children:L(`project.factAuto`)}),(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:L(`project.type.${t}`)}),(0,$.jsx)(A,{className:X(`size-4 shrink-0`,e&&`invisible`)})]}),(0,$.jsx)(`div`,{className:`mx-2 my-1 h-px bg-border-soft`}),l.map(t=>{let n=Mn[t];return(0,$.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e===t,className:d,onClick:()=>f(t),children:[(0,$.jsx)(n,{className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1`,children:L(`project.type.${t}`)}),(0,$.jsx)(A,{className:X(`size-4 shrink-0`,e!==t&&`invisible`)})]},t)})]}):null]})}function Pn({facts:e,save:t,readOnly:n}){let r=(0,Q.useRef)(0),i=(0,Q.useRef)(null),[a,o]=(0,Q.useState)(()=>e.map(e=>({...e,id:`f${r.current++}`}))),s=m(a.filter(e=>e.key&&e.label.trim()).map(({key:e,label:t,value:n,type:r})=>({key:e,label:t.trim(),value:n,...r?{type:r}:{}})),t),c=(e,t)=>o(n=>n.map(n=>n.id===e?{...n,...t}:n)),l=(e,t,n=!1)=>{let a=`f${r.current++}`;i.current=`${a}:${t}`;let s={id:a,key:``,label:``,value:``,...e};o(e=>n?[s,...e]:[...e,s])},d=e=>t=>{t&&i.current===e&&(i.current=null,t.focus())},f=ee.filter(e=>!a.some(t=>t.key===e.key));return(0,$.jsxs)(ge,{title:L(`project.facts`),hint:L(`project.factsHint`),save:s,locked:n,action:a.length<u.facts&&!n?(0,$.jsxs)(Z,{variant:`secondary`,size:`sm`,onClick:()=>l({},`label`,!0),children:[(0,$.jsx)(I,{className:`size-4`}),` `,L(`project.factAdd`)]}):null,children:[(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:a.map(e=>{let t=w(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)(h,{ref:d(`${e.id}:label`),value:e.label,placeholder:L(`project.factLabel`),title:e.key?`{{facts.${e.key}}}`:void 0,onChange:t=>c(e.id,{label:t.target.value}),onBlur:()=>{!e.key&&e.label.trim()&&c(e.id,{key:le(e.label,a.map(e=>e.key))})},className:`max-sm:col-span-3 max-sm:font-medium sm:mr-1`}),e.type===`boolean`?(0,$.jsxs)(`div`,{className:`flex h-11 items-center gap-3`,children:[(0,$.jsx)(O,{checked:jn(e.value),label:e.label,onChange:t=>c(e.id,{value:L(t?`project.yes`:`project.no`)})}),(0,$.jsx)(`span`,{className:`text-[0.875rem] text-ink-2`,children:jn(e.value)?L(`project.yes`):L(`project.no`)})]}):(0,$.jsx)(B,{ref:d(`${e.id}:value`),rows:1,minRows:r===`longtext`?2:1,maxRows:10,value:e.value,placeholder:L(`project.factValue`),onChange:t=>c(e.id,{value:t.target.value}),className:`min-h-11`}),(0,$.jsx)(Nn,{type:e.type,detected:t,onChange:t=>c(e.id,{type:t})}),n?null:(0,$.jsx)(P,{label:L(`project.remove`),onClick:()=>o(t=>t.filter(t=>t.id!==e.id)),className:`size-11 rounded-lg hover:text-rose`,children:(0,$.jsx)(q,{className:`size-4`})})]},e.id)})}),a.length<u.facts&&!n?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${a.length?`mt-4`:``}`,children:[(0,$.jsxs)(Z,{variant:`secondary`,size:`sm`,onClick:()=>l({},`label`),children:[(0,$.jsx)(I,{className:`size-4`}),` `,L(`project.factAdd`)]}),f.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>l({key:e.key,label:fe===`en`?e.en:e.de},`value`),className:`inline-flex h-8 items-center gap-1 rounded-full bg-paper-2 px-3 text-[0.8125rem] text-ink-2 transition hover:bg-paper-3 hover:text-ink`,children:[(0,$.jsx)(I,{className:`size-3.5`}),` `,fe===`en`?e.en:e.de]},e.key))]}):null]})}function Fn({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(tn);i(!1),n&&(t.preventDefault(),e(n))},className:X(`-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 In({projectId:e,data:t,readOnly:n,sections:r,rules:i,sectioned:a,ruled:o,save:s}){let c=_(e,n),[l,d]=(0,Q.useState)(r),f=ye(i),[p,h]=(0,Q.useState)(null),[g,v]=(0,Q.useState)(!1),y=(0,Q.useRef)(null),b=m({logoSections:l,logoRules:f.rules},s),x=t.files.filter(e=>e.kind===`logo`),S=new Map(x.map(e=>[e.id,e])),C=a?l:[],w=new Set(C.flatMap(e=>e.logos)),T=x.filter(e=>!w.has(e.id)),E=K(x,l)?.id,D=(e,t)=>d(n=>n.map(n=>{let r=n.logos.filter(t=>t!==e);return{...n,logos:n.id===t?[...r,e]:r}})),O=(e,t)=>d(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)},A=C.length?{options:[{value:``,label:L(`project.sectionStandard`)},...C.map(e=>({value:e.id,label:e.title||L(`project.sectionUntitled`)}))],current:e=>C.find(t=>t.logos.includes(e.id))?.id??``,onMove:(e,t)=>D(e.id,t||null)}:void 0,ee=(t,n,r)=>(0,$.jsx)(nn,{projectId:e,kind:`logo`,files:t,actions:c,accept:`image/*`,addLabel:r?L(`project.logoAdd`):void 0,onUpload:e=>void k(e,n),mainId:E,onMakeMain:e=>{D(e.id,null),c.order(`logo`,[e.id,...x.filter(t=>t.id!==e.id).map(e=>e.id)])},moveTo:A,onRemove:e=>{confirm(L(`project.removeConfirm`,{name:e.name}))&&(c.remove(e.id),D(e.id,null))}}),j=n?void 0:e=>t=>D(t,e),te=[{label:L(`project.logoUpload`),icon:(0,$.jsx)(Ke,{className:`size-4 shrink-0`}),onPick:()=>y.current?.click()},{label:L(`project.logoFromUrl`),icon:(0,$.jsx)(Gt,{className:`size-4 shrink-0`}),onPick:()=>v(!0)},...a&&l.length<u.logoSections?[{label:L(`project.logoSectionAdd`),icon:(0,$.jsx)(Lt,{className:`size-4 shrink-0`}),onPick:()=>{let e=R();h(e),d(t=>[...t,{id:e,title:``,description:``,logos:[]}])}}]:[],...!o||f.full?[]:[{label:L(`project.ruleNew`),icon:(0,$.jsx)(Ye,{className:`size-4 shrink-0`}),onPick:()=>f.add()}]];return(0,$.jsxs)(ge,{title:L(`project.logos`),hint:L(`project.logosHint`),save:b,action:n?null:(0,$.jsx)(he,{entries:te}),children:[(0,$.jsx)(`input`,{ref:y,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)(Fn,{onLogo:j?.(null),children:ee(T,null,!0)}),C.map(e=>(0,$.jsx)(`div`,{className:`group/section`,children:(0,$.jsxs)(Fn,{onLogo:j?.(e.id),className:`flex flex-col gap-3`,children:[(0,$.jsx)(xe,{title:e.title,description:e.description,titlePlaceholder:L(`project.logoSectionTitle`),descriptionPlaceholder:L(`project.logoSectionUse`),autoFocus:p===e.id,readOnly:n,onChange:t=>O(e.id,t),onRemove:()=>{(!e.logos.length||confirm(L(`project.logoSectionRemoveConfirm`,{name:e.title||L(`project.sectionUntitled`)})))&&d(t=>t.filter(t=>t.id!==e.id))}}),ee(e.logos.map(e=>S.get(e)).filter(e=>!!e),e.id,!0)]})},e.id)),o?(0,$.jsx)(U,{rules:f,placeholder:L(`project.logoRulePlaceholder`),readOnly:n}):null]}),c.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:c.error}):null,g?(0,$.jsx)(rn,{kind:`logo`,onClose:()=>v(!1),fetchUrl:e=>c.fromUrl(`logo`,e),onAdded:e=>{for(let t of e)D(t.id,null)}}):null]})}var Ln=new Set;function Rn(e){(0,Q.useEffect)(()=>{let t=e.trim().toLowerCase().replace(/\s+/g,`-`);if(!t||Ln.has(t))return;Ln.add(t);let n=document.createElement(`link`);n.rel=`stylesheet`,n.href=`https://fonts.bunny.net/css?family=${encodeURIComponent(t)}:${j.join(`,`)}&display=swap`,document.head.append(n)},[e])}var zn=e=>e?`"${e}", system-ui, sans-serif`:`system-ui, sans-serif`;function Bn({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 Vn=`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`,Hn={web:`project.fontUseWeb`,documents:`project.fontUseDocuments`,print:`project.fontUsePrint`,images:`project.fontUseImages`,video:`project.fontUseVideo`};function Un({font:e,first:t,readOnly:n,autoFocus:r,onChange:i,onRemove:a}){return Rn(e.family),(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:zn(e.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`})]}),n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`font-medium text-[0.9375rem]`,children:e.family}),e.role?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:e.role}):null]}):(0,$.jsxs)(`div`,{children:[(0,$.jsx)(J,{value:e.family,label:L(`project.fontFamily`),placeholder:L(`project.fontFamily`),maxLength:80,autoFocus:r,onChange:e=>i({family:e}),className:`font-medium text-[0.9375rem]`}),(0,$.jsx)(J,{value:e.role,label:L(`project.fontRole`),placeholder:L(t?`project.fontRoleFirst`:`project.fontRole`),maxLength:200,onChange:e=>i({role:e}),className:`text-[0.875rem] text-ink-3`})]}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:j.map(t=>{let r=e.weights.includes(t);return(0,$.jsx)(`button`,{type:`button`,disabled:n,"aria-pressed":r,onClick:()=>i({weights:r?e.weights.filter(e=>e!==t):[...e.weights,t].sort((e,t)=>e-t)}),style:{fontFamily:zn(e.family),fontWeight:t},className:X(`h-7 rounded-full px-2.5 text-[0.8125rem] tabular-nums transition`,r?`bg-ink text-paper`:`bg-paper-2 text-ink-3 hover:text-ink`,n&&!r&&`hidden`),children:t},t)})}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[n?e.license?(0,$.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:e.license}):null:(0,$.jsx)(J,{value:e.license??``,label:L(`project.fontLicense`),placeholder:L(`project.fontLicensePlaceholder`),maxLength:200,onChange:e=>i({license:e}),className:`text-[0.8125rem] text-ink-3`}),n&&!e.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:L(`project.fontUses`)}),ve.map(t=>{let r=!!e.uses?.includes(t);return(0,$.jsxs)(`button`,{type:`button`,disabled:n,"aria-pressed":r,onClick:()=>{let n=r?(e.uses??[]).filter(e=>e!==t):ve.filter(n=>n===t||e.uses?.includes(n));i({uses:n.length?n:void 0})},className:X(`inline-flex h-7 items-center gap-1 rounded-full px-2.5 text-[0.8125rem] transition`,r?`bg-card text-ink ring-1 ring-border`:`bg-paper-2 text-ink-3 hover:text-ink`,n&&!r&&`hidden`),children:[r?(0,$.jsx)(A,{className:`size-3.5`}):null,L(Hn[t])]},t)})]})]}),n?null:(0,$.jsx)(P,{label:L(`project.remove`),onClick:a,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)(q,{className:`size-4`})})]})}function Wn({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:zn(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)(J,{value:e.name,label:L(`project.styleName`),placeholder:L(`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":L(`project.styleFont`),value:s?.id??``,onChange:e=>a({font:e.target.value}),className:X(Vn,`max-w-40`),children:t.map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.family||L(`project.fontFamily`)},e.id))}):null,(0,$.jsx)(`select`,{"aria-label":L(`project.styleWeight`),value:e.weight,onChange:e=>a({weight:Number(e.target.value)}),className:Vn,children:[...new Set([...j,e.weight])].sort().map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))}),(0,$.jsx)(Bn,{unit:`px`,label:L(`project.styleSize`),min:6,max:400,value:e.size,onChange:e=>a({size:Number(e.target.value)||16})}),(0,$.jsx)(Bn,{unit:L(`project.styleLine`),label:L(`project.styleLineLabel`),min:50,max:300,value:e.lineHeight,onChange:e=>a({lineHeight:Number(e.target.value)||100})}),(0,$.jsx)(Bn,{unit:L(`project.styleTracking`),label:L(`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:L(`project.styleUpper`),"aria-label":L(`project.styleUpper`),onClick:()=>a({uppercase:!e.uppercase}),className:X(`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)(Ft,{className:`size-4`})})]}),r?null:(0,$.jsx)(P,{label:L(`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)(q,{className:`size-4`})})]})]})}function Gn({projectId:e,onAdd:t,onClose:n}){let[r,i]=(0,Q.useState)(``),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)([]),p=async()=>{o(!0),c(null);try{let{fonts:t}=await Se.post(`/api/studio/projects/${e}/fonts/scan`,{url:r.trim()});t.length?(u(t),f(t.slice(0,2).map(e=>e.family))):c(L(`project.fontsNoneFound`))}catch(e){c(e.message)}o(!1)};return(0,$.jsx)(g,{open:!0,onClose:n,wide:l?!0:void 0,title:L(l?`project.fontsFound`:`project.fontsFromUrl`),children:l?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:L(`project.fontsFoundHint`)}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:l.map(e=>(0,$.jsx)(Kn,{font:e,on:d.includes(e.family),onToggle:()=>f(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)(Z,{variant:`ghost`,onClick:()=>u(null),children:L(`run.back`)}),(0,$.jsx)(Z,{disabled:!d.length,onClick:()=>{t(l.filter(e=>d.includes(e.family))),n()},children:d.length>1?L(`project.addMany`,{n:d.length}):L(`project.add`)})]})]}):(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),p()},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(y,{children:L(`project.logoUrl`)}),(0,$.jsx)(h,{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:L(`project.fontsUrlHint`)})]}),s?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:s}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(Z,{variant:`ghost`,onClick:n,children:L(`common.cancel`)}),(0,$.jsx)(Z,{type:`submit`,busy:a,disabled:!r.trim(),children:L(`run.next`)})]})]})})}function Kn({font:e,on:t,onToggle:n}){return Rn(e.family),(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:n,className:X(`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:zn(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(` · `):L(`project.fontWeightsUnknown`)})]}),t?(0,$.jsx)(`span`,{className:`grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,$.jsx)(A,{className:`size-3.5`})}):null]})}function qn({projectId:e,fonts:t,styles:n,rules:r,ruled:i,sample:a,save:o,readOnly:s}){let[c,l]=(0,Q.useState)(t),[d,f]=(0,Q.useState)(n),p=ye(r),[h,g]=(0,Q.useState)(null),[_,v]=(0,Q.useState)(!1),y=m({fonts:c,textStyles:d,typeRules:p.rules},o),b=(e,t=!1)=>{let n=e.map(e=>({id:R(),family:e.family,role:``,weights:e.weights}));t&&n[0]&&g(n[0].id),l(e=>[...e,...n].slice(0,u.fonts))},x=()=>{let e=R();g(e),f(t=>[...t,{id:e,name:``,size:16,weight:400,lineHeight:150,tracking:0}])},S=[...c.length<u.fonts?[{label:L(`project.fontNew`),icon:(0,$.jsx)(I,{className:`size-4 shrink-0`}),onPick:()=>b([{family:``,weights:[400,700]}],!0)},{label:L(`project.fontsFromUrl`),icon:(0,$.jsx)(Gt,{className:`size-4 shrink-0`}),onPick:()=>v(!0)}]:[],...d.length<u.textStyles?[{label:L(`project.styleNew`),icon:(0,$.jsx)(et,{className:`size-4 shrink-0`}),onPick:x}]:[],...!i||p.full?[]:[{label:L(`project.ruleNew`),icon:(0,$.jsx)(Ye,{className:`size-4 shrink-0`}),onPick:()=>p.add()}]];return(0,$.jsxs)(ge,{title:L(`project.typography`),hint:L(`project.typographyHint`),save:y,action:s?null:(0,$.jsx)(he,{entries:S}),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((e,t)=>(0,$.jsx)(Un,{font:e,first:t===0,readOnly:s,autoFocus:h===e.id,onChange:t=>l(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>l(t=>t.filter(t=>t.id!==e.id))},e.id))}):(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:L(`project.fontsEmpty`)}),d.length?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`font-medium text-[0.9375rem]`,children:L(`project.styles`)}),s?null:(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3 leading-snug`,children:L(`project.stylesHint`)}),(0,$.jsx)(`ul`,{className:`mt-2 flex flex-col`,children:d.map(e=>(0,$.jsx)(Wn,{style:e,fonts:c,sample:a,readOnly:s,autoFocus:h===e.id,onChange:t=>f(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>f(t=>t.filter(t=>t.id!==e.id))},e.id))})]}):null,i?(0,$.jsx)(U,{rules:p,placeholder:L(`project.typeRulePlaceholder`),readOnly:s}):null]}),_?(0,$.jsx)(Gn,{projectId:e,onClose:()=>v(!1),onAdd:e=>b(e)}):null]})}function Jn({project:e,save:t}){let[n,r]=(0,Q.useState)(e.brand.name??``),[i,a]=(0,Q.useState)(e.brand.about??``),o=m({name:n.trim(),about:i.trim()},e=>t({brand:e}));return(0,$.jsx)(ge,{title:L(`project.base`),hint:L(`project.baseHint`),save:o,locked:e.readOnly,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(y,{children:L(`project.title`)}),(0,$.jsx)(h,{value:n,maxLength:120,onChange:e=>r(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:L(`project.titleHint`)})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(y,{children:L(`project.about`)}),(0,$.jsx)(B,{minRows:4,value:i,onChange:e=>a(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:L(`project.aboutHint`)})]})]})})}function Yn({project:e,group:t,children:n}){let r=p(),i=k(e.id),[a,o]=(0,Q.useState)(0),s=async t=>{await Se.patch(`/api/studio/projects/${e.id}`,t),await r.invalidateQueries({queryKey:[`projects`]})},c=Xe({mutationFn:()=>Se.del(`/api/studio/projects/${e.id}`),onSuccess:()=>r.invalidateQueries({queryKey:[`projects`]})}),l=rt(),u=ut(),d=i.data??{files:[],embeddings:!0},f=`${e.id}:${a}`,m=e.readOnly,h=t===`knowledge`,g=Qe(`brandSections`),_=Qe(`brandRules`),v=Qe(`typography`);return tt(m?{}:{title:L(h?`project.assistantTitleKnowledge`:`project.assistantTitle`),hello:L(h?`project.assistantHelloKnowledge`:`project.assistantHello`),placeholder:L(h?`project.assistantComposerKnowledge`:`project.assistantComposer`),suggestions:h?[{label:L(`assistant.suggest.knowledgeHow`)},{label:L(`assistant.suggest.knowledgeSite`),fill:!0},{label:L(`assistant.suggest.knowledgeCategories`)}]:[{label:L(`assistant.suggest.readSite`),fill:!0},{label:L(`assistant.suggest.missing`)},{label:L(`assistant.suggest.facts`)}],summary:h?void 0:[e.brand.name?`title "${e.brand.name}"`:`no title`,`${e.facts.length} facts`,`${e.brand.colors?.length??0} colours`,`${d.files.filter(e=>e.kind===`logo`).length} logos`].join(` · `),onChanged:()=>o(e=>e+1)}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[m?(0,$.jsx)(Ge,{children:Ue(e)}):null,t===`info`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(V,{id:`base`,children:(0,$.jsx)(Jn,{project:e,save:s},`base:${f}`)}),(0,$.jsx)(V,{id:`facts`,children:(0,$.jsx)(Pn,{facts:e.facts,save:e=>s({facts:e}),readOnly:m},`facts:${f}`)}),(0,$.jsx)(V,{id:`logos`,children:(0,$.jsx)(In,{projectId:e.id,data:d,readOnly:m,sections:e.brand.logoSections??[],rules:e.brand.logoRules??[],sectioned:g,ruled:_,save:e=>s({brand:e})},`logos:${f}`)}),(0,$.jsx)(V,{id:`colors`,children:(0,$.jsx)(An,{projectId:e.id,data:d,colors:e.brand.colors??[],sections:e.brand.colorSections??[],gradients:e.brand.gradients??[],patterns:e.brand.patterns??[],rules:e.brand.colorRules??[],sectioned:g,ruled:_,save:e=>s({brand:e}),readOnly:m},`colors:${f}`)}),v?(0,$.jsx)(V,{id:`typography`,children:(0,$.jsx)(qn,{projectId:e.id,fonts:e.brand.fonts??[],styles:e.brand.textStyles??[],rules:e.brand.typeRules??[],ruled:_,sample:e.brand.name||L(`project.typeSample`),save:e=>s({brand:e}),readOnly:m},`typography:${f}`)}):null,(0,$.jsx)(V,{id:`assets`,children:(0,$.jsx)(gn,{projectId:e.id,data:d,readOnly:m,sections:e.brand.assetSections??[],save:e=>s({brand:e})},`assets:${f}`)})]}):null,n,t===`info`&&l&&!m&&u?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(Z,{variant:`danger`,busy:c.isPending,onClick:()=>confirm(`${L(`settings.delete`)}?`)&&c.mutate(),children:L(`settings.delete`)}),c.error?(0,$.jsx)(`p`,{className:`mt-2 text-[0.875rem] text-rose`,children:c.error.message}):null]}):null]})}var Xn={q:``,mode:``,days:0};function Zn(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 pe({queryKey:[`results`,e,i],queryFn:()=>Se.get(`/api/studio/projects/${e}/results${i&&`?${i}`}`),enabled:!!e,placeholderData:e=>e,refetchInterval:15e3})}function Qn({filter:e,onFilter:t}){let[n,r]=(0,Q.useState)(e.q);return(0,Q.useEffect)(()=>{if(n===e.q)return;let r=setTimeout(()=>t({...e,q:n}),250);return()=>clearTimeout(r)},[n,e,t]),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsxs)(`div`,{className:`relative min-w-0 flex-1 basis-56`,children:[(0,$.jsx)(de,{className:`-translate-y-1/2 pointer-events-none absolute top-1/2 left-3 size-4 text-ink-3`}),(0,$.jsx)(h,{type:`search`,value:n,onChange:e=>r(e.target.value),placeholder:L(`space.resultsSearch`),"aria-label":L(`space.resultsSearch`),className:`w-full pl-9`})]}),(0,$.jsx)(F,{value:e.mode,onChange:n=>t({...e,mode:n}),options:[{value:``,label:L(`space.resultsModeAll`)},{value:`live`,label:`Live`},{value:`test`,label:`Test`}],className:`w-32`}),(0,$.jsx)(F,{value:String(e.days),onChange:n=>t({...e,days:Number(n)}),options:[{value:`0`,label:L(`space.resultsAnyTime`)},{value:`1`,label:L(`space.resultsDay`)},{value:`7`,label:L(`space.resultsDays`,{n:7})},{value:`30`,label:L(`space.resultsDays`,{n:30})}],className:`w-44`})]})}function $n({data:e,wizardId:t,filter:n,onFilter:r}){let[i,a]=(0,Q.useState)(null),o=t=>e.wizards.find(e=>e.id===t)?.title??``,s=new Intl.DateTimeFormat(fe,{dateStyle:`medium`,timeStyle:`short`});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(ge,{title:t?o(t):L(`space.resultsAll`),hint:L(`space.resultsHint`),plain:!0,children:[(0,$.jsx)(Qn,{filter:n,onFilter:r}),e.runs.length?(0,$.jsx)(c,{className:`flex flex-col p-1.5`,children:e.runs.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>a(e),className:`flex items-center gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`truncate text-[0.875rem]`,children:t?s.format(new Date(e.doneAt)):o(e.wizardId)}),(0,$.jsxs)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:[t?null:`${s.format(new Date(e.doneAt))} · `,L(`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:L(`space.resultFiles`,{n:e.assets}),children:[(0,$.jsx)(be,{className:`size-3.5`}),e.assets]}):null,e.mode===`test`?(0,$.jsx)(M,{children:`Test`}):(0,$.jsxs)(M,{tone:`live`,children:[`Live v`,e.version]})]},e.id))}):(0,$.jsx)(c,{children:(0,$.jsx)(ne,{children:n.q.trim()||n.mode||n.days?L(`space.resultsNone`):L(`space.resultsEmpty`)})})]}),i?(0,$.jsx)(Pe,{header:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-[0.875rem]`,children:o(i.wizardId)}),i.mode===`test`?(0,$.jsx)(M,{children:`Test`}):(0,$.jsxs)(M,{tone:`live`,children:[`Live v`,i.version]})]}),onClose:()=>a(null),children:(0,$.jsx)(kt,{runId:i.id,compact:!0},i.id)}):null]})}function er({project:e,save:t}){let[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(e.name),o=Xe({mutationFn:()=>t({name:i.trim()}),onSuccess:()=>r(!1)});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(P,{label:L(`project.rename`),onClick:()=>{a(e.name),r(!0)},children:(0,$.jsx)(_e,{className:`size-4`})}),(0,$.jsx)(g,{open:n,onClose:()=>r(!1),title:L(`project.rename`),children:(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),i.trim()&&o.mutate()},children:[(0,$.jsx)(h,{"data-autofocus":!0,value:i,maxLength:80,onChange:e=>a(e.target.value)}),o.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:o.error.message}):null,(0,$.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,$.jsx)(Z,{variant:`ghost`,onClick:()=>r(!1),children:L(`common.cancel`)}),(0,$.jsx)(Z,{type:`submit`,busy:o.isPending,disabled:!i.trim(),children:L(`settings.save`)})]})]})})]})}function tr({project:e}){let t=p();return(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(it,{}),e.readOnly?null:(0,$.jsx)(er,{project:e,save:async n=>{await Se.patch(`/api/studio/projects/${e.id}`,n),await t.invalidateQueries({queryKey:[`projects`]})}})]})}function nr(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=_t(),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 rr(e,t){let n=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;document.getElementById(e)?.scrollIntoView({block:`start`,behavior:t&&!n?`smooth`:`auto`})}function ir({groups:e,current:t,onPick:n}){return e.map(e=>{let r=e.sections.map(e=>(0,$.jsx)(yt,{icon:e.icon??Je,label:e.label,selected:e.id===t,onPick:()=>n(e.id)},e.id));return e.label?(0,$.jsx)(St,{label:e.label,children:r},e.plugin):(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:r},`own`)})}function ar(){let{group:e}=r(),[t,n]=se(),i=D(),a=ie(),{hash:o}=a,{project:s,loading:c}=mt(),l=rt(),u=gt(),d=Ot(),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(null),y=ct(e)?e:void 0,b=y?void 0:u.spaceParts.find(t=>t.id===e),x=y??b?.id,S=a.state?.parts===!0,C=lt(ft(),u).map(e=>({...e,to:`/space/${e.id}`})),w=C.find(e=>e.id===x),T=t.get(`show`),E=x?T?2:1:0,O=d?Math.min(E,1):x&&g!==x&&!S?1:0,k=xt(O),A=xt(E),ee=(0,Q.useMemo)(()=>({slot:f,narrow:d,setDetail:h}),[f,d]),j=s?s.brand.name?.trim()||s.name:L(`nav.project`),te=Qe(`typography`)?[]:[`typography`],M=b?u.spaceMenus[b.id]??[]:[],N=b?[{plugin:null,label:null,sections:M}]:y&&y!==`results`?pt(y,u,te):[],P=y?pt(y,u).filter(e=>e.plugin):[],re=nr([...N,...y===`results`?P:[]].flatMap(e=>e.sections.map(e=>e.id))),F=y===`results`&&T&&T!==`all`?T:null,[ae,oe]=(0,Q.useState)(Xn),I=Zn(y===`results`?s?.id:void 0,F,ae),R=I.data?.wizards.find(e=>e.id===F)?.title,z=y===`data`&&T&&T!==`all`||y===`knowledge`&&T&&/^[ptfcvs]:/.test(T)?T:null,B=z?.startsWith(`s:`)?u.spaceSections.find(e=>e.id===z.slice(2)):void 0,H=y===`knowledge`&&z&&/^[ptf]:/.test(z)?z:null,U=Ee(y===`data`?s?.id:void 0),W=Ne(y===`knowledge`?s?.id:void 0),G=ze(z?.startsWith(`v:`)?z.slice(2):``),K=W.data?.categories.find(e=>e.id===(z?.startsWith(`c:`)?z.slice(2):G.data?.category.id)),ce=y===`knowledge`?B?B.label():z?.startsWith(`v:`)?G.data&&`${G.data.category.name}: ${G.data.value}`:z?.startsWith(`c:`)?K?.name:W.data?.items.find(e=>e.key===z)?.title:U.data?Le(U.data).flatMap(e=>e.items).find(e=>e.key===z)?.title:void 0;vt([{label:L(`nav.project`),to:`/space`},...w?[{label:w.label,to:`/space/${w.id}`}]:[],...w&&(m??R??ce)?[{label:m??R??ce}]:[]]);let le={p:`page`,t:`table`,f:`file`,c:`kategorie`,v:`kategorie value`,s:`plugin section`};tt({...y===`data`||y===`results`?{compact:!0}:{},...y===`data`?{suggestions:[{label:L(`assistant.suggest.dataWhat`)},{label:L(`assistant.suggest.dataWho`)},{label:L(`assistant.suggest.dataEdit`)}]}:y===`results`?{suggestions:[{label:L(`assistant.suggest.resultsFailed`)},{label:L(`assistant.suggest.resultsCost`)},{label:L(`assistant.suggest.resultsShare`)}]}:{},...z&&ce?{open:{kind:le[z[0]]??`item`,id:z.slice(2),label:ce}}:F&&R?{open:{kind:`wizard`,id:F,label:R}}:{}});let ue=y===`results`||y===`data`||z?o.slice(1):T||o.slice(1),q=(0,Q.useRef)(``);if((0,Q.useEffect)(()=>{let e=`${x}#${ue}`;ue&&q.current!==e&&document.getElementById(ue)&&(q.current=e,requestAnimationFrame(()=>rr(ue,!1)))},[x,ue,s?.id,u.spaceSections,M.length]),!x){let t=o.slice(1),n=t?st(t,u):null;if(n===`knowledge`&&u.spaceSections.some(e=>e.id===t))return(0,$.jsx)(v,{to:`/space/knowledge?show=s:${t}`,replace:!0});if(n)return(0,$.jsx)(v,{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)(v,{to:`/space/info`,replace:!0,state:{parts:!0}})}if(y===`knowledge`&&!T&&u.spaceSections.some(e=>e.id===o.slice(1)))return(0,$.jsx)(v,{to:`/space/knowledge?show=s:${o.slice(1)}`,replace:!0});let J=e=>{if(d){i({search:`?show=${e}`});return}q.current=`${x}#${e}`,rr(e,!0),i({search:``,hash:e},{replace:!0})},Y=e=>d?n({show:e}):n(e===`all`?{}:{show:e},{replace:!0}),de=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)(V,{id:e.id,children:(0,$.jsx)(ge,{title:e.label(),hint:e.hint?.(),plain:!0,children:(0,$.jsx)(ht,{of:e,children:(0,$.jsx)(e.component,{})})})},e.serial)),fe=d?void 0:re;return(0,$.jsx)(wt.Provider,{value:ee,children:(0,$.jsx)(`div`,{className:`animate-rise`,children:(0,$.jsxs)(`div`,{className:`grid gap-6 md:grid-cols-[13.5rem_minmax(0,1fr)] md:gap-8 lg:grid-cols-[15rem_minmax(0,1fr)] lg:gap-10`,children:[(0,$.jsxs)(`aside`,{className:X(`min-w-0 md:sticky md:top-6 md:self-start`,d&&E===2&&`hidden`,d&&A===`back`&&bt(`back`)),children:[(0,$.jsx)(Ct,{title:j,open:O===1?w??null:null,onBack:()=>d?i(`/space`):_(x??null)}),(0,$.jsx)(`div`,{className:X(bt(k)),children:O===0?(0,$.jsx)(Tt,{entries:C,current:d?void 0:w,onPick:()=>_(null)}):(0,$.jsx)(`div`,{ref:p})},O)]}),x?(0,$.jsxs)(`div`,{className:X(`min-w-0`,d&&E<2&&`hidden`,d&&A===`deeper`&&bt(`deeper`)),children:[d?(0,$.jsx)(`div`,{className:`mb-3`,children:(0,$.jsx)(Dt,{label:w?.label??j,onBack:()=>i(`/space/${x}`)})}):null,l&&s?(0,$.jsx)(`div`,{className:`mb-6`,children:(0,$.jsx)(tr,{project:s})}):null,y===`results`?(0,$.jsxs)(Et,{children:[(0,$.jsxs)(`ul`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsx)(yt,{icon:Vt,label:L(`space.resultsAll`),selected:!d&&!F,onPick:()=>Y(`all`)}),I.data?.wizards.filter(e=>e.results||e.id===F).map(e=>(0,$.jsx)(yt,{icon:nt,label:e.title,badge:e.results?(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:e.results}):null,selected:!d&&e.id===F,onPick:()=>Y(e.id)},e.id))]}),(0,$.jsx)(ir,{groups:P,current:fe,onPick:J})]}):y===`data`?(0,$.jsxs)(Et,{children:[(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,$.jsx)(yt,{icon:Ut,label:L(`data.all`),selected:!d&&!z,onPick:()=>Y(`all`)})}),U.data?Le(U.data).map(e=>(0,$.jsx)(St,{label:e.label,children:e.items.map(e=>(0,$.jsx)(yt,{icon:we[e.kind],label:e.title,selected:!d&&e.key===z,onPick:()=>Y(e.key)},e.key))},e.key)):null,(0,$.jsx)(ir,{groups:P,current:fe,onPick:J})]}):y===`knowledge`?(0,$.jsxs)(Et,{children:[(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,$.jsx)(yt,{icon:Ut,label:L(`know.all`),selected:!(d||z),onPick:()=>Y(`all`)})}),W.data?.categories.length?(0,$.jsx)(St,{label:L(`know.categories`),children:W.data.categories.map(e=>(0,$.jsx)(yt,{icon:Ae[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}`||G.data?.category.id===e.id),onPick:()=>Y(`c:${e.id}`)},e.id))}):null,(0,$.jsx)(ir,{groups:P,current:d?void 0:B?.id,onPick:e=>Y(`s:${e}`)})]}):(0,$.jsx)(Et,{children:(0,$.jsx)(ir,{groups:N,current:fe,onPick:J})}),s&&(y===`info`||y===`knowledge`)?(0,$.jsxs)(Yn,{project:s,group:y,children:[y===`knowledge`?H?H.startsWith(`p:`)?(0,$.jsx)(Me,{pageId:H.slice(2),onGone:()=>Y(`all`),onOpen:Y},H):H.startsWith(`t:`)?(0,$.jsx)(je,{tableId:H.slice(2),onGone:()=>Y(`all`)},H):(0,$.jsx)(ln,{projectId:s.id,fileId:H.slice(2),readOnly:s.readOnly,onGone:()=>Y(`all`)},H):W.data?B?(0,$.jsx)(ge,{title:B.label(),hint:B.hint?.(),plain:!0,children:(0,$.jsx)(ht,{of:B,children:(0,$.jsx)(B.component,{})})},z):z?.startsWith(`c:`)?K?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(ke,{projectId:s.id,category:K,readOnly:s.readOnly,onOpen:Y,onGone:()=>Y(`all`)}),K.type===`choice`?null:(0,$.jsx)(Re,{projectId:s.id,category:K,categories:W.data.categories,onOpen:Y})]},z):null:z?.startsWith(`v:`)?G.data?(0,$.jsx)(Ce,{value:G.data,readOnly:s.readOnly,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[G.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:G.data.items.map(e=>(0,$.jsx)(De,{item:e,categories:W.data.categories.filter(e=>e.id!==G.data?.category.id),onOpen:Y},e.key))}):null,G.data.rows.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>Y(`t:${e.tableId}`),className:`px-1 text-left text-[0.8125rem] text-ink-3 hover:text-ink`,children:L(`know.tocRows`,{n:e.count,table:e.title})},e.tableId))]})},z):null:(0,$.jsx)(V,{id:`documents`,children:(0,$.jsx)(Ie,{projectId:s.id,data:W.data,readOnly:s.readOnly,onOpen:Y})}):null:null,y===`info`?de(P):null]},s.id):null,s&&b?(0,$.jsx)(ht,{of:b,children:(0,$.jsx)(ot,{part:b.id,children:(0,$.jsx)(b.component,{})},s.id)}):null,s&&y===`data`?(0,$.jsx)(`div`,{className:`flex flex-col gap-9 pb-20`,children:z?.startsWith(`t:`)?(0,$.jsx)(je,{tableId:z.slice(2),onGone:()=>Y(`all`)},z):z?.startsWith(`p:`)?(0,$.jsx)(Me,{pageId:z.slice(2),onGone:()=>Y(`all`)},z):(0,$.jsxs)($.Fragment,{children:[U.data?(0,$.jsx)(Fe,{projectId:s.id,data:U.data,readOnly:s.readOnly,onOpen:Y}):null,de(P)]})}):null,s&&y===`results`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[I.data?(0,$.jsx)($n,{data:I.data,wizardId:F,filter:ae,onFilter:oe}):null,I.isError?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:I.error.message}):null,de(P)]}):null,s||c?null:(0,$.jsx)(ne,{children:L(`settings.noProject`)})]}):null]})})})}export{ar as ProjectPage};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$n as r,$t as i,A as a,An as o,Bn as s,Bt as c,C as l,D as u,E as d,En as f,Er as p,F as m,Gt as h,Ht as g,I as _,Jn as v,Kt as y,L as b,M as x,N as S,Nn as C,O as w,On as T,P as E,Qn as D,Qt as O,R as k,Rn as A,S as ee,T as j,Tn as te,Ut as ne,Vt as M,Wn as N,Wt as P,Xt as re,Yt as F,Zn as ie,Zt as ae,_ as oe,_n as I,an as L,b as R,d as z,en as B,er as se,f as V,fn as H,g as U,h as W,hn as G,j as K,jn as ce,k as le,kn as ue,ln as q,m as J,p as Y,pn as de,rn as fe,tn as X,tr as pe,tt as me,u as he,v as ge,vn as _e,w as ve,x as ye,xn as be,y as xe,z as Se,zt as Z}from"./ui-DTuixH4y.js";import{_ as Ce,a as we,b as Te,c as Ee,d as De,f as Oe,g as ke,h as Ae,i as je,l as Me,m as Ne,n as Pe,o as Fe,p as Ie,s as Le,u as Re,v as ze,x as Be,y as Ve}from"./RunDrawer-B3FNYpgZ.js";import{t as He}from"./phone-BFD815nc.js";import{n as Ue,r as We,t as Ge}from"./ReadOnly-DQPHmvS0.js";import{t as Ke}from"./upload-BEf5-d6X.js";import{Bt as qe,Et as Je,Ft as Ye,Jt as Xe,Pt as Ze,Q as Qe,St as $e,Tt as et,U as tt,_t as nt,at as rt,b as it,bt as at,c as ot,d as st,f as ct,h as lt,it as ut,kt as dt,m as ft,p as pt,rt as mt,s as ht,u as gt,v as _t,y as vt}from"./index-B-D8UvL9.js";import{a as yt,c as bt,f as xt,i as St,n as Ct,o as wt,r as Tt,s as Et,t as Dt,u as Ot}from"./settings-menu-BJm0CwOj.js";import{t as kt}from"./RunnerView-D6sGVnRy.js";var At={name:`blend`,size:24,node:[[`circle`,{cx:`15`,cy:`9`,r:`7`,key:`1i12rt`}],[`circle`,{cx:`9`,cy:`15`,r:`7`,key:`19bs8k`}]]};At.node;var jt=N(At),Mt={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`}]]};Mt.node;var Nt=N(Mt),Pt={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`}]]};Pt.node;var Ft=N(Pt),It={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`}]]};It.node;var Lt=N(It),Rt={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`]};Rt.node;var zt=N(Rt),Bt={name:`layers`,size:24,node:[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]],aliases:[`layers-3`]};Bt.node;var Vt=N(Bt),Ht={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`}]]};Ht.node;var Ut=N(Ht),Wt={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`}]]};Wt.node;var Gt=N(Wt),Kt={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`}]]};Kt.node;var qt=N(Kt),Jt={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`}]]};Jt.node;var Yt=N(Jt),Q=e(t(),1),$=e(n(),1),Xt={backgroundImage:`repeating-conic-gradient(#c9c9c9 0% 25%, #dedede 0% 50%)`,backgroundSize:`16px 16px`};function Zt({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:L(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 Qt(e,t){confirm(L(`project.removeConfirm`,{name:e.name}))&&t.remove(e.id)}function $t({projectId:e,file:t,small:n}){let r=E(e,t.id);if(t.mime.startsWith(`image/`))return(0,$.jsx)(`img`,{src:r,alt:``,loading:`lazy`,className:X(`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)(en,{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)(Yt,{className:i}):t.mime===`application/pdf`?(0,$.jsx)(ue,{className:i}):t.mime===`application/json`?(0,$.jsx)(H,{className:i}):t.mime.startsWith(`model/`)?(0,$.jsx)(Nt,{className:i}):(0,$.jsx)(T,{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 en({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:X(`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 tn=`application/x-wizards-logo`;function nn({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):Qt(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(tn,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)(M,{tone:`ember`,children:L(`project.logoMain`)})}):null,(0,$.jsxs)(`div`,{className:`relative h-28 overflow-hidden rounded-md bg-paper-2`,style:t===`logo`?Xt:void 0,children:[s&&n.mime.startsWith(`image/`)?(0,$.jsx)(`button`,{type:`button`,"aria-label":`${L(`project.preview`)}: ${n.name}`,onClick:()=>s(n),className:`block size-full cursor-zoom-in`,children:(0,$.jsx)($t,{projectId:e,file:n})}):(0,$.jsx)($t,{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)(P,{label:L(`project.preview`),onClick:()=>s(n),className:`size-8 bg-card shadow-soft`,children:(0,$.jsx)(qe,{className:`size-4`})}):null,l&&n.id!==c&&!r.readOnly?(0,$.jsx)(P,{label:L(`project.logoMakeMain`),onClick:()=>l(n),className:`size-8 bg-card shadow-soft`,children:(0,$.jsx)($e,{className:`size-4`})}):null,u&&!r.readOnly?(0,$.jsx)(W,{options:u.options,value:u.current(n),onChange:e=>u.onMove(n,e),className:`bg-card shadow-soft`}):null,r.readOnly?null:(0,$.jsx)(P,{label:L(`project.remove`),onClick:()=>f(n),className:`size-8 bg-card shadow-soft hover:text-rose`,children:(0,$.jsx)(q,{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)(Zt,{file:n,actions:r})]},n.id)),a&&!r.readOnly?(0,$.jsxs)(Y,{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)(re,{className:`size-5`}):(0,$.jsx)(I,{className:`size-5`}),a]}):null]})}function rn({kind:e,fetchUrl:t,onAdded:n,onClose:r}){let[i,a]=(0,Q.useState)(``),[o,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 a=await t(i.trim());a.file?(n([a.file]),r()):a.candidates?.length?(d(a.candidates),p([a.candidates[0].url])):l(L(e===`logo`?`project.logoNoneFound`:`project.assetNoneFound`))}catch(e){l(e.message)}s(!1)},_=async()=>{s(!0),l(null);let e=[];try{for(let n of f){let r=await t(n);r.file&&e.push(r.file)}}catch(e){l(e.message)}s(!1),e.length&&n(e),e.length===f.length&&r()};return(0,$.jsx)(g,{open:!0,onClose:r,wide:u?!0:void 0,title:L(u?e===`logo`?`project.logoFound`:`project.assetFound`:e===`logo`?`project.logoFromUrl`:`project.assetFromUrl`),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:L(e===`logo`?`project.logoFoundHint`:`project.assetFoundHint`)}),(0,$.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(150px,1fr))] gap-3`,children:u.map(t=>{let n=f.includes(t.url);return(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":n,title:t.hint,onClick:()=>p(e=>n?e.filter(e=>e!==t.url):[...e,t.url]),className:X(`relative h-28 overflow-hidden rounded-lg ring-1 transition`,n?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),style:Xt,children:[(0,$.jsx)(`img`,{src:t.url,alt:``,className:X(`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)(A,{className:`size-3.5`})}):null]},t.url)})}),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)(Z,{variant:`ghost`,onClick:()=>d(null),children:L(`run.back`)}),(0,$.jsx)(Z,{busy:o,disabled:!f.length,onClick:()=>void _(),children:f.length>1?L(`project.addMany`,{n:f.length}):L(`project.add`)})]})]}):(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),m()},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(y,{children:L(`project.logoUrl`)}),(0,$.jsx)(h,{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:L(e===`logo`?`project.logoUrlHint`:`project.assetUrlHint`)})]}),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)(Z,{variant:`ghost`,onClick:r,children:L(`common.cancel`)}),(0,$.jsx)(Z,{type:`submit`,busy:o,disabled:!i.trim(),children:L(`run.next`)})]})]})})}function an(e,t,n){return pe({queryKey:[`project-file-text`,t.id,t.chars,n],queryFn:()=>Se.get(`/api/studio/projects/${e}/files/${t.id}/text?limit=${n}`),enabled:t.status===`ready`,staleTime:6e4})}function on(e){return((e.name.includes(`.`)?e.name.split(`.`).pop():``)||e.mime.split(`/`).pop()||``).toUpperCase().slice(0,5)}var sn=e=>[on(e),e.pages?L(`project.pages`,{n:e.pages}):null,S(e.size)].filter(Boolean).join(` · `),cn=2e5;function ln({projectId:e,fileId:t,readOnly:n,onGone:r}){let i=p(),a=k(e),s=Ne(e),l=_(e,n),u=a.data?.files.find(e=>e.id===t),d=u?u.mime===`application/pdf`||u.mime.startsWith(`image/`):!1,[f,m]=(0,Q.useState)(null);if(!u)return a.isLoading?(0,$.jsx)(re,{className:`mx-auto text-ink-3`}):null;let h=f??(d?`original`:`text`),g=s.data?.items.find(e=>e.key===`f:${u.id}`),v=E(e,u.id),y=(e,t)=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":h===e,onClick:()=>m(e),className:X(`rounded-full px-3 py-1 text-[0.8125rem] transition`,h===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:u.name}),(0,$.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 max-sm:hidden`,children:sn(u)}),(0,$.jsx)(`a`,{href:v,target:`_blank`,rel:`noreferrer`,"aria-label":L(`project.openOriginal`),title:L(`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)(o,{className:`size-4`})}),n?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(P,{label:L(`project.reindex`),onClick:async()=>{await l.reindex(u.id),await i.invalidateQueries({queryKey:[`knowledge`,e]})},children:(0,$.jsx)(G,{className:`size-4`})}),(0,$.jsx)(P,{label:L(`know.deleteFile`),className:`hover:text-rose`,onClick:async()=>{confirm(L(`data.confirmDelete`,{title:u.name}))&&(await l.remove(u.id),await i.invalidateQueries({queryKey:[`knowledge`,e]}),r())},children:(0,$.jsx)(q,{className:`size-4`})})]})]}),(0,$.jsx)(Oe,{projectId:e,itemKey:`f:${u.id}`,has:g?.categories??[],originLabel:g?.originLabel??null,kept:!1,review:null,file:null,readOnly:n,onReviewed:()=>void 0}),(0,$.jsx)(`div`,{className:`px-1`,children:(0,$.jsx)(Zt,{file:u,actions:l})}),u.status===`failed`?(0,$.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:u.error}):null,(0,$.jsxs)(c,{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?y(`original`,L(`project.original`)):null,y(`text`,L(`project.readText`))]}),h===`original`?u.mime===`application/pdf`?(0,$.jsx)(`iframe`,{src:v,title:u.name,className:`h-[70dvh] w-full rounded-b-xl bg-paper-2`}):(0,$.jsx)(`img`,{src:v,alt:``,className:`mx-auto max-h-[70dvh] object-contain p-4`}):(0,$.jsx)(un,{projectId:e,file:u})]})]})}function un({projectId:e,file:t}){let n=an(e,t,cn);return n.isLoading||t.status===`pending`?(0,$.jsx)(`div`,{className:`flex h-40 items-center justify-center text-ink-3`,children:(0,$.jsx)(re,{})}):n.data?.text?(0,$.jsxs)(`div`,{className:`overflow-x-auto p-4 sm:p-5`,children:[(0,$.jsx)(me,{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:L(`project.textCut`,{shown:n.data.text.length.toLocaleString(),total:n.data.chars.toLocaleString()})}):null]}):(0,$.jsx)(`p`,{className:`py-8 text-center text-[0.875rem] text-ink-3`,children:L(`project.noText`)})}var dn=`image/*,video/*,audio/*,application/pdf,.pdf,.woff2,.woff,.ttf,.otf,.json,.glb,.gltf`,fn=e=>[(e.name.includes(`.`)?e.name.split(`.`).pop():e.mime.split(`/`).pop())?.toUpperCase().slice(0,5),S(e.size)].filter(Boolean).join(` · `);function pn({projectId:e,file:t,actions:n,onClose:r}){let i=E(e,t.id);return(0,$.jsxs)(g,{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:fn(t)}),(0,$.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,"aria-label":L(`project.openOriginal`),title:L(`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)(o,{className:`size-4`})})]}),t.mime.startsWith(`image/`)?(0,$.jsx)(`div`,{className:`overflow-hidden rounded-lg`,style:Xt,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)(Zt,{file:t,actions:n})})]})}function mn({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":`${L(`project.preview`)}: ${t.name}`,onClick:i,className:`size-14 shrink-0 cursor-zoom-in overflow-hidden rounded-md bg-paper-2`,children:(0,$.jsx)($t,{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:fn(t)})]}),(0,$.jsx)(Zt,{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)(P,{label:L(`project.preview`),onClick:i,children:(0,$.jsx)(qe,{className:`size-4`})}),r&&!n.readOnly?(0,$.jsx)(W,{options:r.options,value:r.current(t),onChange:e=>r.onMove(t,e),className:`size-9`}):null,n.readOnly?null:(0,$.jsx)(P,{label:L(`project.remove`),onClick:a,className:`hover:text-rose`,children:(0,$.jsx)(q,{className:`size-4`})})]})]})}function hn({section:e,onSave:t,onRemove:n,onClose:r}){let[i,a]=(0,Q.useState)(e?.title??``);return(0,$.jsx)(g,{open:!0,onClose:r,title:L(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)(y,{children:L(`project.assetSectionName`)}),(0,$.jsx)(h,{autoFocus:!0,value:i,maxLength:80,placeholder:L(`project.assetSectionTitle`),onChange:e=>a(e.target.value)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n?(0,$.jsx)(Z,{variant:`danger`,onClick:n,children:L(`project.sectionRemove`)}):null,(0,$.jsx)(`span`,{className:`flex-1`}),(0,$.jsx)(Z,{variant:`ghost`,onClick:r,children:L(`common.cancel`)}),(0,$.jsx)(Z,{type:`submit`,disabled:!i.trim(),children:L(e?`settings.save`:`project.add`)})]})]})})}function gn({projectId:e,data:t,readOnly:n,sections:r,save:a}){let o=_(e,n),[s,c]=b(`assets`,`cards`),[l,d]=(0,Q.useState)(``),[f,p]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(r),[v,y]=(0,Q.useState)(``),[x,S]=(0,Q.useState)(null),[C,w]=(0,Q.useState)(!1),T=(0,Q.useRef)(null),E=m({assetSections:h},a),D=t.files.filter(e=>e.kind===`asset`),O=new Map(D.map(e=>[e.id,e])),k=new Set(h.flatMap(e=>e.assets)),A=h.find(e=>e.id===v)??null,ee=A?A.assets.map(e=>O.get(e)).filter(e=>!!e):D.filter(e=>!k.has(e.id)),j=D.find(e=>e.id===f),te=l.trim().toLowerCase(),ne=te?ee.filter(e=>`${e.name} ${e.description}`.toLowerCase().includes(te)):ee,M=(e,t)=>g(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=A?.id??null;for(let n of await o.upload(`asset`,e))M(n.id,t)},F=e=>{confirm(L(`project.removeConfirm`,{name:e.name}))&&(o.remove(e.id),M(e.id,null))},ie=h.length?{options:[{value:``,label:L(`project.assetsGeneral`)},...h.map(e=>({value:e.id,label:e.title||L(`project.sectionUntitled`)}))],current:e=>h.find(t=>t.assets.includes(e.id))?.id??``,onMove:(e,t)=>M(e.id,t||null)}:void 0,ae=[{label:L(`project.assetUpload`),icon:(0,$.jsx)(Ke,{className:`size-4 shrink-0`}),onPick:()=>T.current?.click()},{label:L(`project.assetFromUrl`),icon:(0,$.jsx)(Gt,{className:`size-4 shrink-0`}),onPick:()=>w(!0)},...h.length<u.logoSections?[{label:L(`project.assetSectionAdd`),icon:(0,$.jsx)(Lt,{className:`size-4 shrink-0`}),onPick:()=>S(`new`)}]:[]],I=h.length||D.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:[h.length?(0,$.jsx)(i,{value:v,onChange:e=>{y(e),d(``)},label:L(`project.assets`),options:[{id:``,label:L(`project.assetsGeneral`)},...h.map(e=>({id:e.id,label:e.title||L(`project.sectionUntitled`)}))]}):null,A&&!n?(0,$.jsx)(P,{label:L(`project.assetSectionRename`),onClick:()=>S(`current`),children:(0,$.jsx)(_e,{className:`size-4`})}):null]}),ee.length?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`w-56 max-w-[45%] shrink`,children:(0,$.jsx)(oe,{value:l,onChange:d,placeholder:L(`project.assetSearch`)})}),(0,$.jsx)(P,{label:L(s===`list`?`project.viewCards`:`project.viewList`),onClick:c,children:s===`list`?(0,$.jsx)(Ut,{className:`size-4`}):(0,$.jsx)(qt,{className:`size-4`})})]}):null]}):null;return(0,$.jsxs)(ge,{title:L(`project.assets`),hint:L(`project.assetsHint`),save:E,tabs:I,action:n?null:(0,$.jsx)(he,{entries:ae}),children:[(0,$.jsx)(`input`,{ref:T,type:`file`,multiple:!0,accept:dn,className:`sr-only`,tabIndex:-1,"aria-hidden":!0,onChange:e=>{let t=Array.from(e.target.files??[]);e.target.value=``,t.length&&N(t)}}),ne.length?s===`cards`?(0,$.jsx)(nn,{projectId:e,kind:`asset`,files:ne,actions:o,moveTo:ie,onRemove:F,onPreview:e=>p(e.id)}):(0,$.jsx)(`ul`,{className:`flex flex-col gap-2`,children:ne.map(t=>(0,$.jsx)(mn,{projectId:e,file:t,actions:o,moveTo:ie,onPreview:()=>p(t.id),onRemove:()=>F(t)},t.id))}):ee.length?null:n?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:L(`project.staysLocal`)}):(0,$.jsxs)(Y,{accept:dn,onFiles:e=>void N(e),className:`h-16 w-full`,children:[o.busy?(0,$.jsx)(re,{className:`size-4`}):(0,$.jsx)(Ke,{className:`size-4`}),L(`project.drop`),` `,(0,$.jsx)(`span`,{className:`underline`,children:L(`project.assetAdd`)})]}),o.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:o.error}):null,j?(0,$.jsx)(pn,{projectId:e,file:j,actions:o,onClose:()=>p(null)}):null,x?(0,$.jsx)(hn,{section:x===`current`?A:null,onClose:()=>S(null),onSave:e=>{if(x===`current`&&A)g(t=>t.map(t=>t.id===A.id?{...t,title:e}:t));else{let t=R();g(n=>[...n,{id:t,title:e,assets:[]}]),y(t)}},onRemove:x===`current`&&A?()=>{(!A.assets.length||confirm(L(`project.assetSectionRemoveConfirm`,{name:A.title})))&&(g(e=>e.filter(e=>e.id!==A.id)),y(``),S(null))}:void 0}):null,C?(0,$.jsx)(rn,{kind:`asset`,onClose:()=>w(!1),fetchUrl:e=>o.fromUrl(`asset`,e),onAdded:e=>{for(let t of e)M(t.id,A?.id??null)}}):null]})}var _n=/^#[0-9a-fA-F]{6}$/;async function vn(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 yn={linear:`project.gradientLinear`,radial:`project.gradientRadial`,conic:`project.gradientConic`};function bn({projectId:e,gradient:t,isNew:n,brand:r,onSave:i,onClose:o}){let[s,c]=(0,Q.useState)(t),[l,u]=(0,Q.useState)(a(t)),[f,p]=(0,Q.useState)(!1),[m,_]=(0,Q.useState)(``),[v,b]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(null),[w,T]=(0,Q.useState)(!n),E=e=>{c(e),u(a(e)),p(!1)},D=(e,t)=>E({...s,stops:s.stops.map((n,r)=>r===e?{...n,...t}:n)}),O=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));E({...s,stops:[...s.stops,{color:e??t[0]?.color??`#888888`,at:n}]})},k=async()=>{b(!0),C(null);try{let{gradient:t}=await Se.post(`/api/studio/projects/${e}/gradients/describe`,{text:m.trim(),...w?{gradient:{name:s.name,type:s.type,angle:s.angle,stops:s.stops}}:{}});E({...s,...t,name:s.name.trim()?s.name:t.name}),_(``),T(!0)}catch(e){C(e.message)}b(!1)};return(0,$.jsx)(g,{open:!0,onClose:o,wide:!0,title:L(n?`project.gradientNew`:`project.gradientEdit`),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),m.trim()&&!v&&k()},children:[(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(h,{"data-autofocus":n||void 0,value:m,maxLength:1e3,"aria-label":L(`project.gradientDescribe`),placeholder:L(w?`project.gradientDescribeChange`:`project.gradientDescribeNew`),onChange:e=>_(e.target.value),className:`min-w-0 flex-1`}),(0,$.jsxs)(Z,{type:`submit`,variant:`secondary`,busy:v,disabled:!m.trim(),children:[(0,$.jsx)(H,{className:`size-4`}),L(w?`project.gradientDescribeApply`:`project.gradientDescribeMake`)]})]}),(0,$.jsx)(`p`,{className:X(`mt-1.5 text-[0.8125rem]`,S?`text-rose`:`text-ink-3`),children:S??L(`project.gradientDescribeHint`)})]}),(0,$.jsx)(`div`,{className:`h-40 rounded-lg ring-1 ring-border-soft`,style:{background:a(s)}}),(0,$.jsxs)(`div`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(y,{children:L(`project.gradientName`)}),(0,$.jsx)(h,{value:s.name,maxLength:80,placeholder:L(`project.gradientNamePlaceholder`),onChange:e=>c({...s,name:e.target.value})})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(y,{children:L(`project.fillUseLabel`)}),(0,$.jsx)(h,{value:s.description??``,maxLength:400,placeholder:L(`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)(y,{children:L(`project.gradientType`)}),(0,$.jsx)(`div`,{className:`flex gap-1 rounded-full bg-paper-2 p-0.5 ring-1 ring-border-soft`,children:d.map(e=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":s.type===e,onClick:()=>E({...s,type:e}),className:X(`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:L(yn[e])},e))})]}),s.type===`radial`?null:(0,$.jsxs)(`div`,{className:`min-w-56`,children:[(0,$.jsx)(y,{children:L(`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":L(`project.gradientAngle`),onChange:e=>E({...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)(y,{children:L(`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)(ae,{value:_n.test(e.color)?e.color:`#888888`,onChange:e=>D(t,{color:e.target.value})}),(0,$.jsx)(h,{value:e.color,spellCheck:!1,onChange:e=>{let n=e.target.value.trim();_n.test(n)&&D(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":L(`project.gradientAt`),onChange:e=>D(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)(P,{label:L(`project.remove`),disabled:s.stops.length<=2,onClick:()=>E({...s,stops:s.stops.filter((e,n)=>n!==t)}),className:`hover:text-rose`,children:(0,$.jsx)(q,{className:`size-4`})})]},t))}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[s.stops.length<12?(0,$.jsxs)(Z,{variant:`secondary`,size:`sm`,onClick:()=>O(),children:[(0,$.jsx)(I,{className:`size-4`}),` `,L(`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:L(`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:()=>O(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)(y,{children:`CSS`}),(0,$.jsx)(h,{value:l,spellCheck:!1,onChange:e=>{u(e.target.value);let t=x(e.target.value);p(!t),t&&c({...s,...t})},className:`font-mono text-[0.8125rem]`}),(0,$.jsx)(`p`,{className:X(`mt-1.5 text-[0.8125rem]`,f?`text-rose`:`text-ink-3`),children:L(f?`project.gradientCssError`:`project.gradientCssHint`)})]}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(Z,{variant:`ghost`,onClick:o,children:L(`common.cancel`)}),(0,$.jsx)(Z,{onClick:()=>{i(s),o()},children:L(`settings.save`)})]})]})})}var xn=`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`,Sn=`size-8 bg-card shadow-soft hover:bg-card`;function Cn({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)(J,{value:e,label:L(`project.gradientName`),placeholder:t,maxLength:80,onChange:e=>a({name:e}),className:`font-medium text-[0.875rem]`}),(0,$.jsx)(J,{value:n??``,label:L(`project.fillUseLabel`),placeholder:r,maxLength:400,onChange:e=>a({description:e}),className:`text-[0.8125rem] text-ink-3`})]})}function wn({gradient:e,readOnly:t,onEdit:n,onChange:r,onRemove:i}){let o=a(e),[s,c]=(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":L(`project.gradientEdit`),onClick:n,className:`block h-28 w-full rounded-md ring-1 ring-border-soft transition enabled:hover:brightness-105`,style:{background:o}}),(0,$.jsxs)(`div`,{className:xn,children:[(0,$.jsx)(P,{label:L(s?`project.gradientCopied`:`project.gradientCopy`),onClick:()=>{navigator.clipboard.writeText(`background: ${o};`),c(!0),setTimeout(()=>c(!1),1500)},className:Sn,children:(0,$.jsx)(C,{className:`size-4`})}),(0,$.jsx)(P,{label:L(`project.download`),onClick:()=>void vn(e,e.name),className:Sn,children:(0,$.jsx)(ce,{className:`size-4`})}),t?null:(0,$.jsx)(P,{label:L(`project.remove`),onClick:i,className:X(Sn,`hover:text-rose`),children:(0,$.jsx)(q,{className:`size-4`})})]})]}),(0,$.jsx)(Cn,{name:e.name,namePlaceholder:L(`project.gradientName`),description:e.description,usePlaceholder:L(`project.gradientUse`),readOnly:t,onChange:r})]})}function Tn(e,t){return{backgroundImage:`url("${e}")`,backgroundSize:t?`64px`:`cover`,backgroundRepeat:t?`repeat`:`no-repeat`,backgroundPosition:`center`}}function En({projectId:e,pattern:t,fileName:n,readOnly:r,onEdit:i,onChange:a,onRemove:o}){let s=E(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":L(`project.patternEdit`),onClick:i,className:`block h-28 w-full rounded-md ring-1 ring-border-soft transition enabled:hover:brightness-105`,style:Tn(s,t.tile)}),(0,$.jsxs)(`div`,{className:xn,children:[(0,$.jsx)(`a`,{href:s,download:n,"aria-label":L(`project.download`),title:L(`project.download`),className:X(`inline-flex items-center justify-center rounded-full text-ink-3 transition hover:text-ink`,Sn),children:(0,$.jsx)(ce,{className:`size-4`})}),r?null:(0,$.jsx)(P,{label:L(`project.remove`),onClick:o,className:X(Sn,`hover:text-rose`),children:(0,$.jsx)(q,{className:`size-4`})})]})]}),(0,$.jsx)(Cn,{name:t.name,namePlaceholder:n,description:t.description,usePlaceholder:L(`project.patternUse`),readOnly:r,onChange:a})]})}function Dn({projectId:e,pattern:t,isNew:n,fileName:r,busy:i,error:a,upload:o,removeFile:s,onSave:c,onClose:l}){let[u,d]=(0,Q.useState)(t),[p,m]=(0,Q.useState)([]),_=async e=>{let t=e[0];if(!t)return;let n=await o(t);n&&(m(e=>[...e,n.id]),d(e=>({...e,file:n.id,name:e.name||n.name.replace(/\.[^.]+$/,``)})))},v=()=>{for(let e of p)s(e);l()};return(0,$.jsx)(g,{open:!0,onClose:v,wide:!0,title:L(n?`project.patternNew`:`project.patternEdit`),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[u.file?(0,$.jsx)(`div`,{className:`relative h-40 rounded-lg ring-1 ring-border-soft`,style:Tn(E(e,u.file),u.tile),children:(0,$.jsxs)(Y,{accept:`image/*`,multiple:!1,onFiles:e=>void _(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)(re,{className:`size-4`}):(0,$.jsx)(f,{className:`size-4`}),L(`project.patternReplace`)]})}):(0,$.jsxs)(Y,{accept:`image/*`,multiple:!1,onFiles:e=>void _(e),className:`h-40 flex-col`,children:[i?(0,$.jsx)(re,{className:`size-5`}):(0,$.jsx)(f,{className:`size-5`}),L(`project.patternPick`)]}),(0,$.jsxs)(`div`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(y,{children:L(`project.patternName`)}),(0,$.jsx)(h,{value:u.name,maxLength:80,placeholder:u.file?r(u.file):L(`project.patternNamePlaceholder`),onChange:e=>d({...u,name:e.target.value})})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(y,{children:L(`project.fillUseLabel`)}),(0,$.jsx)(h,{value:u.description??``,maxLength:400,placeholder:L(`project.patternUse`),onChange:e=>d({...u,description:e.target.value})})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(y,{children:L(`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":!!u.tile===e,onClick:()=>d({...u,tile:e||void 0}),className:X(`h-9 rounded-full px-4 font-medium text-[0.875rem] transition`,!!u.tile===e?`bg-card text-ink shadow-sm`:`text-ink-3 hover:text-ink-2`),children:L(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)(Z,{variant:`ghost`,onClick:v,children:L(`common.cancel`)}),(0,$.jsx)(Z,{disabled:!u.file||i,onClick:()=>{for(let e of p.filter(e=>e!==u.file))s(e);t.file&&t.file!==u.file&&s(t.file),c({...u,name:u.name.trim(),description:u.description?.trim()||void 0}),l()},children:L(n?`project.add`:`settings.save`)})]})]})})}var On=/^#[0-9a-fA-F]{6}$/;function kn({projectId:e,onAdd:t,onClose:n}){let[r,i]=(0,Q.useState)(``),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)([]),p=async()=>{o(!0),c(null);try{let{colors:t}=await Se.post(`/api/studio/projects/${e}/colors/scan`,{url:r.trim()});t.length?(u(t),f([])):c(L(`project.colorsNoneFound`))}catch(e){c(e.message)}o(!1)};return(0,$.jsx)(g,{open:!0,onClose:n,wide:l?!0:void 0,title:L(l?`project.colorsFound`:`project.colorsFromUrl`),children:l?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:L(`project.colorsFoundHint`)}),(0,$.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(120px,1fr))] gap-3`,children:l.map(e=>{let t=d.includes(e.value);return(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>f(n=>t?n.filter(t=>t!==e.value):[...n,e.value]),className:X(`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)(A,{className:`size-3.5`})}):null]},e.value)})}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(Z,{variant:`ghost`,onClick:()=>u(null),children:L(`run.back`)}),(0,$.jsx)(Z,{disabled:!d.length,onClick:()=>{t(l.filter(e=>d.includes(e.value))),n()},children:d.length>1?L(`project.addMany`,{n:d.length}):L(`project.add`)})]})]}):(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),p()},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(y,{children:L(`project.logoUrl`)}),(0,$.jsx)(h,{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:L(`project.colorsUrlHint`)})]}),s?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:s}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(Z,{variant:`ghost`,onClick:n,children:L(`common.cancel`)}),(0,$.jsx)(Z,{type:`submit`,busy:a,disabled:!r.trim(),children:L(`run.next`)})]})]})})}function An({projectId:e,data:t,colors:n,sections:r,gradients:i,patterns:a,rules:o,sectioned:c,ruled:l,save:d,readOnly:f}){let[p,g]=(0,Q.useState)(()=>n.map(e=>({...e,id:R()}))),[v,y]=(0,Q.useState)(r),[b,x]=(0,Q.useState)(i),[S,C]=(0,Q.useState)(a),[w,T]=(0,Q.useState)(null),[E,D]=(0,Q.useState)(null),O=_(e,f),k=ye(o),[A,ee]=(0,Q.useState)(null),[j,te]=(0,Q.useState)(null),[ne,N]=(0,Q.useState)(!1),re=m({colors:p.filter(e=>On.test(e.value)).map(({name:e,value:t,section:n})=>({name:e.trim(),value:t,...n?{section:n}:{}})),colorSections:v,gradients:b,patterns:S,colorRules:k.rules},d),F=c?v:[],ie=F.filter(e=>(e.kind??`colors`)===`colors`),oe=e=>ie.some(t=>t.id===e.section),B=p.filter(e=>!oe(e)),se=(B[0]??p[0])?.id,V=(e,t)=>g(n=>n.map(n=>n.id===e?{...n,...t}:n)),H=e=>g(t=>[...t,...e.map(e=>({...e,id:R()}))].slice(0,u.colors)),G=[{value:``,label:L(`project.sectionStandard`)},...ie.map(e=>({value:e.id,label:e.title||L(`project.sectionUntitled`)}))],K=(e,t)=>{let n=R();ee(n),y(r=>[...r,{id:n,title:t,...e===`colors`?{}:{kind:e}}])},ce=e=>({id:R(),name:``,section:e,type:`linear`,angle:90,stops:[{color:p[0]?.value&&On.test(p[0].value)?p[0].value:`#4b73ff`,at:0},{color:p[1]?.value&&On.test(p[1].value)?p[1].value:`#ff6d1b`,at:100}]}),le=e=>t.files.find(t=>t.id===e)?.name??`pattern`,ue=[...p.length<u.colors?[{label:L(`project.colorNew`),icon:(0,$.jsx)(I,{className:`size-4 shrink-0`}),onPick:()=>Y()},{label:L(`project.colorsFromUrl`),icon:(0,$.jsx)(Gt,{className:`size-4 shrink-0`}),onPick:()=>N(!0)}]:[],...c&&v.length<u.logoSections?[{label:L(`project.colorSectionAdd`),icon:(0,$.jsx)(Lt,{className:`size-4 shrink-0`}),onPick:()=>K(`colors`,``)},{label:L(`project.gradientSectionAdd`),icon:(0,$.jsx)(jt,{className:`size-4 shrink-0`}),onPick:()=>K(`gradients`,L(`project.gradientSectionTitle`))},{label:L(`project.patternSectionAdd`),icon:(0,$.jsx)(zt,{className:`size-4 shrink-0`}),onPick:()=>K(`patterns`,L(`project.patternSectionTitle`))}]:[],...!l||k.full?[]:[{label:L(`project.ruleNew`),icon:(0,$.jsx)(Ye,{className:`size-4 shrink-0`}),onPick:()=>k.add()}]],J=e=>(0,$.jsxs)(`div`,{className:`group/row flex items-center gap-2`,children:[(0,$.jsx)(ae,{value:On.test(e.value)?e.value:`#888888`,onChange:t=>V(e.id,{value:t.target.value})}),(0,$.jsx)(h,{value:e.name,autoFocus:e.id===j,placeholder:L(`project.colorName`),maxLength:120,onChange:t=>V(e.id,{name:t.target.value}),className:`min-w-0 flex-1`}),(0,$.jsx)(h,{value:e.value,placeholder:`#e0531b`,spellCheck:!1,onChange:t=>V(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===se?(0,$.jsx)(`span`,{className:`mr-1 max-sm:hidden`,children:(0,$.jsx)(M,{tone:`ember`,children:L(`project.colorAccent`)})}):f?null:(0,$.jsx)(P,{label:L(`project.colorFirst`),onClick:()=>g(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)(s,{className:`size-4`})}),f||!ie.length?null:(0,$.jsx)(W,{options:G,value:oe(e)?e.section??``:``,onChange:t=>V(e.id,{section:t||void 0}),className:`opacity-0 focus-within:opacity-100 group-hover/row:opacity-100 coarse:opacity-100`}),f?null:(0,$.jsx)(P,{label:L(`project.remove`),onClick:()=>g(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)(q,{className:`size-4`})})]})]},e.id),Y=e=>{let t=R();te(t),g(n=>[...n,{id:t,name:``,value:`#888888`,...e?{section:e}:{}}])};return(0,$.jsxs)(ge,{title:L(`project.colors`),hint:L(`project.colorsHint`),save:re,locked:f,action:f?null:(0,$.jsx)(he,{entries:ue}),children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[B.length?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:B.map(J)}),f?null:(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:L(`project.colorUse`)})]}):p.length?null:(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:L(`project.colorsEmpty`)}),F.map(t=>{let n=t.kind??`colors`,r=p.filter(e=>e.section===t.id),i=b.filter(e=>e.section===t.id),a=S.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)(xe,{title:t.title,titlePlaceholder:L(n===`gradients`?`project.gradientSectionTitlePlaceholder`:n===`patterns`?`project.patternSectionTitlePlaceholder`:`project.colorSectionTitle`),kind:n===`gradients`?{icon:(0,$.jsx)(jt,{}),label:L(`project.kindGradients`)}:n===`patterns`?{icon:(0,$.jsx)(zt,{}),label:L(`project.kindPatterns`)}:{icon:(0,$.jsx)(dt,{}),label:L(`project.kindColors`)},autoFocus:A===t.id,readOnly:f,onChange:e=>y(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>{if(!o||confirm(L(n===`colors`?`project.colorSectionRemoveConfirm`:`project.fillSectionRemoveConfirm`,{name:t.title||L(`project.sectionUntitled`)}))){y(e=>e.filter(e=>e.id!==t.id)),g(e=>e.map(e=>e.section===t.id?{...e,section:void 0}:e)),x(e=>e.filter(e=>e.section!==t.id));for(let e of a)O.remove(e.file);C(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)(wn,{gradient:e,readOnly:f,onEdit:()=>T(e),onChange:t=>x(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>x(t=>t.filter(t=>t.id!==e.id))},e.id)),f||b.length>=u.gradients?null:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>T(ce(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)(I,{className:`size-5`}),L(`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)(En,{projectId:e,pattern:t,fileName:le(t.file),readOnly:f,onEdit:()=>D(t),onChange:e=>C(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>{O.remove(t.file),C(e=>e.filter(e=>e.id!==t.id))}},t.id)),f||S.length>=u.files.pattern?null:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>D({id:R(),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)(I,{className:`size-5`}),L(`project.patternAdd`)]})]}):(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.map(J),f||p.length>=u.colors?null:(0,$.jsx)(z,{label:L(`project.colorAdd`),onClick:()=>Y(t.id)})]})]},t.id)}),l?(0,$.jsx)(U,{rules:k,placeholder:L(`project.colorRulePlaceholder`),readOnly:f}):null]}),O.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:O.error}):null,w?(0,$.jsx)(bn,{projectId:e,gradient:w,isNew:!b.some(e=>e.id===w.id),brand:p.filter(e=>On.test(e.value)),onClose:()=>T(null),onSave:e=>x(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e])}):null,E?(0,$.jsx)(Dn,{projectId:e,pattern:E,isNew:!S.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=>C(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e])}):null,ne?(0,$.jsx)(kn,{projectId:e,onClose:()=>N(!1),onAdd:H}):null]})}var jn=e=>/^(ja|yes|true)$/i.test(e.trim()),Mn={text:at,longtext:We,number:Te,date:Be,url:te,email:Ze,phone:He,boolean:Ve};function Nn({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=Mn[e??t],u=`${L(`project.factType`)}: ${L(`project.type.${e??t}`)}`,d=`flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-[0.875rem] text-ink-2 hover:bg-accent hover:text-ink`,f=e=>{n(e),i(!1)};return(0,$.jsxs)(`div`,{className:`relative`,ref:s,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":u,title:u,"aria-haspopup":`menu`,"aria-expanded":r,onClick:e=>{o(window.innerHeight-e.currentTarget.getBoundingClientRect().bottom<400),i(e=>!e)},className:X(`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:X(`absolute right-0 z-50 w-56 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,a?`bottom-12`:`top-12`),children:[(0,$.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":!e,className:d,onClick:()=>f(void 0),children:[(0,$.jsx)(nt,{className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1`,children:L(`project.factAuto`)}),(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:L(`project.type.${t}`)}),(0,$.jsx)(A,{className:X(`size-4 shrink-0`,e&&`invisible`)})]}),(0,$.jsx)(`div`,{className:`mx-2 my-1 h-px bg-border-soft`}),l.map(t=>{let n=Mn[t];return(0,$.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e===t,className:d,onClick:()=>f(t),children:[(0,$.jsx)(n,{className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1`,children:L(`project.type.${t}`)}),(0,$.jsx)(A,{className:X(`size-4 shrink-0`,e!==t&&`invisible`)})]},t)})]}):null]})}function Pn({facts:e,save:t,readOnly:n}){let r=(0,Q.useRef)(0),i=(0,Q.useRef)(null),[a,o]=(0,Q.useState)(()=>e.map(e=>({...e,id:`f${r.current++}`}))),s=m(a.filter(e=>e.key&&e.label.trim()).map(({key:e,label:t,value:n,type:r})=>({key:e,label:t.trim(),value:n,...r?{type:r}:{}})),t),c=(e,t)=>o(n=>n.map(n=>n.id===e?{...n,...t}:n)),l=(e,t,n=!1)=>{let a=`f${r.current++}`;i.current=`${a}:${t}`;let s={id:a,key:``,label:``,value:``,...e};o(e=>n?[s,...e]:[...e,s])},d=e=>t=>{t&&i.current===e&&(i.current=null,t.focus())},f=ee.filter(e=>!a.some(t=>t.key===e.key));return(0,$.jsxs)(ge,{title:L(`project.facts`),hint:L(`project.factsHint`),save:s,locked:n,action:a.length<u.facts&&!n?(0,$.jsxs)(Z,{variant:`secondary`,size:`sm`,onClick:()=>l({},`label`,!0),children:[(0,$.jsx)(I,{className:`size-4`}),` `,L(`project.factAdd`)]}):null,children:[(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:a.map(e=>{let t=w(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)(h,{ref:d(`${e.id}:label`),value:e.label,placeholder:L(`project.factLabel`),title:e.key?`{{facts.${e.key}}}`:void 0,onChange:t=>c(e.id,{label:t.target.value}),onBlur:()=>{!e.key&&e.label.trim()&&c(e.id,{key:le(e.label,a.map(e=>e.key))})},className:`max-sm:col-span-3 max-sm:font-medium sm:mr-1`}),e.type===`boolean`?(0,$.jsxs)(`div`,{className:`flex h-11 items-center gap-3`,children:[(0,$.jsx)(O,{checked:jn(e.value),label:e.label,onChange:t=>c(e.id,{value:L(t?`project.yes`:`project.no`)})}),(0,$.jsx)(`span`,{className:`text-[0.875rem] text-ink-2`,children:jn(e.value)?L(`project.yes`):L(`project.no`)})]}):(0,$.jsx)(B,{ref:d(`${e.id}:value`),rows:1,minRows:r===`longtext`?2:1,maxRows:10,value:e.value,placeholder:L(`project.factValue`),onChange:t=>c(e.id,{value:t.target.value}),className:`min-h-11`}),(0,$.jsx)(Nn,{type:e.type,detected:t,onChange:t=>c(e.id,{type:t})}),n?null:(0,$.jsx)(P,{label:L(`project.remove`),onClick:()=>o(t=>t.filter(t=>t.id!==e.id)),className:`size-11 rounded-lg hover:text-rose`,children:(0,$.jsx)(q,{className:`size-4`})})]},e.id)})}),a.length<u.facts&&!n?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${a.length?`mt-4`:``}`,children:[(0,$.jsxs)(Z,{variant:`secondary`,size:`sm`,onClick:()=>l({},`label`),children:[(0,$.jsx)(I,{className:`size-4`}),` `,L(`project.factAdd`)]}),f.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>l({key:e.key,label:fe===`en`?e.en:e.de},`value`),className:`inline-flex h-8 items-center gap-1 rounded-full bg-paper-2 px-3 text-[0.8125rem] text-ink-2 transition hover:bg-paper-3 hover:text-ink`,children:[(0,$.jsx)(I,{className:`size-3.5`}),` `,fe===`en`?e.en:e.de]},e.key))]}):null]})}function Fn({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(tn);i(!1),n&&(t.preventDefault(),e(n))},className:X(`-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 In({projectId:e,data:t,readOnly:n,sections:r,rules:i,sectioned:a,ruled:o,save:s}){let c=_(e,n),[l,d]=(0,Q.useState)(r),f=ye(i),[p,h]=(0,Q.useState)(null),[g,v]=(0,Q.useState)(!1),y=(0,Q.useRef)(null),b=m({logoSections:l,logoRules:f.rules},s),x=t.files.filter(e=>e.kind===`logo`),S=new Map(x.map(e=>[e.id,e])),C=a?l:[],w=new Set(C.flatMap(e=>e.logos)),T=x.filter(e=>!w.has(e.id)),E=K(x,l)?.id,D=(e,t)=>d(n=>n.map(n=>{let r=n.logos.filter(t=>t!==e);return{...n,logos:n.id===t?[...r,e]:r}})),O=(e,t)=>d(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)},A=C.length?{options:[{value:``,label:L(`project.sectionStandard`)},...C.map(e=>({value:e.id,label:e.title||L(`project.sectionUntitled`)}))],current:e=>C.find(t=>t.logos.includes(e.id))?.id??``,onMove:(e,t)=>D(e.id,t||null)}:void 0,ee=(t,n,r)=>(0,$.jsx)(nn,{projectId:e,kind:`logo`,files:t,actions:c,accept:`image/*`,addLabel:r?L(`project.logoAdd`):void 0,onUpload:e=>void k(e,n),mainId:E,onMakeMain:e=>{D(e.id,null),c.order(`logo`,[e.id,...x.filter(t=>t.id!==e.id).map(e=>e.id)])},moveTo:A,onRemove:e=>{confirm(L(`project.removeConfirm`,{name:e.name}))&&(c.remove(e.id),D(e.id,null))}}),j=n?void 0:e=>t=>D(t,e),te=[{label:L(`project.logoUpload`),icon:(0,$.jsx)(Ke,{className:`size-4 shrink-0`}),onPick:()=>y.current?.click()},{label:L(`project.logoFromUrl`),icon:(0,$.jsx)(Gt,{className:`size-4 shrink-0`}),onPick:()=>v(!0)},...a&&l.length<u.logoSections?[{label:L(`project.logoSectionAdd`),icon:(0,$.jsx)(Lt,{className:`size-4 shrink-0`}),onPick:()=>{let e=R();h(e),d(t=>[...t,{id:e,title:``,description:``,logos:[]}])}}]:[],...!o||f.full?[]:[{label:L(`project.ruleNew`),icon:(0,$.jsx)(Ye,{className:`size-4 shrink-0`}),onPick:()=>f.add()}]];return(0,$.jsxs)(ge,{title:L(`project.logos`),hint:L(`project.logosHint`),save:b,action:n?null:(0,$.jsx)(he,{entries:te}),children:[(0,$.jsx)(`input`,{ref:y,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)(Fn,{onLogo:j?.(null),children:ee(T,null,!0)}),C.map(e=>(0,$.jsx)(`div`,{className:`group/section`,children:(0,$.jsxs)(Fn,{onLogo:j?.(e.id),className:`flex flex-col gap-3`,children:[(0,$.jsx)(xe,{title:e.title,description:e.description,titlePlaceholder:L(`project.logoSectionTitle`),descriptionPlaceholder:L(`project.logoSectionUse`),autoFocus:p===e.id,readOnly:n,onChange:t=>O(e.id,t),onRemove:()=>{(!e.logos.length||confirm(L(`project.logoSectionRemoveConfirm`,{name:e.title||L(`project.sectionUntitled`)})))&&d(t=>t.filter(t=>t.id!==e.id))}}),ee(e.logos.map(e=>S.get(e)).filter(e=>!!e),e.id,!0)]})},e.id)),o?(0,$.jsx)(U,{rules:f,placeholder:L(`project.logoRulePlaceholder`),readOnly:n}):null]}),c.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:c.error}):null,g?(0,$.jsx)(rn,{kind:`logo`,onClose:()=>v(!1),fetchUrl:e=>c.fromUrl(`logo`,e),onAdded:e=>{for(let t of e)D(t.id,null)}}):null]})}var Ln=new Set;function Rn(e){(0,Q.useEffect)(()=>{let t=e.trim().toLowerCase().replace(/\s+/g,`-`);if(!t||Ln.has(t))return;Ln.add(t);let n=document.createElement(`link`);n.rel=`stylesheet`,n.href=`https://fonts.bunny.net/css?family=${encodeURIComponent(t)}:${j.join(`,`)}&display=swap`,document.head.append(n)},[e])}var zn=e=>e?`"${e}", system-ui, sans-serif`:`system-ui, sans-serif`;function Bn({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 Vn=`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`,Hn={web:`project.fontUseWeb`,documents:`project.fontUseDocuments`,print:`project.fontUsePrint`,images:`project.fontUseImages`,video:`project.fontUseVideo`};function Un({font:e,first:t,readOnly:n,autoFocus:r,onChange:i,onRemove:a}){return Rn(e.family),(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:zn(e.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`})]}),n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`font-medium text-[0.9375rem]`,children:e.family}),e.role?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:e.role}):null]}):(0,$.jsxs)(`div`,{children:[(0,$.jsx)(J,{value:e.family,label:L(`project.fontFamily`),placeholder:L(`project.fontFamily`),maxLength:80,autoFocus:r,onChange:e=>i({family:e}),className:`font-medium text-[0.9375rem]`}),(0,$.jsx)(J,{value:e.role,label:L(`project.fontRole`),placeholder:L(t?`project.fontRoleFirst`:`project.fontRole`),maxLength:200,onChange:e=>i({role:e}),className:`text-[0.875rem] text-ink-3`})]}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:j.map(t=>{let r=e.weights.includes(t);return(0,$.jsx)(`button`,{type:`button`,disabled:n,"aria-pressed":r,onClick:()=>i({weights:r?e.weights.filter(e=>e!==t):[...e.weights,t].sort((e,t)=>e-t)}),style:{fontFamily:zn(e.family),fontWeight:t},className:X(`h-7 rounded-full px-2.5 text-[0.8125rem] tabular-nums transition`,r?`bg-ink text-paper`:`bg-paper-2 text-ink-3 hover:text-ink`,n&&!r&&`hidden`),children:t},t)})}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[n?e.license?(0,$.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:e.license}):null:(0,$.jsx)(J,{value:e.license??``,label:L(`project.fontLicense`),placeholder:L(`project.fontLicensePlaceholder`),maxLength:200,onChange:e=>i({license:e}),className:`text-[0.8125rem] text-ink-3`}),n&&!e.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:L(`project.fontUses`)}),ve.map(t=>{let r=!!e.uses?.includes(t);return(0,$.jsxs)(`button`,{type:`button`,disabled:n,"aria-pressed":r,onClick:()=>{let n=r?(e.uses??[]).filter(e=>e!==t):ve.filter(n=>n===t||e.uses?.includes(n));i({uses:n.length?n:void 0})},className:X(`inline-flex h-7 items-center gap-1 rounded-full px-2.5 text-[0.8125rem] transition`,r?`bg-card text-ink ring-1 ring-border`:`bg-paper-2 text-ink-3 hover:text-ink`,n&&!r&&`hidden`),children:[r?(0,$.jsx)(A,{className:`size-3.5`}):null,L(Hn[t])]},t)})]})]}),n?null:(0,$.jsx)(P,{label:L(`project.remove`),onClick:a,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)(q,{className:`size-4`})})]})}function Wn({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:zn(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)(J,{value:e.name,label:L(`project.styleName`),placeholder:L(`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":L(`project.styleFont`),value:s?.id??``,onChange:e=>a({font:e.target.value}),className:X(Vn,`max-w-40`),children:t.map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.family||L(`project.fontFamily`)},e.id))}):null,(0,$.jsx)(`select`,{"aria-label":L(`project.styleWeight`),value:e.weight,onChange:e=>a({weight:Number(e.target.value)}),className:Vn,children:[...new Set([...j,e.weight])].sort().map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))}),(0,$.jsx)(Bn,{unit:`px`,label:L(`project.styleSize`),min:6,max:400,value:e.size,onChange:e=>a({size:Number(e.target.value)||16})}),(0,$.jsx)(Bn,{unit:L(`project.styleLine`),label:L(`project.styleLineLabel`),min:50,max:300,value:e.lineHeight,onChange:e=>a({lineHeight:Number(e.target.value)||100})}),(0,$.jsx)(Bn,{unit:L(`project.styleTracking`),label:L(`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:L(`project.styleUpper`),"aria-label":L(`project.styleUpper`),onClick:()=>a({uppercase:!e.uppercase}),className:X(`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)(Ft,{className:`size-4`})})]}),r?null:(0,$.jsx)(P,{label:L(`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)(q,{className:`size-4`})})]})]})}function Gn({projectId:e,onAdd:t,onClose:n}){let[r,i]=(0,Q.useState)(``),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)([]),p=async()=>{o(!0),c(null);try{let{fonts:t}=await Se.post(`/api/studio/projects/${e}/fonts/scan`,{url:r.trim()});t.length?(u(t),f(t.slice(0,2).map(e=>e.family))):c(L(`project.fontsNoneFound`))}catch(e){c(e.message)}o(!1)};return(0,$.jsx)(g,{open:!0,onClose:n,wide:l?!0:void 0,title:L(l?`project.fontsFound`:`project.fontsFromUrl`),children:l?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:L(`project.fontsFoundHint`)}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:l.map(e=>(0,$.jsx)(Kn,{font:e,on:d.includes(e.family),onToggle:()=>f(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)(Z,{variant:`ghost`,onClick:()=>u(null),children:L(`run.back`)}),(0,$.jsx)(Z,{disabled:!d.length,onClick:()=>{t(l.filter(e=>d.includes(e.family))),n()},children:d.length>1?L(`project.addMany`,{n:d.length}):L(`project.add`)})]})]}):(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),p()},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(y,{children:L(`project.logoUrl`)}),(0,$.jsx)(h,{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:L(`project.fontsUrlHint`)})]}),s?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:s}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(Z,{variant:`ghost`,onClick:n,children:L(`common.cancel`)}),(0,$.jsx)(Z,{type:`submit`,busy:a,disabled:!r.trim(),children:L(`run.next`)})]})]})})}function Kn({font:e,on:t,onToggle:n}){return Rn(e.family),(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:n,className:X(`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:zn(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(` · `):L(`project.fontWeightsUnknown`)})]}),t?(0,$.jsx)(`span`,{className:`grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,$.jsx)(A,{className:`size-3.5`})}):null]})}function qn({projectId:e,fonts:t,styles:n,rules:r,ruled:i,sample:a,save:o,readOnly:s}){let[c,l]=(0,Q.useState)(t),[d,f]=(0,Q.useState)(n),p=ye(r),[h,g]=(0,Q.useState)(null),[_,v]=(0,Q.useState)(!1),y=m({fonts:c,textStyles:d,typeRules:p.rules},o),b=(e,t=!1)=>{let n=e.map(e=>({id:R(),family:e.family,role:``,weights:e.weights}));t&&n[0]&&g(n[0].id),l(e=>[...e,...n].slice(0,u.fonts))},x=()=>{let e=R();g(e),f(t=>[...t,{id:e,name:``,size:16,weight:400,lineHeight:150,tracking:0}])},S=[...c.length<u.fonts?[{label:L(`project.fontNew`),icon:(0,$.jsx)(I,{className:`size-4 shrink-0`}),onPick:()=>b([{family:``,weights:[400,700]}],!0)},{label:L(`project.fontsFromUrl`),icon:(0,$.jsx)(Gt,{className:`size-4 shrink-0`}),onPick:()=>v(!0)}]:[],...d.length<u.textStyles?[{label:L(`project.styleNew`),icon:(0,$.jsx)(et,{className:`size-4 shrink-0`}),onPick:x}]:[],...!i||p.full?[]:[{label:L(`project.ruleNew`),icon:(0,$.jsx)(Ye,{className:`size-4 shrink-0`}),onPick:()=>p.add()}]];return(0,$.jsxs)(ge,{title:L(`project.typography`),hint:L(`project.typographyHint`),save:y,action:s?null:(0,$.jsx)(he,{entries:S}),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((e,t)=>(0,$.jsx)(Un,{font:e,first:t===0,readOnly:s,autoFocus:h===e.id,onChange:t=>l(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>l(t=>t.filter(t=>t.id!==e.id))},e.id))}):(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:L(`project.fontsEmpty`)}),d.length?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`font-medium text-[0.9375rem]`,children:L(`project.styles`)}),s?null:(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3 leading-snug`,children:L(`project.stylesHint`)}),(0,$.jsx)(`ul`,{className:`mt-2 flex flex-col`,children:d.map(e=>(0,$.jsx)(Wn,{style:e,fonts:c,sample:a,readOnly:s,autoFocus:h===e.id,onChange:t=>f(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>f(t=>t.filter(t=>t.id!==e.id))},e.id))})]}):null,i?(0,$.jsx)(U,{rules:p,placeholder:L(`project.typeRulePlaceholder`),readOnly:s}):null]}),_?(0,$.jsx)(Gn,{projectId:e,onClose:()=>v(!1),onAdd:e=>b(e)}):null]})}function Jn({project:e,save:t}){let[n,r]=(0,Q.useState)(e.brand.name??``),[i,a]=(0,Q.useState)(e.brand.about??``),o=m({name:n.trim(),about:i.trim()},e=>t({brand:e}));return(0,$.jsx)(ge,{title:L(`project.base`),hint:L(`project.baseHint`),save:o,locked:e.readOnly,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(y,{children:L(`project.title`)}),(0,$.jsx)(h,{value:n,maxLength:120,onChange:e=>r(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:L(`project.titleHint`)})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(y,{children:L(`project.about`)}),(0,$.jsx)(B,{minRows:4,value:i,onChange:e=>a(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:L(`project.aboutHint`)})]})]})})}function Yn({project:e,group:t,children:n}){let r=p(),i=k(e.id),[a,o]=(0,Q.useState)(0),s=async t=>{await Se.patch(`/api/studio/projects/${e.id}`,t),await r.invalidateQueries({queryKey:[`projects`]})},c=Xe({mutationFn:()=>Se.del(`/api/studio/projects/${e.id}`),onSuccess:()=>r.invalidateQueries({queryKey:[`projects`]})}),l=rt(),u=ut(),d=i.data??{files:[],embeddings:!0},f=`${e.id}:${a}`,m=e.readOnly,h=t===`knowledge`,g=Qe(`brandSections`),_=Qe(`brandRules`),v=Qe(`typography`);return tt(m?{}:{title:L(h?`project.assistantTitleKnowledge`:`project.assistantTitle`),hello:L(h?`project.assistantHelloKnowledge`:`project.assistantHello`),placeholder:L(h?`project.assistantComposerKnowledge`:`project.assistantComposer`),suggestions:h?[{label:L(`assistant.suggest.knowledgeHow`)},{label:L(`assistant.suggest.knowledgeSite`),fill:!0},{label:L(`assistant.suggest.knowledgeCategories`)}]:[{label:L(`assistant.suggest.readSite`),fill:!0},{label:L(`assistant.suggest.missing`)},{label:L(`assistant.suggest.facts`)}],summary:h?void 0:[e.brand.name?`title "${e.brand.name}"`:`no title`,`${e.facts.length} facts`,`${e.brand.colors?.length??0} colours`,`${d.files.filter(e=>e.kind===`logo`).length} logos`].join(` · `),onChanged:()=>o(e=>e+1)}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[m?(0,$.jsx)(Ge,{children:Ue(e)}):null,t===`info`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(V,{id:`base`,children:(0,$.jsx)(Jn,{project:e,save:s},`base:${f}`)}),(0,$.jsx)(V,{id:`facts`,children:(0,$.jsx)(Pn,{facts:e.facts,save:e=>s({facts:e}),readOnly:m},`facts:${f}`)}),(0,$.jsx)(V,{id:`logos`,children:(0,$.jsx)(In,{projectId:e.id,data:d,readOnly:m,sections:e.brand.logoSections??[],rules:e.brand.logoRules??[],sectioned:g,ruled:_,save:e=>s({brand:e})},`logos:${f}`)}),(0,$.jsx)(V,{id:`colors`,children:(0,$.jsx)(An,{projectId:e.id,data:d,colors:e.brand.colors??[],sections:e.brand.colorSections??[],gradients:e.brand.gradients??[],patterns:e.brand.patterns??[],rules:e.brand.colorRules??[],sectioned:g,ruled:_,save:e=>s({brand:e}),readOnly:m},`colors:${f}`)}),v?(0,$.jsx)(V,{id:`typography`,children:(0,$.jsx)(qn,{projectId:e.id,fonts:e.brand.fonts??[],styles:e.brand.textStyles??[],rules:e.brand.typeRules??[],ruled:_,sample:e.brand.name||L(`project.typeSample`),save:e=>s({brand:e}),readOnly:m},`typography:${f}`)}):null,(0,$.jsx)(V,{id:`assets`,children:(0,$.jsx)(gn,{projectId:e.id,data:d,readOnly:m,sections:e.brand.assetSections??[],save:e=>s({brand:e})},`assets:${f}`)})]}):null,n,t===`info`&&l&&!m&&u?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(Z,{variant:`danger`,busy:c.isPending,onClick:()=>confirm(`${L(`settings.delete`)}?`)&&c.mutate(),children:L(`settings.delete`)}),c.error?(0,$.jsx)(`p`,{className:`mt-2 text-[0.875rem] text-rose`,children:c.error.message}):null]}):null]})}var Xn={q:``,mode:``,days:0};function Zn(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 pe({queryKey:[`results`,e,i],queryFn:()=>Se.get(`/api/studio/projects/${e}/results${i&&`?${i}`}`),enabled:!!e,placeholderData:e=>e,refetchInterval:15e3})}function Qn({filter:e,onFilter:t}){let[n,r]=(0,Q.useState)(e.q);return(0,Q.useEffect)(()=>{if(n===e.q)return;let r=setTimeout(()=>t({...e,q:n}),250);return()=>clearTimeout(r)},[n,e,t]),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsxs)(`div`,{className:`relative min-w-0 flex-1 basis-56`,children:[(0,$.jsx)(de,{className:`-translate-y-1/2 pointer-events-none absolute top-1/2 left-3 size-4 text-ink-3`}),(0,$.jsx)(h,{type:`search`,value:n,onChange:e=>r(e.target.value),placeholder:L(`space.resultsSearch`),"aria-label":L(`space.resultsSearch`),className:`w-full pl-9`})]}),(0,$.jsx)(F,{value:e.mode,onChange:n=>t({...e,mode:n}),options:[{value:``,label:L(`space.resultsModeAll`)},{value:`live`,label:`Live`},{value:`test`,label:`Test`}],className:`w-32`}),(0,$.jsx)(F,{value:String(e.days),onChange:n=>t({...e,days:Number(n)}),options:[{value:`0`,label:L(`space.resultsAnyTime`)},{value:`1`,label:L(`space.resultsDay`)},{value:`7`,label:L(`space.resultsDays`,{n:7})},{value:`30`,label:L(`space.resultsDays`,{n:30})}],className:`w-44`})]})}function $n({data:e,wizardId:t,filter:n,onFilter:r}){let[i,a]=(0,Q.useState)(null),o=t=>e.wizards.find(e=>e.id===t)?.title??``,s=new Intl.DateTimeFormat(fe,{dateStyle:`medium`,timeStyle:`short`});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(ge,{title:t?o(t):L(`space.resultsAll`),hint:L(`space.resultsHint`),plain:!0,children:[(0,$.jsx)(Qn,{filter:n,onFilter:r}),e.runs.length?(0,$.jsx)(c,{className:`flex flex-col p-1.5`,children:e.runs.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>a(e),className:`flex items-center gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`truncate text-[0.875rem]`,children:t?s.format(new Date(e.doneAt)):o(e.wizardId)}),(0,$.jsxs)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:[t?null:`${s.format(new Date(e.doneAt))} · `,L(`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:L(`space.resultFiles`,{n:e.assets}),children:[(0,$.jsx)(be,{className:`size-3.5`}),e.assets]}):null,e.mode===`test`?(0,$.jsx)(M,{children:`Test`}):(0,$.jsxs)(M,{tone:`live`,children:[`Live v`,e.version]})]},e.id))}):(0,$.jsx)(c,{children:(0,$.jsx)(ne,{children:n.q.trim()||n.mode||n.days?L(`space.resultsNone`):L(`space.resultsEmpty`)})})]}),i?(0,$.jsx)(Pe,{header:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-[0.875rem]`,children:o(i.wizardId)}),i.mode===`test`?(0,$.jsx)(M,{children:`Test`}):(0,$.jsxs)(M,{tone:`live`,children:[`Live v`,i.version]})]}),onClose:()=>a(null),children:(0,$.jsx)(kt,{runId:i.id,compact:!0},i.id)}):null]})}function er({project:e,save:t}){let[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(e.name),o=Xe({mutationFn:()=>t({name:i.trim()}),onSuccess:()=>r(!1)});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(P,{label:L(`project.rename`),onClick:()=>{a(e.name),r(!0)},children:(0,$.jsx)(_e,{className:`size-4`})}),(0,$.jsx)(g,{open:n,onClose:()=>r(!1),title:L(`project.rename`),children:(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),i.trim()&&o.mutate()},children:[(0,$.jsx)(h,{"data-autofocus":!0,value:i,maxLength:80,onChange:e=>a(e.target.value)}),o.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:o.error.message}):null,(0,$.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,$.jsx)(Z,{variant:`ghost`,onClick:()=>r(!1),children:L(`common.cancel`)}),(0,$.jsx)(Z,{type:`submit`,busy:o.isPending,disabled:!i.trim(),children:L(`settings.save`)})]})]})})]})}function tr({project:e}){let t=p();return(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(it,{}),e.readOnly?null:(0,$.jsx)(er,{project:e,save:async n=>{await Se.patch(`/api/studio/projects/${e.id}`,n),await t.invalidateQueries({queryKey:[`projects`]})}})]})}function nr(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=_t(),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 rr(e,t){let n=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;document.getElementById(e)?.scrollIntoView({block:`start`,behavior:t&&!n?`smooth`:`auto`})}function ir({groups:e,current:t,onPick:n}){return e.map(e=>{let r=e.sections.map(e=>(0,$.jsx)(yt,{icon:e.icon??Je,label:e.label,selected:e.id===t,onPick:()=>n(e.id)},e.id));return e.label?(0,$.jsx)(St,{label:e.label,children:r},e.plugin):(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:r},`own`)})}function ar(){let{group:e}=r(),[t,n]=se(),i=D(),a=ie(),{hash:o}=a,{project:s,loading:c}=mt(),l=rt(),u=gt(),d=Ot(),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(null),y=ct(e)?e:void 0,b=y?void 0:u.spaceParts.find(t=>t.id===e),x=y??b?.id,S=a.state?.parts===!0,C=lt(ft(),u).map(e=>({...e,to:`/space/${e.id}`})),w=C.find(e=>e.id===x),T=t.get(`show`),E=x?T?2:1:0,O=d?Math.min(E,1):x&&g!==x&&!S?1:0,k=xt(O),A=xt(E),ee=(0,Q.useMemo)(()=>({slot:f,narrow:d,setDetail:h}),[f,d]),j=s?s.brand.name?.trim()||s.name:L(`nav.project`),te=Qe(`typography`)?[]:[`typography`],M=b?u.spaceMenus[b.id]??[]:[],N=b?[{plugin:null,label:null,sections:M}]:y&&y!==`results`?pt(y,u,te):[],P=y?pt(y,u).filter(e=>e.plugin):[],re=nr([...N,...y===`results`?P:[]].flatMap(e=>e.sections.map(e=>e.id))),F=y===`results`&&T&&T!==`all`?T:null,[ae,oe]=(0,Q.useState)(Xn),I=Zn(y===`results`?s?.id:void 0,F,ae),R=I.data?.wizards.find(e=>e.id===F)?.title,z=y===`data`&&T&&T!==`all`||y===`knowledge`&&T&&/^[ptfcvs]:/.test(T)?T:null,B=z?.startsWith(`s:`)?u.spaceSections.find(e=>e.id===z.slice(2)):void 0,H=y===`knowledge`&&z&&/^[ptf]:/.test(z)?z:null,U=Ee(y===`data`?s?.id:void 0),W=Ne(y===`knowledge`?s?.id:void 0),G=ze(z?.startsWith(`v:`)?z.slice(2):``),K=W.data?.categories.find(e=>e.id===(z?.startsWith(`c:`)?z.slice(2):G.data?.category.id)),ce=y===`knowledge`?B?B.label():z?.startsWith(`v:`)?G.data&&`${G.data.category.name}: ${G.data.value}`:z?.startsWith(`c:`)?K?.name:W.data?.items.find(e=>e.key===z)?.title:U.data?Le(U.data).flatMap(e=>e.items).find(e=>e.key===z)?.title:void 0;vt([{label:L(`nav.project`),to:`/space`},...w?[{label:w.label,to:`/space/${w.id}`}]:[],...w&&(m??R??ce)?[{label:m??R??ce}]:[]]);let le={p:`page`,t:`table`,f:`file`,c:`kategorie`,v:`kategorie value`,s:`plugin section`};tt({...y===`data`||y===`results`?{compact:!0}:{},...y===`data`?{suggestions:[{label:L(`assistant.suggest.dataWhat`)},{label:L(`assistant.suggest.dataWho`)},{label:L(`assistant.suggest.dataEdit`)}]}:y===`results`?{suggestions:[{label:L(`assistant.suggest.resultsFailed`)},{label:L(`assistant.suggest.resultsCost`)},{label:L(`assistant.suggest.resultsShare`)}]}:{},...z&&ce?{open:{kind:le[z[0]]??`item`,id:z.slice(2),label:ce}}:F&&R?{open:{kind:`wizard`,id:F,label:R}}:{}});let ue=y===`results`||y===`data`||z?o.slice(1):T||o.slice(1),q=(0,Q.useRef)(``);if((0,Q.useEffect)(()=>{let e=`${x}#${ue}`;ue&&q.current!==e&&document.getElementById(ue)&&(q.current=e,requestAnimationFrame(()=>rr(ue,!1)))},[x,ue,s?.id,u.spaceSections,M.length]),!x){let t=o.slice(1),n=t?st(t,u):null;if(n===`knowledge`&&u.spaceSections.some(e=>e.id===t))return(0,$.jsx)(v,{to:`/space/knowledge?show=s:${t}`,replace:!0});if(n)return(0,$.jsx)(v,{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)(v,{to:`/space/info`,replace:!0,state:{parts:!0}})}if(y===`knowledge`&&!T&&u.spaceSections.some(e=>e.id===o.slice(1)))return(0,$.jsx)(v,{to:`/space/knowledge?show=s:${o.slice(1)}`,replace:!0});let J=e=>{if(d){i({search:`?show=${e}`});return}q.current=`${x}#${e}`,rr(e,!0),i({search:``,hash:e},{replace:!0})},Y=e=>d?n({show:e}):n(e===`all`?{}:{show:e},{replace:!0}),de=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)(V,{id:e.id,children:(0,$.jsx)(ge,{title:e.label(),hint:e.hint?.(),plain:!0,children:(0,$.jsx)(ht,{of:e,children:(0,$.jsx)(e.component,{})})})},e.serial)),fe=d?void 0:re;return(0,$.jsx)(wt.Provider,{value:ee,children:(0,$.jsx)(`div`,{className:`animate-rise`,children:(0,$.jsxs)(`div`,{className:`grid gap-6 md:grid-cols-[13.5rem_minmax(0,1fr)] md:gap-8 lg:grid-cols-[15rem_minmax(0,1fr)] lg:gap-10`,children:[(0,$.jsxs)(`aside`,{className:X(`min-w-0 md:sticky md:top-6 md:self-start`,d&&E===2&&`hidden`,d&&A===`back`&&bt(`back`)),children:[(0,$.jsx)(Ct,{title:j,open:O===1?w??null:null,onBack:()=>d?i(`/space`):_(x??null)}),(0,$.jsx)(`div`,{className:X(bt(k)),children:O===0?(0,$.jsx)(Tt,{entries:C,current:d?void 0:w,onPick:()=>_(null)}):(0,$.jsx)(`div`,{ref:p})},O)]}),x?(0,$.jsxs)(`div`,{className:X(`min-w-0`,d&&E<2&&`hidden`,d&&A===`deeper`&&bt(`deeper`)),children:[d?(0,$.jsx)(`div`,{className:`mb-3`,children:(0,$.jsx)(Dt,{label:w?.label??j,onBack:()=>i(`/space/${x}`)})}):null,l&&s?(0,$.jsx)(`div`,{className:`mb-6`,children:(0,$.jsx)(tr,{project:s})}):null,y===`results`?(0,$.jsxs)(Et,{children:[(0,$.jsxs)(`ul`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsx)(yt,{icon:Vt,label:L(`space.resultsAll`),selected:!d&&!F,onPick:()=>Y(`all`)}),I.data?.wizards.filter(e=>e.results||e.id===F).map(e=>(0,$.jsx)(yt,{icon:nt,label:e.title,badge:e.results?(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:e.results}):null,selected:!d&&e.id===F,onPick:()=>Y(e.id)},e.id))]}),(0,$.jsx)(ir,{groups:P,current:fe,onPick:J})]}):y===`data`?(0,$.jsxs)(Et,{children:[(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,$.jsx)(yt,{icon:Ut,label:L(`data.all`),selected:!d&&!z,onPick:()=>Y(`all`)})}),U.data?Le(U.data).map(e=>(0,$.jsx)(St,{label:e.label,children:e.items.map(e=>(0,$.jsx)(yt,{icon:we[e.kind],label:e.title,selected:!d&&e.key===z,onPick:()=>Y(e.key)},e.key))},e.key)):null,(0,$.jsx)(ir,{groups:P,current:fe,onPick:J})]}):y===`knowledge`?(0,$.jsxs)(Et,{children:[(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,$.jsx)(yt,{icon:Ut,label:L(`know.all`),selected:!(d||z),onPick:()=>Y(`all`)})}),W.data?.categories.length?(0,$.jsx)(St,{label:L(`know.categories`),children:W.data.categories.map(e=>(0,$.jsx)(yt,{icon:Ae[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}`||G.data?.category.id===e.id),onPick:()=>Y(`c:${e.id}`)},e.id))}):null,(0,$.jsx)(ir,{groups:P,current:d?void 0:B?.id,onPick:e=>Y(`s:${e}`)})]}):(0,$.jsx)(Et,{children:(0,$.jsx)(ir,{groups:N,current:fe,onPick:J})}),s&&(y===`info`||y===`knowledge`)?(0,$.jsxs)(Yn,{project:s,group:y,children:[y===`knowledge`?H?H.startsWith(`p:`)?(0,$.jsx)(Me,{pageId:H.slice(2),onGone:()=>Y(`all`),onOpen:Y},H):H.startsWith(`t:`)?(0,$.jsx)(je,{tableId:H.slice(2),onGone:()=>Y(`all`)},H):(0,$.jsx)(ln,{projectId:s.id,fileId:H.slice(2),readOnly:s.readOnly,onGone:()=>Y(`all`)},H):W.data?B?(0,$.jsx)(ge,{title:B.label(),hint:B.hint?.(),plain:!0,children:(0,$.jsx)(ht,{of:B,children:(0,$.jsx)(B.component,{})})},z):z?.startsWith(`c:`)?K?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(ke,{projectId:s.id,category:K,readOnly:s.readOnly,onOpen:Y,onGone:()=>Y(`all`)}),K.type===`choice`?null:(0,$.jsx)(Re,{projectId:s.id,category:K,categories:W.data.categories,onOpen:Y})]},z):null:z?.startsWith(`v:`)?G.data?(0,$.jsx)(Ce,{value:G.data,readOnly:s.readOnly,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[G.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:G.data.items.map(e=>(0,$.jsx)(De,{item:e,categories:W.data.categories.filter(e=>e.id!==G.data?.category.id),onOpen:Y},e.key))}):null,G.data.rows.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>Y(`t:${e.tableId}`),className:`px-1 text-left text-[0.8125rem] text-ink-3 hover:text-ink`,children:L(`know.tocRows`,{n:e.count,table:e.title})},e.tableId))]})},z):null:(0,$.jsx)(V,{id:`documents`,children:(0,$.jsx)(Ie,{projectId:s.id,data:W.data,readOnly:s.readOnly,onOpen:Y})}):null:null,y===`info`?de(P):null]},s.id):null,s&&b?(0,$.jsx)(ht,{of:b,children:(0,$.jsx)(ot,{part:b.id,children:(0,$.jsx)(b.component,{})},s.id)}):null,s&&y===`data`?(0,$.jsx)(`div`,{className:`flex flex-col gap-9 pb-20`,children:z?.startsWith(`t:`)?(0,$.jsx)(je,{tableId:z.slice(2),onGone:()=>Y(`all`)},z):z?.startsWith(`p:`)?(0,$.jsx)(Me,{pageId:z.slice(2),onGone:()=>Y(`all`)},z):(0,$.jsxs)($.Fragment,{children:[U.data?(0,$.jsx)(Fe,{projectId:s.id,data:U.data,readOnly:s.readOnly,onOpen:Y}):null,de(P)]})}):null,s&&y===`results`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[I.data?(0,$.jsx)($n,{data:I.data,wizardId:F,filter:ae,onFilter:oe}):null,I.isError?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:I.error.message}):null,de(P)]}):null,s||c?null:(0,$.jsx)(ne,{children:L(`settings.noProject`)})]}):null]})})})}export{ar as ProjectPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$n as r,J as i,Jn as a,Qn as o,Rt as s,U as c,Vn as l,Wn as u,Wt as d,Xt as f,an as p,sn as m,tn as h,tr as g,z as _,zt as v}from"./ui-DTuixH4y.js";import{a as y,i as b,n as x,o as S,r as C,s as w,t as ee}from"./ChatView-DLJfy69U.js";import{a as T,dt as E,ft as D,ht as te,n as O,o as k,ut as A}from"./index-fflYi8P1.js";import{t as j}from"./RunnerView-B_tJroFM.js";var M={name:`bookmark`,size:24,node:[[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}]]};M.node;var ne=u(M),N={name:`smartphone`,size:24,node:[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]};N.node;var P=u(N),F={name:`square-plus`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}],[`path`,{d:`M12 8v8`,key:`napkw2`}]],aliases:[`plus-square`]};F.node;var I=u(F),L=e(t(),1);function R(){if(window.self===window.top)return null;let e=new URLSearchParams(window.location.search).get(`embed`);return e===`inline`||e===`modal`||e===`popout`?e:null}var z=R(),re=z?new URLSearchParams(window.location.search).get(`page`):null,B=(e,t={})=>window.parent.postMessage({type:`engenty-wizard:${e}`,...t},`*`),ie=()=>B(`close`);function V(e){(0,L.useEffect)(()=>{if(z===`inline`&&!e){let e=document.documentElement;document.getElementById(`root`)?.style.setProperty(`min-height`,`0`),e.style.overflow=`hidden`;let t=new ResizeObserver(()=>B(`height`,{height:Math.ceil(e.getBoundingClientRect().height)}));return t.observe(e),()=>t.disconnect()}if(z===`modal`||z===`popout`){let e=e=>{e.key===`Escape`&&!document.querySelector(`dialog[open]`)&&B(`close`)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}},[e])}var H=e(n(),1);function U(e){(0,L.useEffect)(()=>{if(!e)return;let t=document.documentElement;return t.style.setProperty(`--raw-primary`,e),()=>{t.style.removeProperty(`--raw-primary`)}},[e])}function W(e,t){(0,L.useEffect)(()=>{if(!e||!t)return;let n=i(`/api/public/wizards/${e}`),r=[{rel:`manifest`,href:`${n}/manifest.webmanifest`},{rel:`apple-touch-icon`,href:`${n}/icons/apple-touch-icon.png`},{rel:`icon`,href:`${n}/icons/favicon.png`,type:`image/png`}].flatMap(({rel:e,href:t,type:n})=>{let r=document.querySelector(`link[rel="${e}"]`);if(!r)return[];let i={href:r.getAttribute(`href`),type:r.getAttribute(`type`)};return r.setAttribute(`href`,t),n&&r.setAttribute(`type`,n),[{link:r,before:i}]}),a=document.createElement(`meta`);return a.name=`apple-mobile-web-app-title`,a.content=t,document.head.appendChild(a),()=>{for(let{link:e,before:t}of r)for(let[n,r]of Object.entries(t))r===null?e.removeAttribute(n):e.setAttribute(n,r);a.remove()}},[e,t])}var G=/iPhone|iPad|iPod/.test(navigator.userAgent)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1,K=G||/Android/.test(navigator.userAgent);function q(){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||K&&!e&&!G)return null;let i=/Mac/.test(navigator.platform),a=p(K?`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:()=>{K&&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:[K?(0,H.jsx)(I,{className:`size-4`}):(0,H.jsx)(ne,{className:`size-4`}),p(K?`install.add`:`install.bookmark`)]}),n?(0,H.jsx)(`p`,{className:`max-w-xs leading-relaxed`,children:a}):null]})}function J({brand:e,toggle:t=!0}){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:[e.logoUrl?(0,H.jsx)(`img`,{src:i(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)(D,{})}):null]})})}function Y({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 ae({token:e}){return!/iPhone|iPad|iPod|Android/.test(navigator.userAgent)||O||z?null:(0,H.jsxs)(`a`,{href:T(`${window.location.origin}${c}/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)(P,{className:`size-4`}),` `,p(`install.app`)]})}var X=e=>`wz.run.${e}`,Z=O&&new URLSearchParams(window.location.search).get(`start`)===`1`,Q=z===`inline`?`min-h-80`:`min-h-dvh`;function $(e,t){let n=o(),[r,i]=(0,L.useState)(!1),[a,s]=(0,L.useState)(null),[c,l]=(0,L.useState)(null),u=(()=>{try{return localStorage.getItem(X(e.token))}catch{return null}})();return{busy:r,error:a,captcha:c,setCaptcha:l,start:async()=>{i(!0),s(null);try{let{runId:r}=await _.post(`/api/public/wizards/${e.token}/runs`,{turnstileToken:c??void 0,embedded:z!==null,origin:re??void 0});try{localStorage.setItem(X(e.token),r)}catch{}n(`${t}/${r}`,{replace:Z})}catch(e){s(e.message),i(!1)}},resume:u?()=>n(`${t}/${u}`):null}}function oe({wizard:e}){let{busy:t,error:n,captcha:r,setCaptcha:i,start:a,resume:o}=$(e,`/w/${e.token}`),s=Z&&e.available&&!e.turnstileSiteKey,c=(0,L.useRef)(!1);return(0,L.useEffect)(()=>{s&&!c.current&&(c.current=!0,a())},[s]),s&&!n?(0,H.jsx)(`div`,{className:`flex min-h-[60dvh] items-center justify-center text-ink-4`,children:(0,H.jsx)(f,{})}):(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)(E,{kind:e.avatar,size:190,fluffy:!0}),(0,H.jsx)(`h1`,{className:`mt-2 text-balance font-display font-semibold text-[1.875rem] leading-[1.1] tracking-tight sm:text-[2.125rem]`,children:e.title}),e.description?(0,H.jsx)(`p`,{className:`mt-3 text-[1rem] text-ink-2 leading-relaxed`,children:e.description}):null,e.available?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(v,{size:`lg`,className:`mt-10 min-w-48`,busy:t,disabled:!!e.turnstileSiteKey&&!r,onClick:a,children:[p(`run.start`),` `,(0,H.jsx)(l,{className:`size-4`})]}),e.turnstileSiteKey?(0,H.jsx)(Y,{siteKey:e.turnstileSiteKey,onToken:i}):null,o?(0,H.jsx)(`button`,{type:`button`,onClick:o,className:`mt-4 text-[0.875rem] text-ink-3 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:p(`run.resume`)}):null,(0,H.jsx)(se,{wizard:e,current:`steps`}),z||O?null:(0,H.jsx)(q,{}),(0,H.jsx)(ae,{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??p(`run.unavailable`)}),n?(0,H.jsx)(`p`,{className:`mt-4 text-[0.875rem] text-rose`,children:n}):null]})}function se({wizard:e,current:t}){let n=e.runners.filter(e=>e.id!==t&&e.kind===`page`&&e.url);return n.length?(0,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:p(`run.orAs`,{label:e.label})},e.id))}):null}function ce({wizard:e}){let t=w();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:h(t?.speaking&&`animate-breathe`),children:(0,H.jsx)(E,{kind:e.avatar,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]}),e.brand.logoUrl&&z!==`popout`?(0,H.jsx)(`img`,{src:i(e.brand.logoUrl),alt:e.brand.name,className:`h-6 max-w-[120px] object-contain max-sm:hidden`}):null,z?null:(0,H.jsx)(D,{}),z===`popout`?(0,H.jsx)(d,{label:p(`common.close`),onClick:ie,children:(0,H.jsx)(m,{className:`size-5`})}):null]})})}function le({door:e,wizard:t,header:n,footer:r}){let{busy:i,error:a,captcha:o,setCaptcha:s,start:c,resume:u}=$(t,`/w/${t.token}/${e}`),d=[{key:`hello`,who:`bot`,node:t.description||t.title}];return e!==`chat`&&d.push({key:e,who:`bot`,node:p(e===`video`?`video.hint`:`talk.joinHint`)}),t.available||d.push({key:`unavailable`,who:`bot`,node:t.unavailableReason??p(`run.unavailable`)}),a&&d.push({key:`error`,who:`bot`,node:a,tone:`error`}),t.available&&d.push(S(`start`,(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(b,{primary:!0,busy:i,disabled:!!t.turnstileSiteKey&&!o,onClick:()=>void c(),children:[p(`run.start`),` `,(0,H.jsx)(l,{className:`size-4`})]}),u?(0,H.jsx)(b,{onClick:u,children:p(`run.resume`)}):null,t.turnstileSiteKey?(0,H.jsx)(Y,{siteKey:t.turnstileSiteKey,onToken:s}):null]}))),(0,H.jsxs)(x,{header:n,footer:r,children:[(0,H.jsx)(y,{avatar:t.avatar,lines:d}),(0,H.jsx)(C,{})]})}function ue({className:e}){return(0,H.jsx)(`footer`,{className:h(`text-center text-ink-4`,e),children:(0,H.jsx)(`a`,{href:`${c}/`,target:z?`_blank`:void 0,rel:`noreferrer`,className:`inline-block hover:text-ink-2`,children:p(`run.madeWith`).replace(`engenty wizards`,A.name)})})}function de({chat:e=!1,steps:t=!1,talk:n=!1,video:i=!1}){let{token:l,runId:u}=r(),d=o(),m=g({queryKey:[`public`,l],queryFn:()=>_.get(`/api/public/wizards/${l}`),retry:(e,t)=>s(t)&&e<3}),y=m.data?.runners??[],b=!m.data||y.some(e=>e.id===`talk`),x=!m.data||y.some(e=>e.id===`video`),S=!m.data||y.some(e=>e.id===`chat`)||n&&b||i&&x,C=y[0]?.id,w=e||z===`popout`||!t&&!u&&S&&(C===`chat`||C===`talk`||C===`video`),T=i&&x||!t&&!e&&!n&&C===`video`,D=!T&&(n&&b||!t&&!e&&C===`talk`),M=T?`video`:D?`talk`:`chat`;if(U(m.data?.brand.accent),te(m.data?.avatar),W(l,m.data?.title),V(w),(0,L.useEffect)(()=>{m.data&&(document.title=m.data.title)},[m.data]),(0,L.useEffect)(()=>{l&&u&&k(`run`,{token:l,runId:u})},[l,u]),m.isLoading)return(0,H.jsx)(`div`,{className:h(`flex items-center justify-center text-ink-4`,Q),children:(0,H.jsx)(f,{})});if(e&&m.data&&!S||n&&m.data&&!b||i&&m.data&&!x)return(0,H.jsx)(a,{to:`/w/${l}`,replace:!0});if(!m.data){let e=s(m.error);return(0,H.jsxs)(`div`,{className:h(`flex flex-col items-center justify-center gap-4 px-6 text-center`,Q),children:[(0,H.jsx)(E,{kind:`pebble`,size:80}),(0,H.jsx)(`p`,{className:`max-w-xs text-ink-3`,children:p(e?`common.offline`:`run.notFound`)}),e?(0,H.jsx)(v,{variant:`secondary`,onClick:()=>void m.refetch(),children:p(`common.retry`)}):null]})}if(w){let e=(0,H.jsx)(ce,{wizard:m.data}),t=O?(0,H.jsx)(`div`,{className:`safe-bottom`}):(0,H.jsx)(ue,{className:`pb-[max(0.375rem,env(safe-area-inset-bottom))] text-[0.6875rem]`});return(0,H.jsx)(`div`,{className:`flex h-dvh flex-col`,children:u?(0,H.jsx)(ee,{runId:u,talk:D,call:T?`video`:D?`audio`:!1,onRestart:()=>d(`/w/${l}/${M}`),header:T||D?void 0:e,footer:t}):(0,H.jsx)(le,{wizard:m.data,header:e,footer:t,door:M})})}return(0,H.jsxs)(`div`,{className:h(`flex flex-col`,Q),children:[z===`inline`||O?null:(0,H.jsx)(J,{brand:m.data.brand,toggle:!z}),(0,H.jsx)(`div`,{className:`flex-1`,children:u?(0,H.jsx)(j,{runId:u,onRestart:()=>d(`/w/${l}`)}):(0,H.jsx)(oe,{wizard:m.data})}),O?(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:`${c}/`,target:z?`_blank`:void 0,rel:`noreferrer`,className:`inline-block py-3.5 hover:text-ink-2`,children:p(`run.madeWith`).replace(`engenty wizards`,A.name)})})]})}export{J as BrandHeader,de as PublicRunner,U as useBrandAccent};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$n as r,J as i,Jn as a,Qn as o,Rt as s,U as c,Vn as l,Wn as u,Wt as d,Xt as f,an as p,sn as m,tn as h,tr as g,z as _,zt as v}from"./ui-DTuixH4y.js";import{a as y,i as b,n as x,o as S,r as C,s as w,t as ee}from"./ChatView-D0RRIl15.js";import{a as T,dt as E,ft as D,ht as te,n as O,o as k,ut as A}from"./index-B-D8UvL9.js";import{t as j}from"./RunnerView-D6sGVnRy.js";var M={name:`bookmark`,size:24,node:[[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}]]};M.node;var ne=u(M),N={name:`smartphone`,size:24,node:[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]};N.node;var P=u(N),F={name:`square-plus`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}],[`path`,{d:`M12 8v8`,key:`napkw2`}]],aliases:[`plus-square`]};F.node;var I=u(F),L=e(t(),1);function R(){if(window.self===window.top)return null;let e=new URLSearchParams(window.location.search).get(`embed`);return e===`inline`||e===`modal`||e===`popout`?e:null}var z=R(),re=z?new URLSearchParams(window.location.search).get(`page`):null,B=(e,t={})=>window.parent.postMessage({type:`engenty-wizard:${e}`,...t},`*`),ie=()=>B(`close`);function V(e){(0,L.useEffect)(()=>{if(z===`inline`&&!e){let e=document.documentElement;document.getElementById(`root`)?.style.setProperty(`min-height`,`0`),e.style.overflow=`hidden`;let t=new ResizeObserver(()=>B(`height`,{height:Math.ceil(e.getBoundingClientRect().height)}));return t.observe(e),()=>t.disconnect()}if(z===`modal`||z===`popout`){let e=e=>{e.key===`Escape`&&!document.querySelector(`dialog[open]`)&&B(`close`)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}},[e])}var H=e(n(),1);function U(e){(0,L.useEffect)(()=>{if(!e)return;let t=document.documentElement;return t.style.setProperty(`--raw-primary`,e),()=>{t.style.removeProperty(`--raw-primary`)}},[e])}function W(e,t){(0,L.useEffect)(()=>{if(!e||!t)return;let n=i(`/api/public/wizards/${e}`),r=[{rel:`manifest`,href:`${n}/manifest.webmanifest`},{rel:`apple-touch-icon`,href:`${n}/icons/apple-touch-icon.png`},{rel:`icon`,href:`${n}/icons/favicon.png`,type:`image/png`}].flatMap(({rel:e,href:t,type:n})=>{let r=document.querySelector(`link[rel="${e}"]`);if(!r)return[];let i={href:r.getAttribute(`href`),type:r.getAttribute(`type`)};return r.setAttribute(`href`,t),n&&r.setAttribute(`type`,n),[{link:r,before:i}]}),a=document.createElement(`meta`);return a.name=`apple-mobile-web-app-title`,a.content=t,document.head.appendChild(a),()=>{for(let{link:e,before:t}of r)for(let[n,r]of Object.entries(t))r===null?e.removeAttribute(n):e.setAttribute(n,r);a.remove()}},[e,t])}var G=/iPhone|iPad|iPod/.test(navigator.userAgent)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1,K=G||/Android/.test(navigator.userAgent);function q(){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||K&&!e&&!G)return null;let i=/Mac/.test(navigator.platform),a=p(K?`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:()=>{K&&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:[K?(0,H.jsx)(I,{className:`size-4`}):(0,H.jsx)(ne,{className:`size-4`}),p(K?`install.add`:`install.bookmark`)]}),n?(0,H.jsx)(`p`,{className:`max-w-xs leading-relaxed`,children:a}):null]})}function J({brand:e,toggle:t=!0}){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:[e.logoUrl?(0,H.jsx)(`img`,{src:i(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)(D,{})}):null]})})}function Y({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 ae({token:e}){return!/iPhone|iPad|iPod|Android/.test(navigator.userAgent)||O||z?null:(0,H.jsxs)(`a`,{href:T(`${window.location.origin}${c}/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)(P,{className:`size-4`}),` `,p(`install.app`)]})}var X=e=>`wz.run.${e}`,Z=O&&new URLSearchParams(window.location.search).get(`start`)===`1`,Q=z===`inline`?`min-h-80`:`min-h-dvh`;function $(e,t){let n=o(),[r,i]=(0,L.useState)(!1),[a,s]=(0,L.useState)(null),[c,l]=(0,L.useState)(null),u=(()=>{try{return localStorage.getItem(X(e.token))}catch{return null}})();return{busy:r,error:a,captcha:c,setCaptcha:l,start:async()=>{i(!0),s(null);try{let{runId:r}=await _.post(`/api/public/wizards/${e.token}/runs`,{turnstileToken:c??void 0,embedded:z!==null,origin:re??void 0});try{localStorage.setItem(X(e.token),r)}catch{}n(`${t}/${r}`,{replace:Z})}catch(e){s(e.message),i(!1)}},resume:u?()=>n(`${t}/${u}`):null}}function oe({wizard:e}){let{busy:t,error:n,captcha:r,setCaptcha:i,start:a,resume:o}=$(e,`/w/${e.token}`),s=Z&&e.available&&!e.turnstileSiteKey,c=(0,L.useRef)(!1);return(0,L.useEffect)(()=>{s&&!c.current&&(c.current=!0,a())},[s]),s&&!n?(0,H.jsx)(`div`,{className:`flex min-h-[60dvh] items-center justify-center text-ink-4`,children:(0,H.jsx)(f,{})}):(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)(E,{kind:e.avatar,size:190,fluffy:!0}),(0,H.jsx)(`h1`,{className:`mt-2 text-balance font-display font-semibold text-[1.875rem] leading-[1.1] tracking-tight sm:text-[2.125rem]`,children:e.title}),e.description?(0,H.jsx)(`p`,{className:`mt-3 text-[1rem] text-ink-2 leading-relaxed`,children:e.description}):null,e.available?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(v,{size:`lg`,className:`mt-10 min-w-48`,busy:t,disabled:!!e.turnstileSiteKey&&!r,onClick:a,children:[p(`run.start`),` `,(0,H.jsx)(l,{className:`size-4`})]}),e.turnstileSiteKey?(0,H.jsx)(Y,{siteKey:e.turnstileSiteKey,onToken:i}):null,o?(0,H.jsx)(`button`,{type:`button`,onClick:o,className:`mt-4 text-[0.875rem] text-ink-3 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:p(`run.resume`)}):null,(0,H.jsx)(se,{wizard:e,current:`steps`}),z||O?null:(0,H.jsx)(q,{}),(0,H.jsx)(ae,{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??p(`run.unavailable`)}),n?(0,H.jsx)(`p`,{className:`mt-4 text-[0.875rem] text-rose`,children:n}):null]})}function se({wizard:e,current:t}){let n=e.runners.filter(e=>e.id!==t&&e.kind===`page`&&e.url);return n.length?(0,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:p(`run.orAs`,{label:e.label})},e.id))}):null}function ce({wizard:e}){let t=w();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:h(t?.speaking&&`animate-breathe`),children:(0,H.jsx)(E,{kind:e.avatar,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]}),e.brand.logoUrl&&z!==`popout`?(0,H.jsx)(`img`,{src:i(e.brand.logoUrl),alt:e.brand.name,className:`h-6 max-w-[120px] object-contain max-sm:hidden`}):null,z?null:(0,H.jsx)(D,{}),z===`popout`?(0,H.jsx)(d,{label:p(`common.close`),onClick:ie,children:(0,H.jsx)(m,{className:`size-5`})}):null]})})}function le({door:e,wizard:t,header:n,footer:r}){let{busy:i,error:a,captcha:o,setCaptcha:s,start:c,resume:u}=$(t,`/w/${t.token}/${e}`),d=[{key:`hello`,who:`bot`,node:t.description||t.title}];return e!==`chat`&&d.push({key:e,who:`bot`,node:p(e===`video`?`video.hint`:`talk.joinHint`)}),t.available||d.push({key:`unavailable`,who:`bot`,node:t.unavailableReason??p(`run.unavailable`)}),a&&d.push({key:`error`,who:`bot`,node:a,tone:`error`}),t.available&&d.push(S(`start`,(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(b,{primary:!0,busy:i,disabled:!!t.turnstileSiteKey&&!o,onClick:()=>void c(),children:[p(`run.start`),` `,(0,H.jsx)(l,{className:`size-4`})]}),u?(0,H.jsx)(b,{onClick:u,children:p(`run.resume`)}):null,t.turnstileSiteKey?(0,H.jsx)(Y,{siteKey:t.turnstileSiteKey,onToken:s}):null]}))),(0,H.jsxs)(x,{header:n,footer:r,children:[(0,H.jsx)(y,{avatar:t.avatar,lines:d}),(0,H.jsx)(C,{})]})}function ue({className:e}){return(0,H.jsx)(`footer`,{className:h(`text-center text-ink-4`,e),children:(0,H.jsx)(`a`,{href:`${c}/`,target:z?`_blank`:void 0,rel:`noreferrer`,className:`inline-block hover:text-ink-2`,children:p(`run.madeWith`).replace(`engenty wizards`,A.name)})})}function de({chat:e=!1,steps:t=!1,talk:n=!1,video:i=!1}){let{token:l,runId:u}=r(),d=o(),m=g({queryKey:[`public`,l],queryFn:()=>_.get(`/api/public/wizards/${l}`),retry:(e,t)=>s(t)&&e<3}),y=m.data?.runners??[],b=!m.data||y.some(e=>e.id===`talk`),x=!m.data||y.some(e=>e.id===`video`),S=!m.data||y.some(e=>e.id===`chat`)||n&&b||i&&x,C=y[0]?.id,w=e||z===`popout`||!t&&!u&&S&&(C===`chat`||C===`talk`||C===`video`),T=i&&x||!t&&!e&&!n&&C===`video`,D=!T&&(n&&b||!t&&!e&&C===`talk`),M=T?`video`:D?`talk`:`chat`;if(U(m.data?.brand.accent),te(m.data?.avatar),W(l,m.data?.title),V(w),(0,L.useEffect)(()=>{m.data&&(document.title=m.data.title)},[m.data]),(0,L.useEffect)(()=>{l&&u&&k(`run`,{token:l,runId:u})},[l,u]),m.isLoading)return(0,H.jsx)(`div`,{className:h(`flex items-center justify-center text-ink-4`,Q),children:(0,H.jsx)(f,{})});if(e&&m.data&&!S||n&&m.data&&!b||i&&m.data&&!x)return(0,H.jsx)(a,{to:`/w/${l}`,replace:!0});if(!m.data){let e=s(m.error);return(0,H.jsxs)(`div`,{className:h(`flex flex-col items-center justify-center gap-4 px-6 text-center`,Q),children:[(0,H.jsx)(E,{kind:`pebble`,size:80}),(0,H.jsx)(`p`,{className:`max-w-xs text-ink-3`,children:p(e?`common.offline`:`run.notFound`)}),e?(0,H.jsx)(v,{variant:`secondary`,onClick:()=>void m.refetch(),children:p(`common.retry`)}):null]})}if(w){let e=(0,H.jsx)(ce,{wizard:m.data}),t=O?(0,H.jsx)(`div`,{className:`safe-bottom`}):(0,H.jsx)(ue,{className:`pb-[max(0.375rem,env(safe-area-inset-bottom))] text-[0.6875rem]`});return(0,H.jsx)(`div`,{className:`flex h-dvh flex-col`,children:u?(0,H.jsx)(ee,{runId:u,talk:D,call:T?`video`:D?`audio`:!1,onRestart:()=>d(`/w/${l}/${M}`),header:T||D?void 0:e,footer:t}):(0,H.jsx)(le,{wizard:m.data,header:e,footer:t,door:M})})}return(0,H.jsxs)(`div`,{className:h(`flex flex-col`,Q),children:[z===`inline`||O?null:(0,H.jsx)(J,{brand:m.data.brand,toggle:!z}),(0,H.jsx)(`div`,{className:`flex-1`,children:u?(0,H.jsx)(j,{runId:u,onRestart:()=>d(`/w/${l}`)}):(0,H.jsx)(oe,{wizard:m.data})}),O?(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:`${c}/`,target:z?`_blank`:void 0,rel:`noreferrer`,className:`inline-block py-3.5 hover:text-ink-2`,children:p(`run.madeWith`).replace(`engenty wizards`,A.name)})})]})}export{J as BrandHeader,de as PublicRunner,U as useBrandAccent};
|