wizards 0.2.4 → 0.2.5
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/routes/api.js +12 -1
- package/apps/runtime/dist/routes/studio.js +11 -3
- package/apps/runtime/dist/services/cloud.js +24 -0
- package/apps/runtime/dist/services/profile.js +18 -3
- package/apps/runtime/dist/services/spaces.js +7 -1
- package/apps/web/dist/assets/Account-BKribBzW.js +1 -0
- package/apps/web/dist/assets/{ChangelogDialog-lGa0JKY1.js → ChangelogDialog-CYQC4l57.js} +1 -1
- package/apps/web/dist/assets/{ChatPanel-Dk_45uca.js → ChatPanel-Cnd_dfF2.js} +1 -1
- package/apps/web/dist/assets/{CreditsDialog-BPMWo6tp.js → CreditsDialog-7nLXWFvP.js} +1 -1
- package/apps/web/dist/assets/EditorPage-BjFAF_4T.js +2 -0
- package/apps/web/dist/assets/{FlowPreview-gwtUv8-X.js → FlowPreview-BT4i-qIF.js} +1 -1
- package/apps/web/dist/assets/HomePage-F04N9Y1Q.js +1 -0
- package/apps/web/dist/assets/{ImportWizard-D6y4bKlF.js → ImportWizard-Cg0l6q88.js} +1 -1
- package/apps/web/dist/assets/{LocalRuntime-BjzPSsHr.js → LocalRuntime-BoVnl1ga.js} +2 -2
- package/apps/web/dist/assets/NewWizardPage-DumPEWtE.js +2 -0
- package/apps/web/dist/assets/{PublicRunner-Dac_e6wg.js → PublicRunner-CllgpTeL.js} +1 -1
- package/apps/web/dist/assets/{RunnerView-BC6crf1p.js → RunnerView-adkYnOSi.js} +1 -1
- package/apps/web/dist/assets/SettingsPage-7EG_dMSP.js +2 -0
- package/apps/web/dist/assets/{SetupPage-CYKVspBJ.js → SetupPage-BzZMf7Oz.js} +1 -1
- package/apps/web/dist/assets/{SharePage-DFIHsNS-.js → SharePage-CONXJnOU.js} +1 -1
- package/apps/web/dist/assets/{api-BTfKh3La.js → api-BC3K8Na8.js} +1 -1
- package/apps/web/dist/assets/changelog-C0GmxRP2.js +1 -0
- package/apps/web/dist/assets/cloud-off-D--dZLDw.js +1 -0
- package/apps/web/dist/assets/index-CJ3iuK8-.js +10 -0
- package/apps/web/dist/assets/index-mpjxO44v.css +1 -0
- package/apps/web/dist/assets/{meta-BbVhbYf6.js → meta-BeYxDfVN.js} +1 -1
- package/apps/web/dist/assets/{outputs-n_yhxmMk.js → outputs-DLmQMIUm.js} +1 -1
- package/apps/web/dist/assets/{session-D_Zggq_t.js → session-_w8H5O_d.js} +1 -1
- package/apps/web/dist/assets/type-DnfgUhpM.js +1 -0
- package/apps/web/dist/assets/ui-Cj3EzOCA.js +1 -0
- package/apps/web/dist/assets/upload-DNRENWzQ.js +1 -0
- package/apps/web/dist/index.html +6 -5
- package/apps/web/dist/mcp/flow.html +2 -2
- package/package.json +1 -1
- package/apps/web/dist/assets/EditorPage-Dt4MCcrU.js +0 -2
- package/apps/web/dist/assets/HomePage-Bi9FK3_1.js +0 -1
- package/apps/web/dist/assets/NewWizardPage-2HbCaPSt.js +0 -2
- package/apps/web/dist/assets/SettingsPage-BfXxa4SU.js +0 -2
- package/apps/web/dist/assets/changelog-CLmll9By.js +0 -1
- package/apps/web/dist/assets/index-CIwJmOjo.css +0 -1
- package/apps/web/dist/assets/index-DOpyzQiU.js +0 -10
- package/apps/web/dist/assets/type-BMJpS6_D.js +0 -1
- package/apps/web/dist/assets/ui-C3bTWmdM.js +0 -1
- package/apps/web/dist/assets/upload--J5bZhEM.js +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FlowPreview-BT4i-qIF.js","assets/jsx-runtime-D3jfb0Ew.js","assets/ui-Cj3EzOCA.js","assets/esm-rJY59Ixx.js","assets/react-dom-DenslgJm.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{A as r,F as i,I as a,K as o,M as s,N as c,O as l,d as u,g as d,j as f,n as p,nt as m,w as h}from"./api-BC3K8Na8.js";import{f as g,l as _,s as v}from"./session-_w8H5O_d.js";import{t as y}from"./preload-helper-CNEI7N0N.js";import{t as b}from"./createLucideIcon-q3MZMmnf.js";import{n as x,t as S}from"./plug-CLjyCoHB.js";import{t as C}from"./arrow-right-6FyN3e7D.js";import{c as w,l as T,o as ee,s as E,t as te}from"./meta-BeYxDfVN.js";import{t as ne}from"./check-CUpby_J9.js";import{n as re,r as ie,t as ae}from"./wand-sparkles-CKxArWPY.js";import{n as D,t as oe}from"./cloud-off-D--dZLDw.js";import{n as se,r as ce}from"./upload-DNRENWzQ.js";import{n as O,t as le}from"./mic-Bvz4mA2j.js";import{n as k,r as ue,t as de}from"./type-DnfgUhpM.js";import{n as fe,t as A}from"./video-CjgmvRDk.js";import{l as pe,u as me}from"./engenty-Cm8yZLON.js";import{_ as j,d as M,h as N,i as he,m as ge,n as _e,r as ve,t as P,y as F}from"./ui-Cj3EzOCA.js";import{h as I}from"./index-CJ3iuK8-.js";import{t as ye}from"./ImportWizard-Cg0l6q88.js";var be=class extends c{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type=`infinite`,super.setOptions(e)}getOptimisticResult(e){return e._type=`infinite`,super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:o,isRefetching:s,isError:c,isRefetchError:l}=r,u=n.fetchMeta?.fetchMore?.direction,d=c&&u===`forward`,f=o&&u===`forward`,p=c&&u===`backward`,m=o&&u===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:i(t,n.data),hasPreviousPage:a(t,n.data),isFetchNextPageError:d,isFetchingNextPage:f,isFetchPreviousPageError:p,isFetchingPreviousPage:m,isRefetchError:l&&!d&&!p,isRefetching:s&&!f&&!m}}};function xe(e,t){return s(e,be,t)}var Se={name:`audio-lines`,size:24,node:[[`path`,{d:`M2 10v3`,key:`1fnikh`}],[`path`,{d:`M6 6v11`,key:`11sgs0`}],[`path`,{d:`M10 3v18`,key:`yhl04a`}],[`path`,{d:`M14 8v7`,key:`3a1oy3`}],[`path`,{d:`M18 5v13`,key:`123xd1`}],[`path`,{d:`M22 10v3`,key:`154ddg`}]]};Se.node;var Ce=b(Se),we={name:`chart-column`,size:24,node:[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]],aliases:[`bar-chart-3`]};we.node;var Te=b(we),Ee={name:`circle-dollar-sign`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8`,key:`1h4pet`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}]]};Ee.node;var De=b(Ee),Oe={name:`circle-euro`,size:24,node:[[`path`,{d:`M15 9.4a4 4 0 1 0 0 5.2`,key:`1makmb`}],[`path`,{d:`M7 12h5`,key:`gblrwe`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]};Oe.node;var ke=b(Oe),Ae={name:`clapperboard`,size:24,node:[[`path`,{d:`m12.296 3.464 3.02 3.956`,key:`qash78`}],[`path`,{d:`M20.2 6 3 11l-.9-2.4c-.3-1.1.3-2.2 1.3-2.5l13.5-4c1.1-.3 2.2.3 2.5 1.3z`,key:`1h7j8b`}],[`path`,{d:`M3 11h18v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`4lm6w1`}],[`path`,{d:`m6.18 5.276 3.1 3.899`,key:`zjj9t3`}]]};Ae.node;var je=b(Ae),Me={name:`mouse-pointer-click`,size:24,node:[[`path`,{d:`M14 4.1 12 6`,key:`ita8i4`}],[`path`,{d:`m5.1 8-2.9-.8`,key:`1go3kf`}],[`path`,{d:`m6 12-1.9 2`,key:`mnht97`}],[`path`,{d:`M7.2 2.2 8 5.1`,key:`1cfko1`}],[`path`,{d:`M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z`,key:`s0h3yz`}]]};Me.node;var Ne=b(Me),Pe={name:`scan-text`,size:24,node:[[`path`,{d:`M3 7V5a2 2 0 0 1 2-2h2`,key:`aa7l1z`}],[`path`,{d:`M17 3h2a2 2 0 0 1 2 2v2`,key:`4qcy5o`}],[`path`,{d:`M21 17v2a2 2 0 0 1-2 2h-2`,key:`6vwrx8`}],[`path`,{d:`M7 21H5a2 2 0 0 1-2-2v-2`,key:`ioqczr`}],[`path`,{d:`M7 8h8`,key:`1jbsf9`}],[`path`,{d:`M7 12h10`,key:`b7w52i`}],[`path`,{d:`M7 16h6`,key:`1vyc9m`}]]};Pe.node;var Fe=b(Pe),Ie={name:`table-2`,size:24,node:[[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]]};Ie.node;var Le=b(Ie),L={name:`terminal`,size:24,node:[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]};L.node;var Re=b(L),R={name:`volume-2`,size:24,node:[[`path`,{d:`M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z`,key:`uqj9uw`}],[`path`,{d:`M16 9a5 5 0 0 1 0 6`,key:`1q6k2b`}],[`path`,{d:`M19.364 18.364a9 9 0 0 0 0-12.728`,key:`ijwkga`}]]};R.node;var z=b(R),B=e(t(),1),V={text:{de:`Text`,en:`Text`},document:{de:`Dokument (PDF, Word)`,en:`Document (PDF, Word)`},table:{de:`Tabelle`,en:`Table`},image:{de:`Bild`,en:`Image`},video:{de:`Video`,en:`Video`},audio:{de:`Audio`,en:`Audio`},dashboard:{de:`Dashboard`,en:`Dashboard`}},H={any:{de:`Jede Branche`,en:`Any industry`},trades:{de:`Handwerk`,en:`Trades`},gastronomy:{de:`Gastronomie`,en:`Food service`},hospitality:{de:`Hotel & Tourismus`,en:`Hotels & tourism`},realEstate:{de:`Immobilien`,en:`Real estate`},retail:{de:`Handel`,en:`Retail`},health:{de:`Gesundheit`,en:`Health`},professional:{de:`Kanzlei & Beratung`,en:`Professional services`},agency:{de:`Agentur & Marketing`,en:`Agency & marketing`},events:{de:`Veranstaltungen`,en:`Events`},publicSector:{de:`Vereine & Öffentliches`,en:`Associations & public sector`}},U={marketing:{de:`Marketing & Social Media`,en:`Marketing & social media`},sales:{de:`Angebote & Verkauf`,en:`Offers & sales`},accounting:{de:`Buchhaltung & Belege`,en:`Accounting & receipts`},service:{de:`Kundenservice`,en:`Customer service`},research:{de:`Recherche & Analyse`,en:`Research & analysis`},hr:{de:`Personal & Bewerbungen`,en:`HR & applications`},operations:{de:`Planung & Abläufe`,en:`Planning & operations`},website:{de:`Helfer für die Website`,en:`Website helpers`}},W={text:{de:`Text schreiben`,en:`Writes text`},web:{de:`Websuche`,en:`Web search`},browser:{de:`Browser bedienen`,en:`Drives a browser`},documents:{de:`Dokumente & Fotos lesen`,en:`Reads documents & photos`},image:{de:`Bilder erzeugen`,en:`Makes images`},video:{de:`Videos erzeugen`,en:`Makes video`},speech:{de:`Sprachausgabe`,en:`Speech output`},listening:{de:`Sprachnotizen verstehen`,en:`Understands voice notes`},code:{de:`Code ausführen`,en:`Runs code`},connectors:{de:`Verbundene Konten & Systeme`,en:`Connected accounts & systems`}},ze={low:{de:`günstig`,en:`low cost`},medium:{de:`mittel`,en:`medium cost`},high:{de:`teuer`,en:`high cost`}},G=e=>Object.keys(e);G(V),G(H),G(U),G(W);var K=e(n(),1),Be=(0,B.lazy)(()=>y(()=>import(`./FlowPreview-BT4i-qIF.js`),__vite__mapDeps([0,1,2,3,4]))),Ve={useCase:``,industry:``,format:``,capability:``},q=(e,t)=>e[t]?.[j]??t;function He(e){if(e<1)return 1;let t=10**Math.floor(Math.log10(e));return Math.round(e/t)*t}function Ue(e){return e.credits?F(`market.credits`,{n:He(e.credits.credits)}):ze[e.costTier][j]}var We={text:de,document:O,table:Le,image:E,video:A,audio:Ce,dashboard:Te};function J({format:e,className:t}){let n=We[e],r=q(V,e);return(0,K.jsx)(`span`,{title:r,className:`inline-flex`,children:(0,K.jsx)(n,{className:t,"aria-label":r,role:`img`})})}var Y=[`low`,`medium`,`high`];function X({entry:e}){let t=Y.indexOf(e.costTier)+1,n=j===`de`?ke:De;return(0,K.jsxs)(`span`,{title:Ue(e),className:`inline-flex items-center gap-1`,children:[(0,K.jsx)(`span`,{"aria-hidden":`true`,className:`inline-flex shrink-0`,children:Y.slice(0,t).map((e,t)=>(0,K.jsx)(`span`,{className:N(`rounded-full bg-(--coin-bg,var(--color-card))`,t>0&&`-ml-1.5`),children:(0,K.jsx)(n,{className:`size-4`})},e))}),ze[e.costTier][j]]})}function Ge({entry:e,onOpen:t}){return(0,K.jsxs)(_e,{role:`button`,tabIndex:0,onClick:t,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t())},className:N(`relative flex min-h-[124px] cursor-pointer flex-col gap-5 p-4 text-left transition sm:min-h-[136px] sm:p-5 hover:shadow-elevated focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus`,(!e.usable||e.missing.length>0)&&`opacity-60`),children:[(0,K.jsx)(`span`,{className:`-top-4 pointer-events-none absolute right-4`,children:(0,K.jsx)(u,{kind:e.avatar,size:68,interactive:!1})}),(0,K.jsxs)(`div`,{className:`min-w-0 pr-20`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 font-display font-semibold text-[15px]`,children:[e.title,e.starred?(0,K.jsx)(k,{className:`size-3.5 shrink-0 fill-amber text-amber`,"aria-label":F(`market.starred`)}):null]}),(0,K.jsx)(`div`,{className:`mt-0.5 text-[13px] text-ink-3 leading-snug`,children:e.pitch})]}),(0,K.jsx)(`div`,{className:`mt-auto flex flex-wrap items-center gap-x-3 gap-y-1.5 text-[12px] text-ink-3`,children:e.usable&&e.missing.length?(0,K.jsx)(ve,{tone:`warn`,children:F(`market.missing`,{list:Ke(e.missing)})}):e.usable?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,K.jsx)(D,{className:`size-3.5`}),` `,F(`market.minutes`,{n:e.effort.minutes})]}),(0,K.jsx)(X,{entry:e}),(0,K.jsx)(`span`,{className:`ml-auto inline-flex items-center gap-1.5`,children:e.formats.map(e=>(0,K.jsx)(J,{format:e,className:`size-4`},e))})]}):(0,K.jsx)(ve,{tone:`warn`,children:F(`market.needsUpdate`)})})]})}function Z({title:e,children:t}){return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`mb-1.5 font-medium text-[12px] text-ink-3 uppercase tracking-[0.06em]`,children:e}),t]})}var Ke=e=>e.map(e=>q(W,e)).join(`, `),qe={text:fe,web:ue,browser:Ne,documents:Fe,image:E,video:A,speech:z,listening:le,code:Re,connectors:S};function Je(e){switch(e.type){case`page`:return ee;case`agent`:return T;case`generate`:return e.asset===`image`?E:e.asset===`video`?A:e.asset===`voice`?z:e.asset===`dashboard`?Te:O;case`widget`:return e.video?je:x;case`review`:return re;case`result`:return w}return ae}function Ye(e){let t=new Set;for(let[n,r]of e.entries())for(let i of r.branches??[]){let r=i.to===`end`?e.length:e.findIndex(e=>e.id===i.to);for(let i=n+1;i<r;i++)t.add(e[i].id)}return t}function Xe(e){let t=Ye(e);return e.map(e=>({id:e.id,title:e.title,icon:Je(e),tone:te[e.type]??`bg-paper-2 text-ink-2`,optional:t.has(e.id),branches:e.branches}))}function Q({title:e,children:t}){return(0,K.jsx)(`span`,{title:e,className:`inline-flex items-center gap-2 border-border border-l px-4 first:border-l-0 first:pl-0`,children:t})}function $({icon:e,children:t,more:n}){return(0,K.jsxs)(`div`,{className:`flex gap-2.5`,children:[(0,K.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:e}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-[14px] text-ink leading-snug`,children:t}),n?(0,K.jsx)(`div`,{className:`text-[12px] text-ink-3 leading-snug`,children:n}):null]})]})}function Ze({className:e,children:t}){let n=(0,B.useRef)(null),[r,i]=(0,B.useState)({above:!1,below:!1});(0,B.useEffect)(()=>{let e=n.current;if(!e)return;let t=()=>{let t=e.scrollTop>1,n=e.scrollTop+e.clientHeight<e.scrollHeight-1;i(e=>e.above===t&&e.below===n?e:{above:t,below:n})};t(),e.addEventListener(`scroll`,t,{passive:!0});let r=new ResizeObserver(t);return r.observe(e),e.firstElementChild&&r.observe(e.firstElementChild),()=>{e.removeEventListener(`scroll`,t),r.disconnect()}},[]);let a=`linear-gradient(to bottom, ${r.above?`transparent`:`black`} 0, black 28px, black calc(100% - 44px), ${r.below?`transparent`:`black`} 100%)`;return(0,K.jsx)(`div`,{ref:n,className:e,style:{maskImage:a,WebkitMaskImage:a},children:(0,K.jsx)(`div`,{children:t})})}function Qe({id:e,fallback:t,onClose:n,onUse:r,busy:i}){let a=m(),o=l(),s=f({queryKey:[`marketplace-entry`,e,j],queryFn:()=>p.get(`/api/studio/marketplace/${encodeURIComponent(e)}?lang=${j}`),enabled:!!e,retry:!1}),c=s.data??t,h=g({mutationFn:t=>{let n=`/api/studio/marketplace/${encodeURIComponent(e)}/star`;return t?p.put(n):p.del(n)},onSuccess:()=>Promise.all([a.invalidateQueries({queryKey:[`marketplace`]}),a.invalidateQueries({queryKey:[`marketplace-entry`,e]})])}),_=d()===`dark`,v=pe[me[c?.avatar||`round`]],y=_?`var(--card)`:`color-mix(in oklch, ${v??`var(--ink-4)`} 14%, var(--paper-2))`;return(0,K.jsx)(he,{open:!!e,onClose:n,wide:!0,bare:!0,children:c?(0,K.jsxs)(`div`,{className:`relative flex max-h-[calc(100dvh-48px)] flex-col rounded-2xl bg-card shadow-overlay max-sm:h-dvh max-sm:max-h-none max-sm:rounded-none`,children:[(0,K.jsx)(`button`,{type:`button`,"aria-label":F(`common.close`),onClick:n,className:`sm:-top-3.5 sm:-right-3.5 absolute top-3 right-3 z-20 flex size-9 items-center justify-center rounded-full bg-card text-ink-2 shadow-elevated ring-1 ring-border-soft transition hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus`,children:(0,K.jsx)(I,{className:`size-4`})}),(0,K.jsxs)(`header`,{className:`relative shrink-0 border-border-soft border-b px-5 pt-5 pb-4 text-ink sm:rounded-t-2xl sm:px-7`,style:{background:y,"--coin-bg":y},children:[(0,K.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 overflow-hidden sm:rounded-t-2xl`,children:(0,K.jsx)(`span`,{className:N(`-top-28 -right-10 absolute size-80 rounded-full bg-white blur-3xl`,_?`opacity-[0.14]`:`opacity-80`)})}),(0,K.jsx)(`div`,{className:`-bottom-5 absolute right-9 z-10 max-sm:hidden`,children:(0,K.jsx)(u,{kind:c.avatar,size:104})}),(0,K.jsxs)(`div`,{className:`relative sm:pr-36`,children:[(0,K.jsx)(`h2`,{className:`font-display font-semibold text-[22px] leading-tight tracking-tight max-sm:pr-10`,children:c.title}),(0,K.jsx)(`p`,{className:`mt-1 text-[14px] text-ink-2 leading-snug`,children:s.data?.description||c.pitch})]}),c.usable?(0,K.jsxs)(`div`,{className:`-mx-5 sm:-mx-7 relative mt-3.5 flex flex-wrap items-center gap-y-2 border-border-soft border-t px-5 pt-3 font-medium text-[14px] sm:px-7 sm:pr-40`,children:[(0,K.jsxs)(Q,{title:F(`market.duration`),children:[(0,K.jsx)(D,{className:`size-4 text-ink-3`}),F(`market.minutes`,{n:c.effort.minutes})]}),(0,K.jsx)(Q,{title:F(`market.cost`),children:(0,K.jsx)(X,{entry:c})}),(0,K.jsx)(Q,{title:F(`market.result`),children:c.formats.map(e=>(0,K.jsx)(J,{format:e,className:`size-4`},e))})]}):null]}),c.usable?(0,K.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-x-7 gap-y-6 px-5 pt-6 max-sm:overflow-y-auto max-sm:pb-4 sm:grid-cols-[230px_minmax(0,1fr)] sm:grid-rows-[minmax(0,1fr)] sm:px-7`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-5 sm:min-h-0 sm:overflow-y-auto`,children:[(0,K.jsx)(Z,{title:F(`market.duration`),children:(0,K.jsx)($,{icon:(0,K.jsx)(D,{className:`size-4 text-moss`}),more:F(`market.durationHint`,{n:c.effort.fields}),children:F(`market.minutes`,{n:c.effort.minutes})})}),(0,K.jsx)(Z,{title:F(`market.cost`),children:(0,K.jsx)($,{icon:(0,K.jsx)(ce,{className:`size-4 text-amber`}),more:c.credits?F(`market.creditsHint`):void 0,children:(0,K.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2`,children:[(0,K.jsx)(X,{entry:c}),c.credits?(0,K.jsx)(`span`,{className:`text-ink-2`,children:F(`market.creditsRange`,{n:He(c.credits.credits)})}):null]})})}),(0,K.jsx)(Z,{title:F(`market.result`),children:(0,K.jsx)(`div`,{className:`flex flex-col gap-2`,children:(s.data?.results??[]).map(e=>(0,K.jsx)($,{icon:(0,K.jsx)(J,{format:e.kind,className:`size-4 text-ember-strong`}),more:e.formats.map(e=>e.toUpperCase()).join(` · `),children:e.title},e.title))})}),(0,K.jsx)(Z,{title:F(`market.needs`),children:(0,K.jsx)(`ul`,{className:`flex flex-col gap-2`,children:c.capabilities.map(e=>{let t=qe[e],n=c.missing.includes(e);return(0,K.jsxs)(`li`,{className:N(`flex items-center gap-2.5 text-[14px]`,n?`text-ink-3`:`text-ink-2`),children:[(0,K.jsx)(t,{className:N(`size-4 shrink-0`,n?`text-rose`:`text-cobalt`)}),q(W,e),n?(0,K.jsx)(`span`,{className:`text-[12px] text-rose`,children:F(`market.unavailable`)}):null]},e)})})})]}),(0,K.jsxs)(`div`,{className:`flex flex-col sm:min-h-0`,children:[(0,K.jsx)(`div`,{className:`mb-1.5 shrink-0 font-medium text-[12px] text-ink-3 uppercase tracking-[0.06em]`,children:F(`market.steps`)}),(0,K.jsx)(Ze,{className:`-mr-2 overscroll-contain pt-1 pr-2 pl-1 sm:min-h-0 sm:flex-1 sm:overflow-y-auto`,children:s.isLoading?(0,K.jsx)(M,{className:`size-5 text-ink-3`}):(0,K.jsx)(B.Suspense,{fallback:(0,K.jsx)(M,{className:`size-5 text-ink-3`}),children:(0,K.jsx)(Be,{steps:Xe(s.data?.outline??[])})})})]})]}):(0,K.jsx)(`div`,{className:`flex-1 px-5 pt-6 sm:px-7`,children:(0,K.jsx)(`p`,{className:`rounded-lg bg-amber-tint p-3 text-[14px] text-ink-2`,children:F(`market.needsUpdateHint`)})}),(0,K.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 px-5 pt-4 pb-5 max-sm:border-border-soft max-sm:border-t sm:px-7 sm:pb-6`,children:[(0,K.jsxs)(P,{variant:`ghost`,className:`mr-auto`,title:F(`market.starHint`),"aria-pressed":c.starred,busy:h.isPending,onClick:()=>h.mutate(!c.starred),children:[(0,K.jsx)(k,{className:N(`size-4`,c.starred&&`fill-amber text-amber`)}),(0,K.jsx)(`span`,{className:`max-sm:sr-only`,children:F(c.starred?`market.starred`:`market.star`)})]}),(0,K.jsx)(P,{variant:`secondary`,onClick:n,children:F(`common.close`)}),c.usable&&c.missing.length?(0,K.jsx)(P,{variant:`secondary`,onClick:()=>o(`/settings/models`),children:F(`editor.models.settings`)}):null,r?(0,K.jsx)(P,{disabled:!c.usable||c.missing.length>0,title:c.missing.length?F(`market.missingHint`,{list:Ke(c.missing)}):void 0,busy:i,onClick:()=>r(c),children:F(`market.use`)}):null]})]}):(0,K.jsx)(`div`,{className:`flex min-h-48 flex-col items-center justify-center gap-3 rounded-2xl bg-card p-8 text-[14px] text-ink-2 shadow-overlay`,children:s.isLoading?(0,K.jsx)(M,{className:`size-6 text-ink-3`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{children:F(`market.notFound`)}),(0,K.jsx)(P,{variant:`secondary`,onClick:n,children:F(`common.close`)})]})})})}function $e({name:e,value:t,options:n,onChange:r}){let[i,a]=(0,B.useState)(!1),o=(0,B.useRef)(null);(0,B.useEffect)(()=>{if(!i)return;let e=e=>{o.current?.contains(e.target)||a(!1)},t=e=>{e.key===`Escape`&&a(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[i]);let s=n.find(e=>e.value===t);return(0,K.jsxs)(`div`,{ref:o,className:`relative`,children:[(0,K.jsxs)(`div`,{className:N(`flex h-8 items-center rounded-full text-[13px] transition`,s?`bg-ember-tint text-ink`:`text-ink-2 hover:bg-paper-2 hover:text-ink`,i&&!s&&`bg-paper-2 text-ink`),children:[(0,K.jsx)(`button`,{type:`button`,"aria-haspopup":`listbox`,"aria-expanded":i,onClick:()=>a(!i),className:N(`flex h-full items-center gap-1.5 rounded-full pl-3 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus`,s?`pr-1`:`pr-2.5`),children:s?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`text-ink-3`,children:e}),(0,K.jsx)(`span`,{className:`font-medium`,children:s.label})]}):(0,K.jsxs)(K.Fragment,{children:[e,(0,K.jsx)(ie,{className:N(`size-3.5 transition`,i&&`rotate-180`)})]})}),s?(0,K.jsx)(`button`,{type:`button`,"aria-label":`${e}: ${F(`market.reset`)}`,onClick:()=>r(``),className:`mr-1 flex size-6 items-center justify-center rounded-full text-ink-3 hover:bg-card hover:text-ink`,children:(0,K.jsx)(I,{className:`size-3.5`})}):null]}),i?(0,K.jsx)(`div`,{role:`listbox`,"aria-label":e,className:`absolute top-full left-0 z-30 mt-1.5 max-h-80 min-w-60 overflow-y-auto rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,children:n.map(e=>(0,K.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":e.value===t,disabled:!e.count||e.unavailable,onClick:()=>{r(e.value===t?``:e.value),a(!1)},className:N(`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-left text-[14px] transition coarse:py-2.5`,e.count&&!e.unavailable?`text-ink-2 hover:bg-paper-2 hover:text-ink`:`text-ink-4`,e.value===t&&`font-medium text-ink`),children:[e.icon,(0,K.jsx)(`span`,{className:`flex-1 whitespace-nowrap`,children:e.label}),e.value===t?(0,K.jsx)(ne,{className:`size-4 text-ember`}):e.unavailable?(0,K.jsx)(`span`,{className:`whitespace-nowrap text-[12px] text-ink-4`,children:F(`market.unavailable`)}):(0,K.jsx)(`span`,{className:`text-[12px] text-ink-4 tabular-nums`,children:e.count})]},e.value))}):null]})}function et(e,t){let[n,r]=(0,B.useState)(e);return(0,B.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n}var tt=60;function nt({onUse:e,busy:t,open:n}){let[r,i]=(0,B.useState)(``),[a,s]=(0,B.useState)(Ve),[c,l]=(0,B.useState)(!1),[u,d]=(0,B.useState)(n??null),f=et(r.trim(),250),m=xe({queryKey:[`marketplace`,j,f,a,c],queryFn:({pageParam:e})=>{let t=new URLSearchParams({lang:j,limit:String(tt),offset:String(e)});f&&t.set(`q`,f);for(let[e,n]of Object.entries(a))n&&t.set(e,n);return c&&t.set(`starred`,`1`),p.get(`/api/studio/marketplace?${t}`)},initialPageParam:0,getNextPageParam:(e,t)=>{let n=t.reduce((e,t)=>e+t.entries.length,0);return n<e.total?n:void 0},placeholderData:o}),h=m.data?.pages[0],g=m.data?.pages.flatMap(e=>e.entries)??[],_=h?.all??0,v=r.trim()!==f||m.isFetching&&!m.isFetchingNextPage,y=(e,t,n)=>Object.keys(t).filter(t=>h?.facets[e]?.[t]!==void 0).map(r=>({value:r,label:q(t,r),icon:n?.(r),count:(h?.facets[e])[r]??0,unavailable:e===`capability`&&b.has(r)})),b=new Set(h?.unavailable??[]),x=y(`useCase`,U),S=[{key:`industry`,name:F(`market.industry`),options:y(`industry`,H)},{key:`format`,name:F(`market.format`),options:y(`format`,V,e=>(0,K.jsx)(J,{format:e,className:`size-4 text-ink-3`}))},{key:`capability`,name:F(`market.capability`),options:y(`capability`,W,e=>{let t=qe[e];return(0,K.jsx)(t,{className:`size-4 text-ink-3`})})}],C=!!r.trim()||c||Object.values(a).some(Boolean),w=()=>{s(Ve),i(``),l(!1)};if(m.isLoading)return(0,K.jsx)(`div`,{className:`flex justify-center py-10`,children:(0,K.jsx)(M,{className:`size-6 text-ink-3`})});let T=h?.offline?(0,K.jsxs)(`p`,{className:`mt-4 flex items-center justify-center gap-2 text-[13px] text-ink-3`,children:[(0,K.jsx)(oe,{className:`size-4 shrink-0`}),F(`market.offline`)]}):null;if(!_&&!C)return T;let ee=r?(0,K.jsx)(`button`,{type:`button`,"aria-label":F(`market.reset`),onClick:()=>i(``),className:`-mr-1.5 flex size-7 shrink-0 items-center justify-center rounded-full text-ink-3 hover:bg-paper-2 hover:text-ink`,children:(0,K.jsx)(I,{className:`size-4`})}):null,E=e=>N(`inline-flex h-7 shrink-0 items-center gap-1 whitespace-nowrap rounded-full px-2.5 text-[12.5px] transition`,e?`bg-card font-medium text-ink shadow-soft ring-1 ring-border-soft`:`text-ink-3 hover:bg-card/60 hover:text-ink`);return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`relative mx-auto flex h-10 max-w-md items-center gap-2.5 rounded-full bg-card px-4 shadow-soft ring-1 ring-border-soft transition focus-within:ring-2 focus-within:ring-focus sm:h-11`,children:[v?(0,K.jsx)(M,{className:`size-4 shrink-0 text-ink-3`}):(0,K.jsx)(se,{className:`size-4 shrink-0 text-ink-3`}),(0,K.jsx)(`input`,{type:`search`,value:r,onChange:e=>i(e.target.value),placeholder:F(`market.search`),"aria-label":F(`market.search`),className:`min-w-0 flex-1 bg-transparent text-[15px] outline-none placeholder:text-ink-4 [&::-webkit-search-cancel-button]:hidden`}),ee]}),T,(0,K.jsxs)(`div`,{className:`max-sm:-mx-4 mt-4 flex gap-1 max-sm:overflow-x-auto max-sm:px-4 max-sm:[scrollbar-width:none] sm:flex-wrap sm:justify-center max-sm:[&::-webkit-scrollbar]:hidden`,children:[[{value:``,label:F(`market.all`)},...x].map(e=>(0,K.jsx)(`button`,{type:`button`,"aria-pressed":!c&&a.useCase===e.value,onClick:()=>{l(!1),s({...a,useCase:e.value})},className:E(!c&&a.useCase===e.value),children:e.label},e.value)),(0,K.jsxs)(`button`,{type:`button`,"aria-pressed":c,onClick:()=>l(!c),className:E(c),children:[(0,K.jsx)(k,{className:N(`size-3.5`,c&&`fill-amber text-amber`)}),F(`market.starred`)]})]}),(0,K.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-1 gap-y-2 sm:mt-6`,children:[c?null:S.map(e=>(0,K.jsx)($e,{name:e.name,value:a[e.key],options:e.options,onChange:t=>s({...a,[e.key]:t})},e.key)),(0,K.jsxs)(`span`,{className:`ml-auto flex items-center gap-3 whitespace-nowrap pl-2 text-[13px] text-ink-3`,children:[C?(0,K.jsxs)(`button`,{type:`button`,onClick:w,className:`inline-flex items-center gap-1 text-ember-strong underline-offset-2 hover:underline`,children:[(0,K.jsx)(I,{className:`size-3.5 max-sm:size-4`}),(0,K.jsx)(`span`,{className:`max-sm:sr-only`,children:F(`market.resetShort`)})]}):null,C?(0,K.jsx)(`span`,{className:`tabular-nums sm:hidden`,children:F(`market.countOfShort`,{n:h?.total??0,all:_})}):null,(0,K.jsx)(`span`,{className:N(`tabular-nums`,C&&`max-sm:hidden`),children:C?F(`market.countOf`,{n:h?.total??0,all:_}):F(`market.count`,{n:_})})]})]}),g.length?(0,K.jsx)(`div`,{className:`mt-4 grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:g.map(e=>(0,K.jsx)(Ge,{entry:e,onOpen:()=>d(e.id)},e.id))}):(0,K.jsxs)(`div`,{className:`py-10 text-center text-[14px] text-ink-3`,children:[(0,K.jsx)(`p`,{children:F(c?`market.noneStarred`:`market.none`)}),(0,K.jsx)(P,{variant:`ghost`,className:`mt-2`,onClick:w,children:F(`market.reset`)})]}),m.hasNextPage?(0,K.jsx)(`div`,{className:`mt-6 flex justify-center`,children:(0,K.jsx)(P,{variant:`secondary`,busy:m.isFetchingNextPage,onClick:()=>void m.fetchNextPage(),children:F(`market.more`)})}):null,(0,K.jsx)(Qe,{id:u,fallback:g.find(e=>e.id===u)??null,onClose:()=>d(null),onUse:e,busy:t})]})}var rt={de:[`Stellenanzeige aus ein paar Stichworten, als PDF und LinkedIn-Post`,`Produktbeschreibung für den Onlineshop mit drei Bildvarianten`,`Wettbewerbsanalyse zu einer Firma mit Quellen`,`Lead aus einem Formular in unser CRM eintragen`],en:[`A job ad from a few keywords, as PDF and LinkedIn post`,`A shop product description with three image variants`,`A competitor analysis for a company, with sources`,`Put a lead from a form into our CRM`]};function it(){let e=l(),t=m(),{project:n}=v(),i=_(),[a,o]=(0,B.useState)(``),[s]=r(),c=g({mutationFn:e=>p.post(`/api/studio/wizards`,{projectId:n.id,starterId:e,lang:j}),onSuccess:async({id:n},r)=>{await t.invalidateQueries({queryKey:[`projects`]}),await t.invalidateQueries({queryKey:[`wizards`]}),e(r?`/edit/${n}`:`/edit/${n}?prompt=${encodeURIComponent(a.trim())}`)}}),d=()=>{a.trim()&&n&&c.mutate(void 0)};return!i||n?.readOnly?(0,K.jsx)(h,{to:`/`,replace:!0}):(0,K.jsxs)(`div`,{className:`animate-rise pt-4`,children:[(0,K.jsxs)(`div`,{className:`mx-auto max-w-2xl`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,K.jsx)(u,{kind:`sprout`,size:150,fluffy:!0}),(0,K.jsx)(`h1`,{className:`mt-2 font-display font-semibold text-[32px] leading-tight tracking-tight sm:text-[38px]`,children:F(`new.title`)})]}),(0,K.jsxs)(`div`,{className:`mt-8 rounded-2xl bg-card p-2 shadow-elevated ring-1 ring-border-soft focus-within:ring-focus`,children:[(0,K.jsx)(ge,{autoFocus:!0,minRows:4,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&d()},placeholder:F(`new.placeholder`),className:`border-0 bg-transparent text-[16px] shadow-none focus:ring-0`}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-2 pb-1`,children:[(0,K.jsx)(`span`,{className:`hidden text-[12px] text-ink-4 sm:block`,children:F(`new.hint`)}),(0,K.jsxs)(P,{size:`md`,onClick:d,busy:c.isPending&&!c.variables,disabled:!a.trim(),children:[F(`new.build`),` `,(0,K.jsx)(C,{className:`size-4`})]})]})]}),(0,K.jsx)(`div`,{className:`mt-4 flex flex-wrap justify-center gap-2`,children:rt[j].map(e=>(0,K.jsx)(`button`,{type:`button`,onClick:()=>o(e),className:`rounded-full bg-paper-2 px-3.5 py-1.5 text-[13px] text-ink-2 transition hover:bg-paper-3 hover:text-ink`,children:e},e))})]}),(0,K.jsxs)(`section`,{className:`mx-auto max-w-5xl`,children:[(0,K.jsx)(`h2`,{className:`mt-16 mb-5 text-center font-medium text-[13px] text-ink-3 uppercase tracking-[0.08em]`,children:F(`new.orStarter`)}),(0,K.jsx)(nt,{open:s.get(`starter`),busy:c.isPending&&!!c.variables,onUse:e=>n&&!c.isPending&&c.mutate(e.id)}),c.error?(0,K.jsx)(`p`,{className:`mt-3 text-center text-[14px] text-rose`,children:c.error.message}):null]}),(0,K.jsx)(`div`,{className:`mt-8 flex justify-center`,children:(0,K.jsx)(ye,{variant:`ghost`,label:F(`new.import`)})})]})}export{it as NewWizardPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{O as r,a as i,c as a,d as o,f as s,h as c,j as l,k as u,l as d,n as f,r as p}from"./api-
|
|
1
|
+
import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{O as r,a as i,c as a,d as o,f as s,h as c,j as l,k as u,l as d,n as f,r as p}from"./api-BC3K8Na8.js";import{t as m}from"./createLucideIcon-q3MZMmnf.js";import{t as h}from"./RunnerView-adkYnOSi.js";import{t as g}from"./arrow-right-6FyN3e7D.js";import{_,m as v,v as y}from"./outputs-DLmQMIUm.js";import{d as b,h as x,t as S,y as C}from"./ui-Cj3EzOCA.js";var w={name:`smartphone`,size:24,node:[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]};w.node;var T=m(w),E={name:`square-plus`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}],[`path`,{d:`M12 8v8`,key:`napkw2`}]],aliases:[`plus-square`]};E.node;var D=m(E),O=e(t(),1);function k(){if(window.self===window.top)return null;let e=new URLSearchParams(window.location.search).get(`embed`);return e===`inline`||e===`modal`?e:null}var A=k(),j=(e,t={})=>window.parent.postMessage({type:`engenty-wizard:${e}`,...t},`*`);function M(){(0,O.useEffect)(()=>{if(A===`inline`){let e=document.documentElement;document.getElementById(`root`)?.style.setProperty(`min-height`,`0`),e.style.overflow=`hidden`;let t=new ResizeObserver(()=>j(`height`,{height:Math.ceil(e.getBoundingClientRect().height)}));return t.observe(e),()=>t.disconnect()}if(A===`modal`){let e=e=>{e.key===`Escape`&&!document.querySelector(`dialog[open]`)&&j(`close`)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}},[])}var N=e(n(),1);function P(e){(0,O.useEffect)(()=>{if(!e)return;let t=document.documentElement;return t.style.setProperty(`--raw-primary`,e),()=>{t.style.removeProperty(`--raw-primary`)}},[e])}function F(e,t){(0,O.useEffect)(()=>{let n=document.querySelector(`link[rel="manifest"]`);if(!e||!t||!n)return;let r=n.getAttribute(`href`)??`/manifest.webmanifest`;n.setAttribute(`href`,`/api/public/wizards/${e}/manifest.webmanifest`);let i=document.createElement(`meta`);return i.name=`apple-mobile-web-app-title`,i.content=t,document.head.appendChild(i),()=>{n.setAttribute(`href`,r),i.remove()}},[e,t])}function I(){let[e,t]=(0,O.useState)(()=>window.wizardInstall??null),[n,r]=(0,O.useState)(!1);(0,O.useEffect)(()=>{let e=()=>t(window.wizardInstall??null);return window.addEventListener(`wizard-install`,e),()=>window.removeEventListener(`wizard-install`,e)},[]);let i=window.matchMedia(`(display-mode: standalone)`).matches||navigator.standalone===!0,a=/iPhone|iPad|iPod/.test(navigator.userAgent)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1;return i||!e&&!a?null:(0,N.jsxs)(`div`,{className:`mt-6 flex flex-col items-center gap-2 text-[13px] text-ink-3`,children:[(0,N.jsxs)(`button`,{type:`button`,onClick:()=>{e?(e.prompt(),window.wizardInstall=null,t(null)):r(e=>!e)},className:`inline-flex items-center gap-1.5 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:[(0,N.jsx)(D,{className:`size-4`}),` `,C(`install.add`)]}),n?(0,N.jsx)(`p`,{className:`max-w-xs leading-relaxed`,children:C(`install.ios`)}):null]})}function L({brand:e,toggle:t=!0}){return(0,N.jsx)(`header`,{className:`safe-top`,children:(0,N.jsxs)(`div`,{className:`relative flex h-14 items-center justify-center px-5`,children:[e.logoUrl?(0,N.jsx)(`img`,{src:a(e.logoUrl),alt:e.name,className:`h-7 max-w-[160px] object-contain`}):e.name?(0,N.jsx)(`span`,{className:`max-w-[60%] truncate font-display font-semibold text-[15px] text-ink-2 tracking-tight`,children:e.name}):null,t?(0,N.jsx)(`div`,{className:`absolute right-3`,children:(0,N.jsx)(s,{})}):null]})})}function R({siteKey:e,onToken:t}){let n=(0,O.useRef)(null);return(0,O.useEffect)(()=>{let r=()=>{n.current&&window.turnstile&&!n.current.childElementCount&&window.turnstile.render(n.current,{sitekey:e,callback:t,appearance:`interaction-only`})};if(window.turnstile){r();return}let i=document.createElement(`script`);i.src=`https://challenges.cloudflare.com/turnstile/v0/api.js`,i.async=!0,i.onload=r,document.head.appendChild(i)},[e,t]),(0,N.jsx)(`div`,{ref:n,className:`mt-4 flex justify-center`})}function z({token:e}){return!/iPhone|iPad|iPod|Android/.test(navigator.userAgent)||v||A?null:(0,N.jsxs)(`a`,{href:_(`${window.location.origin}${i}/w/${e}`),className:`mt-3 inline-flex items-center gap-1.5 text-[13px] text-ink-3 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:[(0,N.jsx)(T,{className:`size-4`}),` `,C(`install.app`)]})}var B=e=>`wz.run.${e}`,V=v&&new URLSearchParams(window.location.search).get(`start`)===`1`,H=A===`inline`?`min-h-80`:`min-h-dvh`;function U({wizard:e}){let t=r(),[n,i]=(0,O.useState)(!1),[a,s]=(0,O.useState)(null),[c,l]=(0,O.useState)(null),u=(()=>{try{return localStorage.getItem(B(e.token))}catch{return null}})(),d=async()=>{i(!0),s(null);try{let{runId:n}=await f.post(`/api/public/wizards/${e.token}/runs`,{turnstileToken:c??void 0,embedded:A!==null});try{localStorage.setItem(B(e.token),n)}catch{}t(`/w/${e.token}/${n}`,{replace:V})}catch(e){s(e.message),i(!1)}},p=V&&e.available&&!e.turnstileSiteKey,m=(0,O.useRef)(!1);return(0,O.useEffect)(()=>{p&&!m.current&&(m.current=!0,d())},[p]),p&&!a?(0,N.jsx)(`div`,{className:`flex min-h-[60dvh] items-center justify-center text-ink-4`,children:(0,N.jsx)(b,{})}):(0,N.jsxs)(`div`,{className:`mx-auto flex max-w-lg animate-rise flex-col items-center px-6 pt-6 pb-12 text-center sm:pt-16 sm:pb-16`,children:[(0,N.jsx)(o,{kind:e.avatar,size:190,fluffy:!0}),(0,N.jsx)(`h1`,{className:`mt-2 text-balance font-display font-semibold text-[30px] leading-[1.1] tracking-tight sm:text-[34px]`,children:e.title}),e.description?(0,N.jsx)(`p`,{className:`mt-3 text-[16px] text-ink-2 leading-relaxed`,children:e.description}):null,e.available?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(S,{size:`lg`,className:`mt-10 min-w-48`,busy:n,disabled:!!e.turnstileSiteKey&&!c,onClick:d,children:[C(`run.start`),` `,(0,N.jsx)(g,{className:`size-4`})]}),e.turnstileSiteKey?(0,N.jsx)(R,{siteKey:e.turnstileSiteKey,onToken:l}):null,u?(0,N.jsx)(`button`,{type:`button`,onClick:()=>t(`/w/${e.token}/${u}`),className:`mt-4 text-[14px] text-ink-3 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:C(`run.resume`)}):null,A||v?null:(0,N.jsx)(I,{}),(0,N.jsx)(z,{token:e.token})]}):(0,N.jsx)(`p`,{className:`mt-10 rounded-xl bg-paper-2 px-5 py-4 text-[15px] text-ink-2`,children:e.unavailableReason??C(`run.unavailable`)}),a?(0,N.jsx)(`p`,{className:`mt-4 text-[14px] text-rose`,children:a}):null]})}function W(){let{token:e,runId:t}=u(),n=r(),a=l({queryKey:[`public`,e],queryFn:()=>f.get(`/api/public/wizards/${e}`),retry:(e,t)=>p(t)&&e<3});if(P(a.data?.brand.accent),c(a.data?.avatar),F(e,a.data?.title),M(),(0,O.useEffect)(()=>{a.data&&(document.title=a.data.title)},[a.data]),(0,O.useEffect)(()=>{e&&t&&y(`run`,{token:e,runId:t})},[e,t]),a.isLoading)return(0,N.jsx)(`div`,{className:x(`flex items-center justify-center text-ink-4`,H),children:(0,N.jsx)(b,{})});if(!a.data){let e=p(a.error);return(0,N.jsxs)(`div`,{className:x(`flex flex-col items-center justify-center gap-4 px-6 text-center`,H),children:[(0,N.jsx)(o,{kind:`pebble`,size:80}),(0,N.jsx)(`p`,{className:`max-w-xs text-ink-3`,children:C(e?`common.offline`:`run.notFound`)}),e?(0,N.jsx)(S,{variant:`secondary`,onClick:()=>void a.refetch(),children:C(`common.retry`)}):null]})}return(0,N.jsxs)(`div`,{className:x(`flex flex-col`,H),children:[A===`inline`||v?null:(0,N.jsx)(L,{brand:a.data.brand,toggle:!A}),(0,N.jsx)(`div`,{className:`flex-1`,children:t?(0,N.jsx)(h,{runId:t,onRestart:()=>n(`/w/${e}`)}):(0,N.jsx)(U,{wizard:a.data})}),v?(0,N.jsx)(`div`,{className:`safe-bottom`}):(0,N.jsx)(`footer`,{className:`safe-bottom pt-6 text-center text-[12px] text-ink-4`,children:(0,N.jsx)(`a`,{href:`${i}/`,target:A?`_blank`:void 0,rel:`noreferrer`,className:`inline-block py-3.5 hover:text-ink-2`,children:C(`run.madeWith`).replace(`engenty wizards`,d.name)})})]})}export{L as BrandHeader,W as PublicRunner,P as useBrandAccent};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/qr-scanner.min-C_UI0gH-.js","assets/preload-helper-CNEI7N0N.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{c as r,d as i,n as a,t as o}from"./api-BTfKh3La.js";import{t as s}from"./preload-helper-CNEI7N0N.js";import{t as c}from"./createLucideIcon-q3MZMmnf.js";import{t as l}from"./arrow-left-hTN1VoH1.js";import{t as u}from"./arrow-right-6FyN3e7D.js";import{C as d,D as f,E as p,S as m,T as h,a as g,b as _,c as v,d as y,f as b,g as x,h as S,i as C,l as w,o as T,p as E,s as D,t as O,u as k,w as A,x as j,y as M}from"./outputs-n_yhxmMk.js";import{t as N}from"./check-CUpby_J9.js";import{n as P,t as F}from"./plus-Du-Jx8aI.js";import{t as I}from"./external-link-MAL7vJYj.js";import{n as L,t as ee}from"./mic-Bvz4mA2j.js";import{n as te,t as ne}from"./video-CjgmvRDk.js";import{d as re,f as ie,p as R,u as ae}from"./definition-DndaH5Ow.js";import{_ as z,c as B,d as V,f as oe,h as H,i as se,l as ce,m as le,n as ue,o as U,p as de,s as W,t as G,u as fe,y as K}from"./ui-C3bTWmdM.js";import{l as q}from"./index-DOpyzQiU.js";var pe={name:`arrow-down`,size:24,node:[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]};pe.node;var me=c(pe),he={name:`bell-ring`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M22 8c0-2.3-.8-4.3-2-6`,key:`5bb3ad`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}],[`path`,{d:`M4 2C2.8 3.7 2 5.7 2 8`,key:`tap9e0`}]]};he.node;var ge=c(he),_e={name:`bell`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]};_e.node;var ve=c(_e),ye={name:`camera`,size:24,node:[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`,key:`18u6gg`}],[`circle`,{cx:`12`,cy:`13`,r:`3`,key:`1vg3eu`}]]};ye.node;var be=c(ye),xe={name:`corner-down-left`,size:24,node:[[`path`,{d:`M20 4v7a4 4 0 0 1-4 4H4`,key:`6o5b7l`}],[`path`,{d:`m9 10-5 5 5 5`,key:`1kshq7`}]]};xe.node;var Se=c(xe),Ce={name:`database`,size:24,node:[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]};Ce.node;var we=c(Ce),Te={name:`eraser`,size:24,node:[[`path`,{d:`M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21`,key:`g5wo59`}],[`path`,{d:`m5.082 11.09 8.828 8.828`,key:`1wx5vj`}]]};Te.node;var Ee=c(Te),De={name:`file-headphone`,size:24,node:[[`path`,{d:`M4 6.835V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-.343`,key:`1vfytu`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M2 19a2 2 0 0 1 4 0v1a2 2 0 0 1-4 0v-4a6 6 0 0 1 12 0v4a2 2 0 0 1-4 0v-1a2 2 0 0 1 4 0`,key:`1etmh7`}]],aliases:[`file-audio`,`file-audio-2`]};De.node;var Oe=c(De),ke={name:`flashlight-off`,size:24,node:[[`path`,{d:`M11.652 6H18`,key:`voqkpr`}],[`path`,{d:`M12 13v1`,key:`176q98`}],[`path`,{d:`M16 16v4a2 2 0 0 1-2 2h-4a2 2 0 0 1-2-2v-8a4 4 0 0 0-.8-2.4l-.6-.8A3 3 0 0 1 6 7V6`,key:`dzyf92`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M7.649 2H17a1 1 0 0 1 1 1v4a3 3 0 0 1-.6 1.8l-.6.8a4 4 0 0 0-.55 1.007`,key:`1hvcfn`}]]};ke.node;var Ae=c(ke),je={name:`flashlight`,size:24,node:[[`path`,{d:`M12 13v1`,key:`176q98`}],[`path`,{d:`M17 2a1 1 0 0 1 1 1v4a3 3 0 0 1-.6 1.8l-.6.8A4 4 0 0 0 16 12v8a2 2 0 0 1-2 2H10a2 2 0 0 1-2-2v-8a4 4 0 0 0-.8-2.4l-.6-.8A3 3 0 0 1 6 7V3a1 1 0 0 1 1-1z`,key:`17vh7j`}],[`path`,{d:`M6 6h12`,key:`n6hhss`}]]};je.node;var Me=c(je),Ne={name:`grip-vertical`,size:24,node:[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]};Ne.node;var Pe=c(Ne),Fe={name:`image-plus`,size:24,node:[[`path`,{d:`M16 5h6`,key:`1vod17`}],[`path`,{d:`M19 2v6`,key:`4bpg5p`}],[`path`,{d:`M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5`,key:`1ue2ih`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}]]};Fe.node;var Ie=c(Fe),Le={name:`image-up`,size:24,node:[[`path`,{d:`M10.3 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10l-3.1-3.1a2 2 0 0 0-2.814.014L6 21`,key:`9csbqa`}],[`path`,{d:`m14 19.5 3-3 3 3`,key:`9vmjn0`}],[`path`,{d:`M17 22v-5.5`,key:`1aa6fl`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}]]};Le.node;var Re=c(Le),ze={name:`locate-fixed`,size:24,node:[[`line`,{x1:`2`,x2:`5`,y1:`12`,y2:`12`,key:`bvdh0s`}],[`line`,{x1:`19`,x2:`22`,y1:`12`,y2:`12`,key:`1tbv5k`}],[`line`,{x1:`12`,x2:`12`,y1:`2`,y2:`5`,key:`11lu5j`}],[`line`,{x1:`12`,x2:`12`,y1:`19`,y2:`22`,key:`x3vr5v`}],[`circle`,{cx:`12`,cy:`12`,r:`7`,key:`fim9np`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]};ze.node;var Be=c(ze),Ve={name:`lock-keyhole`,size:24,node:[[`circle`,{cx:`12`,cy:`16`,r:`1`,key:`1au0dj`}],[`rect`,{x:`3`,y:`10`,width:`18`,height:`12`,rx:`2`,key:`6s8ecr`}],[`path`,{d:`M7 10V7a5 5 0 0 1 10 0v3`,key:`1pqi11`}]]};Ve.node;var He=c(Ve),Ue={name:`map-pin`,size:24,node:[[`path`,{d:`M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0`,key:`1r0f0z`}],[`circle`,{cx:`12`,cy:`10`,r:`3`,key:`ilqhr7`}]]};Ue.node;var We=c(Ue),Ge={name:`pencil-line`,size:24,node:[[`path`,{d:`M13 21h8`,key:`1jsn5i`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]]};Ge.node;var Ke=c(Ge),qe={name:`rotate-ccw`,size:24,node:[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]};qe.node;var Je=c(qe),Ye={name:`scan-line`,size:24,node:[[`path`,{d:`M3 7V5a2 2 0 0 1 2-2h2`,key:`aa7l1z`}],[`path`,{d:`M17 3h2a2 2 0 0 1 2 2v2`,key:`4qcy5o`}],[`path`,{d:`M21 17v2a2 2 0 0 1-2 2h-2`,key:`6vwrx8`}],[`path`,{d:`M7 21H5a2 2 0 0 1-2-2v-2`,key:`ioqczr`}],[`path`,{d:`M7 12h10`,key:`b7w52i`}]]};Ye.node;var Xe=c(Ye),Ze={name:`share-2`,size:24,node:[[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}],[`circle`,{cx:`6`,cy:`12`,r:`3`,key:`w7nqdw`}],[`circle`,{cx:`18`,cy:`19`,r:`3`,key:`1xt0gg`}],[`line`,{x1:`8.59`,x2:`15.42`,y1:`13.51`,y2:`17.49`,key:`47mynk`}],[`line`,{x1:`15.41`,x2:`8.59`,y1:`6.51`,y2:`10.49`,key:`1n3mei`}]]};Ze.node;var Qe=c(Ze),$e={name:`shield-check`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]};$e.node;var et=c($e),tt={name:`switch-camera`,size:24,node:[[`path`,{d:`M11 19H4a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2h5`,key:`mtk2lu`}],[`path`,{d:`M13 5h7a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-5`,key:`120jsl`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}],[`path`,{d:`m18 22-3-3 3-3`,key:`kgdoj7`}],[`path`,{d:`m6 2 3 3-3 3`,key:`1fnbkv`}]]};tt.node;var nt=c(tt),rt={name:`triangle-alert`,size:24,node:[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`alert-triangle`]};rt.node;var it=c(rt),at={name:`unplug`,size:24,node:[[`path`,{d:`m19 5 3-3`,key:`yk6iyv`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z`,key:`1snsnr`}]]};at.node;var ot=c(at),J=e(t(),1),Y=e(n(),1);function st(e,t){let n=encodeURIComponent(e),r=encodeURIComponent(t);return[{id:`mail`,label:K(`shareRun.email`),href:`mailto:?subject=${r}&body=${r}%0A%0A${n}`},{id:`x`,label:`X`,href:`https://x.com/intent/post?text=${r}&url=${n}`},{id:`linkedin`,label:`LinkedIn`,href:`https://www.linkedin.com/sharing/share-offsite/?url=${n}`},{id:`whatsapp`,label:`WhatsApp`,href:`https://wa.me/?text=${r}%20${n}`},{id:`facebook`,label:`Facebook`,href:`https://www.facebook.com/sharer/sharer.php?u=${n}`}]}var ct={x:`𝕏`,linkedin:`in`,whatsapp:`WA`,facebook:`f`};function lt({runId:e,title:t,initial:n}){let[r,i]=(0,J.useState)(!1),[o,s]=(0,J.useState)(n),[c,l]=(0,J.useState)(!1),[u,d]=(0,J.useState)(!1),[f,p]=(0,J.useState)(null),m=async()=>{if(i(!0),!o){l(!0),p(null);try{s(await a.post(`/api/runs/${e}/share`))}catch(e){p(e.message)}finally{l(!1)}}},g=async()=>{await a.del(`/api/runs/${e}/share`),s(null),i(!1)},_=()=>{o&&(navigator.clipboard.writeText(o.url),d(!0),setTimeout(()=>d(!1),1500))},v=x(`share`)||typeof navigator<`u`&&`share`in navigator,y=o?.expiresAt?new Intl.DateTimeFormat(z,{dateStyle:`long`}).format(new Date(o.expiresAt)):null;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(G,{variant:`secondary`,onClick:()=>void m(),children:[(0,Y.jsx)(Qe,{className:`size-4`}),` `,K(`shareRun.button`)]}),(0,Y.jsx)(se,{open:r,onClose:()=>i(!1),title:K(`shareRun.title`),children:c?(0,Y.jsx)(`div`,{className:`flex justify-center py-8 text-ink-4`,children:(0,Y.jsx)(V,{})}):f?(0,Y.jsx)(`p`,{className:`rounded-lg bg-rose-tint px-3 py-2 text-[14px] text-rose`,children:f}):o?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-paper-2 p-1.5 pl-3`,children:[(0,Y.jsx)(h,{className:`size-4 shrink-0 text-ink-3`}),(0,Y.jsx)(`input`,{readOnly:!0,value:o.url,onFocus:e=>e.target.select(),"aria-label":K(`share.link`),className:`min-w-0 flex-1 bg-transparent text-[14px] outline-none coarse:h-11`}),(0,Y.jsxs)(G,{size:`sm`,onClick:_,children:[u?(0,Y.jsx)(N,{className:`size-3.5`}):(0,Y.jsx)(P,{className:`size-3.5`}),K(u?`share.copied`:`share.copy`)]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-3 gap-3 sm:grid-cols-6`,children:[st(o.url,t).map(e=>(0,Y.jsxs)(`a`,{href:e.href,target:`_blank`,rel:`noreferrer`,className:`flex flex-col items-center gap-1.5 text-[12px] text-ink-2 hover:text-ink`,children:[(0,Y.jsx)(`span`,{className:`inline-flex size-12 items-center justify-center rounded-full bg-paper-2 font-semibold text-[15px] transition hover:bg-paper-3`,children:e.id===`mail`?(0,Y.jsx)(A,{className:`size-5`}):ct[e.id]}),e.label]},e.id)),v?(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>void(x(`share`)?S(`share`,{link:o.url,title:t}):navigator.share({title:t,url:o.url})).catch(()=>void 0),className:`flex flex-col items-center gap-1.5 text-[12px] text-ink-2 hover:text-ink`,children:[(0,Y.jsx)(`span`,{className:`inline-flex size-12 items-center justify-center rounded-full bg-paper-2 transition hover:bg-paper-3`,children:(0,Y.jsx)(Qe,{className:`size-5`})}),K(`shareRun.more`)]}):null]}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-[13px] text-ink-3`,children:[(0,Y.jsx)(`span`,{children:y?K(`shareRun.until`,{date:y}):K(`shareRun.kept`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>void g(),className:`shrink-0 hover:text-rose coarse:min-h-11`,children:K(`shareRun.withdraw`)})]})]}):null})]})}function ut({runId:e,ask:t}){return t.kind===`confirm`?(0,Y.jsx)(dt,{runId:e,ask:t}):(0,Y.jsx)(ft,{runId:e,ask:t})}function dt({runId:e,ask:t}){let[n,r]=(0,J.useState)(!1),[i,o]=(0,J.useState)(!1),[s,c]=(0,J.useState)(null),l=async n=>{o(!0),c(null);try{await a.post(`/api/runs/${e}/ask/${t.id}`,n)}catch(e){c(e.message),o(!1)}},u=t.action.destructive?it:Ke;return(0,Y.jsxs)(`div`,{className:`animate-rise`,children:[(0,Y.jsxs)(`div`,{className:`mb-5 flex items-start gap-3`,children:[(0,Y.jsx)(`div`,{className:H(`flex size-10 shrink-0 items-center justify-center rounded-full`,t.action.destructive?`bg-rose-tint text-rose`:`bg-ember-tint text-ember-strong`),children:(0,Y.jsx)(u,{className:`size-5`})}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`p`,{className:`text-[13px] text-ink-3`,children:K(`ask.wants`,{service:t.service})}),(0,Y.jsx)(`h2`,{className:`font-display font-semibold text-[20px] leading-snug tracking-tight`,children:t.reason})]})]}),(0,Y.jsx)(`pre`,{className:`max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-xl bg-paper-2 p-4 text-[13px] leading-relaxed ring-1 ring-border-soft`,children:t.input}),(0,Y.jsxs)(`div`,{className:`mt-5 flex items-center gap-4`,children:[(0,Y.jsx)(de,{checked:n,onChange:r,label:K(`ask.allowRest`)}),(0,Y.jsx)(`span`,{className:`flex-1 text-[13px] text-ink-2`,children:K(`ask.allowRest`)})]}),s?(0,Y.jsx)(`div`,{className:`mt-3 rounded-lg bg-rose-tint px-4 py-3 text-[14px] text-rose`,children:s}):null,(0,Y.jsxs)(`div`,{className:`action-bar mt-6 flex items-center justify-between gap-3`,children:[(0,Y.jsx)(G,{variant:`ghost`,disabled:i,onClick:()=>void l({type:`skip`}),children:K(`ask.deny`)}),(0,Y.jsx)(G,{busy:i,onClick:()=>void l({type:`done`,remember:n}),children:K(`ask.allow`)})]})]})}function ft({runId:e,ask:t}){let[n,i]=(0,J.useState)({}),[o,s]=(0,J.useState)(!1),[c,l]=(0,J.useState)(!1),[u,d]=(0,J.useState)(null),[p,m]=(0,J.useState)(0),[h,g]=(0,J.useState)(``),[_,v]=(0,J.useState)(!1),y=(0,J.useRef)(null),b=(0,J.useCallback)(()=>m(e=>e+1),[]);(0,J.useEffect)(()=>{let e=setInterval(b,2500);return()=>clearInterval(e)},[b]);let x=async n=>{l(!0),d(null);try{await a.post(`/api/runs/${e}/ask/${t.id}`,n)}catch(e){d(e.message),l(!1)}},S=async t=>{d(null);try{await a.post(`/api/runs/${e}/browser/act`,t)}catch(e){d(e.message)}b()},C=e=>{let t=y.current;if(!t?.naturalWidth)return;let n=t.getBoundingClientRect();S({type:`click`,x:Math.round((e.clientX-n.left)/n.width*t.naturalWidth),y:Math.round((e.clientY-n.top)/n.height*t.naturalHeight)})},w=t.fields.some(e=>n[e.id]);return(0,Y.jsxs)(`div`,{className:`animate-rise`,children:[(0,Y.jsxs)(`div`,{className:`mb-5 flex items-start gap-3`,children:[(0,Y.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-full bg-ember-tint text-ember-strong`,children:(0,Y.jsx)(He,{className:`size-5`})}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`h2`,{className:`font-display font-semibold text-[20px] leading-snug tracking-tight`,children:t.reason}),(0,Y.jsxs)(`p`,{className:`mt-0.5 truncate text-[13px] text-ink-3`,children:[t.site.host,t.site.title?` · ${t.site.title}`:``]})]})]}),(0,Y.jsxs)(`div`,{className:`overflow-hidden rounded-xl bg-paper-2 ring-1 ring-border-soft`,children:[(0,Y.jsx)(`img`,{ref:y,src:r(`/api/runs/${e}/browser/screen?t=${p}`),alt:t.site.host,onClick:C,className:`block w-full cursor-pointer`}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 border-border-soft border-t bg-card p-2`,children:[(0,Y.jsx)(W,{type:_?`password`:`text`,autoComplete:`off`,value:h,placeholder:K(`ask.typeInto`),onChange:e=>g(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),S({type:`type`,text:h}).then(()=>g(``)))},autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,enterKeyHint:`send`,className:`h-9 min-w-[9rem] flex-1 basis-full text-[13px] sm:basis-0 coarse:h-11`}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>v(e=>!e),className:H(`h-9 shrink-0 rounded-md px-2.5 text-[12px] coarse:h-11 coarse:px-3.5`,_?`bg-ember-veil text-ink`:`text-ink-3 hover:bg-paper-2`),children:K(`ask.hide`)}),(0,Y.jsx)(pt,{label:`Enter`,onClick:()=>void S({type:`key`,key:`Enter`}),children:(0,Y.jsx)(Se,{className:`size-4`})}),(0,Y.jsx)(pt,{label:K(`ask.up`),onClick:()=>void S({type:`scroll`,dy:-500}),children:(0,Y.jsx)(f,{className:`size-4`})}),(0,Y.jsx)(pt,{label:K(`ask.down`),onClick:()=>void S({type:`scroll`,dy:500}),children:(0,Y.jsx)(me,{className:`size-4`})})]})]}),(0,Y.jsx)(`p`,{className:`mt-2 text-[12px] text-ink-4`,children:K(`ask.pictureHint`)}),t.fields.length?(0,Y.jsxs)(`form`,{className:`mt-5 flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),x({type:`fill`,values:n,remember:o})},children:[t.fields.map((e,r)=>(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(B,{children:e.label}),(0,Y.jsx)(W,{autoFocus:r===0,type:e.secret?`password`:`text`,autoComplete:`off`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,enterKeyHint:r===t.fields.length-1?`go`:`next`,value:n[e.id]??``,onChange:t=>i(n=>({...n,[e.id]:t.target.value}))})]},e.id)),(0,Y.jsx)(`button`,{type:`submit`,hidden:!0})]}):null,(0,Y.jsxs)(`div`,{className:`mt-5 flex items-center justify-between gap-4`,children:[(0,Y.jsx)(de,{checked:o,onChange:s,label:K(`ask.remember`)}),(0,Y.jsx)(`span`,{className:`flex-1 text-[13px] text-ink-2`,children:K(`ask.remember`)})]}),(0,Y.jsxs)(`p`,{className:`mt-3 flex items-start gap-2 text-[13px] text-ink-3`,children:[(0,Y.jsx)(et,{className:`mt-0.5 size-4 shrink-0 text-moss`}),` `,K(`ask.private`)]}),u?(0,Y.jsx)(`div`,{className:`mt-3 rounded-lg bg-rose-tint px-4 py-3 text-[14px] text-rose`,children:u}):null,(0,Y.jsxs)(`div`,{className:`action-bar mt-6 flex flex-wrap items-center justify-between gap-3`,children:[(0,Y.jsx)(G,{variant:`ghost`,disabled:c,onClick:()=>void x({type:`skip`}),children:K(`ask.skip`)}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[t.fields.length?(0,Y.jsx)(G,{variant:`secondary`,disabled:c,onClick:()=>void x({type:`done`,remember:o}),children:K(`ask.done`)}):null,t.fields.length?(0,Y.jsx)(G,{busy:c,disabled:!w,onClick:()=>void x({type:`fill`,values:n,remember:o}),children:K(`ask.signIn`)}):(0,Y.jsx)(G,{busy:c,onClick:()=>void x({type:`done`,remember:o}),children:K(`ask.done`)})]})]})]})}function pt({label:e,onClick:t,children:n}){return(0,Y.jsx)(`button`,{type:`button`,"aria-label":e,title:e,onClick:t,className:`flex size-9 shrink-0 items-center justify-center rounded-md text-ink-3 hover:bg-paper-2 hover:text-ink coarse:size-11`,children:n})}var X=36e5,Z=6e4,mt=1e3;function ht(e){return e.fractionDigits===void 0?e.style===`integer`?0:2:e.fractionDigits}function gt(e,t,n=`en`){if(typeof e!=`number`||!Number.isFinite(e))return``;let r=ht(t),i=t.grouping!==!1;return t.style===`percent`?new Intl.NumberFormat(n,{maximumFractionDigits:r,minimumFractionDigits:r,style:`percent`,useGrouping:i}).format(e):t.style===`currency`&&t.currency?new Intl.NumberFormat(n,{currency:t.currency,maximumFractionDigits:r,minimumFractionDigits:r,style:`currency`,useGrouping:i}).format(e):new Intl.NumberFormat(n,{maximumFractionDigits:r,minimumFractionDigits:r,useGrouping:i}).format(e)}function _t(e,t,n=`en`){if(typeof e!=`string`||e.length===0)return``;if(t.kind===`time`)return vt(e,t.timePrecision??`minutes`);if(t.dateStyle===`iso`)return t.kind===`date`?e.slice(0,10):e;let r=t.kind===`date`?new Date(`${e}T00:00:00`):new Date(e);if(Number.isNaN(r.getTime()))return e;let i=t.dateStyle??`medium`;if(t.kind===`date`)return new Intl.DateTimeFormat(n,{dateStyle:i}).format(r);let a=t.timePrecision??`minutes`;return new Intl.DateTimeFormat(n,{dateStyle:i,timeStyle:a===`hours`?`short`:`medium`}).format(r)}function vt(e,t){let[n=`0`,r=`00`,i=`00`]=e.split(`:`);return t===`hours`?`${n.padStart(2,`0`)}:00`:t===`minutes`?`${n.padStart(2,`0`)}:${r.padStart(2,`0`)}`:`${n.padStart(2,`0`)}:${r.padStart(2,`0`)}:${i.padStart(2,`0`)}`}function yt(e,t){if(typeof e!=`number`||!Number.isFinite(e))return``;let n=Math.max(0,Math.round(e));if(t.display===`iso`)return bt(n);if(t.display===`minutes`)return`${Math.round(n/Z)} min`;if(t.display===`hours`)return`${(n/X).toFixed(2)} h`;if(t.display===`decimal-hours`)return(n/X).toFixed(2);let r=Math.floor(n/X),i=Math.floor(n%X/Z),a=Math.floor(n%Z/mt);return`${r}:${String(i).padStart(2,`0`)}:${String(a).padStart(2,`0`)}`}function bt(e){let t=Math.floor(e/X),n=Math.floor(e%X/Z),r=Math.floor(e%Z/mt);return`${t>=24?`P${Math.floor(t/24)}D`:`P`}T${t%24}H${n}M${r}S`}function xt(e,t,n=`en`){if(t==null)return``;switch(e.type){case`number`:return gt(t,e.format,n);case`date`:return _t(t,e.format,n);case`duration`:return yt(t,e.format);case`boolean`:return t===!0?`true`:t===!1?`false`:``;case`select`:return St(e,t);default:return String(t)}}function St(e,t){let n=Array.isArray(t)?t:[t],r=e.format.options.reduce((e,t)=>(e[t.id]=t.label,e),{});return n.filter(e=>typeof e==`string`&&e.length>0).map(e=>r[e]??e).join(`, `)}async function Ct(e,t=2400){if(!/^image\/(jpeg|png|webp)$/.test(e.type)||e.size<12e5)return e;try{let n=await createImageBitmap(e),r=Math.min(1,t/Math.max(n.width,n.height)),i=document.createElement(`canvas`);i.width=Math.round(n.width*r),i.height=Math.round(n.height*r),i.getContext(`2d`)?.drawImage(n,0,0,i.width,i.height);let a=await new Promise(e=>i.toBlob(e,`image/jpeg`,.86));return a&&a.size<e.size?new File([a],`${e.name.replace(/\.[^.]+$/,``)}.jpg`,{type:`image/jpeg`}):e}catch{return e}}function wt(){return new Date().toISOString().slice(0,19).replace(/[:T]/g,`-`)}function Tt(e){let t=e?.name;return t===`NotFoundError`||t===`OverconstrainedError`?`missing`:t===`NotReadableError`||t===`AbortError`?`busy`:`denied`}function Et(e){return!!e?.getCapabilities?.()?.torch}function Dt(e,t,n=!1){let r=(0,J.useRef)(null),[i,a]=(0,J.useState)(null),[o,s]=(0,J.useState)(null),[c,l]=(0,J.useState)(1),[u,d]=(0,J.useState)(!1),[f,p]=(0,J.useState)(!1);return(0,J.useEffect)(()=>{if(!e)return;let r=null,i=!1;s(null),a(null),d(!1),p(!1);let o={facingMode:{ideal:t},width:{ideal:2560},height:{ideal:1440}};return(async()=>{if(!navigator.mediaDevices?.getUserMedia)throw new DOMException(`no camera api`,`NotAllowedError`);try{r=await navigator.mediaDevices.getUserMedia({video:o,audio:n})}catch(e){if(!n)throw e;r=await navigator.mediaDevices.getUserMedia({video:o})}if(i){for(let e of r.getTracks())e.stop();return}a(r);let e=r.getVideoTracks()[0],t=()=>!i&&d(Et(e));t(),setTimeout(t,600);let s=await navigator.mediaDevices.enumerateDevices().catch(()=>[]);i||l(s.filter(e=>e.kind===`videoinput`).length)})().catch(e=>!i&&s(Tt(e))),()=>{i=!0;for(let e of r?.getTracks()??[])e.stop()}},[e,t,n]),(0,J.useEffect)(()=>{r.current&&i&&(r.current.srcObject=i)},[i]),{video:r,stream:i,error:o,cameras:c,torchable:u,torch:f,setTorch:async e=>{let t=i?.getVideoTracks()[0];try{await t?.applyConstraints({advanced:[{torch:e}]}),p(e)}catch{d(!1)}},mirrored:i?.getVideoTracks()[0]?.getSettings().facingMode===`user`}}function Ot({open:e,onClose:t,label:n,children:r}){let i=(0,J.useRef)(null);return(0,J.useEffect)(()=>{let t=i.current;t&&(e&&!t.open?t.showModal():!e&&t.open&&t.close())},[e]),(0,Y.jsx)(`dialog`,{ref:i,onClose:t,"aria-label":n,className:`media-sheet`,children:e?(0,Y.jsx)(`div`,{className:`flex h-full flex-col`,children:r}):null})}function kt({label:e,onClick:t,active:n,children:r}){return(0,Y.jsx)(`button`,{type:`button`,"aria-label":e,title:e,"aria-pressed":n,onClick:t,className:H(`flex size-11 shrink-0 items-center justify-center rounded-full transition`,n?`bg-white text-black`:`bg-white/12 text-white hover:bg-white/20`),children:r})}function At({title:e,onClose:t,camera:n,onFlip:r}){return(0,Y.jsx)(`div`,{className:`safe-top`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[(0,Y.jsx)(kt,{label:K(`common.close`),onClick:t,children:(0,Y.jsx)(q,{className:`size-5`})}),(0,Y.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-center font-medium text-[15px]`,children:e}),n.torchable?(0,Y.jsx)(kt,{label:K(`camera.torch`),active:n.torch,onClick:()=>void n.setTorch(!n.torch),children:n.torch?(0,Y.jsx)(Me,{className:`size-5`}):(0,Y.jsx)(Ae,{className:`size-5`})}):null,n.stream&&(n.cameras>1||v)?(0,Y.jsx)(kt,{label:K(`camera.flip`),onClick:r,children:(0,Y.jsx)(nt,{className:`size-5`})}):(0,Y.jsx)(`span`,{className:`size-11`})]})})}function jt({camera:e,asking:t,children:n,actions:r}){return(0,Y.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden`,children:[(0,Y.jsx)(`video`,{ref:e.video,autoPlay:!0,playsInline:!0,muted:!0,className:H(`absolute inset-0 size-full object-contain`,e.mirrored&&`-scale-x-100`)}),e.error?(0,Y.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-5 bg-black px-8 text-center`,children:[(0,Y.jsx)(`p`,{className:`max-w-sm text-[15px] text-white/85 leading-relaxed`,children:K(`camera.${e.error}`)}),r]}):e.stream?n:(0,Y.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-4 px-8 text-center text-white/75`,children:[(0,Y.jsx)(V,{}),(0,Y.jsx)(`p`,{className:`max-w-xs text-[14px] leading-relaxed`,children:t})]})]})}var Mt=30;function Nt(){if(typeof MediaRecorder<`u`)return[`video/mp4;codecs=avc1.42E01E,mp4a.40.2`,`video/mp4`,`video/webm;codecs=vp9,opus`,`video/webm;codecs=vp8,opus`,`video/webm`].find(e=>MediaRecorder.isTypeSupported(e))}var Pt=!!Nt();function Ft({open:e,multiple:t,video:n,onClose:r,onCapture:i,onNative:a}){let[o,s]=(0,J.useState)(`environment`),[c,l]=(0,J.useState)(`photo`),[u,d]=(0,J.useState)(0),[f,p]=(0,J.useState)(!1),[m,h]=(0,J.useState)(null),g=(0,J.useRef)(null),_=Dt(e,o,c===`video`);(0,J.useEffect)(()=>{e&&(d(0),l(`photo`),h(null))},[e]);let y=async e=>{p(!0);try{await i(e),d(e=>e+1),t||r()}finally{p(!1)}},b=async()=>{let e=_.video.current;if(!e?.videoWidth)return;let t=document.createElement(`canvas`);t.width=e.videoWidth,t.height=e.videoHeight,t.getContext(`2d`)?.drawImage(e,0,0);let n=await new Promise(e=>t.toBlob(e,`image/jpeg`,.9));n&&await y(new File([n],`foto-${wt()}.jpg`,{type:`image/jpeg`}))},x=()=>{g.current?.state===`recording`&&g.current.stop()},S=()=>{let e=Nt();if(!_.stream||!e)return;let t=[],n=new MediaRecorder(_.stream,{mimeType:e,videoBitsPerSecond:25e5,audioBitsPerSecond:96e3});n.ondataavailable=e=>e.data.size&&t.push(e.data),n.onstop=()=>{h(null),g.current=null;let n=e.split(`;`)[0];if(t.length){let e=n===`video/mp4`?`mp4`:`webm`;y(new File(t,`video-${wt()}.${e}`,{type:n}))}},g.current=n,n.start(1e3),h(0)};(0,J.useEffect)(()=>{if(m===null)return;if(m>=Mt){g.current?.state===`recording`&&g.current.stop();return}let e=setTimeout(()=>h(e=>e===null?null:e+1),1e3);return()=>clearTimeout(e)},[m]),(0,J.useEffect)(()=>{!e&&g.current&&(g.current.onstop=null,g.current.stop(),g.current=null)},[e]);let C=e=>`0:${String(e).padStart(2,`0`)}`;return(0,Y.jsxs)(Ot,{open:e,onClose:r,label:K(`camera.title`),children:[(0,Y.jsx)(At,{title:m===null?u?K(`camera.taken`,{n:u}):K(`camera.title`):`${C(m)} / ${C(Mt)}`,onClose:r,camera:_,onFlip:()=>s(e=>e===`environment`?`user`:`environment`)}),(0,Y.jsx)(jt,{camera:_,asking:K(`camera.asking`),actions:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[a?(0,Y.jsxs)(Q,{onClick:()=>{r(),a()},children:[(0,Y.jsx)(be,{className:`size-4`}),` `,K(v?`camera.native`:`camera.pick`)]}):null,(0,Y.jsx)(Q,{quiet:!0,onClick:r,children:K(`common.close`)})]})}),(0,Y.jsxs)(`div`,{className:H(`safe-bottom px-4 pt-3`,_.error&&`invisible`),children:[n&&Pt&&m===null?(0,Y.jsx)(`div`,{className:`mb-3 flex justify-center gap-1 text-[13px]`,children:[`photo`,`video`].map(e=>(0,Y.jsx)(`button`,{type:`button`,"aria-pressed":c===e,onClick:()=>l(e),className:H(`h-9 rounded-full px-4 font-medium transition`,c===e?`bg-white text-black`:`text-white/70 hover:text-white`),children:K(e===`photo`?`camera.photo`:`camera.video`)},e))}):null,(0,Y.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto_1fr] items-center gap-3`,children:[(0,Y.jsx)(`span`,{className:`text-[13px] text-white/70 leading-snug`,children:m===null?c===`video`?K(`camera.clipHint`,{s:Mt}):K(t?`camera.hintMany`:`camera.hint`):K(`camera.recording`)}),(0,Y.jsx)(`button`,{type:`button`,"aria-label":K(c===`photo`?`camera.shoot`:m===null?`camera.record`:`camera.stop`),disabled:!_.stream||f,onClick:()=>c===`photo`?void b():m===null?S():x(),className:`flex size-[72px] items-center justify-center rounded-full border-4 border-white transition active:scale-95 disabled:opacity-40`,children:f?(0,Y.jsx)(V,{className:`text-white`}):c===`photo`?(0,Y.jsx)(`span`,{className:`size-[54px] rounded-full bg-white`}):m===null?(0,Y.jsx)(`span`,{className:`flex size-[54px] items-center justify-center rounded-full bg-[#e5484d]`,children:(0,Y.jsx)(ne,{className:`size-6 text-white`})}):(0,Y.jsx)(`span`,{className:`size-7 rounded-md bg-[#e5484d]`})}),(0,Y.jsx)(`div`,{className:`flex justify-end`,children:t&&u&&m===null?(0,Y.jsxs)(Q,{onClick:r,children:[(0,Y.jsx)(N,{className:`size-4`}),` `,K(`camera.done`)]}):null})]})]})]})}function Q({onClick:e,quiet:t,children:n}){return(0,Y.jsx)(`button`,{type:`button`,onClick:e,className:H(`inline-flex h-11 items-center justify-center gap-2 rounded-full px-5 font-medium text-[14px] transition`,t?`text-white/75 hover:text-white`:`bg-white text-black hover:bg-white/90`),children:n})}var It=25,Lt=9e3;function Rt(e){return e.code===e.PERMISSION_DENIED?`denied`:e.code===e.TIMEOUT?`timeout`:`unavailable`}function zt({value:e,runId:t,placeholder:n,onChange:r,onBusy:i}){let o=re(e)?e:null,[s,c]=(0,J.useState)(!1),[l,u]=(0,J.useState)(null),d=(0,J.useRef)(null),f=(0,J.useRef)(!!o?.label),p=(0,J.useRef)(o);p.current=o;let m=o?.lat!==void 0&&o.lng!==void 0,h=typeof navigator<`u`&&`geolocation`in navigator,g=()=>{d.current!==null&&(navigator.geolocation.clearWatch(d.current),d.current=null),c(!1),i?.(!1)};(0,J.useEffect)(()=>()=>{d.current!==null&&navigator.geolocation.clearWatch(d.current)},[]);let _=async(e,n)=>{try{let{label:i}=await a.post(`/api/runs/${t}/geocode`,{lat:e,lng:n,language:z}),o=p.current;i&&!f.current&&o?.lat===e&&o.lng===n&&r({...o,label:i})}catch{}},v=()=>{u(null),c(!0),i?.(!0);let e=Date.now(),t=1/0;d.current=navigator.geolocation.watchPosition(n=>{let{latitude:i,longitude:a,accuracy:o}=n.coords;if(o<t){t=o;let e=Math.round(i*1e6)/1e6,n=Math.round(a*1e6)/1e6,s=f.current?p.current?.label:void 0,c={lat:e,lng:n,accuracy:Math.round(o),...s?{label:s}:{}};p.current=c,r(c)}if(t<=It||Date.now()-e>Lt){g();let e=p.current;e?.lat!==void 0&&e.lng!==void 0&&_(e.lat,e.lng)}},e=>{g(),t===1/0&&u(Rt(e))},{enableHighAccuracy:!0,timeout:15e3,maximumAge:1e4})},y=e=>{f.current=e.trim().length>0;let t={...m?o:{},label:e};r(m||e.trim()?t:void 0)};return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[m?(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl bg-card p-3 ring-1 ring-input`,children:[(0,Y.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-full bg-moss-tint text-moss`,children:(0,Y.jsx)(We,{className:`size-5`})}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`div`,{className:`truncate font-medium text-[15px] tabular-nums`,children:[o.lat?.toFixed(5),`, `,o.lng?.toFixed(5)]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 text-[13px] text-ink-3`,children:[(0,Y.jsx)(`span`,{children:s?K(`location.refining`):o.accuracy?K(`location.accuracy`,{m:o.accuracy}):null}),(0,Y.jsxs)(`a`,{href:`https://www.openstreetmap.org/?mlat=${o.lat}&mlon=${o.lng}#map=17/${o.lat}/${o.lng}`,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 underline-offset-2 hover:text-ink hover:underline coarse:-my-3 coarse:min-h-11 coarse:min-w-11`,children:[K(`location.map`),` `,(0,Y.jsx)(I,{className:`size-3`})]})]})]}),(0,Y.jsx)(U,{label:K(`location.remove`),onClick:()=>{g(),f.current=!1,r(void 0)},children:(0,Y.jsx)(q,{className:`size-4`})})]}):h?(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(G,{variant:`secondary`,size:`lg`,busy:s,onClick:v,className:`w-full sm:w-auto`,children:[s?null:(0,Y.jsx)(Be,{className:`size-4`}),K(s?`location.locating`:`location.use`)]}),l?(0,Y.jsx)(`p`,{className:`mt-2 rounded-lg bg-amber-tint px-3 py-2 text-[13px] text-ink-2 leading-relaxed`,children:K(`location.${l}`)}):(0,Y.jsx)(`p`,{className:`mt-2 text-[13px] text-ink-3 leading-relaxed`,children:K(`location.why`)})]}):null,(0,Y.jsx)(W,{value:o?.label??``,placeholder:n??K(m?`location.label`:`location.manual`),autoComplete:`street-address`,enterKeyHint:`done`,"aria-label":K(`location.manual`),onChange:e=>y(e.target.value)})]})}var Bt=null;function Vt(){return Bt??=(async()=>{let e=window.BarcodeDetector;if(e)try{let t=await e.getSupportedFormats();if(t.includes(`qr_code`)){let n=new e({formats:t});return{qrOnly:!1,detect:async e=>(await n.detect(e))[0]?.rawValue||null}}}catch{}let{default:t}=await s(async()=>{let{default:e}=await import(`./qr-scanner.min-C_UI0gH-.js`);return{default:e}},__vite__mapDeps([0,1])),n=t.createQrEngine();return{qrOnly:!0,detect:async e=>{try{return(await t.scanImage(e,{qrEngine:n,returnDetailedScanResult:!0})).data||null}catch{return null}}}})(),Bt}function Ht({open:e,onClose:t,onResult:n}){let r=(0,J.useRef)(n);r.current=n;let i=(0,J.useRef)(t);return i.current=t,(0,J.useEffect)(()=>{e&&S(`scan`).then(e=>{e&&r.current(e)}).catch(()=>void 0).finally(()=>i.current())},[e]),null}function Ut(e){return x(`scan`)?(0,Y.jsx)(Ht,{...e}):(0,Y.jsx)(Wt,{...e})}function Wt({open:e,onClose:t,onResult:n}){let[r,i]=(0,J.useState)(`environment`),[a,o]=(0,J.useState)(!1),[s,c]=(0,J.useState)(!1),l=(0,J.useRef)(null),u=Dt(e,r),d=(0,J.useRef)(n);d.current=n;let f=(0,J.useRef)(t);f.current=t,(0,J.useEffect)(()=>{e&&(c(!1),Vt().then(e=>o(e.qrOnly)))},[e]),(0,J.useEffect)(()=>{if(!e||!u.stream)return;let t=!1,n,r=async()=>{let e=u.video.current;if(!t&&e&&e.readyState>=2&&e.videoWidth){let n=await(await Vt()).detect(e).catch(()=>null);if(n&&!t){navigator.vibrate?.(60),d.current(n),f.current();return}}t||(n=setTimeout(r,200))};return r(),()=>{t=!0,clearTimeout(n)}},[e,u.stream,u.video]);let p=async e=>{if(!e)return;c(!1);let r=await createImageBitmap(e).catch(()=>null),i=r?await(await Vt()).detect(r).catch(()=>null):null;i?(n(i),t()):c(!0)};return(0,Y.jsxs)(Ot,{open:e,onClose:t,label:K(`scan.title`),children:[(0,Y.jsx)(At,{title:K(`scan.title`),onClose:t,camera:u,onFlip:()=>i(e=>e===`environment`?`user`:`environment`)}),(0,Y.jsx)(jt,{camera:u,asking:K(`scan.asking`),actions:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsxs)(Q,{onClick:()=>l.current?.click(),children:[(0,Y.jsx)(Re,{className:`size-4`}),` `,K(`scan.fromPhoto`)]}),(0,Y.jsx)(Q,{quiet:!0,onClick:t,children:K(`scan.typeInstead`)})]}),children:(0,Y.jsx)(`div`,{className:`pointer-events-none absolute inset-0 flex items-center justify-center`,children:(0,Y.jsx)(`div`,{className:`aspect-square w-[min(68%,320px)] rounded-3xl border-2 border-white/90 shadow-[0_0_0_100vmax_rgb(0_0_0/0.35)]`})})}),(0,Y.jsxs)(`div`,{className:`safe-bottom flex flex-col items-center gap-3 px-5 pt-3 text-center`,children:[(0,Y.jsx)(`p`,{className:`text-[13px] text-white/75 leading-snug`,children:K(s?`scan.miss`:a?`scan.hintQr`:`scan.hint`)}),u.stream?(0,Y.jsxs)(Q,{quiet:!0,onClick:()=>l.current?.click(),children:[(0,Y.jsx)(Re,{className:`size-4`}),` `,K(`scan.fromPhoto`)]}):null]}),(0,Y.jsx)(`input`,{ref:l,type:`file`,hidden:!0,accept:`image/*`,onChange:e=>{p(e.target.files?.[0]),e.target.value=``}})]})}var Gt=`#1d1a17`,Kt={width:1200,height:480};function qt(e,t,n,r,i){e.lineCap=`round`,e.lineJoin=`round`,e.strokeStyle=Gt,e.fillStyle=Gt,e.lineWidth=i;for(let a of t){if(a.length===1){e.beginPath(),e.arc(a[0].x*n,a[0].y*r,i/2,0,Math.PI*2),e.fill();continue}e.beginPath(),e.moveTo(a[0].x*n,a[0].y*r);for(let t=1;t<a.length-1;t++){let i=a[t],o=a[t+1];e.quadraticCurveTo(i.x*n,i.y*r,(i.x+o.x)/2*n,(i.y+o.y)/2*r)}let t=a[a.length-1];e.lineTo(t.x*n,t.y*r),e.stroke()}}function Jt({strokes:e,onStrokes:t}){let n=(0,J.useRef)(null),r=(0,J.useRef)(null),i=(0,J.useRef)(e);i.current=e;let a=()=>{let e=n.current,t=e?.getContext(`2d`);if(!e||!t)return;let a=window.devicePixelRatio||1,o=Math.round(e.clientWidth*a),s=Math.round(e.clientHeight*a);(e.width!==o||e.height!==s)&&(e.width=o,e.height=s),t.clearRect(0,0,o,s),qt(t,r.current?[...i.current,r.current]:i.current,o,s,2.4*a)};(0,J.useEffect)(()=>{a();let e=n.current;if(!e)return;let t=new ResizeObserver(a);return t.observe(e),()=>t.disconnect()},[e]);let o=e=>{let t=e.currentTarget.getBoundingClientRect();return{x:Math.min(1,Math.max(0,(e.clientX-t.left)/t.width)),y:Math.min(1,Math.max(0,(e.clientY-t.top)/t.height))}};return(0,Y.jsxs)(`div`,{className:`relative overflow-hidden rounded-xl bg-white ring-1 ring-input`,children:[(0,Y.jsx)(`canvas`,{ref:n,"aria-label":K(`sign.pad`),className:`block aspect-[5/2] w-full cursor-crosshair touch-none select-none`,onPointerDown:e=>{e.currentTarget.setPointerCapture(e.pointerId),r.current=[o(e)],a()},onPointerMove:e=>{r.current&&(r.current.push(o(e)),a())},onPointerUp:()=>{if(r.current){let e=r.current;r.current=null,t([...i.current,e])}},onPointerCancel:()=>{r.current=null,a()}}),(0,Y.jsx)(`div`,{className:`pointer-events-none absolute inset-x-6 bottom-[22%] border-[#1d1a17]/25 border-b`}),e.length?null:(0,Y.jsx)(`div`,{className:`pointer-events-none absolute inset-0 flex items-center justify-center text-[#1d1a17]/40 text-[14px]`,children:K(`sign.hint`)})]})}async function Yt(e){let t=document.createElement(`canvas`);t.width=Kt.width,t.height=Kt.height;let n=t.getContext(`2d`);if(!n)return null;qt(n,e,Kt.width,Kt.height,7);let r=await new Promise(e=>t.toBlob(e,`image/png`));return r?new File([r],`unterschrift.png`,{type:`image/png`}):null}function Xt({label:e,value:t,runId:n,onChange:i}){let[o,s]=(0,J.useState)(!1),[c,l]=(0,J.useState)([]),[u,d]=(0,J.useState)(!1),[f,p]=(0,J.useState)(null),m=typeof t==`string`&&t?t:null,h=async()=>{d(!0),p(null);try{let e=await Yt(c);if(!e)return;i((await a.upload(`/api/runs/${n}/uploads`,e)).id),s(!1)}catch(e){p(e.message)}finally{d(!1)}};return(0,Y.jsxs)(`div`,{children:[m?(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl bg-card p-2 ring-1 ring-input`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:()=>{l([]),s(!0)},className:`min-w-0 flex-1 rounded-lg bg-white px-3`,"aria-label":K(`sign.again`),children:(0,Y.jsx)(`img`,{src:r(`/api/runs/${n}/assets/${m}`),alt:e,className:`mx-auto h-20 object-contain`})}),(0,Y.jsx)(U,{label:K(`sign.remove`),onClick:()=>i(void 0),children:(0,Y.jsx)(q,{className:`size-4`})})]}):(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{l([]),s(!0)},className:`flex w-full flex-col items-center justify-center gap-2 rounded-xl border border-input border-dashed bg-card px-4 py-7 text-[14px] text-ink-3 transition hover:border-ember hover:text-ink`,children:[(0,Y.jsx)(te,{className:`size-6`}),K(`sign.open`)]}),(0,Y.jsxs)(se,{open:o,onClose:()=>s(!1),title:e,wide:!0,children:[(0,Y.jsx)(Jt,{strokes:c,onStrokes:l}),f?(0,Y.jsx)(`p`,{className:`mt-2 text-[13px] text-rose`,children:f}):null,(0,Y.jsxs)(`div`,{className:`mt-5 flex items-center justify-between gap-3`,children:[(0,Y.jsxs)(G,{variant:`ghost`,disabled:!c.length||u,onClick:()=>l([]),children:[(0,Y.jsx)(Ee,{className:`size-4`}),` `,K(`sign.clear`)]}),(0,Y.jsx)(G,{busy:u,disabled:!c.length,onClick:()=>void h(),children:K(`sign.accept`)})]})]})]})}function Zt({runId:e,connectionId:t,connector:n,onCancel:r}){let[i,o]=(0,J.useState)({}),[s,c]=(0,J.useState)(!1),[l,u]=(0,J.useState)(null),d=async()=>{c(!0),u(null);try{await a.post(`/api/runs/${e}/connections/${t}/credentials/${n.id}`,{values:i})}catch(e){u(e.message)}finally{c(!1)}};return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl bg-card p-4 ring-1 ring-input`,children:[(n.fields??[]).map(e=>(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(B,{children:e.label}),(0,Y.jsx)(W,{type:e.secret?`password`:`text`,autoComplete:`off`,value:i[e.key]??``,placeholder:e.placeholder,onChange:t=>o(n=>({...n,[e.key]:t.target.value})),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),d())}})]},e.key)),n.hint?(0,Y.jsx)(`p`,{className:`text-[13px] text-ink-3`,children:n.hint}):null,l?(0,Y.jsx)(`p`,{className:`text-[13px] text-rose`,children:l}):null,(0,Y.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Y.jsx)(G,{variant:`ghost`,size:`sm`,onClick:r,children:K(`common.cancel`)}),(0,Y.jsx)(G,{size:`sm`,busy:s,onClick:()=>void d(),children:K(`connect.go`)})]})]})}function Qt({runId:e,connection:t}){let[n,r]=(0,J.useState)(null),[i,o]=(0,J.useState)(null),[s,c]=(0,J.useState)(null);if(!t)return null;if(t.account){let n=t.connectors.find(e=>e.id===t.account?.connector)?.name??``;return(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl bg-card p-3 ring-1 ring-input`,children:[(0,Y.jsx)(`div`,{className:`flex size-10 items-center justify-center rounded-full bg-moss-tint text-moss`,children:(0,Y.jsx)(N,{className:`size-5`})}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`div`,{className:`truncate font-medium text-[15px]`,children:t.account.label}),(0,Y.jsx)(`div`,{className:`text-[13px] text-ink-3`,children:K(`connect.connected`,{name:n})})]}),(0,Y.jsx)(U,{label:K(`connect.disconnect`),onClick:()=>void a.del(`/api/runs/${e}/connections/${t.id}`),children:(0,Y.jsx)(ot,{className:`size-4`})})]})}let l=async n=>{if(c(null),o(null),x(`signIn`)){try{let{url:r}=await a.post(`/api/runs/${e}/connections/${t.id}/oauth/${n.id}`);await S(`signIn`,{url:r})}catch(e){c(e.message)}return}let r=window.open(`about:blank`,`wizard-connect`,`width=540,height=700`);try{let{url:i}=await a.post(`/api/runs/${e}/connections/${t.id}/oauth/${n.id}`);r?r.location.replace(i):o(i)}catch(e){r?.close(),c(e.message)}},u=t.connectors.find(e=>e.id===n);return t.connectors.length?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t.connectors.map(e=>(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>e.auth===`oauth2`?void l(e):r(n===e.id?null:e.id),className:H(`inline-flex h-11 items-center gap-2 rounded-full px-4 font-medium text-[14px] ring-1 transition`,n===e.id?`bg-ember-veil text-ink ring-ember`:`bg-card text-ink-2 ring-input hover:text-ink hover:ring-ember`),children:[(0,Y.jsx)(h,{className:`size-4`}),` `,e.name]},e.id))}),u?(0,Y.jsx)(Zt,{runId:e,connectionId:t.id,connector:u,onCancel:()=>r(null)}):null,i?(0,Y.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,className:`text-[14px] text-ember underline`,children:K(`connect.openLink`)}):null,s?(0,Y.jsx)(`p`,{className:`text-[13px] text-rose`,children:s}):null]}):(0,Y.jsx)(`p`,{className:`text-[14px] text-ink-3`,children:K(`connect.none`)})}function $t(e){return e==null?``:Array.isArray(e)?e.join(`, `):String(e)}function en(e,t){if(t.trim()===``)return null;if(e.type===`number`){let e=Number(t.replace(/\s/g,``).replace(`,`,`.`));return Number.isFinite(e)?e:t}return e.type===`boolean`?t===`true`:t}function $({column:e,value:t,boxed:n,onCommit:r}){let[i,a]=(0,J.useState)($t(t));(0,J.useEffect)(()=>a($t(t)),[t]);let o=H(`w-full min-w-0 rounded-md border border-transparent px-2 text-[13px] outline-none focus:border-ember focus:bg-card`,n?`h-11 bg-paper-2`:`h-9 bg-transparent hover:bg-paper-2 coarse:h-11`);return e.type===`boolean`?(0,Y.jsx)(`label`,{className:`flex size-9 cursor-pointer items-center justify-center coarse:size-11`,children:(0,Y.jsx)(`input`,{type:`checkbox`,"aria-label":e.name,checked:t===!0,onChange:e=>r(e.target.checked),className:`size-4 accent-[var(--ember)] coarse:size-6`})}):e.type===`select`&&!e.format.multiple&&!e.format.allowCustom?(0,Y.jsxs)(`select`,{value:i,onChange:e=>r(e.target.value||null),className:o,children:[(0,Y.jsx)(`option`,{value:``}),e.format.options.map(e=>(0,Y.jsx)(`option`,{value:e.id,children:e.label},e.id))]}):(0,Y.jsx)(`input`,{"aria-label":e.name,type:e.type===`date`&&e.format.kind===`date`?`date`:`text`,inputMode:e.type===`number`?`decimal`:void 0,enterKeyHint:`done`,autoComplete:`off`,value:i,onChange:e=>a(e.target.value),onBlur:()=>{i!==$t(t)&&r(en(e,i))},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.target.blur())},className:H(o,e.type===`number`&&`text-right tabular-nums`)})}function tn({runId:e,list:t,editable:n}){let{def:r,rows:i}=t,[s,c]=(0,J.useState)(null),[l,u]=(0,J.useState)({}),d=`/api/runs/${e}/lists/${r.id}/rows`,f=async e=>{c(null);try{await e()}catch(e){c(e instanceof o?e.message:String(e))}},p=()=>f(async()=>{await a.post(d,{cells:l}),u({})}),m=Object.values(l).some(e=>e!=null&&e!==``);if(!i.length&&!n)return(0,Y.jsx)(`p`,{className:`text-[14px] text-ink-3`,children:K(`list.empty`)});let h=(e,t)=>t===0||e.type===`text`&&e.format?.style===`multiline`,g=(e,t,n)=>void f(()=>a.patch(`${d}/${e}`,{cells:{[t]:n}}));return(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 sm:hidden`,children:[i.map(e=>(0,Y.jsxs)(`div`,{className:`rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,Y.jsx)(`div`,{className:`grid grid-cols-2 gap-x-2 gap-y-1.5`,children:r.columns.map((t,r)=>(0,Y.jsxs)(`div`,{className:H(`min-w-0`,h(t,r)&&`col-span-2`),children:[(0,Y.jsx)(`div`,{className:`px-1 pb-0.5 text-[11px] text-ink-3`,children:t.name}),n?(0,Y.jsx)($,{boxed:!0,column:t,value:e.cells[t.id],onCommit:n=>g(e.id,t.id,n)}):(0,Y.jsx)(`div`,{className:H(`break-words px-1 text-[14px]`,t.type===`number`&&`tabular-nums`),children:xt(t,e.cells[t.id],z)||`—`})]},t.id))}),n?(0,Y.jsx)(`div`,{className:`mt-1 flex justify-end`,children:(0,Y.jsx)(U,{label:K(`list.delete`),onClick:()=>void f(()=>a.del(`${d}/${e.id}`)),children:(0,Y.jsx)(M,{className:`size-4`})})}):null]},e.id)),n?(0,Y.jsxs)(`div`,{className:`rounded-lg border border-input border-dashed p-2`,children:[(0,Y.jsx)(`div`,{className:`grid grid-cols-2 gap-x-2 gap-y-1.5`,children:r.columns.map((e,t)=>(0,Y.jsxs)(`div`,{className:H(`min-w-0`,h(e,t)&&`col-span-2`),children:[(0,Y.jsx)(`div`,{className:`px-1 pb-0.5 text-[11px] text-ink-3`,children:e.name}),(0,Y.jsx)($,{boxed:!0,column:e,value:l[e.id],onCommit:t=>u(n=>({...n,[e.id]:t}))})]},e.id))}),(0,Y.jsx)(`div`,{className:`mt-2 flex justify-end`,children:(0,Y.jsxs)(G,{variant:`secondary`,size:`sm`,onClick:()=>m?void p():void 0,children:[(0,Y.jsx)(F,{className:`size-4`}),` `,K(`run.addRow`)]})})]}):null]}),(0,Y.jsx)(`div`,{className:`hidden overflow-x-auto rounded-lg ring-1 ring-border-soft sm:block`,children:(0,Y.jsxs)(`table`,{className:`w-full text-[13px]`,children:[(0,Y.jsx)(`thead`,{className:`bg-paper-2 text-ink-2`,children:(0,Y.jsxs)(`tr`,{children:[r.columns.map(e=>(0,Y.jsx)(`th`,{className:`whitespace-nowrap px-3 py-2 text-left font-medium`,children:e.name},e.id)),n?(0,Y.jsx)(`th`,{className:`w-10`}):null]})}),(0,Y.jsxs)(`tbody`,{children:[i.map(e=>(0,Y.jsxs)(`tr`,{className:`border-border-soft border-t align-top`,children:[r.columns.map(t=>(0,Y.jsx)(`td`,{className:H(`min-w-[7.5rem]`,n?`px-1 py-0.5`:`px-3 py-2`),children:n?(0,Y.jsx)($,{column:t,value:e.cells[t.id],onCommit:n=>g(e.id,t.id,n)}):(0,Y.jsx)(`span`,{className:H(t.type===`number`&&`tabular-nums`),children:xt(t,e.cells[t.id],z)})},t.id)),n?(0,Y.jsx)(`td`,{className:`px-1 py-0.5`,children:(0,Y.jsx)(U,{label:K(`list.delete`),className:`size-9`,onClick:()=>void f(()=>a.del(`${d}/${e.id}`)),children:(0,Y.jsx)(M,{className:`size-3.5`})})}):null]},e.id)),n?(0,Y.jsxs)(`tr`,{className:`border-border-soft border-t bg-paper`,children:[r.columns.map(e=>(0,Y.jsx)(`td`,{className:`px-1 py-0.5`,children:(0,Y.jsx)($,{column:e,value:l[e.id],onCommit:t=>u(n=>({...n,[e.id]:t}))})},e.id)),(0,Y.jsx)(`td`,{className:`px-1 py-0.5`,children:(0,Y.jsx)(U,{label:K(`run.addRow`),className:`size-9`,onClick:()=>m?void p():void 0,children:(0,Y.jsx)(F,{className:`size-4`})})})]}):null]})]})}),s?(0,Y.jsx)(`p`,{className:`mt-2 text-[13px] text-rose`,children:s}):null]})}function nn(e,t,n){let i=t.split(`/`).map(encodeURIComponent).join(`/`);return r(`/api/runs/${e}/store/files/${i}${n?`?inline=1`:``}`)}var rn=[`bg-paper-3 text-ink-3`,`bg-moss-tint text-moss`,`bg-rose-tint text-rose`,`bg-ember-tint text-ember-strong`];function an({runId:e,list:t}){let{def:n,rows:r}=t,i=n.columns.find(e=>e.id===n.check?.file),s=n.columns.find(e=>e.id===n.check?.status),c=s?.type===`select`?s.format.options:[],l=c[0]?.id,u=e=>s?String(e.cells[s.id]??l??``):``,d=e=>!s||u(e)===l,[f,p]=(0,J.useState)(()=>(r.find(d)??r[0])?.id??null),[m,h]=(0,J.useState)(!1),[g,_]=(0,J.useState)(null),v=`/api/runs/${e}/lists/${n.id}/rows`,y=r.find(e=>e.id===f)??r[0],b=m?r.filter(e=>d(e)||e.id===y?.id):r,x=r.filter(e=>!d(e)).length,S=n.columns.filter(e=>e!==i&&e!==s),C=S.filter(e=>e.id!==n.key),w=C.find(e=>e.type===`text`)??C[0],T=C.filter(e=>e!==w),E=async(e,t)=>{_(null);try{await a.patch(`${v}/${e}`,{cells:t})}catch(e){_(e instanceof o?e.message:String(e))}},D=e=>{let t=b.findIndex(e=>e.id===y?.id),n=b[Math.min(b.length-1,Math.max(0,t+e))];n&&p(n.id)},O=async e=>{if(!y||!s)return;let t=r.findIndex(e=>e.id===y.id),n=[...r.slice(t+1),...r.slice(0,t)].find(d);await E(y.id,{[s.id]:e}),n&&e!==l&&p(n.id)},k=e=>{e.target.closest(`input, textarea, select`)||(e.key===`ArrowDown`||e.key===`ArrowUp`?(e.preventDefault(),D(e.key===`ArrowDown`?1:-1)):/^[1-9]$/.test(e.key)&&c[Number(e.key)]&&(e.preventDefault(),O(c[Number(e.key)].id)))};if(!r.length)return(0,Y.jsx)(`p`,{className:`text-[14px] text-ink-3`,children:K(`list.empty`)});let A=i&&y?String(y.cells[i.id]??``).trim():``,j=A.split(`.`).pop()?.toLowerCase()??``,M=e=>rn[Math.min(Math.max(0,c.findIndex(t=>t.id===u(e))),3)];return(0,Y.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[minmax(280px,360px)_minmax(0,1fr)]`,onKeyDown:k,children:[(0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-col`,children:[(0,Y.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[13px] text-ink-3 tabular-nums`,children:K(`check.progress`,{done:x,total:r.length})}),s?(0,Y.jsx)(`button`,{type:`button`,"aria-pressed":m,onClick:()=>h(e=>!e),className:H(`inline-flex h-8 items-center rounded-full px-3 text-[13px] ring-1 transition coarse:h-11`,m?`bg-ember-tint text-ink ring-ember`:`bg-card text-ink-2 ring-input hover:text-ink`),children:K(`check.onlyOpen`)}):null]}),(0,Y.jsx)(`ul`,{className:`flex max-h-[38vh] flex-col gap-1.5 overflow-y-auto p-0.5 pr-1 lg:max-h-[calc(100vh-15rem)]`,children:b.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>p(e.id),"aria-current":e.id===y?.id,className:H(`flex w-full items-center gap-3 rounded-lg px-3 py-2.5 text-left ring-1 transition`,e.id===y?.id?`bg-card shadow-soft ring-ember`:`bg-paper ring-border-soft hover:bg-card`),children:[(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block truncate font-medium text-[14px]`,children:w&&xt(w,e.cells[w.id],z)||`—`}),(0,Y.jsx)(`span`,{className:`block truncate text-[12px] text-ink-3 tabular-nums`,children:T.slice(0,2).map(t=>xt(t,e.cells[t.id],z)).filter(Boolean).join(` · `)})]}),s?(0,Y.jsx)(`span`,{className:H(`shrink-0 rounded-full px-2 py-0.5 font-medium text-[11px]`,M(e)),children:c.find(t=>t.id===u(e))?.label??u(e)}):null]})},e.id))})]}),y?(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[c.length>1?(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[c.slice(1).map((e,t)=>(0,Y.jsxs)(G,{size:`md`,variant:u(y)===e.id?`primary`:`secondary`,onClick:()=>void O(e.id),children:[u(y)===e.id?(0,Y.jsx)(N,{className:`size-4`}):null,e.label,(0,Y.jsx)(`kbd`,{className:`ml-1 hidden rounded bg-black/10 px-1.5 text-[11px] lg:inline`,children:t+1})]},e.id)),u(y)===l?null:(0,Y.jsx)(G,{size:`md`,variant:`ghost`,onClick:()=>void O(l??``),children:K(`check.reopen`)})]}):null,(0,Y.jsx)(`div`,{className:`overflow-hidden rounded-lg bg-paper-2 ring-1 ring-border-soft`,children:A?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 border-border-soft border-b bg-card px-3 py-2 text-[13px]`,children:[(0,Y.jsx)(L,{className:`size-3.5 shrink-0 text-ink-3`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:A.split(`/`).pop()}),(0,Y.jsx)(`a`,{href:nn(e,A,j===`pdf`),target:`_blank`,rel:`noreferrer`,className:`shrink-0 text-ink-2 underline-offset-2 hover:text-ink hover:underline`,children:K(`run.openFull`)})]}),j===`pdf`?(0,Y.jsx)(`iframe`,{title:A,src:`${nn(e,A,!0)}#toolbar=0&navpanes=0&view=FitH`,className:`h-[46vh] w-full border-0 bg-white lg:h-[calc(100vh-27rem)] lg:min-h-[360px]`},A):[`png`,`jpg`,`jpeg`,`webp`].includes(j)?(0,Y.jsx)(`div`,{className:`flex max-h-[46vh] justify-center overflow-auto bg-white lg:max-h-[calc(100vh-27rem)]`,children:(0,Y.jsx)(`img`,{src:nn(e,A,!0),alt:A,className:`max-w-full object-contain`},A)}):(0,Y.jsx)(`p`,{className:`px-4 py-10 text-center text-[14px] text-ink-3`,children:K(`check.noPreview`)})]}):(0,Y.jsx)(`p`,{className:`px-4 py-14 text-center text-[14px] text-ink-3`,children:K(`check.noFile`)})}),(0,Y.jsx)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-2 sm:grid-cols-3`,children:S.map(e=>(0,Y.jsxs)(`div`,{className:H(`min-w-0`,e.type===`text`&&e.format?.style===`multiline`&&`col-span-full`),children:[(0,Y.jsx)(`div`,{className:`px-1 pb-0.5 text-[11px] text-ink-3`,children:e.name}),(0,Y.jsx)($,{boxed:!0,column:e,value:y.cells[e.id],onCommit:t=>void E(y.id,{[e.id]:t})})]},e.id))}),g?(0,Y.jsx)(`p`,{className:`text-[13px] text-rose`,children:g}):null]}):null]})}var on={xlsx:`Excel`,csv:`CSV`,json:`JSON`,md:`Markdown`,zip:`ZIP`};function sn({runId:e,list:t}){return(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t.formats.map(n=>(0,Y.jsx)(`a`,{href:r(`/api/runs/${e}/lists/${t.def.id}/download?format=${n}`),className:`inline-flex h-9 items-center rounded-full bg-paper-2 px-3.5 font-medium text-[13px] text-ink-2 transition hover:bg-paper-3 hover:text-ink coarse:h-11 coarse:px-4`,children:on[n]??n},n))})}function cn(e){return e>1e6?`${(e/1e6).toFixed(1)} MB`:`${Math.max(1,Math.round(e/1e3))} KB`}function ln({runId:e}){let[t,n]=(0,J.useState)(!1),[i,o]=(0,J.useState)(null),[s,c]=(0,J.useState)(!1);(0,J.useEffect)(()=>{t&&(c(!1),a.get(`/api/runs/${e}/store`).then(o))},[t,e]);let l=i&&!i.files.length&&!i.connections.length&&!i.keepsSignIns&&i.lists.every(e=>!e.rows);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>n(!0),className:`inline-flex items-center gap-1.5 text-[13px] text-ink-4 transition hover:text-ink-2 coarse:min-h-11`,children:[(0,Y.jsx)(we,{className:`size-3.5`}),` `,K(`store.open`)]}),(0,Y.jsx)(se,{open:t,onClose:()=>n(!1),title:K(`store.title`),wide:!0,children:i?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-5 text-[14px]`,children:[(0,Y.jsx)(`p`,{className:`text-ink-3`,children:K(`store.explain`)}),l?(0,Y.jsx)(`p`,{className:`text-ink-2`,children:K(`store.empty`)}):null,i.lists.some(e=>e.rows)?(0,Y.jsx)(`ul`,{className:`flex flex-col gap-1`,children:i.lists.filter(e=>e.rows).map(e=>(0,Y.jsxs)(`li`,{className:`flex justify-between gap-3`,children:[(0,Y.jsx)(`span`,{children:e.title}),(0,Y.jsx)(`span`,{className:`text-ink-3 tabular-nums`,children:K(`store.rows`,{n:e.rows})})]},e.id))}):null,i.connections.map(e=>(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(h,{className:`size-4 text-ink-3`}),` `,e.account?.label]},e.id)),i.keepsSignIns?(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(N,{className:`size-4 text-ink-3`}),` `,K(`store.signIns`)]}):null,i.files.length?(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`mb-1 text-ink-3`,children:K(`store.files`,{n:i.files.length,size:cn(i.files.reduce((e,t)=>e+t.size,0))})}),(0,Y.jsx)(`ul`,{className:`max-h-56 overflow-y-auto rounded-lg ring-1 ring-border-soft`,children:i.files.map(t=>(0,Y.jsx)(`li`,{className:`border-border-soft border-b last:border-0`,children:(0,Y.jsxs)(`a`,{href:r(`/api/runs/${e}/store/files/${t.path}`),className:`flex items-center gap-2 px-3 py-2 text-[13px] hover:bg-paper-2 coarse:min-h-11`,title:t.source??void 0,children:[(0,Y.jsx)(L,{className:`size-3.5 shrink-0 text-ink-3`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t.path}),(0,Y.jsx)(`span`,{className:`text-ink-4 tabular-nums`,children:cn(t.size)})]})},t.path))})]}):null,(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 pt-1`,children:[l?(0,Y.jsx)(`span`,{}):s?(0,Y.jsxs)(G,{variant:`secondary`,onClick:async()=>{await a.del(`/api/runs/${e}/store`),o(await a.get(`/api/runs/${e}/store`)),c(!1)},children:[(0,Y.jsx)(M,{className:`size-4`}),` `,K(`store.confirmDelete`)]}):(0,Y.jsxs)(G,{variant:`ghost`,onClick:()=>c(!0),children:[(0,Y.jsx)(M,{className:`size-4`}),` `,K(`store.delete`)]}),(0,Y.jsx)(G,{onClick:()=>n(!1),children:K(`common.close`)})]})]}):(0,Y.jsx)(`div`,{className:`flex justify-center py-8 text-ink-4`,children:(0,Y.jsx)(V,{})})})]})}var un=300;function dn(){if(typeof MediaRecorder<`u`)return[`audio/webm;codecs=opus`,`audio/mp4`,`audio/webm`,`audio/ogg;codecs=opus`].find(e=>MediaRecorder.isTypeSupported(e))}function fn(e){return`${Math.floor(e/60)}:${String(Math.floor(e%60)).padStart(2,`0`)}`}function pn({value:e,runId:t,onChange:n,onBusy:r}){let i=ae(e)?e:null,[o,s]=(0,J.useState)(null),[c,l]=(0,J.useState)(0),[u,d]=(0,J.useState)(!1),[f,p]=(0,J.useState)(null),[m,h]=(0,J.useState)(!1),[v,y]=(0,J.useState)(null),b=(0,J.useRef)(null),x=(0,J.useRef)(null),S=dn(),C=g&&!!S;(0,J.useEffect)(()=>()=>{b.current&&(b.current.recorder.onstop=null,b.current.stop())},[]),(0,J.useEffect)(()=>()=>{v&&URL.revokeObjectURL(v.url)},[v]);let w=async(e,i)=>{d(!0),r?.(!0),p(null);try{let r=await a.upload(`/api/runs/${t}/uploads`,e);y({asset:r.id,url:URL.createObjectURL(e)}),n({asset:r.id,...i===void 0?{}:{seconds:i}})}catch(e){p(e.message)}finally{d(!1),r?.(!1)}},T=async()=>{p(null),h(!1);let e;try{e=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0}})}catch{h(!0);return}let t=[],n=new MediaRecorder(e,{mimeType:S,audioBitsPerSecond:48e3}),i=Date.now(),a=new AudioContext,o=a.createAnalyser();o.fftSize=256,a.createMediaStreamSource(e).connect(o);let c=new Uint8Array(o.fftSize),u=0,d=()=>{o.getByteTimeDomainData(c);let e=0;for(let t of c)e=Math.max(e,Math.abs(t-128));if(l(Math.min(1,e/64)),s((Date.now()-i)/1e3),(Date.now()-i)/1e3>=un){f();return}u=requestAnimationFrame(d)},f=()=>{cancelAnimationFrame(u),n.state!==`inactive`&&n.stop();for(let t of e.getTracks())t.stop();a.close().catch(()=>void 0),b.current=null,s(null),l(0)};n.ondataavailable=e=>e.data.size&&t.push(e.data),n.onstop=()=>{let e=(n.mimeType||S||`audio/webm`).split(`;`)[0],r=e===`audio/mp4`?`m4a`:e===`audio/ogg`?`ogg`:`webm`,a=Math.max(1,Math.round((Date.now()-i)/1e3));w(new File(t,`sprachnotiz-${wt()}.${r}`,{type:e}),a)},b.current={recorder:n,stop:f},r?.(!0),n.start(1e3),u=requestAnimationFrame(d)},E=o!==null,D=(0,Y.jsxs)(G,{variant:`secondary`,onClick:()=>x.current?.click(),children:[(0,Y.jsx)(Oe,{className:`size-4`}),` `,K(`voice.pick`)]});return(0,Y.jsxs)(`div`,{children:[E?(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl bg-card p-3 ring-1 ring-ember`,children:[(0,Y.jsxs)(`span`,{className:`relative flex size-11 shrink-0 items-center justify-center`,children:[(0,Y.jsx)(`span`,{className:`absolute inset-0 rounded-full bg-rose-tint transition-transform duration-75`,style:{transform:`scale(${.7+c*.5})`}}),(0,Y.jsx)(`span`,{className:`relative size-3.5 animate-pulse-dot rounded-full bg-rose`})]}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`div`,{className:`font-medium text-[15px] tabular-nums`,children:fn(o)}),(0,Y.jsx)(`div`,{className:`text-[13px] text-ink-3`,children:o>270?K(`voice.left`,{s:Math.ceil(un-o)}):K(`voice.recording`)})]}),(0,Y.jsxs)(G,{onClick:()=>b.current?.stop(),children:[(0,Y.jsx)(_,{className:`size-3.5 fill-current`}),` `,K(`voice.stop`)]})]}):u?(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl bg-card p-4 text-[14px] text-ink-3 ring-1 ring-input`,children:[(0,Y.jsx)(V,{className:`size-4`}),` `,K(`run.uploading`)]}):i?(0,Y.jsxs)(`div`,{className:`rounded-xl bg-card p-3 ring-1 ring-input`,children:[(0,Y.jsx)(`audio`,{controls:!0,preload:`metadata`,src:v?.asset===i.asset?v.url:`/api/runs/${t}/assets/${i.asset}`,className:`h-11 w-full`}),i.transcript?(0,Y.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap px-1 text-[14px] text-ink-2 leading-relaxed`,children:i.transcript}):null,(0,Y.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center justify-between gap-2`,children:[(0,Y.jsx)(`span`,{className:`px-1 text-[13px] text-ink-3`,children:i.seconds?fn(i.seconds):null}),(0,Y.jsxs)(`div`,{className:`flex gap-1`,children:[C?(0,Y.jsxs)(G,{variant:`ghost`,size:`sm`,onClick:()=>void T(),children:[(0,Y.jsx)(Je,{className:`size-3.5`}),` `,K(`voice.again`)]}):null,(0,Y.jsx)(G,{variant:`ghost`,size:`sm`,onClick:()=>n(void 0),children:K(`voice.remove`)})]})]})]}):(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[C?(0,Y.jsxs)(G,{variant:`secondary`,size:`lg`,onClick:()=>void T(),className:`w-full sm:w-auto`,children:[(0,Y.jsx)(ee,{className:`size-4`}),` `,K(`voice.start`)]}):D,C&&m?D:null]}),m?(0,Y.jsx)(`p`,{className:`mt-2 rounded-lg bg-amber-tint px-3 py-2 text-[13px] text-ink-2 leading-relaxed`,children:K(`voice.denied`)}):(0,Y.jsx)(`p`,{className:`mt-2 text-[13px] text-ink-3 leading-relaxed`,children:K(C?`voice.why`:`voice.noRecorder`)})]}),(0,Y.jsx)(`input`,{ref:x,type:`file`,hidden:!0,accept:`audio/*`,capture:!0,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&w(t,void 0)}}),f?(0,Y.jsx)(`div`,{className:`mt-2 text-[13px] text-rose`,children:f}):null]})}function mn(e,t){try{return new Intl.NumberFormat(void 0,{style:`currency`,currency:t}).format(e)}catch{return`${e.toFixed(2)} ${t}`}}function hn({field:e,value:t,values:n,onChange:r}){let i=e.columns??[],a=Array.isArray(t)&&t.length?t:[{}],o=ie(e,a,n),s=(e,t,n)=>{r(a.map((r,i)=>i===e?{...r,[t]:n}:r))},c=i.map(e=>e.kind===`text`&&e===i[0]?`minmax(0,3fr)`:`minmax(0,1fr)`).join(` `);return(0,Y.jsxs)(`div`,{className:`rounded-xl bg-card p-2 ring-1 ring-input`,children:[(0,Y.jsx)(`div`,{className:`hidden gap-2 px-2 pt-1 pb-2 text-[12px] text-ink-3 sm:grid`,style:{gridTemplateColumns:`${c} 36px`},children:i.map(e=>(0,Y.jsx)(`div`,{className:e.kind===`text`?``:`text-right`,children:e.label},e.id))}),(0,Y.jsx)(`div`,{className:`flex flex-col gap-2`,children:a.map((e,t)=>(0,Y.jsxs)(`div`,{className:`grid grid-cols-6 gap-2 rounded-lg bg-paper p-2 sm:bg-transparent sm:p-0 sm:[grid-template-columns:var(--cols)]`,style:{"--cols":`${c} 36px`},children:[i.map((n,r)=>(0,Y.jsxs)(`label`,{className:H(`flex min-w-0 flex-col gap-1 sm:col-span-1`,r===0?`col-span-5`:i.length-1<=2?`col-span-3`:`col-span-2`),children:[(0,Y.jsx)(`span`,{className:`px-0.5 text-[11px] text-ink-3 sm:hidden`,children:n.label}),(0,Y.jsx)(`input`,{"aria-label":n.label,placeholder:n.label,inputMode:n.kind===`text`?`text`:`decimal`,autoComplete:`off`,value:String(e[n.id]??``),onChange:e=>s(t,n.id,e.target.value),className:H(`h-11 w-full min-w-0 rounded-md border border-transparent bg-paper-2 px-2.5 text-[14px] outline-none placeholder:text-transparent focus:border-focus focus:bg-card sm:placeholder:text-ink-4`,n.kind!==`text`&&`text-right tabular-nums`)})]},n.id)),(0,Y.jsx)(U,{label:K(`list.delete`),onClick:()=>r(a.filter((e,n)=>n!==t)),className:`order-first col-start-6 row-start-1 size-11 justify-self-end self-end sm:order-none sm:col-start-auto sm:row-start-auto`,children:(0,Y.jsx)(M,{className:`size-4`})})]},t))}),(0,Y.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-end justify-between gap-3 px-2 pb-1`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>r([...a,{}]),className:`inline-flex h-9 items-center gap-1.5 rounded-full px-3 text-[13px] text-ink-2 hover:bg-accent coarse:h-11`,children:[(0,Y.jsx)(F,{className:`size-4`}),` `,K(`run.addRow`)]}),(0,Y.jsxs)(`div`,{className:`text-right text-[13px] tabular-nums`,children:[(0,Y.jsxs)(`div`,{className:`text-ink-3`,children:[K(`run.net`),` `,mn(o.net,o.currency)]}),o.vatRate?(0,Y.jsxs)(`div`,{className:`text-ink-3`,children:[K(`run.vat`,{r:o.vatRate}),` `,mn(o.vat,o.currency)]}):null,(0,Y.jsxs)(`div`,{className:`font-semibold text-[15px] text-ink`,children:[K(`run.total`),` `,mn(o.gross,o.currency)]})]})]})]})}function gn(e){return!!e?.closest(`input, textarea, [contenteditable='true']`)}function _n({field:e,value:t,runId:n,onChange:i,onBusy:o}){let s=(0,J.useRef)(null),c=(0,J.useRef)(null),l=(0,J.useRef)(null),u=(0,J.useRef)(null),[f,m]=(0,J.useState)(!1),[h,_]=(0,J.useState)({}),[y,b]=(0,J.useState)(null),[x,S]=(0,J.useState)(!1),[C,w]=(0,J.useState)(!1),[T,E]=(0,J.useState)(null),D=(0,J.useRef)(null),O=e=>{D.current=e,E(e)},k=e.kind===`image`,A=!!e.multiple,j=A?e.max??30:1,M=k||!!e.camera||!!e.video,N=!k&&!!e.video,P=Array.isArray(t)?t:typeof t==`string`&&t?[t]:[],F=(0,J.useRef)(P);F.current=P;let I=P.length<j,L=async e=>{let t=(k?e.filter(e=>e.type.startsWith(`image/`)):e).sort((e,t)=>e.name.localeCompare(t.name,void 0,{numeric:!0}));if(!t.length)return;let r=j-(A?F.current.length:0);m(!0),o?.(!0),b(t.length>r&&A?K(`run.maxFiles`,{n:j}):null);try{for(let e of t.slice(0,Math.max(0,r))){let t=await Ct(e),r=await a.upload(`/api/runs/${n}/uploads`,t);_(e=>({...e,[r.id]:{name:r.name,mime:r.mime}}));let o=A?[...F.current,r.id]:r.id;F.current=A?o:[r.id],i(o)}}catch(e){b(e.message)}finally{m(!1),o?.(!1)}},ee=(0,J.useRef)(L);ee.current=L;let te=e=>{let t=P.filter(t=>t!==e);i(A?t:void 0)},re=(e,t)=>{let n=F.current.indexOf(e),r=Math.min(F.current.length-1,Math.max(0,t));if(n<0||n===r)return;let a=F.current.filter(t=>t!==e);a.splice(r,0,e),F.current=a,i(a)},ie=A&&P.length>1;(0,J.useEffect)(()=>{if(!I)return;let e=e=>{let t=Array.from(e.clipboardData?.files??[]),n=s.current;if(!t.length||!n||gn(document.activeElement))return;let r=document.querySelectorAll(`[data-upload-field]`);(n.matches(`:hover`)||n.contains(document.activeElement)||r.length===1)&&(e.preventDefault(),ee.current(t))};return document.addEventListener(`paste`,e),()=>document.removeEventListener(`paste`,e)},[I]);let R=H(`flex flex-col items-center justify-center gap-2 rounded-xl border border-input border-dashed bg-card px-3 text-[14px] text-ink-3 transition hover:border-ember hover:text-ink`,P.length?`py-4`:`py-8`);return(0,Y.jsxs)(`div`,{ref:s,"data-upload-field":``,onDragOver:e=>{I&&(e.preventDefault(),w(!0))},onDragLeave:()=>w(!1),onDrop:e=>{w(!1),I&&(e.preventDefault(),L(Array.from(e.dataTransfer.files)))},children:[P.length?(0,Y.jsx)(`div`,{className:`mb-2 flex flex-col gap-2`,children:P.map((e,t)=>{let i=h[e],a=i?.mime??(k?`image/`:``);return(0,Y.jsxs)(`div`,{"data-file-id":e,className:H(`flex items-center gap-3 rounded-xl bg-card p-2 ring-1 ring-input transition-shadow`,T===e&&`relative z-10 shadow-elevated ring-2 ring-ember`),children:[ie?(0,Y.jsxs)(`button`,{type:`button`,"aria-label":K(`run.moveFile`,{n:t+1}),title:K(`run.moveFileHint`),className:H(`-mr-1 flex h-14 w-9 shrink-0 touch-none flex-col items-center justify-center gap-0.5 rounded-lg text-ink-3 hover:bg-paper-2 hover:text-ink`,T===e?`cursor-grabbing`:`cursor-grab`),onPointerDown:t=>{try{t.currentTarget.setPointerCapture(t.pointerId)}catch{}O(e)},onPointerMove:t=>{if(D.current!==e)return;let n=document.elementFromPoint(t.clientX,t.clientY)?.closest(`[data-file-id]`),r=n?.getAttribute(`data-file-id`);r&&r!==e&&s.current?.contains(n??null)&&re(e,F.current.indexOf(r))},onPointerUp:()=>O(null),onPointerCancel:()=>O(null),onKeyDown:n=>{(n.key===`ArrowUp`||n.key===`ArrowDown`)&&(n.preventDefault(),re(e,t+(n.key===`ArrowUp`?-1:1)))},children:[(0,Y.jsx)(`span`,{className:`font-medium text-[12px] tabular-nums`,children:t+1}),(0,Y.jsx)(Pe,{className:`size-4`})]}):null,a.startsWith(`image/`)?(0,Y.jsx)(`img`,{src:r(`/api/runs/${n}/assets/${e}`),alt:``,className:`size-14 rounded-lg object-cover`}):(0,Y.jsx)(`div`,{className:`flex size-12 shrink-0 items-center justify-center rounded-lg bg-paper-2`,children:a.startsWith(`video/`)?(0,Y.jsx)(p,{className:`size-5 text-ink-3`}):(0,Y.jsx)(d,{className:`size-5 text-ink-3`})}),(0,Y.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-[14px]`,children:i?.name??`✓`}),(0,Y.jsx)(U,{label:K(`run.removeFile`),onClick:()=>te(e),children:(0,Y.jsx)(q,{className:`size-4`})})]},e)})}):null,I?(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>c.current?.click(),className:H(R,`min-w-[9rem] flex-1 px-4`,C&&`border-ember text-ink`),children:[k?(0,Y.jsx)(Ie,{className:`size-6`}):(0,Y.jsx)(d,{className:`size-6`}),f?K(`run.uploading`):P.length?K(`run.uploadMore`):K(v?`run.uploadTouch`:`run.upload`)]}),M?(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>g?S(!0):l.current?.click(),className:H(R,`w-28`),children:[(0,Y.jsx)(be,{className:`size-6`}),K(`run.camera`)]}):null,N&&!(g&&Pt)?(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>u.current?.click(),className:H(R,`w-28`),children:[(0,Y.jsx)(ne,{className:`size-6`}),K(`camera.video`)]}):null]}):null,(0,Y.jsx)(`input`,{ref:c,type:`file`,hidden:!0,multiple:A,accept:k?`image/*`:void 0,onChange:e=>{L(Array.from(e.target.files??[])),e.target.value=``}}),(0,Y.jsx)(`input`,{ref:l,type:`file`,hidden:!0,accept:`image/*`,capture:`environment`,onChange:e=>{L(Array.from(e.target.files??[])),e.target.value=``}}),N?(0,Y.jsx)(`input`,{ref:u,type:`file`,hidden:!0,accept:`video/*`,capture:`environment`,onChange:e=>{L(Array.from(e.target.files??[])),e.target.value=``}}):null,(0,Y.jsx)(Ft,{open:x,multiple:A,video:N,onClose:()=>S(!1),onCapture:e=>L([e]),onNative:()=>l.current?.click()}),A&&(e.min||e.max)?(0,Y.jsx)(`div`,{className:`mt-2 text-[13px] text-ink-3 tabular-nums`,children:e.min&&P.length<e.min?K(`run.filesMin`,{n:P.length,min:e.min}):e.max?K(`run.filesOf`,{n:P.length,max:e.max}):null}):null,y?(0,Y.jsx)(`div`,{className:`mt-2 text-[13px] text-rose`,children:y}):null]})}function vn(e){let t=`${e.id} ${e.label}`.toLowerCase();return/telefon|phone|handy|mobil(?!it)|\btel\b|rückruf/.test(t)?{type:`tel`,inputMode:`tel`,autoComplete:`tel`}:/\bplz\b|postleitzahl|postal|zip/.test(t)?{inputMode:`numeric`,autoComplete:`postal-code`}:/iban/.test(t)?{autoCapitalize:`characters`,autoCorrect:`off`,spellCheck:!1}:/vorname|first.?name/.test(t)?{autoComplete:`given-name`,autoCapitalize:`words`}:/nachname|last.?name|surname/.test(t)?{autoComplete:`family-name`,autoCapitalize:`words`}:/firma|unternehmen|company|organi[sz]ation/.test(t)?{autoComplete:`organization`,autoCapitalize:`words`}:/straße|strasse|street|anschrift|adresse|address/.test(t)?{autoComplete:`street-address`,autoCapitalize:`words`}:/\b(ort|stadt|city|town)\b/.test(t)?{autoComplete:`address-level2`,autoCapitalize:`words`}:/\bname\b|ansprechp/.test(t)?{autoComplete:`name`,autoCapitalize:`words`}:{autoCapitalize:`sentences`}}function yn({field:e,value:t,onChange:n}){let[r,i]=(0,J.useState)(!1);return(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(W,{value:t,placeholder:e.placeholder,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,onChange:e=>n(e.target.value)}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>i(!0),className:`inline-flex h-11 shrink-0 items-center gap-2 rounded-lg border border-input bg-card px-3.5 font-medium text-[14px] text-ink-2 transition hover:border-ember hover:text-ink`,children:[(0,Y.jsx)(Xe,{className:`size-4`}),` `,K(`scan.button`)]}),(0,Y.jsx)(Ut,{open:r,onClose:()=>i(!1),onResult:n})]})}function bn({field:e,value:t,values:n,runId:r,view:i,onChange:a,onBusy:o,error:s}){let c=t==null?``:String(t),l;switch(e.kind){case`textarea`:l=(0,Y.jsx)(le,{value:c,placeholder:e.placeholder,autoCapitalize:`sentences`,enterKeyHint:`enter`,onChange:e=>a(e.target.value)});break;case`number`:l=(0,Y.jsx)(W,{inputMode:`decimal`,autoComplete:`off`,value:c,placeholder:e.placeholder,onChange:e=>a(e.target.value)});break;case`select`:{let t=e.options??[];l=t.length<=5&&t.every(e=>e.length<=28)?(0,Y.jsx)(ce,{value:c,options:t,onChange:a}):(0,Y.jsx)(fe,{value:c,placeholder:`—`,onChange:a,options:t.map(e=>({value:e,label:e}))});break}case`multiselect`:l=(0,Y.jsx)(ce,{multi:!0,value:Array.isArray(t)?t:[],options:e.options??[],onChange:a});break;case`date`:l=(0,Y.jsx)(W,{type:`date`,value:c,onChange:e=>a(e.target.value),className:`w-full sm:w-56`});break;case`email`:l=(0,Y.jsx)(W,{type:`email`,inputMode:`email`,autoComplete:`email`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,value:c,placeholder:e.placeholder,onChange:e=>a(e.target.value)});break;case`url`:l=(0,Y.jsx)(W,{type:`url`,inputMode:`url`,autoComplete:`url`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,value:c,placeholder:e.placeholder??`https://`,onChange:e=>a(e.target.value)});break;case`toggle`:l=(0,Y.jsx)(de,{checked:t===!0,onChange:a,label:e.label});break;case`color`:l=(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(oe,{value:c||`#e0531b`,onChange:e=>a(e.target.value)}),(0,Y.jsx)(W,{value:c,placeholder:`#e0531b`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,onChange:e=>a(e.target.value),className:`w-36`})]});break;case`image`:case`file`:l=(0,Y.jsx)(_n,{field:e,value:t,runId:r,onChange:a,onBusy:o});break;case`items`:l=(0,Y.jsx)(hn,{field:e,value:t,values:n,onChange:a});break;case`connection`:l=(0,Y.jsx)(Qt,{runId:r,connection:i?.connections.find(t=>t.id===e.connection)});break;case`list`:{let t=i?.lists.find(t=>t.def.id===e.list);l=t?(0,Y.jsx)(tn,{runId:r,list:t,editable:!0}):null;break}case`location`:l=(0,Y.jsx)(zt,{value:t,runId:r,placeholder:e.placeholder,onChange:a,onBusy:o});break;case`audio`:l=(0,Y.jsx)(pn,{value:t,runId:r,onChange:a,onBusy:o});break;case`signature`:l=(0,Y.jsx)(Xt,{label:e.label,value:t,runId:r,onChange:a});break;default:l=e.scan?(0,Y.jsx)(yn,{field:e,value:c,onChange:a}):(0,Y.jsx)(W,{...vn(e),value:c,placeholder:e.placeholder,onChange:e=>a(e.target.value)})}return(0,Y.jsxs)(`div`,{children:[e.kind===`toggle`?(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-6`,children:[(0,Y.jsx)(B,{hint:e.help,children:e.label}),l]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(B,{hint:e.help,required:e.required,children:e.label}),l]}),s?(0,Y.jsx)(`div`,{className:`mt-1.5 text-[13px] text-rose`,children:s}):null]})}var xn=45e3;function Sn(e){let[t,n]=(0,J.useState)(null),[i,s]=(0,J.useState)(null),[c,l]=(0,J.useState)(!1),[u,d]=(0,J.useState)(!1),[f,p]=(0,J.useState)({});(0,J.useEffect)(()=>{if(n(null),l(!1),!e)return;let t=!1,i=0,s,c=null,u=Date.now(),d=()=>{t=!0,c?.close(),l(!0)},f=async()=>{try{let r=await a.get(`/api/runs/${e}`);t||n(r)}catch(e){e instanceof o&&e.status===404&&d()}},p=()=>{if(clearTimeout(s),c?.close(),t)return;let a=new EventSource(r(`/api/runs/${e}/stream`),{withCredentials:!0});c=a,u=Date.now(),a.addEventListener(`view`,e=>{i=0,u=Date.now(),n(JSON.parse(e.data))}),a.addEventListener(`ping`,()=>{u=Date.now()}),a.onerror=()=>{a.close(),!(t||c!==a)&&(c=null,f(),i=Math.min(i+1,6),s=setTimeout(p,500*2**i))}},m=()=>{t||document.visibilityState!==`visible`||(!c||c.readyState===EventSource.CLOSED||Date.now()-u>xn?(i=0,p()):f())},h=setInterval(()=>{!t&&c&&Date.now()-u>xn&&(i=0,p())},15e3);return p(),document.addEventListener(`visibilitychange`,m),window.addEventListener(`pageshow`,m),window.addEventListener(`online`,m),()=>{t=!0,clearTimeout(s),clearInterval(h),document.removeEventListener(`visibilitychange`,m),window.removeEventListener(`pageshow`,m),window.removeEventListener(`online`,m),c?.close()}},[e]);let m=(0,J.useCallback)(async(t,n)=>{if(!e)return!1;d(!0),s(null),p({});try{return await a.post(`/api/runs/${e}/${t}`,n),!0}catch(e){return e instanceof o&&e.status===422&&Array.isArray(e.body?.fields)&&p(Object.fromEntries(e.body.fields.map(e=>[e.field,e.message]))),s(e.message),!1}finally{d(!1)}},[e]);return{view:t,notFound:c,error:i,busy:u,fieldErrors:f,submitPage:(e,t)=>m(`pages/${e}`,{values:t}),accept:(e,t)=>m(`reviews/${e}`,{type:`accept`,edits:t}),regenerate:(e,t,n,r)=>m(`reviews/${e}`,{type:`regenerate`,target:t,note:n,items:r?.length?r:void 0}),back:()=>m(`back`),retry:()=>m(`retry`)}}function Cn({view:e}){let t=Math.round(Math.min(e.progress.done,e.progress.total)/Math.max(1,e.progress.total)*100);return(0,Y.jsx)(`div`,{className:`h-[3px] w-full bg-paper-2`,children:(0,Y.jsx)(`div`,{className:`h-full bg-ember transition-[width] duration-700 ease-out`,style:{width:`${t}%`}})})}function wn({title:e,description:t,kicker:n}){return(0,Y.jsxs)(`div`,{className:`mb-8`,children:[n?(0,Y.jsx)(`p`,{className:`mb-4 text-[15px] text-ink-2 leading-relaxed`,children:n}):null,(0,Y.jsx)(`h1`,{className:`font-display font-semibold text-[28px] leading-[1.15] tracking-tight sm:text-[32px]`,children:e}),t?(0,Y.jsx)(`p`,{className:`mt-2 text-[15px] text-ink-3 leading-relaxed`,children:t}):null]})}function Tn(e,t){let n={};for(let r of e.fields)n[r.id]=t.values[r.id]??t.prefill?.[r.id]??r.default??(r.kind===`multiselect`?[]:void 0);return n}function En(e){return Array.from(e.querySelectorAll(`input:not([type="hidden"], [type="file"], [type="checkbox"], [type="color"], [type="range"], [disabled]), textarea:not([disabled])`)).filter(e=>!e.closest(`dialog`)&&e.offsetParent!==null)}function Dn({view:e,run:t,step:n}){let[r,i]=(0,J.useState)(()=>Tn(n,e)),[a,o]=(0,J.useState)(new Set),s=(0,J.useRef)(null),c=e.progress.done===0,l=()=>void t.submitPage(n.id,r);return(0,J.useEffect)(()=>{if(!s.current)return;let e=En(s.current).filter(e=>e instanceof HTMLInputElement);for(let[t,n]of e.entries())(n.dataset.hint||!n.hasAttribute(`enterkeyhint`))&&(n.dataset.hint=`1`,n.setAttribute(`enterkeyhint`,t===e.length-1?`go`:`next`))}),(0,Y.jsxs)(`form`,{ref:s,className:`animate-rise`,onSubmit:e=>{e.preventDefault(),a.size||l()},onKeyDown:e=>{let t=e.target;if(e.key!==`Enter`||e.defaultPrevented||e.nativeEvent.isComposing||!(t instanceof HTMLInputElement)||t.closest(`dialog`))return;let n=En(e.currentTarget),r=n[n.indexOf(t)+1];r&&(e.preventDefault(),r.focus())},children:[(0,Y.jsx)(wn,{title:n.title,description:n.description,kicker:c?e.wizard.intro:null}),(0,Y.jsx)(`div`,{className:`flex flex-col gap-7`,children:n.fields.map(n=>(0,Y.jsx)(bn,{field:n,value:r[n.id],values:r,runId:e.id,view:e,error:t.fieldErrors[n.id],onChange:e=>i(t=>({...t,[n.id]:e})),onBusy:e=>o(t=>{if(t.has(n.id)===e)return t;let r=new Set(t);return e?r.add(n.id):r.delete(n.id),r})},n.id))}),(0,Y.jsx)(On,{view:e,run:t,sticky:!0,children:(0,Y.jsxs)(G,{type:`submit`,size:`lg`,busy:t.busy,disabled:a.size>0,children:[n.cta||K(`run.next`),` `,(0,Y.jsx)(u,{className:`size-4`})]})})]})}function On({view:e,run:t,sticky:n,children:r}){return(0,Y.jsxs)(`div`,{className:H(`mt-10 flex items-center justify-between gap-3`,n&&`action-bar`),children:[e.canBack?(0,Y.jsxs)(G,{variant:`ghost`,onClick:()=>void t.back(),disabled:t.busy,children:[(0,Y.jsx)(l,{className:`size-4`}),` `,K(`run.back`)]}):(0,Y.jsx)(`span`,{}),r]})}function kn(){let e=b(),[t,n]=(0,J.useState)(!1),r=e!==`off`;return(0,Y.jsxs)(`div`,{className:`mt-6 flex flex-col items-center gap-2`,children:[(0,Y.jsxs)(`button`,{type:`button`,"aria-pressed":r,disabled:t,onClick:async()=>{if(r){T();return}n(!0),await D(),n(!1)},className:H(`inline-flex h-11 items-center gap-2 rounded-full px-4 font-medium text-[14px] ring-1 transition`,r?`bg-ember-tint text-ink ring-ember`:`bg-card text-ink-2 ring-input hover:text-ink hover:ring-ink-4`),children:[r?(0,Y.jsx)(ge,{className:`size-4 text-ember-strong`}):(0,Y.jsx)(ve,{className:`size-4`}),K(r?`notify.on`:`notify.ask`)]}),(0,Y.jsx)(`p`,{className:`max-w-xs text-[12px] text-ink-4 leading-relaxed`,children:K(e===`off`?`notify.why`:e===`on`?`notify.onHint`:w()?`notify.blocked`:`notify.quiet`)})]})}function An({view:e,compact:t,awake:n}){let a=(0,J.useMemo)(()=>{let t=[...e.events].reverse().find(t=>t.type===`step_started`&&t.stepId===e.step?.id);return t?new Date(t.at).getTime():Date.now()},[e.events,e.step?.id]),[o,s]=(0,J.useState)(Date.now());(0,J.useEffect)(()=>{let e=setInterval(()=>s(Date.now()),1e3);return()=>clearInterval(e)},[]);let c=[...e.events].reverse().find(t=>t.type===`step_started`&&t.stepId===e.step?.id)?.message??e.step?.title??K(`run.working`),l=e.events.filter(e=>(e.type===`tool`||e.type===`info`)&&new Date(e.at).getTime()>=a-500),u=l.slice(-4),d=[...new Set(l.map(e=>e.asset).filter(e=>!!e))],f=[...l].reverse().find(e=>e.asset)?.asset;return(0,Y.jsxs)(`div`,{className:`flex animate-rise flex-col items-center pt-6 text-center`,children:[(0,Y.jsx)(i,{kind:e.wizard.avatar,size:t?130:170,fluffy:!0}),(0,Y.jsx)(`h2`,{className:`mt-4 font-display font-semibold text-[22px] tracking-tight`,children:c}),(0,Y.jsx)(`div`,{className:`mt-1 text-[13px] text-ink-4 tabular-nums`,children:K(`run.elapsed`,{s:Math.max(0,Math.round((o-a)/1e3))})}),d.length?(0,Y.jsx)(`div`,{className:`mt-5 flex max-w-full flex-wrap justify-center gap-2`,children:d.slice(-8).map(t=>(0,Y.jsx)(`img`,{src:r(`/api/runs/${e.id}/assets/${t}`),alt:``,className:H(`size-16 animate-rise rounded-lg bg-paper-2 object-cover ring-1 ring-border-soft transition sm:size-20`,t===f?`ring-2 ring-ember`:`opacity-70`)},t))}):null,(0,Y.jsx)(`div`,{className:`mt-6 flex min-h-[7rem] w-full max-w-sm flex-col gap-1.5`,children:u.map((e,t)=>(0,Y.jsxs)(`div`,{className:H(`flex items-center justify-center gap-2 text-[13px] transition-opacity`,t===u.length-1?`text-ink-2`:`text-ink-4`),children:[t===u.length-1?(0,Y.jsx)(j,{className:`size-3.5 animate-breathe text-ember`}):null,(0,Y.jsx)(`span`,{className:`truncate`,children:e.message})]},e.id))}),t?null:(0,Y.jsx)(kn,{}),n?(0,Y.jsx)(`p`,{className:`mt-3 text-[12px] text-ink-4`,children:K(`run.awake`)}):null]})}function jn(e){let t=(0,J.useRef)({running:!1,since:0,ask:null});(0,J.useEffect)(()=>{if(!e)return;let n=t.current,r=e.status===`running`,i=r?n.running?n.since:Date.now():0,a=t=>{document.visibilityState!==`visible`&&!document.title.startsWith(`● `)&&(document.title=`● ${document.title}`),k({title:e.wizard.title,body:t,tag:e.id})};r&&e.ask&&e.ask.id!==n.ask?a(K(`notify.needsYou`)):!r&&n.running&&Date.now()-n.since>8e3&&a(e.status===`failed`?K(`run.failed`):e.status===`done`?K(`notify.done`):K(`notify.next`)),t.current={running:r,since:i,ask:e.ask?.id??null}},[e]),(0,J.useEffect)(()=>{let e=()=>{document.visibilityState===`visible`&&document.title.startsWith(`● `)&&(document.title=document.title.slice(2))};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[])}function Mn({view:e,run:t,step:n}){let[r,i]=(0,J.useState)({}),[a,o]=(0,J.useState)({}),[s,c]=(0,J.useState)(``),l=e.shown.filter(e=>e.output),[d,f]=(0,J.useState)(l.length===1?l[0].step.id:null),[p,h]=(0,J.useState)({}),g=(0,J.useRef)(null),_=l.find(e=>e.step.id===d),v=_?.step.type===`generate`&&(_.output?.assets?.length??0)>1,y=()=>{_&&s.trim()&&t.regenerate(n.id,_.step.id,s.trim(),p[_.step.id])};return(0,Y.jsxs)(`div`,{className:`animate-rise`,children:[(0,Y.jsx)(wn,{title:n.title,description:n.description}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[e.shown.map(({step:t,output:s})=>{let c=!!n.edit&&t.type===`agent`&&t.output.format!==`json`;return(0,Y.jsxs)(`section`,{children:[(0,Y.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,Y.jsx)(`h3`,{className:`font-medium text-[13px] text-ink-3 uppercase tracking-[0.06em]`,children:t.title}),(0,Y.jsx)(`div`,{className:`flex items-center`,children:c&&!a[t.id]?(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>({...e,[t.id]:!0})),className:`inline-flex h-8 items-center gap-1.5 rounded-full px-3 text-[13px] text-ink-2 hover:bg-accent hover:text-ink coarse:h-11`,children:[(0,Y.jsx)(m,{className:`size-3.5`}),` `,K(`run.edit`)]}):null})]}),(0,Y.jsx)(C,{base:`/api/runs/${e.id}`,step:t,output:s,editable:c&&a[t.id],draft:r[t.id],onDraft:e=>i(n=>({...n,[t.id]:e})),picked:p[t.id],onPick:n.regenerate?e=>{f(t.id),h(n=>{let r=n[t.id]??[];return{...n,[t.id]:r.includes(e)?r.filter(t=>t!==e):[...r,e]}}),g.current?.focus()}:void 0})]},t.id)}),e.lists.map(t=>(0,Y.jsxs)(`section`,{children:[(0,Y.jsx)(`h3`,{className:`mb-2 font-medium text-[13px] text-ink-3 uppercase tracking-[0.06em]`,children:t.def.title}),t.def.check?(0,Y.jsx)(an,{runId:e.id,list:t}):(0,Y.jsx)(tn,{runId:e.id,list:t,editable:!0})]},t.def.id)),n.regenerate&&l.length?(0,Y.jsxs)(ue,{className:`p-3`,children:[l.length>1?(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 px-1 pb-2`,children:[(0,Y.jsx)(`span`,{className:`mr-1 text-[13px] text-ink-3`,children:K(`run.feedbackTarget`)}),l.map(({step:e})=>(0,Y.jsx)(`button`,{type:`button`,"aria-pressed":d===e.id,onClick:()=>{f(e.id),g.current?.focus()},className:H(`inline-flex h-8 items-center rounded-full px-3 text-[13px] ring-1 transition coarse:h-11`,d===e.id?`bg-ember-tint text-ink ring-ember`:`bg-card text-ink-2 ring-input hover:text-ink`),children:e.title},e.id))]}):null,(0,Y.jsx)(le,{ref:g,minRows:2,maxRows:8,value:s,placeholder:K(`run.feedbackPlaceholder`),onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),y())},className:`border-0 bg-transparent shadow-none focus:ring-0`}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-1 pt-1`,children:[(0,Y.jsx)(`span`,{className:`min-w-0 text-[12px] text-ink-3`,children:v?p[_.step.id]?.length?K(`run.regeneratePicked`,{n:[...p[_.step.id]].sort((e,t)=>e-t).map(e=>e+1).join(`, `)}):K(`run.regenerateAll`):!_&&s.trim()?K(`run.feedbackPick`):null}),(0,Y.jsxs)(G,{size:`sm`,variant:`secondary`,busy:t.busy,disabled:!s.trim()||!_,onClick:y,children:[(0,Y.jsx)(R,{className:`size-3.5`}),` `,K(`run.regenerateGo`)]})]})]}):null]}),(0,Y.jsx)(On,{view:e,run:t,sticky:!0,children:(0,Y.jsxs)(G,{size:`lg`,busy:t.busy,onClick:()=>void t.accept(n.id,Object.keys(r).length?r:void 0),children:[K(`run.accept`),` `,(0,Y.jsx)(u,{className:`size-4`})]})})]})}function Nn({view:e,run:t,step:n,onRestart:r}){let a=e.shown.filter(e=>e.output);return(0,Y.jsxs)(`div`,{className:`animate-rise`,children:[(0,Y.jsxs)(`div`,{className:`mb-8 flex flex-wrap items-center gap-x-4 gap-y-5`,children:[(0,Y.jsx)(i,{kind:e.wizard.avatar,size:64}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1 basis-[12rem]`,children:[(0,Y.jsx)(`h1`,{className:`text-balance font-display font-semibold text-[28px] leading-tight tracking-tight sm:text-[32px]`,children:n.title}),n.message?(0,Y.jsx)(`p`,{className:`mt-1 text-[15px] text-ink-3`,children:n.message}):null]}),e.shown.some(e=>e.output)?(0,Y.jsx)(`div`,{className:`max-sm:basis-full`,children:(0,Y.jsx)(lt,{runId:e.id,title:`${n.title} · ${e.wizard.title}`,initial:e.shareUrl?{url:e.shareUrl,expiresAt:e.expiresAt}:null})}):null]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[a.map(({step:t,output:n,formats:r,label:i})=>(0,Y.jsxs)(ue,{className:`p-4 sm:p-5`,children:[(0,Y.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-3`,children:[(0,Y.jsx)(`h3`,{className:`font-display font-semibold text-[17px]`,children:i??t.title}),(0,Y.jsx)(O,{base:`/api/runs/${e.id}`,stepId:t.id,formats:r,title:i??t.title})]}),(0,Y.jsx)(C,{base:`/api/runs/${e.id}`,step:t,output:n}),n?.assets?.some(e=>e.ai)?(0,Y.jsx)(`p`,{className:`mt-3 text-[12px] text-ink-3 leading-relaxed`,children:K(`ai.publish`)}):null]},t.id)),e.lists.map(t=>(0,Y.jsxs)(ue,{className:`p-4 sm:p-5`,children:[(0,Y.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-3`,children:[(0,Y.jsx)(`h3`,{className:`font-display font-semibold text-[17px]`,children:t.label??t.def.title}),(0,Y.jsx)(sn,{runId:e.id,list:t})]}),(0,Y.jsx)(tn,{runId:e.id,list:t,editable:!0})]},t.def.id))]}),(0,Y.jsx)(On,{view:e,run:t,children:r?(0,Y.jsxs)(G,{variant:`secondary`,onClick:r,children:[(0,Y.jsx)(Je,{className:`size-4`}),` `,K(`run.again`)]}):(0,Y.jsx)(`span`,{})})]})}function Pn({view:e,run:t}){return(0,Y.jsxs)(`div`,{className:`flex animate-rise flex-col items-center pt-8 text-center`,children:[(0,Y.jsx)(i,{kind:e.wizard.avatar,size:90}),(0,Y.jsx)(`h2`,{className:`mt-4 font-display font-semibold text-[22px]`,children:K(`run.failed`)}),(0,Y.jsx)(`p`,{className:`mt-2 max-w-md text-[15px] text-ink-3`,children:e.error}),(0,Y.jsxs)(`div`,{className:`mt-8 flex gap-3`,children:[e.canBack?(0,Y.jsxs)(G,{variant:`ghost`,onClick:()=>void t.back(),children:[(0,Y.jsx)(l,{className:`size-4`}),` `,K(`run.back`)]}):null,(0,Y.jsxs)(G,{onClick:()=>void t.retry(),busy:t.busy,children:[(0,Y.jsx)(Je,{className:`size-4`}),` `,K(`run.retry`)]})]})]})}function Fn({runId:e,compact:t,onRestart:n,onView:r,stickyProgress:i}){let a=Sn(e),{view:o}=a;(0,J.useEffect)(()=>{r?.(o)},[o,r]),y();let s=E(o?.status===`running`&&!o.ask);if(jn(o),a.notFound)return(0,Y.jsx)(`div`,{className:`py-24 text-center text-ink-3`,children:K(`run.notFound`)});if(!o)return(0,Y.jsx)(`div`,{className:`flex justify-center py-24 text-ink-4`,children:(0,Y.jsx)(V,{})});let c=o.step,l=null;if(o.status===`running`&&o.ask)l=(0,Y.jsx)(ut,{runId:o.id,ask:o.ask},o.ask.id);else if(o.status===`running`)l=(0,Y.jsx)(An,{view:o,compact:t,awake:s});else if(o.status===`failed`)l=(0,Y.jsx)(Pn,{view:o,run:a});else if(o.status===`cancelled`)l=(0,Y.jsx)(`div`,{className:`py-24 text-center text-ink-3`,children:K(`run.cancelled`)});else if(c?.type===`page`)l=(0,Y.jsx)(Dn,{view:o,run:a,step:c},c.id);else if(c?.type===`review`){let e=o.shown.map(e=>e.output?.at??``).join(`|`);l=(0,Y.jsx)(Mn,{view:o,run:a,step:c},`${c.id}:${e}`)}else c?.type===`result`&&(l=(0,Y.jsx)(Nn,{view:o,run:a,step:c,onRestart:n}));let u=c?.type===`review`&&o.status===`waiting_input`&&o.lists.some(e=>e.def.check);return(0,Y.jsxs)(`div`,{className:`flex min-h-full flex-col`,children:[i?(0,Y.jsx)(`div`,{className:`sticky top-0 z-10`,children:(0,Y.jsx)(Cn,{view:o})}):(0,Y.jsx)(Cn,{view:o}),(0,Y.jsxs)(`div`,{className:H(`safe-x mx-auto w-full flex-1`,u?`max-w-[1240px] py-8`:t?`max-w-[620px] py-8`:`max-w-[640px] py-8 sm:py-16`),children:[l,a.error&&o.status!==`failed`?(0,Y.jsx)(`div`,{className:`mt-4 rounded-lg bg-rose-tint px-4 py-3 text-[14px] text-rose`,children:a.error}):null,o.keeps&&o.status!==`running`?(0,Y.jsx)(`div`,{className:`mt-10 flex justify-center`,children:(0,Y.jsx)(ln,{runId:o.id})}):null]})]})}export{Qe as n,me as r,Fn as t};
|
|
2
|
+
import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{c as r,d as i,n as a,t as o}from"./api-BC3K8Na8.js";import{t as s}from"./preload-helper-CNEI7N0N.js";import{t as c}from"./createLucideIcon-q3MZMmnf.js";import{t as l}from"./arrow-left-hTN1VoH1.js";import{t as u}from"./arrow-right-6FyN3e7D.js";import{C as d,D as f,E as p,S as m,T as h,a as g,b as _,c as v,d as y,f as b,g as x,h as S,i as C,l as w,o as T,p as E,s as D,t as O,u as k,w as A,x as j,y as M}from"./outputs-DLmQMIUm.js";import{t as N}from"./check-CUpby_J9.js";import{n as P,t as F}from"./plus-Du-Jx8aI.js";import{t as I}from"./external-link-MAL7vJYj.js";import{n as L,t as ee}from"./mic-Bvz4mA2j.js";import{n as te,t as ne}from"./video-CjgmvRDk.js";import{d as re,f as ie,p as R,u as ae}from"./definition-DndaH5Ow.js";import{_ as z,c as B,d as V,f as oe,h as H,i as se,l as ce,m as le,n as ue,o as U,p as de,s as W,t as G,u as fe,y as K}from"./ui-Cj3EzOCA.js";import{h as q}from"./index-CJ3iuK8-.js";var pe={name:`arrow-down`,size:24,node:[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]};pe.node;var me=c(pe),he={name:`bell-ring`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M22 8c0-2.3-.8-4.3-2-6`,key:`5bb3ad`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}],[`path`,{d:`M4 2C2.8 3.7 2 5.7 2 8`,key:`tap9e0`}]]};he.node;var ge=c(he),_e={name:`bell`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]};_e.node;var ve=c(_e),ye={name:`camera`,size:24,node:[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`,key:`18u6gg`}],[`circle`,{cx:`12`,cy:`13`,r:`3`,key:`1vg3eu`}]]};ye.node;var be=c(ye),xe={name:`corner-down-left`,size:24,node:[[`path`,{d:`M20 4v7a4 4 0 0 1-4 4H4`,key:`6o5b7l`}],[`path`,{d:`m9 10-5 5 5 5`,key:`1kshq7`}]]};xe.node;var Se=c(xe),Ce={name:`database`,size:24,node:[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]};Ce.node;var we=c(Ce),Te={name:`eraser`,size:24,node:[[`path`,{d:`M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21`,key:`g5wo59`}],[`path`,{d:`m5.082 11.09 8.828 8.828`,key:`1wx5vj`}]]};Te.node;var Ee=c(Te),De={name:`file-headphone`,size:24,node:[[`path`,{d:`M4 6.835V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-.343`,key:`1vfytu`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M2 19a2 2 0 0 1 4 0v1a2 2 0 0 1-4 0v-4a6 6 0 0 1 12 0v4a2 2 0 0 1-4 0v-1a2 2 0 0 1 4 0`,key:`1etmh7`}]],aliases:[`file-audio`,`file-audio-2`]};De.node;var Oe=c(De),ke={name:`flashlight-off`,size:24,node:[[`path`,{d:`M11.652 6H18`,key:`voqkpr`}],[`path`,{d:`M12 13v1`,key:`176q98`}],[`path`,{d:`M16 16v4a2 2 0 0 1-2 2h-4a2 2 0 0 1-2-2v-8a4 4 0 0 0-.8-2.4l-.6-.8A3 3 0 0 1 6 7V6`,key:`dzyf92`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M7.649 2H17a1 1 0 0 1 1 1v4a3 3 0 0 1-.6 1.8l-.6.8a4 4 0 0 0-.55 1.007`,key:`1hvcfn`}]]};ke.node;var Ae=c(ke),je={name:`flashlight`,size:24,node:[[`path`,{d:`M12 13v1`,key:`176q98`}],[`path`,{d:`M17 2a1 1 0 0 1 1 1v4a3 3 0 0 1-.6 1.8l-.6.8A4 4 0 0 0 16 12v8a2 2 0 0 1-2 2H10a2 2 0 0 1-2-2v-8a4 4 0 0 0-.8-2.4l-.6-.8A3 3 0 0 1 6 7V3a1 1 0 0 1 1-1z`,key:`17vh7j`}],[`path`,{d:`M6 6h12`,key:`n6hhss`}]]};je.node;var Me=c(je),Ne={name:`grip-vertical`,size:24,node:[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]};Ne.node;var Pe=c(Ne),Fe={name:`image-plus`,size:24,node:[[`path`,{d:`M16 5h6`,key:`1vod17`}],[`path`,{d:`M19 2v6`,key:`4bpg5p`}],[`path`,{d:`M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5`,key:`1ue2ih`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}]]};Fe.node;var Ie=c(Fe),Le={name:`image-up`,size:24,node:[[`path`,{d:`M10.3 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10l-3.1-3.1a2 2 0 0 0-2.814.014L6 21`,key:`9csbqa`}],[`path`,{d:`m14 19.5 3-3 3 3`,key:`9vmjn0`}],[`path`,{d:`M17 22v-5.5`,key:`1aa6fl`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}]]};Le.node;var Re=c(Le),ze={name:`locate-fixed`,size:24,node:[[`line`,{x1:`2`,x2:`5`,y1:`12`,y2:`12`,key:`bvdh0s`}],[`line`,{x1:`19`,x2:`22`,y1:`12`,y2:`12`,key:`1tbv5k`}],[`line`,{x1:`12`,x2:`12`,y1:`2`,y2:`5`,key:`11lu5j`}],[`line`,{x1:`12`,x2:`12`,y1:`19`,y2:`22`,key:`x3vr5v`}],[`circle`,{cx:`12`,cy:`12`,r:`7`,key:`fim9np`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]};ze.node;var Be=c(ze),Ve={name:`lock-keyhole`,size:24,node:[[`circle`,{cx:`12`,cy:`16`,r:`1`,key:`1au0dj`}],[`rect`,{x:`3`,y:`10`,width:`18`,height:`12`,rx:`2`,key:`6s8ecr`}],[`path`,{d:`M7 10V7a5 5 0 0 1 10 0v3`,key:`1pqi11`}]]};Ve.node;var He=c(Ve),Ue={name:`map-pin`,size:24,node:[[`path`,{d:`M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0`,key:`1r0f0z`}],[`circle`,{cx:`12`,cy:`10`,r:`3`,key:`ilqhr7`}]]};Ue.node;var We=c(Ue),Ge={name:`pencil-line`,size:24,node:[[`path`,{d:`M13 21h8`,key:`1jsn5i`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]]};Ge.node;var Ke=c(Ge),qe={name:`rotate-ccw`,size:24,node:[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]};qe.node;var Je=c(qe),Ye={name:`scan-line`,size:24,node:[[`path`,{d:`M3 7V5a2 2 0 0 1 2-2h2`,key:`aa7l1z`}],[`path`,{d:`M17 3h2a2 2 0 0 1 2 2v2`,key:`4qcy5o`}],[`path`,{d:`M21 17v2a2 2 0 0 1-2 2h-2`,key:`6vwrx8`}],[`path`,{d:`M7 21H5a2 2 0 0 1-2-2v-2`,key:`ioqczr`}],[`path`,{d:`M7 12h10`,key:`b7w52i`}]]};Ye.node;var Xe=c(Ye),Ze={name:`share-2`,size:24,node:[[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}],[`circle`,{cx:`6`,cy:`12`,r:`3`,key:`w7nqdw`}],[`circle`,{cx:`18`,cy:`19`,r:`3`,key:`1xt0gg`}],[`line`,{x1:`8.59`,x2:`15.42`,y1:`13.51`,y2:`17.49`,key:`47mynk`}],[`line`,{x1:`15.41`,x2:`8.59`,y1:`6.51`,y2:`10.49`,key:`1n3mei`}]]};Ze.node;var Qe=c(Ze),$e={name:`shield-check`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]};$e.node;var et=c($e),tt={name:`switch-camera`,size:24,node:[[`path`,{d:`M11 19H4a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2h5`,key:`mtk2lu`}],[`path`,{d:`M13 5h7a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-5`,key:`120jsl`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}],[`path`,{d:`m18 22-3-3 3-3`,key:`kgdoj7`}],[`path`,{d:`m6 2 3 3-3 3`,key:`1fnbkv`}]]};tt.node;var nt=c(tt),rt={name:`triangle-alert`,size:24,node:[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`alert-triangle`]};rt.node;var it=c(rt),at={name:`unplug`,size:24,node:[[`path`,{d:`m19 5 3-3`,key:`yk6iyv`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z`,key:`1snsnr`}]]};at.node;var ot=c(at),J=e(t(),1),Y=e(n(),1);function st(e,t){let n=encodeURIComponent(e),r=encodeURIComponent(t);return[{id:`mail`,label:K(`shareRun.email`),href:`mailto:?subject=${r}&body=${r}%0A%0A${n}`},{id:`x`,label:`X`,href:`https://x.com/intent/post?text=${r}&url=${n}`},{id:`linkedin`,label:`LinkedIn`,href:`https://www.linkedin.com/sharing/share-offsite/?url=${n}`},{id:`whatsapp`,label:`WhatsApp`,href:`https://wa.me/?text=${r}%20${n}`},{id:`facebook`,label:`Facebook`,href:`https://www.facebook.com/sharer/sharer.php?u=${n}`}]}var ct={x:`𝕏`,linkedin:`in`,whatsapp:`WA`,facebook:`f`};function lt({runId:e,title:t,initial:n}){let[r,i]=(0,J.useState)(!1),[o,s]=(0,J.useState)(n),[c,l]=(0,J.useState)(!1),[u,d]=(0,J.useState)(!1),[f,p]=(0,J.useState)(null),m=async()=>{if(i(!0),!o){l(!0),p(null);try{s(await a.post(`/api/runs/${e}/share`))}catch(e){p(e.message)}finally{l(!1)}}},g=async()=>{await a.del(`/api/runs/${e}/share`),s(null),i(!1)},_=()=>{o&&(navigator.clipboard.writeText(o.url),d(!0),setTimeout(()=>d(!1),1500))},v=x(`share`)||typeof navigator<`u`&&`share`in navigator,y=o?.expiresAt?new Intl.DateTimeFormat(z,{dateStyle:`long`}).format(new Date(o.expiresAt)):null;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(G,{variant:`secondary`,onClick:()=>void m(),children:[(0,Y.jsx)(Qe,{className:`size-4`}),` `,K(`shareRun.button`)]}),(0,Y.jsx)(se,{open:r,onClose:()=>i(!1),title:K(`shareRun.title`),children:c?(0,Y.jsx)(`div`,{className:`flex justify-center py-8 text-ink-4`,children:(0,Y.jsx)(V,{})}):f?(0,Y.jsx)(`p`,{className:`rounded-lg bg-rose-tint px-3 py-2 text-[14px] text-rose`,children:f}):o?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-paper-2 p-1.5 pl-3`,children:[(0,Y.jsx)(h,{className:`size-4 shrink-0 text-ink-3`}),(0,Y.jsx)(`input`,{readOnly:!0,value:o.url,onFocus:e=>e.target.select(),"aria-label":K(`share.link`),className:`min-w-0 flex-1 bg-transparent text-[14px] outline-none coarse:h-11`}),(0,Y.jsxs)(G,{size:`sm`,onClick:_,children:[u?(0,Y.jsx)(N,{className:`size-3.5`}):(0,Y.jsx)(P,{className:`size-3.5`}),K(u?`share.copied`:`share.copy`)]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-3 gap-3 sm:grid-cols-6`,children:[st(o.url,t).map(e=>(0,Y.jsxs)(`a`,{href:e.href,target:`_blank`,rel:`noreferrer`,className:`flex flex-col items-center gap-1.5 text-[12px] text-ink-2 hover:text-ink`,children:[(0,Y.jsx)(`span`,{className:`inline-flex size-12 items-center justify-center rounded-full bg-paper-2 font-semibold text-[15px] transition hover:bg-paper-3`,children:e.id===`mail`?(0,Y.jsx)(A,{className:`size-5`}):ct[e.id]}),e.label]},e.id)),v?(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>void(x(`share`)?S(`share`,{link:o.url,title:t}):navigator.share({title:t,url:o.url})).catch(()=>void 0),className:`flex flex-col items-center gap-1.5 text-[12px] text-ink-2 hover:text-ink`,children:[(0,Y.jsx)(`span`,{className:`inline-flex size-12 items-center justify-center rounded-full bg-paper-2 transition hover:bg-paper-3`,children:(0,Y.jsx)(Qe,{className:`size-5`})}),K(`shareRun.more`)]}):null]}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-[13px] text-ink-3`,children:[(0,Y.jsx)(`span`,{children:y?K(`shareRun.until`,{date:y}):K(`shareRun.kept`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>void g(),className:`shrink-0 hover:text-rose coarse:min-h-11`,children:K(`shareRun.withdraw`)})]})]}):null})]})}function ut({runId:e,ask:t}){return t.kind===`confirm`?(0,Y.jsx)(dt,{runId:e,ask:t}):(0,Y.jsx)(ft,{runId:e,ask:t})}function dt({runId:e,ask:t}){let[n,r]=(0,J.useState)(!1),[i,o]=(0,J.useState)(!1),[s,c]=(0,J.useState)(null),l=async n=>{o(!0),c(null);try{await a.post(`/api/runs/${e}/ask/${t.id}`,n)}catch(e){c(e.message),o(!1)}},u=t.action.destructive?it:Ke;return(0,Y.jsxs)(`div`,{className:`animate-rise`,children:[(0,Y.jsxs)(`div`,{className:`mb-5 flex items-start gap-3`,children:[(0,Y.jsx)(`div`,{className:H(`flex size-10 shrink-0 items-center justify-center rounded-full`,t.action.destructive?`bg-rose-tint text-rose`:`bg-ember-tint text-ember-strong`),children:(0,Y.jsx)(u,{className:`size-5`})}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`p`,{className:`text-[13px] text-ink-3`,children:K(`ask.wants`,{service:t.service})}),(0,Y.jsx)(`h2`,{className:`font-display font-semibold text-[20px] leading-snug tracking-tight`,children:t.reason})]})]}),(0,Y.jsx)(`pre`,{className:`max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-xl bg-paper-2 p-4 text-[13px] leading-relaxed ring-1 ring-border-soft`,children:t.input}),(0,Y.jsxs)(`div`,{className:`mt-5 flex items-center gap-4`,children:[(0,Y.jsx)(de,{checked:n,onChange:r,label:K(`ask.allowRest`)}),(0,Y.jsx)(`span`,{className:`flex-1 text-[13px] text-ink-2`,children:K(`ask.allowRest`)})]}),s?(0,Y.jsx)(`div`,{className:`mt-3 rounded-lg bg-rose-tint px-4 py-3 text-[14px] text-rose`,children:s}):null,(0,Y.jsxs)(`div`,{className:`action-bar mt-6 flex items-center justify-between gap-3`,children:[(0,Y.jsx)(G,{variant:`ghost`,disabled:i,onClick:()=>void l({type:`skip`}),children:K(`ask.deny`)}),(0,Y.jsx)(G,{busy:i,onClick:()=>void l({type:`done`,remember:n}),children:K(`ask.allow`)})]})]})}function ft({runId:e,ask:t}){let[n,i]=(0,J.useState)({}),[o,s]=(0,J.useState)(!1),[c,l]=(0,J.useState)(!1),[u,d]=(0,J.useState)(null),[p,m]=(0,J.useState)(0),[h,g]=(0,J.useState)(``),[_,v]=(0,J.useState)(!1),y=(0,J.useRef)(null),b=(0,J.useCallback)(()=>m(e=>e+1),[]);(0,J.useEffect)(()=>{let e=setInterval(b,2500);return()=>clearInterval(e)},[b]);let x=async n=>{l(!0),d(null);try{await a.post(`/api/runs/${e}/ask/${t.id}`,n)}catch(e){d(e.message),l(!1)}},S=async t=>{d(null);try{await a.post(`/api/runs/${e}/browser/act`,t)}catch(e){d(e.message)}b()},C=e=>{let t=y.current;if(!t?.naturalWidth)return;let n=t.getBoundingClientRect();S({type:`click`,x:Math.round((e.clientX-n.left)/n.width*t.naturalWidth),y:Math.round((e.clientY-n.top)/n.height*t.naturalHeight)})},w=t.fields.some(e=>n[e.id]);return(0,Y.jsxs)(`div`,{className:`animate-rise`,children:[(0,Y.jsxs)(`div`,{className:`mb-5 flex items-start gap-3`,children:[(0,Y.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-full bg-ember-tint text-ember-strong`,children:(0,Y.jsx)(He,{className:`size-5`})}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`h2`,{className:`font-display font-semibold text-[20px] leading-snug tracking-tight`,children:t.reason}),(0,Y.jsxs)(`p`,{className:`mt-0.5 truncate text-[13px] text-ink-3`,children:[t.site.host,t.site.title?` · ${t.site.title}`:``]})]})]}),(0,Y.jsxs)(`div`,{className:`overflow-hidden rounded-xl bg-paper-2 ring-1 ring-border-soft`,children:[(0,Y.jsx)(`img`,{ref:y,src:r(`/api/runs/${e}/browser/screen?t=${p}`),alt:t.site.host,onClick:C,className:`block w-full cursor-pointer`}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 border-border-soft border-t bg-card p-2`,children:[(0,Y.jsx)(W,{type:_?`password`:`text`,autoComplete:`off`,value:h,placeholder:K(`ask.typeInto`),onChange:e=>g(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),S({type:`type`,text:h}).then(()=>g(``)))},autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,enterKeyHint:`send`,className:`h-9 min-w-[9rem] flex-1 basis-full text-[13px] sm:basis-0 coarse:h-11`}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>v(e=>!e),className:H(`h-9 shrink-0 rounded-md px-2.5 text-[12px] coarse:h-11 coarse:px-3.5`,_?`bg-ember-veil text-ink`:`text-ink-3 hover:bg-paper-2`),children:K(`ask.hide`)}),(0,Y.jsx)(pt,{label:`Enter`,onClick:()=>void S({type:`key`,key:`Enter`}),children:(0,Y.jsx)(Se,{className:`size-4`})}),(0,Y.jsx)(pt,{label:K(`ask.up`),onClick:()=>void S({type:`scroll`,dy:-500}),children:(0,Y.jsx)(f,{className:`size-4`})}),(0,Y.jsx)(pt,{label:K(`ask.down`),onClick:()=>void S({type:`scroll`,dy:500}),children:(0,Y.jsx)(me,{className:`size-4`})})]})]}),(0,Y.jsx)(`p`,{className:`mt-2 text-[12px] text-ink-4`,children:K(`ask.pictureHint`)}),t.fields.length?(0,Y.jsxs)(`form`,{className:`mt-5 flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),x({type:`fill`,values:n,remember:o})},children:[t.fields.map((e,r)=>(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(B,{children:e.label}),(0,Y.jsx)(W,{autoFocus:r===0,type:e.secret?`password`:`text`,autoComplete:`off`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,enterKeyHint:r===t.fields.length-1?`go`:`next`,value:n[e.id]??``,onChange:t=>i(n=>({...n,[e.id]:t.target.value}))})]},e.id)),(0,Y.jsx)(`button`,{type:`submit`,hidden:!0})]}):null,(0,Y.jsxs)(`div`,{className:`mt-5 flex items-center justify-between gap-4`,children:[(0,Y.jsx)(de,{checked:o,onChange:s,label:K(`ask.remember`)}),(0,Y.jsx)(`span`,{className:`flex-1 text-[13px] text-ink-2`,children:K(`ask.remember`)})]}),(0,Y.jsxs)(`p`,{className:`mt-3 flex items-start gap-2 text-[13px] text-ink-3`,children:[(0,Y.jsx)(et,{className:`mt-0.5 size-4 shrink-0 text-moss`}),` `,K(`ask.private`)]}),u?(0,Y.jsx)(`div`,{className:`mt-3 rounded-lg bg-rose-tint px-4 py-3 text-[14px] text-rose`,children:u}):null,(0,Y.jsxs)(`div`,{className:`action-bar mt-6 flex flex-wrap items-center justify-between gap-3`,children:[(0,Y.jsx)(G,{variant:`ghost`,disabled:c,onClick:()=>void x({type:`skip`}),children:K(`ask.skip`)}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[t.fields.length?(0,Y.jsx)(G,{variant:`secondary`,disabled:c,onClick:()=>void x({type:`done`,remember:o}),children:K(`ask.done`)}):null,t.fields.length?(0,Y.jsx)(G,{busy:c,disabled:!w,onClick:()=>void x({type:`fill`,values:n,remember:o}),children:K(`ask.signIn`)}):(0,Y.jsx)(G,{busy:c,onClick:()=>void x({type:`done`,remember:o}),children:K(`ask.done`)})]})]})]})}function pt({label:e,onClick:t,children:n}){return(0,Y.jsx)(`button`,{type:`button`,"aria-label":e,title:e,onClick:t,className:`flex size-9 shrink-0 items-center justify-center rounded-md text-ink-3 hover:bg-paper-2 hover:text-ink coarse:size-11`,children:n})}var X=36e5,Z=6e4,mt=1e3;function ht(e){return e.fractionDigits===void 0?e.style===`integer`?0:2:e.fractionDigits}function gt(e,t,n=`en`){if(typeof e!=`number`||!Number.isFinite(e))return``;let r=ht(t),i=t.grouping!==!1;return t.style===`percent`?new Intl.NumberFormat(n,{maximumFractionDigits:r,minimumFractionDigits:r,style:`percent`,useGrouping:i}).format(e):t.style===`currency`&&t.currency?new Intl.NumberFormat(n,{currency:t.currency,maximumFractionDigits:r,minimumFractionDigits:r,style:`currency`,useGrouping:i}).format(e):new Intl.NumberFormat(n,{maximumFractionDigits:r,minimumFractionDigits:r,useGrouping:i}).format(e)}function _t(e,t,n=`en`){if(typeof e!=`string`||e.length===0)return``;if(t.kind===`time`)return vt(e,t.timePrecision??`minutes`);if(t.dateStyle===`iso`)return t.kind===`date`?e.slice(0,10):e;let r=t.kind===`date`?new Date(`${e}T00:00:00`):new Date(e);if(Number.isNaN(r.getTime()))return e;let i=t.dateStyle??`medium`;if(t.kind===`date`)return new Intl.DateTimeFormat(n,{dateStyle:i}).format(r);let a=t.timePrecision??`minutes`;return new Intl.DateTimeFormat(n,{dateStyle:i,timeStyle:a===`hours`?`short`:`medium`}).format(r)}function vt(e,t){let[n=`0`,r=`00`,i=`00`]=e.split(`:`);return t===`hours`?`${n.padStart(2,`0`)}:00`:t===`minutes`?`${n.padStart(2,`0`)}:${r.padStart(2,`0`)}`:`${n.padStart(2,`0`)}:${r.padStart(2,`0`)}:${i.padStart(2,`0`)}`}function yt(e,t){if(typeof e!=`number`||!Number.isFinite(e))return``;let n=Math.max(0,Math.round(e));if(t.display===`iso`)return bt(n);if(t.display===`minutes`)return`${Math.round(n/Z)} min`;if(t.display===`hours`)return`${(n/X).toFixed(2)} h`;if(t.display===`decimal-hours`)return(n/X).toFixed(2);let r=Math.floor(n/X),i=Math.floor(n%X/Z),a=Math.floor(n%Z/mt);return`${r}:${String(i).padStart(2,`0`)}:${String(a).padStart(2,`0`)}`}function bt(e){let t=Math.floor(e/X),n=Math.floor(e%X/Z),r=Math.floor(e%Z/mt);return`${t>=24?`P${Math.floor(t/24)}D`:`P`}T${t%24}H${n}M${r}S`}function xt(e,t,n=`en`){if(t==null)return``;switch(e.type){case`number`:return gt(t,e.format,n);case`date`:return _t(t,e.format,n);case`duration`:return yt(t,e.format);case`boolean`:return t===!0?`true`:t===!1?`false`:``;case`select`:return St(e,t);default:return String(t)}}function St(e,t){let n=Array.isArray(t)?t:[t],r=e.format.options.reduce((e,t)=>(e[t.id]=t.label,e),{});return n.filter(e=>typeof e==`string`&&e.length>0).map(e=>r[e]??e).join(`, `)}async function Ct(e,t=2400){if(!/^image\/(jpeg|png|webp)$/.test(e.type)||e.size<12e5)return e;try{let n=await createImageBitmap(e),r=Math.min(1,t/Math.max(n.width,n.height)),i=document.createElement(`canvas`);i.width=Math.round(n.width*r),i.height=Math.round(n.height*r),i.getContext(`2d`)?.drawImage(n,0,0,i.width,i.height);let a=await new Promise(e=>i.toBlob(e,`image/jpeg`,.86));return a&&a.size<e.size?new File([a],`${e.name.replace(/\.[^.]+$/,``)}.jpg`,{type:`image/jpeg`}):e}catch{return e}}function wt(){return new Date().toISOString().slice(0,19).replace(/[:T]/g,`-`)}function Tt(e){let t=e?.name;return t===`NotFoundError`||t===`OverconstrainedError`?`missing`:t===`NotReadableError`||t===`AbortError`?`busy`:`denied`}function Et(e){return!!e?.getCapabilities?.()?.torch}function Dt(e,t,n=!1){let r=(0,J.useRef)(null),[i,a]=(0,J.useState)(null),[o,s]=(0,J.useState)(null),[c,l]=(0,J.useState)(1),[u,d]=(0,J.useState)(!1),[f,p]=(0,J.useState)(!1);return(0,J.useEffect)(()=>{if(!e)return;let r=null,i=!1;s(null),a(null),d(!1),p(!1);let o={facingMode:{ideal:t},width:{ideal:2560},height:{ideal:1440}};return(async()=>{if(!navigator.mediaDevices?.getUserMedia)throw new DOMException(`no camera api`,`NotAllowedError`);try{r=await navigator.mediaDevices.getUserMedia({video:o,audio:n})}catch(e){if(!n)throw e;r=await navigator.mediaDevices.getUserMedia({video:o})}if(i){for(let e of r.getTracks())e.stop();return}a(r);let e=r.getVideoTracks()[0],t=()=>!i&&d(Et(e));t(),setTimeout(t,600);let s=await navigator.mediaDevices.enumerateDevices().catch(()=>[]);i||l(s.filter(e=>e.kind===`videoinput`).length)})().catch(e=>!i&&s(Tt(e))),()=>{i=!0;for(let e of r?.getTracks()??[])e.stop()}},[e,t,n]),(0,J.useEffect)(()=>{r.current&&i&&(r.current.srcObject=i)},[i]),{video:r,stream:i,error:o,cameras:c,torchable:u,torch:f,setTorch:async e=>{let t=i?.getVideoTracks()[0];try{await t?.applyConstraints({advanced:[{torch:e}]}),p(e)}catch{d(!1)}},mirrored:i?.getVideoTracks()[0]?.getSettings().facingMode===`user`}}function Ot({open:e,onClose:t,label:n,children:r}){let i=(0,J.useRef)(null);return(0,J.useEffect)(()=>{let t=i.current;t&&(e&&!t.open?t.showModal():!e&&t.open&&t.close())},[e]),(0,Y.jsx)(`dialog`,{ref:i,onClose:t,"aria-label":n,className:`media-sheet`,children:e?(0,Y.jsx)(`div`,{className:`flex h-full flex-col`,children:r}):null})}function kt({label:e,onClick:t,active:n,children:r}){return(0,Y.jsx)(`button`,{type:`button`,"aria-label":e,title:e,"aria-pressed":n,onClick:t,className:H(`flex size-11 shrink-0 items-center justify-center rounded-full transition`,n?`bg-white text-black`:`bg-white/12 text-white hover:bg-white/20`),children:r})}function At({title:e,onClose:t,camera:n,onFlip:r}){return(0,Y.jsx)(`div`,{className:`safe-top`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[(0,Y.jsx)(kt,{label:K(`common.close`),onClick:t,children:(0,Y.jsx)(q,{className:`size-5`})}),(0,Y.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-center font-medium text-[15px]`,children:e}),n.torchable?(0,Y.jsx)(kt,{label:K(`camera.torch`),active:n.torch,onClick:()=>void n.setTorch(!n.torch),children:n.torch?(0,Y.jsx)(Me,{className:`size-5`}):(0,Y.jsx)(Ae,{className:`size-5`})}):null,n.stream&&(n.cameras>1||v)?(0,Y.jsx)(kt,{label:K(`camera.flip`),onClick:r,children:(0,Y.jsx)(nt,{className:`size-5`})}):(0,Y.jsx)(`span`,{className:`size-11`})]})})}function jt({camera:e,asking:t,children:n,actions:r}){return(0,Y.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden`,children:[(0,Y.jsx)(`video`,{ref:e.video,autoPlay:!0,playsInline:!0,muted:!0,className:H(`absolute inset-0 size-full object-contain`,e.mirrored&&`-scale-x-100`)}),e.error?(0,Y.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-5 bg-black px-8 text-center`,children:[(0,Y.jsx)(`p`,{className:`max-w-sm text-[15px] text-white/85 leading-relaxed`,children:K(`camera.${e.error}`)}),r]}):e.stream?n:(0,Y.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-4 px-8 text-center text-white/75`,children:[(0,Y.jsx)(V,{}),(0,Y.jsx)(`p`,{className:`max-w-xs text-[14px] leading-relaxed`,children:t})]})]})}var Mt=30;function Nt(){if(typeof MediaRecorder<`u`)return[`video/mp4;codecs=avc1.42E01E,mp4a.40.2`,`video/mp4`,`video/webm;codecs=vp9,opus`,`video/webm;codecs=vp8,opus`,`video/webm`].find(e=>MediaRecorder.isTypeSupported(e))}var Pt=!!Nt();function Ft({open:e,multiple:t,video:n,onClose:r,onCapture:i,onNative:a}){let[o,s]=(0,J.useState)(`environment`),[c,l]=(0,J.useState)(`photo`),[u,d]=(0,J.useState)(0),[f,p]=(0,J.useState)(!1),[m,h]=(0,J.useState)(null),g=(0,J.useRef)(null),_=Dt(e,o,c===`video`);(0,J.useEffect)(()=>{e&&(d(0),l(`photo`),h(null))},[e]);let y=async e=>{p(!0);try{await i(e),d(e=>e+1),t||r()}finally{p(!1)}},b=async()=>{let e=_.video.current;if(!e?.videoWidth)return;let t=document.createElement(`canvas`);t.width=e.videoWidth,t.height=e.videoHeight,t.getContext(`2d`)?.drawImage(e,0,0);let n=await new Promise(e=>t.toBlob(e,`image/jpeg`,.9));n&&await y(new File([n],`foto-${wt()}.jpg`,{type:`image/jpeg`}))},x=()=>{g.current?.state===`recording`&&g.current.stop()},S=()=>{let e=Nt();if(!_.stream||!e)return;let t=[],n=new MediaRecorder(_.stream,{mimeType:e,videoBitsPerSecond:25e5,audioBitsPerSecond:96e3});n.ondataavailable=e=>e.data.size&&t.push(e.data),n.onstop=()=>{h(null),g.current=null;let n=e.split(`;`)[0];if(t.length){let e=n===`video/mp4`?`mp4`:`webm`;y(new File(t,`video-${wt()}.${e}`,{type:n}))}},g.current=n,n.start(1e3),h(0)};(0,J.useEffect)(()=>{if(m===null)return;if(m>=Mt){g.current?.state===`recording`&&g.current.stop();return}let e=setTimeout(()=>h(e=>e===null?null:e+1),1e3);return()=>clearTimeout(e)},[m]),(0,J.useEffect)(()=>{!e&&g.current&&(g.current.onstop=null,g.current.stop(),g.current=null)},[e]);let C=e=>`0:${String(e).padStart(2,`0`)}`;return(0,Y.jsxs)(Ot,{open:e,onClose:r,label:K(`camera.title`),children:[(0,Y.jsx)(At,{title:m===null?u?K(`camera.taken`,{n:u}):K(`camera.title`):`${C(m)} / ${C(Mt)}`,onClose:r,camera:_,onFlip:()=>s(e=>e===`environment`?`user`:`environment`)}),(0,Y.jsx)(jt,{camera:_,asking:K(`camera.asking`),actions:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[a?(0,Y.jsxs)(Q,{onClick:()=>{r(),a()},children:[(0,Y.jsx)(be,{className:`size-4`}),` `,K(v?`camera.native`:`camera.pick`)]}):null,(0,Y.jsx)(Q,{quiet:!0,onClick:r,children:K(`common.close`)})]})}),(0,Y.jsxs)(`div`,{className:H(`safe-bottom px-4 pt-3`,_.error&&`invisible`),children:[n&&Pt&&m===null?(0,Y.jsx)(`div`,{className:`mb-3 flex justify-center gap-1 text-[13px]`,children:[`photo`,`video`].map(e=>(0,Y.jsx)(`button`,{type:`button`,"aria-pressed":c===e,onClick:()=>l(e),className:H(`h-9 rounded-full px-4 font-medium transition`,c===e?`bg-white text-black`:`text-white/70 hover:text-white`),children:K(e===`photo`?`camera.photo`:`camera.video`)},e))}):null,(0,Y.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto_1fr] items-center gap-3`,children:[(0,Y.jsx)(`span`,{className:`text-[13px] text-white/70 leading-snug`,children:m===null?c===`video`?K(`camera.clipHint`,{s:Mt}):K(t?`camera.hintMany`:`camera.hint`):K(`camera.recording`)}),(0,Y.jsx)(`button`,{type:`button`,"aria-label":K(c===`photo`?`camera.shoot`:m===null?`camera.record`:`camera.stop`),disabled:!_.stream||f,onClick:()=>c===`photo`?void b():m===null?S():x(),className:`flex size-[72px] items-center justify-center rounded-full border-4 border-white transition active:scale-95 disabled:opacity-40`,children:f?(0,Y.jsx)(V,{className:`text-white`}):c===`photo`?(0,Y.jsx)(`span`,{className:`size-[54px] rounded-full bg-white`}):m===null?(0,Y.jsx)(`span`,{className:`flex size-[54px] items-center justify-center rounded-full bg-[#e5484d]`,children:(0,Y.jsx)(ne,{className:`size-6 text-white`})}):(0,Y.jsx)(`span`,{className:`size-7 rounded-md bg-[#e5484d]`})}),(0,Y.jsx)(`div`,{className:`flex justify-end`,children:t&&u&&m===null?(0,Y.jsxs)(Q,{onClick:r,children:[(0,Y.jsx)(N,{className:`size-4`}),` `,K(`camera.done`)]}):null})]})]})]})}function Q({onClick:e,quiet:t,children:n}){return(0,Y.jsx)(`button`,{type:`button`,onClick:e,className:H(`inline-flex h-11 items-center justify-center gap-2 rounded-full px-5 font-medium text-[14px] transition`,t?`text-white/75 hover:text-white`:`bg-white text-black hover:bg-white/90`),children:n})}var It=25,Lt=9e3;function Rt(e){return e.code===e.PERMISSION_DENIED?`denied`:e.code===e.TIMEOUT?`timeout`:`unavailable`}function zt({value:e,runId:t,placeholder:n,onChange:r,onBusy:i}){let o=re(e)?e:null,[s,c]=(0,J.useState)(!1),[l,u]=(0,J.useState)(null),d=(0,J.useRef)(null),f=(0,J.useRef)(!!o?.label),p=(0,J.useRef)(o);p.current=o;let m=o?.lat!==void 0&&o.lng!==void 0,h=typeof navigator<`u`&&`geolocation`in navigator,g=()=>{d.current!==null&&(navigator.geolocation.clearWatch(d.current),d.current=null),c(!1),i?.(!1)};(0,J.useEffect)(()=>()=>{d.current!==null&&navigator.geolocation.clearWatch(d.current)},[]);let _=async(e,n)=>{try{let{label:i}=await a.post(`/api/runs/${t}/geocode`,{lat:e,lng:n,language:z}),o=p.current;i&&!f.current&&o?.lat===e&&o.lng===n&&r({...o,label:i})}catch{}},v=()=>{u(null),c(!0),i?.(!0);let e=Date.now(),t=1/0;d.current=navigator.geolocation.watchPosition(n=>{let{latitude:i,longitude:a,accuracy:o}=n.coords;if(o<t){t=o;let e=Math.round(i*1e6)/1e6,n=Math.round(a*1e6)/1e6,s=f.current?p.current?.label:void 0,c={lat:e,lng:n,accuracy:Math.round(o),...s?{label:s}:{}};p.current=c,r(c)}if(t<=It||Date.now()-e>Lt){g();let e=p.current;e?.lat!==void 0&&e.lng!==void 0&&_(e.lat,e.lng)}},e=>{g(),t===1/0&&u(Rt(e))},{enableHighAccuracy:!0,timeout:15e3,maximumAge:1e4})},y=e=>{f.current=e.trim().length>0;let t={...m?o:{},label:e};r(m||e.trim()?t:void 0)};return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[m?(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl bg-card p-3 ring-1 ring-input`,children:[(0,Y.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-full bg-moss-tint text-moss`,children:(0,Y.jsx)(We,{className:`size-5`})}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`div`,{className:`truncate font-medium text-[15px] tabular-nums`,children:[o.lat?.toFixed(5),`, `,o.lng?.toFixed(5)]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 text-[13px] text-ink-3`,children:[(0,Y.jsx)(`span`,{children:s?K(`location.refining`):o.accuracy?K(`location.accuracy`,{m:o.accuracy}):null}),(0,Y.jsxs)(`a`,{href:`https://www.openstreetmap.org/?mlat=${o.lat}&mlon=${o.lng}#map=17/${o.lat}/${o.lng}`,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 underline-offset-2 hover:text-ink hover:underline coarse:-my-3 coarse:min-h-11 coarse:min-w-11`,children:[K(`location.map`),` `,(0,Y.jsx)(I,{className:`size-3`})]})]})]}),(0,Y.jsx)(U,{label:K(`location.remove`),onClick:()=>{g(),f.current=!1,r(void 0)},children:(0,Y.jsx)(q,{className:`size-4`})})]}):h?(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(G,{variant:`secondary`,size:`lg`,busy:s,onClick:v,className:`w-full sm:w-auto`,children:[s?null:(0,Y.jsx)(Be,{className:`size-4`}),K(s?`location.locating`:`location.use`)]}),l?(0,Y.jsx)(`p`,{className:`mt-2 rounded-lg bg-amber-tint px-3 py-2 text-[13px] text-ink-2 leading-relaxed`,children:K(`location.${l}`)}):(0,Y.jsx)(`p`,{className:`mt-2 text-[13px] text-ink-3 leading-relaxed`,children:K(`location.why`)})]}):null,(0,Y.jsx)(W,{value:o?.label??``,placeholder:n??K(m?`location.label`:`location.manual`),autoComplete:`street-address`,enterKeyHint:`done`,"aria-label":K(`location.manual`),onChange:e=>y(e.target.value)})]})}var Bt=null;function Vt(){return Bt??=(async()=>{let e=window.BarcodeDetector;if(e)try{let t=await e.getSupportedFormats();if(t.includes(`qr_code`)){let n=new e({formats:t});return{qrOnly:!1,detect:async e=>(await n.detect(e))[0]?.rawValue||null}}}catch{}let{default:t}=await s(async()=>{let{default:e}=await import(`./qr-scanner.min-C_UI0gH-.js`);return{default:e}},__vite__mapDeps([0,1])),n=t.createQrEngine();return{qrOnly:!0,detect:async e=>{try{return(await t.scanImage(e,{qrEngine:n,returnDetailedScanResult:!0})).data||null}catch{return null}}}})(),Bt}function Ht({open:e,onClose:t,onResult:n}){let r=(0,J.useRef)(n);r.current=n;let i=(0,J.useRef)(t);return i.current=t,(0,J.useEffect)(()=>{e&&S(`scan`).then(e=>{e&&r.current(e)}).catch(()=>void 0).finally(()=>i.current())},[e]),null}function Ut(e){return x(`scan`)?(0,Y.jsx)(Ht,{...e}):(0,Y.jsx)(Wt,{...e})}function Wt({open:e,onClose:t,onResult:n}){let[r,i]=(0,J.useState)(`environment`),[a,o]=(0,J.useState)(!1),[s,c]=(0,J.useState)(!1),l=(0,J.useRef)(null),u=Dt(e,r),d=(0,J.useRef)(n);d.current=n;let f=(0,J.useRef)(t);f.current=t,(0,J.useEffect)(()=>{e&&(c(!1),Vt().then(e=>o(e.qrOnly)))},[e]),(0,J.useEffect)(()=>{if(!e||!u.stream)return;let t=!1,n,r=async()=>{let e=u.video.current;if(!t&&e&&e.readyState>=2&&e.videoWidth){let n=await(await Vt()).detect(e).catch(()=>null);if(n&&!t){navigator.vibrate?.(60),d.current(n),f.current();return}}t||(n=setTimeout(r,200))};return r(),()=>{t=!0,clearTimeout(n)}},[e,u.stream,u.video]);let p=async e=>{if(!e)return;c(!1);let r=await createImageBitmap(e).catch(()=>null),i=r?await(await Vt()).detect(r).catch(()=>null):null;i?(n(i),t()):c(!0)};return(0,Y.jsxs)(Ot,{open:e,onClose:t,label:K(`scan.title`),children:[(0,Y.jsx)(At,{title:K(`scan.title`),onClose:t,camera:u,onFlip:()=>i(e=>e===`environment`?`user`:`environment`)}),(0,Y.jsx)(jt,{camera:u,asking:K(`scan.asking`),actions:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsxs)(Q,{onClick:()=>l.current?.click(),children:[(0,Y.jsx)(Re,{className:`size-4`}),` `,K(`scan.fromPhoto`)]}),(0,Y.jsx)(Q,{quiet:!0,onClick:t,children:K(`scan.typeInstead`)})]}),children:(0,Y.jsx)(`div`,{className:`pointer-events-none absolute inset-0 flex items-center justify-center`,children:(0,Y.jsx)(`div`,{className:`aspect-square w-[min(68%,320px)] rounded-3xl border-2 border-white/90 shadow-[0_0_0_100vmax_rgb(0_0_0/0.35)]`})})}),(0,Y.jsxs)(`div`,{className:`safe-bottom flex flex-col items-center gap-3 px-5 pt-3 text-center`,children:[(0,Y.jsx)(`p`,{className:`text-[13px] text-white/75 leading-snug`,children:K(s?`scan.miss`:a?`scan.hintQr`:`scan.hint`)}),u.stream?(0,Y.jsxs)(Q,{quiet:!0,onClick:()=>l.current?.click(),children:[(0,Y.jsx)(Re,{className:`size-4`}),` `,K(`scan.fromPhoto`)]}):null]}),(0,Y.jsx)(`input`,{ref:l,type:`file`,hidden:!0,accept:`image/*`,onChange:e=>{p(e.target.files?.[0]),e.target.value=``}})]})}var Gt=`#1d1a17`,Kt={width:1200,height:480};function qt(e,t,n,r,i){e.lineCap=`round`,e.lineJoin=`round`,e.strokeStyle=Gt,e.fillStyle=Gt,e.lineWidth=i;for(let a of t){if(a.length===1){e.beginPath(),e.arc(a[0].x*n,a[0].y*r,i/2,0,Math.PI*2),e.fill();continue}e.beginPath(),e.moveTo(a[0].x*n,a[0].y*r);for(let t=1;t<a.length-1;t++){let i=a[t],o=a[t+1];e.quadraticCurveTo(i.x*n,i.y*r,(i.x+o.x)/2*n,(i.y+o.y)/2*r)}let t=a[a.length-1];e.lineTo(t.x*n,t.y*r),e.stroke()}}function Jt({strokes:e,onStrokes:t}){let n=(0,J.useRef)(null),r=(0,J.useRef)(null),i=(0,J.useRef)(e);i.current=e;let a=()=>{let e=n.current,t=e?.getContext(`2d`);if(!e||!t)return;let a=window.devicePixelRatio||1,o=Math.round(e.clientWidth*a),s=Math.round(e.clientHeight*a);(e.width!==o||e.height!==s)&&(e.width=o,e.height=s),t.clearRect(0,0,o,s),qt(t,r.current?[...i.current,r.current]:i.current,o,s,2.4*a)};(0,J.useEffect)(()=>{a();let e=n.current;if(!e)return;let t=new ResizeObserver(a);return t.observe(e),()=>t.disconnect()},[e]);let o=e=>{let t=e.currentTarget.getBoundingClientRect();return{x:Math.min(1,Math.max(0,(e.clientX-t.left)/t.width)),y:Math.min(1,Math.max(0,(e.clientY-t.top)/t.height))}};return(0,Y.jsxs)(`div`,{className:`relative overflow-hidden rounded-xl bg-white ring-1 ring-input`,children:[(0,Y.jsx)(`canvas`,{ref:n,"aria-label":K(`sign.pad`),className:`block aspect-[5/2] w-full cursor-crosshair touch-none select-none`,onPointerDown:e=>{e.currentTarget.setPointerCapture(e.pointerId),r.current=[o(e)],a()},onPointerMove:e=>{r.current&&(r.current.push(o(e)),a())},onPointerUp:()=>{if(r.current){let e=r.current;r.current=null,t([...i.current,e])}},onPointerCancel:()=>{r.current=null,a()}}),(0,Y.jsx)(`div`,{className:`pointer-events-none absolute inset-x-6 bottom-[22%] border-[#1d1a17]/25 border-b`}),e.length?null:(0,Y.jsx)(`div`,{className:`pointer-events-none absolute inset-0 flex items-center justify-center text-[#1d1a17]/40 text-[14px]`,children:K(`sign.hint`)})]})}async function Yt(e){let t=document.createElement(`canvas`);t.width=Kt.width,t.height=Kt.height;let n=t.getContext(`2d`);if(!n)return null;qt(n,e,Kt.width,Kt.height,7);let r=await new Promise(e=>t.toBlob(e,`image/png`));return r?new File([r],`unterschrift.png`,{type:`image/png`}):null}function Xt({label:e,value:t,runId:n,onChange:i}){let[o,s]=(0,J.useState)(!1),[c,l]=(0,J.useState)([]),[u,d]=(0,J.useState)(!1),[f,p]=(0,J.useState)(null),m=typeof t==`string`&&t?t:null,h=async()=>{d(!0),p(null);try{let e=await Yt(c);if(!e)return;i((await a.upload(`/api/runs/${n}/uploads`,e)).id),s(!1)}catch(e){p(e.message)}finally{d(!1)}};return(0,Y.jsxs)(`div`,{children:[m?(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl bg-card p-2 ring-1 ring-input`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:()=>{l([]),s(!0)},className:`min-w-0 flex-1 rounded-lg bg-white px-3`,"aria-label":K(`sign.again`),children:(0,Y.jsx)(`img`,{src:r(`/api/runs/${n}/assets/${m}`),alt:e,className:`mx-auto h-20 object-contain`})}),(0,Y.jsx)(U,{label:K(`sign.remove`),onClick:()=>i(void 0),children:(0,Y.jsx)(q,{className:`size-4`})})]}):(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{l([]),s(!0)},className:`flex w-full flex-col items-center justify-center gap-2 rounded-xl border border-input border-dashed bg-card px-4 py-7 text-[14px] text-ink-3 transition hover:border-ember hover:text-ink`,children:[(0,Y.jsx)(te,{className:`size-6`}),K(`sign.open`)]}),(0,Y.jsxs)(se,{open:o,onClose:()=>s(!1),title:e,wide:!0,children:[(0,Y.jsx)(Jt,{strokes:c,onStrokes:l}),f?(0,Y.jsx)(`p`,{className:`mt-2 text-[13px] text-rose`,children:f}):null,(0,Y.jsxs)(`div`,{className:`mt-5 flex items-center justify-between gap-3`,children:[(0,Y.jsxs)(G,{variant:`ghost`,disabled:!c.length||u,onClick:()=>l([]),children:[(0,Y.jsx)(Ee,{className:`size-4`}),` `,K(`sign.clear`)]}),(0,Y.jsx)(G,{busy:u,disabled:!c.length,onClick:()=>void h(),children:K(`sign.accept`)})]})]})]})}function Zt({runId:e,connectionId:t,connector:n,onCancel:r}){let[i,o]=(0,J.useState)({}),[s,c]=(0,J.useState)(!1),[l,u]=(0,J.useState)(null),d=async()=>{c(!0),u(null);try{await a.post(`/api/runs/${e}/connections/${t}/credentials/${n.id}`,{values:i})}catch(e){u(e.message)}finally{c(!1)}};return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl bg-card p-4 ring-1 ring-input`,children:[(n.fields??[]).map(e=>(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(B,{children:e.label}),(0,Y.jsx)(W,{type:e.secret?`password`:`text`,autoComplete:`off`,value:i[e.key]??``,placeholder:e.placeholder,onChange:t=>o(n=>({...n,[e.key]:t.target.value})),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),d())}})]},e.key)),n.hint?(0,Y.jsx)(`p`,{className:`text-[13px] text-ink-3`,children:n.hint}):null,l?(0,Y.jsx)(`p`,{className:`text-[13px] text-rose`,children:l}):null,(0,Y.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Y.jsx)(G,{variant:`ghost`,size:`sm`,onClick:r,children:K(`common.cancel`)}),(0,Y.jsx)(G,{size:`sm`,busy:s,onClick:()=>void d(),children:K(`connect.go`)})]})]})}function Qt({runId:e,connection:t}){let[n,r]=(0,J.useState)(null),[i,o]=(0,J.useState)(null),[s,c]=(0,J.useState)(null);if(!t)return null;if(t.account){let n=t.connectors.find(e=>e.id===t.account?.connector)?.name??``;return(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl bg-card p-3 ring-1 ring-input`,children:[(0,Y.jsx)(`div`,{className:`flex size-10 items-center justify-center rounded-full bg-moss-tint text-moss`,children:(0,Y.jsx)(N,{className:`size-5`})}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`div`,{className:`truncate font-medium text-[15px]`,children:t.account.label}),(0,Y.jsx)(`div`,{className:`text-[13px] text-ink-3`,children:K(`connect.connected`,{name:n})})]}),(0,Y.jsx)(U,{label:K(`connect.disconnect`),onClick:()=>void a.del(`/api/runs/${e}/connections/${t.id}`),children:(0,Y.jsx)(ot,{className:`size-4`})})]})}let l=async n=>{if(c(null),o(null),x(`signIn`)){try{let{url:r}=await a.post(`/api/runs/${e}/connections/${t.id}/oauth/${n.id}`);await S(`signIn`,{url:r})}catch(e){c(e.message)}return}let r=window.open(`about:blank`,`wizard-connect`,`width=540,height=700`);try{let{url:i}=await a.post(`/api/runs/${e}/connections/${t.id}/oauth/${n.id}`);r?r.location.replace(i):o(i)}catch(e){r?.close(),c(e.message)}},u=t.connectors.find(e=>e.id===n);return t.connectors.length?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t.connectors.map(e=>(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>e.auth===`oauth2`?void l(e):r(n===e.id?null:e.id),className:H(`inline-flex h-11 items-center gap-2 rounded-full px-4 font-medium text-[14px] ring-1 transition`,n===e.id?`bg-ember-veil text-ink ring-ember`:`bg-card text-ink-2 ring-input hover:text-ink hover:ring-ember`),children:[(0,Y.jsx)(h,{className:`size-4`}),` `,e.name]},e.id))}),u?(0,Y.jsx)(Zt,{runId:e,connectionId:t.id,connector:u,onCancel:()=>r(null)}):null,i?(0,Y.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,className:`text-[14px] text-ember underline`,children:K(`connect.openLink`)}):null,s?(0,Y.jsx)(`p`,{className:`text-[13px] text-rose`,children:s}):null]}):(0,Y.jsx)(`p`,{className:`text-[14px] text-ink-3`,children:K(`connect.none`)})}function $t(e){return e==null?``:Array.isArray(e)?e.join(`, `):String(e)}function en(e,t){if(t.trim()===``)return null;if(e.type===`number`){let e=Number(t.replace(/\s/g,``).replace(`,`,`.`));return Number.isFinite(e)?e:t}return e.type===`boolean`?t===`true`:t}function $({column:e,value:t,boxed:n,onCommit:r}){let[i,a]=(0,J.useState)($t(t));(0,J.useEffect)(()=>a($t(t)),[t]);let o=H(`w-full min-w-0 rounded-md border border-transparent px-2 text-[13px] outline-none focus:border-ember focus:bg-card`,n?`h-11 bg-paper-2`:`h-9 bg-transparent hover:bg-paper-2 coarse:h-11`);return e.type===`boolean`?(0,Y.jsx)(`label`,{className:`flex size-9 cursor-pointer items-center justify-center coarse:size-11`,children:(0,Y.jsx)(`input`,{type:`checkbox`,"aria-label":e.name,checked:t===!0,onChange:e=>r(e.target.checked),className:`size-4 accent-[var(--ember)] coarse:size-6`})}):e.type===`select`&&!e.format.multiple&&!e.format.allowCustom?(0,Y.jsxs)(`select`,{value:i,onChange:e=>r(e.target.value||null),className:o,children:[(0,Y.jsx)(`option`,{value:``}),e.format.options.map(e=>(0,Y.jsx)(`option`,{value:e.id,children:e.label},e.id))]}):(0,Y.jsx)(`input`,{"aria-label":e.name,type:e.type===`date`&&e.format.kind===`date`?`date`:`text`,inputMode:e.type===`number`?`decimal`:void 0,enterKeyHint:`done`,autoComplete:`off`,value:i,onChange:e=>a(e.target.value),onBlur:()=>{i!==$t(t)&&r(en(e,i))},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.target.blur())},className:H(o,e.type===`number`&&`text-right tabular-nums`)})}function tn({runId:e,list:t,editable:n}){let{def:r,rows:i}=t,[s,c]=(0,J.useState)(null),[l,u]=(0,J.useState)({}),d=`/api/runs/${e}/lists/${r.id}/rows`,f=async e=>{c(null);try{await e()}catch(e){c(e instanceof o?e.message:String(e))}},p=()=>f(async()=>{await a.post(d,{cells:l}),u({})}),m=Object.values(l).some(e=>e!=null&&e!==``);if(!i.length&&!n)return(0,Y.jsx)(`p`,{className:`text-[14px] text-ink-3`,children:K(`list.empty`)});let h=(e,t)=>t===0||e.type===`text`&&e.format?.style===`multiline`,g=(e,t,n)=>void f(()=>a.patch(`${d}/${e}`,{cells:{[t]:n}}));return(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 sm:hidden`,children:[i.map(e=>(0,Y.jsxs)(`div`,{className:`rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,Y.jsx)(`div`,{className:`grid grid-cols-2 gap-x-2 gap-y-1.5`,children:r.columns.map((t,r)=>(0,Y.jsxs)(`div`,{className:H(`min-w-0`,h(t,r)&&`col-span-2`),children:[(0,Y.jsx)(`div`,{className:`px-1 pb-0.5 text-[11px] text-ink-3`,children:t.name}),n?(0,Y.jsx)($,{boxed:!0,column:t,value:e.cells[t.id],onCommit:n=>g(e.id,t.id,n)}):(0,Y.jsx)(`div`,{className:H(`break-words px-1 text-[14px]`,t.type===`number`&&`tabular-nums`),children:xt(t,e.cells[t.id],z)||`—`})]},t.id))}),n?(0,Y.jsx)(`div`,{className:`mt-1 flex justify-end`,children:(0,Y.jsx)(U,{label:K(`list.delete`),onClick:()=>void f(()=>a.del(`${d}/${e.id}`)),children:(0,Y.jsx)(M,{className:`size-4`})})}):null]},e.id)),n?(0,Y.jsxs)(`div`,{className:`rounded-lg border border-input border-dashed p-2`,children:[(0,Y.jsx)(`div`,{className:`grid grid-cols-2 gap-x-2 gap-y-1.5`,children:r.columns.map((e,t)=>(0,Y.jsxs)(`div`,{className:H(`min-w-0`,h(e,t)&&`col-span-2`),children:[(0,Y.jsx)(`div`,{className:`px-1 pb-0.5 text-[11px] text-ink-3`,children:e.name}),(0,Y.jsx)($,{boxed:!0,column:e,value:l[e.id],onCommit:t=>u(n=>({...n,[e.id]:t}))})]},e.id))}),(0,Y.jsx)(`div`,{className:`mt-2 flex justify-end`,children:(0,Y.jsxs)(G,{variant:`secondary`,size:`sm`,onClick:()=>m?void p():void 0,children:[(0,Y.jsx)(F,{className:`size-4`}),` `,K(`run.addRow`)]})})]}):null]}),(0,Y.jsx)(`div`,{className:`hidden overflow-x-auto rounded-lg ring-1 ring-border-soft sm:block`,children:(0,Y.jsxs)(`table`,{className:`w-full text-[13px]`,children:[(0,Y.jsx)(`thead`,{className:`bg-paper-2 text-ink-2`,children:(0,Y.jsxs)(`tr`,{children:[r.columns.map(e=>(0,Y.jsx)(`th`,{className:`whitespace-nowrap px-3 py-2 text-left font-medium`,children:e.name},e.id)),n?(0,Y.jsx)(`th`,{className:`w-10`}):null]})}),(0,Y.jsxs)(`tbody`,{children:[i.map(e=>(0,Y.jsxs)(`tr`,{className:`border-border-soft border-t align-top`,children:[r.columns.map(t=>(0,Y.jsx)(`td`,{className:H(`min-w-[7.5rem]`,n?`px-1 py-0.5`:`px-3 py-2`),children:n?(0,Y.jsx)($,{column:t,value:e.cells[t.id],onCommit:n=>g(e.id,t.id,n)}):(0,Y.jsx)(`span`,{className:H(t.type===`number`&&`tabular-nums`),children:xt(t,e.cells[t.id],z)})},t.id)),n?(0,Y.jsx)(`td`,{className:`px-1 py-0.5`,children:(0,Y.jsx)(U,{label:K(`list.delete`),className:`size-9`,onClick:()=>void f(()=>a.del(`${d}/${e.id}`)),children:(0,Y.jsx)(M,{className:`size-3.5`})})}):null]},e.id)),n?(0,Y.jsxs)(`tr`,{className:`border-border-soft border-t bg-paper`,children:[r.columns.map(e=>(0,Y.jsx)(`td`,{className:`px-1 py-0.5`,children:(0,Y.jsx)($,{column:e,value:l[e.id],onCommit:t=>u(n=>({...n,[e.id]:t}))})},e.id)),(0,Y.jsx)(`td`,{className:`px-1 py-0.5`,children:(0,Y.jsx)(U,{label:K(`run.addRow`),className:`size-9`,onClick:()=>m?void p():void 0,children:(0,Y.jsx)(F,{className:`size-4`})})})]}):null]})]})}),s?(0,Y.jsx)(`p`,{className:`mt-2 text-[13px] text-rose`,children:s}):null]})}function nn(e,t,n){let i=t.split(`/`).map(encodeURIComponent).join(`/`);return r(`/api/runs/${e}/store/files/${i}${n?`?inline=1`:``}`)}var rn=[`bg-paper-3 text-ink-3`,`bg-moss-tint text-moss`,`bg-rose-tint text-rose`,`bg-ember-tint text-ember-strong`];function an({runId:e,list:t}){let{def:n,rows:r}=t,i=n.columns.find(e=>e.id===n.check?.file),s=n.columns.find(e=>e.id===n.check?.status),c=s?.type===`select`?s.format.options:[],l=c[0]?.id,u=e=>s?String(e.cells[s.id]??l??``):``,d=e=>!s||u(e)===l,[f,p]=(0,J.useState)(()=>(r.find(d)??r[0])?.id??null),[m,h]=(0,J.useState)(!1),[g,_]=(0,J.useState)(null),v=`/api/runs/${e}/lists/${n.id}/rows`,y=r.find(e=>e.id===f)??r[0],b=m?r.filter(e=>d(e)||e.id===y?.id):r,x=r.filter(e=>!d(e)).length,S=n.columns.filter(e=>e!==i&&e!==s),C=S.filter(e=>e.id!==n.key),w=C.find(e=>e.type===`text`)??C[0],T=C.filter(e=>e!==w),E=async(e,t)=>{_(null);try{await a.patch(`${v}/${e}`,{cells:t})}catch(e){_(e instanceof o?e.message:String(e))}},D=e=>{let t=b.findIndex(e=>e.id===y?.id),n=b[Math.min(b.length-1,Math.max(0,t+e))];n&&p(n.id)},O=async e=>{if(!y||!s)return;let t=r.findIndex(e=>e.id===y.id),n=[...r.slice(t+1),...r.slice(0,t)].find(d);await E(y.id,{[s.id]:e}),n&&e!==l&&p(n.id)},k=e=>{e.target.closest(`input, textarea, select`)||(e.key===`ArrowDown`||e.key===`ArrowUp`?(e.preventDefault(),D(e.key===`ArrowDown`?1:-1)):/^[1-9]$/.test(e.key)&&c[Number(e.key)]&&(e.preventDefault(),O(c[Number(e.key)].id)))};if(!r.length)return(0,Y.jsx)(`p`,{className:`text-[14px] text-ink-3`,children:K(`list.empty`)});let A=i&&y?String(y.cells[i.id]??``).trim():``,j=A.split(`.`).pop()?.toLowerCase()??``,M=e=>rn[Math.min(Math.max(0,c.findIndex(t=>t.id===u(e))),3)];return(0,Y.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[minmax(280px,360px)_minmax(0,1fr)]`,onKeyDown:k,children:[(0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-col`,children:[(0,Y.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[13px] text-ink-3 tabular-nums`,children:K(`check.progress`,{done:x,total:r.length})}),s?(0,Y.jsx)(`button`,{type:`button`,"aria-pressed":m,onClick:()=>h(e=>!e),className:H(`inline-flex h-8 items-center rounded-full px-3 text-[13px] ring-1 transition coarse:h-11`,m?`bg-ember-tint text-ink ring-ember`:`bg-card text-ink-2 ring-input hover:text-ink`),children:K(`check.onlyOpen`)}):null]}),(0,Y.jsx)(`ul`,{className:`flex max-h-[38vh] flex-col gap-1.5 overflow-y-auto p-0.5 pr-1 lg:max-h-[calc(100vh-15rem)]`,children:b.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>p(e.id),"aria-current":e.id===y?.id,className:H(`flex w-full items-center gap-3 rounded-lg px-3 py-2.5 text-left ring-1 transition`,e.id===y?.id?`bg-card shadow-soft ring-ember`:`bg-paper ring-border-soft hover:bg-card`),children:[(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block truncate font-medium text-[14px]`,children:w&&xt(w,e.cells[w.id],z)||`—`}),(0,Y.jsx)(`span`,{className:`block truncate text-[12px] text-ink-3 tabular-nums`,children:T.slice(0,2).map(t=>xt(t,e.cells[t.id],z)).filter(Boolean).join(` · `)})]}),s?(0,Y.jsx)(`span`,{className:H(`shrink-0 rounded-full px-2 py-0.5 font-medium text-[11px]`,M(e)),children:c.find(t=>t.id===u(e))?.label??u(e)}):null]})},e.id))})]}),y?(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[c.length>1?(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[c.slice(1).map((e,t)=>(0,Y.jsxs)(G,{size:`md`,variant:u(y)===e.id?`primary`:`secondary`,onClick:()=>void O(e.id),children:[u(y)===e.id?(0,Y.jsx)(N,{className:`size-4`}):null,e.label,(0,Y.jsx)(`kbd`,{className:`ml-1 hidden rounded bg-black/10 px-1.5 text-[11px] lg:inline`,children:t+1})]},e.id)),u(y)===l?null:(0,Y.jsx)(G,{size:`md`,variant:`ghost`,onClick:()=>void O(l??``),children:K(`check.reopen`)})]}):null,(0,Y.jsx)(`div`,{className:`overflow-hidden rounded-lg bg-paper-2 ring-1 ring-border-soft`,children:A?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 border-border-soft border-b bg-card px-3 py-2 text-[13px]`,children:[(0,Y.jsx)(L,{className:`size-3.5 shrink-0 text-ink-3`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:A.split(`/`).pop()}),(0,Y.jsx)(`a`,{href:nn(e,A,j===`pdf`),target:`_blank`,rel:`noreferrer`,className:`shrink-0 text-ink-2 underline-offset-2 hover:text-ink hover:underline`,children:K(`run.openFull`)})]}),j===`pdf`?(0,Y.jsx)(`iframe`,{title:A,src:`${nn(e,A,!0)}#toolbar=0&navpanes=0&view=FitH`,className:`h-[46vh] w-full border-0 bg-white lg:h-[calc(100vh-27rem)] lg:min-h-[360px]`},A):[`png`,`jpg`,`jpeg`,`webp`].includes(j)?(0,Y.jsx)(`div`,{className:`flex max-h-[46vh] justify-center overflow-auto bg-white lg:max-h-[calc(100vh-27rem)]`,children:(0,Y.jsx)(`img`,{src:nn(e,A,!0),alt:A,className:`max-w-full object-contain`},A)}):(0,Y.jsx)(`p`,{className:`px-4 py-10 text-center text-[14px] text-ink-3`,children:K(`check.noPreview`)})]}):(0,Y.jsx)(`p`,{className:`px-4 py-14 text-center text-[14px] text-ink-3`,children:K(`check.noFile`)})}),(0,Y.jsx)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-2 sm:grid-cols-3`,children:S.map(e=>(0,Y.jsxs)(`div`,{className:H(`min-w-0`,e.type===`text`&&e.format?.style===`multiline`&&`col-span-full`),children:[(0,Y.jsx)(`div`,{className:`px-1 pb-0.5 text-[11px] text-ink-3`,children:e.name}),(0,Y.jsx)($,{boxed:!0,column:e,value:y.cells[e.id],onCommit:t=>void E(y.id,{[e.id]:t})})]},e.id))}),g?(0,Y.jsx)(`p`,{className:`text-[13px] text-rose`,children:g}):null]}):null]})}var on={xlsx:`Excel`,csv:`CSV`,json:`JSON`,md:`Markdown`,zip:`ZIP`};function sn({runId:e,list:t}){return(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t.formats.map(n=>(0,Y.jsx)(`a`,{href:r(`/api/runs/${e}/lists/${t.def.id}/download?format=${n}`),className:`inline-flex h-9 items-center rounded-full bg-paper-2 px-3.5 font-medium text-[13px] text-ink-2 transition hover:bg-paper-3 hover:text-ink coarse:h-11 coarse:px-4`,children:on[n]??n},n))})}function cn(e){return e>1e6?`${(e/1e6).toFixed(1)} MB`:`${Math.max(1,Math.round(e/1e3))} KB`}function ln({runId:e}){let[t,n]=(0,J.useState)(!1),[i,o]=(0,J.useState)(null),[s,c]=(0,J.useState)(!1);(0,J.useEffect)(()=>{t&&(c(!1),a.get(`/api/runs/${e}/store`).then(o))},[t,e]);let l=i&&!i.files.length&&!i.connections.length&&!i.keepsSignIns&&i.lists.every(e=>!e.rows);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>n(!0),className:`inline-flex items-center gap-1.5 text-[13px] text-ink-4 transition hover:text-ink-2 coarse:min-h-11`,children:[(0,Y.jsx)(we,{className:`size-3.5`}),` `,K(`store.open`)]}),(0,Y.jsx)(se,{open:t,onClose:()=>n(!1),title:K(`store.title`),wide:!0,children:i?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-5 text-[14px]`,children:[(0,Y.jsx)(`p`,{className:`text-ink-3`,children:K(`store.explain`)}),l?(0,Y.jsx)(`p`,{className:`text-ink-2`,children:K(`store.empty`)}):null,i.lists.some(e=>e.rows)?(0,Y.jsx)(`ul`,{className:`flex flex-col gap-1`,children:i.lists.filter(e=>e.rows).map(e=>(0,Y.jsxs)(`li`,{className:`flex justify-between gap-3`,children:[(0,Y.jsx)(`span`,{children:e.title}),(0,Y.jsx)(`span`,{className:`text-ink-3 tabular-nums`,children:K(`store.rows`,{n:e.rows})})]},e.id))}):null,i.connections.map(e=>(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(h,{className:`size-4 text-ink-3`}),` `,e.account?.label]},e.id)),i.keepsSignIns?(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(N,{className:`size-4 text-ink-3`}),` `,K(`store.signIns`)]}):null,i.files.length?(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`mb-1 text-ink-3`,children:K(`store.files`,{n:i.files.length,size:cn(i.files.reduce((e,t)=>e+t.size,0))})}),(0,Y.jsx)(`ul`,{className:`max-h-56 overflow-y-auto rounded-lg ring-1 ring-border-soft`,children:i.files.map(t=>(0,Y.jsx)(`li`,{className:`border-border-soft border-b last:border-0`,children:(0,Y.jsxs)(`a`,{href:r(`/api/runs/${e}/store/files/${t.path}`),className:`flex items-center gap-2 px-3 py-2 text-[13px] hover:bg-paper-2 coarse:min-h-11`,title:t.source??void 0,children:[(0,Y.jsx)(L,{className:`size-3.5 shrink-0 text-ink-3`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t.path}),(0,Y.jsx)(`span`,{className:`text-ink-4 tabular-nums`,children:cn(t.size)})]})},t.path))})]}):null,(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 pt-1`,children:[l?(0,Y.jsx)(`span`,{}):s?(0,Y.jsxs)(G,{variant:`secondary`,onClick:async()=>{await a.del(`/api/runs/${e}/store`),o(await a.get(`/api/runs/${e}/store`)),c(!1)},children:[(0,Y.jsx)(M,{className:`size-4`}),` `,K(`store.confirmDelete`)]}):(0,Y.jsxs)(G,{variant:`ghost`,onClick:()=>c(!0),children:[(0,Y.jsx)(M,{className:`size-4`}),` `,K(`store.delete`)]}),(0,Y.jsx)(G,{onClick:()=>n(!1),children:K(`common.close`)})]})]}):(0,Y.jsx)(`div`,{className:`flex justify-center py-8 text-ink-4`,children:(0,Y.jsx)(V,{})})})]})}var un=300;function dn(){if(typeof MediaRecorder<`u`)return[`audio/webm;codecs=opus`,`audio/mp4`,`audio/webm`,`audio/ogg;codecs=opus`].find(e=>MediaRecorder.isTypeSupported(e))}function fn(e){return`${Math.floor(e/60)}:${String(Math.floor(e%60)).padStart(2,`0`)}`}function pn({value:e,runId:t,onChange:n,onBusy:r}){let i=ae(e)?e:null,[o,s]=(0,J.useState)(null),[c,l]=(0,J.useState)(0),[u,d]=(0,J.useState)(!1),[f,p]=(0,J.useState)(null),[m,h]=(0,J.useState)(!1),[v,y]=(0,J.useState)(null),b=(0,J.useRef)(null),x=(0,J.useRef)(null),S=dn(),C=g&&!!S;(0,J.useEffect)(()=>()=>{b.current&&(b.current.recorder.onstop=null,b.current.stop())},[]),(0,J.useEffect)(()=>()=>{v&&URL.revokeObjectURL(v.url)},[v]);let w=async(e,i)=>{d(!0),r?.(!0),p(null);try{let r=await a.upload(`/api/runs/${t}/uploads`,e);y({asset:r.id,url:URL.createObjectURL(e)}),n({asset:r.id,...i===void 0?{}:{seconds:i}})}catch(e){p(e.message)}finally{d(!1),r?.(!1)}},T=async()=>{p(null),h(!1);let e;try{e=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0}})}catch{h(!0);return}let t=[],n=new MediaRecorder(e,{mimeType:S,audioBitsPerSecond:48e3}),i=Date.now(),a=new AudioContext,o=a.createAnalyser();o.fftSize=256,a.createMediaStreamSource(e).connect(o);let c=new Uint8Array(o.fftSize),u=0,d=()=>{o.getByteTimeDomainData(c);let e=0;for(let t of c)e=Math.max(e,Math.abs(t-128));if(l(Math.min(1,e/64)),s((Date.now()-i)/1e3),(Date.now()-i)/1e3>=un){f();return}u=requestAnimationFrame(d)},f=()=>{cancelAnimationFrame(u),n.state!==`inactive`&&n.stop();for(let t of e.getTracks())t.stop();a.close().catch(()=>void 0),b.current=null,s(null),l(0)};n.ondataavailable=e=>e.data.size&&t.push(e.data),n.onstop=()=>{let e=(n.mimeType||S||`audio/webm`).split(`;`)[0],r=e===`audio/mp4`?`m4a`:e===`audio/ogg`?`ogg`:`webm`,a=Math.max(1,Math.round((Date.now()-i)/1e3));w(new File(t,`sprachnotiz-${wt()}.${r}`,{type:e}),a)},b.current={recorder:n,stop:f},r?.(!0),n.start(1e3),u=requestAnimationFrame(d)},E=o!==null,D=(0,Y.jsxs)(G,{variant:`secondary`,onClick:()=>x.current?.click(),children:[(0,Y.jsx)(Oe,{className:`size-4`}),` `,K(`voice.pick`)]});return(0,Y.jsxs)(`div`,{children:[E?(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl bg-card p-3 ring-1 ring-ember`,children:[(0,Y.jsxs)(`span`,{className:`relative flex size-11 shrink-0 items-center justify-center`,children:[(0,Y.jsx)(`span`,{className:`absolute inset-0 rounded-full bg-rose-tint transition-transform duration-75`,style:{transform:`scale(${.7+c*.5})`}}),(0,Y.jsx)(`span`,{className:`relative size-3.5 animate-pulse-dot rounded-full bg-rose`})]}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`div`,{className:`font-medium text-[15px] tabular-nums`,children:fn(o)}),(0,Y.jsx)(`div`,{className:`text-[13px] text-ink-3`,children:o>270?K(`voice.left`,{s:Math.ceil(un-o)}):K(`voice.recording`)})]}),(0,Y.jsxs)(G,{onClick:()=>b.current?.stop(),children:[(0,Y.jsx)(_,{className:`size-3.5 fill-current`}),` `,K(`voice.stop`)]})]}):u?(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl bg-card p-4 text-[14px] text-ink-3 ring-1 ring-input`,children:[(0,Y.jsx)(V,{className:`size-4`}),` `,K(`run.uploading`)]}):i?(0,Y.jsxs)(`div`,{className:`rounded-xl bg-card p-3 ring-1 ring-input`,children:[(0,Y.jsx)(`audio`,{controls:!0,preload:`metadata`,src:v?.asset===i.asset?v.url:`/api/runs/${t}/assets/${i.asset}`,className:`h-11 w-full`}),i.transcript?(0,Y.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap px-1 text-[14px] text-ink-2 leading-relaxed`,children:i.transcript}):null,(0,Y.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center justify-between gap-2`,children:[(0,Y.jsx)(`span`,{className:`px-1 text-[13px] text-ink-3`,children:i.seconds?fn(i.seconds):null}),(0,Y.jsxs)(`div`,{className:`flex gap-1`,children:[C?(0,Y.jsxs)(G,{variant:`ghost`,size:`sm`,onClick:()=>void T(),children:[(0,Y.jsx)(Je,{className:`size-3.5`}),` `,K(`voice.again`)]}):null,(0,Y.jsx)(G,{variant:`ghost`,size:`sm`,onClick:()=>n(void 0),children:K(`voice.remove`)})]})]})]}):(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[C?(0,Y.jsxs)(G,{variant:`secondary`,size:`lg`,onClick:()=>void T(),className:`w-full sm:w-auto`,children:[(0,Y.jsx)(ee,{className:`size-4`}),` `,K(`voice.start`)]}):D,C&&m?D:null]}),m?(0,Y.jsx)(`p`,{className:`mt-2 rounded-lg bg-amber-tint px-3 py-2 text-[13px] text-ink-2 leading-relaxed`,children:K(`voice.denied`)}):(0,Y.jsx)(`p`,{className:`mt-2 text-[13px] text-ink-3 leading-relaxed`,children:K(C?`voice.why`:`voice.noRecorder`)})]}),(0,Y.jsx)(`input`,{ref:x,type:`file`,hidden:!0,accept:`audio/*`,capture:!0,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&w(t,void 0)}}),f?(0,Y.jsx)(`div`,{className:`mt-2 text-[13px] text-rose`,children:f}):null]})}function mn(e,t){try{return new Intl.NumberFormat(void 0,{style:`currency`,currency:t}).format(e)}catch{return`${e.toFixed(2)} ${t}`}}function hn({field:e,value:t,values:n,onChange:r}){let i=e.columns??[],a=Array.isArray(t)&&t.length?t:[{}],o=ie(e,a,n),s=(e,t,n)=>{r(a.map((r,i)=>i===e?{...r,[t]:n}:r))},c=i.map(e=>e.kind===`text`&&e===i[0]?`minmax(0,3fr)`:`minmax(0,1fr)`).join(` `);return(0,Y.jsxs)(`div`,{className:`rounded-xl bg-card p-2 ring-1 ring-input`,children:[(0,Y.jsx)(`div`,{className:`hidden gap-2 px-2 pt-1 pb-2 text-[12px] text-ink-3 sm:grid`,style:{gridTemplateColumns:`${c} 36px`},children:i.map(e=>(0,Y.jsx)(`div`,{className:e.kind===`text`?``:`text-right`,children:e.label},e.id))}),(0,Y.jsx)(`div`,{className:`flex flex-col gap-2`,children:a.map((e,t)=>(0,Y.jsxs)(`div`,{className:`grid grid-cols-6 gap-2 rounded-lg bg-paper p-2 sm:bg-transparent sm:p-0 sm:[grid-template-columns:var(--cols)]`,style:{"--cols":`${c} 36px`},children:[i.map((n,r)=>(0,Y.jsxs)(`label`,{className:H(`flex min-w-0 flex-col gap-1 sm:col-span-1`,r===0?`col-span-5`:i.length-1<=2?`col-span-3`:`col-span-2`),children:[(0,Y.jsx)(`span`,{className:`px-0.5 text-[11px] text-ink-3 sm:hidden`,children:n.label}),(0,Y.jsx)(`input`,{"aria-label":n.label,placeholder:n.label,inputMode:n.kind===`text`?`text`:`decimal`,autoComplete:`off`,value:String(e[n.id]??``),onChange:e=>s(t,n.id,e.target.value),className:H(`h-11 w-full min-w-0 rounded-md border border-transparent bg-paper-2 px-2.5 text-[14px] outline-none placeholder:text-transparent focus:border-focus focus:bg-card sm:placeholder:text-ink-4`,n.kind!==`text`&&`text-right tabular-nums`)})]},n.id)),(0,Y.jsx)(U,{label:K(`list.delete`),onClick:()=>r(a.filter((e,n)=>n!==t)),className:`order-first col-start-6 row-start-1 size-11 justify-self-end self-end sm:order-none sm:col-start-auto sm:row-start-auto`,children:(0,Y.jsx)(M,{className:`size-4`})})]},t))}),(0,Y.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-end justify-between gap-3 px-2 pb-1`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>r([...a,{}]),className:`inline-flex h-9 items-center gap-1.5 rounded-full px-3 text-[13px] text-ink-2 hover:bg-accent coarse:h-11`,children:[(0,Y.jsx)(F,{className:`size-4`}),` `,K(`run.addRow`)]}),(0,Y.jsxs)(`div`,{className:`text-right text-[13px] tabular-nums`,children:[(0,Y.jsxs)(`div`,{className:`text-ink-3`,children:[K(`run.net`),` `,mn(o.net,o.currency)]}),o.vatRate?(0,Y.jsxs)(`div`,{className:`text-ink-3`,children:[K(`run.vat`,{r:o.vatRate}),` `,mn(o.vat,o.currency)]}):null,(0,Y.jsxs)(`div`,{className:`font-semibold text-[15px] text-ink`,children:[K(`run.total`),` `,mn(o.gross,o.currency)]})]})]})]})}function gn(e){return!!e?.closest(`input, textarea, [contenteditable='true']`)}function _n({field:e,value:t,runId:n,onChange:i,onBusy:o}){let s=(0,J.useRef)(null),c=(0,J.useRef)(null),l=(0,J.useRef)(null),u=(0,J.useRef)(null),[f,m]=(0,J.useState)(!1),[h,_]=(0,J.useState)({}),[y,b]=(0,J.useState)(null),[x,S]=(0,J.useState)(!1),[C,w]=(0,J.useState)(!1),[T,E]=(0,J.useState)(null),D=(0,J.useRef)(null),O=e=>{D.current=e,E(e)},k=e.kind===`image`,A=!!e.multiple,j=A?e.max??30:1,M=k||!!e.camera||!!e.video,N=!k&&!!e.video,P=Array.isArray(t)?t:typeof t==`string`&&t?[t]:[],F=(0,J.useRef)(P);F.current=P;let I=P.length<j,L=async e=>{let t=(k?e.filter(e=>e.type.startsWith(`image/`)):e).sort((e,t)=>e.name.localeCompare(t.name,void 0,{numeric:!0}));if(!t.length)return;let r=j-(A?F.current.length:0);m(!0),o?.(!0),b(t.length>r&&A?K(`run.maxFiles`,{n:j}):null);try{for(let e of t.slice(0,Math.max(0,r))){let t=await Ct(e),r=await a.upload(`/api/runs/${n}/uploads`,t);_(e=>({...e,[r.id]:{name:r.name,mime:r.mime}}));let o=A?[...F.current,r.id]:r.id;F.current=A?o:[r.id],i(o)}}catch(e){b(e.message)}finally{m(!1),o?.(!1)}},ee=(0,J.useRef)(L);ee.current=L;let te=e=>{let t=P.filter(t=>t!==e);i(A?t:void 0)},re=(e,t)=>{let n=F.current.indexOf(e),r=Math.min(F.current.length-1,Math.max(0,t));if(n<0||n===r)return;let a=F.current.filter(t=>t!==e);a.splice(r,0,e),F.current=a,i(a)},ie=A&&P.length>1;(0,J.useEffect)(()=>{if(!I)return;let e=e=>{let t=Array.from(e.clipboardData?.files??[]),n=s.current;if(!t.length||!n||gn(document.activeElement))return;let r=document.querySelectorAll(`[data-upload-field]`);(n.matches(`:hover`)||n.contains(document.activeElement)||r.length===1)&&(e.preventDefault(),ee.current(t))};return document.addEventListener(`paste`,e),()=>document.removeEventListener(`paste`,e)},[I]);let R=H(`flex flex-col items-center justify-center gap-2 rounded-xl border border-input border-dashed bg-card px-3 text-[14px] text-ink-3 transition hover:border-ember hover:text-ink`,P.length?`py-4`:`py-8`);return(0,Y.jsxs)(`div`,{ref:s,"data-upload-field":``,onDragOver:e=>{I&&(e.preventDefault(),w(!0))},onDragLeave:()=>w(!1),onDrop:e=>{w(!1),I&&(e.preventDefault(),L(Array.from(e.dataTransfer.files)))},children:[P.length?(0,Y.jsx)(`div`,{className:`mb-2 flex flex-col gap-2`,children:P.map((e,t)=>{let i=h[e],a=i?.mime??(k?`image/`:``);return(0,Y.jsxs)(`div`,{"data-file-id":e,className:H(`flex items-center gap-3 rounded-xl bg-card p-2 ring-1 ring-input transition-shadow`,T===e&&`relative z-10 shadow-elevated ring-2 ring-ember`),children:[ie?(0,Y.jsxs)(`button`,{type:`button`,"aria-label":K(`run.moveFile`,{n:t+1}),title:K(`run.moveFileHint`),className:H(`-mr-1 flex h-14 w-9 shrink-0 touch-none flex-col items-center justify-center gap-0.5 rounded-lg text-ink-3 hover:bg-paper-2 hover:text-ink`,T===e?`cursor-grabbing`:`cursor-grab`),onPointerDown:t=>{try{t.currentTarget.setPointerCapture(t.pointerId)}catch{}O(e)},onPointerMove:t=>{if(D.current!==e)return;let n=document.elementFromPoint(t.clientX,t.clientY)?.closest(`[data-file-id]`),r=n?.getAttribute(`data-file-id`);r&&r!==e&&s.current?.contains(n??null)&&re(e,F.current.indexOf(r))},onPointerUp:()=>O(null),onPointerCancel:()=>O(null),onKeyDown:n=>{(n.key===`ArrowUp`||n.key===`ArrowDown`)&&(n.preventDefault(),re(e,t+(n.key===`ArrowUp`?-1:1)))},children:[(0,Y.jsx)(`span`,{className:`font-medium text-[12px] tabular-nums`,children:t+1}),(0,Y.jsx)(Pe,{className:`size-4`})]}):null,a.startsWith(`image/`)?(0,Y.jsx)(`img`,{src:r(`/api/runs/${n}/assets/${e}`),alt:``,className:`size-14 rounded-lg object-cover`}):(0,Y.jsx)(`div`,{className:`flex size-12 shrink-0 items-center justify-center rounded-lg bg-paper-2`,children:a.startsWith(`video/`)?(0,Y.jsx)(p,{className:`size-5 text-ink-3`}):(0,Y.jsx)(d,{className:`size-5 text-ink-3`})}),(0,Y.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-[14px]`,children:i?.name??`✓`}),(0,Y.jsx)(U,{label:K(`run.removeFile`),onClick:()=>te(e),children:(0,Y.jsx)(q,{className:`size-4`})})]},e)})}):null,I?(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>c.current?.click(),className:H(R,`min-w-[9rem] flex-1 px-4`,C&&`border-ember text-ink`),children:[k?(0,Y.jsx)(Ie,{className:`size-6`}):(0,Y.jsx)(d,{className:`size-6`}),f?K(`run.uploading`):P.length?K(`run.uploadMore`):K(v?`run.uploadTouch`:`run.upload`)]}),M?(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>g?S(!0):l.current?.click(),className:H(R,`w-28`),children:[(0,Y.jsx)(be,{className:`size-6`}),K(`run.camera`)]}):null,N&&!(g&&Pt)?(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>u.current?.click(),className:H(R,`w-28`),children:[(0,Y.jsx)(ne,{className:`size-6`}),K(`camera.video`)]}):null]}):null,(0,Y.jsx)(`input`,{ref:c,type:`file`,hidden:!0,multiple:A,accept:k?`image/*`:void 0,onChange:e=>{L(Array.from(e.target.files??[])),e.target.value=``}}),(0,Y.jsx)(`input`,{ref:l,type:`file`,hidden:!0,accept:`image/*`,capture:`environment`,onChange:e=>{L(Array.from(e.target.files??[])),e.target.value=``}}),N?(0,Y.jsx)(`input`,{ref:u,type:`file`,hidden:!0,accept:`video/*`,capture:`environment`,onChange:e=>{L(Array.from(e.target.files??[])),e.target.value=``}}):null,(0,Y.jsx)(Ft,{open:x,multiple:A,video:N,onClose:()=>S(!1),onCapture:e=>L([e]),onNative:()=>l.current?.click()}),A&&(e.min||e.max)?(0,Y.jsx)(`div`,{className:`mt-2 text-[13px] text-ink-3 tabular-nums`,children:e.min&&P.length<e.min?K(`run.filesMin`,{n:P.length,min:e.min}):e.max?K(`run.filesOf`,{n:P.length,max:e.max}):null}):null,y?(0,Y.jsx)(`div`,{className:`mt-2 text-[13px] text-rose`,children:y}):null]})}function vn(e){let t=`${e.id} ${e.label}`.toLowerCase();return/telefon|phone|handy|mobil(?!it)|\btel\b|rückruf/.test(t)?{type:`tel`,inputMode:`tel`,autoComplete:`tel`}:/\bplz\b|postleitzahl|postal|zip/.test(t)?{inputMode:`numeric`,autoComplete:`postal-code`}:/iban/.test(t)?{autoCapitalize:`characters`,autoCorrect:`off`,spellCheck:!1}:/vorname|first.?name/.test(t)?{autoComplete:`given-name`,autoCapitalize:`words`}:/nachname|last.?name|surname/.test(t)?{autoComplete:`family-name`,autoCapitalize:`words`}:/firma|unternehmen|company|organi[sz]ation/.test(t)?{autoComplete:`organization`,autoCapitalize:`words`}:/straße|strasse|street|anschrift|adresse|address/.test(t)?{autoComplete:`street-address`,autoCapitalize:`words`}:/\b(ort|stadt|city|town)\b/.test(t)?{autoComplete:`address-level2`,autoCapitalize:`words`}:/\bname\b|ansprechp/.test(t)?{autoComplete:`name`,autoCapitalize:`words`}:{autoCapitalize:`sentences`}}function yn({field:e,value:t,onChange:n}){let[r,i]=(0,J.useState)(!1);return(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(W,{value:t,placeholder:e.placeholder,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,onChange:e=>n(e.target.value)}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>i(!0),className:`inline-flex h-11 shrink-0 items-center gap-2 rounded-lg border border-input bg-card px-3.5 font-medium text-[14px] text-ink-2 transition hover:border-ember hover:text-ink`,children:[(0,Y.jsx)(Xe,{className:`size-4`}),` `,K(`scan.button`)]}),(0,Y.jsx)(Ut,{open:r,onClose:()=>i(!1),onResult:n})]})}function bn({field:e,value:t,values:n,runId:r,view:i,onChange:a,onBusy:o,error:s}){let c=t==null?``:String(t),l;switch(e.kind){case`textarea`:l=(0,Y.jsx)(le,{value:c,placeholder:e.placeholder,autoCapitalize:`sentences`,enterKeyHint:`enter`,onChange:e=>a(e.target.value)});break;case`number`:l=(0,Y.jsx)(W,{inputMode:`decimal`,autoComplete:`off`,value:c,placeholder:e.placeholder,onChange:e=>a(e.target.value)});break;case`select`:{let t=e.options??[];l=t.length<=5&&t.every(e=>e.length<=28)?(0,Y.jsx)(ce,{value:c,options:t,onChange:a}):(0,Y.jsx)(fe,{value:c,placeholder:`—`,onChange:a,options:t.map(e=>({value:e,label:e}))});break}case`multiselect`:l=(0,Y.jsx)(ce,{multi:!0,value:Array.isArray(t)?t:[],options:e.options??[],onChange:a});break;case`date`:l=(0,Y.jsx)(W,{type:`date`,value:c,onChange:e=>a(e.target.value),className:`w-full sm:w-56`});break;case`email`:l=(0,Y.jsx)(W,{type:`email`,inputMode:`email`,autoComplete:`email`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,value:c,placeholder:e.placeholder,onChange:e=>a(e.target.value)});break;case`url`:l=(0,Y.jsx)(W,{type:`url`,inputMode:`url`,autoComplete:`url`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,value:c,placeholder:e.placeholder??`https://`,onChange:e=>a(e.target.value)});break;case`toggle`:l=(0,Y.jsx)(de,{checked:t===!0,onChange:a,label:e.label});break;case`color`:l=(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(oe,{value:c||`#e0531b`,onChange:e=>a(e.target.value)}),(0,Y.jsx)(W,{value:c,placeholder:`#e0531b`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,onChange:e=>a(e.target.value),className:`w-36`})]});break;case`image`:case`file`:l=(0,Y.jsx)(_n,{field:e,value:t,runId:r,onChange:a,onBusy:o});break;case`items`:l=(0,Y.jsx)(hn,{field:e,value:t,values:n,onChange:a});break;case`connection`:l=(0,Y.jsx)(Qt,{runId:r,connection:i?.connections.find(t=>t.id===e.connection)});break;case`list`:{let t=i?.lists.find(t=>t.def.id===e.list);l=t?(0,Y.jsx)(tn,{runId:r,list:t,editable:!0}):null;break}case`location`:l=(0,Y.jsx)(zt,{value:t,runId:r,placeholder:e.placeholder,onChange:a,onBusy:o});break;case`audio`:l=(0,Y.jsx)(pn,{value:t,runId:r,onChange:a,onBusy:o});break;case`signature`:l=(0,Y.jsx)(Xt,{label:e.label,value:t,runId:r,onChange:a});break;default:l=e.scan?(0,Y.jsx)(yn,{field:e,value:c,onChange:a}):(0,Y.jsx)(W,{...vn(e),value:c,placeholder:e.placeholder,onChange:e=>a(e.target.value)})}return(0,Y.jsxs)(`div`,{children:[e.kind===`toggle`?(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-6`,children:[(0,Y.jsx)(B,{hint:e.help,children:e.label}),l]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(B,{hint:e.help,required:e.required,children:e.label}),l]}),s?(0,Y.jsx)(`div`,{className:`mt-1.5 text-[13px] text-rose`,children:s}):null]})}var xn=45e3;function Sn(e){let[t,n]=(0,J.useState)(null),[i,s]=(0,J.useState)(null),[c,l]=(0,J.useState)(!1),[u,d]=(0,J.useState)(!1),[f,p]=(0,J.useState)({});(0,J.useEffect)(()=>{if(n(null),l(!1),!e)return;let t=!1,i=0,s,c=null,u=Date.now(),d=()=>{t=!0,c?.close(),l(!0)},f=async()=>{try{let r=await a.get(`/api/runs/${e}`);t||n(r)}catch(e){e instanceof o&&e.status===404&&d()}},p=()=>{if(clearTimeout(s),c?.close(),t)return;let a=new EventSource(r(`/api/runs/${e}/stream`),{withCredentials:!0});c=a,u=Date.now(),a.addEventListener(`view`,e=>{i=0,u=Date.now(),n(JSON.parse(e.data))}),a.addEventListener(`ping`,()=>{u=Date.now()}),a.onerror=()=>{a.close(),!(t||c!==a)&&(c=null,f(),i=Math.min(i+1,6),s=setTimeout(p,500*2**i))}},m=()=>{t||document.visibilityState!==`visible`||(!c||c.readyState===EventSource.CLOSED||Date.now()-u>xn?(i=0,p()):f())},h=setInterval(()=>{!t&&c&&Date.now()-u>xn&&(i=0,p())},15e3);return p(),document.addEventListener(`visibilitychange`,m),window.addEventListener(`pageshow`,m),window.addEventListener(`online`,m),()=>{t=!0,clearTimeout(s),clearInterval(h),document.removeEventListener(`visibilitychange`,m),window.removeEventListener(`pageshow`,m),window.removeEventListener(`online`,m),c?.close()}},[e]);let m=(0,J.useCallback)(async(t,n)=>{if(!e)return!1;d(!0),s(null),p({});try{return await a.post(`/api/runs/${e}/${t}`,n),!0}catch(e){return e instanceof o&&e.status===422&&Array.isArray(e.body?.fields)&&p(Object.fromEntries(e.body.fields.map(e=>[e.field,e.message]))),s(e.message),!1}finally{d(!1)}},[e]);return{view:t,notFound:c,error:i,busy:u,fieldErrors:f,submitPage:(e,t)=>m(`pages/${e}`,{values:t}),accept:(e,t)=>m(`reviews/${e}`,{type:`accept`,edits:t}),regenerate:(e,t,n,r)=>m(`reviews/${e}`,{type:`regenerate`,target:t,note:n,items:r?.length?r:void 0}),back:()=>m(`back`),retry:()=>m(`retry`)}}function Cn({view:e}){let t=Math.round(Math.min(e.progress.done,e.progress.total)/Math.max(1,e.progress.total)*100);return(0,Y.jsx)(`div`,{className:`h-[3px] w-full bg-paper-2`,children:(0,Y.jsx)(`div`,{className:`h-full bg-ember transition-[width] duration-700 ease-out`,style:{width:`${t}%`}})})}function wn({title:e,description:t,kicker:n}){return(0,Y.jsxs)(`div`,{className:`mb-8`,children:[n?(0,Y.jsx)(`p`,{className:`mb-4 text-[15px] text-ink-2 leading-relaxed`,children:n}):null,(0,Y.jsx)(`h1`,{className:`font-display font-semibold text-[28px] leading-[1.15] tracking-tight sm:text-[32px]`,children:e}),t?(0,Y.jsx)(`p`,{className:`mt-2 text-[15px] text-ink-3 leading-relaxed`,children:t}):null]})}function Tn(e,t){let n={};for(let r of e.fields)n[r.id]=t.values[r.id]??t.prefill?.[r.id]??r.default??(r.kind===`multiselect`?[]:void 0);return n}function En(e){return Array.from(e.querySelectorAll(`input:not([type="hidden"], [type="file"], [type="checkbox"], [type="color"], [type="range"], [disabled]), textarea:not([disabled])`)).filter(e=>!e.closest(`dialog`)&&e.offsetParent!==null)}function Dn({view:e,run:t,step:n}){let[r,i]=(0,J.useState)(()=>Tn(n,e)),[a,o]=(0,J.useState)(new Set),s=(0,J.useRef)(null),c=e.progress.done===0,l=()=>void t.submitPage(n.id,r);return(0,J.useEffect)(()=>{if(!s.current)return;let e=En(s.current).filter(e=>e instanceof HTMLInputElement);for(let[t,n]of e.entries())(n.dataset.hint||!n.hasAttribute(`enterkeyhint`))&&(n.dataset.hint=`1`,n.setAttribute(`enterkeyhint`,t===e.length-1?`go`:`next`))}),(0,Y.jsxs)(`form`,{ref:s,className:`animate-rise`,onSubmit:e=>{e.preventDefault(),a.size||l()},onKeyDown:e=>{let t=e.target;if(e.key!==`Enter`||e.defaultPrevented||e.nativeEvent.isComposing||!(t instanceof HTMLInputElement)||t.closest(`dialog`))return;let n=En(e.currentTarget),r=n[n.indexOf(t)+1];r&&(e.preventDefault(),r.focus())},children:[(0,Y.jsx)(wn,{title:n.title,description:n.description,kicker:c?e.wizard.intro:null}),(0,Y.jsx)(`div`,{className:`flex flex-col gap-7`,children:n.fields.map(n=>(0,Y.jsx)(bn,{field:n,value:r[n.id],values:r,runId:e.id,view:e,error:t.fieldErrors[n.id],onChange:e=>i(t=>({...t,[n.id]:e})),onBusy:e=>o(t=>{if(t.has(n.id)===e)return t;let r=new Set(t);return e?r.add(n.id):r.delete(n.id),r})},n.id))}),(0,Y.jsx)(On,{view:e,run:t,sticky:!0,children:(0,Y.jsxs)(G,{type:`submit`,size:`lg`,busy:t.busy,disabled:a.size>0,children:[n.cta||K(`run.next`),` `,(0,Y.jsx)(u,{className:`size-4`})]})})]})}function On({view:e,run:t,sticky:n,children:r}){return(0,Y.jsxs)(`div`,{className:H(`mt-10 flex items-center justify-between gap-3`,n&&`action-bar`),children:[e.canBack?(0,Y.jsxs)(G,{variant:`ghost`,onClick:()=>void t.back(),disabled:t.busy,children:[(0,Y.jsx)(l,{className:`size-4`}),` `,K(`run.back`)]}):(0,Y.jsx)(`span`,{}),r]})}function kn(){let e=b(),[t,n]=(0,J.useState)(!1),r=e!==`off`;return(0,Y.jsxs)(`div`,{className:`mt-6 flex flex-col items-center gap-2`,children:[(0,Y.jsxs)(`button`,{type:`button`,"aria-pressed":r,disabled:t,onClick:async()=>{if(r){T();return}n(!0),await D(),n(!1)},className:H(`inline-flex h-11 items-center gap-2 rounded-full px-4 font-medium text-[14px] ring-1 transition`,r?`bg-ember-tint text-ink ring-ember`:`bg-card text-ink-2 ring-input hover:text-ink hover:ring-ink-4`),children:[r?(0,Y.jsx)(ge,{className:`size-4 text-ember-strong`}):(0,Y.jsx)(ve,{className:`size-4`}),K(r?`notify.on`:`notify.ask`)]}),(0,Y.jsx)(`p`,{className:`max-w-xs text-[12px] text-ink-4 leading-relaxed`,children:K(e===`off`?`notify.why`:e===`on`?`notify.onHint`:w()?`notify.blocked`:`notify.quiet`)})]})}function An({view:e,compact:t,awake:n}){let a=(0,J.useMemo)(()=>{let t=[...e.events].reverse().find(t=>t.type===`step_started`&&t.stepId===e.step?.id);return t?new Date(t.at).getTime():Date.now()},[e.events,e.step?.id]),[o,s]=(0,J.useState)(Date.now());(0,J.useEffect)(()=>{let e=setInterval(()=>s(Date.now()),1e3);return()=>clearInterval(e)},[]);let c=[...e.events].reverse().find(t=>t.type===`step_started`&&t.stepId===e.step?.id)?.message??e.step?.title??K(`run.working`),l=e.events.filter(e=>(e.type===`tool`||e.type===`info`)&&new Date(e.at).getTime()>=a-500),u=l.slice(-4),d=[...new Set(l.map(e=>e.asset).filter(e=>!!e))],f=[...l].reverse().find(e=>e.asset)?.asset;return(0,Y.jsxs)(`div`,{className:`flex animate-rise flex-col items-center pt-6 text-center`,children:[(0,Y.jsx)(i,{kind:e.wizard.avatar,size:t?130:170,fluffy:!0}),(0,Y.jsx)(`h2`,{className:`mt-4 font-display font-semibold text-[22px] tracking-tight`,children:c}),(0,Y.jsx)(`div`,{className:`mt-1 text-[13px] text-ink-4 tabular-nums`,children:K(`run.elapsed`,{s:Math.max(0,Math.round((o-a)/1e3))})}),d.length?(0,Y.jsx)(`div`,{className:`mt-5 flex max-w-full flex-wrap justify-center gap-2`,children:d.slice(-8).map(t=>(0,Y.jsx)(`img`,{src:r(`/api/runs/${e.id}/assets/${t}`),alt:``,className:H(`size-16 animate-rise rounded-lg bg-paper-2 object-cover ring-1 ring-border-soft transition sm:size-20`,t===f?`ring-2 ring-ember`:`opacity-70`)},t))}):null,(0,Y.jsx)(`div`,{className:`mt-6 flex min-h-[7rem] w-full max-w-sm flex-col gap-1.5`,children:u.map((e,t)=>(0,Y.jsxs)(`div`,{className:H(`flex items-center justify-center gap-2 text-[13px] transition-opacity`,t===u.length-1?`text-ink-2`:`text-ink-4`),children:[t===u.length-1?(0,Y.jsx)(j,{className:`size-3.5 animate-breathe text-ember`}):null,(0,Y.jsx)(`span`,{className:`truncate`,children:e.message})]},e.id))}),t?null:(0,Y.jsx)(kn,{}),n?(0,Y.jsx)(`p`,{className:`mt-3 text-[12px] text-ink-4`,children:K(`run.awake`)}):null]})}function jn(e){let t=(0,J.useRef)({running:!1,since:0,ask:null});(0,J.useEffect)(()=>{if(!e)return;let n=t.current,r=e.status===`running`,i=r?n.running?n.since:Date.now():0,a=t=>{document.visibilityState!==`visible`&&!document.title.startsWith(`● `)&&(document.title=`● ${document.title}`),k({title:e.wizard.title,body:t,tag:e.id})};r&&e.ask&&e.ask.id!==n.ask?a(K(`notify.needsYou`)):!r&&n.running&&Date.now()-n.since>8e3&&a(e.status===`failed`?K(`run.failed`):e.status===`done`?K(`notify.done`):K(`notify.next`)),t.current={running:r,since:i,ask:e.ask?.id??null}},[e]),(0,J.useEffect)(()=>{let e=()=>{document.visibilityState===`visible`&&document.title.startsWith(`● `)&&(document.title=document.title.slice(2))};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[])}function Mn({view:e,run:t,step:n}){let[r,i]=(0,J.useState)({}),[a,o]=(0,J.useState)({}),[s,c]=(0,J.useState)(``),l=e.shown.filter(e=>e.output),[d,f]=(0,J.useState)(l.length===1?l[0].step.id:null),[p,h]=(0,J.useState)({}),g=(0,J.useRef)(null),_=l.find(e=>e.step.id===d),v=_?.step.type===`generate`&&(_.output?.assets?.length??0)>1,y=()=>{_&&s.trim()&&t.regenerate(n.id,_.step.id,s.trim(),p[_.step.id])};return(0,Y.jsxs)(`div`,{className:`animate-rise`,children:[(0,Y.jsx)(wn,{title:n.title,description:n.description}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[e.shown.map(({step:t,output:s})=>{let c=!!n.edit&&t.type===`agent`&&t.output.format!==`json`;return(0,Y.jsxs)(`section`,{children:[(0,Y.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,Y.jsx)(`h3`,{className:`font-medium text-[13px] text-ink-3 uppercase tracking-[0.06em]`,children:t.title}),(0,Y.jsx)(`div`,{className:`flex items-center`,children:c&&!a[t.id]?(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>({...e,[t.id]:!0})),className:`inline-flex h-8 items-center gap-1.5 rounded-full px-3 text-[13px] text-ink-2 hover:bg-accent hover:text-ink coarse:h-11`,children:[(0,Y.jsx)(m,{className:`size-3.5`}),` `,K(`run.edit`)]}):null})]}),(0,Y.jsx)(C,{base:`/api/runs/${e.id}`,step:t,output:s,editable:c&&a[t.id],draft:r[t.id],onDraft:e=>i(n=>({...n,[t.id]:e})),picked:p[t.id],onPick:n.regenerate?e=>{f(t.id),h(n=>{let r=n[t.id]??[];return{...n,[t.id]:r.includes(e)?r.filter(t=>t!==e):[...r,e]}}),g.current?.focus()}:void 0})]},t.id)}),e.lists.map(t=>(0,Y.jsxs)(`section`,{children:[(0,Y.jsx)(`h3`,{className:`mb-2 font-medium text-[13px] text-ink-3 uppercase tracking-[0.06em]`,children:t.def.title}),t.def.check?(0,Y.jsx)(an,{runId:e.id,list:t}):(0,Y.jsx)(tn,{runId:e.id,list:t,editable:!0})]},t.def.id)),n.regenerate&&l.length?(0,Y.jsxs)(ue,{className:`p-3`,children:[l.length>1?(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 px-1 pb-2`,children:[(0,Y.jsx)(`span`,{className:`mr-1 text-[13px] text-ink-3`,children:K(`run.feedbackTarget`)}),l.map(({step:e})=>(0,Y.jsx)(`button`,{type:`button`,"aria-pressed":d===e.id,onClick:()=>{f(e.id),g.current?.focus()},className:H(`inline-flex h-8 items-center rounded-full px-3 text-[13px] ring-1 transition coarse:h-11`,d===e.id?`bg-ember-tint text-ink ring-ember`:`bg-card text-ink-2 ring-input hover:text-ink`),children:e.title},e.id))]}):null,(0,Y.jsx)(le,{ref:g,minRows:2,maxRows:8,value:s,placeholder:K(`run.feedbackPlaceholder`),onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),y())},className:`border-0 bg-transparent shadow-none focus:ring-0`}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-1 pt-1`,children:[(0,Y.jsx)(`span`,{className:`min-w-0 text-[12px] text-ink-3`,children:v?p[_.step.id]?.length?K(`run.regeneratePicked`,{n:[...p[_.step.id]].sort((e,t)=>e-t).map(e=>e+1).join(`, `)}):K(`run.regenerateAll`):!_&&s.trim()?K(`run.feedbackPick`):null}),(0,Y.jsxs)(G,{size:`sm`,variant:`secondary`,busy:t.busy,disabled:!s.trim()||!_,onClick:y,children:[(0,Y.jsx)(R,{className:`size-3.5`}),` `,K(`run.regenerateGo`)]})]})]}):null]}),(0,Y.jsx)(On,{view:e,run:t,sticky:!0,children:(0,Y.jsxs)(G,{size:`lg`,busy:t.busy,onClick:()=>void t.accept(n.id,Object.keys(r).length?r:void 0),children:[K(`run.accept`),` `,(0,Y.jsx)(u,{className:`size-4`})]})})]})}function Nn({view:e,run:t,step:n,onRestart:r}){let a=e.shown.filter(e=>e.output);return(0,Y.jsxs)(`div`,{className:`animate-rise`,children:[(0,Y.jsxs)(`div`,{className:`mb-8 flex flex-wrap items-center gap-x-4 gap-y-5`,children:[(0,Y.jsx)(i,{kind:e.wizard.avatar,size:64}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1 basis-[12rem]`,children:[(0,Y.jsx)(`h1`,{className:`text-balance font-display font-semibold text-[28px] leading-tight tracking-tight sm:text-[32px]`,children:n.title}),n.message?(0,Y.jsx)(`p`,{className:`mt-1 text-[15px] text-ink-3`,children:n.message}):null]}),e.shown.some(e=>e.output)?(0,Y.jsx)(`div`,{className:`max-sm:basis-full`,children:(0,Y.jsx)(lt,{runId:e.id,title:`${n.title} · ${e.wizard.title}`,initial:e.shareUrl?{url:e.shareUrl,expiresAt:e.expiresAt}:null})}):null]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[a.map(({step:t,output:n,formats:r,label:i})=>(0,Y.jsxs)(ue,{className:`p-4 sm:p-5`,children:[(0,Y.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-3`,children:[(0,Y.jsx)(`h3`,{className:`font-display font-semibold text-[17px]`,children:i??t.title}),(0,Y.jsx)(O,{base:`/api/runs/${e.id}`,stepId:t.id,formats:r,title:i??t.title})]}),(0,Y.jsx)(C,{base:`/api/runs/${e.id}`,step:t,output:n}),n?.assets?.some(e=>e.ai)?(0,Y.jsx)(`p`,{className:`mt-3 text-[12px] text-ink-3 leading-relaxed`,children:K(`ai.publish`)}):null]},t.id)),e.lists.map(t=>(0,Y.jsxs)(ue,{className:`p-4 sm:p-5`,children:[(0,Y.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-3`,children:[(0,Y.jsx)(`h3`,{className:`font-display font-semibold text-[17px]`,children:t.label??t.def.title}),(0,Y.jsx)(sn,{runId:e.id,list:t})]}),(0,Y.jsx)(tn,{runId:e.id,list:t,editable:!0})]},t.def.id))]}),(0,Y.jsx)(On,{view:e,run:t,children:r?(0,Y.jsxs)(G,{variant:`secondary`,onClick:r,children:[(0,Y.jsx)(Je,{className:`size-4`}),` `,K(`run.again`)]}):(0,Y.jsx)(`span`,{})})]})}function Pn({view:e,run:t}){return(0,Y.jsxs)(`div`,{className:`flex animate-rise flex-col items-center pt-8 text-center`,children:[(0,Y.jsx)(i,{kind:e.wizard.avatar,size:90}),(0,Y.jsx)(`h2`,{className:`mt-4 font-display font-semibold text-[22px]`,children:K(`run.failed`)}),(0,Y.jsx)(`p`,{className:`mt-2 max-w-md text-[15px] text-ink-3`,children:e.error}),(0,Y.jsxs)(`div`,{className:`mt-8 flex gap-3`,children:[e.canBack?(0,Y.jsxs)(G,{variant:`ghost`,onClick:()=>void t.back(),children:[(0,Y.jsx)(l,{className:`size-4`}),` `,K(`run.back`)]}):null,(0,Y.jsxs)(G,{onClick:()=>void t.retry(),busy:t.busy,children:[(0,Y.jsx)(Je,{className:`size-4`}),` `,K(`run.retry`)]})]})]})}function Fn({runId:e,compact:t,onRestart:n,onView:r,stickyProgress:i}){let a=Sn(e),{view:o}=a;(0,J.useEffect)(()=>{r?.(o)},[o,r]),y();let s=E(o?.status===`running`&&!o.ask);if(jn(o),a.notFound)return(0,Y.jsx)(`div`,{className:`py-24 text-center text-ink-3`,children:K(`run.notFound`)});if(!o)return(0,Y.jsx)(`div`,{className:`flex justify-center py-24 text-ink-4`,children:(0,Y.jsx)(V,{})});let c=o.step,l=null;if(o.status===`running`&&o.ask)l=(0,Y.jsx)(ut,{runId:o.id,ask:o.ask},o.ask.id);else if(o.status===`running`)l=(0,Y.jsx)(An,{view:o,compact:t,awake:s});else if(o.status===`failed`)l=(0,Y.jsx)(Pn,{view:o,run:a});else if(o.status===`cancelled`)l=(0,Y.jsx)(`div`,{className:`py-24 text-center text-ink-3`,children:K(`run.cancelled`)});else if(c?.type===`page`)l=(0,Y.jsx)(Dn,{view:o,run:a,step:c},c.id);else if(c?.type===`review`){let e=o.shown.map(e=>e.output?.at??``).join(`|`);l=(0,Y.jsx)(Mn,{view:o,run:a,step:c},`${c.id}:${e}`)}else c?.type===`result`&&(l=(0,Y.jsx)(Nn,{view:o,run:a,step:c,onRestart:n}));let u=c?.type===`review`&&o.status===`waiting_input`&&o.lists.some(e=>e.def.check);return(0,Y.jsxs)(`div`,{className:`flex min-h-full flex-col`,children:[i?(0,Y.jsx)(`div`,{className:`sticky top-0 z-10`,children:(0,Y.jsx)(Cn,{view:o})}):(0,Y.jsx)(Cn,{view:o}),(0,Y.jsxs)(`div`,{className:H(`safe-x mx-auto w-full flex-1`,u?`max-w-[1240px] py-8`:t?`max-w-[620px] py-8`:`max-w-[640px] py-8 sm:py-16`),children:[l,a.error&&o.status!==`failed`?(0,Y.jsx)(`div`,{className:`mt-4 rounded-lg bg-rose-tint px-4 py-3 text-[14px] text-rose`,children:a.error}):null,o.keeps&&o.status!==`running`?(0,Y.jsx)(`div`,{className:`mt-10 flex justify-center`,children:(0,Y.jsx)(ln,{runId:o.id})}):null]})]})}export{Qe as n,me as r,Fn as t};
|