@engenty/wizards-runtime 0.9.6 → 0.9.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/runtime/dist/agents/architect.js +5 -3
- package/apps/runtime/dist/agents/chat-clients.js +299 -0
- package/apps/runtime/dist/agents/company.js +111 -0
- package/apps/runtime/dist/agents/studio-assistant.js +8 -4
- package/apps/runtime/dist/agents/subscription.js +163 -134
- package/apps/runtime/dist/agents/website.js +571 -53
- package/apps/runtime/dist/app.js +6 -3
- package/apps/runtime/dist/assistant/knows.js +5 -5
- package/apps/runtime/dist/assistant/primer.js +4 -4
- package/apps/runtime/dist/auth/account.js +12 -12
- package/apps/runtime/dist/auth/keys.js +18 -8
- package/apps/runtime/dist/authoring/example.js +2 -2
- package/apps/runtime/dist/authoring/guide.js +11 -11
- package/apps/runtime/dist/cli/account.js +20 -18
- package/apps/runtime/dist/cli/features.js +3 -3
- package/apps/runtime/dist/cli/ui.js +6 -0
- package/apps/runtime/dist/credits/estimate.js +5 -5
- package/apps/runtime/dist/db/adopt.js +4 -3
- package/apps/runtime/dist/db/migrations/control/0011_model_classes.sql +11 -0
- package/apps/runtime/dist/db/migrations/control/meta/0011_snapshot.json +600 -0
- package/apps/runtime/dist/db/migrations/control/meta/_journal.json +7 -0
- package/apps/runtime/dist/db/migrations/tenant/0021_model_classes.sql +41 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0021_snapshot.json +3475 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +7 -0
- package/apps/runtime/dist/db/schema.js +1 -1
- package/apps/runtime/dist/docs/dev/plugins/index.md +1 -1
- package/apps/runtime/dist/docs/dev/plugins/quick-start.md +2 -2
- package/apps/runtime/dist/docs/dev/plugins/server.md +4 -4
- package/apps/runtime/dist/docs/dev/plugins/studio.md +1 -1
- package/apps/runtime/dist/docs/dev/wizard-format/agent-steps.md +9 -5
- package/apps/runtime/dist/docs/dev/wizard-format/film-steps.md +2 -2
- package/apps/runtime/dist/docs/dev/wizard-format/index.md +14 -8
- package/apps/runtime/dist/docs/user-guide/ai-apps.md +1 -1
- package/apps/runtime/dist/docs/user-guide/command-line.md +1 -1
- package/apps/runtime/dist/docs/user-guide/create-account.md +6 -6
- package/apps/runtime/dist/docs/user-guide/first-start.md +1 -1
- package/apps/runtime/dist/docs/user-guide/index.md +5 -5
- package/apps/runtime/dist/docs/user-guide/models.md +35 -20
- package/apps/runtime/dist/docs/user-guide/space.md +1 -1
- package/apps/runtime/dist/docs/user-guide/steps.md +6 -6
- package/apps/runtime/dist/documents/parse.js +1 -1
- package/apps/runtime/dist/engine/requirements.js +11 -11
- package/apps/runtime/dist/engine/steps.js +4 -4
- package/apps/runtime/dist/env.js +4 -4
- package/apps/runtime/dist/features.js +4 -4
- package/apps/runtime/dist/film/step.js +1 -1
- package/apps/runtime/dist/harness/antigravity.js +3 -3
- package/apps/runtime/dist/harness/apple.js +1 -1
- package/apps/runtime/dist/harness/claude.js +2 -2
- package/apps/runtime/dist/harness/codex.js +3 -3
- package/apps/runtime/dist/harness/cursor.js +5 -1
- package/apps/runtime/dist/manage.js +4 -4
- package/apps/runtime/dist/mcp/auth.js +1 -1
- package/apps/runtime/dist/mcp/tools.js +6 -3
- package/apps/runtime/dist/models.js +139 -15
- package/apps/runtime/dist/plugins/loader.js +1 -1
- package/apps/runtime/dist/routes/lang.js +13 -4
- package/apps/runtime/dist/routes/runs.js +1 -1
- package/apps/runtime/dist/routes/studio.js +81 -41
- package/apps/runtime/dist/services/access.js +3 -3
- package/apps/runtime/dist/services/architect.js +4 -2
- package/apps/runtime/dist/services/assistant-chats.js +11 -2
- package/apps/runtime/dist/services/brand.js +1 -1
- package/apps/runtime/dist/services/knowledge-model.js +1 -1
- package/apps/runtime/dist/services/marketplace.js +3 -1
- package/apps/runtime/dist/services/onboarding.js +268 -48
- package/apps/runtime/dist/services/pages.js +17 -15
- package/apps/runtime/dist/services/project-files.js +1 -1
- package/apps/runtime/dist/services/translations.js +2 -2
- package/apps/runtime/dist/services/wizards.js +4 -4
- package/apps/runtime/dist/sharing/agent.js +1 -1
- package/apps/runtime/dist/texts.js +54 -8
- package/apps/web/dist/assets/{AboutDialog-CZr1JFvY.js → AboutDialog-B_Ixp_Tb.js} +1 -1
- package/apps/web/dist/assets/{ChangelogDialog-0pKHVdhu.js → ChangelogDialog-BpEIbAZ8.js} +1 -1
- package/apps/web/dist/assets/EditorPage-CKHY4hn4.js +4 -0
- package/apps/web/dist/assets/{FlowPreview-BZZvY5U9.js → FlowPreview-APXdRflR.js} +1 -1
- package/apps/web/dist/assets/{Harness-DPRw6BmX.js → Harness-BsGXMlLg.js} +2 -2
- package/apps/web/dist/assets/Marketplace-Dr-Qnb-F.js +2 -0
- package/apps/web/dist/assets/{NewWizardChannels-K5vfNzaC.js → NewWizardChannels-0JrRdUFd.js} +1 -1
- package/apps/web/dist/assets/NewWizardPage-9igFL5O8.js +7 -0
- package/apps/web/dist/assets/OnboardingPage-BcK9FUnU.js +1 -0
- package/apps/web/dist/assets/PreviewPane-X4LBqA0D.js +4 -0
- package/apps/web/dist/assets/ProjectPage-CG0i-KhR.js +1 -0
- package/apps/web/dist/assets/{PublicRunner-_N7DyvWj.js → PublicRunner-CZR1ziQ4.js} +1 -1
- package/apps/web/dist/assets/{ReadOnly-CQ8lWsnZ.js → ReadOnly-BraZbEG_.js} +1 -1
- package/apps/web/dist/assets/SettingsPage-Bw4tdoV7.js +2 -0
- package/apps/web/dist/assets/SetupPage-CvkE2aKx.js +1 -0
- package/apps/web/dist/assets/{SharePage-BXkykFJC.js → SharePage-Dk7zC5Zo.js} +1 -1
- package/apps/web/dist/assets/changelog-DDXnAaHm.js +1 -0
- package/apps/web/dist/assets/{coins-Bo9_D-7S.js → coins-391m1e4_.js} +1 -1
- package/apps/web/dist/assets/index-BTUtot4r.js +14 -0
- package/apps/web/dist/assets/index-DcUL6teA.css +1 -0
- package/apps/web/dist/assets/{phone-BPybLMSm.js → phone-DvgrtyNO.js} +1 -1
- package/apps/web/dist/assets/{runners-53tvGeez.js → runners-4OBelIgF.js} +1 -1
- package/apps/web/dist/assets/{session-DvW7auj-.js → session-DvnGHbDz.js} +1 -1
- package/apps/web/dist/assets/{settings-menu-tSPDYTfT.js → settings-menu-xK9A-gaP.js} +1 -1
- package/apps/web/dist/assets/theme-D3yDT4QT.js +11 -0
- package/apps/web/dist/assets/ui-BVQk2DtW.js +137 -0
- package/apps/web/dist/assets/{upload-Ct_-rz05.js → upload-BgXbzG6C.js} +1 -1
- package/apps/web/dist/assets/{useMutation-DM9Anfo-.js → useMutation-DkwSQWoD.js} +1 -1
- package/apps/web/dist/assets/{volume-2-CHuzf68z.js → volume-2-DHGoe3Cg.js} +1 -1
- package/apps/web/dist/assets/{wrench-BAgonupx.js → wrench-Cf_aE3O0.js} +1 -1
- package/apps/web/dist/index.html +8 -8
- package/apps/web/dist/mcp/flow.html +56 -56
- package/node_modules/@engenty/wizards/dist/plugin/index.d.ts +2 -2
- package/node_modules/@engenty/wizards/dist/plugin/studio.d.ts +1 -1
- package/node_modules/@engenty/wizards-shared/dist/assistant.d.ts +6 -0
- package/node_modules/@engenty/wizards-shared/dist/assistant.js +2 -0
- package/node_modules/@engenty/wizards-shared/dist/definition.d.ts +876 -18
- package/node_modules/@engenty/wizards-shared/dist/definition.js +61 -11
- package/node_modules/@engenty/wizards-shared/dist/feature-flags.d.ts +5 -5
- package/node_modules/@engenty/wizards-shared/dist/feature-flags.js +5 -5
- package/node_modules/@engenty/wizards-shared/dist/features.d.ts +1 -1
- package/node_modules/@engenty/wizards-shared/dist/features.js +1 -1
- package/node_modules/@engenty/wizards-shared/dist/json-schema.js +3 -3
- package/node_modules/@engenty/wizards-shared/dist/projects.d.ts +1 -1
- package/node_modules/@engenty/wizards-shared/dist/projects.js +2 -2
- package/node_modules/@engenty/wizards-shared/dist/providers.d.ts +38 -1
- package/node_modules/@engenty/wizards-shared/dist/providers.js +65 -13
- package/node_modules/@engenty/wizards-shared/dist/run.d.ts +2 -2
- package/node_modules/@engenty/wizards-shared/dist/run.js +4 -4
- package/package.json +1 -1
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/plugin.json +1 -1
- package/apps/web/dist/assets/EditorPage-_qnWDno2.js +0 -4
- package/apps/web/dist/assets/Marketplace-BwbLRU2n.js +0 -2
- package/apps/web/dist/assets/NewWizardPage-zYwDoQTe.js +0 -7
- package/apps/web/dist/assets/OnboardingPage-jFgWaWJV.js +0 -1
- package/apps/web/dist/assets/PreviewPane-D5Kn9Ila.js +0 -4
- package/apps/web/dist/assets/ProjectPage-CyeEBVGi.js +0 -1
- package/apps/web/dist/assets/SettingsPage-haivwaZK.js +0 -2
- package/apps/web/dist/assets/SetupPage-Dy8KeG7z.js +0 -1
- package/apps/web/dist/assets/changelog-XRs8voQT.js +0 -1
- package/apps/web/dist/assets/index-CXA_do-X.js +0 -14
- package/apps/web/dist/assets/index-DG0i3S-z.css +0 -1
- package/apps/web/dist/assets/theme-CWGl7LyL.js +0 -11
- package/apps/web/dist/assets/ui-Bk08zclS.js +0 -137
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$r as r,$t as i,A as a,Ar as o,B as s,Bt as c,C as l,D as u,Dr as d,E as f,Er as p,H as m,Hr as h,Ht as g,I as _,Jr as v,Jt as y,Kr as b,Kt as x,L as S,Lt as C,M as w,Mr as T,N as E,O as D,Oi as O,Or as k,P as A,Pr as ee,Qt as j,R as te,Rt as M,S as N,T as ne,Tr as re,U as P,Ut as F,V as I,Vt as ie,W as L,Wt as R,Xn as z,Xr as ae,Xt as oe,Yt as B,Zt as V,_ as H,_r as U,b as W,cr as G,d as se,dr as ce,ei as le,f as ue,ft as de,g as fe,h as K,hr as q,j as pe,k as me,kr as he,m as ge,ni as _e,on as J,p as Y,pr as ve,qt as ye,ri as be,ti as xe,tn as Se,v as Ce,vr as we,w as Te,x as Ee,xr as De,y as X,z as Oe,zr as ke,zt as Ae}from"./ui-Bk08zclS.js";import{S as je,_ as Me,g as Ne,m as Pe,p as Fe,v as Ie}from"./Marketplace-BwbLRU2n.js";import{t as Le}from"./useMutation-DM9Anfo-.js";import{F as Re,I as ze,N as Be,S as Ve,_ as He,a as Ue,b as We,c as Ge,d as Ke,f as qe,g as Je,h as Ye,i as Xe,l as Ze,m as Qe,o as $e,p as et,r as tt,s as nt,t as rt,u as it,v as at,x as ot,y as st}from"./PreviewPane-D5Kn9Ila.js";import{b as ct,f as lt}from"./theme-CWGl7LyL.js";import{d as ut,f as dt,g as ft,p as pt,x as mt}from"./session-DvW7auj-.js";import{t as ht}from"./phone-BPybLMSm.js";import{n as gt,r as _t,t as vt}from"./ReadOnly-CQ8lWsnZ.js";import{t as yt}from"./upload-Ct_-rz05.js";import{Ct as bt,Et as xt,K as St,b as Ct,bt as wt,c as Tt,d as Et,et as Dt,f as Ot,ft as kt,h as At,it as jt,lt as Mt,m as Nt,p as Pt,pt as Ft,s as It,u as Lt,v as Rt,vt as zt,y as Bt,yt as Vt}from"./index-CXA_do-X.js";import{a as Ht,c as Ut,f as Wt,i as Gt,n as Kt,o as qt,r as Jt,s as Yt,t as Xt,u as Zt}from"./settings-menu-tSPDYTfT.js";var Qt={name:`blend`,size:24,node:[[`circle`,{cx:`15`,cy:`9`,r:`7`,key:`1i12rt`}],[`circle`,{cx:`9`,cy:`15`,r:`7`,key:`19bs8k`}]]};Qt.node;var $t=b(Qt),en={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`}]]};en.node;var tn=b(en),nn={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`}]]};nn.node;var rn=b(nn),an={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`}]]};an.node;var on=b(an),sn={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`]};sn.node;var cn=b(sn),ln={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`}]]};ln.node;var un=b(ln),dn={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`}]]};dn.node;var fn=b(dn),pn={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`}]]};pn.node;var mn=b(pn),hn={name:`tablet`,size:24,node:[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,ry:`2`,key:`76otgf`}],[`line`,{x1:`12`,x2:`12.01`,y1:`18`,y2:`18`,key:`1dp563`}]]};hn.node;var gn=b(hn),Z=e(t(),1),Q=e(n(),1),_n={backgroundImage:`repeating-conic-gradient(#c9c9c9 0% 25%, #dedede 0% 50%)`,backgroundSize:`16px 16px`};function vn({file:e,actions:t}){let[n,r]=(0,Z.useState)(e.description),i=(0,Z.useRef)(e.description),a=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{e.description!==i.current&&(r(t=>t===i.current?e.description:t),i.current=e.description)},[e.description]),(0,Z.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,Q.jsx)(`p`,{className:`text-[0.8125rem] text-ink-2 leading-snug`,children:n}):null:(0,Q.jsx)(`textarea`,{ref:a,rows:1,value:n,maxLength:600,placeholder:J(o?`project.describing`:`project.description`),onChange:e=>r(e.target.value),onBlur:()=>{n.trim()!==e.description&&(i.current=n.trim(),t.describe(e.id,n.trim()))},className:`-mx-1 block w-[calc(100%+0.5rem)] resize-none overflow-hidden rounded-md bg-transparent px-1 py-0.5 text-[0.8125rem] text-ink-2 leading-snug outline-none transition placeholder:text-ink-4 hover:bg-paper-2 focus:bg-card focus:text-ink focus:ring-1 focus:ring-border`})}function yn(e,t){confirm(J(`project.removeConfirm`,{name:e.name}))&&t.remove(e.id)}function bn({projectId:e,file:t,small:n}){let r=Oe(e,t.id);if(t.mime.startsWith(`image/`))return(0,Q.jsx)(`img`,{src:r,alt:``,loading:`lazy`,className:i(`size-full`,t.kind===`logo`?`object-contain p-3`:`object-cover`)});if(t.mime.startsWith(`video/`))return(0,Q.jsx)(`video`,{src:`${r}#t=0.1`,preload:`metadata`,controls:!n,className:`size-full object-cover`});if(t.mime.startsWith(`font/`))return(0,Q.jsx)(xn,{src:r,small:n});let a=n?`size-5`:`size-7`;return(0,Q.jsxs)(`div`,{className:`flex size-full flex-col items-center justify-center gap-1.5 text-ink-3`,children:[t.mime.startsWith(`audio/`)?(0,Q.jsx)(mn,{className:a}):t.mime===`application/pdf`?(0,Q.jsx)(he,{className:a}):t.mime===`application/json`?(0,Q.jsx)(ce,{className:a}):t.mime.startsWith(`model/`)?(0,Q.jsx)(tn,{className:a}):(0,Q.jsx)(k,{className:a}),n?null:(0,Q.jsx)(`span`,{className:`text-[0.6875rem] uppercase tracking-wide`,children:t.mime===`application/json`?`Lottie / JSON`:t.mime.split(`/`).pop()})]})}function xn({src:e,small:t}){let[n,r]=(0,Z.useState)(null);return(0,Z.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,Q.jsx)(`div`,{className:i(`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 Sn=`application/x-wizards-logo`;function Cn({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):yn(e,r);return(0,Q.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(184px,1fr))] gap-3`,children:[n.map(n=>(0,Q.jsxs)(`div`,{draggable:u&&!r.readOnly?!0:void 0,onDragStart:e=>e.dataTransfer.setData(Sn,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,Q.jsx)(`span`,{className:`absolute -top-3 left-3 z-10 rounded-full ring-2 ring-card`,children:(0,Q.jsx)(Ae,{tone:`ember`,children:J(`project.logoMain`)})}):null,(0,Q.jsxs)(`div`,{className:`relative h-28 overflow-hidden rounded-md bg-paper-2`,style:t===`logo`?_n:void 0,children:[s&&n.mime.startsWith(`image/`)?(0,Q.jsx)(`button`,{type:`button`,"aria-label":`${J(`project.preview`)}: ${n.name}`,onClick:()=>s(n),className:`block size-full cursor-zoom-in`,children:(0,Q.jsx)(bn,{projectId:e,file:n})}):(0,Q.jsx)(bn,{projectId:e,file:n}),(0,Q.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,Q.jsx)(g,{label:J(`project.preview`),onClick:()=>s(n),className:`size-8 bg-card shadow-soft`,children:(0,Q.jsx)(je,{className:`size-4`})}):null,l&&n.id!==c&&!r.readOnly?(0,Q.jsx)(g,{label:J(`project.logoMakeMain`),onClick:()=>l(n),className:`size-8 bg-card shadow-soft`,children:(0,Q.jsx)(Ne,{className:`size-4`})}):null,u&&!r.readOnly?(0,Q.jsx)(fe,{options:u.options,value:u.current(n),onChange:e=>u.onMove(n,e),className:`bg-card shadow-soft`}):null,r.readOnly?null:(0,Q.jsx)(g,{label:J(`project.remove`),onClick:()=>f(n),className:`size-8 bg-card shadow-soft hover:text-rose`,children:(0,Q.jsx)(G,{className:`size-4`})})]})]}),t===`asset`?(0,Q.jsx)(`div`,{className:`truncate px-0.5 text-[0.75rem] text-ink-3`,title:n.name,children:n.name}):null,(0,Q.jsx)(vn,{file:n,actions:r})]},n.id)),a&&!r.readOnly?(0,Q.jsxs)(ge,{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,Q.jsx)(y,{className:`size-5`}):(0,Q.jsx)(U,{className:`size-5`}),a]}):null]})}function wn({kind:e,fetchUrl:t,onAdded:n,onClose:r}){let[a,o]=(0,Z.useState)(``),[s,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)([]),g=async()=>{l(!0),d(null);try{let i=await t(a.trim());i.file?(n([i.file]),r()):i.candidates?.length?(p(i.candidates),h([i.candidates[0].url])):d(J(e===`logo`?`project.logoNoneFound`:`project.assetNoneFound`))}catch(e){d(e.message)}l(!1)},_=async()=>{l(!0),d(null);let e=[];try{for(let n of m){let r=await t(n);r.file&&e.push(r.file)}}catch(e){d(e.message)}l(!1),e.length&&n(e),e.length===m.length&&r()};return(0,Q.jsx)(c,{open:!0,onClose:r,wide:f?!0:void 0,title:J(f?e===`logo`?`project.logoFound`:`project.assetFound`:e===`logo`?`project.logoFromUrl`:`project.assetFromUrl`),children:f?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:J(e===`logo`?`project.logoFoundHint`:`project.assetFoundHint`)}),(0,Q.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(150px,1fr))] gap-3`,children:f.map(t=>{let n=m.includes(t.url);return(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":n,title:t.hint,onClick:()=>h(e=>n?e.filter(e=>e!==t.url):[...e,t.url]),className:i(`relative h-28 overflow-hidden rounded-lg ring-1 transition`,n?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),style:_n,children:[(0,Q.jsx)(`img`,{src:t.url,alt:``,className:i(`size-full`,e===`logo`?`object-contain p-3`:`object-cover`)}),n?(0,Q.jsx)(`span`,{className:`absolute top-1.5 right-1.5 grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,Q.jsx)(ke,{className:`size-3.5`})}):null]},t.url)})}),u?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:u}):null,(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(C,{variant:`ghost`,onClick:()=>p(null),children:J(`run.back`)}),(0,Q.jsx)(C,{busy:s,disabled:!m.length,onClick:()=>void _(),children:m.length>1?J(`project.addMany`,{n:m.length}):J(`project.add`)})]})]}):(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),g()},className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:J(`project.logoUrl`)}),(0,Q.jsx)(F,{autoFocus:!0,value:a,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>o(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:J(e===`logo`?`project.logoUrlHint`:`project.assetUrlHint`)})]}),u?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:u}):null,(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(C,{variant:`ghost`,onClick:r,children:J(`common.cancel`)}),(0,Q.jsx)(C,{type:`submit`,busy:s,disabled:!a.trim(),children:J(`run.next`)})]})]})})}function Tn(e,t,n){return be({queryKey:[`project-file-text`,t.id,t.chars,n],queryFn:()=>L.get(`/api/studio/projects/${e}/files/${t.id}/text?limit=${n}`),enabled:t.status===`ready`,staleTime:6e4})}function En(e){return((e.name.includes(`.`)?e.name.split(`.`).pop():``)||e.mime.split(`/`).pop()||``).toUpperCase().slice(0,5)}var Dn=e=>[En(e),e.pages?J(`project.pages`,{n:e.pages}):null,z(e.size)].filter(Boolean).join(` · `),On=2e5;function kn({projectId:e,fileId:t,readOnly:n,onGone:r}){let a=O(),s=P(e),c=Qe(e),l=I(e,n),u=s.data?.files.find(e=>e.id===t),d=u?u.mime===`application/pdf`||u.mime.startsWith(`image/`):!1,[f,p]=(0,Z.useState)(null);if(!u)return s.isLoading?(0,Q.jsx)(y,{className:`mx-auto text-ink-3`}):null;let m=f??(d?`original`:`text`),h=c.data?.items.find(e=>e.key===`f:${u.id}`),_=Oe(e,u.id),v=(e,t)=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":m===e,onClick:()=>p(e),className:i(`rounded-full px-3 py-1 text-[0.8125rem] transition`,m===e?`bg-paper-2 font-medium text-ink`:`text-ink-3 hover:text-ink`),children:t});return(0,Q.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,Q.jsx)(`h2`,{className:`min-w-0 flex-1 truncate font-display font-semibold text-lg`,children:u.name}),(0,Q.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 max-sm:hidden`,children:Dn(u)}),(0,Q.jsx)(`a`,{href:_,target:`_blank`,rel:`noreferrer`,"aria-label":J(`project.openOriginal`),title:J(`project.openOriginal`),className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,Q.jsx)(o,{className:`size-4`})}),n?null:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(g,{label:J(`project.reindex`),onClick:async()=>{await l.reindex(u.id),await a.invalidateQueries({queryKey:[`knowledge`,e]})},children:(0,Q.jsx)(q,{className:`size-4`})}),(0,Q.jsx)(g,{label:J(`know.deleteFile`),className:`hover:text-rose`,onClick:async()=>{confirm(J(`data.confirmDelete`,{title:u.name}))&&(await l.remove(u.id),await a.invalidateQueries({queryKey:[`knowledge`,e]}),r())},children:(0,Q.jsx)(G,{className:`size-4`})})]})]}),(0,Q.jsx)(qe,{projectId:e,itemKey:`f:${u.id}`,has:h?.categories??[],originLabel:h?.originLabel??null,kept:!1,review:null,file:null,readOnly:n,onReviewed:()=>void 0}),(0,Q.jsx)(`div`,{className:`px-1`,children:(0,Q.jsx)(vn,{file:u,actions:l})}),u.status===`failed`?(0,Q.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:u.error}):null,(0,Q.jsxs)(M,{className:`flex flex-col`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 border-border-soft border-b px-2 py-1.5`,children:[d?v(`original`,J(`project.original`)):null,v(`text`,J(`project.readText`))]}),m===`original`?u.mime===`application/pdf`?(0,Q.jsx)(`iframe`,{src:_,title:u.name,className:`h-[70dvh] w-full rounded-b-xl bg-paper-2`}):(0,Q.jsx)(`img`,{src:_,alt:``,className:`mx-auto max-h-[70dvh] object-contain p-4`}):(0,Q.jsx)(An,{projectId:e,file:u})]})]})}function An({projectId:e,file:t}){let n=Tn(e,t,On);return n.isLoading||t.status===`pending`?(0,Q.jsx)(`div`,{className:`flex h-40 items-center justify-center text-ink-3`,children:(0,Q.jsx)(y,{})}):n.data?.text?(0,Q.jsxs)(`div`,{className:`overflow-x-auto p-4 sm:p-5`,children:[(0,Q.jsx)(de,{text:n.data.text,className:`text-[0.875rem]`}),n.data.chars>n.data.text.length?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-ink-3`,children:J(`project.textCut`,{shown:n.data.text.length.toLocaleString(Se),total:n.data.chars.toLocaleString(Se)})}):null]}):(0,Q.jsx)(`p`,{className:`py-8 text-center text-[0.875rem] text-ink-3`,children:J(`project.noText`)})}var jn=`image/*,video/*,audio/*,application/pdf,.pdf,.woff2,.woff,.ttf,.otf,.json,.glb,.gltf`,Mn=e=>[(e.name.includes(`.`)?e.name.split(`.`).pop():e.mime.split(`/`).pop())?.toUpperCase().slice(0,5),z(e.size)].filter(Boolean).join(` · `);function Nn({projectId:e,file:t,actions:n,onClose:r}){let i=Oe(e,t.id);return(0,Q.jsxs)(c,{open:!0,onClose:r,wide:`page`,title:t.name,children:[(0,Q.jsxs)(`div`,{className:`-mt-2 mb-4 flex items-center justify-between gap-3`,children:[(0,Q.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3`,children:Mn(t)}),(0,Q.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,"aria-label":J(`project.openOriginal`),title:J(`project.openOriginal`),className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,Q.jsx)(o,{className:`size-4`})})]}),t.mime.startsWith(`image/`)?(0,Q.jsx)(`div`,{className:`overflow-hidden rounded-lg`,style:_n,children:(0,Q.jsx)(`img`,{src:i,alt:``,className:`mx-auto max-h-[68dvh] object-contain`})}):t.mime.startsWith(`video/`)?(0,Q.jsx)(`video`,{src:i,controls:!0,className:`max-h-[68dvh] w-full rounded-lg bg-black`}):(0,Q.jsx)(`audio`,{src:i,controls:!0,className:`w-full`}),(0,Q.jsx)(`div`,{className:`mt-4`,children:(0,Q.jsx)(vn,{file:t,actions:n})})]})}function Pn({projectId:e,file:t,actions:n,moveTo:r,onPreview:i,onRemove:a}){return(0,Q.jsxs)(`li`,{className:`group/row flex items-start gap-3 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,Q.jsx)(`button`,{type:`button`,"aria-label":`${J(`project.preview`)}: ${t.name}`,onClick:i,className:`size-14 shrink-0 cursor-zoom-in overflow-hidden rounded-md bg-paper-2`,children:(0,Q.jsx)(bn,{projectId:e,file:t,small:!0})}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1 py-0.5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3`,children:[(0,Q.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,Q.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:Mn(t)})]}),(0,Q.jsx)(vn,{file:t,actions:n})]}),(0,Q.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,Q.jsx)(g,{label:J(`project.preview`),onClick:i,children:(0,Q.jsx)(je,{className:`size-4`})}),r&&!n.readOnly?(0,Q.jsx)(fe,{options:r.options,value:r.current(t),onChange:e=>r.onMove(t,e),className:`size-9`}):null,n.readOnly?null:(0,Q.jsx)(g,{label:J(`project.remove`),onClick:a,className:`hover:text-rose`,children:(0,Q.jsx)(G,{className:`size-4`})})]})]})}function Fn({section:e,onSave:t,onRemove:n,onClose:r}){let[i,a]=(0,Z.useState)(e?.title??``);return(0,Q.jsx)(c,{open:!0,onClose:r,title:J(e?`project.assetSectionRename`:`project.assetSectionAdd`),children:(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),i.trim()&&(t(i.trim()),r())},className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:J(`project.assetSectionName`)}),(0,Q.jsx)(F,{autoFocus:!0,value:i,maxLength:80,placeholder:J(`project.assetSectionTitle`),onChange:e=>a(e.target.value)})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n?(0,Q.jsx)(C,{variant:`danger`,onClick:n,children:J(`project.sectionRemove`)}):null,(0,Q.jsx)(`span`,{className:`flex-1`}),(0,Q.jsx)(C,{variant:`ghost`,onClick:r,children:J(`common.cancel`)}),(0,Q.jsx)(C,{type:`submit`,disabled:!i.trim(),children:J(e?`settings.save`:`project.add`)})]})]})})}function In({projectId:e,data:t,readOnly:n,sections:r,save:i}){let o=I(e,n),[c,l]=m(`assets`,`cards`),[u,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(null),[h,_]=(0,Z.useState)(r),[v,b]=(0,Z.useState)(``),[x,S]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(!1),T=(0,Z.useRef)(null),E=s({assetSections:h},i),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=u.trim().toLowerCase(),M=te?ee.filter(e=>`${e.name} ${e.description}`.toLowerCase().includes(te)):ee,N=(e,t)=>_(n=>n.map(n=>{let r=n.assets.filter(t=>t!==e);return{...n,assets:n.id===t?[...r,e]:r}})),ne=async e=>{let t=A?.id??null;for(let n of await o.upload(`asset`,e))N(n.id,t)},re=e=>{confirm(J(`project.removeConfirm`,{name:e.name}))&&(o.remove(e.id),N(e.id,null))},P=h.length?{options:[{value:``,label:J(`project.assetsGeneral`)},...h.map(e=>({value:e.id,label:e.title||J(`project.sectionUntitled`)}))],current:e=>h.find(t=>t.assets.includes(e.id))?.id??``,onMove:(e,t)=>N(e.id,t||null)}:void 0,F=[{label:J(`project.assetUpload`),icon:(0,Q.jsx)(yt,{className:`size-4 shrink-0`}),onPick:()=>T.current?.click()},{label:J(`project.assetFromUrl`),icon:(0,Q.jsx)(un,{className:`size-4 shrink-0`}),onPick:()=>w(!0)},...h.length<a.logoSections?[{label:J(`project.assetSectionAdd`),icon:(0,Q.jsx)(on,{className:`size-4 shrink-0`}),onPick:()=>S(`new`)}]:[]],ie=h.length||D.length?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.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,Q.jsx)(V,{value:v,onChange:e=>{b(e),d(``)},label:J(`project.assets`),options:[{id:``,label:J(`project.assetsGeneral`)},...h.map(e=>({id:e.id,label:e.title||J(`project.sectionUntitled`)}))]}):null,A&&!n?(0,Q.jsx)(g,{label:J(`project.assetSectionRename`),onClick:()=>S(`current`),children:(0,Q.jsx)(we,{className:`size-4`})}):null]}),ee.length?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`w-56 max-w-[45%] shrink`,children:(0,Q.jsx)(Ce,{value:u,onChange:d,placeholder:J(`project.assetSearch`)})}),(0,Q.jsx)(g,{label:J(c===`list`?`project.viewCards`:`project.viewList`),onClick:l,children:c===`list`?(0,Q.jsx)(Vt,{className:`size-4`}):(0,Q.jsx)(fn,{className:`size-4`})})]}):null]}):null;return(0,Q.jsxs)(X,{title:J(`project.assets`),hint:J(`project.assetsHint`),save:E,tabs:ie,action:n?null:(0,Q.jsx)(se,{entries:F}),children:[(0,Q.jsx)(`input`,{ref:T,type:`file`,multiple:!0,accept:jn,className:`sr-only`,tabIndex:-1,"aria-hidden":!0,onChange:e=>{let t=Array.from(e.target.files??[]);e.target.value=``,t.length&&ne(t)}}),M.length?c===`cards`?(0,Q.jsx)(Cn,{projectId:e,kind:`asset`,files:M,actions:o,moveTo:P,onRemove:re,onPreview:e=>p(e.id)}):(0,Q.jsx)(`ul`,{className:`flex flex-col gap-2`,children:M.map(t=>(0,Q.jsx)(Pn,{projectId:e,file:t,actions:o,moveTo:P,onPreview:()=>p(t.id),onRemove:()=>re(t)},t.id))}):ee.length?null:n?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:J(`project.staysLocal`)}):(0,Q.jsxs)(ge,{accept:jn,onFiles:e=>void ne(e),className:`h-16 w-full`,children:[o.busy?(0,Q.jsx)(y,{className:`size-4`}):(0,Q.jsx)(yt,{className:`size-4`}),J(`project.drop`),` `,(0,Q.jsx)(`span`,{className:`underline`,children:J(`project.assetAdd`)})]}),o.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:o.error}):null,j?(0,Q.jsx)(Nn,{projectId:e,file:j,actions:o,onClose:()=>p(null)}):null,x?(0,Q.jsx)(Fn,{section:x===`current`?A:null,onClose:()=>S(null),onSave:e=>{if(x===`current`&&A)_(t=>t.map(t=>t.id===A.id?{...t,title:e}:t));else{let t=Ee();_(n=>[...n,{id:t,title:e,assets:[]}]),b(t)}},onRemove:x===`current`&&A?()=>{(!A.assets.length||confirm(J(`project.assetSectionRemoveConfirm`,{name:A.title})))&&(_(e=>e.filter(e=>e.id!==A.id)),b(``),S(null))}:void 0}):null,C?(0,Q.jsx)(wn,{kind:`asset`,onClose:()=>w(!1),fetchUrl:e=>o.fromUrl(`asset`,e),onAdded:e=>{for(let t of e)N(t.id,A?.id??null)}}):null]})}var Ln=/^#[0-9a-fA-F]{6}$/;async function Rn(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 zn={linear:`project.gradientLinear`,radial:`project.gradientRadial`,conic:`project.gradientConic`};function Bn({projectId:e,gradient:t,isNew:n,brand:r,onSave:a,onClose:o}){let[s,l]=(0,Z.useState)(t),[d,f]=(0,Z.useState)(A(t)),[p,m]=(0,Z.useState)(!1),[h,_]=(0,Z.useState)(``),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(null),[S,w]=(0,Z.useState)(!n),T=e=>{l(e),f(A(e)),m(!1)},E=(e,t)=>T({...s,stops:s.stops.map((n,r)=>r===e?{...n,...t}:n)}),D=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));T({...s,stops:[...s.stops,{color:e??t[0]?.color??`#888888`,at:n}]})},O=async()=>{y(!0),x(null);try{let{gradient:t}=await L.post(`/api/studio/projects/${e}/gradients/describe`,{text:h.trim(),...S?{gradient:{name:s.name,type:s.type,angle:s.angle,stops:s.stops}}:{}});T({...s,...t,name:s.name.trim()?s.name:t.name}),_(``),w(!0)}catch(e){x(e.message)}y(!1)};return(0,Q.jsx)(c,{open:!0,onClose:o,wide:!0,title:J(n?`project.gradientNew`:`project.gradientEdit`),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),h.trim()&&!v&&O()},children:[(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(F,{"data-autofocus":n||void 0,value:h,maxLength:1e3,"aria-label":J(`project.gradientDescribe`),placeholder:J(S?`project.gradientDescribeChange`:`project.gradientDescribeNew`),onChange:e=>_(e.target.value),className:`min-w-0 flex-1`}),(0,Q.jsxs)(C,{type:`submit`,variant:`secondary`,busy:v,disabled:!h.trim(),children:[(0,Q.jsx)(ce,{className:`size-4`}),J(S?`project.gradientDescribeApply`:`project.gradientDescribeMake`)]})]}),(0,Q.jsx)(`p`,{className:i(`mt-1.5 text-[0.8125rem]`,b?`text-rose`:`text-ink-3`),children:b??J(`project.gradientDescribeHint`)})]}),(0,Q.jsx)(`div`,{className:`h-40 rounded-lg ring-1 ring-border-soft`,style:{background:A(s)}}),(0,Q.jsxs)(`div`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:J(`project.gradientName`)}),(0,Q.jsx)(F,{value:s.name,maxLength:80,placeholder:J(`project.gradientNamePlaceholder`),onChange:e=>l({...s,name:e.target.value})})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:J(`project.fillUseLabel`)}),(0,Q.jsx)(F,{value:s.description??``,maxLength:400,placeholder:J(`project.gradientUse`),onChange:e=>l({...s,description:e.target.value})})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-end gap-x-6 gap-y-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:J(`project.gradientType`)}),(0,Q.jsx)(`div`,{className:`flex gap-1 rounded-full bg-paper-2 p-0.5 ring-1 ring-border-soft`,children:u.map(e=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":s.type===e,onClick:()=>T({...s,type:e}),className:i(`h-9 rounded-full px-4 font-medium text-[0.875rem] transition`,s.type===e?`bg-card text-ink shadow-sm`:`text-ink-3 hover:text-ink-2`),children:J(zn[e])},e))})]}),s.type===`radial`?null:(0,Q.jsxs)(`div`,{className:`min-w-56`,children:[(0,Q.jsx)(R,{children:J(`project.gradientAngle`)}),(0,Q.jsxs)(`div`,{className:`flex h-11 items-center gap-3`,children:[(0,Q.jsx)(`input`,{type:`range`,min:0,max:360,value:s.angle,"aria-label":J(`project.gradientAngle`),onChange:e=>T({...s,angle:Number(e.target.value)}),className:`flex-1 accent-ink`}),(0,Q.jsxs)(`span`,{className:`w-12 text-right text-[0.875rem] text-ink-2 tabular-nums`,children:[Math.round(s.angle),`°`]})]})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:J(`project.gradientStops`)}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:s.stops.map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(B,{value:Ln.test(e.color)?e.color:`#888888`,onChange:e=>E(t,{color:e.target.value})}),(0,Q.jsx)(F,{value:e.color,spellCheck:!1,onChange:e=>{let n=e.target.value.trim();Ln.test(n)&&E(t,{color:n.toLowerCase()})},className:`w-28 font-mono text-[0.8125rem]`}),(0,Q.jsx)(`input`,{type:`range`,min:0,max:100,value:e.at,"aria-label":J(`project.gradientAt`),onChange:e=>E(t,{at:Number(e.target.value)}),className:`flex-1 accent-ink`}),(0,Q.jsxs)(`span`,{className:`w-10 text-right text-[0.875rem] text-ink-2 tabular-nums`,children:[Math.round(e.at),`%`]}),(0,Q.jsx)(g,{label:J(`project.remove`),disabled:s.stops.length<=2,onClick:()=>T({...s,stops:s.stops.filter((e,n)=>n!==t)}),className:`hover:text-rose`,children:(0,Q.jsx)(G,{className:`size-4`})})]},t))}),(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[s.stops.length<12?(0,Q.jsxs)(C,{variant:`secondary`,size:`sm`,onClick:()=>D(),children:[(0,Q.jsx)(U,{className:`size-4`}),` `,J(`project.gradientStopAdd`)]}):null,r.length&&s.stops.length<12?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`ml-2 text-[0.8125rem] text-ink-3`,children:J(`project.gradientFromBrand`)}),r.slice(0,10).map(e=>(0,Q.jsx)(`button`,{type:`button`,title:e.name||e.value,"aria-label":e.name||e.value,onClick:()=>D(e.value),className:`size-6 rounded-full ring-1 ring-border transition hover:scale-110`,style:{background:e.value}},e.value))]}):null]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:`CSS`}),(0,Q.jsx)(F,{value:d,spellCheck:!1,onChange:e=>{f(e.target.value);let t=te(e.target.value);m(!t),t&&l({...s,...t})},className:`font-mono text-[0.8125rem]`}),(0,Q.jsx)(`p`,{className:i(`mt-1.5 text-[0.8125rem]`,p?`text-rose`:`text-ink-3`),children:J(p?`project.gradientCssError`:`project.gradientCssHint`)})]}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(C,{variant:`ghost`,onClick:o,children:J(`common.cancel`)}),(0,Q.jsx)(C,{onClick:()=>{a(s),o()},children:J(`settings.save`)})]})]})})}var Vn=`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`,Hn=`size-8 bg-card shadow-soft hover:bg-card`;function Un({name:e,namePlaceholder:t,description:n,usePlaceholder:r,readOnly:i,onChange:a}){return i?(0,Q.jsxs)(`div`,{className:`min-w-0 px-0.5`,children:[(0,Q.jsx)(`p`,{className:`truncate text-[0.875rem]`,children:e||t}),n?(0,Q.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3 leading-snug`,children:n}):null]}):(0,Q.jsxs)(`div`,{className:`min-w-0 px-0.5`,children:[(0,Q.jsx)(K,{value:e,label:J(`project.gradientName`),placeholder:t,maxLength:80,onChange:e=>a({name:e}),className:`font-medium text-[0.875rem]`}),(0,Q.jsx)(K,{value:n??``,label:J(`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:a}){let o=A(e),[s,c]=(0,Z.useState)(!1);return(0,Q.jsxs)(`div`,{className:`group/card flex flex-col gap-2 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(`button`,{type:`button`,disabled:t,"aria-label":J(`project.gradientEdit`),onClick:n,className:`block h-28 w-full rounded-md ring-1 ring-border-soft transition enabled:hover:brightness-105`,style:{background:o}}),(0,Q.jsxs)(`div`,{className:Vn,children:[(0,Q.jsx)(g,{label:J(s?`project.gradientCopied`:`project.gradientCopy`),onClick:()=>{navigator.clipboard.writeText(`background: ${o};`),c(!0),setTimeout(()=>c(!1),1500)},className:Hn,children:(0,Q.jsx)(ee,{className:`size-4`})}),(0,Q.jsx)(g,{label:J(`project.download`),onClick:()=>void Rn(e,e.name),className:Hn,children:(0,Q.jsx)(T,{className:`size-4`})}),t?null:(0,Q.jsx)(g,{label:J(`project.remove`),onClick:a,className:i(Hn,`hover:text-rose`),children:(0,Q.jsx)(G,{className:`size-4`})})]})]}),(0,Q.jsx)(Un,{name:e.name,namePlaceholder:J(`project.gradientName`),description:e.description,usePlaceholder:J(`project.gradientUse`),readOnly:t,onChange:r})]})}function Gn(e,t){return{backgroundImage:`url("${e}")`,backgroundSize:t?`64px`:`cover`,backgroundRepeat:t?`repeat`:`no-repeat`,backgroundPosition:`center`}}function Kn({projectId:e,pattern:t,fileName:n,readOnly:r,onEdit:a,onChange:o,onRemove:s}){let c=Oe(e,t.file);return(0,Q.jsxs)(`div`,{className:`group/card flex flex-col gap-2 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(`button`,{type:`button`,disabled:r,"aria-label":J(`project.patternEdit`),onClick:a,className:`block h-28 w-full rounded-md ring-1 ring-border-soft transition enabled:hover:brightness-105`,style:Gn(c,t.tile)}),(0,Q.jsxs)(`div`,{className:Vn,children:[(0,Q.jsx)(`a`,{href:c,download:n,"aria-label":J(`project.download`),title:J(`project.download`),className:i(`inline-flex items-center justify-center rounded-full text-ink-3 transition hover:text-ink`,Hn),children:(0,Q.jsx)(T,{className:`size-4`})}),r?null:(0,Q.jsx)(g,{label:J(`project.remove`),onClick:s,className:i(Hn,`hover:text-rose`),children:(0,Q.jsx)(G,{className:`size-4`})})]})]}),(0,Q.jsx)(Un,{name:t.name,namePlaceholder:n,description:t.description,usePlaceholder:J(`project.patternUse`),readOnly:r,onChange:o})]})}function qn({projectId:e,pattern:t,isNew:n,fileName:r,busy:a,error:o,upload:s,removeFile:l,onSave:u,onClose:d}){let[f,m]=(0,Z.useState)(t),[h,g]=(0,Z.useState)([]),_=async e=>{let t=e[0];if(!t)return;let n=await s(t);n&&(g(e=>[...e,n.id]),m(e=>({...e,file:n.id,name:e.name||n.name.replace(/\.[^.]+$/,``)})))},v=()=>{for(let e of h)l(e);d()};return(0,Q.jsx)(c,{open:!0,onClose:v,wide:!0,title:J(n?`project.patternNew`:`project.patternEdit`),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[f.file?(0,Q.jsx)(`div`,{className:`relative h-40 rounded-lg ring-1 ring-border-soft`,style:Gn(Oe(e,f.file),f.tile),children:(0,Q.jsxs)(ge,{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:[a?(0,Q.jsx)(y,{className:`size-4`}):(0,Q.jsx)(p,{className:`size-4`}),J(`project.patternReplace`)]})}):(0,Q.jsxs)(ge,{accept:`image/*`,multiple:!1,onFiles:e=>void _(e),className:`h-40 flex-col`,children:[a?(0,Q.jsx)(y,{className:`size-5`}):(0,Q.jsx)(p,{className:`size-5`}),J(`project.patternPick`)]}),(0,Q.jsxs)(`div`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:J(`project.patternName`)}),(0,Q.jsx)(F,{value:f.name,maxLength:80,placeholder:f.file?r(f.file):J(`project.patternNamePlaceholder`),onChange:e=>m({...f,name:e.target.value})})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:J(`project.fillUseLabel`)}),(0,Q.jsx)(F,{value:f.description??``,maxLength:400,placeholder:J(`project.patternUse`),onChange:e=>m({...f,description:e.target.value})})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:J(`project.patternShow`)}),(0,Q.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,Q.jsx)(`button`,{type:`button`,"aria-pressed":!!f.tile===e,onClick:()=>m({...f,tile:e||void 0}),className:i(`h-9 rounded-full px-4 font-medium text-[0.875rem] transition`,!!f.tile===e?`bg-card text-ink shadow-sm`:`text-ink-3 hover:text-ink-2`),children:J(e?`project.patternTile`:`project.patternFill`)},String(e)))})]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[o?(0,Q.jsx)(`p`,{className:`mr-auto text-[0.8125rem] text-rose`,children:o}):null,(0,Q.jsx)(C,{variant:`ghost`,onClick:v,children:J(`common.cancel`)}),(0,Q.jsx)(C,{disabled:!f.file||a,onClick:()=>{for(let e of h.filter(e=>e!==f.file))l(e);t.file&&t.file!==f.file&&l(t.file),u({...f,name:f.name.trim(),description:f.description?.trim()||void 0}),d()},children:J(n?`project.add`:`settings.save`)})]})]})})}var Jn=/^#[0-9a-fA-F]{6}$/;function Yn({projectId:e,onAdd:t,onClose:n}){let[r,a]=(0,Z.useState)(``),[o,s]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)([]),h=async()=>{s(!0),u(null);try{let{colors:t}=await L.post(`/api/studio/projects/${e}/colors/scan`,{url:r.trim()});t.length?(f(t),m([])):u(J(`project.colorsNoneFound`))}catch(e){u(e.message)}s(!1)};return(0,Q.jsx)(c,{open:!0,onClose:n,wide:d?!0:void 0,title:J(d?`project.colorsFound`:`project.colorsFromUrl`),children:d?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:J(`project.colorsFoundHint`)}),(0,Q.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(120px,1fr))] gap-3`,children:d.map(e=>{let t=p.includes(e.value);return(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>m(n=>t?n.filter(t=>t!==e.value):[...n,e.value]),className:i(`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,Q.jsx)(`span`,{className:`h-16`,style:{background:e.value}}),(0,Q.jsxs)(`span`,{className:`flex flex-col px-2.5 py-2`,children:[(0,Q.jsx)(`span`,{className:`truncate text-[0.8125rem] text-ink-2`,children:e.name||`—`}),(0,Q.jsx)(`span`,{className:`font-mono text-[0.75rem] text-ink-3`,children:e.value})]}),t?(0,Q.jsx)(`span`,{className:`absolute top-1.5 right-1.5 grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,Q.jsx)(ke,{className:`size-3.5`})}):null]},e.value)})}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(C,{variant:`ghost`,onClick:()=>f(null),children:J(`run.back`)}),(0,Q.jsx)(C,{disabled:!p.length,onClick:()=>{t(d.filter(e=>p.includes(e.value))),n()},children:p.length>1?J(`project.addMany`,{n:p.length}):J(`project.add`)})]})]}):(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),h()},className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:J(`project.logoUrl`)}),(0,Q.jsx)(F,{autoFocus:!0,value:r,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>a(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:J(`project.colorsUrlHint`)})]}),l?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:l}):null,(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(C,{variant:`ghost`,onClick:n,children:J(`common.cancel`)}),(0,Q.jsx)(C,{type:`submit`,busy:o,disabled:!r.trim(),children:J(`run.next`)})]})]})})}function Xn({projectId:e,data:t,colors:n,sections:r,gradients:i,patterns:o,rules:c,sectioned:l,ruled:u,save:d,readOnly:f}){let[p,m]=(0,Z.useState)(()=>n.map(e=>({...e,id:Ee()}))),[_,v]=(0,Z.useState)(r),[y,b]=(0,Z.useState)(i),[x,S]=(0,Z.useState)(o),[C,w]=(0,Z.useState)(null),[T,E]=(0,Z.useState)(null),D=I(e,f),O=N(c),[k,A]=(0,Z.useState)(null),[ee,j]=(0,Z.useState)(null),[te,M]=(0,Z.useState)(!1),ne=s({colors:p.filter(e=>Jn.test(e.value)).map(({name:e,value:t,section:n})=>({name:e.trim(),value:t,...n?{section:n}:{}})),colorSections:_,gradients:y,patterns:x,colorRules:O.rules},d),re=l?_:[],P=re.filter(e=>(e.kind??`colors`)===`colors`),ie=e=>P.some(t=>t.id===e.section),L=p.filter(e=>!ie(e)),R=(L[0]??p[0])?.id,z=(e,t)=>m(n=>n.map(n=>n.id===e?{...n,...t}:n)),ae=e=>m(t=>[...t,...e.map(e=>({...e,id:Ee()}))].slice(0,a.colors)),oe=[{value:``,label:J(`project.sectionStandard`)},...P.map(e=>({value:e.id,label:e.title||J(`project.sectionUntitled`)}))],V=(e,t)=>{let n=Ee();A(n),v(r=>[...r,{id:n,title:t,...e===`colors`?{}:{kind:e}}])},ce=e=>({id:Ee(),name:``,section:e,type:`linear`,angle:90,stops:[{color:p[0]?.value&&Jn.test(p[0].value)?p[0].value:`#4b73ff`,at:0},{color:p[1]?.value&&Jn.test(p[1].value)?p[1].value:`#ff6d1b`,at:100}]}),le=e=>t.files.find(t=>t.id===e)?.name??`pattern`,de=[...p.length<a.colors?[{label:J(`project.colorNew`),icon:(0,Q.jsx)(U,{className:`size-4 shrink-0`}),onPick:()=>q()},{label:J(`project.colorsFromUrl`),icon:(0,Q.jsx)(un,{className:`size-4 shrink-0`}),onPick:()=>M(!0)}]:[],...l&&_.length<a.logoSections?[{label:J(`project.colorSectionAdd`),icon:(0,Q.jsx)(on,{className:`size-4 shrink-0`}),onPick:()=>V(`colors`,``)},{label:J(`project.gradientSectionAdd`),icon:(0,Q.jsx)($t,{className:`size-4 shrink-0`}),onPick:()=>V(`gradients`,J(`project.gradientSectionTitle`))},{label:J(`project.patternSectionAdd`),icon:(0,Q.jsx)(cn,{className:`size-4 shrink-0`}),onPick:()=>V(`patterns`,J(`project.patternSectionTitle`))}]:[],...!u||O.full?[]:[{label:J(`project.ruleNew`),icon:(0,Q.jsx)(Ie,{className:`size-4 shrink-0`}),onPick:()=>O.add()}]],K=e=>(0,Q.jsxs)(`div`,{className:`group/row flex items-center gap-2`,children:[(0,Q.jsx)(B,{value:Jn.test(e.value)?e.value:`#888888`,onChange:t=>z(e.id,{value:t.target.value})}),(0,Q.jsx)(F,{value:e.name,autoFocus:e.id===ee,placeholder:J(`project.colorName`),maxLength:120,onChange:t=>z(e.id,{name:t.target.value}),className:`min-w-0 flex-1`}),(0,Q.jsx)(F,{value:e.value,placeholder:`#e0531b`,spellCheck:!1,onChange:t=>z(e.id,{value:t.target.value.trim()}),className:`w-28 font-mono text-[0.8125rem]`}),(0,Q.jsxs)(`div`,{className:`flex w-28 shrink-0 items-center justify-end max-sm:w-auto`,children:[e.id===R?(0,Q.jsx)(`span`,{className:`mr-1 max-sm:hidden`,children:(0,Q.jsx)(Ae,{tone:`ember`,children:J(`project.colorAccent`)})}):f?null:(0,Q.jsx)(g,{label:J(`project.colorFirst`),onClick:()=>m(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,Q.jsx)(h,{className:`size-4`})}),f||!P.length?null:(0,Q.jsx)(fe,{options:oe,value:ie(e)?e.section??``:``,onChange:t=>z(e.id,{section:t||void 0}),className:`opacity-0 focus-within:opacity-100 group-hover/row:opacity-100 coarse:opacity-100`}),f?null:(0,Q.jsx)(g,{label:J(`project.remove`),onClick:()=>m(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,Q.jsx)(G,{className:`size-4`})})]})]},e.id),q=e=>{let t=Ee();j(t),m(n=>[...n,{id:t,name:``,value:`#888888`,...e?{section:e}:{}}])};return(0,Q.jsxs)(X,{title:J(`project.colors`),hint:J(`project.colorsHint`),save:ne,locked:f,action:f?null:(0,Q.jsx)(se,{entries:de}),children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[L.length?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:L.map(K)}),f?null:(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:J(`project.colorUse`)})]}):p.length?null:(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:J(`project.colorsEmpty`)}),re.map(t=>{let n=t.kind??`colors`,r=p.filter(e=>e.section===t.id),i=y.filter(e=>e.section===t.id),o=x.filter(e=>e.section===t.id),s=n===`gradients`?i.length:n===`patterns`?o.length:r.length;return(0,Q.jsxs)(`div`,{className:`group/section flex flex-col gap-3`,children:[(0,Q.jsx)(W,{title:t.title,titlePlaceholder:J(n===`gradients`?`project.gradientSectionTitlePlaceholder`:n===`patterns`?`project.patternSectionTitlePlaceholder`:`project.colorSectionTitle`),kind:n===`gradients`?{icon:(0,Q.jsx)($t,{}),label:J(`project.kindGradients`)}:n===`patterns`?{icon:(0,Q.jsx)(cn,{}),label:J(`project.kindPatterns`)}:{icon:(0,Q.jsx)(kt,{}),label:J(`project.kindColors`)},autoFocus:k===t.id,readOnly:f,onChange:e=>v(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>{if(!s||confirm(J(n===`colors`?`project.colorSectionRemoveConfirm`:`project.fillSectionRemoveConfirm`,{name:t.title||J(`project.sectionUntitled`)}))){v(e=>e.filter(e=>e.id!==t.id)),m(e=>e.map(e=>e.section===t.id?{...e,section:void 0}:e)),b(e=>e.filter(e=>e.section!==t.id));for(let e of o)D.remove(e.file);S(e=>e.filter(e=>e.section!==t.id))}}}),n===`gradients`?(0,Q.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(200px,1fr))] gap-3`,children:[i.map(e=>(0,Q.jsx)(Wn,{gradient:e,readOnly:f,onEdit:()=>w(e),onChange:t=>b(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>b(t=>t.filter(t=>t.id!==e.id))},e.id)),f||y.length>=a.gradients?null:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>w(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,Q.jsx)(U,{className:`size-5`}),J(`project.gradientAdd`)]})]}):n===`patterns`?(0,Q.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(200px,1fr))] gap-3`,children:[o.map(t=>(0,Q.jsx)(Kn,{projectId:e,pattern:t,fileName:le(t.file),readOnly:f,onEdit:()=>E(t),onChange:e=>S(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>{D.remove(t.file),S(e=>e.filter(e=>e.id!==t.id))}},t.id)),f||x.length>=a.files.pattern?null:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>E({id:Ee(),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,Q.jsx)(U,{className:`size-5`}),J(`project.patternAdd`)]})]}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.map(K),f||p.length>=a.colors?null:(0,Q.jsx)(ue,{label:J(`project.colorAdd`),onClick:()=>q(t.id)})]})]},t.id)}),u?(0,Q.jsx)(H,{rules:O,placeholder:J(`project.colorRulePlaceholder`),readOnly:f}):null]}),D.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:D.error}):null,C?(0,Q.jsx)(Bn,{projectId:e,gradient:C,isNew:!y.some(e=>e.id===C.id),brand:p.filter(e=>Jn.test(e.value)),onClose:()=>w(null),onSave:e=>b(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e])}):null,T?(0,Q.jsx)(qn,{projectId:e,pattern:T,isNew:!x.some(e=>e.id===T.id),fileName:le,busy:D.busy,error:D.error,upload:async e=>(await D.upload(`pattern`,[e]))[0]??null,removeFile:e=>void D.remove(e),onClose:()=>E(null),onSave:e=>S(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e])}):null,te?(0,Q.jsx)(Yn,{projectId:e,onClose:()=>M(!1),onAdd:ae}):null]})}var Zn=e=>/^(ja|yes|true)$/i.test(e.trim()),Qn={text:Pe,longtext:_t,number:Re,date:ze,url:re,email:zt,phone:ht,boolean:Be};function $n({type:e,detected:t,onChange:n}){let[r,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1),c=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{if(!r)return;let e=e=>{c.current?.contains(e.target)||a(!1)},t=e=>e.key===`Escape`&&a(!1);return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[r]);let l=Qn[e??t],u=`${J(`project.factType`)}: ${J(`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),a(!1)};return(0,Q.jsxs)(`div`,{className:`relative`,ref:c,children:[(0,Q.jsx)(`button`,{type:`button`,"aria-label":u,title:u,"aria-haspopup":`menu`,"aria-expanded":r,onClick:e=>{s(window.innerHeight-e.currentTarget.getBoundingClientRect().bottom<400),a(e=>!e)},className:i(`inline-flex size-11 items-center justify-center rounded-lg transition hover:bg-accent hover:text-ink`,r?`bg-accent text-ink`:e?`text-ink-2`:`text-ink-4`),children:(0,Q.jsx)(l,{className:`size-4`})}),r?(0,Q.jsxs)(`div`,{role:`menu`,className:i(`absolute right-0 z-50 w-56 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,o?`bottom-12`:`top-12`),children:[(0,Q.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":!e,className:d,onClick:()=>f(void 0),children:[(0,Q.jsx)(Fe,{className:`size-4 shrink-0`}),(0,Q.jsx)(`span`,{className:`flex-1`,children:J(`project.factAuto`)}),(0,Q.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:J(`project.type.${t}`)}),(0,Q.jsx)(ke,{className:i(`size-4 shrink-0`,e&&`invisible`)})]}),(0,Q.jsx)(`div`,{className:`mx-2 my-1 h-px bg-border-soft`}),Te.map(t=>{let n=Qn[t];return(0,Q.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e===t,className:d,onClick:()=>f(t),children:[(0,Q.jsx)(n,{className:`size-4 shrink-0`}),(0,Q.jsx)(`span`,{className:`flex-1`,children:J(`project.type.${t}`)}),(0,Q.jsx)(ke,{className:i(`size-4 shrink-0`,e!==t&&`invisible`)})]},t)})]}):null]})}function er({facts:e,save:t,readOnly:n}){let r=(0,Z.useRef)(0),i=(0,Z.useRef)(null),[o,c]=(0,Z.useState)(()=>e.map(e=>({...e,id:`f${r.current++}`}))),u=s(o.filter(e=>e.key&&e.label.trim()).map(({key:e,label:t,value:n,type:r})=>({key:e,label:t.trim(),value:n,...r?{type:r}:{}})),t),d=(e,t)=>c(n=>n.map(n=>n.id===e?{...n,...t}:n)),f=(e,t,n=!1)=>{let a=`f${r.current++}`;i.current=`${a}:${t}`;let o={id:a,key:``,label:``,value:``,...e};c(e=>n?[o,...e]:[...e,o])},p=e=>t=>{t&&i.current===e&&(i.current=null,t.focus())},m=l.filter(e=>!o.some(t=>t.key===e));return(0,Q.jsxs)(X,{title:J(`project.facts`),hint:J(`project.factsHint`),save:u,locked:n,action:o.length<a.facts&&!n?(0,Q.jsxs)(C,{variant:`secondary`,size:`sm`,onClick:()=>f({},`label`,!0),children:[(0,Q.jsx)(U,{className:`size-4`}),` `,J(`project.factAdd`)]}):null,children:[(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:o.map(e=>{let t=pe(e.value),r=e.type??t;return(0,Q.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,Q.jsx)(F,{ref:p(`${e.id}:label`),value:e.label,placeholder:J(`project.factLabel`),title:e.key?`{{facts.${e.key}}}`:void 0,onChange:t=>d(e.id,{label:t.target.value}),onBlur:()=>{!e.key&&e.label.trim()&&d(e.id,{key:w(e.label,o.map(e=>e.key))})},className:`max-sm:col-span-3 max-sm:font-medium sm:mr-1`}),e.type===`boolean`?(0,Q.jsxs)(`div`,{className:`flex h-11 items-center gap-3`,children:[(0,Q.jsx)(oe,{checked:Zn(e.value),label:e.label,onChange:t=>d(e.id,{value:J(t?`project.yes`:`project.no`)})}),(0,Q.jsx)(`span`,{className:`text-[0.875rem] text-ink-2`,children:Zn(e.value)?J(`project.yes`):J(`project.no`)})]}):(0,Q.jsx)(j,{ref:p(`${e.id}:value`),rows:1,minRows:r===`longtext`?2:1,maxRows:10,value:e.value,placeholder:J(`project.factValue`),onChange:t=>d(e.id,{value:t.target.value}),className:`min-h-11`}),(0,Q.jsx)($n,{type:e.type,detected:t,onChange:t=>d(e.id,{type:t})}),n?null:(0,Q.jsx)(g,{label:J(`project.remove`),onClick:()=>c(t=>t.filter(t=>t.id!==e.id)),className:`size-11 rounded-lg hover:text-rose`,children:(0,Q.jsx)(G,{className:`size-4`})})]},e.id)})}),o.length<a.facts&&!n?(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${o.length?`mt-4`:``}`,children:[(0,Q.jsxs)(C,{variant:`secondary`,size:`sm`,onClick:()=>f({},`label`),children:[(0,Q.jsx)(U,{className:`size-4`}),` `,J(`project.factAdd`)]}),m.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>f({key:e,label:J(`fact.${e}`)},`value`),className:`inline-flex h-8 items-center gap-1 rounded-full bg-paper-2 px-3 text-[0.8125rem] text-ink-2 transition hover:bg-paper-3 hover:text-ink`,children:[(0,Q.jsx)(U,{className:`size-3.5`}),` `,J(`fact.${e}`)]},e))]}):null]})}function tr({onLogo:e,children:t,className:n}){let[r,a]=(0,Z.useState)(!1);return e?(0,Q.jsx)(`div`,{onDragOver:e=>{e.dataTransfer.types.includes(`application/x-wizards-logo`)&&(e.preventDefault(),a(!0))},onDragLeave:()=>a(!1),onDrop:t=>{let n=t.dataTransfer.getData(Sn);a(!1),n&&(t.preventDefault(),e(n))},className:i(`-m-2 rounded-xl p-2 transition`,r&&`bg-paper-2 ring-1 ring-focus`,n),children:t}):(0,Q.jsx)(`div`,{className:n,children:t})}function nr({projectId:e,data:t,readOnly:n,sections:r,rules:i,sectioned:o,ruled:c,save:l}){let u=I(e,n),[d,f]=(0,Z.useState)(r),p=N(i),[m,h]=(0,Z.useState)(null),[g,v]=(0,Z.useState)(!1),y=(0,Z.useRef)(null),b=s({logoSections:d,logoRules:p.rules},l),x=t.files.filter(e=>e.kind===`logo`),S=new Map(x.map(e=>[e.id,e])),C=o?d:[],w=new Set(C.flatMap(e=>e.logos)),T=x.filter(e=>!w.has(e.id)),E=_(x,d)?.id,D=(e,t)=>f(n=>n.map(n=>{let r=n.logos.filter(t=>t!==e);return{...n,logos:n.id===t?[...r,e]:r}})),O=(e,t)=>f(n=>n.map(n=>n.id===e?{...n,...t}:n)),k=async(e,t)=>{let n=await u.upload(`logo`,e);for(let e of n)D(e.id,t)},A=C.length?{options:[{value:``,label:J(`project.sectionStandard`)},...C.map(e=>({value:e.id,label:e.title||J(`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,Q.jsx)(Cn,{projectId:e,kind:`logo`,files:t,actions:u,accept:`image/*`,addLabel:r?J(`project.logoAdd`):void 0,onUpload:e=>void k(e,n),mainId:E,onMakeMain:e=>{D(e.id,null),u.order(`logo`,[e.id,...x.filter(t=>t.id!==e.id).map(e=>e.id)])},moveTo:A,onRemove:e=>{confirm(J(`project.removeConfirm`,{name:e.name}))&&(u.remove(e.id),D(e.id,null))}}),j=n?void 0:e=>t=>D(t,e),te=[{label:J(`project.logoUpload`),icon:(0,Q.jsx)(yt,{className:`size-4 shrink-0`}),onPick:()=>y.current?.click()},{label:J(`project.logoFromUrl`),icon:(0,Q.jsx)(un,{className:`size-4 shrink-0`}),onPick:()=>v(!0)},...o&&d.length<a.logoSections?[{label:J(`project.logoSectionAdd`),icon:(0,Q.jsx)(on,{className:`size-4 shrink-0`}),onPick:()=>{let e=Ee();h(e),f(t=>[...t,{id:e,title:``,description:``,logos:[]}])}}]:[],...!c||p.full?[]:[{label:J(`project.ruleNew`),icon:(0,Q.jsx)(Ie,{className:`size-4 shrink-0`}),onPick:()=>p.add()}]];return(0,Q.jsxs)(X,{title:J(`project.logos`),hint:J(`project.logosHint`),save:b,action:n?null:(0,Q.jsx)(se,{entries:te}),children:[(0,Q.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,Q.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[(0,Q.jsx)(tr,{onLogo:j?.(null),children:ee(T,null,!0)}),C.map(e=>(0,Q.jsx)(`div`,{className:`group/section`,children:(0,Q.jsxs)(tr,{onLogo:j?.(e.id),className:`flex flex-col gap-3`,children:[(0,Q.jsx)(W,{title:e.title,description:e.description,titlePlaceholder:J(`project.logoSectionTitle`),descriptionPlaceholder:J(`project.logoSectionUse`),autoFocus:m===e.id,readOnly:n,onChange:t=>O(e.id,t),onRemove:()=>{(!e.logos.length||confirm(J(`project.logoSectionRemoveConfirm`,{name:e.title||J(`project.sectionUntitled`)})))&&f(t=>t.filter(t=>t.id!==e.id))}}),ee(e.logos.map(e=>S.get(e)).filter(e=>!!e),e.id,!0)]})},e.id)),c?(0,Q.jsx)(H,{rules:p,placeholder:J(`project.logoRulePlaceholder`),readOnly:n}):null]}),u.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:u.error}):null,g?(0,Q.jsx)(wn,{kind:`logo`,onClose:()=>v(!1),fetchUrl:e=>u.fromUrl(`logo`,e),onAdded:e=>{for(let t of e)D(t.id,null)}}):null]})}var rr=e=>URL.canParse(e)?new URL(e).host:e;async function ir(e,t){let n=E({family:t,source:{url:e}});if(!n)return`down`;if(n.stylesheet)return await ar(e,t);let r=await fetch(e,{mode:`cors`}).catch(()=>null);return r?r.ok?await new FontFace(`engenty-check-${Date.now()}`,await r.arrayBuffer()).load().then(()=>`ok`,()=>`noFont`):`down`:await fetch(e,{mode:`no-cors`}).then(()=>!0,()=>!1)?`cors`:`down`}function ar(e,t){let n=new Set(document.fonts),r=document.createElement(`link`);return r.rel=`stylesheet`,r.href=e,new Promise(e=>{r.onerror=()=>e(`down`),r.onload=async()=>{let r=[...document.fonts].filter(e=>!n.has(e)&&e.family.replace(/^["']|["']$/g,``)===t),i=await Promise.allSettled(r.map(e=>e.load()));e(r.length===0?`missing`:i.some(e=>e.status===`fulfilled`)?`ok`:`cors`)},document.head.append(r)}).finally(()=>r.remove())}function or(e,t){let n=e.source;if(!n)return J(`project.fontSourceNone`);if(`file`in n){let e=t.find(e=>e.id===n.file)?.name??``;return J(`project.fontSourceFile`,{name:e})}return J(`project.fontSourceUrl`,{host:rr(n.url)})}function sr({projectId:e,font:t,onSave:n,onClose:r}){let a=(P(e).data?.files??[]).filter(e=>e.mime.startsWith(`font/`)),o=I(e),s=(0,Z.useRef)(null),[l,u]=(0,Z.useState)(t.source&&`url`in t.source?`url`:`file`),[d,f]=(0,Z.useState)(t.source&&`file`in t.source?t.source.file:``),[p,m]=(0,Z.useState)(t.source&&`url`in t.source?t.source.url:``),[h,g]=(0,Z.useState)(t.source&&`url`in t.source?{url:t.source.url,result:`ok`}:null),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(t.license??``),[S,w]=(0,Z.useState)(!1),T=p.trim(),E=async()=>{v(!0),g({url:T,result:await ir(T,t.family.trim())}),v(!1)},D=l===`file`?d?{file:d}:null:h?.url===T&&h.result===`ok`?{url:T}:null,O=h?.url===T?h.result:null;return(0,Q.jsx)(c,{open:!0,onClose:r,title:J(`project.fontSourceTitle`,{family:t.family}),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:J(`project.fontSourceHint`)}),(0,Q.jsx)(x,{value:l,options:[`file`,`url`],label:e=>J(`project.fontSourceKind.${e}`),onChange:e=>u(e)}),l===`file`?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:J(`project.fontSourceFiles`)}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-1`,children:a.map(e=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":d===e.id,onClick:()=>f(e.id),className:i(`rounded-lg px-3 py-2 text-left text-[0.875rem] ring-1 transition`,d===e.id?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),children:e.name},e.id))}),(0,Q.jsx)(`input`,{ref:s,type:`file`,accept:`.woff2,.woff,.ttf,.otf`,className:`hidden`,onChange:async e=>{let t=[...e.target.files??[]];e.target.value=``;let[n]=await o.upload(`asset`,t);n&&f(n.id)}}),(0,Q.jsxs)(C,{variant:`ghost`,className:`mt-2`,busy:o.busy,onClick:()=>s.current?.click(),children:[(0,Q.jsx)(yt,{className:`size-4`}),J(`project.fontSourceUpload`)]}),o.error?(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.875rem] text-rose`,children:o.error}):null]}):(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),E()},children:[(0,Q.jsx)(R,{children:J(`project.fontSourceUrlLabel`)}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(F,{value:p,inputMode:`url`,placeholder:J(`project.fontSourceUrlPlaceholder`),onChange:e=>m(e.target.value)}),(0,Q.jsx)(C,{type:`submit`,variant:`ghost`,busy:_,disabled:!T.startsWith(`https://`),children:J(`project.fontSourceCheck`)})]}),O?(0,Q.jsx)(`p`,{className:i(`mt-1.5 text-[0.875rem]`,O===`ok`?`text-ink-3`:`text-rose`),children:J(`project.fontCheck.${O}`,{host:rr(T),family:t.family})}):null,O===`ok`?(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.875rem] text-ink-3`,children:J(`project.fontPrivacy`,{host:rr(T)})}):null]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{hint:J(`project.fontLicenseHint`),children:J(`project.fontLicense`)}),(0,Q.jsx)(F,{value:y,maxLength:200,placeholder:J(`project.fontLicensePlaceholder`),onChange:e=>b(e.target.value)}),(0,Q.jsxs)(`label`,{className:`mt-2 flex items-start gap-2 text-[0.875rem]`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 accent-ember`,checked:S,onChange:e=>w(e.target.checked)}),J(`project.fontLicenseConfirm`,{family:t.family})]})]}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[t.source?(0,Q.jsx)(C,{variant:`ghost`,className:`mr-auto`,onClick:()=>{n({source:void 0,license:t.license}),r()},children:J(`project.fontSourceRemove`)}):null,(0,Q.jsx)(C,{variant:`ghost`,onClick:r,children:J(`common.cancel`)}),(0,Q.jsx)(C,{disabled:!(D&&S),onClick:()=>{D&&(n({source:D,license:y.trim()||void 0}),r())},children:J(`project.fontSourceSave`)})]})]})})}var cr=new Set;function lr(e){(0,Z.useEffect)(()=>{let t=e.trim().toLowerCase().replace(/\s+/g,`-`);if(!t||cr.has(t))return;cr.add(t);let n=document.createElement(`link`);n.rel=`stylesheet`,n.href=`https://fonts.bunny.net/css?family=${encodeURIComponent(t)}:${f.join(`,`)}&display=swap`,document.head.append(n)},[e])}var ur=e=>e?`"${e}", system-ui, sans-serif`:`system-ui, sans-serif`;function dr({unit:e,label:t,...n}){return(0,Q.jsxs)(`label`,{className:`inline-flex items-center gap-1 text-[0.75rem] text-ink-3`,title:t,children:[(0,Q.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 fr=`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`,pr={web:`project.fontUseWeb`,documents:`project.fontUseDocuments`,print:`project.fontUsePrint`,images:`project.fontUseImages`,video:`project.fontUseVideo`};function mr({projectId:e,font:t,first:n,readOnly:r,autoFocus:a,onChange:o,onRemove:s}){lr(t.family);let c=P(e).data?.files??[],[l,u]=(0,Z.useState)(!1);return(0,Q.jsxs)(`div`,{className:`group/font relative flex flex-col gap-2 rounded-lg bg-paper p-3 ring-1 ring-border-soft`,children:[(0,Q.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:ur(t.family)},children:[(0,Q.jsx)(`span`,{className:`text-[3.5rem] text-ink leading-none`,children:`Aa`}),(0,Q.jsx)(`span`,{className:`truncate pl-3 text-[0.875rem] text-ink-3`,children:`ABCDEFG abcdefg 0123456789`})]}),r?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`font-medium text-[0.9375rem]`,children:t.family}),t.role?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:t.role}):null]}):(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(K,{value:t.family,label:J(`project.fontFamily`),placeholder:J(`project.fontFamily`),maxLength:80,autoFocus:a,onChange:e=>o({family:e}),className:`font-medium text-[0.9375rem]`}),(0,Q.jsx)(K,{value:t.role,label:J(`project.fontRole`),placeholder:J(n?`project.fontRoleFirst`:`project.fontRole`),maxLength:200,onChange:e=>o({role:e}),className:`text-[0.875rem] text-ink-3`})]}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:f.map(e=>{let n=t.weights.includes(e);return(0,Q.jsx)(`button`,{type:`button`,disabled:r,"aria-pressed":n,onClick:()=>o({weights:n?t.weights.filter(t=>t!==e):[...t.weights,e].sort((e,t)=>e-t)}),style:{fontFamily:ur(t.family),fontWeight:e},className:i(`h-7 rounded-full px-2.5 text-[0.8125rem] tabular-nums transition`,n?`bg-ink text-paper`:`bg-paper-2 text-ink-3 hover:text-ink`,r&&!n&&`hidden`),children:e},e)})}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[r?t.license?(0,Q.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:t.license}):null:(0,Q.jsx)(K,{value:t.license??``,label:J(`project.fontLicense`),placeholder:J(`project.fontLicensePlaceholder`),maxLength:200,onChange:e=>o({license:e}),className:`text-[0.8125rem] text-ink-3`}),r&&!t.uses?.length?null:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,Q.jsx)(`span`,{className:`mr-1 text-[0.8125rem] text-ink-3`,children:J(`project.fontUses`)}),ne.map(e=>{let n=!!t.uses?.includes(e);return(0,Q.jsxs)(`button`,{type:`button`,disabled:r,"aria-pressed":n,onClick:()=>{let r=n?(t.uses??[]).filter(t=>t!==e):ne.filter(n=>n===e||t.uses?.includes(n));o({uses:r.length?r:void 0})},className:i(`inline-flex h-7 items-center gap-1 rounded-full px-2.5 text-[0.8125rem] transition`,n?`bg-card text-ink ring-1 ring-border`:`bg-paper-2 text-ink-3 hover:text-ink`,r&&!n&&`hidden`),children:[n?(0,Q.jsx)(ke,{className:`size-3.5`}):null,J(pr[e])]},e)})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-[0.8125rem] text-ink-3`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:or(t,c)}),r||!t.family.trim()?null:(0,Q.jsx)(`button`,{type:`button`,onClick:()=>u(!0),className:`text-ink underline decoration-border underline-offset-2 hover:decoration-ink`,children:J(t.source?`project.fontSourceChange`:`project.fontSourceSet`)})]}),l?(0,Q.jsx)(sr,{projectId:e,font:t,onSave:o,onClose:()=>u(!1)}):null,r?null:(0,Q.jsx)(g,{label:J(`project.remove`),onClick:s,className:`absolute top-4 right-4 size-8 bg-card opacity-0 shadow-soft transition focus:opacity-100 group-hover/font:opacity-100 coarse:opacity-100 hover:text-rose`,children:(0,Q.jsx)(G,{className:`size-4`})})]})}function hr({style:e,fonts:t,sample:n,readOnly:r,autoFocus:a,onChange:o,onRemove:s}){let c=t.find(t=>t.id===e.font)??t[0],l={fontFamily:ur(c?.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,Q.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,Q.jsx)(`div`,{className:`truncate text-ink`,style:l,children:n}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[r?(0,Q.jsx)(`span`,{className:`font-medium text-[0.8125rem] text-ink-2 uppercase tracking-wide`,children:e.name}):(0,Q.jsx)(`div`,{className:`w-40`,children:(0,Q.jsx)(K,{value:e.name,label:J(`project.styleName`),placeholder:J(`project.styleName`),maxLength:60,autoFocus:a,onChange:e=>o({name:e}),className:`font-medium text-[0.8125rem] text-ink-2 uppercase tracking-wide`})}),(0,Q.jsxs)(`fieldset`,{disabled:r,className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[t.length>1?(0,Q.jsx)(`select`,{"aria-label":J(`project.styleFont`),value:c?.id??``,onChange:e=>o({font:e.target.value}),className:i(fr,`max-w-40`),children:t.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.family||J(`project.fontFamily`)},e.id))}):null,(0,Q.jsx)(`select`,{"aria-label":J(`project.styleWeight`),value:e.weight,onChange:e=>o({weight:Number(e.target.value)}),className:fr,children:[...new Set([...f,e.weight])].sort().map(e=>(0,Q.jsx)(`option`,{value:e,children:e},e))}),(0,Q.jsx)(dr,{unit:`px`,label:J(`project.styleSize`),min:6,max:400,value:e.size,onChange:e=>o({size:Number(e.target.value)||16})}),(0,Q.jsx)(dr,{unit:J(`project.styleLine`),label:J(`project.styleLineLabel`),min:50,max:300,value:e.lineHeight,onChange:e=>o({lineHeight:Number(e.target.value)||100})}),(0,Q.jsx)(dr,{unit:J(`project.styleTracking`),label:J(`project.styleTrackingLabel`),min:-20,max:50,step:.5,value:e.tracking,onChange:e=>o({tracking:Number(e.target.value)||0})}),(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":!!e.uppercase,title:J(`project.styleUpper`),"aria-label":J(`project.styleUpper`),onClick:()=>o({uppercase:!e.uppercase}),className:i(`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,Q.jsx)(rn,{className:`size-4`})})]}),r?null:(0,Q.jsx)(g,{label:J(`project.remove`),onClick:s,className:`ml-auto size-8 opacity-0 transition focus:opacity-100 group-hover/row:opacity-100 coarse:opacity-100 hover:text-rose`,children:(0,Q.jsx)(G,{className:`size-4`})})]})]})}function gr({projectId:e,onAdd:t,onClose:n}){let[r,i]=(0,Z.useState)(``),[a,o]=(0,Z.useState)(!1),[s,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)([]),m=async()=>{o(!0),l(null);try{let{fonts:t}=await L.post(`/api/studio/projects/${e}/fonts/scan`,{url:r.trim()});t.length?(d(t),p(t.slice(0,2).map(e=>e.family))):l(J(`project.fontsNoneFound`))}catch(e){l(e.message)}o(!1)};return(0,Q.jsx)(c,{open:!0,onClose:n,wide:u?!0:void 0,title:J(u?`project.fontsFound`:`project.fontsFromUrl`),children:u?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:J(`project.fontsFoundHint`)}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:u.map(e=>(0,Q.jsx)(_r,{font:e,on:f.includes(e.family),onToggle:()=>p(t=>t.includes(e.family)?t.filter(t=>t!==e.family):[...t,e.family])},e.family))}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(C,{variant:`ghost`,onClick:()=>d(null),children:J(`run.back`)}),(0,Q.jsx)(C,{disabled:!f.length,onClick:()=>{t(u.filter(e=>f.includes(e.family))),n()},children:f.length>1?J(`project.addMany`,{n:f.length}):J(`project.add`)})]})]}):(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),m()},className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:J(`project.logoUrl`)}),(0,Q.jsx)(F,{autoFocus:!0,value:r,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>i(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:J(`project.fontsUrlHint`)})]}),s?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:s}):null,(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(C,{variant:`ghost`,onClick:n,children:J(`common.cancel`)}),(0,Q.jsx)(C,{type:`submit`,busy:a,disabled:!r.trim(),children:J(`run.next`)})]})]})})}function _r({font:e,on:t,onToggle:n}){return lr(e.family),(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:n,className:i(`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,Q.jsx)(`span`,{className:`text-[2rem] text-ink leading-none`,style:{fontFamily:ur(e.family)},children:`Aa`}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-[0.9375rem]`,children:e.family}),(0,Q.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 tabular-nums`,children:e.weights.length?e.weights.join(` · `):J(`project.fontWeightsUnknown`)})]}),t?(0,Q.jsx)(`span`,{className:`grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,Q.jsx)(ke,{className:`size-3.5`})}):null]})}function vr({projectId:e,fonts:t,styles:n,rules:r,ruled:i,sample:o,save:c,readOnly:l}){let[u,d]=(0,Z.useState)(t),[f,p]=(0,Z.useState)(n),m=N(r),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(!1),y=s({fonts:u,textStyles:f,typeRules:m.rules},c),b=(e,t=!1)=>{let n=e.map(e=>({id:Ee(),family:e.family,role:``,weights:e.weights}));t&&n[0]&&g(n[0].id),d(e=>[...e,...n].slice(0,a.fonts))},x=()=>{let e=Ee();g(e),p(t=>[...t,{id:e,name:``,size:16,weight:400,lineHeight:150,tracking:0}])},S=[...u.length<a.fonts?[{label:J(`project.fontNew`),icon:(0,Q.jsx)(U,{className:`size-4 shrink-0`}),onPick:()=>b([{family:``,weights:[400,700]}],!0)},{label:J(`project.fontsFromUrl`),icon:(0,Q.jsx)(un,{className:`size-4 shrink-0`}),onPick:()=>v(!0)}]:[],...f.length<a.textStyles?[{label:J(`project.styleNew`),icon:(0,Q.jsx)(Mt,{className:`size-4 shrink-0`}),onPick:x}]:[],...!i||m.full?[]:[{label:J(`project.ruleNew`),icon:(0,Q.jsx)(Ie,{className:`size-4 shrink-0`}),onPick:()=>m.add()}]];return(0,Q.jsxs)(X,{title:J(`project.typography`),hint:J(`project.typographyHint`),save:y,action:l?null:(0,Q.jsx)(se,{entries:S}),children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[u.length?(0,Q.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(260px,1fr))] gap-3`,children:u.map((t,n)=>(0,Q.jsx)(mr,{projectId:e,font:t,first:n===0,readOnly:l,autoFocus:h===t.id,onChange:e=>d(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>d(e=>e.filter(e=>e.id!==t.id))},t.id))}):(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:J(`project.fontsEmpty`)}),f.length?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`font-medium text-[0.9375rem]`,children:J(`project.styles`)}),l?null:(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3 leading-snug`,children:J(`project.stylesHint`)}),(0,Q.jsx)(`ul`,{className:`mt-2 flex flex-col`,children:f.map(e=>(0,Q.jsx)(hr,{style:e,fonts:u,sample:o,readOnly:l,autoFocus:h===e.id,onChange:t=>p(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>p(t=>t.filter(t=>t.id!==e.id))},e.id))})]}):null,i?(0,Q.jsx)(H,{rules:m,placeholder:J(`project.typeRulePlaceholder`),readOnly:l}):null]}),_?(0,Q.jsx)(gr,{projectId:e,onClose:()=>v(!1),onAdd:e=>b(e)}):null]})}function yr({project:e,save:t}){let[n,r]=(0,Z.useState)(e.brand.name??``),[i,a]=(0,Z.useState)(e.brand.about??``),o=s({name:n.trim(),about:i.trim()},e=>t({brand:e}));return(0,Q.jsx)(X,{title:J(`project.base`),hint:J(`project.baseHint`),save:o,locked:e.readOnly,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:J(`project.title`)}),(0,Q.jsx)(F,{value:n,maxLength:120,onChange:e=>r(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:J(`project.titleHint`)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:J(`project.about`)}),(0,Q.jsx)(j,{minRows:4,value:i,onChange:e=>a(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:J(`project.aboutHint`)})]})]})})}function br({project:e,group:t,children:n}){let r=O(),i=P(e.id),[a,o]=(0,Z.useState)(0),[s,l]=(0,Z.useState)(!1),u=async t=>{await L.patch(`/api/studio/projects/${e.id}`,t),await r.invalidateQueries({queryKey:[`projects`]})},d=Le({mutationFn:()=>L.del(`/api/studio/projects/${e.id}`),onSuccess:()=>r.invalidateQueries({queryKey:[`projects`]})}),f=pt(),p=dt(),m=i.data??{files:[],embeddings:!0},h=`${e.id}:${a}`,g=e.readOnly,_=t===`knowledge`,v=jt(`brandSections`),y=jt(`brandRules`),b=jt(`typography`);return St(g?{}:{title:J(_?`project.assistantTitleKnowledge`:`project.assistantTitle`),hello:J(_?`project.assistantHelloKnowledge`:`project.assistantHello`),placeholder:J(_?`project.assistantComposerKnowledge`:`project.assistantComposer`),suggestions:_?[{label:J(`assistant.suggest.knowledgeHow`)},{label:J(`assistant.suggest.knowledgeSite`),fill:!0},{label:J(`assistant.suggest.knowledgeCategories`)}]:[{label:J(`assistant.suggest.readSite`),fill:!0},{label:J(`assistant.suggest.missing`)},{label:J(`assistant.suggest.facts`)}],summary:_?void 0:[e.brand.name?`title "${e.brand.name}"`:`no title`,`${e.facts.length} facts`,`${e.brand.colors?.length??0} colours`,`${m.files.filter(e=>e.kind===`logo`).length} logos`].join(` · `),onChanged:()=>o(e=>e+1)}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[g?(0,Q.jsx)(vt,{children:gt(e)}):null,t===`info`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Y,{id:`base`,children:(0,Q.jsx)(yr,{project:e,save:u},`base:${h}`)}),(0,Q.jsx)(Y,{id:`facts`,children:(0,Q.jsx)(er,{facts:e.facts,save:e=>u({facts:e}),readOnly:g},`facts:${h}`)}),(0,Q.jsx)(Y,{id:`logos`,children:(0,Q.jsx)(nr,{projectId:e.id,data:m,readOnly:g,sections:e.brand.logoSections??[],rules:e.brand.logoRules??[],sectioned:v,ruled:y,save:e=>u({brand:e})},`logos:${h}`)}),(0,Q.jsx)(Y,{id:`colors`,children:(0,Q.jsx)(Xn,{projectId:e.id,data:m,colors:e.brand.colors??[],sections:e.brand.colorSections??[],gradients:e.brand.gradients??[],patterns:e.brand.patterns??[],rules:e.brand.colorRules??[],sectioned:v,ruled:y,save:e=>u({brand:e}),readOnly:g},`colors:${h}`)}),b?(0,Q.jsx)(Y,{id:`typography`,children:(0,Q.jsx)(vr,{projectId:e.id,fonts:e.brand.fonts??[],styles:e.brand.textStyles??[],rules:e.brand.typeRules??[],ruled:y,sample:e.brand.name||J(`project.typeSample`),save:e=>u({brand:e}),readOnly:g},`typography:${h}`)}):null,(0,Q.jsx)(Y,{id:`assets`,children:(0,Q.jsx)(In,{projectId:e.id,data:m,readOnly:g,sections:e.brand.assetSections??[],save:e=>u({brand:e})},`assets:${h}`)})]}):null,n,t===`info`&&f&&!g&&p?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(C,{variant:`danger`,onClick:()=>l(!0),children:J(`settings.delete`)}),(0,Q.jsxs)(c,{open:s,onClose:()=>l(!1),title:J(`settings.deleteTitle`,{name:e.name}),children:[(0,Q.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-2`,children:J(`settings.deleteBody`)}),d.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-rose`,children:d.error.message}):null,(0,Q.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,Q.jsx)(C,{variant:`ghost`,onClick:()=>l(!1),children:J(`common.cancel`)}),(0,Q.jsx)(C,{variant:`danger`,busy:d.isPending,onClick:()=>d.mutate(),children:J(`common.delete`)})]})]})]}):null]})}var xr=[{value:`de-du`,label:`page.lang.deDu`},{value:`de-sie`,label:`page.lang.deSie`},{value:`en`,label:`page.lang.en`}],$=`text-[0.8125rem] text-ink-3 leading-snug`,Sr=`font-mono text-[0.875rem]`,Cr=e=>e.slice(e.indexOf(`.`)+1);function wr(){let[e,t]=(0,Z.useState)(!1),n=(0,Z.useRef)(void 0);return(0,Z.useEffect)(()=>()=>clearTimeout(n.current),[]),{copied:e,copy:e=>navigator.clipboard.writeText(e).then(()=>{t(!0),clearTimeout(n.current),n.current=setTimeout(()=>t(!1),1500)}).catch(()=>t(!1))}}function Tr(){let e=J(`page.sources`).split(/(\{brand\}|\{facts\})/);return(0,Q.jsxs)(`p`,{className:$,children:[e.map((e,t)=>e===`{brand}`?(0,Q.jsx)(v,{to:`/space/info`,className:`text-ink underline-offset-2 hover:underline`,children:J(`space.info`)},t):e===`{facts}`?(0,Q.jsx)(v,{to:`/space/info#facts`,className:`text-ink underline-offset-2 hover:underline`,children:J(`project.facts`)},t):e),` `,J(`page.onlyShared`)]})}function Er({host:e,value:t,onChange:n,disabled:r}){let a=me.test(t);return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex h-11 items-stretch overflow-hidden rounded-lg border border-input bg-card focus-within:border-focus focus-within:ring-4 focus-within:ring-focus-glow`,children:[(0,Q.jsxs)(`span`,{title:`${e}/`,className:`flex max-w-[55%] items-center truncate bg-paper-2 px-3 font-mono text-[0.75rem] text-ink-3`,children:[`…`,Cr(e),`/`]}),(0,Q.jsx)(`input`,{value:t,disabled:r,"aria-label":J(`page.address`),maxLength:D.slug,onChange:e=>n(e.target.value.toLowerCase().replace(/[^a-z0-9-]/g,`-`)),className:i(`min-w-0 flex-1 bg-transparent px-3 outline-none`,Sr)})]}),(0,Q.jsx)(`p`,{className:i(`mt-1.5`,$,!a&&t&&`text-rose`),children:J(`page.addressRules`)})]})}function Dr({host:e,words:t,onChange:n,disabled:r}){return(0,Q.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)] gap-5 sm:grid-cols-[repeat(2,minmax(0,1fr))]`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(R,{children:J(`page.title`)}),(0,Q.jsx)(F,{value:t.title,disabled:r,maxLength:D.title,onChange:e=>n({title:e.target.value})}),(0,Q.jsx)(`p`,{className:i(`mt-1.5`,$),children:J(`page.titleHint`)})]}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(R,{children:J(`page.address`)}),(0,Q.jsx)(Er,{host:e,value:t.slug,disabled:r,onChange:e=>n({slug:e})}),(0,Q.jsx)(`p`,{className:i(`mt-1`,$),children:J(`page.addressChange`)})]}),(0,Q.jsxs)(`div`,{className:`min-w-0 sm:col-span-2`,children:[(0,Q.jsx)(R,{children:J(`page.headline`)}),(0,Q.jsx)(F,{value:t.headline??``,disabled:r,maxLength:D.headline,onChange:e=>n({headline:e.target.value})})]}),(0,Q.jsxs)(`div`,{className:`min-w-0 sm:col-span-2`,children:[(0,Q.jsx)(R,{children:J(`page.words`)}),(0,Q.jsx)(j,{value:t.intro??``,disabled:r,minRows:3,maxLength:D.intro,onChange:e=>n({intro:e.target.value})})]}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(R,{children:J(`page.lang`)}),(0,Q.jsx)(ye,{value:t.voice,onChange:e=>n({voice:e}),options:xr.map(e=>({value:e.value,label:J(e.label)}))}),(0,Q.jsx)(`p`,{className:i(`mt-1.5`,$),children:J(`page.langHint`)})]})]})}function Or(e,t){if(!e.published)return J(`page.draftNote`);if(!e.shareEnabled)return J(`page.notSharedNote`);let n=e.description.trim();return t?[n,J(`page.first`)].filter(Boolean).join(` · `):n}function kr({wizard:e,first:t,on:n,disabled:r,onToggle:a,drag:o}){return(0,Q.jsxs)(`li`,{draggable:o?!0:void 0,onDragStart:o?.onDragStart,onDragOver:o?.onDragOver,onDrop:o?.onDrop,className:i(`flex items-center gap-3 border-border-soft border-t py-2.5 first:border-t-0`,!e.published&&`opacity-60`),children:[o?(0,Q.jsx)(`button`,{type:`button`,"aria-label":`${J(`page.moveUp`)} / ${J(`page.moveDown`)}`,onKeyDown:o.onKeyDown,className:`grid size-7 shrink-0 cursor-grab place-items-center rounded-md text-ink-4 hover:text-ink focus:text-ink`,children:(0,Q.jsx)(d,{className:`size-4`})}):(0,Q.jsx)(`span`,{className:`size-7 shrink-0`}),(0,Q.jsx)(mt,{kind:e.avatar,costume:e.costume,size:36,interactive:!1}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`truncate font-medium text-[0.9375rem]`,children:e.title}),(0,Q.jsx)(`p`,{className:i(`truncate`,$),children:Or(e,t)})]}),(0,Q.jsx)(oe,{checked:n,disabled:r||!e.published,label:J(`page.showOnPage`),onChange:a})]})}function Ar({title:e,text:t,picked:n,disabled:r,later:a,onPick:o}){return(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":n,disabled:r||a,onClick:o,className:i(`flex min-h-20 flex-col items-start gap-1 rounded-xl px-4 py-3 text-left transition`,n?`bg-accent ring-2 ring-primary`:a?`border border-border border-dashed opacity-60`:`ring-1 ring-border-soft hover:bg-paper-2`,(r||a)&&`cursor-not-allowed`),children:[(0,Q.jsx)(`span`,{className:`font-medium text-[0.9375rem]`,children:e}),(0,Q.jsx)(`span`,{className:$,children:t})]})}var jr={desktop:1280,tablet:768,mobile:390},Mr=`wizards.pagePreviewDevice`,Nr=`wizards.pagePreviewHeight`,Pr=360,Fr=e=>e?640:480,Ir=()=>Math.max(Pr,window.innerHeight-140);function Lr(){try{let e=Number(localStorage.getItem(Nr));return e>=Pr?e:null}catch{return null}}function Rr(e){try{e===null?localStorage.removeItem(Nr):localStorage.setItem(Nr,String(Math.round(e)))}catch{}}function zr(){try{let e=localStorage.getItem(Mr);return e&&e in jr?e:`desktop`}catch{return`desktop`}}function Br(e){try{localStorage.setItem(Mr,e)}catch{}}function Vr({url:e,version:t,device:n}){let r=(0,Z.useRef)(null),[a,o]=(0,Z.useState)({width:0,tall:!0});(0,Z.useEffect)(()=>{let e=r.current;if(!e)return;let t=()=>o({width:e.clientWidth,tall:e.clientWidth>=640});t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let s=jr[n],[c,l]=(0,Z.useState)(Lr),[u,d]=(0,Z.useState)(!1),f=(0,Z.useRef)(null),p=Math.min(c??Fr(a.tall),a.width?Ir():9999),m=e=>{let t=Math.round(Math.min(Ir(),Math.max(Pr,e)));return l(t),t},h=n===`mobile`,g=h?12:0,_=a.width?Math.min(1,(a.width-2*g)/s):1,v=(0,Q.jsxs)(`div`,{className:i(`relative overflow-hidden bg-paper-2`,h?`rounded-[1.5rem]`:`rounded-lg ring-1 ring-border-soft`),style:{width:Math.round(s*_),height:p},children:[a.width?(0,Q.jsx)(`iframe`,{title:J(`page.previewTitle`),src:`${e}${e.includes(`?`)?`&`:`?`}v=${t}`,tabIndex:-1,className:i(`absolute top-0 left-0 border-0`,u&&`pointer-events-none`),style:{width:s,height:Math.ceil(p/_),transform:`scale(${_})`,transformOrigin:`top left`}},t):null,(0,Q.jsx)(`button`,{type:`button`,"aria-label":J(`page.resize`),title:J(`page.resize`),onPointerDown:e=>{e.preventDefault();try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}f.current={y:e.clientY,height:p},d(!0)},onPointerMove:e=>{f.current&&m(f.current.height+e.clientY-f.current.y)},onPointerUp:e=>{f.current&&=(Rr(m(f.current.height+e.clientY-f.current.y)),null),d(!1)},onPointerCancel:()=>{f.current=null,d(!1)},onDoubleClick:()=>{l(null),Rr(null)},onKeyDown:e=>{(e.key===`ArrowUp`||e.key===`ArrowDown`)&&(e.preventDefault(),Rr(m(p+(e.key===`ArrowDown`?24:-24))))},className:`absolute right-1 bottom-1 z-10 grid size-7 cursor-ns-resize touch-none place-items-center rounded-md bg-card/90 text-ink-3 shadow-soft ring-1 ring-border-soft hover:text-ink coarse:size-9`,children:(0,Q.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,"aria-hidden":`true`,children:(0,Q.jsx)(`path`,{d:`M11 1 1 11M11 5 5 11M11 9 9 11`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`})})})]});return(0,Q.jsx)(`div`,{ref:r,className:`flex w-full justify-center`,children:h?(0,Q.jsx)(`div`,{className:`rounded-[2.25rem] bg-ink p-3 shadow-soft`,children:v}):v})}function Hr({host:e,page:t,disabled:n,save:r,onState:i}){let a=(0,Z.useRef)(t);a.current=t;let[o,c]=(0,Z.useState)(()=>({slug:t.slug,title:t.title,headline:t.headline??``,intro:t.intro??``,voice:Ve(t)})),l=s(o,async e=>{if(!(me.test(e.slug)&&e.title.trim()))return;let{lang:t,form:n}=st(e.voice);await r({...a.current,slug:e.slug,title:e.title.trim(),headline:e.headline?.trim()||void 0,intro:e.intro?.trim()||void 0,lang:t,form:n})}),{state:u,error:d}=l;return(0,Z.useEffect)(()=>i(l),[u,d]),(0,Q.jsx)(Dr,{host:e,words:o,disabled:n,onChange:e=>c(t=>({...t,...e}))})}function Ur({project:e}){let t=O(),n=ft(),r=n.data?.tenant.pagesHost??null,a=n.data?.manageUrl??null,o=e.readOnly,s=e.page,c=!!s?.on,l=be({queryKey:[`project-wizards`,e.id],queryFn:()=>L.get(`/api/studio/projects/${e.id}/wizards`)}),[u,d]=(0,Z.useState)(1),[f,p]=(0,Z.useState)(zr),m=(0,Z.useRef)(s);m.current=s;let h=async n=>{await L.patch(`/api/studio/projects/${e.id}`,{page:n}),await t.invalidateQueries({queryKey:[`projects`]}),d(e=>e+1)},g=Le({mutationFn:e=>{let t=m.current;return t?h({...t,...e}):Promise.resolve()}}),[_,v]=(0,Z.useState)({state:`idle`,error:null}),{copied:y,copy:b}=wr(),x=l.data??[],w=(s?.wizards??[]).map(e=>x.find(t=>t.id===e)).filter(e=>e!==void 0),T=x.filter(e=>!s?.wizards.includes(e.id)),[E,D]=(0,Z.useState)(null),k=(e,t)=>{let n=[...s?.wizards??[]];if(t<0||t>=n.length||e===t)return;let[r]=n.splice(e,1);n.splice(t,0,r),g.mutate({wizards:n})},A=(e,t)=>g.mutate({wizards:t?[...s?.wizards??[],e]:(s?.wizards??[]).filter(t=>t!==e)}),j=e.brand.name?.trim()||e.name,te=Le({mutationFn:()=>h({on:!0,slug:S(j)||`page`,title:j,...st(Se===`de`?`de-du`:`en`),wizards:x.filter(e=>e.published&&e.shareEnabled).map(e=>e.id),examples:{}})}),N=e=>{s?g.mutate({on:e}):e&&te.mutate()},ne=g.isPending||te.isPending,re=g.error??te.error;if(!r)return(0,Q.jsx)(Y,{id:`page`,children:(0,Q.jsx)(X,{title:J(`space.page`),hint:J(`page.intro`),children:(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-2`,children:J(`page.cloudOnly`)})})});let P=s?.slug||S(j)||`…`,F=We(r,P),I=ot(r,P,a),ie=(0,Q.jsxs)(`span`,{className:i(Sr,`min-w-0 truncate`),children:[(0,Q.jsxs)(`span`,{className:`text-ink-3`,children:[r,`/`]}),(0,Q.jsx)(`b`,{className:`text-ink`,children:P})]}),R=o||!s,z=(0,Q.jsxs)(M,{className:`flex flex-col gap-2.5 p-4`,children:[(0,Q.jsxs)(`div`,{className:`@container flex items-center justify-between gap-3`,children:[(0,Q.jsx)(`h3`,{className:`font-medium text-[0.875rem]`,children:J(`page.previewTitle`)}),c?(0,Q.jsx)(rt,{named:!0,label:J(`editor.device`),value:f,onChange:e=>{p(e),Br(e)},options:[{id:`desktop`,label:J(`editor.deviceDesk`),icon:(0,Q.jsx)(Ft,{className:`size-3.5`})},{id:`tablet`,label:J(`page.deviceTablet`),icon:(0,Q.jsx)(gn,{className:`size-3.5`})},{id:`mobile`,label:J(`editor.devicePhone`),icon:(0,Q.jsx)(ct,{className:`size-3.5`})}]}):null]}),c?(0,Q.jsx)(Vr,{url:I,version:u,device:f}):(0,Q.jsx)(`p`,{className:$,children:J(`page.previewOff`)}),c?(0,Q.jsx)(`p`,{className:$,children:J(`page.previewHint`)}):null]}),ae=(0,Q.jsxs)(M,{className:`flex flex-col gap-3 p-4`,children:[(0,Q.jsx)(`h3`,{className:`font-medium text-[0.875rem]`,children:J(`page.inShare`)}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg bg-paper-2 px-3 py-2.5`,children:[(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`block truncate font-medium text-[0.875rem]`,children:J(`share.onPage`,{space:s?.title||j})}),(0,Q.jsx)(`span`,{className:i(`block truncate font-mono`,$),children:F})]}),(0,Q.jsx)(oe,{checked:!0,disabled:!0,label:J(`page.showOnPage`),onChange:()=>{}})]}),(0,Q.jsx)(`p`,{className:$,children:J(`page.inShareHint`)})]});return(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-9`,children:[(0,Q.jsxs)(`div`,{className:`contents`,children:[(0,Q.jsx)(Y,{id:`page`,children:(0,Q.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,Q.jsxs)(`div`,{className:`px-1`,children:[(0,Q.jsx)(`h2`,{className:`font-display font-semibold text-lg leading-tight`,children:J(`space.page`)}),(0,Q.jsx)(`p`,{className:`mt-1 text-[0.875rem] text-ink-3 leading-snug`,children:J(`page.intro`)})]}),(0,Q.jsxs)(M,{className:`flex flex-wrap items-center gap-3 p-3 sm:pl-4`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:i(`size-2 shrink-0 rounded-full`,c?`bg-moss`:`bg-ink-4`),"aria-hidden":!0}),ie]}),(0,Q.jsxs)(`span`,{className:`flex w-full items-center gap-2 sm:w-auto sm:shrink-0`,children:[(0,Q.jsxs)(C,{variant:`secondary`,size:`sm`,className:`max-sm:flex-1`,disabled:!c,onClick:()=>b(I),children:[y?(0,Q.jsx)(ke,{className:`size-3.5`}):(0,Q.jsx)(ee,{className:`size-3.5`}),J(y?`share.copied`:`share.copyMain`)]}),(0,Q.jsxs)(C,{size:`sm`,className:`max-sm:flex-1`,disabled:!c,onClick:()=>window.open(I,`_blank`,`noopener`),children:[J(`page.open`),` `,(0,Q.jsx)(xt,{className:`size-3.5`})]})]})]}),(0,Q.jsxs)(X,{title:J(`page.sectionPage`),locked:o,children:[(0,Q.jsxs)(`fieldset`,{"aria-label":J(`page.sectionPage`),className:`grid min-w-0 gap-3 sm:grid-cols-[repeat(3,minmax(0,1fr))]`,children:[(0,Q.jsx)(Ar,{title:J(`page.whoOff`),text:J(`page.whoOffHint`),picked:!c,disabled:o||ne,onPick:()=>N(!1)}),(0,Q.jsx)(Ar,{title:J(`page.whoPublic`),text:J(`page.whoPublicHint`),picked:c,disabled:o||ne,onPick:()=>N(!0)}),(0,Q.jsx)(Ar,{title:J(`page.whoMembers`),text:J(`page.whoMembersHint`),picked:!1,later:!0,onPick:()=>{}})]}),re?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:re.message}):null]})]})}),z,(0,Q.jsx)(Y,{id:`page-words`,children:(0,Q.jsx)(X,{title:J(`page.sectionWords`),hint:s?void 0:J(`page.notYet`),save:s?_:void 0,locked:R,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[s?(0,Q.jsx)(Hr,{host:r,page:s,disabled:o,save:h,onState:v},`${e.id}:${s.slug}`):(0,Q.jsx)(Dr,{host:r,disabled:!0,words:{slug:P,title:j,headline:``,intro:``,voice:Se===`de`?`de-du`:`en`},onChange:()=>{}}),(0,Q.jsxs)(`div`,{id:`page-wizards`,className:`scroll-mt-6 border-border-soft border-t pt-5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1`,children:[(0,Q.jsx)(`h3`,{className:`font-medium text-[0.9375rem]`,children:J(`page.sectionWizards`)}),(0,Q.jsx)(`span`,{className:$,children:J(`page.wizardsHint`)})]}),(0,Q.jsxs)(`ul`,{className:`mt-2 flex flex-col`,children:[w.map((e,t)=>(0,Q.jsx)(kr,{wizard:e,first:t===0,on:!0,disabled:R,onToggle:t=>A(e.id,t),drag:{onDragStart:()=>D(t),onDragOver:e=>e.preventDefault(),onDrop:()=>{E!==null&&k(E,t),D(null)},onKeyDown:e=>{(e.key===`ArrowUp`||e.key===`ArrowDown`)&&(e.preventDefault(),k(t,e.key===`ArrowUp`?t-1:t+1))}}},e.id)),T.map(e=>(0,Q.jsx)(kr,{wizard:e,first:!1,on:!1,disabled:R,onToggle:t=>A(e.id,t)},e.id))]}),x.length?null:(0,Q.jsx)(`p`,{className:i(`mt-2`,$),children:J(`page.noWizards`)}),(0,Q.jsx)(`p`,{className:i(`mt-4`,$),children:J(`page.wizardsNote`)})]}),(0,Q.jsx)(Tr,{})]})})})]}),ae]})}var Wr=`results-search`,Gr={q:``,mode:``,days:0};function Kr(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 be({queryKey:[`results`,e,i],queryFn:()=>L.get(`/api/studio/projects/${e}/results${i&&`?${i}`}`),enabled:!!e,placeholderData:e=>e,refetchInterval:15e3})}function qr({data:e,wizardId:t,onWizard:n,filter:r,onFilter:i}){let[a,o]=(0,Z.useState)(r.q);return Dt({icon:ve,label:J(`space.resultsSearch`),run:()=>{let e=document.getElementById(Wr);e?.scrollIntoView({block:`center`,behavior:`smooth`}),e?.focus()}}),(0,Z.useEffect)(()=>{if(a===r.q)return;let e=setTimeout(()=>i({...r,q:a}),250);return()=>clearTimeout(e)},[a,r,i]),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(ye,{value:t??``,onChange:e=>n(e||null),options:[{value:``,label:J(`space.resultsAllWizards`)},...e.wizards.filter(e=>e.results||e.id===t).map(e=>({value:e.id,label:`${e.title} (${e.results})`}))],className:`w-56 max-sm:w-full`}),(0,Q.jsxs)(`div`,{className:`relative min-w-0 flex-1 basis-56`,children:[(0,Q.jsx)(ve,{className:`-translate-y-1/2 pointer-events-none absolute top-1/2 left-3 size-4 text-ink-3`}),(0,Q.jsx)(F,{type:`search`,value:a,onChange:e=>o(e.target.value),id:Wr,placeholder:J(`space.resultsSearch`),"aria-label":J(`space.resultsSearch`),className:`w-full pl-9`})]}),(0,Q.jsx)(ye,{value:r.mode,onChange:e=>i({...r,mode:e}),options:[{value:``,label:J(`space.resultsModeAll`)},{value:`live`,label:`Live`},{value:`test`,label:`Test`}],className:`w-32`}),(0,Q.jsx)(ye,{value:String(r.days),onChange:e=>i({...r,days:Number(e)}),options:[{value:`0`,label:J(`space.resultsAnyTime`)},{value:`1`,label:J(`space.resultsDay`)},{value:`7`,label:J(`space.resultsDays`,{n:7})},{value:`30`,label:J(`space.resultsDays`,{n:30})}],className:`w-44`})]})}function Jr({data:e,wizardId:t,onWizard:n,filter:r,onFilter:i}){let[a,o]=(0,Z.useState)(null),s=t=>e.wizards.find(e=>e.id===t)?.title??``,c=new Intl.DateTimeFormat(Se,{dateStyle:`medium`,timeStyle:`short`});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(X,{title:t?s(t):J(`space.resultsAll`),hint:J(`space.resultsHint`),plain:!0,children:[(0,Q.jsx)(qr,{data:e,wizardId:t,onWizard:n,filter:r,onFilter:i}),e.runs.length?(0,Q.jsx)(M,{className:`flex flex-col p-1.5`,children:e.runs.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>o(e),className:`flex items-center gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`truncate text-[0.875rem]`,children:t?c.format(new Date(e.doneAt)):s(e.wizardId)}),(0,Q.jsxs)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:[t?null:`${c.format(new Date(e.doneAt))} · `,J(`space.resultCredits`,{n:e.credits})]})]}),e.assets?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[0.75rem] text-ink-3 tabular-nums`,title:J(`space.resultFiles`,{n:e.assets}),children:[(0,Q.jsx)(De,{className:`size-3.5`}),e.assets]}):null,e.mode===`test`?(0,Q.jsx)(Ae,{children:J(`run.testChip`)}):(0,Q.jsxs)(Ae,{tone:`live`,children:[`Live v`,e.version]})]},e.id))}):(0,Q.jsx)(M,{children:(0,Q.jsx)(ie,{children:r.q.trim()||r.mode||r.days?J(`space.resultsNone`):J(`space.resultsEmpty`)})})]}),a?(0,Q.jsx)(tt,{header:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-[0.875rem]`,children:s(a.wizardId)}),a.mode===`test`?(0,Q.jsx)(Ae,{children:J(`run.testChip`)}):(0,Q.jsxs)(Ae,{tone:`live`,children:[`Live v`,a.version]})]}),onClose:()=>o(null),children:(0,Q.jsx)(lt,{runId:a.id,compact:!0,studio:!0},a.id)}):null]})}function Yr({project:e,save:t}){let[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(e.name),o=Le({mutationFn:()=>t({name:i.trim()}),onSuccess:()=>r(!1)});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(g,{label:J(`project.rename`),onClick:()=>{a(e.name),r(!0)},children:(0,Q.jsx)(we,{className:`size-4`})}),(0,Q.jsx)(c,{open:n,onClose:()=>r(!1),title:J(`project.rename`),children:(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),i.trim()&&o.mutate()},children:[(0,Q.jsx)(F,{"data-autofocus":!0,value:i,maxLength:80,onChange:e=>a(e.target.value)}),o.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:o.error.message}):null,(0,Q.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,Q.jsx)(C,{variant:`ghost`,onClick:()=>r(!1),children:J(`common.cancel`)}),(0,Q.jsx)(C,{type:`submit`,busy:o.isPending,disabled:!i.trim(),children:J(`settings.save`)})]})]})})]})}function Xr({project:e}){let t=O();return(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(Ct,{}),e.readOnly?null:(0,Q.jsx)(Yr,{project:e,save:async n=>{await L.patch(`/api/studio/projects/${e.id}`,n),await t.invalidateQueries({queryKey:[`projects`]})}})]})}function Zr(e){let t=e.join(` `),[n,r]=(0,Z.useState)(e[0]);return(0,Z.useEffect)(()=>{let e=t.split(` `),n=0,i=()=>{n=0;let t=Rt(),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 Qr(e,t){let n=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;document.getElementById(e)?.scrollIntoView({block:`start`,behavior:t&&!n?`smooth`:`auto`})}function $r({groups:e,current:t,onPick:n}){return e.map(e=>{let r=e.sections.map(e=>(0,Q.jsx)(Ht,{icon:e.icon??Me,label:e.label,selected:e.id===t,onPick:()=>n(e.id)},e.id));return e.label?(0,Q.jsx)(Gt,{label:e.label,children:r},e.plugin):(0,Q.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:r},`own`)})}function ei(){let{group:e}=xe(),[t,n]=_e(),a=le(),o=r(),{hash:s}=o,{project:c,loading:l}=ut(),u=pt(),d=Lt(),f=Zt(),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(null),y=Ot(e)?e:void 0,b=y?void 0:d.spaceParts.find(t=>t.id===e),x=y??b?.id,S=o.state?.parts===!0,C=jt(`pages`),w=Nt().filter(e=>C||e.id!==`page`),T=At(w,d).map(e=>({...e,to:`/space/${e.id}`})),E={id:`results`,label:J(`space.results`),icon:bt,to:`/space/results`},D=y===`results`?E:T.find(e=>e.id===x),O=t.get(`show`),k=y===`results`?2:x?O?2:1:0,A=y===`results`?1:f?Math.min(k,1):x&&_!==x&&!S?1:0,ee=Wt(A),j=Wt(k),te=(0,Z.useMemo)(()=>({slot:p,narrow:f,setDetail:g}),[p,f]),M=c?c.brand.name?.trim()||c.name:J(`nav.project`),N=jt(`typography`)?[]:[`typography`],ne=b?d.spaceMenus[b.id]??[]:[],re=b?[{plugin:null,label:null,sections:ne}]:y&&y!==`results`?Pt(y,d,N):[],P=y?Pt(y,d).filter(e=>e.plugin):[],F=Zr([...re,...y===`results`?P:[]].flatMap(e=>e.sections.map(e=>e.id))),I=y===`results`&&O&&O!==`all`?O:null,[L,R]=(0,Z.useState)(Gr),z=Kr(y===`results`?c?.id:void 0,I,L),oe=z.data?.wizards.find(e=>e.id===I)?.title,B=y===`data`&&O&&O!==`all`||y===`knowledge`&&O&&/^[ptfcvs]:/.test(O)?O:null,V=B?.startsWith(`s:`)?d.spaceSections.find(e=>e.id===B.slice(2)):void 0,H=y===`knowledge`&&B&&/^[ptf]:/.test(B)?B:null,U=Ge(y===`data`?c?.id:void 0),W=Qe(y===`knowledge`?c?.id:void 0),G=at(B?.startsWith(`v:`)?B.slice(2):``),se=W.data?.categories.find(e=>e.id===(B?.startsWith(`c:`)?B.slice(2):G.data?.category.id)),ce=y===`knowledge`?V?V.label():B?.startsWith(`v:`)?G.data&&`${G.data.category.name}: ${G.data.value}`:B?.startsWith(`c:`)?se?.name:W.data?.items.find(e=>e.key===B)?.title:U.data?nt(U.data).flatMap(e=>e.items).find(e=>e.key===B)?.title:void 0;Bt([...y===`results`?[]:[{label:J(`nav.project`),to:`/space`}],...D?[{label:D.label,to:`/space/${D.id}`}]:[],...D&&(h??oe??ce)?[{label:h??oe??ce}]:[]]);let ue={p:`page`,t:`table`,f:`file`,c:`category`,v:`category value`,s:`plugin section`};St({...y===`data`||y===`results`?{compact:!0}:{},...y===`data`?{suggestions:[{label:J(`assistant.suggest.dataWhat`)},{label:J(`assistant.suggest.dataWho`)},{label:J(`assistant.suggest.dataEdit`)}]}:y===`results`?{suggestions:[{label:J(`assistant.suggest.resultsFailed`)},{label:J(`assistant.suggest.resultsCost`)},{label:J(`assistant.suggest.resultsShare`)}]}:{},...B&&ce?{open:{kind:ue[B[0]]??`item`,id:B.slice(2),label:ce}}:I&&oe?{open:{kind:`wizard`,id:I,label:oe}}:{}});let de=y===`results`||y===`data`||B?s.slice(1):O||s.slice(1),fe=(0,Z.useRef)(``);if((0,Z.useEffect)(()=>{let e=`${x}#${de}`;de&&fe.current!==e&&document.getElementById(de)&&(fe.current=e,requestAnimationFrame(()=>Qr(de,!1)))},[x,de,c?.id,d.spaceSections,ne.length]),!x){let t=s.slice(1),n=t?Et(t,d):null;if(n===`knowledge`&&d.spaceSections.some(e=>e.id===t))return(0,Q.jsx)(ae,{to:`/space/knowledge?show=s:${t}`,replace:!0});if(n)return(0,Q.jsx)(ae,{to:f?`/space/${n}?show=${t}`:{pathname:`/space/${n}`,hash:t},replace:!0});if((t||e)&&d.status!==`ready`)return null;if(e!==void 0||!f)return(0,Q.jsx)(ae,{to:`/space/info`,replace:!0,state:{parts:!0}})}if(y===`knowledge`&&!O&&d.spaceSections.some(e=>e.id===s.slice(1)))return(0,Q.jsx)(ae,{to:`/space/knowledge?show=s:${s.slice(1)}`,replace:!0});let K=e=>{if(f){a({search:`?show=${e}`});return}fe.current=`${x}#${e}`,Qr(e,!0),a({search:``,hash:e},{replace:!0})},q=e=>f?n({show:e}):n(e===`all`?{}:{show:e},{replace:!0}),pe=e=>e.flatMap(e=>e.sections).map(e=>d.spaceSections.find(t=>t.id===e.id)).filter(e=>e!==void 0).map(e=>(0,Q.jsx)(Y,{id:e.id,children:(0,Q.jsx)(X,{title:e.label(),hint:e.hint?.(),plain:!0,children:(0,Q.jsx)(It,{of:e,children:(0,Q.jsx)(e.component,{})})})},e.serial)),me=f?void 0:F,he=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Kt,{title:M,open:A===1?D??null:null,onBack:y===`results`?void 0:()=>f?a(`/space`):v(x??null),root:{icon:wt,label:J(`nav.project`),backLabel:J(`nav.wizards`),onBack:()=>a(`/`)}}),(0,Q.jsx)(`div`,{className:i(Ut(ee)),children:A===0?(0,Q.jsx)(Jt,{entries:T,current:f?void 0:D,onPick:()=>v(null)}):(0,Q.jsx)(`div`,{ref:m})},A)]});return(0,Q.jsx)(qt.Provider,{value:te,children:(0,Q.jsx)(`div`,{className:`animate-rise`,children:(0,Q.jsxs)(`div`,{className:i(`grid gap-6`,y!==`results`&&`md:grid-cols-[10.5rem_minmax(0,1fr)] md:gap-5 lg:grid-cols-[15rem_minmax(0,1fr)] lg:gap-10`),children:[y===`results`?null:(0,Q.jsx)(`aside`,{className:i(`min-w-0 md:sticky md:top-6 md:self-start`,f&&k===2&&`hidden`,f&&j===`back`&&Ut(`back`)),children:he}),x?(0,Q.jsxs)(`div`,{className:i(`min-w-0`,f&&k<2&&`hidden`,f&&j===`deeper`&&Ut(`deeper`)),children:[f&&y!==`results`?(0,Q.jsx)(`div`,{className:`mb-3`,children:(0,Q.jsx)(Xt,{label:D?.label??M,onBack:()=>a(`/space/${x}`)})}):null,u&&c?(0,Q.jsx)(`div`,{className:`mb-6`,children:(0,Q.jsx)(Xr,{project:c})}):null,y===`data`?(0,Q.jsxs)(Yt,{children:[(0,Q.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,Q.jsx)(Ht,{icon:Vt,label:J(`data.all`),selected:!f&&!B,onPick:()=>q(`all`)})}),U.data?nt(U.data).map(e=>(0,Q.jsx)(Gt,{label:e.label,children:e.items.map(e=>(0,Q.jsx)(Ht,{icon:Ue[e.kind],label:e.title,selected:!f&&e.key===B,onPick:()=>q(e.key)},e.key))},e.key)):null,(0,Q.jsx)($r,{groups:P,current:me,onPick:K})]}):y===`knowledge`?(0,Q.jsxs)(Yt,{children:[(0,Q.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,Q.jsx)(Ht,{icon:Vt,label:J(`know.all`),selected:!(f||B),onPick:()=>q(`all`)})}),W.data?.categories.length?(0,Q.jsx)(Gt,{label:J(`know.categories`),children:W.data.categories.map(e=>(0,Q.jsx)(Ht,{icon:Ye[e.type],label:e.name,badge:(0,Q.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:e.proposed?`·`:e.count}),selected:!f&&(B===`c:${e.id}`||G.data?.category.id===e.id),onPick:()=>q(`c:${e.id}`)},e.id))}):null,(0,Q.jsx)($r,{groups:P,current:f?void 0:V?.id,onPick:e=>q(`s:${e}`)})]}):(0,Q.jsx)(Yt,{children:(0,Q.jsx)($r,{groups:re,current:me,onPick:K})}),c&&(y===`info`||y===`knowledge`)?(0,Q.jsxs)(br,{project:c,group:y,children:[y===`knowledge`?H?H.startsWith(`p:`)?(0,Q.jsx)(Ze,{pageId:H.slice(2),onGone:()=>q(`all`),onOpen:q},H):H.startsWith(`t:`)?(0,Q.jsx)(Xe,{tableId:H.slice(2),onGone:()=>q(`all`)},H):(0,Q.jsx)(kn,{projectId:c.id,fileId:H.slice(2),readOnly:c.readOnly,onGone:()=>q(`all`)},H):W.data?V?(0,Q.jsx)(X,{title:V.label(),hint:V.hint?.(),plain:!0,children:(0,Q.jsx)(It,{of:V,children:(0,Q.jsx)(V.component,{})})},B):B?.startsWith(`c:`)?se?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(Je,{projectId:c.id,category:se,readOnly:c.readOnly,onOpen:q,onGone:()=>q(`all`)}),se.type===`choice`?null:(0,Q.jsx)(it,{projectId:c.id,category:se,categories:W.data.categories,onOpen:q})]},B):null:B?.startsWith(`v:`)?G.data?(0,Q.jsx)(He,{value:G.data,readOnly:c.readOnly,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[G.data.items.length?(0,Q.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,Q.jsx)(Ke,{item:e,categories:W.data.categories.filter(e=>e.id!==G.data?.category.id),onOpen:q},e.key))}):null,G.data.rows.map(e=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>q(`t:${e.tableId}`),className:`px-1 text-left text-[0.8125rem] text-ink-3 hover:text-ink`,children:J(`know.tocRows`,{n:e.count,table:e.title})},e.tableId))]})},B):null:(0,Q.jsx)(Y,{id:`documents`,children:(0,Q.jsx)(et,{projectId:c.id,data:W.data,readOnly:c.readOnly,onOpen:q})}):null:null,y===`info`?pe(P):null]},c.id):null,c&&y===`page`&&C?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[(0,Q.jsx)(Ur,{project:c},c.id),pe(P)]}):null,c&&b?(0,Q.jsx)(It,{of:b,children:(0,Q.jsx)(Tt,{part:b.id,children:(0,Q.jsx)(b.component,{})},c.id)}):null,c&&y===`data`?(0,Q.jsx)(`div`,{className:`flex flex-col gap-9 pb-20`,children:B?.startsWith(`t:`)?(0,Q.jsx)(Xe,{tableId:B.slice(2),onGone:()=>q(`all`)},B):B?.startsWith(`p:`)?(0,Q.jsx)(Ze,{pageId:B.slice(2),onGone:()=>q(`all`)},B):(0,Q.jsxs)(Q.Fragment,{children:[U.data?(0,Q.jsx)($e,{projectId:c.id,data:U.data,readOnly:c.readOnly,onOpen:q}):null,pe(P)]})}):null,c&&y===`results`?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[z.data?(0,Q.jsx)(Jr,{data:z.data,wizardId:I,onWizard:e=>q(e??`all`),filter:L,onFilter:R}):null,z.isError?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:z.error.message}):null,pe(P)]}):null,c||l?null:(0,Q.jsx)(ie,{children:J(`settings.noProject`)})]}):null]})})})}export{ei as ProjectPage};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/AboutDialog-CZr1JFvY.js","assets/rolldown-runtime-hePW80VL.js","assets/jsx-runtime-BNakU3Ej.js","assets/ui-Bk08zclS.js","assets/preload-helper-DpV6A1kQ.js","assets/logo-CGNoptDg.js","assets/engenty-CNjaZCVM.js","assets/index-CXA_do-X.js","assets/Marketplace-BwbLRU2n.js","assets/useMutation-DM9Anfo-.js","assets/volume-2-CHuzf68z.js","assets/coins-Bo9_D-7S.js","assets/session-DvW7auj-.js","assets/react-dom-hf6EcyAr.js","assets/media-Cej-H610.js","assets/index-DG0i3S-z.css","assets/settings-menu-tSPDYTfT.js","assets/ChangelogDialog-0pKHVdhu.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$t as r,Ar as i,Gt as a,Ht as o,Ir as s,Jr as c,Jt as l,Kr as u,Lt as d,Oi as f,Pr as p,Rr as m,Rt as h,Sn as g,Tr as _,Ur as v,Ut as y,Vt as b,W as x,Xr as S,Xt as C,_r as w,br as T,cr as E,ei as ee,hr as te,ni as ne,on as D,pr as re,qt as ie,ri as O,ti as ae,tn as k,wn as oe,y as se,zr as A,zt as j}from"./ui-Bk08zclS.js";import{C as ce,b as le,w as ue}from"./Marketplace-BwbLRU2n.js";import{t as M}from"./useMutation-DM9Anfo-.js";import{t as de}from"./preload-helper-DpV6A1kQ.js";import{n as fe,r as pe,t as me}from"./volume-2-CHuzf68z.js";import{n as he,r as ge,t as _e}from"./wrench-BAgonupx.js";import{t as N}from"./coins-Bo9_D-7S.js";import{d as ve,g as ye,n as be,p as xe,y as Se}from"./session-DvW7auj-.js";import{n as Ce,r as we,t as Te}from"./ReadOnly-CQ8lWsnZ.js";import{A as P,B as F,C as Ee,F as De,H as Oe,I as ke,K as Ae,L as je,M as Me,N as Ne,P as Pe,R as Fe,S as Ie,V as Le,_ as Re,_t as ze,at as Be,b as Ve,it as He,j as Ue,l as We,pt as Ge,q as Ke,s as qe,st as Je,u as Ye,w as Xe,wt as I,xt as Ze,y as Qe,z as L}from"./index-CXA_do-X.js";import{a as R,c as $e,d as et,f as tt,i as z,l as nt,n as rt,o as it,r as at,s as ot,t as st,u as ct}from"./settings-menu-tSPDYTfT.js";import{t as lt}from"./Harness-DPRw6BmX.js";var ut={name:`ear`,size:24,node:[[`path`,{d:`M6 8.5a6.5 6.5 0 1 1 13 0c0 6-6 6-6 10a3.5 3.5 0 1 1-7 0`,key:`1dfaln`}],[`path`,{d:`M15 8.5a2.5 2.5 0 0 0-5 0v1a2 2 0 1 1 0 4`,key:`1qnva7`}]]};ut.node;var dt=u(ut),ft={name:`key-round`,size:24,node:[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]};ft.node;var B=u(ft),pt={name:`mail-plus`,size:24,node:[[`path`,{d:`M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8`,key:`12jkf8`}],[`path`,{d:`m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7`,key:`1ocrg3`}],[`path`,{d:`M19 16v6`,key:`tddt3s`}],[`path`,{d:`M16 19h6`,key:`xwg31i`}]]};pt.node;var mt=u(pt),ht={name:`rotate-cw`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]};ht.node;var gt=u(ht),V=e(t(),1),H=e(n(),1);function _t(){let e=Ye(),[t,n]=(0,V.useState)(null),[r,i]=(0,V.useState)(null),a=async e=>{n(e??`*`),i(null);try{await We(e)}catch(e){i(e.message)}finally{n(null)}};return(0,H.jsxs)(se,{title:D(`plugins.title`),hint:e.canReload?D(`plugins.hint`):D(`plugins.hintManaged`),action:e.canReload?(0,H.jsx)(d,{variant:`secondary`,busy:t===`*`,onClick:()=>void a(),children:D(`plugins.rescan`)}):null,children:[e.plugins.length||e.problems.length?null:(0,H.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:D(`plugins.none`)}),(0,H.jsxs)(`ul`,{className:`divide-y divide-border-soft`,children:[e.plugins.map(n=>{let r=e.failed[n.id];return(0,H.jsxs)(`li`,{className:`flex items-start gap-4 py-4 first:pt-0 last:pb-0`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1`,children:[(0,H.jsx)(`span`,{className:`font-medium text-[0.9375rem]`,children:n.name}),n.name===n.id?null:(0,H.jsxs)(`span`,{className:`font-mono text-[0.75rem] text-ink-4`,children:[n.id,` · `,n.version]})]}),n.description?(0,H.jsx)(`p`,{className:`mt-0.5 text-[0.875rem] text-ink-3`,children:n.description}):null,n.tools.length?(0,H.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5 text-[0.75rem] text-ink-3`,children:[D(`plugins.tools`),n.tools.map(e=>(0,H.jsx)(j,{children:e.id},e.id))]}):null,n.error?(0,H.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-rose`,children:D(`plugins.serverFailed`,{error:n.error})}):null,r?(0,H.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-rose`,children:D(`plugins.studioFailed`,{error:r})}):null]}),e.canReload?(0,H.jsx)(o,{label:D(`plugins.reload`),disabled:t!==null,onClick:()=>void a(n.id),children:(0,H.jsx)(gt,{className:t===n.id?`size-4 animate-spin`:`size-4`})}):null]},n.id)}),e.problems.map(e=>(0,H.jsxs)(`li`,{className:`py-4 first:pt-0 last:pb-0`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1`,children:[(0,H.jsx)(j,{tone:`warn`,children:D(`plugins.problems`)}),(0,H.jsx)(`span`,{className:`break-all font-mono text-[0.75rem] text-ink-3`,children:e.path})]}),(0,H.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:e.message})]},e.path))]}),r?(0,H.jsx)(`p`,{className:`mt-4 text-[0.8125rem] text-rose`,children:r}):null]})}var vt=[`pro-modules`],yt=`/api/studio/plugins/-/pro`,bt={managed:`pro.held.plan`,not_installed:`pro.held.release`,release:`pro.held.release`,unconfirmed:`pro.held.unconfirmed`,plan:`pro.held.plan`},xt=e=>new Date(e).toLocaleDateString(g[k],{day:`numeric`,month:`long`});function St(){let e=f(),{canReload:t}=Ye(),n=O({queryKey:vt,queryFn:()=>x.get(yt),enabled:t}),r=t=>e.setQueryData(vt,t),a=M({mutationFn:()=>x.post(`${yt}/refresh`),onSuccess:r}),o=M({mutationFn:e=>x.post(`${yt}/${e}`),onSuccess:r}),s=M({mutationFn:e=>x.del(`${yt}/${e}`),onSuccess:r}),c=n.data,u=o.isPending||s.isPending,p=o.error??s.error??a.error;return t?(0,H.jsx)(se,{title:D(`pro.title`),hint:D(`pro.hint`),action:c?.linked?(0,H.jsx)(d,{variant:`secondary`,busy:a.isPending,onClick:()=>a.mutate(),children:D(`pro.check`)}):null,children:n.isError?(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,H.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:D(`pro.failed`,{error:n.error.message})}),(0,H.jsx)(d,{variant:`secondary`,onClick:()=>void n.refetch(),children:D(`pro.retry`)})]}):c?c.linked?(0,H.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 text-[0.8125rem] text-ink-3`,children:[(0,H.jsxs)(`span`,{children:[c.plan?D(`pro.plan`,{plan:c.plan.name}):null,c.plan&&c.expiresAt?` · `:null,c.expiresAt?D(`pro.confirmedUntil`,{date:xt(c.expiresAt)}):null]}),(0,H.jsxs)(d,{variant:`ghost`,onClick:()=>P(`${c.accountUrl}/billing`),children:[D(`pro.plans`),` `,(0,H.jsx)(i,{className:`size-4`})]})]}),c.error?(0,H.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:c.error}):null,c.modules.length?(0,H.jsx)(`ul`,{className:`divide-y divide-border-soft`,children:c.modules.map(e=>(0,H.jsxs)(`li`,{className:`flex items-start gap-4 py-4 first:pt-0 last:pb-0`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1`,children:[(0,H.jsx)(`span`,{className:`font-medium text-[0.9375rem]`,children:e.name}),(0,H.jsxs)(`span`,{className:`font-mono text-[0.75rem] text-ink-4`,children:[e.id,` · `,e.installed?.version??e.version]}),e.loaded?(0,H.jsx)(j,{tone:`live`,children:D(`pro.on`)}):null,e.included?null:(0,H.jsx)(j,{children:D(`pro.notInPlan`)}),e.installed&&e.heldBack&&e.included?(0,H.jsx)(j,{tone:`warn`,children:D(bt[e.heldBack])}):null]}),e.description?(0,H.jsx)(`p`,{className:`mt-0.5 text-[0.875rem] text-ink-3`,children:e.description}):null]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[e.included&&(!e.installed||e.update)?(0,H.jsx)(d,{busy:o.isPending&&o.variables===e.id,disabled:u,onClick:()=>o.mutate(e.id),children:e.installed?D(`pro.update`):D(`pro.install`)}):null,e.installed?(0,H.jsx)(d,{variant:`secondary`,busy:s.isPending&&s.variables===e.id,disabled:u,onClick:()=>s.mutate(e.id),children:D(`pro.remove`)}):null]})]},e.id))}):(0,H.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:D(`pro.none`,{runtime:c.runtime})}),p?(0,H.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:p.message}):null]}):(0,H.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:D(`pro.notLinked`)}):(0,H.jsx)(l,{})}):null}function Ct({connector:e}){let[t,n]=(0,V.useState)(!1);return(0,H.jsxs)(`div`,{className:`rounded-lg bg-paper ring-1 ring-border-soft`,children:[(0,H.jsxs)(`button`,{type:`button`,onClick:()=>n(e=>!e),className:`flex w-full items-center gap-3 px-3 py-2 text-left`,children:[(0,H.jsx)(`span`,{className:r(`size-2 shrink-0 rounded-full`,e.usable?`bg-moss`:`bg-ink-4`)}),(0,H.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-[0.8125rem]`,children:[e.name,` `,(0,H.jsx)(`span`,{className:`font-mono text-[0.6875rem] text-ink-4`,children:e.id})]}),(0,H.jsx)(`span`,{className:`shrink-0 text-[0.75rem] text-ink-3`,children:e.usable?D(`connectors.actions`,{n:e.actions.length,r:e.actions.filter(e=>e.group===`read`).length}):D(`connectors.notSetUp`)})]}),t?(0,H.jsxs)(`div`,{className:`border-border-soft border-t px-3 py-2 text-[0.75rem]`,children:[e.missingSetup?(0,H.jsxs)(`p`,{className:`mb-1 text-ink-3`,children:[D(`connectors.setup`),` `,(0,H.jsx)(`span`,{className:`font-mono text-ink-2`,children:e.missingSetup})]}):null,(0,H.jsx)(`p`,{className:`text-ink-4`,children:e.actions.map(e=>e.group===`read`?e.id:`${e.id} (${D(`connectors.group.${e.group}`)})`).join(` · `)})]}):null]})}var wt={none:`connectors.authNone`,oauth2:`connectors.authOauth`,api_key:`connectors.authKey`};function Tt({projectId:e,connector:t,readOnly:n}){let i=f(),[a,s]=(0,V.useState)(!1),c=()=>i.invalidateQueries({queryKey:[`connectors`,e]}),u=`/api/studio/projects/${e}/connectors/${t.id}`,d=M({mutationFn:()=>x.post(`${u}/refresh`),onSuccess:c}),p=M({mutationFn:()=>x.del(u),onSuccess:c}),m=t.actions.filter(e=>e.group===`read`).length;return(0,H.jsxs)(`div`,{className:`rounded-lg bg-paper ring-1 ring-border-soft`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-3 p-3`,children:[(0,H.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-paper-2 text-ink-2`,children:(0,H.jsx)(fe,{className:`size-4`})}),(0,H.jsxs)(`button`,{type:`button`,onClick:()=>s(e=>!e),className:`min-w-0 flex-1 text-left`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`truncate font-medium text-[0.875rem]`,children:t.name}),(0,H.jsx)(`span`,{className:`font-mono text-[0.6875rem] text-ink-4`,children:t.id})]}),(0,H.jsxs)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:[t.domain,` · `,t.sourceKind===`mcp`?`MCP`:`OpenAPI`,` ·`,` `,D(wt[t.auth]),` ·`,` `,t.toolsPending?D(`connectors.pending`):D(`connectors.actions`,{n:t.actions.length,r:m})]})]}),n?null:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(o,{label:D(`connectors.refresh`),onClick:()=>d.mutate(),children:d.isPending?(0,H.jsx)(l,{className:`size-4`}):(0,H.jsx)(te,{className:`size-4`})}),(0,H.jsx)(o,{label:D(`connectors.remove`),className:`hover:text-rose`,onClick:()=>confirm(D(`connectors.removeConfirm`,{name:t.name}))&&p.mutate(),children:(0,H.jsx)(E,{className:`size-4`})})]})]}),t.needsOAuthClient?(0,H.jsx)(`p`,{className:`border-border-soft border-t px-3 py-2 text-[0.75rem] text-rose`,children:D(`connectors.needsClient`)}):null,d.error??p.error?(0,H.jsx)(`p`,{className:`border-border-soft border-t px-3 py-2 text-[0.75rem] text-rose`,children:(d.error??p.error).message}):null,a&&t.actions.length?(0,H.jsx)(`ul`,{className:`max-h-64 overflow-y-auto border-border-soft border-t px-3 py-2`,children:t.actions.map(e=>(0,H.jsxs)(`li`,{className:`flex items-baseline gap-2 py-1 text-[0.75rem]`,children:[(0,H.jsx)(`span`,{className:r(`w-14 shrink-0 text-[0.6875rem] uppercase tracking-wide`,e.group===`read`?`text-moss`:e.group===`write`?`text-ink-3`:`text-rose`),children:D(`connectors.group.${e.group}`)}),(0,H.jsx)(`span`,{className:`shrink-0 font-mono text-ink-2`,children:e.id}),(0,H.jsx)(`span`,{className:`min-w-0 truncate text-ink-4`,children:e.summary})]},e.id))}):null]})}function Et({projectId:e,domain:t,source:n,taken:r,onDone:i}){let a=f(),[o,s]=(0,V.useState)({id:``,secret:``}),[c,l]=(0,V.useState)(!1),u=r.includes(n.suggestedId),p=M({mutationFn:()=>x.post(`/api/studio/projects/${e}/connectors`,{domain:t,sourceKind:n.sourceKind,sourceUrl:n.sourceUrl,id:n.suggestedId,toolPrefix:n.suggestedToolPrefix,...n.name?{name:n.name}:{},...o.id&&o.secret?{oauthClientId:o.id,oauthClientSecret:o.secret}:{}}),onSuccess:async t=>{await a.invalidateQueries({queryKey:[`connectors`,e]}),i(t.warnings)}});return(0,H.jsxs)(`div`,{className:`rounded-lg bg-card p-3 ring-1 ring-border-soft`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,H.jsx)(j,{tone:n.sourceKind===`mcp`?`ember`:`neutral`,children:n.sourceKind===`mcp`?`MCP`:`OpenAPI`}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`div`,{className:`truncate text-[0.8125rem]`,children:n.name??n.suggestedId}),(0,H.jsx)(`div`,{className:`truncate font-mono text-[0.6875rem] text-ink-4`,children:n.sourceUrl})]}),n.blocked||u?null:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`button`,{type:`button`,onClick:()=>l(e=>!e),className:`text-[0.75rem] text-ink-3 hover:text-ink`,children:D(`connectors.ownClient`)}),(0,H.jsx)(d,{size:`sm`,busy:p.isPending,onClick:()=>p.mutate(),children:D(`connectors.import`)})]})]}),n.blocked?(0,H.jsx)(`p`,{className:`mt-2 text-[0.75rem] text-ink-3`,children:n.blocked}):null,u?(0,H.jsx)(`p`,{className:`mt-2 text-[0.75rem] text-ink-3`,children:D(`connectors.exists`)}):null,c?(0,H.jsxs)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2`,children:[(0,H.jsx)(y,{placeholder:D(`connectors.clientId`),value:o.id,onChange:e=>s(t=>({...t,id:e.target.value}))}),(0,H.jsx)(y,{type:`password`,autoComplete:`off`,placeholder:D(`connectors.clientSecret`),value:o.secret,onChange:e=>s(t=>({...t,secret:e.target.value}))})]}):null,p.error?(0,H.jsx)(`p`,{className:`mt-2 text-[0.75rem] text-rose`,children:p.error.message}):null]})}function Dt({projectId:e,readOnly:t}){let n=He(`unsetConnectors`),[r,i]=(0,V.useState)(``),[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(null),[u,f]=(0,V.useState)([]),p=O({queryKey:[`connectors`,e],queryFn:()=>x.get(`/api/studio/projects/${e}/connectors`)}),g=M({mutationFn:()=>x.post(`/api/studio/connectors/search`,{query:r}),onSuccess:e=>{o(e),c(null),f([])}}),_=M({mutationFn:e=>x.get(`/api/studio/connectors/registry/${encodeURIComponent(e)}`),onSuccess:c}),v=p.data??[],b=v.filter(e=>e.sourceKind===`builtin`&&(n||e.usable)),S=v.filter(e=>e.sourceKind!==`builtin`);return(0,H.jsxs)(h,{className:`p-4 sm:p-6`,children:[(0,H.jsx)(`h2`,{className:`font-display font-semibold text-lg`,children:D(`connectors.title`)}),(0,H.jsx)(`p`,{className:`mt-1 mb-5 text-[0.875rem] text-ink-3`,children:D(`connectors.hint`)}),b.length?(0,H.jsx)(`div`,{className:`mb-5 grid gap-1.5 sm:grid-cols-2`,children:b.map(e=>(0,H.jsx)(Ct,{connector:e},e.id))}):null,(0,H.jsx)(`h3`,{className:`mb-2 font-medium text-[0.75rem] text-ink-3 uppercase tracking-[0.07em]`,children:D(`connectors.imported`)}),S.length?(0,H.jsx)(`div`,{className:`mb-4 flex flex-col gap-2`,children:S.map(n=>(0,H.jsx)(Tt,{projectId:e,connector:n,readOnly:t},n.id))}):null,t?S.length?null:(0,H.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:D(`connectors.noneImported`)}):(0,H.jsxs)(`form`,{className:`flex gap-2`,onSubmit:e=>{e.preventDefault(),r.trim()&&g.mutate()},children:[(0,H.jsx)(y,{value:r,placeholder:D(`connectors.search`),onChange:e=>i(e.target.value)}),(0,H.jsxs)(d,{type:`submit`,variant:`secondary`,busy:g.isPending,children:[(0,H.jsx)(re,{className:`size-4`}),` `,D(`connectors.find`)]})]}),g.error?(0,H.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-rose`,children:g.error.message}):null,a&&!s?(0,H.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1`,children:[a.length?null:(0,H.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:D(`connectors.none`)}),a.map(e=>(0,H.jsxs)(`button`,{type:`button`,disabled:!e.kinds.length,onClick:()=>_.mutate(e.domain),className:`flex items-center gap-3 rounded-lg px-3 py-2 text-left transition hover:bg-paper-2 disabled:opacity-50`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`div`,{className:`truncate text-[0.875rem]`,children:e.domain}),(0,H.jsx)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:e.description})]}),(0,H.jsx)(`span`,{className:`text-[0.6875rem] text-ink-4 uppercase`,children:e.kinds.join(` · `)}),(0,H.jsx)(m,{className:`-rotate-90 size-4 text-ink-4`})]},e.domain)),_.isPending?(0,H.jsx)(l,{className:`mx-auto mt-2 size-4 text-ink-4`}):null,_.error?(0,H.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:_.error.message}):null]}):null,s?(0,H.jsxs)(`div`,{className:`mt-4 flex flex-col gap-2`,children:[(0,H.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,H.jsx)(`div`,{className:`font-medium text-[0.875rem]`,children:s.domain}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>c(null),className:`text-[0.75rem] text-ink-3 hover:text-ink`,children:D(`run.back`)})]}),s.summary?(0,H.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:s.summary}):null,s.sources.map(t=>(0,H.jsx)(Et,{projectId:e,domain:s.domain,source:t,taken:v.map(e=>e.id),onDone:f},`${t.sourceKind}:${t.sourceUrl}`)),s.credentials.filter(e=>e.setup||e.url).map(e=>(0,H.jsxs)(`p`,{className:`text-[0.75rem] text-ink-3`,children:[(0,H.jsxs)(`span`,{className:`text-ink-2`,children:[e.label,`:`]}),` `,e.setup,` `,e.url?(0,H.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`text-ember underline`,children:e.url}):null]},e.label)),u.map(e=>(0,H.jsx)(`p`,{className:`text-[0.75rem] text-ink-3`,children:e},e))]}):null]})}var Ot=e=>new URL(e).host.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``),U=`engenty-wizards`,kt=`wizards`,At=`engenty wizards`,jt=`ENGENTY_WIZARDS_KEY`,Mt=[{id:`claude-desktop`,name:`Claude Desktop`,widgets:!0,connector:!0},{id:`claude-code`,name:`Claude Code`,widgets:!1},{id:`codex`,name:`Codex · ChatGPT app`,widgets:!1},{id:`cursor`,name:`Cursor`,widgets:!0},{id:`vscode`,name:`VS Code (Copilot)`,widgets:!0},{id:`windsurf`,name:`Windsurf`,widgets:!1},{id:`antigravity`,name:`Antigravity`,widgets:!1},{id:`goose`,name:`Goose`,widgets:!0},{id:`openclaw`,name:`OpenClaw`,widgets:!1},{id:`lm-studio`,name:`LM Studio`,widgets:!1},{id:`claude-ai`,name:`claude.ai`,widgets:!0,oauth:!0},{id:`chatgpt`,name:`ChatGPT`,widgets:!0,oauth:!0}],Nt={"claude-ai":{open:`https://claude.ai/settings/connectors`,where:`integrate.claudeAiWhere`,host:`claude.ai`},"claude-desktop":{where:`integrate.desktopWhere`,host:`claude.ai`},chatgpt:{where:`integrate.chatgptWhere`,host:`chatgpt.com`}};function W({text:e,muted:t}){let[n,i]=(0,V.useState)(!1);return(0,H.jsxs)(`div`,{className:r(`flex items-start gap-2 rounded-lg bg-paper-2 p-3`,t&&`text-ink-3 opacity-80`),children:[(0,H.jsx)(`code`,{className:`min-w-0 flex-1 whitespace-pre-wrap break-all font-mono text-[0.75rem] leading-relaxed`,children:e}),(0,H.jsx)(o,{label:D(n?`settings.copied`:`settings.copy`),onClick:async()=>{await navigator.clipboard.writeText(e),i(!0),setTimeout(()=>i(!1),1500)},children:n?(0,H.jsx)(A,{className:`size-4`}):(0,H.jsx)(p,{className:`size-4`})})]})}function Pt(e){try{let t=new URL(e);return t.protocol===`https:`&&!/(^|\.)localhost$/.test(t.hostname)&&!/^(127\.|10\.|192\.168\.|\[::1\])/.test(t.hostname)}catch{return!1}}function G({children:e}){return(0,H.jsx)(`p`,{className:`text-[0.875rem] text-ink-3 leading-relaxed`,children:e})}function Ft({title:e,children:t}){return(0,H.jsxs)(`section`,{className:`flex flex-col gap-2.5 border-border-soft border-t pt-5 first:border-t-0 first:pt-0`,children:[(0,H.jsx)(`h3`,{className:`font-medium text-[0.9375rem]`,children:e}),t]})}var It=`https://github.com/engenty/engenty-wizards-wp-plugin/releases/latest/download/engenty-wizards.zip`;function Lt({managed:e}){return(0,H.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h2`,{className:`font-display font-semibold text-[1.375rem] leading-tight tracking-tight`,children:`WordPress`}),(0,H.jsx)(`p`,{className:`mt-1 text-[0.9375rem] text-ink-2`,children:D(`integrate.wpIntro`)})]}),(0,H.jsxs)(h,{className:`flex flex-col gap-5 p-5`,children:[(0,H.jsxs)(Ft,{title:D(`integrate.wpInstall`),children:[(0,H.jsx)(G,{children:D(`integrate.wpInstallHint`)}),(0,H.jsx)(`div`,{children:(0,H.jsx)(d,{variant:`secondary`,size:`sm`,onClick:()=>window.open(It,`_blank`),children:D(`integrate.wpDownload`)})})]}),(0,H.jsx)(Ft,{title:D(`integrate.wpConnect`),children:(0,H.jsx)(G,{children:D(e?`integrate.wpConnectHint`:`integrate.wpConnectLocal`)})}),(0,H.jsxs)(Ft,{title:D(`integrate.wpPlace`),children:[(0,H.jsx)(G,{children:D(`integrate.wpPlaceHint`)}),(0,H.jsx)(W,{text:`[engenty_wizard id="ID" mode="modal" label="${D(`integrate.wpSampleLabel`)}"]`})]}),(0,H.jsx)(Ft,{title:D(`integrate.wpPro`),children:(0,H.jsx)(G,{children:D(`integrate.wpProHint`)})}),(0,H.jsx)(Ft,{title:D(`integrate.wpLocal`),children:(0,H.jsx)(G,{children:D(`integrate.wpLocalHint`)})})]})]})}function Rt(e,t){return JSON.stringify({[e]:{[U]:t}},null,2)}function zt({id:e,url:t,apiKey:n}){let r=n?`Authorization: Bearer ${n}`:null,i=n?{headers:{Authorization:`Bearer ${n}`}}:{};switch(e){case`claude-code`:{let e=t.replace(/\/api\/mcp$/,`/api/claude-plugin`);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(G,{children:D(`mcp.terminal`)}),(0,H.jsx)(W,{text:`claude mcp add --transport http --scope user ${U} ${t}${r?` --header "${r}"`:``}`}),!n&&Pt(t)?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(G,{children:D(`mcp.ccPlugin`)}),(0,H.jsx)(W,{text:`claude plugin marketplace add ${e}/marketplace.json`}),(0,H.jsx)(W,{text:`claude plugin install ${kt}@${Ot(t)}`})]}):null]})}case`codex`:return n?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(G,{children:D(`mcp.codexKey`)}),(0,H.jsx)(W,{text:`echo 'export ${jt}=${n}' >> ~/.zshrc && source ~/.zshrc`}),(0,H.jsx)(W,{text:`codex mcp add ${U} --url ${t} --bearer-token-env-var ${jt}`})]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(G,{children:D(`mcp.terminal`)}),(0,H.jsx)(W,{text:`codex mcp add ${U} --url ${t}`}),(0,H.jsx)(W,{text:`codex mcp login ${U}`})]});case`antigravity`:return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(G,{children:D(`mcp.terminal`)}),(0,H.jsx)(W,{text:`agy mcp add${r?` -H "${r}"`:``} ${U} ${t}`})]});case`cursor`:return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(G,{children:D(`integrate.file`,{file:`~/.cursor/mcp.json`})}),(0,H.jsx)(W,{text:Rt(`mcpServers`,{url:t,...i})})]});case`vscode`:return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(G,{children:D(`integrate.vscode`)}),(0,H.jsx)(W,{text:Rt(`servers`,{type:`http`,url:t,...i})})]});case`windsurf`:return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(G,{children:D(`integrate.file`,{file:`~/.codeium/windsurf/mcp_config.json`})}),(0,H.jsx)(W,{text:Rt(`mcpServers`,{serverUrl:t,...i})})]});case`lm-studio`:return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(G,{children:D(`integrate.file`,{file:`~/.lmstudio/mcp.json`})}),(0,H.jsx)(W,{text:Rt(`mcpServers`,{url:t,...i})})]});case`claude-desktop`:case`claude-ai`:return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(G,{children:D(`mcp.claudeAi`)}),(0,H.jsx)(W,{text:t})]});case`chatgpt`:return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(G,{children:D(`integrate.chatgpt`)}),(0,H.jsx)(W,{text:t})]});default:return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(G,{children:D(`integrate.generic`)}),(0,H.jsx)(W,{text:t}),r?(0,H.jsx)(W,{text:r}):null]})}}function Bt(){let e=f(),t=O({queryKey:[`api-keys`],queryFn:()=>x.get(`/api/studio/api-keys`)}),n=M({mutationFn:e=>x.del(`/api/studio/api-keys/${e}`),onSuccess:()=>e.invalidateQueries({queryKey:[`api-keys`]})});return t.data?.length?(0,H.jsxs)(`section`,{children:[(0,H.jsx)(`h2`,{className:`font-display font-semibold text-lg`,children:D(`mcp.keys`)}),(0,H.jsx)(`p`,{className:`mt-1 mb-4 text-[0.875rem] text-ink-3`,children:D(`mcp.keysHint`)}),(0,H.jsx)(h,{className:`flex flex-col gap-2 p-3`,children:t.data.map(e=>(0,H.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg px-3 py-2`,children:[(0,H.jsx)(B,{className:`size-4 shrink-0 text-ink-4`}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`div`,{className:`truncate text-[0.875rem]`,children:e.name}),(0,H.jsxs)(`div`,{className:`font-mono text-[0.6875rem] text-ink-4`,children:[e.start,`… ·`,` `,e.lastRequest?D(`settings.lastUsed`,{when:new Date(e.lastRequest).toLocaleString(k)}):D(`settings.neverUsed`)]})]}),(0,H.jsx)(o,{label:D(`settings.revoke`),onClick:()=>n.mutate(e.id),className:`hover:text-rose`,children:(0,H.jsx)(E,{className:`size-4`})})]},e.id))})]}):null}function Vt(e,t){return t?.toolAt?`works`:e?.connected||t?`added`:`none`}var Ht={works:`done`,added:`on`,none:void 0},Ut={works:`integrate.stateWorks`,added:`integrate.stateAdded`,none:`integrate.stateNone`};function Wt({standing:e}){return e===`none`?(0,H.jsx)(`span`,{className:`w-2 text-center text-ink-4 leading-none`,children:`–`}):(0,H.jsx)(`span`,{className:r(`size-2 shrink-0 rounded-full`,e===`works`?`bg-moss`:`bg-ember`)})}function Gt(){return(0,H.jsx)(`div`,{className:`mt-5 flex flex-col gap-1.5 rounded-lg bg-paper-2 px-3 py-2.5 text-[0.75rem] text-ink-3`,children:[`works`,`added`,`none`].map(e=>(0,H.jsxs)(`span`,{className:`flex items-center gap-2.5`,children:[(0,H.jsx)(Wt,{standing:e}),D(Ut[e])]},e))})}function Kt({client:e,signIn:t}){let n=(e,t)=>(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full bg-card px-2.5 py-1 text-[0.8125rem] text-ink-2 ring-1 ring-border-soft`,children:[e,t]}),r=(0,H.jsx)(A,{className:`size-3.5 text-moss`,strokeWidth:3});return(0,H.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[n(r,D(`integrate.outRun`)),e.widgets?n(r,D(`integrate.outWidget`)):n((0,H.jsx)(we,{className:`size-3.5 text-ink-3`}),D(`integrate.outText`)),t?n((0,H.jsx)(he,{className:`size-3.5 text-ink-3`}),D(`integrate.outSignIn`)):null]})}function K({client:e,works:t,children:n}){return(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,H.jsx)(`h2`,{className:`font-display font-semibold text-[1.375rem] leading-tight tracking-tight`,children:e.name}),t?(0,H.jsx)(j,{tone:`live`,icon:(0,H.jsx)(A,{className:`size-3.5`,strokeWidth:3}),children:D(`integrate.works`)}):null]}),n]})}function q({n:e,state:t,title:n,children:i}){return(0,H.jsxs)(`li`,{"aria-current":t===`now`?`step`:void 0,className:r(`grid grid-cols-[28px_minmax(0,1fr)] gap-x-3.5 rounded-xl px-3 py-3`,t===`now`&&`bg-ember-tint/40 ring-1 ring-ember-strong/25`),children:[(0,H.jsx)(`span`,{className:r(`grid size-7 place-items-center rounded-full font-semibold text-[0.8125rem]`,t===`done`&&`bg-moss text-white`,(t===`now`||t===`todo`)&&`bg-primary text-primary-foreground`,t===`later`&&`bg-paper text-ink-3 ring-1 ring-border`),children:t===`done`?(0,H.jsx)(A,{className:`size-3.5`,strokeWidth:3}):e}),(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 pt-1`,children:[(0,H.jsx)(`span`,{className:r(`font-medium text-[0.9375rem]`,t===`later`&&`text-ink-2`),children:n}),i?(0,H.jsx)(`div`,{className:r(`flex flex-col gap-2`,t===`later`&&`opacity-70`),children:i}):null]})]})}function qt({children:e}){return(0,H.jsxs)(h,{className:`p-3 sm:p-4`,children:[(0,H.jsx)(`h3`,{className:`px-3 pt-2 pb-2 font-medium text-[0.9375rem]`,children:D(`integrate.steps`)}),(0,H.jsx)(`ol`,{className:`flex flex-col gap-1`,children:e})]})}function Jt({app:e}){return(0,H.jsxs)(`p`,{className:`flex items-center gap-2 text-[0.8125rem] text-ember-strong`,children:[(0,H.jsx)(`span`,{className:`size-2 rounded-full bg-ember`}),D(`integrate.waiting`,{app:e})]})}function Yt({client:e,seen:t}){let n=(e,t)=>(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[e?(0,H.jsx)(A,{className:`size-3.5 text-moss`,strokeWidth:3}):(0,H.jsx)(`span`,{className:`size-2.5 rounded-full ring-2 ring-ink-4 ring-inset`}),t]});return(0,H.jsxs)(`p`,{className:`flex flex-wrap gap-x-4 gap-y-1 text-[0.8125rem] text-ink-2`,children:[n(!!t,D(`integrate.checkSeen`)),n(!!t?.toolAt,D(`integrate.checkTool`)),e.widgets?n(!!t?.widgetAt,D(`integrate.checkWidget`)):null]})}function Xt(){let e=ye().data,{project:t}=ve(),n=O({queryKey:[`wizards`,t?.id,!!e?.account],queryFn:()=>x.get(`/api/studio/projects/${t.id}/wizards`),enabled:!!t}).data??[];return n.find(e=>e.published)??n[0]??null}function Zt({client:e,footer:t}){let n=Xt(),r=n?[{label:D(`integrate.labelRun`),text:D(`integrate.askRun`,{title:n.title})},{label:D(`integrate.labelBuild`),text:D(`integrate.askBuild`)},{label:D(`integrate.labelExplain`),text:D(`integrate.askExplain`,{title:n.title})}]:[{label:D(`integrate.labelAsk`),text:D(`integrate.askTool`)},{label:D(`integrate.labelBuild`),text:D(`integrate.askBuild`)}];return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(h,{className:`flex flex-col gap-4 p-5 sm:p-6`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h3`,{className:`font-medium text-[0.9375rem]`,children:D(`integrate.next`)}),(0,H.jsx)(G,{children:D(`integrate.nextHint`,{app:e.name})})]}),(0,H.jsx)(`ul`,{className:`flex flex-col gap-2`,children:r.map(e=>(0,H.jsxs)(`li`,{className:`grid items-start gap-1 sm:grid-cols-[5.5rem_minmax(0,1fr)] sm:gap-3`,children:[(0,H.jsx)(`span`,{className:`pt-3 text-[0.75rem] text-ink-3`,children:e.label}),(0,H.jsx)(W,{text:e.text})]},e.label))})]}),e.widgets?null:(0,H.jsxs)(`p`,{className:`flex items-start gap-3 rounded-xl bg-paper-2 px-4 py-3 text-[0.875rem] text-ink-2 leading-relaxed`,children:[(0,H.jsx)(we,{className:`mt-0.5 size-4 shrink-0 text-ink-3`}),D(`integrate.textOnly`,{app:e.name})]}),t]})}function Qt({children:e}){return(0,H.jsx)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1 text-[0.8125rem] text-ink-3`,children:e})}var J=`inline-flex items-center gap-1 text-ember-strong underline-offset-2 transition hover:underline`;function $t({client:e,local:t,seen:n,url:i}){let a=f(),[o,c]=(0,V.useState)(!1),[l,u]=(0,V.useState)(null),[p,m]=(0,V.useState)(!1),h=M({mutationFn:t=>x.post(`/api/studio/local/apps/${e.id}`,{connect:t}),onSuccess:e=>u(e),onError:e=>u({ok:!1,message:e.message}),onSettled:()=>a.invalidateQueries({queryKey:[`local-apps`]})}),g=!!t?.connected,_=!!n?.toolAt;if(o)return(0,H.jsx)(en,{client:e,seen:n,url:i,onBack:()=>c(!1)});let v=t=>(0,H.jsxs)(H.Fragment,{children:[t?(0,H.jsx)(`span`,{children:D(`integrate.addedIn`,{app:e.name})}):null,(0,H.jsxs)(`button`,{type:`button`,className:J,onClick:()=>m(!p),children:[D(`integrate.details`),(0,H.jsx)(s,{className:r(`size-3.5 transition`,p&&`rotate-90`)})]}),(0,H.jsx)(`button`,{type:`button`,className:J,disabled:h.isPending,onClick:()=>h.mutate(!1),children:D(`mcp.appsDisconnect`)})]}),y=p&&t?.where?(0,H.jsx)(`p`,{className:`w-full font-mono text-[0.6875rem] text-ink-4`,children:t.where}):null;return(0,H.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,H.jsx)(K,{client:e,works:_,children:(0,H.jsx)(Kt,{client:e})}),_?(0,H.jsx)(Zt,{client:e,footer:(0,H.jsxs)(Qt,{children:[v(!0),y]})}):(0,H.jsxs)(qt,{children:[(0,H.jsxs)(q,{n:1,state:g?`done`:`now`,title:D(g?`integrate.connected`:`integrate.connect`,{app:e.name}),children:[g?(0,H.jsxs)(Qt,{children:[v(!1),y]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(G,{children:t?.installed===!1?D(`integrate.notInstalled`,{app:e.name}):D(`integrate.connectHint`,{app:e.name})}),(0,H.jsx)(`div`,{children:(0,H.jsxs)(d,{busy:h.isPending,onClick:()=>h.mutate(!0),children:[(0,H.jsx)(w,{className:`size-4`}),` `,D(`integrate.connect`,{app:e.name})]})})]}),l&&!l.ok?(0,H.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:l.message}):null,l?.snippet?(0,H.jsx)(W,{text:l.snippet}):null]}),(0,H.jsx)(q,{n:2,state:n?`done`:g?`now`:`later`,title:D(`integrate.restart`,{app:e.name}),children:n?null:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(G,{children:D(`integrate.restartHint`)}),g?(0,H.jsx)(Jt,{app:e.name}):null]})}),(0,H.jsxs)(q,{n:3,state:n?`now`:`later`,title:D(`integrate.try`),children:[(0,H.jsx)(G,{children:D(`integrate.tryHint`)}),(0,H.jsx)(W,{text:D(`integrate.askTool`),muted:!n})]})]}),(0,H.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-[0.875rem] text-ink-2`,children:[(0,H.jsx)(pe,{className:`size-4 text-ink-3`}),D(`integrate.elsewhere`,{app:e.name}),(0,H.jsx)(`button`,{type:`button`,className:J,onClick:()=>c(!0),children:D(`integrate.byAddress`)})]})]})}function en({client:e,seen:t,url:n,onBack:r}){let i=f(),[a,o]=(0,V.useState)(),s=M({mutationFn:()=>x.post(`/api/studio/api-keys`,{name:e.name.slice(0,32)}),onSuccess:async e=>{o(e.key),await i.invalidateQueries({queryKey:[`api-keys`]})}}),c=(0,H.jsx)(`p`,{className:`text-[0.875rem]`,children:(0,H.jsxs)(`button`,{type:`button`,className:J,onClick:r,children:[(0,H.jsx)(Ge,{className:`size-4`}),D(`integrate.backHere`)]})});return t?.toolAt?(0,H.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,H.jsx)(K,{client:e,works:!0,children:(0,H.jsx)(Kt,{client:e})}),(0,H.jsx)(Zt,{client:e,footer:c})]}):(0,H.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,H.jsx)(K,{client:e,works:!1,children:(0,H.jsx)(Kt,{client:e})}),(0,H.jsxs)(qt,{children:[(0,H.jsx)(q,{n:1,state:a?`done`:`now`,title:a?D(`integrate.keyReady`):D(`integrate.keyCreate`,{app:e.name}),children:a?null:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(G,{children:D(`integrate.keyHint`,{app:e.name})}),(0,H.jsx)(`div`,{children:(0,H.jsxs)(d,{variant:`secondary`,busy:s.isPending,onClick:()=>s.mutate(),children:[(0,H.jsx)(B,{className:`size-4`}),` `,D(`integrate.keyCreate`,{app:e.name})]})})]})}),(0,H.jsx)(q,{n:2,state:a?t?`done`:`now`:`later`,title:D(`integrate.add`),children:a&&!t?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(zt,{id:e.id,url:n,apiKey:a}),(0,H.jsx)(`p`,{className:`text-[0.75rem] text-ink-4`,children:D(`integrate.addressLocal`)}),(0,H.jsx)(Jt,{app:e.name})]}):null}),(0,H.jsxs)(q,{n:3,state:t?`now`:`later`,title:D(`integrate.try`),children:[(0,H.jsx)(G,{children:D(`integrate.tryHint`)}),(0,H.jsx)(W,{text:D(`integrate.askTool`),muted:!t})]})]}),c]})}function tn({app:e,host:t}){return(0,H.jsxs)(`div`,{"aria-hidden":`true`,className:`flex w-56 shrink-0 flex-col items-center gap-2 rounded-xl bg-paper px-4 py-3.5 text-center ring-1 ring-border-soft`,children:[(0,H.jsx)(`span`,{className:`font-display font-semibold text-[0.8125rem] leading-snug`,children:D(`integrate.consentPreview`,{app:e})}),(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[0.6875rem] text-moss`,children:[(0,H.jsx)(he,{className:`size-3`}),t]}),(0,H.jsxs)(`span`,{className:`flex w-full gap-1.5`,children:[(0,H.jsx)(`span`,{className:`h-5 flex-1 rounded-full bg-card ring-1 ring-border`}),(0,H.jsx)(`span`,{className:`h-5 flex-1 rounded-full bg-primary`})]})]})}function nn({client:e,url:t,seen:n,tracked:r,accountUrl:a}){let o=Nt[e.id]??Nt[`claude-desktop`],s=e.id===`chatgpt`?`ChatGPT`:`Claude`;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(qt,{children:[(0,H.jsx)(q,{n:1,state:`todo`,title:D(`integrate.open`,{app:e.name}),children:o.open?(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,H.jsxs)(d,{onClick:()=>P(o.open),children:[D(`integrate.openConnectors`),(0,H.jsx)(i,{className:`size-4`})]}),(0,H.jsx)(G,{children:D(o.where)})]}):(0,H.jsx)(G,{children:D(o.where)})}),(0,H.jsx)(q,{n:2,state:`todo`,title:D(`integrate.nameAddress`),children:(0,H.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:D(`integrate.name`)}),(0,H.jsx)(W,{text:At})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:D(`integrate.address`)}),(0,H.jsx)(W,{text:t})]})]})}),(0,H.jsx)(q,{n:3,state:n?`done`:`todo`,title:D(`integrate.allow`),children:n?null:(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,H.jsx)(`p`,{className:`min-w-0 flex-[1_1_16rem] text-[0.875rem] text-ink-3 leading-relaxed`,children:D(`integrate.allowHint`)}),(0,H.jsx)(tn,{app:s,host:o.host})]})}),(0,H.jsxs)(q,{n:4,state:n?.toolAt?`done`:n?`now`:`later`,title:D(`integrate.try`),children:[n?.toolAt?null:(0,H.jsx)(W,{text:D(`integrate.askTool`),muted:!n}),r?(0,H.jsx)(Yt,{client:e,seen:n}):null]})]}),a?(0,H.jsx)(rn,{accountUrl:a}):null]})}function rn({accountUrl:e}){return(0,H.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 text-[0.8125rem] text-ink-3`,children:[D(`integrate.revoke`),(0,H.jsxs)(`button`,{type:`button`,className:J,onClick:()=>P(e),children:[D(`integrate.revokeLink`),(0,H.jsx)(v,{className:`size-3.5`})]})]})}function an({client:e,me:t,onDesktop:n}){let r=t.account?.signedIn?t.account:null,i=Xe(!!r),a=Be(t.features,`account`);return(0,H.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,H.jsx)(K,{client:e,works:!1,children:(0,H.jsx)(`p`,{className:`mt-2 max-w-2xl text-[0.9375rem] text-ink-2 leading-relaxed`,children:D(`integrate.remoteWhy`,{app:e.name})})}),r?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`p`,{className:`flex items-start gap-2 text-[0.875rem] text-ink-2`,children:[(0,H.jsx)(I,{className:`mt-0.5 size-4 shrink-0 text-ink-3`}),D(`integrate.linked`,{email:r.email,app:e.name})]}),(0,H.jsx)(nn,{client:e,url:`${r.cloudUrl}/api/mcp`,tracked:!1,accountUrl:r.url})]}):a?(0,H.jsxs)(h,{className:`flex flex-col gap-5 p-5 sm:p-6`,children:[(0,H.jsx)(`h3`,{className:`font-medium text-[0.9375rem]`,children:D(`integrate.viaAccount`)}),(0,H.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[{icon:Ge,title:D(`integrate.tileHere`),text:D(`integrate.tileHereText`)},{icon:I,title:`engenty.ai`,text:D(`integrate.tileCloudText`)},{icon:ze,title:e.name,text:D(`integrate.tileAppText`)}].map(e=>(0,H.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-xl bg-paper px-4 py-3.5`,children:[(0,H.jsxs)(`span`,{className:`flex items-center gap-2 font-medium`,children:[(0,H.jsx)(e.icon,{className:`size-4 text-ink-2`}),e.title]}),(0,H.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 leading-relaxed`,children:e.text})]},e.title))}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,H.jsxs)(d,{busy:i.link.isPending,onClick:()=>i.link.mutate({}),children:[(0,H.jsx)(I,{className:`size-4`}),` `,D(`integrate.linkAccount`)]}),(0,H.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3`,children:D(`integrate.linkHint`,{app:e.name})})]}),(0,H.jsx)(Ee,{...i})]}):null,r?null:(0,H.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 rounded-xl bg-paper-2 px-4 py-3 text-[0.875rem] text-ink-2`,children:[D(`integrate.noAccount`),(0,H.jsxs)(`button`,{type:`button`,className:J,onClick:n,children:[D(`integrate.useDesktop`),(0,H.jsx)(v,{className:`size-3.5`})]})]})]})}function on({client:e,seen:t,url:n,me:r}){let i=!!t?.toolAt,a=r.manageUrl?`${r.manageUrl}/account`:null;return(0,H.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,H.jsx)(K,{client:e,works:i,children:(0,H.jsx)(Kt,{client:e,signIn:!0})}),i?(0,H.jsx)(Zt,{client:e}):(0,H.jsxs)(qt,{children:[(0,H.jsx)(q,{n:1,state:t?`done`:`now`,title:D(`integrate.add`),children:t?null:(0,H.jsx)(zt,{id:e.id,url:n})}),(0,H.jsx)(q,{n:2,state:t?`done`:`later`,title:D(`integrate.allowFirst`),children:t?null:(0,H.jsx)(G,{children:D(`integrate.allowFirstHint`,{app:e.name})})}),(0,H.jsx)(q,{n:3,state:t?`now`:`later`,title:D(`integrate.try`),children:(0,H.jsx)(W,{text:D(`integrate.askTool`),muted:!t})})]}),a?(0,H.jsx)(rn,{accountUrl:a}):null]})}function sn({client:e,standing:t,onOpen:n,onConnect:i,busy:a}){return(0,H.jsxs)(h,{className:`flex flex-col gap-3 p-4`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,H.jsx)(`span`,{className:`grid size-10 shrink-0 place-items-center rounded-[10px] bg-paper-2 text-ink-2`,children:e.widgets?(0,H.jsx)(ue,{className:`size-5`}):(0,H.jsx)(_e,{className:`size-5`})}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`div`,{className:`truncate font-medium`,children:e.name}),(0,H.jsxs)(`div`,{className:r(`flex items-center gap-1.5 text-[0.8125rem]`,t===`works`&&`font-medium text-moss`,t===`added`&&`text-ember-strong`,t===`none`&&`text-ink-3`),children:[t===`works`?(0,H.jsx)(A,{className:`size-3.5`,strokeWidth:3}):null,D(Ut[t])]})]})]}),(0,H.jsxs)(`p`,{className:`flex items-center gap-1.5 text-[0.75rem] text-ink-3`,children:[e.widgets?(0,H.jsx)(ue,{className:`size-3.5`}):(0,H.jsx)(we,{className:`size-3.5`}),D(e.widgets?`integrate.outWidget`:`integrate.outText`)]}),(0,H.jsx)(`div`,{children:t===`none`&&i?(0,H.jsx)(d,{size:`sm`,variant:`secondary`,busy:a,onClick:i,children:D(`integrate.connectShort`)}):(0,H.jsx)(d,{size:`sm`,variant:t===`added`?`primary`:`secondary`,onClick:n,children:D(t===`works`?`integrate.view`:t===`added`?`integrate.testIt`:`integrate.connectShort`)})})]})}function cn({managed:e,here:t,web:n,standing:r,open:i}){let a=f(),o=M({mutationFn:e=>x.post(`/api/studio/local/apps/${e}`,{connect:!0}),onSettled:()=>a.invalidateQueries({queryKey:[`local-apps`]}),onSuccess:(e,t)=>i(t)}),s=(e,t)=>(0,H.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-[repeat(auto-fill,minmax(15rem,1fr))]`,children:e.map(e=>(0,H.jsx)(sn,{client:e,standing:r(e.id),onOpen:()=>i(e.id),onConnect:t?()=>o.mutate(e.id):void 0,busy:o.isPending&&o.variables===e.id},e.id))});return(0,H.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h2`,{className:`font-display font-semibold text-[1.625rem] leading-tight tracking-tight`,children:D(`integrate.title`)}),(0,H.jsx)(`p`,{className:`mt-2 max-w-2xl text-[0.9375rem] text-ink-2 leading-relaxed`,children:D(e?`integrate.introManaged`:`integrate.intro`)})]}),e?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,H.jsx)(`h3`,{className:`font-display font-semibold text-lg`,children:D(`integrate.groupBrowser`)}),s(n,!1)]}),(0,H.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,H.jsx)(`h3`,{className:`font-display font-semibold text-lg`,children:D(`integrate.groupDesktop`)}),s(t,!1)]})]}):(0,H.jsxs)(H.Fragment,{children:[t.length?(0,H.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,H.jsx)(`h3`,{className:`font-display font-semibold text-lg`,children:D(`integrate.found`)}),s(t,!0)]}):null,(0,H.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,H.jsx)(`h3`,{className:`font-display font-semibold text-lg`,children:D(`integrate.groupCloud`)}),(0,H.jsxs)(h,{className:`flex flex-wrap items-center gap-4 p-5`,children:[(0,H.jsx)(`span`,{className:`grid size-10 shrink-0 place-items-center rounded-[10px] bg-paper-2 text-ink-2`,children:(0,H.jsx)(I,{className:`size-5`})}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-[1_1_18rem]`,children:[(0,H.jsx)(`div`,{className:`font-medium`,children:D(`integrate.cloudTitle`)}),(0,H.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3 leading-relaxed`,children:D(`integrate.cloudText`)})]}),(0,H.jsx)(d,{variant:`secondary`,onClick:()=>i(`claude-ai`),children:D(`integrate.cloudButton`)})]})]})]})]})}function ln(){let e=ye(),t=e.data?.mode===`managed`,n=O({queryKey:[`local-apps`],queryFn:()=>x.get(`/api/studio/local/apps`),enabled:e.data?.mode===`local`}),r=O({queryKey:[`integrations-seen`],queryFn:()=>x.get(`/api/studio/integrations/seen`),refetchInterval:2500}),[i,a]=ne(),{narrow:o}=et(),s=Be(e.data?.features,`wordpress`),c=s||i.get(`show`)!==`wordpress`?i.get(`show`):null,l=Mt.find(e=>e.id===c)??null;if(nt(c===`wordpress`?`WordPress`:l?.name??null),!e.data||!t&&!n.data)return null;let u=e=>n.data?.find(t=>t.id===e),d=e=>r.data?.[e],f=e=>Vt(u(e),d(e)),p=e=>a({show:e},{replace:!o}),m=e=>!!(u(e.id)?.installed||u(e.id)?.connected),h=Mt.filter(e=>e.oauth),g=Mt.filter(e=>!e.oauth&&(t||m(e))),v=t?[]:Mt.filter(e=>!e.oauth&&!m(e)),y=e.data.mcpUrl??``,b=e=>(0,H.jsx)(R,{icon:e.oauth?I:e.widgets?ue:_e,label:e.name,tone:Ht[f(e.id)],toneLabel:D(Ut[f(e.id)]),selected:e.id===l?.id,onPick:()=>p(e.id)},e.id),S=e.data.manageUrl?`${e.data.manageUrl}/account`:null,C;return C=c===`wordpress`?(0,H.jsx)(Lt,{managed:t}):l?t&&(l.oauth||l.connector)?Pt(y)?(0,H.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,H.jsx)(K,{client:l,works:!!d(l.id)?.toolAt,children:(0,H.jsx)(Kt,{client:l,signIn:!0})}),d(l.id)?.toolAt?(0,H.jsx)(Zt,{client:l,footer:S?(0,H.jsx)(rn,{accountUrl:S}):null}):(0,H.jsx)(nn,{client:l,url:y,seen:d(l.id),tracked:!0,accountUrl:S})]}):(0,H.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,H.jsx)(K,{client:l,works:!1}),(0,H.jsx)(G,{children:D(`integrate.needsPublic`,{app:l.name})})]}):t?(0,H.jsx)(on,{client:l,seen:d(l.id),url:y,me:e.data}):l.oauth?(0,H.jsx)(an,{client:l,me:e.data,onDesktop:()=>p(`claude-desktop`)}):(0,H.jsx)($t,{client:l,local:u(l.id),seen:d(l.id),url:y}):(0,H.jsx)(cn,{managed:t,here:g,web:h,standing:f,open:p}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-10`,children:[(0,H.jsxs)(ot,{children:[(0,H.jsx)(z,{label:D(t?`integrate.groupBrowser`:`integrate.groupHere`),children:(t?h:g).map(b)}),(0,H.jsx)(z,{label:D(t?`integrate.groupDesktop`:`integrate.groupCloud`),children:(t?g:h).map(b)}),v.length?(0,H.jsx)(z,{label:D(`integrate.groupMore`),collapsible:!0,open:v.some(e=>e.id===l?.id),count:v.length,children:v.map(b)}):null,(0,H.jsxs)(z,{label:D(`integrate.groupShare`),children:[(0,H.jsx)(R,{icon:_,label:D(`integrate.shareLink`),badge:(0,H.jsx)(`span`,{className:`text-[0.6875rem] text-ink-4`,children:D(`integrate.soon`)}),selected:!1,disabled:!0}),s?(0,H.jsx)(R,{icon:pe,label:`WordPress`,selected:c===`wordpress`,onPick:()=>p(`wordpress`)}):null,(0,H.jsx)(R,{icon:pe,label:D(`integrate.shareSite`),badge:(0,H.jsx)(`span`,{className:`text-[0.6875rem] text-ink-4`,children:D(`integrate.soon`)}),selected:!1,disabled:!0})]}),(0,H.jsx)(Gt,{})]}),(0,H.jsx)(`div`,{children:C},l?.id??`start`),t||c===`wordpress`?null:(0,H.jsx)(Bt,{})]})}function un(e,t){let n=t===`auto`?e.mode===`managed`:t===`cloud`,r=t===`auto`||t===`linked`?e.account??(t===`linked`?{name:e.user.name,email:e.user.email,team:null,credits:1250,expiring:[],url:``,cloudUrl:``,signedIn:!0}:null):null;return{cloud:n,account:n?null:r,credits:n||!!r?.signedIn,balance:n?e.credits??(t===`cloud`?1250:null):r?.credits??null,topUp:Re(e),harnesses:n?[]:e.harnesses,canEdit:!n||e.tenant.role!==`member`,ownKeys:!n||Be(e.features,`ownKeys`)}}var dn={text:T,image:le,video:ce,speech:me,listening:dt},Y={text:`standard`,image:`image`,video:`video`,speech:`speech`,listening:`audio`},X=e=>e===`text`;function fn(e,t){return JSON.stringify(e)===JSON.stringify(t)}function pn(e,t,n){let r=Y[t];if(X(t)&&!n.cloud){if(e.bindings.standard?.startsWith(`apple:`))return{kind:`local`,by:`apple`};if(e.source===`account`)return{kind:`credits`};if(e.source!==`own`)return{kind:`client`,id:e.source}}let i=e.bindings[r];if(Fe(i))return{kind:`credits`};if(i?.startsWith(`ollama:`))return{kind:`local`,by:`ollama`};if(i?.startsWith(`apple:`))return{kind:`local`,by:`apple`};let a=i?Le(i):null;if(a)return{kind:`key`,provider:a};if(i&&/^(claude|codex|antigravity|cursor)\//.test(i))return{kind:`client`,id:i.split(`/`)[0]};let o=e.ways[r];switch(o.kind){case`client`:return{kind:`client`,id:o.by};case`key`:return F(o.by??``)?{kind:`key`,provider:o.by}:null;case`local`:return{kind:`local`,by:o.by===`apple`?`apple`:`ollama`};case`credits`:return{kind:`credits`};default:return null}}function mn(e,t,n){if(X(t)&&e.text)return e.text;let r=Y[t],i=n.bindings[r],a=i&&Le(i)===e.id?i:e.models[t]?.[0]?.ref;return a?{[r]:a}:{}}function hn(e){return e.version===null?{note:D(`models.noteMissing`),noteTone:`warn`}:e.auth===`none`?{note:D(`models.noteSignedOut`),noteTone:`warn`}:e.auth===`api_key`?{note:D(`models.noteShellKey`)}:{note:D(`models.noteIncluded`),noteTone:`done`}}function gn(e,t){switch(e.kind){case`client`:return{text:t.harnesses.find(t=>t.id===e.by)?.name??e.by??``,tone:`done`};case`key`:return{text:F(e.by??``)?.name??e.by??``,tone:`done`};case`local`:return{text:e.by===`apple`?D(`models.optApple`):D(`models.way.local`),tone:`done`};case`credits`:return{text:t.cloud?D(`models.way.creditsTeam`):D(`models.way.credits`),tone:`ok`};default:return{text:D(`models.way.none`),tone:`warn`}}}function _n(){return O({queryKey:[`models`],queryFn:()=>x.get(`/api/studio/models`)})}function Z(){let e=f();return M({mutationFn:e=>x.put(`/api/studio/models`,e),onSuccess:async t=>{e.setQueryData([`models`],t),await e.invalidateQueries({queryKey:[`me`]})}})}function Q({title:e,aside:t,children:n}){return(0,H.jsxs)(`section`,{className:`flex flex-col gap-3 border-border-soft border-t pt-5 first:border-t-0 first:pt-0`,children:[(0,H.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,H.jsx)(`h3`,{className:`font-medium text-[0.875rem]`,children:e}),t]}),n]})}function $({children:e}){return(0,H.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:e})}function vn({text:e,tone:t}){return(0,H.jsxs)(`span`,{className:r(`inline-flex h-7 shrink-0 items-center gap-1.5 rounded-full px-3 font-medium text-[0.75rem]`,t===`done`&&`bg-moss-tint text-moss`,t===`ok`&&`bg-amber-tint text-ink-2`,t===`warn`&&`bg-paper-2 text-ink-3`),children:[t===`done`?(0,H.jsx)(A,{className:`size-3.5`,strokeWidth:3}):null,t===`ok`?(0,H.jsx)(N,{className:`size-3.5`}):null,t===`warn`?(0,H.jsx)(ge,{className:`size-3.5`}):null,e]})}function yn({icon:e,title:t,lead:n,status:r}){return(0,H.jsxs)(`div`,{className:`flex items-start gap-3 sm:gap-4`,children:[(0,H.jsx)(`span`,{className:`grid size-10 shrink-0 place-items-center rounded-xl bg-ember-tint text-ember-strong`,children:(0,H.jsx)(e,{className:`size-5`})}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,H.jsx)(`h2`,{className:`font-display font-semibold text-[1.375rem] leading-tight tracking-tight`,children:t}),r]}),(0,H.jsx)(`p`,{className:`mt-0.5 text-[0.875rem] text-ink-3`,children:n})]})]})}function bn({label:e,children:t}){return(0,H.jsxs)(`div`,{className:`grid items-start gap-x-4 gap-y-1.5 sm:grid-cols-[7.5rem_minmax(0,1fr)]`,children:[(0,H.jsx)(`span`,{className:`pt-2 text-[0.75rem] text-ink-3`,children:e}),(0,H.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t})]})}function xn({selected:e,title:t,note:n,noteTone:i,disabled:a,onPick:o}){return(0,H.jsxs)(`button`,{type:`button`,onClick:o,disabled:a,"aria-pressed":e,title:n,className:r(`inline-flex h-9 items-center gap-1.5 rounded-full border px-3.5 text-[0.8125rem] transition coarse:h-11`,e?`border-ember bg-ember-tint font-medium text-ink`:i===`done`?`border-input bg-card text-ink hover:border-ink-4`:`border-border-soft border-dashed text-ink-3 hover:border-ink-4 hover:text-ink`,a&&`cursor-not-allowed opacity-50`),children:[i===`done`?(0,H.jsx)(A,{className:`size-3.5 text-moss`,strokeWidth:3}):null,t,(0,H.jsxs)(`span`,{className:`sr-only`,children:[`: `,n]})]})}function Sn({provider:e,stored:t,place:n}){let a=Z(),[o,s]=(0,V.useState)(``),[c,l]=(0,V.useState)(!1),[u,f]=(0,V.useState)(null),p=M({mutationFn:t=>x.post(`/api/studio/models/keys/${e.id}/check`,t?{key:t}:{})}),m=async()=>{f(null);let t=await p.mutateAsync(o.trim());if(!t.ok){f({ok:!1,message:t.message??D(`models.keyBad`)});return}await a.mutateAsync({keys:{[e.id]:o.trim()}}),s(``),l(!1),f({ok:!0,message:D(`models.keyOk`)})},h=!t||c;return n.ownKeys?(0,H.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[h?(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(y,{type:`password`,autoComplete:`off`,className:`min-w-0 flex-1 font-mono text-[0.8125rem]`,placeholder:e.keyPlaceholder,value:o,disabled:!n.canEdit,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&o.trim()&&m()}}),(0,H.jsx)(d,{busy:p.isPending||a.isPending,disabled:!o.trim()||!n.canEdit,onClick:()=>void m(),children:D(`models.keySave`)}),c?(0,H.jsx)(d,{variant:`ghost`,onClick:()=>l(!1),children:D(`common.cancel`)}):null]}):(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,H.jsxs)(`span`,{className:`flex items-center gap-2 text-[0.875rem] text-ink-2`,children:[(0,H.jsx)(B,{className:`size-4 text-moss`}),` `,D(`models.keyStored`)]}),(0,H.jsx)(d,{size:`sm`,variant:`ghost`,busy:p.isPending,onClick:async()=>{let e=await p.mutateAsync(void 0);f(e.ok?{ok:!0,message:D(`models.keyOk`)}:{ok:!1,message:e.message??D(`models.keyBad`)})},children:D(`models.keyCheck`)}),n.canEdit?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(d,{size:`sm`,variant:`ghost`,onClick:()=>l(!0),children:D(`models.keyReplace`)}),(0,H.jsx)(d,{size:`sm`,variant:`danger`,busy:a.isPending,onClick:()=>{f(null),a.mutate({keys:{[e.id]:``}})},children:D(`models.keyRemove`)})]}):null]}),u?(0,H.jsxs)(`p`,{className:r(`flex items-center gap-1.5 text-[0.8125rem]`,u.ok?`text-moss`:`text-rose`),children:[u.ok?(0,H.jsx)(A,{className:`size-3.5`,strokeWidth:3}):null,u.message]}):null,(0,H.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-[0.75rem] text-ink-4`,children:[(0,H.jsxs)(`button`,{type:`button`,onClick:()=>P(e.keyUrl),className:`inline-flex items-center gap-1 font-medium text-ember-strong hover:underline`,children:[D(`models.keyGet`,{name:e.name}),` `,(0,H.jsx)(i,{className:`size-3`})]}),(0,H.jsx)(`span`,{children:n.cloud?D(`models.keyWhereCloud`):D(`models.keyWhereLocal`)})]})]}):(0,H.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:D(`models.ownKeysPlan`)})}var Cn=`__custom__`;function wn({provider:e,cap:t,value:n,onPick:r,disabled:i}){let a=k,o=e.models[t]??[],s=o.some(e=>e.ref===n),[c,l]=(0,V.useState)(!s&&!!n),[u,f]=(0,V.useState)(s?``:n.replace(/^[a-z]+:/,``)),p=e.id===`gateway`?``:`${e.id}:`;return(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsx)(ie,{value:c?Cn:n,onChange:e=>{if(e===Cn){l(!0);return}l(!1),r(e)},options:[...o.map(e=>({value:e.ref,label:e.note?`${e.label} – ${Oe(e.note,a)}`:e.label})),{value:Cn,label:D(`models.modelCustom`)}]}),c?(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(y,{className:`min-w-0 flex-1 font-mono text-[0.8125rem]`,value:u,disabled:i,placeholder:o[0]?.ref.replace(/^[a-z]+:/,``)??``,onChange:e=>f(e.target.value)}),(0,H.jsx)(d,{variant:`secondary`,disabled:!u.trim()||i,onClick:()=>r(`${p}${u.trim()}`),children:D(`settings.save`)})]}):null]})}function Tn({provider:e,state:t}){let n=n=>L(t.bindings[n]??e.text?.[n]??``);return(0,H.jsxs)(`dl`,{className:`grid grid-cols-[auto_minmax(0,1fr)] gap-x-4 gap-y-1 text-[0.875rem]`,children:[(0,H.jsx)(`dt`,{className:`text-ink-3`,children:D(`models.textSimple`)}),(0,H.jsx)(`dd`,{className:`truncate font-medium`,children:n(`standard`)}),(0,H.jsx)(`dt`,{className:`text-ink-3`,children:D(`models.textDemanding`)}),(0,H.jsx)(`dd`,{className:`truncate font-medium`,children:n(`high`)})]})}function En({provider:e,state:t,onPick:n,disabled:r}){return(0,H.jsxs)(`details`,{className:`group rounded-lg ring-1 ring-border-soft`,children:[(0,H.jsx)(`summary`,{className:`cursor-pointer list-none px-3 py-2.5 text-[0.8125rem] text-ink-2 hover:text-ink`,children:(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,H.jsx)(v,{className:`size-3.5 transition group-open:rotate-90`}),D(`models.perClass`)]})}),(0,H.jsx)(`div`,{className:`flex flex-col gap-3 px-3 pt-1 pb-3`,children:oe.map(i=>(0,H.jsxs)(`div`,{className:`grid items-center gap-2 sm:grid-cols-[9rem_minmax(0,1fr)]`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`text-[0.8125rem] text-ink-2`,children:D(`class.${i}`)}),(0,H.jsx)(`div`,{className:`text-[0.6875rem] text-ink-4 leading-snug`,children:D(`class.${i}.hint`)})]}),(0,H.jsx)(wn,{provider:e,cap:`text`,value:t.bindings[i]??e.text?.[i]??``,disabled:r,onPick:e=>n(i,e)})]},i))})]})}function Dn({cap:e,disabled:t}){let n=Y[e],r=M({mutationFn:()=>x.post(`/api/studio/models/test`,{cls:n,lang:k})}),i=r.data;return(0,H.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,H.jsx)(d,{variant:`secondary`,busy:r.isPending,disabled:t,onClick:()=>r.mutate(),children:D(`models.try.${e}`)}),(0,H.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:e===`video`?D(`models.tryCostVideo`):X(e)?null:D(`models.tryCost`)})]}),r.isPending&&e!==`text`?(0,H.jsxs)(`p`,{className:`flex items-center gap-2 text-[0.8125rem] text-ink-3`,children:[(0,H.jsx)(l,{className:`size-3.5`}),` `,D(e===`video`?`models.tryWaitVideo`:`models.tryWait`)]}):null,i?.ok?(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[i.media&&e===`image`?(0,H.jsx)(`img`,{src:i.media,alt:``,className:`size-48 rounded-lg object-cover ring-1 ring-border-soft`}):null,i.media&&e===`speech`?(0,H.jsx)(`audio`,{src:i.media,controls:!0,autoPlay:!0,className:`w-full max-w-sm`}):null,i.media&&e===`video`?(0,H.jsx)(`video`,{src:i.media,controls:!0,autoPlay:!0,muted:!0,className:`w-full max-w-md rounded-lg`}):null,(0,H.jsxs)(`p`,{className:`flex items-start gap-2 text-[0.8125rem] text-ink-2`,children:[(0,H.jsx)(A,{className:`mt-0.5 size-3.5 shrink-0 text-moss`,strokeWidth:3}),(0,H.jsx)(`span`,{children:e===`listening`?i.reply?D(`models.tryHeard`,{text:i.reply}):D(`models.tryHeardNothing`):X(e)?D(`local.testOk`,{s:(i.ms/1e3).toFixed(1),ref:L(i.ref??``),reply:i.reply??``}):D(`models.tryOk`,{s:(i.ms/1e3).toFixed(1),model:L(i.ref??``)})})]})]}):null,i&&!i.ok?(0,H.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:D(`models.tryFailed`,{error:i.error??``})}):null,r.isError?(0,H.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:D(`models.tryFailed`,{error:r.error.message})}):null]})}function On(e){let t=e=>(e<10?Math.round(e*10)/10:Math.ceil(e)).toLocaleString(k);return e?.creditsPerImage?D(`models.notePerImage`,{n:t(e.creditsPerImage)}):e?.creditsPerSecond?D(`models.notePerSecond`,{n:t(e.creditsPerSecond)}):e?.creditsPer1kCharacters?D(`models.notePer1k`,{n:t(e.creditsPer1kCharacters)}):e?.creditsPerMinute?D(`models.notePerMinute`,{n:t(e.creditsPerMinute)}):D(`models.noteUsage`)}function kn(e,t){let n=ke(t.bindings[Y[e]]);return On((n?t.creditModels.find(e=>e.id===n):null)??t.prices?.[Y[e]])}function An(e,t,n){return e.creditModels.filter(e=>De(e.kind)===t&&(!n||e.source===n||e.provider===n))}function jn({cap:e,state:t,disabled:n}){let r=Z(),i=Y[e],a=ke(t.bindings[i]),o=An(t,e),s=t.prices?.[i]?.model,c=e=>e.source===`ai-gateway`?F(e.provider)?.name??e.provider:F(e.source)?.name??e.source;return(0,H.jsx)(ie,{value:a??``,onChange:e=>r.mutate({bindings:{[i]:je(e||null)}}),options:[{value:``,label:s?D(`models.creditsAuto`,{model:L(s)}):D(`models.creditsAutoNone`)},...o.map(e=>({value:e.id,label:`${e.name} · ${c(e)} – ${On(e)}`,disabled:n}))]})}function Mn({models:e,state:t,place:n}){let r=Z();return(0,H.jsx)(`ul`,{className:`flex flex-col divide-y divide-border-soft`,children:e.map(e=>{let i=De(e.kind),a=Y[i],o=t.bindings[a]===je(e.id);return(0,H.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 py-2.5`,children:[(0,H.jsx)(N,{className:`size-4 shrink-0 text-ink-3`}),(0,H.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`span`,{className:`block font-medium text-[0.875rem]`,children:e.name}),(0,H.jsxs)(`span`,{className:`block text-[0.75rem] text-ink-3`,children:[D(`models.cap.${i}`),` · `,On(e)]})]}),o?(0,H.jsxs)(`span`,{className:`flex items-center gap-1 font-medium text-[0.75rem] text-moss`,children:[(0,H.jsx)(A,{className:`size-3.5`,strokeWidth:3}),` `,D(`models.inUse`)]}):(0,H.jsx)(d,{size:`sm`,variant:`secondary`,disabled:!n.canEdit||!n.credits,busy:r.isPending&&r.variables?.bindings?.[a]===je(e.id),onClick:()=>r.mutate({bindings:{[a]:je(e.id)}}),children:D(`models.useFor`)})]},e.id)})})}function Nn({cap:e,state:t,place:n,me:r,onOpen:i}){let o=Z(),s=Y[e],c=t.ways[s],l=pn(t,e,n),[u,d]=(0,V.useState)(!1),f=gn(c,n),p=n.harnesses.filter(t=>(X(e)||e===`image`&&t.images)&&(t.version!==null||l?.kind===`client`&&l.id===t.id)),m=Pe.filter(t=>t.models[e]?.length),g=r=>{if(d(!1),r.kind===`credits`&&!n.credits){d(!0);return}if(fn(r,l))return;let i=Ue[e],a=e=>Object.fromEntries(i.map(t=>[t,e]));switch(r.kind){case`client`:o.mutate(X(e)?{source:r.id,bindings:Se(t.bindings)}:{bindings:{[s]:`${r.id}/image`}});return;case`key`:{let i=F(r.provider);o.mutate({...X(e)&&!n.cloud?{source:`own`}:{},bindings:mn(i,e,t)});return}case`local`:o.mutate(r.by===`apple`?{bindings:X(e)?Pn(t):{audio:`apple:transcribe`}}:{source:`own`,bindings:a(`ollama:qwen3`)});return;case`credits`:o.mutate(X(e)&&!n.cloud?{source:`account`,bindings:Se(t.bindings)}:{bindings:a(Me)});return}},_=l?.kind===`key`?F(l.provider):null,v=_?!t.keys[_.id]:!1,y=l?.kind===`client`?n.harnesses.find(e=>e.id===l.id):null,b=c.kind!==`none`;return(0,H.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,H.jsx)(yn,{icon:dn[e],title:D(`models.cap.${e}`),lead:D(`models.cap.${e}.hint`),status:(0,H.jsx)(vn,{...f})}),(0,H.jsxs)(h,{className:`flex flex-col gap-6 p-3.5 sm:p-5 sm:p-6`,children:[(0,H.jsxs)(Q,{title:D(`models.who`),children:[(0,H.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[p.length?(0,H.jsx)(bn,{label:D(`models.optSubscription`),children:p.map(e=>(0,H.jsx)(xn,{title:e.name,...hn(e),selected:l?.kind===`client`&&l.id===e.id,disabled:!n.canEdit,onPick:()=>g({kind:`client`,id:e.id})},e.id))}):null,(0,H.jsx)(bn,{label:D(`models.optKey`),children:m.map(e=>(0,H.jsx)(xn,{title:e.name,note:t.keys[e.id]?D(`models.noteKey`):D(`models.noteNoKey`),noteTone:t.keys[e.id]?`done`:void 0,selected:l?.kind===`key`&&l.provider===e.id,disabled:!n.canEdit,onPick:()=>g({kind:`key`,provider:e.id})},e.id))}),(0,H.jsxs)(bn,{label:X(e)&&!n.cloud?D(`models.optOther`):D(`models.optCreditsGroup`),children:[(X(e)||e===`listening`)&&!n.cloud&&t.apple?.supported?(0,H.jsx)(xn,{title:D(`models.optApple`),note:X(e)?Fn(t.apple):D(`models.optAppleNote`),noteTone:X(e)&&!t.apple.available?void 0:`done`,selected:l?.kind===`local`&&l.by===`apple`,disabled:!n.canEdit||X(e)&&!t.apple.available,onPick:()=>g({kind:`local`,by:`apple`})}):null,X(e)&&!n.cloud?(0,H.jsx)(xn,{title:D(`models.optLocal`),note:D(`models.optLocalNote`),selected:l?.kind===`local`&&l.by===`ollama`,disabled:!n.canEdit,onPick:()=>g({kind:`local`,by:`ollama`})}):null,(0,H.jsx)(xn,{title:n.cloud?D(`models.creditsTeam`):D(`models.creditsName`),note:n.credits?kn(e,t):D(`models.noteNeedsAccount`),noteTone:n.credits?`done`:void 0,selected:l?.kind===`credits`,disabled:!n.canEdit,onPick:()=>g({kind:`credits`})})]})]}),u?(0,H.jsxs)(`p`,{className:`text-[0.8125rem] text-ink-2`,children:[D(`local.sourceNeedsAccount`),` `,(0,H.jsx)(Vn,{})]}):null,o.isError?(0,H.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:o.error.message}):null]}),_?(0,H.jsxs)(H.Fragment,{children:[v?(0,H.jsxs)(Q,{title:D(`models.keyFor`,{name:_.name}),children:[(0,H.jsx)(Sn,{provider:_,stored:!1,place:n}),n.credits?(0,H.jsxs)($,{children:[(0,H.jsx)(N,{className:`mr-1 inline size-3.5 align-[-2px]`}),D(`models.keyFallback`)]}):null]}):null,v&&n.credits&&An(t,e,_.id).length?(0,H.jsx)(Q,{title:D(`models.viaCredits`,{name:_.name}),children:(0,H.jsx)(Mn,{models:An(t,e,_.id),state:t,place:n})}):null,(0,H.jsx)(Q,{title:D(`models.model`),aside:v?null:(0,H.jsx)(`button`,{type:`button`,onClick:()=>i({type:`provider`,id:_.id}),className:`text-[0.75rem] text-ink-3 hover:text-ink`,children:D(`models.manageKey`,{name:_.name})}),children:X(e)&&_.text?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Tn,{provider:_,state:t}),(0,H.jsx)(En,{provider:_,state:t,disabled:!n.canEdit,onPick:(e,t)=>o.mutate({bindings:{[e]:t}})})]}):(0,H.jsx)(wn,{provider:_,cap:e,value:t.bindings[s]??_.models[e]?.[0]?.ref??``,disabled:!n.canEdit,onPick:e=>o.mutate({bindings:{[s]:e}})},`${_.id}:${t.bindings[s]??``}`)})]}):null,l?.kind===`client`&&y?X(e)?(0,H.jsx)(Q,{title:y.name,children:(0,H.jsx)(lt,{me:r,id:y.id})}):(0,H.jsx)(Q,{title:y.name,children:(0,H.jsx)($,{children:D(`models.clientImages`,{name:y.name,sub:D(`harness.sub.${y.id}`)})})}):null,l?.kind===`local`?l.by===`apple`?(0,H.jsx)(In,{cap:e,state:t,place:n}):(0,H.jsx)(Ln,{state:t,disabled:!n.canEdit}):null,l?.kind===`credits`&&n.credits?X(e)?(0,H.jsx)(Q,{title:D(`models.creditsName`),children:(0,H.jsxs)($,{children:[D(`models.creditsPicks`),c.kind===`credits`&&c.ref?` ${D(`models.creditsModel`,{model:L(c.ref)})}`:``]})}):(0,H.jsxs)(Q,{title:D(`models.model`),children:[(0,H.jsx)(jn,{cap:e,state:t,disabled:!n.canEdit}),(0,H.jsx)($,{children:D(`models.creditsPickHint`)})]}):null,c.problem?(0,H.jsxs)(`p`,{className:`flex items-start gap-2 rounded-lg bg-paper-2 px-3 py-2.5 text-[0.8125rem] text-ink-2`,children:[(0,H.jsx)(ge,{className:`mt-0.5 size-3.5 shrink-0 text-ink-3`}),(0,H.jsx)(`span`,{children:(0,H.jsx)(a,{text:c.problem})})]}):null,l?.kind===`client`&&X(e)?null:(0,H.jsx)(Q,{title:D(`models.try`),children:(0,H.jsx)(Dn,{cap:e,disabled:!b||!n.canEdit},`${e}:${c.ref}`)}),X(e)&&r.subscriptions.includes(`claude`)&&!n.cloud?(0,H.jsx)(Rn,{me:r}):null]})]})}function Pn(e){let t=t=>{let n=e.bindings[t]??``;return/^(ollama|apple):/.test(n)?``:n};return{classifier:`apple:default`,standard:`apple:default`,high:t(`high`),highest:t(`highest`)}}function Fn(e){if(e.available)return D(`models.optAppleNote`);switch(e.reason){case`off`:return D(`models.appleOff`);case`loading`:return D(`models.appleLoading`);default:return D(`models.appleDevice`)}}function In({cap:e,state:t,place:n}){return(0,H.jsx)(Q,{title:D(`models.optApple`),children:(0,H.jsx)($,{children:X(e)?D(`models.appleHint`,{way:gn(t.ways.high,n).text}):D(`models.appleListenHint`)})})}function Ln({state:e,disabled:t}){let n=Z(),[r,i]=(0,V.useState)(e.ollamaUrl),[a,o]=(0,V.useState)((e.bindings.standard??`ollama:qwen3`).replace(/^ollama:/,``));return(0,H.jsxs)(Q,{title:D(`models.optLocal`),children:[(0,H.jsx)($,{children:D(`models.ollamaHint`)}),(0,H.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[minmax(0,1fr)_12rem_auto]`,children:[(0,H.jsx)(y,{className:`font-mono text-[0.8125rem]`,value:r,disabled:t,onChange:e=>i(e.target.value)}),(0,H.jsx)(y,{className:`font-mono text-[0.8125rem]`,value:a,disabled:t,onChange:e=>o(e.target.value)}),(0,H.jsx)(d,{variant:`secondary`,busy:n.isPending,disabled:t||!a.trim(),onClick:()=>n.mutate({ollamaUrl:r,bindings:Object.fromEntries(oe.map(e=>[e,`ollama:${a.trim()}`]))}),children:D(`settings.save`)})]})]})}function Rn({me:e}){let t=f(),n=M({mutationFn:e=>x.put(`/api/studio/local/chat`,{engine:e}),onSuccess:()=>t.invalidateQueries({queryKey:[`me`]})});return(0,H.jsxs)(Q,{title:D(`local.chat`),children:[(0,H.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:[`models`,`claude`].map(t=>(0,H.jsx)(`button`,{type:`button`,"aria-pressed":e.chatEngine===t,onClick:()=>n.mutate(t),className:r(`h-9 rounded-full border px-3.5 text-[0.8125rem] transition`,e.chatEngine===t?`border-ember bg-ember-tint text-ink`:`border-input bg-card text-ink-2 hover:text-ink`),children:D(t===`claude`?`local.chatClaude`:`local.chatModels`)},t))}),(0,H.jsx)($,{children:D(`local.subscription`)})]})}function zn({provider:e,state:t,place:n,onOpen:r}){let i=Z(),a=Ne.filter(t=>e.models[t]?.length),o=t.keys[e.id],s=e.id===`gateway`?[]:t.creditModels.filter(t=>t.source===e.id||t.provider===e.id);return(0,H.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,H.jsx)(yn,{icon:B,title:e.name,lead:Oe(e.about,k),status:(0,H.jsx)(vn,{text:D(o?`models.keyStored`:`models.keyNone`),tone:o?`done`:`warn`})}),(0,H.jsxs)(h,{className:`flex flex-col gap-6 p-3.5 sm:p-5 sm:p-6`,children:[(0,H.jsx)(Q,{title:D(`models.key`),children:(0,H.jsx)(Sn,{provider:e,stored:o,place:n})}),(0,H.jsx)(Q,{title:D(`models.uses`),children:(0,H.jsx)(`ul`,{className:`flex flex-col divide-y divide-border-soft`,children:a.map(a=>{let o=dn[a],s=pn(t,a,n),c=s?.kind===`key`&&s.provider===e.id;return(0,H.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 py-2.5`,children:[(0,H.jsx)(o,{className:`size-4 shrink-0 text-ink-3`}),(0,H.jsxs)(`button`,{type:`button`,onClick:()=>r({type:`cap`,id:a}),className:`min-w-0 flex-1 text-left`,children:[(0,H.jsx)(`span`,{className:`block font-medium text-[0.875rem]`,children:D(`models.cap.${a}`)}),(0,H.jsx)(`span`,{className:`block truncate text-[0.75rem] text-ink-3`,children:(e.models[a]??[]).map(e=>e.label).join(` · `)})]}),c?(0,H.jsxs)(`span`,{className:`flex items-center gap-1 font-medium text-[0.75rem] text-moss`,children:[(0,H.jsx)(A,{className:`size-3.5`,strokeWidth:3}),` `,D(`models.inUse`)]}):(0,H.jsx)(d,{size:`sm`,variant:`secondary`,disabled:!n.canEdit,busy:i.isPending&&i.variables?.bindings!==void 0,onClick:()=>i.mutate({...X(a)&&!n.cloud?{source:`own`}:{},bindings:mn(e,a,t)}),children:D(`models.useFor`)})]},a)})})}),s.length?(0,H.jsxs)(Q,{title:D(`models.viaCredits`,{name:e.name}),children:[(0,H.jsx)($,{children:n.credits?D(`models.viaCreditsHint`):D(`models.viaCreditsNeedsAccount`)}),(0,H.jsx)(Mn,{models:s,state:t,place:n})]}):null]})]})}function Bn({me:e,id:t,state:n,place:r}){let i=Z(),a=r.harnesses.find(e=>e.id===t);if(!a)return null;let o=n.source===t,s=a.version!==null&&a.auth!==`none`;return(0,H.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,H.jsx)(yn,{icon:Ze,title:a.name,lead:D(`harness.desc.${t}`),status:(0,H.jsx)(vn,{text:hn(a).note,tone:s?`done`:`warn`})}),(0,H.jsxs)(h,{className:`flex flex-col gap-6 p-3.5 sm:p-5 sm:p-6`,children:[(0,H.jsx)(Q,{title:D(`models.clientSignIn`),children:(0,H.jsx)(lt,{me:e,id:t})}),(0,H.jsxs)(Q,{title:D(`models.uses`),children:[(0,H.jsx)(`ul`,{className:`flex flex-col divide-y divide-border-soft`,children:[`text`,...a.images?[`image`]:[]].map(e=>{let a=dn[e],o=pn(n,e,r),s=o?.kind===`client`&&o.id===t;return(0,H.jsxs)(`li`,{className:`flex items-center gap-3 py-2.5`,children:[(0,H.jsx)(a,{className:`size-4 shrink-0 text-ink-3`}),(0,H.jsx)(`span`,{className:`min-w-0 flex-1 font-medium text-[0.875rem]`,children:D(`models.cap.${e}`)}),s?(0,H.jsxs)(`span`,{className:`flex items-center gap-1 font-medium text-[0.75rem] text-moss`,children:[(0,H.jsx)(A,{className:`size-3.5`,strokeWidth:3}),` `,D(`models.inUse`)]}):(0,H.jsx)(d,{size:`sm`,variant:`secondary`,busy:i.isPending,onClick:()=>i.mutate(e===`text`?{source:t,bindings:Se(n.bindings)}:{bindings:{image:`${t}/image`}}),children:D(`models.useFor`)})]},e)})}),o?null:(0,H.jsx)($,{children:D(`models.clientNotChosen`,{name:a.name})})]})]})]})}function Vn(){return(0,H.jsx)(c,{to:`/settings/account`,className:`font-medium text-ember-strong underline-offset-2 hover:underline`,children:D(`local.toAccount`)})}function Hn({state:e,place:t,onOpen:n}){let r=Z(),a=Ne.filter(t=>e.ways[Y[t]].kind===`credits`),o=t.cloud?D(`models.creditsTeam`):D(`models.creditsName`);return(0,H.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,H.jsx)(yn,{icon:N,title:o,lead:t.cloud?D(`models.creditsCloudHint`):D(`models.creditsLocalLead`),status:t.balance===null?void 0:(0,H.jsx)(`span`,{className:`font-display font-semibold text-[1.25rem] tabular-nums`,children:D(`nav.credits`,{n:Math.floor(t.balance).toLocaleString(k)})})}),(0,H.jsxs)(h,{className:`flex flex-col gap-6 p-3.5 sm:p-5 sm:p-6`,children:[!t.cloud&&!t.account?(0,H.jsxs)(Q,{title:D(`models.creditsConnectTitle`),children:[(0,H.jsx)($,{children:D(`models.creditsLocalHint`)}),(0,H.jsx)(`div`,{children:(0,H.jsx)(c,{to:`/settings/account`,children:(0,H.jsx)(d,{children:D(`models.creditsConnect`)})})})]}):null,t.account&&!t.account.signedIn?(0,H.jsxs)(`p`,{className:`text-[0.8125rem] text-rose`,children:[D(`local.accountExpired`),` `,(0,H.jsx)(Vn,{})]}):null,t.account?(0,H.jsx)(Q,{title:D(`models.creditsFallback`),children:(0,H.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,H.jsx)(C,{checked:e.creditFallback,disabled:!t.canEdit,onChange:e=>r.mutate({creditFallback:e}),label:D(`models.creditsFallback`)}),(0,H.jsx)($,{children:e.creditFallback?D(`models.creditsFallbackOn`):D(`models.creditsFallbackOff`)})]})}):null,t.credits?(0,H.jsx)(Q,{title:D(`models.creditsOn`),aside:t.topUp?(0,H.jsxs)(`a`,{href:t.topUp,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 font-medium text-[0.8125rem] text-ember-strong hover:underline`,children:[D(`models.creditsTopUp`),` `,(0,H.jsx)(i,{className:`size-3`})]}):null,children:a.length?(0,H.jsx)(`ul`,{className:`flex flex-col divide-y divide-border-soft`,children:a.map(t=>{let r=dn[t],i=e.ways[Y[t]];return(0,H.jsx)(`li`,{children:(0,H.jsxs)(`button`,{type:`button`,onClick:()=>n({type:`cap`,id:t}),className:`flex w-full items-center gap-3 py-2.5 text-left`,children:[(0,H.jsx)(r,{className:`size-4 shrink-0 text-ink-3`}),(0,H.jsx)(`span`,{className:`min-w-0 flex-1 font-medium text-[0.875rem]`,children:D(`models.cap.${t}`)}),(0,H.jsxs)(`span`,{className:`truncate text-[0.75rem] text-ink-3`,children:[i.ref?L(i.ref):``,` · `,kn(t,e)]})]})},t)})}):(0,H.jsx)($,{children:D(`models.creditsNone`)})}):null]})]})}function Un(e){return e?e===`credits`?{type:`credits`}:Ne.includes(e)?{type:`cap`,id:e}:F(e)?{type:`provider`,id:e}:{type:`client`,id:e}:{type:`cap`,id:`text`}}var Wn=e=>e.type===`credits`?`credits`:e.id;function Gn({view:e,onView:t}){return null}function Kn(e){return e.kind===`none`?`off`:e.kind===`credits`?`credits`:`done`}function qn(e,t){switch(e.type){case`cap`:return D(`models.cap.${e.id}`);case`provider`:return F(e.id)?.name??e.id;case`client`:return t?.harnesses.find(t=>t.id===e.id)?.name??e.id;default:return t?.mode===`managed`?D(`models.creditsTeam`):D(`models.creditsName`)}}function Jn(){let e=ye(),t=_n(),[n,r]=ne(),[i,a]=(0,V.useState)(`auto`),{narrow:o}=et(),s=n.get(`show`),c=Un(s);if(nt(s||!o?qn(c,e.data):null),!e.data||!t.data)return t.isError?(0,H.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:t.error.message}):null;let l=t.data,u=un(e.data,i),d=e=>r({show:Wn(e)},{replace:!o}),f=e=>!(!s&&o)&&Wn(e)===Wn(c),p=u.harnesses.filter(e=>e.version!==null||l.source===e.id),m=Pe.filter(e=>l.keys[e.id]),h=Pe.filter(e=>!l.keys[e.id]);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(ot,{children:[(0,H.jsx)(z,{label:D(`models.groupCaps`),children:Ne.map(e=>{let t=l.ways[Y[e]];return(0,H.jsx)(R,{icon:dn[e],label:D(`models.cap.${e}`),tone:Kn(t),toneLabel:gn(t,u).text,selected:f({type:`cap`,id:e}),onPick:()=>d({type:`cap`,id:e})},e)})}),(0,H.jsxs)(z,{label:D(`models.groupAccess`),children:[(0,H.jsx)(R,{icon:N,label:u.cloud?D(`models.creditsTeam`):D(`models.creditsName`),badge:u.balance===null?null:(0,H.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:Math.floor(u.balance).toLocaleString(k)}),tone:u.credits?void 0:`off`,toneLabel:u.credits?void 0:D(`models.noteNeedsAccount`),selected:f({type:`credits`}),onPick:()=>d({type:`credits`})}),p.map(e=>(0,H.jsx)(R,{icon:Ze,label:e.name,tone:e.version!==null&&e.auth===`subscription`?`done`:e.auth===`api_key`?`on`:`off`,toneLabel:hn(e).note,selected:f({type:`client`,id:e.id}),onPick:()=>d({type:`client`,id:e.id})},e.id)),m.map(e=>(0,H.jsx)(R,{icon:B,label:e.name,tone:`done`,toneLabel:D(`models.noteKey`),selected:f({type:`provider`,id:e.id}),onPick:()=>d({type:`provider`,id:e.id})},e.id))]}),h.length?(0,H.jsx)(z,{label:D(`models.groupMore`),collapsible:!0,open:h.some(e=>f({type:`provider`,id:e.id})),count:h.length,children:h.map(e=>(0,H.jsx)(R,{icon:B,label:e.name,selected:f({type:`provider`,id:e.id}),onPick:()=>d({type:`provider`,id:e.id})},e.id))}):null,(0,H.jsx)(Gn,{view:i,onView:a})]}),u.canEdit?null:(0,H.jsx)(`p`,{className:`mb-4 rounded-lg bg-paper-2 px-3 py-2 text-[0.8125rem] text-ink-2`,children:D(`models.readOnly`)}),c.type===`cap`?(0,H.jsx)(Nn,{cap:c.id,state:l,place:u,me:e.data,onOpen:d},c.id):c.type===`provider`&&F(c.id)?(0,H.jsx)(zn,{provider:F(c.id),state:l,place:u,onOpen:d},c.id):c.type===`client`?(0,H.jsx)(Bn,{me:e.data,id:c.id,state:l,place:u},c.id):(0,H.jsx)(Hn,{state:l,place:u,onOpen:d})]})}function Yn({name:e,image:t}){return t?(0,H.jsx)(`img`,{src:t,alt:``,className:`size-9 shrink-0 rounded-full object-cover`}):(0,H.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-full bg-paper-2 font-medium text-[0.75rem] text-ink-2`,children:be(e)})}function Xn({me:e}){let t=O({queryKey:[`team`,e.tenant.id],queryFn:()=>x.get(`/api/studio/team`)}),n=t.data,r=n?.plan??e.tenant.plan,a=n?.seats;return(0,H.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[(0,H.jsxs)(se,{title:D(`team.title`),hint:D(`team.hint`),children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`div`,{className:`text-[0.8125rem] text-ink-3`,children:D(`team.plan`)}),(0,H.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`font-medium text-[0.9375rem]`,children:r?.name??D(`team.planFree`)}),a?(0,H.jsx)(j,{children:a.limit===null?D(`team.seatsUnlimited`):D(`team.seats`,{taken:a.taken,limit:a.limit})}):null]})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsxs)(d,{variant:`secondary`,onClick:()=>P(`${e.manageUrl}/billing`),children:[D(`team.changePlan`),` `,(0,H.jsx)(i,{className:`size-4`})]}),n?.canManage?(0,H.jsxs)(d,{onClick:()=>P(`${e.manageUrl}/`),children:[D(`team.manage`),` `,(0,H.jsx)(i,{className:`size-4`})]}):null]})]}),(0,H.jsx)(`p`,{className:`mt-4 text-[0.8125rem] text-ink-3 leading-relaxed`,children:e.tenant.role===`member`?D(`team.memberNote`):D(`team.roles`)})]}),(0,H.jsx)(se,{title:D(`team.members`),children:t.isPending?(0,H.jsx)(l,{}):t.isError||!n?(0,H.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:D(`team.failed`)}):(0,H.jsxs)(`div`,{className:`flex flex-col divide-y divide-border-soft`,children:[n.members.map(t=>(0,H.jsxs)(`div`,{className:`flex items-center gap-3 py-3 first:pt-0 last:pb-0`,children:[(0,H.jsx)(Yn,{name:t.name,image:t.image}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsxs)(`div`,{className:`truncate text-[0.9375rem]`,children:[t.name,t.userId===e.user.id?(0,H.jsxs)(`span`,{className:`text-ink-4`,children:[` · `,D(`team.you`)]}):null]}),(0,H.jsx)(`div`,{className:`truncate text-[0.8125rem] text-ink-3`,children:t.email})]}),(0,H.jsx)(j,{tone:t.role===`member`?void 0:`live`,children:D(`team.role.${t.role}`)})]},t.userId)),n.invitations.map(e=>(0,H.jsxs)(`div`,{className:`flex items-center gap-3 py-3 first:pt-0 last:pb-0`,children:[(0,H.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-full bg-paper-2 text-ink-3`,children:(0,H.jsx)(mt,{className:`size-4`})}),(0,H.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-[0.9375rem]`,children:e.email}),(0,H.jsxs)(j,{tone:`warn`,children:[D(`team.invited`),` · `,D(`team.role.${e.role}`)]})]},e.id)),n.members.length===0&&n.invitations.length===0?(0,H.jsxs)(`div`,{className:`flex items-center gap-3 text-[0.875rem] text-ink-3`,children:[(0,H.jsx)(Je,{className:`size-4`}),` –`]}):null]})})]})}var Zn=(0,V.lazy)(()=>de(()=>import(`./AboutDialog-CZr1JFvY.js`).then(e=>({default:e.AboutPanel})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17]))),Qn=e=>e===`earlier`||e===`credits`?e:`new`;function $n(e,t){let n=e.toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``).replace(/^[^a-z]+/,``).slice(0,24)||`system`,r=n,i=2;for(;t.includes(r);)r=`${n}_${i++}`;return r}function er({project:e}){let t=f(),[n,r]=(0,V.useState)(e.mcpServers.map(e=>({...e,auth:e.headers?.Authorization??e.headers?.authorization??``}))),[i,a]=(0,V.useState)(!1),s=e.readOnly,c=M({mutationFn:()=>x.patch(`/api/studio/projects/${e.id}`,{mcpServers:n.filter(e=>e.name&&e.url).map(({auth:e,headers:t,...n})=>({...n,headers:e?{...t,Authorization:e}:void 0}))}),onSuccess:async()=>{await t.invalidateQueries({queryKey:[`projects`]}),a(!0),setTimeout(()=>a(!1),1800)}});return(0,H.jsxs)(h,{className:`p-4 sm:p-6`,children:[(0,H.jsx)(`h2`,{className:`font-display font-semibold text-lg`,children:D(`settings.mcp`)}),(0,H.jsx)(`p`,{className:`mt-1 mb-5 text-[0.875rem] text-ink-3`,children:D(`settings.mcpHint`)}),(0,H.jsxs)(`fieldset`,{disabled:s,className:`flex min-w-0 flex-col gap-3`,children:[n.map((e,t)=>(0,H.jsxs)(`div`,{className:`grid gap-2 rounded-lg bg-paper p-3 ring-1 ring-border-soft sm:grid-cols-[1fr_2fr_auto]`,children:[(0,H.jsx)(y,{placeholder:D(`settings.serverName`),value:e.name,onChange:e=>r(n=>n.map((r,i)=>i===t?{...r,name:e.target.value,id:r.id||$n(e.target.value,n.map(e=>e.id))}:r))}),(0,H.jsx)(y,{placeholder:`${D(`settings.serverUrl`)} (https://…/mcp)`,value:e.url,onChange:e=>r(n=>n.map((n,r)=>r===t?{...n,url:e.target.value}:n))}),s?(0,H.jsx)(`span`,{}):(0,H.jsx)(o,{label:D(`common.remove`),onClick:()=>r(e=>e.filter((e,n)=>n!==t)),className:`hover:text-rose`,children:(0,H.jsx)(E,{className:`size-4`})}),(0,H.jsx)(y,{className:`sm:col-span-2`,placeholder:D(`settings.serverHeader`),value:e.auth??``,onChange:e=>r(n=>n.map((n,r)=>r===t?{...n,auth:e.target.value}:n))}),e.id?(0,H.jsx)(`span`,{className:`self-center font-mono text-[0.6875rem] text-ink-4`,children:e.id}):null]},t)),s?null:(0,H.jsxs)(d,{variant:`secondary`,className:`self-start`,onClick:()=>r(e=>[...e,{id:``,name:``,url:``,auth:``}]),children:[(0,H.jsx)(w,{className:`size-4`}),` `,D(`settings.addServer`)]})]}),s?null:(0,H.jsxs)(`div`,{className:`mt-5 flex items-center justify-end gap-3`,children:[c.error?(0,H.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:c.error.message}):null,(0,H.jsx)(d,{busy:c.isPending,onClick:()=>c.mutate(),children:D(i?`settings.saved`:`settings.save`)})]})]})}var tr=new Set([`models`,`integrate`]);function nr(){let{section:e}=ae(),[t]=ne(),n=ee(),i=ye(),{project:a,loading:o}=ve(),s=xe(),[c,l]=(0,V.useState)(a?.id);(0,V.useEffect)(()=>l(a?.id),[a?.id]);let u=Ye(),d=ct(),[f,p]=(0,V.useState)(null),[m,h]=(0,V.useState)(null),[g,_]=(0,V.useState)(null),v=Ke(i.data,u),y=v.find(t=>t.id===e),x=v.map(e=>({...e,to:`/settings/${e.id}`})),C=x.find(t=>t.id===e),w=y?tr.has(y.id):!1,T=y?w&&!t.get(`show`)?1:2:0,E=d?Math.min(T,1):w&&g!==e?1:0,te=tt(E),re=tt(T),ie=(0,V.useMemo)(()=>({slot:f,narrow:d,setDetail:h}),[f,d]);if(Ae(y?.id===`models`?{suggestions:[{label:D(`assistant.suggest.modelsNow`)},{label:D(`assistant.suggest.modelsMissing`)},{label:D(`assistant.suggest.modelsCost`)}]}:y?.id===`account`?{suggestions:[{label:D(`assistant.suggest.credits`)},{label:D(`assistant.suggest.accountWhy`)},{label:D(`assistant.suggest.plans`)}]}:y?.id===`integrate`?{suggestions:[{label:D(`assistant.suggest.integrateWhat`)},{label:D(`assistant.suggest.integrateClaude`)},{label:D(`assistant.suggest.what`)}]}:y?.id===`connectors`?{suggestions:[{label:D(`assistant.suggest.connectorsWhat`)},{label:D(`assistant.suggest.connectorsAdd`),fill:!0},{label:D(`assistant.suggest.what`)}]}:{}),Qe([{label:D(`settings.title`),to:`/settings`},...y?[{label:y.label,to:`/settings/${y.id}`}]:[],...y&&m?[{label:m}]:[]]),!y){if(e===`build`)return(0,H.jsx)(S,{to:`/settings/integrate`,replace:!0});if(e===`project`)return(0,H.jsx)(S,{to:`/space`,replace:!0});if(e!==void 0||!d)return u.status===`ready`||e===void 0?(0,H.jsx)(S,{to:`/settings/account`,replace:!0}):null}let O=y?.id===`connectors`&&s,k=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(rt,{title:D(`settings.title`),open:E===1?C??null:null,onBack:()=>d?n(`/settings`):_(e??null)}),(0,H.jsx)(`div`,{className:r($e(te)),children:E===0?(0,H.jsx)(at,{entries:x,current:d?void 0:C,onPick:()=>_(null)}):(0,H.jsx)(`div`,{ref:p})},E)]});return(0,H.jsx)(it.Provider,{value:ie,children:(0,H.jsx)(`div`,{className:`animate-rise`,children:(0,H.jsxs)(`div`,{className:r(`grid gap-6`,`md:grid-cols-[10.5rem_minmax(0,1fr)] md:gap-5 lg:grid-cols-[15rem_minmax(0,1fr)] lg:gap-10`),children:[(0,H.jsx)(`aside`,{className:r(`min-w-0 md:sticky md:top-6 md:self-start`,d&&T===2&&`hidden`,d&&re===`back`&&$e(`back`)),children:k}),y?(0,H.jsxs)(`div`,{className:r(`min-w-0`,![`integrate`,`models`].includes(y.id)&&`max-w-2xl`,d&&T<2&&`hidden`,d&&re===`deeper`&&$e(`deeper`)),children:[d?(0,H.jsx)(`div`,{className:`mb-3`,children:(0,H.jsx)(st,{label:w?y.label:D(`settings.title`),onBack:()=>n(w?`/settings/${y.id}`:`/settings`)})}):null,O?(0,H.jsx)(`div`,{className:`mb-6`,children:(0,H.jsx)(Ve,{})}):null,y.id===`connectors`&&a?(0,H.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[a.readOnly?(0,H.jsx)(Te,{children:Ce(a)}):null,(0,H.jsx)(Dt,{projectId:a.id,readOnly:a.readOnly},c),(0,H.jsx)(er,{project:a},c)]}):null,y.id===`connectors`&&!a&&!o?(0,H.jsx)(b,{children:D(`settings.noProject`)}):null,y.id===`models`?(0,H.jsx)(Jn,{}):null,y.id===`integrate`?(0,H.jsx)(ln,{}):null,y.id===`account`&&i.data?(0,H.jsx)(Ie,{me:i.data}):null,y.id===`about`?(0,H.jsx)(V.Suspense,{fallback:null,children:(0,H.jsx)(Zn,{me:i.data,active:!0,initialTab:Qn(t.get(`tab`))})}):null,y.id===`team`&&i.data?(0,H.jsx)(Xn,{me:i.data}):null,y.id===`plugins`?(0,H.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,H.jsx)(_t,{}),(0,H.jsx)(St,{})]}):null,y.plugin?(0,H.jsx)(qe,{of:y.plugin,children:(0,H.jsx)(y.plugin.component,{})}):null]}):null]})})})}export{nr as SettingsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$t as r,Lt as i,Oi as a,Ur as o,W as s,Wr as ee,ei as te,hr as ne,on as c,tn as l,zr as u}from"./ui-Bk08zclS.js";import{t as d}from"./useMutation-DM9Anfo-.js";import{D as re,d as f,g as ie,w as ae,x as p,y as m}from"./session-DvW7auj-.js";import{t as h}from"./logo-CGNoptDg.js";import{A as g,C as oe,O as se,W as ce,it as _,k as le,rt as ue,w as de,wt as fe}from"./index-CXA_do-X.js";import{n as v,t as pe}from"./Harness-DPRw6BmX.js";var y=e(t(),1),b=e(n(),1),x=`oklch(50% 0.2 262)`,S=`oklch(32% 0.15 262)`,C=`oklch(90% 0.1 80)`,w=`var(--step-done)`,T=`var(--step-now)`,E=`color-mix(in oklab, var(--on) 38%, transparent)`,me={"--on":`white`,"--tile":`rgb(255 255 255 / 0.1)`,"--tile-hover":`rgb(255 255 255 / 0.15)`,"--tile-ring":`rgb(255 255 255 / 0.15)`,"--panel":`rgb(255 255 255 / 0.07)`,"--panel-ring":`rgb(255 255 255 / 0.12)`,"--pick":`white`,"--pick-ink":S,"--pick-mark":S,"--dot":C,"--step-done":`oklch(88% 0.17 150)`,"--step-now":`oklch(88% 0.14 80)`,"--ready-ink":`oklch(27% 0.09 150)`,"--ink-2":`oklch(96% 0.02 262)`,"--ink-3":`oklch(90% 0.035 262)`,"--ink-4":`oklch(82% 0.05 262)`,"--moss":`oklch(90% 0.14 150)`,"--rose":`oklch(89% 0.09 45)`},he={"--on":`var(--ink)`,"--tile":`var(--card)`,"--tile-hover":`var(--paper-2)`,"--tile-ring":`var(--border-soft)`,"--panel":`var(--card)`,"--panel-ring":`var(--border-soft)`,"--pick":x,"--pick-ink":`white`,"--pick-mark":`white`,"--dot":x,"--step-done":`oklch(52% 0.15 150)`,"--step-now":`oklch(60% 0.15 65)`,"--ready-ink":`white`},D=`ease-[cubic-bezier(0.3,0.7,0.2,1)]`,ge=220,_e={codex:`dome`,claude:`oval`,antigravity:`wedge`,cursor:`sprout`,own:`bean`,account:`drop`,apple:`pebble`};function ve(e){if(e.available)return c(`models.optAppleNote`);switch(e.reason){case`off`:return c(`models.appleOff`);case`loading`:return c(`models.appleLoading`);default:return c(`models.appleDevice`)}}var O=`relative w-fit max-w-full transition-[left,translate] duration-700 ease-[cubic-bezier(0.3,0.7,0.2,1)] motion-reduce:transition-none`,k=`left-1/2 -translate-x-1/2 text-center`,A=`max-lg:left-1/2 max-lg:-translate-x-1/2 max-lg:text-center lg:left-0 lg:translate-x-0 lg:text-left`;function j(){window.matchMedia(`(max-width: 1023px)`).matches&&window.scrollTo({top:0})}var M=`wizards.setup.own`;function N(){try{return sessionStorage.getItem(M)===`1`}catch{return!1}}function P(e){try{e?sessionStorage.setItem(M,`1`):sessionStorage.removeItem(M)}catch{}}function ye(){return(0,b.jsxs)(`span`,{className:`inline-flex items-center gap-2.5`,children:[(0,b.jsx)(h,{size:28}),(0,b.jsxs)(`span`,{className:`font-display font-semibold text-[1.0625rem] tracking-tight`,children:[`engenty`,(0,b.jsx)(`span`,{className:`mr-[0.09em] ml-[0.06em] text-(color:--dot)`,children:`.`}),(0,b.jsx)(`span`,{className:`font-normal text-(color:--on)/70`,children:`wizards`})]})]})}function F({selected:e,title:t,description:n,badge:i,note:a,onPick:s}){return(0,b.jsxs)(`button`,{type:`button`,onClick:s,"aria-pressed":e,className:r(`group relative flex w-full items-center gap-3 rounded-2xl px-4 py-3 text-left transition-[background-color,color,box-shadow] duration-300`,e?`bg-(color:--pick) text-(color:--pick-ink) shadow-elevated`:`bg-(color:--tile) ring-(color:--tile-ring) ring-1 hover:bg-(color:--tile-hover)`),children:[i?(0,b.jsx)(`span`,{className:`absolute -top-2.5 right-4 rounded-full px-2.5 py-[3px] font-semibold text-[0.6875rem] leading-none tracking-wide shadow-[0_2px_8px_oklch(0%_0_0/0.22)]`,style:{background:C,color:S},children:i}):null,(0,b.jsx)(`span`,{className:r(`flex size-5 shrink-0 items-center justify-center rounded-full border transition-colors duration-300`,e?`border-transparent bg-(color:--pick-mark)`:`border-(color:--on)/40`),children:e?(0,b.jsx)(u,{className:`size-3.5 text-(color:--pick)`}):null}),(0,b.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,b.jsx)(`span`,{className:`block font-medium text-[0.9375rem]`,children:t}),(0,b.jsx)(`span`,{className:r(`mt-0.5 block truncate text-[0.8125rem]`,e?`opacity-70`:`text-(color:--on)/65`),children:n})]}),a?(0,b.jsx)(`span`,{className:r(`shrink-0 text-[0.75rem]`,e?`opacity-70`:`text-(color:--on)/65`),children:a}):null,(0,b.jsx)(o,{className:r(`size-4 shrink-0 transition`,e?`opacity-70`:`text-(color:--on)/40 group-hover:translate-x-0.5 group-hover:text-(color:--on)/80`)})]})}function be({name:e,at:t,done:n}){let r=[c(`setup.stage.connect`),c(`setup.stage.test`),c(`setup.stage.done`)],i=n?r.length:t+1;return(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 font-medium text-[0.75rem] uppercase tracking-[0.14em]`,children:[(0,b.jsx)(`span`,{className:`text-(color:--on)/70`,children:e}),(0,b.jsx)(`ol`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:r.map((e,r)=>{let i=n||r<t;return(0,b.jsxs)(`li`,{"aria-current":!i&&r===t?`step`:void 0,className:`flex items-center gap-1 transition-colors duration-500`,style:{color:i?w:r===t?T:E},children:[i?(0,b.jsx)(u,{className:`size-3.5`,strokeWidth:3}):null,e]},e)})}),(0,b.jsx)(`span`,{"aria-hidden":`true`,className:`flex gap-1.5`,children:r.map((e,t)=>(0,b.jsx)(`span`,{className:`h-[3px] w-5 rounded-full transition-colors duration-500`,style:{background:t<i?n?w:T:`color-mix(in oklab, var(--on) 22%, transparent)`}},e))})]})}function xe({href:e,children:t}){return(0,b.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,className:`transition hover:text-(color:--on)`,onClick:t=>{t.preventDefault(),g(e)},children:t})}function I(){let e=_(`site`),t=re()===`dark`;ae(t?x:null);let n=ie(),o=a(),h=te(),g=ue(),C=_(`account`),{project:T}=f(),E=de(!!n.data?.account?.signedIn),[M,I]=(0,y.useState)(N),[L,R]=(0,y.useState)(!1),z=d({mutationFn:e=>s.put(`/api/studio/local/models`,e===`apple`?{bindings:{classifier:`apple:default`,standard:`apple:default`}}:e===`own`?{source:`own`,bindings:{classifier:``,standard:``}}:{source:e,bindings:m(n.data?.models?.bindings??{})}),onSuccess:async(e,t)=>{await o.invalidateQueries({queryKey:[`me`]}),I(!0),R(!1),j(),P(t===`own`)}}),B=d({mutationFn:()=>Promise.all((n.data?.harnesses??[]).map(e=>s.post(`/api/studio/local/harness/${e.id}/detect`))),onSuccess:()=>o.invalidateQueries({queryKey:[`me`]})});if(!n.data?.models)return null;let V=n.data.models,H=e=>(e.version===null?2:0)+ +!e.app,U=[...n.data.harnesses].sort((e,t)=>H(e)-H(t)),Se=U.filter(e=>e.version!==null),W=n.data.apple,G=V.bindings.standard?.startsWith(`apple:`)?`apple`:M||n.data.setupDone||V.source!==`own`?V.source:null,K=n.data.harnesses.find(e=>e.id===G),q=V.source===`account`?c(`models.creditsName`):n.data.harnesses.find(e=>e.id===V.source)?.name??null,J=n.data.setupDone,Y=Object.values(V.keys).some(Boolean),Ce=J?2:K?K.auth===`none`?0:1:G===`apple`||G===`account`||Y?1:0,X=J?c(`setup.h.done`):K?K.version===null?c(`setup.h.install`,{name:K.name}):K.auth===`none`?c(`setup.h.signIn`,{name:K.name}):c(`setup.h.test`):c(G===`apple`||G===`account`||Y?`setup.h.test`:`setup.h.keys`),Z=e?g.data?.site:null,Q=G!==null&&!L,$=z.isPending?z.variables??G:G;return(0,b.jsxs)(`div`,{className:`flex min-h-dvh flex-col px-6 text-(color:--on) sm:px-10`,style:t?me:he,children:[(0,b.jsxs)(`header`,{className:`flex items-center justify-between pt-6 sm:pt-8`,children:[(0,b.jsx)(ye,{}),(0,b.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(se,{tone:t?`ground`:`surface`}),(0,b.jsx)(ce,{tone:t?`ground`:`surface`,ink:S})]})]}),(0,b.jsxs)(`main`,{className:`relative mx-auto flex w-full max-w-6xl flex-1 flex-col pt-6 pb-10 lg:pt-[6vh]`,children:[(0,b.jsx)(`div`,{"aria-hidden":`true`,className:r(`absolute top-6 left-1/2 z-10 origin-top -translate-x-1/2 transition-[opacity,scale,left] duration-500 motion-reduce:transition-none lg:top-[calc(6vh+5.25rem)] lg:origin-center lg:translate-x-0`,D,G?`lg:pointer-events-none lg:left-[calc(50%-560px)] lg:scale-75 lg:opacity-0`:`lg:left-[calc(50%-508px)] lg:scale-100 lg:opacity-100`,Q?`max-lg:pointer-events-none max-lg:scale-[0.4] max-lg:opacity-0`:`max-lg:scale-[0.6] max-lg:opacity-100`),children:(0,b.jsx)(`div`,{className:`animate-rise`,children:(0,b.jsx)(p,{kind:`drop`,size:ge,fluffy:!0,coat:`fur`})})}),(0,b.jsx)(`div`,{"aria-hidden":`true`,className:r(`shrink-0 transition-[height] duration-500 motion-reduce:transition-none lg:h-0`,D,Q?`max-lg:h-0`:`max-lg:h-[148px]`)}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-10 lg:flex-row lg:items-start lg:gap-14`,children:[(0,b.jsxs)(`section`,{className:r(`flex w-full shrink-0 animate-rise flex-col lg:w-[32rem] lg:transition-[margin] lg:duration-700 motion-reduce:transition-none`,D,G?`lg:ml-0`:`lg:ml-[calc(50%-16rem)]`,Q?`max-lg:hidden`:``),children:[(0,b.jsxs)(`div`,{className:`flex flex-col lg:min-h-[6.5rem]`,children:[(0,b.jsx)(`p`,{className:r(O,`font-medium text-(color:--on)/70 text-[0.75rem] uppercase tracking-[0.16em]`,G?A:k),children:c(`setup.title`)}),(0,b.jsx)(`h1`,{className:r(O,`mt-2 font-display font-semibold text-[1.625rem] leading-[1.08] tracking-[-0.02em] sm:text-[1.75rem]`,G?A:k),children:c(`setup.source`)}),(0,b.jsx)(`p`,{className:r(O,`mt-2.5 text-(color:--on)/75 text-[0.9375rem] leading-relaxed`,G?A:k),children:c(`setup.sub`)})]}),C?(0,b.jsxs)(`div`,{className:`mt-5 flex items-center gap-3.5 rounded-2xl bg-(color:--panel) px-4 py-3.5 ring-(color:--panel-ring) ring-1`,children:[(0,b.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-full bg-(color:--pick) font-semibold text-(color:--pick-ink) text-[0.9375rem]`,children:n.data.account?.signedIn?(n.data.account.name||n.data.account.email).slice(0,1).toUpperCase():(0,b.jsx)(fe,{className:`size-4.5`})}),(0,b.jsx)(`div`,{className:`min-w-0 flex-1`,children:n.data.account?.signedIn?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`p`,{className:`font-medium text-[0.9375rem]`,children:c(`setup.accountLinked`,{name:n.data.account.name||n.data.account.email})}),(0,b.jsx)(`p`,{className:`text-(color:--on)/75 text-[0.8125rem]`,children:[n.data.account.team,n.data.account.credits===null?null:c(`setup.accountCredits`,{credits:n.data.account.credits.toLocaleString(l)})].filter(Boolean).join(` · `)})]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`p`,{className:`font-medium text-[0.9375rem]`,children:c(`setup.account`)}),(0,b.jsx)(`p`,{className:`text-(color:--on)/75 text-[0.8125rem] leading-snug`,children:c(`setup.accountText`)}),(0,b.jsx)(oe,{...E})]})}),n.data.account?.signedIn?null:(0,b.jsx)(i,{variant:`secondary`,size:`sm`,busy:E.link.isPending,onClick:()=>E.link.mutate({}),children:c(`account.signIn`)})]}):null,(0,b.jsxs)(`div`,{className:`mt-5 flex flex-col gap-2.5`,children:[n.data.account?.signedIn?(0,b.jsx)(F,{selected:$===`account`,title:c(`setup.creditsChoice`),description:c(`setup.creditsDesc`),note:n.data.account.credits===null?void 0:c(`setup.accountCredits`,{credits:n.data.account.credits.toLocaleString(l)}),onPick:()=>z.mutate(`account`)}):null,U.map((e,t)=>(0,b.jsx)(F,{selected:$===e.id,title:e.name,description:c(`harness.desc.${e.id}`),badge:t===0?c(`setup.recommended`):void 0,note:e.version===null?c(`harness.notInstalled`):e.auth===`subscription`?c(`harness.ready`):void 0,onPick:()=>z.mutate(e.id)},e.id)),W?.supported?(0,b.jsx)(F,{selected:$===`apple`,title:c(`models.optApple`),description:c(`setup.appleDesc`),note:ve(W),onPick:()=>z.mutate(`apple`)}):null,(0,b.jsx)(F,{selected:$===`own`,title:c(`local.sourceOwn`),description:c(`setup.ownDesc`),onPick:()=>z.mutate(`own`)})]}),(0,b.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center justify-center gap-x-2 gap-y-1 text-(color:--on)/60 text-[0.8125rem]`,children:[(0,b.jsx)(`span`,{children:Se.length?null:c(`setup.noHarness`)}),(0,b.jsxs)(i,{variant:`ghost`,size:`sm`,busy:B.isPending,onClick:()=>B.mutate(),children:[(0,b.jsx)(ne,{className:`size-3.5`}),` `,c(`local.recheck`)]})]})]}),G?(0,b.jsxs)(`section`,{className:r(`min-w-0 flex-1 animate-settle`,L?`max-lg:hidden`:``),children:[(0,b.jsxs)(`button`,{type:`button`,onClick:()=>{R(!0),j()},className:`-ml-1.5 mb-5 inline-flex items-center gap-1.5 rounded-full px-1.5 py-1 text-(color:--on)/80 text-[0.875rem] transition hover:text-(color:--on) lg:hidden`,children:[(0,b.jsx)(ee,{className:`size-4`}),` `,c(`run.back`)]}),(0,b.jsxs)(`div`,{className:`relative`,children:[(0,b.jsx)(`div`,{"aria-hidden":`true`,className:`absolute top-6 right-2 z-10`,children:(0,b.jsx)(p,{kind:_e[G],size:120,fluffy:!0,coat:`fur`})}),(0,b.jsxs)(`div`,{className:`min-h-[6.5rem]`,children:[(0,b.jsx)(be,{name:K?.name??c(G===`apple`?`models.optApple`:G===`account`?`setup.creditsChoice`:`local.sourceOwn`),at:Ce,done:J}),(0,b.jsx)(`h2`,{className:`mt-2 animate-rise pr-32 font-display font-semibold text-[clamp(28px,3vw,40px)] leading-[1.06] tracking-[-0.03em]`,children:X},X)]}),(0,b.jsx)(`div`,{className:`mt-5 rounded-2xl bg-(color:--panel) p-5 ring-(color:--panel-ring) ring-1 sm:p-6`,children:K?(0,b.jsx)(pe,{me:n.data,id:K.id,autoTest:!J}):G===`apple`?(0,b.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,b.jsx)(`p`,{className:`text-[0.875rem] text-ink-2 leading-relaxed`,children:q?c(`setup.appleHintKeeps`,{way:q}):c(`setup.appleHint`)}),(0,b.jsx)(v,{auto:!J&&W?.available===!0})]}):G===`account`?(0,b.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,b.jsx)(`p`,{className:`text-[0.875rem] text-ink-2 leading-relaxed`,children:c(`setup.creditsDesc`)}),(0,b.jsx)(v,{auto:!J})]}):(0,b.jsx)(le,{models:V})}),(0,b.jsxs)(`div`,{className:`mt-9`,children:[J?(0,b.jsxs)(`p`,{className:`mb-3 flex animate-rise items-center gap-2 font-medium text-[0.9375rem]`,style:{color:w},children:[(0,b.jsx)(u,{className:`size-4`,strokeWidth:3}),c(`setup.ready`)]}):null,(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,b.jsxs)(`button`,{type:`button`,disabled:!J,onClick:()=>h(`/`,{replace:!0}),className:r(`group inline-flex h-12 items-center gap-2.5 rounded-full px-6 font-semibold text-[1rem] transition-[background-color,color,box-shadow,filter] duration-300`,J?`shadow-[0_6px_24px_oklch(88%_0.17_150/0.35)] hover:brightness-105`:`cursor-not-allowed bg-(color:--on)/20 text-(color:--on)/65`),style:J?{background:w,color:`var(--ready-ink)`}:void 0,children:[c(`setup.done`),(0,b.jsx)(`span`,{"aria-hidden":`true`,className:`transition-transform group-enabled:group-hover:translate-x-0.5`,children:`→`})]}),J?null:(0,b.jsx)(`span`,{className:`text-(color:--on)/65 text-[0.8125rem]`,children:c(`setup.untilWorks`)})]})]})]})]},G):null]})]}),(0,b.jsxs)(`footer`,{className:`mx-auto flex w-full max-w-6xl items-center justify-between gap-4 pb-6 text-(color:--on)/55 text-[0.75rem] sm:pb-8`,children:[(0,b.jsxs)(`span`,{children:[`engenty ·`,` `,n.data.account?.signedIn?c(`setup.thisComputer`,{space:T?.name??``,team:n.data.account.team??n.data.account.name}):c(`setup.local`)]}),(0,b.jsxs)(`span`,{className:`flex items-center gap-5`,children:[Z?(0,b.jsx)(xe,{href:Z,children:new URL(Z).host}):null,(0,b.jsx)(`span`,{"aria-hidden":`true`,className:`size-[3px] bg-(color:--dot)`})]})]})]})}export{I as SetupPage};
|